[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-10-13 7:19:37
Message-ID: 20101013071937.3C6B9AC897 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1185372 by lassin:

Fixed vml drawings to take border style into account.


 M  +6 -1      MsooXmlUtils.cpp  
 M  +1 -1      MsooXmlUtils.h  
 M  +93 -15    MsooXmlVmlReaderImpl.h  
 M  +2 -0      MsooXmlVmlReaderMethods.h  
 M  +1 -0      VmlDrawingReader.cpp  


--- trunk/koffice/filters/libmsooxml/MsooXmlUtils.cpp #1185371:1185372
@@ -1267,8 +1267,13 @@
     return value; // the original is OK
 }
 
-MSOOXML_EXPORT QString Utils::rgbColor(const QString& color)
+MSOOXML_EXPORT QString Utils::rgbColor(QString color)
 {
+    // It is possible that color is eg #abcdef [adddd], this removes the extra end
+    if (color.indexOf(' ') > 0) {
+        color = color.left(color.indexOf(' '));
+    }
+
     QString newColor;
     if (color == "red") {
         newColor = "#ff0000";
--- trunk/koffice/filters/libmsooxml/MsooXmlUtils.h #1185371:1185372
@@ -291,7 +291,7 @@
 };
 
 //! Converts color string to rgb color string #xxYYZZ
-MSOOXML_EXPORT QString rgbColor(const QString& color);
+MSOOXML_EXPORT QString rgbColor(QString color);
 
 MSOOXML_EXPORT QColor colorForLuminance(const QColor& color,
     const DoubleModifier& modulation, const DoubleModifier& offset);
--- trunk/koffice/filters/libmsooxml/MsooXmlVmlReaderImpl.h #1185371:1185372
@@ -53,8 +53,6 @@
 {
     body->startElement("draw:frame");
 
-    pushCurrentDrawStyle(new KoGenStyle(KoGenStyle::GraphicAutoStyle, "graphic"));
-
     QString width(m_vmlStyle.value("width")); // already in "...cm" format
     QString height(m_vmlStyle.value("height")); // already in "...cm" format
     QString x_mar(m_vmlStyle.value("margin-left"));
@@ -164,8 +162,6 @@
 
     body->endElement(); //draw:frame
 
-    popCurrentDrawStyle();
-
     return KoFilter::OK;
 }
 
@@ -202,7 +198,7 @@
  - shadow (Shadow Effect)  §14.1.2.18
  - signatureline (Digital Signature Line)  §14.2.2.30
  - skew (Skew Transform)  §14.2.2.31
- - stroke (Line Stroke Settings)  §14.1.2.21
+ - [done] stroke (Line Stroke Settings)  §14.1.2.21
  - [done] textbox (Text Box)  §14.1.2.22
  - textdata (VML Diagram Text)  §14.5.2.2
  - textpath (Text Layout Path)  §14.1.2.23
@@ -218,35 +214,87 @@
     RETURN_IF_ERROR(parseCSS(style))
 
     TRY_READ_ATTR_WITHOUT_NS(fillcolor)
+    TRY_READ_ATTR_WITHOUT_NS(strokecolor)
+    TRY_READ_ATTR_WITHOUT_NS(strokeweight)
 
+    m_strokeWidth = 1 ; // This seems to be the default
+
+    if (!strokeweight.isEmpty()) {
+        m_strokeWidth = strokeweight.left(strokeweight.length() - 2).toDouble(); // -2 removes 'pt'
+    }
+
     m_shapeColor.clear();
+    m_strokeColor.clear();
 
     if (!fillcolor.isEmpty()) {
-        // It is possible that fillcolor is eg #abcdef [adddd], this removes the extra end
-        if (fillcolor.indexOf(' ') > 0) {
-            fillcolor = fillcolor.left(fillcolor.indexOf(' '));
-        }
         m_shapeColor = MSOOXML::Utils::rgbColor(fillcolor);
     }
 
-    createFrameStart();
+    if (!strokecolor.isEmpty()) {
+        m_strokeColor = MSOOXML::Utils::rgbColor(strokecolor);
+    }
 
+    MSOOXML::Utils::XmlWriteBuffer frameBuf;
+    body = frameBuf.setWriter(body);
+
+    pushCurrentDrawStyle(new KoGenStyle(KoGenStyle::GraphicAutoStyle, "graphic"));
+
     while (!atEnd()) {
         readNext();
         BREAK_IF_END_OF(CURRENT_EL);
         if (isStartElement()) {
             TRY_READ_IF(fill)
             ELSE_TRY_READ_IF(textbox)
+            ELSE_TRY_READ_IF(stroke)
 //! @todo add ELSE_WRONG_FORMAT
         }
     }
 
+    body = frameBuf.originalWriter();
+
+    createFrameStart();
+
+    (void)frameBuf.releaseWriter();
+
     createFrameEnd();
 
+    popCurrentDrawStyle();
+
     READ_EPILOGUE
 }
 
 #undef CURRENT_EL
+#define CURRENT_EL stroke
+//! Stroke style handler
+KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_stroke()
+{
+    READ_PROLOGUE
+    const QXmlStreamAttributes attrs(attributes());
+
+    m_currentPen = QPen();
+
+    TRY_READ_ATTR_WITHOUT_NS(endcap)
+    Qt::PenCapStyle penCap = m_currentPen.capStyle();
+    if (endcap.isEmpty() || endcap == "sq") {
+       penCap = Qt::SquareCap;
+    }
+    else if (endcap == "round") {
+        penCap = Qt::RoundCap;
+    }
+    else if (endcap == "flat") {
+        penCap = Qt::FlatCap;
+    }
+    m_currentPen.setCapStyle(penCap);
+    m_currentPen.setWidthF(m_strokeWidth);
+    m_currentPen.setColor(QColor(m_strokeColor));
+
+    KoOdfGraphicStyles::saveOdfStrokeStyle(*m_currentDrawStyle, *mainStyles, m_currentPen);
+
+    readNext();
+    READ_EPILOGUE
+}
+
+#undef CURRENT_EL
 #define CURRENT_EL group
 //! Vml group handler
 KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_group()
@@ -345,8 +393,11 @@
     TRY_READ_ATTR_WITHOUT_NS(style)
     RETURN_IF_ERROR(parseCSS(style))
 
-    createFrameStart();
+    pushCurrentDrawStyle(new KoGenStyle(KoGenStyle::GraphicAutoStyle, "graphic"));
 
+    MSOOXML::Utils::XmlWriteBuffer frameBuf;
+    body = frameBuf.setWriter(body);
+
     while (!atEnd()) {
         readNext();
         BREAK_IF_END_OF(CURRENT_EL);
@@ -357,8 +408,16 @@
         }
     }
 
+    body = frameBuf.originalWriter();
+
+    createFrameStart();
+
+    (void)frameBuf.releaseWriter();
+
     createFrameEnd();
 
+    popCurrentDrawStyle();
+
     READ_EPILOGUE
 }
 
@@ -570,7 +629,7 @@
  - shadow (Shadow Effect)  §14.1.2.18
  - signatureline (Digital Signature Line)  §14.2.2.30
  - skew (Skew Transform)  §14.2.2.31
- - stroke (Line Stroke Settings)  §14.1.2.21
+ - [done] stroke (Line Stroke Settings)  §14.1.2.21
  - [done] textbox (Text Box)  §14.1.2.22
  - textdata (VML Diagram Text)  §14.5.2.2
  - textpath (Text Layout Path)  §14.1.2.23
@@ -628,7 +687,14 @@
     TRY_READ_ATTR_WITHOUT_NS_INTO(title, m_shapeTitle)
     TRY_READ_ATTR_WITHOUT_NS(fillcolor)
     TRY_READ_ATTR_WITHOUT_NS(strokecolor)
+    TRY_READ_ATTR_WITHOUT_NS(strokeweight)
 
+    m_strokeWidth = 1 ; // This seems to be the default
+
+    if (!strokeweight.isEmpty()) {
+        m_strokeWidth = strokeweight.left(strokeweight.length() - 2).toDouble(); // -2 removes 'pt'
+    }
+
     m_shapeColor.clear();
     m_strokeColor.clear();
 
@@ -640,25 +706,37 @@
         m_strokeColor = MSOOXML::Utils::rgbColor(strokecolor);
     }
 
-    if (m_outputFrames) {
-        createFrameStart();
-    }
+    MSOOXML::Utils::XmlWriteBuffer frameBuf;
+    body = frameBuf.setWriter(body);
 
+    pushCurrentDrawStyle(new KoGenStyle(KoGenStyle::GraphicAutoStyle, "graphic"));
+
     while (!atEnd()) {
         readNext();
         BREAK_IF_END_OF(CURRENT_EL);
         if (isStartElement()) {
             TRY_READ_IF(imagedata)
             ELSE_TRY_READ_IF(textbox)
+            ELSE_TRY_READ_IF(stroke)
         }
     }
 
+    body = frameBuf.originalWriter();
+
+    if (m_outputFrames) {
+        createFrameStart();
+    }
+
+    (void)frameBuf.releaseWriter();
+
     m_objectRectInitialized = true;
 
     if (m_outputFrames) {
         createFrameEnd();
     }
 
+    popCurrentDrawStyle();
+
     READ_EPILOGUE
 }
 
--- trunk/koffice/filters/libmsooxml/MsooXmlVmlReaderMethods.h #1185371:1185372
@@ -45,6 +45,7 @@
     KoFilter::ConversionStatus read_imagedata();
     KoFilter::ConversionStatus read_textbox();
     KoFilter::ConversionStatus read_group();
+    KoFilter::ConversionStatus read_stroke();
 
     void createFrameStart();
     KoFilter::ConversionStatus createFrameEnd();
@@ -80,6 +81,7 @@
     QString m_currentShapeId; //!< set in read_shape()
 
     QString m_strokeColor; // stroke color
+    qreal m_strokeWidth; // stroke width
 
     bool m_outputFrames; // Whether read_shape should output something to shape
 
--- trunk/koffice/filters/libmsooxml/VmlDrawingReader.cpp #1185371:1185372
@@ -28,6 +28,7 @@
 #include <MsooXmlUnits.h>
 #include <KoXmlWriter.h>
 #include <KoGenStyles.h>
+#include <KoOdfGraphicStyles.h>
 #include <limits.h>
 
 #define MSOOXML_CURRENT_NS empty // Without this, the vml methods won't have ns identifier in them
[prev in list] [next in list] [prev in thread] [next in thread] 

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