[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 28 09:01:24 UTC 2020


 include/vcl/weld.hxx          |    4 ++--
 vcl/source/app/salvtables.cxx |   16 ++++++++++++----
 vcl/unx/gtk3/gtk3gtkinst.cxx  |   21 +++++++++++++--------
 3 files changed, 27 insertions(+), 14 deletions(-)

New commits:
commit f4873d0e7972ec3ee646aa0d847c626ebe7d857f
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 27 21:28:04 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 28 10:00:47 2020 +0100

    use COL_AUTO to let set_font_color reset to automatic text color
    
    Change-Id: I5761081fde66da3dc8071709e53b2014f10b5916
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89651
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index a6d9978850c5..fa6594089de9 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -848,7 +848,7 @@ public:
     virtual bool get_text_emphasis(int row, int col) const = 0;
     virtual void swap(int pos1, int pos2) = 0;
     virtual std::vector<int> get_selected_rows() const = 0;
-    virtual void set_font_color(int pos, const Color& rColor) const = 0;
+    virtual void set_font_color(int pos, const Color& rColor) = 0;
     virtual void scroll_to_row(int pos) = 0;
     virtual bool is_selected(int pos) const = 0;
     virtual int get_cursor_index() const = 0;
@@ -932,7 +932,7 @@ public:
     virtual void set_image(const TreeIter& rIter,
                            const css::uno::Reference<css::graphic::XGraphic>& rImage, int col = -1)
         = 0;
-    virtual void set_font_color(const TreeIter& rIter, const Color& rColor) const = 0;
+    virtual void set_font_color(const TreeIter& rIter, const Color& rColor) = 0;
     virtual void scroll_to_row(const TreeIter& rIter) = 0;
     virtual bool is_selected(const TreeIter& rIter) const = 0;
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 943f6f1e0be4..cd076d517150 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3276,6 +3276,14 @@ private:
         return nullptr;
     }
 
+    static void set_font_color(SvTreeListEntry* pEntry, const Color& rColor)
+    {
+        if (rColor == COL_AUTO)
+            pEntry->SetTextColor(std::optional<Color>());
+        else
+            pEntry->SetTextColor(rColor);
+    }
+
 public:
     SalInstanceTreeView(SvTabListBox* pTreeView, SalInstanceBuilder* pBuilder, bool bTakeOwnership)
         : SalInstanceContainer(pTreeView, pBuilder, bTakeOwnership)
@@ -3523,16 +3531,16 @@ public:
         thaw();
     }
 
-    virtual void set_font_color(int pos, const Color& rColor) const override
+    virtual void set_font_color(int pos, const Color& rColor) override
     {
         SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
-        pEntry->SetTextColor(rColor);
+        set_font_color(pEntry, rColor);
     }
 
-    virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) const override
+    virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) override
     {
         const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
-        rVclIter.iter->SetTextColor(rColor);
+        set_font_color(rVclIter.iter, rColor);
     }
 
     virtual void remove(int pos) override
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index f1d28a270e15..a1f5c28c0964 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -9078,6 +9078,17 @@ private:
         return lastpath;
     }
 
+    void set_font_color(const GtkTreeIter& iter, const Color& rColor)
+    {
+        if (rColor == COL_AUTO)
+            gtk_tree_store_set(m_pTreeStore, const_cast<GtkTreeIter*>(&iter), m_nIdCol + 1, nullptr, -1);
+        else
+        {
+            GdkRGBA aColor{rColor.GetRed()/255.0, rColor.GetGreen()/255.0, rColor.GetBlue()/255.0, 0};
+            gtk_tree_store_set(m_pTreeStore, const_cast<GtkTreeIter*>(&iter), m_nIdCol + 1, &aColor, -1);
+        }
+    }
+
 public:
     GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
         : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership)
@@ -9260,20 +9271,14 @@ public:
         enable_notify_events();
     }
 
-    void set_font_color(const GtkTreeIter& iter, const Color& rColor) const
-    {
-        GdkRGBA aColor{rColor.GetRed()/255.0, rColor.GetGreen()/255.0, rColor.GetBlue()/255.0, 0};
-        gtk_tree_store_set(m_pTreeStore, const_cast<GtkTreeIter*>(&iter), m_nIdCol + 1, &aColor, -1);
-    }
-
-    virtual void set_font_color(int pos, const Color& rColor) const override
+    virtual void set_font_color(int pos, const Color& rColor) override
     {
         GtkTreeIter iter;
         gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pTreeStore), &iter, nullptr, pos);
         set_font_color(iter, rColor);
     }
 
-    virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) const override
+    virtual void set_font_color(const weld::TreeIter& rIter, const Color& rColor) override
     {
         const GtkInstanceTreeIter& rGtkIter = static_cast<const GtkInstanceTreeIter&>(rIter);
         set_font_color(rGtkIter.iter, rColor);


More information about the Libreoffice-commits mailing list