summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Brown <1st2be@gmail.com>2012-08-13 23:23:04 -0400
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2012-08-14 16:36:55 +0200
commit84a219020ca37a28799972cc60d9286c82ca7511 (patch)
tree3eb708be24292c172b2e7187b5f2d33788d63da5
parentc9cae5b599a951ce0a0aae67dff69b6b677b1e86 (diff)
fdo#51695 Check for Textformat
Numbers shouldn't be in NUMBERFORMAT_TEXT, but it can happen. When it does, IsNumberFormat call fails even when a number is entered. Also reordered other check logic and removed unused code. 1st2be@gmail.com -- Joseph Brown Change-Id: Icabd8b33b634c324302a970e137f8d74a2c20caf
-rw-r--r--chart2/source/controller/dialogs/tp_Scale.cxx53
1 files changed, 23 insertions, 30 deletions
diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx
index 5604785b85c4..d53a6cbaca29 100644
--- a/chart2/source/controller/dialogs/tp_Scale.cxx
+++ b/chart2/source/controller/dialogs/tp_Scale.cxx
@@ -559,14 +559,13 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
bool bDateAxis = chart2::AxisType::DATE == m_nAxisType;
- sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM);
- const SfxPoolItem *pPoolItem = NULL;
- if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET )
- nIndex = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue());
- else
- {
- OSL_FAIL( "Using Standard Language" );
- }
+ sal_uInt32 nMinMaxOriginFmt = aFmtFldMax.GetFormatKey();
+ if ((pNumFormatter->GetType(nMinMaxOriginFmt) &~ NUMBERFORMAT_DEFINED) == NUMBERFORMAT_TEXT)
+ nMinMaxOriginFmt = 0;
+ // numberformat_text cause numbers to fail being numbers... Shouldn't happen, but can.
+ sal_uInt32 nStepFmt = aFmtFldStepMain.GetFormatKey();
+ if ((pNumFormatter->GetType(nStepFmt) &~NUMBERFORMAT_DEFINED) == NUMBERFORMAT_TEXT)
+ nStepFmt = 0;
Control* pControl = NULL;
sal_uInt16 nErrStrId = 0;
@@ -593,42 +592,30 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
pControl = &aFmtFldMin;
nErrStrId = STR_BAD_LOGARITHM;
}
- else if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() &&
- fMin >= fMax)
- {
- pControl = &aFmtFldMin;
- nErrStrId = STR_MIN_GREATER_MAX;
- }
- else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0)
- {
- pControl = &aFmtFldStepMain;
- nErrStrId = STR_STEP_GT_ZERO;
- }
// check for entries that cannot be parsed for the current number format
else if ( aFmtFldMin.IsModified()
- && !aCbxAutoMin.IsChecked()
- && !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy))
+ && !aCbxAutoMin.IsChecked()
+ && !pNumFormatter->IsNumberFormat( aFmtFldMin.GetText(), nMinMaxOriginFmt, fDummy))
{
pControl = &aFmtFldMin;
nErrStrId = STR_INVALID_NUMBER;
}
- else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() &&
- !pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(),
- nIndex, fDummy))
+ else if ( aFmtFldMax.IsModified()
+ && !aCbxAutoMax.IsChecked()
+ && !pNumFormatter->IsNumberFormat( aFmtFldMax.GetText(), nMinMaxOriginFmt, fDummy))
{
pControl = &aFmtFldMax;
nErrStrId = STR_INVALID_NUMBER;
}
- else if ( !bDateAxis && aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() &&
- !pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(),
- nIndex, fDummy))
+ else if ( !bDateAxis && aFmtFldStepMain.IsModified()
+ && !aCbxAutoStepMain.IsChecked()
+ && !pNumFormatter->IsNumberFormat( aFmtFldStepMain.GetText(), nStepFmt, fDummy))
{
pControl = &aFmtFldStepMain;
- nErrStrId = STR_STEP_GT_ZERO;
+ nErrStrId = STR_INVALID_NUMBER;
}
else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() &&
- !pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(),
- nIndex, fDummy))
+ !pNumFormatter->IsNumberFormat( aFmtFldOrigin.GetText(), nMinMaxOriginFmt, fDummy))
{
pControl = &aFmtFldOrigin;
nErrStrId = STR_INVALID_NUMBER;
@@ -638,6 +625,12 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
pControl = &aFmtFldStepMain;
nErrStrId = STR_STEP_GT_ZERO;
}
+ else if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() &&
+ fMin >= fMax)
+ {
+ pControl = &aFmtFldMin;
+ nErrStrId = STR_MIN_GREATER_MAX;
+ }
else if( bDateAxis )
{
if( !aCbxAutoStepMain.IsChecked() && !aCbxAutoStepHelp.IsChecked() )