vcl/source/gdi/embeddedfontshelper.cxx |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

New commits:
commit 6ab8d4d1ebb0be9721099d628b105cd1a90e289b
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Aug 2 19:03:40 2025 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Aug 2 17:59:53 2025 +0200

    Factor out temporary fonts directory path code into a function
    
    Change-Id: Ia7b6831ea3ea6c6bd47d6970fe39077edc92e342
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188823
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/vcl/source/gdi/embeddedfontshelper.cxx 
b/vcl/source/gdi/embeddedfontshelper.cxx
index 3a2191dfa8a2..aea57e857563 100644
--- a/vcl/source/gdi/embeddedfontshelper.cxx
+++ b/vcl/source/gdi/embeddedfontshelper.cxx
@@ -42,6 +42,16 @@ namespace libeot
 using namespace com::sun::star;
 using namespace vcl;
 
+namespace
+{
+OUString GetEmbeddedFontsRoot()
+{
+    OUString path = u"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( 
"bootstrap") "::UserInstallation}"_ustr;
+    rtl::Bootstrap::expandMacros( path );
+    return path + "/user/temp/embeddedfonts/";
+}
+}
+
 static void clearDir( const OUString& path )
 {
     osl::Directory dir( path );
@@ -61,9 +71,7 @@ static void clearDir( const OUString& path )
 
 void EmbeddedFontsHelper::clearTemporaryFontFiles()
 {
-    OUString path = u"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( 
"bootstrap") "::UserInstallation}"_ustr;
-    rtl::Bootstrap::expandMacros( path );
-    path += "/user/temp/embeddedfonts/";
+    OUString path = GetEmbeddedFontsRoot();
     clearDir( path + "fromdocs/" );
     clearDir( path + "fromsystem/" );
 }
@@ -241,9 +249,7 @@ OUString EmbeddedFontsHelper::fileUrlForTemporaryFont( 
const OUString& fontName,
         filename = "font" + OUString::number(uniqueCounter++) + ".ttf";
     }
 
-    OUString path = u"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( 
"bootstrap") "::UserInstallation}"_ustr;
-    rtl::Bootstrap::expandMacros( path );
-    path += "/user/temp/embeddedfonts/fromdocs/";
+    OUString path = GetEmbeddedFontsRoot() + "fromdocs/";
     osl::Directory::createPath( path );
     return path + filename;
 }
@@ -279,9 +285,7 @@ bool EmbeddedFontsHelper::sufficientTTFRights( const void* 
data, tools::Long siz
 OUString EmbeddedFontsHelper::fontFileUrl( std::u16string_view familyName, 
FontFamily family, FontItalic italic,
     FontWeight weight, FontPitch pitch, FontRights rights )
 {
-    OUString path = u"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( 
"bootstrap") "::UserInstallation}"_ustr;
-    rtl::Bootstrap::expandMacros( path );
-    path += "/user/temp/embeddedfonts/fromsystem/";
+    OUString path = GetEmbeddedFontsRoot() + "fromsystem/";
     osl::Directory::createPath( path );
     OUString filename = OUString::Concat(familyName) + "_" + OUString::number( 
family ) + "_" + OUString::number( italic )
         + "_" + OUString::number( weight ) + "_" + OUString::number( pitch )

Reply via email to