include/vcl/ColorDialog.hxx           |   14 +++--------
 vcl/inc/colorpicker.hxx               |   10 +++++---
 vcl/source/app/ColorDialog.cxx        |   40 +++++++++++++++++++++++-----------
 vcl/source/components/ColorPicker.cxx |   12 +++-------
 4 files changed, 43 insertions(+), 33 deletions(-)

New commits:
commit da8ee1416eaceb37ba14598b22eef1fa38b5f9b5
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Dec 5 16:38:10 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Dec 8 07:46:25 2025 +0100

    tdf#169505 Let ColorPickerDialog subclass ColorDialogController
    
    Subclass the new abstract class ColorDialogController
    introduced in previous commit
    
        Change-Id: I15900a2bc164c86b74ffe70246b59cb43dcc0543
        Author: Michael Weghorn <[email protected]>
        Date:   Fri Dec 5 16:21:37 2025 +0100
    
            tdf#169505 Add abstract ColorDialogController
    
    in ColorPickerDialog, which implements LibreOffice's
    custom color picker.
    
    This is another step to prepare for allowing to explicitly
    switch to the custom color picker instead of using the
    native GTK and Qt ones again.
    
    Change-Id: If0fc4607077254c13c1e02eb5415a23cbcd0fd96
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195103
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>
    (cherry picked from commit 0b839726d4cb3c54741faa66414f0ad119ddc9f3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195151

diff --git a/vcl/inc/colorpicker.hxx b/vcl/inc/colorpicker.hxx
index dcc780dfd3ca..45ae44dd468f 100644
--- a/vcl/inc/colorpicker.hxx
+++ b/vcl/inc/colorpicker.hxx
@@ -159,7 +159,7 @@ private:
     double mdValue;
 };
 
-class ColorPickerDialog : public weld::GenericDialogController
+class ColorPickerDialog : public weld::GenericDialogController, public virtual 
ColorDialogController
 {
 private:
     ColorFieldControl m_aColorField;
@@ -204,8 +204,12 @@ private:
 public:
     ColorPickerDialog(weld::Window* pParent, const Color& rColor, 
vcl::ColorPickerMode eDialogMode);
 
-    Color GetColor() const;
-    void SetColor(const Color& rColor);
+    virtual weld::Dialog* getDialog() override
+    {
+        return weld::GenericDialogController::getDialog();
+    }
+    virtual Color GetColor() const override;
+    virtual void SetColor(const Color& rColor) override;
 
 private:
     void update_color(UpdateFlags n = UpdateFlags::All);
commit 3238177f56fa1bfc0e39bb737f6158893911d352
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Dec 5 16:21:37 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Dec 8 07:46:18 2025 +0100

    tdf#169505 Add abstract ColorDialogController
    
    Instead of using ColorChooserDialogController
    directly in ColorDialog, which makes use of native
    GTK and Qt color dialogs for those VCL plugins,
    introduce a new base class ColorDialogController
    and let ColorChooserDialogController subclass it
    and move the implementation from the header to
    the source file.
    
    This is another step to prepare for alternatively using
    the custom LibreOffice implementation of a color
    picker, ColorPickerDialog again in the future
    if a still to be introduced option is set.
    
    Change-Id: I15900a2bc164c86b74ffe70246b59cb43dcc0543
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195102
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>
    (cherry picked from commit 77c2dc5b69e0bfe8816e8aac3ced3b6478350294)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195150

diff --git a/include/vcl/ColorDialog.hxx b/include/vcl/ColorDialog.hxx
index a55ecf47cec9..1fd9f138f51c 100644
--- a/include/vcl/ColorDialog.hxx
+++ b/include/vcl/ColorDialog.hxx
@@ -31,17 +31,11 @@ namespace vcl
     enum class ColorPickerMode { Select, Modify };
 }
 
-class ColorChooserDialogController : public weld::DialogController
+class ColorDialogController : public weld::DialogController
 {
-    std::unique_ptr<weld::ColorChooserDialog> m_pColorChooserDialog;
-
 public:
-    ColorChooserDialogController(std::unique_ptr<weld::ColorChooserDialog> 
pColorChooserDialog)
-        : m_pColorChooserDialog(std::move(pColorChooserDialog))
-    {
-    }
-
-    virtual weld::ColorChooserDialog* getDialog() override { return 
m_pColorChooserDialog.get(); }
+    virtual void SetColor(const Color& rColor) = 0;
+    virtual Color GetColor() const = 0;
 };
 
 class VCL_DLLPUBLIC ColorDialog final
@@ -57,7 +51,7 @@ public:
     void            ExecuteAsync(const std::function<void(sal_Int32)>& func);
 
 private:
-    std::shared_ptr<ColorChooserDialogController> 
m_pColorChooserDialogController;
+    std::shared_ptr<ColorDialogController> m_pColorDialogController;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/ColorDialog.cxx b/vcl/source/app/ColorDialog.cxx
index 589af550dc88..b231fce639a5 100644
--- a/vcl/source/app/ColorDialog.cxx
+++ b/vcl/source/app/ColorDialog.cxx
@@ -24,33 +24,49 @@
 #include <vcl/abstdlg.hxx>
 #include <vcl/weld.hxx>
 
+namespace
+{
+class ColorChooserDialogController : public ColorDialogController
+{
+    std::unique_ptr<weld::ColorChooserDialog> m_pColorChooserDialog;
+
+public:
+    ColorChooserDialogController(std::unique_ptr<weld::ColorChooserDialog> 
pColorChooserDialog)
+        : m_pColorChooserDialog(std::move(pColorChooserDialog))
+    {
+    }
+
+    virtual void SetColor(const Color& rColor) override
+    {
+        m_pColorChooserDialog->set_color(rColor);
+    }
+    virtual Color GetColor() const override { return 
m_pColorChooserDialog->get_color(); }
+
+private:
+    virtual weld::ColorChooserDialog* getDialog() override { return 
m_pColorChooserDialog.get(); }
+};
+}
+
 ColorDialog::ColorDialog(weld::Window* pParent, vcl::ColorPickerMode eMode)
 {
     std::unique_ptr<weld::ColorChooserDialog> pDialog
         = GetSalInstance()->CreateColorChooserDialog(pParent, eMode);
     assert(pDialog);
     pDialog->set_modal(true);
-    m_pColorChooserDialogController
-        = std::make_shared<ColorChooserDialogController>(std::move(pDialog));
+    m_pColorDialogController = 
std::make_shared<ColorChooserDialogController>(std::move(pDialog));
 }
 
 ColorDialog::~ColorDialog() {}
 
-void ColorDialog::SetColor(const Color& rColor)
-{
-    m_pColorChooserDialogController->getDialog()->set_color(rColor);
-}
+void ColorDialog::SetColor(const Color& rColor) { 
m_pColorDialogController->SetColor(rColor); }
 
-Color ColorDialog::GetColor() const
-{
-    return m_pColorChooserDialogController->getDialog()->get_color();
-}
+Color ColorDialog::GetColor() const { return 
m_pColorDialogController->GetColor(); }
 
-short ColorDialog::Execute() { return m_pColorChooserDialogController->run(); }
+short ColorDialog::Execute() { return m_pColorDialogController->run(); }
 
 void ColorDialog::ExecuteAsync(const std::function<void(sal_Int32)>& func)
 {
-    weld::DialogController::runAsync(m_pColorChooserDialogController, func);
+    weld::DialogController::runAsync(m_pColorDialogController, func);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit cbfae1c3be2d1cc2ee75f93c8f0dc6d7f26ae5be
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Dec 5 15:46:56 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Dec 8 07:46:12 2025 +0100

    tdf#169505 Use ColorDialog in ColorPicker
    
    Use the ColorDialog wrapper/abstraction instead
    of using weld::ColorChooserDialog directly.
    
    No change in behavior intended yet or seen for the
    sample macro mentioned in
    
        commit 9d6ade1f3b8e4ee59ae7bbe7fda440152af60221
        Author: Michael Weghorn <[email protected]>
        Date:   Tue Nov 18 17:06:04 2025 +0100
    
            [API CHANGE] Reintroduce com.sun.star.ui.dialogs.ColorPicker
    
    , but this way, a non-native dialog will be used here as well
    if use of native dialogs gets disabled, once an upcoming
    commit introduces that possibility for tdf#169505.
    
    Change-Id: I5ec37966fb2e68f39d5ae78cc829d47d897523a3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195101
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>
    (cherry picked from commit 86a04e193376b732bd8827103e1507046efff07b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195149

diff --git a/vcl/source/components/ColorPicker.cxx 
b/vcl/source/components/ColorPicker.cxx
index 3308001d1776..4ddba4fed433 100644
--- a/vcl/source/components/ColorPicker.cxx
+++ b/vcl/source/components/ColorPicker.cxx
@@ -7,9 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <salinst.hxx>
-#include <svdata.hxx>
-
 #include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/beans/XPropertyAccess.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -20,6 +17,7 @@
 #include <comphelper/propertyvalue.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <tools/color.hxx>
+#include <vcl/ColorDialog.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
 
@@ -105,12 +103,10 @@ void SAL_CALL ColorPicker::setTitle(const OUString&) {}
 
 sal_Int16 SAL_CALL ColorPicker::execute()
 {
-    std::unique_ptr<weld::ColorChooserDialog> pColorChooserDialog
-        = 
ImplGetSVData()->mpDefInst->CreateColorChooserDialog(Application::GetFrameWeld(m_xParent),
-                                                               
vcl::ColorPickerMode::Select);
-    const int nRet = pColorChooserDialog->run();
+    ColorDialog aColorDialog(Application::GetFrameWeld(m_xParent));
+    const int nRet = aColorDialog.Execute();
     if (nRet == RET_OK)
-        m_aColor = pColorChooserDialog->get_color();
+        m_aColor = aColorDialog.GetColor();
     return nRet;
 }
 

Reply via email to