summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorsushil_shinde <sushil.shinde@synerzip.com>2013-11-15 12:20:36 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-15 18:40:33 +0100
commitb8a4abdda4e6a95535992c26a906226ede7f050a (patch)
tree2ede37f746ea38fd7a233635fa65f0ca3b85bec3 /sw
parent9fbdb2b8a71e195ac2aa68740e66e84316b08ed7 (diff)
[docx] activeX reference files (.bin) saved in InteropGrabBag and exported.
The XInputStream for activeX.bin files is stored as the PropertyValue "OOXActiveXBin" into the "InteropGraBag" Added mxActiveXBinList object which holds XInputStreams for each activeX.bin from activeX folder. Added .bin files entry to respective acivex.xml's .rels file. Added Unit Test to test all .bin files are stores properly. Reviewed on: https://gerrit.libreoffice.org/6679 Change-Id: I3a0e9462a6cc53d8cbb9c7d59ed24631d77d4d30
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/activexbin.docxbin0 -> 363044 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx28
-rw-r--r--sw/source/filter/ww8/docxexport.cxx54
3 files changed, 81 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/activexbin.docx b/sw/qa/extras/ooxmlexport/data/activexbin.docx
new file mode 100644
index 000000000000..e7c15e81cfb7
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/activexbin.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 66a24c57dd53..18a00310e760 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1617,6 +1617,34 @@ DECLARE_OOXML_TEST(testActiveXGrabBag, "activex.docx")
CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements
}
+DECLARE_OOXML_TEST(testActiveXBinGrabBag, "activexbin.docx")
+{
+ // The problem was that activeX.bin files were missing from docx file after saving file.
+ // This test case tests whether activex bin files grabbagged properly in correct object.
+
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
+ uno::Sequence<beans::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 == "OOXActiveXBin")
+ {
+ bActiveX = sal_True;
+ uno::Reference<io::XInputStream> aActiveXBin;
+ uno::Sequence<uno::Reference<io::XInputStream> > aActiveXBinList;
+ CPPUNIT_ASSERT(aGrabBag[i].Value >>= aActiveXBinList); // PropertyValue of proper type
+ sal_Int32 length = aActiveXBinList.getLength();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length);
+ aActiveXBin = aActiveXBinList[0];
+ CPPUNIT_ASSERT(aActiveXBin.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 9053d6b5719c..e29cd64f0b8c 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -867,6 +867,7 @@ void DocxExport::WriteActiveX()
return;
uno::Sequence<uno::Reference<xml::dom::XDocument> > activeXDomlist;
+ uno::Sequence<uno::Reference<io::XInputStream> > activeXBinList;
uno::Sequence< beans::PropertyValue > propList;
xPropSet->getPropertyValue( pName ) >>= propList;
for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
@@ -879,9 +880,20 @@ void DocxExport::WriteActiveX()
}
}
+ for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
+ {
+ OUString propName = propList[nProp].Name;
+ if ( propName == "OOXActiveXBin" )
+ {
+ propList[nProp].Value >>= activeXBinList;
+ break;
+ }
+ }
+
for (sal_Int32 j = 0; j < activeXDomlist.getLength(); j++)
{
uno::Reference<xml::dom::XDocument> activeXDom = activeXDomlist[j];
+ uno::Reference<io::XInputStream> activeXBin = activeXBinList[j];
if ( activeXDom.is() )
{
@@ -895,7 +907,47 @@ void DocxExport::WriteActiveX()
"application/vnd.ms-office.activeX+xml" ) );
serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
uno::Sequence< beans::StringPair >() );
- }
+ }
+
+ if ( activeXBin.is() )
+ {
+ uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream("word/activeX/activeX"+OUString::number((j+1))+".bin",
+ "application/vnd.ms-office.activeX");
+
+ try
+ {
+ sal_Int32 nBufferSize = 512;
+ uno::Sequence< sal_Int8 > aDataBuffer(nBufferSize);
+ sal_Int32 nRead;
+ do
+ {
+ nRead = activeXBin->readBytes( aDataBuffer, nBufferSize );
+ if( nRead )
+ {
+ if( nRead < nBufferSize )
+ {
+ nBufferSize = nRead;
+ aDataBuffer.realloc(nRead);
+ }
+ xOutStream->writeBytes( aDataBuffer );
+ }
+ }
+ while( nRead );
+ xOutStream->flush();
+ }
+ catch(const uno::Exception&)
+ {
+ SAL_WARN("sw.ww8", "WriteActiveX() ::Failed to copy Inputstream to outputstream exception catched!");
+ }
+
+ xOutStream->closeOutput();
+ // Adding itemprops's relationship entry to item.xml.rels file
+ m_pFilter->addRelation( GetFilter().openFragmentStream( "/word/activeX/activeX"+OUString::number((j+1))+".xml",
+ "application/vnd.ms-office.activeX+xml" ) ,
+ "http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary",
+ "activeX"+OUString::number((j+1))+".bin" );
+
+ }
}
}