summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-09-05 14:56:08 +0200
committerEike Rathke <erack@redhat.com>2013-09-05 14:57:29 +0200
commit660fe83b4357c9fa070739b9c4da9d9002c9bd51 (patch)
tree36a6dd9b686aaea54d0a6fe5475697515bea0e6a /i18npool
parent34af964c640c14db9f4890414641595e9af34696 (diff)
use sensible indentation
that always annoyed me Change-Id: I0c439ddb00d78590b465cd47db6e60d1939bd9f7
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/source/breakiterator/breakiteratorImpl.cxx632
-rw-r--r--i18npool/source/breakiterator/breakiterator_cjk.cxx124
-rw-r--r--i18npool/source/breakiterator/breakiterator_unicode.cxx282
-rw-r--r--i18npool/source/breakiterator/xdictionary.cxx164
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx828
-rw-r--r--i18npool/source/characterclassification/characterclassificationImpl.cxx136
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx146
-rw-r--r--i18npool/source/indexentry/indexentrysupplier.cxx162
-rw-r--r--i18npool/source/inputchecker/inputsequencechecker.cxx104
-rw-r--r--i18npool/source/nativenumber/nativenumbersupplier.cxx888
-rw-r--r--i18npool/source/transliteration/hiraganaToKatakana.cxx18
-rw-r--r--i18npool/source/transliteration/ignoreBaFa_ja_JP.cxx20
-rw-r--r--i18npool/source/transliteration/ignoreHyuByu_ja_JP.cxx20
-rw-r--r--i18npool/source/transliteration/ignoreMiddleDot_ja_JP.cxx10
-rw-r--r--i18npool/source/transliteration/ignoreMinusSign_ja_JP.cxx10
-rw-r--r--i18npool/source/transliteration/ignoreSeZe_ja_JP.cxx30
-rw-r--r--i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx12
-rw-r--r--i18npool/source/transliteration/ignoreSpace_ja_JP.cxx10
-rw-r--r--i18npool/source/transliteration/ignoreTiJi_ja_JP.cxx38
-rw-r--r--i18npool/source/transliteration/ignoreTraditionalKana_ja_JP.cxx10
-rw-r--r--i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx12
-rw-r--r--i18npool/source/transliteration/ignoreZiZu_ja_JP.cxx10
-rw-r--r--i18npool/source/transliteration/transliteration_Ignore.cxx98
-rw-r--r--i18npool/source/transliteration/transliteration_Numeric.cxx122
-rw-r--r--i18npool/source/transliteration/transliteration_body.cxx24
-rw-r--r--i18npool/source/transliteration/transliteration_commonclass.cxx94
26 files changed, 2004 insertions, 2000 deletions
diff --git a/i18npool/source/breakiterator/breakiteratorImpl.cxx b/i18npool/source/breakiterator/breakiteratorImpl.cxx
index 595c921d46b5..4235027feeca 100644
--- a/i18npool/source/breakiterator/breakiteratorImpl.cxx
+++ b/i18npool/source/breakiterator/breakiteratorImpl.cxx
@@ -39,10 +39,10 @@ BreakIteratorImpl::BreakIteratorImpl()
BreakIteratorImpl::~BreakIteratorImpl()
{
- // Clear lookuptable
- for (size_t l = 0; l < lookupTable.size(); l++)
- delete lookupTable[l];
- lookupTable.clear();
+ // Clear lookuptable
+ for (size_t l = 0; l < lookupTable.size(); l++)
+ delete lookupTable[l];
+ lookupTable.clear();
}
#define LBI getLocaleSpecificBreakIterator(rLocale)
@@ -51,75 +51,75 @@ sal_Int32 SAL_CALL BreakIteratorImpl::nextCharacters( const OUString& Text, sal_
const Locale &rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone )
throw(RuntimeException)
{
- if (nCount < 0) throw RuntimeException();
+ if (nCount < 0) throw RuntimeException();
- return LBI->nextCharacters( Text, nStartPos, rLocale, nCharacterIteratorMode, nCount, nDone);
+ return LBI->nextCharacters( Text, nStartPos, rLocale, nCharacterIteratorMode, nCount, nDone);
}
sal_Int32 SAL_CALL BreakIteratorImpl::previousCharacters( const OUString& Text, sal_Int32 nStartPos,
const Locale& rLocale, sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone )
throw(RuntimeException)
{
- if (nCount < 0) throw RuntimeException();
+ if (nCount < 0) throw RuntimeException();
- return LBI->previousCharacters( Text, nStartPos, rLocale, nCharacterIteratorMode, nCount, nDone);
+ return LBI->previousCharacters( Text, nStartPos, rLocale, nCharacterIteratorMode, nCount, nDone);
}
#define isZWSP(c) (ch == 0x200B)
static sal_Int32 skipSpace(const OUString& Text, sal_Int32 nPos, sal_Int32 len, sal_Int16 rWordType, sal_Bool bDirection)
{
- sal_uInt32 ch=0;
- sal_Int32 pos=nPos;
- switch (rWordType) {
- case WordType::ANYWORD_IGNOREWHITESPACES:
- if (bDirection)
- while (nPos < len && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, 1)) || isZWSP(ch))) nPos=pos;
- else
- while (nPos > 0 && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, -1)) || isZWSP(ch))) nPos=pos;
+ sal_uInt32 ch=0;
+ sal_Int32 pos=nPos;
+ switch (rWordType) {
+ case WordType::ANYWORD_IGNOREWHITESPACES:
+ if (bDirection)
+ while (nPos < len && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, 1)) || isZWSP(ch))) nPos=pos;
+ else
+ while (nPos > 0 && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, -1)) || isZWSP(ch))) nPos=pos;
break;
- case WordType::DICTIONARY_WORD:
- if (bDirection)
- while (nPos < len && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, 1)) || isZWSP(ch) ||
+ case WordType::DICTIONARY_WORD:
+ if (bDirection)
+ while (nPos < len && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, 1)) || isZWSP(ch) ||
! (ch == 0x002E || u_isalnum(ch)))) nPos=pos;
- else
- while (nPos > 0 && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, -1)) || isZWSP(ch) ||
+ else
+ while (nPos > 0 && (u_isWhitespace(ch = Text.iterateCodePoints(&pos, -1)) || isZWSP(ch) ||
! (ch == 0x002E || u_isalnum(ch)))) nPos=pos;
break;
- case WordType::WORD_COUNT:
- if (bDirection)
- while (nPos < len && (u_isUWhiteSpace(ch = Text.iterateCodePoints(&pos, 1)) || isZWSP(ch))) nPos=pos;
- else
- while (nPos > 0 && (u_isUWhiteSpace(ch = Text.iterateCodePoints(&pos, -1)) || isZWSP(ch))) nPos=pos;
+ case WordType::WORD_COUNT:
+ if (bDirection)
+ while (nPos < len && (u_isUWhiteSpace(ch = Text.iterateCodePoints(&pos, 1)) || isZWSP(ch))) nPos=pos;
+ else
+ while (nPos > 0 && (u_isUWhiteSpace(ch = Text.iterateCodePoints(&pos, -1)) || isZWSP(ch))) nPos=pos;
break;
- }
- return nPos;
+ }
+ return nPos;
}
Boundary SAL_CALL BreakIteratorImpl::nextWord( const OUString& Text, sal_Int32 nStartPos,
const Locale& rLocale, sal_Int16 rWordType ) throw(RuntimeException)
{
- sal_Int32 len = Text.getLength();
- if( nStartPos < 0 || len == 0 )
- result.endPos = result.startPos = 0;
- else if (nStartPos >= len)
- result.endPos = result.startPos = len;
- else {
- result = LBI->nextWord(Text, nStartPos, rLocale, rWordType);
-
- nStartPos = skipSpace(Text, result.startPos, len, rWordType, sal_True);
-
- if ( nStartPos != result.startPos) {
- if( nStartPos >= len )
- result.startPos = result.endPos = len;
- else {
- result = LBI->getWordBoundary(Text, nStartPos, rLocale, rWordType, sal_True);
- // i88041: avoid startPos goes back to nStartPos when switching between Latin and CJK scripts
- if (result.startPos < nStartPos) result.startPos = nStartPos;
- }
+ sal_Int32 len = Text.getLength();
+ if( nStartPos < 0 || len == 0 )
+ result.endPos = result.startPos = 0;
+ else if (nStartPos >= len)
+ result.endPos = result.startPos = len;
+ else {
+ result = LBI->nextWord(Text, nStartPos, rLocale, rWordType);
+
+ nStartPos = skipSpace(Text, result.startPos, len, rWordType, sal_True);
+
+ if ( nStartPos != result.startPos) {
+ if( nStartPos >= len )
+ result.startPos = result.endPos = len;
+ else {
+ result = LBI->getWordBoundary(Text, nStartPos, rLocale, rWordType, sal_True);
+ // i88041: avoid startPos goes back to nStartPos when switching between Latin and CJK scripts
+ if (result.startPos < nStartPos) result.startPos = nStartPos;
}
}
- return result;
+ }
+ return result;
}
static inline sal_Bool SAL_CALL isCJK( const Locale& rLocale ) {
@@ -129,124 +129,124 @@ static inline sal_Bool SAL_CALL isCJK( const Locale& rLocale ) {
Boundary SAL_CALL BreakIteratorImpl::previousWord( const OUString& Text, sal_Int32 nStartPos,
const Locale& rLocale, sal_Int16 rWordType) throw(RuntimeException)
{
- sal_Int32 len = Text.getLength();
- if( nStartPos <= 0 || len == 0 ) {
- result.endPos = result.startPos = 0;
- return result;
- } else if (nStartPos > len) {
- result.endPos = result.startPos = len;
- return result;
- }
+ sal_Int32 len = Text.getLength();
+ if( nStartPos <= 0 || len == 0 ) {
+ result.endPos = result.startPos = 0;
+ return result;
+ } else if (nStartPos > len) {
+ result.endPos = result.startPos = len;
+ return result;
+ }
- sal_Int32 nPos = skipSpace(Text, nStartPos, len, rWordType, sal_False);
+ sal_Int32 nPos = skipSpace(Text, nStartPos, len, rWordType, sal_False);
- // if some spaces are skiped, and the script type is Asian with no CJK rLocale, we have to return
- // (nStartPos, -1) for caller to send correct rLocale for loading correct dictionary.
- result.startPos = nPos;
- if (nPos != nStartPos && nPos > 0 && !isCJK(rLocale) && getScriptClass(Text.iterateCodePoints(&nPos, -1)) == ScriptType::ASIAN) {
- result.endPos = -1;
- return result;
- }
+ // if some spaces are skiped, and the script type is Asian with no CJK rLocale, we have to return
+ // (nStartPos, -1) for caller to send correct rLocale for loading correct dictionary.
+ result.startPos = nPos;
+ if (nPos != nStartPos && nPos > 0 && !isCJK(rLocale) && getScriptClass(Text.iterateCodePoints(&nPos, -1)) == ScriptType::ASIAN) {
+ result.endPos = -1;
+ return result;
+ }
- return LBI->previousWord(Text, result.startPos, rLocale, rWordType);
+ return LBI->previousWord(Text, result.startPos, rLocale, rWordType);
}
Boundary SAL_CALL BreakIteratorImpl::getWordBoundary( const OUString& Text, sal_Int32 nPos, const Locale& rLocale,
sal_Int16 rWordType, sal_Bool bDirection ) throw(RuntimeException)
{
- sal_Int32 len = Text.getLength();
- if( nPos < 0 || len == 0 )
+ sal_Int32 len = Text.getLength();
+ if( nPos < 0 || len == 0 )
+ result.endPos = result.startPos = 0;
+ else if (nPos > len)
+ result.endPos = result.startPos = len;
+ else {
+ sal_Int32 next, prev;
+ next = skipSpace(Text, nPos, len, rWordType, sal_True);
+ prev = skipSpace(Text, nPos, len, rWordType, sal_False);
+ if (prev == 0 && next == len) {
+ result.endPos = result.startPos = nPos;
+ } else if (prev == 0 && ! bDirection) {
result.endPos = result.startPos = 0;
- else if (nPos > len)
+ } else if (next == len && bDirection) {
result.endPos = result.startPos = len;
- else {
- sal_Int32 next, prev;
- next = skipSpace(Text, nPos, len, rWordType, sal_True);
- prev = skipSpace(Text, nPos, len, rWordType, sal_False);
- if (prev == 0 && next == len) {
- result.endPos = result.startPos = nPos;
- } else if (prev == 0 && ! bDirection) {
- result.endPos = result.startPos = 0;
- } else if (next == len && bDirection) {
- result.endPos = result.startPos = len;
- } else {
- if (next != prev) {
- if (next == nPos && next != len)
- bDirection = sal_True;
- else if (prev == nPos && prev != 0)
- bDirection = sal_False;
- else
- nPos = bDirection ? next : prev;
- }
- result = LBI->getWordBoundary(Text, nPos, rLocale, rWordType, bDirection);
+ } else {
+ if (next != prev) {
+ if (next == nPos && next != len)
+ bDirection = sal_True;
+ else if (prev == nPos && prev != 0)
+ bDirection = sal_False;
+ else
+ nPos = bDirection ? next : prev;
}
+ result = LBI->getWordBoundary(Text, nPos, rLocale, rWordType, bDirection);
}
- return result;
+ }
+ return result;
}
sal_Bool SAL_CALL BreakIteratorImpl::isBeginWord( const OUString& Text, sal_Int32 nPos,
const Locale& rLocale, sal_Int16 rWordType ) throw(RuntimeException)
{
- sal_Int32 len = Text.getLength();
+ sal_Int32 len = Text.getLength();
- if (nPos < 0 || nPos >= len) return sal_False;
+ if (nPos < 0 || nPos >= len) return sal_False;
- sal_Int32 tmp = skipSpace(Text, nPos, len, rWordType, sal_True);
+ sal_Int32 tmp = skipSpace(Text, nPos, len, rWordType, sal_True);
- if (tmp != nPos) return sal_False;
+ if (tmp != nPos) return sal_False;
- result = getWordBoundary(Text, nPos, rLocale, rWordType, sal_True);
+ result = getWordBoundary(Text, nPos, rLocale, rWordType, sal_True);
- return result.startPos == nPos;
+ return result.startPos == nPos;
}
sal_Bool SAL_CALL BreakIteratorImpl::isEndWord( const OUString& Text, sal_Int32 nPos,
const Locale& rLocale, sal_Int16 rWordType ) throw(RuntimeException)
{
- sal_Int32 len = Text.getLength();
+ sal_Int32 len = Text.getLength();
- if (nPos <= 0 || nPos > len) return sal_False;
+ if (nPos <= 0 || nPos > len) return sal_False;
- sal_Int32 tmp = skipSpace(Text, nPos, len, rWordType, sal_False);
+ sal_Int32 tmp = skipSpace(Text, nPos, len, rWordType, sal_False);
- if (tmp != nPos) return sal_False;
+ if (tmp != nPos) return sal_False;
- result = getWordBoundary(Text, nPos, rLocale, rWordType, sal_False);
+ result = getWordBoundary(Text, nPos, rLocale, rWordType, sal_False);
- return result.endPos == nPos;
+ return result.endPos == nPos;
}
sal_Int32 SAL_CALL BreakIteratorImpl::beginOfSentence( const OUString& Text, sal_Int32 nStartPos,
const Locale &rLocale ) throw(RuntimeException)
{
- if (nStartPos < 0 || nStartPos > Text.getLength())
- return -1;
- if (Text.isEmpty()) return 0;
- return LBI->beginOfSentence(Text, nStartPos, rLocale);
+ if (nStartPos < 0 || nStartPos > Text.getLength())
+ return -1;
+ if (Text.isEmpty()) return 0;
+ return LBI->beginOfSentence(Text, nStartPos, rLocale);
}
sal_Int32 SAL_CALL BreakIteratorImpl::endOfSentence( const OUString& Text, sal_Int32 nStartPos,
const Locale &rLocale ) throw(RuntimeException)
{
- if (nStartPos < 0 || nStartPos > Text.getLength())
- return -1;
- if (Text.isEmpty()) return 0;
- return LBI->endOfSentence(Text, nStartPos, rLocale);
+ if (nStartPos < 0 || nStartPos > Text.getLength())
+ return -1;
+ if (Text.isEmpty()) return 0;
+ return LBI->endOfSentence(Text, nStartPos, rLocale);
}
LineBreakResults SAL_CALL BreakIteratorImpl::getLineBreak( const OUString& Text, sal_Int32 nStartPos,
const Locale& rLocale, sal_Int32 nMinBreakPos, const LineBreakHyphenationOptions& hOptions,
const LineBreakUserOptions& bOptions ) throw(RuntimeException)
{
- return LBI->getLineBreak(Text, nStartPos, rLocale, nMinBreakPos, hOptions, bOptions);
+ return LBI->getLineBreak(Text, nStartPos, rLocale, nMinBreakPos, hOptions, bOptions);
}
sal_Int16 SAL_CALL BreakIteratorImpl::getScriptType( const OUString& Text, sal_Int32 nPos )
throw(RuntimeException)
{
- return (nPos < 0 || nPos >= Text.getLength()) ? ScriptType::WEAK :
- getScriptClass(Text.iterateCodePoints(&nPos, 0));
+ return (nPos < 0 || nPos >= Text.getLength()) ? ScriptType::WEAK :
+ getScriptClass(Text.iterateCodePoints(&nPos, 0));
}
@@ -280,122 +280,122 @@ static sal_Int32 SAL_CALL iterateCodePoints(const OUString& Text, sal_Int32 &nSt
sal_Int32 SAL_CALL BreakIteratorImpl::beginOfScript( const OUString& Text,
sal_Int32 nStartPos, sal_Int16 ScriptType ) throw(RuntimeException)
{
- if (nStartPos < 0 || nStartPos >= Text.getLength())
- return -1;
+ if (nStartPos < 0 || nStartPos >= Text.getLength())
+ return -1;
- if(ScriptType != getScriptClass(Text.iterateCodePoints(&nStartPos, 0)))
- return -1;
+ if(ScriptType != getScriptClass(Text.iterateCodePoints(&nStartPos, 0)))
+ return -1;
+ if (nStartPos == 0) return 0;
+ sal_uInt32 ch=0;
+ while (iterateCodePoints(Text, nStartPos, -1, ch) >= 0 && ScriptType == getScriptClass(ch)) {
if (nStartPos == 0) return 0;
- sal_uInt32 ch=0;
- while (iterateCodePoints(Text, nStartPos, -1, ch) >= 0 && ScriptType == getScriptClass(ch)) {
- if (nStartPos == 0) return 0;
- }
+ }
- return iterateCodePoints(Text, nStartPos, 1, ch);
+ return iterateCodePoints(Text, nStartPos, 1, ch);
}
sal_Int32 SAL_CALL BreakIteratorImpl::endOfScript( const OUString& Text,
sal_Int32 nStartPos, sal_Int16 ScriptType ) throw(RuntimeException)
{
- if (nStartPos < 0 || nStartPos >= Text.getLength())
- return -1;
+ if (nStartPos < 0 || nStartPos >= Text.getLength())
+ return -1;
- if(ScriptType != getScriptClass(Text.iterateCodePoints(&nStartPos, 0)))
- return -1;
+ if(ScriptType != getScriptClass(Text.iterateCodePoints(&nStartPos, 0)))
+ return -1;
- sal_Int32 strLen = Text.getLength();
- sal_uInt32 ch=0;
- while(iterateCodePoints(Text, nStartPos, 1, ch) < strLen ) {
- sal_Int16 currentCharScriptType = getScriptClass(ch);
- if(ScriptType != currentCharScriptType && currentCharScriptType != ScriptType::WEAK)
- break;
- }
- return nStartPos;
+ sal_Int32 strLen = Text.getLength();
+ sal_uInt32 ch=0;
+ while(iterateCodePoints(Text, nStartPos, 1, ch) < strLen ) {
+ sal_Int16 currentCharScriptType = getScriptClass(ch);
+ if(ScriptType != currentCharScriptType && currentCharScriptType != ScriptType::WEAK)
+ break;
+ }
+ return nStartPos;
}
sal_Int32 SAL_CALL BreakIteratorImpl::previousScript( const OUString& Text,
sal_Int32 nStartPos, sal_Int16 ScriptType ) throw(RuntimeException)
{
- if (nStartPos < 0)
- return -1;
- if (nStartPos > Text.getLength())
- nStartPos = Text.getLength();
+ if (nStartPos < 0)
+ return -1;
+ if (nStartPos > Text.getLength())
+ nStartPos = Text.getLength();
- sal_Int16 numberOfChange = (ScriptType == getScriptClass(Text.iterateCodePoints(&nStartPos, 0))) ? 3 : 2;
+ sal_Int16 numberOfChange = (ScriptType == getScriptClass(Text.iterateCodePoints(&nStartPos, 0))) ? 3 : 2;
- sal_uInt32 ch=0;
- while (numberOfChange > 0 && iterateCodePoints(Text, nStartPos, -1, ch) >= 0) {
- if ((((numberOfChange % 2) == 0) ^ (ScriptType != getScriptClass(ch))))
+ sal_uInt32 ch=0;
+ while (numberOfChange > 0 && iterateCodePoints(Text, nStartPos, -1, ch) >= 0) {
+ if ((((numberOfChange % 2) == 0) ^ (ScriptType != getScriptClass(ch))))
+ numberOfChange--;
+ else if (nStartPos == 0) {
+ if (numberOfChange > 0)
numberOfChange--;
- else if (nStartPos == 0) {
- if (numberOfChange > 0)
- numberOfChange--;
- if (nStartPos > 0)
- Text.iterateCodePoints(&nStartPos, -1);
- else
- return -1;
- }
+ if (nStartPos > 0)
+ Text.iterateCodePoints(&nStartPos, -1);
+ else
+ return -1;
}
- return numberOfChange == 0 ? iterateCodePoints(Text, nStartPos, 1, ch) : -1;
+ }
+ return numberOfChange == 0 ? iterateCodePoints(Text, nStartPos, 1, ch) : -1;
}
sal_Int32 SAL_CALL BreakIteratorImpl::nextScript( const OUString& Text, sal_Int32 nStartPos,
sal_Int16 ScriptType ) throw(RuntimeException)
{
- if (nStartPos < 0)
- nStartPos = 0;
- sal_Int32 strLen = Text.getLength();
- if (nStartPos > strLen)
- return -1;
+ if (nStartPos < 0)
+ nStartPos = 0;
+ sal_Int32 strLen = Text.getLength();
+ if (nStartPos > strLen)
+ return -1;
- sal_Int16 numberOfChange = (ScriptType == getScriptClass(Text.iterateCodePoints(&nStartPos, 0))) ? 2 : 1;
+ sal_Int16 numberOfChange = (ScriptType == getScriptClass(Text.iterateCodePoints(&nStartPos, 0))) ? 2 : 1;
- sal_uInt32 ch=0;
- while (numberOfChange > 0 && iterateCodePoints(Text, nStartPos, 1, ch) < strLen) {
- sal_Int16 currentCharScriptType = getScriptClass(ch);
- if ((numberOfChange == 1) ? (ScriptType == currentCharScriptType) :
- (ScriptType != currentCharScriptType && currentCharScriptType != ScriptType::WEAK))
- numberOfChange--;
- }
- return numberOfChange == 0 ? nStartPos : -1;
+ sal_uInt32 ch=0;
+ while (numberOfChange > 0 && iterateCodePoints(Text, nStartPos, 1, ch) < strLen) {
+ sal_Int16 currentCharScriptType = getScriptClass(ch);
+ if ((numberOfChange == 1) ? (ScriptType == currentCharScriptType) :
+ (ScriptType != currentCharScriptType && currentCharScriptType != ScriptType::WEAK))
+ numberOfChange--;
+ }
+ return numberOfChange == 0 ? nStartPos : -1;
}
sal_Int32 SAL_CALL BreakIteratorImpl::beginOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
const Locale& /*rLocale*/, sal_Int16 CharType ) throw(RuntimeException)
{
- if (CharType == CharType::ANY_CHAR) return 0;
- if (nStartPos < 0 || nStartPos >= Text.getLength()) return -1;
- if (CharType != (sal_Int16)u_charType( Text.iterateCodePoints(&nStartPos, 0))) return -1;
+ if (CharType == CharType::ANY_CHAR) return 0;
+ if (nStartPos < 0 || nStartPos >= Text.getLength()) return -1;
+ if (CharType != (sal_Int16)u_charType( Text.iterateCodePoints(&nStartPos, 0))) return -1;
- sal_Int32 nPos=nStartPos;
- while(nStartPos > 0 && CharType == (sal_Int16)u_charType(Text.iterateCodePoints(&nPos, -1))) { nStartPos=nPos; }
- return nStartPos; // begin of char block is inclusive
+ sal_Int32 nPos=nStartPos;
+ while(nStartPos > 0 && CharType == (sal_Int16)u_charType(Text.iterateCodePoints(&nPos, -1))) { nStartPos=nPos; }
+ return nStartPos; // begin of char block is inclusive
}
sal_Int32 SAL_CALL BreakIteratorImpl::endOfCharBlock( const OUString& Text, sal_Int32 nStartPos,
const Locale& /*rLocale*/, sal_Int16 CharType ) throw(RuntimeException)
{
- sal_Int32 strLen = Text.getLength();
+ sal_Int32 strLen = Text.getLength();
- if (CharType == CharType::ANY_CHAR) return strLen; // end of char block is exclusive
- if (nStartPos < 0 || nStartPos >= strLen) return -1;
- if (CharType != (sal_Int16)u_charType(Text.iterateCodePoints(&nStartPos, 0))) return -1;
+ if (CharType == CharType::ANY_CHAR) return strLen; // end of char block is exclusive
+ if (nStartPos < 0 || nStartPos >= strLen) return -1;
+ if (CharType != (sal_Int16)u_charType(Text.iterateCodePoints(&nStartPos, 0))) return -1;
- sal_uInt32 ch=0;
- while(iterateCodePoints(Text, nStartPos, 1, ch) < strLen && CharType == (sal_Int16)u_charType(ch)) {}
- return nStartPos; // end of char block is exclusive
+ sal_uInt32 ch=0;
+ while(iterateCodePoints(Text, nStartPos, 1, ch) < strLen && CharType == (sal_Int16)u_charType(ch)) {}
+ return nStartPos; // end of char block is exclusive
}
sal_Int32 SAL_CALL BreakIteratorImpl::nextCharBlock( const OUString& Text, sal_Int32 nStartPos,
const Locale& /*rLocale*/, sal_Int16 CharType ) throw(RuntimeException)
{
- if (CharType == CharType::ANY_CHAR) return -1;
- if (nStartPos < 0 || nStartPos >= Text.getLength()) return -1;
+ if (CharType == CharType::ANY_CHAR) return -1;
+ if (nStartPos < 0 || nStartPos >= Text.getLength()) return -1;
- sal_Int16 numberOfChange = (CharType == (sal_Int16)u_charType(Text.iterateCodePoints(&nStartPos, 0))) ? 2 : 1;
- sal_Int32 strLen = Text.getLength();
+ sal_Int16 numberOfChange = (CharType == (sal_Int16)u_charType(Text.iterateCodePoints(&nStartPos, 0))) ? 2 : 1;
+ sal_Int32 strLen = Text.getLength();
sal_uInt32 ch=0;
while (numberOfChange > 0 && iterateCodePoints(Text, nStartPos, 1, ch) < strLen) {
@@ -408,21 +408,21 @@ sal_Int32 SAL_CALL BreakIteratorImpl::nextCharBlock( const OUString& Text, sal_I
sal_Int32 SAL_CALL BreakIteratorImpl::previousCharBlock( const OUString& Text, sal_Int32 nStartPos,
const Locale& /*rLocale*/, sal_Int16 CharType ) throw(RuntimeException)
{
- if(CharType == CharType::ANY_CHAR) return -1;
- if (nStartPos < 0 || nStartPos >= Text.getLength()) return -1;
+ if(CharType == CharType::ANY_CHAR) return -1;
+ if (nStartPos < 0 || nStartPos >= Text.getLength()) return -1;
- sal_Int16 numberOfChange = (CharType == (sal_Int16)u_charType(Text.iterateCodePoints(&nStartPos, 0))) ? 3 : 2;
+ sal_Int16 numberOfChange = (CharType == (sal_Int16)u_charType(Text.iterateCodePoints(&nStartPos, 0))) ? 3 : 2;
- sal_uInt32 ch=0;
- while (numberOfChange > 0 && iterateCodePoints(Text, nStartPos, -1, ch) >= 0) {
- if (((numberOfChange % 2) == 0) ^ (CharType != (sal_Int16)u_charType(ch)))
- numberOfChange--;
- if (nStartPos == 0 && numberOfChange > 0) {
- numberOfChange--;
- if (numberOfChange == 0) return nStartPos;
- }
+ sal_uInt32 ch=0;
+ while (numberOfChange > 0 && iterateCodePoints(Text, nStartPos, -1, ch) >= 0) {
+ if (((numberOfChange % 2) == 0) ^ (CharType != (sal_Int16)u_charType(ch)))
+ numberOfChange--;
+ if (nStartPos == 0 && numberOfChange > 0) {
+ numberOfChange--;
+ if (numberOfChange == 0) return nStartPos;
}
- return numberOfChange == 0 ? iterateCodePoints(Text, nStartPos, 1, ch) : -1;
+ }
+ return numberOfChange == 0 ? iterateCodePoints(Text, nStartPos, 1, ch) : -1;
}
@@ -430,88 +430,88 @@ sal_Int32 SAL_CALL BreakIteratorImpl::previousCharBlock( const OUString& Text, s
sal_Int16 SAL_CALL BreakIteratorImpl::getWordType( const OUString& /*Text*/,
sal_Int32 /*nPos*/, const Locale& /*rLocale*/ ) throw(RuntimeException)
{
- return 0;
+ return 0;
}
namespace
{
- sal_Int16 getScriptClassByUAX24Script(sal_uInt32 currentChar)
- {
- int32_t script = u_getIntPropertyValue(currentChar, UCHAR_SCRIPT);
- return unicode::getScriptClassFromUScriptCode(static_cast<UScriptCode>(script));
- }
+sal_Int16 getScriptClassByUAX24Script(sal_uInt32 currentChar)
+{
+ int32_t script = u_getIntPropertyValue(currentChar, UCHAR_SCRIPT);
+ return unicode::getScriptClassFromUScriptCode(static_cast<UScriptCode>(script));
+}
- struct UBlock2Script
- {
- UBlockCode from;
- UBlockCode to;
- sal_Int16 script;
- };
+struct UBlock2Script
+{
+ UBlockCode from;
+ UBlockCode to;
+ sal_Int16 script;
+};
- static const UBlock2Script scriptList[] =
- {
- {UBLOCK_NO_BLOCK, UBLOCK_NO_BLOCK, ScriptType::WEAK},
- {UBLOCK_BASIC_LATIN, UBLOCK_ARMENIAN, ScriptType::LATIN},
- {UBLOCK_HEBREW, UBLOCK_MYANMAR, ScriptType::COMPLEX},
- {UBLOCK_GEORGIAN, UBLOCK_GEORGIAN, ScriptType::LATIN},
- {UBLOCK_HANGUL_JAMO, UBLOCK_HANGUL_JAMO, ScriptType::ASIAN},
- {UBLOCK_ETHIOPIC, UBLOCK_ETHIOPIC, ScriptType::COMPLEX},
- {UBLOCK_CHEROKEE, UBLOCK_RUNIC, ScriptType::LATIN},
- {UBLOCK_KHMER, UBLOCK_MONGOLIAN, ScriptType::COMPLEX},
- {UBLOCK_LATIN_EXTENDED_ADDITIONAL, UBLOCK_GREEK_EXTENDED, ScriptType::LATIN},
- {UBLOCK_NUMBER_FORMS, UBLOCK_NUMBER_FORMS, ScriptType::WEAK},
- {UBLOCK_CJK_RADICALS_SUPPLEMENT, UBLOCK_HANGUL_SYLLABLES, ScriptType::ASIAN},
- {UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS, ScriptType::ASIAN},
- {UBLOCK_ARABIC_PRESENTATION_FORMS_A, UBLOCK_ARABIC_PRESENTATION_FORMS_A, ScriptType::COMPLEX},
- {UBLOCK_CJK_COMPATIBILITY_FORMS, UBLOCK_CJK_COMPATIBILITY_FORMS, ScriptType::ASIAN},
- {UBLOCK_ARABIC_PRESENTATION_FORMS_B, UBLOCK_ARABIC_PRESENTATION_FORMS_B, ScriptType::COMPLEX},
- {UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, ScriptType::ASIAN},
- {UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, ScriptType::ASIAN},
- {UBLOCK_CJK_STROKES, UBLOCK_CJK_STROKES, ScriptType::ASIAN},
- {UBLOCK_LATIN_EXTENDED_C, UBLOCK_LATIN_EXTENDED_D, ScriptType::LATIN}
- };
-
- #define scriptListCount SAL_N_ELEMENTS(scriptList)
-
- //always sets rScriptType
- //
- //returns true for characters historically explicitly assigned to
- //latin/weak/asian
- //
- //returns false for characters that historically implicitly assigned to
- //weak as unknown
- bool getCompatibilityScriptClassByBlock(sal_uInt32 currentChar, sal_Int16 &rScriptType)
+static const UBlock2Script scriptList[] =
+{
+ {UBLOCK_NO_BLOCK, UBLOCK_NO_BLOCK, ScriptType::WEAK},
+ {UBLOCK_BASIC_LATIN, UBLOCK_ARMENIAN, ScriptType::LATIN},
+ {UBLOCK_HEBREW, UBLOCK_MYANMAR, ScriptType::COMPLEX},
+ {UBLOCK_GEORGIAN, UBLOCK_GEORGIAN, ScriptType::LATIN},
+ {UBLOCK_HANGUL_JAMO, UBLOCK_HANGUL_JAMO, ScriptType::ASIAN},
+ {UBLOCK_ETHIOPIC, UBLOCK_ETHIOPIC, ScriptType::COMPLEX},
+ {UBLOCK_CHEROKEE, UBLOCK_RUNIC, ScriptType::LATIN},
+ {UBLOCK_KHMER, UBLOCK_MONGOLIAN, ScriptType::COMPLEX},
+ {UBLOCK_LATIN_EXTENDED_ADDITIONAL, UBLOCK_GREEK_EXTENDED, ScriptType::LATIN},
+ {UBLOCK_NUMBER_FORMS, UBLOCK_NUMBER_FORMS, ScriptType::WEAK},
+ {UBLOCK_CJK_RADICALS_SUPPLEMENT, UBLOCK_HANGUL_SYLLABLES, ScriptType::ASIAN},
+ {UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS, ScriptType::ASIAN},
+ {UBLOCK_ARABIC_PRESENTATION_FORMS_A, UBLOCK_ARABIC_PRESENTATION_FORMS_A, ScriptType::COMPLEX},
+ {UBLOCK_CJK_COMPATIBILITY_FORMS, UBLOCK_CJK_COMPATIBILITY_FORMS, ScriptType::ASIAN},
+ {UBLOCK_ARABIC_PRESENTATION_FORMS_B, UBLOCK_ARABIC_PRESENTATION_FORMS_B, ScriptType::COMPLEX},
+ {UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS, ScriptType::ASIAN},
+ {UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT, ScriptType::ASIAN},
+ {UBLOCK_CJK_STROKES, UBLOCK_CJK_STROKES, ScriptType::ASIAN},
+ {UBLOCK_LATIN_EXTENDED_C, UBLOCK_LATIN_EXTENDED_D, ScriptType::LATIN}
+};
+
+#define scriptListCount SAL_N_ELEMENTS(scriptList)
+
+//always sets rScriptType
+//
+//returns true for characters historically explicitly assigned to
+//latin/weak/asian
+//
+//returns false for characters that historically implicitly assigned to
+//weak as unknown
+bool getCompatibilityScriptClassByBlock(sal_uInt32 currentChar, sal_Int16 &rScriptType)
+{
+ bool bKnown = true;
+ //handle specific characters always as weak:
+ // 0x01 - this breaks a word
+ // 0x02 - this can be inside a word
+ // 0x20 & 0xA0 - Bug 102975, declare western space and non-break space as WEAK char.
+ if( 0x01 == currentChar || 0x02 == currentChar || 0x20 == currentChar || 0xA0 == currentChar)
+ rScriptType = ScriptType::WEAK;
+ // workaround for Coptic
+ else if ( 0x2C80 <= currentChar && 0x2CE3 >= currentChar)
+ rScriptType = ScriptType::LATIN;
+ else
{
- bool bKnown = true;
- //handle specific characters always as weak:
- // 0x01 - this breaks a word
- // 0x02 - this can be inside a word
- // 0x20 & 0xA0 - Bug 102975, declare western space and non-break space as WEAK char.
- if( 0x01 == currentChar || 0x02 == currentChar || 0x20 == currentChar || 0xA0 == currentChar)
- rScriptType = ScriptType::WEAK;
- // workaround for Coptic
- else if ( 0x2C80 <= currentChar && 0x2CE3 >= currentChar)
- rScriptType = ScriptType::LATIN;
+ UBlockCode block=ublock_getCode(currentChar);
+ size_t i = 0;
+ while (i < scriptListCount)
+ {
+ if (block <= scriptList[i].to)
+ break;
+ ++i;
+ }
+ if (i < scriptListCount && block >= scriptList[i].from)
+ rScriptType = scriptList[i].script;
else
{
- UBlockCode block=ublock_getCode(currentChar);
- size_t i = 0;
- while (i < scriptListCount)
- {
- if (block <= scriptList[i].to)
- break;
- ++i;
- }
- if (i < scriptListCount && block >= scriptList[i].from)
- rScriptType = scriptList[i].script;
- else
- {
- rScriptType = ScriptType::WEAK;
- bKnown = false;
- }
+ rScriptType = ScriptType::WEAK;
+ bKnown = false;
}
- return bKnown;
}
+ return bKnown;
+}
}
sal_Int16 BreakIteratorImpl::getScriptClass(sal_uInt32 currentChar)
@@ -536,73 +536,73 @@ static inline sal_Bool operator == (const Locale& l1, const Locale& l2) {
sal_Bool SAL_CALL BreakIteratorImpl::createLocaleSpecificBreakIterator(const OUString& aLocaleName) throw( RuntimeException )
{
- // to share service between same Language but different Country code, like zh_CN and zh_TW
- for (size_t l = 0; l < lookupTable.size(); l++) {
- lookupTableItem *listItem = lookupTable[l];
- if (aLocaleName == listItem->aLocale.Language) {
- xBI = listItem->xBI;
- return sal_True;
- }
+ // to share service between same Language but different Country code, like zh_CN and zh_TW
+ for (size_t l = 0; l < lookupTable.size(); l++) {
+ lookupTableItem *listItem = lookupTable[l];
+ if (aLocaleName == listItem->aLocale.Language) {
+ xBI = listItem->xBI;
+ return sal_True;
}
+ }
- Reference < uno::XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
+ Reference < uno::XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
OUString("com.sun.star.i18n.BreakIterator_") + aLocaleName, m_xContext);
- if ( xI.is() ) {
- xBI.set(xI, UNO_QUERY);
- if (xBI.is()) {
- lookupTable.push_back(new lookupTableItem(Locale(aLocaleName, aLocaleName, aLocaleName), xBI));
- return sal_True;
- }
+ if ( xI.is() ) {
+ xBI.set(xI, UNO_QUERY);
+ if (xBI.is()) {
+ lookupTable.push_back(new lookupTableItem(Locale(aLocaleName, aLocaleName, aLocaleName), xBI));
+ return sal_True;
}
- return sal_False;
+ }
+ return sal_False;
}
Reference < XBreakIterator > SAL_CALL
BreakIteratorImpl::getLocaleSpecificBreakIterator(const Locale& rLocale) throw (RuntimeException)
{
- if (xBI.is() && rLocale == aLocale)
- return xBI;
- else if (m_xContext.is()) {
- aLocale = rLocale;
-
- for (size_t i = 0; i < lookupTable.size(); i++) {
- lookupTableItem *listItem = lookupTable[i];
- if (rLocale == listItem->aLocale)
- return xBI = listItem->xBI;
- }
+ if (xBI.is() && rLocale == aLocale)
+ return xBI;
+ else if (m_xContext.is()) {
+ aLocale = rLocale;
+
+ for (size_t i = 0; i < lookupTable.size(); i++) {
+ lookupTableItem *listItem = lookupTable[i];
+ if (rLocale == listItem->aLocale)
+ return xBI = listItem->xBI;
+ }
- sal_Unicode under = (sal_Unicode)'_';
+ sal_Unicode under = (sal_Unicode)'_';
- sal_Int32 l = rLocale.Language.getLength();
- sal_Int32 c = rLocale.Country.getLength();
- sal_Int32 v = rLocale.Variant.getLength();
- OUStringBuffer aBuf(l+c+v+3);
+ sal_Int32 l = rLocale.Language.getLength();
+ sal_Int32 c = rLocale.Country.getLength();
+ sal_Int32 v = rLocale.Variant.getLength();
+ OUStringBuffer aBuf(l+c+v+3);
- if ((l > 0 && c > 0 && v > 0 &&
+ if ((l > 0 && c > 0 && v > 0 &&
// load service with name <base>_<lang>_<country>_<varian>
createLocaleSpecificBreakIterator(aBuf.append(rLocale.Language).append(under).append(
- rLocale.Country).append(under).append(rLocale.Variant).makeStringAndClear())) ||
+ rLocale.Country).append(under).append(rLocale.Variant).makeStringAndClear())) ||
(l > 0 && c > 0 &&
- // load service with name <base>_<lang>_<country>
- createLocaleSpecificBreakIterator(aBuf.append(rLocale.Language).append(under).append(
- rLocale.Country).makeStringAndClear())) ||
+ // load service with name <base>_<lang>_<country>
+ createLocaleSpecificBreakIterator(aBuf.append(rLocale.Language).append(under).append(
+ rLocale.Country).makeStringAndClear())) ||
(l > 0 && c > 0 && rLocale.Language.compareToAscii("zh") == 0 &&
- (rLocale.Country.compareToAscii("HK") == 0 ||
- rLocale.Country.compareToAscii("MO") == 0) &&
- // if the country code is HK or MO, one more step to try TW.
- createLocaleSpecificBreakIterator(aBuf.append(rLocale.Language).append(under).appendAscii(
- "TW").makeStringAndClear())) ||
+ (rLocale.Country.compareToAscii("HK") == 0 ||
+ rLocale.Country.compareToAscii("MO") == 0) &&
+ // if the country code is HK or MO, one more step to try TW.
+ createLocaleSpecificBreakIterator(aBuf.append(rLocale.Language).append(under).appendAscii(
+ "TW").makeStringAndClear())) ||
(l > 0 &&
- // load service with name <base>_<lang>
- createLocaleSpecificBreakIterator(rLocale.Language)) ||
- // load default service with name <base>_Unicode
- createLocaleSpecificBreakIterator(OUString("Unicode"))) {
- lookupTable.push_back( new lookupTableItem(aLocale, xBI) );
- return xBI;
- }
+ // load service with name <base>_<lang>
+ createLocaleSpecificBreakIterator(rLocale.Language)) ||
+ // load default service with name <base>_Unicode
+ createLocaleSpecificBreakIterator(OUString("Unicode"))) {
+ lookupTable.push_back( new lookupTableItem(aLocale, xBI) );
+ return xBI;
}
- throw RuntimeException();
+ }
+ throw RuntimeException();
}
const sal_Char cBreakIterator[] = "com.sun.star.i18n.BreakIterator";
@@ -610,21 +610,21 @@ const sal_Char cBreakIterator[] = "com.sun.star.i18n.BreakIterator";
OUString SAL_CALL
BreakIteratorImpl::getImplementationName(void) throw( RuntimeException )
{
- return OUString::createFromAscii(cBreakIterator);
+ return OUString::createFromAscii(cBreakIterator);
}
sal_Bool SAL_CALL
BreakIteratorImpl::supportsService(const OUString& rServiceName) throw( RuntimeException )
{
- return !rServiceName.compareToAscii(cBreakIterator);
+ return !rServiceName.compareToAscii(cBreakIterator);
}
Sequence< OUString > SAL_CALL
BreakIteratorImpl::getSupportedServiceNames(void) throw( RuntimeException )
{
- Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii(cBreakIterator);
- return aRet;
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii(cBreakIterator);
+ return aRet;
}
} } } }
diff --git a/i18npool/source/breakiterator/breakiterator_cjk.cxx b/i18npool/source/breakiterator/breakiterator_cjk.cxx
index 28f263157510..9ff6a40a7c5d 100644
--- a/i18npool/source/breakiterator/breakiterator_cjk.cxx
+++ b/i18npool/source/breakiterator/breakiterator_cjk.cxx
@@ -37,41 +37,41 @@ BreakIterator_CJK::BreakIterator_CJK() :
dict( NULL ),
hangingCharacters()
{
- cBreakIterator = "com.sun.star.i18n.BreakIterator_CJK";
+ cBreakIterator = "com.sun.star.i18n.BreakIterator_CJK";
}
Boundary SAL_CALL
BreakIterator_CJK::previousWord(const OUString& text, sal_Int32 anyPos,
const lang::Locale& nLocale, sal_Int16 wordType) throw(RuntimeException)
{
- if (dict) {
- result = dict->previousWord(text, anyPos, wordType);
- // #109813# for non-CJK, single character word, fallback to ICU breakiterator.
- if (result.endPos - result.startPos != 1 ||
- getScriptType(text, result.startPos) == ScriptType::ASIAN)
- return result;
- result = BreakIterator_Unicode::getWordBoundary(text, result.startPos, nLocale, wordType, true);
- if (result.endPos < anyPos)
- return result;
- }
- return BreakIterator_Unicode::previousWord(text, anyPos, nLocale, wordType);
+ if (dict) {
+ result = dict->previousWord(text, anyPos, wordType);
+ // #109813# for non-CJK, single character word, fallback to ICU breakiterator.
+ if (result.endPos - result.startPos != 1 ||
+ getScriptType(text, result.startPos) == ScriptType::ASIAN)
+ return result;
+ result = BreakIterator_Unicode::getWordBoundary(text, result.startPos, nLocale, wordType, true);
+ if (result.endPos < anyPos)
+ return result;
+ }
+ return BreakIterator_Unicode::previousWord(text, anyPos, nLocale, wordType);
}
Boundary SAL_CALL
BreakIterator_CJK::nextWord(const OUString& text, sal_Int32 anyPos,
const lang::Locale& nLocale, sal_Int16 wordType) throw(RuntimeException)
{
- if (dict) {
- result = dict->nextWord(text, anyPos, wordType);
- // #109813# for non-CJK, single character word, fallback to ICU breakiterator.
- if (result.endPos - result.startPos != 1 ||
- getScriptType(text, result.startPos) == ScriptType::ASIAN)
- return result;
- result = BreakIterator_Unicode::getWordBoundary(text, result.startPos, nLocale, wordType, true);
- if (result.startPos > anyPos)
- return result;
- }
- return BreakIterator_Unicode::nextWord(text, anyPos, nLocale, wordType);
+ if (dict) {
+ result = dict->nextWord(text, anyPos, wordType);
+ // #109813# for non-CJK, single character word, fallback to ICU breakiterator.
+ if (result.endPos - result.startPos != 1 ||
+ getScriptType(text, result.startPos) == ScriptType::ASIAN)
+ return result;
+ result = BreakIterator_Unicode::getWordBoundary(text, result.startPos, nLocale, wordType, true);
+ if (result.startPos > anyPos)
+ return result;
+ }
+ return BreakIterator_Unicode::nextWord(text, anyPos, nLocale, wordType);
}
Boundary SAL_CALL
@@ -79,14 +79,14 @@ BreakIterator_CJK::getWordBoundary( const OUString& text, sal_Int32 anyPos,
const lang::Locale& nLocale, sal_Int16 wordType, sal_Bool bDirection )
throw(RuntimeException)
{
- if (dict) {
- result = dict->getWordBoundary(text, anyPos, wordType, bDirection);
- // #109813# for non-CJK, single character word, fallback to ICU breakiterator.
- if (result.endPos - result.startPos != 1 ||
- getScriptType(text, result.startPos) == ScriptType::ASIAN)
- return result;
- }
- return BreakIterator_Unicode::getWordBoundary(text, anyPos, nLocale, wordType, bDirection);
+ if (dict) {
+ result = dict->getWordBoundary(text, anyPos, wordType, bDirection);
+ // #109813# for non-CJK, single character word, fallback to ICU breakiterator.
+ if (result.endPos - result.startPos != 1 ||
+ getScriptType(text, result.startPos) == ScriptType::ASIAN)
+ return result;
+ }
+ return BreakIterator_Unicode::getWordBoundary(text, anyPos, nLocale, wordType, bDirection);
}
LineBreakResults SAL_CALL BreakIterator_CJK::getLineBreak(
@@ -95,22 +95,22 @@ LineBreakResults SAL_CALL BreakIterator_CJK::getLineBreak(
const LineBreakHyphenationOptions& /*hOptions*/,
const LineBreakUserOptions& bOptions ) throw(RuntimeException)
{
- LineBreakResults lbr;
-
- if (bOptions.allowPunctuationOutsideMargin &&
- hangingCharacters.indexOf(Text[nStartPos]) != -1 &&
- (Text.iterateCodePoints( &nStartPos, 1), nStartPos == Text.getLength())) {
- ; // do nothing
- } else if (bOptions.applyForbiddenRules && 0 < nStartPos && nStartPos < Text.getLength()) {
- while (nStartPos > 0 &&
- (bOptions.forbiddenBeginCharacters.indexOf(Text[nStartPos]) != -1 ||
- bOptions.forbiddenEndCharacters.indexOf(Text[nStartPos-1]) != -1))
- Text.iterateCodePoints( &nStartPos, -1);
- }
-
- lbr.breakIndex = nStartPos;
- lbr.breakType = BreakType::WORDBOUNDARY;
- return lbr;
+ LineBreakResults lbr;
+
+ if (bOptions.allowPunctuationOutsideMargin &&
+ hangingCharacters.indexOf(Text[nStartPos]) != -1 &&
+ (Text.iterateCodePoints( &nStartPos, 1), nStartPos == Text.getLength())) {
+ ; // do nothing
+ } else if (bOptions.applyForbiddenRules && 0 < nStartPos && nStartPos < Text.getLength()) {
+ while (nStartPos > 0 &&
+ (bOptions.forbiddenBeginCharacters.indexOf(Text[nStartPos]) != -1 ||
+ bOptions.forbiddenEndCharacters.indexOf(Text[nStartPos-1]) != -1))
+ Text.iterateCodePoints( &nStartPos, -1);
+ }
+
+ lbr.breakIndex = nStartPos;
+ lbr.breakType = BreakType::WORDBOUNDARY;
+ return lbr;
}
#define LOCALE(language, country) lang::Locale(OUString::createFromAscii(language), OUString::createFromAscii(country), OUString())
@@ -119,14 +119,14 @@ LineBreakResults SAL_CALL BreakIterator_CJK::getLineBreak(
// ----------------------------------------------------;
BreakIterator_zh::BreakIterator_zh()
{
- dict = new xdictionary("zh");
- hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("zh", "CN"));
- cBreakIterator = "com.sun.star.i18n.BreakIterator_zh";
+ dict = new xdictionary("zh");
+ hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("zh", "CN"));
+ cBreakIterator = "com.sun.star.i18n.BreakIterator_zh";
}
BreakIterator_zh::~BreakIterator_zh()
{
- delete dict;
+ delete dict;
}
// ----------------------------------------------------
@@ -134,14 +134,14 @@ BreakIterator_zh::~BreakIterator_zh()
// ----------------------------------------------------;
BreakIterator_zh_TW::BreakIterator_zh_TW()
{
- dict = new xdictionary("zh");
- hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("zh", "TW"));
- cBreakIterator = "com.sun.star.i18n.BreakIterator_zh_TW";
+ dict = new xdictionary("zh");
+ hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("zh", "TW"));
+ cBreakIterator = "com.sun.star.i18n.BreakIterator_zh_TW";
}
BreakIterator_zh_TW::~BreakIterator_zh_TW()
{
- delete dict;
+ delete dict;
}
// ----------------------------------------------------
@@ -149,15 +149,15 @@ BreakIterator_zh_TW::~BreakIterator_zh_TW()
// ----------------------------------------------------;
BreakIterator_ja::BreakIterator_ja()
{
- dict = new xdictionary("ja");
- dict->setJapaneseWordBreak();
- hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("ja", "JP"));
- cBreakIterator = "com.sun.star.i18n.BreakIterator_ja";
+ dict = new xdictionary("ja");
+ dict->setJapaneseWordBreak();
+ hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("ja", "JP"));
+ cBreakIterator = "com.sun.star.i18n.BreakIterator_ja";
}
BreakIterator_ja::~BreakIterator_ja()
{
- delete dict;
+ delete dict;
}
// ----------------------------------------------------
@@ -165,8 +165,8 @@ BreakIterator_ja::~BreakIterator_ja()
// ----------------------------------------------------;
BreakIterator_ko::BreakIterator_ko()
{
- hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("ko", "KR"));
- cBreakIterator = "com.sun.star.i18n.BreakIterator_ko";
+ hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("ko", "KR"));
+ cBreakIterator = "com.sun.star.i18n.BreakIterator_ko";
}
BreakIterator_ko::~BreakIterator_ko()
diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx
index 63ebe53e3df2..0e64343e476c 100644
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -205,18 +205,18 @@ sal_Int32 SAL_CALL BreakIterator_Unicode::nextCharacters( const OUString& Text,
sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone )
throw(uno::RuntimeException)
{
- if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) { // for CELL mode
- loadICUBreakIterator(rLocale, LOAD_CHARACTER_BREAKITERATOR, 0, "char", Text);
- for (nDone = 0; nDone < nCount; nDone++) {
- nStartPos = character.aBreakIterator->following(nStartPos);
- if (nStartPos == BreakIterator::DONE)
- return Text.getLength();
- }
- } else { // for CHARACTER mode
- for (nDone = 0; nDone < nCount && nStartPos < Text.getLength(); nDone++)
- Text.iterateCodePoints(&nStartPos, 1);
+ if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) { // for CELL mode
+ loadICUBreakIterator(rLocale, LOAD_CHARACTER_BREAKITERATOR, 0, "char", Text);
+ for (nDone = 0; nDone < nCount; nDone++) {
+ nStartPos = character.aBreakIterator->following(nStartPos);
+ if (nStartPos == BreakIterator::DONE)
+ return Text.getLength();
}
- return nStartPos;
+ } else { // for CHARACTER mode
+ for (nDone = 0; nDone < nCount && nStartPos < Text.getLength(); nDone++)
+ Text.iterateCodePoints(&nStartPos, 1);
+ }
+ return nStartPos;
}
sal_Int32 SAL_CALL BreakIterator_Unicode::previousCharacters( const OUString& Text,
@@ -224,131 +224,131 @@ sal_Int32 SAL_CALL BreakIterator_Unicode::previousCharacters( const OUString& Te
sal_Int16 nCharacterIteratorMode, sal_Int32 nCount, sal_Int32& nDone )
throw(uno::RuntimeException)
{
- if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) { // for CELL mode
- loadICUBreakIterator(rLocale, LOAD_CHARACTER_BREAKITERATOR, 0, "char", Text);
- for (nDone = 0; nDone < nCount; nDone++) {
- nStartPos = character.aBreakIterator->preceding(nStartPos);
- if (nStartPos == BreakIterator::DONE)
- return 0;
- }
- } else { // for BS to delete one char and CHARACTER mode.
- for (nDone = 0; nDone < nCount && nStartPos > 0; nDone++)
- Text.iterateCodePoints(&nStartPos, -1);
+ if (nCharacterIteratorMode == CharacterIteratorMode::SKIPCELL ) { // for CELL mode
+ loadICUBreakIterator(rLocale, LOAD_CHARACTER_BREAKITERATOR, 0, "char", Text);
+ for (nDone = 0; nDone < nCount; nDone++) {
+ nStartPos = character.aBreakIterator->preceding(nStartPos);
+ if (nStartPos == BreakIterator::DONE)
+ return 0;
}
- return nStartPos;
+ } else { // for BS to delete one char and CHARACTER mode.
+ for (nDone = 0; nDone < nCount && nStartPos > 0; nDone++)
+ Text.iterateCodePoints(&nStartPos, -1);
+ }
+ return nStartPos;
}
Boundary SAL_CALL BreakIterator_Unicode::nextWord( const OUString& Text, sal_Int32 nStartPos,
const lang::Locale& rLocale, sal_Int16 rWordType ) throw(uno::RuntimeException)
{
- loadICUBreakIterator(rLocale, LOAD_WORD_BREAKITERATOR, rWordType, NULL, Text);
+ loadICUBreakIterator(rLocale, LOAD_WORD_BREAKITERATOR, rWordType, NULL, Text);
- result.startPos = icuBI->aBreakIterator->following(nStartPos);
- if( result.startPos >= Text.getLength() || result.startPos == BreakIterator::DONE )
- result.endPos = result.startPos;
- else {
- if ( (rWordType == WordType::ANYWORD_IGNOREWHITESPACES ||
+ result.startPos = icuBI->aBreakIterator->following(nStartPos);
+ if( result.startPos >= Text.getLength() || result.startPos == BreakIterator::DONE )
+ result.endPos = result.startPos;
+ else {
+ if ( (rWordType == WordType::ANYWORD_IGNOREWHITESPACES ||
rWordType == WordType::DICTIONARY_WORD ) &&
- u_isWhitespace(Text.iterateCodePoints(&result.startPos, 0)) )
- result.startPos = icuBI->aBreakIterator->following(result.startPos);
+ u_isWhitespace(Text.iterateCodePoints(&result.startPos, 0)) )
+ result.startPos = icuBI->aBreakIterator->following(result.startPos);
- result.endPos = icuBI->aBreakIterator->following(result.startPos);
- if(result.endPos == BreakIterator::DONE)
- result.endPos = result.startPos;
- }
- return result;
+ result.endPos = icuBI->aBreakIterator->following(result.startPos);
+ if(result.endPos == BreakIterator::DONE)
+ result.endPos = result.startPos;
+ }
+ return result;
}
Boundary SAL_CALL BreakIterator_Unicode::previousWord(const OUString& Text, sal_Int32 nStartPos,
const lang::Locale& rLocale, sal_Int16 rWordType) throw(uno::RuntimeException)
{
- loadICUBreakIterator(rLocale, LOAD_WORD_BREAKITERATOR, rWordType, NULL, Text);
+ loadICUBreakIterator(rLocale, LOAD_WORD_BREAKITERATOR, rWordType, NULL, Text);
- result.startPos = icuBI->aBreakIterator->preceding(nStartPos);
- if( result.startPos < 0 || result.startPos == BreakIterator::DONE)
- result.endPos = result.startPos;
- else {
- if ( (rWordType == WordType::ANYWORD_IGNOREWHITESPACES ||
+ result.startPos = icuBI->aBreakIterator->preceding(nStartPos);
+ if( result.startPos < 0 || result.startPos == BreakIterator::DONE)
+ result.endPos = result.startPos;
+ else {
+ if ( (rWordType == WordType::ANYWORD_IGNOREWHITESPACES ||
rWordType == WordType::DICTIONARY_WORD) &&
- u_isWhitespace(Text.iterateCodePoints(&result.startPos, 0)) )
- result.startPos = icuBI->aBreakIterator->preceding(result.startPos);
+ u_isWhitespace(Text.iterateCodePoints(&result.startPos, 0)) )
+ result.startPos = icuBI->aBreakIterator->preceding(result.startPos);
- result.endPos = icuBI->aBreakIterator->following(result.startPos);
- if(result.endPos == BreakIterator::DONE)
- result.endPos = result.startPos;
- }
- return result;
+ result.endPos = icuBI->aBreakIterator->following(result.startPos);
+ if(result.endPos == BreakIterator::DONE)
+ result.endPos = result.startPos;
+ }
+ return result;
}
Boundary SAL_CALL BreakIterator_Unicode::getWordBoundary( const OUString& Text, sal_Int32 nPos, const lang::Locale& rLocale,
sal_Int16 rWordType, sal_Bool bDirection ) throw(uno::RuntimeException)
{
- loadICUBreakIterator(rLocale, LOAD_WORD_BREAKITERATOR, rWordType, NULL, Text);
- sal_Int32 len = Text.getLength();
-
- if(icuBI->aBreakIterator->isBoundary(nPos)) {
- result.startPos = result.endPos = nPos;
- if((bDirection || nPos == 0) && nPos < len) //forward
- result.endPos = icuBI->aBreakIterator->following(nPos);
- else
- result.startPos = icuBI->aBreakIterator->preceding(nPos);
+ loadICUBreakIterator(rLocale, LOAD_WORD_BREAKITERATOR, rWordType, NULL, Text);
+ sal_Int32 len = Text.getLength();
+
+ if(icuBI->aBreakIterator->isBoundary(nPos)) {
+ result.startPos = result.endPos = nPos;
+ if((bDirection || nPos == 0) && nPos < len) //forward
+ result.endPos = icuBI->aBreakIterator->following(nPos);
+ else
+ result.startPos = icuBI->aBreakIterator->preceding(nPos);
+ } else {
+ if(nPos <= 0) {
+ result.startPos = 0;
+ result.endPos = len ? icuBI->aBreakIterator->following((sal_Int32)0) : 0;
+ } else if(nPos >= len) {
+ result.startPos = icuBI->aBreakIterator->preceding(len);
+ result.endPos = len;
} else {
- if(nPos <= 0) {
- result.startPos = 0;
- result.endPos = len ? icuBI->aBreakIterator->following((sal_Int32)0) : 0;
- } else if(nPos >= len) {
- result.startPos = icuBI->aBreakIterator->preceding(len);
- result.endPos = len;
- } else {
- result.startPos = icuBI->aBreakIterator->preceding(nPos);
- result.endPos = icuBI->aBreakIterator->following(nPos);
- }
+ result.startPos = icuBI->aBreakIterator->preceding(nPos);
+ result.endPos = icuBI->aBreakIterator->following(nPos);
}
- if (result.startPos == BreakIterator::DONE)
- result.startPos = result.endPos;
- else if (result.endPos == BreakIterator::DONE)
- result.endPos = result.startPos;
+ }
+ if (result.startPos == BreakIterator::DONE)
+ result.startPos = result.endPos;
+ else if (result.endPos == BreakIterator::DONE)
+ result.endPos = result.startPos;
- return result;
+ return result;
}
sal_Int32 SAL_CALL BreakIterator_Unicode::beginOfSentence( const OUString& Text, sal_Int32 nStartPos,
const lang::Locale &rLocale ) throw(uno::RuntimeException)
{
- loadICUBreakIterator(rLocale, LOAD_SENTENCE_BREAKITERATOR, 0, "sent", Text);
+ loadICUBreakIterator(rLocale, LOAD_SENTENCE_BREAKITERATOR, 0, "sent", Text);
- sal_Int32 len = Text.getLength();
- if (len > 0 && nStartPos == len)
- Text.iterateCodePoints(&nStartPos, -1); // issue #i27703# treat end position as part of last sentence
- if (!sentence.aBreakIterator->isBoundary(nStartPos))
- nStartPos = sentence.aBreakIterator->preceding(nStartPos);
+ sal_Int32 len = Text.getLength();
+ if (len > 0 && nStartPos == len)
+ Text.iterateCodePoints(&nStartPos, -1); // issue #i27703# treat end position as part of last sentence
+ if (!sentence.aBreakIterator->isBoundary(nStartPos))
+ nStartPos = sentence.aBreakIterator->preceding(nStartPos);
- // skip preceding space.
- sal_uInt32 ch = Text.iterateCodePoints(&nStartPos, 1);
- while (nStartPos < len && u_isWhitespace(ch)) ch = Text.iterateCodePoints(&nStartPos, 1);
- Text.iterateCodePoints(&nStartPos, -1);
+ // skip preceding space.
+ sal_uInt32 ch = Text.iterateCodePoints(&nStartPos, 1);
+ while (nStartPos < len && u_isWhitespace(ch)) ch = Text.iterateCodePoints(&nStartPos, 1);
+ Text.iterateCodePoints(&nStartPos, -1);
- return nStartPos;
+ return nStartPos;
}
sal_Int32 SAL_CALL BreakIterator_Unicode::endOfSentence( const OUString& Text, sal_Int32 nStartPos,
const lang::Locale &rLocale ) throw(uno::RuntimeException)
{
- loadICUBreakIterator(rLocale, LOAD_SENTENCE_BREAKITERATOR, 0, "sent", Text);
+ loadICUBreakIterator(rLocale, LOAD_SENTENCE_BREAKITERATOR, 0, "sent", Text);
- sal_Int32 len = Text.getLength();
- if (len > 0 && nStartPos == len)
- Text.iterateCodePoints(&nStartPos, -1); // issue #i27703# treat end position as part of last sentence
- nStartPos = sentence.aBreakIterator->following(nStartPos);
+ sal_Int32 len = Text.getLength();
+ if (len > 0 && nStartPos == len)
+ Text.iterateCodePoints(&nStartPos, -1); // issue #i27703# treat end position as part of last sentence
+ nStartPos = sentence.aBreakIterator->following(nStartPos);
- sal_Int32 nPos=nStartPos;
- while (nPos > 0 && u_isWhitespace(Text.iterateCodePoints(&nPos, -1))) nStartPos=nPos;
+ sal_Int32 nPos=nStartPos;
+ while (nPos > 0 && u_isWhitespace(Text.iterateCodePoints(&nPos, -1))) nStartPos=nPos;
- return nStartPos;
+ return nStartPos;
}
LineBreakResults SAL_CALL BreakIterator_Unicode::getLineBreak(
@@ -357,63 +357,63 @@ LineBreakResults SAL_CALL BreakIterator_Unicode::getLineBreak(
const LineBreakHyphenationOptions& hOptions,
const LineBreakUserOptions& /*rOptions*/ ) throw(uno::RuntimeException)
{
- LineBreakResults lbr;
+ LineBreakResults lbr;
- if (nStartPos >= Text.getLength()) {
- lbr.breakIndex = Text.getLength();
- lbr.breakType = BreakType::WORDBOUNDARY;
- return lbr;
- }
+ if (nStartPos >= Text.getLength()) {
+ lbr.breakIndex = Text.getLength();
+ lbr.breakType = BreakType::WORDBOUNDARY;
+ return lbr;
+ }
- loadICUBreakIterator(rLocale, LOAD_LINE_BREAKITERATOR, 0, lineRule, Text);
-
- sal_Bool GlueSpace=sal_True;
- while (GlueSpace) {
- if (line.aBreakIterator->preceding(nStartPos + 1) == nStartPos) { //Line boundary break
- lbr.breakIndex = nStartPos;
- lbr.breakType = BreakType::WORDBOUNDARY;
- } else if (hOptions.rHyphenator.is()) { //Hyphenation break
- Boundary wBoundary = getWordBoundary( Text, nStartPos, rLocale,
- WordType::DICTIONARY_WORD, false);
- uno::Reference< linguistic2::XHyphenatedWord > aHyphenatedWord;
- aHyphenatedWord = hOptions.rHyphenator->hyphenate(Text.copy(wBoundary.startPos,
- wBoundary.endPos - wBoundary.startPos), rLocale,
+ loadICUBreakIterator(rLocale, LOAD_LINE_BREAKITERATOR, 0, lineRule, Text);
+
+ sal_Bool GlueSpace=sal_True;
+ while (GlueSpace) {
+ if (line.aBreakIterator->preceding(nStartPos + 1) == nStartPos) { //Line boundary break
+ lbr.breakIndex = nStartPos;
+ lbr.breakType = BreakType::WORDBOUNDARY;
+ } else if (hOptions.rHyphenator.is()) { //Hyphenation break
+ Boundary wBoundary = getWordBoundary( Text, nStartPos, rLocale,
+ WordType::DICTIONARY_WORD, false);
+ uno::Reference< linguistic2::XHyphenatedWord > aHyphenatedWord;
+ aHyphenatedWord = hOptions.rHyphenator->hyphenate(Text.copy(wBoundary.startPos,
+ wBoundary.endPos - wBoundary.startPos), rLocale,
(sal_Int16) (hOptions.hyphenIndex - wBoundary.startPos), hOptions.aHyphenationOptions);
- if (aHyphenatedWord.is()) {
- lbr.rHyphenatedWord = aHyphenatedWord;
- if(wBoundary.startPos + aHyphenatedWord->getHyphenationPos() + 1 < nMinBreakPos )
- lbr.breakIndex = -1;
- else
- lbr.breakIndex = wBoundary.startPos; //aHyphenatedWord->getHyphenationPos();
- lbr.breakType = BreakType::HYPHENATION;
- } else {
- lbr.breakIndex = line.aBreakIterator->preceding(nStartPos);
- lbr.breakType = BreakType::WORDBOUNDARY;;
- }
- } else { //word boundary break
+ if (aHyphenatedWord.is()) {
+ lbr.rHyphenatedWord = aHyphenatedWord;
+ if(wBoundary.startPos + aHyphenatedWord->getHyphenationPos() + 1 < nMinBreakPos )
+ lbr.breakIndex = -1;
+ else
+ lbr.breakIndex = wBoundary.startPos; //aHyphenatedWord->getHyphenationPos();
+ lbr.breakType = BreakType::HYPHENATION;
+ } else {
lbr.breakIndex = line.aBreakIterator->preceding(nStartPos);
- lbr.breakType = BreakType::WORDBOUNDARY;
+ lbr.breakType = BreakType::WORDBOUNDARY;;
}
+ } else { //word boundary break
+ lbr.breakIndex = line.aBreakIterator->preceding(nStartPos);
+ lbr.breakType = BreakType::WORDBOUNDARY;
+ }
#define WJ 0x2060 // Word Joiner
- GlueSpace=sal_False;
- if (lbr.breakType == BreakType::WORDBOUNDARY) {
- nStartPos = lbr.breakIndex;
+ GlueSpace=sal_False;
+ if (lbr.breakType == BreakType::WORDBOUNDARY) {
+ nStartPos = lbr.breakIndex;
+ if (Text[nStartPos--] == WJ)
+ GlueSpace=sal_True;
+ while (nStartPos >= 0 &&
+ (u_isWhitespace(Text.iterateCodePoints(&nStartPos, 0)) || Text[nStartPos] == WJ)) {
if (Text[nStartPos--] == WJ)
GlueSpace=sal_True;
- while (nStartPos >= 0 &&
- (u_isWhitespace(Text.iterateCodePoints(&nStartPos, 0)) || Text[nStartPos] == WJ)) {
- if (Text[nStartPos--] == WJ)
- GlueSpace=sal_True;
- }
- if (GlueSpace && nStartPos < 0) {
- lbr.breakIndex = 0;
- break;
- }
+ }
+ if (GlueSpace && nStartPos < 0) {
+ lbr.breakIndex = 0;
+ break;
}
}
+ }
- return lbr;
+ return lbr;
}
@@ -421,21 +421,21 @@ LineBreakResults SAL_CALL BreakIterator_Unicode::getLineBreak(
OUString SAL_CALL
BreakIterator_Unicode::getImplementationName(void) throw( uno::RuntimeException )
{
- return OUString::createFromAscii(cBreakIterator);
+ return OUString::createFromAscii(cBreakIterator);
}
sal_Bool SAL_CALL
BreakIterator_Unicode::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
{
- return !rServiceName.compareToAscii(cBreakIterator);
+ return !rServiceName.compareToAscii(cBreakIterator);
}
uno::Sequence< OUString > SAL_CALL
BreakIterator_Unicode::getSupportedServiceNames(void) throw( uno::RuntimeException )
{
- uno::Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii(cBreakIterator);
- return aRet;
+ uno::Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii(cBreakIterator);
+ return aRet;
}
} } } }
diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx
index cf22d6cbd3e4..1200535f38cf 100644
--- a/i18npool/source/breakiterator/xdictionary.cxx
+++ b/i18npool/source/breakiterator/xdictionary.cxx
@@ -83,61 +83,62 @@ xdictionary::xdictionary(const sal_Char *lang) :
OUStringBuffer aBuf( strlen(lang) + 7 + 4 ); // mostly "*.dll" (with * == dict_zh)
#endif
aBuf.appendAscii( "dict_" ).appendAscii( lang ).appendAscii( SAL_DLLEXTENSION );
- hModule = osl_loadModuleRelative( &thisModule, aBuf.makeStringAndClear().pData, SAL_LOADMODULE_DEFAULT );
- if( hModule ) {
- sal_IntPtr (*func)();
- func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getExistMark").pData );
- existMark = (sal_uInt8*) (*func)();
- func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getIndex1").pData );
- index1 = (sal_Int16*) (*func)();
- func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getIndex2").pData );
- index2 = (sal_Int32*) (*func)();
- func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getLenArray").pData );
- lenArray = (sal_Int32*) (*func)();
- func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getDataArea").pData );
- dataArea = (sal_Unicode*) (*func)();
- }
- else
- {
- existMark = NULL;
- index1 = NULL;
- index2 = NULL;
- lenArray = NULL;
- dataArea = NULL;
- }
+ hModule = osl_loadModuleRelative( &thisModule, aBuf.makeStringAndClear().pData, SAL_LOADMODULE_DEFAULT );
+ if( hModule ) {
+ sal_IntPtr (*func)();
+ func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getExistMark").pData );
+ existMark = (sal_uInt8*) (*func)();
+ func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getIndex1").pData );
+ index1 = (sal_Int16*) (*func)();
+ func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getIndex2").pData );
+ index2 = (sal_Int32*) (*func)();
+ func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getLenArray").pData );
+ lenArray = (sal_Int32*) (*func)();
+ func = (sal_IntPtr(*)()) osl_getFunctionSymbol( hModule, OUString("getDataArea").pData );
+ dataArea = (sal_Unicode*) (*func)();
+ }
+ else
+ {
+ existMark = NULL;
+ index1 = NULL;
+ index2 = NULL;
+ lenArray = NULL;
+ dataArea = NULL;
+ }
#else
- if( strcmp( lang, "ja" ) == 0 ) {
- existMark = getExistMark_ja();
- index1 = getIndex1_ja();
- index2 = getIndex2_ja();
- lenArray = getLenArray_ja();
- dataArea = getDataArea_ja();
- }
- else if( strcmp( lang, "zh" ) == 0 ) {
- existMark = getExistMark_zh();
- index1 = getIndex1_zh();
- index2 = getIndex2_zh();
- lenArray = getLenArray_zh();
- dataArea = getDataArea_zh();
- }
- else
- {
- existMark = NULL;
- index1 = NULL;
- index2 = NULL;
- lenArray = NULL;
- dataArea = NULL;
- }
+ if( strcmp( lang, "ja" ) == 0 ) {
+ existMark = getExistMark_ja();
+ index1 = getIndex1_ja();
+ index2 = getIndex2_ja();
+ lenArray = getLenArray_ja();
+ dataArea = getDataArea_ja();
+ }
+ else if( strcmp( lang, "zh" ) == 0 ) {
+ existMark = getExistMark_zh();
+ index1 = getIndex1_zh();
+ index2 = getIndex2_zh();
+ lenArray = getLenArray_zh();
+ dataArea = getDataArea_zh();
+ }
+ else
+ {
+ existMark = NULL;
+ index1 = NULL;
+ index2 = NULL;
+ lenArray = NULL;
+ dataArea = NULL;
+ }
#endif
- for (sal_Int32 i = 0; i < CACHE_MAX; i++)
- cache[i].size = 0;
+ for (sal_Int32 i = 0; i < CACHE_MAX; i++)
+ cache[i].size = 0;
- japaneseWordBreak = sal_False;
+ japaneseWordBreak = sal_False;
}
-xdictionary::~xdictionary() {
+xdictionary::~xdictionary()
+{
#ifndef DISABLE_DYNLOADING
osl_unloadModule(hModule);
#endif
@@ -151,46 +152,48 @@ xdictionary::~xdictionary() {
void xdictionary::setJapaneseWordBreak()
{
- japaneseWordBreak = sal_True;
+ japaneseWordBreak = sal_True;
}
-sal_Bool xdictionary::exists(const sal_uInt32 c) {
- // 0x1FFF is the hardcoded limit in gendict for existMarks
- sal_Bool exist = (existMark && ((c>>3) < 0x1FFF)) ? sal::static_int_cast<sal_Bool>((existMark[c>>3] & (1<<(c&0x07))) != 0) : sal_False;
- if (!exist && japaneseWordBreak)
- return BreakIteratorImpl::getScriptClass(c) == ScriptType::ASIAN;
- else
- return exist;
+sal_Bool xdictionary::exists(const sal_uInt32 c)
+{
+ // 0x1FFF is the hardcoded limit in gendict for existMarks
+ sal_Bool exist = (existMark && ((c>>3) < 0x1FFF)) ? sal::static_int_cast<sal_Bool>((existMark[c>>3] & (1<<(c&0x07))) != 0) : sal_False;
+ if (!exist && japaneseWordBreak)
+ return BreakIteratorImpl::getScriptClass(c) == ScriptType::ASIAN;
+ else
+ return exist;
}
-sal_Int32 xdictionary::getLongestMatch(const sal_Unicode* str, sal_Int32 sLen) {
+sal_Int32 xdictionary::getLongestMatch(const sal_Unicode* str, sal_Int32 sLen)
+{
- if ( !index1 ) return 0;
+ if ( !index1 ) return 0;
- sal_Int16 idx = index1[str[0] >> 8];
+ sal_Int16 idx = index1[str[0] >> 8];
- if (idx == 0xFF) return 0;
+ if (idx == 0xFF) return 0;
- idx = (idx<<8) | (str[0]&0xff);
+ idx = (idx<<8) | (str[0]&0xff);
- sal_uInt32 begin = index2[idx], end = index2[idx+1];
+ sal_uInt32 begin = index2[idx], end = index2[idx+1];
- if (begin == 0) return 0;
+ if (begin == 0) return 0;
- str++; sLen--; // first character is not stored in the dictionary
- for (sal_uInt32 i = end; i > begin; i--) {
- sal_Int32 len = lenArray[i] - lenArray[i - 1];
- if (sLen >= len) {
- const sal_Unicode *dstr = dataArea + lenArray[i-1];
- sal_Int32 pos = 0;
+ str++; sLen--; // first character is not stored in the dictionary
+ for (sal_uInt32 i = end; i > begin; i--) {
+ sal_Int32 len = lenArray[i] - lenArray[i - 1];
+ if (sLen >= len) {
+ const sal_Unicode *dstr = dataArea + lenArray[i-1];
+ sal_Int32 pos = 0;
- while (pos < len && dstr[pos] == str[pos]) { pos++; }
+ while (pos < len && dstr[pos] == str[pos]) { pos++; }
- if (pos == len)
- return len + 1;
- }
+ if (pos == len)
+ return len + 1;
}
- return 0;
+ }
+ return 0;
}
@@ -210,14 +213,15 @@ WordBreakCache::WordBreakCache() :
* Compare two unicode string,
*/
-sal_Bool WordBreakCache::equals(const sal_Unicode* str, Boundary& boundary) {
- // Different length, different string.
- if (length != boundary.endPos - boundary.startPos) return sal_False;
+sal_Bool WordBreakCache::equals(const sal_Unicode* str, Boundary& boundary)
+{
+ // Different length, different string.
+ if (length != boundary.endPos - boundary.startPos) return sal_False;
- for (sal_Int32 i = 0; i < length; i++)
- if (contents[i] != str[i + boundary.startPos]) return sal_False;
+ for (sal_Int32 i = 0; i < length; i++)
+ if (contents[i] != str[i + boundary.startPos]) return sal_False;
- return sal_True;
+ return sal_True;
}
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index dddeea78f65b..ecb912fb94d3 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -137,66 +137,66 @@ Calendar_gregorian::Calendar_gregorian(const Era *_earArray)
void SAL_CALL
Calendar_gregorian::init(const Era *_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_gregorian";
-
- // #i102356# With icu::Calendar::createInstance(UErrorCode) in a Thai
- // th_TH system locale we accidentally used a Buddhist calendar. Though
- // the ICU documentation says that should be the case only for
- // th_TH_TRADITIONAL (and ja_JP_TRADITIONAL Gengou), a plain th_TH
- // already triggers that behavior, ja_JP does not. Strange enough,
- // passing a th_TH locale to the calendar creation doesn't trigger
- // this.
- // See also http://userguide.icu-project.org/datetime/calendar
-
- // Whatever ICU offers as the default calendar for a locale, ensure we
- // have a Gregorian calendar as requested.
-
- /* XXX: with the current implementation the aLocale member variable is
- * not set prior to loading a calendar from locale data. This
- * creates an empty (root) locale for ICU, but at least the correct
- * calendar is used. The language part must not be NULL (respectively
- * not all, language and country and variant), otherwise the current
- * default locale would be used again and the calendar keyword ignored.
- * */
- icu::Locale aIcuLocale( "", NULL, NULL, "calendar=gregorian");
+ cCalendar = "com.sun.star.i18n.Calendar_gregorian";
+
+ // #i102356# With icu::Calendar::createInstance(UErrorCode) in a Thai
+ // th_TH system locale we accidentally used a Buddhist calendar. Though
+ // the ICU documentation says that should be the case only for
+ // th_TH_TRADITIONAL (and ja_JP_TRADITIONAL Gengou), a plain th_TH
+ // already triggers that behavior, ja_JP does not. Strange enough,
+ // passing a th_TH locale to the calendar creation doesn't trigger
+ // this.
+ // See also http://userguide.icu-project.org/datetime/calendar
+
+ // Whatever ICU offers as the default calendar for a locale, ensure we
+ // have a Gregorian calendar as requested.
+
+ /* XXX: with the current implementation the aLocale member variable is
+ * not set prior to loading a calendar from locale data. This
+ * creates an empty (root) locale for ICU, but at least the correct
+ * calendar is used. The language part must not be NULL (respectively
+ * not all, language and country and variant), otherwise the current
+ * default locale would be used again and the calendar keyword ignored.
+ * */
+ icu::Locale aIcuLocale( "", NULL, NULL, "calendar=gregorian");
- UErrorCode status;
- body = icu::Calendar::createInstance( aIcuLocale, status = U_ZERO_ERROR);
- if (!body || !U_SUCCESS(status)) throw ERROR;
- eraArray=_eraArray;
+ UErrorCode status;
+ body = icu::Calendar::createInstance( aIcuLocale, status = U_ZERO_ERROR);
+ if (!body || !U_SUCCESS(status)) throw ERROR;
+ eraArray=_eraArray;
}
Calendar_gregorian::~Calendar_gregorian()
{
- delete body;
+ delete body;
}
Calendar_hanja::Calendar_hanja()
{
- cCalendar = "com.sun.star.i18n.Calendar_hanja";
+ cCalendar = "com.sun.star.i18n.Calendar_hanja";
}
OUString SAL_CALL
Calendar_hanja::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) throw(RuntimeException)
{
- if ( displayIndex == CalendarDisplayIndex::AM_PM ) {
- // Am/Pm string for Korean Hanja calendar will refer to Japanese locale
- com::sun::star::lang::Locale jaLocale =
- com::sun::star::lang::Locale(OUString("ja"), OUString(), OUString());
- if (idx == 0) return LocaleDataImpl().getLocaleItem(jaLocale).timeAM;
- else if (idx == 1) return LocaleDataImpl().getLocaleItem(jaLocale).timePM;
- else throw ERROR;
- }
- else
- return Calendar_gregorian::getDisplayName( displayIndex, idx, nameType );
+ if ( displayIndex == CalendarDisplayIndex::AM_PM ) {
+ // Am/Pm string for Korean Hanja calendar will refer to Japanese locale
+ com::sun::star::lang::Locale jaLocale =
+ com::sun::star::lang::Locale(OUString("ja"), OUString(), OUString());
+ if (idx == 0) return LocaleDataImpl().getLocaleItem(jaLocale).timeAM;
+ else if (idx == 1) return LocaleDataImpl().getLocaleItem(jaLocale).timePM;
+ else throw ERROR;
+ }
+ else
+ return Calendar_gregorian::getDisplayName( displayIndex, idx, nameType );
}
void SAL_CALL
Calendar_hanja::loadCalendar( const OUString& /*uniqueID*/, const com::sun::star::lang::Locale& rLocale ) throw(RuntimeException)
{
- // Since this class could be called by service name 'hanja_yoil', we have to
- // rename uniqueID to get right calendar defined in locale data.
- Calendar_gregorian::loadCalendar(OUString("hanja"), rLocale);
+ // Since this class could be called by service name 'hanja_yoil', we have to
+ // rename uniqueID to get right calendar defined in locale data.
+ Calendar_gregorian::loadCalendar(OUString("hanja"), rLocale);
}
static const Era gengou_eraArray[] = {
@@ -208,7 +208,7 @@ static const Era gengou_eraArray[] = {
};
Calendar_gengou::Calendar_gengou() : Calendar_gregorian(gengou_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_gengou";
+ cCalendar = "com.sun.star.i18n.Calendar_gengou";
}
static const Era ROC_eraArray[] = {
@@ -217,7 +217,7 @@ static const Era ROC_eraArray[] = {
};
Calendar_ROC::Calendar_ROC() : Calendar_gregorian(ROC_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_ROC";
+ cCalendar = "com.sun.star.i18n.Calendar_ROC";
}
static const Era buddhist_eraArray[] = {
@@ -226,118 +226,118 @@ static const Era buddhist_eraArray[] = {
};
Calendar_buddhist::Calendar_buddhist() : Calendar_gregorian(buddhist_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_buddhist";
+ cCalendar = "com.sun.star.i18n.Calendar_buddhist";
}
void SAL_CALL
Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star::lang::Locale& rLocale ) throw(RuntimeException)
{
- // init. fieldValue[]
- getValue();
+ // init. fieldValue[]
+ getValue();
- aLocale = rLocale;
- Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale);
- for (sal_Int32 i = 0; i < xC.getLength(); i++)
+ aLocale = rLocale;
+ Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale);
+ for (sal_Int32 i = 0; i < xC.getLength(); i++)
+ {
+ if (uniqueID == xC[i].Name)
{
- if (uniqueID == xC[i].Name)
+ aCalendar = xC[i];
+ // setup minimalDaysInFirstWeek
+ setMinimumNumberOfDaysForFirstWeek(
+ aCalendar.MinimumNumberOfDaysForFirstWeek);
+ // setup first day of week
+ for (sal_Int16 day = sal::static_int_cast<sal_Int16>(
+ aCalendar.Days.getLength()-1); day>=0; day--)
{
- aCalendar = xC[i];
- // setup minimalDaysInFirstWeek
- setMinimumNumberOfDaysForFirstWeek(
- aCalendar.MinimumNumberOfDaysForFirstWeek);
- // setup first day of week
- for (sal_Int16 day = sal::static_int_cast<sal_Int16>(
- aCalendar.Days.getLength()-1); day>=0; day--)
+ if (aCalendar.StartOfWeek == aCalendar.Days[day].ID)
{
- if (aCalendar.StartOfWeek == aCalendar.Days[day].ID)
- {
- setFirstDayOfWeek( day);
- return;
- }
+ setFirstDayOfWeek( day);
+ return;
}
}
}
- // Calendar is not for the locale
- throw ERROR;
+ }
+ // Calendar is not for the locale
+ throw ERROR;
}
com::sun::star::i18n::Calendar2 SAL_CALL
Calendar_gregorian::getLoadedCalendar2() throw(RuntimeException)
{
- return aCalendar;
+ return aCalendar;
}
com::sun::star::i18n::Calendar SAL_CALL
Calendar_gregorian::getLoadedCalendar() throw(RuntimeException)
{
- return LocaleDataImpl::downcastCalendar( aCalendar);
+ return LocaleDataImpl::downcastCalendar( aCalendar);
}
OUString SAL_CALL
Calendar_gregorian::getUniqueID() throw(RuntimeException)
{
- return aCalendar.Name;
+ return aCalendar.Name;
}
void SAL_CALL
Calendar_gregorian::setDateTime( double timeInDays ) throw(RuntimeException)
{
- // ICU handles dates in milliseconds as double values and uses floor()
- // to obtain integer values, which may yield a date decremented by one
- // for odd (historical) timezone values where the computed value due to
- // rounding errors has a fractional part in milliseconds. Ensure we
- // pass a value without fraction here. If not, that may lead to
- // fdo#44286 or fdo#52619 and the like, e.g. when passing
- // -2136315212000.000244 instead of -2136315212000.000000
- double fM = timeInDays * U_MILLIS_PER_DAY;
- double fR = rtl::math::round( fM );
- SAL_INFO_IF( fM != fR, "i18npool",
- "Calendar_gregorian::setDateTime: " << std::fixed << fM << " rounded to " << fR);
- UErrorCode status;
- body->setTime( fR, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) ) throw ERROR;
- getValue();
+ // ICU handles dates in milliseconds as double values and uses floor()
+ // to obtain integer values, which may yield a date decremented by one
+ // for odd (historical) timezone values where the computed value due to
+ // rounding errors has a fractional part in milliseconds. Ensure we
+ // pass a value without fraction here. If not, that may lead to
+ // fdo#44286 or fdo#52619 and the like, e.g. when passing
+ // -2136315212000.000244 instead of -2136315212000.000000
+ double fM = timeInDays * U_MILLIS_PER_DAY;
+ double fR = rtl::math::round( fM );
+ SAL_INFO_IF( fM != fR, "i18npool",
+ "Calendar_gregorian::setDateTime: " << std::fixed << fM << " rounded to " << fR);
+ UErrorCode status;
+ body->setTime( fR, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) ) throw ERROR;
+ getValue();
}
double SAL_CALL
Calendar_gregorian::getDateTime() throw(RuntimeException)
{
- if (fieldSet) {
- setValue();
- getValue();
- }
- UErrorCode status;
- double r = body->getTime(status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) ) throw ERROR;
- return r / U_MILLIS_PER_DAY;
+ if (fieldSet) {
+ setValue();
+ getValue();
+ }
+ UErrorCode status;
+ double r = body->getTime(status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) ) throw ERROR;
+ return r / U_MILLIS_PER_DAY;
}
// map field value from gregorian calendar to other calendar, it can be overwritten by derived class.
// By using eraArray, it can take care Japanese and Taiwan ROC calendar.
void Calendar_gregorian::mapFromGregorian() throw(RuntimeException)
{
- if (eraArray) {
- sal_Int16 e, y, m, d;
+ if (eraArray) {
+ sal_Int16 e, y, m, d;
- e = fieldValue[CalendarFieldIndex::ERA];
- y = fieldValue[CalendarFieldIndex::YEAR];
- m = fieldValue[CalendarFieldIndex::MONTH] + 1;
- d = fieldValue[CalendarFieldIndex::DAY_OF_MONTH];
+ e = fieldValue[CalendarFieldIndex::ERA];
+ y = fieldValue[CalendarFieldIndex::YEAR];
+ m = fieldValue[CalendarFieldIndex::MONTH] + 1;
+ d = fieldValue[CalendarFieldIndex::DAY_OF_MONTH];
- // since the year is reversed for first era, it is reversed again here for Era compare.
- if (e == 0)
- y = 1 - y;
+ // since the year is reversed for first era, it is reversed again here for Era compare.
+ if (e == 0)
+ y = 1 - y;
- for (e = 0; eraArray[e].year; e++)
- if ((y != eraArray[e].year) ? y < eraArray[e].year :
+ for (e = 0; eraArray[e].year; e++)
+ if ((y != eraArray[e].year) ? y < eraArray[e].year :
(m != eraArray[e].month) ? m < eraArray[e].month : d < eraArray[e].day)
- break;
+ break;
- fieldValue[CalendarFieldIndex::ERA] = e;
- fieldValue[CalendarFieldIndex::YEAR] =
- sal::static_int_cast<sal_Int16>( (e == 0) ? (eraArray[0].year - y) : (y - eraArray[e-1].year + 1) );
- }
+ fieldValue[CalendarFieldIndex::ERA] = e;
+ fieldValue[CalendarFieldIndex::YEAR] =
+ sal::static_int_cast<sal_Int16>( (e == 0) ? (eraArray[0].year - y) : (y - eraArray[e-1].year + 1) );
+ }
}
#define FIELDS ((1 << CalendarFieldIndex::ERA) | (1 << CalendarFieldIndex::YEAR))
@@ -345,42 +345,42 @@ void Calendar_gregorian::mapFromGregorian() throw(RuntimeException)
// By using eraArray, it can take care Japanese and Taiwan ROC calendar.
void Calendar_gregorian::mapToGregorian() throw(RuntimeException)
{
- if (eraArray && (fieldSet & FIELDS)) {
- sal_Int16 y, e = fieldValue[CalendarFieldIndex::ERA];
- if (e == 0)
- y = sal::static_int_cast<sal_Int16>( eraArray[0].year - fieldValue[CalendarFieldIndex::YEAR] );
- else
- y = sal::static_int_cast<sal_Int16>( eraArray[e-1].year + fieldValue[CalendarFieldIndex::YEAR] - 1 );
-
- fieldSetValue[CalendarFieldIndex::ERA] = y <= 0 ? 0 : 1;
- fieldSetValue[CalendarFieldIndex::YEAR] = (y <= 0 ? 1 - y : y);
- fieldSet |= FIELDS;
- }
+ if (eraArray && (fieldSet & FIELDS)) {
+ sal_Int16 y, e = fieldValue[CalendarFieldIndex::ERA];
+ if (e == 0)
+ y = sal::static_int_cast<sal_Int16>( eraArray[0].year - fieldValue[CalendarFieldIndex::YEAR] );
+ else
+ y = sal::static_int_cast<sal_Int16>( eraArray[e-1].year + fieldValue[CalendarFieldIndex::YEAR] - 1 );
+
+ fieldSetValue[CalendarFieldIndex::ERA] = y <= 0 ? 0 : 1;
+ fieldSetValue[CalendarFieldIndex::YEAR] = (y <= 0 ? 1 - y : y);
+ fieldSet |= FIELDS;
+ }
}
static UCalendarDateFields fieldNameConverter(sal_Int16 fieldIndex) throw(RuntimeException)
{
- UCalendarDateFields f;
-
- switch (fieldIndex) {
- case CalendarFieldIndex::AM_PM: f = UCAL_AM_PM; break;
- case CalendarFieldIndex::DAY_OF_MONTH: f = UCAL_DATE; break;
- case CalendarFieldIndex::DAY_OF_WEEK: f = UCAL_DAY_OF_WEEK; break;
- case CalendarFieldIndex::DAY_OF_YEAR: f = UCAL_DAY_OF_YEAR; break;
- case CalendarFieldIndex::DST_OFFSET: f = UCAL_DST_OFFSET; break;
- case CalendarFieldIndex::ZONE_OFFSET: f = UCAL_ZONE_OFFSET; break;
- case CalendarFieldIndex::HOUR: f = UCAL_HOUR_OF_DAY; break;
- case CalendarFieldIndex::MINUTE: f = UCAL_MINUTE; break;
- case CalendarFieldIndex::SECOND: f = UCAL_SECOND; break;
- case CalendarFieldIndex::MILLISECOND: f = UCAL_MILLISECOND; break;
- case CalendarFieldIndex::WEEK_OF_MONTH: f = UCAL_WEEK_OF_MONTH; break;
- case CalendarFieldIndex::WEEK_OF_YEAR: f = UCAL_WEEK_OF_YEAR; break;
- case CalendarFieldIndex::YEAR: f = UCAL_YEAR; break;
- case CalendarFieldIndex::MONTH: f = UCAL_MONTH; break;
- case CalendarFieldIndex::ERA: f = UCAL_ERA; break;
- default: throw ERROR;
- }
- return f;
+ UCalendarDateFields f;
+
+ switch (fieldIndex) {
+ case CalendarFieldIndex::AM_PM: f = UCAL_AM_PM; break;
+ case CalendarFieldIndex::DAY_OF_MONTH: f = UCAL_DATE; break;
+ case CalendarFieldIndex::DAY_OF_WEEK: f = UCAL_DAY_OF_WEEK; break;
+ case CalendarFieldIndex::DAY_OF_YEAR: f = UCAL_DAY_OF_YEAR; break;
+ case CalendarFieldIndex::DST_OFFSET: f = UCAL_DST_OFFSET; break;
+ case CalendarFieldIndex::ZONE_OFFSET: f = UCAL_ZONE_OFFSET; break;
+ case CalendarFieldIndex::HOUR: f = UCAL_HOUR_OF_DAY; break;
+ case CalendarFieldIndex::MINUTE: f = UCAL_MINUTE; break;
+ case CalendarFieldIndex::SECOND: f = UCAL_SECOND; break;
+ case CalendarFieldIndex::MILLISECOND: f = UCAL_MILLISECOND; break;
+ case CalendarFieldIndex::WEEK_OF_MONTH: f = UCAL_WEEK_OF_MONTH; break;
+ case CalendarFieldIndex::WEEK_OF_YEAR: f = UCAL_WEEK_OF_YEAR; break;
+ case CalendarFieldIndex::YEAR: f = UCAL_YEAR; break;
+ case CalendarFieldIndex::MONTH: f = UCAL_MONTH; break;
+ case CalendarFieldIndex::ERA: f = UCAL_ERA; break;
+ default: throw ERROR;
+ }
+ return f;
}
void SAL_CALL
@@ -491,220 +491,220 @@ static void lcl_setCombinedOffsetFieldValues( sal_Int32 nValue,
void Calendar_gregorian::setValue() throw(RuntimeException)
{
- // Correct DST glitch, see also localtime/gmtime conversion pitfalls at
- // http://www.erack.de/download/timetest.c
- //
- // #i24082# in order to make the DST correction work in all
- // circumstances, the time values have to be always resubmitted,
- // regardless whether specified by the caller or not. It is not
- // sufficient to rely on the ICU internal values previously set, as the
- // following may happen:
- // - Let 2004-03-28T02:00 be the onsetRule.
- // - On 2004-03-29 (calendar initialized with 2004-03-29T00:00 DST) set
- // a date of 2004-03-28 => calendar results in 2004-03-27T23:00 no DST.
- // - Correcting this with simply "2004-03-28 no DST" and no time
- // specified results in 2004-03-29T00:00, the ICU internal 23:00 time
- // being adjusted to 24:00 in this case, switching one day further.
- // => submit 2004-03-28T00:00 no DST.
-
- // This got even weirder since ICU incorporated also historical data,
- // even the timezone may differ for different dates! It is necessary to
- // let ICU choose the corresponding OlsonTimeZone transitions and adapt
- // values.
- // #i86094# gives examples where that went wrong:
- // TZ=Europe/Moscow date <= 1919-07-01
- // zone +2:30:48 (!) instead of +3h, DST +2h instead of +1h
- // TZ=America/St_Johns date <= 1935-03-30
- // zone -3:30:52 (!) instead of -3:30
-
- // Copy fields before calling submitFields() directly or indirectly below.
- memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
- // Possibly setup ERA and YEAR in fieldSetValue.
- mapToGregorian();
-
- DUMP_ICU_CAL_MSG(("%s\n","setValue() before any submission"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() before any submission"));
-
- bool bNeedZone = !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET));
- bool bNeedDST = !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET));
- sal_Int32 nZone1, nDST1, nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0;
- nZone1 = nDST1 = nZone0 = nDST0 = 0;
- nYear = nMonth = nDay = nHour = nMinute = nSecond = nMilliSecond = -1;
- if ( bNeedZone || bNeedDST )
+ // Correct DST glitch, see also localtime/gmtime conversion pitfalls at
+ // http://www.erack.de/download/timetest.c
+ //
+ // #i24082# in order to make the DST correction work in all
+ // circumstances, the time values have to be always resubmitted,
+ // regardless whether specified by the caller or not. It is not
+ // sufficient to rely on the ICU internal values previously set, as the
+ // following may happen:
+ // - Let 2004-03-28T02:00 be the onsetRule.
+ // - On 2004-03-29 (calendar initialized with 2004-03-29T00:00 DST) set
+ // a date of 2004-03-28 => calendar results in 2004-03-27T23:00 no DST.
+ // - Correcting this with simply "2004-03-28 no DST" and no time
+ // specified results in 2004-03-29T00:00, the ICU internal 23:00 time
+ // being adjusted to 24:00 in this case, switching one day further.
+ // => submit 2004-03-28T00:00 no DST.
+
+ // This got even weirder since ICU incorporated also historical data,
+ // even the timezone may differ for different dates! It is necessary to
+ // let ICU choose the corresponding OlsonTimeZone transitions and adapt
+ // values.
+ // #i86094# gives examples where that went wrong:
+ // TZ=Europe/Moscow date <= 1919-07-01
+ // zone +2:30:48 (!) instead of +3h, DST +2h instead of +1h
+ // TZ=America/St_Johns date <= 1935-03-30
+ // zone -3:30:52 (!) instead of -3:30
+
+ // Copy fields before calling submitFields() directly or indirectly below.
+ memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
+ // Possibly setup ERA and YEAR in fieldSetValue.
+ mapToGregorian();
+
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() before any submission"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() before any submission"));
+
+ bool bNeedZone = !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET));
+ bool bNeedDST = !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET));
+ sal_Int32 nZone1, nDST1, nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0;
+ nZone1 = nDST1 = nZone0 = nDST0 = 0;
+ nYear = nMonth = nDay = nHour = nMinute = nSecond = nMilliSecond = -1;
+ if ( bNeedZone || bNeedDST )
+ {
+ UErrorCode status;
+ if ( !(fieldSet & (1 << CalendarFieldIndex::YEAR)) )
{
- UErrorCode status;
- if ( !(fieldSet & (1 << CalendarFieldIndex::YEAR)) )
- {
- nYear = body->get( UCAL_YEAR, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nYear = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::MONTH)) )
- {
- nMonth = body->get( UCAL_MONTH, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nMonth = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::DAY_OF_MONTH)) )
- {
- nDay = body->get( UCAL_DATE, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDay = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::HOUR)) )
- {
- nHour = body->get( UCAL_HOUR_OF_DAY, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nHour = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::MINUTE)) )
- {
- nMinute = body->get( UCAL_MINUTE, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nMinute = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::SECOND)) )
- {
- nSecond = body->get( UCAL_SECOND, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nSecond = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::MILLISECOND)) )
- {
- nMilliSecond = body->get( UCAL_MILLISECOND, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nMilliSecond = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET)) )
- {
- nZone0 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nZone0 = 0;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET)) )
- {
- nDST0 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDST0 = 0;
- }
-
- // Submit values to obtain a time zone and DST corresponding to the date/time.
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0);
-
- DUMP_ICU_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
- nZone1 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ nYear = body->get( UCAL_YEAR, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nYear = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::MONTH)) )
+ {
+ nMonth = body->get( UCAL_MONTH, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nMonth = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::DAY_OF_MONTH)) )
+ {
+ nDay = body->get( UCAL_DATE, status = U_ZERO_ERROR);
if ( !U_SUCCESS(status) )
- nZone1 = 0;
- nDST1 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ nDay = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::HOUR)) )
+ {
+ nHour = body->get( UCAL_HOUR_OF_DAY, status = U_ZERO_ERROR);
if ( !U_SUCCESS(status) )
- nDST1 = 0;
+ nHour = -1;
}
+ if ( !(fieldSet & (1 << CalendarFieldIndex::MINUTE)) )
+ {
+ nMinute = body->get( UCAL_MINUTE, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nMinute = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::SECOND)) )
+ {
+ nSecond = body->get( UCAL_SECOND, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nSecond = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::MILLISECOND)) )
+ {
+ nMilliSecond = body->get( UCAL_MILLISECOND, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nMilliSecond = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET)) )
+ {
+ nZone0 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nZone0 = 0;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET)) )
+ {
+ nDST0 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST0 = 0;
+ }
+
+ // Submit values to obtain a time zone and DST corresponding to the date/time.
+ submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0);
+
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
+ nZone1 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nZone1 = 0;
+ nDST1 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST1 = 0;
+ }
- // The original submission, may lead to a different zone/DST and
- // different date.
- submitFields();
- DUMP_ICU_CAL_MSG(("%s\n","setValue() after original submission"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() after original submission"));
+ // The original submission, may lead to a different zone/DST and
+ // different date.
+ submitFields();
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() after original submission"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() after original submission"));
- if ( bNeedZone || bNeedDST )
+ if ( bNeedZone || bNeedDST )
+ {
+ UErrorCode status;
+ sal_Int32 nZone2 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nZone2 = nZone1;
+ sal_Int32 nDST2 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST2 = nDST1;
+ if ( nZone0 != nZone1 || nZone2 != nZone1 || nDST0 != nDST1 || nDST2 != nDST1 )
{
- UErrorCode status;
- sal_Int32 nZone2 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ // Due to different DSTs, resulting date values may differ if
+ // DST is onset at 00:00 and the very onsetRule date was
+ // submitted with DST off => date-1 23:00, for example, which
+ // is not what we want.
+ // Resubmit all values, this time including DST => date 01:00
+ // Similar for zone differences.
+ // If already the first full submission with nZone0 and nDST0
+ // lead to date-1 23:00, the original submission was based on
+ // that date if it wasn't a full date (nDST0 set, nDST1 not
+ // set, nDST2==nDST1). If it was January 1st without year we're
+ // even off by one year now. Resubmit all values including new
+ // DST => date 00:00.
+
+ // Set field values accordingly in case they were used.
+ if (!bNeedZone)
+ lcl_setCombinedOffsetFieldValues( nZone2, fieldSetValue,
+ fieldValue, CalendarFieldIndex::ZONE_OFFSET,
+ CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS);
+ if (!bNeedDST)
+ lcl_setCombinedOffsetFieldValues( nDST2, fieldSetValue,
+ fieldValue, CalendarFieldIndex::DST_OFFSET,
+ CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS);
+ submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone2, nDST2);
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
+
+ // Time zone transition => resubmit.
+ // TZ=America/St_Johns date <= 1935-03-30
+ // -3:30:52 (!) instead of -3:30
+ // if first submission included time zone -3:30 that would be wrong.
+ bool bResubmit = false;
+ sal_Int32 nZone3 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
if ( !U_SUCCESS(status) )
- nZone2 = nZone1;
- sal_Int32 nDST2 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDST2 = nDST1;
- if ( nZone0 != nZone1 || nZone2 != nZone1 || nDST0 != nDST1 || nDST2 != nDST1 )
+ nZone3 = nZone2;
+ if (nZone3 != nZone2)
{
- // Due to different DSTs, resulting date values may differ if
- // DST is onset at 00:00 and the very onsetRule date was
- // submitted with DST off => date-1 23:00, for example, which
- // is not what we want.
- // Resubmit all values, this time including DST => date 01:00
- // Similar for zone differences.
- // If already the first full submission with nZone0 and nDST0
- // lead to date-1 23:00, the original submission was based on
- // that date if it wasn't a full date (nDST0 set, nDST1 not
- // set, nDST2==nDST1). If it was January 1st without year we're
- // even off by one year now. Resubmit all values including new
- // DST => date 00:00.
-
- // Set field values accordingly in case they were used.
+ bResubmit = true;
if (!bNeedZone)
- lcl_setCombinedOffsetFieldValues( nZone2, fieldSetValue,
+ lcl_setCombinedOffsetFieldValues( nZone3, fieldSetValue,
fieldValue, CalendarFieldIndex::ZONE_OFFSET,
CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS);
- if (!bNeedDST)
- lcl_setCombinedOffsetFieldValues( nDST2, fieldSetValue,
- fieldValue, CalendarFieldIndex::DST_OFFSET,
- CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS);
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone2, nDST2);
- DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
-
- // Time zone transition => resubmit.
- // TZ=America/St_Johns date <= 1935-03-30
- // -3:30:52 (!) instead of -3:30
- // if first submission included time zone -3:30 that would be wrong.
- bool bResubmit = false;
- sal_Int32 nZone3 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nZone3 = nZone2;
- if (nZone3 != nZone2)
- {
- bResubmit = true;
- if (!bNeedZone)
- lcl_setCombinedOffsetFieldValues( nZone3, fieldSetValue,
- fieldValue, CalendarFieldIndex::ZONE_OFFSET,
- CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS);
- }
+ }
- // If the DST onset rule says to switch from 00:00 to 01:00 and
- // we tried to set onsetDay 00:00 with DST, the result was
- // onsetDay-1 23:00 and no DST, which is not what we want. So
- // once again without DST, resulting in onsetDay 01:00 and DST.
- // Yes, this seems to be weird, but logically correct.
- // It doesn't even have to be on an onsetDay as the DST is
- // factored in all days by ICU and there seems to be some
- // unknown behavior.
- // TZ=Asia/Tehran 1999-03-22 exposes this, for example.
- sal_Int32 nDST3 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDST3 = nDST2;
- if (nDST2 != nDST3 && !nDST3)
- {
- bResubmit = true;
- if (!bNeedDST)
- {
- fieldSetValue[CalendarFieldIndex::DST_OFFSET] =
- fieldValue[CalendarFieldIndex::DST_OFFSET] = 0;
- fieldSetValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] =
- fieldValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] = 0;
- }
- }
- if (bResubmit)
+ // If the DST onset rule says to switch from 00:00 to 01:00 and
+ // we tried to set onsetDay 00:00 with DST, the result was
+ // onsetDay-1 23:00 and no DST, which is not what we want. So
+ // once again without DST, resulting in onsetDay 01:00 and DST.
+ // Yes, this seems to be weird, but logically correct.
+ // It doesn't even have to be on an onsetDay as the DST is
+ // factored in all days by ICU and there seems to be some
+ // unknown behavior.
+ // TZ=Asia/Tehran 1999-03-22 exposes this, for example.
+ sal_Int32 nDST3 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST3 = nDST2;
+ if (nDST2 != nDST3 && !nDST3)
+ {
+ bResubmit = true;
+ if (!bNeedDST)
{
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone3, nDST3);
- DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
+ fieldSetValue[CalendarFieldIndex::DST_OFFSET] =
+ fieldValue[CalendarFieldIndex::DST_OFFSET] = 0;
+ fieldSetValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] =
+ fieldValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] = 0;
}
- SAL_INFO( "i18npool", "Calendar_gregorian::setValue:" <<
- " nZone0 " << nZone0 << ", nDST0 " << nDST0 <<
- ", nZone1 " << nZone1 << ", nDST1 " << nDST1 <<
- ", nZone2 " << nZone2 << ", nDST2 " << nDST2 <<
- ", nZone3 " << nZone3 << ", nDST3 " << nDST3);
}
+ if (bResubmit)
+ {
+ submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone3, nDST3);
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
+ }
+ SAL_INFO( "i18npool", "Calendar_gregorian::setValue:" <<
+ " nZone0 " << nZone0 << ", nDST0 " << nDST0 <<
+ ", nZone1 " << nZone1 << ", nDST1 " << nDST1 <<
+ ", nZone2 " << nZone2 << ", nDST2 " << nDST2 <<
+ ", nZone3 " << nZone3 << ", nDST3 " << nDST3);
}
+ }
#if erDUMP_ICU_CALENDAR || erDUMP_I18N_CALENDAR
- {
- // force icu::Calendar to recalculate
- UErrorCode status;
- sal_Int32 nTmp = body->get( UCAL_DATE, status = U_ZERO_ERROR);
- DUMP_ICU_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
- DUMP_I18N_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
- }
+ {
+ // force icu::Calendar to recalculate
+ UErrorCode status;
+ sal_Int32 nTmp = body->get( UCAL_DATE, status = U_ZERO_ERROR);
+ DUMP_ICU_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
+ DUMP_I18N_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
+ }
#endif
}
@@ -768,30 +768,30 @@ Calendar_gregorian::getValue( sal_Int16 fieldIndex ) throw(RuntimeException)
void SAL_CALL
Calendar_gregorian::addValue( sal_Int16 fieldIndex, sal_Int32 value ) throw(RuntimeException)
{
- // since ZONE and DST could not be add, we don't need to convert value here
- UErrorCode status;
- body->add(fieldNameConverter(fieldIndex), value, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) ) throw ERROR;
- getValue();
+ // since ZONE and DST could not be add, we don't need to convert value here
+ UErrorCode status;
+ body->add(fieldNameConverter(fieldIndex), value, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) ) throw ERROR;
+ getValue();
}
sal_Bool SAL_CALL
Calendar_gregorian::isValid() throw(RuntimeException)
{
- if (fieldSet) {
- sal_Int32 tmp = fieldSet;
- setValue();
- memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
- getValue();
- for ( sal_Int16 fieldIndex = 0; fieldIndex < FIELD_INDEX_COUNT; fieldIndex++ ) {
- // compare only with fields that are set and reset fieldSet[]
- if (tmp & (1 << fieldIndex)) {
- if (fieldSetValue[fieldIndex] != fieldValue[fieldIndex])
- return sal_False;
- }
+ if (fieldSet) {
+ sal_Int32 tmp = fieldSet;
+ setValue();
+ memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
+ getValue();
+ for ( sal_Int16 fieldIndex = 0; fieldIndex < FIELD_INDEX_COUNT; fieldIndex++ ) {
+ // compare only with fields that are set and reset fieldSet[]
+ if (tmp & (1 << fieldIndex)) {
+ if (fieldSetValue[fieldIndex] != fieldValue[fieldIndex])
+ return sal_False;
}
}
- return true;
+ }
+ return true;
}
// NativeNumberMode has different meaning between Number and Calendar for Asian locales.
@@ -894,123 +894,123 @@ throw(RuntimeException)
void SAL_CALL
Calendar_gregorian::setMinimumNumberOfDaysForFirstWeek( sal_Int16 days ) throw(RuntimeException)
{
- aCalendar.MinimumNumberOfDaysForFirstWeek = days;
- body->setMinimalDaysInFirstWeek( static_cast<uint8_t>( days));
+ aCalendar.MinimumNumberOfDaysForFirstWeek = days;
+ body->setMinimalDaysInFirstWeek( static_cast<uint8_t>( days));
}
sal_Int16 SAL_CALL
Calendar_gregorian::getMinimumNumberOfDaysForFirstWeek() throw(RuntimeException)
{
- return aCalendar.MinimumNumberOfDaysForFirstWeek;
+ return aCalendar.MinimumNumberOfDaysForFirstWeek;
}
sal_Int16 SAL_CALL
Calendar_gregorian::getNumberOfMonthsInYear() throw(RuntimeException)
{
- return (sal_Int16) aCalendar.Months.getLength();
+ return (sal_Int16) aCalendar.Months.getLength();
}
sal_Int16 SAL_CALL
Calendar_gregorian::getNumberOfDaysInWeek() throw(RuntimeException)
{
- return (sal_Int16) aCalendar.Days.getLength();
+ return (sal_Int16) aCalendar.Days.getLength();
}
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getDays() throw(RuntimeException)
{
- return LocaleDataImpl::downcastCalendarItems( aCalendar.Days);
+ return LocaleDataImpl::downcastCalendarItems( aCalendar.Days);
}
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getMonths() throw(RuntimeException)
{
- return LocaleDataImpl::downcastCalendarItems( aCalendar.Months);
+ return LocaleDataImpl::downcastCalendarItems( aCalendar.Months);
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getDays2() throw(RuntimeException)
{
- return aCalendar.Days;
+ return aCalendar.Days;
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getMonths2() throw(RuntimeException)
{
- return aCalendar.Months;
+ return aCalendar.Months;
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getGenitiveMonths2() throw(RuntimeException)
{
- return aCalendar.GenitiveMonths;
+ return aCalendar.GenitiveMonths;
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getPartitiveMonths2() throw(RuntimeException)
{
- return aCalendar.PartitiveMonths;
+ return aCalendar.PartitiveMonths;
}
OUString SAL_CALL
Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) throw(RuntimeException)
{
- OUString aStr;
+ OUString aStr;
- switch( displayIndex ) {
- case CalendarDisplayIndex::AM_PM:/* ==0 */
- if (idx == 0) aStr = LocaleDataImpl().getLocaleItem(aLocale).timeAM;
- else if (idx == 1) aStr = LocaleDataImpl().getLocaleItem(aLocale).timePM;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::DAY:
- if( idx >= aCalendar.Days.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.Days[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.Days[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.Days[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::MONTH:
- if( idx >= aCalendar.Months.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.Months[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.Months[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::GENITIVE_MONTH:
- if( idx >= aCalendar.GenitiveMonths.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.GenitiveMonths[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.GenitiveMonths[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::PARTITIVE_MONTH:
- if( idx >= aCalendar.PartitiveMonths.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.PartitiveMonths[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.PartitiveMonths[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.PartitiveMonths[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::ERA:
- if( idx >= aCalendar.Eras.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.Eras[idx].FullName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::YEAR:
- break;
- default:
- throw ERROR;
- }
- return aStr;
+ switch( displayIndex ) {
+ case CalendarDisplayIndex::AM_PM:/* ==0 */
+ if (idx == 0) aStr = LocaleDataImpl().getLocaleItem(aLocale).timeAM;
+ else if (idx == 1) aStr = LocaleDataImpl().getLocaleItem(aLocale).timePM;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::DAY:
+ if( idx >= aCalendar.Days.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.Days[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.Days[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Days[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::MONTH:
+ if( idx >= aCalendar.Months.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.Months[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Months[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::GENITIVE_MONTH:
+ if( idx >= aCalendar.GenitiveMonths.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.GenitiveMonths[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.GenitiveMonths[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::PARTITIVE_MONTH:
+ if( idx >= aCalendar.PartitiveMonths.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.PartitiveMonths[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.PartitiveMonths[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.PartitiveMonths[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::ERA:
+ if( idx >= aCalendar.Eras.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.Eras[idx].FullName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::YEAR:
+ break;
+ default:
+ throw ERROR;
+ }
+ return aStr;
}
// Methods in XExtendedCalendar
@@ -1168,21 +1168,21 @@ Calendar_buddhist::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 n
OUString SAL_CALL
Calendar_gregorian::getImplementationName(void) throw( RuntimeException )
{
- return OUString::createFromAscii(cCalendar);
+ return OUString::createFromAscii(cCalendar);
}
sal_Bool SAL_CALL
Calendar_gregorian::supportsService(const OUString& rServiceName) throw( RuntimeException )
{
- return !rServiceName.compareToAscii(cCalendar);
+ return !rServiceName.compareToAscii(cCalendar);
}
Sequence< OUString > SAL_CALL
Calendar_gregorian::getSupportedServiceNames(void) throw( RuntimeException )
{
- Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii(cCalendar);
- return aRet;
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii(cCalendar);
+ return aRet;
}
}}}}
diff --git a/i18npool/source/characterclassification/characterclassificationImpl.cxx b/i18npool/source/characterclassification/characterclassificationImpl.cxx
index d1389b69ba0b..e7fe8e692958 100644
--- a/i18npool/source/characterclassification/characterclassificationImpl.cxx
+++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx
@@ -31,8 +31,8 @@ namespace com { namespace sun { namespace star { namespace i18n {
CharacterClassificationImpl::CharacterClassificationImpl(
const Reference < uno::XComponentContext >& rxContext ) : m_xContext( rxContext )
{
- if (createLocaleSpecificCharacterClassification(OUString("Unicode"), Locale()))
- xUCI = cachedItem->xCI;
+ if (createLocaleSpecificCharacterClassification(OUString("Unicode"), Locale()))
+ xUCI = cachedItem->xCI;
}
CharacterClassificationImpl::~CharacterClassificationImpl() {
@@ -47,62 +47,62 @@ OUString SAL_CALL
CharacterClassificationImpl::toUpper( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
- return getLocaleSpecificCharacterClassification(rLocale)->toUpper(Text, nPos, nCount, rLocale);
+ return getLocaleSpecificCharacterClassification(rLocale)->toUpper(Text, nPos, nCount, rLocale);
}
OUString SAL_CALL
CharacterClassificationImpl::toLower( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
- return getLocaleSpecificCharacterClassification(rLocale)->toLower(Text, nPos, nCount, rLocale);
+ return getLocaleSpecificCharacterClassification(rLocale)->toLower(Text, nPos, nCount, rLocale);
}
OUString SAL_CALL
CharacterClassificationImpl::toTitle( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
- return getLocaleSpecificCharacterClassification(rLocale)->toTitle(Text, nPos, nCount, rLocale);
+ return getLocaleSpecificCharacterClassification(rLocale)->toTitle(Text, nPos, nCount, rLocale);
}
sal_Int16 SAL_CALL
CharacterClassificationImpl::getType( const OUString& Text, sal_Int32 nPos )
throw(RuntimeException)
{
- if (xUCI.is())
- return xUCI->getType(Text, nPos);
- throw RuntimeException();
+ if (xUCI.is())
+ return xUCI->getType(Text, nPos);
+ throw RuntimeException();
}
sal_Int16 SAL_CALL
CharacterClassificationImpl::getCharacterDirection( const OUString& Text, sal_Int32 nPos )
throw(RuntimeException)
{
- if (xUCI.is())
- return xUCI->getCharacterDirection(Text, nPos);
- throw RuntimeException();
+ if (xUCI.is())
+ return xUCI->getCharacterDirection(Text, nPos);
+ throw RuntimeException();
}
sal_Int16 SAL_CALL
CharacterClassificationImpl::getScript( const OUString& Text, sal_Int32 nPos )
throw(RuntimeException)
{
- if (xUCI.is())
- return xUCI->getScript(Text, nPos);
- throw RuntimeException();
+ if (xUCI.is())
+ return xUCI->getScript(Text, nPos);
+ throw RuntimeException();
}
sal_Int32 SAL_CALL
CharacterClassificationImpl::getCharacterType( const OUString& Text, sal_Int32 nPos,
const Locale& rLocale ) throw(RuntimeException)
{
- return getLocaleSpecificCharacterClassification(rLocale)->getCharacterType(Text, nPos, rLocale);
+ return getLocaleSpecificCharacterClassification(rLocale)->getCharacterType(Text, nPos, rLocale);
}
sal_Int32 SAL_CALL
CharacterClassificationImpl::getStringType( const OUString& Text, sal_Int32 nPos,
sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException)
{
- return getLocaleSpecificCharacterClassification(rLocale)->getStringType(Text, nPos, nCount, rLocale);
+ return getLocaleSpecificCharacterClassification(rLocale)->getStringType(Text, nPos, nCount, rLocale);
}
ParseResult SAL_CALL CharacterClassificationImpl::parseAnyToken(
@@ -111,9 +111,9 @@ ParseResult SAL_CALL CharacterClassificationImpl::parseAnyToken(
sal_Int32 contCharTokenType, const OUString& userDefinedCharactersCont )
throw(RuntimeException)
{
- return getLocaleSpecificCharacterClassification(rLocale)->parseAnyToken(Text, nPos, rLocale,
- startCharTokenType,userDefinedCharactersStart,
- contCharTokenType, userDefinedCharactersCont);
+ return getLocaleSpecificCharacterClassification(rLocale)->parseAnyToken(Text, nPos, rLocale,
+ startCharTokenType,userDefinedCharactersStart,
+ contCharTokenType, userDefinedCharactersCont);
}
@@ -123,73 +123,73 @@ ParseResult SAL_CALL CharacterClassificationImpl::parsePredefinedToken(
const OUString& userDefinedCharactersStart, sal_Int32 contCharTokenType,
const OUString& userDefinedCharactersCont ) throw(RuntimeException)
{
- return getLocaleSpecificCharacterClassification(rLocale)->parsePredefinedToken(
- nTokenType, Text, nPos, rLocale, startCharTokenType, userDefinedCharactersStart,
- contCharTokenType, userDefinedCharactersCont);
+ return getLocaleSpecificCharacterClassification(rLocale)->parsePredefinedToken(
+ nTokenType, Text, nPos, rLocale, startCharTokenType, userDefinedCharactersStart,
+ contCharTokenType, userDefinedCharactersCont);
}
sal_Bool SAL_CALL CharacterClassificationImpl::createLocaleSpecificCharacterClassification(const OUString& serviceName, const Locale& rLocale)
{
- // to share service between same Language but different Country code, like zh_CN and zh_SG
- for (size_t l = 0; l < lookupTable.size(); l++) {
- cachedItem = lookupTable[l];
- if (serviceName == cachedItem->aName) {
- lookupTable.push_back( cachedItem = new lookupTableItem(rLocale, serviceName, cachedItem->xCI) );
- return sal_True;
- }
+ // to share service between same Language but different Country code, like zh_CN and zh_SG
+ for (size_t l = 0; l < lookupTable.size(); l++) {
+ cachedItem = lookupTable[l];
+ if (serviceName == cachedItem->aName) {
+ lookupTable.push_back( cachedItem = new lookupTableItem(rLocale, serviceName, cachedItem->xCI) );
+ return sal_True;
}
+ }
- Reference < XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
- OUString("com.sun.star.i18n.CharacterClassification_") + serviceName, m_xContext);
+ Reference < XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
+ OUString("com.sun.star.i18n.CharacterClassification_") + serviceName, m_xContext);
- Reference < XCharacterClassification > xCI;
- if ( xI.is() ) {
- xCI.set( xI, UNO_QUERY );
- if (xCI.is()) {
- lookupTable.push_back( cachedItem = new lookupTableItem(rLocale, serviceName, xCI) );
- return sal_True;
- }
+ Reference < XCharacterClassification > xCI;
+ if ( xI.is() ) {
+ xCI.set( xI, UNO_QUERY );
+ if (xCI.is()) {
+ lookupTable.push_back( cachedItem = new lookupTableItem(rLocale, serviceName, xCI) );
+ return sal_True;
}
- return sal_False;
+ }
+ return sal_False;
}
Reference < XCharacterClassification > SAL_CALL
CharacterClassificationImpl::getLocaleSpecificCharacterClassification(const Locale& rLocale)
throw(RuntimeException)
{
- // reuse instance if locale didn't change
- if (cachedItem && cachedItem->equals(rLocale))
- return cachedItem->xCI;
- else {
- for (size_t i = 0; i < lookupTable.size(); i++) {
- cachedItem = lookupTable[i];
- if (cachedItem->equals(rLocale))
- return cachedItem->xCI;
- }
-
- // Load service with name <base>_<lang>_<country> or
- // <base>_<bcp47> and fallbacks.
- bool bLoaded = createLocaleSpecificCharacterClassification(
- LocaleDataImpl::getFirstLocaleServiceName( rLocale), rLocale);
- if (!bLoaded)
- {
- ::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
- for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
- {
- bLoaded = createLocaleSpecificCharacterClassification( *it, rLocale);
- if (bLoaded)
- break;
- }
- }
- if (bLoaded)
+ // reuse instance if locale didn't change
+ if (cachedItem && cachedItem->equals(rLocale))
+ return cachedItem->xCI;
+ else {
+ for (size_t i = 0; i < lookupTable.size(); i++) {
+ cachedItem = lookupTable[i];
+ if (cachedItem->equals(rLocale))
return cachedItem->xCI;
- else if (xUCI.is())
+ }
+
+ // Load service with name <base>_<lang>_<country> or
+ // <base>_<bcp47> and fallbacks.
+ bool bLoaded = createLocaleSpecificCharacterClassification(
+ LocaleDataImpl::getFirstLocaleServiceName( rLocale), rLocale);
+ if (!bLoaded)
+ {
+ ::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
+ for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
{
- lookupTable.push_back( cachedItem = new lookupTableItem( rLocale, OUString("Unicode"), xUCI));
- return cachedItem->xCI;
+ bLoaded = createLocaleSpecificCharacterClassification( *it, rLocale);
+ if (bLoaded)
+ break;
}
}
- throw RuntimeException();
+ if (bLoaded)
+ return cachedItem->xCI;
+ else if (xUCI.is())
+ {
+ lookupTable.push_back( cachedItem = new lookupTableItem( rLocale, OUString("Unicode"), xUCI));
+ return cachedItem->xCI;
+ }
+ }
+ throw RuntimeException();
}
const sal_Char cClass[] = "com.sun.star.i18n.CharacterClassification";
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 32c1c4f2d156..e1914bb48a86 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -267,7 +267,7 @@ DefaultNumberingProvider::DefaultNumberingProvider( const Reference < XComponent
DefaultNumberingProvider::~DefaultNumberingProvider()
{
- delete translit;
+ delete translit;
}
void DefaultNumberingProvider::impl_loadTranslit()
@@ -293,42 +293,42 @@ OUString toRoman( sal_Int32 n )
// i, ii, iii, iv, v, vi, vii, vii, viii, ix
// (Dummy),1000,500,100,50,10,5,1
- static const sal_Char coRomanArr[] = "MDCLXVI--"; // +2 Dummy entries !!
- const sal_Char* cRomanStr = coRomanArr;
- sal_uInt16 nMask = 1000;
- sal_uInt32 nOver1000 = n / nMask;
- n -= ( nOver1000 * nMask );
+ static const sal_Char coRomanArr[] = "MDCLXVI--"; // +2 Dummy entries !!
+ const sal_Char* cRomanStr = coRomanArr;
+ sal_uInt16 nMask = 1000;
+ sal_uInt32 nOver1000 = n / nMask;
+ n -= ( nOver1000 * nMask );
- OUStringBuffer sTmp;
- while(nOver1000--)
- sTmp.append(sal_Unicode(*coRomanArr));
+ OUStringBuffer sTmp;
+ while(nOver1000--)
+ sTmp.append(sal_Unicode(*coRomanArr));
- while( nMask )
+ while( nMask )
+ {
+ sal_uInt8 nZahl = sal_uInt8( n / nMask );
+ sal_uInt8 nDiff = 1;
+ n %= nMask;
+
+ if( 5 < nZahl )
+ {
+ if( nZahl < 9 )
+ sTmp.append(sal_Unicode(*(cRomanStr-1)));
+ ++nDiff;
+ nZahl -= 5;
+ }
+ switch( nZahl )
{
- sal_uInt8 nZahl = sal_uInt8( n / nMask );
- sal_uInt8 nDiff = 1;
- n %= nMask;
-
- if( 5 < nZahl )
- {
- if( nZahl < 9 )
- sTmp.append(sal_Unicode(*(cRomanStr-1)));
- ++nDiff;
- nZahl -= 5;
- }
- switch( nZahl )
- {
- case 3: sTmp.append(sal_Unicode(*cRomanStr)); //no break!
- case 2: sTmp.append(sal_Unicode(*cRomanStr)); //no break!
- case 1: sTmp.append(sal_Unicode(*cRomanStr)); break;
- case 4: sTmp.append(sal_Unicode(*cRomanStr)).append(sal_Unicode(*(cRomanStr-nDiff))); break;
- case 5: sTmp.append(sal_Unicode(*(cRomanStr-nDiff))); break;
- }
-
- nMask /= 10; // to the next decade
- cRomanStr += 2;
+ case 3: sTmp.append(sal_Unicode(*cRomanStr)); //no break!
+ case 2: sTmp.append(sal_Unicode(*cRomanStr)); //no break!
+ case 1: sTmp.append(sal_Unicode(*cRomanStr)); break;
+ case 4: sTmp.append(sal_Unicode(*cRomanStr)).append(sal_Unicode(*(cRomanStr-nDiff))); break;
+ case 5: sTmp.append(sal_Unicode(*(cRomanStr-nDiff))); break;
}
- return sTmp.makeStringAndClear();
+
+ nMask /= 10; // to the next decade
+ cRomanStr += 2;
+ }
+ return sTmp.makeStringAndClear();
}
// not used:
@@ -943,24 +943,24 @@ static const sal_Int32 nSupported_NumberingTypes = sizeof(aSupportedTypes) / siz
OUString DefaultNumberingProvider::makeNumberingIdentifier(sal_Int16 index)
throw(RuntimeException)
{
- if (aSupportedTypes[index].cSymbol)
- return OUString(aSupportedTypes[index].cSymbol, strlen(aSupportedTypes[index].cSymbol), RTL_TEXTENCODING_UTF8);
-// return OUString::createFromAscii(aSupportedTypes[index].cSymbol);
- else {
- OUString result;
- Locale aLocale(OUString("en"), OUString(), OUString());
- Sequence<beans::PropertyValue> aProperties(2);
- aProperties[0].Name = OUString("NumberingType");
- aProperties[0].Value <<= aSupportedTypes[index].nType;
- aProperties[1].Name = OUString("Value");
- for (sal_Int32 j = 1; j <= 3; j++) {
- aProperties[1].Value <<= j;
- result += makeNumberingString( aProperties, aLocale );
- result += ", ";
- }
- result += "...";
- return result;
+ if (aSupportedTypes[index].cSymbol)
+ return OUString(aSupportedTypes[index].cSymbol, strlen(aSupportedTypes[index].cSymbol), RTL_TEXTENCODING_UTF8);
+ // return OUString::createFromAscii(aSupportedTypes[index].cSymbol);
+ else {
+ OUString result;
+ Locale aLocale(OUString("en"), OUString(), OUString());
+ Sequence<beans::PropertyValue> aProperties(2);
+ aProperties[0].Name = OUString("NumberingType");
+ aProperties[0].Value <<= aSupportedTypes[index].nType;
+ aProperties[1].Name = OUString("Value");
+ for (sal_Int32 j = 1; j <= 3; j++) {
+ aProperties[1].Value <<= j;
+ result += makeNumberingString( aProperties, aLocale );
+ result += ", ";
}
+ result += "...";
+ return result;
+ }
}
sal_Bool SAL_CALL
@@ -1000,46 +1000,46 @@ DefaultNumberingProvider::isScriptFlagEnabled(const OUString& aName) throw(Runti
Sequence< sal_Int16 > DefaultNumberingProvider::getSupportedNumberingTypes( )
throw(RuntimeException)
{
- Sequence< sal_Int16 > aRet(nSupported_NumberingTypes );
- sal_Int16* pArray = aRet.getArray();
+ Sequence< sal_Int16 > aRet(nSupported_NumberingTypes );
+ sal_Int16* pArray = aRet.getArray();
- sal_Bool cjkEnabled = isScriptFlagEnabled(OUString("CJK/CJKFont"));
- sal_Bool ctlEnabled = isScriptFlagEnabled(OUString("CTL/CTLFont"));
+ sal_Bool cjkEnabled = isScriptFlagEnabled(OUString("CJK/CJKFont"));
+ sal_Bool ctlEnabled = isScriptFlagEnabled(OUString("CTL/CTLFont"));
- for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++) {
- if ( (aSupportedTypes[i].langOption & LANG_ALL) ||
- ((aSupportedTypes[i].langOption & LANG_CJK) && cjkEnabled) ||
- ((aSupportedTypes[i].langOption & LANG_CTL) && ctlEnabled) )
- pArray[i] = aSupportedTypes[i].nType;
- }
- return aRet;
+ for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++) {
+ if ( (aSupportedTypes[i].langOption & LANG_ALL) ||
+ ((aSupportedTypes[i].langOption & LANG_CJK) && cjkEnabled) ||
+ ((aSupportedTypes[i].langOption & LANG_CTL) && ctlEnabled) )
+ pArray[i] = aSupportedTypes[i].nType;
+ }
+ return aRet;
}
sal_Int16 DefaultNumberingProvider::getNumberingType( const OUString& rNumberingIdentifier )
throw(RuntimeException)
{
- for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
- if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
- return aSupportedTypes[i].nType;
- throw RuntimeException();
+ for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
+ if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
+ return aSupportedTypes[i].nType;
+ throw RuntimeException();
}
sal_Bool DefaultNumberingProvider::hasNumberingType( const OUString& rNumberingIdentifier )
throw(RuntimeException)
{
- for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
- if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
- return sal_True;
- return sal_False;
+ for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
+ if(rNumberingIdentifier.equals(makeNumberingIdentifier(i)))
+ return sal_True;
+ return sal_False;
}
OUString DefaultNumberingProvider::getNumberingIdentifier( sal_Int16 nNumberingType )
throw(RuntimeException)
{
- for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
- if(nNumberingType == aSupportedTypes[i].nType)
- return makeNumberingIdentifier(i);
- return OUString();
+ for(sal_Int16 i = 0; i < nSupported_NumberingTypes; i++)
+ if(nNumberingType == aSupportedTypes[i].nType)
+ return makeNumberingIdentifier(i);
+ return OUString();
}
static const sal_Char cDefaultNumberingProvider[] = "com.sun.star.text.DefaultNumberingProvider";
diff --git a/i18npool/source/indexentry/indexentrysupplier.cxx b/i18npool/source/indexentry/indexentrysupplier.cxx
index e832dc8ca7dd..6a4ef3b4b4ff 100644
--- a/i18npool/source/indexentry/indexentrysupplier.cxx
+++ b/i18npool/source/indexentry/indexentrysupplier.cxx
@@ -33,144 +33,144 @@ IndexEntrySupplier::IndexEntrySupplier( const Reference < XComponentContext >& r
Sequence < Locale > SAL_CALL IndexEntrySupplier::getLocaleList() throw (RuntimeException)
{
- return LocaleDataImpl().getAllInstalledLocaleNames();
+ return LocaleDataImpl().getAllInstalledLocaleNames();
}
Sequence < OUString > SAL_CALL IndexEntrySupplier::getAlgorithmList( const Locale& rLocale ) throw (RuntimeException)
{
- return LocaleDataImpl().getIndexAlgorithm(rLocale);
+ return LocaleDataImpl().getIndexAlgorithm(rLocale);
}
sal_Bool SAL_CALL IndexEntrySupplier::loadAlgorithm( const Locale& rLocale, const OUString& SortAlgorithm,
sal_Int32 collatorOptions ) throw (RuntimeException)
{
- Sequence < OUString > algorithmList = getAlgorithmList( rLocale );
- for (sal_Int32 i = 0; i < algorithmList.getLength(); i++) {
- if (algorithmList[i] == SortAlgorithm) {
- if (getLocaleSpecificIndexEntrySupplier(rLocale, SortAlgorithm).is())
- return xIES->loadAlgorithm(rLocale, SortAlgorithm, collatorOptions);
- }
+ Sequence < OUString > algorithmList = getAlgorithmList( rLocale );
+ for (sal_Int32 i = 0; i < algorithmList.getLength(); i++) {
+ if (algorithmList[i] == SortAlgorithm) {
+ if (getLocaleSpecificIndexEntrySupplier(rLocale, SortAlgorithm).is())
+ return xIES->loadAlgorithm(rLocale, SortAlgorithm, collatorOptions);
}
- return sal_False;
+ }
+ return sal_False;
}
sal_Bool SAL_CALL IndexEntrySupplier::usePhoneticEntry( const Locale& rLocale ) throw (RuntimeException)
{
- return LocaleDataImpl().hasPhonetic(rLocale);
+ return LocaleDataImpl().hasPhonetic(rLocale);
}
OUString SAL_CALL IndexEntrySupplier::getPhoneticCandidate( const OUString& rIndexEntry,
const Locale& rLocale ) throw (RuntimeException)
{
- if (getLocaleSpecificIndexEntrySupplier(rLocale, OUString()).is())
- return xIES->getPhoneticCandidate(rIndexEntry, rLocale);
- else
- throw RuntimeException();
+ if (getLocaleSpecificIndexEntrySupplier(rLocale, OUString()).is())
+ return xIES->getPhoneticCandidate(rIndexEntry, rLocale);
+ else
+ throw RuntimeException();
}
OUString SAL_CALL IndexEntrySupplier::getIndexKey( const OUString& rIndexEntry,
const OUString& rPhoneticEntry, const Locale& rLocale ) throw (RuntimeException)
{
- if (xIES.is())
- return xIES->getIndexKey(rIndexEntry, rPhoneticEntry, rLocale);
- else
- throw RuntimeException();
+ if (xIES.is())
+ return xIES->getIndexKey(rIndexEntry, rPhoneticEntry, rLocale);
+ else
+ throw RuntimeException();
}
sal_Int16 SAL_CALL IndexEntrySupplier::compareIndexEntry(
const OUString& rIndexEntry1, const OUString& rPhoneticEntry1, const Locale& rLocale1,
const OUString& rIndexEntry2, const OUString& rPhoneticEntry2, const Locale& rLocale2 )
- throw (com::sun::star::uno::RuntimeException)
+throw (com::sun::star::uno::RuntimeException)
{
- if (xIES.is())
- return xIES->compareIndexEntry(rIndexEntry1, rPhoneticEntry1, rLocale1,
- rIndexEntry2, rPhoneticEntry2, rLocale2);
- else
- throw RuntimeException();
+ if (xIES.is())
+ return xIES->compareIndexEntry(rIndexEntry1, rPhoneticEntry1, rLocale1,
+ rIndexEntry2, rPhoneticEntry2, rLocale2);
+ else
+ throw RuntimeException();
}
OUString SAL_CALL IndexEntrySupplier::getIndexCharacter( const OUString& rIndexEntry,
const Locale& rLocale, const OUString& rSortAlgorithm )
- throw (RuntimeException)
+throw (RuntimeException)
{
- return getLocaleSpecificIndexEntrySupplier(rLocale, rSortAlgorithm)->
- getIndexCharacter( rIndexEntry, rLocale, rSortAlgorithm );
+ return getLocaleSpecificIndexEntrySupplier(rLocale, rSortAlgorithm)->
+ getIndexCharacter( rIndexEntry, rLocale, rSortAlgorithm );
}
sal_Bool SAL_CALL IndexEntrySupplier::createLocaleSpecificIndexEntrySupplier(const OUString& name) throw( RuntimeException )
{
- Reference < XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
+ Reference < XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
OUString("com.sun.star.i18n.IndexEntrySupplier_") + name, m_xContext);
- if ( xI.is() ) {
- xIES.set( xI, UNO_QUERY );
- return xIES.is();
- }
- return sal_False;
+ if ( xI.is() ) {
+ xIES.set( xI, UNO_QUERY );
+ return xIES.is();
+ }
+ return sal_False;
}
Reference < com::sun::star::i18n::XExtendedIndexEntrySupplier > SAL_CALL
IndexEntrySupplier::getLocaleSpecificIndexEntrySupplier(const Locale& rLocale, const OUString& rSortAlgorithm) throw (RuntimeException)
{
- if (xIES.is() && rSortAlgorithm == aSortAlgorithm && rLocale.Language == aLocale.Language &&
- rLocale.Country == aLocale.Country && rLocale.Variant == aLocale.Variant)
+ if (xIES.is() && rSortAlgorithm == aSortAlgorithm && rLocale.Language == aLocale.Language &&
+ rLocale.Country == aLocale.Country && rLocale.Variant == aLocale.Variant)
+ return xIES;
+ else {
+ LocaleDataImpl ld;
+ aLocale = rLocale;
+ if (rSortAlgorithm.isEmpty())
+ aSortAlgorithm = ld.getDefaultIndexAlgorithm( rLocale );
+ else
+ aSortAlgorithm = rSortAlgorithm;
+
+ OUString module = ld.getIndexModuleByAlgorithm(rLocale, aSortAlgorithm);
+ if (!module.isEmpty() && createLocaleSpecificIndexEntrySupplier(module))
return xIES;
- else {
- LocaleDataImpl ld;
- aLocale = rLocale;
- if (rSortAlgorithm.isEmpty())
- aSortAlgorithm = ld.getDefaultIndexAlgorithm( rLocale );
- else
- aSortAlgorithm = rSortAlgorithm;
-
- OUString module = ld.getIndexModuleByAlgorithm(rLocale, aSortAlgorithm);
- if (!module.isEmpty() && createLocaleSpecificIndexEntrySupplier(module))
- return xIES;
-
- bool bLoaded = false;
- if (!aSortAlgorithm.isEmpty())
+
+ bool bLoaded = false;
+ if (!aSortAlgorithm.isEmpty())
+ {
+ // Load service with name <base>_<lang>_<country>_<algorithm>
+ // or <base>_<bcp47>_<algorithm> and fallbacks.
+ bLoaded = createLocaleSpecificIndexEntrySupplier(
+ LocaleDataImpl::getFirstLocaleServiceName( rLocale) + "_" + aSortAlgorithm);
+ if (!bLoaded)
{
- // Load service with name <base>_<lang>_<country>_<algorithm>
- // or <base>_<bcp47>_<algorithm> and fallbacks.
- bLoaded = createLocaleSpecificIndexEntrySupplier(
- LocaleDataImpl::getFirstLocaleServiceName( rLocale) + "_" + aSortAlgorithm);
+ ::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
+ for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
+ {
+ bLoaded = createLocaleSpecificIndexEntrySupplier( *it + "_" + aSortAlgorithm);
+ if (bLoaded)
+ break;
+ }
if (!bLoaded)
{
- ::std::vector< OUString > aFallbacks( LocaleDataImpl::getFallbackLocaleServiceNames( rLocale));
- for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
- {
- bLoaded = createLocaleSpecificIndexEntrySupplier( *it + "_" + aSortAlgorithm);
- if (bLoaded)
- break;
- }
- if (!bLoaded)
- {
- // load service with name <base>_<algorithm>
- bLoaded = createLocaleSpecificIndexEntrySupplier( aSortAlgorithm);
- }
+ // load service with name <base>_<algorithm>
+ bLoaded = createLocaleSpecificIndexEntrySupplier( aSortAlgorithm);
}
}
+ }
+ if (!bLoaded)
+ {
+ // load default service with name <base>_Unicode
+ bLoaded = createLocaleSpecificIndexEntrySupplier( "Unicode");
if (!bLoaded)
{
- // load default service with name <base>_Unicode
- bLoaded = createLocaleSpecificIndexEntrySupplier( "Unicode");
- if (!bLoaded)
- {
- throw RuntimeException(); // could not load any service
- }
+ throw RuntimeException(); // could not load any service
}
- return xIES;
}
+ return xIES;
+ }
}
OUString SAL_CALL IndexEntrySupplier::getIndexFollowPageWord( sal_Bool bMorePages,
const Locale& rLocale ) throw (RuntimeException)
{
- Sequence< OUString > aFollowPageWords = LocaleDataImpl().getFollowPageWords(rLocale);
+ Sequence< OUString > aFollowPageWords = LocaleDataImpl().getFollowPageWords(rLocale);
- return (bMorePages && aFollowPageWords.getLength() > 1) ?
- aFollowPageWords[1] : (aFollowPageWords.getLength() > 0 ?
- aFollowPageWords[0] : OUString());
+ return (bMorePages && aFollowPageWords.getLength() > 1) ?
+ aFollowPageWords[1] : (aFollowPageWords.getLength() > 0 ?
+ aFollowPageWords[0] : OUString());
}
#define implementationName "com.sun.star.i18n.IndexEntrySupplier"
@@ -178,21 +178,21 @@ OUString SAL_CALL IndexEntrySupplier::getIndexFollowPageWord( sal_Bool bMorePage
OUString SAL_CALL
IndexEntrySupplier::getImplementationName() throw( RuntimeException )
{
- return OUString::createFromAscii( implementationName );
+ return OUString::createFromAscii( implementationName );
}
sal_Bool SAL_CALL
IndexEntrySupplier::supportsService(const OUString& rServiceName) throw( RuntimeException )
{
- return rServiceName.compareToAscii(implementationName) == 0;
+ return rServiceName.compareToAscii(implementationName) == 0;
}
Sequence< OUString > SAL_CALL
IndexEntrySupplier::getSupportedServiceNames() throw( RuntimeException )
{
- Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii( implementationName );
- return aRet;
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii( implementationName );
+ return aRet;
}
} } } }
diff --git a/i18npool/source/inputchecker/inputsequencechecker.cxx b/i18npool/source/inputchecker/inputsequencechecker.cxx
index 159663edc3fc..d1a6e881683a 100644
--- a/i18npool/source/inputchecker/inputsequencechecker.cxx
+++ b/i18npool/source/inputchecker/inputsequencechecker.cxx
@@ -32,8 +32,8 @@ namespace com { namespace sun { namespace star { namespace i18n {
InputSequenceCheckerImpl::InputSequenceCheckerImpl( const Reference < XComponentContext >& rxContext ) : m_xContext( rxContext )
{
- serviceName = "com.sun.star.i18n.InputSequenceCheckerImpl";
- cachedItem = NULL;
+ serviceName = "com.sun.star.i18n.InputSequenceCheckerImpl";
+ cachedItem = NULL;
}
InputSequenceCheckerImpl::InputSequenceCheckerImpl()
@@ -42,49 +42,49 @@ InputSequenceCheckerImpl::InputSequenceCheckerImpl()
InputSequenceCheckerImpl::~InputSequenceCheckerImpl()
{
- // Clear lookuptable
- for (size_t l = 0; l < lookupTable.size(); l++)
- delete lookupTable[l];
+ // Clear lookuptable
+ for (size_t l = 0; l < lookupTable.size(); l++)
+ delete lookupTable[l];
- lookupTable.clear();
+ lookupTable.clear();
}
sal_Bool SAL_CALL
InputSequenceCheckerImpl::checkInputSequence(const OUString& Text, sal_Int32 nStartPos,
sal_Unicode inputChar, sal_Int16 inputCheckMode) throw(RuntimeException)
{
- if (inputCheckMode == InputSequenceCheckMode::PASSTHROUGH)
- return sal_True;
+ if (inputCheckMode == InputSequenceCheckMode::PASSTHROUGH)
+ return sal_True;
- sal_Char* language = getLanguageByScripType(Text[nStartPos], inputChar);
+ sal_Char* language = getLanguageByScripType(Text[nStartPos], inputChar);
- if (language)
- return getInputSequenceChecker(language)->checkInputSequence(Text, nStartPos, inputChar, inputCheckMode);
- else
- return sal_True; // not a checkable languages.
+ if (language)
+ return getInputSequenceChecker(language)->checkInputSequence(Text, nStartPos, inputChar, inputCheckMode);
+ else
+ return sal_True; // not a checkable languages.
}
sal_Int32 SAL_CALL
InputSequenceCheckerImpl::correctInputSequence(OUString& Text, sal_Int32 nStartPos,
sal_Unicode inputChar, sal_Int16 inputCheckMode) throw(RuntimeException)
{
- if (inputCheckMode != InputSequenceCheckMode::PASSTHROUGH) {
- sal_Char* language = getLanguageByScripType(Text[nStartPos], inputChar);
+ if (inputCheckMode != InputSequenceCheckMode::PASSTHROUGH) {
+ sal_Char* language = getLanguageByScripType(Text[nStartPos], inputChar);
- if (language)
- return getInputSequenceChecker(language)->correctInputSequence(Text, nStartPos, inputChar, inputCheckMode);
- }
- Text = Text.replaceAt(++nStartPos, 0, OUString(inputChar));
- return nStartPos;
+ if (language)
+ return getInputSequenceChecker(language)->correctInputSequence(Text, nStartPos, inputChar, inputCheckMode);
+ }
+ Text = Text.replaceAt(++nStartPos, 0, OUString(inputChar));
+ return nStartPos;
}
static ScriptTypeList typeList[] = {
- //{ UnicodeScript_kHebrew, UnicodeScript_kHebrew }, // 10,
- //{ UnicodeScript_kArabic, UnicodeScript_kArabic }, // 11,
- { UnicodeScript_kDevanagari,UnicodeScript_kDevanagari, UnicodeScript_kDevanagari }, // 14,
- { UnicodeScript_kThai, UnicodeScript_kThai, UnicodeScript_kThai }, // 24,
+ //{ UnicodeScript_kHebrew, UnicodeScript_kHebrew }, // 10,
+ //{ UnicodeScript_kArabic, UnicodeScript_kArabic }, // 11,
+ { UnicodeScript_kDevanagari,UnicodeScript_kDevanagari, UnicodeScript_kDevanagari }, // 14,
+ { UnicodeScript_kThai, UnicodeScript_kThai, UnicodeScript_kThai }, // 24,
- { UnicodeScript_kScriptCount, UnicodeScript_kScriptCount, UnicodeScript_kScriptCount } // 88
+ { UnicodeScript_kScriptCount, UnicodeScript_kScriptCount, UnicodeScript_kScriptCount } // 88
};
sal_Char* SAL_CALL
@@ -96,8 +96,8 @@ InputSequenceCheckerImpl::getLanguageByScripType(sal_Unicode cChar, sal_Unicode
type == unicode::getUnicodeScriptType( nChar, typeList, UnicodeScript_kScriptCount )) {
switch(type) {
case UnicodeScript_kThai: return (sal_Char*)"th";
- //case UnicodeScript_kArabic: return (sal_Char*)"ar";
- //case UnicodeScript_kHebrew: return (sal_Char*)"he";
+ //case UnicodeScript_kArabic: return (sal_Char*)"ar";
+ //case UnicodeScript_kHebrew: return (sal_Char*)"he";
case UnicodeScript_kDevanagari: return (sal_Char*)"hi";
}
}
@@ -107,50 +107,50 @@ InputSequenceCheckerImpl::getLanguageByScripType(sal_Unicode cChar, sal_Unicode
Reference< XExtendedInputSequenceChecker >& SAL_CALL
InputSequenceCheckerImpl::getInputSequenceChecker(sal_Char* rLanguage) throw (RuntimeException)
{
- if (cachedItem && cachedItem->aLanguage == rLanguage) {
- return cachedItem->xISC;
+ if (cachedItem && cachedItem->aLanguage == rLanguage) {
+ return cachedItem->xISC;
+ }
+ else {
+ for (size_t l = 0; l < lookupTable.size(); l++) {
+ cachedItem = lookupTable[l];
+ if (cachedItem->aLanguage == rLanguage)
+ return cachedItem->xISC;
}
- else {
- for (size_t l = 0; l < lookupTable.size(); l++) {
- cachedItem = lookupTable[l];
- if (cachedItem->aLanguage == rLanguage)
- return cachedItem->xISC;
- }
- Reference < uno::XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
- OUString("com.sun.star.i18n.InputSequenceChecker_") +
- OUString::createFromAscii(rLanguage),
- m_xContext);
-
- if ( xI.is() ) {
- Reference< XExtendedInputSequenceChecker > xISC( xI, uno::UNO_QUERY );
- if (xISC.is()) {
- lookupTable.push_back(cachedItem = new lookupTableItem(rLanguage, xISC));
- return cachedItem->xISC;
- }
+ Reference < uno::XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext(
+ OUString("com.sun.star.i18n.InputSequenceChecker_") +
+ OUString::createFromAscii(rLanguage),
+ m_xContext);
+
+ if ( xI.is() ) {
+ Reference< XExtendedInputSequenceChecker > xISC( xI, uno::UNO_QUERY );
+ if (xISC.is()) {
+ lookupTable.push_back(cachedItem = new lookupTableItem(rLanguage, xISC));
+ return cachedItem->xISC;
}
}
- throw RuntimeException();
+ }
+ throw RuntimeException();
}
OUString SAL_CALL
InputSequenceCheckerImpl::getImplementationName(void) throw( RuntimeException )
{
- return OUString::createFromAscii(serviceName);
+ return OUString::createFromAscii(serviceName);
}
sal_Bool SAL_CALL
InputSequenceCheckerImpl::supportsService(const OUString& rServiceName) throw( RuntimeException )
{
- return !rServiceName.compareToAscii(serviceName);
+ return !rServiceName.compareToAscii(serviceName);
}
Sequence< OUString > SAL_CALL
InputSequenceCheckerImpl::getSupportedServiceNames(void) throw( RuntimeException )
{
- Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii(serviceName);
- return aRet;
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii(serviceName);
+ return aRet;
}
} } } }
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index b85aadea8300..382d58c53ebd 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -62,315 +62,315 @@ OUString SAL_CALL getHebrewNativeNumberString(const OUString& aNumberString, sal
OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int16 number ) throw(RuntimeException)
{
- const sal_Unicode *src = inStr.getStr() + startPos;
- rtl_uString *newStr = rtl_uString_alloc(nCount);
- if (useOffset)
- offset.realloc(nCount);
+ const sal_Unicode *src = inStr.getStr() + startPos;
+ rtl_uString *newStr = rtl_uString_alloc(nCount);
+ if (useOffset)
+ offset.realloc(nCount);
- for (sal_Int32 i = 0; i < nCount; i++)
- {
- sal_Unicode ch = src[i];
- if (isNumber(ch))
- newStr->buffer[i] = NumberChar[number][ ch - NUMBER_ZERO ];
- else if (i+1 < nCount && isNumber(src[i+1])) {
- if (i > 0 && isNumber(src[i-1]) && isSeparator(ch))
- newStr->buffer[i] = SeparatorChar[number] ? SeparatorChar[number] : ch;
- else
- newStr->buffer[i] = isDecimal(ch) ? (DecimalChar[number] ? DecimalChar[number] : ch) :
- isMinus(ch) ? (MinusChar[number] ? MinusChar[number] : ch) : ch;
- }
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ sal_Unicode ch = src[i];
+ if (isNumber(ch))
+ newStr->buffer[i] = NumberChar[number][ ch - NUMBER_ZERO ];
+ else if (i+1 < nCount && isNumber(src[i+1])) {
+ if (i > 0 && isNumber(src[i-1]) && isSeparator(ch))
+ newStr->buffer[i] = SeparatorChar[number] ? SeparatorChar[number] : ch;
else
- newStr->buffer[i] = ch;
- if (useOffset)
- offset[i] = startPos + i;
+ newStr->buffer[i] = isDecimal(ch) ? (DecimalChar[number] ? DecimalChar[number] : ch) :
+ isMinus(ch) ? (MinusChar[number] ? MinusChar[number] : ch) : ch;
}
- return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
+ else
+ newStr->buffer[i] = ch;
+ if (useOffset)
+ offset[i] = startPos + i;
+ }
+ return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
}
sal_Bool SAL_CALL AsciiToNative_numberMaker(const sal_Unicode *str, sal_Int32 begin, sal_Int32 len,
sal_Unicode *dst, sal_Int32& count, sal_Int16 multiChar_index, Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int32 startPos,
const Number *number, const sal_Unicode* numberChar)
{
- sal_Unicode multiChar = (multiChar_index == -1 ? 0 : number->multiplierChar[multiChar_index]);
- if ( len <= number->multiplierExponent[number->exponentCount-1] ) {
- if (number->multiplierExponent[number->exponentCount-1] > 1) {
- sal_Int16 i;
- sal_Bool notZero = false;
- for (i = 0; i < len; i++, begin++) {
- if (notZero || str[begin] != NUMBER_ZERO) {
- dst[count] = numberChar[str[begin] - NUMBER_ZERO];
- if (useOffset)
- offset[count] = begin + startPos;
- count++;
- notZero = sal_True;
- }
- }
- if (notZero && multiChar > 0) {
- dst[count] = multiChar;
- if (useOffset)
- offset[count] = begin + startPos;
- count++;
- }
- return notZero;
- } else if (str[begin] != NUMBER_ZERO) {
- if (!(number->numberFlag & (multiChar_index < 0 ? 0 : NUMBER_OMIT_ONE_CHECK(multiChar_index))) || str[begin] != NUMBER_ONE) {
+ sal_Unicode multiChar = (multiChar_index == -1 ? 0 : number->multiplierChar[multiChar_index]);
+ if ( len <= number->multiplierExponent[number->exponentCount-1] ) {
+ if (number->multiplierExponent[number->exponentCount-1] > 1) {
+ sal_Int16 i;
+ sal_Bool notZero = false;
+ for (i = 0; i < len; i++, begin++) {
+ if (notZero || str[begin] != NUMBER_ZERO) {
dst[count] = numberChar[str[begin] - NUMBER_ZERO];
if (useOffset)
offset[count] = begin + startPos;
count++;
+ notZero = sal_True;
}
- if (multiChar > 0) {
- dst[count] = multiChar;
- if (useOffset)
- offset[count] = begin + startPos;
- count++;
- }
- } else if (!(number->numberFlag & NUMBER_OMIT_ZERO) && count > 0 && dst[count-1] != numberChar[0]) {
- dst[count] = numberChar[0];
+ }
+ if (notZero && multiChar > 0) {
+ dst[count] = multiChar;
if (useOffset)
offset[count] = begin + startPos;
count++;
}
- return str[begin] != NUMBER_ZERO;
- } else {
- sal_Bool printPower = sal_False;
- // sal_Int16 last = 0;
- for (sal_Int16 i = 1; i <= number->exponentCount; i++) {
- sal_Int32 tmp = len - (i == number->exponentCount ? 0 : number->multiplierExponent[i]);
- if (tmp > 0) {
- printPower |= AsciiToNative_numberMaker(str, begin, tmp, dst, count,
+ return notZero;
+ } else if (str[begin] != NUMBER_ZERO) {
+ if (!(number->numberFlag & (multiChar_index < 0 ? 0 : NUMBER_OMIT_ONE_CHECK(multiChar_index))) || str[begin] != NUMBER_ONE) {
+ dst[count] = numberChar[str[begin] - NUMBER_ZERO];
+ if (useOffset)
+ offset[count] = begin + startPos;
+ count++;
+ }
+ if (multiChar > 0) {
+ dst[count] = multiChar;
+ if (useOffset)
+ offset[count] = begin + startPos;
+ count++;
+ }
+ } else if (!(number->numberFlag & NUMBER_OMIT_ZERO) && count > 0 && dst[count-1] != numberChar[0]) {
+ dst[count] = numberChar[0];
+ if (useOffset)
+ offset[count] = begin + startPos;
+ count++;
+ }
+ return str[begin] != NUMBER_ZERO;
+ } else {
+ sal_Bool printPower = sal_False;
+ // sal_Int16 last = 0;
+ for (sal_Int16 i = 1; i <= number->exponentCount; i++) {
+ sal_Int32 tmp = len - (i == number->exponentCount ? 0 : number->multiplierExponent[i]);
+ if (tmp > 0) {
+ printPower |= AsciiToNative_numberMaker(str, begin, tmp, dst, count,
(i == number->exponentCount ? -1 : i), offset, useOffset, startPos, number, numberChar);
- begin += tmp;
- len -= tmp;
- }
+ begin += tmp;
+ len -= tmp;
}
- if (printPower) {
- if (count > 0 && number->multiplierExponent[number->exponentCount-1] == 1 &&
- dst[count-1] == numberChar[0])
- count--;
- if (multiChar > 0) {
- dst[count] = multiChar;
- if (useOffset)
- offset[count] = begin + startPos;
- count++;
- }
+ }
+ if (printPower) {
+ if (count > 0 && number->multiplierExponent[number->exponentCount-1] == 1 &&
+ dst[count-1] == numberChar[0])
+ count--;
+ if (multiChar > 0) {
+ dst[count] = multiChar;
+ if (useOffset)
+ offset[count] = begin + startPos;
+ count++;
}
- return printPower;
}
+ return printPower;
+ }
}
OUString SAL_CALL AsciiToNative( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
Sequence< sal_Int32 >& offset, sal_Bool useOffset, const Number* number ) throw(RuntimeException)
{
- OUString aRet;
+ OUString aRet;
- sal_Int32 strLen = inStr.getLength() - startPos;
- const sal_Unicode *numberChar = NumberChar[number->number];
+ sal_Int32 strLen = inStr.getLength() - startPos;
+ const sal_Unicode *numberChar = NumberChar[number->number];
- if (nCount > strLen)
- nCount = strLen;
+ if (nCount > strLen)
+ nCount = strLen;
- if (nCount > 0)
- {
- const sal_Unicode *str = inStr.getStr() + startPos;
- sal_Unicode *newStr = new sal_Unicode[nCount * 2 + 1];
- sal_Unicode *srcStr = new sal_Unicode[nCount + 1]; // for keeping number without comma
- sal_Int32 i, len = 0, count = 0;
+ if (nCount > 0)
+ {
+ const sal_Unicode *str = inStr.getStr() + startPos;
+ sal_Unicode *newStr = new sal_Unicode[nCount * 2 + 1];
+ sal_Unicode *srcStr = new sal_Unicode[nCount + 1]; // for keeping number without comma
+ sal_Int32 i, len = 0, count = 0;
- if (useOffset)
- offset.realloc( nCount * 2 );
- sal_Bool doDecimal = sal_False;
-
- for (i = 0; i <= nCount; i++)
- {
- if (i < nCount && isNumber(str[i])) {
- if (doDecimal) {
- newStr[count] = numberChar[str[i] - NUMBER_ZERO];
- if (useOffset)
- offset[count] = i + startPos;
- count++;
- }
- else
- srcStr[len++] = str[i];
- } else {
- if (len > 0) {
- if (isSeparator(str[i]) && i < nCount-1 && isNumber(str[i+1]))
- continue; // skip comma inside number string
- sal_Bool notZero = sal_False;
- for (sal_Int32 begin = 0, end = len % number->multiplierExponent[0];
- end <= len; begin = end, end += number->multiplierExponent[0]) {
- if (end == 0) continue;
- sal_Int32 _count = count;
- notZero |= AsciiToNative_numberMaker(srcStr, begin, end - begin, newStr, count,
- end == len ? -1 : 0, offset, useOffset, i - len + startPos, number, numberChar);
- if (count > 0 && number->multiplierExponent[number->exponentCount-1] == 1 &&
- newStr[count-1] == numberChar[0])
- count--;
- if (notZero && _count == count) {
- if (end != len) {
- newStr[count] = number->multiplierChar[0];
- if (useOffset)
- offset[count] = i - len + startPos;
- count++;
- }
+ if (useOffset)
+ offset.realloc( nCount * 2 );
+ sal_Bool doDecimal = sal_False;
+
+ for (i = 0; i <= nCount; i++)
+ {
+ if (i < nCount && isNumber(str[i])) {
+ if (doDecimal) {
+ newStr[count] = numberChar[str[i] - NUMBER_ZERO];
+ if (useOffset)
+ offset[count] = i + startPos;
+ count++;
+ }
+ else
+ srcStr[len++] = str[i];
+ } else {
+ if (len > 0) {
+ if (isSeparator(str[i]) && i < nCount-1 && isNumber(str[i+1]))
+ continue; // skip comma inside number string
+ sal_Bool notZero = sal_False;
+ for (sal_Int32 begin = 0, end = len % number->multiplierExponent[0];
+ end <= len; begin = end, end += number->multiplierExponent[0]) {
+ if (end == 0) continue;
+ sal_Int32 _count = count;
+ notZero |= AsciiToNative_numberMaker(srcStr, begin, end - begin, newStr, count,
+ end == len ? -1 : 0, offset, useOffset, i - len + startPos, number, numberChar);
+ if (count > 0 && number->multiplierExponent[number->exponentCount-1] == 1 &&
+ newStr[count-1] == numberChar[0])
+ count--;
+ if (notZero && _count == count) {
+ if (end != len) {
+ newStr[count] = number->multiplierChar[0];
+ if (useOffset)
+ offset[count] = i - len + startPos;
+ count++;
}
}
- if (! notZero && ! (number->numberFlag & NUMBER_OMIT_ONLY_ZERO)) {
- newStr[count] = numberChar[0];
- if (useOffset)
- offset[count] = i - len + startPos;
- count++;
- }
- len = 0;
}
- if (i < nCount) {
- if ((doDecimal = (!doDecimal && isDecimal(str[i]) && i < nCount-1 && isNumber(str[i+1]))) != sal_False)
- newStr[count] = (DecimalChar[number->number] ? DecimalChar[number->number] : str[i]);
- else if (isMinus(str[i]) && i < nCount-1 && isNumber(str[i+1]))
- newStr[count] = (MinusChar[number->number] ? MinusChar[number->number] : str[i]);
- else if (isSeparator(str[i]) && i < nCount-1 && isNumber(str[i+1]))
- newStr[count] = (SeparatorChar[number->number] ? SeparatorChar[number->number] : str[i]);
- else
- newStr[count] = str[i];
+ if (! notZero && ! (number->numberFlag & NUMBER_OMIT_ONLY_ZERO)) {
+ newStr[count] = numberChar[0];
if (useOffset)
- offset[count] = i + startPos;
+ offset[count] = i - len + startPos;
count++;
}
+ len = 0;
+ }
+ if (i < nCount) {
+ if ((doDecimal = (!doDecimal && isDecimal(str[i]) && i < nCount-1 && isNumber(str[i+1]))) != sal_False)
+ newStr[count] = (DecimalChar[number->number] ? DecimalChar[number->number] : str[i]);
+ else if (isMinus(str[i]) && i < nCount-1 && isNumber(str[i+1]))
+ newStr[count] = (MinusChar[number->number] ? MinusChar[number->number] : str[i]);
+ else if (isSeparator(str[i]) && i < nCount-1 && isNumber(str[i+1]))
+ newStr[count] = (SeparatorChar[number->number] ? SeparatorChar[number->number] : str[i]);
+ else
+ newStr[count] = str[i];
+ if (useOffset)
+ offset[count] = i + startPos;
+ count++;
}
}
+ }
- delete[] srcStr;
+ delete[] srcStr;
- if (useOffset)
- offset.realloc(count);
- aRet = OUString(newStr, count);
- delete[] newStr;
- }
- return aRet;
+ if (useOffset)
+ offset.realloc(count);
+ aRet = OUString(newStr, count);
+ delete[] newStr;
+ }
+ return aRet;
}
static void SAL_CALL NativeToAscii_numberMaker(sal_Int16 max, sal_Int16 prev, const sal_Unicode *str,
sal_Int32& i, sal_Int32 nCount, sal_Unicode *dst, sal_Int32& count, Sequence< sal_Int32 >& offset, sal_Bool useOffset,
OUString& numberChar, OUString& multiplierChar)
{
- sal_Int16 curr = 0, num = 0, end = 0, shift = 0;
- while (++i < nCount) {
- if ((curr = sal::static_int_cast<sal_Int16>( numberChar.indexOf(str[i]) )) >= 0) {
- if (num > 0)
- break;
- num = curr % 10;
- } else if ((curr = sal::static_int_cast<sal_Int16>( multiplierChar.indexOf(str[i]) )) >= 0) {
- curr = MultiplierExponent_7_CJK[curr % ExponentCount_7_CJK];
- if (prev > curr && num == 0) num = 1; // One may be omitted in informal format
- shift = end = 0;
- if (curr >= max)
- max = curr;
- else if (curr > prev)
- shift = max - curr;
- else
- end = curr;
- while (end++ < prev) {
- dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
+ sal_Int16 curr = 0, num = 0, end = 0, shift = 0;
+ while (++i < nCount) {
+ if ((curr = sal::static_int_cast<sal_Int16>( numberChar.indexOf(str[i]) )) >= 0) {
+ if (num > 0)
+ break;
+ num = curr % 10;
+ } else if ((curr = sal::static_int_cast<sal_Int16>( multiplierChar.indexOf(str[i]) )) >= 0) {
+ curr = MultiplierExponent_7_CJK[curr % ExponentCount_7_CJK];
+ if (prev > curr && num == 0) num = 1; // One may be omitted in informal format
+ shift = end = 0;
+ if (curr >= max)
+ max = curr;
+ else if (curr > prev)
+ shift = max - curr;
+ else
+ end = curr;
+ while (end++ < prev) {
+ dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
+ if (useOffset)
+ offset[count] = i;
+ count++;
+ }
+ if (shift) {
+ count -= max;
+ for (sal_Int16 j = 0; j < shift; j++, count++) {
+ dst[count] = dst[count + curr];
if (useOffset)
- offset[count] = i;
- count++;
- }
- if (shift) {
- count -= max;
- for (sal_Int16 j = 0; j < shift; j++, count++) {
- dst[count] = dst[count + curr];
- if (useOffset)
- offset[count] = offset[count + curr];
- }
- max = curr;
+ offset[count] = offset[count + curr];
}
- NativeToAscii_numberMaker(max, curr, str, i, nCount, dst,
- count, offset, useOffset, numberChar, multiplierChar);
- return;
- } else
- break;
- }
- while (end++ < prev) {
- dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
- if (useOffset)
- offset[count] = i - 1;
- count++;
- }
+ max = curr;
+ }
+ NativeToAscii_numberMaker(max, curr, str, i, nCount, dst,
+ count, offset, useOffset, numberChar, multiplierChar);
+ return;
+ } else
+ break;
+ }
+ while (end++ < prev) {
+ dst[count] = NUMBER_ZERO + (end == prev ? num : 0);
+ if (useOffset)
+ offset[count] = i - 1;
+ count++;
+ }
}
static OUString SAL_CALL NativeToAscii(const OUString& inStr,
sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset, sal_Bool useOffset ) throw(RuntimeException)
{
- OUString aRet;
+ OUString aRet;
- sal_Int32 strLen = inStr.getLength() - startPos;
+ sal_Int32 strLen = inStr.getLength() - startPos;
- if (nCount > strLen)
- nCount = strLen;
+ if (nCount > strLen)
+ nCount = strLen;
- if (nCount > 0) {
- const sal_Unicode *str = inStr.getStr() + startPos;
- sal_Unicode *newStr = new sal_Unicode[nCount * MultiplierExponent_7_CJK[0] + 2];
- if (useOffset)
- offset.realloc( nCount * MultiplierExponent_7_CJK[0] + 1 );
- sal_Int32 count = 0, index;
- sal_Int32 i;
-
- OUString numberChar, multiplierChar, decimalChar, minusChar, separatorChar;
- numberChar = OUString((sal_Unicode*)NumberChar, 10*NumberChar_Count);
- multiplierChar = OUString((sal_Unicode*) MultiplierChar_7_CJK, ExponentCount_7_CJK*Multiplier_Count);
- decimalChar = OUString(DecimalChar, NumberChar_Count);
- minusChar = OUString(MinusChar, NumberChar_Count);
- separatorChar = OUString(SeparatorChar, NumberChar_Count);
-
- for ( i = 0; i < nCount; i++) {
- if ((index = multiplierChar.indexOf(str[i])) >= 0) {
- if (count == 0 || !isNumber(newStr[count-1])) { // add 1 in front of multiplier
- newStr[count] = NUMBER_ONE;
- if (useOffset)
- offset[count] = i;
- count++;
- }
- index = MultiplierExponent_7_CJK[index % ExponentCount_7_CJK];
- NativeToAscii_numberMaker(
- sal::static_int_cast<sal_Int16>( index ), sal::static_int_cast<sal_Int16>( index ),
- str, i, nCount, newStr, count, offset, useOffset,
- numberChar, multiplierChar);
- } else {
- if ((index = numberChar.indexOf(str[i])) >= 0)
- newStr[count] = sal::static_int_cast<sal_Unicode>( (index % 10) + NUMBER_ZERO );
- else if ((index = separatorChar.indexOf(str[i])) >= 0 &&
- (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
- multiplierChar.indexOf(str[i+1]) >= 0)))
- newStr[count] = SeparatorChar[NumberChar_HalfWidth];
- else if ((index = decimalChar.indexOf(str[i])) >= 0 &&
- (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
- multiplierChar.indexOf(str[i+1]) >= 0)))
- // Only when decimal point is followed by numbers,
- // it will be convert to ASCII decimal point
- newStr[count] = DecimalChar[NumberChar_HalfWidth];
- else if ((index = minusChar.indexOf(str[i])) >= 0 &&
- (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
- multiplierChar.indexOf(str[i+1]) >= 0)))
- // Only when minus is followed by numbers,
- // it will be convert to ASCII minus sign
- newStr[count] = MinusChar[NumberChar_HalfWidth];
- else
- newStr[count] = str[i];
+ if (nCount > 0) {
+ const sal_Unicode *str = inStr.getStr() + startPos;
+ sal_Unicode *newStr = new sal_Unicode[nCount * MultiplierExponent_7_CJK[0] + 2];
+ if (useOffset)
+ offset.realloc( nCount * MultiplierExponent_7_CJK[0] + 1 );
+ sal_Int32 count = 0, index;
+ sal_Int32 i;
+
+ OUString numberChar, multiplierChar, decimalChar, minusChar, separatorChar;
+ numberChar = OUString((sal_Unicode*)NumberChar, 10*NumberChar_Count);
+ multiplierChar = OUString((sal_Unicode*) MultiplierChar_7_CJK, ExponentCount_7_CJK*Multiplier_Count);
+ decimalChar = OUString(DecimalChar, NumberChar_Count);
+ minusChar = OUString(MinusChar, NumberChar_Count);
+ separatorChar = OUString(SeparatorChar, NumberChar_Count);
+
+ for ( i = 0; i < nCount; i++) {
+ if ((index = multiplierChar.indexOf(str[i])) >= 0) {
+ if (count == 0 || !isNumber(newStr[count-1])) { // add 1 in front of multiplier
+ newStr[count] = NUMBER_ONE;
if (useOffset)
offset[count] = i;
count++;
}
+ index = MultiplierExponent_7_CJK[index % ExponentCount_7_CJK];
+ NativeToAscii_numberMaker(
+ sal::static_int_cast<sal_Int16>( index ), sal::static_int_cast<sal_Int16>( index ),
+ str, i, nCount, newStr, count, offset, useOffset,
+ numberChar, multiplierChar);
+ } else {
+ if ((index = numberChar.indexOf(str[i])) >= 0)
+ newStr[count] = sal::static_int_cast<sal_Unicode>( (index % 10) + NUMBER_ZERO );
+ else if ((index = separatorChar.indexOf(str[i])) >= 0 &&
+ (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
+ multiplierChar.indexOf(str[i+1]) >= 0)))
+ newStr[count] = SeparatorChar[NumberChar_HalfWidth];
+ else if ((index = decimalChar.indexOf(str[i])) >= 0 &&
+ (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
+ multiplierChar.indexOf(str[i+1]) >= 0)))
+ // Only when decimal point is followed by numbers,
+ // it will be convert to ASCII decimal point
+ newStr[count] = DecimalChar[NumberChar_HalfWidth];
+ else if ((index = minusChar.indexOf(str[i])) >= 0 &&
+ (i < nCount-1 && (numberChar.indexOf(str[i+1]) >= 0 ||
+ multiplierChar.indexOf(str[i+1]) >= 0)))
+ // Only when minus is followed by numbers,
+ // it will be convert to ASCII minus sign
+ newStr[count] = MinusChar[NumberChar_HalfWidth];
+ else
+ newStr[count] = str[i];
+ if (useOffset)
+ offset[count] = i;
+ count++;
}
+ }
- if (useOffset) {
- offset.realloc(count);
- for (i = 0; i < count; i++)
- offset[i] += startPos;
- }
- aRet = OUString(newStr, count);
- delete[] newStr;
+ if (useOffset) {
+ offset.realloc(count);
+ for (i = 0; i < count; i++)
+ offset[i] += startPos;
}
- return aRet;
+ aRet = OUString(newStr, count);
+ delete[] newStr;
+ }
+ return aRet;
}
static const Number natnum4[4] = {
@@ -523,79 +523,79 @@ static sal_Int16 SAL_CALL getLanguageNumber( const Locale& rLocale)
OUString SAL_CALL NativeNumberSupplier::getNativeNumberString(const OUString& aNumberString, const Locale& rLocale,
sal_Int16 nNativeNumberMode, Sequence< sal_Int32 >& offset) throw (RuntimeException)
{
- const Number *number = 0;
- sal_Int16 num = -1;
-
- if (isValidNatNum(rLocale, nNativeNumberMode)) {
- sal_Int16 langnum = getLanguageNumber(rLocale);
- switch (nNativeNumberMode) {
- case NativeNumberMode::NATNUM0: // Ascii
- return NativeToAscii(aNumberString, 0, aNumberString.getLength(), offset, useOffset);
- case NativeNumberMode::NATNUM1: // Char, Lower
- num = natnum1[langnum];
+ const Number *number = 0;
+ sal_Int16 num = -1;
+
+ if (isValidNatNum(rLocale, nNativeNumberMode)) {
+ sal_Int16 langnum = getLanguageNumber(rLocale);
+ switch (nNativeNumberMode) {
+ case NativeNumberMode::NATNUM0: // Ascii
+ return NativeToAscii(aNumberString, 0, aNumberString.getLength(), offset, useOffset);
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ num = natnum1[langnum];
break;
- case NativeNumberMode::NATNUM2: // Char, Upper
- num = natnum2[langnum];
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ num = natnum2[langnum];
break;
- case NativeNumberMode::NATNUM3: // Char, FullWidth
- num = NumberChar_FullWidth;
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ num = NumberChar_FullWidth;
break;
- case NativeNumberMode::NATNUM4: // Text, Lower, Long
- number = &natnum4[langnum];
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ number = &natnum4[langnum];
break;
- case NativeNumberMode::NATNUM5: // Text, Upper, Long
- number = &natnum5[langnum];
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ number = &natnum5[langnum];
break;
- case NativeNumberMode::NATNUM6: // Text, FullWidth
- number = &natnum6[langnum];
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ number = &natnum6[langnum];
break;
- case NativeNumberMode::NATNUM7: // Text. Lower, Short
- number = &natnum7[langnum];
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ number = &natnum7[langnum];
break;
- case NativeNumberMode::NATNUM8: // Text, Upper, Short
- number = &natnum8[langnum];
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ number = &natnum8[langnum];
break;
- case NativeNumberMode::NATNUM9: // Char, Hangul
- num = NumberChar_Hangul_ko;
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ num = NumberChar_Hangul_ko;
break;
- case NativeNumberMode::NATNUM10: // Text, Hangul, Long
- number = &natnum10;
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ number = &natnum10;
break;
- case NativeNumberMode::NATNUM11: // Text, Hangul, Short
- number = &natnum11;
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ number = &natnum11;
break;
- default:
+ default:
break;
- }
}
+ }
- if (number || num >= 0) {
- if (!aLocale.Language.equals(rLocale.Language) ||
- !aLocale.Country.equals(rLocale.Country) ||
- !aLocale.Variant.equals(rLocale.Variant)) {
- LocaleDataItem item = LocaleDataImpl().getLocaleItem( rLocale );
- aLocale = rLocale;
- DecimalChar[NumberChar_HalfWidth]=item.decimalSeparator.toChar();
- if (DecimalChar[NumberChar_HalfWidth] > 0x7E || DecimalChar[NumberChar_HalfWidth] < 0x21)
- DecimalChar[NumberChar_FullWidth]=0xFF0E;
- else
- DecimalChar[NumberChar_FullWidth]=DecimalChar[NumberChar_HalfWidth]+0xFEE0;
- SeparatorChar[NumberChar_HalfWidth]=item.thousandSeparator.toChar();
- if (SeparatorChar[NumberChar_HalfWidth] > 0x7E || SeparatorChar[NumberChar_HalfWidth] < 0x21)
- SeparatorChar[NumberChar_FullWidth]=0xFF0C;
- else
- SeparatorChar[NumberChar_FullWidth]=SeparatorChar[NumberChar_HalfWidth]+0xFEE0;
- }
- if (number)
- return AsciiToNative( aNumberString, 0, aNumberString.getLength(), offset, useOffset, number );
- else if (num == NumberChar_he)
- return getHebrewNativeNumberString(aNumberString,
- nNativeNumberMode == NativeNumberMode::NATNUM2);
+ if (number || num >= 0) {
+ if (!aLocale.Language.equals(rLocale.Language) ||
+ !aLocale.Country.equals(rLocale.Country) ||
+ !aLocale.Variant.equals(rLocale.Variant)) {
+ LocaleDataItem item = LocaleDataImpl().getLocaleItem( rLocale );
+ aLocale = rLocale;
+ DecimalChar[NumberChar_HalfWidth]=item.decimalSeparator.toChar();
+ if (DecimalChar[NumberChar_HalfWidth] > 0x7E || DecimalChar[NumberChar_HalfWidth] < 0x21)
+ DecimalChar[NumberChar_FullWidth]=0xFF0E;
+ else
+ DecimalChar[NumberChar_FullWidth]=DecimalChar[NumberChar_HalfWidth]+0xFEE0;
+ SeparatorChar[NumberChar_HalfWidth]=item.thousandSeparator.toChar();
+ if (SeparatorChar[NumberChar_HalfWidth] > 0x7E || SeparatorChar[NumberChar_HalfWidth] < 0x21)
+ SeparatorChar[NumberChar_FullWidth]=0xFF0C;
else
- return AsciiToNativeChar(aNumberString, 0, aNumberString.getLength(), offset, useOffset, num);
+ SeparatorChar[NumberChar_FullWidth]=SeparatorChar[NumberChar_HalfWidth]+0xFEE0;
}
+ if (number)
+ return AsciiToNative( aNumberString, 0, aNumberString.getLength(), offset, useOffset, number );
+ else if (num == NumberChar_he)
+ return getHebrewNativeNumberString(aNumberString,
+ nNativeNumberMode == NativeNumberMode::NATNUM2);
else
- return aNumberString;
+ return AsciiToNativeChar(aNumberString, 0, aNumberString.getLength(), offset, useOffset, num);
+ }
+ else
+ return aNumberString;
}
OUString SAL_CALL NativeNumberSupplier::getNativeNumberString(const OUString& aNumberString, const Locale& rLocale,
@@ -607,181 +607,181 @@ OUString SAL_CALL NativeNumberSupplier::getNativeNumberString(const OUString& aN
sal_Unicode SAL_CALL NativeNumberSupplier::getNativeNumberChar( const sal_Unicode inChar, const Locale& rLocale, sal_Int16 nNativeNumberMode ) throw(com::sun::star::uno::RuntimeException)
{
- if (nNativeNumberMode == NativeNumberMode::NATNUM0) { // Ascii
- for (sal_Int16 i = 0; i < NumberChar_Count; i++)
- for (sal_Int16 j = 0; j < 10; j++)
- if (inChar == NumberChar[i][j])
- return j;
- return inChar;
- }
- else if (isNumber(inChar) && isValidNatNum(rLocale, nNativeNumberMode)) {
- sal_Int16 langnum = getLanguageNumber(rLocale);
- switch (nNativeNumberMode) {
- case NativeNumberMode::NATNUM1: // Char, Lower
- case NativeNumberMode::NATNUM4: // Text, Lower, Long
- case NativeNumberMode::NATNUM7: // Text. Lower, Short
- return NumberChar[natnum1[langnum]][inChar - NUMBER_ZERO];
- case NativeNumberMode::NATNUM2: // Char, Upper
- case NativeNumberMode::NATNUM5: // Text, Upper, Long
- case NativeNumberMode::NATNUM8: // Text, Upper, Short
- return NumberChar[natnum2[langnum]][inChar - NUMBER_ZERO];
- case NativeNumberMode::NATNUM3: // Char, FullWidth
- case NativeNumberMode::NATNUM6: // Text, FullWidth
- return NumberChar[NumberChar_FullWidth][inChar - NUMBER_ZERO];
- case NativeNumberMode::NATNUM9: // Char, Hangul
- case NativeNumberMode::NATNUM10: // Text, Hangul, Long
- case NativeNumberMode::NATNUM11: // Text, Hangul, Short
- return NumberChar[NumberChar_Hangul_ko][inChar - NUMBER_ZERO];
- default:
+ if (nNativeNumberMode == NativeNumberMode::NATNUM0) { // Ascii
+ for (sal_Int16 i = 0; i < NumberChar_Count; i++)
+ for (sal_Int16 j = 0; j < 10; j++)
+ if (inChar == NumberChar[i][j])
+ return j;
+ return inChar;
+ }
+ else if (isNumber(inChar) && isValidNatNum(rLocale, nNativeNumberMode)) {
+ sal_Int16 langnum = getLanguageNumber(rLocale);
+ switch (nNativeNumberMode) {
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ return NumberChar[natnum1[langnum]][inChar - NUMBER_ZERO];
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ return NumberChar[natnum2[langnum]][inChar - NUMBER_ZERO];
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ return NumberChar[NumberChar_FullWidth][inChar - NUMBER_ZERO];
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ return NumberChar[NumberChar_Hangul_ko][inChar - NUMBER_ZERO];
+ default:
break;
- }
}
- return inChar;
+ }
+ return inChar;
}
sal_Bool SAL_CALL NativeNumberSupplier::isValidNatNum( const Locale& rLocale, sal_Int16 nNativeNumberMode ) throw (RuntimeException)
{
- sal_Int16 langnum = getLanguageNumber(rLocale);
-
- switch (nNativeNumberMode) {
- case NativeNumberMode::NATNUM0: // Ascii
- case NativeNumberMode::NATNUM3: // Char, FullWidth
+ sal_Int16 langnum = getLanguageNumber(rLocale);
+
+ switch (nNativeNumberMode) {
+ case NativeNumberMode::NATNUM0: // Ascii
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ return sal_True;
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ return (langnum >= 0);
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ if (langnum == 4) // Hebrew numbering
return sal_True;
- case NativeNumberMode::NATNUM1: // Char, Lower
- return (langnum >= 0);
- case NativeNumberMode::NATNUM2: // Char, Upper
- if (langnum == 4) // Hebrew numbering
- return sal_True;
- case NativeNumberMode::NATNUM4: // Text, Lower, Long
- case NativeNumberMode::NATNUM5: // Text, Upper, Long
- case NativeNumberMode::NATNUM6: // Text, FullWidth
- case NativeNumberMode::NATNUM7: // Text. Lower, Short
- case NativeNumberMode::NATNUM8: // Text, Upper, Short
- return (langnum >= 0 && langnum < 4); // CJK numbering
- case NativeNumberMode::NATNUM9: // Char, Hangul
- case NativeNumberMode::NATNUM10: // Text, Hangul, Long
- case NativeNumberMode::NATNUM11: // Text, Hangul, Short
- return (langnum == 3); // Korean numbering
- }
- return sal_False;
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ return (langnum >= 0 && langnum < 4); // CJK numbering
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ return (langnum == 3); // Korean numbering
+ }
+ return sal_False;
}
NativeNumberXmlAttributes SAL_CALL NativeNumberSupplier::convertToXmlAttributes( const Locale& rLocale, sal_Int16 nNativeNumberMode ) throw (RuntimeException)
{
- static const sal_Int16 attShort = 0;
- static const sal_Int16 attMedium = 1;
- static const sal_Int16 attLong = 2;
- static const sal_Char *attType[] = { "short", "medium", "long" };
-
- sal_Int16 number = NumberChar_HalfWidth, type = attShort;
-
- if (isValidNatNum(rLocale, nNativeNumberMode)) {
- sal_Int16 langnum = getLanguageNumber(rLocale);
- switch (nNativeNumberMode) {
- case NativeNumberMode::NATNUM0: // Ascii
- number = NumberChar_HalfWidth;
- type = attShort;
+ static const sal_Int16 attShort = 0;
+ static const sal_Int16 attMedium = 1;
+ static const sal_Int16 attLong = 2;
+ static const sal_Char *attType[] = { "short", "medium", "long" };
+
+ sal_Int16 number = NumberChar_HalfWidth, type = attShort;
+
+ if (isValidNatNum(rLocale, nNativeNumberMode)) {
+ sal_Int16 langnum = getLanguageNumber(rLocale);
+ switch (nNativeNumberMode) {
+ case NativeNumberMode::NATNUM0: // Ascii
+ number = NumberChar_HalfWidth;
+ type = attShort;
break;
- case NativeNumberMode::NATNUM1: // Char, Lower
- number = natnum1[langnum];
- type = attShort;
+ case NativeNumberMode::NATNUM1: // Char, Lower
+ number = natnum1[langnum];
+ type = attShort;
break;
- case NativeNumberMode::NATNUM2: // Char, Upper
- number = natnum2[langnum];
- type = number == NumberChar_he ? attMedium : attShort;
+ case NativeNumberMode::NATNUM2: // Char, Upper
+ number = natnum2[langnum];
+ type = number == NumberChar_he ? attMedium : attShort;
break;
- case NativeNumberMode::NATNUM3: // Char, FullWidth
- number = NumberChar_FullWidth;
- type = attShort;
+ case NativeNumberMode::NATNUM3: // Char, FullWidth
+ number = NumberChar_FullWidth;
+ type = attShort;
break;
- case NativeNumberMode::NATNUM4: // Text, Lower, Long
- number = natnum1[langnum];
- type = attLong;
+ case NativeNumberMode::NATNUM4: // Text, Lower, Long
+ number = natnum1[langnum];
+ type = attLong;
break;
- case NativeNumberMode::NATNUM5: // Text, Upper, Long
- number = natnum2[langnum];
- type = attLong;
+ case NativeNumberMode::NATNUM5: // Text, Upper, Long
+ number = natnum2[langnum];
+ type = attLong;
break;
- case NativeNumberMode::NATNUM6: // Text, FullWidth
- number = NumberChar_FullWidth;
- type = attLong;
+ case NativeNumberMode::NATNUM6: // Text, FullWidth
+ number = NumberChar_FullWidth;
+ type = attLong;
break;
- case NativeNumberMode::NATNUM7: // Text. Lower, Short
- number = natnum1[langnum];
- type = attMedium;
+ case NativeNumberMode::NATNUM7: // Text. Lower, Short
+ number = natnum1[langnum];
+ type = attMedium;
break;
- case NativeNumberMode::NATNUM8: // Text, Upper, Short
- number = natnum2[langnum];
- type = attMedium;
+ case NativeNumberMode::NATNUM8: // Text, Upper, Short
+ number = natnum2[langnum];
+ type = attMedium;
break;
- case NativeNumberMode::NATNUM9: // Char, Hangul
- number = NumberChar_Hangul_ko;
- type = attShort;
+ case NativeNumberMode::NATNUM9: // Char, Hangul
+ number = NumberChar_Hangul_ko;
+ type = attShort;
break;
- case NativeNumberMode::NATNUM10: // Text, Hangul, Long
- number = NumberChar_Hangul_ko;
- type = attLong;
+ case NativeNumberMode::NATNUM10: // Text, Hangul, Long
+ number = NumberChar_Hangul_ko;
+ type = attLong;
break;
- case NativeNumberMode::NATNUM11: // Text, Hangul, Short
- number = NumberChar_Hangul_ko;
- type = attMedium;
+ case NativeNumberMode::NATNUM11: // Text, Hangul, Short
+ number = NumberChar_Hangul_ko;
+ type = attMedium;
break;
- default:
+ default:
break;
- }
}
- return NativeNumberXmlAttributes(rLocale, OUString(&NumberChar[number][1], 1),
- OUString::createFromAscii(attType[type]));
+ }
+ return NativeNumberXmlAttributes(rLocale, OUString(&NumberChar[number][1], 1),
+ OUString::createFromAscii(attType[type]));
}
static sal_Bool natNumIn(sal_Int16 num, const sal_Int16 natnum[], sal_Int16 len)
{
- for (sal_Int16 i = 0; i < len; i++)
- if (natnum[i] == num)
- return sal_True;
- return sal_False;
+ for (sal_Int16 i = 0; i < len; i++)
+ if (natnum[i] == num)
+ return sal_True;
+ return sal_False;
}
sal_Int16 SAL_CALL NativeNumberSupplier::convertFromXmlAttributes( const NativeNumberXmlAttributes& aAttr ) throw (RuntimeException)
{
- sal_Unicode numberChar[NumberChar_Count];
- for (sal_Int16 i = 0; i < NumberChar_Count; i++)
- numberChar[i] = NumberChar[i][1];
- OUString number(numberChar, NumberChar_Count);
-
- sal_Int16 num = sal::static_int_cast<sal_Int16>( number.indexOf(aAttr.Format) );
-
- if ( aAttr.Style == "short" ) {
- if (num == NumberChar_FullWidth)
- return NativeNumberMode::NATNUM3;
- else if (num == NumberChar_Hangul_ko)
- return NativeNumberMode::NATNUM9;
- else if (natNumIn(num, natnum1, sizeof_natnum1))
- return NativeNumberMode::NATNUM1;
- else if (natNumIn(num, natnum2, sizeof_natnum2))
- return NativeNumberMode::NATNUM2;
- } else if ( aAttr.Style == "medium" ) {
- if (num == NumberChar_Hangul_ko)
- return NativeNumberMode::NATNUM11;
- else if (num == NumberChar_he)
- return NativeNumberMode::NATNUM2;
- else if (natNumIn(num, natnum1, sizeof_natnum1))
- return NativeNumberMode::NATNUM7;
- else if (natNumIn(num, natnum2, sizeof_natnum2))
- return NativeNumberMode::NATNUM8;
- } else if ( aAttr.Style == "long" ) {
- if (num == NumberChar_FullWidth)
- return NativeNumberMode::NATNUM6;
- else if (num == NumberChar_Hangul_ko)
- return NativeNumberMode::NATNUM10;
- else if (natNumIn(num, natnum1, sizeof_natnum1))
- return NativeNumberMode::NATNUM4;
- else if (natNumIn(num, natnum2, sizeof_natnum2))
- return NativeNumberMode::NATNUM5;
- } else {
- throw RuntimeException();
- }
- return NativeNumberMode::NATNUM0;
+ sal_Unicode numberChar[NumberChar_Count];
+ for (sal_Int16 i = 0; i < NumberChar_Count; i++)
+ numberChar[i] = NumberChar[i][1];
+ OUString number(numberChar, NumberChar_Count);
+
+ sal_Int16 num = sal::static_int_cast<sal_Int16>( number.indexOf(aAttr.Format) );
+
+ if ( aAttr.Style == "short" ) {
+ if (num == NumberChar_FullWidth)
+ return NativeNumberMode::NATNUM3;
+ else if (num == NumberChar_Hangul_ko)
+ return NativeNumberMode::NATNUM9;
+ else if (natNumIn(num, natnum1, sizeof_natnum1))
+ return NativeNumberMode::NATNUM1;
+ else if (natNumIn(num, natnum2, sizeof_natnum2))
+ return NativeNumberMode::NATNUM2;
+ } else if ( aAttr.Style == "medium" ) {
+ if (num == NumberChar_Hangul_ko)
+ return NativeNumberMode::NATNUM11;
+ else if (num == NumberChar_he)
+ return NativeNumberMode::NATNUM2;
+ else if (natNumIn(num, natnum1, sizeof_natnum1))
+ return NativeNumberMode::NATNUM7;
+ else if (natNumIn(num, natnum2, sizeof_natnum2))
+ return NativeNumberMode::NATNUM8;
+ } else if ( aAttr.Style == "long" ) {
+ if (num == NumberChar_FullWidth)
+ return NativeNumberMode::NATNUM6;
+ else if (num == NumberChar_Hangul_ko)
+ return NativeNumberMode::NATNUM10;
+ else if (natNumIn(num, natnum1, sizeof_natnum1))
+ return NativeNumberMode::NATNUM4;
+ else if (natNumIn(num, natnum2, sizeof_natnum2))
+ return NativeNumberMode::NATNUM5;
+ } else {
+ throw RuntimeException();
+ }
+ return NativeNumberMode::NATNUM0;
}
diff --git a/i18npool/source/transliteration/hiraganaToKatakana.cxx b/i18npool/source/transliteration/hiraganaToKatakana.cxx
index 119dfa3ee1a8..f9afa35fb412 100644
--- a/i18npool/source/transliteration/hiraganaToKatakana.cxx
+++ b/i18npool/source/transliteration/hiraganaToKatakana.cxx
@@ -32,19 +32,19 @@ namespace com { namespace sun { namespace star { namespace i18n {
// see http://charts.unicode.org/Web/U3040.html Hiragana (U+3040..U+309F)
// see http://charts.unicode.org/Web/U30A0.html Katakana (U+30A0..U+30FF)
static sal_Unicode toKatakana (const sal_Unicode c) {
- if ( (0x3041 <= c && c <= 0x3096) || (0x309d <= c && c <= 0x309f) ) { // 3040 - 309F HIRAGANA LETTER
- // shift code point by 0x0060
- return c + (0x30a0 - 0x3040);
- }
- return c;
+ if ( (0x3041 <= c && c <= 0x3096) || (0x309d <= c && c <= 0x309f) ) { // 3040 - 309F HIRAGANA LETTER
+ // shift code point by 0x0060
+ return c + (0x30a0 - 0x3040);
+ }
+ return c;
}
hiraganaToKatakana::hiraganaToKatakana()
{
- func = toKatakana;
- table = 0;
- transliterationName = "hiraganaToKatakana";
- implementationName = "com.sun.star.i18n.Transliteration.HIRAGANA_KATAKANA";
+ func = toKatakana;
+ table = 0;
+ transliterationName = "hiraganaToKatakana";
+ implementationName = "com.sun.star.i18n.Transliteration.HIRAGANA_KATAKANA";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreBaFa_ja_JP.cxx b/i18npool/source/transliteration/ignoreBaFa_ja_JP.cxx
index 9b47ff41b3ae..076df1b61827 100644
--- a/i18npool/source/transliteration/ignoreBaFa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreBaFa_ja_JP.cxx
@@ -29,20 +29,20 @@ using namespace com::sun::star::uno;
namespace com { namespace sun { namespace star { namespace i18n {
static const Mapping BaFa[] = {
- { 0x30F4, 0x30A1, 0x30D0, sal_True },
- { 0x3094, 0x3041, 0x3070, sal_True },
- { 0x30D5, 0x30A1, 0x30CF, sal_True },
- { 0x3075, 0x3041, 0x306F, sal_True },
- { 0, 0, 0, sal_True }
+ { 0x30F4, 0x30A1, 0x30D0, sal_True },
+ { 0x3094, 0x3041, 0x3070, sal_True },
+ { 0x30D5, 0x30A1, 0x30CF, sal_True },
+ { 0x3075, 0x3041, 0x306F, sal_True },
+ { 0, 0, 0, sal_True }
};
ignoreBaFa_ja_JP::ignoreBaFa_ja_JP()
{
- func = (TransFunc) 0;
- table = 0;
- map = BaFa;
- transliterationName = "ignoreBaFa_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreBaFa_ja_JP";
+ func = (TransFunc) 0;
+ table = 0;
+ map = BaFa;
+ transliterationName = "ignoreBaFa_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreBaFa_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreHyuByu_ja_JP.cxx b/i18npool/source/transliteration/ignoreHyuByu_ja_JP.cxx
index 9a8d747dace7..6af92f48efd2 100644
--- a/i18npool/source/transliteration/ignoreHyuByu_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreHyuByu_ja_JP.cxx
@@ -30,20 +30,20 @@ using namespace com::sun::star::lang;
namespace com { namespace sun { namespace star { namespace i18n {
static const Mapping HyuByu[] = {
- { 0x30D5, 0x30E5, 0x30D2, sal_False },
- { 0x3075, 0x3085, 0x3072, sal_False },
- { 0x30F4, 0x30E5, 0x30D3, sal_False },
- { 0x3094, 0x3085, 0x3073, sal_False },
- { 0, 0, 0, sal_False }
+ { 0x30D5, 0x30E5, 0x30D2, sal_False },
+ { 0x3075, 0x3085, 0x3072, sal_False },
+ { 0x30F4, 0x30E5, 0x30D3, sal_False },
+ { 0x3094, 0x3085, 0x3073, sal_False },
+ { 0, 0, 0, sal_False }
};
ignoreHyuByu_ja_JP::ignoreHyuByu_ja_JP()
{
- func = (TransFunc) 0;
- table = 0;
- map = HyuByu;
- transliterationName = "ignoreHyuByu_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreHyuByu_ja_JP";
+ func = (TransFunc) 0;
+ table = 0;
+ map = HyuByu;
+ transliterationName = "ignoreHyuByu_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreHyuByu_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreMiddleDot_ja_JP.cxx b/i18npool/source/transliteration/ignoreMiddleDot_ja_JP.cxx
index 2071a335a3d4..a9b5e9df9ae8 100644
--- a/i18npool/source/transliteration/ignoreMiddleDot_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreMiddleDot_ja_JP.cxx
@@ -40,11 +40,11 @@ ignoreMiddleDot_ja_JP_translator (const sal_Unicode c)
ignoreMiddleDot_ja_JP::ignoreMiddleDot_ja_JP()
{
- func = ignoreMiddleDot_ja_JP_translator;
- table = 0;
- map = 0;
- transliterationName = "ignoreMiddleDot_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreMiddleDot_ja_JP";
+ func = ignoreMiddleDot_ja_JP_translator;
+ table = 0;
+ map = 0;
+ transliterationName = "ignoreMiddleDot_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreMiddleDot_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreMinusSign_ja_JP.cxx b/i18npool/source/transliteration/ignoreMinusSign_ja_JP.cxx
index d3af113641de..4a3d04943166 100644
--- a/i18npool/source/transliteration/ignoreMinusSign_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreMinusSign_ja_JP.cxx
@@ -47,11 +47,11 @@ ignoreMinusSign_ja_JP_translator (const sal_Unicode c)
ignoreMinusSign_ja_JP::ignoreMinusSign_ja_JP()
{
- func = ignoreMinusSign_ja_JP_translator;
- table = 0;
- map = 0;
- transliterationName = "ignoreMinusSign_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreMinusSign_ja_JP";
+ func = ignoreMinusSign_ja_JP_translator;
+ table = 0;
+ map = 0;
+ transliterationName = "ignoreMinusSign_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreMinusSign_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreSeZe_ja_JP.cxx b/i18npool/source/transliteration/ignoreSeZe_ja_JP.cxx
index cb8124485389..eeeea2f71740 100644
--- a/i18npool/source/transliteration/ignoreSeZe_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreSeZe_ja_JP.cxx
@@ -30,25 +30,25 @@ using namespace com::sun::star::lang;
namespace com { namespace sun { namespace star { namespace i18n {
static const Mapping SeZe[] = {
- // SI + E --> SE
- { 0x30B7, 0x30A7, 0x30BB, sal_True },
- // SI + E --> SE
- { 0x3057, 0x3047, 0x305B, sal_True },
- // ZI + E --> ZE
- { 0x30B8, 0x30A7, 0x30BC, sal_True },
- // ZI + E --> ZE
- { 0x3058, 0x3047, 0x305C, sal_True },
-
- { 0, 0, 0, sal_True }
+ // SI + E --> SE
+ { 0x30B7, 0x30A7, 0x30BB, sal_True },
+ // SI + E --> SE
+ { 0x3057, 0x3047, 0x305B, sal_True },
+ // ZI + E --> ZE
+ { 0x30B8, 0x30A7, 0x30BC, sal_True },
+ // ZI + E --> ZE
+ { 0x3058, 0x3047, 0x305C, sal_True },
+
+ { 0, 0, 0, sal_True }
};
ignoreSeZe_ja_JP::ignoreSeZe_ja_JP()
{
- func = (TransFunc) 0;
- table = 0;
- map = SeZe;
- transliterationName = "ignoreSeZe_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreSeZe_ja_JP";
+ func = (TransFunc) 0;
+ table = 0;
+ map = SeZe;
+ transliterationName = "ignoreSeZe_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreSeZe_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx b/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx
index b395fbe97cdd..ade020ccfdb5 100644
--- a/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx
@@ -104,12 +104,12 @@ OneToOneMappingTable_t ignoreSeparatorTable[] = {
ignoreSeparator_ja_JP::ignoreSeparator_ja_JP()
{
- static oneToOneMapping _table(ignoreSeparatorTable, sizeof(ignoreSeparatorTable));
- func = (TransFunc) 0;
- table = &_table;
- map = 0;
- transliterationName = "ignoreSeparator_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreSeparator_ja_JP";
+ static oneToOneMapping _table(ignoreSeparatorTable, sizeof(ignoreSeparatorTable));
+ func = (TransFunc) 0;
+ table = &_table;
+ map = 0;
+ transliterationName = "ignoreSeparator_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreSeparator_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx b/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx
index b4d68f8ad5d4..9f8f75d1d9a4 100644
--- a/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx
@@ -47,11 +47,11 @@ OneToOneMappingTable_t ignoreSpace_ja_JP_mappingTable[] = {
ignoreSpace_ja_JP::ignoreSpace_ja_JP()
{
- func = (TransFunc)0;
- table = new oneToOneMapping(ignoreSpace_ja_JP_mappingTable, sizeof(ignoreSpace_ja_JP_mappingTable));
- map = 0;
- transliterationName = "ignoreSpace_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreSpace_ja_JP";
+ func = (TransFunc)0;
+ table = new oneToOneMapping(ignoreSpace_ja_JP_mappingTable, sizeof(ignoreSpace_ja_JP_mappingTable));
+ map = 0;
+ transliterationName = "ignoreSpace_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreSpace_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreTiJi_ja_JP.cxx b/i18npool/source/transliteration/ignoreTiJi_ja_JP.cxx
index ed084242bff6..799b3e15634c 100644
--- a/i18npool/source/transliteration/ignoreTiJi_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreTiJi_ja_JP.cxx
@@ -31,29 +31,29 @@ namespace com { namespace sun { namespace star { namespace i18n {
static const Mapping TiJi[] = {
- // TU + I --> TI
- { 0x30C4, 0x30A3, 0x30C1, sal_True },
- // TE + I --> TI
- { 0x30C6, 0x30A3, 0x30C1, sal_True },
- // TU + I --> TI
- { 0x3064, 0x3043, 0x3061, sal_True },
- // TE + I --> TI
- { 0x3066, 0x3043, 0x3061, sal_True },
- // DE + I --> ZI
- { 0x30C7, 0x30A3, 0x30B8, sal_True },
- // DE + I --> ZI
- { 0x3067, 0x3043, 0x3058, sal_True },
-
- { 0, 0, 0, sal_True }
+ // TU + I --> TI
+ { 0x30C4, 0x30A3, 0x30C1, sal_True },
+ // TE + I --> TI
+ { 0x30C6, 0x30A3, 0x30C1, sal_True },
+ // TU + I --> TI
+ { 0x3064, 0x3043, 0x3061, sal_True },
+ // TE + I --> TI
+ { 0x3066, 0x3043, 0x3061, sal_True },
+ // DE + I --> ZI
+ { 0x30C7, 0x30A3, 0x30B8, sal_True },
+ // DE + I --> ZI
+ { 0x3067, 0x3043, 0x3058, sal_True },
+
+ { 0, 0, 0, sal_True }
};
ignoreTiJi_ja_JP::ignoreTiJi_ja_JP()
{
- func = (TransFunc) 0;
- table = 0;
- map = TiJi;
- transliterationName = "ignoreTiJi_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreTiJi_ja_JP";
+ func = (TransFunc) 0;
+ table = 0;
+ map = TiJi;
+ transliterationName = "ignoreTiJi_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreTiJi_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreTraditionalKana_ja_JP.cxx b/i18npool/source/transliteration/ignoreTraditionalKana_ja_JP.cxx
index bea404c4821e..e2bc44ad9bd2 100644
--- a/i18npool/source/transliteration/ignoreTraditionalKana_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreTraditionalKana_ja_JP.cxx
@@ -48,11 +48,11 @@ ignoreTraditionalKana_ja_JP_translator (const sal_Unicode c)
ignoreTraditionalKana_ja_JP::ignoreTraditionalKana_ja_JP()
{
- func = ignoreTraditionalKana_ja_JP_translator;
- table = 0;
- map = 0;
- transliterationName = "ignoreTraditionalKana_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreTraditionalKana_ja_JP";
+ func = ignoreTraditionalKana_ja_JP_translator;
+ table = 0;
+ map = 0;
+ transliterationName = "ignoreTraditionalKana_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreTraditionalKana_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx b/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx
index 85700ab5d14c..d19a1f796cfd 100644
--- a/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx
@@ -726,12 +726,12 @@ OneToOneMappingTable_t traditionalKanji2updateKanji[] = {
ignoreTraditionalKanji_ja_JP::ignoreTraditionalKanji_ja_JP()
{
- static oneToOneMapping _table(traditionalKanji2updateKanji, sizeof(traditionalKanji2updateKanji));
- func = (TransFunc)0;
- table = &_table;
- map = 0;
- transliterationName = "ignoreTraditionalKanji_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreTraditionalKanji_ja_JP";
+ static oneToOneMapping _table(traditionalKanji2updateKanji, sizeof(traditionalKanji2updateKanji));
+ func = (TransFunc)0;
+ table = &_table;
+ map = 0;
+ transliterationName = "ignoreTraditionalKanji_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreTraditionalKanji_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreZiZu_ja_JP.cxx b/i18npool/source/transliteration/ignoreZiZu_ja_JP.cxx
index d39578a797fa..e9362b021b3c 100644
--- a/i18npool/source/transliteration/ignoreZiZu_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreZiZu_ja_JP.cxx
@@ -48,11 +48,11 @@ ignoreZiZu_ja_JP_translator (const sal_Unicode c)
ignoreZiZu_ja_JP::ignoreZiZu_ja_JP()
{
- func = ignoreZiZu_ja_JP_translator;
- table = 0;
- map = 0;
- transliterationName = "ignoreZiZu_ja_JP";
- implementationName = "com.sun.star.i18n.Transliteration.ignoreZiZu_ja_JP";
+ func = ignoreZiZu_ja_JP_translator;
+ table = 0;
+ map = 0;
+ transliterationName = "ignoreZiZu_ja_JP";
+ implementationName = "com.sun.star.i18n.Transliteration.ignoreZiZu_ja_JP";
}
} } } }
diff --git a/i18npool/source/transliteration/transliteration_Ignore.cxx b/i18npool/source/transliteration/transliteration_Ignore.cxx
index 6851b7c4599d..711571d7f10c 100644
--- a/i18npool/source/transliteration/transliteration_Ignore.cxx
+++ b/i18npool/source/transliteration/transliteration_Ignore.cxx
@@ -32,53 +32,53 @@ sal_Bool SAL_CALL
transliteration_Ignore::equals(const OUString& str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32& nMatch1,
const OUString& str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) throw(RuntimeException)
{
- Sequence< sal_Int32 > offset1;
- Sequence< sal_Int32 > offset2;
+ Sequence< sal_Int32 > offset1;
+ Sequence< sal_Int32 > offset2;
- // The method folding is defined in a sub class.
- OUString s1 = this->folding( str1, pos1, nCount1, offset1);
- OUString s2 = this->folding( str2, pos2, nCount2, offset2);
+ // The method folding is defined in a sub class.
+ OUString s1 = this->folding( str1, pos1, nCount1, offset1);
+ OUString s2 = this->folding( str2, pos2, nCount2, offset2);
- const sal_Unicode * p1 = s1.getStr();
- const sal_Unicode * p2 = s2.getStr();
- sal_Int32 length = Min(s1.getLength(), s2.getLength());
- sal_Int32 nmatch;
+ const sal_Unicode * p1 = s1.getStr();
+ const sal_Unicode * p2 = s2.getStr();
+ sal_Int32 length = Min(s1.getLength(), s2.getLength());
+ sal_Int32 nmatch;
- for ( nmatch = 0; nmatch < length; nmatch++)
- if (*p1++ != *p2++)
- break;
+ for ( nmatch = 0; nmatch < length; nmatch++)
+ if (*p1++ != *p2++)
+ break;
- if (nmatch > 0) {
- nMatch1 = offset1[ nmatch - 1 ] + 1; // Subtract 1 from nmatch because the index starts from zero.
- nMatch2 = offset2[ nmatch - 1 ] + 1; // And then, add 1 to position because it means the number of character matched.
- }
- else {
- nMatch1 = 0; // No character was matched.
- nMatch2 = 0;
- }
+ if (nmatch > 0) {
+ nMatch1 = offset1[ nmatch - 1 ] + 1; // Subtract 1 from nmatch because the index starts from zero.
+ nMatch2 = offset2[ nmatch - 1 ] + 1; // And then, add 1 to position because it means the number of character matched.
+ }
+ else {
+ nMatch1 = 0; // No character was matched.
+ nMatch2 = 0;
+ }
- return (nmatch == s1.getLength()) && (nmatch == s2.getLength());
+ return (nmatch == s1.getLength()) && (nmatch == s2.getLength());
}
Sequence< OUString > SAL_CALL
transliteration_Ignore::transliterateRange( const OUString& str1, const OUString& str2 ) throw(RuntimeException)
{
- if (str1.isEmpty() || str2.isEmpty())
- throw RuntimeException();
+ if (str1.isEmpty() || str2.isEmpty())
+ throw RuntimeException();
- Sequence< OUString > r(2);
- r[0] = str1.copy(0, 1);
- r[1] = str2.copy(0, 1);
- return r;
+ Sequence< OUString > r(2);
+ r[0] = str1.copy(0, 1);
+ r[1] = str2.copy(0, 1);
+ return r;
}
sal_Int16 SAL_CALL
transliteration_Ignore::getType() throw(RuntimeException)
{
- // The type is also defined in com/sun/star/util/TransliterationType.hdl
- return TransliterationType::IGNORE;
+ // The type is also defined in com/sun/star/util/TransliterationType.hdl
+ return TransliterationType::IGNORE;
}
@@ -86,36 +86,36 @@ OUString SAL_CALL
transliteration_Ignore::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
Sequence< sal_Int32 >& offset ) throw(RuntimeException)
{
- // The method folding is defined in a sub class.
- return this->folding( inStr, startPos, nCount, offset);
+ // The method folding is defined in a sub class.
+ return this->folding( inStr, startPos, nCount, offset);
}
Sequence< OUString > SAL_CALL
transliteration_Ignore::transliterateRange( const OUString& str1, const OUString& str2,
XTransliteration& t1, XTransliteration& t2 ) throw(RuntimeException)
{
- if (str1.isEmpty() || str2.isEmpty())
- throw RuntimeException();
-
- Sequence< sal_Int32 > offset;
- OUString s11 = t1.transliterate( str1, 0, 1, offset );
- OUString s12 = t1.transliterate( str2, 0, 1, offset );
- OUString s21 = t2.transliterate( str1, 0, 1, offset );
- OUString s22 = t2.transliterate( str2, 0, 1, offset );
-
- if ( (s11 == s21) && (s12 == s22) ) {
- Sequence< OUString > r(2);
- r[0] = s11;
- r[1] = s12;
- return r;
- }
+ if (str1.isEmpty() || str2.isEmpty())
+ throw RuntimeException();
+
+ Sequence< sal_Int32 > offset;
+ OUString s11 = t1.transliterate( str1, 0, 1, offset );
+ OUString s12 = t1.transliterate( str2, 0, 1, offset );
+ OUString s21 = t2.transliterate( str1, 0, 1, offset );
+ OUString s22 = t2.transliterate( str2, 0, 1, offset );
- Sequence< OUString > r(4);
+ if ( (s11 == s21) && (s12 == s22) ) {
+ Sequence< OUString > r(2);
r[0] = s11;
r[1] = s12;
- r[2] = s21;
- r[3] = s22;
return r;
+ }
+
+ Sequence< OUString > r(4);
+ r[0] = s11;
+ r[1] = s12;
+ r[2] = s21;
+ r[3] = s22;
+ return r;
}
OUString SAL_CALL
diff --git a/i18npool/source/transliteration/transliteration_Numeric.cxx b/i18npool/source/transliteration/transliteration_Numeric.cxx
index 8f09c261a4a6..8129e62452f3 100644
--- a/i18npool/source/transliteration/transliteration_Numeric.cxx
+++ b/i18npool/source/transliteration/transliteration_Numeric.cxx
@@ -30,28 +30,28 @@ namespace com { namespace sun { namespace star { namespace i18n {
sal_Int16 SAL_CALL transliteration_Numeric::getType() throw(RuntimeException)
{
- return TransliterationType::NUMERIC;
+ return TransliterationType::NUMERIC;
}
OUString SAL_CALL
-transliteration_Numeric::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/, sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/ )
- throw(RuntimeException)
+ transliteration_Numeric::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/, sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/ )
+throw(RuntimeException)
{
- throw RuntimeException();
+ throw RuntimeException();
}
sal_Bool SAL_CALL
-transliteration_Numeric::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 /*nCount1*/, sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 /*nCount2*/, sal_Int32& /*nMatch2*/ )
- throw(RuntimeException)
+ transliteration_Numeric::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 /*nCount1*/, sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 /*nCount2*/, sal_Int32& /*nMatch2*/ )
+throw(RuntimeException)
{
- throw RuntimeException();
+ throw RuntimeException();
}
Sequence< OUString > SAL_CALL
-transliteration_Numeric::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
- throw(RuntimeException)
+ transliteration_Numeric::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
+throw(RuntimeException)
{
- throw RuntimeException();
+ throw RuntimeException();
}
@@ -62,79 +62,79 @@ OUString SAL_CALL
transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
Sequence< sal_Int32 >& offset ) throw(RuntimeException)
{
- sal_Int32 number = -1, j = 0, endPos = startPos + nCount;
+ sal_Int32 number = -1, j = 0, endPos = startPos + nCount;
- if (endPos > inStr.getLength())
- endPos = inStr.getLength();
+ if (endPos > inStr.getLength())
+ endPos = inStr.getLength();
- rtl_uString* pStr = rtl_uString_alloc(nCount);
- sal_Unicode* out = pStr->buffer;
+ rtl_uString* pStr = rtl_uString_alloc(nCount);
+ sal_Unicode* out = pStr->buffer;
- if (useOffset)
- offset.realloc(nCount);
+ if (useOffset)
+ offset.realloc(nCount);
- for (sal_Int32 i = startPos; i < endPos; i++) {
- if (i < endPos && isNumber(inStr[i])) {
- if (number == -1) {
- startPos = i;
- number = (inStr[i] - NUMBER_ZERO);
- } else {
- number = number * 10 + (inStr[i] - NUMBER_ZERO);
- }
- } else {
- if (number == 0) {
- if (useOffset)
- offset[j] = startPos;
- out[j++] = NUMBER_ZERO;
- } if (number > tableSize && !recycleSymbol) {
- for (sal_Int32 k = startPos; k < i; k++) {
- if (useOffset)
- offset[j] = k;
- out[j++] = inStr[k];
- }
- } else if (number > 0) {
- if (useOffset)
- offset[j] = startPos;
- out[j++] = table[--number % tableSize];
- } else if (i < endPos) {
+ for (sal_Int32 i = startPos; i < endPos; i++) {
+ if (i < endPos && isNumber(inStr[i])) {
+ if (number == -1) {
+ startPos = i;
+ number = (inStr[i] - NUMBER_ZERO);
+ } else {
+ number = number * 10 + (inStr[i] - NUMBER_ZERO);
+ }
+ } else {
+ if (number == 0) {
+ if (useOffset)
+ offset[j] = startPos;
+ out[j++] = NUMBER_ZERO;
+ } if (number > tableSize && !recycleSymbol) {
+ for (sal_Int32 k = startPos; k < i; k++) {
if (useOffset)
- offset[j] = i;
- out[j++] = inStr[i];
+ offset[j] = k;
+ out[j++] = inStr[k];
}
- number = -1;
+ } else if (number > 0) {
+ if (useOffset)
+ offset[j] = startPos;
+ out[j++] = table[--number % tableSize];
+ } else if (i < endPos) {
+ if (useOffset)
+ offset[j] = i;
+ out[j++] = inStr[i];
}
+ number = -1;
}
- out[j] = 0;
+ }
+ out[j] = 0;
- if (useOffset)
- offset.realloc(j);
+ if (useOffset)
+ offset.realloc(j);
- return OUString( pStr, SAL_NO_ACQUIRE );
+ return OUString( pStr, SAL_NO_ACQUIRE );
}
OUString SAL_CALL
transliteration_Numeric::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
Sequence< sal_Int32 >& offset ) throw(RuntimeException)
{
- if (tableSize)
- return transliterateBullet( inStr, startPos, nCount, offset);
- else
- return NativeNumberSupplier(useOffset).getNativeNumberString( inStr.copy(startPos, nCount), aLocale, nNativeNumberMode, offset );
+ if (tableSize)
+ return transliterateBullet( inStr, startPos, nCount, offset);
+ else
+ return NativeNumberSupplier(useOffset).getNativeNumberString( inStr.copy(startPos, nCount), aLocale, nNativeNumberMode, offset );
}
sal_Unicode SAL_CALL
transliteration_Numeric::transliterateChar2Char( sal_Unicode inChar ) throw(RuntimeException, MultipleCharsOutputException)
{
- if (tableSize) {
- if (isNumber(inChar)) {
- sal_Int16 number = inChar - NUMBER_ZERO;
- if (number <= tableSize || recycleSymbol)
- return table[--number % tableSize];
- }
- return inChar;
+ if (tableSize) {
+ if (isNumber(inChar)) {
+ sal_Int16 number = inChar - NUMBER_ZERO;
+ if (number <= tableSize || recycleSymbol)
+ return table[--number % tableSize];
}
- else
- return NativeNumberSupplier().getNativeNumberChar( inChar, aLocale, nNativeNumberMode );
+ return inChar;
+ }
+ else
+ return NativeNumberSupplier().getNativeNumberChar( inChar, aLocale, nNativeNumberMode );
}
} } } }
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx
index 1c3e4d8ea063..28e440927cf4 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -183,25 +183,25 @@ Transliteration_body::transliterate(
OUString SAL_CALL
Transliteration_body::transliterateChar2String( sal_Unicode inChar ) throw(RuntimeException)
{
- const Mapping &map = casefolding::getValue(&inChar, 0, 1, aLocale, nMappingType);
- rtl_uString* pStr = rtl_uString_alloc(map.nmap);
- sal_Unicode* out = pStr->buffer;
- sal_Int32 i;
+ const Mapping &map = casefolding::getValue(&inChar, 0, 1, aLocale, nMappingType);
+ rtl_uString* pStr = rtl_uString_alloc(map.nmap);
+ sal_Unicode* out = pStr->buffer;
+ sal_Int32 i;
- for (i = 0; i < map.nmap; i++)
- out[i] = map.map[i];
- out[i] = 0;
+ for (i = 0; i < map.nmap; i++)
+ out[i] = map.map[i];
+ out[i] = 0;
- return OUString( pStr, SAL_NO_ACQUIRE );
+ return OUString( pStr, SAL_NO_ACQUIRE );
}
sal_Unicode SAL_CALL
Transliteration_body::transliterateChar2Char( sal_Unicode inChar ) throw(MultipleCharsOutputException, RuntimeException)
{
- const Mapping &map = casefolding::getValue(&inChar, 0, 1, aLocale, nMappingType);
- if (map.nmap > 1)
- throw MultipleCharsOutputException();
- return map.map[0];
+ const Mapping &map = casefolding::getValue(&inChar, 0, 1, aLocale, nMappingType);
+ if (map.nmap > 1)
+ throw MultipleCharsOutputException();
+ return map.map[0];
}
OUString SAL_CALL
diff --git a/i18npool/source/transliteration/transliteration_commonclass.cxx b/i18npool/source/transliteration/transliteration_commonclass.cxx
index 3732626adf6c..8e5853c7e31a 100644
--- a/i18npool/source/transliteration/transliteration_commonclass.cxx
+++ b/i18npool/source/transliteration/transliteration_commonclass.cxx
@@ -29,91 +29,91 @@ namespace com { namespace sun { namespace star { namespace i18n {
transliteration_commonclass::transliteration_commonclass()
{
- transliterationName = "";
- implementationName = "";
- useOffset = sal_True;
+ transliterationName = "";
+ implementationName = "";
+ useOffset = sal_True;
}
OUString SAL_CALL transliteration_commonclass::getName() throw(RuntimeException)
{
- return OUString::createFromAscii(transliterationName);
+ return OUString::createFromAscii(transliterationName);
}
void SAL_CALL transliteration_commonclass::loadModule( TransliterationModules /*modName*/, const Locale& rLocale )
- throw(RuntimeException)
+throw(RuntimeException)
{
- aLocale = rLocale;
+ aLocale = rLocale;
}
void SAL_CALL
transliteration_commonclass::loadModuleNew( const Sequence < TransliterationModulesNew >& /*modName*/, const Locale& /*rLocale*/ )
- throw(RuntimeException)
+throw(RuntimeException)
{
- throw RuntimeException();
+ throw RuntimeException();
}
void SAL_CALL
transliteration_commonclass::loadModuleByImplName( const OUString& /*implName*/, const Locale& /*rLocale*/ )
- throw(RuntimeException)
+throw(RuntimeException)
{
- throw RuntimeException();
+ throw RuntimeException();
}
void SAL_CALL
transliteration_commonclass::loadModulesByImplNames(const Sequence< OUString >& /*modNamelist*/, const Locale& /*rLocale*/)
- throw(RuntimeException)
+throw(RuntimeException)
{
- throw RuntimeException();
+ throw RuntimeException();
}
Sequence< OUString > SAL_CALL
transliteration_commonclass::getAvailableModules( const Locale& /*rLocale*/, sal_Int16 /*sType*/ )
- throw(RuntimeException)
+throw(RuntimeException)
{
- throw RuntimeException();
+ throw RuntimeException();
}
sal_Int32 SAL_CALL
transliteration_commonclass::compareSubstring(
const OUString& str1, sal_Int32 off1, sal_Int32 len1,
const OUString& str2, sal_Int32 off2, sal_Int32 len2)
- throw(RuntimeException)
+throw(RuntimeException)
{
- const sal_Unicode* unistr1 = NULL;
- const sal_Unicode* unistr2 = NULL;
- sal_uInt32 strlen1;
- sal_uInt32 strlen2;
-
- Sequence <sal_Int32> offset1(2*len1);
- Sequence <sal_Int32> offset2(2*len2);
-
- OUString in_str1 = this->transliterate(str1, off1, len1, offset1);
- OUString in_str2 = this->transliterate(str2, off2, len2, offset2);
- strlen1 = in_str1.getLength();
- strlen2 = in_str2.getLength();
- unistr1 = in_str1.getStr();
- unistr2 = in_str2.getStr();
-
- while (strlen1 && strlen2)
- {
- sal_uInt32 ret = *unistr1 - *unistr2;
- if (ret)
- return ret;
-
- unistr1++;
- unistr2++;
- strlen1--;
- strlen2--;
- }
- return strlen1 - strlen2;
+ const sal_Unicode* unistr1 = NULL;
+ const sal_Unicode* unistr2 = NULL;
+ sal_uInt32 strlen1;
+ sal_uInt32 strlen2;
+
+ Sequence <sal_Int32> offset1(2*len1);
+ Sequence <sal_Int32> offset2(2*len2);
+
+ OUString in_str1 = this->transliterate(str1, off1, len1, offset1);
+ OUString in_str2 = this->transliterate(str2, off2, len2, offset2);
+ strlen1 = in_str1.getLength();
+ strlen2 = in_str2.getLength();
+ unistr1 = in_str1.getStr();
+ unistr2 = in_str2.getStr();
+
+ while (strlen1 && strlen2)
+ {
+ sal_uInt32 ret = *unistr1 - *unistr2;
+ if (ret)
+ return ret;
+
+ unistr1++;
+ unistr2++;
+ strlen1--;
+ strlen2--;
+ }
+ return strlen1 - strlen2;
}
sal_Int32 SAL_CALL
transliteration_commonclass::compareString( const OUString& str1, const OUString& str2 ) throw ( RuntimeException)
{
- return( this->compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength()));
+ return( this->compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength()));
}
OUString SAL_CALL
@@ -141,14 +141,14 @@ const sal_Char cTrans[] = "com.sun.star.i18n.Transliteration.l10n";
sal_Bool SAL_CALL transliteration_commonclass::supportsService(const OUString& rServiceName) throw( RuntimeException )
{
- return rServiceName.equalsAscii(cTrans);
+ return rServiceName.equalsAscii(cTrans);
}
Sequence< OUString > SAL_CALL transliteration_commonclass::getSupportedServiceNames() throw( RuntimeException )
{
- Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii(cTrans);
- return aRet;
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii(cTrans);
+ return aRet;
}
} } } }