summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Hong <khong@openoffice.org>2002-08-02 00:35:52 +0000
committerKarl Hong <khong@openoffice.org>2002-08-02 00:35:52 +0000
commit00e8eba862df67e843a0c050d25240f9523ac903 (patch)
tree457fd91fd8af56dddf2443c5802d86a584e99352
parent30dd0bfd87eed63bd2dcd79c7894dba5eb01e76a (diff)
#93992# skip punctuations when counting the words
-rw-r--r--i18npool/inc/xdictionary.hxx10
-rw-r--r--i18npool/source/breakiterator/breakiterator_cjk.cxx10
-rw-r--r--i18npool/source/breakiterator/xdictionary.cxx22
3 files changed, 24 insertions, 18 deletions
diff --git a/i18npool/inc/xdictionary.hxx b/i18npool/inc/xdictionary.hxx
index d292e024ac0b..059f9ec9ac4b 100644
--- a/i18npool/inc/xdictionary.hxx
+++ b/i18npool/inc/xdictionary.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: xdictionary.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: er $ $Date: 2002-03-26 17:57:44 $
+ * last change: $Author: khong $ $Date: 2002-08-02 01:33:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -96,9 +96,9 @@ private:
public:
xdictionary(sal_Char *lang);
~xdictionary();
- Boundary SAL_CALL nextWord( const sal_Unicode *text, sal_Int32 nPos, sal_Int32 len);
- Boundary SAL_CALL previousWord( const sal_Unicode *text, sal_Int32 nPos, sal_Int32 len);
- Boundary SAL_CALL getWordBoundary( const sal_Unicode *text, sal_Int32 nPos, sal_Int32 len,
+ Boundary SAL_CALL nextWord( const sal_Unicode *text, sal_Int32 nPos, sal_Int32 len, sal_Int16 wordType);
+ Boundary SAL_CALL previousWord( const sal_Unicode *text, sal_Int32 nPos, sal_Int32 len, sal_Int16 wordType);
+ Boundary SAL_CALL getWordBoundary( const sal_Unicode *text, sal_Int32 nPos, sal_Int32 len, sal_Int16 wordType,
sal_Bool bDirection );
void SAL_CALL setCellBoundary(sal_Int32* cellBondary);
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;
}