diff options
Diffstat (limited to 'i18npool/source')
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_cjk.cxx | 10 | ||||
-rw-r--r-- | i18npool/source/breakiterator/xdictionary.cxx | 22 |
2 files changed, 19 insertions, 13 deletions
diff --git a/i18npool/source/breakiterator/breakiterator_cjk.cxx b/i18npool/source/breakiterator/breakiterator_cjk.cxx index 876e00f836ae..faffc33c000b 100644 --- a/i18npool/source/breakiterator/breakiterator_cjk.cxx +++ b/i18npool/source/breakiterator/breakiterator_cjk.cxx @@ -2,9 +2,9 @@ * * $RCSfile: breakiterator_cjk.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: er $ $Date: 2002-03-26 16:55:00 $ + * last change: $Author: khong $ $Date: 2002-08-02 01:35:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,7 +83,7 @@ BreakIterator_CJK::previousWord(const OUString& text, sal_Int32 anyPos, const lang::Locale& nLocale, sal_Int16 wordType) throw(RuntimeException) { if (dict) - return dict->previousWord(text.getStr(), anyPos, text.getLength()); + return dict->previousWord(text.getStr(), anyPos, text.getLength(), wordType); else throw RuntimeException(); } @@ -93,7 +93,7 @@ BreakIterator_CJK::nextWord(const OUString& text, sal_Int32 anyPos, const lang::Locale& nLocale, sal_Int16 wordType) throw(RuntimeException) { if (dict) - return dict->nextWord(text.getStr(), anyPos, text.getLength()); + return dict->nextWord(text.getStr(), anyPos, text.getLength(), wordType); else throw RuntimeException(); } @@ -104,7 +104,7 @@ BreakIterator_CJK::getWordBoundary( const OUString& text, sal_Int32 anyPos, throw(RuntimeException) { if (dict) - return dict->getWordBoundary(text.getStr(), anyPos, text.getLength(), bDirection); + return dict->getWordBoundary(text.getStr(), anyPos, text.getLength(), wordType, bDirection); else throw RuntimeException(); } diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx index 80fa3b4be7df..a4ab7461b5a0 100644 --- a/i18npool/source/breakiterator/xdictionary.cxx +++ b/i18npool/source/breakiterator/xdictionary.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xdictionary.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: khong $ $Date: 2002-04-16 00:05:32 $ + * last change: $Author: khong $ $Date: 2002-08-02 01:35:52 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,7 @@ // ////////////////////////////////////////////////////////////////////// +#include <com/sun/star/i18n/WordType.hpp> #include <tools/string.hxx> #include <xdictionary.hxx> #include <unicode.hxx> @@ -239,24 +240,24 @@ WordBreakCache& SAL_CALL xdictionary::getCache(const sal_Unicode *text, Boundary return aCache; } -Boundary SAL_CALL xdictionary::previousWord(const sal_Unicode *text, sal_Int32 anyPos, sal_Int32 len) +Boundary SAL_CALL xdictionary::previousWord(const sal_Unicode *text, sal_Int32 anyPos, sal_Int32 len, sal_Int16 wordType) { // looking for the first non-whitespace character from anyPos while (unicode::isWhiteSpace(text[anyPos - 1])) anyPos --; - return getWordBoundary(text, anyPos - 1, len, true); + return getWordBoundary(text, anyPos - 1, len, wordType, true); } -Boundary SAL_CALL xdictionary::nextWord(const sal_Unicode *text, sal_Int32 anyPos, sal_Int32 len) +Boundary SAL_CALL xdictionary::nextWord(const sal_Unicode *text, sal_Int32 anyPos, sal_Int32 len, sal_Int16 wordType) { - boundary = getWordBoundary(text, anyPos, len, true); + boundary = getWordBoundary(text, anyPos, len, wordType, true); // looknig for the first non-whitespace character from anyPos anyPos = boundary.endPos; while (unicode::isWhiteSpace(text[anyPos])) anyPos ++; - return getWordBoundary(text, anyPos, len, true); + return getWordBoundary(text, anyPos, len, wordType, true); } -Boundary SAL_CALL xdictionary::getWordBoundary(const sal_Unicode *text, sal_Int32 anyPos, sal_Int32 len, sal_Bool bDirection) +Boundary SAL_CALL xdictionary::getWordBoundary(const sal_Unicode *text, sal_Int32 anyPos, sal_Int32 len, sal_Int16 wordType, sal_Bool bDirection) { Boundary boundary; @@ -279,6 +280,11 @@ Boundary SAL_CALL xdictionary::getWordBoundary(const sal_Unicode *text, sal_Int3 boundary.startPos = anyPos++; boundary.endPos = anyPos < len ? anyPos : len; } + if (wordType == WordType::WORD_COUNT) { + // skip punctuation for word count. + while (boundary.endPos < len && unicode::isPunctuation(text[boundary.endPos])) + boundary.endPos++; + } return boundary; } |