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

Jan Holesovsky kendy at collabora.com
Thu Mar 8 14:45:16 UTC 2018


 include/oox/core/xmlfilterbase.hxx        |    6 +++++-
 oox/source/core/xmlfilterbase.cxx         |    2 --
 sc/qa/unit/subsequent_export-test.cxx     |    4 ++++
 sc/source/filter/excel/excdoc.cxx         |    3 ++-
 sd/qa/unit/export-tests-ooxml1.cxx        |    4 ++--
 sd/source/filter/eppt/pptx-epptooxml.cxx  |    4 ++--
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx |   11 +++++++++++
 7 files changed, 26 insertions(+), 8 deletions(-)

New commits:
commit bf5c486946f2b0a708a251c8ff614293ae37c6ba
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Mar 8 12:24:48 2018 +0100

    tdf#116283 oox customXml: Don't write the Relationship to DOCX files twice.
    
    Change-Id: Id3da40138e86c142707e377aa897df372aacb704
    Reviewed-on: https://gerrit.libreoffice.org/50947
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 75fc03920b79..69586fe020bb 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -226,7 +226,12 @@ public:
      */
     void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties );
 
+    /** Write the customXml entries we are preserving (xlsx and pptx only). */
+    void exportCustomFragments();
+
+    /** Read the document properties and also the customXml entries (xlsx and pptx only). */
     void importDocumentProperties();
+
     static void putPropertiesToDocumentGrabBag(const css::uno::Reference<css::lang::XComponent>& xDstDoc,
                                                const comphelper::SequenceAsHashMap& rProperties);
 
@@ -259,7 +264,6 @@ private:
                             const css::uno::Reference< css::io::XStream >& rxOutStream ) const override;
 
     void importCustomFragments(css::uno::Reference<css::embed::XStorage>& xDocumentStorage);
-    void exportCustomFragments();
 
 private:
     ::std::unique_ptr< XmlFilterBaseImpl > mxImpl;
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 0388fae5f473..00d202b315da 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -841,8 +841,6 @@ void XmlFilterBase::exportDocumentProperties( const Reference< XDocumentProperti
         writeAppProperties( *this, xProperties );
         writeCustomProperties( *this, xProperties );
     }
-
-    exportCustomFragments();
 }
 
 // protected ------------------------------------------------------------------
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 595e563dc301..ff4063f8ed84 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -3055,6 +3055,10 @@ void ScExportTest::testCustomXml()
     xmlDocPtr pRelsDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "customXml/_rels/item1.xml.rels");
     CPPUNIT_ASSERT(pRelsDoc);
 
+    // Check there is a relation to itemProps1.xml.
+    assertXPath(pRelsDoc, "/r:Relationships/r:Relationship", 1);
+    assertXPath(pRelsDoc, "/r:Relationships/r:Relationship[@Id='rId1']", "Target", "itemProps1.xml");
+
     std::shared_ptr<SvStream> pStream = XPathHelper::parseExportStream(pXPathFile, m_xSFactory, "ddp/ddpfile.xen");
     CPPUNIT_ASSERT(pStream);
 }
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index d2dd5d147b0e..bc0d4e3de177 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -830,7 +830,8 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm )
     uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
     uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
 
-    rStrm.exportDocumentProperties( xDocProps );
+    rStrm.exportDocumentProperties(xDocProps);
+    rStrm.exportCustomFragments();
 
     sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream();
     rWorkbook->startElement( XML_workbook,
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 2ccc48982727..54e411a482f7 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -847,8 +847,8 @@ void SdOOXMLExportTest1::testCustomXml()
     CPPUNIT_ASSERT(pRelsDoc);
 
     // Check there is a relation to itemProps1.xml.
-    const OUString sXmlPath = "/rels:Relationships/rels:Relationship[@Id='rId1']";
-    assertXPath(pRelsDoc, OUStringToOString(sXmlPath, RTL_TEXTENCODING_UTF8), "Target", "itemProps1.xml");
+    assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship", 1);
+    assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "itemProps1.xml");
 
     std::shared_ptr<SvStream> pStream = parseExportStream(tempFile, "ddp/ddpfile.xen");
     CPPUNIT_ASSERT(pStream);
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index ca5f9ef56c67..2672f17c185f 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -358,9 +358,9 @@ void PowerPointExport::writeDocumentProperties()
     uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
 
     if (xDocProps.is())
-    {
         exportDocumentProperties(xDocProps);
-    }
+
+    exportCustomFragments();
 }
 
 bool PowerPointExport::importDocument() throw()
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index bfab921a26ae..02b26aba67c3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -536,6 +536,17 @@ DECLARE_OOXMLEXPORT_TEST(testCustomXmlGrabBag, "customxml.docx")
     CPPUNIT_ASSERT(CustomXml); // Grab Bag has all the expected elements
 }
 
+DECLARE_OOXMLEXPORT_TEST(testCustomXmlRelationships, "customxml.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("customXml/_rels/item1.xml.rels");
+    if(!pXmlDoc)
+        return;
+
+    // Check there is a relation to itemProps1.xml.
+    assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship", 1);
+    assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "itemProps1.xml");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testFdo69644, "fdo69644.docx")
 {
     // The problem was that the exporter exported the table definition


More information about the Libreoffice-commits mailing list