summaryrefslogtreecommitdiffstats
path: root/basic/source/uno/namecont.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/uno/namecont.cxx')
-rw-r--r--basic/source/uno/namecont.cxx245
1 files changed, 163 insertions, 82 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index b92f5a590617..228220182811 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -25,11 +25,14 @@
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/lang/NoSupportException.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ucb/ContentCreationException.hpp>
#include <com/sun/star/xml/sax/SAXException.hpp>
+#include <utility>
#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
#include <osl/mutex.hxx>
#include <vcl/errinf.hxx>
#include <rtl/ustring.hxx>
@@ -41,7 +44,7 @@
#include <namecont.hxx>
#include <basic/basicmanagerrepository.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
#include <unotools/pathoptions.hxx>
#include <svtools/sfxecode.hxx>
@@ -87,7 +90,6 @@ using namespace com::sun::star::frame;
using namespace com::sun::star::deployment;
using namespace com::sun::star;
using namespace cppu;
-using namespace osl;
using com::sun::star::uno::Reference;
@@ -141,7 +143,7 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement )
const Type& aAnyType = aElement.getValueType();
if( mType != aAnyType )
{
- throw IllegalArgumentException("types do not match", static_cast<cppu::OWeakObject*>(this), 2);
+ throw IllegalArgumentException("types do not match", getXWeak(), 2);
}
NameContainerNameMap::iterator aIt = mHashMap.find( aName );
if( aIt == mHashMap.end() )
@@ -153,27 +155,29 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement )
mValues[ iHashResult ] = aElement;
+ std::unique_lock aGuard(m_aMutex);
+
// Fire event
- if( maContainerListeners.getLength() > 0 )
+ if( maContainerListeners.getLength(aGuard) > 0 )
{
ContainerEvent aEvent;
aEvent.Source = mpxEventSource;
aEvent.Accessor <<= aName;
aEvent.Element = aElement;
aEvent.ReplacedElement = aOldElement;
- maContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvent );
+ maContainerListeners.notifyEach( aGuard, &XContainerListener::elementReplaced, aEvent );
}
/* After the container event has been fired (one listener will update the
core Basic manager), fire change event. Listeners can rely on that the
Basic source code of the core Basic manager is up-to-date. */
- if( maChangesListeners.getLength() > 0 )
+ if( maChangesListeners.getLength(aGuard) > 0 )
{
ChangesEvent aEvent;
aEvent.Source = mpxEventSource;
aEvent.Base <<= aEvent.Source;
aEvent.Changes = { { Any(aName), aElement, aOldElement } };
- maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent );
+ maChangesListeners.notifyEach( aGuard, &XChangesListener::changesOccurred, aEvent );
}
}
@@ -192,7 +196,7 @@ void NameContainer::insertNoCheck(const OUString& aName, const Any& aElement)
const Type& aAnyType = aElement.getValueType();
if( mType != aAnyType )
{
- throw IllegalArgumentException("types do not match", static_cast<cppu::OWeakObject*>(this), 2);
+ throw IllegalArgumentException("types do not match", getXWeak(), 2);
}
sal_Int32 nCount = mNames.size();
@@ -202,26 +206,28 @@ void NameContainer::insertNoCheck(const OUString& aName, const Any& aElement)
mHashMap[ aName ] = nCount;
mnElementCount++;
+ std::unique_lock aGuard(m_aMutex);
+
// Fire event
- if( maContainerListeners.getLength() > 0 )
+ if( maContainerListeners.getLength(aGuard) > 0 )
{
ContainerEvent aEvent;
aEvent.Source = mpxEventSource;
aEvent.Accessor <<= aName;
aEvent.Element = aElement;
- maContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent );
+ maContainerListeners.notifyEach( aGuard, &XContainerListener::elementInserted, aEvent );
}
/* After the container event has been fired (one listener will update the
core Basic manager), fire change event. Listeners can rely on that the
Basic source code of the core Basic manager is up-to-date. */
- if( maChangesListeners.getLength() > 0 )
+ if( maChangesListeners.getLength(aGuard) > 0 )
{
ChangesEvent aEvent;
aEvent.Source = mpxEventSource;
aEvent.Base <<= aEvent.Source;
aEvent.Changes = { { Any(aName), aElement, {} } };
- maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent );
+ maChangesListeners.notifyEach( aGuard, &XChangesListener::changesOccurred, aEvent );
}
}
@@ -254,20 +260,22 @@ void NameContainer::removeByName( const OUString& aName )
mValues.resize( iLast );
mnElementCount--;
+ std::unique_lock aGuard(m_aMutex);
+
// Fire event
- if( maContainerListeners.getLength() > 0 )
+ if( maContainerListeners.getLength(aGuard) > 0 )
{
ContainerEvent aEvent;
aEvent.Source = mpxEventSource;
aEvent.Accessor <<= aName;
aEvent.Element = aOldElement;
- maContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent );
+ maContainerListeners.notifyEach( aGuard, &XContainerListener::elementRemoved, aEvent );
}
/* After the container event has been fired (one listener will update the
core Basic manager), fire change event. Listeners can rely on that the
Basic source code of the core Basic manager is up-to-date. */
- if( maChangesListeners.getLength() > 0 )
+ if( maChangesListeners.getLength(aGuard) > 0 )
{
ChangesEvent aEvent;
aEvent.Source = mpxEventSource;
@@ -275,7 +283,7 @@ void NameContainer::removeByName( const OUString& aName )
aEvent.Changes = { { Any(aName),
{}, // Element remains empty (meaning "replaced with nothing")
aOldElement } };
- maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent );
+ maChangesListeners.notifyEach( aGuard, &XChangesListener::changesOccurred, aEvent );
}
}
@@ -285,18 +293,20 @@ void SAL_CALL NameContainer::addContainerListener( const Reference< XContainerLi
{
if( !xListener.is() )
{
- throw RuntimeException("addContainerListener called with null xListener",static_cast< cppu::OWeakObject * >(this));
+ throw RuntimeException("addContainerListener called with null xListener",getXWeak());
}
- maContainerListeners.addInterface( xListener );
+ std::unique_lock aGuard(m_aMutex);
+ maContainerListeners.addInterface( aGuard, xListener );
}
void SAL_CALL NameContainer::removeContainerListener( const Reference< XContainerListener >& xListener )
{
if( !xListener.is() )
{
- throw RuntimeException("removeContainerListener called with null xListener",static_cast< cppu::OWeakObject * >(this));
+ throw RuntimeException("removeContainerListener called with null xListener",getXWeak());
}
- maContainerListeners.removeInterface( xListener );
+ std::unique_lock aGuard(m_aMutex);
+ maContainerListeners.removeInterface( aGuard, xListener );
}
// Methods XChangesNotifier
@@ -304,18 +314,20 @@ void SAL_CALL NameContainer::addChangesListener( const Reference< XChangesListen
{
if( !xListener.is() )
{
- throw RuntimeException("addChangesListener called with null xListener",static_cast< cppu::OWeakObject * >(this));
+ throw RuntimeException("addChangesListener called with null xListener",getXWeak());
}
- maChangesListeners.addInterface( xListener );
+ std::unique_lock aGuard(m_aMutex);
+ maChangesListeners.addInterface( aGuard, xListener );
}
void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesListener >& xListener )
{
if( !xListener.is() )
{
- throw RuntimeException("removeChangesListener called with null xListener",static_cast< cppu::OWeakObject * >(this));
+ throw RuntimeException("removeChangesListener called with null xListener",getXWeak());
}
- maChangesListeners.removeInterface( xListener );
+ std::unique_lock aGuard(m_aMutex);
+ maChangesListeners.removeInterface( aGuard, xListener );
}
@@ -344,6 +356,7 @@ SfxLibraryContainer::SfxLibraryContainer()
, maVBAScriptListeners( m_aMutex )
, mnRunningVBAScripts( 0 )
, mbVBACompat( false )
+ , meVBATextEncoding( RTL_TEXTENCODING_DONTKNOW )
, maModifiable( *this, m_aMutex )
, maNameContainer( new NameContainer(cppu::UnoType<XNameAccess>::get()) )
, mbOldInfoFormat( false )
@@ -418,7 +431,7 @@ void SAL_CALL SfxLibraryContainer::setRootStorage( const Reference< XStorage >&
LibraryContainerMethodGuard aGuard( *this );
if ( !_rxRootStorage.is() )
{
- throw IllegalArgumentException("no root storage", static_cast<cppu::OWeakObject*>(this), 1);
+ throw IllegalArgumentException("no root storage", getXWeak(), 1);
}
mxStorage = _rxRootStorage;
onNewRootStorage();
@@ -429,7 +442,7 @@ void SAL_CALL SfxLibraryContainer::storeLibrariesToStorage( const Reference< XSt
LibraryContainerMethodGuard aGuard( *this );
if ( !_rxRootStorage.is() )
{
- throw IllegalArgumentException("no root storage", static_cast<cppu::OWeakObject*>(this), 1);
+ throw IllegalArgumentException("no root storage", getXWeak(), 1);
}
try
{
@@ -533,7 +546,9 @@ void SAL_CALL SfxLibraryContainer::storeLibraries( )
}
}
-static void checkAndCopyFileImpl( const INetURLObject& rSourceFolderInetObj,
+namespace
+{
+void checkAndCopyFileImpl( const INetURLObject& rSourceFolderInetObj,
const INetURLObject& rTargetFolderInetObj,
std::u16string_view rCheckFileName,
std::u16string_view rCheckExtension,
@@ -555,19 +570,23 @@ static void checkAndCopyFileImpl( const INetURLObject& rSourceFolderInetObj,
}
}
-static void createVariableURL( OUString& rStr, std::u16string_view rLibName,
+constexpr OUString sUserBasicVariablePrefix = u"$(USER)/basic/"_ustr;
+constexpr OUString sInstBasicVariablePrefix = u"$(INST)/" LIBO_SHARE_FOLDER "/basic/"_ustr;
+
+void createVariableURL( OUString& rStr, std::u16string_view rLibName,
std::u16string_view rInfoFileName, bool bUser )
{
if( bUser )
{
- rStr = "$(USER)/basic/";
+ rStr = sUserBasicVariablePrefix;
}
else
{
- rStr = "$(INST)/" LIBO_SHARE_FOLDER "/basic/";
+ rStr = sInstBasicVariablePrefix;
}
rStr += OUString::Concat(rLibName) + "/" + rInfoFileName + ".xlb/";
}
+}
void SfxLibraryContainer::init( const OUString& rInitialDocumentURL, const uno::Reference< embed::XStorage >& rxInitialStorage )
{
@@ -585,10 +604,10 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
uno::Reference< embed::XStorage > xStorage = rxInitialStorage;
maInitialDocumentURL = rInitialDocumentURL;
- maInfoFileName = OUString::createFromAscii( getInfoFileName() );
- maOldInfoFileName = OUString::createFromAscii( getOldInfoFileName() );
- maLibElementFileExtension = OUString::createFromAscii( getLibElementFileExtension() );
- maLibrariesDir = OUString::createFromAscii( getLibrariesDir() );
+ maInfoFileName = getInfoFileName();
+ maOldInfoFileName = getOldInfoFileName();
+ maLibElementFileExtension = getLibElementFileExtension();
+ maLibrariesDir = getLibrariesDir();
meInitMode = DEFAULT;
INetURLObject aInitUrlInetObj( maInitialDocumentURL );
@@ -646,8 +665,6 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
maLibraryPath = SvtPathOptions().GetBasicPath();
}
- Reference< XParser > xParser = xml::sax::Parser::create(mxContext);
-
uno::Reference< io::XInputStream > xInput;
mxStorage = xStorage;
@@ -731,11 +748,11 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
{
if( nPass == 1 )
{
- pLibInfoInetObj.reset(new INetURLObject( maLibraryPath.getToken(0, ';') ));
+ pLibInfoInetObj.reset(new INetURLObject( o3tl::getToken(maLibraryPath, 0, ';') ));
}
else
{
- pLibInfoInetObj.reset(new INetURLObject( maLibraryPath.getToken(1, ';') ));
+ pLibInfoInetObj.reset(new INetURLObject( o3tl::getToken(maLibraryPath, 1, ';') ));
}
pLibInfoInetObj->insertName( maInfoFileName, false, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
pLibInfoInetObj->setExtension( u"xlc" );
@@ -755,7 +772,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
// Old variant?
if( !xInput.is() && nPass == 0 )
{
- INetURLObject aLibInfoInetObj( maLibraryPath.getToken(1, ';') );
+ INetURLObject aLibInfoInetObj( o3tl::getToken(maLibraryPath, 1, ';') );
aLibInfoInetObj.insertName( maOldInfoFileName, false, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
aLibInfoInetObj.setExtension( u"xli" );
aFileName = aLibInfoInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
@@ -781,6 +798,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
// start parsing
auto pLibArray = std::make_unique<::xmlscript::LibDescriptorArray> ( );
+ Reference< XParser > xParser = xml::sax::Parser::create(mxContext);
try
{
xParser->setDocumentHandler( ::xmlscript::importLibraryContainer( pLibArray.get() ) );
@@ -828,7 +846,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
else if( rLib.bLink )
{
// Check "share" path
- INetURLObject aShareInetObj( maLibraryPath.getToken(0, ';') );
+ INetURLObject aShareInetObj( o3tl::getToken(maLibraryPath, 0, ';') );
aShareInetObj.insertName( rLib.aName, true, INetURLObject::LAST_SEGMENT,
INetURLObject::EncodeMechanism::All );
OUString aShareLibDirPath = aShareInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
@@ -970,7 +988,11 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
if( meInitMode != DEFAULT )
return;
- INetURLObject aUserBasicInetObj( maLibraryPath.getToken(1, ';') );
+ // tdf#121740 speed up loading documents with lots of embedded documents by avoid the UCB work of updating non-existent VBA libraries
+ if (rInitialDocumentURL.isEmpty())
+ return;
+
+ INetURLObject aUserBasicInetObj( o3tl::getToken(maLibraryPath, 1, ';') );
OUString aStandardStr("Standard");
INetURLObject aPrevUserBasicInetObj_1( aUserBasicInetObj );
@@ -1254,6 +1276,17 @@ void SfxLibraryContainer::checkStorageURL( const OUString& aSourceURL,
{
aUnexpandedStorageURL = aSourceURL;
}
+ else
+ {
+ // try to re-create the variable URL: helps moving the profile
+ if (OUString aRest; aSourceURL.startsWith(expand_url(sUserBasicVariablePrefix), &aRest))
+ aUnexpandedStorageURL = sUserBasicVariablePrefix + aRest;
+ else if (aSourceURL.startsWith(expand_url(sInstBasicVariablePrefix), &aRest))
+ aUnexpandedStorageURL = sInstBasicVariablePrefix + aRest;
+ else
+ aUnexpandedStorageURL.clear(); // This will use eventual value of aLibInfoFileURL
+ }
+
INetURLObject aInetObj( aExpandedSourceURL );
OUString aExtension = aInetObj.getExtension();
if( aExtension == "xlb" )
@@ -1318,7 +1351,7 @@ OUString SfxLibraryContainer::createAppLibraryFolder( SfxLibrary* pLib, std::u16
OUString aLibDirPath = pLib->maStorageURL;
if( aLibDirPath.isEmpty() )
{
- INetURLObject aInetObj( maLibraryPath.getToken(1, ';') );
+ INetURLObject aInetObj( o3tl::getToken(maLibraryPath, 1, ';') );
aInetObj.insertName( aName, true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
checkStorageURL( aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), pLib->maLibInfoFileURL,
pLib->maStorageURL, pLib->maUnexpandedStorageURL );
@@ -1345,14 +1378,14 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
{
Reference< XSimpleFileAccess3 > xDummySFA;
Reference< XInteractionHandler > xDummyHandler;
- implStoreLibrary( pLib, aName, xStorage, OUString(), xDummySFA, xDummyHandler );
+ implStoreLibrary( pLib, aName, xStorage, u"", xDummySFA, xDummyHandler );
}
// New variant for library export
void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
std::u16string_view aName,
const uno::Reference< embed::XStorage >& xStorage,
- const OUString& aTargetURL,
+ std::u16string_view aTargetURL,
const Reference< XSimpleFileAccess3 >& rToUseSFI,
const Reference< XInteractionHandler >& xHandler )
{
@@ -1413,7 +1446,7 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
else
{
// Export?
- bool bExport = !aTargetURL.isEmpty();
+ bool bExport = !aTargetURL.empty();
try
{
Reference< XSimpleFileAccess3 > xSFI = mxSFI;
@@ -1497,14 +1530,14 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
const uno::Reference< embed::XStorage >& xStorage )
{
Reference< XSimpleFileAccess3 > xDummySFA;
- implStoreLibraryIndexFile( pLib, rLib, xStorage, OUString(), xDummySFA );
+ implStoreLibraryIndexFile( pLib, rLib, xStorage, u"", xDummySFA );
}
// New variant for library export
void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
const ::xmlscript::LibDescriptor& rLib,
const uno::Reference< embed::XStorage >& xStorage,
- const OUString& aTargetURL,
+ std::u16string_view aTargetURL,
const Reference< XSimpleFileAccess3 >& rToUseSFI )
{
// Create sax writer
@@ -1546,7 +1579,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
else
{
// Export?
- bool bExport = !aTargetURL.isEmpty();
+ bool bExport = !aTargetURL.empty();
Reference< XSimpleFileAccess3 > xSFI = mxSFI;
if( rToUseSFI.is() )
{
@@ -1781,10 +1814,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
sal_Int32 index = 0;
do
{
- OUStringBuffer aTempTargetName( aTempTargetNameBase );
- aTempTargetName.append( index++ );
-
- sTargetLibrariesStoreName = aTempTargetName.makeStringAndClear();
+ sTargetLibrariesStoreName = aTempTargetNameBase + OUString::number( index++ );
if ( !i_rStorage->hasByName( sTargetLibrariesStoreName ) )
{
break;
@@ -2051,7 +2081,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
else
{
// Create Output stream
- INetURLObject aLibInfoInetObj( maLibraryPath.getToken(1, ';') );
+ INetURLObject aLibInfoInetObj( o3tl::getToken(maLibraryPath, 1, ';') );
aLibInfoInetObj.insertName( maInfoFileName, false, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
aLibInfoInetObj.setExtension( u"xlc" );
OUString aLibInfoPath( aLibInfoInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
@@ -2139,6 +2169,9 @@ Reference< XNameContainer > SAL_CALL SfxLibraryContainer::createLibrary( const O
pNewLib->maLibElementFileExtension = maLibElementFileExtension;
createVariableURL( pNewLib->maUnexpandedStorageURL, Name, maInfoFileName, true );
+ // tdf#151741 - fill various storage URLs for the newly created library
+ checkStorageURL(pNewLib->maUnexpandedStorageURL, pNewLib->maLibInfoFileURL,
+ pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL);
Reference< XNameAccess > xNameAccess( pNewLib );
Any aElement;
@@ -2204,7 +2237,7 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
SfxLibrary* pImplLib = static_cast< SfxLibrary* >( xNameAccess.get() );
if( pImplLib->mbReadOnly && !pImplLib->mbLink )
{
- throw IllegalArgumentException("readonly && !link", static_cast<cppu::OWeakObject*>(this), 1);
+ throw IllegalArgumentException("readonly && !link", getXWeak(), 1);
}
// Remove from container
maNameContainer->removeByName( Name );
@@ -2242,7 +2275,7 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
catch(const Exception& ) {}
// Delete folder if empty
- INetURLObject aInetObj( maLibraryPath.getToken(1, ';') );
+ INetURLObject aInetObj( o3tl::getToken(maLibraryPath, 1, ';') );
aInetObj.insertName( Name, true, INetURLObject::LAST_SEGMENT,
INetURLObject::EncodeMechanism::All );
OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
@@ -2310,7 +2343,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
" storage!"));
if ( !xLibrariesStor.is() )
{
- throw uno::RuntimeException("null returned from openStorageElement",static_cast< cppu::OWeakObject * >(this));
+ throw uno::RuntimeException("null returned from openStorageElement",getXWeak());
}
xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
@@ -2320,7 +2353,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
" storage!"));
if ( !xLibrariesStor.is() )
{
- throw uno::RuntimeException("null returned from openStorageElement",static_cast< cppu::OWeakObject * >(this));
+ throw uno::RuntimeException("null returned from openStorageElement",getXWeak());
}
#if OSL_DEBUG_LEVEL > 0
}
@@ -2427,7 +2460,7 @@ OUString SAL_CALL SfxLibraryContainer::getLibraryLinkURL( const OUString& Name )
bool bLink = pImplLib->mbLink;
if( !bLink )
{
- throw IllegalArgumentException("!link", static_cast<cppu::OWeakObject*>(this), 1);
+ throw IllegalArgumentException("!link", getXWeak(), 1);
}
OUString aRetStr = pImplLib->maLibInfoFileURL;
return aRetStr;
@@ -2484,10 +2517,6 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
}
loadLibrary( Name );
- // Remove from container
- maNameContainer->removeByName( Name );
- maModifiable.setModified( true );
-
// Rename library folder, but not for linked libraries
bool bMovedSuccessful = true;
@@ -2498,15 +2527,23 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
bMovedSuccessful = false;
OUString aLibDirPath = pImplLib->maStorageURL;
+ // tdf#151741 - fill various storage URLs for the library
+ // These URLs should not be empty for newly created libraries after
+ // the change in SfxLibraryContainer::createLibrary.
+ if (aLibDirPath.isEmpty())
+ {
+ checkStorageURL(pImplLib->maUnexpandedStorageURL, pImplLib->maLibInfoFileURL,
+ pImplLib->maStorageURL, pImplLib->maUnexpandedStorageURL);
+ }
- INetURLObject aDestInetObj( maLibraryPath.getToken(1, ';'));
+ INetURLObject aDestInetObj( o3tl::getToken(maLibraryPath, 1, ';'));
aDestInetObj.insertName( NewName, true, INetURLObject::LAST_SEGMENT,
INetURLObject::EncodeMechanism::All );
OUString aDestDirPath = aDestInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
// Store new URL
OUString aLibInfoFileURL = pImplLib->maLibInfoFileURL;
- checkStorageURL( aDestDirPath, pImplLib->maLibInfoFileURL, pImplLib->maStorageURL,
+ checkStorageURL(aDestDirPath, pImplLib->maLibInfoFileURL, pImplLib->maStorageURL,
pImplLib->maUnexpandedStorageURL );
try
@@ -2574,12 +2611,13 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
bMovedSuccessful = true;
pImplLib->implSetModified( true );
+ // Remove old library from container
+ maNameContainer->removeByName( Name );
+ maModifiable.setModified( true );
}
}
catch(const Exception& )
{
- // Restore old library
- maNameContainer->insertByName( Name, aLibAny ) ;
}
}
@@ -2600,7 +2638,7 @@ void SAL_CALL SfxLibraryContainer::initialize( const Sequence< Any >& _rArgument
LibraryContainerMethodGuard aGuard( *this );
sal_Int32 nArgCount = _rArguments.getLength();
if ( nArgCount != 1 )
- throw IllegalArgumentException("too many args", static_cast<cppu::OWeakObject*>(this), -1);
+ throw IllegalArgumentException("too many args", getXWeak(), -1);
OUString sInitialDocumentURL;
Reference< XStorageBasedDocument > xDocument;
@@ -2615,7 +2653,7 @@ void SAL_CALL SfxLibraryContainer::initialize( const Sequence< Any >& _rArgument
initializeFromDocument( xDocument );
return;
}
- throw IllegalArgumentException("arg1 unknown type", static_cast<cppu::OWeakObject*>(this), 1);
+ throw IllegalArgumentException("arg1 unknown type", getXWeak(), 1);
}
@@ -2640,7 +2678,7 @@ void SfxLibraryContainer::initializeFromDocument( const Reference< XStorageBased
if ( !xDocStorage.is() )
{
- throw IllegalArgumentException("no doc storage", static_cast<cppu::OWeakObject*>(this), 1);
+ throw IllegalArgumentException("no doc storage", getXWeak(), 1);
}
init( OUString(), xDocStorage );
}
@@ -2694,7 +2732,7 @@ void SAL_CALL SfxLibraryContainer::changeLibraryPassword(const OUString&, const
void SAL_CALL SfxLibraryContainer::addContainerListener( const Reference< XContainerListener >& xListener )
{
LibraryContainerMethodGuard aGuard( *this );
- maNameContainer->setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
+ maNameContainer->setEventSource( getXWeak() );
maNameContainer->addContainerListener( xListener );
}
@@ -2766,7 +2804,7 @@ OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString
bool bLink = pImplLib->mbLink;
if( !bLink )
{
- throw IllegalArgumentException("!link", static_cast<cppu::OWeakObject*>(this), 1);
+ throw IllegalArgumentException("!link", getXWeak(), 1);
}
OUString aRetStr = pImplLib->maOriginalStorageURL;
return aRetStr;
@@ -2867,6 +2905,51 @@ void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifie
maVBAScriptListeners.notifyEach( &css::script::vba::XVBAScriptListener::notifyVBAScriptEvent, aEvent );
}
+// Methods XPropertySet
+css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL SfxLibraryContainer::getPropertySetInfo()
+{
+ return uno::Reference<beans::XPropertySetInfo>();
+}
+
+void SAL_CALL SfxLibraryContainer::setPropertyValue(const OUString& aPropertyName,
+ const uno::Any& aValue)
+{
+ if (aPropertyName != sVBATextEncodingPropName)
+ throw UnknownPropertyException(aPropertyName, getXWeak());
+ aValue >>= meVBATextEncoding;
+}
+
+css::uno::Any SAL_CALL SfxLibraryContainer::getPropertyValue(const OUString& aPropertyName)
+{
+ if (aPropertyName == sVBATextEncodingPropName)
+ return uno::Any(meVBATextEncoding);
+ throw UnknownPropertyException(aPropertyName, getXWeak());
+}
+
+void SAL_CALL SfxLibraryContainer::addPropertyChangeListener(
+ const OUString& /* aPropertyName */, const Reference<XPropertyChangeListener>& /* xListener */)
+{
+ throw NoSupportException();
+}
+
+void SAL_CALL SfxLibraryContainer::removePropertyChangeListener(
+ const OUString& /* aPropertyName */, const Reference<XPropertyChangeListener>& /* aListener */)
+{
+ throw NoSupportException();
+}
+
+void SAL_CALL SfxLibraryContainer::addVetoableChangeListener(
+ const OUString& /* PropertyName */, const Reference<XVetoableChangeListener>& /* aListener */)
+{
+ throw NoSupportException();
+}
+
+void SAL_CALL SfxLibraryContainer::removeVetoableChangeListener(
+ const OUString& /* PropertyName */, const Reference<XVetoableChangeListener>& /* aListener */)
+{
+ throw NoSupportException();
+}
+
// Methods XServiceInfo
sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const OUString& _rServiceName )
{
@@ -2878,8 +2961,7 @@ sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const OUString& _rServic
// Ctor
SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType,
const Reference< XSimpleFileAccess3 >& xSFI )
- : OComponentHelper( m_aMutex )
- , mxSFI( xSFI )
+ : mxSFI( xSFI )
, mrModifiable( _rModifiable )
, maNameContainer( new NameContainer(aType) )
, mbLoaded( true )
@@ -2899,16 +2981,15 @@ SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType,
SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType,
const Reference< XSimpleFileAccess3 >& xSFI,
- const OUString& aLibInfoFileURL, const OUString& aStorageURL, bool ReadOnly )
- : OComponentHelper( m_aMutex )
- , mxSFI( xSFI )
+ OUString aLibInfoFileURL, OUString aStorageURL, bool ReadOnly )
+ : mxSFI( xSFI )
, mrModifiable( _rModifiable )
, maNameContainer( new NameContainer(aType) )
, mbLoaded( false )
, mbIsModified( true )
, mbInitialised( false )
- , maLibInfoFileURL( aLibInfoFileURL )
- , maStorageURL( aStorageURL )
+ , maLibInfoFileURL(std::move( aLibInfoFileURL ))
+ , maStorageURL(std::move( aStorageURL ))
, mbLink( true )
, mbReadOnly( false )
, mbReadOnlyLink( ReadOnly )
@@ -2952,7 +3033,7 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType )
static_cast< XChangesNotifier * >( this ) );
if( !aRet.hasValue() )
{
- aRet = OComponentHelper::queryInterface( rType );
+ aRet = WeakComponentImplHelper::queryInterface( rType );
}
return aRet;
}
@@ -3088,7 +3169,7 @@ Sequence< Type > SfxLibrary::getTypes()
cppu::UnoType<XNameContainer>::get(),
cppu::UnoType<XContainer>::get(),
cppu::UnoType<XChangesNotifier>::get(),
- OComponentHelper::getTypes() );
+ WeakComponentImplHelper::getTypes() );
return ourTypes_NameContainer.getTypes();
}
@@ -3102,7 +3183,7 @@ Sequence< sal_Int8 > SfxLibrary::getImplementationId()
// Methods XContainer
void SAL_CALL SfxLibrary::addContainerListener( const Reference< XContainerListener >& xListener )
{
- maNameContainer->setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
+ maNameContainer->setEventSource( getXWeak() );
maNameContainer->addContainerListener( xListener );
}
@@ -3114,7 +3195,7 @@ void SAL_CALL SfxLibrary::removeContainerListener( const Reference< XContainerLi
// Methods XChangesNotifier
void SAL_CALL SfxLibrary::addChangesListener( const Reference< XChangesListener >& xListener )
{
- maNameContainer->setEventSource( static_cast< XInterface* >( static_cast<OWeakObject*>(this) ) );
+ maNameContainer->setEventSource( getXWeak() );
maNameContainer->addChangesListener( xListener );
}