[Libreoffice-commits] core.git: oox/source sw/qa

Tushar Bende tushar.bende at synerzip.com
Fri Aug 1 01:43:22 PDT 2014


 oox/source/shape/ShapeContextHandler.cxx    |   10 +++++++++-
 sw/qa/extras/ooxmlexport/data/fdo80895.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx |   18 ++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

New commits:
commit 194c17a7c7c00f966b0256a1e90d50d8dd49f2bc
Author: Tushar Bende <tushar.bende at synerzip.com>
Date:   Tue Jul 22 11:40:49 2014 +0530

    fdo#80895 : Shape in Header&Footer is getting lost after RT
    
    If there is a shape in Header or footer in a docx created in MSO-2010 that shape was
    getting lost after RT(actually shape was there but it's properties were getting missed).
    Root cause was : When LO processes Header it has msRelationFragmentPath= header.xml in
    ShapeContextHandler::startFastElement() and searches for theme as there is No theme specific
    to header or footer, aThemeFragmentPath becomes empty in that case.
    This is because MS office shares same theme for both documentBody as well as Header or footer.
    
    To fix Get Target for Type = "officeDocument" from _rels/.rels file this target is
     "word/document.xml" for docx & to "ppt/presentation.xml" for pptx and use this Target for fetching correct theme.xml.
    Tested group shapes in header/footer,previously was not getting rendred and not preserved
     after RT.After this patch it's now working correctly.
    Tested chart in header/footer previously chart colour was not coming properly
    both during rendering as well as after RT.after this patch it's working correctly.
    
    Reviewed on:
    	https://gerrit.libreoffice.org/10451
    
    Change-Id: Id47008550da90c0d697b434b676765230e3258a7

diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index d9ae694..aed9438 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -290,8 +290,16 @@ void SAL_CALL ShapeContextHandler::startFastElement
         // Parse the theme relation, if available; the diagram won't have colors without it.
         if (!msRelationFragmentPath.isEmpty())
         {
-            FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, msRelationFragmentPath));
+            // Get Target for Type = "officeDocument" from _rels/.rels file
+            // aOfficeDocumentFragmentPath is pointing to "word/document.xml" for docx & to "ppt/presentation.xml" for pptx
+            FragmentHandlerRef rFragmentHandlerRef(new ShapeFragmentHandler(*mxFilterBase, "/"));
+            OUString aOfficeDocumentFragmentPath = rFragmentHandlerRef->getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" );
+
+            // Get the theme DO NOT  use msRelationFragmentPath for getting theme as for a document there is a single theme in document.xml.rels
+            // and the same is used by header and footer as well.
+            FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxFilterBase, aOfficeDocumentFragmentPath));
             OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
+
             if(!aThemeFragmentPath.isEmpty())
             {
                 uno::Reference<xml::sax::XFastSAXSerializable> xDoc(mxFilterBase->importFragment(aThemeFragmentPath), uno::UNO_QUERY_THROW);
diff --git a/sw/qa/extras/ooxmlexport/data/fdo80895.docx b/sw/qa/extras/ooxmlexport/data/fdo80895.docx
new file mode 100644
index 0000000..711882f
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo80895.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 20f7fd7..a6b7342 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -1762,6 +1762,24 @@ DECLARE_OOXMLEXPORT_TEST(testFdo80894, "TextFrameRotation.docx")
     "rot","16200000");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testfdo80895, "fdo80895.docx")
+{
+    // DML shapes in header and footer were not getting rendered in LO and the same were not preserved after RT.
+    // In actual there was a shape but because of fetching wrong theme for header.xml or footer.xml
+    // resultant shape was with <a:noFill/> prop in <wps:spPr> hence was not visible.
+    // Checking there is a shape in header without <a:noFill/> element.
+
+    xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
+    if (!pXmlDoc)
+        return;
+    assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:noFill",0);
+    assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:noFill",0);
+
+    // Check for fallback (required for MSO-2007)
+    assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "fillcolor", "#4f81bd");
+    assertXPath(pXmlDoc, "/w:hdr/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:rect/v:fill", "type", "solid");
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list