1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/uno/XComponentContext.hpp>
21 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
22 #include <com/sun/star/beans/XPropertyAccess.hpp>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/datatransfer/XTransferable.hpp>
26 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
27 #include <com/sun/star/awt/XWindow.hpp>
28 #include <cppuhelper/compbase4.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <comphelper/broadcasthelper.hxx>
31 #include <vcl/dialog.hxx>
32 #include <vcl/button.hxx>
33 #include <vcl/fixed.hxx>
34 #include <vcl/edit.hxx>
35 #include <vcl/field.hxx>
36 #include <vcl/bmpacc.hxx>
37 #include <vcl/decoview.hxx>
38 #include <vcl/svapp.hxx>
39 #include <vcl/builderfactory.hxx>
40 #include <toolkit/helper/vclunohelper.hxx>
41 #include <sot/exchange.hxx>
42 #include <sot/formats.hxx>
43 #include <sax/tools/converter.hxx>
44 #include <basegfx/color/bcolortools.hxx>
45 #include "dialmgr.hxx"
46 #include "colorpicker.hxx"
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::ui::dialogs
;
53 using namespace ::com::sun::star::beans
;
54 using namespace ::basegfx
;
58 const sal_uInt16 COLORMODE_RGB
= 0x10;
59 const sal_uInt16 COLORMODE_HSV
= 0x20;
61 const sal_uInt16 COLORCOMP_RED
= 0x10;
62 const sal_uInt16 COLORCOMP_GREEN
= 0x11;
63 const sal_uInt16 COLORCOMP_BLUE
= 0x12;
65 const sal_uInt16 COLORCOMP_HUE
= 0x20;
66 const sal_uInt16 COLORCOMP_SAT
= 0x21;
67 const sal_uInt16 COLORCOMP_BRI
= 0x22;
69 const sal_uInt16 COLORCOMP_CYAN
= 0x40;
70 const sal_uInt16 COLORCOMP_YELLOW
= 0x41;
71 const sal_uInt16 COLORCOMP_MAGENTA
= 0x42;
72 const sal_uInt16 COLORCOMP_KEY
= 0x43;
74 // color space conversion helpers
76 static void RGBtoHSV( double dR
, double dG
, double dB
, double& dH
, double& dS
, double& dV
)
78 BColor result
= basegfx::tools::rgb2hsv( BColor( dR
, dG
, dB
) );
85 static void HSVtoRGB(double dH
, double dS
, double dV
, double& dR
, double& dG
, double& dB
)
87 BColor result
= basegfx::tools::hsv2rgb( BColor( dH
, dS
, dV
) );
90 dG
= result
.getGreen();
91 dB
= result
.getBlue();
94 // CMYK values from 0 to 1
95 static void CMYKtoRGB( double fCyan
, double fMagenta
, double fYellow
, double fKey
, double& dR
, double& dG
, double& dB
)
97 fCyan
= (fCyan
* ( 1.0 - fKey
)) + fKey
;
98 fMagenta
= (fMagenta
* ( 1.0 - fKey
)) + fKey
;
99 fYellow
= (fYellow
* ( 1.0 - fKey
)) + fKey
;
101 dR
= std::max( std::min( ( 1.0 - fCyan
), 1.0), 0.0 );
102 dG
= std::max( std::min( ( 1.0 - fMagenta
), 1.0), 0.0 );
103 dB
= std::max( std::min( ( 1.0 - fYellow
), 1.0), 0.0 );
106 // CMY results from 0 to 1
107 static void RGBtoCMYK( double dR
, double dG
, double dB
, double& fCyan
, double& fMagenta
, double& fYellow
, double& fKey
)
113 //CMYK and CMY values from 0 to 1
115 if( fCyan
< fKey
) fKey
= fCyan
;
116 if( fMagenta
< fKey
) fKey
= fMagenta
;
117 if( fYellow
< fKey
) fKey
= fYellow
;
128 fCyan
= ( fCyan
- fKey
) / ( 1.0 - fKey
);
129 fMagenta
= ( fMagenta
- fKey
) / ( 1.0 - fKey
);
130 fYellow
= ( fYellow
- fKey
) / ( 1.0 - fKey
);
134 class HexColorControl
: public Edit
137 HexColorControl( vcl::Window
* pParent
, const WinBits
& nStyle
);
139 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
140 virtual void Paste() SAL_OVERRIDE
;
142 void SetColor( sal_Int32 nColor
);
143 sal_Int32
GetColor();
146 static bool ImplProcessKeyInput( const KeyEvent
& rKEv
);
149 HexColorControl::HexColorControl( vcl::Window
* pParent
, const WinBits
& nStyle
)
150 : Edit(pParent
, nStyle
)
155 VCL_BUILDER_FACTORY_ARGS(HexColorControl
, WB_BORDER
)
157 void HexColorControl::SetColor(sal_Int32 nColor
)
159 OUStringBuffer aBuffer
;
160 sax::Converter::convertColor(aBuffer
, nColor
);
161 SetText(aBuffer
.makeStringAndClear().copy(1));
164 sal_Int32
HexColorControl::GetColor()
166 sal_Int32 nColor
= -1;
170 sal_Int32 nLen
= aStr
.getLength();
174 static const sal_Char
* pNullStr
= "000000";
175 aStr
+= OUString::createFromAscii( &pNullStr
[nLen
-1] );
178 sax::Converter::convertColor(nColor
, aStr
);
181 SetControlBackground(Color(COL_RED
));
183 SetControlBackground();
188 bool HexColorControl::PreNotify( NotifyEvent
& rNEvt
)
190 if ( (rNEvt
.GetType() == MouseNotifyEvent::KEYINPUT
) && !rNEvt
.GetKeyEvent()->GetKeyCode().IsMod2() )
192 if ( ImplProcessKeyInput( *rNEvt
.GetKeyEvent() ) )
196 return Edit::PreNotify( rNEvt
);
199 void HexColorControl::Paste()
201 css::uno::Reference
<css::datatransfer::clipboard::XClipboard
> aClipboard(GetClipboard());
204 css::uno::Reference
<css::datatransfer::XTransferable
> xDataObj
;
208 SolarMutexReleaser aReleaser
;
209 xDataObj
= aClipboard
->getContents();
211 catch (const css::uno::Exception
&)
217 css::datatransfer::DataFlavor aFlavor
;
218 SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING
, aFlavor
);
221 css::uno::Any aData
= xDataObj
->getTransferData(aFlavor
);
225 if( !aText
.isEmpty() && aText
.startsWith( "#" ) )
226 aText
= aText
.copy(1);
228 if( aText
.getLength() > 6 )
229 aText
= aText
.copy( 0, 6 );
233 catch(const css::uno::Exception
&)
239 bool HexColorControl::ImplProcessKeyInput( const KeyEvent
& rKEv
)
241 const vcl::KeyCode
& rKeyCode
= rKEv
.GetKeyCode();
243 if( rKeyCode
.GetGroup() == KEYGROUP_ALPHA
&& !rKeyCode
.IsMod1() && !rKeyCode
.IsMod2() )
245 if( (rKeyCode
.GetCode() < KEY_A
) || (rKeyCode
.GetCode() > KEY_F
) )
248 else if( rKeyCode
.GetGroup() == KEYGROUP_NUM
)
250 if( rKeyCode
.IsShift() )
256 class ColorPreviewControl
: public Control
259 ColorPreviewControl( vcl::Window
* pParent
, const WinBits
& nStyle
);
261 virtual void Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
263 void SetColor(const Color
& rColor
);
269 ColorPreviewControl::ColorPreviewControl(vcl::Window
* pParent
, const WinBits
& nStyle
)
270 : Control(pParent
, nStyle
)
274 VCL_BUILDER_DECL_FACTORY(ColorPreviewControl
)
278 OString sBorder
= VclBuilder::extractCustomProperty(rMap
);
279 if (!sBorder
.isEmpty())
282 rRet
= VclPtr
<ColorPreviewControl
>::Create(pParent
, nBits
);
285 void ColorPreviewControl::SetColor( const Color
& rCol
)
294 void ColorPreviewControl::Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
)
296 rRenderContext
.SetFillColor(maColor
);
297 rRenderContext
.SetLineColor(maColor
);
298 rRenderContext
.DrawRect(rRect
);
301 enum ColorMode
{ HUE
, SATURATION
, BRIGHTNESS
, RED
, GREEN
, BLUE
};
302 const ColorMode DefaultMode
= HUE
;
304 class ColorFieldControl
: public Control
307 ColorFieldControl(vcl::Window
* pParent
, const WinBits
& nStyle
);
308 virtual ~ColorFieldControl();
310 virtual void dispose() SAL_OVERRIDE
;
312 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
313 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
314 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
315 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
316 virtual void Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
317 virtual void Resize() SAL_OVERRIDE
;
319 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
322 void ShowPosition( const Point
& rPos
, bool bUpdate
);
323 void UpdatePosition();
326 void SetValues(Color aColor
, ColorMode eMode
, double x
, double y
);
327 double GetX() { return mdX
;}
328 double GetY() { return mdY
;}
330 void KeyMove(int dx
, int dy
);
332 void SetModifyHdl(Link
<>& rLink
) { maModifyHdl
= rLink
; }
342 std::vector
<sal_uInt8
> maRGB_Horiz
;
343 std::vector
<sal_uInt16
> maGrad_Horiz
;
344 std::vector
<sal_uInt16
> maPercent_Horiz
;
345 std::vector
<sal_uInt8
> maRGB_Vert
;
346 std::vector
<sal_uInt16
> maPercent_Vert
;
349 ColorFieldControl::ColorFieldControl( vcl::Window
* pParent
, const WinBits
& nStyle
)
350 : Control( pParent
, nStyle
)
351 , meMode( DefaultMode
)
356 SetControlBackground();
359 ColorFieldControl::~ColorFieldControl()
364 void ColorFieldControl::dispose()
371 VCL_BUILDER_DECL_FACTORY(ColorFieldControl
)
375 OString sBorder
= VclBuilder::extractCustomProperty(rMap
);
376 if (!sBorder
.isEmpty())
379 rRet
= VclPtr
<ColorFieldControl
>::Create(pParent
, nBits
);
382 Size
ColorFieldControl::GetOptimalSize() const
384 return LogicToPixel(Size(158, 158), MAP_APPFONT
);
387 void ColorFieldControl::UpdateBitmap()
389 const Size
aSize(GetOutputSizePixel());
391 if (mpBitmap
&& mpBitmap
->GetSizePixel() != aSize
)
392 delete mpBitmap
, mpBitmap
= NULL
;
394 const sal_Int32 nWidth
= aSize
.Width();
395 const sal_Int32 nHeight
= aSize
.Height();
397 if (nWidth
== 0 || nHeight
== 0)
402 mpBitmap
= new Bitmap( aSize
, 24 );
404 maRGB_Horiz
.resize( nWidth
);
405 maGrad_Horiz
.resize( nWidth
);
406 maPercent_Horiz
.resize( nWidth
);
408 sal_uInt8
* pRGB
= maRGB_Horiz
.data();
409 sal_uInt16
* pGrad
= maGrad_Horiz
.data();
410 sal_uInt16
* pPercent
= maPercent_Horiz
.data();
412 for( sal_Int32 x
= 0; x
< nWidth
; x
++ )
414 *pRGB
++ = static_cast<sal_uInt8
>((x
* 256) / nWidth
);
415 *pGrad
++ = static_cast<sal_uInt16
>((x
* 359) / nWidth
);
416 *pPercent
++ = static_cast<sal_uInt16
>((x
* 100) / nWidth
);
419 maRGB_Vert
.resize(nHeight
);
420 maPercent_Vert
.resize(nHeight
);
422 pRGB
= maRGB_Vert
.data();
423 pPercent
= maPercent_Vert
.data();
425 sal_Int32 y
= nHeight
;
428 *pRGB
++ = static_cast<sal_uInt8
>((y
* 256) / nHeight
);
429 *pPercent
++ = static_cast<sal_uInt16
>((y
* 100) / nHeight
);
433 sal_uInt8
* pRGB_Horiz
= maRGB_Horiz
.data();
434 sal_uInt16
* pGrad_Horiz
= maGrad_Horiz
.data();
435 sal_uInt16
* pPercent_Horiz
= maPercent_Horiz
.data();
436 sal_uInt8
* pRGB_Vert
= maRGB_Vert
.data();
437 sal_uInt16
* pPercent_Vert
= maPercent_Vert
.data();
439 BitmapWriteAccess
* pWriteAccess
= mpBitmap
->AcquireWriteAccess();
442 BitmapColor
aBitmapColor(maColor
);
444 sal_uInt16 nHue
, nSat
, nBri
;
445 maColor
.RGBtoHSB(nHue
, nSat
, nBri
);
447 // this has been unlooped for performance reason, please do not merge back!
449 sal_uInt16 y
= nHeight
,x
;
456 nBri
= pPercent_Vert
[y
];
460 nSat
= pPercent_Horiz
[x
];
461 pWriteAccess
->SetPixel(y
, x
, BitmapColor(Color(Color::HSBtoRGB(nHue
, nSat
, nBri
))));
468 nBri
= pPercent_Vert
[y
];
472 nHue
= pGrad_Horiz
[x
];
473 pWriteAccess
->SetPixel(y
, x
, BitmapColor(Color(Color::HSBtoRGB(nHue
, nSat
, nBri
))));
480 nSat
= pPercent_Vert
[y
];
484 nHue
= pGrad_Horiz
[x
];
485 pWriteAccess
->SetPixel(y
, x
, BitmapColor(Color(Color::HSBtoRGB(nHue
, nSat
, nBri
))));
492 aBitmapColor
.SetGreen(pRGB_Vert
[y
]);
496 aBitmapColor
.SetBlue(pRGB_Horiz
[x
]);
497 pWriteAccess
->SetPixel(y
, x
, aBitmapColor
);
504 aBitmapColor
.SetRed(pRGB_Vert
[y
]);
508 aBitmapColor
.SetBlue(pRGB_Horiz
[x
]);
509 pWriteAccess
->SetPixel(y
, x
, aBitmapColor
);
516 aBitmapColor
.SetGreen(pRGB_Vert
[y
]);
520 aBitmapColor
.SetRed(pRGB_Horiz
[x
]);
521 pWriteAccess
->SetPixel(y
, x
, aBitmapColor
);
527 Bitmap::ReleaseAccess(pWriteAccess
);
531 void ColorFieldControl::ShowPosition( const Point
& rPos
, bool bUpdate
)
542 const Size
aSize(mpBitmap
->GetSizePixel());
548 else if (nX
>= aSize
.Width())
549 nX
= aSize
.Width() - 1L;
553 else if (nY
>= aSize
.Height())
554 nY
= aSize
.Height() - 1L;
556 Point aPos
= maPosition
;
557 maPosition
.X() = nX
- 5;
558 maPosition
.Y() = nY
- 5;
559 Invalidate(Rectangle(aPos
, Size(11, 11)));
560 Invalidate(Rectangle(maPosition
, Size(11, 11)));
564 mdX
= double(nX
) / double(aSize
.Width() - 1.0);
565 mdY
= double(aSize
.Height() - 1.0 - nY
) / double(aSize
.Height() - 1.0);
567 BitmapReadAccess
* pReadAccess
= mpBitmap
->AcquireReadAccess();
568 if (pReadAccess
!= NULL
)
570 // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
571 maColor
= pReadAccess
->GetPixel(nY
, nX
);
572 Bitmap::ReleaseAccess(pReadAccess
);
578 void ColorFieldControl::MouseMove( const MouseEvent
& rMEvt
)
582 ShowPosition( rMEvt
.GetPosPixel(), true );
587 void ColorFieldControl::MouseButtonDown( const MouseEvent
& rMEvt
)
589 if( rMEvt
.IsLeft() && !rMEvt
.IsShift() )
592 ShowPosition( rMEvt
.GetPosPixel(), true );
597 void ColorFieldControl::MouseButtonUp( const MouseEvent
& )
599 if( IsMouseCaptured() )
603 void ColorFieldControl::KeyMove( int dx
, int dy
)
605 Size
aSize(GetOutputSizePixel());
606 Point
aPos(static_cast<long>(mdX
* aSize
.Width()), static_cast<long>((1.0 - mdY
) * aSize
.Height()));
610 aPos
.X() += aSize
.Width();
611 else if( aPos
.X() >= aSize
.Width() )
612 aPos
.X() -= aSize
.Width();
615 aPos
.Y() += aSize
.Height();
616 else if( aPos
.Y() >= aSize
.Height() )
617 aPos
.Y() -= aSize
.Height();
619 ShowPosition( aPos
, true );
623 void ColorFieldControl::KeyInput( const KeyEvent
& rKEvt
)
625 bool bShift
= rKEvt
.GetKeyCode().IsShift();
626 bool bCtrl
= rKEvt
.GetKeyCode().IsMod1();
627 bool bAlt
= rKEvt
.GetKeyCode().IsMod2();
629 if (!bAlt
&& !bShift
)
631 switch( rKEvt
.GetKeyCode().GetCode() )
634 KeyMove(0, bCtrl
? 5 : 1);
637 KeyMove(0, bCtrl
? -5 : -1);
640 KeyMove(bCtrl
? -5 : -1, 0);
643 KeyMove(bCtrl
? 5 : 1, 0);
647 Control::KeyInput(rKEvt
);
650 void ColorFieldControl::Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
)
657 Bitmap
aOutputBitmap(*mpBitmap
);
659 if (GetBitCount() <= 8)
660 aOutputBitmap
.Dither();
662 rRenderContext
.DrawBitmap(rRect
.TopLeft(), rRect
.GetSize(), rRect
.TopLeft(), rRect
.GetSize(), aOutputBitmap
);
665 // draw circle around current color
666 if (maColor
.IsDark())
667 rRenderContext
.SetLineColor( COL_WHITE
);
669 rRenderContext
.SetLineColor( COL_BLACK
);
671 rRenderContext
.SetFillColor();
673 rRenderContext
.DrawEllipse(Rectangle(maPosition
, Size(11, 11)));
676 void ColorFieldControl::Resize()
683 void ColorFieldControl::Modify()
685 maModifyHdl
.Call( this );
688 void ColorFieldControl::SetValues( Color aColor
, ColorMode eMode
, double x
, double y
)
690 bool bUpdateBitmap
= (maColor
!= aColor
) || (meMode
!= eMode
);
691 if( bUpdateBitmap
|| (mdX
!= x
) || (mdY
!= y
) )
706 void ColorFieldControl::UpdatePosition()
708 Size
aSize(GetOutputSizePixel());
709 ShowPosition(Point(static_cast<long>(mdX
* aSize
.Width()), static_cast<long>((1.0 - mdY
) * aSize
.Height())), false);
712 class ColorSliderControl
: public Control
715 ColorSliderControl( vcl::Window
* pParent
, const WinBits
& nStyle
);
716 virtual ~ColorSliderControl();
717 virtual void dispose() SAL_OVERRIDE
;
719 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
720 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
721 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
722 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
723 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
724 virtual void Resize() SAL_OVERRIDE
;
727 void ChangePosition( long nY
);
730 void SetValue( const Color
& rColor
, ColorMode eMode
, double dValue
);
731 double GetValue() const { return mdValue
; }
733 void KeyMove( int dy
);
735 void SetModifyHdl( Link
<>& rLink
) { maModifyHdl
= rLink
; }
737 sal_Int16
GetLevel() const { return mnLevel
; }
748 ColorSliderControl::ColorSliderControl( vcl::Window
* pParent
, const WinBits
& nStyle
)
749 : Control( pParent
, nStyle
)
750 , meMode( DefaultMode
)
755 SetControlBackground();
758 ColorSliderControl::~ColorSliderControl()
763 void ColorSliderControl::dispose()
770 VCL_BUILDER_DECL_FACTORY(ColorSliderControl
)
774 OString sBorder
= VclBuilder::extractCustomProperty(rMap
);
775 if (!sBorder
.isEmpty())
778 rRet
= VclPtr
<ColorSliderControl
>::Create(pParent
, nBits
);
781 void ColorSliderControl::UpdateBitmap()
783 Size
aSize(1, GetOutputSizePixel().Height());
785 if (mpBitmap
&& mpBitmap
->GetSizePixel() != aSize
)
786 delete mpBitmap
, mpBitmap
= NULL
;
789 mpBitmap
= new Bitmap(aSize
, 24);
791 BitmapWriteAccess
* pWriteAccess
= mpBitmap
->AcquireWriteAccess();
795 const long nY
= aSize
.Height() - 1;
797 BitmapColor
aBitmapColor(maColor
);
799 sal_uInt16 nHue
, nSat
, nBri
;
800 maColor
.RGBtoHSB(nHue
, nSat
, nBri
);
802 // this has been unlooped for performance reason, please do not merge back!
809 for (long y
= 0; y
<= nY
; y
++)
811 nHue
= static_cast<sal_uInt16
>((359 * y
) / nY
);
812 aBitmapColor
= BitmapColor(Color(Color::HSBtoRGB(nHue
, nSat
, nBri
)));
813 pWriteAccess
->SetPixel(nY
- y
, 0, aBitmapColor
);
818 nBri
= std::max(sal_uInt16(32), nBri
);
819 for (long y
= 0; y
<= nY
; y
++)
821 nSat
= static_cast<sal_uInt16
>((100 * y
) / nY
);
822 pWriteAccess
->SetPixel(nY
- y
, 0, BitmapColor(Color(Color::HSBtoRGB(nHue
, nSat
, nBri
))));
827 for (long y
= 0; y
<= nY
; y
++)
829 nBri
= static_cast<sal_uInt16
>((100 * y
) / nY
);
830 pWriteAccess
->SetPixel(nY
- y
, 0, BitmapColor(Color(Color::HSBtoRGB(nHue
, nSat
, nBri
))));
835 for (long y
= 0; y
<= nY
; y
++)
837 aBitmapColor
.SetRed(sal_uInt8(((long)255 * y
) / nY
));
838 pWriteAccess
->SetPixel(nY
- y
, 0, aBitmapColor
);
843 for (long y
= 0; y
<= nY
; y
++)
845 aBitmapColor
.SetGreen(sal_uInt8(((long)255 * y
) / nY
));
846 pWriteAccess
->SetPixel(nY
- y
, 0, aBitmapColor
);
851 for (long y
= 0; y
<= nY
; y
++)
853 aBitmapColor
.SetBlue(sal_uInt8(((long)255 * y
) / nY
));
854 pWriteAccess
->SetPixel(nY
- y
, 0, aBitmapColor
);
859 Bitmap::ReleaseAccess(pWriteAccess
);
863 void ColorSliderControl::ChangePosition(long nY
)
865 const long nHeight
= GetOutputSizePixel().Height() - 1;
869 else if (nY
> nHeight
)
873 mdValue
= double(nHeight
- nY
) / double(nHeight
);
876 void ColorSliderControl::MouseMove( const MouseEvent
& rMEvt
)
880 ChangePosition(rMEvt
.GetPosPixel().Y());
885 void ColorSliderControl::MouseButtonDown(const MouseEvent
& rMEvt
)
887 if (rMEvt
.IsLeft() && !rMEvt
.IsShift())
890 ChangePosition( rMEvt
.GetPosPixel().Y() );
895 void ColorSliderControl::MouseButtonUp(const MouseEvent
&)
897 if (IsMouseCaptured())
901 void ColorSliderControl::KeyMove(int dy
)
903 ChangePosition( mnLevel
+ dy
);
907 void ColorSliderControl::KeyInput(const KeyEvent
& rKEvt
)
909 if (!rKEvt
.GetKeyCode().IsMod2() && !rKEvt
.GetKeyCode().IsShift())
911 switch (rKEvt
.GetKeyCode().GetCode())
914 KeyMove(rKEvt
.GetKeyCode().IsMod1() ? 5 : 1);
917 KeyMove(rKEvt
.GetKeyCode().IsMod1() ? -5 : -1);
922 Control::KeyInput( rKEvt
);
925 void ColorSliderControl::Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& /*rRect*/)
930 const Size
aSize(GetOutputSizePixel());
932 Bitmap
aOutputBitmap(*mpBitmap
);
934 if (GetBitCount() <= 8)
935 aOutputBitmap
.Dither();
938 int x
= aSize
.Width();
941 rRenderContext
.DrawBitmap(aPos
, aOutputBitmap
);
946 void ColorSliderControl::Resize()
952 void ColorSliderControl::Modify()
954 maModifyHdl
.Call(this);
957 void ColorSliderControl::SetValue(const Color
& rColor
, ColorMode eMode
, double dValue
)
959 bool bUpdateBitmap
= (rColor
!= maColor
) || (eMode
!= meMode
);
960 if( bUpdateBitmap
|| (mdValue
!= dValue
))
964 mnLevel
= static_cast<sal_Int16
>((1.0-dValue
) * GetOutputSizePixel().Height());
972 const sal_uInt16 UPDATE_RGB
= 0x01;
973 const sal_uInt16 UPDATE_CMYK
= 0x02;
974 const sal_uInt16 UPDATE_HSB
= 0x04;
975 const sal_uInt16 UPDATE_COLORCHOOSER
= 0x08;
976 const sal_uInt16 UPDATE_COLORSLIDER
= 0x10;
977 const sal_uInt16 UPDATE_HEX
= 0x20;
978 const sal_uInt16 UPDATE_ALL
= 0xff;
980 class ColorPickerDialog
: public ModalDialog
983 ColorPickerDialog(vcl::Window
* pParent
, sal_Int32 nColor
, sal_Int16 nMode
);
984 virtual ~ColorPickerDialog()
988 virtual void dispose() SAL_OVERRIDE
;
990 void update_color(sal_uInt16 n
= UPDATE_ALL
);
992 DECL_LINK(ColorModifyHdl
, void*);
993 DECL_LINK(ModeModifyHdl
, void*);
995 sal_Int32
GetColor() const;
997 void setColorComponent(sal_uInt16 nComp
, double dValue
);
1000 sal_Int16 mnDialogMode
;
1003 double mdRed
, mdGreen
, mdBlue
;
1004 double mdHue
, mdSat
, mdBri
;
1005 double mdCyan
, mdMagenta
, mdYellow
, mdKey
;
1008 VclPtr
<ColorFieldControl
> mpColorField
;
1009 VclPtr
<ColorSliderControl
> mpColorSlider
;
1010 VclPtr
<ColorPreviewControl
> mpColorPreview
;
1011 VclPtr
<ColorPreviewControl
> mpColorPrevious
;
1013 VclPtr
<FixedImage
> mpFISliderLeft
;
1014 VclPtr
<FixedImage
> mpFISliderRight
;
1015 Image maSliderImage
;
1017 VclPtr
<RadioButton
> mpRBRed
;
1018 VclPtr
<RadioButton
> mpRBGreen
;
1019 VclPtr
<RadioButton
> mpRBBlue
;
1020 VclPtr
<RadioButton
> mpRBHue
;
1021 VclPtr
<RadioButton
> mpRBSaturation
;
1022 VclPtr
<RadioButton
> mpRBBrightness
;
1024 VclPtr
<MetricField
> mpMFRed
;
1025 VclPtr
<MetricField
> mpMFGreen
;
1026 VclPtr
<MetricField
> mpMFBlue
;
1027 VclPtr
<HexColorControl
> mpEDHex
;
1029 VclPtr
<MetricField
> mpMFHue
;
1030 VclPtr
<MetricField
> mpMFSaturation
;
1031 VclPtr
<MetricField
> mpMFBrightness
;
1033 VclPtr
<MetricField
> mpMFCyan
;
1034 VclPtr
<MetricField
> mpMFMagenta
;
1035 VclPtr
<MetricField
> mpMFYellow
;
1036 VclPtr
<MetricField
> mpMFKey
;
1039 ColorPickerDialog::ColorPickerDialog( vcl::Window
* pParent
, sal_Int32 nColor
, sal_Int16 nMode
)
1040 : ModalDialog( pParent
, "ColorPicker", "cui/ui/colorpickerdialog.ui" )
1041 , mnDialogMode( nMode
)
1042 , meMode( DefaultMode
)
1043 , maSliderImage( FixedImage::loadThemeImage("res/colorslider.png") )
1045 get(mpColorField
, "colorField");
1046 get(mpColorSlider
, "colorSlider");
1047 get(mpColorPreview
, "preview");
1048 get(mpColorPrevious
, "previous");
1049 get(mpRBRed
, "redRadiobutton");
1050 get(mpRBGreen
, "greenRadiobutton");
1051 get(mpRBBlue
, "blueRadiobutton");
1052 get(mpRBHue
, "hueRadiobutton");
1053 get(mpRBSaturation
, "satRadiobutton");
1054 get(mpRBBrightness
, "brightRadiobutton");
1055 get(mpMFRed
, "redSpinbutton");
1056 get(mpMFGreen
, "greenSpinbutton");
1057 get(mpMFBlue
, "blueSpinbutton");
1058 get(mpEDHex
, "hexEntry");
1059 get(mpMFHue
, "hueSpinbutton");
1060 get(mpMFSaturation
, "satSpinbutton");
1061 get(mpMFBrightness
, "brightSpinbutton");
1062 get(mpMFCyan
, "cyanSpinbutton");
1063 get(mpMFMagenta
, "magSpinbutton");
1064 get(mpMFYellow
, "yellowSpinbutton");
1065 get(mpMFKey
, "keySpinbutton");
1066 get(mpFISliderLeft
, "leftImage");
1067 get(mpFISliderRight
, "rightImage");
1069 Size aDialogSize
= get_preferred_size();
1070 set_width_request(aDialogSize
.Width() + 50);
1071 set_height_request(aDialogSize
.Height() + 30);
1073 Link
<> aLink( LINK( this, ColorPickerDialog
, ColorModifyHdl
) );
1074 mpColorField
->SetModifyHdl( aLink
);
1075 mpColorSlider
->SetModifyHdl( aLink
);
1077 mpMFRed
->SetModifyHdl( aLink
);
1078 mpMFGreen
->SetModifyHdl( aLink
);
1079 mpMFBlue
->SetModifyHdl( aLink
);
1081 mpMFCyan
->SetModifyHdl( aLink
);
1082 mpMFMagenta
->SetModifyHdl( aLink
);
1083 mpMFYellow
->SetModifyHdl( aLink
);
1084 mpMFKey
->SetModifyHdl( aLink
);
1086 mpMFHue
->SetModifyHdl( aLink
);
1087 mpMFSaturation
->SetModifyHdl( aLink
);
1088 mpMFBrightness
->SetModifyHdl( aLink
);
1090 mpEDHex
->SetModifyHdl( aLink
);
1092 aLink
= LINK( this, ColorPickerDialog
, ModeModifyHdl
);
1093 mpRBRed
->SetToggleHdl( aLink
);
1094 mpRBGreen
->SetToggleHdl( aLink
);
1095 mpRBBlue
->SetToggleHdl( aLink
);
1096 mpRBHue
->SetToggleHdl( aLink
);
1097 mpRBSaturation
->SetToggleHdl( aLink
);
1098 mpRBBrightness
->SetToggleHdl( aLink
);
1100 Image
aSliderImage( maSliderImage
);
1102 mpFISliderLeft
->SetImage( aSliderImage
);
1103 mpFISliderLeft
->Show(true);
1105 BitmapEx
aTmpBmp( maSliderImage
.GetBitmapEx() );
1106 aTmpBmp
.Mirror( BmpMirrorFlags::Horizontal
);
1107 mpFISliderRight
->SetImage( Image( aTmpBmp
) );
1109 Size
aSize( maSliderImage
.GetSizePixel() );
1110 mpFISliderLeft
->SetSizePixel( aSize
);
1111 mpFISliderRight
->SetSizePixel( aSize
);
1113 Point
aPos( mpColorSlider
->GetPosPixel() );
1115 aPos
.X() -= aSize
.Width();
1116 aPos
.Y() -= aSize
.Height() / 2;
1117 mpFISliderLeft
->SetPosPixel( aPos
);
1119 aPos
.X() += aSize
.Width() + mpColorSlider
->GetSizePixel().Width();
1120 mpFISliderRight
->SetPosPixel( aPos
);
1122 Color
aColor( nColor
);
1125 if( mnDialogMode
== 2 )
1127 mpColorPreview
->SetSizePixel( mpColorPrevious
->GetSizePixel() );
1128 mpColorPrevious
->SetColor( aColor
);
1129 mpColorPrevious
->Show( true );
1132 mdRed
= ((double)aColor
.GetRed()) / 255.0;
1133 mdGreen
= ((double)aColor
.GetGreen()) / 255.0;
1134 mdBlue
= ((double)aColor
.GetBlue()) / 255.0;
1136 RGBtoHSV( mdRed
, mdGreen
, mdBlue
, mdHue
, mdSat
, mdBri
);
1137 RGBtoCMYK( mdRed
, mdGreen
, mdBlue
, mdCyan
, mdMagenta
, mdYellow
, mdKey
);
1142 void ColorPickerDialog::dispose()
1144 mpColorField
.clear();
1145 mpColorSlider
.clear();
1146 mpColorPreview
.clear();
1147 mpColorPrevious
.clear();
1148 mpFISliderLeft
.clear();
1149 mpFISliderRight
.clear();
1154 mpRBSaturation
.clear();
1155 mpRBBrightness
.clear();
1161 mpMFSaturation
.clear();
1162 mpMFBrightness
.clear();
1164 mpMFMagenta
.clear();
1167 ModalDialog::dispose();
1170 static int toInt( double dValue
, double dRange
)
1172 return static_cast< int >( std::floor((dValue
* dRange
) + 0.5 ) );
1175 sal_Int32
ColorPickerDialog::GetColor() const
1177 return Color( toInt(mdRed
,255.0), toInt(mdGreen
,255.0), toInt(mdBlue
,255.0) ).GetColor();
1180 void ColorPickerDialog::update_color( sal_uInt16 n
)
1182 sal_uInt8 nRed
= toInt(mdRed
,255.0);
1183 sal_uInt8 nGreen
= toInt(mdGreen
,255.0);
1184 sal_uInt8 nBlue
= toInt(mdBlue
,255.0);
1186 Color
aColor(nRed
, nGreen
, nBlue
);
1188 if (n
& UPDATE_RGB
) // update RGB
1190 mpMFRed
->SetValue(nRed
);
1191 mpMFGreen
->SetValue(nGreen
);
1192 mpMFBlue
->SetValue(nBlue
);
1195 if (n
& UPDATE_CMYK
) // update CMYK
1197 mpMFCyan
->SetValue(toInt(mdCyan
, 100.0));
1198 mpMFMagenta
->SetValue(toInt(mdMagenta
, 100.0));
1199 mpMFYellow
->SetValue(toInt(mdYellow
, 100.0));
1200 mpMFKey
->SetValue(toInt(mdKey
, 100.0));
1203 if (n
& UPDATE_HSB
) // update HSB
1205 mpMFHue
->SetValue(toInt(mdHue
, 1.0));
1206 mpMFSaturation
->SetValue(toInt( mdSat
, 100.0));
1207 mpMFBrightness
->SetValue(toInt( mdBri
, 100.0));
1210 if (n
& UPDATE_COLORCHOOSER
) // update Color Chooser 1
1215 mpColorField
->SetValues(aColor
, meMode
, mdSat
, mdBri
);
1218 mpColorField
->SetValues(aColor
, meMode
, mdHue
/ 360.0, mdBri
);
1221 mpColorField
->SetValues(aColor
, meMode
, mdHue
/ 360.0, mdSat
);
1224 mpColorField
->SetValues(aColor
, meMode
, mdBlue
, mdGreen
);
1227 mpColorField
->SetValues(aColor
, meMode
, mdBlue
, mdRed
);
1230 mpColorField
->SetValues(aColor
, meMode
, mdRed
, mdGreen
);
1235 if (n
& UPDATE_COLORSLIDER
) // update Color Chooser 2
1240 mpColorSlider
->SetValue(aColor
, meMode
, mdHue
/ 360.0);
1243 mpColorSlider
->SetValue(aColor
, meMode
, mdSat
);
1246 mpColorSlider
->SetValue(aColor
, meMode
, mdBri
);
1249 mpColorSlider
->SetValue(aColor
, meMode
, mdRed
);
1252 mpColorSlider
->SetValue(aColor
, meMode
, mdGreen
);
1255 mpColorSlider
->SetValue(aColor
, meMode
, mdBlue
);
1260 if (n
& UPDATE_HEX
) // update hex
1262 mpEDHex
->SetColor(aColor
.GetColor());
1266 Point
aPos(0, mpColorSlider
->GetLevel() + mpColorSlider
->GetPosPixel().Y() - 1);
1268 aPos
.X() = mpFISliderLeft
->GetPosPixel().X();
1269 if (aPos
!= mpFISliderLeft
->GetPosPixel())
1271 mpFISliderLeft
->SetPosPixel(aPos
);
1273 aPos
.X() = mpFISliderRight
->GetPosPixel().X();
1274 mpFISliderRight
->SetPosPixel(aPos
);
1278 mpColorPreview
->SetColor(aColor
);
1281 IMPL_LINK(ColorPickerDialog
, ColorModifyHdl
, void *, p
)
1285 if (p
== mpColorField
)
1287 double x
= mpColorField
->GetX();
1288 double y
= mpColorField
->GetY();
1294 setColorComponent( COLORCOMP_BRI
, y
);
1298 setColorComponent( COLORCOMP_BRI
, y
);
1302 setColorComponent( COLORCOMP_SAT
, y
);
1306 setColorComponent( COLORCOMP_GREEN
, y
);
1310 setColorComponent( COLORCOMP_RED
, y
);
1314 setColorComponent( COLORCOMP_GREEN
, y
);
1318 n
= UPDATE_ALL
&~ (UPDATE_COLORCHOOSER
);
1320 else if (p
== mpColorSlider
)
1322 double dValue
= mpColorSlider
->GetValue();
1326 setColorComponent( COLORCOMP_HUE
, dValue
* 360.0 );
1329 setColorComponent( COLORCOMP_SAT
, dValue
);
1332 setColorComponent( COLORCOMP_BRI
, dValue
);
1335 setColorComponent( COLORCOMP_RED
, dValue
);
1338 setColorComponent( COLORCOMP_GREEN
, dValue
);
1341 setColorComponent( COLORCOMP_BLUE
, dValue
);
1345 n
= UPDATE_ALL
&~(UPDATE_COLORSLIDER
);
1347 else if (p
== mpMFRed
)
1349 setColorComponent( COLORCOMP_RED
, ((double)mpMFRed
->GetValue()) / 255.0 );
1350 n
= UPDATE_ALL
&~ (UPDATE_RGB
);
1352 else if (p
== mpMFGreen
)
1354 setColorComponent( COLORCOMP_GREEN
, ((double)mpMFGreen
->GetValue()) / 255.0 );
1355 n
= UPDATE_ALL
&~ (UPDATE_RGB
);
1357 else if (p
== mpMFBlue
)
1359 setColorComponent( COLORCOMP_BLUE
, ((double)mpMFBlue
->GetValue()) / 255.0 );
1360 n
= UPDATE_ALL
&~ (UPDATE_RGB
);
1362 else if (p
== mpMFHue
)
1364 setColorComponent( COLORCOMP_HUE
, (double)mpMFHue
->GetValue() );
1365 n
= UPDATE_ALL
&~ (UPDATE_HSB
);
1367 else if (p
== mpMFSaturation
)
1369 setColorComponent( COLORCOMP_SAT
, ((double)mpMFSaturation
->GetValue()) / 100.0 );
1370 n
= UPDATE_ALL
&~ (UPDATE_HSB
);
1372 else if (p
== mpMFBrightness
)
1374 setColorComponent( COLORCOMP_BRI
, ((double)mpMFBrightness
->GetValue()) / 100.0 );
1375 n
= UPDATE_ALL
&~ (UPDATE_HSB
);
1377 else if (p
== mpMFCyan
)
1379 setColorComponent( COLORCOMP_CYAN
, ((double)mpMFCyan
->GetValue()) / 100.0 );
1380 n
= UPDATE_ALL
&~ (UPDATE_CMYK
);
1382 else if (p
== mpMFMagenta
)
1384 setColorComponent( COLORCOMP_MAGENTA
, ((double)mpMFMagenta
->GetValue()) / 100.0 );
1385 n
= UPDATE_ALL
&~ (UPDATE_CMYK
);
1387 else if (p
== mpMFYellow
)
1389 setColorComponent( COLORCOMP_YELLOW
, ((double)mpMFYellow
->GetValue()) / 100.0 );
1390 n
= UPDATE_ALL
&~ (UPDATE_CMYK
);
1392 else if (p
== mpMFKey
)
1394 setColorComponent( COLORCOMP_KEY
, ((double)mpMFKey
->GetValue()) / 100.0 );
1395 n
= UPDATE_ALL
&~(UPDATE_CMYK
);
1397 else if (p
== mpEDHex
)
1399 sal_Int32 nColor
= mpEDHex
->GetColor();
1403 Color
aColor(nColor
);
1405 if (aColor
!= GetColor())
1407 mdRed
= ((double)aColor
.GetRed()) / 255.0;
1408 mdGreen
= ((double)aColor
.GetGreen()) / 255.0;
1409 mdBlue
= ((double)aColor
.GetBlue()) / 255.0;
1411 RGBtoHSV( mdRed
, mdGreen
, mdBlue
, mdHue
, mdSat
, mdBri
);
1412 RGBtoCMYK( mdRed
, mdGreen
, mdBlue
, mdCyan
, mdMagenta
, mdYellow
, mdKey
);
1413 n
= UPDATE_ALL
&~ (UPDATE_HEX
);
1424 IMPL_LINK_NOARG(ColorPickerDialog
, ModeModifyHdl
)
1426 ColorMode eMode
= HUE
;
1428 if (mpRBRed
->IsChecked())
1432 else if (mpRBGreen
->IsChecked())
1436 else if (mpRBBlue
->IsChecked())
1440 else if (mpRBSaturation
->IsChecked())
1444 else if (mpRBBrightness
->IsChecked())
1449 if (meMode
!= eMode
)
1452 update_color(UPDATE_COLORCHOOSER
| UPDATE_COLORSLIDER
);
1458 void ColorPickerDialog::setColorComponent( sal_uInt16 nComp
, double dValue
)
1465 case COLORCOMP_GREEN
:
1468 case COLORCOMP_BLUE
:
1480 case COLORCOMP_CYAN
:
1483 case COLORCOMP_YELLOW
:
1486 case COLORCOMP_MAGENTA
:
1494 if (nComp
& COLORMODE_RGB
)
1496 RGBtoHSV( mdRed
, mdGreen
, mdBlue
, mdHue
, mdSat
, mdBri
);
1497 RGBtoCMYK( mdRed
, mdGreen
, mdBlue
, mdCyan
, mdMagenta
, mdYellow
, mdKey
);
1499 else if (nComp
& COLORMODE_HSV
)
1501 HSVtoRGB( mdHue
, mdSat
, mdBri
, mdRed
, mdGreen
, mdBlue
);
1502 RGBtoCMYK( mdRed
, mdGreen
, mdBlue
, mdCyan
, mdMagenta
, mdYellow
, mdKey
);
1506 CMYKtoRGB( mdCyan
, mdMagenta
, mdYellow
, mdKey
, mdRed
, mdGreen
, mdBlue
);
1507 RGBtoHSV( mdRed
, mdGreen
, mdBlue
, mdHue
, mdSat
, mdBri
);
1511 typedef ::cppu::WeakComponentImplHelper4
< XServiceInfo
, XExecutableDialog
, XInitialization
, XPropertyAccess
> ColorPickerBase
;
1513 class ColorPicker
: protected ::comphelper::OBaseMutex
, // Struct for right initalization of mutex member! Must be first of baseclasses.
1514 public ColorPickerBase
1517 ColorPicker( Reference
< XComponentContext
> const & xContext
);
1520 virtual void SAL_CALL
initialize( const Sequence
< Any
>& aArguments
) throw (Exception
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
1523 virtual OUString SAL_CALL
getImplementationName( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1524 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1525 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1528 virtual Sequence
< PropertyValue
> SAL_CALL
getPropertyValues( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1529 virtual void SAL_CALL
setPropertyValues( const Sequence
< PropertyValue
>& aProps
) throw (UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
, std::exception
) SAL_OVERRIDE
;
1531 // XExecutableDialog
1532 virtual void SAL_CALL
setTitle( const OUString
& aTitle
) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1533 virtual sal_Int16 SAL_CALL
execute( ) throw (RuntimeException
, std::exception
) SAL_OVERRIDE
;
1536 Reference
< XComponentContext
> mxContext
;
1538 const OUString msColorKey
;
1539 const OUString msModeKey
;
1542 Reference
<css::awt::XWindow
> mxParent
;
1545 OUString SAL_CALL
ColorPicker_getImplementationName()
1547 return OUString( "com.sun.star.cui.ColorPicker" );
1550 Reference
< XInterface
> SAL_CALL
ColorPicker_createInstance( Reference
< XComponentContext
> const & xContext
)
1552 return static_cast<XWeak
*>( new ColorPicker( xContext
) );
1555 Sequence
< OUString
> SAL_CALL
ColorPicker_getSupportedServiceNames() throw( RuntimeException
)
1557 Sequence
< OUString
> seq(1);
1558 seq
[0] = "com.sun.star.ui.dialogs.ColorPicker";
1562 ColorPicker::ColorPicker( Reference
< XComponentContext
> const & xContext
)
1563 : ColorPickerBase( m_aMutex
)
1564 , mxContext( xContext
)
1565 , msColorKey( "Color" )
1566 , msModeKey( "Mode" )
1573 void SAL_CALL
ColorPicker::initialize( const Sequence
< Any
>& aArguments
) throw (Exception
, RuntimeException
, std::exception
)
1575 if( aArguments
.getLength() == 1 )
1577 aArguments
[0] >>= mxParent
;
1582 OUString SAL_CALL
ColorPicker::getImplementationName( ) throw (RuntimeException
, std::exception
)
1584 return ColorPicker_getImplementationName();
1587 sal_Bool SAL_CALL
ColorPicker::supportsService( const OUString
& sServiceName
) throw (RuntimeException
, std::exception
)
1589 return cppu::supportsService(this, sServiceName
);
1592 Sequence
< OUString
> SAL_CALL
ColorPicker::getSupportedServiceNames( ) throw (RuntimeException
, std::exception
)
1594 return ColorPicker_getSupportedServiceNames();
1598 Sequence
< PropertyValue
> SAL_CALL
ColorPicker::getPropertyValues( ) throw (RuntimeException
, std::exception
)
1600 Sequence
< PropertyValue
> props(1);
1601 props
[0].Name
= msColorKey
;
1602 props
[0].Value
<<= mnColor
;
1606 void SAL_CALL
ColorPicker::setPropertyValues( const Sequence
< PropertyValue
>& aProps
) throw (UnknownPropertyException
, PropertyVetoException
, IllegalArgumentException
, WrappedTargetException
, RuntimeException
, std::exception
)
1608 for( sal_Int32 n
= 0; n
< aProps
.getLength(); n
++ )
1610 if( aProps
[n
].Name
.equals( msColorKey
) )
1612 aProps
[n
].Value
>>= mnColor
;
1614 else if( aProps
[n
].Name
.equals( msModeKey
) )
1616 aProps
[n
].Value
>>= mnMode
;
1621 // XExecutableDialog
1622 void SAL_CALL
ColorPicker::setTitle( const OUString
& sTitle
) throw (RuntimeException
, std::exception
)
1627 sal_Int16 SAL_CALL
ColorPicker::execute( ) throw (RuntimeException
, std::exception
)
1629 ScopedVclPtrInstance
< ColorPickerDialog
> aDlg( VCLUnoHelper::GetWindow( mxParent
), mnColor
, mnMode
);
1630 sal_Int16 ret
= aDlg
->Execute();
1632 mnColor
= aDlg
->GetColor();
1639 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */