diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-03-09 16:20:50 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-03-09 16:20:50 -0600 |
commit | ab1deb45e8bdfcb406ed40cc279412bfb8ebb7da (patch) | |
tree | 4fabc6cfb877b36a045647e22ab9afb895a0c6e2 /lingucomponent | |
parent | 8d39bcae009afc1022974a6b0efdbbdb5b057ad4 (diff) | |
parent | e887a292fa3a7662fea0fc682d41f55e9e170a33 (diff) |
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101
* commit 'ooo/DEV300_m101': (185 commits)
masterfix DEV300: #i10000# usage of L10N build_type
masterfix: #i10000# INT16 -> sal_Int16
fixed compile errors after resync to m100, part2
gridsort: post-rebase fixes
CWS gnumake3: found another tools integer type
removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw
native359: #i114398# changing mac langpack icon
native359: #i115669# fixing package description for solaris packages
gnumake3: remove comphelper version; fix including extract.hxx
locales34: #i106785# add Haitian_Haiti [ht-HT] to language list and locale data; locale data contributed by <jcpoulard>
sb138: #i116659# timely termination of OnLogRotateThread
accfixes: removed include of obsolete header file
accfixes: removed obsolete file
removetooltypes01: #i112600# Fix build problems on non-pro
accfixes: moved some shared strings to svx part2
accfixes: moved some shared strings to svx
accfixes: added more accessibility information and fixed tab orders in multiple dialogs (cui module)
removetooltypes01: #i112600# Remove tools types for Mac specific parts
fixed tab order in BasicIDE, Library dialog tab page
added some accessible names in BasicIDE
...
Conflicts:
UnoControls/source/base/registercontrols.cxx
accessibility/inc/accessibility/standard/vclxaccessiblelistboxlist.hxx
automation/inc/automation/communi.hxx
automation/inc/automation/simplecm.hxx
automation/source/communi/communi.cxx
automation/source/inc/rcontrol.hxx
automation/source/miniapp/servuid.hxx
automation/source/server/XMLParser.cxx
automation/source/server/cmdbasestream.cxx
automation/source/server/profiler.hxx
automation/source/server/recorder.cxx
automation/source/server/retstrm.hxx
automation/source/server/server.cxx
automation/source/server/sta_list.cxx
automation/source/server/statemnt.cxx
automation/source/server/statemnt.hxx
automation/source/simplecm/packethandler.cxx
automation/source/simplecm/simplecm.cxx
automation/source/simplecm/tcpio.cxx
automation/source/simplecm/tcpio.hxx
automation/source/testtool/comm_bas.hxx
automation/source/testtool/cretstrm.hxx
automation/source/testtool/httprequest.cxx
automation/source/testtool/httprequest.hxx
automation/source/testtool/objtest.cxx
automation/source/testtool/objtest.hxx
basctl/source/basicide/baside2.cxx
basctl/source/basicide/baside2.hxx
basctl/source/basicide/baside2b.cxx
basctl/source/basicide/baside3.cxx
basctl/source/basicide/basides1.cxx
basctl/source/basicide/basides2.cxx
basctl/source/basicide/basidesh.cxx
basctl/source/basicide/basidesh.src
basctl/source/basicide/basobj3.cxx
basctl/source/basicide/bastype2.cxx
basctl/source/basicide/bastype3.cxx
basctl/source/basicide/bastypes.cxx
basctl/source/basicide/brkdlg.cxx
basctl/source/basicide/iderdll.cxx
basctl/source/basicide/macrodlg.cxx
basctl/source/basicide/moduldl2.cxx
basctl/source/basicide/moduldlg.cxx
basctl/source/basicide/objdlg.cxx
basctl/source/basicide/scriptdocument.cxx
basctl/source/basicide/tbxctl.cxx
basctl/source/basicide/tbxctl.hxx
basctl/source/basicide/tbxctl.src
basctl/source/dlged/dlged.cxx
basctl/source/dlged/dlgedfunc.cxx
basctl/source/dlged/dlgedobj.cxx
basctl/source/inc/basidesh.hxx
basctl/source/inc/bastypes.hxx
basctl/source/inc/dlgedmod.hxx
basctl/source/inc/dlgedpage.hxx
crashrep/prj/build.lst
cui/inc/pch/precompiled_cui.hxx
cui/source/customize/acccfg.cxx
cui/source/customize/acccfg.hrc
cui/source/customize/acccfg.src
cui/source/customize/cfg.cxx
cui/source/customize/cfgutil.cxx
cui/source/customize/macropg.cxx
cui/source/customize/macropg.src
cui/source/customize/selector.cxx
cui/source/dialogs/SpellDialog.cxx
cui/source/dialogs/commonlingui.cxx
cui/source/dialogs/cuicharmap.cxx
cui/source/dialogs/cuifmsearch.cxx
cui/source/dialogs/cuigaldlg.cxx
cui/source/dialogs/cuigrfflt.cxx
cui/source/dialogs/hldocntp.cxx
cui/source/dialogs/hldoctp.cxx
cui/source/dialogs/hlinettp.cxx
cui/source/dialogs/hlmailtp.cxx
cui/source/dialogs/hlmarkwn.cxx
cui/source/dialogs/hlmarkwn.src
cui/source/dialogs/hltpbase.cxx
cui/source/dialogs/iconcdlg.cxx
cui/source/dialogs/passwdomdlg.cxx
cui/source/dialogs/pastedlg.cxx
cui/source/dialogs/scriptdlg.cxx
cui/source/dialogs/thesdlg.cxx
cui/source/dialogs/zoom.cxx
cui/source/factory/dlgfact.hxx
cui/source/inc/SpellDialog.hxx
cui/source/inc/autocdlg.hxx
cui/source/inc/backgrnd.hxx
cui/source/inc/bbdlg.hxx
cui/source/inc/cfg.hxx
cui/source/inc/cfgutil.hxx
cui/source/inc/cuigaldlg.hxx
cui/source/inc/cuigrfflt.hxx
cui/source/inc/cuitabarea.hxx
cui/source/inc/cuitabline.hxx
cui/source/inc/hldocntp.hxx
cui/source/inc/hltpbase.hxx
cui/source/inc/iconcdlg.hxx
cui/source/inc/numpages.hxx
cui/source/inc/page.hxx
cui/source/inc/postdlg.hxx
cui/source/inc/scriptdlg.hxx
cui/source/inc/transfrm.hxx
cui/source/inc/zoom.hxx
cui/source/options/cfgchart.cxx
cui/source/options/cuisrchdlg.cxx
cui/source/options/dbregister.cxx
cui/source/options/dbregister.src
cui/source/options/fontsubs.cxx
cui/source/options/internationaloptions.cxx
cui/source/options/optasian.cxx
cui/source/options/optchart.cxx
cui/source/options/optcolor.cxx
cui/source/options/optcolor.src
cui/source/options/optfltr.cxx
cui/source/options/optfltr.src
cui/source/options/optgdlg.cxx
cui/source/options/optgdlg.src
cui/source/options/optgenrl.cxx
cui/source/options/opthtml.cxx
cui/source/options/optimprove.cxx
cui/source/options/optinet2.cxx
cui/source/options/optinet2.hxx
cui/source/options/optjava.cxx
cui/source/options/optlingu.cxx
cui/source/options/optsave.cxx
cui/source/options/optsave.hxx
cui/source/options/treeopt.cxx
cui/source/options/webconninfo.cxx
cui/source/tabpages/autocdlg.cxx
cui/source/tabpages/backgrnd.cxx
cui/source/tabpages/border.cxx
cui/source/tabpages/chardlg.cxx
cui/source/tabpages/dstribut.cxx
cui/source/tabpages/grfpage.cxx
cui/source/tabpages/macroass.cxx
cui/source/tabpages/measure.cxx
cui/source/tabpages/numfmt.cxx
cui/source/tabpages/numpages.cxx
cui/source/tabpages/page.cxx
cui/source/tabpages/paragrph.cxx
cui/source/tabpages/swpossizetabpage.cxx
cui/source/tabpages/tabarea.src
cui/source/tabpages/textanim.cxx
cui/source/tabpages/textattr.cxx
cui/source/tabpages/tparea.cxx
cui/source/tabpages/tpbitmap.cxx
cui/source/tabpages/tpcolor.cxx
cui/source/tabpages/tpgradnt.cxx
cui/source/tabpages/tphatch.cxx
cui/source/tabpages/tpline.cxx
cui/source/tabpages/tplnedef.cxx
cui/source/tabpages/tplneend.cxx
cui/source/tabpages/tpshadow.cxx
cui/source/tabpages/transfrm.cxx
embedserv/source/embed/register.cxx
extensions/inc/pch/precompiled_extensions.hxx
extensions/inc/propctrlr.hrc
extensions/source/abpilot/abpservices.cxx
extensions/source/bibliography/bibload.cxx
extensions/source/bibliography/datman.cxx
extensions/source/bibliography/general.cxx
extensions/source/dbpilots/dbpservices.cxx
extensions/source/inc/componentmodule.cxx
extensions/source/nsplugin/source/so_env.cxx
extensions/source/ole/oleobjw.cxx
extensions/source/ole/oleobjw.hxx
extensions/source/oooimprovement/invite_job.cxx
extensions/source/oooimprovement/onlogrotate_job.cxx
extensions/source/plugin/base/service.cxx
extensions/source/plugin/inc/plugin/unx/mediator.hxx
extensions/source/plugin/inc/plugin/unx/plugcon.hxx
extensions/source/plugin/unx/mediator.cxx
extensions/source/plugin/unx/nppapi.cxx
extensions/source/plugin/unx/plugcon.cxx
extensions/source/preload/services.cxx
extensions/source/propctrlr/formmetadata.cxx
extensions/source/propctrlr/pcrservices.cxx
extensions/source/resource/resource.cxx
extensions/source/scanner/sane.hxx
extensions/source/scanner/sanedlg.cxx
extensions/source/scanner/scanunx.cxx
extensions/source/scanner/scanwin.cxx
extensions/source/scanner/twain.cxx
extensions/source/scanner/twain.hxx
extensions/source/update/check/updatecheckconfig.cxx
extensions/test/stm/datatest.cxx
extensions/test/stm/marktest.cxx
extensions/test/stm/pipetest.cxx
extensions/test/stm/testfactreg.cxx
extensions/workben/testpgp.cxx
forms/qa/complex/forms/CheckOGroupBoxModel.java
forms/qa/makefile.mk
forms/source/component/Button.cxx
forms/source/component/Button.hxx
forms/source/component/ListBox.cxx
forms/source/inc/forms_module_impl.hxx
forms/source/misc/services.cxx
forms/source/solar/control/navtoolbar.cxx
javainstaller2/prj/build.lst
javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java
lingucomponent/prj/build.lst
lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
lingucomponent/source/spellcheck/spell/sreg.cxx
lingucomponent/source/spellcheck/spell/sspellimp.cxx
package/source/manifest/ManifestExport.cxx
package/source/manifest/UnoRegister.cxx
package/source/xstor/owriteablestream.cxx
package/source/xstor/owriteablestream.hxx
package/source/xstor/xstorage.hxx
package/source/zippackage/ZipPackageFolder.cxx
package/source/zippackage/ZipPackageStream.cxx
setup_native/source/mac/ooo/DS_Store
setup_native/source/win32/customactions/shellextensions/registerextensions.cxx
xmlsecurity/prj/build.lst
xmlsecurity/source/component/registerservices.cxx
xmlsecurity/source/dialogs/stbcontrl.cxx
xmlsecurity/source/framework/xsec_framework.cxx
xmlsecurity/source/xmlsec/xsec_xmlsec.cxx
xmlsecurity/tools/demo/util.hxx
xmlsecurity/workben/signaturetest.cxx
Diffstat (limited to 'lingucomponent')
32 files changed, 1217 insertions, 1252 deletions
diff --git a/lingucomponent/prj/build.lst b/lingucomponent/prj/build.lst index 15ee595c6..23137e620 100644 --- a/lingucomponent/prj/build.lst +++ b/lingucomponent/prj/build.lst @@ -1,4 +1,4 @@ -lc lingucomponent : linguistic LIBTEXTCAT:libtextcat LIBTEXTCATDATA:libtextcat svl HYPHEN:hyphen HUNSPELL:hunspell MYTHES:mythes NULL +lc lingucomponent : linguistic LIBTEXTCAT:libtextcat LIBTEXTCATDATA:libtextcat svl HYPHEN:hyphen HUNSPELL:hunspell MYTHES:mythes LIBXSLT:libxslt NULL lc lingucomponent usr1 - all lc_mkout NULL lc lingucomponent\inc nmake - all lc_inc NULL lc lingucomponent\source\lingutil nmake - all lc_util lc_inc NULL diff --git a/lingucomponent/prj/d.lst b/lingucomponent/prj/d.lst index 666ee38d5..4760a299c 100644 --- a/lingucomponent/prj/d.lst +++ b/lingucomponent/prj/d.lst @@ -46,3 +46,8 @@ mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice mkdir: %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office ..\config\*.xcu %_DEST%\xml%_EXT%\registry\data\org\openoffice\Office\*.xcu +..\%__SRC%\misc\MacOSXSpell.component %_DEST%\xml%_EXT%\MacOSXSpell.component +..\%__SRC%\misc\guesslang.component %_DEST%\xml%_EXT%\guesslang.component +..\%__SRC%\misc\hyphen.component %_DEST%\xml%_EXT%\hyphen.component +..\%__SRC%\misc\lnth.component %_DEST%\xml%_EXT%\lnth.component +..\%__SRC%\misc\spell.component %_DEST%\xml%_EXT%\spell.component diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/exports.dxp b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/exports.dxp index b0f85bf7b..a9861e3ff 100644 --- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/exports.dxp +++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/exports.dxp @@ -1,3 +1,2 @@ component_getFactory component_getImplementationEnvironment -component_writeInfo diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hreg.cxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hreg.cxx index 6d2fe012b..2ae63c8fa 100644 --- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hreg.cxx +++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hreg.cxx @@ -43,9 +43,6 @@ using namespace com::sun::star::registry; // declaration of external RegEntry-functions defined by the service objects // -extern sal_Bool SAL_CALL Hyphenator_writeInfo( - void * /*pServiceManager*/, XRegistryKey * pRegistryKey ); - extern void * SAL_CALL Hyphenator_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, @@ -58,12 +55,6 @@ extern void * SAL_CALL Hyphenator_getFactory( extern "C" { -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, XRegistryKey * pRegistryKey ) -{ - return Hyphenator_writeInfo( pServiceManager, pRegistryKey ); -} - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) { diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphen.component b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphen.component new file mode 100644 index 000000000..aeae4c577 --- /dev/null +++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphen.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="org.openoffice.lingu.LibHnjHyphenator"> + <service name="com.sun.star.linguistic2.Hyphenator"/> + </implementation> +</component> diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx index 6e35c2039..95282ac0c 100644 --- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx +++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx @@ -41,13 +41,12 @@ #include <osl/mutex.hxx> #include <hyphen.h> - #include <hyphenimp.hxx> #include <linguistic/hyphdta.hxx> #include <rtl/ustring.hxx> - #include <rtl/ustrbuf.hxx> +#include <rtl/textenc.h> #include <linguistic/lngprops.hxx> #include <unotools/pathoptions.hxx> @@ -90,11 +89,10 @@ using ::rtl::OUString; Hyphenator::Hyphenator() : aEvtListeners ( GetLinguMutex() ) { - bDisposing = FALSE; + bDisposing = sal_False; pPropHelper = NULL; - aDicts = NULL; - numdict = 0; - + aDicts = NULL; + numdict = 0; } @@ -103,21 +101,22 @@ Hyphenator::~Hyphenator() if (pPropHelper) pPropHelper->RemoveAsPropListener(); - if ((numdict) && (aDicts)) { - for (int i=0; i < numdict; i++) { + 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; + if (aDicts) delete[] aDicts; aDicts = NULL; - numdict = 0; + numdict = 0; } PropertyHelper_Hyphen & Hyphenator::GetPropHelper_Impl() { - if (!pPropHelper) { Reference< XPropertySet > xPropSet( GetLinguProperties(), UNO_QUERY ); @@ -223,7 +222,7 @@ Sequence< Locale > SAL_CALL Hyphenator::getLocales() for (sal_Int32 i = 0; i < nLocales; ++i) { aDicts[k].aPtr = NULL; - aDicts[k].aEnc = 0; + aDicts[k].eEnc = RTL_TEXTENCODING_DONTKNOW; aDicts[k].aLoc = MsLangId::convertLanguageToLocale( MsLangId::convertIsoStringToLanguage( aDictIt->aLocaleNames[i] )); aDicts[k].apCC = new CharClass( aDicts[k].aLoc ); @@ -260,17 +259,17 @@ sal_Bool SAL_CALL Hyphenator::hasLocale(const Locale& rLocale) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!aSuppLocales.getLength()) getLocales(); const Locale *pLocale = aSuppLocales.getConstArray(); - INT32 nLen = aSuppLocales.getLength(); - for (INT32 i = 0; i < nLen; ++i) + sal_Int32 nLen = aSuppLocales.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) { if (rLocale == pLocale[i]) { - bRes = TRUE; + bRes = sal_True; break; } } @@ -278,240 +277,268 @@ sal_Bool SAL_CALL Hyphenator::hasLocale(const Locale& rLocale) } -Reference< XHyphenatedWord > SAL_CALL -Hyphenator::hyphenate( const ::rtl::OUString& aWord, - const ::com::sun::star::lang::Locale& aLocale, - sal_Int16 nMaxLeading, - const ::com::sun::star::beans::PropertyValues& aProperties ) - throw (com::sun::star::uno::RuntimeException, - com::sun::star::lang::IllegalArgumentException) +Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const ::rtl::OUString& aWord, + const ::com::sun::star::lang::Locale& aLocale, + sal_Int16 nMaxLeading, + const ::com::sun::star::beans::PropertyValues& aProperties ) + throw (com::sun::star::uno::RuntimeException, com::sun::star::lang::IllegalArgumentException) { int nHyphenationPos = -1; - int nHyphenationPosAlt = -1; - int nHyphenationPosAltHyph = -1; + int nHyphenationPosAlt = -1; + int nHyphenationPosAltHyph = -1; int wordlen; char *hyphens; - char *lcword; - int k = 0; + char *lcword; + int k = 0; - PropertyHelper_Hyphen & rHelper = GetPropHelper(); - rHelper.SetTmpPropVals(aProperties); + PropertyHelper_Hyphen & rHelper = GetPropHelper(); + rHelper.SetTmpPropVals(aProperties); sal_Int16 minTrail = rHelper.GetMinTrailing(); sal_Int16 minLead = rHelper.GetMinLeading(); sal_Int16 minLen = rHelper.GetMinWordLength(); HyphenDict *dict = NULL; - rtl_TextEncoding aEnc = 0; - CharClass * pCC = NULL; + rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; + CharClass * pCC = NULL; Reference< XHyphenatedWord > xRes; - k = -1; - for (int j = 0; j < numdict; j++) - if (aLocale == aDicts[j].aLoc) k = j; - - - // if we have a hyphenation dictionary matching this locale - if (k != -1) { + k = -1; + for (int j = 0; j < numdict; j++) + { + if (aLocale == aDicts[j].aLoc) + k = j; + } + // if we have a hyphenation dictionary matching this locale + if (k != -1) + { // if this dictinary has not been loaded yet do that - if (!aDicts[k].aPtr) { - - OUString DictFN = aDicts[k].aName + A2OU(".dic"); - OUString dictpath; + if (!aDicts[k].aPtr) + { + OUString DictFN = aDicts[k].aName + A2OU(".dic"); + OUString dictpath; - osl::FileBase::getSystemPathFromFileURL( DictFN, dictpath ); - OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); + osl::FileBase::getSystemPathFromFileURL( DictFN, dictpath ); + OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); #if defined(WNT) - // workaround for Windows specifc problem that the - // path length in calls to 'fopen' is limted to somewhat - // about 120+ characters which will usually be exceed when - // using dictionaries as extensions. - sTmp = Win_GetShortPathName( dictpath ); + // workaround for Windows specifc problem that the + // path length in calls to 'fopen' is limted to somewhat + // about 120+ characters which will usually be exceed when + // using dictionaries as extensions. + sTmp = Win_GetShortPathName( dictpath ); #endif - if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL ) - { - fprintf(stderr, "Couldn't find file %s\n", OU2ENC(dictpath, osl_getThreadTextEncoding()) ); - return NULL; - } - aDicts[k].aPtr = dict; - aDicts[k].aEnc = rtl_getTextEncodingFromUnixCharset(dict->cset); - if (aDicts[k].aEnc == RTL_TEXTENCODING_DONTKNOW) { - if (strcmp("ISCII-DEVANAGARI", dict->cset) == 0) { - aDicts[k].aEnc = RTL_TEXTENCODING_ISCII_DEVANAGARI; - } else if (strcmp("UTF-8", dict->cset) == 0) { - aDicts[k].aEnc = RTL_TEXTENCODING_UTF8; - } - } + if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL ) + { + fprintf(stderr, "Couldn't find file %s\n", OU2ENC(dictpath, osl_getThreadTextEncoding()) ); + return NULL; + } + aDicts[k].aPtr = dict; + aDicts[k].eEnc = getTextEncodingFromCharset(dict->cset); } - // other wise hyphenate the word with that dictionary - dict = aDicts[k].aPtr; - aEnc = aDicts[k].aEnc; - pCC = aDicts[k].apCC; + // other wise hyphenate the word with that dictionary + dict = aDicts[k].aPtr; + eEnc = aDicts[k].eEnc; + pCC = aDicts[k].apCC; + + // we don't want to work with a default text encoding since following incorrect + // results may occur only for specific text and thus may be hard to notice. + // Thus better always make a clean exit here if the text encoding is in question. + // Hopefully something not working at all will raise proper attention quickly. ;-) + DBG_ASSERT( eEnc != RTL_TEXTENCODING_DONTKNOW, "failed to get text encoding! (maybe incorrect encoding string in file)" ); + if (eEnc == RTL_TEXTENCODING_DONTKNOW) + return NULL; - sal_uInt16 ct = CAPTYPE_UNKNOWN; - ct = capitalType(aWord, pCC); + sal_uInt16 ct = CAPTYPE_UNKNOWN; + ct = capitalType(aWord, pCC); - // first convert any smart quotes or apostrophes to normal ones + // first convert any smart quotes or apostrophes to normal ones OUStringBuffer rBuf(aWord); - sal_Int32 nc = rBuf.getLength(); - sal_Unicode ch; - for (sal_Int32 ix=0; ix < nc; ix++) { + sal_Int32 nc = rBuf.getLength(); + sal_Unicode ch; + for (sal_Int32 ix=0; ix < nc; ix++) + { ch = rBuf.charAt(ix); - if ((ch == 0x201C) || (ch == 0x201D)) rBuf.setCharAt(ix,(sal_Unicode)0x0022); - if ((ch == 0x2018) || (ch == 0x2019)) rBuf.setCharAt(ix,(sal_Unicode)0x0027); - } - OUString nWord(rBuf.makeStringAndClear()); + if ((ch == 0x201C) || (ch == 0x201D)) + rBuf.setCharAt(ix,(sal_Unicode)0x0022); + if ((ch == 0x2018) || (ch == 0x2019)) + rBuf.setCharAt(ix,(sal_Unicode)0x0027); + } + OUString nWord(rBuf.makeStringAndClear()); - // now convert word to all lowercase for pattern recognition - OUString nTerm(makeLowerCase(nWord, pCC)); + // 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)); + // now convert word to needed encoding + OString encWord(OU2ENC(nTerm,eEnc)); wordlen = encWord.getLength(); - lcword = new char[wordlen + 1]; + 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()); - - // now strip off any ending periods - int n = wordlen-1; - while((n >=0) && (lcword[n] == '.')) n--; - n++; - if (n > 0) { - 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))))) - { - //whoops something did not work - delete[] hyphens; - delete[] lcword; - if (rep) { - for(int j = 0; j < n; j++) { + 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()); + + // now strip off any ending periods + int n = wordlen-1; + while((n >=0) && (lcword[n] == '.')) + n--; + n++; + if (n > 0) + { + const bool bFailed = 0 != 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))) ); + if (bFailed) + { + //whoops something did not work + 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; - } + } + if (pos) free(pos); + if (cut) free(cut); + return NULL; } + } - // now backfill hyphens[] for any removed trailing periods - for (int c = n; c < wordlen; c++) hyphens[c] = '0'; - hyphens[wordlen] = '\0'; + // now backfill hyphens[] for any removed trailing periods + for (int c = n; c < wordlen; c++) hyphens[c] = '0'; + hyphens[wordlen] = '\0'; - INT32 Leading = GetPosInWordToCheck( aWord, nMaxLeading ); + sal_Int32 Leading = GetPosInWordToCheck( aWord, nMaxLeading ); - for (INT32 i = 0; i < n; i++) + for (sal_Int32 i = 0; i < n; i++) { - int leftrep = 0; - BOOL hit = (n >= minLen); - if (!rep || !rep[i] || (i >= n)) { - hit = hit && (hyphens[i]&1) && (i < Leading); - hit = hit && (i >= (minLead-1) ); - hit = hit && ((n - i - 1) >= minTrail); - } else { - // calculate change character length before hyphenation point signed with '=' - for (char * c = rep[i]; *c && (*c != '='); c++) { - if (aEnc == RTL_TEXTENCODING_UTF8) { - if (((unsigned char) *c) >> 6 != 2) leftrep++; - } else leftrep++; - } - hit = hit && (hyphens[i]&1) && ((i + leftrep - pos[i]) < Leading); - hit = hit && ((i + leftrep - pos[i]) >= (minLead-1) ); - hit = hit && ((n - i - 1 + sal::static_int_cast< sal_sSize >(strlen(rep[i])) - leftrep - 1) >= minTrail); + int leftrep = 0; + sal_Bool hit = (n >= minLen); + if (!rep || !rep[i] || (i >= n)) + { + hit = hit && (hyphens[i]&1) && (i < Leading); + hit = hit && (i >= (minLead-1) ); + hit = hit && ((n - i - 1) >= minTrail); + } + else + { + // calculate change character length before hyphenation point signed with '=' + for (char * c = rep[i]; *c && (*c != '='); c++) + { + if (eEnc == RTL_TEXTENCODING_UTF8) + { + if (((unsigned char) *c) >> 6 != 2) + leftrep++; + } + else + leftrep++; } - if (hit) { - nHyphenationPos = i; - if (rep && (i < n) && rep[i]) { - nHyphenationPosAlt = i - pos[i]; - nHyphenationPosAltHyph = i + leftrep - pos[i]; - } + hit = hit && (hyphens[i]&1) && ((i + leftrep - pos[i]) < Leading); + hit = hit && ((i + leftrep - pos[i]) >= (minLead-1) ); + hit = hit && ((n - i - 1 + sal::static_int_cast< sal_sSize >(strlen(rep[i])) - leftrep - 1) >= minTrail); + } + if (hit) + { + nHyphenationPos = i; + if (rep && (i < n) && rep[i]) + { + nHyphenationPosAlt = i - pos[i]; + nHyphenationPosAltHyph = i + leftrep - pos[i]; } - } - - if (nHyphenationPos == -1) { - xRes = NULL; - } else { - if (rep && rep[nHyphenationPos]) { - // remove equal sign - char * s = rep[nHyphenationPos]; - int eq = 0; - for (; *s; s++) { - if (*s == '=') eq = 1; - if (eq) *s = *(s + 1); - } - OUString repHyphlow(rep[nHyphenationPos], strlen(rep[nHyphenationPos]), aEnc); - OUString repHyph; - switch (ct) { - case CAPTYPE_ALLCAP: - { - repHyph = makeUpperCase(repHyphlow, pCC); - break; - } - case CAPTYPE_INITCAP: - { - if (nHyphenationPosAlt == 0) { - repHyph = makeInitCap(repHyphlow, pCC); - } else { - repHyph = repHyphlow; - } - break; - } - default: - { - repHyph = repHyphlow; - break; - } } + } - // handle shortening - INT16 nPos = (INT16) ((nHyphenationPosAltHyph < nHyphenationPos) ? - nHyphenationPosAltHyph : nHyphenationPos); - // dicretionary hyphenation + if (nHyphenationPos == -1) + { + xRes = NULL; + } + else + { + if (rep && rep[nHyphenationPos]) + { + // remove equal sign + char * s = rep[nHyphenationPos]; + int eq = 0; + for (; *s; s++) + { + if (*s == '=') eq = 1; + if (eq) *s = *(s + 1); + } + OUString repHyphlow(rep[nHyphenationPos], strlen(rep[nHyphenationPos]), eEnc); + OUString repHyph; + switch (ct) + { + case CAPTYPE_ALLCAP: + { + repHyph = makeUpperCase(repHyphlow, pCC); + break; + } + case CAPTYPE_INITCAP: + { + if (nHyphenationPosAlt == 0) + repHyph = makeInitCap(repHyphlow, pCC); + else + repHyph = repHyphlow; + break; + } + default: + { + repHyph = repHyphlow; + break; + } + } + + // handle shortening + sal_Int16 nPos = (sal_Int16) ((nHyphenationPosAltHyph < nHyphenationPos) ? + nHyphenationPosAltHyph : nHyphenationPos); + // dicretionary hyphenation xRes = new HyphenatedWord( aWord, LocaleToLanguage( aLocale ), nPos, - aWord.replaceAt(nHyphenationPosAlt + 1, cut[nHyphenationPos], repHyph), - (INT16) nHyphenationPosAltHyph); - } else { + aWord.replaceAt(nHyphenationPosAlt + 1, cut[nHyphenationPos], repHyph), + (sal_Int16) nHyphenationPosAltHyph); + } + else + { xRes = new HyphenatedWord( aWord, LocaleToLanguage( aLocale ), - (INT16)nHyphenationPos, aWord, (INT16) nHyphenationPos); - } + (sal_Int16)nHyphenationPos, aWord, (sal_Int16) nHyphenationPos); + } } - delete[] lcword; + delete[] lcword; delete[] hyphens; - if (rep) { - for(int j = 0; j < n; j++) { - if (rep[j]) free(rep[j]); - } - free(rep); + if (rep) + { + for(int j = 0; j < n; j++) + { + if (rep[j]) free(rep[j]); } - if (pos) free(pos); - if (cut) free(cut); + free(rep); + } + if (pos) free(pos); + if (cut) free(cut); return xRes; } - return NULL; + return NULL; } -Reference < XHyphenatedWord > SAL_CALL - Hyphenator::queryAlternativeSpelling( const ::rtl::OUString& /*aWord*/, - const ::com::sun::star::lang::Locale& /*aLocale*/, - sal_Int16 /*nIndex*/, - const ::com::sun::star::beans::PropertyValues& /*aProperties*/ ) - throw(::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) +Reference < XHyphenatedWord > SAL_CALL Hyphenator::queryAlternativeSpelling( + const ::rtl::OUString& /*aWord*/, + const ::com::sun::star::lang::Locale& /*aLocale*/, + sal_Int16 /*nIndex*/, + const ::com::sun::star::beans::PropertyValues& /*aProperties*/ ) + throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { /* alternative spelling isn't supported by tex dictionaries */ /* XXX: OOo's extended libhjn algorithm can support alternative spellings with extended TeX dic. */ @@ -519,252 +546,263 @@ Reference < XHyphenatedWord > SAL_CALL return NULL; } -Reference< XPossibleHyphens > SAL_CALL - Hyphenator::createPossibleHyphens( const ::rtl::OUString& aWord, - const ::com::sun::star::lang::Locale& aLocale, - const ::com::sun::star::beans::PropertyValues& aProperties ) - throw(::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) - +Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const ::rtl::OUString& aWord, + const ::com::sun::star::lang::Locale& aLocale, + const ::com::sun::star::beans::PropertyValues& aProperties ) + throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - int wordlen; - char *hyphens; - char *lcword; - int k; + int wordlen; + char *hyphens; + char *lcword; + int k; - PropertyHelper_Hyphen & rHelper = GetPropHelper(); - rHelper.SetTmpPropVals(aProperties); - sal_Int16 minTrail = rHelper.GetMinTrailing(); - sal_Int16 minLead = rHelper.GetMinLeading(); + PropertyHelper_Hyphen & rHelper = GetPropHelper(); + rHelper.SetTmpPropVals(aProperties); + sal_Int16 minTrail = rHelper.GetMinTrailing(); + sal_Int16 minLead = rHelper.GetMinLeading(); - HyphenDict *dict = NULL; - rtl_TextEncoding aEnc = 0; - CharClass* pCC = NULL; + HyphenDict *dict = NULL; + rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; + CharClass* pCC = NULL; - Reference< XPossibleHyphens > xRes; + Reference< XPossibleHyphens > xRes; - k = -1; - for (int j = 0; j < numdict; j++) - if (aLocale == aDicts[j].aLoc) k = j; + k = -1; + for (int j = 0; j < numdict; j++) + { + if (aLocale == aDicts[j].aLoc) k = j; + } + // if we have a hyphenation dictionary matching this locale + if (k != -1) + { + // if this dictioanry has not been loaded yet do that + if (!aDicts[k].aPtr) + { + OUString DictFN = aDicts[k].aName + A2OU(".dic"); + OUString dictpath; - // if we have a hyphenation dictionary matching this locale - if (k != -1) { + osl::FileBase::getSystemPathFromFileURL( DictFN, dictpath ); + OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); - // if this dictioanry has not been loaded yet do that - if (!aDicts[k].aPtr) { +#if defined(WNT) + // workaround for Windows specifc problem that the + // path length in calls to 'fopen' is limted to somewhat + // about 120+ characters which will usually be exceed when + // using dictionaries as extensions. + sTmp = Win_GetShortPathName( dictpath ); +#endif - OUString DictFN = aDicts[k].aName + A2OU(".dic"); - OUString dictpath; + if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL ) + { + fprintf(stderr, "Couldn't find file %s and %s\n", sTmp.getStr(), OU2ENC(dictpath, osl_getThreadTextEncoding()) ); + return NULL; + } + aDicts[k].aPtr = dict; + aDicts[k].eEnc = getTextEncodingFromCharset(dict->cset); + } - osl::FileBase::getSystemPathFromFileURL( DictFN, dictpath ); - OString sTmp( OU2ENC( dictpath, osl_getThreadTextEncoding() ) ); + // other wise hyphenate the word with that dictionary + dict = aDicts[k].aPtr; + eEnc = aDicts[k].eEnc; + pCC = aDicts[k].apCC; -#if defined(WNT) - // workaround for Windows specifc problem that the - // path length in calls to 'fopen' is limted to somewhat - // about 120+ characters which will usually be exceed when - // using dictionaries as extensions. - sTmp = Win_GetShortPathName( dictpath ); -#endif + // we don't want to work with a default text encoding since following incorrect + // results may occur only for specific text and thus may be hard to notice. + // Thus better always make a clean exit here if the text encoding is in question. + // Hopefully something not working at all will raise proper attention quickly. ;-) + DBG_ASSERT( eEnc != RTL_TEXTENCODING_DONTKNOW, "failed to get text encoding! (maybe incorrect encoding string in file)" ); + if (eEnc == RTL_TEXTENCODING_DONTKNOW) + return NULL; - if ( ( dict = hnj_hyphen_load ( sTmp.getStr()) ) == NULL ) + // first handle smart quotes both single and double + OUStringBuffer rBuf(aWord); + sal_Int32 nc = rBuf.getLength(); + sal_Unicode ch; + for (sal_Int32 ix=0; ix < nc; ix++) { - fprintf(stderr, "Couldn't find file %s and %s\n", sTmp.getStr(), OU2ENC(dictpath, osl_getThreadTextEncoding()) ); - return NULL; + ch = rBuf.charAt(ix); + if ((ch == 0x201C) || (ch == 0x201D)) + rBuf.setCharAt(ix,(sal_Unicode)0x0022); + if ((ch == 0x2018) || (ch == 0x2019)) + rBuf.setCharAt(ix,(sal_Unicode)0x0027); } - aDicts[k].aPtr = dict; - aDicts[k].aEnc = rtl_getTextEncodingFromUnixCharset(dict->cset); - if (aDicts[k].aEnc == RTL_TEXTENCODING_DONTKNOW) { - if (strcmp("ISCII-DEVANAGARI", dict->cset) == 0) { - aDicts[k].aEnc = RTL_TEXTENCODING_ISCII_DEVANAGARI; - } else if (strcmp("UTF-8", dict->cset) == 0) { - aDicts[k].aEnc = RTL_TEXTENCODING_UTF8; + 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(nTerm,eEnc)); + + 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()); + + // first remove any trailing periods + int n = wordlen-1; + while((n >=0) && (lcword[n] == '.')) + n--; + n++; + if (n > 0) + { + const bool bFailed = 0 != 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))) ); + if (bFailed) + { + 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; } - } - } - - // 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); - sal_Int32 nc = rBuf.getLength(); - sal_Unicode ch; - for (sal_Int32 ix=0; ix < nc; ix++) { - ch = rBuf.charAt(ix); - if ((ch == 0x201C) || (ch == 0x201D)) rBuf.setCharAt(ix,(sal_Unicode)0x0022); - if ((ch == 0x2018) || (ch == 0x2019)) rBuf.setCharAt(ix,(sal_Unicode)0x0027); - } - 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(nTerm,aEnc)); - - 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()); - - // first remove any trailing periods - int n = wordlen-1; - while((n >=0) && (lcword[n] == '.')) n--; - n++; - if (n > 0) { - 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; - } - } - // now backfill hyphens[] for any removed periods - for (int c = n; c < wordlen; c++) hyphens[c] = '0'; - hyphens[wordlen] = '\0'; - - INT16 nHyphCount = 0; - INT16 i; - - for ( i = 0; i < encWord.getLength(); i++) - if (hyphens[i]&1 && (!rep || !rep[i])) - nHyphCount++; - - Sequence< INT16 > aHyphPos(nHyphCount); - INT16 *pPos = aHyphPos.getArray(); - OUStringBuffer hyphenatedWordBuffer; - OUString hyphenatedWord; - nHyphCount = 0; - - for (i = 0; i < nWord.getLength(); i++) { - hyphenatedWordBuffer.append(aWord[i]); - // hyphenation position (not alternative) - if (hyphens[i]&1 && (!rep || !rep[i])) { - pPos[nHyphCount] = i; - hyphenatedWordBuffer.append(sal_Unicode('=')); - nHyphCount++; - } - } - - hyphenatedWord = hyphenatedWordBuffer.makeStringAndClear(); - - xRes = new PossibleHyphens( aWord, LocaleToLanguage( aLocale ), - hyphenatedWord, aHyphPos ); - - 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; - } + } + // now backfill hyphens[] for any removed periods + for (int c = n; c < wordlen; c++) + hyphens[c] = '0'; + hyphens[wordlen] = '\0'; - return NULL; + sal_Int16 nHyphCount = 0; + sal_Int16 i; + for ( i = 0; i < encWord.getLength(); i++) + { + if (hyphens[i]&1 && (!rep || !rep[i])) + nHyphCount++; + } + + Sequence< sal_Int16 > aHyphPos(nHyphCount); + sal_Int16 *pPos = aHyphPos.getArray(); + OUStringBuffer hyphenatedWordBuffer; + OUString hyphenatedWord; + nHyphCount = 0; + + for (i = 0; i < nWord.getLength(); i++) + { + hyphenatedWordBuffer.append(aWord[i]); + // hyphenation position (not alternative) + if (hyphens[i]&1 && (!rep || !rep[i])) + { + pPos[nHyphCount] = i; + hyphenatedWordBuffer.append(sal_Unicode('=')); + nHyphCount++; + } + } + + hyphenatedWord = hyphenatedWordBuffer.makeStringAndClear(); + + xRes = new PossibleHyphens( aWord, LocaleToLanguage( aLocale ), + hyphenatedWord, aHyphPos ); + + 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; + } + + return NULL; } sal_uInt16 SAL_CALL Hyphenator::capitalType(const OUString& aTerm, CharClass * pCC) { - sal_Int32 tlen = aTerm.getLength(); - if ((pCC) && (tlen)) { - String aStr(aTerm); - sal_Int32 nc = 0; - for (xub_StrLen tindex = 0; tindex < tlen; tindex++) { - if (pCC->getCharacterType(aStr,tindex) & - ::com::sun::star::i18n::KCharacterType::UPPER) nc++; - } - - if (nc == 0) return (sal_uInt16) CAPTYPE_NOCAP; - - if (nc == tlen) return (sal_uInt16) CAPTYPE_ALLCAP; + sal_Int32 tlen = aTerm.getLength(); + if ((pCC) && (tlen)) + { + String aStr(aTerm); + sal_Int32 nc = 0; + for (xub_StrLen tindex = 0; tindex < tlen; tindex++) + { + if (pCC->getCharacterType(aStr,tindex) & ::com::sun::star::i18n::KCharacterType::UPPER) + nc++; + } - if ((nc == 1) && (pCC->getCharacterType(aStr,0) & - ::com::sun::star::i18n::KCharacterType::UPPER)) - return (sal_uInt16) CAPTYPE_INITCAP; + if (nc == 0) + return (sal_uInt16) CAPTYPE_NOCAP; + if (nc == tlen) + return (sal_uInt16) CAPTYPE_ALLCAP; + if ((nc == 1) && (pCC->getCharacterType(aStr,0) & ::com::sun::star::i18n::KCharacterType::UPPER)) + return (sal_uInt16) CAPTYPE_INITCAP; - return (sal_uInt16) CAPTYPE_MIXED; + return (sal_uInt16) CAPTYPE_MIXED; } - return (sal_uInt16) CAPTYPE_UNKNOWN; + return (sal_uInt16) CAPTYPE_UNKNOWN; } OUString SAL_CALL Hyphenator::makeLowerCase(const OUString& aTerm, CharClass * pCC) { - if (pCC) - return pCC->toLower_rtl(aTerm, 0, aTerm.getLength()); - return aTerm; + if (pCC) + return pCC->toLower_rtl(aTerm, 0, aTerm.getLength()); + return aTerm; } OUString SAL_CALL Hyphenator::makeUpperCase(const OUString& aTerm, CharClass * pCC) { - if (pCC) - return pCC->toUpper_rtl(aTerm, 0, aTerm.getLength()); - return aTerm; + if (pCC) + return pCC->toUpper_rtl(aTerm, 0, aTerm.getLength()); + return aTerm; } OUString SAL_CALL Hyphenator::makeInitCap(const OUString& aTerm, CharClass * pCC) { - sal_Int32 tlen = aTerm.getLength(); - if ((pCC) && (tlen)) { - OUString bTemp = aTerm.copy(0,1); - if (tlen > 1) - return ( pCC->toUpper_rtl(bTemp, 0, 1) - + pCC->toLower_rtl(aTerm,1,(tlen-1)) ); - - return pCC->toUpper_rtl(bTemp, 0, 1); + sal_Int32 tlen = aTerm.getLength(); + if ((pCC) && (tlen)) + { + OUString bTemp = aTerm.copy(0,1); + if (tlen > 1) + return ( pCC->toUpper_rtl(bTemp, 0, 1) + pCC->toLower_rtl(aTerm,1,(tlen-1)) ); + + return pCC->toUpper_rtl(bTemp, 0, 1); } - return aTerm; + return aTerm; } - - Reference< XInterface > SAL_CALL Hyphenator_CreateInstance( - const Reference< XMultiServiceFactory > & /*rSMgr*/ ) + const Reference< XMultiServiceFactory > & /*rSMgr*/ ) throw(Exception) { - Reference< XInterface > xService = (cppu::OWeakObject*) new Hyphenator; return xService; } -sal_Bool SAL_CALL - Hyphenator::addLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) +sal_Bool SAL_CALL Hyphenator::addLinguServiceEventListener( + const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bDisposing && rxLstnr.is()) { bRes = GetPropHelper().addLinguServiceEventListener( rxLstnr ); @@ -773,14 +811,13 @@ sal_Bool SAL_CALL } -sal_Bool SAL_CALL - Hyphenator::removeLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) +sal_Bool SAL_CALL Hyphenator::removeLinguServiceEventListener( + const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bDisposing && rxLstnr.is()) { DBG_ASSERT( xPropHelper.is(), "xPropHelper non existent" ); @@ -790,8 +827,7 @@ sal_Bool SAL_CALL } -OUString SAL_CALL - Hyphenator::getServiceDisplayName( const Locale& /*rLocale*/ ) +OUString SAL_CALL Hyphenator::getServiceDisplayName( const Locale& /*rLocale*/ ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -799,15 +835,14 @@ OUString SAL_CALL } -void SAL_CALL - Hyphenator::initialize( const Sequence< Any >& rArguments ) +void SAL_CALL Hyphenator::initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); if (!pPropHelper) { - INT32 nLen = rArguments.getLength(); + sal_Int32 nLen = rArguments.getLength(); if (2 == nLen) { Reference< XPropertySet > xPropSet; @@ -825,28 +860,25 @@ void SAL_CALL else { OSL_FAIL( "wrong number of arguments in sequence" ); } - } } -void SAL_CALL - Hyphenator::dispose() +void SAL_CALL Hyphenator::dispose() throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); if (!bDisposing) { - bDisposing = TRUE; + bDisposing = sal_True; EventObject aEvtObj( (XHyphenator *) this ); aEvtListeners.disposeAndClear( aEvtObj ); } } -void SAL_CALL - Hyphenator::addEventListener( const Reference< XEventListener >& rxListener ) +void SAL_CALL Hyphenator::addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -856,8 +888,7 @@ void SAL_CALL } -void SAL_CALL - Hyphenator::removeEventListener( const Reference< XEventListener >& rxListener ) +void SAL_CALL Hyphenator::removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -887,10 +918,10 @@ sal_Bool SAL_CALL Hyphenator::supportsService( const OUString& ServiceName ) Sequence< OUString > aSNL = getSupportedServiceNames(); const OUString * pArray = aSNL.getConstArray(); - for( INT32 i = 0; i < aSNL.getLength(); i++ ) + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) if( pArray[i] == ServiceName ) - return TRUE; - return FALSE; + return sal_True; + return sal_False; } @@ -913,32 +944,6 @@ Sequence< OUString > Hyphenator::getSupportedServiceNames_Static() return aSNS; } - -sal_Bool SAL_CALL Hyphenator_writeInfo( - void * /*pServiceManager*/, registry::XRegistryKey * pRegistryKey ) -{ - - try - { - String aImpl( '/' ); - aImpl += Hyphenator::getImplementationName_Static().getStr(); - aImpl.AppendAscii( "/UNO/SERVICES" ); - Reference< registry::XRegistryKey > xNewKey = - pRegistryKey->createKey( aImpl ); - Sequence< OUString > aServices = - Hyphenator::getSupportedServiceNames_Static(); - for( INT32 i = 0; i < aServices.getLength(); i++ ) - xNewKey->createKey( aServices.getConstArray()[i] ); - - return sal_True; - } - catch(Exception &) - { - return sal_False; - } -} - - void * SAL_CALL Hyphenator_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx index d7456abc1..e0e984908 100644 --- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx +++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx @@ -66,7 +66,7 @@ struct HDInfo { HyphenDict * aPtr; OUString aName; Locale aLoc; - rtl_TextEncoding aEnc; + rtl_TextEncoding eEnc; CharClass * apCC; }; @@ -84,14 +84,14 @@ class Hyphenator : > { Sequence< Locale > aSuppLocales; - HDInfo * aDicts; - sal_Int32 numdict; + HDInfo * aDicts; + sal_Int32 numdict; ::cppu::OInterfaceContainerHelper aEvtListeners; Reference< XPropertyChangeListener > xPropHelper; - Reference< XMultiServiceFactory > rSMgr; + Reference< XMultiServiceFactory > rSMgr; linguistic::PropertyHelper_Hyphen * pPropHelper; - BOOL bDisposing; + sal_Bool bDisposing; // disallow copy-constructor and assignment-operator for now Hyphenator(const Hyphenator &); @@ -109,88 +109,38 @@ public: virtual ~Hyphenator(); // XSupportedLocales (for XHyphenator) - virtual Sequence< Locale > SAL_CALL getLocales() - throw(RuntimeException); - virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) - throw(RuntimeException); + virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException); + virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException); // XHyphenator - virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL - hyphenate( const ::rtl::OUString& aWord, - const ::com::sun::star::lang::Locale& aLocale, - sal_Int16 nMaxLeading, - const ::com::sun::star::beans::PropertyValues& aProperties ) - throw(::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL - queryAlternativeSpelling( const ::rtl::OUString& aWord, - const ::com::sun::star::lang::Locale& aLocale, - sal_Int16 nIndex, - const ::com::sun::star::beans::PropertyValues& aProperties ) - throw(::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL - createPossibleHyphens( const ::rtl::OUString& aWord, - const ::com::sun::star::lang::Locale& aLocale, - const ::com::sun::star::beans::PropertyValues& aProperties ) - throw(::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL hyphenate( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nMaxLeading, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL queryAlternativeSpelling( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nIndex, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL createPossibleHyphens( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); // XLinguServiceEventBroadcaster - virtual sal_Bool SAL_CALL - addLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) - throw(RuntimeException); - virtual sal_Bool SAL_CALL - removeLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) - throw(RuntimeException); + virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); + virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); // XServiceDisplayName - virtual OUString SAL_CALL - getServiceDisplayName( const Locale& rLocale ) - throw(RuntimeException); + virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException); // XInitialization - virtual void SAL_CALL - initialize( const Sequence< Any >& rArguments ) - throw(Exception, RuntimeException); + virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException); // XComponent - virtual void SAL_CALL - dispose() - throw(RuntimeException); - virtual void SAL_CALL - addEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - virtual void SAL_CALL - removeEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - - //////////////////////////////////////////////////////////// - // Service specific part - // + virtual void SAL_CALL dispose() throw(RuntimeException); + virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); + virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); // XServiceInfo - virtual OUString SAL_CALL - getImplementationName() - throw(RuntimeException); - virtual sal_Bool SAL_CALL - supportsService( const OUString& rServiceName ) - throw(RuntimeException); - virtual Sequence< OUString > SAL_CALL - getSupportedServiceNames() - throw(RuntimeException); - - - static inline OUString - getImplementationName_Static() throw(); - static Sequence< OUString > - getSupportedServiceNames_Static() throw(); + virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); + static inline OUString getImplementationName_Static() throw(); + static Sequence< OUString > getSupportedServiceNames_Static() throw(); + private: sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *); diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk index d2972e70b..bc5d1ae66 100644 --- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk +++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/makefile.mk @@ -91,3 +91,11 @@ DEF1EXPORTFILE= exports.dxp .INCLUDE : target.mk + +ALLTAR : $(MISC)/hyphen.component + +$(MISC)/hyphen.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + hyphen.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt hyphen.component diff --git a/lingucomponent/source/languageguessing/guesslang.component b/lingucomponent/source/languageguessing/guesslang.component new file mode 100644 index 000000000..633a489c3 --- /dev/null +++ b/lingucomponent/source/languageguessing/guesslang.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.lingu2.LanguageGuessing"> + <service name="com.sun.star.linguistic2.LanguageGuessing"/> + </implementation> +</component> diff --git a/lingucomponent/source/languageguessing/guesslang.cxx b/lingucomponent/source/languageguessing/guesslang.cxx index 7c7751904..bc942e32a 100644 --- a/lingucomponent/source/languageguessing/guesslang.cxx +++ b/lingucomponent/source/languageguessing/guesslang.cxx @@ -428,13 +428,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -sal_Bool SAL_CALL component_writeInfo( - XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry ) -{ - return ::cppu::component_writeInfoHelper( - xMgr, xRegistry, s_component_entries ); -} - void * SAL_CALL component_getFactory( sal_Char const * implName, lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry ) diff --git a/lingucomponent/source/languageguessing/makefile.mk b/lingucomponent/source/languageguessing/makefile.mk index ebad4076b..624ccba3c 100644 --- a/lingucomponent/source/languageguessing/makefile.mk +++ b/lingucomponent/source/languageguessing/makefile.mk @@ -78,3 +78,11 @@ DEF1NAME =$(SHL1TARGET) .INCLUDE : target.mk + +ALLTAR : $(MISC)/guesslang.component + +$(MISC)/guesslang.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + guesslang.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt guesslang.component diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx index 5e8b0489f..0f286292b 100644..100755 --- a/lingucomponent/source/lingutil/lingutil.cxx +++ b/lingucomponent/source/lingutil/lingutil.cxx @@ -51,6 +51,7 @@ #include <unotools/pathoptions.hxx> #include <rtl/ustring.hxx> #include <rtl/string.hxx> +#include <rtl/tencinfo.h> #include <linguistic/misc.hxx> #include <set> @@ -263,6 +264,26 @@ void MergeNewStyleDicsAndOldStyleDics( } } + +rtl_TextEncoding getTextEncodingFromCharset(const sal_Char* pCharset) +{ + // default result: used to indicate that we failed to get the proper encoding + rtl_TextEncoding eRet = RTL_TEXTENCODING_DONTKNOW; + + if (pCharset) + { + eRet = rtl_getTextEncodingFromMimeCharset(pCharset); + if (eRet == RTL_TEXTENCODING_DONTKNOW) + eRet = rtl_getTextEncodingFromUnixCharset(pCharset); + if (eRet == RTL_TEXTENCODING_DONTKNOW) + { + if (strcmp("ISCII-DEVANAGARI", pCharset) == 0) + eRet = RTL_TEXTENCODING_ISCII_DEVANAGARI; + } + } + return eRet; +} + ////////////////////////////////////////////////////////////////////// /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lingucomponent/source/lingutil/lingutil.hxx b/lingucomponent/source/lingutil/lingutil.hxx index 7ddb50b7c..53f322d80 100644 --- a/lingucomponent/source/lingutil/lingutil.hxx +++ b/lingucomponent/source/lingutil/lingutil.hxx @@ -72,7 +72,7 @@ struct lt_rtl_OUString } }; -inline BOOL operator == ( const ::com::sun::star::lang::Locale &rL1, const ::com::sun::star::lang::Locale &rL2 ) +inline sal_Bool operator == ( const ::com::sun::star::lang::Locale &rL1, const ::com::sun::star::lang::Locale &rL2 ) { return rL1.Language == rL2.Language && rL1.Country == rL2.Country && @@ -104,6 +104,14 @@ void MergeNewStyleDicsAndOldStyleDics( std::list< SvtLinguConfigDictionaryEntry /////////////////////////////////////////////////////////////////////////// + +//Find an encoding from a charset string, using +//rtl_getTextEncodingFromMimeCharset and falling back to +//rtl_getTextEncodingFromUnixCharset with the addition of +//ISCII-DEVANAGARI. On failure will return final fallback of +//RTL_TEXTENCODING_ISO_8859_1 +rtl_TextEncoding getTextEncodingFromCharset(const sal_Char* pCharset); + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lingucomponent/source/spellcheck/macosxspell/MacOSXSpell.component b/lingucomponent/source/spellcheck/macosxspell/MacOSXSpell.component new file mode 100644 index 000000000..2f2f9e102 --- /dev/null +++ b/lingucomponent/source/spellcheck/macosxspell/MacOSXSpell.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="org.openoffice.lingu.MacOSXSpellChecker"> + <service name="com.sun.star.linguistic2.SpellChecker"/> + </implementation> +</component> diff --git a/lingucomponent/source/spellcheck/macosxspell/macreg.cxx b/lingucomponent/source/spellcheck/macosxspell/macreg.cxx index 5284fcac8..f3b3d8586 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macreg.cxx +++ b/lingucomponent/source/spellcheck/macosxspell/macreg.cxx @@ -42,9 +42,6 @@ using namespace com::sun::star::registry; // declaration of external RegEntry-functions defined by the service objects // -extern sal_Bool SAL_CALL MacSpellChecker_writeInfo( - void * /*pServiceManager*/, XRegistryKey * pRegistryKey ); - extern void * SAL_CALL MacSpellChecker_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, @@ -57,12 +54,6 @@ extern void * SAL_CALL MacSpellChecker_getFactory( extern "C" { -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, XRegistryKey * pRegistryKey ) -{ - return MacSpellChecker_writeInfo( pServiceManager, pRegistryKey ); -} - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) { diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx b/lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx index 2686d37cb..fd9004e28 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx +++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx @@ -100,7 +100,7 @@ MacSpellChecker::MacSpellChecker() : aDEncs = NULL; aDLocs = NULL; aDNames = NULL; - bDisposing = FALSE; + bDisposing = sal_False; pPropHelper = NULL; numdict = 0; NSApplicationLoad(); @@ -249,17 +249,17 @@ sal_Bool SAL_CALL MacSpellChecker::hasLocale(const Locale& rLocale) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!aSuppLocales.getLength()) getLocales(); - INT32 nLen = aSuppLocales.getLength(); - for (INT32 i = 0; i < nLen; ++i) + sal_Int32 nLen = aSuppLocales.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) { const Locale *pLocale = aSuppLocales.getConstArray(); if (rLocale == pLocale[i]) { - bRes = TRUE; + bRes = sal_True; break; } } @@ -267,7 +267,7 @@ sal_Bool SAL_CALL MacSpellChecker::hasLocale(const Locale& rLocale) } -INT16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale ) +sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale ) { rtl_TextEncoding aEnc; @@ -275,7 +275,7 @@ INT16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLo // (note: mutex is held higher up in isValid) - INT16 nRes = -1; + sal_Int16 nRes = -1; // first handle smart quotes both single and double OUStringBuffer rBuf(rWord); @@ -304,7 +304,7 @@ INT16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLo } int aCount; - NSRange range = [macSpell checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:FALSE inSpellDocumentWithTag:macTag wordCount:&aCount]; + NSRange range = [macSpell checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:sal_False inSpellDocumentWithTag:macTag wordCount:&aCount]; int rVal = 0; if(range.length>0) { @@ -335,13 +335,13 @@ sal_Bool SAL_CALL MutexGuard aGuard( GetLinguMutex() ); if (rLocale == Locale() || !rWord.getLength()) - return TRUE; + return sal_True; if (!hasLocale( rLocale )) #ifdef LINGU_EXCEPTIONS throw( IllegalArgumentException() ); #else - return TRUE; + return sal_True; #endif // Get property values to be used. @@ -354,10 +354,10 @@ sal_Bool SAL_CALL PropertyHelper_Spell &rHelper = GetPropHelper(); rHelper.SetTmpPropVals( rProperties ); - INT16 nFailure = GetSpellFailure( rWord, rLocale ); + sal_Int16 nFailure = GetSpellFailure( rWord, rLocale ); if (nFailure != -1) { - INT16 nLang = LocaleToLanguage( rLocale ); + sal_Int16 nLang = LocaleToLanguage( rLocale ); // postprocess result for errors that should be ignored if ( (!rHelper.IsSpellUpperCase() && IsUpper( rWord, nLang )) || (!rHelper.IsSpellWithDigits() && HasDigits( rWord )) @@ -381,7 +381,7 @@ Reference< XSpellAlternatives > Reference< XSpellAlternatives > xRes; // note: mutex is held by higher up by spell which covers both - INT16 nLang = LocaleToLanguage( rLocale ); + sal_Int16 nLang = LocaleToLanguage( rLocale ); int count; Sequence< OUString > aStr( 0 ); @@ -484,7 +484,7 @@ sal_Bool SAL_CALL { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bDisposing && rxLstnr.is()) { bRes = GetPropHelper().addLinguServiceEventListener( rxLstnr ); @@ -500,7 +500,7 @@ sal_Bool SAL_CALL { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bDisposing && rxLstnr.is()) { DBG_ASSERT( xPropHelper.is(), "xPropHelper non existent" ); @@ -527,7 +527,7 @@ void SAL_CALL if (!pPropHelper) { - INT32 nLen = rArguments.getLength(); + sal_Int32 nLen = rArguments.getLength(); if (2 == nLen) { Reference< XPropertySet > xPropSet; @@ -557,7 +557,7 @@ void SAL_CALL if (!bDisposing) { - bDisposing = TRUE; + bDisposing = sal_True; EventObject aEvtObj( (XSpellChecker *) this ); aEvtListeners.disposeAndClear( aEvtObj ); } @@ -606,10 +606,10 @@ sal_Bool SAL_CALL MacSpellChecker::supportsService( const OUString& ServiceName Sequence< OUString > aSNL = getSupportedServiceNames(); const OUString * pArray = aSNL.getConstArray(); - for( INT32 i = 0; i < aSNL.getLength(); i++ ) + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) if( pArray[i] == ServiceName ) - return TRUE; - return FALSE; + return sal_True; + return sal_False; } @@ -632,32 +632,6 @@ Sequence< OUString > MacSpellChecker::getSupportedServiceNames_Static() return aSNS; } - -sal_Bool SAL_CALL MacSpellChecker_writeInfo( - void * /*pServiceManager*/, registry::XRegistryKey * pRegistryKey ) -{ - - try - { - String aImpl( '/' ); - aImpl += MacSpellChecker::getImplementationName_Static().getStr(); - aImpl.AppendAscii( "/UNO/SERVICES" ); - Reference< registry::XRegistryKey > xNewKey = - pRegistryKey->createKey( aImpl ); - Sequence< OUString > aServices = - MacSpellChecker::getSupportedServiceNames_Static(); - for( INT32 i = 0; i < aServices.getLength(); i++ ) - xNewKey->createKey( aServices.getConstArray()[i] ); - - return sal_True; - } - catch(Exception &) - { - return sal_False; - } -} - - void * SAL_CALL MacSpellChecker_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx b/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx index a831b9913..7e20d332c 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx +++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.hxx @@ -77,19 +77,19 @@ class MacSpellChecker : XServiceDisplayName > { - Sequence< Locale > aSuppLocales; + Sequence< Locale > aSuppLocales; // Hunspell ** aDicts; - rtl_TextEncoding * aDEncs; - Locale * aDLocs; - OUString * aDNames; - sal_Int32 numdict; - NSSpellChecker * macSpell; - int macTag; //unique tag for this doc + rtl_TextEncoding * aDEncs; + Locale * aDLocs; + OUString * aDNames; + sal_Int32 numdict; + NSSpellChecker * macSpell; + int macTag; //unique tag for this doc ::cppu::OInterfaceContainerHelper aEvtListeners; Reference< XPropertyChangeListener > xPropHelper; linguistic::PropertyHelper_Spell * pPropHelper; - BOOL bDisposing; + sal_Bool bDisposing; // disallow copy-constructor and assignment-operator for now MacSpellChecker(const MacSpellChecker &); @@ -101,85 +101,44 @@ class MacSpellChecker : return pPropHelper ? *pPropHelper : GetPropHelper_Impl(); } - INT16 GetSpellFailure( const OUString &rWord, const Locale &rLocale ); - Reference< XSpellAlternatives > - GetProposals( const OUString &rWord, const Locale &rLocale ); + sal_Int16 GetSpellFailure( const OUString &rWord, const Locale &rLocale ); + Reference< XSpellAlternatives > GetProposals( const OUString &rWord, const Locale &rLocale ); public: MacSpellChecker(); virtual ~MacSpellChecker(); // XSupportedLocales (for XSpellChecker) - virtual Sequence< Locale > SAL_CALL - getLocales() - throw(RuntimeException); - virtual sal_Bool SAL_CALL - hasLocale( const Locale& rLocale ) - throw(RuntimeException); + virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException); + virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException); // XSpellChecker - virtual sal_Bool SAL_CALL - isValid( const OUString& rWord, const Locale& rLocale, - const PropertyValues& rProperties ) - throw(IllegalArgumentException, - RuntimeException); - virtual Reference< XSpellAlternatives > SAL_CALL - spell( const OUString& rWord, const Locale& rLocale, - const PropertyValues& rProperties ) - throw(IllegalArgumentException, - RuntimeException); + virtual sal_Bool SAL_CALL isValid( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); + virtual Reference< XSpellAlternatives > SAL_CALL spell( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); // XLinguServiceEventBroadcaster - virtual sal_Bool SAL_CALL - addLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) - throw(RuntimeException); - virtual sal_Bool SAL_CALL - removeLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) - throw(RuntimeException); + virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); + virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); // XServiceDisplayName - virtual OUString SAL_CALL - getServiceDisplayName( const Locale& rLocale ) - throw(RuntimeException); + virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException); // XInitialization - virtual void SAL_CALL - initialize( const Sequence< Any >& rArguments ) - throw(Exception, RuntimeException); + virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException); // XComponent - virtual void SAL_CALL - dispose() - throw(RuntimeException); - virtual void SAL_CALL - addEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - virtual void SAL_CALL - removeEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - - //////////////////////////////////////////////////////////// - // Service specific part - // + virtual void SAL_CALL dispose() throw(RuntimeException); + virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); + virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); // XServiceInfo - virtual OUString SAL_CALL - getImplementationName() - throw(RuntimeException); - virtual sal_Bool SAL_CALL - supportsService( const OUString& rServiceName ) - throw(RuntimeException); - virtual Sequence< OUString > SAL_CALL - getSupportedServiceNames() - throw(RuntimeException); - - - static inline OUString - getImplementationName_Static() throw(); - static Sequence< OUString > - getSupportedServiceNames_Static() throw(); + virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); + + + static inline OUString getImplementationName_Static() throw(); + static Sequence< OUString > getSupportedServiceNames_Static() throw(); }; inline OUString MacSpellChecker::getImplementationName_Static() throw() diff --git a/lingucomponent/source/spellcheck/macosxspell/makefile.mk b/lingucomponent/source/spellcheck/macosxspell/makefile.mk index 571d36b99..0a724f0f1 100644 --- a/lingucomponent/source/spellcheck/macosxspell/makefile.mk +++ b/lingucomponent/source/spellcheck/macosxspell/makefile.mk @@ -90,3 +90,11 @@ SHL1VERSIONMAP=$(SOLARENV)/src/component.map dummy: @echo " Nothing to build for GUIBASE=$(GUIBASE)" .ENDIF + +ALLTAR : $(MISC)/MacOSXSpell.component + +$(MISC)/MacOSXSpell.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt MacOSXSpell.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt MacOSXSpell.component diff --git a/lingucomponent/source/spellcheck/spell/exports.dxp b/lingucomponent/source/spellcheck/spell/exports.dxp index b0f85bf7b..a9861e3ff 100644 --- a/lingucomponent/source/spellcheck/spell/exports.dxp +++ b/lingucomponent/source/spellcheck/spell/exports.dxp @@ -1,3 +1,2 @@ component_getFactory component_getImplementationEnvironment -component_writeInfo diff --git a/lingucomponent/source/spellcheck/spell/makefile.mk b/lingucomponent/source/spellcheck/spell/makefile.mk index 2e0d4b9d3..81a683c99 100644 --- a/lingucomponent/source/spellcheck/spell/makefile.mk +++ b/lingucomponent/source/spellcheck/spell/makefile.mk @@ -85,3 +85,11 @@ DEF1EXPORTFILE= exports.dxp .INCLUDE : target.mk + +ALLTAR : $(MISC)/spell.component + +$(MISC)/spell.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + spell.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt spell.component diff --git a/lingucomponent/source/spellcheck/spell/spell.component b/lingucomponent/source/spellcheck/spell/spell.component new file mode 100644 index 000000000..9f951a8a8 --- /dev/null +++ b/lingucomponent/source/spellcheck/spell/spell.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="org.openoffice.lingu.MySpellSpellChecker"> + <service name="com.sun.star.linguistic2.SpellChecker"/> + </implementation> +</component> diff --git a/lingucomponent/source/spellcheck/spell/sreg.cxx b/lingucomponent/source/spellcheck/spell/sreg.cxx index f140ebb9d..68ee24d10 100644 --- a/lingucomponent/source/spellcheck/spell/sreg.cxx +++ b/lingucomponent/source/spellcheck/spell/sreg.cxx @@ -41,9 +41,6 @@ using namespace com::sun::star::registry; //////////////////////////////////////// // declaration of external RegEntry-functions defined by the service objects // -extern sal_Bool SAL_CALL SpellChecker_writeInfo( - void * /*pServiceManager*/, XRegistryKey * pRegistryKey ); - extern void * SAL_CALL SpellChecker_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, @@ -55,12 +52,6 @@ extern void * SAL_CALL SpellChecker_getFactory( extern "C" { -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, XRegistryKey * pRegistryKey ) -{ - return SpellChecker_writeInfo( pServiceManager, pRegistryKey ); -} - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) { diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx index d8743dff2..dd073bb4c 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_lingucomponent.hxx" + #include <com/sun/star/uno/Reference.h> #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> @@ -38,9 +39,9 @@ #include <unotools/processfactory.hxx> #include <osl/mutex.hxx> +#include <lingutil.hxx> #include <hunspell.hxx> #include <dictmgr.hxx> - #include <sspellimp.hxx> #include <linguistic/lngprops.hxx> @@ -51,8 +52,7 @@ #include <unotools/useroptions.hxx> #include <osl/file.hxx> #include <rtl/ustrbuf.hxx> - -#include <lingutil.hxx> +#include <rtl/textenc.h> #include <list> #include <set> @@ -79,35 +79,37 @@ using ::rtl::OString; SpellChecker::SpellChecker() : aEvtListeners ( GetLinguMutex() ) { - aDicts = NULL; + aDicts = NULL; aDEncs = NULL; aDLocs = NULL; aDNames = NULL; - bDisposing = FALSE; + bDisposing = sal_False; pPropHelper = NULL; - numdict = 0; + numdict = 0; } SpellChecker::~SpellChecker() { - if (aDicts) { - for (int i = 0; i < numdict; i++) { + if (aDicts) + { + for (int i = 0; i < numdict; i++) + { if (aDicts[i]) delete aDicts[i]; aDicts[i] = NULL; - } - delete[] aDicts; - } - aDicts = NULL; - numdict = 0; - if (aDEncs) delete[] aDEncs; - aDEncs = NULL; - if (aDLocs) delete[] aDLocs; - aDLocs = NULL; - if (aDNames) delete[] aDNames; - aDNames = NULL; - if (pPropHelper) - pPropHelper->RemoveAsPropListener(); + } + delete[] aDicts; + } + aDicts = NULL; + numdict = 0; + if (aDEncs) delete[] aDEncs; + aDEncs = NULL; + if (aDLocs) delete[] aDLocs; + aDLocs = NULL; + if (aDNames) delete[] aDNames; + aDNames = NULL; + if (pPropHelper) + pPropHelper->RemoveAsPropListener(); } @@ -219,7 +221,7 @@ Sequence< Locale > SAL_CALL SpellChecker::getLocales() for (sal_Int32 i = 0; i < nLocales; ++i) { aDicts[k] = NULL; - aDEncs[k] = 0; + aDEncs[k] = RTL_TEXTENCODING_DONTKNOW; aDLocs[k] = MsLangId::convertLanguageToLocale( MsLangId::convertIsoStringToLanguage( aLocaleNames[i] )); // also both files have to be in the same directory and the @@ -257,101 +259,103 @@ sal_Bool SAL_CALL SpellChecker::hasLocale(const Locale& rLocale) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!aSuppLocales.getLength()) getLocales(); - INT32 nLen = aSuppLocales.getLength(); - for (INT32 i = 0; i < nLen; ++i) + sal_Int32 nLen = aSuppLocales.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) { const Locale *pLocale = aSuppLocales.getConstArray(); if (rLocale == pLocale[i]) { - bRes = TRUE; + bRes = sal_True; break; } } return bRes; } -INT16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale ) + +sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale ) { - Hunspell * pMS; - rtl_TextEncoding aEnc; + Hunspell * pMS = NULL; + rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; // initialize a myspell object for each dictionary once - // (note: mutex is held higher up in isValid) - + // (note: mutex is held higher up in isValid) - INT16 nRes = -1; + sal_Int16 nRes = -1; - // first handle smart quotes both single and double + // first handle smart quotes both single and double OUStringBuffer rBuf(rWord); - sal_Int32 n = rBuf.getLength(); - sal_Unicode c; - for (sal_Int32 ix=0; ix < n; ix++) { + sal_Int32 n = rBuf.getLength(); + sal_Unicode c; + for (sal_Int32 ix=0; ix < n; ix++) + { c = rBuf.charAt(ix); - if ((c == 0x201C) || (c == 0x201D)) rBuf.setCharAt(ix,(sal_Unicode)0x0022); - if ((c == 0x2018) || (c == 0x2019)) rBuf.setCharAt(ix,(sal_Unicode)0x0027); - } - OUString nWord(rBuf.makeStringAndClear()); + if ((c == 0x201C) || (c == 0x201D)) + rBuf.setCharAt(ix,(sal_Unicode)0x0022); + if ((c == 0x2018) || (c == 0x2019)) + rBuf.setCharAt(ix,(sal_Unicode)0x0027); + } + OUString nWord(rBuf.makeStringAndClear()); if (n) { - for (sal_Int32 i = 0; i < numdict; ++i) { + for (sal_Int32 i = 0; i < numdict; ++i) + { pMS = NULL; - aEnc = 0; + eEnc = RTL_TEXTENCODING_DONTKNOW; if (rLocale == aDLocs[i]) { - if (!aDicts[i]) - { - OUString dicpath = aDNames[i] + A2OU(".dic"); - OUString affpath = aDNames[i] + A2OU(".aff"); - OUString dict; - OUString aff; - osl::FileBase::getSystemPathFromFileURL(dicpath,dict); - osl::FileBase::getSystemPathFromFileURL(affpath,aff); - OString aTmpaff(OU2ENC(aff,osl_getThreadTextEncoding())); - OString aTmpdict(OU2ENC(dict,osl_getThreadTextEncoding())); + if (!aDicts[i]) + { + OUString dicpath = aDNames[i] + A2OU(".dic"); + OUString affpath = aDNames[i] + A2OU(".aff"); + OUString dict; + OUString aff; + osl::FileBase::getSystemPathFromFileURL(dicpath,dict); + osl::FileBase::getSystemPathFromFileURL(affpath,aff); + OString aTmpaff(OU2ENC(aff,osl_getThreadTextEncoding())); + OString aTmpdict(OU2ENC(dict,osl_getThreadTextEncoding())); #if defined(WNT) - // workaround for Windows specifc problem that the - // path length in calls to 'fopen' is limted to somewhat - // about 120+ characters which will usually be exceed when - // using dictionaries as extensions. - aTmpaff = Win_GetShortPathName( aff ); - aTmpdict = Win_GetShortPathName( dict ); + // workaround for Windows specifc problem that the + // path length in calls to 'fopen' is limted to somewhat + // about 120+ characters which will usually be exceed when + // using dictionaries as extensions. + aTmpaff = Win_GetShortPathName( aff ); + aTmpdict = Win_GetShortPathName( dict ); #endif - aDicts[i] = new Hunspell(aTmpaff.getStr(),aTmpdict.getStr()); - aDEncs[i] = 0; - if (aDicts[i]) { - char * dic_encoding = aDicts[i]->get_dic_encoding(); - aDEncs[i] = rtl_getTextEncodingFromUnixCharset(aDicts[i]->get_dic_encoding()); - if (aDEncs[i] == RTL_TEXTENCODING_DONTKNOW) { - if (strcmp("ISCII-DEVANAGARI", dic_encoding) == 0) { - aDEncs[i] = RTL_TEXTENCODING_ISCII_DEVANAGARI; - } else if (strcmp("UTF-8", dic_encoding) == 0) { - aDEncs[i] = RTL_TEXTENCODING_UTF8; - } - } - } - } - pMS = aDicts[i]; - aEnc = aDEncs[i]; - } + aDicts[i] = new Hunspell(aTmpaff.getStr(),aTmpdict.getStr()); + aDEncs[i] = RTL_TEXTENCODING_DONTKNOW; + if (aDicts[i]) + aDEncs[i] = getTextEncodingFromCharset(aDicts[i]->get_dic_encoding()); + } + pMS = aDicts[i]; + eEnc = aDEncs[i]; + } + if (pMS) - { - OString aWrd(OU2ENC(nWord,aEnc)); + { + // we don't want to work with a default text encoding since following incorrect + // results may occur only for specific text and thus may be hard to notice. + // Thus better always make a clean exit here if the text encoding is in question. + // Hopefully something not working at all will raise proper attention quickly. ;-) + DBG_ASSERT( eEnc != RTL_TEXTENCODING_DONTKNOW, "failed to get text encoding! (maybe incorrect encoding string in file)" ); + if (eEnc == RTL_TEXTENCODING_DONTKNOW) + return -1; + + OString aWrd(OU2ENC(nWord,eEnc)); int rVal = pMS->spell((char*)aWrd.getStr()); - if (rVal != 1) - { - nRes = SpellFailure::SPELLING_ERROR; - } else { - return -1; - } - pMS = NULL; + if (rVal != 1) + nRes = SpellFailure::SPELLING_ERROR; + else + return -1; + pMS = NULL; } } } @@ -360,25 +364,24 @@ INT16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocal } -sal_Bool SAL_CALL - SpellChecker::isValid( const OUString& rWord, const Locale& rLocale, +sal_Bool SAL_CALL SpellChecker::isValid( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); if (rLocale == Locale() || !rWord.getLength()) - return TRUE; + return sal_True; if (!hasLocale( rLocale )) #ifdef LINGU_EXCEPTIONS throw( IllegalArgumentException() ); #else - return TRUE; + return sal_True; #endif - // return FALSE to process SPELLML requests (they are longer than the header) - if (rWord.match(A2OU(SPELLML_HEADER), 0) && (rWord.getLength() > 10)) return FALSE; + // return sal_False to process SPELLML requests (they are longer than the header) + if (rWord.match(A2OU(SPELLML_HEADER), 0) && (rWord.getLength() > 10)) return sal_False; // Get property values to be used. // These are be the default values set in the SN_LINGU_PROPERTIES @@ -390,16 +393,16 @@ sal_Bool SAL_CALL PropertyHelper_Spell &rHelper = GetPropHelper(); rHelper.SetTmpPropVals( rProperties ); - INT16 nFailure = GetSpellFailure( rWord, rLocale ); + sal_Int16 nFailure = GetSpellFailure( rWord, rLocale ); if (nFailure != -1 && !rWord.match(A2OU(SPELLML_HEADER), 0)) { - INT16 nLang = LocaleToLanguage( rLocale ); + sal_Int16 nLang = LocaleToLanguage( rLocale ); // postprocess result for errors that should be ignored - if ( (!rHelper.IsSpellUpperCase() && IsUpper( rWord, nLang )) - || (!rHelper.IsSpellWithDigits() && HasDigits( rWord )) - || (!rHelper.IsSpellCapitalization() - && nFailure == SpellFailure::CAPTION_ERROR) - ) + const bool bIgnoreError = + (!rHelper.IsSpellUpperCase() && IsUpper( rWord, nLang )) || + (!rHelper.IsSpellWithDigits() && HasDigits( rWord )) || + (!rHelper.IsSpellCapitalization() && nFailure == SpellFailure::CAPTION_ERROR); + if (bIgnoreError) nFailure = -1; } @@ -415,80 +418,82 @@ Reference< XSpellAlternatives > // Especially it may give a list of suggested (correct) words: Reference< XSpellAlternatives > xRes; - // note: mutex is held by higher up by spell which covers both + // note: mutex is held by higher up by spell which covers both - Hunspell* pMS; - rtl_TextEncoding aEnc; - int count; - int numsug = 0; + Hunspell* pMS = NULL; + rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; + int count = 0; + int numsug = 0; - // first handle smart quotes (single and double) + // first handle smart quotes (single and double) OUStringBuffer rBuf(rWord); - sal_Int32 n = rBuf.getLength(); - sal_Unicode c; - for (sal_Int32 ix=0; ix < n; ix++) { - c = rBuf.charAt(ix); - if ((c == 0x201C) || (c == 0x201D)) rBuf.setCharAt(ix,(sal_Unicode)0x0022); - if ((c == 0x2018) || (c == 0x2019)) rBuf.setCharAt(ix,(sal_Unicode)0x0027); - } - OUString nWord(rBuf.makeStringAndClear()); + sal_Int32 n = rBuf.getLength(); + sal_Unicode c; + for (sal_Int32 ix=0; ix < n; ix++) + { + c = rBuf.charAt(ix); + if ((c == 0x201C) || (c == 0x201D)) + rBuf.setCharAt(ix,(sal_Unicode)0x0022); + if ((c == 0x2018) || (c == 0x2019)) + rBuf.setCharAt(ix,(sal_Unicode)0x0027); + } + OUString nWord(rBuf.makeStringAndClear()); if (n) { - INT16 nLang = LocaleToLanguage( rLocale ); + sal_Int16 nLang = LocaleToLanguage( rLocale ); Sequence< OUString > aStr( 0 ); - for (int i =0; i < numdict; i++) { + for (int i =0; i < numdict; i++) + { pMS = NULL; - aEnc = 0; - count = 0; + eEnc = RTL_TEXTENCODING_DONTKNOW; + count = 0; if (rLocale == aDLocs[i]) { - pMS = aDicts[i]; - aEnc = aDEncs[i]; - } + pMS = aDicts[i]; + eEnc = aDEncs[i]; + } if (pMS) { char ** suglst = NULL; - OString aWrd(OU2ENC(nWord,aEnc)); - count = pMS->suggest(&suglst, (const char *) aWrd.getStr()); - - if (count) { - aStr.realloc( numsug + count ); - OUString *pStr = aStr.getArray(); - for (int ii=0; ii < count; ++ii) - { - OUString cvtwrd(suglst[ii],strlen(suglst[ii]),aEnc); - pStr[numsug + ii] = cvtwrd; - } - pMS->free_list(&suglst, count); - numsug += count; + OString aWrd(OU2ENC(nWord,eEnc)); + count = pMS->suggest(&suglst, (const char *) aWrd.getStr()); + + if (count) + { + aStr.realloc( numsug + count ); + OUString *pStr = aStr.getArray(); + for (int ii=0; ii < count; ++ii) + { + OUString cvtwrd(suglst[ii],strlen(suglst[ii]),eEnc); + pStr[numsug + ii] = cvtwrd; } - } + pMS->free_list(&suglst, count); + numsug += count; + } + } } - // now return an empty alternative for no suggestions or the list of alternatives if some found + // now return an empty alternative for no suggestions or the list of alternatives if some found SpellAlternatives *pAlt = new SpellAlternatives; - String aTmp(rWord); + String aTmp(rWord); pAlt->SetWordLanguage( aTmp, nLang ); pAlt->SetFailureType( SpellFailure::SPELLING_ERROR ); pAlt->SetAlternatives( aStr ); xRes = pAlt; - return xRes; - - } return xRes; + } + return xRes; } - - -Reference< XSpellAlternatives > SAL_CALL - SpellChecker::spell( const OUString& rWord, const Locale& rLocale, - const PropertyValues& rProperties ) +Reference< XSpellAlternatives > SAL_CALL SpellChecker::spell( + const OUString& rWord, const Locale& rLocale, + const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -513,7 +518,7 @@ Reference< XSpellAlternatives > SAL_CALL Reference< XInterface > SAL_CALL SpellChecker_CreateInstance( - const Reference< XMultiServiceFactory > & /*rSMgr*/ ) + const Reference< XMultiServiceFactory > & /*rSMgr*/ ) throw(Exception) { @@ -522,14 +527,13 @@ Reference< XInterface > SAL_CALL SpellChecker_CreateInstance( } -sal_Bool SAL_CALL - SpellChecker::addLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) +sal_Bool SAL_CALL SpellChecker::addLinguServiceEventListener( + const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bDisposing && rxLstnr.is()) { bRes = GetPropHelper().addLinguServiceEventListener( rxLstnr ); @@ -538,14 +542,13 @@ sal_Bool SAL_CALL } -sal_Bool SAL_CALL - SpellChecker::removeLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) +sal_Bool SAL_CALL SpellChecker::removeLinguServiceEventListener( + const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!bDisposing && rxLstnr.is()) { DBG_ASSERT( xPropHelper.is(), "xPropHelper non existent" ); @@ -555,8 +558,7 @@ sal_Bool SAL_CALL } -OUString SAL_CALL - SpellChecker::getServiceDisplayName( const Locale& /*rLocale*/ ) +OUString SAL_CALL SpellChecker::getServiceDisplayName( const Locale& /*rLocale*/ ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -564,15 +566,14 @@ OUString SAL_CALL } -void SAL_CALL - SpellChecker::initialize( const Sequence< Any >& rArguments ) +void SAL_CALL SpellChecker::initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); if (!pPropHelper) { - INT32 nLen = rArguments.getLength(); + sal_Int32 nLen = rArguments.getLength(); if (2 == nLen) { Reference< XPropertySet > xPropSet; @@ -590,28 +591,25 @@ void SAL_CALL else { OSL_FAIL( "wrong number of arguments in sequence" ); } - } } -void SAL_CALL - SpellChecker::dispose() +void SAL_CALL SpellChecker::dispose() throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); if (!bDisposing) { - bDisposing = TRUE; + bDisposing = sal_True; EventObject aEvtObj( (XSpellChecker *) this ); aEvtListeners.disposeAndClear( aEvtObj ); } } -void SAL_CALL - SpellChecker::addEventListener( const Reference< XEventListener >& rxListener ) +void SAL_CALL SpellChecker::addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -621,8 +619,7 @@ void SAL_CALL } -void SAL_CALL - SpellChecker::removeEventListener( const Reference< XEventListener >& rxListener ) +void SAL_CALL SpellChecker::removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -652,10 +649,10 @@ sal_Bool SAL_CALL SpellChecker::supportsService( const OUString& ServiceName ) Sequence< OUString > aSNL = getSupportedServiceNames(); const OUString * pArray = aSNL.getConstArray(); - for( INT32 i = 0; i < aSNL.getLength(); i++ ) + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) if( pArray[i] == ServiceName ) - return TRUE; - return FALSE; + return sal_True; + return sal_False; } @@ -678,32 +675,6 @@ Sequence< OUString > SpellChecker::getSupportedServiceNames_Static() return aSNS; } - -sal_Bool SAL_CALL SpellChecker_writeInfo( - void * /*pServiceManager*/, registry::XRegistryKey * pRegistryKey ) -{ - - try - { - String aImpl( '/' ); - aImpl += SpellChecker::getImplementationName_Static().getStr(); - aImpl.AppendAscii( "/UNO/SERVICES" ); - Reference< registry::XRegistryKey > xNewKey = - pRegistryKey->createKey( aImpl ); - Sequence< OUString > aServices = - SpellChecker::getSupportedServiceNames_Static(); - for( INT32 i = 0; i < aServices.getLength(); i++ ) - xNewKey->createKey( aServices.getConstArray()[i] ); - - return sal_True; - } - catch(Exception &) - { - return sal_False; - } -} - - void * SAL_CALL SpellChecker_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.hxx b/lingucomponent/source/spellcheck/spell/sspellimp.hxx index 937681e11..45ac8a6a8 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.hxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.hxx @@ -70,16 +70,16 @@ class SpellChecker : > { Sequence< Locale > aSuppLocales; - Hunspell ** aDicts; - rtl_TextEncoding * aDEncs; - Locale * aDLocs; - OUString * aDNames; - sal_Int32 numdict; + Hunspell ** aDicts; + rtl_TextEncoding * aDEncs; + Locale * aDLocs; + OUString * aDNames; + sal_Int32 numdict; ::cppu::OInterfaceContainerHelper aEvtListeners; Reference< XPropertyChangeListener > xPropHelper; linguistic::PropertyHelper_Spell * pPropHelper; - BOOL bDisposing; + sal_Bool bDisposing; // disallow copy-constructor and assignment-operator for now SpellChecker(const SpellChecker &); @@ -91,85 +91,44 @@ class SpellChecker : return pPropHelper ? *pPropHelper : GetPropHelper_Impl(); } - INT16 GetSpellFailure( const OUString &rWord, const Locale &rLocale ); - Reference< XSpellAlternatives > - GetProposals( const OUString &rWord, const Locale &rLocale ); + sal_Int16 GetSpellFailure( const OUString &rWord, const Locale &rLocale ); + Reference< XSpellAlternatives > GetProposals( const OUString &rWord, const Locale &rLocale ); public: SpellChecker(); virtual ~SpellChecker(); // XSupportedLocales (for XSpellChecker) - virtual Sequence< Locale > SAL_CALL - getLocales() - throw(RuntimeException); - virtual sal_Bool SAL_CALL - hasLocale( const Locale& rLocale ) - throw(RuntimeException); + virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException); + virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException); // XSpellChecker - virtual sal_Bool SAL_CALL - isValid( const OUString& rWord, const Locale& rLocale, - const PropertyValues& rProperties ) - throw(IllegalArgumentException, - RuntimeException); - virtual Reference< XSpellAlternatives > SAL_CALL - spell( const OUString& rWord, const Locale& rLocale, - const PropertyValues& rProperties ) - throw(IllegalArgumentException, - RuntimeException); + virtual sal_Bool SAL_CALL isValid( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); + virtual Reference< XSpellAlternatives > SAL_CALL spell( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); // XLinguServiceEventBroadcaster - virtual sal_Bool SAL_CALL - addLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) - throw(RuntimeException); - virtual sal_Bool SAL_CALL - removeLinguServiceEventListener( - const Reference< XLinguServiceEventListener >& rxLstnr ) - throw(RuntimeException); + virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); + virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); // XServiceDisplayName - virtual OUString SAL_CALL - getServiceDisplayName( const Locale& rLocale ) - throw(RuntimeException); + virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException); // XInitialization - virtual void SAL_CALL - initialize( const Sequence< Any >& rArguments ) - throw(Exception, RuntimeException); + virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException); // XComponent - virtual void SAL_CALL - dispose() - throw(RuntimeException); - virtual void SAL_CALL - addEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - virtual void SAL_CALL - removeEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - - //////////////////////////////////////////////////////////// - // Service specific part - // + virtual void SAL_CALL dispose() throw(RuntimeException); + virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); + virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); // XServiceInfo - virtual OUString SAL_CALL - getImplementationName() - throw(RuntimeException); - virtual sal_Bool SAL_CALL - supportsService( const OUString& rServiceName ) - throw(RuntimeException); - virtual Sequence< OUString > SAL_CALL - getSupportedServiceNames() - throw(RuntimeException); - - - static inline OUString - getImplementationName_Static() throw(); - static Sequence< OUString > - getSupportedServiceNames_Static() throw(); + virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); + + + static inline OUString getImplementationName_Static() throw(); + static Sequence< OUString > getSupportedServiceNames_Static() throw(); }; inline OUString SpellChecker::getImplementationName_Static() throw() @@ -178,7 +137,6 @@ inline OUString SpellChecker::getImplementationName_Static() throw() } - /////////////////////////////////////////////////////////////////////////// #endif diff --git a/lingucomponent/source/thesaurus/libnth/exports.dxp b/lingucomponent/source/thesaurus/libnth/exports.dxp index b0f85bf7b..a9861e3ff 100644 --- a/lingucomponent/source/thesaurus/libnth/exports.dxp +++ b/lingucomponent/source/thesaurus/libnth/exports.dxp @@ -1,3 +1,2 @@ component_getFactory component_getImplementationEnvironment -component_writeInfo diff --git a/lingucomponent/source/thesaurus/libnth/lnth.component b/lingucomponent/source/thesaurus/libnth/lnth.component new file mode 100644 index 000000000..bea91b94c --- /dev/null +++ b/lingucomponent/source/thesaurus/libnth/lnth.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="org.openoffice.lingu.new.Thesaurus"> + <service name="com.sun.star.linguistic2.Thesaurus"/> + </implementation> +</component> diff --git a/lingucomponent/source/thesaurus/libnth/makefile.mk b/lingucomponent/source/thesaurus/libnth/makefile.mk index acc027d9a..d204fb2c7 100644 --- a/lingucomponent/source/thesaurus/libnth/makefile.mk +++ b/lingucomponent/source/thesaurus/libnth/makefile.mk @@ -105,3 +105,11 @@ DEF1EXPORTFILE= exports.dxp .INCLUDE : target.mk + +ALLTAR : $(MISC)/lnth.component + +$(MISC)/lnth.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + lnth.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt lnth.component diff --git a/lingucomponent/source/thesaurus/libnth/nthesdta.cxx b/lingucomponent/source/thesaurus/libnth/nthesdta.cxx index 982658130..549c9c0e4 100644 --- a/lingucomponent/source/thesaurus/libnth/nthesdta.cxx +++ b/lingucomponent/source/thesaurus/libnth/nthesdta.cxx @@ -53,10 +53,10 @@ namespace linguistic Meaning::Meaning( #if 0 - const OUString &rTerm, INT16 nLang, + const OUString &rTerm, sal_Int16 nLang, const PropertyHelper_Thes &rHelper ) : #else - const OUString &rTerm, INT16 nLang) : + const OUString &rTerm, sal_Int16 nLang) : #endif aSyn ( Sequence< OUString >(1) ), diff --git a/lingucomponent/source/thesaurus/libnth/nthesdta.hxx b/lingucomponent/source/thesaurus/libnth/nthesdta.hxx index fa8b3db6e..6e0352bf7 100644 --- a/lingucomponent/source/thesaurus/libnth/nthesdta.hxx +++ b/lingucomponent/source/thesaurus/libnth/nthesdta.hxx @@ -49,11 +49,11 @@ class Meaning : { ::com::sun::star::uno::Sequence< ::rtl::OUString > aSyn; // list of synonyms, may be empty. ::rtl::OUString aTerm; - INT16 nLanguage; + sal_Int16 nLanguage; #if 0 // this is for future use by a German thesaurus - BOOL bIsGermanPreReform; + sal_Bool bIsGermanPreReform; #endif // disallow copy-constructor and assignment-operator for now @@ -62,29 +62,19 @@ class Meaning : public: #if 0 - Meaning(const ::rtl::OUString &rTerm, INT16 nLang, const PropertyHelper_Thes &rHelper); + Meaning(const ::rtl::OUString &rTerm, sal_Int16 nLang, const PropertyHelper_Thes &rHelper); #else - Meaning(const ::rtl::OUString &rTerm, INT16 nLang); + Meaning(const ::rtl::OUString &rTerm, sal_Int16 nLang); #endif virtual ~Meaning(); // XMeaning - virtual ::rtl::OUString SAL_CALL - getMeaning() - throw(::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL - querySynonyms() - throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getMeaning() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL querySynonyms() throw(::com::sun::star::uno::RuntimeException); // non-interface specific functions - void SetSynonyms( - const ::com::sun::star::uno::Sequence< ::rtl::OUString > - &rSyn ); - - void SetMeaning(const ::rtl::OUString &rTerm ); - - + void SetSynonyms( const ::com::sun::star::uno::Sequence< ::rtl::OUString > &rSyn ); + void SetMeaning( const ::rtl::OUString &rTerm ); }; diff --git a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx index af02bbfee..e2f7363e9 100644 --- a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx +++ b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx @@ -29,9 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_lingucomponent.hxx" -// include <stdio.h> #include <com/sun/star/uno/Reference.h> - #include <cppuhelper/factory.hxx> // helper for factories #include <com/sun/star/registry/XRegistryKey.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -44,6 +42,8 @@ #include <rtl/string.hxx> #include <rtl/ustrbuf.hxx> +#include <rtl/textenc.h> + #include "nthesimp.hxx" #include <linguistic/misc.hxx> #include <linguistic/lngprops.hxx> @@ -95,30 +95,34 @@ static uno::Reference< XLinguServiceManager > GetLngSvcMgr_Impl() Thesaurus::Thesaurus() : aEvtListeners ( GetLinguMutex() ) { - bDisposing = FALSE; + bDisposing = sal_False; pPropHelper = NULL; aThes = NULL; aCharSetInfo = NULL; aTEncs = NULL; aTLocs = NULL; aTNames = NULL; - numthes = 0; + numthes = 0; } Thesaurus::~Thesaurus() { - if (aThes) { - for (int i = 0; i < numthes; i++) { + if (aThes) + { + for (int i = 0; i < numthes; i++) + { if (aThes[i]) delete aThes[i]; aThes[i] = NULL; } delete[] aThes; } aThes = NULL; - if (aCharSetInfo) { - for (int i = 0; i < numthes; i++) { + if (aCharSetInfo) + { + for (int i = 0; i < numthes; i++) + { if (aCharSetInfo[i]) delete aCharSetInfo[i]; aCharSetInfo[i] = NULL; } @@ -246,7 +250,7 @@ Sequence< Locale > SAL_CALL Thesaurus::getLocales() for (sal_Int32 i = 0; i < nLocales; ++i) { aThes[k] = NULL; - aTEncs[k] = 0; + aTEncs[k] = RTL_TEXTENCODING_DONTKNOW; aTLocs[k] = MsLangId::convertLanguageToLocale( MsLangId::convertIsoStringToLanguage( aDictIt->aLocaleNames[i] )); aCharSetInfo[k] = new CharClass( aTLocs[k] ); @@ -287,16 +291,16 @@ sal_Bool SAL_CALL Thesaurus::hasLocale(const Locale& rLocale) { MutexGuard aGuard( GetLinguMutex() ); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; if (!aSuppLocales.getLength()) getLocales(); - INT32 nLen = aSuppLocales.getLength(); - for (INT32 i = 0; i < nLen; ++i) + sal_Int32 nLen = aSuppLocales.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) { const Locale *pLocale = aSuppLocales.getConstArray(); if (rLocale == pLocale[i]) { - bRes = TRUE; + bRes = sal_True; break; } } @@ -304,28 +308,28 @@ sal_Bool SAL_CALL Thesaurus::hasLocale(const Locale& rLocale) } -Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL - Thesaurus::queryMeanings( const OUString& qTerm, const Locale& rLocale, - const PropertyValues& rProperties) - throw(IllegalArgumentException, RuntimeException) +Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL Thesaurus::queryMeanings( + const OUString& qTerm, const Locale& rLocale, + const PropertyValues& rProperties) + throw(IllegalArgumentException, RuntimeException) { - MutexGuard aGuard( GetLinguMutex() ); + MutexGuard aGuard( GetLinguMutex() ); - uno::Sequence< Reference< XMeaning > > aMeanings( 1 ); - uno::Sequence< Reference< XMeaning > > noMeanings( 0 ); - uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() ); - uno::Reference< XSpellChecker1 > xSpell; + uno::Sequence< Reference< XMeaning > > aMeanings( 1 ); + uno::Sequence< Reference< XMeaning > > noMeanings( 0 ); + uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() ); + uno::Reference< XSpellChecker1 > xSpell; - OUString rTerm(qTerm); - OUString pTerm(qTerm); - sal_uInt16 ct = CAPTYPE_UNKNOWN; - sal_Int32 stem = 0; - sal_Int32 stem2 = 0; + OUString rTerm(qTerm); + OUString pTerm(qTerm); + sal_uInt16 ct = CAPTYPE_UNKNOWN; + sal_Int32 stem = 0; + sal_Int32 stem2 = 0; - INT16 nLanguage = LocaleToLanguage( rLocale ); + sal_Int16 nLanguage = LocaleToLanguage( rLocale ); - if (nLanguage == LANGUAGE_NONE || !rTerm.getLength()) - return noMeanings; + if (nLanguage == LANGUAGE_NONE || !rTerm.getLength()) + return noMeanings; if (!hasLocale( rLocale )) #ifdef LINGU_EXCEPTIONS @@ -334,195 +338,202 @@ Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL return noMeanings; #endif - if (prevTerm == qTerm && prevLocale == nLanguage) return prevMeanings; + if (prevTerm == qTerm && prevLocale == nLanguage) + return prevMeanings; - mentry * pmean = NULL; + mentry * pmean = NULL; sal_Int32 nmean = 0; - PropertyHelper_Thes &rHelper = GetPropHelper(); - rHelper.SetTmpPropVals( rProperties ); + PropertyHelper_Thes &rHelper = GetPropHelper(); + rHelper.SetTmpPropVals( rProperties ); - MyThes * pTH = NULL; - rtl_TextEncoding aEnc = 0; - CharClass * pCC = NULL; + MyThes * pTH = NULL; + rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW; + CharClass * pCC = NULL; - // find the first thesaurus that matches the locale - for (int i =0; i < numthes; i++) { - if (rLocale == aTLocs[i]) + // find the first thesaurus that matches the locale + for (int i =0; i < numthes; i++) + { + if (rLocale == aTLocs[i]) + { + // open up and intialize this thesaurus if need be + if (!aThes[i]) { - // open up and intialize this thesaurus if need be - if (!aThes[i]) - { - OUString datpath = aTNames[i] + A2OU(".dat"); - OUString idxpath = aTNames[i] + A2OU(".idx"); - OUString ndat; - OUString nidx; - osl::FileBase::getSystemPathFromFileURL(datpath,ndat); - osl::FileBase::getSystemPathFromFileURL(idxpath,nidx); - OString aTmpidx(OU2ENC(nidx,osl_getThreadTextEncoding())); - OString aTmpdat(OU2ENC(ndat,osl_getThreadTextEncoding())); + OUString datpath = aTNames[i] + A2OU(".dat"); + OUString idxpath = aTNames[i] + A2OU(".idx"); + OUString ndat; + OUString nidx; + osl::FileBase::getSystemPathFromFileURL(datpath,ndat); + osl::FileBase::getSystemPathFromFileURL(idxpath,nidx); + OString aTmpidx(OU2ENC(nidx,osl_getThreadTextEncoding())); + OString aTmpdat(OU2ENC(ndat,osl_getThreadTextEncoding())); #if defined(WNT) - // workaround for Windows specifc problem that the - // path length in calls to 'fopen' is limted to somewhat - // about 120+ characters which will usually be exceed when - // using dictionaries as extensions. - aTmpidx = Win_GetShortPathName( nidx ); - aTmpdat = Win_GetShortPathName( ndat ); + // workaround for Windows specifc problem that the + // path length in calls to 'fopen' is limted to somewhat + // about 120+ characters which will usually be exceed when + // using dictionaries as extensions. + aTmpidx = Win_GetShortPathName( nidx ); + aTmpdat = Win_GetShortPathName( ndat ); #endif - aThes[i] = new MyThes(aTmpidx.getStr(),aTmpdat.getStr()); - if (aThes[i]) { - const char * enc_string = aThes[i]->get_th_encoding(); - if (!enc_string) { - aTEncs[i] = rtl_getTextEncodingFromUnixCharset("ISO8859-1"); - } else { - aTEncs[i] = rtl_getTextEncodingFromUnixCharset(enc_string); - if (aTEncs[i] == RTL_TEXTENCODING_DONTKNOW) { - if (strcmp("ISCII-DEVANAGARI", enc_string) == 0) { - aTEncs[i] = RTL_TEXTENCODING_ISCII_DEVANAGARI; - } else if (strcmp("UTF-8", enc_string) == 0) { - aTEncs[i] = RTL_TEXTENCODING_UTF8; - } - } - } - } - } - pTH = aThes[i]; - aEnc = aTEncs[i]; - pCC = aCharSetInfo[i]; - - if (pTH) - break; + aThes[i] = new MyThes(aTmpidx.getStr(),aTmpdat.getStr()); + if (aThes[i]) + aTEncs[i] = getTextEncodingFromCharset(aThes[i]->get_th_encoding()); + } + pTH = aThes[i]; + eEnc = aTEncs[i]; + pCC = aCharSetInfo[i]; + + if (pTH) + break; } } - while (pTH) { - // convert word to all lower case for searching - if (!stem) ct = capitalType(rTerm, pCC); - OUString nTerm(makeLowerCase(rTerm, pCC)); - OString aTmp( OU2ENC(nTerm, aEnc) ); - nmean = pTH->Lookup(aTmp.getStr(),aTmp.getLength(),&pmean); + // we don't want to work with a default text encoding since following incorrect + // results may occur only for specific text and thus may be hard to notice. + // Thus better always make a clean exit here if the text encoding is in question. + // Hopefully something not working at all will raise proper attention quickly. ;-) + DBG_ASSERT( eEnc != RTL_TEXTENCODING_DONTKNOW, "failed to get text encoding! (maybe incorrect encoding string in file)" ); + if (eEnc == RTL_TEXTENCODING_DONTKNOW) + return noMeanings; + + while (pTH) + { + // convert word to all lower case for searching + if (!stem) + ct = capitalType(rTerm, pCC); + OUString nTerm(makeLowerCase(rTerm, pCC)); + OString aTmp( OU2ENC(nTerm, eEnc) ); + nmean = pTH->Lookup(aTmp.getStr(),aTmp.getLength(),&pmean); - if (nmean) aMeanings.realloc( nmean ); + if (nmean) + aMeanings.realloc( nmean ); - mentry * pe = pmean; - OUString codeTerm = qTerm; - Reference< XSpellAlternatives > xTmpRes2; + mentry * pe = pmean; + OUString codeTerm = qTerm; + Reference< XSpellAlternatives > xTmpRes2; - if (stem) { - xTmpRes2 = xSpell->spell( A2OU("<?xml?><query type='analyze'><word>") + + if (stem) + { + xTmpRes2 = xSpell->spell( A2OU("<?xml?><query type='analyze'><word>") + pTerm + A2OU("</word></query>"), nLanguage, rProperties ); - if (xTmpRes2.is()) { - Sequence<OUString>seq = xTmpRes2->getAlternatives(); - if (seq.getLength() > 0) { + if (xTmpRes2.is()) + { + Sequence<OUString>seq = xTmpRes2->getAlternatives(); + if (seq.getLength() > 0) + { codeTerm = seq[0]; stem2 = 1; - } + } #if 0 - OString o = OUStringToOString(codeTerm, rtl_getTextEncodingFromUnixCharset("UTF-8")); - fprintf(stderr, "CODETERM: %s\n", o.pData->buffer); + OString o = OUStringToOString(codeTerm, RTL_TEXTENCODING_UTF8); + fprintf(stderr, "CODETERM: %s\n", o.pData->buffer); #endif - } - } - - for (int j = 0; j < nmean; j++) { - int count = pe->count; - if (count) { - Sequence< OUString > aStr( count ); - OUString *pStr = aStr.getArray(); - - for (int i=0; i < count; i++) { - OUString sTerm(pe->psyns[i],strlen(pe->psyns[i]),aEnc ); - sal_Int32 catpos = sTerm.indexOf('('); - sal_Int32 catpos2 = 0; - OUString catst; - OUString catst2; - if (catpos > 2) { - // remove category name for affixation and casing - catst = A2OU(" ") + sTerm.copy(catpos); - sTerm = sTerm.copy(0, catpos); - sTerm = sTerm.trim(); - } - // generate synonyms with affixes - if (stem && stem2) { - Reference< XSpellAlternatives > xTmpRes; - xTmpRes = xSpell->spell( A2OU("<?xml?><query type='generate'><word>") + - sTerm + A2OU("</word>") + codeTerm + A2OU("</query>"), nLanguage, rProperties ); - if (xTmpRes.is()) { - Sequence<OUString>seq = xTmpRes->getAlternatives(); - for (int k = 0; k < seq.getLength(); k++) { - OString o = OUStringToOString(seq[k], rtl_getTextEncodingFromUnixCharset("UTF-8")); - } - if (seq.getLength() > 0) sTerm = seq[0]; - } - } - if (catpos2) sTerm = catst2 + sTerm; - - sal_uInt16 ct1 = capitalType(sTerm, pCC); - if (CAPTYPE_MIXED == ct1) - ct = ct1; - OUString cTerm; - switch (ct) { - case CAPTYPE_ALLCAP: - { - cTerm = makeUpperCase(sTerm, pCC); - break; - } - case CAPTYPE_INITCAP: - { - cTerm = makeInitCap(sTerm, pCC); - break; - } - default: - { - cTerm = sTerm; - break; - } - } - OUString aAlt( cTerm + catst); - pStr[i] = aAlt; - } + } + } + + for (int j = 0; j < nmean; j++) + { + int count = pe->count; + if (count) + { + Sequence< OUString > aStr( count ); + OUString *pStr = aStr.getArray(); + + for (int i=0; i < count; i++) + { + OUString sTerm(pe->psyns[i],strlen(pe->psyns[i]),eEnc ); + sal_Int32 catpos = sTerm.indexOf('('); + sal_Int32 catpos2 = 0; + OUString catst; + OUString catst2; + if (catpos > 2) + { + // remove category name for affixation and casing + catst = A2OU(" ") + sTerm.copy(catpos); + sTerm = sTerm.copy(0, catpos); + sTerm = sTerm.trim(); + } + // generate synonyms with affixes + if (stem && stem2) + { + Reference< XSpellAlternatives > xTmpRes; + xTmpRes = xSpell->spell( A2OU("<?xml?><query type='generate'><word>") + + sTerm + A2OU("</word>") + codeTerm + A2OU("</query>"), nLanguage, rProperties ); + if (xTmpRes.is()) + { + Sequence<OUString>seq = xTmpRes->getAlternatives(); + if (seq.getLength() > 0) + sTerm = seq[0]; + } + } + if (catpos2) + sTerm = catst2 + sTerm; + + sal_uInt16 ct1 = capitalType(sTerm, pCC); + if (CAPTYPE_MIXED == ct1) + ct = ct1; + OUString cTerm; + switch (ct) + { + case CAPTYPE_ALLCAP: + cTerm = makeUpperCase(sTerm, pCC); + break; + case CAPTYPE_INITCAP: + cTerm = makeInitCap(sTerm, pCC); + break; + default: + cTerm = sTerm; + break; + } + OUString aAlt( cTerm + catst); + pStr[i] = aAlt; + } #if 0 - Meaning * pMn = new Meaning(rTerm,nLanguage,rHelper); + Meaning * pMn = new Meaning(rTerm,nLanguage,rHelper); #endif - Meaning * pMn = new Meaning(rTerm,nLanguage); - OUString dTerm(pe->defn,strlen(pe->defn),aEnc ); - pMn->SetMeaning(dTerm); - pMn->SetSynonyms(aStr); - Reference<XMeaning>* pMeaning = aMeanings.getArray(); - pMeaning[j] = pMn; - } - pe++; - } - pTH->CleanUpAfterLookup(&pmean,nmean); - - if (nmean) { + Meaning * pMn = new Meaning(rTerm,nLanguage); + OUString dTerm(pe->defn,strlen(pe->defn),eEnc ); + pMn->SetMeaning(dTerm); + pMn->SetSynonyms(aStr); + Reference<XMeaning>* pMeaning = aMeanings.getArray(); + pMeaning[j] = pMn; + } + pe++; + } + pTH->CleanUpAfterLookup(&pmean,nmean); + + if (nmean) + { prevTerm = qTerm; prevMeanings = aMeanings; prevLocale = nLanguage; return aMeanings; - } + } - if (stem || !xLngSvcMgr.is()) return noMeanings; + if (stem || !xLngSvcMgr.is()) + return noMeanings; stem = 1; xSpell = uno::Reference< XSpellChecker1 >( xLngSvcMgr->getSpellChecker(), UNO_QUERY ); - if (!xSpell.is() || !xSpell->isValid( A2OU(SPELLML_SUPPORT), nLanguage, rProperties )) { + if (!xSpell.is() || !xSpell->isValid( A2OU(SPELLML_SUPPORT), nLanguage, rProperties )) return noMeanings; - } Reference< XSpellAlternatives > xTmpRes; xTmpRes = xSpell->spell( A2OU("<?xml?><query type='stem'><word>") + rTerm + A2OU("</word></query>"), nLanguage, rProperties ); - if (xTmpRes.is()) { + if (xTmpRes.is()) + { Sequence<OUString>seq = xTmpRes->getAlternatives(); #if 0 - for (int i = 0; i < seq.getLength(); i++) { - OString o = OUStringToOString(seq[i], rtl_getTextEncodingFromUnixCharset("UTF-8")); + for (int i = 0; i < seq.getLength(); i++) + { + OString o = OUStringToOString(seq[i], RTL_TEXTENCODING_UTF8); fprintf(stderr, "%d: %s\n", i + 1, o.pData->buffer); } #endif - if (seq.getLength() > 0) { + if (seq.getLength() > 0) + { rTerm = seq[0]; // XXX Use only the first stem continue; } @@ -531,17 +542,21 @@ Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL // stem the last word of the synonym (for categories after affixation) rTerm = rTerm.trim(); sal_Int32 pos = rTerm.lastIndexOf(' '); - if (!pos) return noMeanings; + if (!pos) + return noMeanings; xTmpRes = xSpell->spell( A2OU("<?xml?><query type='stem'><word>") + rTerm.copy(pos + 1) + A2OU("</word></query>"), nLanguage, rProperties ); - if (xTmpRes.is()) { + if (xTmpRes.is()) + { Sequence<OUString>seq = xTmpRes->getAlternatives(); - if (seq.getLength() > 0) { + if (seq.getLength() > 0) + { pTerm = rTerm.copy(pos + 1); rTerm = rTerm.copy(0, pos + 1) + seq[0]; -#if 0 - for (int i = 0; i < seq.getLength(); i++) { - OString o = OUStringToOString(seq[i], rtl_getTextEncodingFromUnixCharset("UTF-8")); +#if 0 + for (int i = 0; i < seq.getLength(); i++) + { + OString o = OUStringToOString(seq[i], RTL_TEXTENCODING_UTF8); fprintf(stderr, "%d: %s\n", i + 1, o.pData->buffer); } #endif @@ -549,12 +564,11 @@ Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL } } break; - } + } return noMeanings; } - Reference< XInterface > SAL_CALL Thesaurus_CreateInstance( const Reference< XMultiServiceFactory > & /*rSMgr*/ ) throw(Exception) @@ -564,8 +578,7 @@ Reference< XInterface > SAL_CALL Thesaurus_CreateInstance( } -OUString SAL_CALL - Thesaurus::getServiceDisplayName( const Locale& /*rLocale*/ ) +OUString SAL_CALL Thesaurus::getServiceDisplayName( const Locale& /*rLocale*/ ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -573,15 +586,14 @@ OUString SAL_CALL } -void SAL_CALL - Thesaurus::initialize( const Sequence< Any >& rArguments ) +void SAL_CALL Thesaurus::initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); if (!pPropHelper) { - INT32 nLen = rArguments.getLength(); + sal_Int32 nLen = rArguments.getLength(); if (1 == nLen) { Reference< XPropertySet > xPropSet; @@ -605,24 +617,26 @@ void SAL_CALL sal_uInt16 SAL_CALL Thesaurus::capitalType(const OUString& aTerm, CharClass * pCC) { sal_Int32 tlen = aTerm.getLength(); - if ((pCC) && (tlen)) { - String aStr(aTerm); - sal_Int32 nc = 0; - for (USHORT tindex = 0; tindex < tlen; tindex++) { - if (pCC->getCharacterType(aStr,tindex) & - ::com::sun::star::i18n::KCharacterType::UPPER) nc++; - } - - if (nc == 0) return (sal_uInt16) CAPTYPE_NOCAP; - - if (nc == tlen) return (sal_uInt16) CAPTYPE_ALLCAP; + if ((pCC) && (tlen)) + { + String aStr(aTerm); + sal_Int32 nc = 0; + for (sal_uInt16 tindex = 0; tindex < tlen; tindex++) + { + if (pCC->getCharacterType(aStr,tindex) & + ::com::sun::star::i18n::KCharacterType::UPPER) nc++; + } - if ((nc == 1) && (pCC->getCharacterType(aStr,0) & - ::com::sun::star::i18n::KCharacterType::UPPER)) - return (sal_uInt16) CAPTYPE_INITCAP; + if (nc == 0) + return (sal_uInt16) CAPTYPE_NOCAP; + if (nc == tlen) + return (sal_uInt16) CAPTYPE_ALLCAP; + if ((nc == 1) && (pCC->getCharacterType(aStr,0) & + ::com::sun::star::i18n::KCharacterType::UPPER)) + return (sal_uInt16) CAPTYPE_INITCAP; - return (sal_uInt16) CAPTYPE_MIXED; - } + return (sal_uInt16) CAPTYPE_MIXED; + } return (sal_uInt16) CAPTYPE_UNKNOWN; } @@ -630,53 +644,54 @@ sal_uInt16 SAL_CALL Thesaurus::capitalType(const OUString& aTerm, CharClass * pC OUString SAL_CALL Thesaurus::makeLowerCase(const OUString& aTerm, CharClass * pCC) { - if (pCC) - return pCC->toLower_rtl(aTerm, 0, aTerm.getLength()); - return aTerm; + if (pCC) + return pCC->toLower_rtl(aTerm, 0, aTerm.getLength()); + return aTerm; } OUString SAL_CALL Thesaurus::makeUpperCase(const OUString& aTerm, CharClass * pCC) { - if (pCC) - return pCC->toUpper_rtl(aTerm, 0, aTerm.getLength()); - return aTerm; + if (pCC) + return pCC->toUpper_rtl(aTerm, 0, aTerm.getLength()); + return aTerm; } OUString SAL_CALL Thesaurus::makeInitCap(const OUString& aTerm, CharClass * pCC) { - sal_Int32 tlen = aTerm.getLength(); - if ((pCC) && (tlen)) { - OUString bTemp = aTerm.copy(0,1); - if (tlen > 1) - return ( pCC->toUpper_rtl(bTemp, 0, 1) - + pCC->toLower_rtl(aTerm,1,(tlen-1)) ); + sal_Int32 tlen = aTerm.getLength(); + if ((pCC) && (tlen)) + { + OUString bTemp = aTerm.copy(0,1); + if (tlen > 1) + { + return ( pCC->toUpper_rtl(bTemp, 0, 1) + + pCC->toLower_rtl(aTerm,1,(tlen-1)) ); + } - return pCC->toUpper_rtl(bTemp, 0, 1); + return pCC->toUpper_rtl(bTemp, 0, 1); } - return aTerm; + return aTerm; } -void SAL_CALL - Thesaurus::dispose() +void SAL_CALL Thesaurus::dispose() throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); if (!bDisposing) { - bDisposing = TRUE; + bDisposing = sal_True; EventObject aEvtObj( (XThesaurus *) this ); aEvtListeners.disposeAndClear( aEvtObj ); } } -void SAL_CALL - Thesaurus::addEventListener( const Reference< XEventListener >& rxListener ) +void SAL_CALL Thesaurus::addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -686,8 +701,7 @@ void SAL_CALL } -void SAL_CALL - Thesaurus::removeEventListener( const Reference< XEventListener >& rxListener ) +void SAL_CALL Thesaurus::removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -716,10 +730,10 @@ sal_Bool SAL_CALL Thesaurus::supportsService( const OUString& ServiceName ) Sequence< OUString > aSNL = getSupportedServiceNames(); const OUString * pArray = aSNL.getConstArray(); - for( INT32 i = 0; i < aSNL.getLength(); i++ ) + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) if( pArray[i] == ServiceName ) - return TRUE; - return FALSE; + return sal_True; + return sal_False; } @@ -741,31 +755,6 @@ Sequence< OUString > Thesaurus::getSupportedServiceNames_Static() return aSNS; } - -sal_Bool SAL_CALL Thesaurus_writeInfo( - void * /*pServiceManager*/, registry::XRegistryKey * pRegistryKey ) -{ - try - { - String aImpl( '/' ); - aImpl += Thesaurus::getImplementationName_Static().getStr(); - aImpl.AppendAscii( "/UNO/SERVICES" ); - Reference< registry::XRegistryKey > xNewKey = - pRegistryKey->createKey( aImpl ); - Sequence< OUString > aServices = - Thesaurus::getSupportedServiceNames_Static(); - for( INT32 i = 0; i < aServices.getLength(); i++ ) - xNewKey->createKey( aServices.getConstArray()[i] ); - - return sal_True; - } - catch(Exception &) - { - return sal_False; - } -} - - void * SAL_CALL Thesaurus_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { diff --git a/lingucomponent/source/thesaurus/libnth/nthesimp.hxx b/lingucomponent/source/thesaurus/libnth/nthesimp.hxx index ab7401e62..78c948b9b 100644 --- a/lingucomponent/source/thesaurus/libnth/nthesimp.hxx +++ b/lingucomponent/source/thesaurus/libnth/nthesimp.hxx @@ -88,7 +88,7 @@ class Thesaurus : ::cppu::OInterfaceContainerHelper aEvtListeners; Reference< XPropertyChangeListener > xPropHelper; linguistic::PropertyHelper_Thes * pPropHelper; - BOOL bDisposing; + sal_Bool bDisposing; CharClass ** aCharSetInfo; MyThes ** aThes; rtl_TextEncoding * aTEncs; @@ -99,7 +99,7 @@ class Thesaurus : // cache for the Thesaurus dialog Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > prevMeanings; OUString prevTerm; - INT16 prevLocale; + sal_Int16 prevLocale; // disallow copy-constructor and assignment-operator for now Thesaurus(const Thesaurus &); @@ -117,55 +117,27 @@ public: virtual ~Thesaurus(); // XSupportedLocales (for XThesaurus) - virtual Sequence< Locale > SAL_CALL - getLocales() - throw(RuntimeException); - virtual sal_Bool SAL_CALL - hasLocale( const Locale& rLocale ) - throw(RuntimeException); + virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException); + virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException); // XThesaurus - virtual Sequence< Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL - queryMeanings( const OUString& rTerm, const Locale& rLocale, - const PropertyValues& rProperties ) - throw(IllegalArgumentException, - RuntimeException); + virtual Sequence< Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL queryMeanings( const OUString& rTerm, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); // XServiceDisplayName - virtual OUString SAL_CALL - getServiceDisplayName( const Locale& rLocale ) - throw(RuntimeException); + virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException); // XInitialization - virtual void SAL_CALL - initialize( const Sequence< Any >& rArguments ) - throw(Exception, RuntimeException); + virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException); // XComponent - virtual void SAL_CALL - dispose() - throw(RuntimeException); - virtual void SAL_CALL - addEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - virtual void SAL_CALL - removeEventListener( const Reference< XEventListener >& rxListener ) - throw(RuntimeException); - - //////////////////////////////////////////////////////////// - // Service specific part - // + virtual void SAL_CALL dispose() throw(RuntimeException); + virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); + virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); // XServiceInfo - virtual OUString SAL_CALL - getImplementationName() - throw(RuntimeException); - virtual sal_Bool SAL_CALL - supportsService( const OUString& rServiceName ) - throw(RuntimeException); - virtual Sequence< OUString > SAL_CALL - getSupportedServiceNames() - throw(RuntimeException); + virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); static inline OUString @@ -184,8 +156,7 @@ private: static ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellChecker1 > xSpell; */ - static ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XLinguServiceManager > GetLngSvcMgr(); + static ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLinguServiceManager > GetLngSvcMgr(); }; diff --git a/lingucomponent/source/thesaurus/libnth/ntreg.cxx b/lingucomponent/source/thesaurus/libnth/ntreg.cxx index 27849021b..4628cc60c 100644 --- a/lingucomponent/source/thesaurus/libnth/ntreg.cxx +++ b/lingucomponent/source/thesaurus/libnth/ntreg.cxx @@ -42,9 +42,6 @@ using namespace com::sun::star::registry; // declaration of external RegEntry-functions defined by the service objects // -extern sal_Bool SAL_CALL Thesaurus_writeInfo( - void * /*pServiceManager*/, XRegistryKey * pRegistryKey ); - extern void * SAL_CALL Thesaurus_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, @@ -57,12 +54,6 @@ extern void * SAL_CALL Thesaurus_getFactory( extern "C" { -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, XRegistryKey * pRegistryKey ) -{ - return Thesaurus_writeInfo( pServiceManager, pRegistryKey ); -} - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) { |