summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-08-31 09:25:34 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-08-31 09:35:34 +0100
commit6f11653287ad41df935bf25ffd6ffe8e7acb3bb1 (patch)
tree5b5beb327402a60079bf44fcc93f2f6337d63223 /svx
parent2e31a37b87397e6d77cbffc127a0998f54e7f35c (diff)
Resolves: tdf#98097 no tooltip for colors in "Recent" colors area
cause the tip is the color name and that's not stored, so store the name when we have one, generate a #rrggbb if there isn't one and on loading the names, "repair" the names if the names didnt't exist because this option didn't exist when the colors were last saved Change-Id: I33d373081e8a5a46ac585bc55fe449dba0519f99
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx42
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx2
2 files changed, 23 insertions, 21 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index c2c9748cf461..bf78e310f135 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -126,11 +126,10 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
css::uno::Sequence< sal_Int32 > CustomColorList( officecfg::Office::Common::UserColors::CustomColor::get() );
css::uno::Sequence< OUString > CustomColorNameList( officecfg::Office::Common::UserColors::CustomColorName::get() );
int nIx = 1;
- for( int i = 0;i < CustomColorList.getLength();i++ )
+ for (int i = 0; i < CustomColorList.getLength(); ++i)
{
- Color aColor( CustomColorList[i] );
- OUString aColorName( CustomColorNameList[i] );
- rColorSet.InsertItem( nIx, aColor, aColorName );
+ Color aColor(CustomColorList[i]);
+ rColorSet.InsertItem(nIx, aColor, CustomColorNameList[i]);
++nIx;
}
}
@@ -152,18 +151,17 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
void PaletteManager::ReloadRecentColorSet(SvxColorValueSet& rColorSet)
{
maRecentColors.clear();
- css::uno::Sequence< sal_Int32 > Colorlist(officecfg::Office::Common::UserColors::RecentColor::get());
- for(int i = 0;i < Colorlist.getLength();i++)
- {
- Color aColor( Colorlist[i] );
- maRecentColors.push_back( aColor );
- }
rColorSet.Clear();
+ css::uno::Sequence< sal_Int32 > Colorlist(officecfg::Office::Common::UserColors::RecentColor::get());
+ css::uno::Sequence< OUString > ColorNamelist(officecfg::Office::Common::UserColors::RecentColorName::get());
int nIx = 1;
- for(std::deque<Color>::const_iterator it = maRecentColors.begin();
- it != maRecentColors.end(); ++it)
+ const bool bHasColorNames = Colorlist.getLength() == ColorNamelist.getLength();
+ for (int i = 0; i < Colorlist.getLength(); ++i)
{
- rColorSet.InsertItem(nIx, *it, "");
+ Color aColor(Colorlist[i]);
+ OUString sColorName = bHasColorNames ? ColorNamelist[i] : (OUString("#") + aColor.AsRGBHexString().toAsciiUpperCase());
+ maRecentColors.push_back(std::make_pair(aColor, sColorName));
+ rColorSet.InsertItem(nIx, aColor, sColorName);
++nIx;
}
}
@@ -255,24 +253,28 @@ void PaletteManager::SetLastColor(const Color& rLastColor)
mLastColor = rLastColor;
}
-void PaletteManager::AddRecentColor(const Color& rRecentColor)
+void PaletteManager::AddRecentColor(const Color& rRecentColor, const OUString& rName)
{
- std::deque<Color>::iterator itColor =
- std::find(maRecentColors.begin(), maRecentColors.end(), rRecentColor);
+ auto itColor = std::find_if(maRecentColors.begin(),
+ maRecentColors.end(),
+ [rRecentColor] (const auto &a) { return a.first == rRecentColor; });
// if recent color to be added is already in list, remove it
if( itColor != maRecentColors.end() )
maRecentColors.erase( itColor );
- maRecentColors.push_front( rRecentColor );
+ maRecentColors.push_front(std::make_pair(rRecentColor, rName));
if( maRecentColors.size() > mnMaxRecentColors )
maRecentColors.pop_back();
css::uno::Sequence< sal_Int32 > aColorList(maRecentColors.size());
- for(std::deque<Color>::size_type i = 0;i < maRecentColors.size();i++)
+ css::uno::Sequence< OUString > aColorNameList(maRecentColors.size());
+ for (size_t i = 0; i < maRecentColors.size(); ++i)
{
- aColorList[i] = static_cast<sal_Int32>(maRecentColors[i].GetColor());
+ aColorList[i] = static_cast<sal_Int32>(maRecentColors[i].first.GetColor());
+ aColorNameList[i] = maRecentColors[i].second;
}
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
officecfg::Office::Common::UserColors::RecentColor::set(aColorList, batch);
+ officecfg::Office::Common::UserColors::RecentColorName::set(aColorNameList, batch);
batch->commit();
}
@@ -298,7 +300,7 @@ void PaletteManager::PopupColorPicker(const OUString& aCommand)
if (mpBtnUpdater)
mpBtnUpdater->Update( aColorDlg.GetColor() );
mLastColor = aColorDlg.GetColor();
- AddRecentColor( mLastColor );
+ AddRecentColor(mLastColor, (OUString("#") + mLastColor.AsRGBHexString().toAsciiUpperCase()));
maColorSelectFunction(aCommandCopy, mLastColor);
}
}
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index b8a68b755021..757a15b2cd44 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1397,7 +1397,7 @@ IMPL_LINK_TYPED(SvxColorWindow_Impl, SelectHdl, ValueSet*, pColorSet, void)
if ( pColorSet != mpRecentColorSet )
{
- mrPaletteManager.AddRecentColor( aColor );
+ mrPaletteManager.AddRecentColor(aColor, pColorSet->GetItemText(pColorSet->GetSelectItemId()));
if ( !IsInPopupMode() )
mrPaletteManager.ReloadRecentColorSet( *mpRecentColorSet );
}