diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-08-24 23:56:54 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-09-10 04:14:48 +0200 |
commit | 8e06037b3f9d13a29a6ffd2f030e4360c7e1a30a (patch) | |
tree | 0ee8f69dc5beedd469ac8fe6c8504cbfea8bbc32 /sc | |
parent | 1f1ec819edc14ad266d49f16116056fd439b7c46 (diff) |
introduce mode to save vba stream also to xls files
Change-Id: Ic1066fa9492090e42d37ec487c2e9e8234de4375
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/excel/expop2.cxx | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/sc/source/filter/excel/expop2.cxx b/sc/source/filter/excel/expop2.cxx index b81e5d0eb154..ba08fb285eee 100644 --- a/sc/source/filter/excel/expop2.cxx +++ b/sc/source/filter/excel/expop2.cxx @@ -23,6 +23,8 @@ #include <sfx2/docinf.hxx> #include <filter/msfilter/svxmsbas.hxx> +#include <oox/ole/vbaexport.hxx> + #include "scerrors.hxx" #include "scextopt.hxx" @@ -38,9 +40,22 @@ #include "xltools.hxx" #include "xelink.hxx" +#include <officecfg/Office/Calc.hxx> + #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +namespace { + +enum class VBAExportMode +{ + NONE, + REEXPORT_STREAM, + FULL_EXPORT +}; + +} + ExportBiff5::ExportBiff5( XclExpRootData& rExpData, SvStream& rStrm ): ExportTyp( rStrm, &rExpData.mrDoc, rExpData.meTextEnc ), XclExpRoot( rExpData ) @@ -65,14 +80,26 @@ FltError ExportBiff5::Write() tools::SvRef<SotStorage> xRootStrg = GetRootStorage(); OSL_ENSURE( xRootStrg.Is(), "ExportBiff5::Write - no root storage" ); - bool bWriteBasicStrg = false; + VBAExportMode eVbaExportMode = VBAExportMode::NONE; if( GetBiff() == EXC_BIFF8 ) { - const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get(); - bWriteBasicStrg = rFilterOpt.IsLoadExcelBasicStorage(); + if (officecfg::Office::Calc::Filter::Import::VBA::UseExport::get()) + eVbaExportMode = VBAExportMode::FULL_EXPORT; + else + { + const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get(); + if (rFilterOpt.IsLoadExcelBasicStorage()) + eVbaExportMode = VBAExportMode::REEXPORT_STREAM; + } } - if( pDocShell && xRootStrg.Is() && bWriteBasicStrg ) + if ( pDocShell && xRootStrg.Is() && eVbaExportMode == VBAExportMode::FULL_EXPORT) + { + VbaExport aExport(pDocShell->GetModel()); + if (aExport.containsVBAProject()) + aExport.exportVBA(); + } + else if( pDocShell && xRootStrg.Is() && eVbaExportMode == VBAExportMode::REEXPORT_STREAM ) { SvxImportMSVBasic aBasicImport( *pDocShell, *xRootStrg ); sal_uLong nErr = aBasicImport.SaveOrDelMSVBAStorage( true, EXC_STORAGE_VBA_PROJECT ); |