21#include <com/sun/star/awt/XWindow.hpp>
22#include <com/sun/star/beans/XPropertyAccess.hpp>
23#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
24#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
25#include <com/sun/star/cui/AsynchronousColorPicker.hpp>
26#include <com/sun/star/cui/ColorPicker.hpp>
35#include <osl/diagnose.h>
42constexpr OUStringLiteral
sColor =
u"Color";
67 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
69 Reference<css::awt::XWindow> xParent;
73 Reference< XExecutableDialog > xDialog = css::cui::ColorPicker::createWithParent(xContext, xParent);
74 Reference< XPropertyAccess > xPropertyAccess( xDialog, UNO_QUERY_THROW );
76 Sequence< PropertyValue >
props{
81 xPropertyAccess->setPropertyValues(
props );
83 ret = xDialog->execute();
87 props = xPropertyAccess->getPropertyValues();
88 for(
const auto& rProp : std::as_const(
props) )
111 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
113 Reference<css::awt::XWindow> xParent;
117 mxDialog = css::cui::AsynchronousColorPicker::createWithParent(xContext, xParent);
118 Reference< XPropertyAccess > xPropertyAccess(
mxDialog, UNO_QUERY_THROW );
120 Sequence< PropertyValue >
props{
125 xPropertyAccess->setPropertyValues(
props );
130 mxDialog->startExecuteModal( pListener );
140 sal_Int32 nResult = 0;
141 sal_Int16 nDialogRet = pEvent->DialogResult;
142 if( nDialogRet == ExecutableDialogResults::OK )
146 Reference< XPropertyAccess > xPropertyAccess( mxDialog, UNO_QUERY_THROW );
147 Sequence< PropertyValue >
props = xPropertyAccess->getPropertyValues();
149 for(
const auto& rProp : std::as_const(
props) )
151 if( rProp.Name ==
sColor )
158 m_aResultFunc(nResult);
void SetMode(svtools::ColorPickerMode eMode)
::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XAsynchronousExecutableDialog > mxDialog
short Execute(weld::Window *pParent)
void SetColor(const Color &rColor)
void ExecuteAsync(weld::Window *pParent, const std::function< void(sal_Int32)> &func)
std::function< void(sal_Int32)> m_aResultFunc
svtools::ColorPickerMode meMode
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
constexpr OUStringLiteral sColor
IMPL_LINK(SvColorDialog, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent *, pEvent, void)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)