summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorAlexandre Vicenzi <vicenzi.alexandre@gmail.com>2014-01-25 16:24:52 -0200
committerMarcos Souza <marcos.souza.org@gmail.com>2014-02-03 14:35:46 +0000
commitf9369d33a455b328f96fa554e3e942e64a40a4da (patch)
tree20916e357bd757412b977800a74141592928aaaf /cui
parent326bec33e0a08123d716b9d2a06884368a8f07eb (diff)
fdo#54938 Convert to cppu::supportsService
Change-Id: I512c525029ebd63d261560d27e9f38bbe94f7e10 Reviewed-on: https://gerrit.libreoffice.org/7649 Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org> Reviewed-by: Marcos Souza <marcos.souza.org@gmail.com> Tested-by: Marcos Souza <marcos.souza.org@gmail.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/colorpicker.cxx123
1 files changed, 2 insertions, 121 deletions
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index e0ca149e799f..f4858e5083ab 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/supportsservice.hxx>
#include <comphelper/broadcasthelper.hxx>
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
@@ -89,8 +90,6 @@ static void HSVtoRGB(double dH, double dS, double dV, double& dR, double& dG, do
dB = result.getBlue();
}
-// -----------------------------------------------------------------------
-
// CMYK values from 0 to 1
static void CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey, double& dR, double& dG, double& dB )
{
@@ -103,8 +102,6 @@ static void CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKe
dB = std::max( std::min( ( 1.0 - fYellow ), 1.0), 0.0 );
}
-// -----------------------------------------------------------------------
-
// CMY results from 0 to 1
static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& fMagenta, double& fYellow, double& fKey )
{
@@ -133,8 +130,6 @@ static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& f
}
}
-// ====================================================================
-
class HexColorControl : public Edit
{
public:
@@ -156,8 +151,6 @@ HexColorControl::HexColorControl( Window* pParent, const ResId& rResId )
SetMaxTextLen( 6 );
}
-// -----------------------------------------------------------------------
-
void HexColorControl::SetColor( sal_Int32 nColor )
{
OUStringBuffer aBuffer;
@@ -165,8 +158,6 @@ void HexColorControl::SetColor( sal_Int32 nColor )
SetText( aBuffer.makeStringAndClear().copy(1) );
}
-// -----------------------------------------------------------------------
-
sal_Int32 HexColorControl::GetColor()
{
sal_Int32 nColor = -1;
@@ -190,8 +181,6 @@ sal_Int32 HexColorControl::GetColor()
return nColor;
}
-// -----------------------------------------------------------------------
-
bool HexColorControl::PreNotify( NotifyEvent& rNEvt )
{
if ( (rNEvt.GetType() == EVENT_KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
@@ -203,8 +192,6 @@ bool HexColorControl::PreNotify( NotifyEvent& rNEvt )
return Edit::PreNotify( rNEvt );
}
-// -----------------------------------------------------------------------
-
void HexColorControl::Paste()
{
::com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
@@ -249,8 +236,6 @@ void HexColorControl::Paste()
}
}
-// -----------------------------------------------------------------------
-
bool HexColorControl::ImplProcessKeyInput( const KeyEvent& rKEv )
{
const KeyCode& rKeyCode = rKEv.GetKeyCode();
@@ -268,8 +253,6 @@ bool HexColorControl::ImplProcessKeyInput( const KeyEvent& rKEv )
return false;
}
-// ====================================================================
-
class ColorPreviewControl : public Control
{
public:
@@ -282,8 +265,6 @@ private:
Color maColor;
};
-// -----------------------------------------------------------------------
-
ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId )
: Control( pParent, rResId )
{
@@ -291,8 +272,6 @@ ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId )
SetLineColor( maColor );
}
-// -----------------------------------------------------------------------
-
void ColorPreviewControl::SetColor( const Color& rCol )
{
if( rCol != maColor )
@@ -304,15 +283,11 @@ void ColorPreviewControl::SetColor( const Color& rCol )
}
}
-// -----------------------------------------------------------------------
-
void ColorPreviewControl::Paint( const Rectangle& rRect )
{
DrawRect( rRect );
}
-// ====================================================================
-
enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE };
const ColorMode DefaultMode = HUE;
@@ -357,8 +332,6 @@ private:
std::vector< sal_uInt16 > maPercent_Vert;
};
-// -----------------------------------------------------------------------
-
ColorFieldControl::ColorFieldControl( Window* pParent, const ResId& rResId )
: Control( pParent, rResId )
, meMode( DefaultMode )
@@ -369,15 +342,11 @@ ColorFieldControl::ColorFieldControl( Window* pParent, const ResId& rResId )
SetControlBackground();
}
-// -----------------------------------------------------------------------
-
ColorFieldControl::~ColorFieldControl()
{
delete mpBitmap;
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::UpdateBitmap()
{
const Size aSize( GetOutputSizePixel() );
@@ -519,8 +488,6 @@ void ColorFieldControl::UpdateBitmap()
}
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate )
{
if( !mpBitmap )
@@ -564,7 +531,6 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate )
}
}
}
-// -----------------------------------------------------------------------
void ColorFieldControl::MouseMove( const MouseEvent& rMEvt )
{
@@ -575,7 +541,6 @@ void ColorFieldControl::MouseMove( const MouseEvent& rMEvt )
}
}
-// -----------------------------------------------------------------------
void ColorFieldControl::MouseButtonDown( const MouseEvent& rMEvt )
{
if( rMEvt.IsLeft() && !rMEvt.IsShift() )
@@ -586,15 +551,12 @@ void ColorFieldControl::MouseButtonDown( const MouseEvent& rMEvt )
}
}
-// -----------------------------------------------------------------------
void ColorFieldControl::MouseButtonUp( const MouseEvent& )
{
if( IsMouseCaptured() )
ReleaseMouse();
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::KeyMove( int dx, int dy )
{
Size aSize( GetOutputSizePixel() );
@@ -615,8 +577,6 @@ void ColorFieldControl::KeyMove( int dx, int dy )
Modify();
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::KeyInput( const KeyEvent& rKEvt )
{
bool bShift = rKEvt.GetKeyCode().IsShift();
@@ -636,8 +596,6 @@ void ColorFieldControl::KeyInput( const KeyEvent& rKEvt )
Control::KeyInput( rKEvt );
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::Paint( const Rectangle& rRect )
{
if( !mpBitmap )
@@ -661,23 +619,17 @@ void ColorFieldControl::Paint( const Rectangle& rRect )
DrawEllipse( Rectangle( maPosition, Size( 11, 11) ) );
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::Resize()
{
UpdateBitmap();
Control::Resize();
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::Modify()
{
maModifyHdl.Call( this );
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y )
{
bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode);
@@ -696,30 +648,22 @@ void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, doub
}
}
-// -----------------------------------------------------------------------
-
double ColorFieldControl::GetX()
{
return mdX;
}
-// -----------------------------------------------------------------------
-
double ColorFieldControl::GetY()
{
return mdY;
}
-// -----------------------------------------------------------------------
-
void ColorFieldControl::UpdatePosition()
{
Size aSize( GetOutputSizePixel() );
ShowPosition( Point(static_cast<long>(mdX * aSize.Width()), static_cast<long>((1.0 - mdY) * aSize.Height())), false );
}
-// ====================================================================
-
class ColorSliderControl : public Control
{
public:
@@ -755,8 +699,6 @@ private:
double mdValue;
};
-// -----------------------------------------------------------------------
-
ColorSliderControl::ColorSliderControl( Window* pParent, const ResId& rResId )
: Control( pParent, rResId )
, meMode( DefaultMode )
@@ -767,15 +709,11 @@ ColorSliderControl::ColorSliderControl( Window* pParent, const ResId& rResId )
SetControlBackground();
}
-// -----------------------------------------------------------------------
-
ColorSliderControl::~ColorSliderControl()
{
delete mpBitmap;
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::UpdateBitmap()
{
Size aSize( 1, GetOutputSizePixel().Height() );
@@ -858,8 +796,6 @@ void ColorSliderControl::UpdateBitmap()
}
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::ChangePosition( long nY )
{
const long nHeight = GetOutputSizePixel().Height() - 1;
@@ -873,8 +809,6 @@ void ColorSliderControl::ChangePosition( long nY )
mdValue = ((double)(nHeight - nY)) / (double)nHeight;
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::MouseMove( const MouseEvent& rMEvt )
{
if( rMEvt.IsLeft() )
@@ -884,7 +818,6 @@ void ColorSliderControl::MouseMove( const MouseEvent& rMEvt )
}
}
-// -----------------------------------------------------------------------
void ColorSliderControl::MouseButtonDown( const MouseEvent& rMEvt )
{
if( rMEvt.IsLeft() && !rMEvt.IsShift() )
@@ -895,23 +828,18 @@ void ColorSliderControl::MouseButtonDown( const MouseEvent& rMEvt )
}
}
-// -----------------------------------------------------------------------
void ColorSliderControl::MouseButtonUp( const MouseEvent& )
{
if( IsMouseCaptured() )
ReleaseMouse();
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::KeyMove( int dy )
{
ChangePosition( mnLevel + dy );
Modify();
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::KeyInput( const KeyEvent& rKEvt )
{
if ( !rKEvt.GetKeyCode().IsMod2() && !rKEvt.GetKeyCode().IsShift() )
@@ -925,7 +853,6 @@ void ColorSliderControl::KeyInput( const KeyEvent& rKEvt )
Control::KeyInput( rKEvt );
}
-// -----------------------------------------------------------------------
void ColorSliderControl::Paint( const Rectangle& /*rRect*/ )
{
@@ -948,23 +875,17 @@ void ColorSliderControl::Paint( const Rectangle& /*rRect*/ )
}
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::Resize()
{
UpdateBitmap();
Control::Resize();
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::Modify()
{
maModifyHdl.Call( this );
}
-// -----------------------------------------------------------------------
-
void ColorSliderControl::SetValue( const Color& rColor, ColorMode eMode, double dValue )
{
bool bUpdateBitmap = (rColor != maColor) || (eMode != meMode);
@@ -980,8 +901,6 @@ void ColorSliderControl::SetValue( const Color& rColor, ColorMode eMode, double
}
}
-// ====================================================================
-
const sal_uInt16 UPDATE_RGB = 0x01;
const sal_uInt16 UPDATE_CMYK = 0x02;
const sal_uInt16 UPDATE_HSB = 0x04;
@@ -1069,8 +988,6 @@ private:
CancelButton maBTNCancel;
};
-// --------------------------------------------------------------------
-
ColorPickerDialog::ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int16 nMode )
: ModalDialog( pParent, CUI_RES( RID_CUI_DIALOG_COLORPICKER ) )
, maPreviousColor( nColor )
@@ -1193,8 +1110,6 @@ ColorPickerDialog::ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int
update_color();
}
-// --------------------------------------------------------------------
-
static int toInt( double dValue, double dRange )
{
return static_cast< int >( std::floor((dValue * dRange) + 0.5 ) );
@@ -1282,8 +1197,6 @@ void ColorPickerDialog::update_color( sal_uInt16 n )
maColorPreview.SetColor( aColor );
}
-// --------------------------------------------------------------------
-
IMPL_LINK( ColorPickerDialog, ColorModifyHdl, void *, p )
{
sal_uInt16 n = 0;
@@ -1397,8 +1310,6 @@ IMPL_LINK( ColorPickerDialog, ColorModifyHdl, void *, p )
return 0;
}
-// --------------------------------------------------------------------
-
IMPL_LINK_NOARG(ColorPickerDialog, ModeModifyHdl)
{
ColorMode eMode = HUE;
@@ -1433,8 +1344,6 @@ IMPL_LINK_NOARG(ColorPickerDialog, ModeModifyHdl)
return 0;
}
-// --------------------------------------------------------------------
-
void ColorPickerDialog::setColorComponent( sal_uInt16 nComp, double dValue )
{
switch( nComp )
@@ -1468,8 +1377,6 @@ void ColorPickerDialog::setColorComponent( sal_uInt16 nComp, double dValue )
}
}
-// --------------------------------------------------------------------
-
typedef ::cppu::WeakComponentImplHelper4< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
class ColorPicker : protected ::comphelper::OBaseMutex, // Struct for right initalization of mutex member! Must be first of baseclasses.
@@ -1504,22 +1411,16 @@ private:
Reference< ::com::sun::star::awt::XWindow > mxParent;
};
-// --------------------------------------------------------------------
-
OUString SAL_CALL ColorPicker_getImplementationName()
{
return OUString( "com.sun.star.cui.ColorPicker" );
}
-// --------------------------------------------------------------------
-
Reference< XInterface > SAL_CALL ColorPicker_createInstance( Reference< XComponentContext > const & xContext ) SAL_THROW( (Exception) )
{
return static_cast<XWeak*>( new ColorPicker( xContext ) );
}
-// --------------------------------------------------------------------
-
Sequence< OUString > SAL_CALL ColorPicker_getSupportedServiceNames() throw( RuntimeException )
{
Sequence< OUString > seq(1);
@@ -1527,8 +1428,6 @@ Sequence< OUString > SAL_CALL ColorPicker_getSupportedServiceNames() throw( Runt
return seq;
}
-// --------------------------------------------------------------------
-
ColorPicker::ColorPicker( Reference< XComponentContext > const & xContext )
: ColorPickerBase( m_aMutex )
, mxContext( xContext )
@@ -1539,8 +1438,6 @@ ColorPicker::ColorPicker( Reference< XComponentContext > const & xContext )
{
}
-// --------------------------------------------------------------------
-
// XInitialization
void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
{
@@ -1550,30 +1447,22 @@ void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments ) throw
}
}
-// --------------------------------------------------------------------
-
// XInitialization
OUString SAL_CALL ColorPicker::getImplementationName( ) throw (RuntimeException)
{
return ColorPicker_getImplementationName();
}
-// --------------------------------------------------------------------
-
sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName ) throw (RuntimeException)
{
- return sServiceName == "com.sun.star.ui.dialogs.ColorPicker";
+ return cppu::supportsService(this, sServiceName);
}
-// --------------------------------------------------------------------
-
Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames( ) throw (RuntimeException)
{
return ColorPicker_getSupportedServiceNames();
}
-// --------------------------------------------------------------------
-
// XPropertyAccess
Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues( ) throw (RuntimeException)
{
@@ -1583,8 +1472,6 @@ Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues( ) throw (Run
return props;
}
-// --------------------------------------------------------------------
-
void SAL_CALL ColorPicker::setPropertyValues( const Sequence< PropertyValue >& aProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
{
for( sal_Int32 n = 0; n < aProps.getLength(); n++ )
@@ -1600,16 +1487,12 @@ void SAL_CALL ColorPicker::setPropertyValues( const Sequence< PropertyValue >& a
}
}
-// --------------------------------------------------------------------
-
// XExecutableDialog
void SAL_CALL ColorPicker::setTitle( const OUString& sTitle ) throw (RuntimeException)
{
msTitle = sTitle;
}
-// --------------------------------------------------------------------
-
sal_Int16 SAL_CALL ColorPicker::execute( ) throw (RuntimeException)
{
ColorPickerDialog aDlg( VCLUnoHelper::GetWindow( mxParent ), mnColor, mnMode );
@@ -1620,8 +1503,6 @@ sal_Int16 SAL_CALL ColorPicker::execute( ) throw (RuntimeException)
return ret;
}
-// --------------------------------------------------------------------
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */