summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorDaniel Rentz [dr] <daniel.rentz@oracle.com>2010-09-17 15:28:21 +0200
committerDaniel Rentz [dr] <daniel.rentz@oracle.com>2010-09-17 15:28:21 +0200
commit1fd5a79a0b542ae5a97d45d14106fbcc1645cd22 (patch)
treebb93ce45d3d7f6b7a5d33129cc1fbacf95957ff3 /sc
parentmerged heads (diff)
downloadcore-1fd5a79a0b542ae5a97d45d14106fbcc1645cd22.tar.gz
core-1fd5a79a0b542ae5a97d45d14106fbcc1645cd22.zip
mib19: #163556# preserve VBA compatibility in ODF roundtrip
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx16
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx26
-rw-r--r--sc/source/filter/xml/xmlwrap.cxx20
-rw-r--r--sc/source/ui/vba/vbaworkbooks.cxx10
4 files changed, 48 insertions, 24 deletions
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index ca5403e3b18d..1d3cd65f9920 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -4338,15 +4338,20 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&
++nPropsToAdd;
}
+ bool bVBACompat = false;
uno::Reference <container::XNameAccess> xCodeNameAccess;
DBG_ASSERT( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" );
if( pDoc && pDoc->IsInVBAMode() )
{
+ // VBA compatibility mode
+ bVBACompat = true;
+ ++nPropsToAdd;
+ // code names
xCodeNameAccess = new XMLCodeNameProvider( pDoc );
- if( xCodeNameAccess.is() && xCodeNameAccess->hasElements() )
+ if( xCodeNameAccess->hasElements() )
++nPropsToAdd;
else
- xCodeNameAccess = 0;
+ xCodeNameAccess.clear();
}
if( nPropsToAdd > 0 )
@@ -4359,10 +4364,17 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>&
rProps[nCount].Value <<= aTrackedChangesKey.makeStringAndClear();
++nCount;
}
+ if( bVBACompat )
+ {
+ rProps[nCount].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VBACompatibilityMode"));
+ rProps[nCount].Value <<= bVBACompat;
+ ++nCount;
+ }
if( xCodeNameAccess.is() )
{
rProps[nCount].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScriptConfiguration"));
rProps[nCount].Value <<= xCodeNameAccess;
+ ++nCount;
}
}
}
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 269e1dd9a7e4..e83f68bb2bbd 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -2219,6 +2219,7 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa
{
sal_Int32 nCount(aConfigProps.getLength());
rtl::OUString sCTName(RTL_CONSTASCII_USTRINGPARAM("TrackedChangesProtectionKey"));
+ rtl::OUString sVBName(RTL_CONSTASCII_USTRINGPARAM("VBACompatibilityMode"));
rtl::OUString sSCName(RTL_CONSTASCII_USTRINGPARAM("ScriptConfiguration"));
for (sal_Int32 i = nCount - 1; i >= 0; --i)
{
@@ -2243,26 +2244,15 @@ void ScXMLImport::SetConfigurationSettings(const uno::Sequence<beans::PropertyVa
}
}
}
- else if (aConfigProps[i].Name == sSCName)
+ // store the following items for later use (after document is loaded)
+ else if ((aConfigProps[i].Name == sVBName) || (aConfigProps[i].Name == sSCName))
{
- uno::Type aType = aConfigProps[i].Value.getValueType();
- uno::Reference<beans::XPropertySet> xImportInfo =
- getImportInfo();
-
- if (xImportInfo.is() &&
- (aType.equals(getCppuType(
- (uno::Reference<container::XNameContainer> *)0 ) ) ||
- aType.equals(getCppuType(
- (uno::Reference<container::XNameAccess> *)0 ) ) ) )
+ uno::Reference< beans::XPropertySet > xImportInfo = getImportInfo();
+ if (xImportInfo.is())
{
- uno::Reference< beans::XPropertySetInfo > xPropertySetInfo =
- xImportInfo->getPropertySetInfo();
- if (xPropertySetInfo.is() &&
- xPropertySetInfo->hasPropertyByName(sSCName) )
- {
- xImportInfo->setPropertyValue(sSCName,
- aConfigProps[i].Value );
- }
+ uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = xImportInfo->getPropertySetInfo();
+ if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName(aConfigProps[i].Name))
+ xImportInfo->setPropertyValue( aConfigProps[i].Name, aConfigProps[i].Value );
}
}
}
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index dbe647bc433f..7721260367c9 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -65,6 +65,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/packages/zip/ZipIOException.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
#include <svx/xmleohlp.hxx>
#include <rtl/logfile.hxx>
@@ -426,6 +427,7 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
{ MAP_LEN( "StreamRelPath" ), 0, &::getCppuType( (rtl::OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
{ MAP_LEN( "StreamName" ), 0, &::getCppuType( (rtl::OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
{ MAP_LEN( "BuildId" ), 0, &::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
+ { MAP_LEN( "VBACompatibilityMode" ), 0, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
{ MAP_LEN( "ScriptConfiguration" ), 0, &::getCppuType((uno::Reference<container::XNameAccess> *)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
{ NULL, 0, 0, NULL, 0, 0 }
@@ -643,6 +645,24 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
uno::Reference <container::XNameAccess> xCodeNameAccess;
if( aAny >>= xCodeNameAccess )
XMLCodeNameProvider::set( xCodeNameAccess, &rDoc );
+
+ // VBA compatibility
+ bool bVBACompat = false;
+ if ( (xInfoSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VBACompatibilityMode"))) >>= bVBACompat) && bVBACompat )
+ {
+ /* Set library container to VBA compatibility mode, this
+ forces loading the Basic project, which in turn creates the
+ VBA Globals object and does all related initialization. */
+ if ( xModelSet.is() ) try
+ {
+ uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModelSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW );
+ xVBACompat->setVBACompatibilityMode( sal_True );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
}
// Don't test bStylesRetval and bMetaRetval, because it could be an older file which not contain such streams
diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx
index 194d3d1b9656..a9f1970be34e 100644
--- a/sc/source/ui/vba/vbaworkbooks.cxx
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -75,11 +75,15 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >&
ScDocShell* pShell = excel::getDocShell( xModel );
if ( pShell )
{
+ String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ pShell->GetBasicManager()->SetName( aPrjName );
+
+ /* Set library container to VBA compatibility mode. This will create
+ the VBA Globals object and store it in the Basic manager of the
+ document. */
uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer();
uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW );
xVBACompat->setVBACompatibilityMode( sal_True );
- String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
- pShell->GetBasicManager()->SetName( aPrjName );
if( xLibContainer.is() )
{
@@ -92,8 +96,6 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >&
{
uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW );
uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW);
- // bootstrap vbaglobals
- xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals")));
uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW );
// set up the module info for the workbook and sheets in the nealy created
// spreadsheet