nativenumbersupplier.cxx (926c4440) nativenumbersupplier.cxx (4674bdb9)
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

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

68namespace com { namespace sun { namespace star { namespace i18n {
69
70OUString SAL_CALL getHebrewNativeNumberString(const OUString& aNumberString, sal_Bool useGeresh);
71
72OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
73 Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int16 number ) throw(RuntimeException)
74{
75 const sal_Unicode *src = inStr.getStr() + startPos;
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

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

68namespace com { namespace sun { namespace star { namespace i18n {
69
70OUString SAL_CALL getHebrewNativeNumberString(const OUString& aNumberString, sal_Bool useGeresh);
71
72OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
73 Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int16 number ) throw(RuntimeException)
74{
75 const sal_Unicode *src = inStr.getStr() + startPos;
76 rtl_uString *newStr = x_rtl_uString_new_WithLength(nCount);
76 rtl_uString *newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
77 if (useOffset)
78 offset.realloc(nCount);
79
80 for (sal_Int32 i = 0; i < nCount; i++) {
81 sal_Unicode ch = src[i];
82 if (isNumber(ch))
83 newStr->buffer[i] = NumberChar[number][ ch - NUMBER_ZERO ];
84 else if (i+1 < nCount && isNumber(src[i+1])) {
85 if (i > 0 && isNumber(src[i-1]) && isSeparator(ch))
86 newStr->buffer[i] = SeparatorChar[number] ? SeparatorChar[number] : ch;
87 else
88 newStr->buffer[i] = isDecimal(ch) ? (DecimalChar[number] ? DecimalChar[number] : ch) :
89 isMinus(ch) ? (MinusChar[number] ? MinusChar[number] : ch) : ch;
90 }
91 else
92 newStr->buffer[i] = ch;
93 if (useOffset)
94 offset[i] = startPos + i;
95 }
77 if (useOffset)
78 offset.realloc(nCount);
79
80 for (sal_Int32 i = 0; i < nCount; i++) {
81 sal_Unicode ch = src[i];
82 if (isNumber(ch))
83 newStr->buffer[i] = NumberChar[number][ ch - NUMBER_ZERO ];
84 else if (i+1 < nCount && isNumber(src[i+1])) {
85 if (i > 0 && isNumber(src[i-1]) && isSeparator(ch))
86 newStr->buffer[i] = SeparatorChar[number] ? SeparatorChar[number] : ch;
87 else
88 newStr->buffer[i] = isDecimal(ch) ? (DecimalChar[number] ? DecimalChar[number] : ch) :
89 isMinus(ch) ? (MinusChar[number] ? MinusChar[number] : ch) : ch;
90 }
91 else
92 newStr->buffer[i] = ch;
93 if (useOffset)
94 offset[i] = startPos + i;
95 }
96 return OUString( newStr, SAL_NO_ACQUIRE);
96 return OUString( newStr, SAL_NO_ACQUIRE); // take over ownership of <newStr>
97}
98
99sal_Bool SAL_CALL AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, sal_Int32 len,
100 sal_Unicode *dst, sal_Int32& count, sal_Int16 multiChar_index, Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int32 startPos,
101 Number *number, sal_Unicode* numberChar)
102{
103 sal_Unicode multiChar = (multiChar_index == -1 ? 0 : number->multiplierChar[multiChar_index]);
104 if ( len <= number->multiplierExponent[number->exponentCount-1] ) {

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

241 offset[count] = i + startPos;
242 count++;
243 }
244 }
245 }
246
247 if (useOffset)
248 offset.realloc(count);
97}
98
99sal_Bool SAL_CALL AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, sal_Int32 len,
100 sal_Unicode *dst, sal_Int32& count, sal_Int16 multiChar_index, Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int32 startPos,
101 Number *number, sal_Unicode* numberChar)
102{
103 sal_Unicode multiChar = (multiChar_index == -1 ? 0 : number->multiplierChar[multiChar_index]);
104 if ( len <= number->multiplierExponent[number->exponentCount-1] ) {

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

241 offset[count] = i + startPos;
242 count++;
243 }
244 }
245 }
246
247 if (useOffset)
248 offset.realloc(count);
249 return OUString(newStr->buffer, count);
249 OUString resultStr( newStr->buffer, count );
250 x_rtl_uString_release( newStr );
251 x_rtl_uString_release( srcStr );
252 return resultStr;
250 }
251 return OUString();
252}
253static void SAL_CALL NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_Unicode *str,
254 sal_Int32& i, sal_Int32 nCount, sal_Unicode *dst, sal_Int32& count, Sequence< sal_Int32 >& offset, sal_Bool useOffset,
255 OUString& numberChar, OUString& multiplierChar)
256{
257 sal_Int16 curr = 0, num = 0, end = 0, shift = 0;

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

304{
305 sal_Int32 strLen = inStr.getLength() - startPos;
306
307 if (nCount > strLen)
308 nCount = strLen;
309
310 if (nCount > 0) {
311 const sal_Unicode *str = inStr.getStr() + startPos;
253 }
254 return OUString();
255}
256static void SAL_CALL NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_Unicode *str,
257 sal_Int32& i, sal_Int32 nCount, sal_Unicode *dst, sal_Int32& count, Sequence< sal_Int32 >& offset, sal_Bool useOffset,
258 OUString& numberChar, OUString& multiplierChar)
259{
260 sal_Int16 curr = 0, num = 0, end = 0, shift = 0;

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

307{
308 sal_Int32 strLen = inStr.getLength() - startPos;
309
310 if (nCount > strLen)
311 nCount = strLen;
312
313 if (nCount > 0) {
314 const sal_Unicode *str = inStr.getStr() + startPos;
312 rtl_uString *newStr = x_rtl_uString_new_WithLength(nCount * MultiplierExponent_7_CJK[0] + 1);
315 rtl_uString *newStr = x_rtl_uString_new_WithLength( nCount * MultiplierExponent_7_CJK[0] + 1 );
313 if (useOffset)
314 offset.realloc( nCount * MultiplierExponent_7_CJK[0] + 1 );
315 sal_Int32 count = 0, index;
316 sal_Int32 i;
317
318 OUString numberChar, multiplierChar, decimalChar, minusChar, separatorChar;
319 numberChar = OUString((sal_Unicode*)NumberChar, 10*NumberChar_Count);
320 multiplierChar = OUString((sal_Unicode*) MultiplierChar_7_CJK, ExponentCount_7_CJK*Multiplier_Count);

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

362 }
363 }
364
365 if (useOffset) {
366 offset.realloc(count);
367 for (i = 0; i < count; i++)
368 offset[i] += startPos;
369 }
316 if (useOffset)
317 offset.realloc( nCount * MultiplierExponent_7_CJK[0] + 1 );
318 sal_Int32 count = 0, index;
319 sal_Int32 i;
320
321 OUString numberChar, multiplierChar, decimalChar, minusChar, separatorChar;
322 numberChar = OUString((sal_Unicode*)NumberChar, 10*NumberChar_Count);
323 multiplierChar = OUString((sal_Unicode*) MultiplierChar_7_CJK, ExponentCount_7_CJK*Multiplier_Count);

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

365 }
366 }
367
368 if (useOffset) {
369 offset.realloc(count);
370 for (i = 0; i < count; i++)
371 offset[i] += startPos;
372 }
370 return OUString(newStr->buffer, count);
373 OUString resultStr( newStr->buffer, count );
374 x_rtl_uString_release( newStr );
375 return resultStr;
371 }
372 return OUString();
373}
374
375static Number natnum4[4] = {
376 { NumberChar_Lower_zh, MultiplierChar_6_CJK[Multiplier_Lower_zh], 0,
377 ExponentCount_6_CJK, MultiplierExponent_6_CJK },
378 { NumberChar_Lower_zh, MultiplierChar_6_CJK[Multiplier_Lower_zh_TW], 0,

--- 535 unchanged lines hidden ---
376 }
377 return OUString();
378}
379
380static Number natnum4[4] = {
381 { NumberChar_Lower_zh, MultiplierChar_6_CJK[Multiplier_Lower_zh], 0,
382 ExponentCount_6_CJK, MultiplierExponent_6_CJK },
383 { NumberChar_Lower_zh, MultiplierChar_6_CJK[Multiplier_Lower_zh_TW], 0,

--- 535 unchanged lines hidden ---