From 70e6dd0eb1874f0c5e260948b2c8b9e192841372 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 29 Sep 2026 12:39:22 -0400 Subject: [PATCH] tdf#161182 tdf#135857 find&replace format: finding only white color Similar to my earlier commit 45311ffe342adde3e187f0ecaec965affad646a5 tdf#164402 find&replace format: find white font color a COL_AUTO should not be allowed to match a white color (or vise versa). Since this should be a pattern that is always followed, make a function to handle it. Change-Id: I1f2c96891264c960f42d7d6ec50ef1dfa012b921 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211584 Reviewed-by: Justin Luth Tested-by: Jenkins --- sw/source/core/crsr/findattr.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 63bddbebe95b..a7382cc754b4 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -53,6 +53,14 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; +static bool lcl_ColorsAreBasicallyEqual(const ::Color& rColor1, const ::Color& rColor2) +{ + if (rColor1 == COL_AUTO || rColor2 == COL_AUTO) + return rColor1 == rColor2; + + return rColor1.IsRGBEqual(rColor2); +} + // Special case for SvxFontItem: only compare the name static bool CmpAttr( const SfxPoolItem& rItem1, const SfxPoolItem& rItem2 ) { @@ -68,7 +76,7 @@ static bool CmpAttr( const SfxPoolItem& rItem1, const SfxPoolItem& rItem2 ) if (rBrush1.getComplexColor().isUsed() && rBrush2.getComplexColor().isUsed()) return rItem1 == rItem2; - return rBrush1.GetColor().IsRGBEqual(rBrush2.GetColor()); + return lcl_ColorsAreBasicallyEqual(rBrush1.GetColor(), rBrush2.GetColor()); } case RES_CHRATR_OVERLINE: case RES_CHRATR_UNDERLINE: @@ -78,16 +86,14 @@ static bool CmpAttr( const SfxPoolItem& rItem1, const SfxPoolItem& rItem2 ) if (rUnderline1.getComplexColor().isUsed() && rUnderline2.getComplexColor().isUsed()) return rItem1 == rItem2; - return rUnderline1.GetColor().IsRGBEqual(rUnderline2.GetColor()) + return lcl_ColorsAreBasicallyEqual(rUnderline1.GetColor(), rUnderline2.GetColor()) && rUnderline1.GetLineStyle() == rUnderline2.GetLineStyle(); } case RES_CHRATR_COLOR: { ::Color Color1 = rItem1.StaticWhichCast(RES_CHRATR_COLOR).GetValue(); ::Color Color2 = rItem2.StaticWhichCast(RES_CHRATR_COLOR).GetValue(); - if (Color1 == COL_AUTO || Color2 == COL_AUTO) - return Color1 == Color2; - return Color1.IsRGBEqual(Color2); + return lcl_ColorsAreBasicallyEqual(Color1, Color2); } case RES_PAGEDESC: ::std::optional const oNumOffset1 = rItem1.StaticWhichCast(RES_PAGEDESC).GetNumOffset();