diff options
author | sushil_shinde <sushil.shinde@synerzip.com> | 2013-11-07 10:45:03 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-13 10:27:28 +0100 |
commit | 52ee03760e26e2ac7eb2561e96ab557ad287de58 (patch) | |
tree | 6d2cfbb823dee012397eb9055c86e0462e64cd2e /sw | |
parent | 97747499b26314bb308b12cd331bf0d99f21c96c (diff) |
[docx] CustomXml relationship files saved in InteropGrabBag and exported.
The XDocuments representing the DOM of an OOXML's customxml property
document is stored as the PropertyValue "OOXCustomXmlProps" into the
"InteropGraBag".
Added mxCustomXmlDomPropList object which holds xDocument for each
itemProps.xml from relationship of item.xml.
Exporting all itemprops files from customxml.
Reviewed on:
https://gerrit.libreoffice.org/6603
Change-Id: I3973e6ce40382bbc4da247b5b27d99b03e851744
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 35 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.hxx | 2 |
3 files changed, 39 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index e3f60a94ca68..5c44dc818fd4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1534,7 +1534,8 @@ DECLARE_OOXML_TEST(testCharHighlight, "char_highlight.docx") DECLARE_OOXML_TEST(testCustomXmlGrabBag, "customxml.docx") { - // The problem was that CustomXml/item[n].xml files were missing from docx file after saving file. + // The problem was that item[n].xml and itemProps[n].xml and .rels files for item[n].xml + // files were missing from docx file after saving file. // This test case tests whether customxml files grabbagged properly in correct object. uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); @@ -1545,15 +1546,15 @@ DECLARE_OOXML_TEST(testCustomXmlGrabBag, "customxml.docx") sal_Bool CustomXml = sal_False; for(int i = 0; i < aGrabBag.getLength(); ++i) { - if (aGrabBag[i].Name == OUString("OOXCustomXml")) + if (aGrabBag[i].Name == "OOXCustomXml" || aGrabBag[i].Name == "OOXCustomXmlProps") { CustomXml = sal_True; uno::Reference<xml::dom::XDocument> aCustomXmlDom; uno::Sequence<uno::Reference<xml::dom::XDocument> > aCustomXmlDomList; CPPUNIT_ASSERT(aGrabBag[i].Value >>= aCustomXmlDomList); // PropertyValue of proper type sal_Int32 length = aCustomXmlDomList.getLength(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), length); - aCustomXmlDom = aCustomXmlDomList[1]; + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length); + aCustomXmlDom = aCustomXmlDomList[0]; CPPUNIT_ASSERT(aCustomXmlDom.get()); // Reference not empty } } diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index fffa8e3c8916..126e3ef31e33 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -794,6 +794,7 @@ void DocxExport::WriteCustomXml() return; uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomlist; + uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomPropslist; uno::Sequence< beans::PropertyValue > propList; xPropSet->getPropertyValue( pName ) >>= propList; for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp ) @@ -806,23 +807,51 @@ void DocxExport::WriteCustomXml() } } - for (sal_Int32 j = 1; j < customXmlDomlist.getLength(); j++) + for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp ) { + OUString propName = propList[nProp].Name; + if ( propName == "OOXCustomXmlProps" ) + { + propList[nProp].Value >>= customXmlDomPropslist; + break; + } + } + + for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++) { uno::Reference<xml::dom::XDocument> customXmlDom = customXmlDomlist[j]; + uno::Reference<xml::dom::XDocument> customXmlDomProps = customXmlDomPropslist[j]; if ( customXmlDom.is() ) { m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml", - "../customXml/item"+OUString::number(j)+".xml" ); + "../customXml/item"+OUString::number((j+1))+".xml" ); uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDom, uno::UNO_QUERY ); uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); - writer->setOutputStream( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j)+".xml", + writer->setOutputStream( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml", "application/xml" ) ); serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), uno::Sequence< beans::StringPair >() ); } + + if ( customXmlDomProps.is() ) + { + + uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDomProps, uno::UNO_QUERY ); + uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); + writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number((j+1))+".xml", + "application/vnd.openxmlformats-officedocument.customXmlProperties+xml" ) ); + serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), + uno::Sequence< beans::StringPair >() ); + + // Adding itemprops's relationship entry to item.xml.rels file + m_pFilter->addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml", + "application/xml" ) , + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", + "itemProps"+OUString::number((j+1))+".xml" ); + + } } } diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 531dcc511e5c..8c2f958e36b5 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -207,7 +207,9 @@ private: /// Write word/theme/theme1.xml void WriteTheme(); + /// Write customXml/item[n].xml and customXml/itemProps[n].xml void WriteCustomXml(); + /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...) sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer ); |