include/svx/PaletteManager.hxx         |    4 ----
 svx/source/tbxctrls/PaletteManager.cxx |   23 +++++------------------
 svx/source/tbxctrls/tbcontrl.cxx       |   16 +++-------------
 3 files changed, 8 insertions(+), 35 deletions(-)

New commits:
commit 1305aaefa4ec327556f6bff237604b5f9689b936
Author: Maxim Monastirsky <momonas...@gmail.com>
Date:   Sun Jun 24 22:37:01 2018 +0300

    Kill the useless PaletteManager "last color" thing
    
    Change-Id: Iafd4677460bf6ee2cc5bb7cd3f67c2719865a151
    Reviewed-on: https://gerrit.libreoffice.org/56360
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>

diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index ed8f639374f3..486edd94b4a2 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -43,7 +43,6 @@ class SVX_DLLPUBLIC PaletteManager
     svx::ToolboxButtonColorUpdater* mpBtnUpdater;
 
     XColorListRef           pColorList;
-    Color                   mLastColor;
     std::deque<NamedColor>  maRecentColors;
     std::vector<std::unique_ptr<Palette>> m_Palettes;
 
@@ -68,9 +67,6 @@ public:
 
     long        GetColorCount();
     long        GetRecentColorCount();
-
-    const Color& GetLastColor();
-    void        SetLastColor(const Color& rLastColor);
     void        AddRecentColor(const Color& rRecentColor, const OUString& 
rColorName, bool bFront = true);
 
     void        SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater);
diff --git a/svx/source/tbxctrls/PaletteManager.cxx 
b/svx/source/tbxctrls/PaletteManager.cxx
index 27c84cdbfd56..40f99c9074ab 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -43,7 +43,6 @@ PaletteManager::PaletteManager() :
     mnCurrentPalette(0),
     mnColorCount(0),
     mpBtnUpdater(nullptr),
-    mLastColor(COL_AUTO),
     maColorSelectFunction(PaletteManager::DispatchColorCommand),
     m_context(comphelper::getProcessComponentContext())
 {
@@ -307,16 +306,6 @@ long PaletteManager::GetRecentColorCount()
     return maRecentColors.size();
 }
 
-const Color& PaletteManager::GetLastColor()
-{
-    return mLastColor;
-}
-
-void PaletteManager::SetLastColor(const Color& rLastColor)
-{
-    mLastColor = rLastColor;
-}
-
 void PaletteManager::AddRecentColor(const Color& rRecentColor, const OUString& 
rName, bool bFront)
 {
     auto itColor = std::find_if(maRecentColors.begin(),
@@ -348,8 +337,6 @@ void PaletteManager::AddRecentColor(const Color& 
rRecentColor, const OUString& r
 void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater)
 {
     mpBtnUpdater = pBtnUpdater;
-    if (mpBtnUpdater)
-        mLastColor = mpBtnUpdater->GetCurrentColor();
 }
 
 void PaletteManager::SetColorSelectFunction(const std::function<void(const 
OUString&, const NamedColor&)>& aColorSelectFunction)
@@ -366,12 +353,12 @@ void PaletteManager::PopupColorPicker(weld::Window* 
pParent, const OUString& aCo
     aColorDlg.SetMode(svtools::ColorPickerMode::Modify);
     if (aColorDlg.Execute(pParent) == RET_OK)
     {
+        Color aLastColor = aColorDlg.GetColor();
         if (mpBtnUpdater)
-            mpBtnUpdater->Update( aColorDlg.GetColor() );
-        mLastColor = aColorDlg.GetColor();
-        OUString sColorName = ("#" + 
mLastColor.AsRGBHexString().toAsciiUpperCase());
-        NamedColor aNamedColor = std::make_pair(mLastColor, sColorName);
-        AddRecentColor(mLastColor, sColorName);
+            mpBtnUpdater->Update(aLastColor);
+        OUString sColorName = ("#" + 
aLastColor.AsRGBHexString().toAsciiUpperCase());
+        NamedColor aNamedColor = std::make_pair(aLastColor, sColorName);
+        AddRecentColor(aLastColor, sColorName);
         maColorSelectFunction(aCommandCopy, aNamedColor);
     }
 }
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e8694d85d223..ad1d096aa95f 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2850,7 +2850,6 @@ void SvxColorToolBoxControl::EnsurePaletteManager()
     {
         m_xPaletteManager.reset(new PaletteManager);
         m_xPaletteManager->SetBtnUpdater(m_xBtnUpdater.get());
-        m_xPaletteManager->SetLastColor(m_xBtnUpdater->GetCurrentColor());
     }
 }
 
@@ -2892,8 +2891,6 @@ VclPtr<vcl::Window> 
SvxColorToolBoxControl::createPopupWindow( vcl::Window* pPar
 IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void)
 {
     m_xBtnUpdater->Update(rColor.first);
-    if (m_xPaletteManager)
-        m_xPaletteManager->SetLastColor(rColor.first);
 }
 
 void SvxColorToolBoxControl::statusChanged( const 
css::frame::FeatureStateEvent& rEvent )
@@ -2920,8 +2917,6 @@ void SvxColorToolBoxControl::statusChanged( const 
css::frame::FeatureStateEvent&
             rEvent.State >>= aColor;
         }
         m_xBtnUpdater->Update( aColor );
-        if (m_xPaletteManager)
-            m_xPaletteManager->SetLastColor(aColor);
     }
     else if ( rEvent.State >>= bValue )
         pToolBox->CheckItem( nId, bValue );
@@ -2937,6 +2932,7 @@ void SvxColorToolBoxControl::execute(sal_Int16 
/*nSelectModifier*/)
     }
 
     OUString aCommand = m_aCommandURL;
+    Color aColor = m_xBtnUpdater->GetCurrentColor();
 
     switch( m_nSlotId )
     {
@@ -2949,14 +2945,12 @@ void SvxColorToolBoxControl::execute(sal_Int16 
/*nSelectModifier*/)
             break;
     }
 
-    EnsurePaletteManager();
-    Color aColor = m_xPaletteManager->GetLastColor();
-
     auto aArgs( comphelper::InitPropertySequence( {
         { m_aCommandURL.copy(5), css::uno::makeAny(aColor) }
     } ) );
     dispatchCommand( aCommand, aArgs );
 
+    EnsurePaletteManager();
     OUString sColorName = ("#" + aColor.AsRGBHexString().toAsciiUpperCase());
     m_xPaletteManager->AddRecentColor(aColor, sColorName);
 }
@@ -2980,8 +2974,7 @@ void SvxColorToolBoxControl::updateImage()
     if ( !!aImage )
     {
         pToolBox->SetItemImage( nId, aImage );
-        EnsurePaletteManager();
-        m_xBtnUpdater->Update(m_xPaletteManager->GetLastColor(), true);
+        m_xBtnUpdater->Update(m_xBtnUpdater->GetCurrentColor(), true);
     }
 }
 
@@ -3293,7 +3286,6 @@ void SvxColorListBox::EnsurePaletteManager()
     {
         m_xPaletteManager.reset(new PaletteManager);
         m_xPaletteManager->SetColorSelectFunction(std::ref(m_aColorWrapper));
-        m_xPaletteManager->SetLastColor(m_aSelectedColor.first);
     }
 }
 
@@ -3408,8 +3400,6 @@ void SvxColorListBox::createColorWindow()
 void SvxColorListBox::Selected(const NamedColor& rColor)
 {
     ShowPreview(rColor);
-    if (m_xPaletteManager)
-        m_xPaletteManager->SetLastColor(rColor.first);
     m_aSelectedColor = rColor;
     if (m_aSelectedLink.IsSet())
         m_aSelectedLink.Call(*this);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to