From c05f35f4f56a1e65b92f4b1bc43b0fa6138d209c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 22 May 2017 12:05:17 +0100 Subject: Resolves: tdf#107981 SID_FM_CTL_PROPERTIES colorbox needs a 'default' entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we don't need MakeHexStr either, the colorbox will do that on its own Reviewed-on: https://gerrit.libreoffice.org/37898 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara (cherry picked from commit 7539c77fd49889015ad3a952009e33fac5324df6) Change-Id: Ifad523092c0f15cd51d0d829790c0cec1c96bb53 Reviewed-on: https://gerrit.libreoffice.org/37905 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- extensions/source/propctrlr/standardcontrol.cxx | 36 ++++++------------------- svx/source/tbxctrls/tbcontrl.cxx | 9 +++++++ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index af15abfb508e..b99445c6e315 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -642,47 +642,27 @@ namespace pcr #define LB_DEFAULT_COUNT 20 - OUString MakeHexStr(sal_uInt32 nVal, sal_Int32 nLength) - { - OUStringBuffer aStr; - while (nVal>0) - { - char c = char(nVal & 0x000F); - nVal >>= 4; - if (c<=9) c += '0'; - else c += 'A' - 10; - aStr.insert(0, c); - } - while (aStr.getLength() < nLength) aStr.insert(0, '0'); - return aStr.makeStringAndClear(); - } - OColorControl::OColorControl(vcl::Window* pParent, WinBits nWinStyle) : OColorControl_Base(PropertyControlType::ColorListBox, pParent, nWinStyle) { + getTypedControlWindow()->SetSlotId(SID_FM_CTL_PROPERTIES); } void SAL_CALL OColorControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException, std::exception) { - if ( _rValue.hasValue() ) - { - css::util::Color nColor = COL_TRANSPARENT; + css::util::Color nColor = COL_TRANSPARENT; + if (_rValue.hasValue()) _rValue >>= nColor; - ::Color aRgbCol((ColorData)nColor); - getTypedControlWindow()->SelectEntry(std::make_pair(aRgbCol, MakeHexStr(nColor, 8))); - } - else - getTypedControlWindow()->SetNoSelection(); + getTypedControlWindow()->SelectEntry(::Color((ColorData)nColor)); } Any SAL_CALL OColorControl::getValue() throw (RuntimeException, std::exception) { Any aPropValue; - if (!getTypedControlWindow()->IsNoSelection()) - { - ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor(); - aPropValue <<= (css::util::Color)aRgbCol.GetColor(); - } + ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor(); + if (aRgbCol == COL_TRANSPARENT) + return aPropValue; + aPropValue <<= (css::util::Color)aRgbCol.GetColor(); return aPropValue; } diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 95ec9f400143..7b5a6cfd7843 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1300,6 +1300,11 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand, mpButtonAutoColor->SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) ); break; } + case SID_FM_CTL_PROPERTIES: + { + mpButtonAutoColor->SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) ); + break; + } default: { mpButtonAutoColor->Hide(); @@ -1499,6 +1504,10 @@ namespace aColor = COL_TRANSPARENT; sColorName = SVX_RESSTR(RID_SVXSTR_TRANSPARENT); break; + case SID_FM_CTL_PROPERTIES: + aColor = COL_TRANSPARENT; + sColorName = SVX_RESSTR(RID_SVXSTR_AUTOMATIC); + break; case SID_ATTR_CHAR_COLOR: case SID_ATTR_CHAR_COLOR2: case SID_EXTRUSION_3D_COLOR: -- cgit v1.2.3