From adb203bc05e3e36173cbd46b9951f79821a81799 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:27:54 +0200 Subject: Merging upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- basic/source/uno/namecont.cxx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'basic/source/uno') diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index beeee133b0..eb04dd2ee7 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -537,7 +537,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, @@ -559,12 +561,14 @@ static void checkAndCopyFileImpl( const INetURLObject& rSourceFolderInetObj, } } -static void createVariableURL( OUString& rStr, std::u16string_view rLibName, +constexpr OUString sUserBasicVariablePrefix = u"$(USER)/basic/"_ustr; + +void createVariableURL( OUString& rStr, std::u16string_view rLibName, std::u16string_view rInfoFileName, bool bUser ) { if( bUser ) { - rStr = "$(USER)/basic/"; + rStr = sUserBasicVariablePrefix; } else { @@ -572,6 +576,7 @@ static void createVariableURL( OUString& rStr, std::u16string_view rLibName, } rStr += OUString::Concat(rLibName) + "/" + rInfoFileName + ".xlb/"; } +} void SfxLibraryContainer::init( const OUString& rInitialDocumentURL, const uno::Reference< embed::XStorage >& rxInitialStorage ) { @@ -1261,6 +1266,11 @@ void SfxLibraryContainer::checkStorageURL( const OUString& aSourceURL, { aUnexpandedStorageURL = aSourceURL; } + else + { + aUnexpandedStorageURL.clear(); + } + INetURLObject aInetObj( aExpandedSourceURL ); OUString aExtension = aInetObj.getExtension(); if( aExtension == "xlb" ) @@ -2515,9 +2525,18 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU INetURLObject::EncodeMechanism::All ); OUString aDestDirPath = aDestInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + OUString aDestDirUnexpandedPath = aDestDirPath; + if (pImplLib->maUnexpandedStorageURL.startsWith(sUserBasicVariablePrefix)) + { + // try to re-create the variable URL: helps moving the profile + OUString aUserBasicURL = expand_url(sUserBasicVariablePrefix); + if (OUString aRest; aDestDirPath.startsWith(aUserBasicURL, &aRest)) + aDestDirUnexpandedPath = sUserBasicVariablePrefix + aRest; + } + // Store new URL OUString aLibInfoFileURL = pImplLib->maLibInfoFileURL; - checkStorageURL( aDestDirPath, pImplLib->maLibInfoFileURL, pImplLib->maStorageURL, + checkStorageURL(aDestDirUnexpandedPath, pImplLib->maLibInfoFileURL, pImplLib->maStorageURL, pImplLib->maUnexpandedStorageURL ); try -- cgit v1.2.3