incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1239729 [2/2] - in /incubator/ooo/trunk/main: cui/prj/ cui/source/dialogs/ cui/source/inc/ cui/source/tabpages/ cui/source/uno/ cui/source/uno/services/ cui/util/ default_images/res/ postprocess/packcomponents/ svtools/ svtools/inc/svtools...
Date Thu, 02 Feb 2012 17:19:14 GMT
Modified: incubator/ooo/trunk/main/svtools/Package_inc.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/Package_inc.mk?rev=1239729&r1=1239728&r2=1239729&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/Package_inc.mk (original)
+++ incubator/ooo/trunk/main/svtools/Package_inc.mk Thu Feb  2 17:19:13 2012
@@ -38,7 +38,6 @@ $(eval $(call gb_Package_add_file,svtool
 $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/brwhead.hxx,svtools/brwhead.hxx))
 $(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/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))

Modified: incubator/ooo/trunk/main/svtools/inc/svtools/colrdlg.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/inc/svtools/colrdlg.hxx?rev=1239729&r1=1239728&r2=1239729&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/inc/svtools/colrdlg.hxx (original)
+++ incubator/ooo/trunk/main/svtools/inc/svtools/colrdlg.hxx Thu Feb  2 17:19:13 2012
@@ -19,85 +19,39 @@
  * 
  *************************************************************/
 
-
-
 #ifndef _SV_COLRDLG_HXX
 #define _SV_COLRDLG_HXX
 
 #include "svtools/svtdllapi.h"
-#include <vcl/dialog.hxx>
-#ifndef _SV_BUTTON_HXX //autogen
-#include <vcl/button.hxx>
-#endif
-#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

Modified: incubator/ooo/trunk/main/svtools/source/dialogs/colrdlg.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/source/dialogs/colrdlg.cxx?rev=1239729&r1=1239728&r2=1239729&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/source/dialogs/colrdlg.cxx (original)
+++ incubator/ooo/trunk/main/svtools/source/dialogs/colrdlg.cxx Thu Feb  2 17:19:13 2012
@@ -26,299 +26,103 @@
 #ifndef GCC
 #endif
 
-#include <svtools/svtdata.hxx>
-#include "colrdlg.hrc"
-#include <svtools/colrdlg.hxx>
-
-// ---------------
-// - ColorDialog -
-// ---------------
-
-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 ) ),
-
-		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 ) ),
-
-		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 ) ),
-
-		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 ) ),
-
-		maCtlPreview	( this, SvtResId( CTL_PREVIEW ) ),
-		maCtlPreviewOld ( this, SvtResId( CTL_PREVIEW_OLD ) ),
-
-		maBtnOK			( this, SvtResId( BTN_OK ) ),
-		maBtnCancel		( this, SvtResId( BTN_CANCEL ) ),
-		maBtnHelp		( this, SvtResId( BTN_HELP ) )
+#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>
+#include <comphelper/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svtools/colrdlg.hxx>
+
+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;
+
+// ---------------
+// - ColorDialog -
+// ---------------
+
+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 );
-}
-
-// -----------------------------------------------------------------------
-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;
-}
-
-// -----------------------------------------------------------------------
-IMPL_LINK( SvColorDialog, ClickBtnHdl, void *, p )
+const Color& SvColorDialog::GetColor() const
 {
-	/*
-	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 )
-	{
-		sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
-		maColor = maColMixCtrl.GetItemColor( nPos );
-		maCtlColor.SetColor( maColor );
-		ColorModifyHdl( &maCtlColor );
-	}
-
-	return 0;
+	return maColor;
 }
 
 // -----------------------------------------------------------------------
-IMPL_LINK( SvColorDialog, ClickMixCtrlHdl, void *, EMPTYARG )
-{
-	sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
-	CMCPosition ePos = maColMixCtrl.GetCMCPosition();
-
-	if( ePos != CMC_OTHER )
-		maColMixCtrl.SetColor( ePos, maColor );
-	else
+
+void SvColorDialog::SetMode( sal_Int16 eMode )
+{
+    meMode = eMode;
+}
+
+// -----------------------------------------------------------------------
+
+short SvColorDialog::Execute()
+{
+    short ret = 0;
+    try
+	{
+        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 );
+                    }
+
+                }
+            }
+        }
+	}
+    catch(Exception&)
 	{
-		maColor = maColMixCtrl.GetItemColor( nPos );
-		maCtlColor.SetColor( maColor );
-		ColorModifyHdl( &maCtlColor );
+        OSL_ASSERT(false);
 	}
-
-	return 0;
+
+    return ret;
 }
 
 // -----------------------------------------------------------------------
-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 );
-}
-
+// eof

Modified: incubator/ooo/trunk/main/tools/inc/tools/color.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/tools/inc/tools/color.hxx?rev=1239729&r1=1239728&r2=1239729&view=diff
==============================================================================
--- incubator/ooo/trunk/main/tools/inc/tools/color.hxx (original)
+++ incubator/ooo/trunk/main/tools/inc/tools/color.hxx Thu Feb  2 17:19:13 2012
@@ -174,10 +174,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 );

Modified: incubator/ooo/trunk/main/tools/source/generic/color.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/tools/source/generic/color.cxx?rev=1239729&r1=1239728&r2=1239729&view=diff
==============================================================================
--- incubator/ooo/trunk/main/tools/source/generic/color.cxx (original)
+++ incubator/ooo/trunk/main/tools/source/generic/color.cxx Thu Feb  2 17:19:13 2012
@@ -259,6 +259,53 @@ ColorData Color::HSBtoRGB( sal_uInt16 nH
 
 // -----------------------------------------------------------------------
 
+// 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 )



Mime
View raw message