diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:27:54 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:27:54 +0000 |
commit | adb203bc05e3e36173cbd46b9951f79821a81799 (patch) | |
tree | 6e6739df9b3f0a567330a0dd7ee0e03ae70876a3 /basic/source/uno/namecont.cxx | |
parent | Adding debian version 4:24.2.0-3. (diff) | |
download | libreoffice-adb203bc05e3e36173cbd46b9951f79821a81799.tar.xz libreoffice-adb203bc05e3e36173cbd46b9951f79821a81799.zip |
Merging upstream version 4:24.2.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'basic/source/uno/namecont.cxx')
-rw-r--r-- | basic/source/uno/namecont.cxx | 27 |
1 files changed, 23 insertions, 4 deletions
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 |