summaryrefslogtreecommitdiff
path: root/basic/source/uno/namecont.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 14:35:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-19 08:30:49 +0200
commit8b0a69498b025e13d9772689e9e4fa3d6b05e609 (patch)
tree5fce654b3e02cd08d85dc95655c97d7181517687 /basic/source/uno/namecont.cxx
parent5dccf84b14ed0e09262411295c5880f787342d59 (diff)
loplugin:flatten in basic
Change-Id: Icb8e3cda312b50c9a9f12f96bec1c746f41c8979 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92483 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source/uno/namecont.cxx')
-rw-r--r--basic/source/uno/namecont.cxx763
1 files changed, 382 insertions, 381 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 6a510e0cc313..0904dcb766c2 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -983,232 +983,232 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
}
}
- if( meInitMode == DEFAULT )
- {
- INetURLObject aUserBasicInetObj( maLibraryPath.getToken(1, ';') );
- OUString aStandardStr("Standard");
+ if( meInitMode != DEFAULT )
+ return;
- INetURLObject aPrevUserBasicInetObj_1( aUserBasicInetObj );
- aPrevUserBasicInetObj_1.removeSegment();
- INetURLObject aPrevUserBasicInetObj_2 = aPrevUserBasicInetObj_1;
- aPrevUserBasicInetObj_1.Append( "__basic_80" );
- aPrevUserBasicInetObj_2.Append( "__basic_80_2" );
+ INetURLObject aUserBasicInetObj( maLibraryPath.getToken(1, ';') );
+ OUString aStandardStr("Standard");
- // #i93163
- bool bCleanUp = false;
- try
+ INetURLObject aPrevUserBasicInetObj_1( aUserBasicInetObj );
+ aPrevUserBasicInetObj_1.removeSegment();
+ INetURLObject aPrevUserBasicInetObj_2 = aPrevUserBasicInetObj_1;
+ aPrevUserBasicInetObj_1.Append( "__basic_80" );
+ aPrevUserBasicInetObj_2.Append( "__basic_80_2" );
+
+ // #i93163
+ bool bCleanUp = false;
+ try
+ {
+ INetURLObject aPrevUserBasicInetObj = aPrevUserBasicInetObj_1;
+ OUString aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( mxSFI->isFolder( aPrevFolder ) )
{
- INetURLObject aPrevUserBasicInetObj = aPrevUserBasicInetObj_1;
- OUString aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevFolder ) )
+ // Check if Standard folder exists and is complete
+ INetURLObject aUserBasicStandardInetObj( aUserBasicInetObj );
+ aUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ INetURLObject aPrevUserBasicStandardInetObj( aPrevUserBasicInetObj );
+ aPrevUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ OUString aPrevStandardFolder = aPrevUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( mxSFI->isFolder( aPrevStandardFolder ) )
{
- // Check if Standard folder exists and is complete
- INetURLObject aUserBasicStandardInetObj( aUserBasicInetObj );
- aUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- INetURLObject aPrevUserBasicStandardInetObj( aPrevUserBasicInetObj );
- aPrevUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- OUString aPrevStandardFolder = aPrevUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevStandardFolder ) )
- {
- OUString aXlbExtension( "xlb" );
- OUString aCheckFileName;
-
- // Check if script.xlb exists
- aCheckFileName = "script";
- checkAndCopyFileImpl( aUserBasicStandardInetObj,
- aPrevUserBasicStandardInetObj,
- aCheckFileName, aXlbExtension, mxSFI );
-
- // Check if dialog.xlb exists
- aCheckFileName = "dialog";
- checkAndCopyFileImpl( aUserBasicStandardInetObj,
- aPrevUserBasicStandardInetObj,
- aCheckFileName, aXlbExtension, mxSFI );
-
- // Check if module1.xba exists
- aCheckFileName = "Module1";
- checkAndCopyFileImpl( aUserBasicStandardInetObj,
- aPrevUserBasicStandardInetObj,
- aCheckFileName, "xba", mxSFI );
- }
- else
- {
- OUString aStandardFolder = aUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- mxSFI->copy( aStandardFolder, aPrevStandardFolder );
- }
-
- OUString aPrevCopyToFolder = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- mxSFI->copy( aPrevFolder, aPrevCopyToFolder );
+ OUString aXlbExtension( "xlb" );
+ OUString aCheckFileName;
+
+ // Check if script.xlb exists
+ aCheckFileName = "script";
+ checkAndCopyFileImpl( aUserBasicStandardInetObj,
+ aPrevUserBasicStandardInetObj,
+ aCheckFileName, aXlbExtension, mxSFI );
+
+ // Check if dialog.xlb exists
+ aCheckFileName = "dialog";
+ checkAndCopyFileImpl( aUserBasicStandardInetObj,
+ aPrevUserBasicStandardInetObj,
+ aCheckFileName, aXlbExtension, mxSFI );
+
+ // Check if module1.xba exists
+ aCheckFileName = "Module1";
+ checkAndCopyFileImpl( aUserBasicStandardInetObj,
+ aPrevUserBasicStandardInetObj,
+ aCheckFileName, "xba", mxSFI );
}
else
{
- aPrevUserBasicInetObj = aPrevUserBasicInetObj_2;
- aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ OUString aStandardFolder = aUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ mxSFI->copy( aStandardFolder, aPrevStandardFolder );
}
- if( mxSFI->isFolder( aPrevFolder ) )
- {
- rtl::Reference<SfxLibraryContainer> pPrevCont = createInstanceImpl();
- // Rename previous basic folder to make storage URLs correct during initialisation
- OUString aFolderUserBasic = aUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- INetURLObject aUserBasicTmpInetObj( aUserBasicInetObj );
- aUserBasicTmpInetObj.removeSegment();
- aUserBasicTmpInetObj.Append( "__basic_tmp" );
- OUString aFolderTmp = aUserBasicTmpInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ OUString aPrevCopyToFolder = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ mxSFI->copy( aPrevFolder, aPrevCopyToFolder );
+ }
+ else
+ {
+ aPrevUserBasicInetObj = aPrevUserBasicInetObj_2;
+ aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ }
+ if( mxSFI->isFolder( aPrevFolder ) )
+ {
+ rtl::Reference<SfxLibraryContainer> pPrevCont = createInstanceImpl();
+
+ // Rename previous basic folder to make storage URLs correct during initialisation
+ OUString aFolderUserBasic = aUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ INetURLObject aUserBasicTmpInetObj( aUserBasicInetObj );
+ aUserBasicTmpInetObj.removeSegment();
+ aUserBasicTmpInetObj.Append( "__basic_tmp" );
+ OUString aFolderTmp = aUserBasicTmpInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- mxSFI->move( aFolderUserBasic, aFolderTmp );
+ mxSFI->move( aFolderUserBasic, aFolderTmp );
+ try
+ {
+ mxSFI->move( aPrevFolder, aFolderUserBasic );
+ }
+ catch(const Exception& )
+ {
+ // Move back user/basic folder
try
{
- mxSFI->move( aPrevFolder, aFolderUserBasic );
+ mxSFI->kill( aFolderUserBasic );
}
catch(const Exception& )
- {
- // Move back user/basic folder
- try
- {
- mxSFI->kill( aFolderUserBasic );
- }
- catch(const Exception& )
- {}
- mxSFI->move( aFolderTmp, aFolderUserBasic );
- throw;
- }
-
- INetURLObject aPrevUserBasicLibInfoInetObj( aUserBasicInetObj );
- aPrevUserBasicLibInfoInetObj.insertName( maInfoFileName, false, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- aPrevUserBasicLibInfoInetObj.setExtension( "xlc");
- OUString aLibInfoFileName = aPrevUserBasicLibInfoInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- Sequence<Any> aInitSeq( 1 );
- aInitSeq.getArray()[0] <<= aLibInfoFileName;
- GbMigrationSuppressErrors = true;
- pPrevCont->initialize( aInitSeq );
- GbMigrationSuppressErrors = false;
-
- // Rename folders back
- mxSFI->move( aFolderUserBasic, aPrevFolder );
+ {}
mxSFI->move( aFolderTmp, aFolderUserBasic );
+ throw;
+ }
- Sequence< OUString > aNames = pPrevCont->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nNameCount = aNames.getLength();
+ INetURLObject aPrevUserBasicLibInfoInetObj( aUserBasicInetObj );
+ aPrevUserBasicLibInfoInetObj.insertName( maInfoFileName, false, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ aPrevUserBasicLibInfoInetObj.setExtension( "xlc");
+ OUString aLibInfoFileName = aPrevUserBasicLibInfoInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ Sequence<Any> aInitSeq( 1 );
+ aInitSeq.getArray()[0] <<= aLibInfoFileName;
+ GbMigrationSuppressErrors = true;
+ pPrevCont->initialize( aInitSeq );
+ GbMigrationSuppressErrors = false;
+
+ // Rename folders back
+ mxSFI->move( aFolderUserBasic, aPrevFolder );
+ mxSFI->move( aFolderTmp, aFolderUserBasic );
+
+ Sequence< OUString > aNames = pPrevCont->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_Int32 nNameCount = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ {
+ OUString aLibName = pNames[ i ];
+ if( hasByName( aLibName ) )
{
- OUString aLibName = pNames[ i ];
- if( hasByName( aLibName ) )
+ if( aLibName == aStandardStr )
{
- if( aLibName == aStandardStr )
- {
- SfxLibrary* pImplLib = getImplLib( aStandardStr );
- OUString aStandardFolder = pImplLib->maStorageURL;
- mxSFI->kill( aStandardFolder );
- }
- else
- {
- continue;
- }
+ SfxLibrary* pImplLib = getImplLib( aStandardStr );
+ OUString aStandardFolder = pImplLib->maStorageURL;
+ mxSFI->kill( aStandardFolder );
}
+ else
+ {
+ continue;
+ }
+ }
- SfxLibrary* pImplLib = pPrevCont->getImplLib( aLibName );
- if( pImplLib->mbLink )
+ SfxLibrary* pImplLib = pPrevCont->getImplLib( aLibName );
+ if( pImplLib->mbLink )
+ {
+ OUString aStorageURL = pImplLib->maUnexpandedStorageURL;
+ bool bCreateLink = true;
+ if( aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ) != -1 ||
+ aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ) != -1 ||
+ aStorageURL.indexOf( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ) != -1 ||
+ aStorageURL.indexOf( "$(INST)" ) != -1 )
{
- OUString aStorageURL = pImplLib->maUnexpandedStorageURL;
- bool bCreateLink = true;
- if( aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ) != -1 ||
- aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ) != -1 ||
- aStorageURL.indexOf( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ) != -1 ||
- aStorageURL.indexOf( "$(INST)" ) != -1 )
- {
- bCreateLink = false;
- }
- if( bCreateLink )
- {
- createLibraryLink( aLibName, pImplLib->maStorageURL, pImplLib->mbReadOnly );
- }
+ bCreateLink = false;
}
- else
+ if( bCreateLink )
{
- // Move folder if not already done
- INetURLObject aUserBasicLibFolderInetObj( aUserBasicInetObj );
- aUserBasicLibFolderInetObj.Append( aLibName );
- OUString aLibFolder = aUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
-
- INetURLObject aPrevUserBasicLibFolderInetObj( aPrevUserBasicInetObj );
- aPrevUserBasicLibFolderInetObj.Append( aLibName );
- OUString aPrevLibFolder = aPrevUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ createLibraryLink( aLibName, pImplLib->maStorageURL, pImplLib->mbReadOnly );
+ }
+ }
+ else
+ {
+ // Move folder if not already done
+ INetURLObject aUserBasicLibFolderInetObj( aUserBasicInetObj );
+ aUserBasicLibFolderInetObj.Append( aLibName );
+ OUString aLibFolder = aUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevLibFolder ) && !mxSFI->isFolder( aLibFolder ) )
- {
- mxSFI->move( aPrevLibFolder, aLibFolder );
- }
+ INetURLObject aPrevUserBasicLibFolderInetObj( aPrevUserBasicInetObj );
+ aPrevUserBasicLibFolderInetObj.Append( aLibName );
+ OUString aPrevLibFolder = aPrevUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( aLibName == aStandardStr )
- {
- maNameContainer->removeByName( aLibName );
- }
+ if( mxSFI->isFolder( aPrevLibFolder ) && !mxSFI->isFolder( aLibFolder ) )
+ {
+ mxSFI->move( aPrevLibFolder, aLibFolder );
+ }
- // Create library
- Reference< XNameContainer > xLib = createLibrary( aLibName );
- SfxLibrary* pNewLib = static_cast< SfxLibrary* >( xLib.get() );
- pNewLib->mbLoaded = false;
- pNewLib->implSetModified( false );
- checkStorageURL( aLibFolder, pNewLib->maLibInfoFileURL,
- pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL );
-
- uno::Reference< embed::XStorage > xDummyStor;
- ::xmlscript::LibDescriptor aLibDesc;
- implLoadLibraryIndexFile( pNewLib, aLibDesc, xDummyStor, pNewLib->maLibInfoFileURL );
- implImportLibDescriptor( pNewLib, aLibDesc );
+ if( aLibName == aStandardStr )
+ {
+ maNameContainer->removeByName( aLibName );
}
+
+ // Create library
+ Reference< XNameContainer > xLib = createLibrary( aLibName );
+ SfxLibrary* pNewLib = static_cast< SfxLibrary* >( xLib.get() );
+ pNewLib->mbLoaded = false;
+ pNewLib->implSetModified( false );
+ checkStorageURL( aLibFolder, pNewLib->maLibInfoFileURL,
+ pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL );
+
+ uno::Reference< embed::XStorage > xDummyStor;
+ ::xmlscript::LibDescriptor aLibDesc;
+ implLoadLibraryIndexFile( pNewLib, aLibDesc, xDummyStor, pNewLib->maLibInfoFileURL );
+ implImportLibDescriptor( pNewLib, aLibDesc );
}
- mxSFI->kill( aPrevFolder );
}
+ mxSFI->kill( aPrevFolder );
}
- catch(const Exception&)
+ }
+ catch(const Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("basic", "Upgrade of Basic installation failed somehow" );
+ bCleanUp = true;
+ }
+
+ // #i93163
+ if( !bCleanUp )
+ return;
+
+ INetURLObject aPrevUserBasicInetObj_Err( aUserBasicInetObj );
+ aPrevUserBasicInetObj_Err.removeSegment();
+ aPrevUserBasicInetObj_Err.Append( "__basic_80_err" );
+ OUString aPrevFolder_Err = aPrevUserBasicInetObj_Err.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+
+ bool bSaved = false;
+ try
+ {
+ OUString aPrevFolder_1 = aPrevUserBasicInetObj_1.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( mxSFI->isFolder( aPrevFolder_1 ) )
{
- TOOLS_WARN_EXCEPTION("basic", "Upgrade of Basic installation failed somehow" );
- bCleanUp = true;
+ mxSFI->move( aPrevFolder_1, aPrevFolder_Err );
+ bSaved = true;
}
-
- // #i93163
- if( bCleanUp )
+ }
+ catch(const Exception& )
+ {}
+ try
+ {
+ OUString aPrevFolder_2 = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( !bSaved && mxSFI->isFolder( aPrevFolder_2 ) )
{
- INetURLObject aPrevUserBasicInetObj_Err( aUserBasicInetObj );
- aPrevUserBasicInetObj_Err.removeSegment();
- aPrevUserBasicInetObj_Err.Append( "__basic_80_err" );
- OUString aPrevFolder_Err = aPrevUserBasicInetObj_Err.GetMainURL( INetURLObject::DecodeMechanism::NONE );
-
- bool bSaved = false;
- try
- {
- OUString aPrevFolder_1 = aPrevUserBasicInetObj_1.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevFolder_1 ) )
- {
- mxSFI->move( aPrevFolder_1, aPrevFolder_Err );
- bSaved = true;
- }
- }
- catch(const Exception& )
- {}
- try
- {
- OUString aPrevFolder_2 = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( !bSaved && mxSFI->isFolder( aPrevFolder_2 ) )
- {
- mxSFI->move( aPrevFolder_2, aPrevFolder_Err );
- }
- else
- {
- mxSFI->kill( aPrevFolder_2 );
- }
- }
- catch(const Exception& )
- {}
+ mxSFI->move( aPrevFolder_2, aPrevFolder_Err );
+ }
+ else
+ {
+ mxSFI->kill( aPrevFolder_2 );
}
}
+ catch(const Exception& )
+ {}
}
void SfxLibraryContainer::implScanExtensions()
@@ -1715,21 +1715,21 @@ bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
void SfxLibraryContainer::implImportLibDescriptor( SfxLibrary* pLib,
::xmlscript::LibDescriptor const & rLib )
{
- if( !pLib->mbInitialised )
+ if( pLib->mbInitialised )
+ return;
+
+ sal_Int32 nElementCount = rLib.aElementNames.getLength();
+ const OUString* pElementNames = rLib.aElementNames.getConstArray();
+ Any aDummyElement = createEmptyLibraryElement();
+ for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
{
- sal_Int32 nElementCount = rLib.aElementNames.getLength();
- const OUString* pElementNames = rLib.aElementNames.getConstArray();
- Any aDummyElement = createEmptyLibraryElement();
- for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
- {
- pLib->maNameContainer->insertByName( pElementNames[i], aDummyElement );
- }
- pLib->mbPasswordProtected = rLib.bPasswordProtected;
- pLib->mbReadOnly = rLib.bReadOnly;
- pLib->mbPreload = rLib.bPreload;
- pLib->implSetModified( false );
- pLib->mbInitialised = true;
+ pLib->maNameContainer->insertByName( pElementNames[i], aDummyElement );
}
+ pLib->mbPasswordProtected = rLib.bPasswordProtected;
+ pLib->mbReadOnly = rLib.bReadOnly;
+ pLib->mbPreload = rLib.bPreload;
+ pLib->implSetModified( false );
+ pLib->mbInitialised = true;
}
@@ -2227,56 +2227,56 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
maModifiable.setModified( true );
// Delete library files, but not for linked libraries
- if( !pImplLib->mbLink )
+ if( pImplLib->mbLink )
+ return;
+
+ if( mxStorage.is() )
+ {
+ return;
+ }
+ if( xNameAccess->hasElements() )
{
- if( mxStorage.is() )
+ Sequence< OUString > aNames = pImplLib->getElementNames();
+ sal_Int32 nNameCount = aNames.getLength();
+ const OUString* pNames = aNames.getConstArray();
+ for( sal_Int32 i = 0 ; i < nNameCount ; ++i, ++pNames )
{
- return;
- }
- if( xNameAccess->hasElements() )
- {
- Sequence< OUString > aNames = pImplLib->getElementNames();
- sal_Int32 nNameCount = aNames.getLength();
- const OUString* pNames = aNames.getConstArray();
- for( sal_Int32 i = 0 ; i < nNameCount ; ++i, ++pNames )
- {
- pImplLib->removeElementWithoutChecks( *pNames, SfxLibrary::LibraryContainerAccess() );
- }
+ pImplLib->removeElementWithoutChecks( *pNames, SfxLibrary::LibraryContainerAccess() );
}
+ }
- // Delete index file
- createAppLibraryFolder( pImplLib, Name );
- OUString aLibInfoPath = pImplLib->maLibInfoFileURL;
- try
+ // Delete index file
+ createAppLibraryFolder( pImplLib, Name );
+ OUString aLibInfoPath = pImplLib->maLibInfoFileURL;
+ try
+ {
+ if( mxSFI->exists( aLibInfoPath ) )
{
- if( mxSFI->exists( aLibInfoPath ) )
- {
- mxSFI->kill( aLibInfoPath );
- }
+ mxSFI->kill( aLibInfoPath );
}
- catch(const Exception& ) {}
+ }
+ catch(const Exception& ) {}
- // Delete folder if empty
- INetURLObject aInetObj( maLibraryPath.getToken(1, ';') );
- aInetObj.insertName( Name, true, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ // Delete folder if empty
+ INetURLObject aInetObj( maLibraryPath.getToken(1, ';') );
+ aInetObj.insertName( Name, true, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- try
+ try
+ {
+ if( mxSFI->isFolder( aLibDirPath ) )
{
- if( mxSFI->isFolder( aLibDirPath ) )
+ Sequence< OUString > aContentSeq = mxSFI->getFolderContents( aLibDirPath, true );
+ sal_Int32 nCount = aContentSeq.getLength();
+ if( !nCount )
{
- Sequence< OUString > aContentSeq = mxSFI->getFolderContents( aLibDirPath, true );
- sal_Int32 nCount = aContentSeq.getLength();
- if( !nCount )
- {
- mxSFI->kill( aLibDirPath );
- }
+ mxSFI->kill( aLibDirPath );
}
}
- catch(const Exception& )
- {
- }
+ }
+ catch(const Exception& )
+ {
}
}
@@ -2299,132 +2299,132 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
bool bLoaded = pImplLib->mbLoaded;
pImplLib->mbLoaded = true;
- if( !bLoaded && xNameAccess->hasElements() )
+ if( !(!bLoaded && xNameAccess->hasElements()) )
+ return;
+
+ if( pImplLib->mbPasswordProtected )
{
- if( pImplLib->mbPasswordProtected )
- {
- implLoadPasswordLibrary( pImplLib, Name );
- return;
- }
+ implLoadPasswordLibrary( pImplLib, Name );
+ return;
+ }
- bool bLink = pImplLib->mbLink;
- bool bStorage = mxStorage.is() && !bLink;
+ bool bLink = pImplLib->mbLink;
+ bool bStorage = mxStorage.is() && !bLink;
- uno::Reference< embed::XStorage > xLibrariesStor;
- uno::Reference< embed::XStorage > xLibraryStor;
- if( bStorage )
- {
+ uno::Reference< embed::XStorage > xLibrariesStor;
+ uno::Reference< embed::XStorage > xLibraryStor;
+ if( bStorage )
+ {
#if OSL_DEBUG_LEVEL > 0
- try
- {
+ try
+ {
#endif
- xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
- SAL_WARN_IF(
- !xLibrariesStor.is(), "basic",
- ("The method must either throw exception or return a"
- " storage!"));
- if ( !xLibrariesStor.is() )
- {
- throw uno::RuntimeException("null returned from openStorageElement");
- }
-
- xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
- SAL_WARN_IF(
- !xLibraryStor.is(), "basic",
- ("The method must either throw exception or return a"
- " storage!"));
- if ( !xLibrariesStor.is() )
- {
- throw uno::RuntimeException("null returned from openStorageElement");
- }
-#if OSL_DEBUG_LEVEL > 0
+ xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
+ SAL_WARN_IF(
+ !xLibrariesStor.is(), "basic",
+ ("The method must either throw exception or return a"
+ " storage!"));
+ if ( !xLibrariesStor.is() )
+ {
+ throw uno::RuntimeException("null returned from openStorageElement");
}
- catch(const uno::Exception& )
+
+ xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
+ SAL_WARN_IF(
+ !xLibraryStor.is(), "basic",
+ ("The method must either throw exception or return a"
+ " storage!"));
+ if ( !xLibrariesStor.is() )
{
- TOOLS_WARN_EXCEPTION(
- "basic",
- "couldn't open sub storage for library \"" << Name << "\"");
- throw;
+ throw uno::RuntimeException("null returned from openStorageElement");
}
-#endif
+#if OSL_DEBUG_LEVEL > 0
}
+ catch(const uno::Exception& )
+ {
+ TOOLS_WARN_EXCEPTION(
+ "basic",
+ "couldn't open sub storage for library \"" << Name << "\"");
+ throw;
+ }
+#endif
+ }
- Sequence< OUString > aNames = pImplLib->getElementNames();
- sal_Int32 nNameCount = aNames.getLength();
- const OUString* pNames = aNames.getConstArray();
- for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ Sequence< OUString > aNames = pImplLib->getElementNames();
+ sal_Int32 nNameCount = aNames.getLength();
+ const OUString* pNames = aNames.getConstArray();
+ for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ {
+ OUString aElementName = pNames[ i ];
+
+ OUString aFile;
+ uno::Reference< io::XInputStream > xInStream;
+
+ if( bStorage )
{
- OUString aElementName = pNames[ i ];
+ uno::Reference< io::XStream > xElementStream;
- OUString aFile;
- uno::Reference< io::XInputStream > xInStream;
+ aFile = aElementName + ".xml";
- if( bStorage )
+ try
{
- uno::Reference< io::XStream > xElementStream;
-
- aFile = aElementName + ".xml";
+ xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
+ }
+ catch(const uno::Exception& )
+ {}
+ if( !xElementStream.is() )
+ {
+ // Check for EA2 document version with wrong extensions
+ aFile = aElementName + "." + maLibElementFileExtension;
try
{
xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
}
catch(const uno::Exception& )
{}
-
- if( !xElementStream.is() )
- {
- // Check for EA2 document version with wrong extensions
- aFile = aElementName + "." + maLibElementFileExtension;
- try
- {
- xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
- }
- catch(const uno::Exception& )
- {}
- }
-
- if ( xElementStream.is() )
- {
- xInStream = xElementStream->getInputStream();
- }
- if ( !xInStream.is() )
- {
- SAL_WARN(
- "basic",
- "couldn't open library element stream - attempted to"
- " open library \"" << Name << '"');
- throw RuntimeException("couldn't open library element stream", *this);
- }
}
- else
+
+ if ( xElementStream.is() )
{
- OUString aLibDirPath = pImplLib->maStorageURL;
- INetURLObject aElementInetObj( aLibDirPath );
- aElementInetObj.insertName( aElementName, false,
- INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- aElementInetObj.setExtension( maLibElementFileExtension );
- aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ xInStream = xElementStream->getInputStream();
}
-
- Reference< XNameContainer > xLib( pImplLib );
- Any aAny = importLibraryElement( xLib, aElementName,
- aFile, xInStream );
- if( pImplLib->hasByName( aElementName ) )
+ if ( !xInStream.is() )
{
- if( aAny.hasValue() )
- {
- pImplLib->maNameContainer->replaceByName( aElementName, aAny );
- }
+ SAL_WARN(
+ "basic",
+ "couldn't open library element stream - attempted to"
+ " open library \"" << Name << '"');
+ throw RuntimeException("couldn't open library element stream", *this);
}
- else
+ }
+ else
+ {
+ OUString aLibDirPath = pImplLib->maStorageURL;
+ INetURLObject aElementInetObj( aLibDirPath );
+ aElementInetObj.insertName( aElementName, false,
+ INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ aElementInetObj.setExtension( maLibElementFileExtension );
+ aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ }
+
+ Reference< XNameContainer > xLib( pImplLib );
+ Any aAny = importLibraryElement( xLib, aElementName,
+ aFile, xInStream );
+ if( pImplLib->hasByName( aElementName ) )
+ {
+ if( aAny.hasValue() )
{
- pImplLib->maNameContainer->insertNoCheck(aElementName, aAny);
+ pImplLib->maNameContainer->replaceByName( aElementName, aAny );
}
}
- pImplLib->implSetModified( false );
+ else
+ {
+ pImplLib->maNameContainer->insertNoCheck(aElementName, aAny);
+ }
}
+ pImplLib->implSetModified( false );
}
// Methods XLibraryContainer2
@@ -2801,34 +2801,35 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( sal_Bool _vbacompatm
to getBasicManager() may call getVBACompatibilityMode() which returns
this value. */
mbVBACompat = _vbacompatmodeon;
- if( BasicManager* pBasMgr = getBasicManager() )
+ BasicManager* pBasMgr = getBasicManager();
+ if( !pBasMgr )
+ return;
+
+ // get the standard library
+ OUString aLibName = pBasMgr->GetName();
+ if ( aLibName.isEmpty())
+ {
+ aLibName = "Standard";
+ }
+ if( StarBASIC* pBasic = pBasMgr->GetLib( aLibName ) )
+ {
+ pBasic->SetVBAEnabled( _vbacompatmodeon );
+ }
+ /* If in VBA compatibility mode, force creation of the VBA Globals
+ object. Each application will create an instance of its own
+ implementation and store it in its Basic manager. Implementations
+ will do all necessary additional initialization, such as
+ registering the global "This***Doc" UNO constant, starting the
+ document events processor etc.
+ */
+ if( mbVBACompat ) try
+ {
+ Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
+ Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
+ xFactory->createInstance("ooo.vba.VBAGlobals");
+ }
+ catch(const Exception& )
{
- // get the standard library
- OUString aLibName = pBasMgr->GetName();
- if ( aLibName.isEmpty())
- {
- aLibName = "Standard";
- }
- if( StarBASIC* pBasic = pBasMgr->GetLib( aLibName ) )
- {
- pBasic->SetVBAEnabled( _vbacompatmodeon );
- }
- /* If in VBA compatibility mode, force creation of the VBA Globals
- object. Each application will create an instance of its own
- implementation and store it in its Basic manager. Implementations
- will do all necessary additional initialization, such as
- registering the global "This***Doc" UNO constant, starting the
- document events processor etc.
- */
- if( mbVBACompat ) try
- {
- Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
- Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
- xFactory->createInstance("ooo.vba.VBAGlobals");
- }
- catch(const Exception& )
- {
- }
}
}
@@ -3066,27 +3067,27 @@ void SfxLibrary::impl_removeWithoutChecks( const OUString& _rElementName )
implSetModified( true );
// Remove element file
- if( !maStorageURL.isEmpty() )
- {
- INetURLObject aElementInetObj( maStorageURL );
- aElementInetObj.insertName( _rElementName, false,
- INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- aElementInetObj.setExtension( maLibElementFileExtension );
- OUString aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( maStorageURL.isEmpty() )
+ return;
- try
- {
- if( mxSFI->exists( aFile ) )
- {
- mxSFI->kill( aFile );
- }
- }
- catch(const Exception& )
+ INetURLObject aElementInetObj( maStorageURL );
+ aElementInetObj.insertName( _rElementName, false,
+ INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ aElementInetObj.setExtension( maLibElementFileExtension );
+ OUString aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+
+ try
+ {
+ if( mxSFI->exists( aFile ) )
{
- DBG_UNHANDLED_EXCEPTION("basic");
+ mxSFI->kill( aFile );
}
}
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basic");
+ }
}
void SfxLibrary::removeByName( const OUString& Name )