stringutil.cxx (b3f79822) stringutil.cxx (c32d42b5)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 31 unchanged lines hidden (view full) ---

40 // unicode space to ascii space
41 gsep = 0x0020;
42
43 OUStringBuffer aBuf;
44 sal_Int32 n = rStr.getLength();
45 const sal_Unicode* p = rStr.getStr();
46 sal_Int32 nPosDSep = -1, nPosGSep = -1;
47 sal_uInt32 nDigitCount = 0;
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 31 unchanged lines hidden (view full) ---

40 // unicode space to ascii space
41 gsep = 0x0020;
42
43 OUStringBuffer aBuf;
44 sal_Int32 n = rStr.getLength();
45 const sal_Unicode* p = rStr.getStr();
46 sal_Int32 nPosDSep = -1, nPosGSep = -1;
47 sal_uInt32 nDigitCount = 0;
48 bool haveSeenDigit = false;
48
49 for (sal_Int32 i = 0; i < n; ++i)
50 {
51 sal_Unicode c = p[i];
52 if (c == 0x00A0)
53 // unicode space to ascii space
54 c = 0x0020;
55
56 if (sal_Unicode('0') <= c && c <= sal_Unicode('9'))
57 {
58 // this is a digit.
59 aBuf.append(c);
49
50 for (sal_Int32 i = 0; i < n; ++i)
51 {
52 sal_Unicode c = p[i];
53 if (c == 0x00A0)
54 // unicode space to ascii space
55 c = 0x0020;
56
57 if (sal_Unicode('0') <= c && c <= sal_Unicode('9'))
58 {
59 // this is a digit.
60 aBuf.append(c);
61 haveSeenDigit = true;
60 ++nDigitCount;
61 }
62 else if (c == dsep)
63 {
64 // this is a decimal separator.
65
66 if (nPosDSep >= 0)
67 // a second decimal separator -> not a valid number.

--- 8 unchanged lines hidden (view full) ---

76 nPosGSep = -1;
77 aBuf.append(c);
78 nDigitCount = 0;
79 }
80 else if (c == gsep)
81 {
82 // this is a group (thousand) separator.
83
62 ++nDigitCount;
63 }
64 else if (c == dsep)
65 {
66 // this is a decimal separator.
67
68 if (nPosDSep >= 0)
69 // a second decimal separator -> not a valid number.

--- 8 unchanged lines hidden (view full) ---

78 nPosGSep = -1;
79 aBuf.append(c);
80 nDigitCount = 0;
81 }
82 else if (c == gsep)
83 {
84 // this is a group (thousand) separator.
85
84 if (i == 0)
85 // not allowed as the first character.
86 if (!haveSeenDigit)
87 // not allowed before digits.
86 return false;
87
88 if (nPosDSep >= 0)
89 // not allowed after the decimal separator.
90 return false;
91
92 if (nPosGSep >= 0 && nDigitCount != 3)
93 // must be exactly 3 digits since the last group separator.

--- 31 unchanged lines hidden ---
88 return false;
89
90 if (nPosDSep >= 0)
91 // not allowed after the decimal separator.
92 return false;
93
94 if (nPosGSep >= 0 && nDigitCount != 3)
95 // must be exactly 3 digits since the last group separator.

--- 31 unchanged lines hidden ---