summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-12-08 20:32:30 +0100
committerEike Rathke <erack@redhat.com>2017-12-08 20:35:20 +0100
commit39854837073158555ee26bee9254d1e5ac36a215 (patch)
tree7d615de433f06c3462de82126504f6c2db7816f5 /sc/source
parent0898ced81a3129b4c36c08e0222f96c513f0fd77 (diff)
Slightly change state method logic, tdf#86085 follow-up
It is unnecessary to obtain the SvNumberformat, we already have the type information of the selection, so use that if the item state is not DONTCARE. Also, SfxRequest::Done() needs to be called in the excute method to flag the slot execution as not cancelled. Change-Id: I2fbb8df9b8233fc45552540b996bc6b45a16cbc2
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/ui/view/formatsh.cxx36
1 files changed, 21 insertions, 15 deletions
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 3ffb0c2db725..5cd763ef286d 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -1148,7 +1148,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
pDoc->GetNumberFormat(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo(), nCurrentNumberFormat);
const SvNumberformat* pEntry = pFormatter->GetEntry(nCurrentNumberFormat);
- if(pEntry)
+ if (pEntry)
eLanguage = pEntry->GetLanguage();
pFormatter->GetFormatSpecialInfo(nCurrentNumberFormat, bThousand, bNegRed, nPrecision, nLeadZeroes);
@@ -1164,6 +1164,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
aSet.Put(SfxBoolItem(nSlot, bThousand));
rBindings.Invalidate(nSlot);
+ rReq.Done();
}
break;
case SID_NUMBER_FORMAT:
@@ -2524,23 +2525,28 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
{
case SID_NUMBER_THOUSANDS:
{
- const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
- if ( SfxItemState::DONTCARE != rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) &&
- pFormatEntry && ( pFormatEntry->GetType() &
- ( css::util::NumberFormat::NUMBER |
- css::util::NumberFormat::PERCENT |
- css::util::NumberFormat::CURRENCY |
- css::util::NumberFormat::FRACTION ) ) )
+ bool bEnable = (SfxItemState::DONTCARE != rAttrSet.GetItemState( ATTR_VALUE_FORMAT ));
+ if (bEnable)
{
- bool bThousand( false );
- bool bNegRed( false );
- sal_uInt16 nPrecision( 0 );
- sal_uInt16 nLeadZeroes( 0 );
- pFormatter->GetFormatSpecialInfo( nNumberFormat, bThousand, bNegRed, nPrecision, nLeadZeroes );
- rSet.Put( SfxBoolItem( nWhich, bThousand ) );
+ bEnable = ((nType != css::util::NumberFormat::ALL) && (nType &
+ (css::util::NumberFormat::NUMBER |
+ css::util::NumberFormat::PERCENT |
+ css::util::NumberFormat::CURRENCY |
+ css::util::NumberFormat::FRACTION)));
+ if (bEnable)
+ {
+ bool bThousand( false );
+ bool bNegRed( false );
+ sal_uInt16 nPrecision( 0 );
+ sal_uInt16 nLeadZeroes( 0 );
+ pFormatter->GetFormatSpecialInfo( nNumberFormat, bThousand, bNegRed, nPrecision, nLeadZeroes);
+ rSet.Put( SfxBoolItem( nWhich, bThousand));
+ }
}
- else
+ if (!bEnable)
+ {
rSet.DisableItem( nWhich );
+ }
}
break;
case SID_NUMBER_FORMAT: