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 9d6ade1f3b
    Author: Michael Weghorn <m.weghorn@posteo.de>
    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 <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn
2025-12-06 08:41:27 +01:00
parent 005d7e91a2
commit 86a04e1933
+4 -8
View File
@@ -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;
}