summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2019-07-12 20:45:08 +0200
committerEike Rathke <erack@redhat.com>2019-07-13 19:41:27 +0200
commit43701b20ee53ee52278acbcf611cf2b96d8e787d (patch)
tree751e075a697c64281c79f361db6d89f3dd822e9d /svl
parent73c5eb47db46acfd9818876f36f6a2cbc572e798 (diff)
Move logic to GetDateOrder()
Which saves a call to GetDatePatternOrder() in case a pattern was matched (usual case) and allows us to use the same logic in other places if needed. Change-Id: I259c7edf9fa301bf05184d0b25710edf54619a80 Reviewed-on: https://gerrit.libreoffice.org/75518 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx29
-rw-r--r--svl/source/numbers/zforfind.hxx6
2 files changed, 17 insertions, 18 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index 3fb23572b66b..63209ca04b0c 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -1555,12 +1555,15 @@ sal_uInt32 ImpSvNumberInputScan::GetDatePatternOrder()
}
-DateOrder ImpSvNumberInputScan::GetDateOrder()
+DateOrder ImpSvNumberInputScan::GetDateOrder( bool bFromFormatIfNoPattern )
{
sal_uInt32 nOrder = GetDatePatternOrder();
if (!nOrder)
{
- return pFormatter->GetLocaleData()->getDateOrder();
+ if (bFromFormatIfNoPattern && mpFormat)
+ return mpFormat->GetDateOrder();
+ else
+ return pFormatter->GetLocaleData()->getDateOrder();
}
switch ((nOrder & 0xff0000) >> 16)
{
@@ -1703,21 +1706,13 @@ bool ImpSvNumberInputScan::GetDateRef( double& fDays, sal_uInt16& nCounter )
// again is to be preferred. Both date orders can be different
// so we need to obtain the actual match. For example ISO
// YYYY-MM-DD format vs locale's DD.MM.YY input.
- if (!GetDatePatternOrder())
- {
- // No pattern match => format match.
- DateFmt = mpFormat->GetDateOrder();
- }
- else
- {
- // Pattern match. Note that patterns may have been
- // constructed from the format's locale and prepended to
- // the current locale's patterns, it doesn't necessarily
- // mean a current locale's pattern was matched, but may if
- // the format's locale's patterns didn't match, which were
- // tried first.
- DateFmt = GetDateOrder();
- }
+ // If no pattern was matched, obtain from format.
+ // Note that patterns may have been constructed from the
+ // format's locale and prepended to the current locale's
+ // patterns, it doesn't necessarily mean a current locale's
+ // pattern was matched, but may if the format's locale's
+ // patterns didn't match, which were tried first.
+ DateFmt = GetDateOrder(true);
}
break;
default:
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index dfa9b6df4ed7..db19f847c026 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -393,8 +393,12 @@ private:
/** Obtain date format order, from accepted date pattern if available or
otherwise the locale's default order.
+
+ @param bFromFormatIfNoPattern
+ If <TRUE/> and no pattern was matched, obtain date order from
+ format if available, instead from format's or current locale.
*/
- DateOrder GetDateOrder();
+ DateOrder GetDateOrder( bool bFromFormatIfNoPattern = false );
/** Whether input may be an ISO 8601 date format, yyyy-mm-dd...