Kaydet (Commit) bf5c4869 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

tdf#116283 oox customXml: Don't write the Relationship to DOCX files twice.

Change-Id: Id3da40138e86c142707e377aa897df372aacb704
Reviewed-on: https://gerrit.libreoffice.org/50947Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
Tested-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst c15ea73f
......@@ -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;
......
......@@ -841,8 +841,6 @@ void XmlFilterBase::exportDocumentProperties( const Reference< XDocumentProperti
writeAppProperties( *this, xProperties );
writeCustomProperties( *this, xProperties );
}
exportCustomFragments();
}
// protected ------------------------------------------------------------------
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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);
......
......@@ -358,9 +358,9 @@ void PowerPointExport::writeDocumentProperties()
uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
if (xDocProps.is())
{
exportDocumentProperties(xDocProps);
}
exportCustomFragments();
}
bool PowerPointExport::importDocument() throw()
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment