include/unotools/fontcfg.hxx | 4 ++-- unotools/source/config/fontcfg.cxx | 15 +++++++-------- unotools/source/misc/fontdefs.cxx | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-)
New commits: commit 7cb91a40e20b0ea405042429a1b497bf3c983e01 Author: Noel Grandin <[email protected]> AuthorDate: Thu Mar 17 15:24:27 2022 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Fri Mar 18 09:59:04 2022 +0100 tdf#133603 cache languagetag in FontSubstConfiguration speeds up saving XLSX by 10% Change-Id: I5f48fcd3de44675d27e275c6ff2f4e51a067c750 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131727 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/unotools/fontcfg.hxx b/include/unotools/fontcfg.hxx index 99520e39528b..1f77d484531a 100644 --- a/include/unotools/fontcfg.hxx +++ b/include/unotools/fontcfg.hxx @@ -24,6 +24,7 @@ #include <tools/fontenum.hxx> #include <com/sun/star/uno/Reference.hxx> #include <o3tl/typed_flags_set.hxx> +#include <i18nlangtag/languagetag.hxx> #include <unordered_map> #include <unordered_set> @@ -32,8 +33,6 @@ namespace com::sun::star::container { class XNameAccess; } namespace com::sun::star::lang { class XMultiServiceFactory; } -class LanguageTag; - enum class DefaultFontType; // If you think the below concept of classifying a font (typeface) as possibly being one or several @@ -156,6 +155,7 @@ private: std::unordered_map< OUString, LocaleSubst > m_aSubst; typedef std::unordered_set< OUString > UniqueSubstHash; mutable UniqueSubstHash maSubstHash; + LanguageTag maLanguageTag; void fillSubstVector( const css::uno::Reference< css::container::XNameAccess >& rFont, const OUString& rType, diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index ef94981d7746..371084708084 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -299,7 +299,8 @@ FontSubstConfiguration& FontSubstConfiguration::get() */ FontSubstConfiguration::FontSubstConfiguration() : - maSubstHash( 300 ) + maSubstHash( 300 ), + maLanguageTag("en") { if (utl::ConfigManager::IsFuzzing()) return; @@ -339,6 +340,9 @@ FontSubstConfiguration::FontSubstConfiguration() : } SAL_INFO("unotools.config", "config provider: " << m_xConfigProvider.is() << ", config access: " << m_xConfigAccess.is()); + + if( maLanguageTag.isSystemLocale() ) + maLanguageTag = SvtSysLocale().GetUILanguageTag(); } /* @@ -1042,13 +1046,8 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN FontNameAttr aSearchAttr; aSearchAttr.Name = aSearchFont; - LanguageTag aLanguageTag("en"); - - if( aLanguageTag.isSystemLocale() ) - aLanguageTag = SvtSysLocale().GetUILanguageTag(); - - ::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings( true)); - if (aLanguageTag.getLanguage() != "en") + ::std::vector< OUString > aFallbacks( maLanguageTag.getFallbackStrings( true)); + if (maLanguageTag.getLanguage() != "en") aFallbacks.emplace_back("en"); for (const auto& rFallback : aFallbacks) diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx index 66bd91363be7..9015f93e9de6 100644 --- a/unotools/source/misc/fontdefs.cxx +++ b/unotools/source/misc/fontdefs.cxx @@ -545,18 +545,19 @@ OUString GetSubsFontName( const OUString& rName, SubsFontFlags nFlags ) || aOrgName == "opensymbol" ) ) return aName; - const utl::FontNameAttr* pAttr = utl::FontSubstConfiguration::get().getSubstInfo( aOrgName ); - if ( pAttr && (nFlags & SubsFontFlags::MS) ) + if (nFlags & SubsFontFlags::MS) { - for( const auto& rSubstitution : pAttr->MSSubstitutions ) - if( ! ImplIsFontToken( rName, rSubstitution ) ) - { - ImplAppendFontToken( aName, rSubstitution ); - if( nFlags & SubsFontFlags::ONLYONE ) + const utl::FontNameAttr* pAttr = utl::FontSubstConfiguration::get().getSubstInfo( aOrgName ); + if (pAttr) + for( const auto& rSubstitution : pAttr->MSSubstitutions ) + if( ! ImplIsFontToken( rName, rSubstitution ) ) { - break; + ImplAppendFontToken( aName, rSubstitution ); + if( nFlags & SubsFontFlags::ONLYONE ) + { + break; + } } - } } return aName;
