[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - svl/source
Laurent Balland-Poirier
laurent.balland-poirier at laposte.net
Mon Aug 1 13:11:27 UTC 2016
svl/source/numbers/zforscan.cxx | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
New commits:
commit 24a0aa8d9c28624b4e0961726922e054554af705
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date: Wed Jul 27 09:02:46 2016 +0200
tdf#101147 Improve (again) minute/month detection
For format like HH:MM:SS MM/DD
second MM is detected as minute: see tdf#95339
New rules:
- first M following each H is minute
- first M following first S is minute
Detection Month/minute now fully compatible with Excel even with unwanted detection:
SS:MM:HH DD/MM/YY
second MM is minute even if user would expect month
Reviewed-on: https://gerrit.libreoffice.org/27560
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
(cherry picked from commit aa6bca0dfa0a58aae91eb5fa3564add642cd4238)
Conflicts:
svl/qa/unit/svl.cxx
svl/source/numbers/zforscan.cxx
Change-Id: Ia789fbc2dbd6d2dcbe9b9c34d3f288674966dd10
Reviewed-on: https://gerrit.libreoffice.org/27771
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index ccdcf30..e73d2bd 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1121,6 +1121,8 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
short eNewType;
bool bMatchBracket = false;
bool bHaveGeneral = false; // if General/Standard encountered
+ bool bIsTimeDetected =false; // hour or second found in format
+ bool bHaveMinute = false;
SkipStrings(i, nPos);
while (i < nAnzStrings)
@@ -1129,43 +1131,48 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
{ // keyword
sal_uInt16 nIndexPre;
sal_uInt16 nIndexNex;
- sal_Unicode cChar;
switch (nTypeArray[i])
{
case NF_KEY_E: // E
eNewType = css::util::NumberFormat::SCIENTIFIC;
break;
- case NF_KEY_AMPM: // AM,A,PM,P
- case NF_KEY_AP:
case NF_KEY_H: // H
case NF_KEY_HH: // HH
+ bIsTimeDetected = true;
+ // fallthru
case NF_KEY_S: // S
case NF_KEY_SS: // SS
+ if ( !bHaveMinute )
+ bIsTimeDetected = true;
+ // fallthru
+ case NF_KEY_AMPM: // AM,A,PM,P
+ case NF_KEY_AP:
eNewType = css::util::NumberFormat::TIME;
break;
case NF_KEY_M: // M
case NF_KEY_MM: // MM
/* Minute or month.
Minute if one of:
- * preceded by time keyword H or S (ignoring separators)
+ * preceded by time keyword H (ignoring separators)
* followed by time keyword S (ignoring separators)
+ * H or S was detected
* preceded by '[' amount bracket
Else month.
*/
nIndexPre = PreviousKeyword(i);
nIndexNex = NextKeyword(i);
- cChar = PreviousChar(i);
if (nIndexPre == NF_KEY_H || // H
nIndexPre == NF_KEY_HH || // HH
- nIndexPre == NF_KEY_S || // S before M tdf#95339
- nIndexPre == NF_KEY_SS || // SS
nIndexNex == NF_KEY_S || // S
nIndexNex == NF_KEY_SS || // SS
- cChar == '[' ) // [M
+ bIsTimeDetected || // tdf#101147
+ PreviousChar(i) == '[' ) // [M
{
eNewType = css::util::NumberFormat::TIME;
nTypeArray[i] -= 2; // 6 -> 4, 7 -> 5
+ bIsTimeDetected = false; // next M should be month
+ bHaveMinute = true;
}
else
{
More information about the Libreoffice-commits
mailing list