summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-04-13 13:16:27 +0200
committerEike Rathke <erack@redhat.com>2017-04-13 18:36:05 +0200
commit608e93bce9d72ccabadeb6707f9a29c3499fd32e (patch)
treea37d9f370342c6d76fe6e5b4741a90535d12bde1 /svl
parentfe62003caabf7665d41085c5d16f177f8186fce4 (diff)
convert DateFormat to scoped enum and rename to DateOrder
Change-Id: I71d7a7755a5c20d5146d1ad7e96ca22b7823173a Reviewed-on: https://gerrit.libreoffice.org/36517 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx81
-rw-r--r--svl/source/numbers/zforfind.hxx6
-rw-r--r--svl/source/numbers/zforlist.cxx2
-rw-r--r--svl/source/numbers/zformat.cxx10
4 files changed, 50 insertions, 49 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 9c257130373f..e9c7fabb4405 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -1039,7 +1039,7 @@ bool ImpSvNumberInputScan::MayBeIso8601()
}
-bool ImpSvNumberInputScan::CanForceToIso8601( DateFormat eDateFormat )
+bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder )
{
if (nCanForceToIso8601 == 0)
{
@@ -1058,23 +1058,24 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateFormat eDateFormat )
}
sal_Int32 n;
- switch (eDateFormat)
+ switch (eDateOrder)
{
- case DMY: // "day" value out of range => ISO 8601 year
+ case DateOrder::DMY: // "day" value out of range => ISO 8601 year
if ((n = sStrArray[nNums[0]].toInt32()) < 1 || n > 31)
{
nCanForceToIso8601 = 2;
}
break;
- case MDY: // "month" value out of range => ISO 8601 year
+ case DateOrder::MDY: // "month" value out of range => ISO 8601 year
if ((n = sStrArray[nNums[0]].toInt32()) < 1 || n > 12)
{
nCanForceToIso8601 = 2;
}
break;
- case YMD: // always possible
+ case DateOrder::YMD: // always possible
nCanForceToIso8601 = 2;
break;
+ default: break;
}
}
return nCanForceToIso8601 > 1;
@@ -1381,31 +1382,31 @@ sal_uInt32 ImpSvNumberInputScan::GetDatePatternOrder()
}
-DateFormat ImpSvNumberInputScan::GetDateOrder()
+DateOrder ImpSvNumberInputScan::GetDateOrder()
{
sal_uInt32 nOrder = GetDatePatternOrder();
if (!nOrder)
{
- return pFormatter->GetLocaleData()->getDateFormat();
+ return pFormatter->GetLocaleData()->getDateOrder();
}
switch ((nOrder & 0xff0000) >> 16)
{
case 'Y':
if ((((nOrder & 0xff00) >> 8) == 'M') && ((nOrder & 0xff) == 'D'))
{
- return YMD;
+ return DateOrder::YMD;
}
break;
case 'M':
if ((((nOrder & 0xff00) >> 8) == 'D') && ((nOrder & 0xff) == 'Y'))
{
- return MDY;
+ return DateOrder::MDY;
}
break;
case 'D':
if ((((nOrder & 0xff00) >> 8) == 'M') && ((nOrder & 0xff) == 'Y'))
{
- return DMY;
+ return DateOrder::DMY;
}
break;
default:
@@ -1416,25 +1417,25 @@ DateFormat ImpSvNumberInputScan::GetDateOrder()
switch ((nOrder & 0xff))
{
case 'M':
- return YMD;
+ return DateOrder::YMD;
}
break;
case 'M':
switch ((nOrder & 0xff))
{
case 'Y':
- return DMY;
+ return DateOrder::DMY;
case 'D':
- return MDY;
+ return DateOrder::MDY;
}
break;
case 'D':
switch ((nOrder & 0xff))
{
case 'Y':
- return MDY;
+ return DateOrder::MDY;
case 'M':
- return DMY;
+ return DateOrder::DMY;
}
break;
default:
@@ -1442,17 +1443,17 @@ DateFormat ImpSvNumberInputScan::GetDateOrder()
switch ((nOrder & 0xff))
{
case 'Y':
- return YMD;
+ return DateOrder::YMD;
case 'M':
- return MDY;
+ return DateOrder::MDY;
case 'D':
- return DMY;
+ return DateOrder::DMY;
}
break;
}
}
SAL_WARN( "svl.numbers", "ImpSvNumberInputScan::GetDateOrder: undefined, falling back to locale's default");
- return pFormatter->GetLocaleData()->getDateFormat();
+ return pFormatter->GetLocaleData()->getDateOrder();
}
bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter,
@@ -1492,7 +1493,7 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter,
{
pCal->setGregorianDateTime( Date( Date::SYSTEM ) ); // today
OUString aOrgCalendar; // empty => not changed yet
- DateFormat DateFmt;
+ DateOrder DateFmt;
bool bFormatTurn;
switch ( eEDF )
{
@@ -1530,7 +1531,7 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter,
break;
default:
SAL_WARN( "svl.numbers", "ImpSvNumberInputScan::GetDateRef: unknown NfEvalDateFormat" );
- DateFmt = YMD;
+ DateFmt = DateOrder::YMD;
bFormatTurn = false;
}
if ( bFormatTurn )
@@ -1625,8 +1626,8 @@ input for the following reasons:
pCal->setValue( CalendarFieldIndex::MONTH, std::abs(nMonth)-1 );
switch (DateFmt)
{
- case MDY:
- case YMD:
+ case DateOrder::MDY:
+ case DateOrder::YMD:
{
sal_uInt16 nDay = ImplGetDay(0);
sal_uInt16 nYear = ImplGetYear(0);
@@ -1640,7 +1641,7 @@ input for the following reasons:
}
break;
}
- case DMY:
+ case DateOrder::DMY:
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
break;
default:
@@ -1652,10 +1653,10 @@ input for the following reasons:
pCal->setValue( CalendarFieldIndex::MONTH, std::abs(nMonth)-1 );
switch (DateFmt)
{
- case DMY:
+ case DateOrder::DMY:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
break;
- case YMD:
+ case DateOrder::YMD:
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
break;
default:
@@ -1739,7 +1740,7 @@ input for the following reasons:
}
switch (DateFmt)
{
- case MDY:
+ case DateOrder::MDY:
// M D
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
@@ -1750,7 +1751,7 @@ input for the following reasons:
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
}
break;
- case DMY:
+ case DateOrder::DMY:
// D M
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
@@ -1761,7 +1762,7 @@ input for the following reasons:
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
}
break;
- case YMD:
+ case DateOrder::YMD:
// M D
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
@@ -1801,14 +1802,14 @@ input for the following reasons:
case 2: // month in the middle (10 Jan 94)
{
pCal->setValue( CalendarFieldIndex::MONTH, std::abs(nMonth)-1 );
- DateFormat eDF = (MayBeMonthDate() ? (nMayBeMonthDate == 2 ? DMY : YMD) : DateFmt);
+ DateOrder eDF = (MayBeMonthDate() ? (nMayBeMonthDate == 2 ? DateOrder::DMY : DateOrder::YMD) : DateFmt);
switch (eDF)
{
- case DMY:
+ case DateOrder::DMY:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
break;
- case YMD:
+ case DateOrder::YMD:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
break;
@@ -1842,22 +1843,22 @@ input for the following reasons:
}
}
// ISO 8601 yyyy-mm-dd forced recognition
- DateFormat eDF = (CanForceToIso8601( DateFmt) ? YMD : DateFmt);
+ DateOrder eDF = (CanForceToIso8601( DateFmt) ? DateOrder::YMD : DateFmt);
switch (eDF)
{
- case MDY:
+ case DateOrder::MDY:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(0) );
if ( nCounter > 2 )
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(2) );
break;
- case DMY:
+ case DateOrder::DMY:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
if ( nCounter > 2 )
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(2) );
break;
- case YMD:
+ case DateOrder::YMD:
if ( nCounter > 2 )
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(2) );
pCal->setValue( CalendarFieldIndex::MONTH, ImplGetMonth(1) );
@@ -1873,7 +1874,7 @@ input for the following reasons:
nCounter = 2;
switch (DateFmt)
{
- case MDY:
+ case DateOrder::MDY:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
pCal->setValue( CalendarFieldIndex::MONTH, std::abs(nMonth)-1 );
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
@@ -1888,11 +1889,11 @@ input for the following reasons:
pCal->setValue( CalendarFieldIndex::MONTH, std::abs(nMonth)-1 );
switch (DateFmt)
{
- case DMY:
+ case DateOrder::DMY:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(0) );
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(1) );
break;
- case YMD:
+ case DateOrder::YMD:
pCal->setValue( CalendarFieldIndex::DAY_OF_MONTH, ImplGetDay(1) );
pCal->setValue( CalendarFieldIndex::YEAR, ImplGetYear(0) );
break;
@@ -2446,7 +2447,7 @@ bool ImpSvNumberInputScan::ScanMidString( const OUString& rString,
switch (eScannedType)
{
case css::util::NumberFormat::DATE:
- if (nMonthPos == 1 && pLoc->getLongDateFormat() == MDY)
+ if (nMonthPos == 1 && pLoc->getLongDateOrder() == DateOrder::MDY)
{
// #68232# recognize long date separators like ", " in "September 5, 1999"
if (SkipString( pLoc->getLongDateDaySep(), rString, nPos ))
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index cedda8c7d73d..e7d0be0d9acf 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -62,13 +62,13 @@ public:
Depends on locale's date separator and a specific date format order.
- @param eDateFormat
+ @param eDateOrder
Evaluated only on first call during one scan process, subsequent
calls return state of nCanForceToIso8601!
@see nCanForceToIso8601
*/
- bool CanForceToIso8601( DateFormat eDateFormat );
+ bool CanForceToIso8601( DateOrder eDateOrder );
void InvalidateDateAcceptancePatterns();
@@ -402,7 +402,7 @@ private:
/** Obtain date format order, from accepted date pattern if available or
otherwise the locale's default order.
*/
- DateFormat GetDateOrder();
+ DateOrder GetDateOrder();
/** Whether input may be an ISO 8601 date format, yyyy-mm-dd...
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 086b02fe490d..e2284f83782d 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1105,7 +1105,7 @@ bool SvNumberFormatter::IsNumberFormat(const OUString& sString,
{
case css::util::NumberFormat::DATE :
// Preserve ISO 8601 input.
- if (pStringScanner->CanForceToIso8601( DMY))
+ if (pStringScanner->CanForceToIso8601( DateOrder::DMY))
{
F_Index = GetFormatIndex( NF_DATE_DIN_YYYYMMDD, ActLnge );
}
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 80841f320f16..b180eb384bee 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -4789,7 +4789,7 @@ bool SvNumberformat::HasPositiveBracketPlaceholder() const
return tmpStr[nAnz-1] == "_)";
}
-DateFormat SvNumberformat::GetDateOrder() const
+DateOrder SvNumberformat::GetDateOrder() const
{
if ( (eType & css::util::NumberFormat::DATE) == css::util::NumberFormat::DATE )
{
@@ -4801,20 +4801,20 @@ DateFormat SvNumberformat::GetDateOrder() const
{
case NF_KEY_D :
case NF_KEY_DD :
- return DMY;
+ return DateOrder::DMY;
case NF_KEY_M :
case NF_KEY_MM :
case NF_KEY_MMM :
case NF_KEY_MMMM :
case NF_KEY_MMMMM :
- return MDY;
+ return DateOrder::MDY;
case NF_KEY_YY :
case NF_KEY_YYYY :
case NF_KEY_EC :
case NF_KEY_EEC :
case NF_KEY_R :
case NF_KEY_RR :
- return YMD;
+ return DateOrder::YMD;
}
}
}
@@ -4822,7 +4822,7 @@ DateFormat SvNumberformat::GetDateOrder() const
{
SAL_WARN( "svl.numbers", "SvNumberformat::GetDateOrder: no date" );
}
- return rLoc().getDateFormat();
+ return rLoc().getDateOrder();
}
sal_uInt32 SvNumberformat::GetExactDateOrder() const