summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Calc.xcs8
-rw-r--r--sc/source/filter/excel/expop2.cxx35
2 files changed, 39 insertions, 4 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index c3fa5239a712..8e1200ef5cbc 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1629,6 +1629,14 @@
<info>
<desc>Specifies how VBA macros are treated in Excel files.</desc>
</info>
+ <prop oor:name="UseExport" oor:type="xs:boolean" oor:nillable="false">
+ <!-- UIHints: Tools Options - Filter Settings Microsoft Office [Section] Microsoft Excel 97/2000 -->
+ <info>
+ <desc>Indicates whether VBA macros are exported through the vba export code.</desc>
+ <label>Export VBA</label>
+ </info>
+ <value>true</value>
+ </prop>
<prop oor:name="Load" oor:type="xs:boolean" oor:nillable="false">
<!-- OldPath: Filter/MS_Office/Basic/Excel -->
<!-- OldLocation: soffice.cfg -->
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 );