diff options
-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) |