[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-11 11:55:39
Message-ID: 20101011115539.DE560AC7E4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1184796 by lassin:

Fixed drawingML to support picture bullets.


 M  +58 -7     MsooXmlCommonReaderDrawingMLImpl.h  
 M  +2 -0      MsooXmlCommonReaderDrawingMLMethods.h  
 M  +26 -2     MsooXmlUtils.cpp  
 M  +8 -1      MsooXmlUtils.h  


--- trunk/koffice/filters/libmsooxml/MsooXmlCommonReaderDrawingMLImpl.h \
#1184795:1184796 @@ -2080,7 +2080,7 @@
   - rtl (Right To Left)
  Child elements:
   - [done] buAutoNum (Auto-Numbered Bullet)  §21.1.2.4.1
-  - buBlip (Picture Bullet)  §21.1.2.4.2
+  - [done] buBlip (Picture Bullet)  §21.1.2.4.2
   - [done] buChar (Character Bullet)  §21.1.2.4.3
   - buClr (Color Specified)  §21.1.2.4.4
   - buClrTx (Follow Text)  §21.1.2.4.5
@@ -2153,6 +2153,7 @@
             ELSE_TRY_READ_IF(buNone)
             ELSE_TRY_READ_IF(buChar)
             ELSE_TRY_READ_IF(buFont)
+            ELSE_TRY_READ_IF(buBlip)
             else if (QUALIFIED_NAME_IS(spcBef)) {
                 m_currentSpacingType = spacingMarginTop;
                 TRY_READ(spcBef)
@@ -2448,7 +2449,7 @@
     - blipFill ( §20.2.2.1) - DrawingML, p. 3456
     - blipFill ( §20.5.2.2) - DrawingML, p. 3518
     - [done] blipFill ( §19.3.1.4) - PresentationML, p. 2818
-    - buBlip ( §21.1.2.4.2)
+    - [done] buBlip ( §21.1.2.4.2)
 
  Child elements:
     - alphaBiLevel (Alpha Bi-Level Effect)  §20.1.8.1
@@ -2491,6 +2492,9 @@
         const QString sourceName(m_context->relationships->target(m_context->path,
                                                                   m_context->file, \
r_embed));  kDebug() << "sourceName:" << sourceName;
+
+        m_imageSize = imageSize(sourceName);
+
         if (sourceName.isEmpty()) {
             return KoFilter::FileNotFound;
         }
@@ -2509,7 +2513,7 @@
 #else
         QString destinationName;
         RETURN_IF_ERROR( copyFile(sourceName, QLatin1String("Pictures/"), \
                destinationName) )
-
+        addManifestEntryForFile(destinationName);
         m_recentSourceName = sourceName;
         addManifestEntryForPicturesDir();
         m_xlinkHref = destinationName;
@@ -4246,12 +4250,16 @@
     while (!atEnd()) {
         readNext();
         kDebug() << *this;
+        if (isEndElement() && qualifiedName() == QString("a:%1").arg(level)) {
+            break;
+        }
         if (isStartElement()) {
             TRY_READ_IF(defRPr) // fills m_currentTextStyleProperties
             ELSE_TRY_READ_IF(buNone)
             ELSE_TRY_READ_IF(buAutoNum)
             ELSE_TRY_READ_IF(buChar)
             ELSE_TRY_READ_IF(buFont)
+            ELSE_TRY_READ_IF(buBlip)
             else if (QUALIFIED_NAME_IS(spcBef)) {
                 m_currentSpacingType = spacingMarginTop;
                 TRY_READ(spcBef)
@@ -4266,10 +4274,7 @@
             }
 //! @todo add ELSE_WRONG_FORMAT
         }
-        if (isEndElement() && qualifiedName() == QString("a:%1").arg(level)) {
-            break;
         }
-    }
 
     if (m_bulletFont == "Wingdings") {
         // Ooxml files have very often wingdings fonts, but usually they are not \
installed @@ -4306,7 +4311,7 @@
 
  Child elements:
   - [done] buAutoNum (Auto-Numbered Bullet)      §21.1.2.4.1
-  - buBlip (Picture Bullet)               §21.1.2.4.2
+  - [done] buBlip (Picture Bullet)               §21.1.2.4.2
   - [done] buChar (Character Bullet)             §21.1.2.4.3
   - buClr (Color Specified)               §21.1.2.4.4
   - buClrTx (Follow Text)                 §21.1.2.4.5
@@ -4413,6 +4418,52 @@
 }
 
 #undef CURRENT_EL
+#define CURRENT_EL buBlip
+//! buBlip - bullet picture
+/*!
+ Parent elements:
+ - defPPr ( §21.1.2.2.2)
+ - [done] lvl1pPr ( §21.1.2.4.13)
+ - [done] lvl2pPr ( §21.1.2.4.14)
+ - [done] lvl3pPr ( §21.1.2.4.15)
+ - [done] lvl4pPr ( §21.1.2.4.16)
+ - [done] lvl5pPr ( §21.1.2.4.17)
+ - [done] lvl6pPr ( §21.1.2.4.18)
+ - [done] lvl7pPr ( §21.1.2.4.19)
+ - [done] lvl8pPr ( §21.1.2.4.20)
+ - [done] lvl9pPr ( §21.1.2.4.21)
+ - [done] pPr ( §21.1.2.2.7)
+
+ Child elements:
+ - [done] blip
+*/
+//! @todo support all attributes
+KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_buBlip()
+{
+    READ_PROLOGUE
+    const QXmlStreamAttributes attrs(attributes());
+
+    m_xlinkHref.clear();
+
+    while (!atEnd()) {
+        readNext();
+        BREAK_IF_END_OF(CURRENT_EL);
+        if (isStartElement()) {
+            TRY_READ_IF(blip)
+        }
+    }
+
+    if (!m_xlinkHref.isEmpty()) {
+        m_currentBulletProperties.setPicturePath(m_xlinkHref);
+        m_currentBulletProperties.setPictureSize(m_imageSize);
+        m_lstStyleFound = true;
+        m_listStylePropertiesAltered = true;
+    }
+
+    READ_EPILOGUE
+}
+
+#undef CURRENT_EL
 #define CURRENT_EL buChar
 //! buChar - bullet character
 /*!
--- trunk/koffice/filters/libmsooxml/MsooXmlCommonReaderDrawingMLMethods.h \
#1184795:1184796 @@ -150,6 +150,7 @@
 bool m_listStylePropertiesAltered;
 
 KoFilter::ConversionStatus read_buChar();
+KoFilter::ConversionStatus read_buBlip();
 KoFilter::ConversionStatus read_buNone();
 QString m_bulletFont; // set by buFont;
 KoFilter::ConversionStatus read_buFont();
@@ -231,6 +232,7 @@
 bool m_noFill;
 
 QString m_xlinkHref; //!< set by read_blip()
+QSize m_imageSize; //!< set by read_blip()
 QString m_recentSourceName; //!< set by read_blip()
 QString m_cNvPrId; //!< set by read_cNvPr()
 QString m_cNvPrName; //!< set by read_cNvPr()
--- trunk/koffice/filters/libmsooxml/MsooXmlUtils.cpp #1184795:1184796
@@ -1348,6 +1348,17 @@
     m_type = ParagraphBulletProperties::NumberType;
 }
 
+MSOOXML_EXPORT void Utils::ParagraphBulletProperties::setPicturePath(const QString& \
picturePath) +{
+    m_picturePath = picturePath;
+    m_type = ParagraphBulletProperties::PictureType;
+}
+
+MSOOXML_EXPORT void Utils::ParagraphBulletProperties::setPictureSize(const QSize& \
size) +{
+    m_pictureSize = size;
+}
+
 MSOOXML_EXPORT QString Utils::ParagraphBulletProperties::convertToListProperties() \
const  {
     QString returnValue;
@@ -1360,6 +1371,12 @@
         }
         ending = "</text:list-level-style-number>";
     }
+    else if (m_type == ParagraphBulletProperties::PictureType) {
+        returnValue = QString("<text:list-level-style-image text:level=\"%1\" \
").arg(m_level); +        returnValue += QString("xlink:href=\"%1\" \
").arg(m_picturePath); +        returnValue += "xlink:type=\"simple\" \
xlink:show=\"embed\" xlink:actuate=\"onLoad\" "; +        ending = \
"</text:list-level-style-image>"; +    }
     else {
         returnValue = QString("<text:list-level-style-bullet text:level=\"%1\" \
                ").arg(m_level);
         returnValue += QString("text:bullet-char=\"%1\" ").arg(m_bulletChar);
@@ -1370,12 +1387,19 @@
     }
     returnValue += ">";
 
+    returnValue += "<style:list-level-properties ";
+
     if (m_indent > 0) {
-        returnValue += "<style:list-level-properties ";
         returnValue += QString("text:space-before=\"%1pt\" ").arg(m_indent);
-        returnValue += "/>";
     }
 
+    if (m_type == ParagraphBulletProperties::PictureType) {
+        returnValue += QString("fo:width=\"%1\" fo:height=\"%2\" \
").arg(MSOOXML::Utils::cmString(POINT_TO_CM(m_pictureSize.width()))). +            \
arg(MSOOXML::Utils::cmString(POINT_TO_CM(m_pictureSize.height()))); +    }
+
+    returnValue += "/>";
+
     returnValue += ending;
 
     return returnValue;
--- trunk/koffice/filters/libmsooxml/MsooXmlUtils.h #1184795:1184796
@@ -28,6 +28,7 @@
 
 #include "msooxml_export.h"
 
+#include <QSize>
 #include <QColor>
 #include <QBuffer>
 #include <KoFilterChain.h>
@@ -84,11 +85,15 @@
 
     void setIndent(qreal indent);
 
+    void setPicturePath(const QString& picturePath);
+
+    void setPictureSize(const QSize& size);
+
     int m_level;
     int m_startValue;
 
 private:
-    enum ParagraphBulletType {BulletType, NumberType};
+    enum ParagraphBulletType {BulletType, NumberType, PictureType};
     ParagraphBulletType m_type;
 
     QString m_bulletChar;
@@ -96,6 +101,8 @@
     QString m_suffix;
     QString m_align;
     qreal m_indent;
+    QString m_picturePath;
+    QSize m_pictureSize;
 };
 
 //! Container autodeleter. Works for QList, QHash and QMap.


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

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