cui/source/inc/cuitabarea.hxx   |    4 -
 cui/source/tabpages/tpcolor.cxx |   91 ++++++++++++++++++++--------------------
 include/svx/Palette.hxx         |   31 +++++++++++--
 3 files changed, 76 insertions(+), 50 deletions(-)

New commits:
commit d7d2b172065f90aa2f61c0216f3722e868ae76a1
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon May 29 19:03:33 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Jun 1 18:26:14 2023 +0200

    prefix aPreviousColor and aCurrentColor in SvxColorTabPage
    
    Change-Id: I631ce120d7a2825c6d170f4b25ffefdd155e04e2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152396
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 7399f03eb0be..2d6c713236da 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -657,8 +657,8 @@ private:
 
     ColorModel          eCM;
 
-    Color               aPreviousColor;
-    NamedColor aCurrentColor;
+    Color m_aPreviousColor;
+    NamedColor m_aCurrentColor;
 
     PaletteManager maPaletteManager;
     SvxXRectPreview m_aCtlPreviewOld;
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index bdefcf10114d..056afe822e7a 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -238,25 +238,25 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet )
 {
     Color aColor = m_xValSetColorList->GetItemColor( 
m_xValSetColorList->GetSelectedItemId() );
     OUString sColorName;
-    if ( aCurrentColor.m_aColor == aColor )
+    if (m_aCurrentColor.m_aColor == aColor)
        sColorName = m_xValSetColorList->GetItemText( 
m_xValSetColorList->GetSelectedItemId() );
     else
-       sColorName = "#" + 
aCurrentColor.m_aColor.AsRGBHexString().toAsciiUpperCase();
-    maPaletteManager.AddRecentColor( aCurrentColor.m_aColor, sColorName );
-    XFillColorItem aColorItem( sColorName, aCurrentColor.m_aColor );
-    model::ThemeColorType eType = 
model::convertToThemeColorType(aCurrentColor.m_nThemeIndex);
+       sColorName = "#" + 
m_aCurrentColor.m_aColor.AsRGBHexString().toAsciiUpperCase();
+    maPaletteManager.AddRecentColor( m_aCurrentColor.m_aColor, sColorName );
+    XFillColorItem aColorItem( sColorName, m_aCurrentColor.m_aColor );
+    model::ThemeColorType eType = 
model::convertToThemeColorType(m_aCurrentColor.m_nThemeIndex);
     if (eType != model::ThemeColorType::Unknown)
     {
         aColorItem.getComplexColor().setSchemeColor(eType);
     }
     aColorItem.getComplexColor().clearTransformations();
-    if (aCurrentColor.m_nLumMod != 10000)
+    if (m_aCurrentColor.m_nLumMod != 10000)
     {
-        
aColorItem.getComplexColor().addTransformation({model::TransformationType::LumMod,
 aCurrentColor.m_nLumMod});
+        
aColorItem.getComplexColor().addTransformation({model::TransformationType::LumMod,
 m_aCurrentColor.m_nLumMod});
     }
-    if (aCurrentColor.m_nLumOff != 0)
+    if (m_aCurrentColor.m_nLumOff != 0)
     {
-        
aColorItem.getComplexColor().addTransformation({model::TransformationType::LumOff,
 aCurrentColor.m_nLumOff});
+        
aColorItem.getComplexColor().addTransformation({model::TransformationType::LumOff,
 m_aCurrentColor.m_nLumOff});
     }
     rSet->Put( aColorItem );
     rSet->Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
@@ -278,7 +278,7 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet )
     if ( nState >= SfxItemState::DEFAULT )
     {
         XFillColorItem aColorItem( rSet->Get( XATTR_FILLCOLOR ) );
-        aPreviousColor = aColorItem.GetColorValue();
+        m_aPreviousColor = aColorItem.GetColorValue();
         aNewColor = aColorItem.GetColorValue();
     }
 
@@ -304,12 +304,12 @@ std::unique_ptr<SfxTabPage> 
SvxColorTabPage::Create(weld::Container* pPage, weld
 IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void)
 {
     // read current MtrFields, if cmyk, then k-value as transparency
-    aCurrentColor.m_aColor = 
Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())),
+    m_aCurrentColor.m_aColor = 
Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())),
                           
static_cast<sal_uInt8>(PercentToColor_Impl(m_xGcustom->get_value())),
                           
static_cast<sal_uInt8>(PercentToColor_Impl(m_xBcustom->get_value())));
     UpdateColorValues();
 
-    rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) );
+    rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) );
     m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
 
     m_aCtlPreviewNew.Invalidate();
@@ -318,13 +318,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, 
weld::SpinButton&, void)
 IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, 
weld::MetricSpinButton&, void)
 {
     // read current MtrFields, if cmyk, then k-value as transparency
-    aCurrentColor.m_aColor = Color(ColorTransparency, 
static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))),
+    m_aCurrentColor.m_aColor = Color(ColorTransparency, 
static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))),
                           
static_cast<sal_uInt8>(PercentToColor_Impl(m_xCcustom->get_value(FieldUnit::NONE))),
                           
static_cast<sal_uInt8>(PercentToColor_Impl(m_xYcustom->get_value(FieldUnit::NONE))),
                           
static_cast<sal_uInt8>(PercentToColor_Impl(m_xMcustom->get_value(FieldUnit::NONE))));
-    ConvertColorValues (aCurrentColor.m_aColor, ColorModel::RGB);
+    ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB);
 
-    rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) );
+    rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) );
     m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
 
     m_aCtlPreviewNew.Invalidate();
@@ -332,10 +332,10 @@ IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, 
weld::MetricSpinButton
 
 IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl, weld::Entry&, void)
 {
-    aCurrentColor.m_aColor = m_xHexcustom->GetColor();
+    m_aCurrentColor.m_aColor = m_xHexcustom->GetColor();
     UpdateColorValues();
 
-    rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) );
+    rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) );
     m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
 
     m_aCtlPreviewNew.Invalidate();
@@ -389,13 +389,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, 
weld::Button&, void)
         sal_Int32 nSize = aCustomColorList.getLength();
         aCustomColorList.realloc( nSize + 1 );
         aCustomColorNameList.realloc( nSize + 1 );
-        aCustomColorList.getArray()[nSize] = sal_Int32(aCurrentColor.m_aColor);
+        aCustomColorList.getArray()[nSize] = 
sal_Int32(m_aCurrentColor.m_aColor);
         aCustomColorNameList.getArray()[nSize] = aName;
         
officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, 
batch);
         
officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList,
 batch);
         batch->commit();
         sal_uInt16 nId = m_xValSetColorList->GetItemId(nSize - 1);
-        m_xValSetColorList->InsertItem( nId + 1 , aCurrentColor.m_aColor, 
aName );
+        m_xValSetColorList->InsertItem( nId + 1 , m_aCurrentColor.m_aColor, 
aName );
         m_xValSetColorList->SelectItem( nId + 1 );
         m_xBtnDelete->set_sensitive(false);
         m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) 
);
@@ -409,13 +409,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl, 
weld::Button&, void)
 {
     SvColorDialog aColorDlg;
 
-    aColorDlg.SetColor (aCurrentColor.m_aColor);
+    aColorDlg.SetColor (m_aCurrentColor.m_aColor);
     aColorDlg.SetMode( svtools::ColorPickerMode::Modify );
 
     if (aColorDlg.Execute(GetFrameWeld()) == RET_OK)
     {
         Color aPreviewColor = aColorDlg.GetColor();
-        aCurrentColor.m_aColor = aPreviewColor;
+        m_aCurrentColor.m_aColor = aPreviewColor;
         UpdateColorValues( false );
         // fill ItemSet and pass it on to XOut
         rXFSet.Put( XFillColorItem( OUString(), aPreviewColor ) );
@@ -596,11 +596,14 @@ IMPL_STATIC_LINK_NOARG(SvxColorTabPage, 
OnMoreColorsClick, weld::Button&, void)
 
 void SvxColorTabPage::ChangeColor(const NamedColor &rNewColor, bool 
bUpdatePreset )
 {
-    aPreviousColor = rNewColor.m_aColor;
-    aCurrentColor = rNewColor;
+    m_aPreviousColor = rNewColor.m_aColor;
+    m_aCurrentColor = rNewColor;
     UpdateColorValues( bUpdatePreset );
     // fill ItemSet and pass it on to XOut
-    rXFSet.Put( XFillColorItem( OUString(), aCurrentColor.m_aColor ) );
+    XFillColorItem aItem(OUString(), m_aCurrentColor.m_aColor);
+    aItem.setComplexColor(m_aCurrentColor.getComplexColor());
+    rXFSet.Put(aItem);
+
     m_aCtlPreviewNew.SetAttributes(aXFillAttr.GetItemSet());
     m_aCtlPreviewNew.Invalidate();
 }
@@ -641,42 +644,42 @@ void SvxColorTabPage::UpdateColorValues( bool 
bUpdatePreset )
 {
     if (eCM != ColorModel::RGB)
     {
-        ConvertColorValues (aPreviousColor, eCM );
-        ConvertColorValues (aCurrentColor.m_aColor, eCM);
+        ConvertColorValues (m_aPreviousColor, eCM );
+        ConvertColorValues (m_aCurrentColor.m_aColor, eCM);
 
-        m_xCcustom->set_value( ColorToPercent_Impl( 
aCurrentColor.m_aColor.GetRed() ), FieldUnit::PERCENT );
-        m_xMcustom->set_value( ColorToPercent_Impl( 
aCurrentColor.m_aColor.GetBlue() ), FieldUnit::PERCENT );
-        m_xYcustom->set_value( ColorToPercent_Impl( 
aCurrentColor.m_aColor.GetGreen() ), FieldUnit::PERCENT );
-        m_xKcustom->set_value( ColorToPercent_Impl( 255 - 
aCurrentColor.m_aColor.GetAlpha() ), FieldUnit::PERCENT );
+        m_xCcustom->set_value( ColorToPercent_Impl( 
m_aCurrentColor.m_aColor.GetRed() ), FieldUnit::PERCENT );
+        m_xMcustom->set_value( ColorToPercent_Impl( 
m_aCurrentColor.m_aColor.GetBlue() ), FieldUnit::PERCENT );
+        m_xYcustom->set_value( ColorToPercent_Impl( 
m_aCurrentColor.m_aColor.GetGreen() ), FieldUnit::PERCENT );
+        m_xKcustom->set_value( ColorToPercent_Impl( 255 - 
m_aCurrentColor.m_aColor.GetAlpha() ), FieldUnit::PERCENT );
 
         if( bUpdatePreset )
         {
-            
m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetRed()),
+            
m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetRed()),
                                                         
Application::GetSettings().GetUILanguageTag()));
-            
m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetBlue()),
+            
m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetBlue()),
                                                         
Application::GetSettings().GetUILanguageTag()));
-            
m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetGreen()),
+            
m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetGreen()),
                                                         
Application::GetSettings().GetUILanguageTag()));
-            
m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - 
aPreviousColor.GetAlpha()),
+            
m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - 
m_aPreviousColor.GetAlpha()),
                                                         
Application::GetSettings().GetUILanguageTag()));
         }
 
-        ConvertColorValues (aPreviousColor, ColorModel::RGB);
-        ConvertColorValues (aCurrentColor.m_aColor, ColorModel::RGB);
+        ConvertColorValues (m_aPreviousColor, ColorModel::RGB);
+        ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB);
     }
     else
     {
-        m_xRcustom->set_value( ColorToPercent_Impl( 
aCurrentColor.m_aColor.GetRed() ) );
-        m_xGcustom->set_value( ColorToPercent_Impl( 
aCurrentColor.m_aColor.GetGreen() ) );
-        m_xBcustom->set_value( ColorToPercent_Impl( 
aCurrentColor.m_aColor.GetBlue() ) );
-        m_xHexcustom->SetColor( aCurrentColor.m_aColor );
+        m_xRcustom->set_value( ColorToPercent_Impl( 
m_aCurrentColor.m_aColor.GetRed() ) );
+        m_xGcustom->set_value( ColorToPercent_Impl( 
m_aCurrentColor.m_aColor.GetGreen() ) );
+        m_xBcustom->set_value( ColorToPercent_Impl( 
m_aCurrentColor.m_aColor.GetBlue() ) );
+        m_xHexcustom->SetColor( m_aCurrentColor.m_aColor );
 
         if( bUpdatePreset )
         {
-            
m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetRed())));
-            
m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetGreen())));
-            
m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetBlue())));
-            m_xHexpreset->SetColor( aPreviousColor );
+            
m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetRed())));
+            
m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetGreen())));
+            
m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetBlue())));
+            m_xHexpreset->SetColor( m_aPreviousColor );
         }
     }
 }
diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx
index ebdcb63a1377..4858b47140c4 100644
--- a/include/svx/Palette.hxx
+++ b/include/svx/Palette.hxx
@@ -16,8 +16,8 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#ifndef INCLUDED_SVX_PALETTE_HXX
-#define INCLUDED_SVX_PALETTE_HXX
+
+#pragma once
 
 #include <sal/config.h>
 
@@ -27,6 +27,9 @@
 #include <tools/color.hxx>
 #include <svx/svxdllapi.h>
 
+#include <docmodel/color/ComplexColor.hxx>
+#include <docmodel/theme/ThemeColorType.hxx>
+
 class SvxColorValueSet;
 
 struct SVXCORE_DLLPUBLIC NamedColor
@@ -43,6 +46,28 @@ struct SVXCORE_DLLPUBLIC NamedColor
         : m_aColor(rColor)
         , m_aName(rName)
     {}
+
+    model::ComplexColor getComplexColor()
+    {
+        model::ComplexColor aComplexColor;
+
+        auto eThemeColorType = model::convertToThemeColorType(m_nThemeIndex);
+
+        if (eThemeColorType != model::ThemeColorType::Unknown)
+        {
+            aComplexColor.setSchemeColor(eThemeColorType);
+
+            if (m_nLumMod != 10000)
+                
aComplexColor.addTransformation({model::TransformationType::LumMod, m_nLumMod});
+
+            if (m_nLumMod != 0)
+                
aComplexColor.addTransformation({model::TransformationType::LumOff, m_nLumOff});
+        }
+
+        aComplexColor.setFinalColor(m_aColor);
+
+        return aComplexColor;
+    }
 };
 
 typedef std::function<void(const OUString&, const NamedColor&)> 
ColorSelectFunction;
@@ -64,6 +89,4 @@ public:
     virtual Palette*            Clone() const = 0;
 };
 
-#endif // INCLUDED_SVX_PALETTE_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to