i18nlangtag/source/languagetag/languagetag.cxx | 18 ++++++++++++- sw/source/core/unocore/unostyle.cxx | 33 +++++++++++++++---------- 2 files changed, 38 insertions(+), 13 deletions(-)
New commits: commit 741909fea54b49de295af6685efa69b8444dc382 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Aug 28 14:58:29 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 28 19:35:19 2024 +0200 crashtesting in abiword doc regression from commit 60aeca980bbe6cd35d9ce530ea8704bc4ade7b7b Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Aug 14 09:32:51 2024 +0200 tdf#158556 bypass some more logic for toggle properties re-introduce some of the logic I elided Change-Id: If20ca9eb0134d743ca62335fb4eae400e8c8221a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172531 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index de77ddadf66d..3cc2533c7137 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2451,29 +2451,38 @@ void SwXStyle::getToggleAttributes( xDocStyleSheet = new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pStyleSheetBase)); maUnoStyleSheets.insert({pStyleSheetBase, xDocStyleSheet}); } - const SfxItemSet& rItemSet(xDocStyleSheet->GetItemSet()); - assert(rItemSet.GetParent()); + std::optional<SfxItemSet> oTempItemSet; + const SfxItemSet* pItemSet; + if (xDocStyleSheet->GetItemSet().GetParent()) + pItemSet = &xDocStyleSheet->GetItemSet(); + else + { + // set parent style to have the correct XFillStyle setting as XFILL_NONE + oTempItemSet.emplace(xDocStyleSheet->GetItemSet()); + oTempItemSet->SetParent(&m_pDoc->GetDfltTextFormatColl()->GetAttrSet()); + pItemSet = &*oTempItemSet; + } uno::Any aResult; - lcl_getTogglePropertyValue(RES_CHRATR_WEIGHT, MID_WEIGHT, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_WEIGHT, MID_WEIGHT, *pItemSet, aResult); aResult >>= rfCharStyleBold; - lcl_getTogglePropertyValue(RES_CHRATR_CTL_WEIGHT, MID_WEIGHT, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_CTL_WEIGHT, MID_WEIGHT, *pItemSet, aResult); aResult >>= rfCharStyleBoldComplex; - lcl_getTogglePropertyValue(RES_CHRATR_POSTURE, MID_POSTURE, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_POSTURE, MID_POSTURE, *pItemSet, aResult); aResult >>= reCharStylePosture; - lcl_getTogglePropertyValue(RES_CHRATR_CTL_POSTURE, MID_POSTURE, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_CTL_POSTURE, MID_POSTURE, *pItemSet, aResult); aResult >>= reCharStylePostureComplex; - lcl_getTogglePropertyValue(RES_CHRATR_CASEMAP, 0, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_CASEMAP, 0, *pItemSet, aResult); aResult >>= rnCharStyleCaseMap; - lcl_getTogglePropertyValue(RES_CHRATR_RELIEF, 0, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_RELIEF, 0, *pItemSet, aResult); aResult >>= rnCharStyleRelief; - lcl_getTogglePropertyValue(RES_CHRATR_CONTOUR, 0, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_CONTOUR, 0, *pItemSet, aResult); aResult >>= rbCharStyleContoured; - lcl_getTogglePropertyValue(RES_CHRATR_SHADOWED, 0, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_SHADOWED, 0, *pItemSet, aResult); aResult >>= rbCharStyleShadowed; - lcl_getTogglePropertyValue(RES_CHRATR_CROSSEDOUT, MID_CROSS_OUT, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_CROSSEDOUT, MID_CROSS_OUT, *pItemSet, aResult); aResult >>= rnCharStyleStrikeThrough; - lcl_getTogglePropertyValue(RES_CHRATR_HIDDEN, 0, rItemSet, aResult); + lcl_getTogglePropertyValue(RES_CHRATR_HIDDEN, 0, *pItemSet, aResult); aResult >>= rbCharStyleHidden; } commit b076e6a0b92ee989d31a8525cfab4636737b30dc Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Aug 28 10:48:20 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 28 19:35:08 2024 +0200 tdf#158556 avoid a ton of temporary OUString Change-Id: I5256210d73eb54d4e6ea98b68c1e9eabf8770ccd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172525 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx index 5a922babd5ea..b43efe2625a0 100644 --- a/i18nlangtag/source/languagetag/languagetag.cxx +++ b/i18nlangtag/source/languagetag/languagetag.cxx @@ -23,6 +23,7 @@ #include <atomic> #include <map> #include <mutex> +#include <optional> #include <string_view> #include <unordered_set> @@ -2822,7 +2823,22 @@ LanguageType LanguageTag::convertToLanguageType( const css::lang::Locale& rLocal if (rLocale.Language.isEmpty() && !bResolveSystem) return LANGUAGE_SYSTEM; - return LanguageTag( rLocale).getLanguageType( bResolveSystem); + if (!bResolveSystem) + { + // single-item cache + static std::mutex gMutex; + static std::optional<lang::Locale> moCacheKey; + static std::optional<LanguageType> moCacheValue; + std::unique_lock l(gMutex); + if (!moCacheKey || *moCacheKey != rLocale) + { + moCacheValue = LanguageTag(rLocale).getLanguageType(false); + moCacheKey = rLocale; + } + return *moCacheValue; + } + else + return LanguageTag( rLocale).getLanguageType( bResolveSystem); }