summaryrefslogtreecommitdiff
path: root/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx')
-rw-r--r--lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx61
1 files changed, 45 insertions, 16 deletions
diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
index b24bc6ee80f5..7ebd9a7b66f3 100644
--- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
+++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
@@ -39,8 +39,8 @@
#include <cppuhelper/factory.hxx> // helper for factories
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <i18npool/mslangid.hxx>
-#include <svtools/pathoptions.hxx>
-#include <svtools/useroptions.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/useroptions.hxx>
#include <tools/debug.hxx>
#include <unotools/processfactory.hxx>
#include <osl/mutex.hxx>
@@ -57,14 +57,15 @@
#include <rtl/ustrbuf.hxx>
#include <linguistic/lngprops.hxx>
-#include <svtools/pathoptions.hxx>
-#include <svtools/useroptions.hxx>
-#include <svtools/lingucfg.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/useroptions.hxx>
+#include <unotools/lingucfg.hxx>
#include <osl/file.hxx>
#include "dictmgr.hxx"
#include <stdio.h>
+#include <string.h>
#include <list>
#include <set>
@@ -534,7 +535,7 @@ Reference < XHyphenatedWord > SAL_CALL
Reference< XPossibleHyphens > SAL_CALL
Hyphenator::createPossibleHyphens( const ::rtl::OUString& aWord,
const ::com::sun::star::lang::Locale& aLocale,
- const ::com::sun::star::beans::PropertyValues& /*aProperties*/ )
+ const ::com::sun::star::beans::PropertyValues& aProperties )
throw(::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException)
@@ -544,6 +545,10 @@ Reference< XPossibleHyphens > SAL_CALL
char *lcword;
int k;
+ PropertyHelper_Hyphen & rHelper = GetPropHelper();
+ rHelper.SetTmpPropVals(aProperties);
+ sal_Int16 minTrail = rHelper.GetMinTrailing();
+ sal_Int16 minLead = rHelper.GetMinLeading();
HyphenDict *dict = NULL;
rtl_TextEncoding aEnc = 0;
@@ -617,6 +622,9 @@ Reference< XPossibleHyphens > SAL_CALL
wordlen = encWord.getLength();
lcword = new char[wordlen+1];
hyphens = new char[wordlen+5];
+ char ** rep = NULL; // replacements of discretionary hyphenation
+ int * pos = NULL; // array of [hyphenation point] minus [deletion position]
+ int * cut = NULL; // length of deletions in original word
// copy converted word into simple char buffer
strcpy(lcword,encWord.getStr());
@@ -627,10 +635,22 @@ Reference< XPossibleHyphens > SAL_CALL
n++;
// fprintf(stderr,"hyphenate... %s\n",lcword); fflush(stderr);
if (n > 0) {
- if (hnj_hyphen_hyphenate(dict, lcword, n, hyphens))
+ if (hnj_hyphen_hyphenate3(dict, lcword, n, hyphens, NULL, &rep, &pos, &cut,
+ minLead, minTrail, Max(dict->clhmin, Max(dict->clhmin, 2) + Max(0, minLead - Max(dict->lhmin, 2))),
+ Max(dict->crhmin, Max(dict->crhmin, 2) + Max(0, minTrail - Max(dict->rhmin, 2)))))
{
delete[] hyphens;
delete[] lcword;
+
+ if (rep) {
+ for(int j = 0; j < n; j++) {
+ if (rep[j]) free(rep[j]);
+ }
+ free(rep);
+ }
+ if (pos) free(pos);
+ if (cut) free(cut);
+
return NULL;
}
}
@@ -643,7 +663,7 @@ Reference< XPossibleHyphens > SAL_CALL
INT16 i;
for ( i = 0; i < encWord.getLength(); i++)
- if (hyphens[i]&1)
+ if (hyphens[i]&1 && (!rep || !rep[i]))
nHyphCount++;
Sequence< INT16 > aHyphPos(nHyphCount);
@@ -652,15 +672,14 @@ Reference< XPossibleHyphens > SAL_CALL
OUString hyphenatedWord;
nHyphCount = 0;
- for (i = 0; i < encWord.getLength(); i++)
- {
+ for (i = 0; i < nWord.getLength(); i++) {
hyphenatedWordBuffer.append(aWord[i]);
- if (hyphens[i]&1)
- {
- pPos[nHyphCount] = i;
- hyphenatedWordBuffer.append(sal_Unicode('='));
- nHyphCount++;
- }
+ // hyphenation position (not alternative)
+ if (hyphens[i]&1 && (!rep || !rep[i])) {
+ pPos[nHyphCount] = i;
+ hyphenatedWordBuffer.append(sal_Unicode('='));
+ nHyphCount++;
+ }
}
hyphenatedWord = hyphenatedWordBuffer.makeStringAndClear();
@@ -672,6 +691,16 @@ Reference< XPossibleHyphens > SAL_CALL
delete[] hyphens;
delete[] lcword;
+
+ if (rep) {
+ for(int j = 0; j < n; j++) {
+ if (rep[j]) free(rep[j]);
+ }
+ free(rep);
+ }
+ if (pos) free(pos);
+ if (cut) free(cut);
+
return xRes;
}