From aac4d6a3a645d3c11e4094a2c5ca701810e6df07 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 12:39:31 +0000 Subject: npower13_objectmodule: #i109734# object module stuff --- sc/inc/document.hxx | 2 + sc/inc/servuno.hxx | 5 +- sc/source/core/data/documen2.cxx | 37 ++++++++++ sc/source/core/data/document.cxx | 12 +++- sc/source/filter/excel/excimp8.cxx | 9 +-- sc/source/filter/excel/read.cxx | 2 +- sc/source/ui/docshell/docfunc.cxx | 139 ++++++++++++++++++++++++++++++++++++- sc/source/ui/docshell/docsh5.cxx | 40 +++++++++++ sc/source/ui/unoobj/servuno.cxx | 123 +++++++++++++++++++++++++++++++- sc/source/ui/view/viewfun2.cxx | 17 +++++ 10 files changed, 376 insertions(+), 10 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 44bda96f8322..48b98a7551af 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1716,6 +1716,8 @@ public: { return eStorageGrammar; } SfxUndoManager* GetUndoManager(); + bool IsInVBAMode() const; + private: // CLOOK-Impl-Methoden /** diff --git a/sc/inc/servuno.hxx b/sc/inc/servuno.hxx index 785e5e4049d0..a8159da5158f 100644 --- a/sc/inc/servuno.hxx +++ b/sc/inc/servuno.hxx @@ -90,9 +90,10 @@ class ScDocShell; #define SC_SERVICE_FORMULAPARS 38 #define SC_SERVICE_OPCODEMAPPER 39 -#define SC_SERVICE_VBACODENAMEPROVIDER 40 +#define SC_SERVICE_VBAOBJECTPROVIDER 40 +#define SC_SERVICE_VBACODENAMEPROVIDER 41 -#define SC_SERVICE_COUNT 41 +#define SC_SERVICE_COUNT 42 #define SC_SERVICE_INVALID USHRT_MAX diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index c08fb7a10228..ce3bf4df3490 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -93,6 +93,7 @@ #include "tabprotection.hxx" #include "formulaparserpool.hxx" #include "clipparam.hxx" +#include // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and // dtor plus helpers are convenient. @@ -934,6 +935,8 @@ BOOL ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM return bValid; } +void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource ); + ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos, BOOL bInsertNew, BOOL bResultsOnly ) @@ -1104,6 +1107,40 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, } if (!bValid) nRetVal = 0; + SfxObjectShell* pDestShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL; + StarBASIC* pStarBASIC = pDestShell ? pDestShell->GetBasic() : NULL; + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( pDestShell && pDestShell->GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = pDestShell->GetBasicManager()->GetName(); + pStarBASIC = pDestShell->GetBasicManager()->GetLib( aLibName ); + } + + BOOL bVbaEnabled = IsInVBAMode(); + + if ( bVbaEnabled && pDestShell ) + { + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pDestShell->GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + + if( xLib.is() ) + { + String sSrcCodeName; + pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName ); + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( *this, nDestPos, sCodeName, sSource ); + } + return nRetVal; } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index fa4fb296d9a7..3424df4824af 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -51,6 +51,7 @@ #include #include +#include #include "document.hxx" #include "table.hxx" @@ -4963,4 +4964,13 @@ void ScDocument::EnableUndo( bool bVal ) mbUndoEnabled = bVal; } - +bool ScDocument::IsInVBAMode() const +{ + bool bResult = false; + if ( pShell ) + { + com::sun::star::uno::Reference< com::sun::star::script::XVBACompat > xVBA( pShell->GetBasicContainer(), com::sun::star::uno::UNO_QUERY ); + bResult = xVBA->getVBACompatModeOn(); + } + return bResult; +} diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index e424ad2d95fe..19df7c2520c1 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -104,7 +104,6 @@ #include #include - using namespace com::sun::star; @@ -257,8 +256,6 @@ void ImportExcel8::SheetProtection( void ) void ImportExcel8::ReadBasic( void ) { - bHasBasic = TRUE; - SfxObjectShell* pShell = GetDocShell(); SotStorageRef xRootStrg = GetRootStorage(); SvtFilterOptions* pFilterOpt = SvtFilterOptions::Get(); @@ -271,7 +268,7 @@ void ImportExcel8::ReadBasic( void ) { SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg ); bool bAsComment = !bLoadExecutable; - aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment ); + aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment ); } } } @@ -286,6 +283,10 @@ void ImportExcel8::EndSheet( void ) void ImportExcel8::PostDocLoad( void ) { + // delay reading basic until sheet object ( codenames etc. ) are read + + if ( bHasBasic ) + ReadBasic(); // #i11776# filtered ranges before outlines and hidden rows if( pExcRoot->pAutoFilterBuffer ) pExcRoot->pAutoFilterBuffer->Apply(); diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx index 91b749030dd7..9c99c9a0a6c6 100644 --- a/sc/source/filter/excel/read.cxx +++ b/sc/source/filter/excel/read.cxx @@ -983,7 +983,7 @@ FltError ImportExcel8::Read( void ) case 0x22: Rec1904(); break; // 1904 [ 2345 ] case 0x56: Builtinfmtcnt(); break; // BUILTINFMTCNT[ 34 ] case 0x8D: Hideobj(); break; // HIDEOBJ [ 345 ] - case 0xD3: ReadBasic(); break; + case 0xD3: bHasBasic = true; break; case 0xDE: Olesize(); break; case 0x01BA: Codename( TRUE ); break; diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index cd28daa99401..3b735c061cab 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -48,6 +48,12 @@ #include #include +#include +#include +#include +#include +#include + #include #include "docfunc.hxx" @@ -94,6 +100,7 @@ #include "clipparam.hxx" #include +#include using namespace com::sun::star; using ::com::sun::star::uno::Sequence; @@ -2576,6 +2583,106 @@ BOOL ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, } //------------------------------------------------------------------------ +uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, String& sCodeName ) +{ + uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY); + uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess; + uno::Reference< uno::XInterface > xDocModuleApiObject; + if ( xSF.is() ) + { + xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY ); + xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY ); + } + return xDocModuleApiObject; + +} + +script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule ) +{ + ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); + script::ModuleInfo sModuleInfo; + sModuleInfo.ModuleType = script::ModuleType::Document; + sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule ); + return sModuleInfo; +} + +void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sSource ) +{ + SFX_APP()->EnterBasicCall(); + SfxObjectShell& rDocSh = *rDoc.GetDocumentShell(); + uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer(); + DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" ); + + uno::Reference< container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() ) + aLibName = rDocSh.GetBasicManager()->GetName(); + uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + // if the Module with codename exists then find a new name + sal_Int32 nNum = 0; + String genModuleName; + if ( sModuleName.Len() ) + sModuleName = sModuleName; + else + { + genModuleName = String::CreateFromAscii( "Sheet1" ); + nNum = 1; + } + while( xLib->hasByName( genModuleName ) ) + genModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( ++nNum ); + + uno::Any aSourceAny; + rtl::OUString sTmpSource = sSource; + if ( sTmpSource.getLength() == 0 ) + sTmpSource = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); + aSourceAny <<= sTmpSource; + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); + if ( xVBAModuleInfo.is() ) + { + String sCodeName( genModuleName ); + rDoc.SetCodeName( nTab, sCodeName ); + script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, genModuleName ); + xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo ); + xLib->insertByName( genModuleName, aSourceAny ); + } + + } + SFX_APP()->LeaveBasicCall(); +} + +void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName ) +{ + SFX_APP()->EnterBasicCall(); + uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer(); + DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" ); + + uno::Reference< container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() ) + aLibName = rDocSh.GetBasicManager()->GetName(); + uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); + if( xLib->hasByName( sModuleName ) ) + xLib->removeByName( sModuleName ); + if ( xVBAModuleInfo.is() ) + xVBAModuleInfo->removeModuleInfo( sModuleName ); + + } + SFX_APP()->LeaveBasicCall(); +} + BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi ) { @@ -2585,8 +2692,19 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL ScDocShellModificator aModificator( rDocShell ); ScDocument* pDoc = rDocShell.GetDocument(); - if (bRecord && !pDoc->IsUndoEnabled()) + + + // Strange loop, also basic is loaded too early ( InsertTable ) + // is called via the xml import for sheets in described in odf + BOOL bInsertDocModule = false; + + if( !rDocShell.GetDocument()->IsImportingXML() ) + { + bInsertDocModule = pDoc ? pDoc->IsInVBAMode() : false; + } + if ( bInsertDocModule || ( bRecord && !pDoc->IsUndoEnabled() ) ) bRecord = FALSE; + if (bRecord) pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage @@ -2597,10 +2715,17 @@ BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL if (pDoc->InsertTab( nTab, rName )) { + String sCodeName; if (bRecord) rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName)); // Views updaten: + // Only insert vba modules if vba mode ( and not currently importing XML ) + if( bInsertDocModule ) + { + String sSource; + VBA_InsertModule( *pDoc, nTab, sCodeName, sSource ); + } rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) ); rDocShell.PostPaintExtras(); @@ -2622,8 +2747,11 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ ) BOOL bSuccess = FALSE; ScDocument* pDoc = rDocShell.GetDocument(); + BOOL bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : false; if (bRecord && !pDoc->IsUndoEnabled()) bRecord = FALSE; + if ( bVbaEnabled ) + bRecord = FALSE; BOOL bWasLinked = pDoc->IsLinked(nTab); ScDocument* pUndoDoc = NULL; ScRefUndoData* pUndoData = NULL; @@ -2664,6 +2792,8 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ ) pUndoData = new ScRefUndoData( pDoc ); } + String sCodeName; + BOOL bHasCodeName = pDoc->GetCodeName( nTab, sCodeName ); if (pDoc->DeleteTab( nTab, pUndoDoc )) { if (bRecord) @@ -2674,6 +2804,13 @@ BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ ) new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData )); } // Views updaten: + if( bVbaEnabled ) + { + if( bHasCodeName ) + { + VBA_DeleteModule( rDocShell, sCodeName ); + } + } rDocShell.Broadcast( ScTablesHint( SC_TAB_DELETED, nTab ) ); if (bWasLinked) diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 6fa6a5ac7863..06d7cab0d14d 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -65,6 +65,11 @@ #include "sc.hrc" #include "waitoff.hxx" #include "sizedev.hxx" +#include +#include + +// defined in docfunc.cxx +void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource ); // --------------------------------------------------------------------------- @@ -846,6 +851,8 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec if (bRecord) aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions + String sSrcCodeName; + aDocument.GetCodeName( nSrcTab, sSrcCodeName ); if (!aDocument.CopyTab( nSrcTab, nDestTab )) { //! EndDrawUndo? @@ -869,6 +876,39 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec GetUndoManager()->AddUndoAction( new ScUndoCopyTab( this, aSrcList, aDestList ) ); } + + StarBASIC* pStarBASIC = GetBasic(); + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = GetBasicManager()->GetName(); + pStarBASIC = GetBasicManager()->GetLib( aLibName ); + } + BOOL bVbaEnabled = aDocument.IsInVBAMode(); + SCTAB nTabToUse = nDestTab; + + if ( nDestTab == SC_TAB_APPEND ) + nTabToUse = aDocument.GetMaxTableNumber() - 1; + + if ( bVbaEnabled ) + { + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); + } } Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index 0c57963a4f12..d69659b41f11 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -64,9 +64,121 @@ #include #include #include - using namespace ::com::sun::star; +#ifndef CWS_NPOWER14MISCFIXES +#include +uno::Reference< uno::XInterface > lcl_createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException) +{ + uno::Any aUnoVar; + if ( !pShell || !pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) ) + throw lang::IllegalArgumentException(); + uno::Reference< lang::XMultiServiceFactory > xVBAFactory( aUnoVar, uno::UNO_QUERY_THROW ); + ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); + uno::Reference< uno::XInterface > xIf = xVBAFactory->createInstanceWithArguments( sVarName, aArgs ); + return xIf; +} +#endif + +class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess > +{ + uno::Any maWorkbook; + uno::Any maCachedObject; + ScDocShell* mpDocShell; +public: + ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) + { + ScDocument* pDoc = mpDocShell->GetDocument(); + if ( !pDoc ) + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() ); + + uno::Sequence< uno::Any > aArgs(2); + aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); + aArgs[1] = uno::Any( mpDocShell->GetModel() ); +#ifdef CWS_NPOWER14MISCFIXES + maWorkbook <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); +#else + maWorkbook <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); +#endif + } + + virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException ) + { + maCachedObject = uno::Any(); // clear cached object + String sName = aName; + + ScDocument* pDoc = mpDocShell->GetDocument(); + if ( !pDoc ) + throw uno::RuntimeException(); + if ( sName == pDoc->GetCodeName() ) + maCachedObject = maWorkbook; + else + { + String sCodeName; + SCTAB nCount = pDoc->GetTableCount(); + for( SCTAB i = 0; i < nCount; i++ ) + { + pDoc->GetCodeName( i, sCodeName ); + if( sCodeName == sName ) + { + String sSheetName; + if( pDoc->GetName( i, sSheetName ) ) + { + uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() ); + uno::Reference xSpreadDoc( xModel, uno::UNO_QUERY_THROW ); + uno::Reference xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Any > aArgs(3); + aArgs[0] = maWorkbook; + aArgs[1] = uno::Any( xModel ); + aArgs[2] = uno::Any( rtl::OUString( sSheetName ) ); +#ifdef CWS_NPOWER14MISCFIXES + // use the convience function + maCachedObject <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); +#else + // use the temp function + maCachedObject <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); +#endif + break; + } + } + } + } + return maCachedObject.hasValue(); + + } + ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + OSL_TRACE("ScVbaObjectForCodeNameProvider::getByName( %s )", + rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if ( !hasByName( aName ) ) + throw ::com::sun::star::container::NoSuchElementException(); + return maCachedObject; + } + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException) + { + ScDocument* pDoc = mpDocShell->GetDocument(); + if ( !pDoc ) + throw uno::RuntimeException(); + SCTAB nCount = pDoc->GetTableCount(); + uno::Sequence< rtl::OUString > aNames( nCount + 1 ); + SCTAB index = 0; + String sCodeName; + for( ; index < nCount; ++index ) + { + pDoc->GetCodeName( index, sCodeName ); + aNames[ index ] = sCodeName; + } + aNames[ index ] = pDoc->GetCodeName(); + return aNames; + } + // XElemenAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); } + virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException ) { return sal_True; } + +}; + class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery > { ScDocShell* mpDocShell; @@ -172,6 +284,7 @@ static const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { SC_SERVICENAME_CHDATAPROV, SC_SERVICE_CHDATAPROV }, { SC_SERVICENAME_FORMULAPARS, SC_SERVICE_FORMULAPARS }, { SC_SERVICENAME_OPCODEMAPPER, SC_SERVICE_OPCODEMAPPER }, + { "ooo.vba.VBAObjectModuleObjectProvider", SC_SERVICE_VBAOBJECTPROVIDER }, // SC_SERVICE_VBAOBJECTPROVIDER { "ooo.vba.VBACodeNameProvider", SC_SERVICE_VBACODENAMEPROVIDER }, // case-correct versions of the service names (#i102468#) @@ -235,6 +348,7 @@ static const sal_Char* __FAR_DATA aOldNames[SC_SERVICE_COUNT] = "", // SC_SERVICE_CHDATAPROV "", // SC_SERVICE_FORMULAPARS "", // SC_SERVICE_OPCODEMAPPER + "", // SC_SERVICE_VBAOBJECTPROVIDER "", // SC_SERVICE_VBACODENAMEPROVIDER }; @@ -440,6 +554,13 @@ uno::Reference ScServiceProvider::MakeInstance( xRet.set(static_cast(new ScFormulaOpCodeMapperObj(::std::auto_ptr (pComp)))); break; } + case SC_SERVICE_VBAOBJECTPROVIDER: + if ( pDocShell ) + { + OSL_TRACE("**** creating VBA Object mapper"); + xRet.set(static_cast(new ScVbaObjectForCodeNameProvider( pDocShell ))); + } + break; case SC_SERVICE_VBACODENAMEPROVIDER: { // Only create the excel faking service for excel docs diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 627f214c4ec6..4c0d14d620bc 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -86,6 +86,13 @@ #include "funcdesc.hxx" #include "docuno.hxx" +#include +#include +#include +using namespace com::sun::star; + +// helper func defined in docfunc.cxx +void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName ); // STATIC DATA --------------------------------------------------------------- @@ -2140,6 +2147,7 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord ) { ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocument* pDoc = pDocSh->GetDocument(); + BOOL bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : FALSE; SCTAB nNewTab = TheTabs[0]; int i; WaitObject aWait( GetFrameWin() ); @@ -2211,9 +2219,18 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord ) for(i=TheTabs.Count()-1;i>=0;i--) { + String sCodeName; + BOOL bHasCodeName = pDoc->GetCodeName( TheTabs[sal::static_int_cast(i)], sCodeName ); if (pDoc->DeleteTab( TheTabs[sal::static_int_cast(i)], pUndoDoc )) { bDelDone = TRUE; + if( bVbaEnabled ) + { + if( bHasCodeName ) + { + VBA_DeleteModule( *pDocSh, sCodeName ); + } + } pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast(i)] ) ); } } -- cgit v1.2.3 From 6b5831d19fcb6eef490521badec23f460bb01958 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 2 Mar 2010 16:13:21 +0000 Subject: npower13_objectmodule: #i109734# resolve macros after basic is loaded, fix error with 'Me' rtlfunc --- sc/source/filter/excel/xiescher.cxx | 6 +++--- sc/source/filter/excel/xlescher.cxx | 15 +++++++++++---- sc/source/filter/inc/xlescher.hxx | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index e963495a3f4b..adb4a5d34107 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -486,14 +486,14 @@ void XclImpDrawObjBase::ProcessSdrObject( SdrObject& rSdrObj ) const { if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) ) { - pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName ) ); + pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName, GetDocShell() ) ); pInfo->SetHlink( maHyperlink ); } } #else if( mbSimpleMacro && (maMacroName.Len() > 0) ) if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) ) - pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName ) ); + pInfo->SetMacro( XclControlHelper::GetScMacroName( maMacroName, GetDocShell() ) ); #endif // call virtual function for object type specific processing @@ -1939,7 +1939,7 @@ void XclImpTbxObjBase::SetDffProperties( const DffPropSet& rDffPropSet ) bool XclImpTbxObjBase::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor ) const { - return XclControlHelper::FillMacroDescriptor( rDescriptor, DoGetEventType(), GetMacroName() ); + return XclControlHelper::FillMacroDescriptor( rDescriptor, DoGetEventType(), GetMacroName(), GetDocShell() ); } void XclImpTbxObjBase::ConvertFont( ScfPropertySet& rPropSet ) const diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx index 5d74346608fd..882340b4220e 100644 --- a/sc/source/filter/excel/xlescher.cxx +++ b/sc/source/filter/excel/xlescher.cxx @@ -35,6 +35,7 @@ #include "document.hxx" #include "xistream.hxx" #include "xlescher.hxx" +#include using ::rtl::OUString; using ::com::sun::star::uno::Reference; @@ -298,10 +299,16 @@ Reference< XControlModel > XclControlHelper::GetControlModel( Reference< XShape #define EXC_MACRONAME_PRE "vnd.sun.star.script:Standard." #define EXC_MACRONAME_SUF "?language=Basic&location=document" -OUString XclControlHelper::GetScMacroName( const String& rXclMacroName ) +OUString XclControlHelper::GetScMacroName( const String& rXclMacroName, SfxObjectShell* pDocShell ) { + String sTmp( rXclMacroName ); if( rXclMacroName.Len() > 0 ) - return CREATE_OUSTRING( EXC_MACRONAME_PRE ) + rXclMacroName + CREATE_OUSTRING( EXC_MACRONAME_SUF ); + { + ooo::vba::VBAMacroResolvedInfo aMacro = ooo::vba::resolveVBAMacro( pDocShell, rXclMacroName, false ); + if ( aMacro.IsResolved() ) + return ooo::vba::makeMacroURL( aMacro.ResolvedMacro() ); + + } return OUString(); } @@ -335,14 +342,14 @@ spTbxListenerData[] = #define EXC_MACROSCRIPT "Script" bool XclControlHelper::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor, - XclTbxEventType eEventType, const String& rXclMacroName ) + XclTbxEventType eEventType, const String& rXclMacroName, SfxObjectShell* pShell ) { if( rXclMacroName.Len() > 0 ) { rDescriptor.ListenerType = OUString::createFromAscii( spTbxListenerData[ eEventType ].mpcListenerType ); rDescriptor.EventMethod = OUString::createFromAscii( spTbxListenerData[ eEventType ].mpcEventMethod ); rDescriptor.ScriptType = CREATE_OUSTRING( EXC_MACROSCRIPT ); - rDescriptor.ScriptCode = GetScMacroName( rXclMacroName ); + rDescriptor.ScriptCode = GetScMacroName( rXclMacroName, pShell ); return true; } return false; diff --git a/sc/source/filter/inc/xlescher.hxx b/sc/source/filter/inc/xlescher.hxx index f60d6d3a5ee5..698faa966fd3 100644 --- a/sc/source/filter/inc/xlescher.hxx +++ b/sc/source/filter/inc/xlescher.hxx @@ -429,7 +429,7 @@ public: GetControlModel( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ); /** Returns the Calc macro name from an Excel macro name. */ - static ::rtl::OUString GetScMacroName( const String& rXclMacroName ); + static ::rtl::OUString GetScMacroName( const String& rXclMacroName, SfxObjectShell* pShell = NULL ); /** Returns the Excel macro name from a Calc macro name. */ static String GetXclMacroName( const ::rtl::OUString& rScMacroName ); @@ -437,7 +437,7 @@ public: static bool FillMacroDescriptor( ::com::sun::star::script::ScriptEventDescriptor& rDescriptor, XclTbxEventType eEventType, - const String& rXclMacroName ); + const String& rXclMacroName, SfxObjectShell* pShell = NULL ); /** Tries to extract an Excel macro name from the passed macro descriptor. */ static String ExtractFromMacroDescriptor( const ::com::sun::star::script::ScriptEventDescriptor& rDescriptor, -- cgit v1.2.3 From 3227fc50dc89c295f31bdca8eead66798058c915 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 16:47:55 +0000 Subject: npower13_objectmodule: some cleanup --- sc/source/ui/docshell/docsh5.cxx | 61 +++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 06d7cab0d14d..763febfb9def 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -877,39 +877,36 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec new ScUndoCopyTab( this, aSrcList, aDestList ) ); } - StarBASIC* pStarBASIC = GetBasic(); - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( GetBasicManager()->GetName().Len() > 0 ) - { - aLibName = GetBasicManager()->GetName(); - pStarBASIC = GetBasicManager()->GetLib( aLibName ); - } BOOL bVbaEnabled = aDocument.IsInVBAMode(); - SCTAB nTabToUse = nDestTab; - - if ( nDestTab == SC_TAB_APPEND ) - nTabToUse = aDocument.GetMaxTableNumber() - 1; - - if ( bVbaEnabled ) - { - String sCodeName; - String sSource; - com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer(); - com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; - if( xLibContainer.is() ) - { - com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); - aLibAny >>= xLib; - } - if( xLib.is() ) - { - rtl::OUString sRTLSource; - xLib->getByName( sSrcCodeName ) >>= sRTLSource; - sSource = sRTLSource; - } - VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); - } - } + if ( bVbaEnabled ) + { + StarBASIC* pStarBASIC = GetBasic(); + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = GetBasicManager()->GetName(); + pStarBASIC = GetBasicManager()->GetLib( aLibName ); + } + SCTAB nTabToUse = nDestTab; + if ( nDestTab == SC_TAB_APPEND ) + nTabToUse = aDocument.GetMaxTableNumber() - 1; + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + if( xLib.is() ) + { + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); + } Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); } -- cgit v1.2.3 From 7580076aad41973fe754d6543aa97f9405a9d5ce Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 3 Mar 2010 18:36:44 +0000 Subject: npower13_objectmodule: #i109734# smooth out logic for tab copy ( and associated creation of new basic module ) --- sc/source/core/data/documen2.cxx | 55 +++++++++++++++++++++------------------- sc/source/ui/docshell/docsh5.cxx | 2 +- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index ce3bf4df3490..138b55f0794c 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1107,38 +1107,41 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, } if (!bValid) nRetVal = 0; - SfxObjectShell* pDestShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL; - StarBASIC* pStarBASIC = pDestShell ? pDestShell->GetBasic() : NULL; - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( pDestShell && pDestShell->GetBasicManager()->GetName().Len() > 0 ) - { - aLibName = pDestShell->GetBasicManager()->GetName(); - pStarBASIC = pDestShell->GetBasicManager()->GetLib( aLibName ); - } - BOOL bVbaEnabled = IsInVBAMode(); - if ( bVbaEnabled && pDestShell ) + if ( bVbaEnabled ) { - String sCodeName; - String sSource; - com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pDestShell->GetBasicContainer(); - com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; - if( xLibContainer.is() ) + SfxObjectShell* pSrcShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL; + if ( pSrcShell ) { - com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); - aLibAny >>= xLib; - } + StarBASIC* pStarBASIC = pSrcShell ? pSrcShell->GetBasic() : NULL; + String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + if ( pSrcShell && pSrcShell->GetBasicManager()->GetName().Len() > 0 ) + { + aLibName = pSrcShell->GetBasicManager()->GetName(); + pStarBASIC = pSrcShell->GetBasicManager()->GetLib( aLibName ); + } - if( xLib.is() ) - { - String sSrcCodeName; - pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName ); - rtl::OUString sRTLSource; - xLib->getByName( sSrcCodeName ) >>= sRTLSource; - sSource = sRTLSource; + String sCodeName; + String sSource; + com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer(); + com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + if( xLibContainer.is() ) + { + com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + aLibAny >>= xLib; + } + + if( xLib.is() ) + { + String sSrcCodeName; + pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName ); + rtl::OUString sRTLSource; + xLib->getByName( sSrcCodeName ) >>= sRTLSource; + sSource = sRTLSource; + } + VBA_InsertModule( *this, nDestPos, sCodeName, sSource ); } - VBA_InsertModule( *this, nDestPos, sCodeName, sSource ); } return nRetVal; diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 763febfb9def..02d4a523f7e2 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -907,7 +907,7 @@ BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRec } VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); } - + } Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); } else -- cgit v1.2.3 From 7d79523ba745c5e226eb5ccc9a00f7f494bd14b3 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 7 Apr 2010 17:02:52 +0100 Subject: npower13_objectmodule: #i110672# fix Application.ThisWorkbook ( from dr ) --- sc/source/ui/vba/vbaapplication.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 5d9e513dabeb..984c5b27c97b 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -132,10 +132,16 @@ ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException) { return new ActiveWorkbook( this, mxContext ); } + uno::Reference< excel::XWorkbook > SAL_CALL ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException) { - return getActiveWorkbook(); + uno::Reference< frame::XModel > xModel = getThisExcelDoc(mxContext); + if( !xModel.is() ) + return uno::Reference< excel::XWorkbook >(); + + ScVbaWorkbook *pWb = new ScVbaWorkbook( this, mxContext, xModel ); + return uno::Reference< excel::XWorkbook > (pWb); } uno::Reference< XAssistant > SAL_CALL -- cgit v1.2.3 From 8616787ccb5d3cd09bef7ad2a77d97155890173e Mon Sep 17 00:00:00 2001 From: npower Developer Date: Tue, 13 Apr 2010 19:44:24 +0100 Subject: npower13_objectmodules: #i110724# fix for union and some clean up for determining multicell property values ( using SfxItemSet ) --- sc/source/ui/vba/excelvbahelper.cxx | 7 ++-- sc/source/ui/vba/excelvbahelper.hxx | 4 +-- sc/source/ui/vba/vbaapplication.cxx | 70 ++++++++++++++++++++++++++----------- sc/source/ui/vba/vbaformat.cxx | 60 ++++++++++++++++++++++++++----- sc/source/ui/vba/vbaformat.hxx | 5 +++ sc/source/ui/vba/vbarange.cxx | 66 +++++++++------------------------- sc/source/ui/vba/vbarange.hxx | 11 +++--- 7 files changed, 132 insertions(+), 91 deletions(-) diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 4912863a446e..b1c4db637434 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -208,12 +208,11 @@ getViewFrame( const uno::Reference< frame::XModel >& xModel ) } SfxItemSet* -ScVbaCellRangeAccess::GetDataSet( ScCellRangeObj* pRangeObj ) +ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { - SfxItemSet* pDataSet = pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : NULL ; - return pDataSet; - + return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0; } + } //excel } //vba } //ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 34b099e6db46..9af804ab169f 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -30,7 +30,7 @@ #include #include -class ScCellRangeObj; +class ScCellRangesBase; namespace ooo { @@ -51,7 +51,7 @@ namespace ooo class ScVbaCellRangeAccess { public: - static SfxItemSet* GetDataSet( ScCellRangeObj* pRangeObj ); + static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); }; } } diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 984c5b27c97b..3d5af01acef1 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -775,46 +775,74 @@ bool lcl_canJoin( ScRange& r1, ScRange& r2 ) void lcl_strip_containedRanges( Ranges& vRanges ) { // get rid of ranges that are surrounded by other ranges - for( Ranges::iterator it = vRanges.begin(); it != vRanges.end(); ++it ) + Ranges::iterator it_outer = vRanges.begin(); + while( it_outer != vRanges.end() ) { - for( Ranges::iterator it_inner = vRanges.begin(); it_inner != vRanges.end(); ++it_inner ) + bool it_outer_erased = false; // true = it_outer erased from vRanges + Ranges::iterator it_inner = vRanges.begin(); + /* Exit the inner loop if outer iterator has been erased in its last + iteration (this means it has been joined to last it_inner, or that + the it_inner contains it completely). The inner loop will restart + with next element of the outer loop, and all elements (from the + beginning of the list) will be checked against that new element. */ + while( !it_outer_erased && (it_inner != vRanges.end()) ) { - if ( it != it_inner ) + bool it_inner_erased = false; // true = it_inner erased from vRanges + if ( it_outer != it_inner ) { #ifdef DEBUG - String r1; - String r2; - it->Format( r1, SCA_VALID ) ; - it_inner->Format( r2, SCA_VALID ) ; - OSL_TRACE( "try strip/join address %s with %s ", - rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); + String r1; + String r2; + it_outer->Format( r1, SCA_VALID ) ; + it_inner->Format( r2, SCA_VALID ) ; + OSL_TRACE( "try strip/join address %s with %s ", + rtl::OUStringToOString( r1, RTL_TEXTENCODING_UTF8 ).getStr(), + rtl::OUStringToOString( r2, RTL_TEXTENCODING_UTF8 ).getStr() ); #endif - if ( it->In( *it_inner ) ) + if ( it_outer->In( *it_inner ) ) + { it_inner = vRanges.erase( it_inner ); - else if ( it_inner->In( *it ) ) - it = vRanges.erase( it ); + it_inner_erased = true; + } + else if ( it_inner->In( *it_outer ) ) + { + it_outer = vRanges.erase( it_outer ); + it_outer_erased = true; + } #ifndef OWN_JOIN - else if ( (*it_inner).aStart.Row() == (*it).aStart.Row() - && (*it_inner).aEnd.Row() == (*it).aEnd.Row() ) + else if ( (*it_inner).aStart.Row() == (*it_outer).aStart.Row() + && (*it_inner).aEnd.Row() == (*it_outer).aEnd.Row() ) { - it->ExtendTo( *it_inner ); + it_outer->ExtendTo( *it_inner ); it_inner = vRanges.erase( it_inner ); + it_inner_erased = true; } #else - else if ( lcl_canJoin( *it, *it_inner ) ) + else if ( lcl_canJoin( *it_outer, *it_inner ) ) { - it->ExtendTo( *it_inner ); + it_outer->ExtendTo( *it_inner ); it_inner = vRanges.erase( it_inner ); + it_inner_erased = true; } - else if ( lcl_canJoin( *it_inner, *it) ) + else if ( lcl_canJoin( *it_inner, *it_outer) ) { - it_inner->ExtendTo( *it ); - it = vRanges.erase( it ); + it_inner->ExtendTo( *it_outer ); + it_outer = vRanges.erase( it_outer ); + it_outer_erased = true; } #endif } + /* If it_inner has not been erased from vRanges, continue inner + loop with next element. Otherwise, it_inner already points to + the next element (return value of list::erase()). */ + if( !it_inner_erased ) + ++it_inner; } + /* If it_outer has not been erased from vRanges, continue outer loop + with next element. Otherwise, it_outer already points to the next + element (return value of list::erase()). */ + if( !it_outer_erased ) + ++it_outer; } } diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx index c98029fb1292..23c2bf96a810 100644 --- a/sc/source/ui/vba/vbaformat.cxx +++ b/sc/source/ui/vba/vbaformat.cxx @@ -45,7 +45,10 @@ #include "vbafont.hxx" #include "vbainterior.hxx" -#include "unonames.hxx" +#include +#include +#include +#include using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -571,14 +574,24 @@ ScVbaFormat::getLocked( ) throw (script::BasicErrorException, uno::Runtim uno::Any aCellProtection = aNULL(); try { - rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) ); + if (!isAmbiguous(sCellProt)) { - util::CellProtection cellProtection; - mxPropertySet->getPropertyValue(sCellProt) >>= cellProtection; - - aCellProtection = uno::makeAny( cellProtection.IsLocked ); + SfxItemSet* pDataSet = getCurrentDataSet(); + if ( pDataSet ) + { + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + if(eState != SFX_ITEM_DONTCARE) + aCellProtection = uno::makeAny(rProtAttr.GetProtection()); + } + else // fallback to propertyset + { + util::CellProtection cellProtection; + mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection; + aCellProtection = uno::makeAny( cellProtection.IsLocked ); + } } } catch (uno::Exception& ) @@ -598,9 +611,20 @@ ScVbaFormat::getFormulaHidden( ) throw (script::BasicErrorException, uno: rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) ); if (!isAmbiguous(sCellProt)) { - util::CellProtection aCellProtection; - mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection; - aBoolRet = uno::makeAny( aCellProtection.IsFormulaHidden ); + SfxItemSet* pDataSet = getCurrentDataSet(); + if ( pDataSet ) + { + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + if(eState != SFX_ITEM_DONTCARE) + aBoolRet = uno::makeAny(rProtAttr.GetHideFormula()); + } + else + { + util::CellProtection aCellProtection; + mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection; + aBoolRet = uno::makeAny( aCellProtection.IsFormulaHidden ); + } } } catch (uno::Exception e) @@ -794,6 +818,24 @@ ScVbaFormat::getServiceNames() return aServiceNames; } +template< typename Ifc1 > +ScCellRangesBase* +ScVbaFormat::getCellRangesBase() throw ( ::uno::RuntimeException ) +{ + return ScCellRangesBase::getImplementation( mxPropertySet ); +} + +template< typename Ifc1 > +SfxItemSet* +ScVbaFormat::getCurrentDataSet( ) throw ( uno::RuntimeException ) +{ + SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( getCellRangesBase() ); + if ( !pDataSet ) + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for XPropertySet" ) ), uno::Reference< uno::XInterface >() ); + return pDataSet; +} + + template class ScVbaFormat< excel::XStyle >; template class ScVbaFormat< excel::XRange >; diff --git a/sc/source/ui/vba/vbaformat.hxx b/sc/source/ui/vba/vbaformat.hxx index e024cd68b9ad..bfa88d6c7cb8 100644 --- a/sc/source/ui/vba/vbaformat.hxx +++ b/sc/source/ui/vba/vbaformat.hxx @@ -38,6 +38,8 @@ #include #include +class ScCellRangesBase; + template< typename Ifc1 > class ScVbaFormat : public InheritedHelperInterfaceImpl1< Ifc1 > { @@ -60,6 +62,9 @@ protected: css::uno::Reference< css::beans::XPropertyState > getXPropertyState() throw ( css::uno::RuntimeException ); void initializeNumberFormats() throw ( css::script::BasicErrorException ); void setNumberFormat( css::lang::Locale _aLocale, const rtl::OUString& _sFormatString) throw( css::script::BasicErrorException ); + SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); +protected: + virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); public: ScVbaFormat( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, const css::uno::Reference< css::frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( css::script::BasicErrorException ); virtual ~ScVbaFormat() {} diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index b3307ffdc55d..1a153b440b15 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -238,21 +238,28 @@ uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( const uno::Re return xRange; } -ScCellRangeObj* ScVbaRange::getCellRangeObj() throw ( uno::RuntimeException ) +ScCellRangesBase* ScVbaRange::getCellRangesBase() throw ( uno::RuntimeException ) { - uno::Reference< uno::XInterface > xIf; - if ( mxRanges.is() ) - xIf.set( mxRanges, uno::UNO_QUERY_THROW ); - else - xIf.set( mxRange, uno::UNO_QUERY_THROW ); - ScCellRangeObj* pUnoCellRange = dynamic_cast< ScCellRangeObj* >( xIf.get() ); - return pUnoCellRange; + if( mxRanges.is() ) + return ScCellRangesBase::getImplementation( mxRanges ); + if( mxRange.is() ) + return ScCellRangesBase::getImplementation( mxRange ); + throw uno::RuntimeException( rtl::OUString::createFromAscii("General Error creating range - Unknown" ), uno::Reference< uno::XInterface >() ); +} + +ScCellRangeObj* ScVbaRange::getCellRangeObj() throw ( uno::RuntimeException ) +{ + return dynamic_cast< ScCellRangeObj* >( getCellRangesBase() ); +} + +ScCellRangesObj* ScVbaRange::getCellRangesObj() throw ( uno::RuntimeException ) +{ + return dynamic_cast< ScCellRangesObj* >( getCellRangesBase() ); } SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) { - ScCellRangeObj* pUnoCellRange = getCellRangeObj(); - SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); + SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( getCellRangesBase() ); if ( !pDataSet ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for range" ) ), uno::Reference< uno::XInterface >() ); return pDataSet; @@ -3852,25 +3859,6 @@ ScVbaRange::getWorksheet() throw (uno::RuntimeException) return xSheet; } -ScCellRangesBase* -ScVbaRange::getCellRangesBase() throw( uno::RuntimeException ) -{ - ScCellRangesBase* pUnoRangesBase = NULL; - if ( mxRanges.is() ) - { - uno::Reference< uno::XInterface > xIf( mxRanges, uno::UNO_QUERY_THROW ); - pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); - } - else if ( mxRange.is() ) - { - uno::Reference< uno::XInterface > xIf( mxRange, uno::UNO_QUERY_THROW ); - pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() ); - } - else - throw uno::RuntimeException( rtl::OUString::createFromAscii("General Error creating range - Unknown" ), uno::Reference< uno::XInterface >() ); - return pUnoRangesBase; -} - // #TODO remove this ugly application processing // Process an application Range request e.g. 'Range("a1,b2,a4:b6") uno::Reference< excel::XRange > @@ -4589,26 +4577,6 @@ ScVbaRange::getValidation() throw (css::uno::RuntimeException) return m_xValidation; } -uno::Any ScVbaRange::getFormulaHidden() throw ( script::BasicErrorException, css::uno::RuntimeException) -{ - SfxItemSet* pDataSet = getCurrentDataSet(); - const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) - pDataSet->Get(ATTR_PROTECTION, TRUE); - SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); - if(eState == SFX_ITEM_DONTCARE) - return aNULL(); - return uno::makeAny(rProtAttr.GetHideFormula()); - -} -void ScVbaRange::setFormulaHidden(const uno::Any& Hidden) throw ( script::BasicErrorException, css::uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY_THROW); - util::CellProtection rCellAttr; - xProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLPRO))) >>= rCellAttr; - Hidden >>= rCellAttr.IsFormulaHidden; - xProps->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLPRO)), uno::makeAny(rCellAttr)); -} - uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException) { // #FIXME, If the specified range is in a PivotTable report diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index 89ae741c7535..1f161a79d973 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -57,6 +57,7 @@ class ScTableSheetsObj; class ScCellRangesBase; class ScCellRangeObj; +class ScCellRangesObj; class ScDocShell; class ScDocument; @@ -111,14 +112,16 @@ class ScVbaRange : public ScVbaRange_BASE virtual css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); virtual void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar ) throw ( css::uno::RuntimeException); css::uno::Reference< ov::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException ); - ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); ScCellRangeObj* getCellRangeObj( ) throw ( css::uno::RuntimeException ); - SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); + ScCellRangesObj* getCellRangesObj() throw ( css::uno::RuntimeException ); css::uno::Reference< ov::XCollection >& getBorders(); void groupUnGroup( bool bUnGroup = false ) throw ( css::script::BasicErrorException, css::uno::RuntimeException ); css::uno::Reference< ov::excel::XRange > PreviousNext( bool bIsPrevious ); css::uno::Reference< ov::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException ); css::awt::Point getPosition() throw ( css::uno::RuntimeException ); +protected: + virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); + virtual SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); public: ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException ); ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException ); @@ -170,10 +173,6 @@ public: virtual css::uno::Any SAL_CALL getPageBreak() throw (css::uno::RuntimeException); virtual void SAL_CALL setPageBreak( const css::uno::Any& _pagebreak ) throw (css::uno::RuntimeException); virtual css::uno::Reference< ov::excel::XValidation > SAL_CALL getValidation() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getFormulaHidden() throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL setFormulaHidden(const css::uno::Any& aHidden) throw (css::script::BasicErrorException, css::uno::RuntimeException); - //virtual css::uno::Any SAL_CALL getLocked() throw (css::script::BasicErrorException, css::uno::RuntimeException); - //virtual void SAL_CALL setLocked(const css::uno::Any& aLocked) throw (css::script::BasicErrorException, css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getShowDetail() throw (css::uno::RuntimeException); virtual void SAL_CALL setShowDetail(const css::uno::Any& aShowDetail) throw (css::uno::RuntimeException); // Methods -- cgit v1.2.3 From 0e17741fb26f9aa7d6ec986c5b03e2846da6a964 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 14 Apr 2010 12:31:52 +0100 Subject: npower13_objectmodules: add a CodeName property for Sheet and Document/Model objects --- sc/inc/unonames.hxx | 1 + sc/inc/unowids.hxx | 3 ++- sc/source/ui/unoobj/cellsuno.cxx | 17 +++++++++++++++++ sc/source/ui/unoobj/docuno.cxx | 13 +++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index f5de35c9d033..5bcc22ae72d3 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -484,6 +484,7 @@ #define SC_UNO_ISEXECUTELINKENABLED "IsExecuteLinkEnabled" #define SC_UNO_ISCHANGEREADONLYENABLED "IsChangeReadOnlyEnabled" #define SC_UNO_REFERENCEDEVICE "ReferenceDevice" +#define SC_UNO_CODENAME "CodeName" // document properties from FormModel #define SC_UNO_APPLYFMDES "ApplyFormDesignMode" diff --git a/sc/inc/unowids.hxx b/sc/inc/unowids.hxx index 1765b9d06361..f58c3248bf81 100644 --- a/sc/inc/unowids.hxx +++ b/sc/inc/unowids.hxx @@ -77,7 +77,8 @@ #define SC_WID_UNO_TABLAYOUT ( SC_WID_UNO_START + 37 ) #define SC_WID_UNO_AUTOPRINT ( SC_WID_UNO_START + 38 ) #define SC_WID_UNO_ABSNAME ( SC_WID_UNO_START + 39 ) -#define SC_WID_UNO_END ( SC_WID_UNO_START + 39 ) +#define SC_WID_UNO_CODENAME ( SC_WID_UNO_START + 40 ) +#define SC_WID_UNO_END ( SC_WID_UNO_START + 40 ) inline BOOL IsScUnoWid( USHORT nWid ) diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index c61a6443af99..2c1774b8994d 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -769,6 +769,7 @@ const SfxItemPropertySet* lcl_GetSheetPropertySet() {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((table::CellVertJustify*)0), 0, 0 }, {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 }, + {MAP_CHAR_LEN(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, {0,0,0,0,0,0} }; static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl ); @@ -8467,6 +8468,15 @@ void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEn pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag. } } + else if ( pEntry->nWID == SC_WID_UNO_CODENAME ) + { + rtl::OUString aCodeName; + if ( pDocSh && ( aValue >>= aCodeName ) ) + { + String sNewName( aCodeName ); + pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), sNewName ); + } + } else ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID } @@ -8605,6 +8615,13 @@ void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEn BOOL bAutoPrint = pDoc->IsPrintEntireSheet( nTab ); ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint ); } + else if ( pEntry->nWID == SC_WID_UNO_CODENAME ) + { + String aCodeName; + if ( pDocSh ) + pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName ); + rAny <<= rtl::OUString( aCodeName ); + } else ScCellRangeObj::GetOnePropertyValue(pEntry, rAny); } diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 8e857adca09c..826f7b59bf32 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -152,6 +152,7 @@ const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap() {MAP_CHAR_LEN(SC_UNO_ISCHANGEREADONLYENABLED), 0, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNO_REFERENCEDEVICE), 0, &getCppuType((uno::Reference*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN("BuildId"), 0, &::getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, + {MAP_CHAR_LEN(SC_UNO_CODENAME), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, {0,0,0,0,0,0} }; @@ -1651,6 +1652,12 @@ void SAL_CALL ScModelObj::setPropertyValue( pDoc->SetLanguage( eLatin, eCjk, eCtl ); } } + else if ( aString.EqualsAscii( SC_UNO_CODENAME ) ) + { + rtl::OUString sCodeName; + if ( aValue >>= sCodeName ) + pDoc->SetCodeName( sCodeName ); + } else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) ) { lang::Locale aLocale; @@ -1783,6 +1790,12 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa ScUnoConversion::FillLocale( aLocale, eLatin ); aRet <<= aLocale; } + else if ( aString.EqualsAscii( SC_UNO_CODENAME ) ) + { + rtl::OUString sCodeName = pDoc->GetCodeName(); + aRet <<= sCodeName; + } + else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) ) { LanguageType eLatin, eCjk, eCtl; -- cgit v1.2.3 From da9d0047fe373b0083b23e45bef4fca7f008af11 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 14 Apr 2010 17:31:33 +0200 Subject: npower13_objectmodules: make vba import available in oox filters --- sc/source/ui/unoobj/servuno.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index d69659b41f11..f4f27357bdbb 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -37,6 +37,7 @@ #include #include "servuno.hxx" +#include "unoguard.hxx" #include "unonames.hxx" #include "cellsuno.hxx" #include "fielduno.hxx" @@ -104,6 +105,7 @@ public: virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException ) { + ScUnoGuard aGuard; maCachedObject = uno::Any(); // clear cached object String sName = aName; @@ -150,6 +152,7 @@ public: } ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { + ScUnoGuard aGuard; OSL_TRACE("ScVbaObjectForCodeNameProvider::getByName( %s )", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr() ); if ( !hasByName( aName ) ) @@ -158,6 +161,7 @@ public: } virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException) { + ScUnoGuard aGuard; ScDocument* pDoc = mpDocShell->GetDocument(); if ( !pDoc ) throw uno::RuntimeException(); @@ -187,6 +191,7 @@ public: // XCodeNameQuery rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException ) { + ScUnoGuard aGuard; rtl::OUString sCodeName; if ( mpDocShell ) { -- cgit v1.2.3 From 2cc76813f2da296840d94e94c652f573313b21cf Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 16 Apr 2010 17:28:52 +0200 Subject: npower13_objectmodules: uppercase UNO constants --- sc/source/ui/docshell/docfunc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 3b735c061cab..01d03d49b50a 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2601,7 +2601,7 @@ script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule ) { ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); script::ModuleInfo sModuleInfo; - sModuleInfo.ModuleType = script::ModuleType::Document; + sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule ); return sModuleInfo; } -- cgit v1.2.3