[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/inc writerfilter/source
sw/qa/extras/ooxmlexport/data/tdf108269.docm|binary sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 12 +++ sw/source/filter/ww8/docxexport.cxx | 75 sw/source/filter/ww8/docxexport.hxx |3 writerfilter/inc/ooxml/OOXMLDocument.hxx|1 writerfilter/source/filter/WriterFilter.cxx |3 writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 75 writerfilter/source/ooxml/OOXMLDocumentImpl.hxx |4 + writerfilter/source/ooxml/OOXMLStreamImpl.hxx |3 9 files changed, 176 insertions(+) New commits: commit 8a59b30bb1af55f7afd8b98e4b60234f98d84c76 Author: Miklos VajnaDate: Fri Jun 2 18:41:38 2017 +0200 Related: tdf#108269 DOCM filter: preserve VBA stream This means 2 new streams when roundtripping DOCM files that actually have macros: word/vbaProject.bin and word/vbaData.xml (+ the relation pointing to the second from the first). Change-Id: Iba24eea4c5bca8f743a53027c71ed2aae48f1934 Reviewed-on: https://gerrit.libreoffice.org/38360 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/ooxmlexport/data/tdf108269.docm b/sw/qa/extras/ooxmlexport/data/tdf108269.docm new file mode 100644 index ..44e943531d30 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf108269.docm differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 0191b8a38023..a7aadf16549f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -93,6 +93,18 @@ DECLARE_SW_ROUNDTRIP_TEST(testBadDocm, "bad.docm", nullptr, DocmTest) CPPUNIT_ASSERT_EQUAL(OUString("MS Word 2007 XML VBA"), pTextDoc->GetDocShell()->GetMedium()->GetFilter()->GetName()); } +DECLARE_SW_ROUNDTRIP_TEST(testTdf108269, "tdf108269.docm", nullptr, DocmTest) +{ +if (!mbExported) +return; + +uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); +// This failed: VBA streams were not roundtripped via the doc-level +// grab-bag. +CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaProject.bin")); +CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaData.xml")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx") { // This was true, resulted in setting the blinking font effect. diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 57432c9add87..a57eb02915c8 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -77,6 +77,7 @@ #include #include #include +#include using namespace sax_fastparser; using namespace ::comphelper; @@ -464,6 +465,8 @@ void DocxExport::ExportDocument_Impl() WriteEmbeddings(); +WriteVBA(); + m_aLinkedTextboxesHelper.clear(); //final cleanup delete m_pStyles; m_pStyles = nullptr; @@ -1251,6 +1254,78 @@ void DocxExport::WriteActiveX() } } +void DocxExport::WriteVBA() +{ +uno::Reference xPropertySet(m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY); +if (!xPropertySet.is()) +return; + +uno::Reference xPropertySetInfo = xPropertySet->getPropertySetInfo(); +if (!xPropertySetInfo->hasPropertyByName(UNO_NAME_MISC_OBJ_INTEROPGRABBAG)) +return; + +uno::Sequence aGrabBag; +xPropertySet->getPropertyValue(UNO_NAME_MISC_OBJ_INTEROPGRABBAG) >>= aGrabBag; +uno::Sequence aVBA; +for (const auto& rProperty : aGrabBag) +{ +if (rProperty.Name == "OOXVBA") +rProperty.Value >>= aVBA; +} +if (!aVBA.hasElements()) +return; + +uno::Reference xProjectStream; +for (const auto& rProperty : aVBA) +{ +if (rProperty.Name == "ProjectStream") +{ +// First check for the project stream, this sets xProjectStream. +uno::Reference xInputStream; +rProperty.Value >>= xInputStream; +if (!xInputStream.is()) +return; +std::unique_ptr pIn(utl::UcbStreamHelper::CreateStream(xInputStream)); + +xProjectStream = GetFilter().openFragmentStream("word/vbaProject.bin", "application/vnd.ms-office.vbaProject"); +uno::Reference xOutputStream(xProjectStream, uno::UNO_QUERY); +if (!xOutputStream.is()) +return; +std::unique_ptr pOut(utl::UcbStreamHelper::CreateStream(xOutputStream)); + +// Write the stream. +pOut->WriteStream(*pIn); + +// Write the relationship. +m_pFilter->addRelation(m_pDocumentFS->getOutputStream(), "http://schemas.microsoft.com/office/2006/relationships/vbaProject;, "vbaProject.bin"); +} +else if (rProperty.Name == "DataStream") +{
[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/inc writerfilter/source
sw/qa/extras/ooxmlexport/data/activex.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx| 28 sw/source/filter/ww8/docxexport.cxx | 44 ++ sw/source/filter/ww8/docxexport.hxx |3 + writerfilter/inc/ooxml/OOXMLDocument.hxx|3 - writerfilter/source/filter/ImportFilter.cxx | 30 writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 56 writerfilter/source/ooxml/OOXMLDocumentImpl.hxx |3 + writerfilter/source/ooxml/OOXMLStreamImpl.cxx |6 ++ 9 files changed, 171 insertions(+), 2 deletions(-) New commits: commit f4714220903cbd657fbb4d103fb5293f5b8f7cf8 Author: sushil_shinde sushil.shi...@synerzip.com Date: Tue Nov 12 20:29:00 2013 +0530 [docx] activeX files saved in InteropGrabBag and exported. The XDocuments representing the DOM of an OOXML's activex document is stored as the PropertyValue OOXActiveX into the InteropGraBag. Added mxActiveXDomList object which holds xDocument for each activeX.xml from activeX folder. This changeset stores only activeX[n].xml files. Relationship files (example activeX.bin) from activex are not stored yet. (Working on it.) Reviewed on: https://gerrit.libreoffice.org/6654 Change-Id: I658e361211e1446ed095a73b0422da0c4f74df1c diff --git a/sw/qa/extras/ooxmlexport/data/activex.docx b/sw/qa/extras/ooxmlexport/data/activex.docx new file mode 100644 index 000..e7c15e8 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/activex.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index b622cb2..ce9a0a9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1587,6 +1587,34 @@ DECLARE_OOXML_TEST(testCustomXmlGrabBag, customxml.docx) CPPUNIT_ASSERT(CustomXml); // Grab Bag has all the expected elements } +DECLARE_OOXML_TEST(testActiveXGrabBag, activex.docx) +{ + // The problem was that activeX.xml files were missing from docx file after saving file. + // This test case tests whether activex files grabbagged properly in correct object. + + uno::Referencetext::XTextDocument xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Referencebeans::XPropertySet xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); + uno::Sequencebeans::PropertyValue aGrabBag(0); + xTextDocumentPropertySet-getPropertyValue(OUString(InteropGrabBag)) = aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + bool bActiveX = sal_False; + for(int i = 0; i aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == OOXActiveX) + { + bActiveX = sal_True; + uno::Referencexml::dom::XDocument aActiveXDom; + uno::Sequenceuno::Referencexml::dom::XDocument aActiveXDomList; + CPPUNIT_ASSERT(aGrabBag[i].Value = aActiveXDomList); // PropertyValue of proper type + sal_Int32 length = aActiveXDomList.getLength(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length); + aActiveXDom = aActiveXDomList[0]; + CPPUNIT_ASSERT(aActiveXDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements +} + DECLARE_OOXML_TEST(testFdo69644, fdo69644.docx) { // The problem was that the exporter exported the table definition diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 2df1a60..9053d6b 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -353,6 +353,8 @@ void DocxExport::ExportDocument_Impl() WriteCustomXml(); +WriteActiveX(); + delete pStyles, pStyles = NULL; delete m_pSections, m_pSections = NULL; } @@ -855,6 +857,48 @@ void DocxExport::WriteCustomXml() } } +void DocxExport::WriteActiveX() +{ +uno::Reference beans::XPropertySet xPropSet( pDoc-GetDocShell()-GetBaseModel(), uno::UNO_QUERY_THROW ); + +uno::Reference beans::XPropertySetInfo xPropSetInfo = xPropSet-getPropertySetInfo(); +OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG; +if ( !xPropSetInfo-hasPropertyByName( pName ) ) +return; + +uno::Sequenceuno::Referencexml::dom::XDocument activeXDomlist; +uno::Sequence beans::PropertyValue propList; +xPropSet-getPropertyValue( pName ) = propList; +for ( sal_Int32 nProp=0; nProp propList.getLength(); ++nProp ) +{ +OUString propName = propList[nProp].Name; +if ( propName == OOXActiveX ) +{ + propList[nProp].Value = activeXDomlist; + break; +} +} + +for (sal_Int32 j = 0; j activeXDomlist.getLength(); j++) +{ +uno::Referencexml::dom::XDocument activeXDom = activeXDomlist[j]; + +if ( activeXDom.is() ) +{ +m_pFilter-addRelation(
[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/inc writerfilter/source
sw/qa/extras/ooxmlexport/ooxmlexport.cxx|9 +- sw/source/filter/ww8/docxexport.cxx | 35 +- sw/source/filter/ww8/docxexport.hxx |2 writerfilter/inc/ooxml/OOXMLDocument.hxx|3 writerfilter/source/filter/ImportFilter.cxx |7 +- writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 77 ++-- writerfilter/source/ooxml/OOXMLDocumentImpl.hxx |5 + writerfilter/source/ooxml/OOXMLStreamImpl.cxx |4 + 8 files changed, 127 insertions(+), 15 deletions(-) New commits: commit 52ee03760e26e2ac7eb2561e96ab557ad287de58 Author: sushil_shinde sushil.shi...@synerzip.com Date: Thu Nov 7 10:45:03 2013 +0530 [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 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index e3f60a9..5c44dc8 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::Referencetext::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::Referencexml::dom::XDocument aCustomXmlDom; uno::Sequenceuno::Referencexml::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 fffa8e3..126e3ef 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -794,6 +794,7 @@ void DocxExport::WriteCustomXml() return; uno::Sequenceuno::Referencexml::dom::XDocument customXmlDomlist; +uno::Sequenceuno::Referencexml::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::Referencexml::dom::XDocument customXmlDom = customXmlDomlist[j]; +uno::Referencexml::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, +
[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/inc writerfilter/source
sw/qa/extras/ooxmlexport/data/customxml.docx|binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx| 28 sw/source/filter/ww8/docxexport.cxx | 43 +++ sw/source/filter/ww8/docxexport.hxx |1 writerfilter/inc/ooxml/OOXMLDocument.hxx|3 - writerfilter/source/filter/ImportFilter.cxx | 32 ++ writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 54 writerfilter/source/ooxml/OOXMLDocumentImpl.hxx |5 +- writerfilter/source/ooxml/OOXMLStreamImpl.cxx | 20 writerfilter/source/ooxml/OOXMLStreamImpl.hxx |3 + 10 files changed, 184 insertions(+), 5 deletions(-) New commits: commit 8ab553117e038ec1eab76ac1c3d8a0b5aa968baa Author: sushil_shinde sushil.shi...@synerzip.com Date: Fri Nov 1 19:21:01 2013 +0530 [docx] CustomXml saved in InteropGrabBag and exported customxml when saving. The XDocuments representing the DOM of an OOXML's customxml document is stored as the PropertyValue OOXCustomXml into the InteropGraBag. Added mxCustomXmlDomList object which holds xDocuments for each item.xml from CustomXml. Exporting all items dom tree from customxml that has been parsed when loading the file. This is necessary in order to properly reopen docx files that contain data like citation. This fix grab bags only item[n].xml's files from CustomXml folder. itemProps[n].xml's and item.xml's .rels are not preserved and exported yet. (Working on this part) Change-Id: I330f34f38a7aa4cd39094371bff15ebbc0318167 Reviewed-on: https://gerrit.libreoffice.org/6519 Reviewed-by: Miklos Vajna vmik...@collabora.co.uk Tested-by: Miklos Vajna vmik...@collabora.co.uk diff --git a/sw/qa/extras/ooxmlexport/data/customxml.docx b/sw/qa/extras/ooxmlexport/data/customxml.docx new file mode 100644 index 000..bfdf8ec Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/customxml.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index f8b7904..028189b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1506,6 +1506,34 @@ 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. + // This test case tests whether customxml files grabbagged properly in correct object. + + uno::Referencetext::XTextDocument xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Referencebeans::XPropertySet xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); + uno::Sequencebeans::PropertyValue aGrabBag(0); + xTextDocumentPropertySet-getPropertyValue(OUString(InteropGrabBag)) = aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + sal_Bool CustomXml = sal_False; + for(int i = 0; i aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == OUString(OOXCustomXml)) + { + CustomXml = sal_True; + uno::Referencexml::dom::XDocument aCustomXmlDom; + uno::Sequenceuno::Referencexml::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(aCustomXmlDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(CustomXml); // Grab Bag has all the expected elements +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 69fc7e9..40112cf 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -351,6 +351,8 @@ void DocxExport::ExportDocument_Impl() WriteTheme(); +WriteCustomXml(); + delete pStyles, pStyles = NULL; delete m_pSections, m_pSections = NULL; } @@ -782,6 +784,47 @@ void DocxExport::WriteTheme() uno::Sequence beans::StringPair () ); } +void DocxExport::WriteCustomXml() +{ +uno::Reference beans::XPropertySet xPropSet( pDoc-GetDocShell()-GetBaseModel(), uno::UNO_QUERY_THROW ); + +uno::Reference beans::XPropertySetInfo xPropSetInfo = xPropSet-getPropertySetInfo(); +OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG; +if ( !xPropSetInfo-hasPropertyByName( pName ) ) +return; + +uno::Sequenceuno::Referencexml::dom::XDocument customXmlDomlist; +uno::Sequence beans::PropertyValue propList; +xPropSet-getPropertyValue( pName ) = propList; +for ( sal_Int32 nProp=0; nProp propList.getLength(); ++nProp ) +{ +OUString propName = propList[nProp].Name; +if ( propName