[API CHANGE] Reintroduce com.sun.star.ui.dialogs.ColorPicker
Bring back the com.sun.star.ui.dialogs.ColorPicker service
previously dropped in
commit 5ba0ccb296
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Mon Jun 16 08:01:55 2025 +0200
[API CHANGE] Drop ColorPicker, AsynchronousColorPicker
The unpublished com::sun::star::cui::ColorPicker and
com::sun::star::cui::AsynchronousColorPicker UNO services
were previously used to be able to use ColorPickerDialog
(implemented in cui) from svtools.
That's no longer the case since
commit 0905c23676
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri Jun 13 18:27:09 2025 +0200
Stop using UNO abstraction for color picker
, so drop the now unused services and the ColorPicker
class that implemented them.
While the service was unpublished and undocumented, it was
still used in practice by third party code, see for
example the macro in [1] and further discussion in Gerrit
change [2].
Therefore bring back the service, but with a new
implementation in vcl that no longer uses the ColorPickerDialog
implemented in cui directly, but instead uses the
weld::ColorChooserDialog abstraction introduced in
commit dae9472b27
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri Jul 25 14:26:06 2025 +0200
tdf#167669 weld: Introduce weld::ColorChooserDialog
which supports the use of the native platform/toolkit
color dialogs (currently implemented for GTK and Qt), see
tdf#167669.
Don't reintroduce evaluation of the "Mode" parameter
to set a vcl::ColorPickerMode because that seems unused
by third-party code according to a quick Google search.
This makes the macro from [1] work again, and results in
the native GTK and Qt color pickers being used for the
case of the gtk3/qt6 VCL plugins on Linux.
[1] https://forum.openoffice.org/en/forum/viewtopic.php?f=21&t=99268
[2] https://gerrit.libreoffice.org/c/core/+/186538/comments/3af0d3d8_8b843d4e
Change-Id: Ic0f2ce2b289f37bf1fb32192d0f3b3deb99121ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194172
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
This commit is contained in:
committed by
Stephan Bergmann
parent
c8fa51cec1
commit
9d6ade1f3b
@@ -99,6 +99,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/configuration,\
|
||||
theDefaultProvider \
|
||||
))
|
||||
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/cui,\
|
||||
ColorPicker \
|
||||
GetCreateDialogFactoryService \
|
||||
))
|
||||
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/datatransfer,\
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* This file incorporates work covered by the following license notice:
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
|
||||
module com { module sun { module star { module cui {
|
||||
|
||||
/**
|
||||
@since LibreOffice 4.1
|
||||
*/
|
||||
service ColorPicker : com::sun::star::ui::dialogs::XExecutableDialog
|
||||
{
|
||||
createWithParent([in] com::sun::star::awt::XWindow Parent);
|
||||
};
|
||||
|
||||
|
||||
}; }; }; };
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -114,6 +114,7 @@ core_constructor_list = [
|
||||
# cppcanvas/source/uno/mtfrenderer.component
|
||||
"com_sun_star_comp_rendering_MtfRenderer_get_implementation",
|
||||
# cui/util/cui.component
|
||||
("com_sun_star_cui_ColorPicker_get_implementation", "#if !ENABLE_FUZZERS"),
|
||||
("com_sun_star_cui_GetCreateDialogFactoryService", "#if !ENABLE_FUZZERS"),
|
||||
# dbaccess/util/dba.component
|
||||
"com_sun_star_comp_dba_DataAccessDescriptorFactory",
|
||||
|
||||
@@ -472,6 +472,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
|
||||
vcl/source/app/watchdog \
|
||||
vcl/source/app/weldutils \
|
||||
vcl/source/app/winscheduler \
|
||||
vcl/source/components/ColorPicker \
|
||||
vcl/source/components/dtranscomp \
|
||||
vcl/source/components/fontident \
|
||||
vcl/source/filter/bmp/BmpReader \
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* 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>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
#include <comphelper/compbase.hxx>
|
||||
#include <comphelper/propertyvalue.hxx>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
#include <tools/color.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <vcl/weld.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
class ColorPicker : public comphelper::WeakComponentImplHelper<
|
||||
css::lang::XServiceInfo, css::ui::dialogs::XExecutableDialog,
|
||||
css::lang::XInitialization, css::beans::XPropertyAccess>
|
||||
{
|
||||
public:
|
||||
explicit ColorPicker();
|
||||
|
||||
// XInitialization
|
||||
virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override;
|
||||
|
||||
// XServiceInfo
|
||||
virtual OUString SAL_CALL getImplementationName() override;
|
||||
virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
|
||||
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
|
||||
|
||||
// XPropertyAccess
|
||||
virtual css::uno::Sequence<css::beans::PropertyValue> SAL_CALL getPropertyValues() override;
|
||||
virtual void SAL_CALL
|
||||
setPropertyValues(const css::uno::Sequence<css::beans::PropertyValue>& rProperties) override;
|
||||
|
||||
// XExecutableDialog
|
||||
virtual void SAL_CALL setTitle(const OUString& rTitle) override;
|
||||
virtual sal_Int16 SAL_CALL execute() override;
|
||||
|
||||
private:
|
||||
Color m_aColor;
|
||||
css::uno::Reference<css::awt::XWindow> m_xParent;
|
||||
};
|
||||
|
||||
constexpr OUString COLOR_PROPERTY_NAME = u"Color"_ustr;
|
||||
|
||||
ColorPicker::ColorPicker()
|
||||
: m_aColor(COL_BLACK)
|
||||
{
|
||||
}
|
||||
|
||||
void SAL_CALL ColorPicker::initialize(const css::uno::Sequence<css::uno::Any>& rArguments)
|
||||
{
|
||||
if (rArguments.getLength() == 1)
|
||||
{
|
||||
rArguments[0] >>= m_xParent;
|
||||
}
|
||||
}
|
||||
|
||||
OUString SAL_CALL ColorPicker::getImplementationName()
|
||||
{
|
||||
return u"com.sun.star.cui.ColorPicker"_ustr;
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL ColorPicker::supportsService(const OUString& rServiceName)
|
||||
{
|
||||
return cppu::supportsService(this, rServiceName);
|
||||
}
|
||||
|
||||
css::uno::Sequence<OUString> SAL_CALL ColorPicker::getSupportedServiceNames()
|
||||
{
|
||||
return { u"com.sun.star.ui.dialogs.ColorPicker"_ustr };
|
||||
}
|
||||
|
||||
css::uno::Sequence<css::beans::PropertyValue> SAL_CALL ColorPicker::getPropertyValues()
|
||||
{
|
||||
css::uno::Sequence<css::beans::PropertyValue> aProps{ comphelper::makePropertyValue(
|
||||
COLOR_PROPERTY_NAME, m_aColor) };
|
||||
return aProps;
|
||||
}
|
||||
|
||||
void SAL_CALL
|
||||
ColorPicker::setPropertyValues(const css::uno::Sequence<css::beans::PropertyValue>& rProperties)
|
||||
{
|
||||
for (const css::beans::PropertyValue& rProp : rProperties)
|
||||
{
|
||||
if (rProp.Name == COLOR_PROPERTY_NAME)
|
||||
rProp.Value >>= m_aColor;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
if (nRet == RET_OK)
|
||||
m_aColor = pColorChooserDialog->get_color();
|
||||
return nRet;
|
||||
}
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
com_sun_star_cui_ColorPicker_get_implementation(css::uno::XComponentContext*,
|
||||
const css::uno::Sequence<css::uno::Any>&)
|
||||
{
|
||||
return cppu::acquire(new ColorPicker);
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
@@ -27,6 +27,10 @@
|
||||
constructor="com_sun_star_comp_graphic_GraphicProvider_get_implementation">
|
||||
<service name="com.sun.star.graphic.GraphicProvider"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.cui.ColorPicker"
|
||||
constructor="com_sun_star_cui_ColorPicker_get_implementation">
|
||||
<service name="com.sun.star.ui.dialogs.ColorPicker"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.datatransfer.clipboard.AquaClipboard"
|
||||
constructor="vcl_SystemClipboard_get_implementation">
|
||||
<service name="com.sun.star.datatransfer.clipboard.SystemClipboard"/>
|
||||
|
||||
Reference in New Issue
Block a user