summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorsushil_shinde <sushil.shinde@synerzip.com>2013-12-27 14:34:03 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-01-10 12:21:16 +0000
commita37043b8d1508b3a3a2844e9092e4af05d726f28 (patch)
tree164b648c14b2fa5141d915c73f64813420de1580 /sw/source
parent0e114b9967ddfb490cd9865220520701004db7ab (diff)
fdo#72520 : Exporting embedding data folder from grab bag.
Change-Id: I3eeff18f0f39f97c2d0fc95eba427b478c95e80d Reviewed-on: https://gerrit.libreoffice.org/7213 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/docxexport.cxx62
-rw-r--r--sw/source/filter/ww8/docxexport.hxx3
2 files changed, 65 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index ece1c41ed1e2..e67b538cf1e0 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -400,6 +400,8 @@ void DocxExport::ExportDocument_Impl()
WriteActiveX();
+ WriteEmbeddings();
+
delete pStyles, pStyles = NULL;
delete m_pSections, m_pSections = NULL;
}
@@ -1105,6 +1107,66 @@ void DocxExport::WriteActiveX()
}
}
+void DocxExport::WriteEmbeddings()
+{
+ 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::Sequence< beans::PropertyValue > embeddingsList;
+ 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 == "OOXEmbeddings" )
+ {
+ propList[nProp].Value >>= embeddingsList;
+ break;
+ }
+ }
+ for (sal_Int32 j = 0; j < embeddingsList.getLength(); j++)
+ {
+ OUString embeddingPath = embeddingsList[j].Name;
+ uno::Reference<io::XInputStream> embeddingsStream;
+ embeddingsList[j].Value >>= embeddingsStream;
+ if ( embeddingsStream.is() )
+ {
+ uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream(embeddingPath,
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ try
+ {
+ sal_Int32 nBufferSize = 512;
+ uno::Sequence< sal_Int8 > aDataBuffer(nBufferSize);
+ sal_Int32 nRead;
+ do
+ {
+ nRead = embeddingsStream->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", "WriteEmbeddings() ::Failed to copy Inputstream to outputstream exception catched!");
+ }
+ xOutStream->closeOutput();
+ }
+ }
+}
+
VMLExport& DocxExport::VMLExporter()
{
return *m_pVMLExport;
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index abf22ebf2cdb..d371fa19042f 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -227,6 +227,9 @@ private:
/// Write word/activeX/activeX[n].xml
void WriteActiveX();
+ /// Write word/embeddings/Worksheet[n].xlsx
+ void WriteEmbeddings();
+
/// 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 );