diff options
author | Karl Hong <khong@openoffice.org> | 2002-08-02 15:00:18 +0000 |
---|---|---|
committer | Karl Hong <khong@openoffice.org> | 2002-08-02 15:00:18 +0000 |
commit | 3d4688152c69feb37ac5908258614ac653bdd9a1 (patch) | |
tree | 029f81df72d707b5af9b31ea8057650026fa985f | |
parent | e0f5c3dfaaf4e0d6d948ebcc4db780562b8e31df (diff) |
#93992# add word count mode in breakiterator
-rw-r--r-- | i18npool/inc/breakiterator_unicode.hxx | 12 | ||||
-rw-r--r-- | i18npool/source/breakiterator/breakiterator_unicode.cxx | 24 |
2 files changed, 20 insertions, 16 deletions
diff --git a/i18npool/inc/breakiterator_unicode.hxx b/i18npool/inc/breakiterator_unicode.hxx index ca6868366c1f..78cd35520c2a 100644 --- a/i18npool/inc/breakiterator_unicode.hxx +++ b/i18npool/inc/breakiterator_unicode.hxx @@ -2,9 +2,9 @@ * * $RCSfile: breakiterator_unicode.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: khong $ $Date: 2002-06-03 19:07:46 $ + * last change: $Author: khong $ $Date: 2002-08-02 15:56:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -112,10 +112,10 @@ protected: Boundary result; // for word break iterator private: - rtl::OUString cachedText; // for script boundary - sal_Int32 scriptStart, scriptLength; - icu::BreakIterator *characterBreak, *editWordBreak, *dictWordBreak, *sentenceBreak, *lineBreak; - sal_Int32 SAL_CALL setTextByScriptBoundary(const rtl::OUString& Text, sal_Int32 nPos); + icu::BreakIterator *characterBreak, *editWordBreak, *dictWordBreak, + *countWordBreak, *sentenceBreak, *lineBreak; + icu::BreakIterator* SAL_CALL loadICUWordBreakIterator(const com::sun::star::lang::Locale& rLocale, + sal_Int16 rWordType) throw( com::sun::star::uno::RuntimeException); }; } } } } diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx index e21b955ffd65..470ebc833f45 100644 --- a/i18npool/source/breakiterator/breakiterator_unicode.cxx +++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: breakiterator_unicode.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: khong $ $Date: 2002-07-23 16:59:52 $ + * last change: $Author: khong $ $Date: 2002-08-02 16:00:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -82,7 +82,7 @@ static UErrorCode status; // status is shared in all calls to Calendar, it has t BreakIterator_Unicode::BreakIterator_Unicode() { - characterBreak = dictWordBreak = editWordBreak = sentenceBreak = lineBreak = NULL; + characterBreak = dictWordBreak = editWordBreak = countWordBreak = sentenceBreak = lineBreak = NULL; cBreakIterator = ImplementName; } @@ -92,6 +92,7 @@ BreakIterator_Unicode::~BreakIterator_Unicode() if (characterBreak) delete characterBreak; if (dictWordBreak) delete dictWordBreak; if (editWordBreak) delete editWordBreak; + if (countWordBreak) delete countWordBreak; if (sentenceBreak) delete sentenceBreak; if (lineBreak) delete lineBreak; } @@ -126,11 +127,14 @@ static icu::BreakIterator* SAL_CALL loadICUBreakIterator(const com::sun::star::l return breakiterator; } -static icu::BreakIterator* SAL_CALL loadICUWordBreakIterator(const com::sun::star::lang::Locale& rLocale, - sal_Int16 rWordType, icu::BreakIterator* &dictWordBreak, icu::BreakIterator* &editWordBreak) - throw(RuntimeException) +icu::BreakIterator* SAL_CALL BreakIterator_Unicode::loadICUWordBreakIterator(const lang::Locale& rLocale, + sal_Int16 rWordType) throw(RuntimeException) { - if (rWordType == WordType::DICTIONARY_WORD) { + if (rWordType == WordType::WORD_COUNT) { + if (!countWordBreak) countWordBreak = loadICUBreakIterator(rLocale, "count_word", LOAD_WORD_BREAKITERATOR); + return countWordBreak; + } + else if (rWordType == WordType::DICTIONARY_WORD) { if (!dictWordBreak) dictWordBreak = loadICUBreakIterator(rLocale, "dict_word", LOAD_WORD_BREAKITERATOR); return dictWordBreak; } else { @@ -186,7 +190,7 @@ sal_Int32 SAL_CALL BreakIterator_Unicode::previousCharacters( const OUString& Te Boundary SAL_CALL BreakIterator_Unicode::nextWord( const OUString& Text, sal_Int32 nStartPos, const lang::Locale& rLocale, sal_Int16 rWordType ) throw(RuntimeException) { - icu::BreakIterator* wordBreak = loadICUWordBreakIterator(rLocale, rWordType, dictWordBreak, editWordBreak); + icu::BreakIterator* wordBreak = loadICUWordBreakIterator(rLocale, rWordType); wordBreak->setText(UnicodeString(Text.getStr(), Text.getLength())); result.startPos = wordBreak->following(nStartPos); @@ -209,7 +213,7 @@ Boundary SAL_CALL BreakIterator_Unicode::nextWord( const OUString& Text, sal_Int Boundary SAL_CALL BreakIterator_Unicode::previousWord(const OUString& Text, sal_Int32 nStartPos, const lang::Locale& rLocale, sal_Int16 rWordType) throw(RuntimeException) { - icu::BreakIterator* wordBreak = loadICUWordBreakIterator(rLocale, rWordType, dictWordBreak, editWordBreak); + icu::BreakIterator* wordBreak = loadICUWordBreakIterator(rLocale, rWordType); wordBreak->setText(UnicodeString(Text.getStr(), Text.getLength())); result.startPos = wordBreak->preceding(nStartPos); @@ -232,7 +236,7 @@ Boundary SAL_CALL BreakIterator_Unicode::previousWord(const OUString& Text, sal_ Boundary SAL_CALL BreakIterator_Unicode::getWordBoundary( const OUString& Text, sal_Int32 nPos, const lang::Locale& rLocale, sal_Int16 rWordType, sal_Bool bDirection ) throw(RuntimeException) { - icu::BreakIterator* wordBreak = loadICUWordBreakIterator(rLocale, rWordType, dictWordBreak, editWordBreak); + icu::BreakIterator* wordBreak = loadICUWordBreakIterator(rLocale, rWordType); sal_Int32 len = Text.getLength(); wordBreak->setText(UnicodeString(Text.getStr(), len)); |