[calligra] /: Fix saving of shapes in the correct order.

Thorsten Zachmann t.zachmann at zagge.de
Sun Mar 4 18:38:53 GMT 2012


Git commit 5af08715b5f9e8fb16ef9a9c48e3507203e40c1e by Thorsten Zachmann.
Committed on 04/03/2012 at 19:16.
Pushed by zachmann into branch 'master'.

Fix saving of shapes in the correct order.

The saving of the order is currently broken for quite a lot of files.

One example is slide 4 of

http://www.zagge.de/anchor/bug/open.umich.edu%252Fsites%252Fdefault%252Ffiles%252FSeverance-SI5%25302-W%25309-Week11-Sesons-and-Cookies.odp

This was caused by the commit 3fd6c20f31f946f3128af63fc433449f36c06c9d that saves the
z-index out to the file. However the way it is done is not fully correct. I works mostly
for words. With this patch we go to back to the original behaviour of not saving the z-index
as it is defined by the order of the shapes in the xml file. We still save the z-index for
words.

Please review.

I have run cstester --roundtip and it improves for odp and not regressions for odt files.

CCMAIL: calligra-devel at kde.org

M  +1    -1    libs/flake/KoShape.cpp
M  +5    -1    libs/flake/KoShapeSavingContext.h
M  +2    -1    words/part/KWOdfWriter.cpp

http://commits.kde.org/calligra/5af08715b5f9e8fb16ef9a9c48e3507203e40c1e

diff --git a/libs/flake/KoShape.cpp b/libs/flake/KoShape.cpp
index cbeed5f..5ae13c9 100644
--- a/libs/flake/KoShape.cpp
+++ b/libs/flake/KoShape.cpp
@@ -1772,7 +1772,7 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
         }
     }
 
-    if (attributes & OdfZIndex) {
+    if (attributes & OdfZIndex && context.isSet(KoShapeSavingContext::ZIndex)) {
         context.xmlWriter().addAttribute("draw:z-index", zIndex());
     }
 
diff --git a/libs/flake/KoShapeSavingContext.h b/libs/flake/KoShapeSavingContext.h
index a61a7e8..f7d328c 100644
--- a/libs/flake/KoShapeSavingContext.h
+++ b/libs/flake/KoShapeSavingContext.h
@@ -69,7 +69,11 @@ public:
         /**
          * If set duplicate master pages will be merged to one
          */
-        UniqueMasterPages = 8
+        UniqueMasterPages = 8,
+        /**
+         * If set the z-index is saved in the shape
+         */
+        ZIndex = 16
     };
     Q_DECLARE_FLAGS(ShapeSavingOptions, ShapeSavingOption)
 
diff --git a/words/part/KWOdfWriter.cpp b/words/part/KWOdfWriter.cpp
index edd0a89..b061b96 100644
--- a/words/part/KWOdfWriter.cpp
+++ b/words/part/KWOdfWriter.cpp
@@ -79,7 +79,7 @@ QByteArray KWOdfWriter::serializeHeaderFooter(KoShapeSavingContext &context, KWT
     KoXmlWriter &savedWriter = context.xmlWriter();
 
     KoShapeSavingContext::ShapeSavingOptions options = context.options();
-    context.setOptions(KoShapeSavingContext::AutoStyleInStyleXml);
+    context.setOptions(KoShapeSavingContext::AutoStyleInStyleXml | KoShapeSavingContext::ZIndex);
     context.setXmlWriter(writer);
 
     Q_ASSERT(!fs->frames().isEmpty());
@@ -226,6 +226,7 @@ bool KWOdfWriter::save(KoOdfWriteStore &odfStore, KoEmbeddedDocumentSaver &embed
     KoChangeTracker *changeTracker = m_document->resourceManager()->resource(KoText::ChangeTracker).value<KoChangeTracker*>();
 
     KoShapeSavingContext context(*tmpBodyWriter, mainStyles, embeddedSaver);
+    context.addOption(KoShapeSavingContext::ZIndex);
 
     KoTextSharedSavingData *sharedData = new KoTextSharedSavingData;
     sharedData->setGenChanges(changes);




More information about the calligra-devel mailing list