Kaydet (Commit) c564086e authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS calc06 (1.4.36); FILE MERGED

2003/03/21 22:08:16 khong 1.4.36.1: #106680# Implementing new XExtendedTransliteration interface
üst c0220e30
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: transliteration_Ignore.cxx,v $ * $RCSfile: transliteration_Ignore.cxx,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: khong $ $Date: 2002-09-16 16:31:37 $ * last change: $Author: rt $ $Date: 2003-04-08 16:06:57 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include <transliteration_Ignore.hxx> #include <transliteration_Ignore.hxx>
using namespace drafts::com::sun::star::i18n;
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace rtl; using namespace rtl;
...@@ -161,8 +162,9 @@ transliteration_Ignore::transliterateRange( const OUString& str1, const OUString ...@@ -161,8 +162,9 @@ transliteration_Ignore::transliterateRange( const OUString& str1, const OUString
} }
OUString SAL_CALL OUString SAL_CALL
transliteration_Ignore::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, transliteration_Ignore::folding( const OUString& inStr, sal_Int32 startPos,
Sequence< sal_Int32 >& offset, oneToOneMapping& table ) throw(RuntimeException) sal_Int32 nCount, Sequence< sal_Int32 >& offset)
throw(RuntimeException)
{ {
// Create a string buffer which can hold nCount + 1 characters. // Create a string buffer which can hold nCount + 1 characters.
// The reference count is 0 now. // The reference count is 0 now.
...@@ -171,60 +173,69 @@ transliteration_Ignore::transliterate( const OUString& inStr, sal_Int32 startPos ...@@ -171,60 +173,69 @@ transliteration_Ignore::transliterate( const OUString& inStr, sal_Int32 startPos
const sal_Unicode * src = inStr.getStr() + startPos; const sal_Unicode * src = inStr.getStr() + startPos;
// Allocate nCount length to offset argument. // Allocate nCount length to offset argument.
sal_Int32 *p, position;
if (useOffset) {
offset.realloc( nCount ); offset.realloc( nCount );
sal_Int32 *p = offset.getArray(); p = offset.getArray();
sal_Int32 position = startPos; position = startPos;
sal_Int32 count = 0; }
if (map) {
sal_Unicode previousChar = *src ++;
sal_Unicode currentChar;
// Translation // Translation
while (nCount -- > 0) { while (-- nCount > 0) {
sal_Unicode c = table[ *src++ ]; currentChar = *src ++;
// if the "func" returns 0xffff, skip the character.
if (c != 0xffff) { Mapping *m;
*dst ++ = c; for (m = map; m->replaceChar; m++) {
*p ++ = position; if (previousChar == m->previousChar && currentChar == m->currentChar ) {
count++; if (useOffset) {
position++;
*p++ = position++;
}
*dst++ = m->replaceChar;\
previousChar = *src++;
nCount--;
break;
} }
position ++;
} }
*dst = (sal_Unicode) 0;
offset.realloc(count);
return OUString( newStr->buffer, count); // defined in rtl/usrting. The reference count is increased from 0 to 1.
}
OUString SAL_CALL
transliteration_Ignore::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
Sequence< sal_Int32 >& offset, sal_Unicode (*func)(const sal_Unicode) ) throw(RuntimeException)
{
// Create a string buffer which can hold nCount + 1 characters.
// The reference count is 0 now.
rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
sal_Unicode * dst = newStr->buffer;
const sal_Unicode * src = inStr.getStr() + startPos;
// Allocate nCount length to offset argument. if (! m->replaceChar) {
offset.realloc( nCount ); if (useOffset)
sal_Int32 *p = offset.getArray(); *p ++ = position ++;
sal_Int32 position = startPos; *dst ++ = previousChar;
sal_Int32 count = 0; previousChar = currentChar;
}
}
if (nCount == 0) {
if (useOffset)
*p = position;
*dst ++ = previousChar;
}
newStr->length = sal_Int32(dst - newStr->buffer);
if (useOffset)
offset.realloc(newStr->length);
} else {
// Translation // Translation
while (nCount -- > 0) { while (nCount -- > 0) {
sal_Unicode c = func( *src++ ); sal_Unicode c = *src++;
// if the "func" returns 0xffff, skip the character. *dst ++ = func ? func( c) : (*table)[ c ];
if (c != 0xffff) { if (useOffset)
*dst ++ = c; *p ++ = position ++;
*p ++ = position;
count++;
} }
position ++;
} }
*dst = (sal_Unicode) 0; *dst = (sal_Unicode) 0;
offset.realloc(count); return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
return OUString( newStr->buffer, count ); // defined in rtl/usrting. The reference count is increased from 0 to 1. }
sal_Unicode SAL_CALL
transliteration_Ignore::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException)
{
return func ? func( inChar) : table ? (*table)[ inChar ] : inChar;
} }
} } } } } } } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment