[Libreoffice-commits] core.git: 3 commits - svl/source
Eike Rathke
erack at redhat.com
Wed Aug 30 09:11:08 UTC 2017
svl/source/numbers/zforfind.cxx | 60 ++++++++++++++++++++++++----------------
svl/source/numbers/zforfind.hxx | 21 +++-----------
2 files changed, 42 insertions(+), 39 deletions(-)
New commits:
commit 1cfe6a904d3349413173f5d412c280936f938a9e
Author: Eike Rathke <erack at redhat.com>
Date: Wed Aug 30 11:02:59 2017 +0200
Resolves: tdf#91758 more stringent check for ISO date like looking input
Already check at the end of input analysis whether it could be an ISO date to
not apply x-y-z onto MDY or DMY later. For an acceptable ISO input, apart from
M and D restrictions, Y-M-D year numbers must be greater than 12 in MDY order
or greater than 31 in DMY order, or have at least 3 digits (possibly leading 0).
Change-Id: I8d3eb7e2403421469050850e45d1db5c0be018f5
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 4c4d70e64d39..61af0c9c3c6a 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -1074,6 +1074,24 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder )
}
+bool ImpSvNumberInputScan::IsAcceptableIso8601( const SvNumberformat* pFormat )
+{
+ if (pFormat && (pFormat->GetType() & css::util::NumberFormat::DATE))
+ {
+ switch (pFormatter->GetEvalDateFormat())
+ {
+ case NF_EVALDATEFORMAT_INTL:
+ return CanForceToIso8601( GetDateOrder());
+ case NF_EVALDATEFORMAT_FORMAT:
+ return CanForceToIso8601( pFormat->GetDateOrder());
+ default:
+ return CanForceToIso8601( GetDateOrder()) || CanForceToIso8601( pFormat->GetDateOrder());
+ }
+ }
+ return CanForceToIso8601( GetDateOrder());
+}
+
+
bool ImpSvNumberInputScan::MayBeMonthDate()
{
if (nMayBeMonthDate == 0)
@@ -3631,7 +3649,7 @@ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString, // s
// not. The count of numbers in pattern must match the
// count of numbers in input.
res = (GetDatePatternNumbers() == nNumericsCnt)
- || MayBeIso8601() || nMatchedAllStrings;
+ || IsAcceptableIso8601( pFormat) || nMatchedAllStrings;
}
}
break;
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index 6a4ebf7ee9f2..a6fc36a12cb2 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -412,6 +412,11 @@ private:
@see nMayBeMonthDate
*/
bool MayBeMonthDate();
+
+ /** Whether input is acceptable as ISO 8601 date format in the current
+ NfEvalDateFormat setting.
+ */
+ bool IsAcceptableIso8601( const SvNumberformat* pFormat );
};
#endif // INCLUDED_SVL_SOURCE_NUMBERS_ZFORFIND_HXX
commit 6254fbf8a76a0d8edb290b03e0632ef6513a8d98
Author: Eike Rathke <erack at redhat.com>
Date: Tue Aug 29 18:31:04 2017 +0200
Related: tdf#91758 shortcut CanForceToIso8601() for MayBeIso8601() results
Change-Id: I3cd6967931abcbf806a539a19f7f9371398567c2
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 2c6bf47ce297..4c4d70e64d39 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -1039,11 +1039,11 @@ bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder )
int nCanForceToIso8601 = 0;
if (!MayBeIso8601())
{
- nCanForceToIso8601 = 1;
+ return false;
}
else if (nMayBeIso8601 >= 3)
{
- nCanForceToIso8601 = 2; // at least 3 digits in year
+ return true; // at least 3 digits in year
}
else
{
commit ae6c5083f04f8fad299cdc7a6b6558f1270cc619
Author: Eike Rathke <erack at redhat.com>
Date: Tue Aug 29 18:24:05 2017 +0200
Related: tdf#91758 don't remember nCanForceToIso8601 state
CanForceToIso8601() can be called twice for different DateOrder.
Change-Id: I656d499b8a557814326fe71333fcb644c7d3e909
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index cc4f160ee1d0..2c6bf47ce297 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -124,7 +124,6 @@ void ImpSvNumberInputScan::Reset()
nAcceptedDatePattern = -2;
nDatePatternStart = 0;
nDatePatternNumbers = 0;
- nCanForceToIso8601 = 0;
for (sal_uInt32 i = 0; i < SV_MAX_COUNT_INPUT_STRINGS; i++)
{
@@ -1037,42 +1036,39 @@ bool ImpSvNumberInputScan::MayBeIso8601()
bool ImpSvNumberInputScan::CanForceToIso8601( DateOrder eDateOrder )
{
- if (nCanForceToIso8601 == 0)
+ int nCanForceToIso8601 = 0;
+ if (!MayBeIso8601())
{
+ nCanForceToIso8601 = 1;
+ }
+ else if (nMayBeIso8601 >= 3)
+ {
+ nCanForceToIso8601 = 2; // at least 3 digits in year
+ }
+ else
+ {
+ nCanForceToIso8601 = 1;
+ }
- if (!MayBeIso8601())
- {
- nCanForceToIso8601 = 1;
- }
- else if (nMayBeIso8601 >= 3)
- {
- nCanForceToIso8601 = 2; // at least 3 digits in year
- }
- else
- {
- nCanForceToIso8601 = 1;
- }
-
- sal_Int32 n;
- switch (eDateOrder)
- {
+ sal_Int32 n;
+ switch (eDateOrder)
+ {
case DateOrder::DMY: // "day" value out of range => ISO 8601 year
if ((n = sStrArray[nNums[0]].toInt32()) < 1 || n > 31)
{
nCanForceToIso8601 = 2;
}
- break;
+ break;
case DateOrder::MDY: // "month" value out of range => ISO 8601 year
if ((n = sStrArray[nNums[0]].toInt32()) < 1 || n > 12)
{
nCanForceToIso8601 = 2;
}
- break;
+ break;
case DateOrder::YMD: // always possible
nCanForceToIso8601 = 2;
- break;
+ break;
default: break;
- }
}
return nCanForceToIso8601 > 1;
}
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index 0ea6c18d03bb..6a4ebf7ee9f2 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -62,12 +62,6 @@ public:
/** Whether input can be forced to ISO 8601 format.
Depends on locale's date separator and a specific date format order.
-
- @param eDateOrder
- Evaluated only on first call during one scan process, subsequent
- calls return state of nCanForceToIso8601!
-
- @see nCanForceToIso8601
*/
bool CanForceToIso8601( DateOrder eDateOrder );
@@ -143,16 +137,6 @@ private:
*/
sal_uInt8 nMayBeIso8601;
- /** State of ISO 8601 can be forced.
-
- 0:= don't know yet
- 1:= no
- 2:= yes
-
- @see CanForceToIso8601()
- */
- sal_uInt8 nCanForceToIso8601;
-
/** State of dd-month-yy or yy-month-dd detection, with month name.
0:= don't know yet
More information about the Libreoffice-commits
mailing list