Kaydet (Commit) 00bc5a09 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Eike Rathke

wrap scoped enum around css::util::NumberFormat

Change-Id: Icab5ded8bccdb95f79b3fa35ea164f47919c68fa
Reviewed-on: https://gerrit.libreoffice.org/46339Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst b74da08e
......@@ -575,8 +575,8 @@ bool SbiScanner::NextSym()
bool bSuccess = pFormatter->IsNumberFormat(aSym, nIndex, nVal);
if( bSuccess )
{
short nType_ = pFormatter->GetType(nIndex);
if( !(nType_ & css::util::NumberFormat::DATE) )
SvNumFormatType nType_ = pFormatter->GetType(nIndex);
if( !(nType_ & SvNumFormatType::DATE) )
bSuccess = false;
}
......
......@@ -2048,7 +2048,7 @@ void SbRtl_DateValue(StarBASIC *, SbxArray & rPar, bool)
double fResult;
OUString aStr( rPar.Get(1)->GetOUString() );
bool bSuccess = pFormatter->IsNumberFormat( aStr, nIndex, fResult );
short nType = pFormatter->GetType( nIndex );
SvNumFormatType nType = pFormatter->GetType( nIndex );
// DateValue("February 12, 1969") raises error if the system locale is not en_US
// It seems that both locale number formatter and English number
......@@ -2061,9 +2061,9 @@ void SbRtl_DateValue(StarBASIC *, SbxArray & rPar, bool)
nType = pFormatter->GetType( nIndex );
}
if(bSuccess && (nType==css::util::NumberFormat::DATE || nType==css::util::NumberFormat::DATETIME))
if(bSuccess && (nType==SvNumFormatType::DATE || nType==SvNumFormatType::DATETIME))
{
if ( nType == css::util::NumberFormat::DATETIME )
if ( nType == SvNumFormatType::DATETIME )
{
// cut time
if ( fResult > 0.0 )
......@@ -2105,10 +2105,10 @@ void SbRtl_TimeValue(StarBASIC *, SbxArray & rPar, bool)
double fResult;
bool bSuccess = pFormatter->IsNumberFormat( rPar.Get(1)->GetOUString(),
nIndex, fResult );
short nType = pFormatter->GetType(nIndex);
if(bSuccess && (nType==css::util::NumberFormat::TIME||nType==css::util::NumberFormat::DATETIME))
SvNumFormatType nType = pFormatter->GetType(nIndex);
if(bSuccess && (nType==SvNumFormatType::TIME||nType==SvNumFormatType::DATETIME))
{
if ( nType == css::util::NumberFormat::DATETIME )
if ( nType == SvNumFormatType::DATETIME )
{
// cut days
fResult = fmod( fResult, 1 );
......
......@@ -408,8 +408,9 @@ std::shared_ptr<SvNumberFormatter> SbiInstance::PrepareNumberFormatter( sal_uInt
std::shared_ptr<SvNumberFormatter> pNumberFormatter(
new SvNumberFormatter( comphelper::getProcessComponentContext(), eLangType ));
sal_Int32 nCheckPos = 0; short nType;
rnStdTimeIdx = pNumberFormatter->GetStandardFormat( css::util::NumberFormat::TIME, eLangType );
sal_Int32 nCheckPos = 0;
SvNumFormatType nType;
rnStdTimeIdx = pNumberFormatter->GetStandardFormat( SvNumFormatType::TIME, eLangType );
// the formatter's standard templates have only got a two-digit date
// -> registering an own format
......
......@@ -116,7 +116,8 @@ double ImpGetDate( const SbxValues* p )
sal_uInt32 nIndex;
sal_Int32 nCheckPos = 0;
short nType = 127;
SvNumFormatType nType = SvNumFormatType::DEFINED | SvNumFormatType::DATE | SvNumFormatType::TIME | SvNumFormatType::CURRENCY
| SvNumFormatType::NUMBER | SvNumFormatType::SCIENTIFIC | SvNumFormatType::FRACTION;
// Default templates of the formatter have only two-digit
// date. Therefore register an own format.
......@@ -144,9 +145,9 @@ double ImpGetDate( const SbxValues* p )
bool bSuccess = pFormatter->IsNumberFormat( *p->pOUString, nIndex, nRes );
if ( bSuccess )
{
short nType_ = pFormatter->GetType( nIndex );
if(!(nType_ & ( css::util::NumberFormat::DATETIME | css::util::NumberFormat::DATE |
css::util::NumberFormat::TIME | css::util::NumberFormat::DEFINED )))
SvNumFormatType nType_ = pFormatter->GetType( nIndex );
if(!(nType_ & ( SvNumFormatType::DATETIME | SvNumFormatType::DATE |
SvNumFormatType::TIME | SvNumFormatType::DEFINED )))
{
bSuccess = false;
}
......@@ -292,7 +293,7 @@ start:
sal_uInt32 nIndex;
sal_Int32 nCheckPos = 0;
short nType;
SvNumFormatType nType;
SvtSysLocale aSysLocale;
DateOrder eDate = aSysLocale.GetLocaleData().getDateOrder();
......
......@@ -703,7 +703,7 @@ void SbxValue::Format( OUString& rRes, const OUString* pFmt ) const
if( bSuccess )
{
sal_Int32 nCheckPos = 0;
short nType;
SvNumFormatType nType;
OUString aFmtStr = *pFmt;
const VbaFormatInfo* pInfo = getFormatInfo( aFmtStr );
if( pInfo->meType != VbaFormatType::Null )
......
......@@ -1130,8 +1130,8 @@ bool DataBrowser::isDateTimeString( const OUString& aInputString, double& fOutDa
SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : nullptr;
if( !aInputString.isEmpty() && pSvNumberFormatter && pSvNumberFormatter->IsNumberFormat( aInputString, nNumberFormat, fOutDateTimeValue ) )
{
short nType = pSvNumberFormatter->GetType( nNumberFormat);
return (nType & util::NumberFormat::DATE) || (nType & util::NumberFormat::TIME);
SvNumFormatType nType = pSvNumberFormatter->GetType( nNumberFormat);
return (nType & SvNumFormatType::DATE) || (nType & SvNumFormatType::TIME);
}
return false;
}
......
......@@ -422,11 +422,11 @@ DeactivateRC ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
bool bDateAxis = m_nAxisType == chart2::AxisType::DATE;
sal_uInt32 nMinMaxOriginFmt = m_pFmtFldMax->GetFormatKey();
if (pNumFormatter->GetType(nMinMaxOriginFmt) == css::util::NumberFormat::TEXT)
if (pNumFormatter->GetType(nMinMaxOriginFmt) == SvNumFormatType::TEXT)
nMinMaxOriginFmt = 0;
// numberformat_text cause numbers to fail being numbers... Shouldn't happen, but can.
sal_uInt32 nStepFmt = m_pFmtFldStepMain->GetFormatKey();
if (pNumFormatter->GetType(nStepFmt) == css::util::NumberFormat::TEXT)
if (pNumFormatter->GetType(nStepFmt) == SvNumFormatType::TEXT)
nStepFmt = 0;
Control* pControl = nullptr;
......@@ -564,8 +564,8 @@ void ScaleTabPage::SetNumFormat()
if( pNumFormatter )
{
short eType = pNumFormatter->GetType( nFmt );
if( eType == css::util::NumberFormat::DATE )
SvNumFormatType eType = pNumFormatter->GetType( nFmt );
if( eType == SvNumFormatType::DATE )
{
// for intervals use standard format for dates (so you can enter a number of days)
const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
......@@ -574,23 +574,23 @@ void ScaleTabPage::SetNumFormat()
else
nFmt = pNumFormatter->GetStandardIndex();
}
else if( eType == css::util::NumberFormat::DATETIME )
else if( eType == SvNumFormatType::DATETIME )
{
// for intervals use time format for date times
const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
if( pFormat )
nFmt = pNumFormatter->GetStandardFormat( css::util::NumberFormat::TIME, pFormat->GetLanguage() );
nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME, pFormat->GetLanguage() );
else
nFmt = pNumFormatter->GetStandardFormat( css::util::NumberFormat::TIME );
nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME );
}
if( m_nAxisType == chart2::AxisType::DATE && ( eType != css::util::NumberFormat::DATE && eType != css::util::NumberFormat::DATETIME) )
if( m_nAxisType == chart2::AxisType::DATE && ( eType != SvNumFormatType::DATE && eType != SvNumFormatType::DATETIME) )
{
const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
if( pFormat )
nFmt = pNumFormatter->GetStandardFormat( css::util::NumberFormat::DATE, pFormat->GetLanguage() );
nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::DATE, pFormat->GetLanguage() );
else
nFmt = pNumFormatter->GetStandardFormat( css::util::NumberFormat::DATE );
nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::DATE );
m_pFmtFldMax->SetFormatKey( nFmt );
m_pFmtFldMin->SetFormatKey( nFmt );
......
......@@ -1173,7 +1173,7 @@ sal_Int32 DiagramHelper::getDateTimeInputNumberFormat( const Reference< util::XN
SAL_WARN("chart2", "DiagramHelper::getDateTimeInputNumberFormat - no SvNumberFormatter");
else
{
short nType;
SvNumFormatType nType;
// Obtain best matching date, time or datetime format.
nRet = pNumFormatter->GuessDateTimeFormat( nType, fNumber, LANGUAGE_SYSTEM);
// Obtain the corresponding edit format.
......@@ -1190,7 +1190,7 @@ sal_Int32 DiagramHelper::getPercentNumberFormat( const Reference< util::XNumberF
SvNumberFormatter* pNumFormatter = aNumberFormatterWrapper.getSvNumberFormatter();
if( pNumFormatter )
{
nRet = pNumFormatter->GetStandardFormat( util::NumberFormat::PERCENT, rLanguageTag.getLanguageType() );
nRet = pNumFormatter->GetStandardFormat( SvNumFormatType::PERCENT, rLanguageTag.getLanguageType() );
}
else
{
......
......@@ -145,11 +145,11 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
SvNumberFormatter *pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessComponentContext(), eUILang );
Color* pColor = nullptr;
const Date& rNullDate = pNumberFormatter->GetNullDate();
sal_uInt32 nFormat = pNumberFormatter->GetStandardFormat( css::util::NumberFormat::DATE, eUILang );
sal_uInt32 nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::DATE, eUILang );
pNumberFormatter->GetOutputString( aDate - rNullDate, nFormat, aDateStr, &pColor );
nFormat = pNumberFormatter->GetStandardFormat( css::util::NumberFormat::TIME, eUILang );
nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::TIME, eUILang );
pNumberFormatter->GetOutputString( aTime.GetTimeInDays(), nFormat, aTimeStr, &pColor );
delete pColor;
......
......@@ -834,7 +834,7 @@ bool callColumnFormatDialog(vcl::Window* _pParent,
pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, true));
if (!_pFormatter->IsTextFormat(_nFormatKey))
// text fields can only have text formats
_nFormatKey = _pFormatter->GetStandardFormat(css::util::NumberFormat::TEXT,_pParent->GetSettings().GetLanguageTag().getLanguageType());
_nFormatKey = _pFormatter->GetStandardFormat(SvNumFormatType::TEXT,_pParent->GetSettings().GetLanguageTag().getLanguageType());
}
pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, _nFormatKey));
......
......@@ -418,7 +418,7 @@ OUString SvxDateField::GetFormatted( Date const & aDate, SvxDateFormat eFormat,
nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY, eLang );
break;
default:
nFormatKey = rFormatter.GetStandardFormat( css::util::NumberFormat::DATE, eLang );
nFormatKey = rFormatter.GetStandardFormat( SvNumFormatType::DATE, eLang );
}
double fDiffDate = aDate - rFormatter.GetNullDate();
......@@ -675,7 +675,7 @@ OUString SvxExtTimeField::GetFormatted( tools::Time const & aTime, SvxTimeFormat
// no builtin format available, try to insert or reuse
OUString aFormatCode( "HH:MM:SS.00 AM/PM" );
sal_Int32 nCheckPos;
short nType;
SvNumFormatType nType;
rFormatter.PutandConvertEntry( aFormatCode, nCheckPos, nType,
nFormatKey, LANGUAGE_ENGLISH_US, eLang );
DBG_ASSERT( nCheckPos == 0, "SvxTimeFormat::HH12_MM_SS_00: could not insert format code" );
......@@ -699,7 +699,7 @@ OUString SvxExtTimeField::GetFormatted( tools::Time const & aTime, SvxTimeFormat
break;
case SvxTimeFormat::Standard:
default:
nFormatKey = rFormatter.GetStandardFormat( css::util::NumberFormat::TIME, eLang );
nFormatKey = rFormatter.GetStandardFormat( SvNumFormatType::TIME, eLang );
}
double fFracTime = aTime.GetTimeInDays();
......
......@@ -261,7 +261,7 @@ namespace pcr
getTypedControlWindow()->SetFormatter( getTypedControlWindow()->StandardFormatter() );
SvNumberFormatter* pFormatter = getTypedControlWindow()->GetFormatter();
sal_uLong nStandardDateTimeFormat = pFormatter->GetStandardFormat( css::util::NumberFormat::DATETIME, eSysLanguage );
sal_uLong nStandardDateTimeFormat = pFormatter->GetStandardFormat( SvNumFormatType::DATETIME, eSysLanguage );
getTypedControlWindow()->SetFormatKey( nStandardDateTimeFormat );
}
......
......@@ -118,17 +118,17 @@ namespace pcr
double OFormatSampleControl::getPreviewValue( const SvNumberformat& i_rEntry )
{
double nValue = 1234.56789;
switch ( i_rEntry.GetType() & ~css::util::NumberFormat::DEFINED )
switch ( i_rEntry.GetType() & ~SvNumFormatType::DEFINED )
{
case css::util::NumberFormat::DATE:
case SvNumFormatType::DATE:
{
Date aCurrentDate( Date::SYSTEM );
static css::util::Date STANDARD_DB_DATE(30,12,1899);
nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(aCurrentDate.GetDate()),STANDARD_DB_DATE);
}
break;
case css::util::NumberFormat::TIME:
case css::util::NumberFormat::DATETIME:
case SvNumFormatType::TIME:
case SvNumFormatType::DATETIME:
{
tools::Time aCurrentTime( tools::Time::SYSTEM );
nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime()));
......
......@@ -52,7 +52,7 @@ class FormulaCompilerRecursionGuard
~FormulaCompilerRecursionGuard() { --rRecursion; }
};
short lcl_GetRetFormat( OpCode eOpCode )
SvNumFormatType lcl_GetRetFormat( OpCode eOpCode )
{
switch (eOpCode)
{
......@@ -81,15 +81,15 @@ short lcl_GetRetFormat( OpCode eOpCode )
case ocIsEven:
case ocIsOdd:
case ocExact:
return css::util::NumberFormat::LOGICAL;
return SvNumFormatType::LOGICAL;
case ocGetActDate:
case ocGetDate:
case ocEasterSunday :
return css::util::NumberFormat::DATE;
return SvNumFormatType::DATE;
case ocGetActTime:
return css::util::NumberFormat::DATETIME;
return SvNumFormatType::DATETIME;
case ocGetTime:
return css::util::NumberFormat::TIME;
return SvNumFormatType::TIME;
case ocNPV:
case ocPV:
case ocSYD:
......@@ -103,7 +103,7 @@ short lcl_GetRetFormat( OpCode eOpCode )
case ocPpmt:
case ocCumIpmt:
case ocCumPrinc:
return css::util::NumberFormat::CURRENCY;
return SvNumFormatType::CURRENCY;
case ocRate:
case ocIRR:
case ocMIRR:
......@@ -111,9 +111,9 @@ short lcl_GetRetFormat( OpCode eOpCode )
case ocEffect:
case ocNominal:
case ocPercentSign:
return css::util::NumberFormat::PERCENT;
return SvNumFormatType::PERCENT;
default:
return css::util::NumberFormat::NUMBER;
return SvNumFormatType::NUMBER;
}
}
......@@ -716,7 +716,7 @@ FormulaCompiler::FormulaCompiler( FormulaTokenArray& rArr )
pStack( nullptr ),
eLastOp( ocPush ),
nRecursion( 0 ),
nNumFmt( css::util::NumberFormat::UNDEFINED ),
nNumFmt( SvNumFormatType::UNDEFINED ),
pc( 0 ),
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ),
......@@ -738,7 +738,7 @@ FormulaCompiler::FormulaCompiler()
pStack( nullptr ),
eLastOp( ocPush ),
nRecursion(0),
nNumFmt( css::util::NumberFormat::UNDEFINED ),
nNumFmt( SvNumFormatType::UNDEFINED ),
pc( 0 ),
meGrammar( formula::FormulaGrammar::GRAM_UNSPECIFIED ),
bAutoCorrect( false ),
......@@ -1417,7 +1417,7 @@ void FormulaCompiler::Factor()
}
else
{
if( nNumFmt == css::util::NumberFormat::UNDEFINED )
if( nNumFmt == SvNumFormatType::UNDEFINED )
nNumFmt = lcl_GetRetFormat( eOp );
if ( IsOpCodeVolatile( eOp) )
......@@ -1556,8 +1556,8 @@ void FormulaCompiler::Factor()
// standard handling of ocNot, ocNeg and 1-parameter opcodes
pFacToken = mpToken;
eOp = NextToken();
if( nNumFmt == css::util::NumberFormat::UNDEFINED && eOp == ocNot )
nNumFmt = css::util::NumberFormat::LOGICAL;
if( nNumFmt == SvNumFormatType::UNDEFINED && eOp == ocNot )
nNumFmt = SvNumFormatType::LOGICAL;
if (eOp == ocOpen)
{
NextToken();
......@@ -2036,8 +2036,8 @@ bool FormulaCompiler::CompileTokenArray()
if ( bWasForced )
pArr->SetRecalcModeForced();
}
if( nNumFmt == css::util::NumberFormat::UNDEFINED )
nNumFmt = css::util::NumberFormat::NUMBER;
if( nNumFmt == SvNumFormatType::UNDEFINED )
nNumFmt = SvNumFormatType::NUMBER;
return glSubTotal;
}
......
......@@ -210,13 +210,13 @@ double & FormulaToken::GetDoubleAsReference()
return fVal;
}
short FormulaToken::GetDoubleType() const
sal_Int16 FormulaToken::GetDoubleType() const
{
SAL_WARN( "formula.core", "FormulaToken::GetDoubleType: virtual dummy called" );
return 0;
}
void FormulaToken::SetDoubleType( short )
void FormulaToken::SetDoubleType( sal_Int16 )
{
assert( !"virtual dummy called" );
}
......@@ -1785,7 +1785,7 @@ void FormulaTokenArrayPlainIterator::AfterRemoveToken( sal_uInt16 nOffset, sal_u
double FormulaDoubleToken::GetDouble() const { return fDouble; }
double & FormulaDoubleToken::GetDoubleAsReference() { return fDouble; }
short FormulaDoubleToken::GetDoubleType() const
sal_Int16 FormulaDoubleToken::GetDoubleType() const
{
// This is a plain double value without type information, don't emit a
// warning via FormulaToken::GetDoubleType().
......@@ -1797,12 +1797,12 @@ bool FormulaDoubleToken::operator==( const FormulaToken& r ) const
return FormulaToken::operator==( r ) && fDouble == r.GetDouble();
}
short FormulaTypedDoubleToken::GetDoubleType() const
sal_Int16 FormulaTypedDoubleToken::GetDoubleType() const
{
return mnType;
}
void FormulaTypedDoubleToken::SetDoubleType( short nType )
void FormulaTypedDoubleToken::SetDoubleType( sal_Int16 nType )
{
mnType = nType;
}
......
......@@ -52,6 +52,7 @@ namespace com { namespace sun { namespace star {
class CharClass;
enum class FormulaError : sal_uInt16;
enum class SvNumFormatType : sal_Int16;
namespace formula
{
......@@ -236,7 +237,7 @@ public:
static sal_Unicode GetNativeSymbolChar( OpCode eOp );
static bool IsMatrixFunction(OpCode _eOpCode); // if a function _always_ returns a Matrix
short GetNumFormatType() const { return nNumFmt; }
SvNumFormatType GetNumFormatType() const { return nNumFmt; }
bool CompileTokenArray();
void CreateStringFromTokenArray( OUString& rFormula );
......@@ -340,7 +341,7 @@ protected:
OpCode eLastOp;
short nRecursion; // GetToken() recursions
short nNumFmt; // set during CompileTokenArray()
SvNumFormatType nNumFmt; // set during CompileTokenArray()
sal_uInt16 pc; // program counter
FormulaGrammar::Grammar meGrammar; // The grammar used, language plus convention.
......
......@@ -183,8 +183,8 @@ public:
virtual void SetInForceArray( ParamClass c );
virtual double GetDouble() const;
virtual double& GetDoubleAsReference();
virtual short GetDoubleType() const;
virtual void SetDoubleType( short nType );
virtual sal_Int16 GetDoubleType() const;
virtual void SetDoubleType( sal_Int16 nType );
virtual svl::SharedString GetString() const;
virtual void SetString( const svl::SharedString& rStr );
virtual sal_uInt16 GetIndex() const;
......@@ -304,7 +304,7 @@ public:
virtual FormulaToken* Clone() const override { return new FormulaDoubleToken(*this); }
virtual double GetDouble() const override;
virtual double& GetDoubleAsReference() override;
virtual short GetDoubleType() const override; ///< always returns 0 for "not typed"
virtual sal_Int16 GetDoubleType() const override; ///< always returns 0 for "not typed"
virtual bool operator==( const FormulaToken& rToken ) const override;
DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaDoubleToken )
......@@ -313,19 +313,19 @@ public:
class FORMULA_DLLPUBLIC FormulaTypedDoubleToken : public FormulaDoubleToken
{
private:
short mnType; /**< Can hold, for example, a value
of css::util::NumberFormat, or by
sal_Int16 mnType; /**< Can hold, for example, a value
of SvNumFormatType, or by
contract any other
classification. */
public:
FormulaTypedDoubleToken( double f, short nType ) :
FormulaTypedDoubleToken( double f, sal_Int16 nType ) :
FormulaDoubleToken( f ), mnType( nType ) {}
FormulaTypedDoubleToken( const FormulaTypedDoubleToken& r ) :
FormulaDoubleToken( r ), mnType( r.mnType ) {}
virtual FormulaToken* Clone() const override { return new FormulaTypedDoubleToken(*this); }
virtual short GetDoubleType() const override;
virtual void SetDoubleType( short nType ) override;
virtual sal_Int16 GetDoubleType() const override;
virtual void SetDoubleType( sal_Int16 nType ) override;
virtual bool operator==( const FormulaToken& rToken ) const override;
DECL_FIXEDMEMPOOL_NEWDEL_DLL( FormulaTypedDoubleToken )
......
......@@ -32,6 +32,7 @@
#include <tools/link.hxx>
#include <svl/ondemand.hxx>
#include <svl/nfkeytab.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <map>
#include <memory>
......@@ -61,6 +62,55 @@ constexpr sal_uInt32 NF_STANDARD_FORMAT_TEXT = SV_MAX_COUNT_STANDARD_FORMATS;
#define NUMBERFORMAT_ENTRY_NOT_FOUND (sal_uInt32)(0xffffffff) /// MAX_ULONG
enum class SvNumFormatType : sal_Int16
{
/** selects all number formats.
*/
ALL = css::util::NumberFormat::ALL, // 0
/** selects only user-defined number formats.
*/
DEFINED = css::util::NumberFormat::DEFINED, // 1
/** selects date formats.
*/
DATE = css::util::NumberFormat::DATE, // 2
/** selects time formats.
*/
TIME = css::util::NumberFormat::TIME, // 4
/** selects currency formats.
*/
CURRENCY = css::util::NumberFormat::CURRENCY, // 8
/** selects decimal number formats.
*/
NUMBER = css::util::NumberFormat::NUMBER, // 16
/** selects scientific number formats.
*/
SCIENTIFIC = css::util::NumberFormat::SCIENTIFIC, // 32
/** selects number formats for fractions.
*/
FRACTION = css::util::NumberFormat::FRACTION, // 64
/** selects percentage number formats.
*/
PERCENT = css::util::NumberFormat::PERCENT, // 128
/** selects text number formats.
*/
TEXT = css::util::NumberFormat::TEXT, // 256
/** selects number formats which contain date and time.
*/
DATETIME = DATE | TIME, // 6
/** selects boolean number formats.
*/
LOGICAL = css::util::NumberFormat::LOGICAL, // 1024
/** is used as a return value if no format exists.
*/
UNDEFINED = css::util::NumberFormat::UNDEFINED, // 2048
/** @internal is used to flag an empty sub format.
@since LibreOffice 5.1
*/
EMPTY = css::util::NumberFormat::EMPTY, // 4096
};
namespace o3tl {
template<> struct typed_flags<SvNumFormatType> : is_typed_flags<SvNumFormatType, 0x1dff> {};
}
/** enum values for <method>SvNumberFormatter::GetFormatIndex</method>
......@@ -361,26 +411,26 @@ public:
LanguageType GetLanguage() const;
// Determine whether two format types are input compatible or not
static bool IsCompatible(short eOldType, short eNewType);
static bool IsCompatible(SvNumFormatType eOldType, SvNumFormatType eNewType);
/** Get table of formats of a specific type of a locale. A format FIndex is
tested whether it has the type and locale requested, if it doesn't
match FIndex returns the default format for the type/locale. If no
specific format is to be selected FIndex may be initialized to 0. */
SvNumberFormatTable& GetEntryTable(short eType,
SvNumberFormatTable& GetEntryTable(SvNumFormatType eType,
sal_uInt32& FIndex,
LanguageType eLnge);
/** Get table of formats of a specific type of a language/country.
FIndex returns the default format of that type.
If the language/country was never touched before new entries are generated */
SvNumberFormatTable& ChangeCL(short eType,
SvNumberFormatTable& ChangeCL(SvNumFormatType eType,
sal_uInt32& FIndex,
LanguageType eLnge);
/** Get table of formats of the same type as FIndex; eType and rLnge are
set accordingly. An unknown format is set to Standard/General */
SvNumberFormatTable& GetFirstEntryTable(short& eType,
SvNumberFormatTable& GetFirstEntryTable(SvNumFormatType& eType,
sal_uInt32& FIndex,
LanguageType& rLnge);
......@@ -400,14 +450,14 @@ public:
nType contains the type of the format.
nKey contains the index key of the format.
*/
bool PutEntry( OUString& rString, sal_Int32& nCheckPos, short& nType, sal_uInt32& nKey,
bool PutEntry( OUString& rString, sal_Int32& nCheckPos, SvNumFormatType& nType, sal_uInt32& nKey,
LanguageType eLnge = LANGUAGE_DONTKNOW );
/** Same as <method>PutEntry</method> but the format code string is
considered to be of language/country eLnge and is converted to
language/country eNewLnge */
bool PutandConvertEntry( OUString& rString, sal_Int32& nCheckPos,
short& nType, sal_uInt32& nKey,
SvNumFormatType& nType, sal_uInt32& nKey,
LanguageType eLnge, LanguageType eNewLnge,
bool bForExcelExport = false );
......@@ -416,7 +466,7 @@ public:
converted to another System language/country eNewLnge. In this case
the automatic currency is converted too. */
bool PutandConvertEntrySystem( OUString& rString, sal_Int32& nCheckPos,
short& nType, sal_uInt32& nKey,
SvNumFormatType& nType, sal_uInt32& nKey,
LanguageType eLnge, LanguageType eNewLnge );
/** Similar to <method>PutEntry</method> and
......@@ -457,7 +507,7 @@ public:
and/or could not be converted.
*/
sal_uInt32 GetIndexPuttingAndConverting( OUString & rString, LanguageType eLnge,
LanguageType eSysLnge, short & rType,
LanguageType eSysLnge, SvNumFormatType & rType,
bool & rNewInserted, sal_Int32 & rCheckPos );
/** Create a format code string using format nIndex as a template and
......@@ -566,17 +616,17 @@ public:
sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW);
/// Return the format index of the default format of a type for language/country
sal_uInt32 GetStandardFormat(short eType, LanguageType eLnge = LANGUAGE_DONTKNOW);
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge = LANGUAGE_DONTKNOW);
/** Return the format index of the default format of a type for language/country.
Maybe not the default format but a special builtin format, e.g. for
NF_TIME_HH_MMSS00, if that format is passed in nFIndex. */
sal_uInt32 GetStandardFormat( sal_uInt32 nFIndex, short eType, LanguageType eLnge );
sal_uInt32 GetStandardFormat( sal_uInt32 nFIndex, SvNumFormatType eType, LanguageType eLnge );
/** Return the format index of the default format of a type for language/country.
Maybe not the default format but a special builtin format, e.g. for
NF_TIME_HH_MMSS00, or NF_TIME_HH_MMSS if fNumber >= 1.0 */
sal_uInt32 GetStandardFormat( double fNumber, sal_uInt32 nFIndex, short eType,
sal_uInt32 GetStandardFormat( double fNumber, sal_uInt32 nFIndex, SvNumFormatType eType,
LanguageType eLnge );
/// Whether nFIndex is a special builtin format
......@@ -589,10 +639,10 @@ public:
fNumber is assumed to be a date, time or datetime value, but unknown
which. Originally introduced for Chart databrowser editor, probably
should not be used otherwise. */
sal_uInt32 GuessDateTimeFormat( short& rType, double fNumber, LanguageType eLnge );
sal_uInt32 GuessDateTimeFormat( SvNumFormatType& rType, double fNumber, LanguageType eLnge );
/** Return the corresponding edit format of a format. */
sal_uInt32 GetEditFormat( double fNumber, sal_uInt32 nFIndex, short eType,
sal_uInt32 GetEditFormat( double fNumber, sal_uInt32 nFIndex, SvNumFormatType eType,
LanguageType eLnge, SvNumberformat const * pFormat );
/// Return the reference date
......@@ -603,7 +653,7 @@ public:
bool GetNoZero() const;
/** Get the type of a format (or css::util::NumberFormat::UNDEFINED if no entry),
but with css::util::NumberFormat::DEFINED masked out */
short GetType(sal_uInt32 nFIndex) const;
SvNumFormatType GetType(sal_uInt32 nFIndex) const;