diff options
Diffstat (limited to 'sc')
-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 ); } |