Kaydet (Commit) 864f3d6d authored tarafından Gulsah Kose's avatar Gulsah Kose Kaydeden (comit) Eike Rathke

tdf#86119 Generalize number format control.

Change-Id: I3d657aee45533d4c2cafb0c6ea8aab7a77732d2d
Signed-off-by: 's avatarGulsah Kose <gulsah.1004@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/38434Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst afb8a2f4
...@@ -1127,9 +1127,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) ...@@ -1127,9 +1127,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
rReq.Done(); rReq.Done();
break; break;
case SID_NUMBER_STANDARD: case SID_NUMBER_STANDARD:
if (!(nType & css::util::NumberFormat::NUMBER)) pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
rBindings.Invalidate( nSlot );
rReq.Done(); rReq.Done();
break; break;
case SID_NUMBER_INCDEC: case SID_NUMBER_INCDEC:
...@@ -2485,9 +2483,14 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) ...@@ -2485,9 +2483,14 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
ScDocument* pDoc = pViewData->GetDocument(); ScDocument* pDoc = pViewData->GetDocument();
short nType = GetCurrentNumberFormatType(); short nType = GetCurrentNumberFormatType();
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item&>(rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue();
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
NfIndexTableOffset nOffset = pFormatter->GetIndexTableOffset(nNumberFormat);
SfxWhichIter aIter(rSet); SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich(); sal_uInt16 nWhich = aIter.FirstWhich();
while ( nWhich ) while ( nWhich )
{ {
switch ( nWhich ) switch ( nWhich )
...@@ -2495,12 +2498,8 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) ...@@ -2495,12 +2498,8 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
case SID_NUMBER_FORMAT: case SID_NUMBER_FORMAT:
// symphony version with format interpretation // symphony version with format interpretation
{ {
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
if(SfxItemState::DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT)) if(SfxItemState::DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT))
{ {
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item&>(rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue();
bool bThousand(false); bool bThousand(false);
bool bNegRed(false); bool bNegRed(false);
sal_uInt16 nPrecision(0); sal_uInt16 nPrecision(0);
...@@ -2543,11 +2542,8 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) ...@@ -2543,11 +2542,8 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
case SID_NUMBER_TYPE_FORMAT: case SID_NUMBER_TYPE_FORMAT:
{ {
sal_Int16 aFormatCode = -1; sal_Int16 aFormatCode = -1;
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SfxItemState::DEFAULT ) //Modify for more robust if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SfxItemState::DEFAULT ) //Modify for more robust
{ {
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter );
const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat ); const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
bool bStandard = false; bool bStandard = false;
...@@ -2633,18 +2629,10 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) ...@@ -2633,18 +2629,10 @@ void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::TIME)) ); rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::TIME)) );
break; break;
case SID_NUMBER_TWODEC: case SID_NUMBER_TWODEC:
{ rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::NUMBER) && nOffset == NF_NUMBER_1000DEC2 ) );
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; break;
case SID_NUMBER_STANDARD: case SID_NUMBER_STANDARD:
{ rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::NUMBER) && (nNumberFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) );
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 == 0 ) );
}
break; break;
} }
nWhich = aIter.NextWhich(); nWhich = aIter.NextWhich();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment