diff options
author | Gulsah Kose <gulsah.1004@gmail.com> | 2017-03-21 23:26:38 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2017-03-24 10:57:44 +0300 |
commit | 63a5e37a45e48b9f0c9ae2b632042e2a2d57dcbf (patch) | |
tree | 5e31083a149bf5cb4235e2dd0b4e9a6c0c555513 | |
parent | ad89ee8fe3d0d028fa0b61a9cbef54a112093177 (diff) |
tdf#86119 Fix toggle behaviour of SID_NUMBER_TWODEC.
Change-Id: If17935cbb35c1a57fe9ea4cfaca58385ed437842
Signed-off-by: Gulsah Kose <gulsah.1004@gmail.com>
-rw-r--r-- | sc/sdi/formatsh.sdi | 4 | ||||
-rw-r--r-- | sc/source/ui/view/formatsh.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/view/tabview3.cxx | 1 |
3 files changed, 21 insertions, 4 deletions
diff --git a/sc/sdi/formatsh.sdi b/sc/sdi/formatsh.sdi index 740e0024bdfd..0acabdc56999 100644 --- a/sc/sdi/formatsh.sdi +++ b/sc/sdi/formatsh.sdi @@ -106,8 +106,8 @@ interface FormatForSelection SID_CTLFONT_STATE [ StateMethod = GetTextDirectionState ; Export = FALSE; ] SID_ATTR_NUMBERFORMAT_VALUE [ ExecMethod = ExecuteNumFormat; StateMethod = GetNumFormatState;] - SID_NUMBER_FORMAT [ ExecMethod = ExecuteNumFormat; StateMethod = GetNumFormatState;] - SID_NUMBER_TWODEC [ ExecMethod = ExecuteNumFormat;] + SID_NUMBER_FORMAT [ ExecMethod = ExecuteNumFormat; StateMethod = GetNumFormatState; ] + SID_NUMBER_TWODEC [ ExecMethod = ExecuteNumFormat; StateMethod = GetNumFormatState; ] SID_NUMBER_SCIENTIFIC [ ExecMethod = ExecuteNumFormat; StateMethod = GetNumFormatState; ] SID_NUMBER_DATE [ ExecMethod = ExecuteNumFormat; StateMethod = GetNumFormatState; ] SID_NUMBER_CURRENCY [ ExecMethod = ExecuteNumFormat; StateMethod = GetNumFormatState; ] diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index d68d801f8034..db32a2bcbe82 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1036,9 +1036,18 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) switch ( nSlot ) { case SID_NUMBER_TWODEC: - pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER, 4 ); // Standard+4 = #.##0,00 + { + const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); + sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item&>(rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue(); + + if ((nType & css::util::NumberFormat::NUMBER) && nNumberFormat == 4) + pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER ); + else + pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER, 4 ); + rBindings.Invalidate( nSlot ); rReq.Done(); - break; + } + break; case SID_NUMBER_SCIENTIFIC: if ((nType & css::util::NumberFormat::SCIENTIFIC)) pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER ); @@ -2597,6 +2606,13 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) case SID_NUMBER_TIME: rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::TIME)) ); break; + case SID_NUMBER_TWODEC: + { + const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); + sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item&>(rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue(); + rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::NUMBER) && nNumberFormat == 4 ) ); + } + break; } nWhich = aIter.NextWhich(); } diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index abbd807a1ade..9c63bdb7d242 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -319,6 +319,7 @@ void ScTabView::InvalidateAttribs() rBindings.Invalidate( SID_NUMBER_DATE ); rBindings.Invalidate( SID_NUMBER_CURRENCY ); rBindings.Invalidate( SID_NUMBER_PERCENT ); + rBindings.Invalidate( SID_NUMBER_TWODEC ); rBindings.Invalidate( SID_NUMBER_TIME ); } |