diff options
| author | Rishabh Kumar <kris.kr296@gmail.com> | 2016-07-29 18:39:46 +0530 |
|---|---|---|
| committer | Rishabh Kumar <kris.kr296@yahoo.in> | 2016-07-29 14:52:56 +0000 |
| commit | 7f262a41017685709c288b57c8f03244e8c6149e (patch) | |
| tree | 130677ce67e64e47ab6341fa59a9ecac8fae2b63 | |
| parent | bb01247f71a46fb7cae18b51516096adfd059bbc (diff) | |
[GSoC] Fix recent colors in color popup widget
Save recent colors in user configuration.
Change-Id: I1637e9fe3150bd1892f72ff9df06dc2a7c3e1e9e
Reviewed-on: https://gerrit.libreoffice.org/27688
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Jenkins <ci@libreoffice.org>
| -rw-r--r-- | include/svx/PaletteManager.hxx | 2 | ||||
| -rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Common.xcs | 10 | ||||
| -rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 20 |
3 files changed, 30 insertions, 2 deletions
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx index 09adc3653a92..c8eb922df874 100644 --- a/include/svx/PaletteManager.hxx +++ b/include/svx/PaletteManager.hxx @@ -52,7 +52,7 @@ class PaletteManager std::vector<std::unique_ptr<Palette>> m_Palettes; std::function<void(const OUString&, const Color&)> maColorSelectFunction; - + css::uno::Reference < css::uno::XComponentContext > m_context; public: PaletteManager(); ~PaletteManager(); diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 2d9ea8cee647..5edc96c46edc 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -3406,6 +3406,16 @@ </info> </prop> </group> + <group oor:name="UserColors"> + <info> + <desc>Contains recent colors and custom colors</desc> + </info> + <prop oor:name="RecentColor" oor:type="oor:int-list" oor:nillable="false"> + <info> + <desc>List of Recent colors</desc> + </info> + <value/> </prop> + </group> <group oor:name="Help"> <info> <desc>Contains settings that specify the common help settings.</desc> diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 55123aa002f8..e14c172c371b 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -30,6 +30,8 @@ #include <vcl/settings.hxx> #include <stack> #include <set> +#include <cppu/unotype.hxx> +#include <officecfg/Office/Common.hxx> PaletteManager::PaletteManager() : mnMaxRecentColors(Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()), @@ -38,7 +40,8 @@ PaletteManager::PaletteManager() : mnColorCount(0), mpBtnUpdater(nullptr), mLastColor(COL_AUTO), - maColorSelectFunction(PaletteManager::DispatchColorCommand) + maColorSelectFunction(PaletteManager::DispatchColorCommand), + m_context(comphelper::getProcessComponentContext()) { SfxObjectShell* pDocSh = SfxObjectShell::Current(); if(pDocSh) @@ -134,6 +137,13 @@ 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(); int nIx = 1; for(std::deque<Color>::const_iterator it = maRecentColors.begin(); @@ -217,6 +227,14 @@ void PaletteManager::AddRecentColor(const Color& rRecentColor) maRecentColors.push_front( rRecentColor ); if( maRecentColors.size() > mnMaxRecentColors ) maRecentColors.pop_back(); + css::uno::Sequence< sal_Int32 > aColorList(maRecentColors.size()); + for(sal_uInt16 i = 0;i < maRecentColors.size();i++) + { + aColorList[i] = (int)maRecentColors[i].GetColor(); + } + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); + officecfg::Office::Common::UserColors::RecentColor::set(aColorList, batch); + batch->commit(); } void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater) |
