diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-10-28 13:37:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-04 17:14:26 +0000 |
commit | 43bc3031483d172eccd72c3804e2d4fc2ef37de4 (patch) | |
tree | 991d98e8e61fae47ada28ba7a0b02e1d6c8e443f /svx/source/tbxctrls/PaletteManager.cxx | |
parent | 44523738f094ff3987e85ea0c47b8c636bbe5786 (diff) |
unify color selectors
Note: this removes the use of auto-color from writer's asian text grid, because
its always invisible as far as I can see in practice.
Change-Id: Ie850790d740a4d56c43015e493e093678cef3b4e
Diffstat (limited to 'svx/source/tbxctrls/PaletteManager.cxx')
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 3ba048559620..7f1d5a140437 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -254,18 +254,21 @@ void PaletteManager::SetLastColor(const Color& rLastColor) mLastColor = rLastColor; } -void PaletteManager::AddRecentColor(const Color& rRecentColor, const OUString& rName) +void PaletteManager::AddRecentColor(const Color& rRecentColor, const OUString& rName, bool bFront) { auto itColor = std::find_if(maRecentColors.begin(), maRecentColors.end(), - [rRecentColor] (const color_and_name &a) { return a.first == rRecentColor; }); + [rRecentColor] (const NamedColor &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(std::make_pair(rRecentColor, rName)); - if( maRecentColors.size() > mnMaxRecentColors ) + if (maRecentColors.size() == mnMaxRecentColors) maRecentColors.pop_back(); + if (bFront) + maRecentColors.push_front(std::make_pair(rRecentColor, rName)); + else + maRecentColors.push_back(std::make_pair(rRecentColor, rName)); css::uno::Sequence< sal_Int32 > aColorList(maRecentColors.size()); css::uno::Sequence< OUString > aColorNameList(maRecentColors.size()); for (size_t i = 0; i < maRecentColors.size(); ++i) @@ -285,7 +288,7 @@ void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater) mLastColor = mpBtnUpdater->GetCurrentColor(); } -void PaletteManager::SetColorSelectFunction(const std::function<void(const OUString&, const Color&)>& aColorSelectFunction) +void PaletteManager::SetColorSelectFunction(const std::function<void(const OUString&, const NamedColor&)>& aColorSelectFunction) { maColorSelectFunction = aColorSelectFunction; } @@ -302,12 +305,14 @@ void PaletteManager::PopupColorPicker(const OUString& aCommand) if (mpBtnUpdater) mpBtnUpdater->Update( aColorDlg.GetColor() ); mLastColor = aColorDlg.GetColor(); - AddRecentColor(mLastColor, ("#" + mLastColor.AsRGBHexString().toAsciiUpperCase())); - maColorSelectFunction(aCommandCopy, mLastColor); + OUString sColorName = ("#" + mLastColor.AsRGBHexString().toAsciiUpperCase()); + NamedColor aNamedColor = std::make_pair(mLastColor, sColorName); + AddRecentColor(mLastColor, sColorName); + maColorSelectFunction(aCommandCopy, aNamedColor); } } -void PaletteManager::DispatchColorCommand(const OUString& aCommand, const Color& rColor) +void PaletteManager::DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor) { using namespace css::uno; using namespace css::frame; @@ -323,7 +328,7 @@ void PaletteManager::DispatchColorCommand(const OUString& aCommand, const Color& Sequence<PropertyValue> aArgs(1); aArgs[0].Name = aObj.GetURLPath(); - aArgs[0].Value = makeAny(sal_Int32(rColor.GetColor())); + aArgs[0].Value = makeAny(sal_Int32(rColor.first.GetColor())); URL aTargetURL; aTargetURL.Complete = aCommand; |