summaryrefslogtreecommitdiff
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
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
-rw-r--r--cui/source/tabpages/tpcolor.cxx2
-rw-r--r--include/svx/PaletteManager.hxx5
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs8
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx42
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx2
5 files changed, 34 insertions, 25 deletions
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 696379c76564..32c43f8199be 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -315,7 +315,7 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet )
if( ( nDlgType != 0 ) ||
( *pPageType == PageType::Color && !*pbAreaTP ) )
{
- maPaletteManager.AddRecentColor( aCurrentColor );
+ maPaletteManager.AddRecentColor(aCurrentColor, OUString("#") + aCurrentColor.AsRGBHexString().toAsciiUpperCase());
rSet->Put( XFillColorItem( OUString(), aCurrentColor ) );
rSet->Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
}
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index ceeea5d5a5e8..c527b85f0f88 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -48,7 +48,8 @@ class SVX_DLLPUBLIC PaletteManager
XColorListRef pColorList;
Color mLastColor;
- std::deque<Color> maRecentColors;
+ typedef std::pair<Color, OUString> color_and_name;
+ std::deque<color_and_name> maRecentColors;
std::vector<std::unique_ptr<Palette>> m_Palettes;
std::function<void(const OUString&, const Color&)> maColorSelectFunction;
@@ -73,7 +74,7 @@ public:
const Color& GetLastColor();
void SetLastColor(const Color& rLastColor);
- void AddRecentColor(const Color& rRecentColor);
+ void AddRecentColor(const Color& rRecentColor, const OUString& rColorName);
void SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater);
void PopupColorPicker(const OUString& aCommand);
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 394b00df4913..117f803a538a 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -3416,6 +3416,12 @@
</info>
<value/>
</prop>
+ <prop oor:name="RecentColorName" oor:type="oor:string-list" oor:nillable="false">
+ <info>
+ <desc>List of Recent color names</desc>
+ </info>
+ <value/>
+ </prop>
<prop oor:name="PaletteName" oor:type="xs:string" oor:nillable="false">
<info>
<desc>Name of selected palette</desc>
@@ -3430,7 +3436,7 @@
</prop>
<prop oor:name="CustomColorName" oor:type="oor:string-list" oor:nillable="false">
<info>
- <desc>List of Custom colors</desc>
+ <desc>List of Custom color names</desc>
</info>
<value/>
</prop>
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 );
}