summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-03-08 12:24:48 +0100
committerJan Holesovsky <kendy@collabora.com>2018-03-08 15:44:50 +0100
commitbf5c486946f2b0a708a251c8ff614293ae37c6ba (patch)
treee7c96ff3e21bf85c59f2d9c50f6b3042b1c97269
parentc15ea73f960bbd3d2a4b0c43b467ac62eeba3505 (diff)
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@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--include/oox/core/xmlfilterbase.hxx6
-rw-r--r--oox/source/core/xmlfilterbase.cxx2
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx4
-rw-r--r--sc/source/filter/excel/excdoc.cxx3
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx4
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport3.cxx11
7 files changed, 26 insertions, 8 deletions
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