Kaydet (Commit) 1305aaef authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

Kill the useless PaletteManager "last color" thing

Change-Id: Iafd4677460bf6ee2cc5bb7cd3f67c2719865a151
Reviewed-on: https://gerrit.libreoffice.org/56360
Tested-by: Jenkins
Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst 2fd31c75
......@@ -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);
......
......@@ -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);
}
}
......
......@@ -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);
......
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