basic/source/uno/namecont.cxx |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

New commits:
commit 942e9a79f066a26276e299660ba56874874841c6
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Jan 31 10:26:04 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Jan 31 06:56:42 2024 +0100

    Related: tdf#159458 Move variable URL re-creation to a central place
    
    Change-Id: Ib73ae476f308b2579a15c9b2474a55e3558c134c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162786
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index eb04dd2ee767..430cab8b3264 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -562,6 +562,7 @@ void checkAndCopyFileImpl( const INetURLObject& 
rSourceFolderInetObj,
 }
 
 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 )
@@ -572,7 +573,7 @@ void createVariableURL( OUString& rStr, std::u16string_view 
rLibName,
     }
     else
     {
-        rStr = "$(INST)/" LIBO_SHARE_FOLDER "/basic/";
+        rStr = sInstBasicVariablePrefix;
     }
     rStr += OUString::Concat(rLibName) + "/" + rInfoFileName + ".xlb/";
 }
@@ -1268,7 +1269,13 @@ void SfxLibraryContainer::checkStorageURL( const 
OUString& aSourceURL,
     }
     else
     {
-        aUnexpandedStorageURL.clear();
+        // 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 );
@@ -2525,18 +2532,9 @@ 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(aDestDirUnexpandedPath, pImplLib->maLibInfoFileURL, 
pImplLib->maStorageURL,
+        checkStorageURL(aDestDirPath, pImplLib->maLibInfoFileURL, 
pImplLib->maStorageURL,
                          pImplLib->maUnexpandedStorageURL );
 
         try

Reply via email to