From fea2ef657d22beecc6161c7dc49fe99fdfc29d7d Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Fri, 17 Apr 2026 09:24:02 +0200 Subject: [PATCH] sc: only rewrite cell attrs on theme change when color actually differs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ThemeColorChanger::changeCellItems() / changeBorderLine() rebuilt the font / background / border items and reported the pattern as changed unconditionally whenever the item carried a valid theme type - even when the resolved theme color was already identical to the color stored on the item. The outer loop in changeSheets() then rewrote the pattern and called ApplySelectionPattern for every such "change", which made applying a theme on a document with many themed cell attributes effectively hang. Compare the resolved color to the current one in all three paths and only rewrite / signal bChanged when they actually differ. Iteration still traverses every pattern on the sheet, but no-op patterns no longer trigger a rewrite. Change-Id: I40c6a8ac98a0e49e34c7a557606c61f00bbdc5f9 Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/1106 Tested-by: Jenkins CPCI Reviewed-by: Tomaž Vajngerl (cherry picked from commit 861d009764c45d5b4a053452d8df43367ca52b17) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206617 Reviewed-by: Xisco Fauli Tested-by: Jenkins --- sc/source/ui/theme/ThemeColorChanger.cxx | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx b/sc/source/ui/theme/ThemeColorChanger.cxx index 8aac445576c8..d6884735e9fb 100644 --- a/sc/source/ui/theme/ThemeColorChanger.cxx +++ b/sc/source/ui/theme/ThemeColorChanger.cxx @@ -60,6 +60,8 @@ bool changeBorderLine(editeng::SvxBorderLine* pBorderLine, model::ColorSet const if (rComplexColor.isValidThemeType()) { Color aColor = rColorSet.resolveColor(rComplexColor); + if (aColor == pBorderLine->GetColor()) + return false; pBorderLine->SetColor(aColor); return true; } @@ -77,11 +79,13 @@ bool changeCellItems(SfxItemSet& rItemSet, model::ColorSet const& rColorSet) if (rComplexColor.isValidThemeType()) { Color aColor = rColorSet.resolveColor(rComplexColor); - - SvxColorItem aColorItem(*pColorItem); - aColorItem.setColor(aColor); - rItemSet.Put(aColorItem); - bChanged = true; + if (aColor != pColorItem->getColor()) + { + SvxColorItem aColorItem(*pColorItem); + aColorItem.setColor(aColor); + rItemSet.Put(aColorItem); + bChanged = true; + } } } if (rItemSet.HasItem(ATTR_BACKGROUND, &pItem)) @@ -91,11 +95,13 @@ bool changeCellItems(SfxItemSet& rItemSet, model::ColorSet const& rColorSet) if (rComplexColor.isValidThemeType()) { Color aColor = rColorSet.resolveColor(rComplexColor); - - SvxBrushItem aNewBrushItem(*pBrushItem); - aNewBrushItem.SetColor(aColor); - rItemSet.Put(aNewBrushItem); - bChanged = true; + if (aColor != pBrushItem->GetColor()) + { + SvxBrushItem aNewBrushItem(*pBrushItem); + aNewBrushItem.SetColor(aColor); + rItemSet.Put(aNewBrushItem); + bChanged = true; + } } } if (rItemSet.HasItem(ATTR_BORDER, &pItem))