summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2004-03-09 11:39:01 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2004-03-09 11:39:01 +0000
commit50034a6fdc30ca2b76a209af2e51205ef2d40980 (patch)
treeec13b1514de88e2b5bcddb91534494eb1e9a641e
parent26aa11851a13f8b1915b5f418a00dd9722b90b84 (diff)
INTEGRATION: CWS ooo20040225 (1.12.2); FILE MERGED
2004/02/14 11:15:00 khendricks 1.12.2.1: syncing the 680 tree with my local lingucomponent tree
-rw-r--r--lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx67
1 files changed, 47 insertions, 20 deletions
diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
index 48bf1146157c..60722d2b87d0 100644
--- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
+++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hyphenimp.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: hr $ $Date: 2004-02-02 20:17:06 $
+ * last change: $Author: hr $ $Date: 2004-03-09 12:39:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -114,7 +114,6 @@
#include <osl/file.hxx>
#include "dictmgr.hxx"
-#include "csutil.hxx"
#include <stdio.h>
#include <iostream>
@@ -151,6 +150,7 @@ Hyphenator::Hyphenator() :
pPropHelper = NULL;
aDicts = NULL;
numdict = 0;
+
}
@@ -158,11 +158,16 @@ Hyphenator::~Hyphenator()
{
if (pPropHelper)
pPropHelper->RemoveAsPropListener();
- if ((aDicts) || (numdict)) {
- if (aDicts) delete[] aDicts;
- aDicts = NULL;
- numdict = 0;
- }
+
+ if ((numdict) && (aDicts)) {
+ for (int i=0; i < numdict; i++) {
+ if (aDicts[i].apCC) delete aDicts[i].apCC;
+ aDicts[i].apCC = NULL;
+ }
+ }
+ if (aDicts) delete[] aDicts;
+ aDicts = NULL;
+ numdict = 0;
}
@@ -256,6 +261,7 @@ Sequence< Locale > SAL_CALL Hyphenator::getLocales()
aDicts[k].aLoc = nLoc;
aDicts[k].aEnc = 0;
aDicts[k].aName = A2OU(updict->filename);
+ aDicts[k].apCC = new CharClass(nLoc);
k++;
updict++;
}
@@ -277,6 +283,7 @@ Sequence< Locale > SAL_CALL Hyphenator::getLocales()
aDicts[k].aLoc = nLoc;
aDicts[k].aEnc = 0;
aDicts[k].aName = A2OU(spdict->filename);
+ aDicts[k].apCC = new CharClass(nLoc);
k++;
spdict++;
}
@@ -319,8 +326,8 @@ sal_Bool SAL_CALL Hyphenator::hasLocale(const Locale& rLocale)
if (!aSuppLocales.getLength())
getLocales();
- INT32 nLen = aSuppLocales.getLength();
const Locale *pLocale = aSuppLocales.getConstArray();
+ INT32 nLen = aSuppLocales.getLength();
for (INT32 i = 0; i < nLen; ++i)
{
if (rLocale == pLocale[i])
@@ -357,6 +364,7 @@ Hyphenator::hyphenate( const ::rtl::OUString& aWord,
HyphenDict *dict = NULL;
rtl_TextEncoding aEnc = 0;
+ CharClass * pCC = NULL;
Reference< XHyphenatedWord > xRes;
@@ -399,6 +407,7 @@ Hyphenator::hyphenate( const ::rtl::OUString& aWord,
// other wise hyphenate the word with that dictionary
dict = aDicts[k].aPtr;
aEnc = aDicts[k].aEnc;
+ pCC = aDicts[k].apCC;
// first convert any smart quotes or apostrophes to normal ones
OUStringBuffer rBuf(aWord);
@@ -411,13 +420,19 @@ Hyphenator::hyphenate( const ::rtl::OUString& aWord,
}
OUString nWord(rBuf.makeStringAndClear());
+ // now convert word to all lowercase for pattern recognition
+ OUString nTerm(makeLowerCase(nWord, pCC));
+
// now convert word to needed encoding
- OString encWord(OU2ENC(nWord,aEnc));
+ OString encWord(OU2ENC(nTerm,aEnc));
wordlen = encWord.getLength();
lcword = new char[wordlen+1];
hyphens = new char[wordlen+5];
- enmkallsmall(lcword,encWord.getStr(),dict->cset);
+
+ // copy converted word into simple char buffer
+ strcpy(lcword,encWord.getStr());
+
// now strip off any ending periods
int n = wordlen-1;
while((n >=0) && (lcword[n] == '.')) n--;
@@ -497,7 +512,6 @@ Reference< XPossibleHyphens > SAL_CALL
{
SvtPathOptions aPathOpt;
- // CharClass chclass( rSMgr, aLocale );
int nHyphenationPos = -1;
int wordlen;
@@ -506,8 +520,9 @@ Reference< XPossibleHyphens > SAL_CALL
int k;
- HyphenDict *dict;
- rtl_TextEncoding aEnc;
+ HyphenDict *dict = NULL;
+ rtl_TextEncoding aEnc = 0;
+ CharClass* pCC = NULL;
Reference< XPossibleHyphens > xRes;
@@ -515,8 +530,6 @@ Reference< XPossibleHyphens > SAL_CALL
for (int j = 0; j < numdict; j++)
if (aLocale == aDicts[j].aLoc) k = j;
- dict = NULL;
- aEnc = 0;
// if we have a hyphenation dictionary matching this locale
if (k != -1) {
@@ -551,7 +564,7 @@ Reference< XPossibleHyphens > SAL_CALL
// other wise hyphenate the word with that dictionary
dict = aDicts[k].aPtr;
aEnc = aDicts[k].aEnc;
-
+ pCC = aDicts[k].apCC;
// first handle smart quotes both single and double
OUStringBuffer rBuf(aWord);
@@ -564,13 +577,19 @@ Reference< XPossibleHyphens > SAL_CALL
}
OUString nWord(rBuf.makeStringAndClear());
- // now convert the string to the proper encoding
- OString encWord(OU2ENC(nWord, aEnc));
+ // now convert word to all lowercase for pattern recognition
+ OUString nTerm(makeLowerCase(nWord, pCC));
+
+ // now convert word to needed encoding
+ OString encWord(OU2ENC(nTerm,aEnc));
wordlen = encWord.getLength();
lcword = new char[wordlen+1];
hyphens = new char[wordlen+5];
- enmkallsmall(lcword,encWord.getStr(),dict->cset);
+
+ // copy converted word into simple char buffer
+ strcpy(lcword,encWord.getStr());
+
// first remove any trailing periods
int n = wordlen-1;
while((n >=0) && (lcword[n] == '.')) n--;
@@ -630,6 +649,14 @@ Reference< XPossibleHyphens > SAL_CALL
}
+OUString SAL_CALL Hyphenator::makeLowerCase(const OUString& aTerm, CharClass * pCC)
+{
+ if (pCC)
+ return pCC->toLower_rtl(aTerm, 0, aTerm.getLength());
+ return aTerm;
+}
+
+
Reference< XInterface > SAL_CALL Hyphenator_CreateInstance(
const Reference< XMultiServiceFactory > & rSMgr )