[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/filters/libmsooxml
From:       Lassi Taneli Nieminen <lassniem () gmail ! com>
Date:       2010-11-30 9:27:35
Message-ID: 20101130092735.315EEAC8A3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1202252 by lassin:

Fixed Vml part of the filter to support lines somehow.


 M  +82 -18    MsooXmlVmlReaderImpl.h  
 M  +1 -1      MsooXmlVmlReaderMethods.h  


--- trunk/koffice/filters/libmsooxml/MsooXmlVmlReaderImpl.h #1202251:1202252
@@ -55,6 +55,10 @@
     if (startType == RectStart) {
         body->startElement("draw:rect");
     }
+    // Simplifying connector to be a line
+    else if (startType == StraightConnectorStart) {
+        body->startElement("draw:line");
+    }
     else {
         body->startElement("draw:frame");
     }
@@ -70,42 +74,96 @@
     const QString hor_pos_rel(m_vmlStyle.value("mso-position-horizontal-relative"));
     const QString ver_pos_rel(m_vmlStyle.value("mso-position-vertical-relative"));
 
-    if (!width.isEmpty()) {
+    qreal x_position = 0;
+    QString x_pos_string, y_pos_string, widthString, heightString;
+    qreal y_position = 0;
+    qreal widthValue = 0;
+    qreal heightValue = 0;
+
+    if (!x_mar.isEmpty()) {
         if (m_insideGroup) {
-            width = QString("%1%2").arg(width.toInt() * m_real_groupWidth / \
m_groupWidth).arg(m_groupUnit); +            x_position = (x_mar.toInt() - m_groupX) \
* m_real_groupWidth / m_groupWidth; +            x_pos_string = \
QString("%1%2").arg(x_position).arg(m_groupUnit); +        } else {
+            x_position = x_mar.left(x_mar.length() - 2).toDouble(); // removing the \
unit +            x_pos_string = x_mar;
         }
-        body->addAttribute("svg:width", width);
     }
-    if (!height.isEmpty()) {
+    else if (!leftPos.isEmpty()) {
         if (m_insideGroup) {
-            height = QString("%1%2").arg(height.toInt() * m_real_groupHeight / \
m_groupHeight).arg(m_groupUnit); +            x_position = (leftPos.toInt() - \
m_groupX) * m_real_groupWidth / m_groupWidth; +            x_pos_string = \
QString("%1%2").arg(x_position).arg(m_groupUnit); +        } else {
+            x_position = leftPos.left(leftPos.length() - 2).toDouble();
+            x_pos_string = leftPos;
         }
-        body->addAttribute("svg:height", height);
     }
-    if (!x_mar.isEmpty()) {
+    if (!y_mar.isEmpty()) {
         if (m_insideGroup) {
-            x_mar = QString("%1%2").arg((x_mar.toInt() - m_groupX) * \
m_real_groupWidth / m_groupWidth).arg(m_groupUnit); +            y_position = \
(y_mar.toInt() - m_groupY) * m_real_groupHeight / m_groupHeight; +            \
y_pos_string = QString("%1%2").arg(y_position).arg(m_groupUnit); +        } else {
+            y_position = y_mar.left(y_mar.length() -2).toDouble();
+            y_pos_string = y_mar;
         }
-        body->addAttribute("svg:x", x_mar);
     }
-    else if (!leftPos.isEmpty()) {
+    else if (!topPos.isEmpty()) {
         if (m_insideGroup) {
-            leftPos = QString("%1%2").arg((leftPos.toInt() - m_groupX) * \
m_real_groupWidth / m_groupWidth).arg(m_groupUnit); +            y_position = \
(topPos.toInt() - m_groupY) * m_real_groupHeight / m_groupHeight; +            \
y_pos_string = QString("%1%2").arg(y_position).arg(m_groupUnit); +        } else {
+            y_position = topPos.left(topPos.length() - 2).toDouble();
+            y_pos_string = topPos;
         }
-        body->addAttribute("svg:x", leftPos);
     }
-    if (!y_mar.isEmpty()) {
+    if (!width.isEmpty()) {
         if (m_insideGroup) {
-            y_mar = QString("%1%2").arg((y_mar.toInt() - m_groupY) * \
m_real_groupHeight / m_groupHeight).arg(m_groupUnit); +            widthValue = \
width.toInt() * m_real_groupWidth / m_groupWidth; +            widthString = \
QString("%1%2").arg(widthValue).arg(m_groupUnit); +        } else {
+            widthValue = width.left(width.length() - 2).toDouble();
+            widthString = width;
         }
-        body->addAttribute("svg:y", y_mar);
     }
-    else if (!topPos.isEmpty()) {
+    if (!height.isEmpty()) {
         if (m_insideGroup) {
-            topPos = QString("%1%2").arg((topPos.toInt() - m_groupY) * \
m_real_groupHeight / m_groupHeight).arg(m_groupUnit); +            heightValue = \
height.toInt() * m_real_groupHeight / m_groupHeight; +            heightString = \
QString("%1%2").arg(heightValue).arg(m_groupUnit);  }
-        body->addAttribute("svg:y", topPos);
+        else {
+            heightValue = height.left(height.length() - 2).toDouble();
+            heightString = height;
     }
+    }
+
+    if (startType == StraightConnectorStart) {
+        QString flip(m_vmlStyle.value("flip"));
+        QString y1 = y_pos_string;
+        QString x2 = QString("%1%2").arg(x_position + \
widthValue).arg(widthString.right(2)); // right(2) takes the unit +        QString x1 \
= x_pos_string; +        QString y2 = QString("%1%2").arg(y_position + \
heightValue).arg(heightString.right(2)); +        if (flip == "x") {
+            QString temp = y2;
+            y2 = y1;
+            y1 = temp;
+        }
+        if (flip == "y") {
+            QString temp = x2;
+            x2 = x1;
+            x1 = temp;
+        }
+        body->addAttribute("svg:x1", x1);
+        body->addAttribute("svg:y1", y1);
+        body->addAttribute("svg:x2", x2);
+        body->addAttribute("svg:y2", y2);
+    }
+    else {
+        body->addAttribute("svg:x", x_pos_string);
+        body->addAttribute("svg:y", y_pos_string);
+        body->addAttribute("svg:width", widthString);
+        body->addAttribute("svg:height", heightString);
+    }
+
     if (!m_shapeColor.isEmpty()) {
         m_currentDrawStyle->addProperty("draw:fill", "solid");
         m_currentDrawStyle->addProperty("draw:fill-color", m_shapeColor);
@@ -684,6 +742,8 @@
         m_currentShapeId = o_spid;
     }
 
+    TRY_READ_ATTR_WITH_NS(o, connectortype)
+
     // CSS2 styling properties of the shape, http://www.w3.org/TR/REC-CSS2
     TRY_READ_ATTR_WITHOUT_NS(style)
     RETURN_IF_ERROR(parseCSS(style))
@@ -731,8 +791,12 @@
     body = frameBuf.originalWriter();
 
     if (m_outputFrames) {
+        if (o_connectortype.isEmpty()) {
         createFrameStart();
+        } else {
+            createFrameStart(StraightConnectorStart);
     }
+    }
 
     (void)frameBuf.releaseWriter();
 
--- trunk/koffice/filters/libmsooxml/MsooXmlVmlReaderMethods.h #1202251:1202252
@@ -47,7 +47,7 @@
     KoFilter::ConversionStatus read_group();
     KoFilter::ConversionStatus read_stroke();
 
-    enum FrameStartElement {FrameStart, RectStart};
+    enum FrameStartElement {FrameStart, RectStart, StraightConnectorStart};
 
     void createFrameStart(FrameStartElement startType = FrameStart);
     KoFilter::ConversionStatus createFrameEnd();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic