sw/inc/doc.hxx                     |    5 ++++-
 sw/source/core/doc/doc.cxx         |   10 ++++++++--
 sw/source/core/doc/docfmt.cxx      |   31 ++++++++++++++++++++++++++-----
 sw/source/filter/ww8/rtfexport.cxx |    2 +-
 4 files changed, 39 insertions(+), 9 deletions(-)

New commits:
commit e094bed14d8cd30538f20e052c66528c10905765
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Sep 22 10:51:21 2025 +0200
Commit:     Ilmari Lauhakangas <[email protected]>
CommitDate: Wed Oct 1 12:45:35 2025 +0200

    tdf#166895 Document Colors do not appear anymore in the color selection
    
    missed a spot where we are using surrogate functionality.
    
    Also rename ForEachCharacterBrushItem->ForEachCharacterBackgroundBrushItem 
to make it more obvious.
    
    Regression from
    
      commit 56d35ad0eaccd353c8acd2a259293199e233e8ec
      Author: Noel Grandin <[email protected]>
      Date:   Mon Sep 9 17:14:43 2024 +0200
      RES_CHRATR_HIGHLIGHT does not need surrogate support
    
    and
    
      commit 08c58ac51962b65b57c5b76a45467d45807ef02d
      Author: Noel Grandin <[email protected]>
      Date:   Mon Sep 16 21:04:59 2024 +0200
      dont use GetItemSurrogates for gathering SvxColorItem
    
    and
    
      commit b6a5cdc0f753c8ed6ed080f9189ac2e2601dce9d
      Author: Noel Grandin <[email protected]>
      Date:   Tue Sep 17 20:19:06 2024 +020
      dont use GetItemSurrogates for gathering SvxBrushItem
    
    Change-Id: Id67d78aa82f8731555f06b23760c4ea8f0d8eeb5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191317
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>
    (cherry picked from commit 50099a54cd32afd361810e3059af3b420741d41b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191352
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>
    (cherry picked from commit 5442778d975c1a6146ce6ff0c66a13c64dcab904)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191636
    Tested-by: Ilmari Lauhakangas <[email protected]>
    Reviewed-by: Xisco Fauli <[email protected]>
    Reviewed-by: Ilmari Lauhakangas <[email protected]>

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 0c9a77bd3cac..3ee03fbe31f1 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1455,7 +1455,7 @@ public:
     SW_DLLPUBLIC void ForEachCharacterUnderlineItem(const 
std::function<bool(const SvxUnderlineItem&)>&  ) const;
 
     /// Iterate over all RES_CHRATR_BACKGROUND SvxBrushItem, if the function 
returns false, iteration is stopped
-    SW_DLLPUBLIC void ForEachCharacterBrushItem(const std::function<bool(const 
SvxBrushItem&)>&  ) const;
+    SW_DLLPUBLIC void ForEachCharacterBackgroundBrushItem(const 
std::function<bool(const SvxBrushItem&)>&  ) const;
 
     /// Iterate over all 
RES_CHRATR_FONT/RES_CHRATR_CJK_FONT/RES_CHRATR_CTL_FONT SvxFontItem, if the 
function returns false, iteration is stopped
     SW_DLLPUBLIC void ForEachCharacterFontItem(TypedWhichId<SvxFontItem> 
nWhich, bool bIgnoreAutoStyles, const std::function<bool(const SvxFontItem&)>&  
);
@@ -1478,6 +1478,9 @@ public:
     /// Iterate over all RES_BACKGROUND SvxBrushItem, if the function returns 
false, iteration is stopped
     SW_DLLPUBLIC void ForEachBackgroundBrushItem(const 
std::function<bool(const SvxBrushItem&)>&  ) const;
 
+    /// Iterate over all RES_CHRATR_HIGHLIGHT SvxBrushItem, if the function 
returns false, iteration is stopped
+    SW_DLLPUBLIC void ForEachCharacterHighlightBrushItem(const 
std::function<bool(const SvxBrushItem&)>&  ) const;
+
     // Call into intransparent Basic; expect possible Return String.
     void ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs );
 
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 01c064af5b25..ee4e1fa1359b 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1449,12 +1449,18 @@ void SwDoc::ForEachCharacterUnderlineItem( const 
std::function<bool(const SvxUnd
     ForEachCharacterItem(this, RES_CHRATR_UNDERLINE, rFunc);
 }
 
-/// Iterate over all SvxBrushItem, if the function returns false, iteration is 
stopped
-void SwDoc::ForEachCharacterBrushItem( const std::function<bool(const 
SvxBrushItem&)>& rFunc ) const
+/// Iterate over all RES_CHRATR_BACKGROUND SvxBrushItem, if the function 
returns false, iteration is stopped
+void SwDoc::ForEachCharacterBackgroundBrushItem( const 
std::function<bool(const SvxBrushItem&)>& rFunc ) const
 {
     ForEachCharacterItem(this, RES_CHRATR_BACKGROUND, rFunc);
 }
 
+/// Iterate over all RES_CHRATR_HIGHLIGHT SvxBrushItem, if the function 
returns false, iteration is stopped
+void SwDoc::ForEachCharacterHighlightBrushItem( const std::function<bool(const 
SvxBrushItem&)>& rFunc ) const
+{
+    ForEachCharacterItem(this, RES_CHRATR_HIGHLIGHT, rFunc);
+}
+
 /// Iterate over all RES_TXTATR_UNKNOWN_CONTAINER SvXMLAttrContainerItem, if 
the function returns false, iteration is stopped
 void SwDoc::ForEachTxtAtrContainerItem(const std::function<bool(const 
SvXMLAttrContainerItem&)>& rFunc ) const
 {
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 51c8e7f9f8a4..0a6c994c6bfe 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -19,6 +19,8 @@
 
 #include <libxml/xmlwriter.h>
 #include <hintids.hxx>
+#include <editeng/brushitem.hxx>
+#include <editeng/colritem.hxx>
 #include <svl/itemiter.hxx>
 #include <svl/numformat.hxx>
 #include <editeng/tstpitem.hxx>
@@ -28,7 +30,6 @@
 #include <officecfg/Office/Common.hxx>
 #include <osl/diagnose.h>
 #include <svl/zforlist.hxx>
-#include <svx/DocumentColorHelper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <unotools/configmgr.hxx>
 #include <sal/log.hxx>
@@ -2056,11 +2057,31 @@ void SwDBData::dumpAsXml(xmlTextWriterPtr pWriter) const
 std::set<Color> SwDoc::GetDocColors()
 {
     std::set<Color> aDocColors;
-    SwAttrPool& rPool = GetAttrPool();
 
-    svx::DocumentColorHelper::queryColors<SvxColorItem>(RES_CHRATR_COLOR, 
&rPool, aDocColors);
-    svx::DocumentColorHelper::queryColors<SvxBrushItem>(RES_CHRATR_HIGHLIGHT, 
&rPool, aDocColors);
-    svx::DocumentColorHelper::queryColors<SvxBrushItem>(RES_CHRATR_BACKGROUND, 
&rPool, aDocColors);
+    ForEachCharacterColorItem(
+            [&aDocColors] (const SvxColorItem& rColorItem) -> bool
+            {
+                Color aColor(rColorItem.GetValue());
+                if (COL_AUTO != aColor)
+                    aDocColors.insert(aColor);
+                return true;
+            });
+    ForEachCharacterHighlightBrushItem(
+            [&aDocColors] (const SvxBrushItem& rColorItem) -> bool
+            {
+                Color aColor(rColorItem.GetColor());
+                if (COL_AUTO != aColor)
+                    aDocColors.insert(aColor);
+                return true;
+            });
+    ForEachCharacterBackgroundBrushItem(
+            [&aDocColors] (const SvxBrushItem& rColorItem) -> bool
+            {
+                Color aColor(rColorItem.GetColor());
+                if (COL_AUTO != aColor)
+                    aDocColors.insert(aColor);
+                return true;
+            });
 
     return aDocColors;
 }
diff --git a/sw/source/filter/ww8/rtfexport.cxx 
b/sw/source/filter/ww8/rtfexport.cxx
index c12f528e43db..1bc1e77c53e2 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -1379,7 +1379,7 @@ void RtfExport::OutColorTable()
         {
             InsColor(pBackground->GetColor());
         }
-        m_rDoc.ForEachCharacterBrushItem([this](const SvxBrushItem& rBrush) -> 
bool {
+        m_rDoc.ForEachCharacterBackgroundBrushItem([this](const SvxBrushItem& 
rBrush) -> bool {
             InsColor(rBrush.GetColor());
             return true;
         });

Reply via email to