svl/source/numbers/zforfind.cxx | 29 ++++++++++++----------------- svl/source/numbers/zforfind.hxx | 6 +++++- 2 files changed, 17 insertions(+), 18 deletions(-)
New commits: commit 43701b20ee53ee52278acbcf611cf2b96d8e787d Author: Eike Rathke <er...@redhat.com> AuthorDate: Fri Jul 12 20:45:08 2019 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Sat Jul 13 19:41:27 2019 +0200 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 <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> 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... _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits