summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-25 06:39:40 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-25 06:43:05 +0200
commitc52982e7410dc8457b0496ece681ff06f1d3596d (patch)
tree14391d21aff0684c9cb3763c29ec415c712a4863 /sc
parent14c521c879514006af72193c7f6546d954626f73 (diff)
better OOXML VBA export
Change-Id: If02aa26e974b0f16b45c5476234c6425fd128ae4
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/excel/xestream.cxx42
-rw-r--r--sc/source/filter/inc/xestream.hxx4
-rw-r--r--sc/source/filter/oox/excelfilter.cxx3
3 files changed, 31 insertions, 18 deletions
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 1595019fe3eb..716b360226f7 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -928,9 +928,10 @@ sax_fastparser::FSHelperPtr XclXmlUtils::WriteFontData( sax_fastparser::FSHelper
return pStream;
}
-XclExpXmlStream::XclExpXmlStream( const Reference< XComponentContext >& rCC )
+XclExpXmlStream::XclExpXmlStream( const Reference< XComponentContext >& rCC, bool bExportVBA )
: XmlFilterBase( rCC ),
- mpRoot( NULL )
+ mpRoot( NULL ),
+ mbExportVBA(bExportVBA)
{
}
@@ -1088,25 +1089,34 @@ bool XclExpXmlStream::exportDocument()
ScDocShell::GetViewData()->WriteExtOptions( mpRoot->GetExtDocOptions() );
OUString const workbook = "xl/workbook.xml";
+ const char* pWorkbookContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
+
+
+ if (mbExportVBA)
+ pWorkbookContentType = "application/vnd.ms-excel.sheet.macroEnabled.main+xml";
+
PushStream( CreateOutputStream( workbook, workbook,
Reference <XOutputStream>(),
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
+ pWorkbookContentType,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ) );
- VbaExport aExport(getModel());
- if (aExport.containsVBAProject())
+ if (mbExportVBA)
{
- SvMemoryStream aVbaStream(4096, 4096);
- tools::SvRef<SotStorage> pVBAStorage(new SotStorage(aVbaStream));
- aExport.exportVBA(pVBAStorage);
- aVbaStream.Seek(0);
- css::uno::Reference<css::io::XInputStream> xVBAStream(
- new utl::OInputStreamWrapper(aVbaStream));
- css::uno::Reference<css::io::XOutputStream> xVBAOutput =
- openFragmentStream("xl/vbaProject.bin", "VBA");
- comphelper::OStorageHelper::CopyInputToOutput(xVBAStream, xVBAOutput);
-
- addRelation(GetCurrentStream()->getOutputStream(), "http://schemas.microsoft.com/office/2006/relationships/vbaProject", "vbaProject.bin");
+ VbaExport aExport(getModel());
+ if (aExport.containsVBAProject())
+ {
+ SvMemoryStream aVbaStream(4096, 4096);
+ tools::SvRef<SotStorage> pVBAStorage(new SotStorage(aVbaStream));
+ aExport.exportVBA(pVBAStorage);
+ aVbaStream.Seek(0);
+ css::uno::Reference<css::io::XInputStream> xVBAStream(
+ new utl::OInputStreamWrapper(aVbaStream));
+ css::uno::Reference<css::io::XOutputStream> xVBAOutput =
+ openFragmentStream("xl/vbaProject.bin", "application/vnd.ms-office.vbaProject");
+ comphelper::OStorageHelper::CopyInputToOutput(xVBAStream, xVBAOutput);
+
+ addRelation(GetCurrentStream()->getOutputStream(), "http://schemas.microsoft.com/office/2006/relationships/vbaProject", "vbaProject.bin");
+ }
}
// destruct at the end of the block
diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index a4177dc70df1..dce1cd4cc85f 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -293,7 +293,7 @@ public:
class XclExpXmlStream : public oox::core::XmlFilterBase
{
public:
- XclExpXmlStream( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rCC );
+ XclExpXmlStream( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rCC, bool bExportVBA );
virtual ~XclExpXmlStream();
/** Returns the filter root data. */
@@ -374,6 +374,8 @@ private:
const XclExpRoot* mpRoot;
std::stack< sax_fastparser::FSHelperPtr > maStreams;
XclExpXmlPathToStateMap maOpenedStreamMap;
+
+ bool mbExportVBA;
};
#endif
diff --git a/sc/source/filter/oox/excelfilter.cxx b/sc/source/filter/oox/excelfilter.cxx
index 5771a9054005..ef992e78f7a1 100644
--- a/sc/source/filter/oox/excelfilter.cxx
+++ b/sc/source/filter/oox/excelfilter.cxx
@@ -158,8 +158,9 @@ sal_Bool SAL_CALL ExcelFilter::filter( const ::com::sun::star::uno::Sequence< ::
if ( isExportFilter() )
{
+ bool bExportVBA = exportVBA();
Reference< XExporter > xExporter(
- new XclExpXmlStream( getComponentContext() ) );
+ new XclExpXmlStream( getComponentContext(), bExportVBA ) );
Reference< XComponent > xDocument( getModel(), UNO_QUERY );
Reference< XFilter > xFilter( xExporter, UNO_QUERY );