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

New commits:
commit 28951647b54823e6c1aecbc250f1b023bab45649
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Aug 2 19:03:40 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Aug 12 19:12:32 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 <mike.kagan...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189339
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/vcl/source/gdi/embeddedfontshelper.cxx 
b/vcl/source/gdi/embeddedfontshelper.cxx
index 830afa2babe1..e50e641b7edc 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