[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - include/oox oox/source sc/qa sc/source sd/qa sd/source sw/qa

Jan Holesovsky kendy at collabora.com
Thu Mar 8 12:36:52 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  |    6 +++---
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx |   11 +++++++++++
 7 files changed, 27 insertions(+), 9 deletions(-)

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

    oox customXml: Don't write the Relationship to DOCX files twice.
    
    Change-Id: Id3da40138e86c142707e377aa897df372aacb704
    Reviewed-on: https://gerrit.libreoffice.org/50943
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 53c80057ba60..be6366c31859 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -227,7 +227,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);
 
@@ -258,7 +263,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 491d83a5770c..7caf551c1836 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -854,8 +854,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 c013d836fb8b..793b239d510d 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -3030,6 +3030,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 70e4d4e68b28..f9ff9a891b55 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -853,7 +853,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 9147c662c634..64d2443f37bf 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -822,8 +822,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 9d6f3066b7e9..c977471aaaa8 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -349,9 +349,9 @@ void PowerPointExport::writeDocumentProperties()
     uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
 
     if (xDocProps.is())
-    {
-        exportDocumentProperties( xDocProps );
-    }
+        exportDocumentProperties(xDocProps);
+
+    exportCustomFragments();
 }
 
 bool PowerPointExport::importDocument() throw()
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index bb33e40c003a..656e0a999ec9 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