summaryrefslogtreecommitdiffstats
path: root/basic/source
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 09:27:30 +0000
commita2baea7faff31d26459dab3668a39eae85e4991b (patch)
treeeaa2048ce9c715481f932dcfe20368e252b77d2f /basic/source
parentAdding upstream version 4:24.2.0. (diff)
downloadlibreoffice-a2baea7faff31d26459dab3668a39eae85e4991b.tar.xz
libreoffice-a2baea7faff31d26459dab3668a39eae85e4991b.zip
Adding upstream version 4:24.2.1.upstream/4%24.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'basic/source')
-rw-r--r--basic/source/uno/namecont.cxx27
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