Lines 94-141
extern USHORT nScFillModeMouseModifier; // global.cxx
Link Here
|
94 |
|
94 |
|
95 |
short lcl_DecompValueString( String& aValue, sal_Int32& nVal, USHORT* pMinDigits = NULL ) |
95 |
short lcl_DecompValueString( String& aValue, sal_Int32& nVal, USHORT* pMinDigits = NULL ) |
96 |
{ |
96 |
{ |
97 |
if ( !aValue.Len() ) |
97 |
xub_StrLen nLen = aValue.Len(); |
|
|
98 |
if (!nLen) |
98 |
{ |
99 |
{ |
99 |
nVal = 0; |
100 |
nVal = 0; |
100 |
return 0; |
101 |
return 0; |
101 |
} |
102 |
} |
102 |
const sal_Unicode* p = aValue.GetBuffer(); |
103 |
const sal_Unicode* p = aValue.GetBuffer(); |
103 |
xub_StrLen nNeg = 0; |
104 |
xub_StrLen nSign = (p[0] == '+' || p[0] == '-') ? 1 : 0; |
104 |
xub_StrLen nNum = 0; |
105 |
xub_StrLen nDot = nLen, nFirst = nLen; |
105 |
if ( p[nNum] == '-' ) |
106 |
String aBuf; |
106 |
nNum = nNeg = 1; |
107 |
bool bLeadingNum = true; |
107 |
while ( p[nNum] && CharClass::isAsciiNumeric( p[nNum] ) ) |
108 |
for (xub_StrLen i = nSign; i < nLen; ++i) |
108 |
nNum++; |
109 |
{ |
109 |
if ( nNum > nNeg ) |
110 |
sal_Unicode c = p[i]; |
110 |
{ // number at the beginning |
111 |
if (CharClass::isAsciiNumeric(c) && c != '+' && c != '-') |
111 |
nVal = aValue.Copy( 0, nNum ).ToInt32(); |
112 |
{ |
112 |
// #60893# any number with a leading zero sets the minimum number of digits |
113 |
aBuf.Append(c); |
113 |
if ( p[nNeg] == '0' && pMinDigits && ( nNum - nNeg > *pMinDigits ) ) |
114 |
continue; |
114 |
*pMinDigits = nNum - nNeg; |
115 |
} |
115 |
aValue.Erase( 0, nNum ); |
116 |
else |
116 |
return -1; |
117 |
{ |
117 |
} |
118 |
if (bLeadingNum) |
118 |
else |
119 |
bLeadingNum = false; |
119 |
{ |
120 |
else |
120 |
nNeg = 0; |
121 |
aBuf.Erase(); |
121 |
xub_StrLen nEnd = nNum = aValue.Len() - 1; |
122 |
} |
122 |
while ( nNum && CharClass::isAsciiNumeric( p[nNum] ) ) |
123 |
|
123 |
nNum--; |
124 |
if (nFirst == nLen) |
124 |
if ( p[nNum] == '-' ) |
125 |
nFirst = i; |
125 |
{ |
126 |
|
126 |
nNum--; |
127 |
if (c == '.') |
127 |
nNeg = 1; |
128 |
{ |
128 |
} |
129 |
// if it's a dot, erase the buffer and keep going. |
129 |
if ( nNum < nEnd - nNeg ) |
130 |
aBuf.Erase(); |
130 |
{ // number at the end |
131 |
nDot = i; |
131 |
nVal = aValue.Copy( nNum + 1 ).ToInt32(); |
132 |
continue; |
132 |
// #60893# any number with a leading zero sets the minimum number of digits |
133 |
} |
133 |
if ( p[nNum+1+nNeg] == '0' && pMinDigits && ( nEnd - nNum - nNeg > *pMinDigits ) ) |
134 |
else if (aBuf.Len()) |
134 |
*pMinDigits = nEnd - nNum - nNeg; |
135 |
{ |
135 |
aValue.Erase( nNum + 1 ); |
136 |
// leading number |
136 |
return 1; |
137 |
if (nDot < nLen) |
137 |
} |
138 |
{ |
138 |
} |
139 |
// If a dot has been previously encountered, then use the |
|
|
140 |
// first numerical segment. |
141 |
i = nFirst; |
142 |
aBuf = aValue.Copy(0, nFirst); |
143 |
} |
144 |
|
145 |
nVal = aBuf.ToInt32(); |
146 |
if (nSign && p[0] == '-') |
147 |
nVal *= -1; |
148 |
aValue.Erase(0, i); |
149 |
if (pMinDigits) |
150 |
*pMinDigits = i - nSign; |
151 |
return -1; |
152 |
} |
153 |
} |
154 |
if (aBuf.Len()) |
155 |
{ |
156 |
// trailing number. |
157 |
xub_StrLen nBufLen = aBuf.Len(); |
158 |
nVal = aBuf.ToInt32(); |
159 |
aValue.Erase(nLen - nBufLen); |
160 |
if (pMinDigits) |
161 |
*pMinDigits = nBufLen; |
162 |
return 1; |
163 |
} |
164 |
|
139 |
nVal = 0; |
165 |
nVal = 0; |
140 |
return 0; |
166 |
return 0; |
141 |
} |
167 |
} |