diff options
-rw-r--r-- | basic/inc/basic/basmgr.hxx | 64 | ||||
-rw-r--r-- | basic/source/basmgr/basicmanagerrepository.cxx | 34 | ||||
-rw-r--r-- | basic/source/basmgr/basmgr.cxx | 293 | ||||
-rw-r--r-- | basic/source/inc/scriptcont.hxx | 8 | ||||
-rw-r--r-- | basic/source/uno/scriptcont.cxx | 24 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 7 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/docshell/macromgr.cxx | 6 | ||||
-rw-r--r-- | scripting/source/vbaevents/eventhelper.cxx | 40 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 7 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbahelper.cxx | 2 |
13 files changed, 290 insertions, 220 deletions
diff --git a/basic/inc/basic/basmgr.hxx b/basic/inc/basic/basmgr.hxx index 69ddb8e056a3..6ff8a69bf0f2 100644 --- a/basic/inc/basic/basmgr.hxx +++ b/basic/inc/basic/basmgr.hxx @@ -49,19 +49,19 @@ class BASIC_DLLPUBLIC BasicError private: sal_uIntPtr nErrorId; sal_uInt16 nReason; - String aErrStr; + OUString aErrStr; public: BasicError( const BasicError& rErr ); - BasicError( sal_uIntPtr nId, sal_uInt16 nR, const String& rErrStr ); + BasicError( sal_uIntPtr nId, sal_uInt16 nR, const OUString& rErrStr ); sal_uIntPtr GetErrorId() const { return nErrorId; } sal_uInt16 GetReason() const { return nReason; } - String GetErrorStr() { return aErrStr; } + OUString GetErrorStr() { return aErrStr; } void SetErrorId( sal_uIntPtr n ) { nErrorId = n; } void SetReason( sal_uInt16 n ) { nReason = n; } - void SetErrorStr( const String& rStr) { aErrStr = rStr; } + void SetErrorStr( const OUString& rStr) { aErrStr = rStr; } }; class BasicLibs; @@ -74,10 +74,10 @@ namespace basic { class BasicManagerCleaner; } class BASIC_DLLPUBLIC OldBasicPassword { public: - virtual void setLibraryPassword( const String& rLibraryName, const String& rPassword ) = 0; - virtual String getLibraryPassword( const String& rLibraryName ) = 0; - virtual void clearLibraryPassword( const String& rLibraryName ) = 0; - virtual sal_Bool hasLibraryPassword( const String& rLibraryName ) = 0; + virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ) = 0; + virtual OUString getLibraryPassword( const OUString& rLibraryName ) = 0; + virtual void clearLibraryPassword( const OUString& rLibraryName ) = 0; + virtual sal_Bool hasLibraryPassword( const OUString& rLibraryName ) = 0; protected: ~OldBasicPassword() {} @@ -122,8 +122,8 @@ private: BasicLibs* pLibs; std::vector<BasicError> aErrors; - String aName; - String maStorageName; + OUString aName; + OUString maStorageName; bool mbDocMgr; BasicManagerImpl* mpImpl; @@ -134,9 +134,9 @@ protected: sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo ) const; sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly = sal_False ); void ImpCreateStdLib( StarBASIC* pParentFromStdLib ); - void ImpMgrNotLoaded( const String& rStorageName ); + void ImpMgrNotLoaded( const OUString& rStorageName ); BasicLibInfo* CreateLibInfo(); - void LoadBasicManager( SotStorage& rStorage, const String& rBaseURL, sal_Bool bLoadBasics = sal_True ); + void LoadBasicManager( SotStorage& rStorage, const OUString& rBaseURL, sal_Bool bLoadBasics = sal_True ); void LoadOldBasicManager( SotStorage& rStorage ); sal_Bool ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) const; sal_Bool ImplEncryptStream( SvStream& rStream ) const; @@ -146,8 +146,8 @@ protected: public: TYPEINFO(); - BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBASIC* pParentFromStdLib = NULL, String* pLibPath = NULL, bool bDocMgr = false ); - BasicManager( StarBASIC* pStdLib, String* pLibPath = NULL, bool bDocMgr = false ); + BasicManager( SotStorage& rStorage, const OUString& rBaseURL, StarBASIC* pParentFromStdLib = NULL, OUString* pLibPath = NULL, bool bDocMgr = false ); + BasicManager( StarBASIC* pStdLib, OUString* pLibPath = NULL, bool bDocMgr = false ); /** deletes the given BasicManager instance @@ -158,18 +158,18 @@ public: */ static void LegacyDeleteBasicManager( BasicManager*& _rpManager ); - void SetStorageName( const String& rName ) { maStorageName = rName; } - String GetStorageName() const { return maStorageName; } - void SetName( const String& rName ) { aName = rName; } - String GetName() const { return aName; } + void SetStorageName( const OUString& rName ) { maStorageName = rName; } + OUString GetStorageName() const { return maStorageName; } + void SetName( const OUString& rName ) { aName = rName; } + OUString GetName() const { return aName; } sal_uInt16 GetLibCount() const; StarBASIC* GetLib( sal_uInt16 nLib ) const; - StarBASIC* GetLib( const String& rName ) const; - sal_uInt16 GetLibId( const String& rName ) const; + StarBASIC* GetLib( const OUString& rName ) const; + sal_uInt16 GetLibId( const OUString& rName ) const; - String GetLibName( sal_uInt16 nLib ); + OUString GetLibName( sal_uInt16 nLib ); /** announces the library containers which belong to this BasicManager @@ -207,31 +207,31 @@ public: takes the names of modules whose size exceeds the legacy limit */ bool LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< rtl::OUString >& _out_rModuleNames ); - bool HasExeCode( const String& ); + bool HasExeCode( const OUString& ); /// determines whether the Basic Manager has a given macro, given by fully qualified name - bool HasMacro( String const& i_fullyQualifiedName ) const; + bool HasMacro( OUString const& i_fullyQualifiedName ) const; /// executes a given macro - ErrCode ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ); + ErrCode ExecuteMacro( OUString const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ); /// executes a given macro - ErrCode ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue ); + ErrCode ExecuteMacro( OUString const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue ); private: BASIC_DLLPRIVATE sal_Bool IsReference( sal_uInt16 nLib ); - BASIC_DLLPRIVATE sal_Bool SetLibName( sal_uInt16 nLib, const String& rName ); + BASIC_DLLPRIVATE sal_Bool SetLibName( sal_uInt16 nLib, const OUString& rName ); BASIC_DLLPRIVATE StarBASIC* GetStdLib() const; - BASIC_DLLPRIVATE StarBASIC* AddLib( SotStorage& rStorage, const String& rLibName, sal_Bool bReference ); + BASIC_DLLPRIVATE StarBASIC* AddLib( SotStorage& rStorage, const OUString& rLibName, sal_Bool bReference ); BASIC_DLLPRIVATE sal_Bool RemoveLib( sal_uInt16 nLib ); - BASIC_DLLPRIVATE sal_Bool HasLib( const String& rName ) const; + BASIC_DLLPRIVATE sal_Bool HasLib( const OUString& rName ) const; - BASIC_DLLPRIVATE StarBASIC* CreateLibForLibContainer( const String& rLibName, + BASIC_DLLPRIVATE StarBASIC* CreateLibForLibContainer( const OUString& rLibName, const com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer >& xScriptCont ); // For XML import/export: - BASIC_DLLPRIVATE StarBASIC* CreateLib( const String& rLibName ); - BASIC_DLLPRIVATE StarBASIC* CreateLib( const String& rLibName, const String& Password, - const String& LinkTargetURL ); + BASIC_DLLPRIVATE StarBASIC* CreateLib( const OUString& rLibName ); + BASIC_DLLPRIVATE StarBASIC* CreateLib( const OUString& rLibName, const OUString& Password, + const OUString& LinkTargetURL ); }; #endif //_BASMGR_HXX diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx index 63015fa78fd9..5f0078d67660 100644 --- a/basic/source/basmgr/basicmanagerrepository.cxx +++ b/basic/source/basmgr/basicmanagerrepository.cxx @@ -285,12 +285,13 @@ namespace basic // Determine Directory SvtPathOptions aPathCFG; - String aAppBasicDir( aPathCFG.GetBasicPath() ); - if ( !aAppBasicDir.Len() ) + OUString aAppBasicDir( aPathCFG.GetBasicPath() ); + if ( aAppBasicDir.isEmpty() ) + { aPathCFG.SetBasicPath(rtl::OUString("$(prog)")); - + } // soffice.new search only in user dir => first dir - String aAppFirstBasicDir = aAppBasicDir.GetToken(1); + OUString aAppFirstBasicDir = aAppBasicDir.getToken(1, ';'); // Create basic and load it // AppBasicDir is now a PATH @@ -301,8 +302,8 @@ namespace basic setApplicationBasicManager( pBasicManager ); // The first dir in the path as destination: - String aFileName( aAppBasic.getName() ); - aAppBasic = INetURLObject( aAppBasicDir.GetToken(1) ); + OUString aFileName( aAppBasic.getName() ); + aAppBasic = INetURLObject( aAppBasicDir.getToken(1, ';') ); DBG_ASSERT(aAppBasic.GetProtocol() != INET_PROT_NOT_VALID, rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("Invalid URL: \"")). append(rtl::OUStringToOString(aAppBasicDir, @@ -328,10 +329,8 @@ namespace basic // StarDesktop Reference< XMultiServiceFactory > xSMgr = ::comphelper::getProcessServiceFactory(); - pBasicManager->SetGlobalUNOConstant( - "StarDesktop", - makeAny( xSMgr->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ) ) - ); + pBasicManager->SetGlobalUNOConstant( "StarDesktop", + makeAny( xSMgr->createInstance("com.sun.star.frame.Desktop"))); // (BasicLibraries and DialogLibraries have automatically been added in SetLibraryContainerInfo) @@ -402,12 +401,16 @@ namespace basic try { // ensure there's a standard library in the basic container - ::rtl::OUString aStdLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + OUString aStdLibName( "Standard" ); if ( !_rxBasicLibraries->hasByName( aStdLibName ) ) + { _rxBasicLibraries->createLibrary( aStdLibName ); + } // as well as in the dialog container if ( !_rxDialogLibraries->hasByName( aStdLibName ) ) + { _rxDialogLibraries->createLibrary( aStdLibName ); + } } catch( const Exception& ) { @@ -423,9 +426,10 @@ namespace basic _out_rpBasicManager = 0; Reference< XStorage > xStorage; if ( !impl_getDocumentStorage_nothrow( _rxDocumentModel, xStorage ) ) + { // the document is not able to provide the storage it is based on. return; - + } Reference< XPersistentLibraryContainer > xBasicLibs; Reference< XPersistentLibraryContainer > xDialogLibs; if ( !impl_getDocumentLibraryContainers_nothrow( _rxDocumentModel, xBasicLibs, xDialogLibs ) ) @@ -437,11 +441,11 @@ namespace basic // load BASIC-manager SfxErrorContext aErrContext( ERRCTX_SFX_LOADBASIC, ::comphelper::DocumentInfo::getDocumentTitle( _rxDocumentModel ) ); - String aAppBasicDir = SvtPathOptions().GetBasicPath(); + OUString aAppBasicDir = SvtPathOptions().GetBasicPath(); // Storage and BaseURL are only needed by binary documents! - SotStorageRef xDummyStor = new SotStorage( ::rtl::OUString() ); - _out_rpBasicManager = new BasicManager( *xDummyStor, String() /* TODO/LATER: xStorage */, + SotStorageRef xDummyStor = new SotStorage( OUString() ); + _out_rpBasicManager = new BasicManager( *xDummyStor, OUString() /* TODO/LATER: xStorage */, pAppBasic, &aAppBasicDir, sal_True ); if ( !_out_rpBasicManager->GetErrors().empty() ) diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 3bd3a52438b2..d6812738a11b 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -358,7 +358,7 @@ void SAL_CALL BasMgrContainerListenerImpl::elementRemoved( const container::Cont } } -BasicError::BasicError( sal_uIntPtr nId, sal_uInt16 nR, const String& rErrStr ) : +BasicError::BasicError( sal_uIntPtr nId, sal_uInt16 nR, const OUString& rErrStr ) : aErrStr( rErrStr ) { nErrorId = nId; @@ -379,10 +379,10 @@ class BasicLibInfo { private: StarBASICRef xLib; - String aLibName; - String aStorageName; // String is sufficient, unique at runtime - String aRelStorageName; - String aPassword; + OUString aLibName; + OUString aStorageName; // String is sufficient, unique at runtime + OUString aRelStorageName; + OUString aPassword; sal_Bool bDoLoad; sal_Bool bReference; @@ -397,13 +397,13 @@ public: sal_Bool IsReference() const { return bReference; } sal_Bool& IsReference() { return bReference; } - sal_Bool IsExtern() const { return ! aStorageName.EqualsAscii(szImbedded); } + sal_Bool IsExtern() const { return ! aStorageName.equalsAscii(szImbedded); } - void SetStorageName( const String& rName ) { aStorageName = rName; } - const String& GetStorageName() const { return aStorageName; } + void SetStorageName( const OUString& rName ) { aStorageName = rName; } + const OUString& GetStorageName() const { return aStorageName; } - void SetRelStorageName( const String& rN ) { aRelStorageName = rN; } - const String& GetRelStorageName() const { return aRelStorageName; } + void SetRelStorageName( const OUString& rN ) { aRelStorageName = rN; } + const OUString& GetRelStorageName() const { return aRelStorageName; } StarBASICRef GetLib() const { @@ -415,15 +415,15 @@ public: StarBASICRef& GetLibRef() { return xLib; } void SetLib( StarBASIC* pBasic ) { xLib = pBasic; } - const String& GetLibName() const { return aLibName; } - void SetLibName( const String& rName ) { aLibName = rName; } + const OUString& GetLibName() const { return aLibName; } + void SetLibName( const OUString& rName ) { aLibName = rName; } // Only temporary for Load/Save sal_Bool DoLoad() { return bDoLoad; } - sal_Bool HasPassword() const { return aPassword.Len() != 0; } - const String& GetPassword() const { return aPassword; } - void SetPassword( const String& rNewPassword ) + sal_Bool HasPassword() const { return !aPassword.isEmpty(); } + const OUString& GetPassword() const { return aPassword; } + void SetPassword( const OUString& rNewPassword ) { aPassword = rNewPassword; } sal_Bool IsPasswordVerified() const { return bPasswordVerified; } void SetPasswordVerified() { bPasswordVerified = sal_True; } @@ -447,7 +447,7 @@ private: public: ~BasicLibs(); - String aBasicLibPath; // TODO: Should be member of manager, but currently not incompatible + OUString aBasicLibPath; // TODO: Should be member of manager, but currently not incompatible BasicLibInfo* GetObject( size_t i ); BasicLibInfo* First(); BasicLibInfo* Next(); @@ -554,15 +554,15 @@ BasicLibInfo* BasicLibInfo::Create( SotStorageStream& rSStream ) pInfo->bDoLoad = bDoLoad; // The name of the lib... - String aName = rSStream.ReadUniOrByteString(rSStream.GetStreamCharSet()); + OUString aName = rSStream.ReadUniOrByteString(rSStream.GetStreamCharSet()); pInfo->SetLibName( aName ); // Absolute path... - String aStorageName = rSStream.ReadUniOrByteString(rSStream.GetStreamCharSet()); + OUString aStorageName = rSStream.ReadUniOrByteString(rSStream.GetStreamCharSet()); pInfo->SetStorageName( aStorageName ); // Relative path... - String aRelStorageName = rSStream.ReadUniOrByteString(rSStream.GetStreamCharSet()); + OUString aRelStorageName = rSStream.ReadUniOrByteString(rSStream.GetStreamCharSet()); pInfo->SetRelStorageName( aRelStorageName ); if ( nVer >= 2 ) @@ -577,21 +577,22 @@ BasicLibInfo* BasicLibInfo::Create( SotStorageStream& rSStream ) return pInfo; } -BasicManager::BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBASIC* pParentFromStdLib, String* pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) +BasicManager::BasicManager( SotStorage& rStorage, const OUString& rBaseURL, StarBASIC* pParentFromStdLib, OUString* pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) { DBG_CTOR( BasicManager, 0 ); Init(); if( pLibPath ) + { pLibs->aBasicLibPath = *pLibPath; - - String aStorName( rStorage.GetName() ); + } + OUString aStorName( rStorage.GetName() ); maStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); // If there is no Manager Stream, no further actions are necessary - if ( rStorage.IsStream( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)) ) ) + if ( rStorage.IsStream( OUString(szManagerStream) ) ) { LoadBasicManager( rStorage, rBaseURL ); // StdLib contains Parent: @@ -606,8 +607,8 @@ BasicManager::BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBA pStdLibInfo = CreateLibInfo(); pStdLibInfo->SetLib( pStdLib ); StarBASICRef xStdLib = pStdLibInfo->GetLib(); - xStdLib->SetName( rtl::OUString(szStdLibName) ); - pStdLibInfo->SetLibName( rtl::OUString(szStdLibName) ); + xStdLib->SetName( OUString(szStdLibName) ); + pStdLibInfo->SetLibName( OUString(szStdLibName) ); xStdLib->SetFlag( SBX_DONTSTORE | SBX_EXTSEARCH ); xStdLib->SetModified( sal_False ); } @@ -630,13 +631,11 @@ BasicManager::BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBA // #91626 Save all stream data to save it unmodified if basic isn't modified // in an 6.0+ office. So also the old basic dialogs can be saved. - SotStorageStreamRef xManagerStream = rStorage.OpenSotStream - ( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)), eStreamReadMode ); + SotStorageStreamRef xManagerStream = rStorage.OpenSotStream( OUString(szManagerStream), eStreamReadMode ); mpImpl->mpManagerStream = new SvMemoryStream(); *static_cast<SvStream*>(&xManagerStream) >> *mpImpl->mpManagerStream; - SotStorageRef xBasicStorage = rStorage.OpenSotStorage - ( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)), eStorageReadMode, sal_False ); + SotStorageRef xBasicStorage = rStorage.OpenSotStorage( OUString(szBasicStorage), eStorageReadMode, sal_False ); if( xBasicStorage.Is() && !xBasicStorage->GetError() ) { sal_uInt16 nLibs = GetLibCount(); @@ -665,7 +664,7 @@ void copyToLibraryContainer( StarBASIC* pBasic, const LibraryContainerInfo& rInf if ( !xScriptCont.is() ) return; - String aLibName = pBasic->GetName(); + OUString aLibName = pBasic->GetName(); if( !xScriptCont->hasByName( aLibName ) ) xScriptCont->createLibrary( aLibName ); @@ -681,10 +680,10 @@ void copyToLibraryContainer( StarBASIC* pBasic, const LibraryContainerInfo& rInf SbModule* pModule = (SbModule*)pBasic->GetModules()->Get( nMod ); DBG_ASSERT( pModule, "Modul nicht erhalten!" ); - String aModName = pModule->GetName(); + OUString aModName = pModule->GetName(); if( !xLib->hasByName( aModName ) ) { - ::rtl::OUString aSource = pModule->GetSource32(); + OUString aSource = pModule->GetSource32(); uno::Any aSourceAny; aSourceAny <<= aSource; xLib->insertByName( aModName, aSourceAny ); @@ -708,11 +707,11 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ) uno::Reference< script::XLibraryContainer > xScriptCont( mpImpl->maContainerInfo.mxScriptCont.get() ); StarBASIC* pStdLib = GetStdLib(); - String aLibName = pStdLib->GetName(); + OUString aLibName = pStdLib->GetName(); if( xScriptCont.is() ) { // Register listener for lib container - ::rtl::OUString aEmptyLibName; + OUString aEmptyLibName; uno::Reference< container::XContainerListener > xLibContainerListener = static_cast< container::XContainerListener* > ( new BasMgrContainerListenerImpl( this, aEmptyLibName ) ); @@ -720,8 +719,8 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ) uno::Reference< container::XContainer> xLibContainer( xScriptCont, uno::UNO_QUERY ); xLibContainer->addContainerListener( xLibContainerListener ); - uno::Sequence< ::rtl::OUString > aScriptLibNames = xScriptCont->getElementNames(); - const ::rtl::OUString* pScriptLibName = aScriptLibNames.getConstArray(); + uno::Sequence< OUString > aScriptLibNames = xScriptCont->getElementNames(); + const OUString* pScriptLibName = aScriptLibNames.getConstArray(); sal_Int32 i, nNameCount = aScriptLibNames.getLength(); if( nNameCount ) @@ -774,15 +773,16 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ) SetGlobalUNOConstant( "DialogLibraries", makeAny( mpImpl->maContainerInfo.mxDialogCont ) ); } -BasicManager::BasicManager( StarBASIC* pSLib, String* pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) +BasicManager::BasicManager( StarBASIC* pSLib, OUString* pLibPath, bool bDocMgr ) : mbDocMgr( bDocMgr ) { DBG_CTOR( BasicManager, 0 ); Init(); DBG_ASSERT( pSLib, "BasicManager cannot be created with a NULL-Pointer!" ); if( pLibPath ) + { pLibs->aBasicLibPath = *pLibPath; - + } BasicLibInfo* pStdLibInfo = CreateLibInfo(); pStdLibInfo->SetLib( pSLib ); StarBASICRef xStdLib = pStdLibInfo->GetLib(); @@ -794,7 +794,7 @@ BasicManager::BasicManager( StarBASIC* pSLib, String* pLibPath, bool bDocMgr ) : xStdLib->SetModified( sal_False ); } -void BasicManager::ImpMgrNotLoaded( const String& rStorageName ) +void BasicManager::ImpMgrNotLoaded( const OUString& rStorageName ) { // pErrInf is only destroyed if the error os processed by an // ErrorHandler @@ -822,15 +822,14 @@ void BasicManager::ImpCreateStdLib( StarBASIC* pParentFromStdLib ) pStdLib->SetFlag( SBX_DONTSTORE | SBX_EXTSEARCH ); } -void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseURL, sal_Bool bLoadLibs ) +void BasicManager::LoadBasicManager( SotStorage& rStorage, const OUString& rBaseURL, sal_Bool bLoadLibs ) { DBG_CHKTHIS( BasicManager, 0 ); - SotStorageStreamRef xManagerStream = rStorage.OpenSotStream - ( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)), eStreamReadMode ); + SotStorageStreamRef xManagerStream = rStorage.OpenSotStream( OUString(szManagerStream), eStreamReadMode ); - String aStorName( rStorage.GetName() ); + OUString aStorName( rStorage.GetName() ); // #i13114 removed, DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); if ( !xManagerStream.Is() || xManagerStream->GetError() || ( xManagerStream->Seek( STREAM_SEEK_TO_END ) == 0 ) ) @@ -842,13 +841,15 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR maStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); // #i13114 removed, DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); - String aRealStorageName = maStorageName; // for relative paths, can be modified through BaseURL + OUString aRealStorageName = maStorageName; // for relative paths, can be modified through BaseURL - if ( rBaseURL.Len() ) + if ( !rBaseURL.isEmpty() ) { INetURLObject aObj( rBaseURL ); if ( aObj.GetProtocol() == INET_PROT_FILE ) + { aRealStorageName = aObj.PathToFileName(); + } } xManagerStream->SetBufferSize( 1024 ); @@ -871,7 +872,7 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR // Correct absolute pathname if relative is existing. // Always try relative first if there are two stands on disk - if ( pInfo->GetRelStorageName().Len() && ( ! pInfo->GetRelStorageName().EqualsAscii(szImbedded) ) ) + if ( !pInfo->GetRelStorageName().isEmpty() && ( ! pInfo->GetRelStorageName().equalsAscii(szImbedded) ) ) { INetURLObject aObj( aRealStorageName, INET_PROT_FILE ); aObj.removeSegment(); @@ -880,12 +881,13 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR //*** TODO: Replace if still necessary //*** TODO-End - if ( pLibs->aBasicLibPath.Len() ) + if ( ! pLibs->aBasicLibPath.isEmpty() ) { // Search lib in path - String aSearchFile = pInfo->GetRelStorageName(); + OUString aSearchFile = pInfo->GetRelStorageName(); + String aSearchFileOldFormat(aSearchFile); SvtPathOptions aPathCFG; - if( aPathCFG.SearchFile( aSearchFile, SvtPathOptions::PATH_BASIC ) ) + if( aPathCFG.SearchFile( aSearchFileOldFormat, SvtPathOptions::PATH_BASIC ) ) { pInfo->SetStorageName( aSearchFile ); } @@ -912,10 +914,9 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage ) DBG_CHKTHIS( BasicManager, 0 ); - SotStorageStreamRef xManagerStream = rStorage.OpenSotStream - ( rtl::OUString(szOldManagerStream), eStreamReadMode ); + SotStorageStreamRef xManagerStream = rStorage.OpenSotStream( OUString(szOldManagerStream), eStreamReadMode ); - String aStorName( rStorage.GetName() ); + OUString aStorName( rStorage.GetName() ); DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); if ( !xManagerStream.Is() || xManagerStream->GetError() || ( xManagerStream->Seek( STREAM_SEEK_TO_END ) == 0 ) ) @@ -940,23 +941,23 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage ) // and it proceeds ... } xManagerStream->Seek( nBasicEndOff+1 ); // +1: 0x00 as separator - String aLibs = xManagerStream->ReadUniOrByteString(xManagerStream->GetStreamCharSet()); + OUString aLibs = xManagerStream->ReadUniOrByteString(xManagerStream->GetStreamCharSet()); xManagerStream->SetBufferSize( 0 ); xManagerStream.Clear(); // Close stream - if ( aLibs.Len() ) + if ( !aLibs.isEmpty() ) { - String aCurStorageName( aStorName ); + OUString aCurStorageName( aStorName ); INetURLObject aCurStorage( aCurStorageName, INET_PROT_FILE ); sal_Int32 nLibs = comphelper::string::getTokenCount(aLibs, LIB_SEP); for ( sal_Int32 nLib = 0; nLib < nLibs; nLib++ ) { - String aLibInfo(comphelper::string::getToken(aLibs, nLib, LIB_SEP)); + OUString aLibInfo(comphelper::string::getToken(aLibs, nLib, LIB_SEP)); // TODO: Remove == 2 DBG_ASSERT( ( comphelper::string::getTokenCount(aLibInfo, LIBINFO_SEP) == 2 ) || ( comphelper::string::getTokenCount(aLibInfo, LIBINFO_SEP) == 3 ), "Ungueltige Lib-Info!" ); - String aLibName( aLibInfo.GetToken( 0, LIBINFO_SEP ) ); - String aLibAbsStorageName( aLibInfo.GetToken( 1, LIBINFO_SEP ) ); - String aLibRelStorageName( aLibInfo.GetToken( 2, LIBINFO_SEP ) ); + OUString aLibName( aLibInfo.getToken( 0, LIBINFO_SEP ) ); + OUString aLibAbsStorageName( aLibInfo.getToken( 1, LIBINFO_SEP ) ); + OUString aLibRelStorageName( aLibInfo.getToken( 2, LIBINFO_SEP ) ); INetURLObject aLibAbsStorage( aLibAbsStorageName, INET_PROT_FILE ); INetURLObject aLibRelStorage( aStorName ); @@ -966,8 +967,10 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage ) DBG_ASSERT(!bWasAbsolute, "RelStorageName was absolute!" ); SotStorageRef xStorageRef; - if ( ( aLibAbsStorage == aCurStorage ) || ( aLibRelStorageName.EqualsAscii(szImbedded) ) ) + if ( ( aLibAbsStorage == aCurStorage ) || ( aLibRelStorageName.equalsAscii(szImbedded) ) ) + { xStorageRef = &rStorage; + } else { xStorageRef = new SotStorage( sal_False, aLibAbsStorage.GetMainURL @@ -977,7 +980,9 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage ) GetMainURL( INetURLObject::NO_DECODE ), eStorageReadMode, sal_True ); } if ( xStorageRef.Is() ) + { AddLib( *xStorageRef, aLibName, sal_False ); + } else { StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, ERRCODE_BUTTON_OK ); @@ -1007,7 +1012,7 @@ void BasicManager::LegacyDeleteBasicManager( BasicManager*& _rpManager ) } -bool BasicManager::HasExeCode( const String& sLib ) +bool BasicManager::HasExeCode( const OUString& sLib ) { StarBASIC* pLib = GetLib(sLib); if ( pLib ) @@ -1048,15 +1053,16 @@ sal_Bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurS DBG_ASSERT( pLibInfo, "LibInfo!?" ); - String aStorageName( pLibInfo->GetStorageName() ); - if ( !aStorageName.Len() || ( aStorageName.EqualsAscii(szImbedded) ) ) + OUString aStorageName( pLibInfo->GetStorageName() ); + if ( aStorageName.isEmpty() || ( aStorageName.equalsAscii(szImbedded) ) ) + { aStorageName = GetStorageName(); - + } SotStorageRef xStorage; // The current must not be opened again... if ( pCurStorage ) { - String aStorName( pCurStorage->GetName() ); + OUString aStorName( pCurStorage->GetName() ); // #i13114 removed, DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); INetURLObject aCurStorageEntry(aStorName, INET_PROT_FILE); @@ -1066,14 +1072,16 @@ sal_Bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurS // #i13114 removed, DBG_ASSERT(aCurStorageEntry.GetMainURL( INetURLObject::NO_DECODE ).Len() != 0, "Bad storage name"); if ( aCurStorageEntry == aStorageEntry ) + { xStorage = pCurStorage; + } } if ( !xStorage.Is() ) + { xStorage = new SotStorage( sal_False, aStorageName, eStorageReadMode ); - - SotStorageRef xBasicStorage = xStorage->OpenSotStorage - ( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)), eStorageReadMode, sal_False ); + } + SotStorageRef xBasicStorage = xStorage->OpenSotStorage( OUString(szBasicStorage), eStorageReadMode, sal_False ); if ( !xBasicStorage.Is() || xBasicStorage->GetError() ) { @@ -1097,7 +1105,9 @@ sal_Bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurS if ( !bInfosOnly ) { if ( !pLibInfo->GetLib().Is() ) + { pLibInfo->SetLib( new StarBASIC( GetStdLib(), mbDocMgr ) ); + } xBasicStream->SetBufferSize( 1024 ); xBasicStream->Seek( STREAM_SEEK_TO_BEGIN ); bLoaded = ImplLoadBasic( *xBasicStream, pLibInfo->GetLibRef() ); @@ -1130,7 +1140,7 @@ sal_Bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurS *xBasicStream >> nPasswordMarker; if ( ( nPasswordMarker == PASSWORD_MARKER ) && !xBasicStream->IsEof() ) { - String aPassword = xBasicStream->ReadUniOrByteString( + OUString aPassword = xBasicStream->ReadUniOrByteString( xBasicStream->GetStreamCharSet()); pLibInfo->SetPassword( aPassword ); } @@ -1177,7 +1187,9 @@ sal_Bool BasicManager::ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) { pNew->SetParent( rOldBasic->GetParent() ); if( pNew->GetParent() ) + { pNew->GetParent()->Insert( pNew ); + } pNew->SetFlag( SBX_EXTSEARCH ); } rOldBasic = pNew; @@ -1190,15 +1202,18 @@ sal_Bool BasicManager::ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) } } if ( bProtected ) + { rStrm.SetCryptMaskKey(rtl::OString()); + } return bLoaded; } void BasicManager::CheckModules( StarBASIC* pLib, sal_Bool bReference ) const { if ( !pLib ) + { return; - + } sal_Bool bModified = pLib->IsModified(); for ( sal_uInt16 nMod = 0; nMod < pLib->GetModules()->Count(); nMod++ ) @@ -1206,7 +1221,9 @@ void BasicManager::CheckModules( StarBASIC* pLib, sal_Bool bReference ) const SbModule* pModule = (SbModule*)pLib->GetModules()->Get( nMod ); DBG_ASSERT( pModule, "Modul nicht erhalten!" ); if ( !pModule->IsCompiled() && !StarBASIC::GetErrorCode() ) + { pLib->Compile( pModule ); + } } // #67477, AB 8.12.99 On demand compile in referenced libs should not @@ -1218,20 +1235,21 @@ void BasicManager::CheckModules( StarBASIC* pLib, sal_Bool bReference ) const } } -StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const String& rLibName, sal_Bool bReference ) +StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const OUString& rLibName, sal_Bool bReference ) { DBG_CHKTHIS( BasicManager, 0 ); - String aStorName( rStorage.GetName() ); - DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); + OUString aStorName( rStorage.GetName() ); + DBG_ASSERT( !aStorName.isEmpty(), "No Storage Name!" ); - String aStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); - DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); + OUString aStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); + DBG_ASSERT(!aStorageName.isEmpty() != 0, "Bad storage name"); - String aNewLibName( rLibName ); + OUString aNewLibName( rLibName ); while ( HasLib( aNewLibName ) ) - aNewLibName += '_'; - + { + aNewLibName += "_"; + } BasicLibInfo* pLibInfo = CreateLibInfo(); // Use original name otherwise ImpLoadLibrary failes... pLibInfo->SetLibName( rLibName ); @@ -1245,12 +1263,13 @@ StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const String& rLibName, s if ( bLoaded ) { if ( aNewLibName != rLibName ) + { SetLibName( nLibId, aNewLibName ); - + } if ( bReference ) { pLibInfo->GetLib()->SetModified( sal_False ); // Don't save in this case - pLibInfo->SetRelStorageName( String() ); + pLibInfo->SetRelStorageName( OUString() ); pLibInfo->IsReference() = sal_True; } else @@ -1265,10 +1284,8 @@ StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const String& rLibName, s pLibInfo = 0; } - if( pLibInfo ) - return &*pLibInfo->GetLib() ; - else - return 0; + return pLibInfo ? &*pLibInfo->GetLib() : 0; + } sal_Bool BasicManager::IsReference( sal_uInt16 nLib ) @@ -1278,8 +1295,9 @@ sal_Bool BasicManager::IsReference( sal_uInt16 nLib ) BasicLibInfo* pLibInfo = pLibs->GetObject( nLib ); DBG_ASSERT( pLibInfo, "Lib?!" ); if ( pLibInfo ) + { return pLibInfo->IsReference(); - + } return sal_False; } @@ -1311,14 +1329,18 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage { SotStorageRef xStorage; if ( !pLibInfo->IsExtern() ) + { xStorage = new SotStorage( sal_False, GetStorageName() ); + } else + { xStorage = new SotStorage( sal_False, pLibInfo->GetStorageName() ); + } - if ( xStorage->IsStorage( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)) ) ) + if ( xStorage->IsStorage( OUString(szBasicStorage) ) ) { SotStorageRef xBasicStorage = xStorage->OpenSotStorage - ( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)), STREAM_STD_READWRITE, sal_False ); + ( OUString(szBasicStorage), STREAM_STD_READWRITE, sal_False ); if ( !xBasicStorage.Is() || xBasicStorage->GetError() ) { @@ -1337,7 +1359,7 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage if ( aInfoList.empty() ) { xBasicStorage.Clear(); - xStorage->Remove( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)) ); + xStorage->Remove( OUString(szBasicStorage) ); xStorage->Commit(); // If no further Streams or SubStorages available, // delete the Storage, too. @@ -1345,7 +1367,7 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage xStorage->FillInfoList( &aInfoList ); if ( aInfoList.empty() ) { - String aName_( xStorage->GetName() ); + OUString aName_( xStorage->GetName() ); xStorage.Clear(); //*** TODO: Replace if still necessary //SfxContentHelper::Kill( aName ); @@ -1356,7 +1378,9 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage } } if ( pLibInfo->GetLib().Is() ) + { GetStdLib()->Remove( pLibInfo->GetLib() ); + } delete pLibs->Remove( pLibInfo ); return sal_True; // Remove was successful, del unimportant } @@ -1373,7 +1397,9 @@ StarBASIC* BasicManager::GetLib( sal_uInt16 nLib ) const BasicLibInfo* pInf = pLibs->GetObject( nLib ); DBG_ASSERT( pInf, "Lib existiert nicht!" ); if ( pInf ) + { return pInf->GetLib(); + } return 0; } @@ -1384,52 +1410,55 @@ StarBASIC* BasicManager::GetStdLib() const return pLib; } -StarBASIC* BasicManager::GetLib( const String& rName ) const +StarBASIC* BasicManager::GetLib( const OUString& rName ) const { DBG_CHKTHIS( BasicManager, 0 ); BasicLibInfo* pInf = pLibs->First(); while ( pInf ) { - if ( pInf->GetLibName().CompareIgnoreCaseToAscii( rName ) == COMPARE_EQUAL )// Check if available... + if ( pInf->GetLibName().equalsIgnoreAsciiCase( rName ))// Check if available... + { return pInf->GetLib(); - + } pInf = pLibs->Next(); } return 0; } -sal_uInt16 BasicManager::GetLibId( const String& rName ) const +sal_uInt16 BasicManager::GetLibId( const OUString& rName ) const { DBG_CHKTHIS( BasicManager, 0 ); BasicLibInfo* pInf = pLibs->First(); while ( pInf ) { - if ( pInf->GetLibName().CompareIgnoreCaseToAscii( rName ) == COMPARE_EQUAL ) + if ( pInf->GetLibName().equalsIgnoreAsciiCase( rName )) + { return (sal_uInt16)pLibs->GetCurPos(); - + } pInf = pLibs->Next(); } return LIB_NOTFOUND; } -sal_Bool BasicManager::HasLib( const String& rName ) const +sal_Bool BasicManager::HasLib( const OUString& rName ) const { DBG_CHKTHIS( BasicManager, 0 ); BasicLibInfo* pInf = pLibs->First(); while ( pInf ) { - if ( pInf->GetLibName().CompareIgnoreCaseToAscii( rName ) == COMPARE_EQUAL ) + if ( pInf->GetLibName().equalsIgnoreAsciiCase(rName)) + { return sal_True; - + } pInf = pLibs->Next(); } return sal_False; } -sal_Bool BasicManager::SetLibName( sal_uInt16 nLib, const String& rName ) +sal_Bool BasicManager::SetLibName( sal_uInt16 nLib, const OUString& rName ) { DBG_CHKTHIS( BasicManager, 0 ); @@ -1449,15 +1478,17 @@ sal_Bool BasicManager::SetLibName( sal_uInt16 nLib, const String& rName ) return sal_False; } -String BasicManager::GetLibName( sal_uInt16 nLib ) +OUString BasicManager::GetLibName( sal_uInt16 nLib ) { DBG_CHKTHIS( BasicManager, 0 ); BasicLibInfo* pLibInfo = pLibs->GetObject( nLib ); DBG_ASSERT( pLibInfo, "Lib?!" ); if ( pLibInfo ) + { return pLibInfo->GetLibName(); - return String(); + } + return OUString(); } sal_Bool BasicManager::LoadLib( sal_uInt16 nLib ) @@ -1472,7 +1503,7 @@ sal_Bool BasicManager::LoadLib( sal_uInt16 nLib ) uno::Reference< script::XLibraryContainer > xLibContainer = pLibInfo->GetLibraryContainer(); if( xLibContainer.is() ) { - String aLibName = pLibInfo->GetLibName(); + OUString aLibName = pLibInfo->GetLibName(); xLibContainer->loadLibrary( aLibName ); bDone = xLibContainer->isLibraryLoaded( aLibName );; } @@ -1489,18 +1520,19 @@ sal_Bool BasicManager::LoadLib( sal_uInt16 nLib ) } else { - StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, rtl::OUString(), ERRCODE_BUTTON_OK ); - aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_LIBNOTFOUND, rtl::OUString::valueOf(static_cast<sal_Int32>(nLib)))); + StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, OUString(), ERRCODE_BUTTON_OK ); + aErrors.push_back(BasicError(*pErrInf, BASERR_REASON_LIBNOTFOUND, OUString::valueOf(static_cast<sal_Int32>(nLib)))); } return bDone; } -StarBASIC* BasicManager::CreateLib( const String& rLibName ) +StarBASIC* BasicManager::CreateLib( const OUString& rLibName ) { DBG_CHKTHIS( BasicManager, 0 ); if ( GetLib( rLibName ) ) + { return 0; - + } BasicLibInfo* pLibInfo = CreateLibInfo(); StarBASIC* pNew = new StarBASIC( GetStdLib(), mbDocMgr ); GetStdLib()->Insert( pNew ); @@ -1512,14 +1544,14 @@ StarBASIC* BasicManager::CreateLib( const String& rLibName ) } // For XML import/export: -StarBASIC* BasicManager::CreateLib - ( const String& rLibName, const String& Password, const String& LinkTargetURL ) +StarBASIC* BasicManager::CreateLib( const OUString& rLibName, const OUString& Password, + const OUString& LinkTargetURL ) { // Ask if lib exists because standard lib is always there StarBASIC* pLib = GetLib( rLibName ); if( !pLib ) { - if( LinkTargetURL.Len() != 0 ) + if( !LinkTargetURL.isEmpty()) { SotStorageRef xStorage = new SotStorage( sal_False, LinkTargetURL, STREAM_READ | STREAM_SHARE_DENYWRITE ); if( !xStorage->GetError() ) @@ -1532,7 +1564,7 @@ StarBASIC* BasicManager::CreateLib else { pLib = CreateLib( rLibName ); - if( Password.Len() != 0 ) + if( Password.isEmpty()) { BasicLibInfo* pLibInfo = FindLibInfo( pLib ); pLibInfo ->SetPassword( Password ); @@ -1543,13 +1575,14 @@ StarBASIC* BasicManager::CreateLib return pLib; } -StarBASIC* BasicManager::CreateLibForLibContainer( const String& rLibName, +StarBASIC* BasicManager::CreateLibForLibContainer( const OUString& rLibName, const uno::Reference< script::XLibraryContainer >& xScriptCont ) { DBG_CHKTHIS( BasicManager, 0 ); if ( GetLib( rLibName ) ) + { return 0; - + } BasicLibInfo* pLibInfo = CreateLibInfo(); StarBASIC* pNew = new StarBASIC( GetStdLib(), mbDocMgr ); GetStdLib()->Insert( pNew ); @@ -1570,8 +1603,9 @@ BasicLibInfo* BasicManager::FindLibInfo( StarBASIC* pBasic ) const while ( pInf ) { if ( pInf->GetLib() == pBasic ) + { return pInf; - + } pInf = ((BasicManager*)this)->pLibs->Next(); } return 0; @@ -1586,8 +1620,9 @@ sal_Bool BasicManager::IsBasicModified() const while ( pInf ) { if ( pInf->GetLib().Is() && pInf->GetLib()->IsModified() ) + { return sal_True; - + } pInf = pLibs->Next(); } return sal_False; @@ -1617,7 +1652,7 @@ uno::Any BasicManager::SetGlobalUNOConstant( const sal_Char* _pAsciiName, const if ( !pStandardLib ) return aOldValue; - ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); + OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); // obtain the old value SbxVariable* pVariable = pStandardLib->Find( sVarName, SbxCLASS_OBJECT ); @@ -1684,13 +1719,21 @@ bool BasicManager::LegacyPsswdBinaryLimitExceeded( uno::Sequence< rtl::OUString namespace { - SbMethod* lcl_queryMacro( BasicManager* i_manager, String const& i_fullyQualifiedName ) + SbMethod* lcl_queryMacro( BasicManager* i_manager, OUString const& i_fullyQualifiedName ) { - sal_uInt16 nLast = 0; - String sMacro = i_fullyQualifiedName; - String sLibName = sMacro.GetToken( 0, '.', nLast ); - String sModule = sMacro.GetToken( 0, '.', nLast ); - sMacro.Erase( 0, nLast ); + sal_Int32 nLast = 0; + const OUString sParse = i_fullyQualifiedName; + OUString sLibName = sParse.getToken( (sal_Int32)0, (sal_Unicode)'.', nLast ); + OUString sModule = sParse.getToken( (sal_Int32)0, (sal_Unicode)'.', nLast ); + OUString sMacro; + if(nLast >= 0) + { + sMacro = OUString(sParse.getStr() + nLast, sParse.getLength() - nLast ); + } + else + { + sMacro = sParse; + } utl::TransliterationWrapper& rTransliteration = SbGlobal::GetTransliteration(); sal_uInt16 nLibCount = i_manager->GetLibCount(); @@ -1715,7 +1758,9 @@ namespace { SbMethod* pMethod = (SbMethod*)pMod->Find( sMacro, SbxCLASS_METHOD ); if( pMethod ) + { return pMethod; + } } } } @@ -1725,12 +1770,12 @@ namespace } } -bool BasicManager::HasMacro( String const& i_fullyQualifiedName ) const +bool BasicManager::HasMacro( OUString const& i_fullyQualifiedName ) const { return ( NULL != lcl_queryMacro( const_cast< BasicManager* >( this ), i_fullyQualifiedName ) ); } -ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ) +ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, SbxArray* i_arguments, SbxValue* i_retValue ) { SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName ); ErrCode nError = 0; @@ -1745,7 +1790,7 @@ ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, SbxArray return nError; } -ErrCode BasicManager::ExecuteMacro( String const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue ) +ErrCode BasicManager::ExecuteMacro( OUString const& i_fullyQualifiedName, String const& i_commaSeparatedArgs, SbxValue* i_retValue ) { SbMethod* pMethod = lcl_queryMacro( this, i_fullyQualifiedName ); if ( !pMethod ) diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index 372a298dcac4..a7bdb200444e 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -81,10 +81,10 @@ class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPas // OldBasicPassword interface - virtual void setLibraryPassword( const String& rLibraryName, const String& rPassword ); - virtual String getLibraryPassword( const String& rLibraryName ); - virtual void clearLibraryPassword( const String& rLibraryName ); - virtual sal_Bool hasLibraryPassword( const String& rLibraryName ); + virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ); + virtual OUString getLibraryPassword( const OUString& rLibraryName ); + virtual void clearLibraryPassword( const OUString& rLibraryName ); + virtual sal_Bool hasLibraryPassword( const OUString& rLibraryName ); virtual const sal_Char* SAL_CALL getInfoFileName() const; virtual const sal_Char* SAL_CALL getOldInfoFileName() const; diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 606db40bb4d6..0dfa8b40602a 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -85,12 +85,12 @@ const sal_Char* SAL_CALL SfxScriptLibraryContainer::getLibrariesDir() const { re // OldBasicPassword interface void SfxScriptLibraryContainer::setLibraryPassword - ( const String& rLibraryName, const String& rPassword ) + ( const OUString& rLibraryName, const OUString& rPassword ) { try { SfxLibrary* pImplLib = getImplLib( rLibraryName ); - if( rPassword.Len() ) + if( !rPassword.isEmpty() ) { pImplLib->mbDoc50Password = true; pImplLib->mbPasswordProtected = sal_True; @@ -100,16 +100,16 @@ void SfxScriptLibraryContainer::setLibraryPassword catch(const NoSuchElementException& ) {} } -String SfxScriptLibraryContainer::getLibraryPassword( const String& rLibraryName ) +OUString SfxScriptLibraryContainer::getLibraryPassword( const OUString& rLibraryName ) { SfxLibrary* pImplLib = getImplLib( rLibraryName ); - String aPassword; + OUString aPassword; if( pImplLib->mbPasswordVerified ) aPassword = pImplLib->maPassword; return aPassword; } -void SfxScriptLibraryContainer::clearLibraryPassword( const String& rLibraryName ) +void SfxScriptLibraryContainer::clearLibraryPassword( const OUString& rLibraryName ) { try { @@ -121,7 +121,7 @@ void SfxScriptLibraryContainer::clearLibraryPassword( const String& rLibraryName catch(const NoSuchElementException& ) {} } -sal_Bool SfxScriptLibraryContainer::hasLibraryPassword( const String& rLibraryName ) +sal_Bool SfxScriptLibraryContainer::hasLibraryPassword( const OUString& rLibraryName ) { SfxLibrary* pImplLib = getImplLib( rLibraryName ); return pImplLib->mbPasswordProtected; @@ -610,7 +610,7 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, if( pMod ) { OUString aCodeStreamName = aElementName; - aCodeStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".bin") ); + aCodeStreamName += ".bin"; try { uno::Reference< io::XStream > xCodeStream = xStorage->openStreamElement( @@ -656,7 +656,7 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, } OUString aSourceStreamName = aElementName; - aSourceStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".xml") ); + aSourceStreamName += ".xml"; try { uno::Reference< io::XStream > xSourceStream = xStorage->openStreamElement( @@ -723,7 +723,7 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, aElementInetObj.insertName( aElementName, sal_False, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL ); aElementInetObj.setExtension( OUString( "pba" ) ); - String aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ); + OUString aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ); if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { @@ -914,7 +914,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary } OUString aCodeStreamName= aElementName; - aCodeStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".bin") ); + aCodeStreamName += ".bin"; try { uno::Reference< io::XStream > xCodeStream = xLibraryStor->openStreamElement( @@ -947,7 +947,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary { // Access encrypted source stream OUString aSourceStreamName = aElementName; - aSourceStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".xml") ); + aSourceStreamName += ".xml"; try { uno::Reference< io::XStream > xSourceStream = xLibraryStor->openEncryptedStreamElement( @@ -1000,7 +1000,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary aElementInetObj.insertName( aElementName, sal_False, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL ); aElementInetObj.setExtension( OUString( "pba" ) ); - String aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ); + OUString aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ); uno::Reference< embed::XStorage > xElementRootStorage; try { diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index c0e94665a3fa..0c54df362190 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1004,11 +1004,12 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, SfxObjectShell* pSrcShell = pSrcDoc ? pSrcDoc->GetDocumentShell() : NULL; if ( pSrcShell ) { - rtl::OUString aLibName(RTL_CONSTASCII_USTRINGPARAM("Standard")); + rtl::OUString aLibName("Standard"); const BasicManager *pBasicManager = pSrcShell->GetBasicManager(); - if (pBasicManager && pBasicManager->GetName().Len() > 0) + if (pBasicManager && !pBasicManager->GetName().isEmpty() > 0) + { aLibName = pSrcShell->GetBasicManager()->GetName(); - + } rtl::OUString sCodeName; rtl::OUString sSource; uno::Reference< script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 4eb288cbefd7..85856993ba7d 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3091,24 +3091,27 @@ static uno::Any lcl_getSheetModule( const uno::Reference<table::XCellRange>& xCe BasicManager* pBasMgr = pDok->GetDocumentShell()->GetBasicManager(); uno::Reference< uno::XInterface > xIf; - if ( pBasMgr && pBasMgr->GetName().Len() ) + if ( pBasMgr && !pBasMgr->GetName().isEmpty() ) { String sProj = String( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( pDok->GetDocumentShell()->GetBasicManager()->GetName().Len() ) + if ( !pDok->GetDocumentShell()->GetBasicManager()->GetName().isEmpty() ) + { sProj = pDok->GetDocumentShell()->GetBasicManager()->GetName(); + } StarBASIC* pBasic = pDok->GetDocumentShell()->GetBasicManager()->GetLib( sProj ); if ( pBasic ) { SbModule* pMod = pBasic->FindModule( sCodeName ); if ( pMod ) + { xIf = pMod->GetUnoModule(); + } } } return uno::makeAny( xIf ); } -static bool -lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPar ) +static bool lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPar ) { bool bOk = false; try diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index e77f4caafef0..2c53a44e2a8c 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2651,9 +2651,11 @@ void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const rtl::OUString& sModul uno::Reference< container::XNameContainer > xLib; if( xLibContainer.is() ) { - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() ) + String aLibName( "Standard" ); + if ( rDocSh.GetBasicManager() && !rDocSh.GetBasicManager()->GetName().isEmpty() ) + { aLibName = rDocSh.GetBasicManager()->GetName(); + } uno::Any aLibAny = xLibContainer->getByName( aLibName ); aLibAny >>= xLib; } @@ -2697,9 +2699,11 @@ void VBA_DeleteModule( ScDocShell& rDocSh, const rtl::OUString& sModuleName ) uno::Reference< container::XNameContainer > xLib; if( xLibContainer.is() ) { - String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() ) + String aLibName( "Standard" ); + if ( rDocSh.GetBasicManager() && !rDocSh.GetBasicManager()->GetName().isEmpty() ) + { aLibName = rDocSh.GetBasicManager()->GetName(); + } uno::Any aLibAny = xLibContainer->getByName( aLibName ); aLibAny >>= xLib; } diff --git a/sc/source/ui/docshell/macromgr.cxx b/sc/source/ui/docshell/macromgr.cxx index f873b8c26942..66890f223942 100644 --- a/sc/source/ui/docshell/macromgr.cxx +++ b/sc/source/ui/docshell/macromgr.cxx @@ -143,12 +143,14 @@ void ScMacroManager::InitUserFuncData() { // Clear boost::unordered_map mhFuncToVolatile.clear(); - String sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + OUString sProjectName("Standard"); Reference< container::XContainer > xModuleContainer; SfxObjectShell* pShell = mpDoc->GetDocumentShell(); - if ( pShell && pShell->GetBasicManager()->GetName().Len() > 0 ) + if ( pShell && ! pShell->GetBasicManager()->GetName().isEmpty() > 0 ) + { sProjectName = pShell->GetBasicManager()->GetName(); + } try { Reference< script::XLibraryContainer > xLibraries( pShell->GetBasicContainer(), uno::UNO_QUERY_THROW ); diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index ee1768af053d..ac9d302aac73 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -896,7 +896,9 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce uno::Reference< script::provider::XScriptProviderSupplier > xSPS( m_xModel, uno::UNO_QUERY ); uno::Reference< script::provider::XScriptProvider > xScriptProvider; if ( xSPS.is() ) + { xScriptProvider = xSPS->getScriptProvider(); + } if ( xScriptProvider.is() && mpShell ) { std::list< TranslateInfo >::const_iterator txInfo = @@ -906,22 +908,24 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce BasicManager* pBasicManager = mpShell->GetBasicManager(); rtl::OUString sProject; rtl::OUString sScriptCode( evt.ScriptCode ); - // dialogs pass their own library, presence of Dot determines that - if ( sScriptCode.indexOf( '.' ) == -1 ) - { - //'Project' is a better default but I want to force failures - //rtl::OUString sMacroLoc("Project"); - sProject = rtl::OUString("Standard"); + // dialogs pass their own library, presence of Dot determines that + if ( sScriptCode.indexOf( '.' ) == -1 ) + { + //'Project' is a better default but I want to force failures + //rtl::OUString sMacroLoc("Project"); + sProject = "Standard"; - if ( pBasicManager->GetName().Len() > 0 ) - sProject = pBasicManager->GetName(); - } - else - { - sal_Int32 nIndex = sScriptCode.indexOf( '.' ); - sProject = sScriptCode.copy( 0, nIndex ); - sScriptCode = sScriptCode.copy( nIndex + 1 ); - } + if ( !pBasicManager->GetName().isEmpty() > 0 ) + { + sProject = pBasicManager->GetName(); + } + } + else + { + sal_Int32 nIndex = sScriptCode.indexOf( '.' ); + sProject = sScriptCode.copy( 0, nIndex ); + sScriptCode = sScriptCode.copy( nIndex + 1 ); + } rtl::OUString sMacroLoc = sProject; sMacroLoc = sMacroLoc.concat( rtl::OUString(".") ); sMacroLoc = sMacroLoc.concat( sScriptCode ).concat( rtl::OUString(".") ); @@ -954,9 +958,13 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce // !! translate arguments & emulate events where necessary Sequence< Any > aArguments; if ( (*txInfo).toVBA ) + { aArguments = (*txInfo).toVBA( evt.Arguments ); + } else + { aArguments = evt.Arguments; + } if ( aArguments.getLength() ) { // call basic event handlers for event @@ -971,7 +979,9 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) throw(RuntimeExce { uno::Any aDummyCaller = uno::makeAny( rtl::OUString("Error") ); if ( pRet ) + { ooo::vba::executeMacro( mpShell, url, aArguments, *pRet, aDummyCaller ); + } else { uno::Any aRet; diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index fa308568b59d..ffb4853e7ec1 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -1908,7 +1908,7 @@ ErrCode SfxMacroLoader::loadMacro( const ::rtl::OUString& rURL, com::sun::star:: aQualifiedMethod.Erase( nArgsPos - nHashPos - 1 ); } - if ( pBasMgr->HasMacro( aQualifiedMethod ) ) + if ( pBasMgr->HasMacro( OUString(aQualifiedMethod) ) ) { Any aOldThisComponent; const bool bSetDocMacroMode = ( pDoc != NULL ) && bIsDocBasic; diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 95fac205454e..846d7d20e6d0 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -123,10 +123,11 @@ public: { uno::Reference< beans::XPropertySet > xProps( mpDocShell->GetModel(), uno::UNO_QUERY_THROW ); uno::Reference< container::XNameAccess > xLibContainer( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW ); - rtl::OUString sProjectName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ) ); - if ( mpDocShell->GetBasicManager()->GetName().Len() ) + rtl::OUString sProjectName( "Standard"); + if ( !mpDocShell->GetBasicManager()->GetName().isEmpty() ) + { sProjectName = mpDocShell->GetBasicManager()->GetName(); - + } uno::Reference< container::XNameAccess > xLib( xLibContainer->getByName( sProjectName ), uno::UNO_QUERY_THROW ); uno::Sequence< rtl::OUString > sModuleNames = xLib->getElementNames(); uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY ); diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index a531e06cae89..f0f2f0641dc8 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -1154,7 +1154,7 @@ uno::Reference< XHelperInterface > getUnoDocModule( const String& aModName, SfxO { OUString sProj( "Standard" ); BasicManager* pBasMgr = pShell->GetBasicManager(); - if ( pBasMgr && pBasMgr->GetName().Len() ) + if ( pBasMgr && !pBasMgr->GetName().isEmpty() ) sProj = pBasMgr->GetName(); if( StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ) ) if( SbModule* pMod = pBasic->FindModule( aModName ) ) |