Kaydet (Commit) d643cad3 authored tarafından Noel Grandin's avatar Noel Grandin

convert ColorModel to scoped enum

and move it into CUI, since it is only used there

Change-Id: I6f8dcfc8d705aa2de2a05eec16f087f17c488872
üst fde3facb
...@@ -711,6 +711,12 @@ public: ...@@ -711,6 +711,12 @@ public:
/************************************************************************/ /************************************************************************/
enum class ColorModel
{
RGB,
CMYK // can be extend with more models, e.g. HSV
};
struct SvxColorTabPageShadow; struct SvxColorTabPageShadow;
class SvxColorTabPage : public SfxTabPage class SvxColorTabPage : public SfxTabPage
{ {
......
...@@ -89,7 +89,7 @@ SvxColorTabPage::SvxColorTabPage(vcl::Window* pParent, const SfxItemSet& rInAttr ...@@ -89,7 +89,7 @@ SvxColorTabPage::SvxColorTabPage(vcl::Window* pParent, const SfxItemSet& rInAttr
, aXFillColorItem( OUString(), Color( COL_BLACK ) ) , aXFillColorItem( OUString(), Color( COL_BLACK ) )
, aXFillAttr( static_cast<XOutdevItemPool*>( rInAttrs.GetPool() )) , aXFillAttr( static_cast<XOutdevItemPool*>( rInAttrs.GetPool() ))
, rXFSet( aXFillAttr.GetItemSet() ) , rXFSet( aXFillAttr.GetItemSet() )
, eCM( CM_RGB ) , eCM( ColorModel::RGB )
, m_context(comphelper::getProcessComponentContext()) , m_context(comphelper::getProcessComponentContext())
{ {
get(m_pSelectPalette, "paletteselector"); get(m_pSelectPalette, "paletteselector");
...@@ -280,7 +280,7 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) ...@@ -280,7 +280,7 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& )
const SfxPoolItem* pPoolItem = nullptr; const SfxPoolItem* pPoolItem = nullptr;
if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
{ {
SetColorModel( CM_RGB ); SetColorModel( ColorModel::RGB );
ChangeColorModel(); ChangeColorModel();
aPreviousColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue(); aPreviousColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue();
...@@ -406,7 +406,7 @@ VclPtr<SfxTabPage> SvxColorTabPage::Create( vcl::Window* pWindow, ...@@ -406,7 +406,7 @@ VclPtr<SfxTabPage> SvxColorTabPage::Create( vcl::Window* pWindow,
// is called when the content of the MtrFields is changed for color values // is called when the content of the MtrFields is changed for color values
IMPL_LINK_TYPED(SvxColorTabPage, ModifiedHdl_Impl, Edit&, rEdit, void) IMPL_LINK_TYPED(SvxColorTabPage, ModifiedHdl_Impl, Edit&, rEdit, void)
{ {
if (eCM == CM_RGB) if (eCM == ColorModel::RGB)
{ {
// read current MtrFields, if cmyk, then k-value as transparency // read current MtrFields, if cmyk, then k-value as transparency
if(&rEdit == m_pHexcustom) if(&rEdit == m_pHexcustom)
...@@ -427,7 +427,7 @@ IMPL_LINK_TYPED(SvxColorTabPage, ModifiedHdl_Impl, Edit&, rEdit, void) ...@@ -427,7 +427,7 @@ IMPL_LINK_TYPED(SvxColorTabPage, ModifiedHdl_Impl, Edit&, rEdit, void)
(sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pCcustom->GetValue() ), (sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pCcustom->GetValue() ),
(sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pYcustom->GetValue() ), (sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pYcustom->GetValue() ),
(sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pMcustom->GetValue() ) ).GetColor() ); (sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pMcustom->GetValue() ) ).GetColor() );
ConvertColorValues (aCurrentColor, CM_RGB); ConvertColorValues (aCurrentColor, ColorModel::RGB);
} }
rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) );
...@@ -626,14 +626,14 @@ void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell) ...@@ -626,14 +626,14 @@ void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell)
{ {
switch (eModell) switch (eModell)
{ {
case CM_RGB: case ColorModel::RGB:
{ {
CmykToRgb_Impl (rColor, (sal_uInt16)rColor.GetTransparency() ); CmykToRgb_Impl (rColor, (sal_uInt16)rColor.GetTransparency() );
rColor.SetTransparency ((sal_uInt8) 0); rColor.SetTransparency ((sal_uInt8) 0);
} }
break; break;
case CM_CMYK: case ColorModel::CMYK:
{ {
sal_uInt16 nK; sal_uInt16 nK;
RgbToCmyk_Impl (rColor, nK ); RgbToCmyk_Impl (rColor, nK );
...@@ -645,9 +645,9 @@ void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell) ...@@ -645,9 +645,9 @@ void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell)
IMPL_LINK_TYPED(SvxColorTabPage, SelectColorModeHdl_Impl, RadioButton&, rRadioButton, void) IMPL_LINK_TYPED(SvxColorTabPage, SelectColorModeHdl_Impl, RadioButton&, rRadioButton, void)
{ {
if( &rRadioButton == m_pRbRGB ) if( &rRadioButton == m_pRbRGB )
eCM = CM_RGB; eCM = ColorModel::RGB;
if( &rRadioButton == m_pRbCMYK ) if( &rRadioButton == m_pRbCMYK )
eCM = CM_CMYK; eCM = ColorModel::CMYK;
ChangeColorModel(); ChangeColorModel();
UpdateColorValues(); UpdateColorValues();
} }
...@@ -667,9 +667,9 @@ void SvxColorTabPage::SetColorModel( ColorModel eModel ) ...@@ -667,9 +667,9 @@ void SvxColorTabPage::SetColorModel( ColorModel eModel )
{ {
m_pRbRGB->SetState(false); m_pRbRGB->SetState(false);
m_pRbCMYK->SetState(false); m_pRbCMYK->SetState(false);
if(eModel == CM_RGB) if(eModel == ColorModel::RGB)
m_pRbRGB->SetState(true); m_pRbRGB->SetState(true);
if(eModel == CM_CMYK) if(eModel == ColorModel::CMYK)
m_pRbCMYK->SetState(true); m_pRbCMYK->SetState(true);
} }
...@@ -677,7 +677,7 @@ void SvxColorTabPage::ChangeColorModel() ...@@ -677,7 +677,7 @@ void SvxColorTabPage::ChangeColorModel()
{ {
switch( eCM ) switch( eCM )
{ {
case CM_RGB: case ColorModel::RGB:
{ {
m_pRGBcustom->Show(); m_pRGBcustom->Show();
m_pRGBpreset->Show(); m_pRGBpreset->Show();
...@@ -686,7 +686,7 @@ void SvxColorTabPage::ChangeColorModel() ...@@ -686,7 +686,7 @@ void SvxColorTabPage::ChangeColorModel()
} }
break; break;
case CM_CMYK: case ColorModel::CMYK:
{ {
m_pCMYKcustom->Show(); m_pCMYKcustom->Show();
m_pCMYKpreset->Show(); m_pCMYKpreset->Show();
...@@ -699,7 +699,7 @@ void SvxColorTabPage::ChangeColorModel() ...@@ -699,7 +699,7 @@ void SvxColorTabPage::ChangeColorModel()
void SvxColorTabPage::UpdateColorValues() void SvxColorTabPage::UpdateColorValues()
{ {
if (eCM != CM_RGB) if (eCM != ColorModel::RGB)
{ {
ConvertColorValues (aPreviousColor, eCM ); ConvertColorValues (aPreviousColor, eCM );
ConvertColorValues (aCurrentColor, eCM); ConvertColorValues (aCurrentColor, eCM);
...@@ -713,8 +713,8 @@ void SvxColorTabPage::UpdateColorValues() ...@@ -713,8 +713,8 @@ void SvxColorTabPage::UpdateColorValues()
m_pKcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetTransparency() ) ); m_pKcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetTransparency() ) );
m_pKpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetTransparency() ) ); m_pKpreset->SetValue( ColorToPercent_Impl( aPreviousColor.GetTransparency() ) );
ConvertColorValues (aPreviousColor, CM_RGB); ConvertColorValues (aPreviousColor, ColorModel::RGB);
ConvertColorValues (aCurrentColor, CM_RGB); ConvertColorValues (aCurrentColor, ColorModel::RGB);
} }
else else
{ {
...@@ -798,11 +798,11 @@ sal_uInt16 SvxColorTabPage::ColorToPercent_Impl( sal_uInt16 nColor ) ...@@ -798,11 +798,11 @@ sal_uInt16 SvxColorTabPage::ColorToPercent_Impl( sal_uInt16 nColor )
switch (eCM) switch (eCM)
{ {
case CM_RGB : case ColorModel::RGB :
nWert = nColor; nWert = nColor;
break; break;
case CM_CMYK: case ColorModel::CMYK:
nWert = (sal_uInt16) ( (double) nColor * 100.0 / 255.0 + 0.5 ); nWert = (sal_uInt16) ( (double) nColor * 100.0 / 255.0 + 0.5 );
break; break;
} }
...@@ -817,11 +817,11 @@ sal_uInt16 SvxColorTabPage::PercentToColor_Impl( sal_uInt16 nPercent ) ...@@ -817,11 +817,11 @@ sal_uInt16 SvxColorTabPage::PercentToColor_Impl( sal_uInt16 nPercent )
switch (eCM) switch (eCM)
{ {
case CM_RGB : case ColorModel::RGB :
nWert = nPercent; nWert = nPercent;
break; break;
case CM_CMYK: case ColorModel::CMYK:
nWert = (sal_uInt16) ( (double) nPercent * 255.0 / 100.0 + 0.5 ); nWert = (sal_uInt16) ( (double) nPercent * 255.0 / 100.0 + 0.5 );
break; break;
} }
...@@ -833,7 +833,7 @@ sal_uInt16 SvxColorTabPage::PercentToColor_Impl( sal_uInt16 nPercent ) ...@@ -833,7 +833,7 @@ sal_uInt16 SvxColorTabPage::PercentToColor_Impl( sal_uInt16 nPercent )
void SvxColorTabPage::FillUserData() void SvxColorTabPage::FillUserData()
{ {
// the color model is saved in the Ini-file // the color model is saved in the Ini-file
SetUserData( OUString::number( eCM ) ); SetUserData( OUString::number( (int)eCM ) );
} }
......
...@@ -21,12 +21,6 @@ ...@@ -21,12 +21,6 @@
#include <o3tl/typed_flags_set.hxx> #include <o3tl/typed_flags_set.hxx>
enum ColorModel
{
CM_RGB,
CM_CMYK // can be extend with more models, e.g. HSV
};
enum class ChangeType enum class ChangeType
{ {
NONE = 0x00, NONE = 0x00,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment