diff options
author | Noel Grandin <noel@peralex.com> | 2016-08-24 11:28:40 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-08-25 08:40:00 +0200 |
commit | 9296ec4403b642939ae49322c5d84066ac5854c8 (patch) | |
tree | d836c77eaac63f49b9f7d0a7b0d38725cadec55c | |
parent | 6d61808a3dd98a9d05dacb4e4db68bcdb31dcee9 (diff) |
convert SvxNumValCategory to scoped enum
and fix bug in NumFormatListBox::GetDefValue in SW
Change-Id: I459b7d5bd181235daa5d128315604f1ed1259ed4
-rw-r--r-- | cui/source/tabpages/numfmt.cxx | 22 | ||||
-rw-r--r-- | include/svx/flagsdef.hxx | 42 | ||||
-rw-r--r-- | svx/source/items/numfmtsh.cxx | 22 | ||||
-rw-r--r-- | sw/source/uibase/utlui/numfmtlb.cxx | 18 |
4 files changed, 53 insertions, 51 deletions
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index d37ed270e8bd..e5768dcfdf39 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -1722,28 +1722,28 @@ OUString SvxNumberFormatTabPage::GetExpColorString( SvxNumValCategory i; switch (nTmpCatPos) { - case CAT_ALL: i=SVX_NUMVAL_STANDARD; break; + case CAT_ALL: i=SvxNumValCategory::Standard; break; - case CAT_NUMBER: i=SVX_NUMVAL_STANDARD; break; + case CAT_NUMBER: i=SvxNumValCategory::Standard; break; - case CAT_PERCENT: i=SVX_NUMVAL_PERCENT; break; + case CAT_PERCENT: i=SvxNumValCategory::Percent; break; - case CAT_CURRENCY: i=SVX_NUMVAL_CURRENCY; break; + case CAT_CURRENCY: i=SvxNumValCategory::Currency; break; - case CAT_DATE: i=SVX_NUMVAL_DATE; break; + case CAT_DATE: i=SvxNumValCategory::Date; break; - case CAT_TIME: i=SVX_NUMVAL_TIME; break; + case CAT_TIME: i=SvxNumValCategory::Time; break; - case CAT_SCIENTIFIC: i=SVX_NUMVAL_SCIENTIFIC; break; + case CAT_SCIENTIFIC: i=SvxNumValCategory::Scientific; break; - case CAT_FRACTION: i=SVX_NUMVAL_FRACTION; break; + case CAT_FRACTION: i=SvxNumValCategory::Fraction; break; - case CAT_BOOLEAN: i=SVX_NUMVAL_BOOLEAN; break; + case CAT_BOOLEAN: i=SvxNumValCategory::Boolean; break; - case CAT_USERDEFINED: i=SVX_NUMVAL_STANDARD; break; + case CAT_USERDEFINED: i=SvxNumValCategory::Standard; break; case CAT_TEXT: - default: i=SVX_NUMVAL_NOVALUE;break; + default: i=SvxNumValCategory::NoValue;break; } double fVal = fSvxNumValConst[i]; diff --git a/include/svx/flagsdef.hxx b/include/svx/flagsdef.hxx index fbf833d6902e..dd4e91569fe9 100644 --- a/include/svx/flagsdef.hxx +++ b/include/svx/flagsdef.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SVX_FLAGSDEF_HXX #include <o3tl/typed_flags_set.hxx> +#include <o3tl/enumarray.hxx> // defines --------------------------------------------------------------- @@ -71,28 +72,29 @@ namespace o3tl // Default values for Number Format Category List and Preview -enum SvxNumValCategory +enum class SvxNumValCategory { - SVX_NUMVAL_STANDARD = 0, - SVX_NUMVAL_PERCENT, - SVX_NUMVAL_CURRENCY, - SVX_NUMVAL_DATE, - SVX_NUMVAL_TIME, - SVX_NUMVAL_SCIENTIFIC, - SVX_NUMVAL_FRACTION, - SVX_NUMVAL_BOOLEAN, - SVX_NUMVAL_NOVALUE + Standard = 0, + Percent, + Currency, + Date, + Time, + Scientific, + Fraction, + Boolean, + NoValue, + LAST = NoValue }; -const double fSvxNumValConst[] = { - -1234.56789012345678, // SVX_NUMVAL_STANDARD - -0.1295, // SVX_NUMVAL_PERCENT - -1234.0, // SVX_NUMVAL_CURRENCY - 36525.5678935185, // SVX_NUMVAL_DATE - 36525.5678935185, // SVX_NUMVAL_TIME - 12345.67889, // SVX_NUMVAL_SCIENTIFIC - 123.456, // SVX_NUMVAL_FRACTION - 1.0, // SVX_NUMVAL_BOOLEAN - 0.0 // SVX_NUMVAL_NOVALUE +const o3tl::enumarray<SvxNumValCategory, double> fSvxNumValConst = { + -1234.56789012345678, // SvxNumValCategory::Standard + -0.1295, // SvxNumValCategory::Percent + -1234.0, // SvxNumValCategory::Currency + 36525.5678935185, // SvxNumValCategory::Date + 36525.5678935185, // SvxNumValCategory::Time + 12345.67889, // SvxNumValCategory::Scientific + 123.456, // SvxNumValCategory::Fraction + 1.0, // SvxNumValCategory::Boolean + 0.0 // SvxNumValCategory::NoValue }; // copy from page.hxx diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index dd539826e546..a1d22852879a 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -39,25 +39,25 @@ double GetDefaultValNum( const short nType ) switch( nType ) { case css::util::NumberFormat::NUMBER: - return fSvxNumValConst[SVX_NUMVAL_STANDARD]; + return fSvxNumValConst[SvxNumValCategory::Standard]; case css::util::NumberFormat::CURRENCY: - return fSvxNumValConst[SVX_NUMVAL_CURRENCY]; + return fSvxNumValConst[SvxNumValCategory::Currency]; case css::util::NumberFormat::PERCENT: - return fSvxNumValConst[SVX_NUMVAL_PERCENT]; + return fSvxNumValConst[SvxNumValCategory::Percent]; case css::util::NumberFormat::DATE: case css::util::NumberFormat::DATETIME: - return fSvxNumValConst[SVX_NUMVAL_DATE]; + return fSvxNumValConst[SvxNumValCategory::Date]; case css::util::NumberFormat::TIME: - return fSvxNumValConst[SVX_NUMVAL_TIME]; + return fSvxNumValConst[SvxNumValCategory::Time]; case css::util::NumberFormat::SCIENTIFIC: - return fSvxNumValConst[SVX_NUMVAL_SCIENTIFIC]; + return fSvxNumValConst[SvxNumValCategory::Scientific]; case css::util::NumberFormat::FRACTION: - return fSvxNumValConst[SVX_NUMVAL_FRACTION]; + return fSvxNumValConst[SvxNumValCategory::Fraction]; case css::util::NumberFormat::LOGICAL: - return fSvxNumValConst[SVX_NUMVAL_BOOLEAN]; + return fSvxNumValConst[SvxNumValCategory::Boolean]; default: break; } - return fSvxNumValConst[SVX_NUMVAL_NOVALUE]; + return fSvxNumValConst[SvxNumValCategory::NoValue]; } } @@ -99,7 +99,7 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter, , bUseStarFormat (false) , bIsDefaultValNum (true) { - nValNum = SVX_NUMVAL_STANDARD; + nValNum = 0; switch ( eValType ) { @@ -150,7 +150,7 @@ SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter, case SvxNumberValueType::String: case SvxNumberValueType::Undefined: default: - nValNum = SVX_NUMVAL_STANDARD; + nValNum = 0; bIsDefaultValNum = true; } } diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx index 0a535a8d6948..d54d84ce9866 100644 --- a/sw/source/uibase/utlui/numfmtlb.cxx +++ b/sw/source/uibase/utlui/numfmtlb.cxx @@ -438,42 +438,42 @@ IMPL_LINK_TYPED( NumFormatListBox, SelectHdl, ListBox&, rBox, void ) double NumFormatListBox::GetDefValue(const short nFormatType) const { - double fDefValue = 0.0; + SvxNumValCategory nDefValue = SvxNumValCategory::Standard; switch (nFormatType) { case css::util::NumberFormat::DATE: case css::util::NumberFormat::DATE|css::util::NumberFormat::TIME: - fDefValue = SVX_NUMVAL_DATE; + nDefValue = SvxNumValCategory::Date; break; case css::util::NumberFormat::TIME: - fDefValue = SVX_NUMVAL_TIME; + nDefValue = SvxNumValCategory::Time; break; case css::util::NumberFormat::TEXT: case css::util::NumberFormat::UNDEFINED: - fDefValue = 0; + nDefValue = SvxNumValCategory::Standard; break; case css::util::NumberFormat::CURRENCY: - fDefValue = SVX_NUMVAL_CURRENCY; + nDefValue = SvxNumValCategory::Currency; break; case css::util::NumberFormat::PERCENT: - fDefValue = SVX_NUMVAL_PERCENT; + nDefValue = SvxNumValCategory::Percent; break; case css::util::NumberFormat::LOGICAL: - fDefValue = SVX_NUMVAL_BOOLEAN; + nDefValue = SvxNumValCategory::Boolean; break; default: - fDefValue = SVX_NUMVAL_STANDARD; + nDefValue = SvxNumValCategory::Standard; break; } - return fDefValue; + return fSvxNumValConst[nDefValue]; } void NumFormatListBox::Clear() |