summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svtools/AllLangResTarget_svt.mk1
-rw-r--r--svtools/Library_svt.mk1
-rw-r--r--svtools/Package_inc.mk1
-rw-r--r--svtools/inc/svtools/colctrl.hxx205
-rw-r--r--svtools/inc/svtools/colrdlg.hxx76
-rw-r--r--svtools/source/dialogs/colctrl.cxx676
-rw-r--r--svtools/source/dialogs/colrdlg.cxx329
-rw-r--r--svtools/source/dialogs/colrdlg.hrc69
-rw-r--r--svtools/source/dialogs/colrdlg.src294
-rw-r--r--tools/inc/tools/color.hxx12
-rw-r--r--tools/source/generic/color.cxx47
11 files changed, 140 insertions, 1571 deletions
diff --git a/svtools/AllLangResTarget_svt.mk b/svtools/AllLangResTarget_svt.mk
index 0311c80d1316..71dfd1801c29 100644
--- a/svtools/AllLangResTarget_svt.mk
+++ b/svtools/AllLangResTarget_svt.mk
@@ -51,7 +51,6 @@ $(eval $(call gb_SrsTarget_add_files,svt/res,\
svtools/source/control/ctrltool.src \
svtools/source/control/filectrl.src \
svtools/source/dialogs/addresstemplate.src \
- svtools/source/dialogs/colrdlg.src \
svtools/source/dialogs/filedlg2.src \
svtools/source/dialogs/formats.src \
svtools/source/dialogs/prnsetup.src \
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index fea3ca79e43f..11e658641ac6 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -150,7 +150,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/control/valueacc \
svtools/source/control/valueset \
svtools/source/dialogs/addresstemplate \
- svtools/source/dialogs/colctrl \
svtools/source/dialogs/colrdlg \
svtools/source/dialogs/filedlg \
svtools/source/dialogs/filedlg2 \
diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk
index b5a32a27b865..39d2331641fc 100644
--- a/svtools/Package_inc.mk
+++ b/svtools/Package_inc.mk
@@ -44,7 +44,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/brwhead.hxx,svtools/br
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/calendar.hxx,svtools/calendar.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/chartprettypainter.hxx,svtools/chartprettypainter.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/cliplistener.hxx,svtools/cliplistener.hxx))
-$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colctrl.hxx,svtools/colctrl.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/collatorres.hxx,svtools/collatorres.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colorcfg.hxx,svtools/colorcfg.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colrdlg.hxx,svtools/colrdlg.hxx))
diff --git a/svtools/inc/svtools/colctrl.hxx b/svtools/inc/svtools/colctrl.hxx
deleted file mode 100644
index 5ad4681b26bb..000000000000
--- a/svtools/inc/svtools/colctrl.hxx
+++ /dev/null
@@ -1,205 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _SV_COLCTRL_HXX
-#define _SV_COLCTRL_HXX
-
-#include <tools/color.hxx>
-#include <vcl/ctrl.hxx>
-#include <svtools/valueset.hxx>
-
-// ----------------
-// - ColorControl -
-// ----------------
-
-class Bitmap;
-class BitmapReadAccess;
-class ColorHSB;
-
-class SvColorControl : public Control
-{
-private:
- Bitmap* mpBitmap;
- BitmapReadAccess* mpReadAccess;
- Color maColor;
- short mnLuminance;
- Point maPosition;
- Link maModifyHdl;
-
- void Initialize();
- void CreateBitmap();
- void ShowPosition( const Point& aPos );
-
-public:
- SvColorControl( Window* pParent, WinBits nStyle = 0 );
- SvColorControl( Window* pParent, const ResId& rResId );
- ~SvColorControl();
-
- virtual void MouseMove( const MouseEvent& rMEvt );
- virtual void MouseButtonDown( const MouseEvent& rMEvt );
- virtual void MouseButtonUp( const MouseEvent& rMEvt );
-// virtual void KeyInput( const KeyEvent& rKEvent );
- virtual void Paint( const Rectangle& rRect );
- virtual void Resize();
-// virtual void GetFocus();
-// virtual void LoseFocus();
-
- virtual void Modify();
-
- Color GetColor() const { return maColor; };
- void SetColor( const Color& rCol );
- void SetColor( const ColorHSB& rCol, sal_Bool bSetColor = sal_True );
-
- short GetLuminance() const { return mnLuminance; };
- void SetLuminance( short nLum );
-
- void SetModifyHdl( const Link& rLink ) { maModifyHdl = rLink; }
- const Link& GetModifyHdl() const { return maModifyHdl; }
-
-};
-
-// -----------------------
-// - ColorPreviewControl -
-// -----------------------
-
-class ColorPreviewControl : public Control
-{
-private:
- Color maColor;
-
-public:
- ColorPreviewControl( Window* pParent, WinBits nStyle = 0 );
- ColorPreviewControl( Window* pParent, const ResId& rResId );
- ~ColorPreviewControl();
-
- virtual void Paint( const Rectangle& rRect );
-
- Color GetColor() const { return maColor; };
- void SetColor( const Color& rCol );
-};
-
-// -----------------------
-// - ColorMixingControl -
-// -----------------------
-
-enum CMCPosition { CMC_TOPLEFT, CMC_TOPRIGHT, CMC_BOTTOMLEFT, CMC_BOTTOMRIGHT, CMC_OTHER };
-
-class ColorMixingControl : public ValueSet
-{
-private:
- sal_uInt16 mnRows;
- sal_uInt16 mnColumns;
- Color maColor[4];
-
- void Initialize();
-
- Color CalcDifferenceColor( sal_uInt16 nCol1, sal_uInt16 nCol2, sal_uInt16 nSteps );
- void FillRow( sal_uInt16 nRow );
- void FillColumn( sal_uInt16 nColumn );
-
-public:
- ColorMixingControl( Window* pParent, WinBits nStyle = 0,
- sal_uInt16 nRows = 4, sal_uInt16 nColumns = 4 );
- ColorMixingControl( Window* pParent, const ResId& rResId,
- sal_uInt16 nRows = 4, sal_uInt16 nColumns = 4 );
- ~ColorMixingControl();
-
- sal_uInt16 GetRows() const { return mnRows; };
- void SetRows( sal_uInt16 nRows );
- sal_uInt16 GetColumns() const { return mnColumns; };
- void SetColumns( sal_uInt16 nColumns );
-
- using ValueSet::GetColor;
- Color GetColor( CMCPosition ePos ) const { return maColor[ ePos ]; };
- using ValueSet::SetColor;
- void SetColor( CMCPosition ePos, const Color& rCol );
-
- String GetRGBString( const Color& rColor );
- CMCPosition GetCMCPosition() const;
-};
-
-// ------------
-// - ColorHSB -
-// ------------
-
-class ColorHSB
-{
-private:
- sal_uInt16 mnHue; // Farbwinkel, 360 Grad
- sal_uInt16 mnSat; // Saturation, 100 %
- sal_uInt16 mnBri; // Brightness, 100 %
-
-public:
- ColorHSB()
- { mnHue=0; mnSat=0; mnBri=0; }
- ColorHSB( sal_uInt16 nH, sal_uInt16 nS, sal_uInt16 nB )
- { mnHue=nH; mnSat=nS; mnBri=nB; }
- ColorHSB( const Color& rColor );
-
- void SetHue( sal_uInt16 nH ) { mnHue=nH; }
- void SetSat( sal_uInt16 nS ) { mnSat=nS; }
- void SetBri( sal_uInt16 nB ) { mnBri=nB; }
- sal_uInt16 GetHue() const { return mnHue; }
- sal_uInt16 GetSat() const { return mnSat; }
- sal_uInt16 GetBri() const { return mnBri; }
- Color GetRGB() const;
-};
-
-// -------------
-// - ColorCMYK -
-// -------------
-
-class ColorCMYK
-{
-private:
- sal_uInt16 mnCyan;
- sal_uInt16 mnMagenta;
- sal_uInt16 mnYellow;
- sal_uInt16 mnKey;
-
-public:
- ColorCMYK()
- { mnCyan=0; mnMagenta=0; mnYellow=0; mnKey=100; }
- ColorCMYK( sal_uInt16 nC, sal_uInt16 nM, sal_uInt16 nY, sal_uInt16 nK )
- { mnCyan=nC; mnMagenta=nM; mnYellow=nY; mnKey=nK; }
- ColorCMYK( const Color& rColor );
-
- void SetCyan( sal_uInt16 nC ) { mnCyan=nC; }
- void SetMagenta( sal_uInt16 nM ) { mnMagenta=nM; }
- void SetYellow( sal_uInt16 nY ) { mnYellow=nY; }
- void SetKey( sal_uInt16 nK ) { mnKey=nK; }
- sal_uInt16 GetCyan() const { return mnCyan; }
- sal_uInt16 GetMagenta() const { return mnMagenta; }
- sal_uInt16 GetYellow() const { return mnYellow; }
- sal_uInt16 GetKey() const { return mnKey; }
- Color GetRGB() const;
-};
-
-#endif // _SV_COLCTRL_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/inc/svtools/colrdlg.hxx b/svtools/inc/svtools/colrdlg.hxx
index 8197bb81de28..09336e12d134 100644
--- a/svtools/inc/svtools/colrdlg.hxx
+++ b/svtools/inc/svtools/colrdlg.hxx
@@ -30,77 +30,37 @@
#define _SV_COLRDLG_HXX
#include "svtools/svtdllapi.h"
-#include <vcl/dialog.hxx>
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/field.hxx>
-#include <svtools/colctrl.hxx>
+
+#include <tools/color.hxx>
+
+class Window;
// ---------------
// - ColorDialog -
// ---------------
-class SVT_DLLPUBLIC SvColorDialog : public ModalDialog
+namespace svtools
{
-private:
- ColorMixingControl maColMixCtrl;
- PushButton maBtn1;
- PushButton maBtn2;
- //PushButton maBtn3;
- //PushButton maBtn4;
- //FixedText maFtRGB;
- SvColorControl maCtlColor;
-
- // CMYK controls.
- FixedText maFtCyan;
- MetricField maNumCyan;
- FixedText maFtMagenta;
- MetricField maNumMagenta;
- FixedText maFtYellow;
- MetricField maNumYellow;
- FixedText maFtKey;
- MetricField maNumKey;
-
- // RGB controls.
- FixedText maFtRed;
- NumericField maNumRed;
- FixedText maFtGreen;
- NumericField maNumGreen;
- FixedText maFtBlue;
- NumericField maNumBlue;
-
- // HSL controls.
- FixedText maFtHue;
- NumericField maNumHue;
- FixedText maFtSaturation;
- NumericField maNumSaturation;
- FixedText maFtLuminance;
- NumericField maNumLuminance;
-
- ColorPreviewControl maCtlPreview;
- ColorPreviewControl maCtlPreviewOld;
-
- OKButton maBtnOK;
- CancelButton maBtnCancel;
- HelpButton maBtnHelp;
-
- Color maColor;
-
- SVT_DLLPRIVATE void Initialize();
-
- DECL_DLLPRIVATE_LINK( ColorModifyHdl, void * );
- DECL_DLLPRIVATE_LINK( ClickBtnHdl, void * );
- DECL_DLLPRIVATE_LINK( ClickMixCtrlHdl, void * );
- DECL_DLLPRIVATE_LINK( SelectMixCtrlHdl, void * );
+ // SELECT is the default
+ enum ColorPickerMode { ColorPickerMode_SELECT = 0, ColorPickerMode_ADD = 1, ColorPickerMode_MODIFY = 2 };
+}
+class SVT_DLLPUBLIC SvColorDialog
+{
public:
- SvColorDialog( Window* pParent );
- ~SvColorDialog();
+ SvColorDialog( ::Window* pParent );
void SetColor( const Color& rColor );
const Color& GetColor() const;
+ void SetMode( sal_Int16 eMode );
+
virtual short Execute();
+
+private:
+ Window* mpParent;
+ Color maColor;
+ sal_Int16 meMode;
};
#endif // _SV_COLRDLG_HXX
diff --git a/svtools/source/dialogs/colctrl.cxx b/svtools/source/dialogs/colctrl.cxx
deleted file mode 100644
index d98e0bd780b9..000000000000
--- a/svtools/source/dialogs/colctrl.cxx
+++ /dev/null
@@ -1,676 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_svtools.hxx"
-
-
-#include <vcl/salbtype.hxx>
-#include <vcl/bmpacc.hxx>
-
-#include <svtools/colctrl.hxx>
-
-// ----------------
-// - ColorControl -
-// ----------------
-
-SvColorControl::SvColorControl( Window* pParent, WinBits nStyle ) :
- Control ( pParent, nStyle ),
- mpBitmap ( NULL ),
- mpReadAccess ( NULL ),
- mnLuminance ( 50 )
-{
- Initialize();
-}
-
-// -----------------------------------------------------------------------
-SvColorControl::SvColorControl( Window* pParent, const ResId& rResId ) :
- Control ( pParent, rResId ),
- mpBitmap ( NULL ),
- mpReadAccess ( NULL ),
- mnLuminance ( 50 )
-{
- Initialize();
-}
-
-
-// -----------------------------------------------------------------------
-SvColorControl::~SvColorControl()
-{
- delete mpBitmap;
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::Initialize()
-{
- SetLineColor( Color( COL_BLACK ) );
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::CreateBitmap()
-{
- const Size aSize( GetOutputSizePixel() );
-
- if( mpBitmap && mpBitmap->GetSizePixel() != aSize )
- delete mpBitmap, mpBitmap = NULL;
-
- if( !mpBitmap )
- mpBitmap = new Bitmap( aSize, 24 );
-
- BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess();
-
- if( pWriteAccess )
- {
- sal_uInt16 nX = (sal_uInt16) aSize.Width();
- sal_uInt16 nY = (sal_uInt16) aSize.Height();
-
- sal_uInt16 nHue, nSat;
- ColorHSB aColHSB( 0, 0, mnLuminance );
-
- for( sal_uInt16 i = 0; i < nY; i++ )
- {
- nSat = (sal_uInt16) FRound( 100 - ( 100.0 * i + 0.5 ) / nY );
-
- for( sal_uInt16 j = 0; j < nX; j++ )
- {
- nHue = (sal_uInt16) FRound( ( 360.0 * j + 0.5 ) / nX );
-
- aColHSB.SetHue( nHue );
- aColHSB.SetSat( nSat );
-
- // mpBitmap always has a bit count of 24 => use of SetPixel(...) is safe
- pWriteAccess->SetPixel( i, j, BitmapColor( aColHSB.GetRGB() ) );
- }
- }
-
- mpBitmap->ReleaseAccess( pWriteAccess );
- }
-
- SetColor( maColor );
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::ShowPosition( const Point& rPos )
-{
- // Explizites Abfragen des Bereichs, da schon mal ein Wert < 0 vorhanden ist
- if( mpBitmap )
- {
- long nX = rPos.X();
- long nY = rPos.Y();
- if( nX < 0L )
- nX = 0L;
- else if( nX >= mpBitmap->GetSizePixel().Width() )
- nX = mpBitmap->GetSizePixel().Width() - 1L;
-
- if( nY < 0L )
- nY= 0L;
- else if( nY >= mpBitmap->GetSizePixel().Height() )
- nY = mpBitmap->GetSizePixel().Height() - 1L;
-
- Point aPos = maPosition;
- maPosition.X() = nX - 2;
- maPosition.Y() = nY - 2;
- Invalidate( Rectangle( aPos, Size( 5, 5) ) );
- Invalidate( Rectangle( maPosition, Size( 5, 5) ) );
-
- if( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL )
- {
- // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
- maColor = mpReadAccess->GetPixel( nY, nX );
- mpBitmap->ReleaseAccess( mpReadAccess );
- mpReadAccess = NULL;
- }
- }
-}
-// -----------------------------------------------------------------------
-void SvColorControl::MouseMove( const MouseEvent& rMEvt )
-{
- if( rMEvt.IsLeft() )
- {
- ShowPosition( rMEvt.GetPosPixel() );
- Modify();
- }
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::MouseButtonDown( const MouseEvent& rMEvt )
-{
- if( rMEvt.IsLeft() && !rMEvt.IsShift() )
- {
- //ShowPointer( sal_False );
- CaptureMouse();
- ShowPosition( rMEvt.GetPosPixel() );
- Modify();
- }
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::MouseButtonUp( const MouseEvent& )
-{
- //ShowPointer( sal_True );
- if( IsMouseCaptured() )
- ReleaseMouse();
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::Paint( const Rectangle& rRect )
-{
- if( !mpBitmap )
- CreateBitmap();
-
- Bitmap aOutputBitmap( *mpBitmap );
-
- if( GetBitCount() <= 8 )
- aOutputBitmap.Dither();
-
- DrawBitmap( rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), aOutputBitmap );
-
- // Positions-Control (Fadenkreuz oder Aehnliches)
- Point aPos1( maPosition );
- Point aPos2( maPosition );
- aPos2.X() += 4;
- DrawLine( aPos1, aPos2 );
- aPos2.X() -= 4;
- aPos2.Y() += 4;
- DrawLine( aPos1, aPos2 );
- aPos1.Y() += 4;
- aPos2.X() += 4;
- DrawLine( aPos1, aPos2 );
- aPos1.X() += 4;
- aPos2.Y() -= 4;
- DrawLine( aPos1, aPos2 );
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::Resize()
-{
- CreateBitmap();
- Control::Resize();
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::Modify()
-{
- maModifyHdl.Call( this );
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::SetColor( const ColorHSB& rCol, sal_Bool bSetColor )
-{
- if( bSetColor )
- maColor = rCol.GetRGB();
-
- if( mpBitmap )
- {
- sal_uInt16 nX = (sal_uInt16) mpBitmap->GetSizePixel().Width();
- sal_uInt16 nY = (sal_uInt16) mpBitmap->GetSizePixel().Height();
- sal_Int16 nZ = rCol.GetBri();
-
- SetLuminance( nZ );
- nX = rCol.GetHue() * nX / 360; // Farbe
- nY = nY - rCol.GetSat() * nY / 100; // Saettigung
- ShowPosition( Point( nX, nY ) );
- }
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::SetColor( const Color& rCol )
-{
- maColor = rCol;
-
- if( mpBitmap )
- {
- ColorHSB aColHsb( rCol );
- SetColor( aColHsb, sal_False );
- }
-}
-
-// -----------------------------------------------------------------------
-void SvColorControl::SetLuminance( short nLum )
-{
- if( nLum != mnLuminance && nLum >= 0 && nLum <= 100 )
- {
- mnLuminance = nLum;
-
- if( mnLuminance < 40 )
- SetLineColor( Color( COL_WHITE ) );
- else
- SetLineColor( Color( COL_BLACK ) );
-
- CreateBitmap();
-
- long nX = maPosition.X() + 2;
- long nY = maPosition.Y() + 2;
-
- if( mpBitmap && ( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL ) )
- {
- // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
- maColor = mpReadAccess->GetPixel( nY, nX );
- mpBitmap->ReleaseAccess( mpReadAccess );
- mpReadAccess = NULL;
- }
-
- Invalidate();
- }
-}
-
-
-// -----------------------
-// - ColorPreviewControl -
-// -----------------------
-
-
-// -----------------------------------------------------------------------
-ColorPreviewControl::ColorPreviewControl( Window* pParent, WinBits nStyle ) :
- Control ( pParent, nStyle )
-{
- SetFillColor( maColor );
- SetLineColor( maColor );
-}
-
-// -----------------------------------------------------------------------
-ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId ) :
- Control ( pParent, rResId )
-{
- SetFillColor( maColor );
- SetLineColor( maColor );
-}
-
-
-// -----------------------------------------------------------------------
-ColorPreviewControl::~ColorPreviewControl()
-{
-}
-
-// -----------------------------------------------------------------------
-void ColorPreviewControl::Paint( const Rectangle& rRect )
-{
- DrawRect( rRect );
-}
-
-// -----------------------------------------------------------------------
-void ColorPreviewControl::SetColor( const Color& rCol )
-{
- if( rCol != maColor )
- {
- maColor = rCol;
- SetFillColor( maColor );
- SetLineColor( maColor );
- Invalidate();
- }
-}
-
-
-// -----------------------
-// - ColorMixingControl -
-// -----------------------
-
-
-// -----------------------------------------------------------------------
-ColorMixingControl::ColorMixingControl( Window* pParent, WinBits nStyle,
- sal_uInt16 nRows, sal_uInt16 nColumns ) :
- ValueSet ( pParent, nStyle ),
- mnRows ( nRows ),
- mnColumns ( nColumns )
-{
- Initialize();
-}
-
-// -----------------------------------------------------------------------
-ColorMixingControl::ColorMixingControl( Window* pParent, const ResId& rResId,
- sal_uInt16 nRows, sal_uInt16 nColumns ) :
- ValueSet ( pParent, rResId ),
- mnRows ( nRows ),
- mnColumns ( nColumns )
-{
- Initialize();
-}
-
-
-// -----------------------------------------------------------------------
-ColorMixingControl::~ColorMixingControl()
-{
-}
-
-// -----------------------------------------------------------------------
-void ColorMixingControl::Initialize()
-{
- SetColCount( mnColumns );
-
- Color aColor;
- String aStr;
- for( sal_uInt16 i = 1; i <= mnRows * mnColumns; i++ )
- {
- InsertItem( i, aColor, aStr );
- }
-
- SetColor( CMC_TOPLEFT, Color( COL_LIGHTRED ) );
- SetColor( CMC_BOTTOMRIGHT, Color( COL_LIGHTBLUE ) );
-
- SetColor( CMC_TOPRIGHT, Color( COL_LIGHTGREEN ) );
- SetColor( CMC_BOTTOMLEFT, Color( COL_YELLOW ) );
-}
-
-// -----------------------------------------------------------------------
-Color ColorMixingControl::CalcDifferenceColor( sal_uInt16 nCol1, sal_uInt16 nCol2,
- sal_uInt16 nSteps )
-{
- // Die Berechnung ist noch etwas ungenau, daher sollte besser mit floats
- // gearbeitet werden... (muss !!!)
- Color aColor( GetItemColor( nCol1 ) );
- Color aColor2( GetItemColor( nCol2 ) );
-
- aColor.SetRed( (sal_uInt8) ( ( aColor2.GetRed() - aColor.GetRed() ) / nSteps ) );
- aColor.SetGreen( (sal_uInt8) ( ( aColor2.GetGreen() - aColor.GetGreen() ) / nSteps ) );
- aColor.SetBlue( (sal_uInt8) ( ( aColor2.GetBlue() - aColor.GetBlue() ) / nSteps ) );
-
- return( aColor );
-}
-
-// -----------------------------------------------------------------------
-void ColorMixingControl::FillRow( sal_uInt16 nRow )
-{
- sal_uInt16 nCol1 = nRow * mnColumns + 1;
- sal_uInt16 nCol2 = ( nRow + 1 ) * mnColumns;
- Color aColor( GetItemColor( nCol1 ) );
- Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnColumns - 1 ) );
-
- for( sal_uInt16 i = nCol1 + 1; i < nCol2; i++ )
- {
- aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() );
- aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() );
- aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() );
-
- SetItemColor( i, aColor );
- SetItemText( i, GetRGBString( aColor ) );
- }
-}
-
-// -----------------------------------------------------------------------
-void ColorMixingControl::FillColumn( sal_uInt16 nColumn )
-{
- sal_uInt16 nCol1 = nColumn + 1;
- sal_uInt16 nCol2 = nColumn + ( mnRows - 1 ) * mnColumns + 1;
- Color aColor( GetItemColor( nCol1 ) );
- Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnRows - 1 ) );
-
- for( sal_uInt16 i = nCol1 + mnColumns; i < nCol2; i = i + mnColumns )
- {
- aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() );
- aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() );
- aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() );
-
- SetItemColor( i, aColor );
- SetItemText( i, GetRGBString( aColor ) );
- }
-}
-
-// -----------------------------------------------------------------------
-void ColorMixingControl::SetRows( sal_uInt16 nRows )
-{
- mnRows = nRows;
-}
-
-// -----------------------------------------------------------------------
-void ColorMixingControl::SetColumns( sal_uInt16 nColumns )
-{
- mnColumns = nColumns;
-}
-
-// -----------------------------------------------------------------------
-void ColorMixingControl::SetColor( CMCPosition ePos, const Color& rCol )
-{
- if( rCol != maColor[ ePos ] )
- {
- maColor[ ePos ] = rCol;
- sal_uInt16 nPos = 0;
- sal_uInt16 nColumn = 0;
- String aStr( GetRGBString( rCol ) );
-
- switch( ePos )
- {
- case CMC_TOPLEFT:
- nPos = 1;
- nColumn = 0;
- break;
-
- case CMC_TOPRIGHT:
- nPos = mnColumns;
- nColumn = mnColumns - 1;
- break;
-
- case CMC_BOTTOMLEFT:
- nPos = ( mnRows - 1 ) * mnColumns + 1;
- nColumn = 0;
- break;
-
- case CMC_BOTTOMRIGHT:
- nPos = mnRows * mnColumns;
- nColumn = mnColumns - 1;
- break;
- case CMC_OTHER:
- break; // -Wall not handled.
- }
- SetItemColor( nPos, rCol );
- SetItemText( nPos, aStr );
- FillColumn( nColumn );
-
- for( sal_uInt16 i = 0; i < mnRows; i++ )
- FillRow( i );
- }
-}
-
-// -----------------------------------------------------------------------
-String ColorMixingControl::GetRGBString( const Color& rColor )
-{
- String aStr( String::CreateFromInt32(rColor.GetRed()) );
- aStr += ' ';
- aStr += String::CreateFromInt32(rColor.GetGreen());
- aStr += ' ';
- aStr += String::CreateFromInt32(rColor.GetBlue());
-
- return aStr;
-}
-// -----------------------------------------------------------------------
-CMCPosition ColorMixingControl::GetCMCPosition() const
-{
- CMCPosition ePos = CMC_OTHER;
- sal_uInt16 nPos = GetSelectItemId();
-
- if( nPos == 1 )
- ePos = CMC_TOPLEFT;
- else if( nPos == mnColumns )
- ePos = CMC_TOPRIGHT;
- else if( nPos == ( mnRows - 1 ) * mnColumns + 1 )
- ePos = CMC_BOTTOMLEFT;
- else if( nPos == mnRows * mnColumns )
- ePos = CMC_BOTTOMRIGHT;
-
- return( ePos );
-}
-
-
-// ------------
-// - ColorHSB -
-// ------------
-
-// Erste Ansaetze gingen auf die Berechnung von Sven Hannover zurueck
-// Der jetzige Algorithmus stammt im weitesten Sinne aus dem Foley/VanDam
-
-
-/**************************************************************************
-|*
-|* ColorHSB::ColorHSB()
-|*
-**************************************************************************/
-
-ColorHSB::ColorHSB( const Color& rColor )
-{
- sal_uInt8 c[3];
- sal_uInt8 cMax, cMin;
-
- c[0] = rColor.GetRed();
- c[1] = rColor.GetGreen();
- c[2] = rColor.GetBlue();
-
- cMax = c[0];
- if( c[1] > cMax )
- cMax = c[1];
- if( c[2] > cMax )
- cMax = c[2];
-
- // Brightness = max(R, G, B);
- mnBri = cMax * 100 / 255;
-
- cMin = c[0];
- if( c[1] < cMin )
- cMin = c[1];
- if( c[2] < cMin )
- cMin = c[2];
-
- sal_uInt8 cDelta = cMax - cMin;
-
- // Saturation = max - min / max
- if( mnBri > 0 )
- mnSat = cDelta * 100 / cMax;
- else
- mnSat = 0;
-
- if( mnSat == 0 )
- mnHue = 0; // Default = undefined
- else
- {
- double dHue = 0;
-
- if( c[0] == cMax )
- {
- dHue = (double)( c[1] - c[2] ) / (double)cDelta;
- }
- else if( c[1] == cMax )
- {
- dHue = 2.0 + (double)( c[2] - c[0] ) / (double)cDelta;
- }
- else if ( c[2] == cMax )
- {
- dHue = 4.0 + (double)( c[0] - c[1] ) / (double)cDelta;
- }
- // else dHue = ??? -Wall FIXME
- dHue *= 60.0;
-
- if( dHue < 0.0 )
- dHue += 360.0;
-
- mnHue = (sal_uInt16) dHue;
- }
-}
-
-/**************************************************************************
-|*
-|* ColorHSB::GetRGB()
-|*
-**************************************************************************/
-
-Color ColorHSB::GetRGB() const
-{
- sal_uInt8 cR,cG,cB;
- sal_uInt8 nB = (sal_uInt8) ( mnBri * 255 / 100 );
-
- if( mnSat == 0 )
- {
- cR = nB;
- cG = nB;
- cB = nB;
- }
- else
- {
- double dH = mnHue;
- double f;
- sal_uInt16 n;
- if( dH == 360.0 )
- dH = 0.0;
-
- dH /= 60.0;
- n = (sal_uInt16) dH;
- f = dH - n;
-
- // #107375# Doing the calculation completely in floating
- // point, the former optimization gave sometimes negative
- // results for c and was pointless anyway
- sal_uInt8 a = static_cast<sal_uInt8>( nB * ( 100.0 - mnSat ) / 100.0 );
- sal_uInt8 b = static_cast<sal_uInt8>( nB * ( 100.0 - mnSat * f ) / 100.0 );
- sal_uInt8 c = static_cast<sal_uInt8>( nB * ( 100.0 - mnSat * ( 1.0 - f ) ) / 100.0 );
-
- switch( n )
- {
- case 0: cR = nB; cG = c; cB = a; break;
- case 1: cR = b; cG = nB; cB = a; break;
- case 2: cR = a; cG = nB; cB = c; break;
- case 3: cR = a; cG = b; cB = nB; break;
- case 4: cR = c; cG = a; cB = nB; break;
- case 5: cR = nB; cG = a; cB = b; break;
- default: cR = 0; cG = 0; cB = 0; break; // -Wall ????
- }
- }
-
- return( Color( cR, cG, cB ) );
-}
-
-// ------------
-// - ColorCMYK -
-// ------------
-
-
-// -----------------------------------------------------------------------
-ColorCMYK::ColorCMYK( const Color& rColor )
-{
- mnCyan = 255 - rColor.GetRed();
- mnMagenta = 255 - rColor.GetGreen();
- mnYellow = 255 - rColor.GetBlue();
-
- mnKey = Min( Min( mnCyan, mnMagenta ), mnYellow );
-
- mnCyan = mnCyan - mnKey;
- mnMagenta = mnMagenta - mnKey;
- mnYellow = mnYellow - mnKey;
-}
-
-// -----------------------------------------------------------------------
-Color ColorCMYK::GetRGB() const
-{
- int nTmp = Max( 0, 255 - ( mnCyan + mnKey ) );
- sal_uInt8 cR = (sal_uInt8) nTmp;
- nTmp = Max( 0, 255 - ( mnMagenta + mnKey ) );
- sal_uInt8 cG = (sal_uInt8) nTmp;
- nTmp = Max( 0, 255 - ( mnYellow + mnKey ) );
- sal_uInt8 cB = (sal_uInt8) nTmp;
-
- return( Color( cR, cG, cB ) );
-}
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/dialogs/colrdlg.cxx b/svtools/source/dialogs/colrdlg.cxx
index 5e94c0529760..d5f3b4ea9c65 100644
--- a/svtools/source/dialogs/colrdlg.cxx
+++ b/svtools/source/dialogs/colrdlg.cxx
@@ -29,300 +29,105 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svtools.hxx"
-#include <svtools/svtdata.hxx>
-#include "colrdlg.hrc"
-#include <svtools/colrdlg.hxx>
-
-// ---------------
-// - ColorDialog -
-// ---------------
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
-SvColorDialog::SvColorDialog( Window* pWindow ) :
- ModalDialog ( pWindow, SvtResId( DLG_COLOR ) ),
- maColMixCtrl ( this, SvtResId( VAL_SET_COLOR ), 8, 8 ),
- maBtn1 ( this, SvtResId( BTN_1 ) ),
- maBtn2 ( this, SvtResId( BTN_2 ) ),
- //maBtn3 ( this, SvtResId( BTN_3 ) ),
- //maBtn4 ( this, SvtResId( BTN_4 ) ),
- //maFtRGB ( this, SvtResId( FT_RGB ) ),
- maCtlColor ( this, SvtResId( CTL_COLOR ) ),
+#include <comphelper/processfactory.hxx>
- maFtCyan ( this, SvtResId( FT_CYAN ) ),
- maNumCyan ( this, SvtResId( NUM_CYAN ) ),
- maFtMagenta ( this, SvtResId( FT_MAGENTA ) ),
- maNumMagenta ( this, SvtResId( NUM_MAGENTA ) ),
- maFtYellow ( this, SvtResId( FT_YELLOW ) ),
- maNumYellow ( this, SvtResId( NUM_YELLOW ) ),
- maFtKey ( this, SvtResId( FT_KEY ) ),
- maNumKey ( this, SvtResId( NUM_KEY ) ),
+#include <toolkit/helper/vclunohelper.hxx>
- maFtRed ( this, SvtResId( FT_RED ) ),
- maNumRed ( this, SvtResId( NUM_RED ) ),
- maFtGreen ( this, SvtResId( FT_GREEN ) ),
- maNumGreen ( this, SvtResId( NUM_GREEN ) ),
- maFtBlue ( this, SvtResId( FT_BLUE ) ),
- maNumBlue ( this, SvtResId( NUM_BLUE ) ),
+#include <svtools/colrdlg.hxx>
- maFtHue ( this, SvtResId( FT_HUE ) ),
- maNumHue ( this, SvtResId( NUM_HUE ) ),
- maFtSaturation ( this, SvtResId( FT_SATURATION ) ),
- maNumSaturation ( this, SvtResId( NUM_SATURATION ) ),
- maFtLuminance ( this, SvtResId( FT_LUMINANCE ) ),
- maNumLuminance ( this, SvtResId( NUM_LUMINANCE ) ),
+using rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::ui::dialogs;
- maCtlPreview ( this, SvtResId( CTL_PREVIEW ) ),
- maCtlPreviewOld ( this, SvtResId( CTL_PREVIEW_OLD ) ),
+// ---------------
+// - ColorDialog -
+// ---------------
- maBtnOK ( this, SvtResId( BTN_OK ) ),
- maBtnCancel ( this, SvtResId( BTN_CANCEL ) ),
- maBtnHelp ( this, SvtResId( BTN_HELP ) )
+SvColorDialog::SvColorDialog( Window* pWindow )
+: mpParent( pWindow )
+, meMode( svtools::ColorPickerMode_SELECT )
{
- FreeResource();
-
- maColMixCtrl.SetDoubleClickHdl( LINK( this, SvColorDialog, ClickMixCtrlHdl ) );
- maColMixCtrl.SetSelectHdl( LINK( this, SvColorDialog, SelectMixCtrlHdl ) );
-
- Link aLink( LINK( this, SvColorDialog, ColorModifyHdl ) );
- maCtlColor.SetModifyHdl( aLink );
-
- maNumRed.SetModifyHdl( aLink );
- maNumGreen.SetModifyHdl( aLink );
- maNumBlue.SetModifyHdl( aLink );
-
- maNumCyan.SetModifyHdl( aLink );
- maNumMagenta.SetModifyHdl( aLink );
- maNumYellow.SetModifyHdl( aLink );
- maNumKey.SetModifyHdl( aLink );
-
- maNumHue.SetModifyHdl( aLink );
- maNumSaturation.SetModifyHdl( aLink );
- maNumLuminance.SetModifyHdl( aLink );
-
- aLink = ( LINK( this, SvColorDialog, ClickBtnHdl ) );
- maBtn1.SetClickHdl( aLink );
- maBtn2.SetClickHdl( aLink );
- //maBtn3.SetClickHdl( aLink );
- //maBtn4.SetClickHdl( aLink );
-
- maColMixCtrl.SetExtraSpacing( 0 );
}
-
// -----------------------------------------------------------------------
-SvColorDialog::~SvColorDialog()
-{
-}
-// -----------------------------------------------------------------------
-void SvColorDialog::Initialize()
-{
- maNumRed.SetValue( maColor.GetRed() );
- maNumGreen.SetValue( maColor.GetGreen() );
- maNumBlue.SetValue( maColor.GetBlue() );
-
- ColorCMYK aColorCMYK( maColor );
-
- long aCyan = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 );
- long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 );
- long aYellow = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 );
- long aKey = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 );
- maNumCyan.SetValue( aCyan );
- maNumMagenta.SetValue( aMagenta );
- maNumYellow.SetValue( aYellow );
- maNumKey.SetValue( aKey );
-
- ColorHSB aColorHSB( maColor );
- maNumHue.SetValue( aColorHSB.GetHue() );
- maNumSaturation.SetValue( aColorHSB.GetSat() );
- maNumLuminance.SetValue( aColorHSB.GetBri() );
-
- maCtlColor.SetColor( aColorHSB );
-
- maColMixCtrl.SelectItem( 1 );
-
- maCtlPreview.SetColor( maColor );
- maCtlPreviewOld.SetColor( maColor );
-}
-
-// -----------------------------------------------------------------------
void SvColorDialog::SetColor( const Color& rColor )
{
maColor = rColor;
}
// -----------------------------------------------------------------------
+
const Color& SvColorDialog::GetColor() const
{
- return( maColor );
+ return maColor;
}
// -----------------------------------------------------------------------
-IMPL_LINK( SvColorDialog, ColorModifyHdl, void *, p )
-{
- sal_uInt16 n = 0x00; // 1 == RGB, 2 == CMYK, 4 == HSB
-
- if( p == &maCtlColor )
- {
- maColor = maCtlColor.GetColor();
- maNumRed.SetValue( maColor.GetRed() );
- maNumGreen.SetValue( maColor.GetGreen() );
- maNumBlue.SetValue( maColor.GetBlue() );
- n = 7;
- }
- else if( p == &maNumRed )
- {
- maColor.SetRed( (sal_uInt8)maNumRed.GetValue() );
- maCtlColor.SetColor( maColor );
- n = 6;
- }
- else if( p == &maNumGreen )
- {
- maColor.SetGreen( (sal_uInt8)maNumGreen.GetValue() );
- maCtlColor.SetColor( maColor );
- n = 6;
- }
- else if( p == &maNumBlue )
- {
- maColor.SetBlue( (sal_uInt8)maNumBlue.GetValue() );
- maCtlColor.SetColor( maColor );
- n = 6;
- }
- else if( p == &maNumHue ||
- p == &maNumSaturation ||
- p == &maNumLuminance )
- {
-
- ColorHSB aColorHSB( (sal_uInt16) maNumHue.GetValue(),
- (sal_uInt16) maNumSaturation.GetValue(),
- (sal_uInt16) maNumLuminance.GetValue() );
- maCtlColor.SetColor( aColorHSB );
- maColor = maCtlColor.GetColor();
- n = 3;
- }
- else if( p == &maNumCyan ||
- p == &maNumMagenta ||
- p == &maNumYellow ||
- p == &maNumKey )
- {
- long aCyan = (long) ( (double)maNumCyan.GetValue() * 255.0 / 100.0 + 0.5 );
- long aMagenta = (long) ( (double)maNumMagenta.GetValue() * 255.0 / 100.0 + 0.5 );
- long aYellow = (long) ( (double)maNumYellow.GetValue() * 255.0 / 100.0 + 0.5 );
- long aKey = (long) ( (double)maNumKey.GetValue() * 255.0 / 100.0 + 0.5 );
-
- ColorCMYK aColorCMYK( (sal_uInt16) aCyan,
- (sal_uInt16) aMagenta,
- (sal_uInt16) aYellow,
- (sal_uInt16) aKey );
- maColor = aColorCMYK.GetRGB();
- maCtlColor.SetColor( maColor );
- n = 5;
- }
-
- if( n & 1 ) // RGB setzen
- {
- maNumRed.SetValue( maColor.GetRed() );
- maNumGreen.SetValue( maColor.GetGreen() );
- maNumBlue.SetValue( maColor.GetBlue() );
- }
- if( n & 2 ) // CMYK setzen
- {
- ColorCMYK aColorCMYK( maColor );
- long aCyan = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 );
- long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 );
- long aYellow = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 );
- long aKey = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 );
- maNumCyan.SetValue( aCyan );
- maNumMagenta.SetValue( aMagenta );
- maNumYellow.SetValue( aYellow );
- maNumKey.SetValue( aKey );
- }
- if( n & 4 ) // HSB setzen
- {
- ColorHSB aColorHSB( maColor );
- maNumHue.SetValue( aColorHSB.GetHue() );
- maNumSaturation.SetValue( aColorHSB.GetSat() );
- maNumLuminance.SetValue( aColorHSB.GetBri() );
- }
-
- maCtlPreview.SetColor( maColor );
-
- return 0;
+void SvColorDialog::SetMode( sal_Int16 eMode )
+{
+ meMode = eMode;
}
// -----------------------------------------------------------------------
-IMPL_LINK( SvColorDialog, ClickBtnHdl, void *, p )
-{
- /*
- Color aColor = maCtlColor.GetColor();
- if( p == &maBtn1 )
- maColMixCtrl.SetColor( CMC_TOPLEFT, aColor );
- if( p == &maBtn2 )
- maColMixCtrl.SetColor( CMC_TOPRIGHT, aColor );
- if( p == &maBtn3 )
- maColMixCtrl.SetColor( CMC_BOTTOMLEFT, aColor );
- if( p == &maBtn4 )
- maColMixCtrl.SetColor( CMC_BOTTOMRIGHT, aColor );
- */
- if( p == &maBtn1 )
- {
- CMCPosition ePos = maColMixCtrl.GetCMCPosition();
- if( ePos != CMC_OTHER )
- maColMixCtrl.SetColor( ePos, maColor );
- }
- else if( p == &maBtn2 )
+short SvColorDialog::Execute()
+{
+ short ret = 0;
+ try
{
- sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
- maColor = maColMixCtrl.GetItemColor( nPos );
- maCtlColor.SetColor( maColor );
- ColorModifyHdl( &maCtlColor );
+ const OUString sColor( RTL_CONSTASCII_USTRINGPARAM( "Color" ) );
+ Reference< XMultiServiceFactory > xSMGR( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+
+ Reference< com::sun::star::awt::XWindow > xParent( VCLUnoHelper::GetInterface( mpParent ) );
+
+ Sequence< Any > args(1);
+ args[0] = Any( xParent );
+
+ Reference< XExecutableDialog > xDialog( xSMGR->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.cui.ColorPicker"), args), UNO_QUERY_THROW );
+ Reference< XPropertyAccess > xPropertyAccess( xDialog, UNO_QUERY_THROW );
+
+ Sequence< PropertyValue > props( 2 );
+ props[0].Name = sColor;
+ props[0].Value <<= (sal_Int32) maColor.GetColor();
+ props[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Mode" ) );
+ props[1].Value <<= (sal_Int16) meMode;
+
+ xPropertyAccess->setPropertyValues( props );
+
+ ret = xDialog->execute();
+
+ if( ret )
+ {
+ props = xPropertyAccess->getPropertyValues();
+ for( sal_Int32 n = 0; n < props.getLength(); n++ )
+ {
+ if( props[n].Name.equals( sColor ) )
+ {
+ sal_Int32 nColor = 0;
+ if( props[n].Value >>= nColor )
+ {
+ maColor.SetColor( nColor );
+ }
+
+ }
+ }
+ }
}
-
- return 0;
-}
-
-// -----------------------------------------------------------------------
-IMPL_LINK( SvColorDialog, ClickMixCtrlHdl, void *, EMPTYARG )
-{
- sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
- CMCPosition ePos = maColMixCtrl.GetCMCPosition();
-
- if( ePos != CMC_OTHER )
- maColMixCtrl.SetColor( ePos, maColor );
- else
+ catch(Exception&)
{
- maColor = maColMixCtrl.GetItemColor( nPos );
- maCtlColor.SetColor( maColor );
- ColorModifyHdl( &maCtlColor );
+ OSL_ASSERT(false);
}
- return 0;
-}
-
-// -----------------------------------------------------------------------
-IMPL_LINK( SvColorDialog, SelectMixCtrlHdl, void *, EMPTYARG )
-{
- //sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
- //maFtRGB.SetText( maColMixCtrl.GetItemText( nPos ) );
-
- CMCPosition ePos = maColMixCtrl.GetCMCPosition();
- if( ePos == CMC_OTHER )
- maBtn1.Enable( sal_False );
- else
- maBtn1.Enable();
-
- return 0;
-}
-
-// -----------------------------------------------------------------------
-short SvColorDialog::Execute()
-{
- Initialize();
-
- short nRet = ModalDialog::Execute();
-
- return( nRet );
+ return ret;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/dialogs/colrdlg.hrc b/svtools/source/dialogs/colrdlg.hrc
deleted file mode 100644
index b1e785bd2f17..000000000000
--- a/svtools/source/dialogs/colrdlg.hrc
+++ /dev/null
@@ -1,69 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#define DLG_COLOR 996
-
-#define VAL_SET_COLOR 2
-#define BTN_1 1
-#define BTN_2 2
-#define BTN_3 3
-#define BTN_4 4
-#define FT_RGB 12
-
-#define CTL_COLOR 1
-
-#define FT_RED 1
-#define NUM_RED 1
-#define FT_GREEN 2
-#define NUM_GREEN 2
-#define FT_BLUE 3
-#define NUM_BLUE 3
-
-#define FT_CYAN 7
-#define NUM_CYAN 7
-#define FT_MAGENTA 8
-#define NUM_MAGENTA 8
-#define FT_YELLOW 9
-#define NUM_YELLOW 9
-#define FT_KEY 10
-#define NUM_KEY 10
-
-#define FT_HUE 4
-#define NUM_HUE 4
-#define FT_SATURATION 5
-#define NUM_SATURATION 5
-#define FT_LUMINANCE 6
-#define NUM_LUMINANCE 6
-
-#define CTL_PREVIEW 3
-#define CTL_PREVIEW_OLD 4
-
-#define BTN_OK 1
-#define BTN_CANCEL 1
-#define BTN_HELP 1
-
-//IAccessibility2 Implementation 2009-----
-#define STR_COLORDES 3001
diff --git a/svtools/source/dialogs/colrdlg.src b/svtools/source/dialogs/colrdlg.src
deleted file mode 100644
index c0b4f33db69a..000000000000
--- a/svtools/source/dialogs/colrdlg.src
+++ /dev/null
@@ -1,294 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "colrdlg.hrc"
-#define DIFF 3
-ModalDialog DLG_COLOR
-{
- HelpID = "svtools:ModalDialog:DLG_COLOR";
- OutputSize = TRUE ;
- SVLook = TRUE ;
- Size = MAP_APPFONT ( 260 , 165 + DIFF ) ;
- Moveable = TRUE ;
- Text [ en-US ] = "Color" ;
- OKButton BTN_OK
- {
- Pos = MAP_APPFONT ( 205 , 6 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
- TabStop = TRUE ;
- DefButton = TRUE ;
- };
- CancelButton BTN_CANCEL
- {
- Pos = MAP_APPFONT ( 205 , 23 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
- TabStop = TRUE ;
- };
- HelpButton BTN_HELP
- {
- Pos = MAP_APPFONT ( 205 , 43 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
- TabStop = TRUE ;
- };
- Control VAL_SET_COLOR
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( 6 , 6 ) ;
- Size = MAP_APPFONT ( 91 , 100 ) ;
- TabStop = TRUE ;
- };
- Control CTL_COLOR
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( 100 , 6 ) ;
- Size = MAP_APPFONT ( 100 , 100 ) ;
- TabStop = TRUE ;
- };
- FixedText FT_CYAN
- {
- Pos = MAP_APPFONT ( 6 , 110 + DIFF ) ;
- Size = MAP_APPFONT ( 34 , 10 ) ;
- Text [ en-US ] = "~Cyan" ;
- };
- FixedText FT_MAGENTA
- {
- Pos = MAP_APPFONT ( 6 , 123 + DIFF ) ;
- Size = MAP_APPFONT ( 34 , 10 ) ;
- Text [ en-US ] = "~Magenta" ;
- };
- FixedText FT_YELLOW
- {
- Pos = MAP_APPFONT ( 6 , 136 + DIFF ) ;
- Size = MAP_APPFONT ( 34 , 10 ) ;
- Text [ en-US ] = "~Yellow" ;
- };
- FixedText FT_KEY
- {
- Pos = MAP_APPFONT ( 6 , 149 + DIFF ) ;
- Size = MAP_APPFONT ( 34 , 10 ) ;
- Text [ en-US ] = "~Key" ;
- };
- MetricField NUM_CYAN
- {
- HelpID = "svtools:MetricField:DLG_COLOR:NUM_CYAN";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 42 , 109 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 100 ;
- Last = 100 ;
- Unit = FUNIT_CUSTOM ;
- CustomUnitText = "%" ;
- };
- MetricField NUM_MAGENTA
- {
- HelpID = "svtools:MetricField:DLG_COLOR:NUM_MAGENTA";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 42 , 122 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 100 ;
- Last = 100 ;
- Unit = FUNIT_CUSTOM ;
- CustomUnitText = "%" ;
- };
- MetricField NUM_YELLOW
- {
- HelpID = "svtools:MetricField:DLG_COLOR:NUM_YELLOW";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 42 , 135 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 100 ;
- Last = 100 ;
- Unit = FUNIT_CUSTOM ;
- CustomUnitText = "%" ;
- };
- MetricField NUM_KEY
- {
- HelpID = "svtools:MetricField:DLG_COLOR:NUM_KEY";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 42 , 148 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 100 ;
- Last = 100 ;
- Unit = FUNIT_CUSTOM ;
- CustomUnitText = "%" ;
- };
- FixedText FT_RED
- {
- Pos = MAP_APPFONT ( 72 , 123 + DIFF ) ;
- Size = MAP_APPFONT ( 33 , 10 ) ;
- Text [ en-US ] = "~Red" ;
- };
- FixedText FT_GREEN
- {
- Pos = MAP_APPFONT ( 72 , 136 + DIFF ) ;
- Size = MAP_APPFONT ( 33 , 10 ) ;
- Text [ en-US ] = "~Green" ;
- };
- FixedText FT_BLUE
- {
- Pos = MAP_APPFONT ( 72 , 149 + DIFF ) ;
- Size = MAP_APPFONT ( 33 , 10 ) ;
- Text [ en-US ] = "~Blue" ;
- };
- NumericField NUM_RED
- {
- HelpID = "svtools:NumericField:DLG_COLOR:NUM_RED";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 106 , 122 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 255 ;
- Last = 255 ;
- };
- NumericField NUM_GREEN
- {
- HelpID = "svtools:NumericField:DLG_COLOR:NUM_GREEN";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 106 , 135 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 255 ;
- Last = 255 ;
- };
- NumericField NUM_BLUE
- {
- HelpID = "svtools:NumericField:DLG_COLOR:NUM_BLUE";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 106 , 148 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 255 ;
- Last = 255 ;
- };
- FixedText FT_HUE
- {
- Pos = MAP_APPFONT ( 135 , 123 + DIFF ) ;
- Size = MAP_APPFONT ( 34 , 10 ) ;
- Text [ en-US ] = "H~ue" ;
- };
- NumericField NUM_HUE
- {
- HelpID = "svtools:NumericField:DLG_COLOR:NUM_HUE";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 171 , 122 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 359 ;
- Last = 359 ;
- };
- FixedText FT_SATURATION
- {
- Pos = MAP_APPFONT ( 135 , 136 + DIFF ) ;
- Size = MAP_APPFONT ( 34 , 10 ) ;
- Text [ en-US ] = "~Saturation" ;
- };
- NumericField NUM_SATURATION
- {
- HelpID = "svtools:NumericField:DLG_COLOR:NUM_SATURATION";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 171 , 135 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 100 ;
- Last = 100 ;
- };
- FixedText FT_LUMINANCE
- {
- Pos = MAP_APPFONT ( 135 , 149 + DIFF ) ;
- Size = MAP_APPFONT ( 34 , 10 ) ;
- Text [ en-US ] = "Bright~ness" ;
- };
- NumericField NUM_LUMINANCE
- {
- HelpID = "svtools:NumericField:DLG_COLOR:NUM_LUMINANCE";
- Border = TRUE ;
- Pos = MAP_APPFONT ( 171 , 148 + DIFF ) ;
- Size = MAP_APPFONT ( 26 , 12 ) ;
- TabStop = TRUE ;
- Repeat = TRUE ;
- Spin = TRUE ;
- Maximum = 100 ;
- Last = 100 ;
- };
- PushButton BTN_1
- {
- HelpID = "svtools:PushButton:DLG_COLOR:BTN_1";
- Pos = MAP_APPFONT ( 80 , 109 ) ;
- Size = MAP_APPFONT ( 17 , 12 ) ;
- Text = "~<--" ;
- TabStop = TRUE ;
- };
- PushButton BTN_2
- {
- HelpID = "svtools:PushButton:DLG_COLOR:BTN_2";
- Pos = MAP_APPFONT ( 100 , 109 ) ;
- Size = MAP_APPFONT ( 17 , 12 ) ;
- Text = "--~>" ;
- TabStop = TRUE ;
- };
- Control CTL_PREVIEW_OLD
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( 200 , 109 ) ;
- Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
- TabStop = FALSE ;
- };
- Control CTL_PREVIEW
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( 229 , 109 ) ;
- Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
- TabStop = FALSE ;
- };
-};
-
-String STR_COLORDES
-{
- Text [ en-US ] = "RGB(%1, %2, %3) Hue:%4 Saturation:%5 Brightness:%6";
-}; \ No newline at end of file
diff --git a/tools/inc/tools/color.hxx b/tools/inc/tools/color.hxx
index a75319d89677..ecd5f83b688c 100644
--- a/tools/inc/tools/color.hxx
+++ b/tools/inc/tools/color.hxx
@@ -177,10 +177,14 @@ public:
static ColorData HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri );
void RGBtoHSB( sal_uInt16& nHue, sal_uInt16& nSat, sal_uInt16& nBri ) const;
- sal_Bool operator==( const Color& rColor ) const
- { return (mnColor == rColor.mnColor); }
- sal_Bool operator!=( const Color& rColor ) const
- { return !(Color::operator==( rColor )); }
+ // the range for cymk is 0 to 1.0
+ static ColorData CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey );
+ void RGBtoCMYK( double& fCyan, double& fMagenta, double& fYellow, double& fKey );
+
+ sal_Bool operator==( const Color& rColor ) const
+ { return (mnColor == rColor.mnColor); }
+ sal_Bool operator!=( const Color& rColor ) const
+ { return !(Color::operator==( rColor )); }
SvStream& Read( SvStream& rIStm, sal_Bool bNewFormat = sal_True );
SvStream& Write( SvStream& rOStm, sal_Bool bNewFormat = sal_True );
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index 9a209b38f754..5560e631767a 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -261,6 +261,53 @@ ColorData Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri )
// -----------------------------------------------------------------------
+// CMYK values from 0 to 1
+ColorData Color::CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey )
+{
+ fCyan = (fCyan * ( 1.0 - fKey )) + fKey;
+ fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
+ fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
+
+ sal_uInt8 nRed = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fCyan ) * 255.0, 255.0), 0.0 ) );
+ sal_uInt8 nGreen = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fMagenta ) * 255.0, 255.0), 0.0 ) );
+ sal_uInt8 nBlue = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fYellow ) * 255.0, 255.0), 0.0 ) );
+
+ return RGB_COLORDATA( nRed, nGreen, nBlue );
+}
+
+// -----------------------------------------------------------------------
+
+// RGB values from 0 to 255
+// CMY results from 0 to 1
+void Color::RGBtoCMYK( double& fCyan, double& fMagenta, double& fYellow, double& fKey )
+{
+ fCyan = 1 - ( GetRed() / 255.0 );
+ fMagenta = 1 - ( GetGreen() / 255.0 );
+ fYellow = 1 - ( GetBlue() / 255.0 );
+
+ //CMYK and CMY values from 0 to 1
+ fKey = 1.0;
+ if( fCyan < fKey ) fKey = fCyan;
+ if( fMagenta < fKey ) fKey = fMagenta;
+ if( fYellow < fKey ) fKey = fYellow;
+
+ if ( fKey == 1.0 )
+ {
+ //Black
+ fCyan = 0.0;
+ fMagenta = 0.0;
+ fYellow = 0.0;
+ }
+ else
+ {
+ fCyan = ( fCyan - fKey ) / ( 1.0 - fKey );
+ fMagenta = ( fMagenta - fKey ) / ( 1.0 - fKey );
+ fYellow = ( fYellow - fKey ) / ( 1.0 - fKey );
+ }
+}
+
+// -----------------------------------------------------------------------
+
SvStream& Color::Read( SvStream& rIStm, sal_Bool bNewFormat )
{
if ( bNewFormat )