diff options
author | Laurent Balland-Poirier <laurent.balland-poirier@laposte.net> | 2016-06-15 22:55:59 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-06-29 09:46:20 +0000 |
commit | 9724eaa94e1f1e58dbbba2ecad4287245e0f0bf0 (patch) | |
tree | 0c46b710a396e20f6fe27335bc1e8df27e520e71 /svx/source/items | |
parent | ac265f6210452ee48c1766942a3a311aedc3cdcd (diff) |
tdf#100413 Use same default values for preview string and format list
Add specific default values for:
- scientific: to distinguish engineering notation
- fraction: to have quarter format understandable
Change-Id: I73b74713a4bc502e9967b8d2c9983cfc6244912e
Reviewed-on: https://gerrit.libreoffice.org/26391
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svx/source/items')
-rw-r--r-- | svx/source/items/numfmtsh.cxx | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index b4a4fc2cad6a..878d38868632 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -27,13 +27,11 @@ #include <svl/currencytable.hxx> #include <svx/numfmtsh.hxx> +#include <svx/flagsdef.hxx> #include <svx/tbcontrl.hxx> #include <limits> -const double SvxNumberFormatShell::DEFAULT_NUMVALUE = 1234.56789; - - SvxNumberFormatShell* SvxNumberFormatShell::Create( SvNumberFormatter* pNumFormatter, sal_uInt32 nFormatKey, SvxNumberValueType eNumValType, @@ -69,8 +67,9 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter, , bBankingSymbol (false) , nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE) , bUseStarFormat (false) + , bIsDefaultValNum (true) { - nValNum = DEFAULT_NUMVALUE; + nValNum = SVX_NUMVAL_STANDARD; switch ( eValType ) { @@ -78,13 +77,17 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter, aValStr = rNumStr; break; case SVX_VALUE_TYPE_NUMBER: + if ( pFormatter ) + { + nValNum = GetDefaultValNum( pFormatter->GetType( nCurFormatKey ) ); + } + SAL_FALLTHROUGH; case SVX_VALUE_TYPE_UNDEFINED: default: aValStr.clear(); } } - SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter, sal_uInt32 nFormatKey, SvxNumberValueType eNumValType, @@ -101,6 +104,7 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter, , bBankingSymbol (false) , nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE) , bUseStarFormat (false) + , bIsDefaultValNum (false) { // #50441# When used in Writer, the SvxNumberInfoItem contains the // original string in addition to the value @@ -116,7 +120,8 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter, case SVX_VALUE_TYPE_STRING: case SVX_VALUE_TYPE_UNDEFINED: default: - nValNum = DEFAULT_NUMVALUE; + nValNum = SVX_NUMVAL_STANDARD; + bIsDefaultValNum = true; } } @@ -401,6 +406,33 @@ void SvxNumberFormatShell::GetOptions( const OUString& rFormat, } +double SvxNumberFormatShell::GetDefaultValNum( const short nType ) const +{ + switch( nType ) + { + case css::util::NumberFormat::NUMBER: + return fSvxNumValConst[SVX_NUMVAL_STANDARD]; + case css::util::NumberFormat::CURRENCY: + return fSvxNumValConst[SVX_NUMVAL_CURRENCY]; + case css::util::NumberFormat::PERCENT: + return fSvxNumValConst[SVX_NUMVAL_PERCENT]; + case css::util::NumberFormat::DATE: + case css::util::NumberFormat::DATETIME: + return fSvxNumValConst[SVX_NUMVAL_DATE]; + case css::util::NumberFormat::TIME: + return fSvxNumValConst[SVX_NUMVAL_TIME]; + case css::util::NumberFormat::SCIENTIFIC: + return fSvxNumValConst[SVX_NUMVAL_SCIENTIFIC]; + case css::util::NumberFormat::FRACTION: + return fSvxNumValConst[SVX_NUMVAL_FRACTION]; + case css::util::NumberFormat::LOGICAL: + return fSvxNumValConst[SVX_NUMVAL_BOOLEAN]; + default: break; + } + return fSvxNumValConst[SVX_NUMVAL_NOVALUE]; +} + + void SvxNumberFormatShell::MakePreviewString( const OUString& rFormatStr, OUString& rPreviewStr, Color*& rpFontColor ) @@ -428,6 +460,8 @@ void SvxNumberFormatShell::MakePreviewString( const OUString& rFormatStr, } else { + if ( bIsDefaultValNum ) + nValNum = GetDefaultValNum( pFormatter->GetType(nExistingFormat) ); pFormatter->GetOutputString( nValNum, nExistingFormat, rPreviewStr, &rpFontColor, bUseStarFormat ); } |