[calligra] libs/kotext/styles: Add collection to datacenters so images are saved

Thorsten Zachmann t.zachmann at zagge.de
Tue May 1 06:37:24 BST 2012


Git commit f80a91d466afd17c773f23bf98adbffe11859d14 by Thorsten Zachmann.
Committed on 01/05/2012 at 07:32.
Pushed by zachmann into branch 'master'.

Add collection to datacenters so images are saved

If there was no image in the document the image bullets where not saved as the image collection
was not added to the data centers and therefore the images where not saved. This fixes that by
adding the image collection to the datacenters.
Reorder the way the attributes are added. They need to be added before a child element is added
therefore they are moved up.
Parts of the patch are provided by gopalK.

Is it ok to include KoImageData_p.h in a lib of our own code or should we find a different solution?

Ok to backport?

CCMAIL: calligra-devel at kde.org
BUG: 299112

M  +11   -8    libs/kotext/styles/KoListLevelProperties.cpp

http://commits.kde.org/calligra/f80a91d466afd17c773f23bf98adbffe11859d14

diff --git a/libs/kotext/styles/KoListLevelProperties.cpp b/libs/kotext/styles/KoListLevelProperties.cpp
index f3dd4ff..8bc97ac 100644
--- a/libs/kotext/styles/KoListLevelProperties.cpp
+++ b/libs/kotext/styles/KoListLevelProperties.cpp
@@ -41,6 +41,7 @@
 #include <KoText.h>
 #include <KoImageCollection.h>
 #include <KoImageData.h>
+#include <KoImageData_p.h>
 #include <KoOdfNumberDefinition.h>
 #include <KoGenStyle.h>
 #include <KoTextSharedSavingData.h>
@@ -809,12 +810,14 @@ void KoListLevelProperties::saveOdf(KoXmlWriter *writer, KoShapeSavingContext &c
     }
     else if (style() == KoListStyle::ImageItem) {
         KoImageData *imageData = d->stylesPrivate.value(KoListStyle::BulletImage).value<KoImageData *>();
-        if (imageData) {
+        Q_ASSERT(imageData->priv()->collection);
+        if (imageData && imageData->priv()->collection) {
             writer->startElement("text:list-level-style-image");
             writer->addAttribute("xlink:show", "embed");
             writer->addAttribute("xlink:actuate", "onLoad");
             writer->addAttribute("xlink:type", "simple");
             writer->addAttribute("xlink:href", context.imageHref(imageData));
+            context.addDataCenter(imageData->priv()->collection);
         }
     }
     else {
@@ -849,6 +852,13 @@ void KoListLevelProperties::saveOdf(KoXmlWriter *writer, KoShapeSavingContext &c
 
     writer->startElement("style:list-level-properties", false);
 
+    if (d->stylesPrivate.contains(KoListStyle::Width)) {
+        writer->addAttributePt("fo:width", width());
+    }
+    if (d->stylesPrivate.contains(KoListStyle::Height)) {
+        writer->addAttributePt("fo:height", height());
+    }
+
     if(d->stylesPrivate.contains(KoListStyle::AlignmentMode) && alignmentMode()==false) {
 
         writer->addAttribute("text:list-level-position-and-space-mode","label-width-and-position");
@@ -887,13 +897,6 @@ void KoListLevelProperties::saveOdf(KoXmlWriter *writer, KoShapeSavingContext &c
         writer->endElement();
     }
 
-    if (d->stylesPrivate.contains(KoListStyle::Width)) {
-        writer->addAttributePt("fo:width", width());
-    }
-    if (d->stylesPrivate.contains(KoListStyle::Height)) {
-        writer->addAttributePt("fo:height", height());
-    }
-
     writer->endElement(); // list-level-properties
 
     // text properties



More information about the calligra-devel mailing list