diff options
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/app/basic.src | 4 | ||||
-rw-r--r-- | basic/source/basmgr/basmgr.cxx | 27 | ||||
-rw-r--r-- | basic/source/classes/sb.cxx | 7 | ||||
-rw-r--r--[-rwxr-xr-x] | basic/source/classes/sbunoobj.cxx | 14 | ||||
-rw-r--r-- | basic/source/uno/namecont.cxx | 157 |
5 files changed, 129 insertions, 80 deletions
diff --git a/basic/source/app/basic.src b/basic/source/app/basic.src index fe7bcff7f6b3..0713fd859f56 100644 --- a/basic/source/app/basic.src +++ b/basic/source/app/basic.src @@ -87,7 +87,7 @@ ModalDialog IDD_ABOUT_DIALOG { FixedText { Pos = MAP_APPFONT( 40, 60 ); Size = MAP_APPFONT( 110, 10 ); - TEXT = "1995 Sun Microsystems, Inc."; + TEXT = "1995-2010 Oracle"; CENTER = TRUE; }; }; @@ -127,7 +127,7 @@ ModalDialog IDD_TT_ABOUT_DIALOG { Pos = MAP_APPFONT( 5, 40 ); Size = MAP_APPFONT( 110, 10 ); CENTER = TRUE; - TEXT[ en-US ] = "©1995-2005 Sun Microsystems, Inc."; + TEXT[ en-US ] = "©1995-2010 Oracle"; }; OKButton RID_OK { Pos = MAP_APPFONT( 40, 60 ); diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index da792f269fc9..7646667bc277 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -97,20 +97,13 @@ typedef WeakImplHelper1< XStarBasicAccess > StarBasicAccessHelper; // + BOOL bReference static const char* szStdLibName = "Standard"; -static const char* szBasicStorage = "StarBASIC"; +static const char szBasicStorage[] = "StarBASIC"; static const char* szOldManagerStream = "BasicManager"; -static const char* szManagerStream = "BasicManager2"; +static const char szManagerStream[] = "BasicManager2"; static const char* szImbedded = "LIBIMBEDDED"; static const char* szCryptingKey = "CryptedBasic"; static const char* szScriptLanguage = "StarBasic"; -static const String BasicStreamName( String::CreateFromAscii(szBasicStorage) ); -static const String ManagerStreamName( String::CreateFromAscii(szManagerStream) ); - - -#define DEFINE_CONST_UNICODE(CONSTASCII) UniString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII)) - - TYPEINIT1( BasicManager, SfxBroadcaster ); DBG_NAME( BasicManager ); @@ -666,7 +659,7 @@ BasicManager::BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBA // DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); // If there is no Manager Stream, no further actions are necessary - if ( rStorage.IsStream( ManagerStreamName ) ) + if ( rStorage.IsStream( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)) ) ) { LoadBasicManager( rStorage, rBaseURL ); // StdLib contains Parent: @@ -707,12 +700,12 @@ 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 - ( ManagerStreamName, eStreamReadMode ); + ( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)), eStreamReadMode ); mpImpl->mpManagerStream = new SvMemoryStream(); *static_cast<SvStream*>(&xManagerStream) >> *mpImpl->mpManagerStream; SotStorageRef xBasicStorage = rStorage.OpenSotStorage - ( BasicStreamName, eStorageReadMode, FALSE ); + ( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)), eStorageReadMode, FALSE ); if( xBasicStorage.Is() && !xBasicStorage->GetError() ) { USHORT nLibs = GetLibCount(); @@ -921,7 +914,7 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR // StreamMode eStreamMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE; SotStorageStreamRef xManagerStream = rStorage.OpenSotStream - ( ManagerStreamName, eStreamReadMode ); + ( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)), eStreamReadMode ); String aStorName( rStorage.GetName() ); // #i13114 removed, DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); @@ -1169,7 +1162,7 @@ BOOL BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurStorag xStorage = new SotStorage( FALSE, aStorageName, eStorageReadMode ); SotStorageRef xBasicStorage = xStorage->OpenSotStorage - ( BasicStreamName, eStorageReadMode, FALSE ); + ( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)), eStorageReadMode, FALSE ); if ( !xBasicStorage.Is() || xBasicStorage->GetError() ) { @@ -1422,10 +1415,10 @@ BOOL BasicManager::RemoveLib( USHORT nLib, BOOL bDelBasicFromStorage ) else xStorage = new SotStorage( FALSE, pLibInfo->GetStorageName() ); - if ( xStorage->IsStorage( BasicStreamName ) ) + if ( xStorage->IsStorage( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)) ) ) { SotStorageRef xBasicStorage = xStorage->OpenSotStorage - ( BasicStreamName, STREAM_STD_READWRITE, FALSE ); + ( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)), STREAM_STD_READWRITE, FALSE ); if ( !xBasicStorage.Is() || xBasicStorage->GetError() ) { @@ -1445,7 +1438,7 @@ BOOL BasicManager::RemoveLib( USHORT nLib, BOOL bDelBasicFromStorage ) if ( !aInfoList.Count() ) { xBasicStorage.Clear(); - xStorage->Remove( BasicStreamName ); + xStorage->Remove( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)) ); xStorage->Commit(); // If no further Streams or SubStorages available, // delete the Storage, too. diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index c5ac53c43092..86850d9991c6 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -64,20 +64,17 @@ TYPEINIT1(StarBASIC,SbxObject) #define RTLNAME "@SBRTL" // i#i68894# -const static String aThisComponent( RTL_CONSTASCII_USTRINGPARAM("ThisComponent") ); -const static String aVBAHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) ); - SbxObject* StarBASIC::getVBAGlobals( ) { if ( !pVBAGlobals ) - pVBAGlobals = (SbUnoObject*)Find( aVBAHook , SbxCLASS_DONTCARE ); + pVBAGlobals = (SbUnoObject*)Find( String(RTL_CONSTASCII_USTRINGPARAM("VBAGlobals")), SbxCLASS_DONTCARE ); return pVBAGlobals; } // i#i68894# SbxVariable* StarBASIC::VBAFind( const String& rName, SbxClassType t ) { - if( rName == aThisComponent ) + if( rName.EqualsAscii("ThisComponent") ) return NULL; // rename to init globals if ( getVBAGlobals( ) ) diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 476dfbc90686..f9ff0b6dbeb2 100755..100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -112,9 +112,9 @@ typedef WeakImplHelper1< XAllListener > BasicAllListenerHelper; // Identifier fuer die dbg_-Properies als Strings anlegen -static String ID_DBG_SUPPORTEDINTERFACES( RTL_CONSTASCII_USTRINGPARAM("Dbg_SupportedInterfaces") ); -static String ID_DBG_PROPERTIES( RTL_CONSTASCII_USTRINGPARAM("Dbg_Properties") ); -static String ID_DBG_METHODS( RTL_CONSTASCII_USTRINGPARAM("Dbg_Methods") ); +static char const ID_DBG_SUPPORTEDINTERFACES[] = "Dbg_SupportedInterfaces"; +static char const ID_DBG_PROPERTIES[] = "Dbg_Properties"; +static char const ID_DBG_METHODS[] = "Dbg_Methods"; static ::rtl::OUString aSeqLevelStr( RTL_CONSTASCII_USTRINGPARAM("[]") ); static ::rtl::OUString defaultNameSpace( RTL_CONSTASCII_USTRINGPARAM("ooo.vba") ); @@ -1630,7 +1630,7 @@ String Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj ) String aRet; if( eType != TypeClass_INTERFACE ) { - aRet += ID_DBG_SUPPORTEDINTERFACES; + aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM(ID_DBG_SUPPORTEDINTERFACES) ); aRet.AppendAscii( " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" ); } else @@ -2653,15 +2653,15 @@ void SbUnoObject::implCreateDbgProperties( void ) Property aProp; // Id == -1: Implementierte Interfaces gemaess ClassProvider anzeigen - SbxVariableRef xVarRef = new SbUnoProperty( ID_DBG_SUPPORTEDINTERFACES, SbxSTRING, aProp, -1, false ); + SbxVariableRef xVarRef = new SbUnoProperty( String(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_SUPPORTEDINTERFACES)), SbxSTRING, aProp, -1, false ); QuickInsert( (SbxVariable*)xVarRef ); // Id == -2: Properties ausgeben - xVarRef = new SbUnoProperty( ID_DBG_PROPERTIES, SbxSTRING, aProp, -2, false ); + xVarRef = new SbUnoProperty( String(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_PROPERTIES)), SbxSTRING, aProp, -2, false ); QuickInsert( (SbxVariable*)xVarRef ); // Id == -3: Methoden ausgeben - xVarRef = new SbUnoProperty( ID_DBG_METHODS, SbxSTRING, aProp, -3, false ); + xVarRef = new SbUnoProperty( String(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_METHODS)), SbxSTRING, aProp, -3, false ); QuickInsert( (SbxVariable*)xVarRef ); } diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index 6ccb7e81d2c4..14c84420dad6 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -1744,7 +1744,7 @@ void SfxLibraryContainer::implImportLibDescriptor // Methods of new XLibraryStorage interface? -void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& xStorage, sal_Bool bComplete ) +void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& i_rStorage, sal_Bool bComplete ) { const Sequence< OUString > aNames = maNameContainer.getElementNames(); sal_Int32 nNameCount = aNames.getLength(); @@ -1765,35 +1765,13 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto ::xmlscript::LibDescriptorArray* pLibArray = new ::xmlscript::LibDescriptorArray( nLibsToSave ); // Write to storage? - sal_Bool bStorage = xStorage.is(); - uno::Reference< embed::XStorage > xLibrariesStor; + sal_Bool bStorage = i_rStorage.is(); uno::Reference< embed::XStorage > xSourceLibrariesStor; - if( bStorage ) + uno::Reference< embed::XStorage > xTargetLibrariesStor; + ::rtl::OUString sTempTargetStorName; + const bool bInplaceStorage = bStorage && ( i_rStorage == mxStorage ); + if ( bStorage ) { - // when we save to our root storage, ensure the libs are all loaded. Else the below cleaning - // of the target storage will loose them. - if ( xStorage == mxStorage ) - { - pName = aNames.getConstArray(); - for ( ; pName != pNamesEnd; ++pName ) - { - if ( !isLibraryLoaded( *pName ) ) - loadLibrary( *pName ); - } - } - - // first of all, clean the target library storage, since the storing procedure must do overwrite - try - { - if ( xStorage->hasByName( maLibrariesDir ) ) - xStorage->removeElement( maLibrariesDir ); - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - return; - } - // Don't write if only empty standard lib exists if ( ( nNameCount == 1 ) && ( aNames[0].equalsAscii( "Standard" ) ) ) { @@ -1804,29 +1782,54 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto return; } - try { - xLibrariesStor.set( xStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READWRITE ), UNO_QUERY_THROW ); + // create the empty target storage + try + { + ::rtl::OUString sTargetLibrariesStoreName; + if ( bInplaceStorage ) + { + // create a temporary target storage + const ::rtl::OUStringBuffer aTempTargetNameBase = maLibrariesDir + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_temp_" ) ); + sal_Int32 index = 0; + do + { + ::rtl::OUStringBuffer aTempTargetName( aTempTargetNameBase ); + aTempTargetName.append( index++ ); + + sTargetLibrariesStoreName = aTempTargetName.makeStringAndClear(); + if ( !i_rStorage->hasByName( sTargetLibrariesStoreName ) ) + break; + } + while ( true ); + sTempTargetStorName = sTargetLibrariesStoreName; + } + else + { + sTargetLibrariesStoreName = maLibrariesDir; + if ( i_rStorage->hasByName( sTargetLibrariesStoreName ) ) + i_rStorage->removeElement( sTargetLibrariesStoreName ); + } + + xTargetLibrariesStor.set( i_rStorage->openStorageElement( sTargetLibrariesStoreName, embed::ElementModes::READWRITE ), UNO_QUERY_THROW ); } - catch( uno::Exception& ) + catch( const uno::Exception& ) { - #if OSL_DEBUG_LEVEL > 0 - Any aError( ::cppu::getCaughtException() ); - ::rtl::OStringBuffer aMessage; - aMessage.append( "couln't open source library storage.\n\nException:" ); - aMessage.append( ::rtl::OUStringToOString( ::comphelper::anyToString( aError ), osl_getThreadTextEncoding() ) ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); - #endif + DBG_UNHANDLED_EXCEPTION(); return; } + // open the source storage which might be used to copy yet-unmodified libraries try { - if ( ( mxStorage != xStorage ) && ( mxStorage->hasByName( maLibrariesDir ) ) ) - xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ ); + if ( mxStorage->hasByName( maLibrariesDir ) ) + xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, bInplaceStorage ? embed::ElementModes::READWRITE : embed::ElementModes::READ ); + else if ( bInplaceStorage ) + xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READWRITE ); } catch( const uno::Exception& ) { DBG_UNHANDLED_EXCEPTION(); + return; } } @@ -1838,7 +1841,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto SfxLibrary* pImplLib = getImplLib( *pName ); if( pImplLib->mbSharedIndexFile ) continue; - bool bExtensionLib = pImplLib->mbExtension; + const bool bExtensionLib = pImplLib->mbExtension; ::xmlscript::LibDescriptor& rLib = bExtensionLib ? aLibDescriptorForExtensionLibs : pLibArray->mpLibs[iArray]; if( !bExtensionLib ) @@ -1858,12 +1861,14 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto if( pImplLib->implIsModified() || bComplete ) { - // Can we copy the storage? + // Can we simply copy the storage? if( !mbOldInfoFormat && !pImplLib->implIsModified() && !mbOasis2OOoFormat && xSourceLibrariesStor.is() ) { - try { - xSourceLibrariesStor->copyElementTo( rLib.aName, xLibrariesStor, rLib.aName ); - } catch( uno::Exception& ) + try + { + xSourceLibrariesStor->copyElementTo( rLib.aName, xTargetLibrariesStor, rLib.aName ); + } + catch( const uno::Exception& ) { DBG_UNHANDLED_EXCEPTION(); // TODO: error handling? @@ -1876,7 +1881,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto { try { - xLibraryStor = xLibrariesStor->openStorageElement( + xLibraryStor = xTargetLibrariesStor->openStorageElement( rLib.aName, embed::ElementModes::READWRITE ); } @@ -1908,7 +1913,8 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto implStoreLibraryIndexFile( pImplLib, rLib, xLibraryStor ); if( bStorage ) { - try { + try + { uno::Reference< embed::XTransactedObject > xTransact( xLibraryStor, uno::UNO_QUERY_THROW ); xTransact->commit(); } @@ -1928,6 +1934,59 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto rLib.bReadOnly = pImplLib->mbReadOnlyLink; } + // if we did an in-place save into a storage (i.e. a save into the storage we were already based on), + // then we need to clean up the temporary storage we used for this + if ( bInplaceStorage && sTempTargetStorName.getLength() ) + { + OSL_ENSURE( xSourceLibrariesStor.is(), "SfxLibrariesContainer::storeLibraries_impl: unexpected: we should have a source storage here!" ); + try + { + // for this, we first remove everything from the source storage, then copy the complete content + // from the temporary target storage. From then on, what used to be the "source storage" becomes + // the "targt storage" for all subsequent operations. + + // (We cannot simply remove the storage, denoted by maLibrariesDir, from i_rStorage - there might be + // open references to it.) + + if ( xSourceLibrariesStor.is() ) + { + // remove + const Sequence< ::rtl::OUString > aRemoveNames( xSourceLibrariesStor->getElementNames() ); + for ( const ::rtl::OUString* pRemoveName = aRemoveNames.getConstArray(); + pRemoveName != aRemoveNames.getConstArray() + aRemoveNames.getLength(); + ++pRemoveName + ) + { + xSourceLibrariesStor->removeElement( *pRemoveName ); + } + + // copy + const Sequence< ::rtl::OUString > aCopyNames( xTargetLibrariesStor->getElementNames() ); + for ( const ::rtl::OUString* pCopyName = aCopyNames.getConstArray(); + pCopyName != aCopyNames.getConstArray() + aCopyNames.getLength(); + ++pCopyName + ) + { + xTargetLibrariesStor->copyElementTo( *pCopyName, xSourceLibrariesStor, *pCopyName ); + } + } + + // close and remove temp target + xTargetLibrariesStor->dispose(); + i_rStorage->removeElement( sTempTargetStorName ); + xTargetLibrariesStor.clear(); + sTempTargetStorName = ::rtl::OUString(); + + // adjust target + xTargetLibrariesStor = xSourceLibrariesStor; + xSourceLibrariesStor.clear(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + if( !mbOldInfoFormat && !maModifiable.isModified() ) return; maModifiable.setModified( sal_False ); @@ -1953,7 +2012,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto aStreamName += String( RTL_CONSTASCII_USTRINGPARAM("-lc.xml") ); try { - xInfoStream = xLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE ); + xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE ); uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY ); OSL_ENSURE ( xProps.is(), "The stream must implement XPropertySet!\n" ); if ( !xProps.is() ) @@ -2012,7 +2071,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto xmlscript::exportLibraryContainer( xHandler, pLibArray ); if ( bStorage ) { - uno::Reference< embed::XTransactedObject > xTransact( xLibrariesStor, uno::UNO_QUERY ); + uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY ); OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" ); if ( !xTransact.is() ) throw uno::RuntimeException(); |