2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 23:40:16 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:40:16 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:40:16 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:40:16 +00:00
|
|
|
* 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.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:40:16 +00:00
|
|
|
* 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).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 23:40:16 +00:00
|
|
|
* 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.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 03:54:12 +00:00
|
|
|
|
2006-11-22 09:34:52 +00:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <vector>
|
2011-02-05 13:34:36 +01:00
|
|
|
#include <list>
|
2008-03-25 15:42:43 +00:00
|
|
|
#include <memory>
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/unolingu.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
2005-04-04 11:50:50 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/pathoptions.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/frame/XModel.hpp>
|
2008-03-25 15:42:43 +00:00
|
|
|
#include <com/sun/star/frame/XStorable.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/lang/XEventListener.hpp>
|
2002-12-04 12:05:00 +00:00
|
|
|
#include <com/sun/star/linguistic2/XAvailableLocales.hpp>
|
2005-04-04 11:50:50 +00:00
|
|
|
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
|
|
|
|
#include <com/sun/star/ucb/XContentAccess.hpp>
|
|
|
|
#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
|
|
|
|
#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
|
|
|
|
#include <com/sun/star/ucb/XContentAccess.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XResultSet.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
|
|
|
#include <com/sun/star/util/DateTime.hpp>
|
|
|
|
|
2000-10-23 11:08:49 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <cppuhelper/implbase1.hxx> // helper for implementations
|
2006-04-07 13:04:17 +00:00
|
|
|
#include <i18npool/mslangid.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/lingucfg.hxx>
|
2005-04-04 11:50:50 +00:00
|
|
|
#include <unotools/ucbhelper.hxx>
|
|
|
|
#include <unotools/localfilehelper.hxx>
|
|
|
|
#include <ucbhelper/commandenvironment.hxx>
|
|
|
|
#include <ucbhelper/content.hxx>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <tools/shl.hxx>
|
2002-12-04 12:05:00 +00:00
|
|
|
#include <linguistic/misc.hxx>
|
2010-01-06 19:26:54 +01:00
|
|
|
#include <editeng/eerdll.hxx>
|
|
|
|
#include <editeng/editrids.hrc>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
using namespace ::rtl;
|
2000-10-23 11:08:49 +00:00
|
|
|
using namespace ::comphelper;
|
2005-04-04 11:50:50 +00:00
|
|
|
using namespace ::linguistic;
|
2000-09-18 16:07:07 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::frame;
|
2000-10-27 09:25:31 +00:00
|
|
|
using namespace ::com::sun::star::linguistic2;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-04-04 11:50:50 +00:00
|
|
|
#define CSS com::sun::star
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
static uno::Reference< XLinguServiceManager > GetLngSvcMgr_Impl()
|
2002-02-19 12:25:41 +00:00
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XLinguServiceManager > xRes;
|
|
|
|
uno::Reference< XMultiServiceFactory > xMgr = getProcessServiceFactory();
|
2002-02-19 12:25:41 +00:00
|
|
|
if (xMgr.is())
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
xRes = uno::Reference< XLinguServiceManager > ( xMgr->createInstance(
|
2002-09-26 08:28:54 +00:00
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM(
|
2002-02-19 12:25:41 +00:00
|
|
|
"com.sun.star.linguistic2.LinguServiceManager" ) ) ), UNO_QUERY ) ;
|
|
|
|
}
|
|
|
|
return xRes;
|
|
|
|
}
|
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool lcl_FindEntry( const OUString &rEntry, const Sequence< OUString > &rCfgSvcs )
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nRes = -1;
|
|
|
|
sal_Int32 nEntries = rCfgSvcs.getLength();
|
2002-12-04 12:05:00 +00:00
|
|
|
const OUString *pEntry = rCfgSvcs.getConstArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 i = 0; i < nEntries && nRes == -1; ++i)
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
|
|
|
if (rEntry == pEntry[i])
|
|
|
|
nRes = i;
|
|
|
|
}
|
|
|
|
return nRes != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Sequence< OUString > lcl_RemoveMissingEntries(
|
|
|
|
const Sequence< OUString > &rCfgSvcs,
|
|
|
|
const Sequence< OUString > &rAvailSvcs )
|
|
|
|
{
|
|
|
|
Sequence< OUString > aRes( rCfgSvcs.getLength() );
|
|
|
|
OUString *pRes = aRes.getArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nCnt = 0;
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nEntries = rCfgSvcs.getLength();
|
2002-12-04 12:05:00 +00:00
|
|
|
const OUString *pEntry = rCfgSvcs.getConstArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 i = 0; i < nEntries; ++i)
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
|
|
|
if (pEntry[i].getLength() && lcl_FindEntry( pEntry[i], rAvailSvcs ))
|
|
|
|
pRes[ nCnt++ ] = pEntry[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
aRes.realloc( nCnt );
|
|
|
|
return aRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Sequence< OUString > lcl_GetLastFoundSvcs(
|
2005-04-04 11:50:50 +00:00
|
|
|
SvtLinguConfig &rCfg,
|
2002-12-04 12:05:00 +00:00
|
|
|
const OUString &rLastFoundList ,
|
|
|
|
const Locale &rAvailLocale )
|
|
|
|
{
|
|
|
|
Sequence< OUString > aRes;
|
|
|
|
|
2006-04-07 13:04:17 +00:00
|
|
|
OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
|
2002-12-04 12:05:00 +00:00
|
|
|
SvxLocaleToLanguage( rAvailLocale ) ) );
|
|
|
|
|
|
|
|
Sequence< OUString > aNodeNames( rCfg.GetNodeNames(rLastFoundList) );
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool bFound = lcl_FindEntry( aCfgLocaleStr, aNodeNames);
|
2002-12-04 12:05:00 +00:00
|
|
|
|
|
|
|
if (bFound)
|
|
|
|
{
|
|
|
|
Sequence< OUString > aNames(1);
|
|
|
|
OUString &rNodeName = aNames.getArray()[0];
|
|
|
|
rNodeName = rLastFoundList;
|
|
|
|
rNodeName += OUString::valueOf( (sal_Unicode)'/' );
|
|
|
|
rNodeName += aCfgLocaleStr;
|
|
|
|
Sequence< Any > aValues( rCfg.GetProperties( aNames ) );
|
|
|
|
if (aValues.getLength())
|
|
|
|
{
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( aValues.getLength() == 1, "unexpected length of sequence" );
|
2002-12-04 12:05:00 +00:00
|
|
|
Sequence< OUString > aSvcImplNames;
|
|
|
|
if (aValues.getConstArray()[0] >>= aSvcImplNames)
|
|
|
|
aRes = aSvcImplNames;
|
|
|
|
else
|
2008-06-30 14:42:48 +00:00
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "type mismatch" );
|
2008-06-30 14:42:48 +00:00
|
|
|
}
|
2002-12-04 12:05:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Sequence< OUString > lcl_GetNewEntries(
|
|
|
|
const Sequence< OUString > &rLastFoundSvcs,
|
|
|
|
const Sequence< OUString > &rAvailSvcs )
|
|
|
|
{
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nLen = rAvailSvcs.getLength();
|
2002-12-04 12:05:00 +00:00
|
|
|
Sequence< OUString > aRes( nLen );
|
|
|
|
OUString *pRes = aRes.getArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nCnt = 0;
|
2002-12-04 12:05:00 +00:00
|
|
|
|
|
|
|
const OUString *pEntry = rAvailSvcs.getConstArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 i = 0; i < nLen; ++i)
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
|
|
|
if (pEntry[i].getLength() && !lcl_FindEntry( pEntry[i], rLastFoundSvcs ))
|
|
|
|
pRes[ nCnt++ ] = pEntry[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
aRes.realloc( nCnt );
|
|
|
|
return aRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Sequence< OUString > lcl_MergeSeq(
|
|
|
|
const Sequence< OUString > &rCfgSvcs,
|
|
|
|
const Sequence< OUString > &rNewSvcs )
|
|
|
|
{
|
|
|
|
Sequence< OUString > aRes( rCfgSvcs.getLength() + rNewSvcs.getLength() );
|
|
|
|
OUString *pRes = aRes.getArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nCnt = 0;
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 k = 0; k < 2; ++k)
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
2004-11-27 12:38:24 +00:00
|
|
|
// add previously configuerd service first and append
|
|
|
|
// new found services at the end
|
2002-12-04 12:05:00 +00:00
|
|
|
const Sequence< OUString > &rSeq = k == 0 ? rCfgSvcs : rNewSvcs;
|
2004-11-27 12:38:24 +00:00
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nLen = rSeq.getLength();
|
2002-12-04 12:05:00 +00:00
|
|
|
const OUString *pEntry = rSeq.getConstArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 i = 0; i < nLen; ++i)
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
|
|
|
if (pEntry[i].getLength() && !lcl_FindEntry( pEntry[i], aRes ))
|
|
|
|
pRes[ nCnt++ ] = pEntry[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aRes.realloc( nCnt );
|
|
|
|
return aRes;
|
|
|
|
}
|
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int16 SvxLinguConfigUpdate::nNeedUpdating = -1;
|
|
|
|
sal_Int32 SvxLinguConfigUpdate::nCurrentDataFilesChangedCheckValue = -1;
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2007-01-02 14:15:01 +00:00
|
|
|
void SvxLinguConfigUpdate::UpdateAll( sal_Bool bForceCheck )
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
2005-04-04 11:50:50 +00:00
|
|
|
RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::UpdateAll" );
|
|
|
|
|
2007-01-02 14:15:01 +00:00
|
|
|
if (IsNeedUpdateAll( bForceCheck ))
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
2006-03-17 07:57:46 +00:00
|
|
|
typedef OUString OUstring_t;
|
2006-03-16 13:08:34 +00:00
|
|
|
typedef Sequence< OUString > Sequence_OUString_t;
|
2006-03-17 07:57:46 +00:00
|
|
|
typedef std::vector< OUstring_t > OUString_vector_t;
|
|
|
|
typedef std::set< OUstring_t > OUString_set_t;
|
|
|
|
std::vector< OUString_vector_t > aVector;
|
|
|
|
typedef std::map< OUstring_t, Sequence_OUString_t > list_entry_map_t;
|
2006-03-16 13:08:34 +00:00
|
|
|
|
2005-04-04 11:50:50 +00:00
|
|
|
RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::UpdateAll - updating..." );
|
|
|
|
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( nNeedUpdating == 1, "SvxLinguConfigUpdate::UpdateAll already updated!" );
|
2005-04-04 11:50:50 +00:00
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( xLngSvcMgr.is(), "service manager missing");
|
2002-12-04 12:05:00 +00:00
|
|
|
if (!xLngSvcMgr.is())
|
|
|
|
return;
|
|
|
|
|
2005-04-04 11:50:50 +00:00
|
|
|
SvtLinguConfig aCfg;
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
const int nNumServices = 4;
|
|
|
|
const sal_Char * apServices[nNumServices] = { SN_SPELLCHECKER, SN_GRAMMARCHECKER, SN_HYPHENATOR, SN_THESAURUS };
|
|
|
|
const sal_Char * apCurLists[nNumServices] = { "ServiceManager/SpellCheckerList", "ServiceManager/GrammarCheckerList", "ServiceManager/HyphenatorList", "ServiceManager/ThesaurusList" };
|
|
|
|
const sal_Char * apLastFoundLists[nNumServices] = { "ServiceManager/LastFoundSpellCheckers", "ServiceManager/LastFoundGrammarCheckers", "ServiceManager/LastFoundHyphenators", "ServiceManager/LastFoundThesauri" };
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
// usage of indices as above: 0 = spell checker, 1 = grammar checker, 2 = hyphenator, 3 = thesaurus
|
|
|
|
std::vector< list_entry_map_t > aLastFoundSvcs(nNumServices);
|
|
|
|
std::vector< list_entry_map_t > aCurSvcs(nNumServices);
|
2006-03-16 13:08:34 +00:00
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
for (int k = 0; k < nNumServices; ++k)
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
2010-12-23 12:38:55 +00:00
|
|
|
OUString aService( ::rtl::OUString::createFromAscii( apServices[k] ) );
|
|
|
|
OUString aActiveList( ::rtl::OUString::createFromAscii( apCurLists[k] ) );
|
|
|
|
OUString aLastFoundList( ::rtl::OUString::createFromAscii( apLastFoundLists[k] ) );
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 i;
|
2002-12-04 12:05:00 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// remove configured but not available language/services entries
|
|
|
|
//
|
|
|
|
Sequence< OUString > aNodeNames( aCfg.GetNodeNames( aActiveList ) ); // list of configured locales
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nNodeNames = aNodeNames.getLength();
|
2002-12-04 12:05:00 +00:00
|
|
|
const OUString *pNodeName = aNodeNames.getConstArray();
|
|
|
|
for (i = 0; i < nNodeNames; ++i)
|
|
|
|
{
|
2006-04-07 13:04:17 +00:00
|
|
|
Locale aLocale( SvxCreateLocale( MsLangId::convertIsoStringToLanguage(pNodeName[i]) ) );
|
2002-12-04 12:05:00 +00:00
|
|
|
Sequence< OUString > aCfgSvcs(
|
|
|
|
xLngSvcMgr->getConfiguredServices( aService, aLocale ));
|
|
|
|
Sequence< OUString > aAvailSvcs(
|
|
|
|
xLngSvcMgr->getAvailableServices( aService, aLocale ));
|
2008-12-15 12:01:46 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2011-12-14 14:43:58 -05:00
|
|
|
const OUString * pCfgSvcs = aCfgSvcs.getConstArray();
|
|
|
|
const OUString * pAvailSvcs = aAvailSvcs.getConstArray();
|
2008-12-15 12:01:46 +00:00
|
|
|
(void) pCfgSvcs;
|
|
|
|
(void) pAvailSvcs;
|
|
|
|
#endif
|
2002-12-04 12:05:00 +00:00
|
|
|
aCfgSvcs = lcl_RemoveMissingEntries( aCfgSvcs, aAvailSvcs );
|
2006-03-16 13:08:34 +00:00
|
|
|
|
|
|
|
aCurSvcs[k][ pNodeName[i] ] = aCfgSvcs;
|
2002-12-04 12:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// add new available language/servcice entries
|
|
|
|
//
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XAvailableLocales > xAvail( xLngSvcMgr, UNO_QUERY );
|
2002-12-04 12:05:00 +00:00
|
|
|
Sequence< Locale > aAvailLocales( xAvail->getAvailableLocales(aService) );
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nAvailLocales = aAvailLocales.getLength();
|
2002-12-04 12:05:00 +00:00
|
|
|
const Locale *pAvailLocale = aAvailLocales.getConstArray();
|
|
|
|
for (i = 0; i < nAvailLocales; ++i)
|
|
|
|
{
|
|
|
|
Sequence< OUString > aAvailSvcs(
|
|
|
|
xLngSvcMgr->getAvailableServices( aService, pAvailLocale[i] ));
|
2008-12-15 12:01:46 +00:00
|
|
|
Sequence< OUString > aLastSvcs(
|
2002-12-04 12:05:00 +00:00
|
|
|
lcl_GetLastFoundSvcs( aCfg, aLastFoundList , pAvailLocale[i] ));
|
|
|
|
Sequence< OUString > aNewSvcs =
|
2008-12-15 12:01:46 +00:00
|
|
|
lcl_GetNewEntries( aLastSvcs, aAvailSvcs );
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
const OUString * pAvailSvcs = aAvailSvcs.getConstArray();
|
|
|
|
const OUString * pLastSvcs = aLastSvcs.getConstArray();
|
|
|
|
const OUString * pNewSvcs = aNewSvcs.getConstArray();
|
|
|
|
(void) pAvailSvcs;
|
|
|
|
(void) pLastSvcs;
|
|
|
|
(void) pNewSvcs;
|
|
|
|
#endif
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2006-04-10 11:51:43 +00:00
|
|
|
OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
|
2006-03-16 13:08:34 +00:00
|
|
|
SvxLocaleToLanguage( pAvailLocale[i] ) ) );
|
|
|
|
Sequence< OUString > aCfgSvcs( aCurSvcs[k][ aCfgLocaleStr ] );
|
2004-11-27 12:38:24 +00:00
|
|
|
|
2006-03-16 13:08:34 +00:00
|
|
|
// merge services list (previously configured to be listed first).
|
2002-12-04 12:05:00 +00:00
|
|
|
aCfgSvcs = lcl_MergeSeq( aCfgSvcs, aNewSvcs );
|
2004-11-27 12:38:24 +00:00
|
|
|
|
2008-03-25 15:42:43 +00:00
|
|
|
/*
|
2004-11-27 12:38:24 +00:00
|
|
|
// there is at most one Hyphenator per language allowed
|
|
|
|
// to be configured, thus we only use the first one found.
|
|
|
|
if (k == 2 && aCfgSvcs.getLength() > 1)
|
|
|
|
aCfgSvcs.realloc(1);
|
2008-03-25 15:42:43 +00:00
|
|
|
*/
|
2006-03-16 13:08:34 +00:00
|
|
|
aCurSvcs[k][ aCfgLocaleStr ] = aCfgSvcs;
|
2002-12-04 12:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// set last found services to currently available ones
|
|
|
|
//
|
|
|
|
for (i = 0; i < nAvailLocales; ++i)
|
|
|
|
{
|
|
|
|
Sequence< OUString > aSvcImplNames(
|
2008-12-15 12:01:46 +00:00
|
|
|
xLngSvcMgr->getAvailableServices( aService, pAvailLocale[i] ) );
|
2002-12-04 12:05:00 +00:00
|
|
|
|
2003-04-15 16:30:17 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nSvcs = aSvcImplNames.getLength();
|
2002-12-04 12:05:00 +00:00
|
|
|
const OUString *pSvcImplName = aSvcImplNames.getConstArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 j = 0; j < nSvcs; ++j)
|
2002-12-04 12:05:00 +00:00
|
|
|
{
|
|
|
|
OUString aImplName( pSvcImplName[j] );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-04-07 13:04:17 +00:00
|
|
|
OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
|
2002-12-04 12:05:00 +00:00
|
|
|
SvxLocaleToLanguage( pAvailLocale[i] ) ) );
|
2006-03-16 13:08:34 +00:00
|
|
|
aLastFoundSvcs[k][ aCfgLocaleStr ] = aSvcImplNames;
|
2002-12-04 12:05:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-16 13:08:34 +00:00
|
|
|
//
|
|
|
|
// write new data back to configuration
|
|
|
|
//
|
2008-12-15 12:01:46 +00:00
|
|
|
for (int k = 0; k < nNumServices; ++k)
|
2006-03-16 13:08:34 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
const sal_Char *pSubNodeName = (i == 0) ? apCurLists[k] : apLastFoundLists[k];
|
2010-12-23 12:38:55 +00:00
|
|
|
OUString aSubNodeName( ::rtl::OUString::createFromAscii(pSubNodeName) );
|
2006-03-16 13:08:34 +00:00
|
|
|
|
|
|
|
list_entry_map_t &rCurMap = (i == 0) ? aCurSvcs[k] : aLastFoundSvcs[k];
|
|
|
|
list_entry_map_t::const_iterator aIt( rCurMap.begin() );
|
|
|
|
sal_Int32 nVals = static_cast< sal_Int32 >( rCurMap.size() );
|
|
|
|
Sequence< PropertyValue > aNewValues( nVals );
|
|
|
|
PropertyValue *pNewValue = aNewValues.getArray();
|
|
|
|
while (aIt != rCurMap.end())
|
|
|
|
{
|
|
|
|
OUString aCfgEntryName( aSubNodeName );
|
|
|
|
aCfgEntryName += OUString::valueOf( (sal_Unicode) '/' );
|
|
|
|
aCfgEntryName += (*aIt).first;
|
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
Sequence< OUString > aSvcImplNames( (*aIt).second );
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nSvcs = aSvcImplNames.getLength();
|
2006-03-16 13:08:34 +00:00
|
|
|
const OUString *pSvcImplName = aSvcImplNames.getConstArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 j = 0; j < nSvcs; ++j)
|
2006-03-16 13:08:34 +00:00
|
|
|
{
|
|
|
|
OUString aImplName( pSvcImplName[j] );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
pNewValue->Name = aCfgEntryName;
|
|
|
|
pNewValue->Value <<= (*aIt).second;
|
|
|
|
++pNewValue;
|
|
|
|
++aIt;
|
|
|
|
}
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( pNewValue - aNewValues.getArray() == nVals,
|
2006-03-16 13:08:34 +00:00
|
|
|
"possible mismatch of sequence size and property number" );
|
2005-04-04 11:50:50 +00:00
|
|
|
|
2006-03-16 13:08:34 +00:00
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::UpdateAll - ReplaceSetProperties" );
|
|
|
|
// add new or replace existing entries.
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool bRes = aCfg.ReplaceSetProperties( aSubNodeName, aNewValues );
|
2006-11-22 11:08:13 +00:00
|
|
|
if (!bRes)
|
|
|
|
{
|
2007-01-02 14:15:01 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "failed to set new configuration values" );
|
2007-01-02 14:15:01 +00:00
|
|
|
#endif
|
2006-11-22 11:08:13 +00:00
|
|
|
}
|
2006-03-16 13:08:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( nCurrentDataFilesChangedCheckValue != -1, "SvxLinguConfigUpdate::UpdateAll DataFilesChangedCheckValue not yet calculated!" );
|
2005-04-04 11:50:50 +00:00
|
|
|
Any aAny;
|
2008-03-25 15:42:43 +00:00
|
|
|
|
|
|
|
// for the time being (developer builds until OOo 3.0)
|
|
|
|
// we should always check for everything available
|
|
|
|
// otherwise we may miss a new installed extension dicitonary
|
|
|
|
// just because e.g. the spellchecker is not asked what
|
|
|
|
// languages it does support currently...
|
|
|
|
// Since the check is on-demand occuring and executed once it should
|
|
|
|
// not be too troublesome.
|
|
|
|
// In OOo 3.0 we will not need the respective code anymore at all.
|
|
|
|
// aAny <<= nCurrentDataFilesChangedCheckValue;
|
2011-01-13 14:12:48 +01:00
|
|
|
aAny <<= (sal_Int32) -1; // keep the value set to 'need to check'
|
2008-03-25 15:42:43 +00:00
|
|
|
|
2005-04-04 11:50:50 +00:00
|
|
|
aCfg.SetProperty( A2OU( "DataFilesChangedCheckValue" ), aAny );
|
2006-03-16 13:08:34 +00:00
|
|
|
|
|
|
|
//! Note 1: the new values are commited when the 'aCfg' object
|
|
|
|
//! gets destroyed.
|
|
|
|
//! Note 2: the new settings in the configuration get applied
|
|
|
|
//! because the 'LngSvcMgr' (in linguistic/source/lngsvcmgr.hxx)
|
|
|
|
//! listens to the configuration for changes of the relevant
|
|
|
|
//! properties and then applies the new settings.
|
|
|
|
|
|
|
|
// nothing needs to be done anymore
|
|
|
|
nNeedUpdating = 0;
|
2005-04-04 11:50:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 SvxLinguConfigUpdate::CalcDataFilesChangedCheckValue()
|
2005-04-04 11:50:50 +00:00
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::CalcDataFilesChangedCheckValue" );
|
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nHashVal = 0;
|
2008-12-15 12:01:46 +00:00
|
|
|
// nothing to be checked anymore since those old directory paths are gone by now
|
2005-04-04 11:50:50 +00:00
|
|
|
return nHashVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool SvxLinguConfigUpdate::IsNeedUpdateAll( sal_Bool bForceCheck )
|
2005-04-04 11:50:50 +00:00
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::IsNeedUpdateAll" );
|
2007-01-02 14:15:01 +00:00
|
|
|
if (nNeedUpdating == -1 || bForceCheck ) // need to check if updating is necessary
|
2005-04-04 11:50:50 +00:00
|
|
|
{
|
|
|
|
// calculate hash value for current data files
|
|
|
|
nCurrentDataFilesChangedCheckValue = CalcDataFilesChangedCheckValue();
|
|
|
|
|
|
|
|
// compare hash value and check value to see if anything has changed
|
|
|
|
// and thus the configuration needs to be updated
|
|
|
|
SvtLinguOptions aLinguOpt;
|
|
|
|
SvtLinguConfig aCfg;
|
|
|
|
aCfg.GetOptions( aLinguOpt );
|
|
|
|
nNeedUpdating = (nCurrentDataFilesChangedCheckValue == aLinguOpt.nDataFilesChangedCheckValue) ? 0 : 1;
|
|
|
|
}
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( nNeedUpdating != -1,
|
2005-04-04 11:50:50 +00:00
|
|
|
"need for linguistic configuration update should have been already checked." );
|
|
|
|
|
|
|
|
return nNeedUpdating == 1;
|
2002-12-04 12:05:00 +00:00
|
|
|
}
|
2002-02-19 12:25:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
//! Dummy implementation in order to avoid loading of lingu DLL
|
|
|
|
//! when only the XSupportedLocales interface is used.
|
|
|
|
//! The dummy accesses the real implementation (and thus loading the DLL)
|
|
|
|
//! when "real" work needs to be done only.
|
|
|
|
class ThesDummy_Impl :
|
2002-12-04 12:05:00 +00:00
|
|
|
public cppu::WeakImplHelper1< XThesaurus >
|
2002-02-19 12:25:41 +00:00
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XThesaurus > xThes; // the real one...
|
2002-02-19 12:25:41 +00:00
|
|
|
Sequence< Locale > *pLocaleSeq;
|
|
|
|
|
|
|
|
void GetCfgLocales();
|
2002-12-04 12:05:00 +00:00
|
|
|
|
|
|
|
void GetThes_Impl();
|
2002-02-19 12:25:41 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ThesDummy_Impl() : pLocaleSeq(0) {}
|
|
|
|
~ThesDummy_Impl();
|
|
|
|
|
|
|
|
// XSupportedLocales
|
|
|
|
virtual ::com::sun::star::uno::Sequence<
|
|
|
|
::com::sun::star::lang::Locale > SAL_CALL
|
|
|
|
getLocales()
|
|
|
|
throw(::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual sal_Bool SAL_CALL
|
|
|
|
hasLocale( const ::com::sun::star::lang::Locale& rLocale )
|
|
|
|
throw(::com::sun::star::uno::RuntimeException);
|
|
|
|
|
|
|
|
// XThesaurus
|
|
|
|
virtual ::com::sun::star::uno::Sequence<
|
|
|
|
::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::linguistic2::XMeaning > > SAL_CALL
|
|
|
|
queryMeanings( const ::rtl::OUString& rTerm,
|
|
|
|
const ::com::sun::star::lang::Locale& rLocale,
|
|
|
|
const ::com::sun::star::beans::PropertyValues& rProperties )
|
|
|
|
throw(::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::uno::RuntimeException);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ThesDummy_Impl::~ThesDummy_Impl()
|
|
|
|
{
|
|
|
|
delete pLocaleSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ThesDummy_Impl::GetCfgLocales()
|
|
|
|
{
|
|
|
|
if (!pLocaleSeq)
|
|
|
|
{
|
2005-04-04 11:50:50 +00:00
|
|
|
SvtLinguConfig aCfg;
|
|
|
|
String aNode( A2OU( "ServiceManager/ThesaurusList" ) );
|
2002-02-19 12:25:41 +00:00
|
|
|
Sequence < OUString > aNodeNames( aCfg.GetNodeNames( aNode ) );
|
|
|
|
const OUString *pNodeNames = aNodeNames.getConstArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int32 nLen = aNodeNames.getLength();
|
2002-02-19 12:25:41 +00:00
|
|
|
pLocaleSeq = new Sequence< Locale >( nLen );
|
|
|
|
Locale *pLocale = pLocaleSeq->getArray();
|
2011-01-13 14:12:48 +01:00
|
|
|
for (sal_Int32 i = 0; i < nLen; ++i)
|
2002-02-19 12:25:41 +00:00
|
|
|
{
|
|
|
|
pLocale[i] = SvxCreateLocale(
|
2006-04-07 13:04:17 +00:00
|
|
|
MsLangId::convertIsoStringToLanguage( pNodeNames[i] ) );
|
2002-02-19 12:25:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-04 12:05:00 +00:00
|
|
|
void ThesDummy_Impl::GetThes_Impl()
|
|
|
|
{
|
|
|
|
// update configuration before accessing the service
|
2005-04-04 11:50:50 +00:00
|
|
|
if (SvxLinguConfigUpdate::IsNeedUpdateAll())
|
2002-12-04 12:05:00 +00:00
|
|
|
SvxLinguConfigUpdate::UpdateAll();
|
|
|
|
|
|
|
|
if (!xThes.is())
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
|
2002-12-04 12:05:00 +00:00
|
|
|
if (xLngSvcMgr.is())
|
|
|
|
xThes = xLngSvcMgr->getThesaurus();
|
|
|
|
|
|
|
|
if (xThes.is())
|
|
|
|
{
|
|
|
|
// no longer needed...
|
|
|
|
delete pLocaleSeq; pLocaleSeq = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-19 12:25:41 +00:00
|
|
|
uno::Sequence< lang::Locale > SAL_CALL
|
|
|
|
ThesDummy_Impl::getLocales()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
2005-04-04 11:50:50 +00:00
|
|
|
if (!SvxLinguConfigUpdate::IsNeedUpdateAll()) // configuration already update and thus lingu DLL's already loaded ?
|
2002-12-04 12:05:00 +00:00
|
|
|
GetThes_Impl();
|
2002-02-19 12:25:41 +00:00
|
|
|
if (xThes.is())
|
|
|
|
return xThes->getLocales();
|
2005-04-04 11:50:50 +00:00
|
|
|
else if (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
|
2002-02-19 12:25:41 +00:00
|
|
|
GetCfgLocales();
|
|
|
|
return *pLocaleSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL
|
|
|
|
ThesDummy_Impl::hasLocale( const lang::Locale& rLocale )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
2005-04-04 11:50:50 +00:00
|
|
|
if (!SvxLinguConfigUpdate::IsNeedUpdateAll()) // configuration already update and thus lingu DLL's already loaded ?
|
2002-12-04 12:05:00 +00:00
|
|
|
GetThes_Impl();
|
2002-02-19 12:25:41 +00:00
|
|
|
if (xThes.is())
|
|
|
|
return xThes->hasLocale( rLocale );
|
2005-04-04 11:50:50 +00:00
|
|
|
else if (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
|
|
|
|
GetCfgLocales();
|
2002-02-19 12:25:41 +00:00
|
|
|
GetCfgLocales();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool bFound = sal_False;
|
|
|
|
sal_Int32 nLen = pLocaleSeq->getLength();
|
2002-02-19 12:25:41 +00:00
|
|
|
const Locale *pLocale = pLocaleSeq->getConstArray();
|
|
|
|
const Locale *pEnd = pLocale + nLen;
|
|
|
|
for ( ; pLocale < pEnd && !bFound; ++pLocale)
|
|
|
|
{
|
|
|
|
bFound = pLocale->Language == rLocale.Language &&
|
|
|
|
pLocale->Country == rLocale.Country &&
|
|
|
|
pLocale->Variant == rLocale.Variant;
|
|
|
|
}
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL
|
|
|
|
ThesDummy_Impl::queryMeanings(
|
|
|
|
const rtl::OUString& rTerm,
|
|
|
|
const lang::Locale& rLocale,
|
|
|
|
const beans::PropertyValues& rProperties )
|
|
|
|
throw(lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
2002-12-04 12:05:00 +00:00
|
|
|
GetThes_Impl();
|
2002-02-19 12:25:41 +00:00
|
|
|
uno::Sequence< uno::Reference< linguistic2::XMeaning > > aRes;
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( xThes.is(), "Thesaurus missing" );
|
2002-02-19 12:25:41 +00:00
|
|
|
if (xThes.is())
|
|
|
|
aRes = xThes->queryMeanings( rTerm, rLocale, rProperties );
|
|
|
|
return aRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-20 09:41:36 +00:00
|
|
|
//! Dummy implementation in order to avoid loading of lingu DLL.
|
|
|
|
//! The dummy accesses the real implementation (and thus loading the DLL)
|
|
|
|
//! when it needs to be done only.
|
|
|
|
class SpellDummy_Impl :
|
2002-12-04 12:05:00 +00:00
|
|
|
public cppu::WeakImplHelper1< XSpellChecker1 >
|
2002-02-20 09:41:36 +00:00
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XSpellChecker1 > xSpell; // the real one...
|
2002-02-20 09:41:36 +00:00
|
|
|
|
|
|
|
void GetSpell_Impl();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// XSupportedLanguages (for XSpellChecker1)
|
|
|
|
virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL
|
|
|
|
getLanguages()
|
|
|
|
throw(::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual sal_Bool SAL_CALL
|
|
|
|
hasLanguage( sal_Int16 nLanguage )
|
|
|
|
throw(::com::sun::star::uno::RuntimeException);
|
|
|
|
|
|
|
|
// XSpellChecker1 (same as XSpellChecker but sal_Int16 for language)
|
|
|
|
virtual sal_Bool SAL_CALL
|
|
|
|
isValid( const ::rtl::OUString& rWord, sal_Int16 nLanguage,
|
|
|
|
const ::com::sun::star::beans::PropertyValues& rProperties )
|
|
|
|
throw(::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual ::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL
|
|
|
|
spell( const ::rtl::OUString& rWord, sal_Int16 nLanguage,
|
|
|
|
const ::com::sun::star::beans::PropertyValues& rProperties )
|
|
|
|
throw(::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::uno::RuntimeException);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void SpellDummy_Impl::GetSpell_Impl()
|
|
|
|
{
|
2002-12-04 12:05:00 +00:00
|
|
|
// update configuration before accessing the service
|
2005-04-04 11:50:50 +00:00
|
|
|
if (SvxLinguConfigUpdate::IsNeedUpdateAll())
|
2002-12-04 12:05:00 +00:00
|
|
|
SvxLinguConfigUpdate::UpdateAll();
|
|
|
|
|
2002-02-20 09:41:36 +00:00
|
|
|
if (!xSpell.is())
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
|
2002-02-20 09:41:36 +00:00
|
|
|
if (xLngSvcMgr.is())
|
2007-06-05 13:34:53 +00:00
|
|
|
xSpell = uno::Reference< XSpellChecker1 >( xLngSvcMgr->getSpellChecker(), UNO_QUERY );
|
2002-02-20 09:41:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Sequence< sal_Int16 > SAL_CALL
|
|
|
|
SpellDummy_Impl::getLanguages()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetSpell_Impl();
|
|
|
|
if (xSpell.is())
|
|
|
|
return xSpell->getLanguages();
|
|
|
|
else
|
|
|
|
return uno::Sequence< sal_Int16 >();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL
|
|
|
|
SpellDummy_Impl::hasLanguage( sal_Int16 nLanguage )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetSpell_Impl();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool bRes = sal_False;
|
2002-02-20 09:41:36 +00:00
|
|
|
if (xSpell.is())
|
|
|
|
bRes = xSpell->hasLanguage( nLanguage );
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL
|
|
|
|
SpellDummy_Impl::isValid( const rtl::OUString& rWord, sal_Int16 nLanguage,
|
|
|
|
const beans::PropertyValues& rProperties )
|
|
|
|
throw(lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetSpell_Impl();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool bRes = sal_True;
|
2002-02-20 09:41:36 +00:00
|
|
|
if (xSpell.is())
|
|
|
|
bRes = xSpell->isValid( rWord, nLanguage, rProperties );
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Reference< linguistic2::XSpellAlternatives > SAL_CALL
|
|
|
|
SpellDummy_Impl::spell( const rtl::OUString& rWord, sal_Int16 nLanguage,
|
|
|
|
const beans::PropertyValues& rProperties )
|
|
|
|
throw(lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetSpell_Impl();
|
|
|
|
uno::Reference< linguistic2::XSpellAlternatives > xRes;
|
|
|
|
if (xSpell.is())
|
|
|
|
xRes = xSpell->spell( rWord, nLanguage, rProperties );
|
|
|
|
return xRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Dummy implementation in order to avoid loading of lingu DLL.
|
|
|
|
//! The dummy accesses the real implementation (and thus loading the DLL)
|
|
|
|
//! when it needs to be done only.
|
|
|
|
class HyphDummy_Impl :
|
2002-12-04 12:05:00 +00:00
|
|
|
public cppu::WeakImplHelper1< XHyphenator >
|
2002-02-20 09:41:36 +00:00
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XHyphenator > xHyph; // the real one...
|
2002-02-20 09:41:36 +00:00
|
|
|
|
|
|
|
void GetHyph_Impl();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// XSupportedLocales
|
|
|
|
virtual ::com::sun::star::uno::Sequence<
|
|
|
|
::com::sun::star::lang::Locale > SAL_CALL
|
|
|
|
getLocales()
|
|
|
|
throw(::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual sal_Bool SAL_CALL
|
|
|
|
hasLocale( const ::com::sun::star::lang::Locale& rLocale )
|
|
|
|
throw(::com::sun::star::uno::RuntimeException);
|
|
|
|
|
|
|
|
// XHyphenator
|
|
|
|
virtual ::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL
|
|
|
|
hyphenate( const ::rtl::OUString& rWord,
|
|
|
|
const ::com::sun::star::lang::Locale& rLocale,
|
|
|
|
sal_Int16 nMaxLeading,
|
|
|
|
const ::com::sun::star::beans::PropertyValues& rProperties )
|
|
|
|
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& rWord,
|
|
|
|
const ::com::sun::star::lang::Locale& rLocale,
|
|
|
|
sal_Int16 nIndex,
|
|
|
|
const ::com::sun::star::beans::PropertyValues& rProperties )
|
|
|
|
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& rWord,
|
|
|
|
const ::com::sun::star::lang::Locale& rLocale,
|
|
|
|
const ::com::sun::star::beans::PropertyValues& rProperties )
|
|
|
|
throw(::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::uno::RuntimeException);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void HyphDummy_Impl::GetHyph_Impl()
|
|
|
|
{
|
2002-12-04 12:05:00 +00:00
|
|
|
// update configuration before accessing the service
|
2005-04-04 11:50:50 +00:00
|
|
|
if (SvxLinguConfigUpdate::IsNeedUpdateAll())
|
2002-12-04 12:05:00 +00:00
|
|
|
SvxLinguConfigUpdate::UpdateAll();
|
|
|
|
|
2002-02-20 09:41:36 +00:00
|
|
|
if (!xHyph.is())
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
|
2002-02-20 09:41:36 +00:00
|
|
|
if (xLngSvcMgr.is())
|
|
|
|
xHyph = xLngSvcMgr->getHyphenator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Sequence< lang::Locale > SAL_CALL
|
|
|
|
HyphDummy_Impl::getLocales()
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetHyph_Impl();
|
|
|
|
if (xHyph.is())
|
|
|
|
return xHyph->getLocales();
|
|
|
|
else
|
|
|
|
return uno::Sequence< lang::Locale >();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL
|
|
|
|
HyphDummy_Impl::hasLocale( const lang::Locale& rLocale )
|
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetHyph_Impl();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Bool bRes = sal_False;
|
2002-02-20 09:41:36 +00:00
|
|
|
if (xHyph.is())
|
|
|
|
bRes = xHyph->hasLocale( rLocale );
|
|
|
|
return bRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL
|
|
|
|
HyphDummy_Impl::hyphenate(
|
|
|
|
const rtl::OUString& rWord,
|
|
|
|
const lang::Locale& rLocale,
|
|
|
|
sal_Int16 nMaxLeading,
|
|
|
|
const beans::PropertyValues& rProperties )
|
|
|
|
throw(lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetHyph_Impl();
|
|
|
|
uno::Reference< linguistic2::XHyphenatedWord > xRes;
|
|
|
|
if (xHyph.is())
|
|
|
|
xRes = xHyph->hyphenate( rWord, rLocale, nMaxLeading, rProperties );
|
|
|
|
return xRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL
|
|
|
|
HyphDummy_Impl::queryAlternativeSpelling(
|
|
|
|
const rtl::OUString& rWord,
|
|
|
|
const lang::Locale& rLocale,
|
|
|
|
sal_Int16 nIndex,
|
|
|
|
const PropertyValues& rProperties )
|
|
|
|
throw(lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetHyph_Impl();
|
|
|
|
uno::Reference< linguistic2::XHyphenatedWord > xRes;
|
|
|
|
if (xHyph.is())
|
|
|
|
xRes = xHyph->queryAlternativeSpelling( rWord, rLocale, nIndex, rProperties );
|
|
|
|
return xRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Reference< linguistic2::XPossibleHyphens > SAL_CALL
|
|
|
|
HyphDummy_Impl::createPossibleHyphens(
|
|
|
|
const rtl::OUString& rWord,
|
|
|
|
const lang::Locale& rLocale,
|
|
|
|
const beans::PropertyValues& rProperties )
|
|
|
|
throw(lang::IllegalArgumentException,
|
|
|
|
uno::RuntimeException)
|
|
|
|
{
|
|
|
|
GetHyph_Impl();
|
|
|
|
uno::Reference< linguistic2::XPossibleHyphens > xRes;
|
|
|
|
if (xHyph.is())
|
|
|
|
xRes = xHyph->createPossibleHyphens( rWord, rLocale, rProperties );
|
|
|
|
return xRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
typedef cppu::WeakImplHelper1 < XEventListener > LinguMgrAppExitLstnrBaseClass;
|
|
|
|
|
2011-02-13 18:43:56 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
class LinguMgrAppExitLstnr : public LinguMgrAppExitLstnrBaseClass
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XComponent > xDesktop;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
LinguMgrAppExitLstnr();
|
|
|
|
virtual ~LinguMgrAppExitLstnr();
|
|
|
|
|
|
|
|
virtual void AtExit() = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// lang::XEventListener
|
|
|
|
virtual void SAL_CALL disposing(const EventObject& rSource)
|
|
|
|
throw( RuntimeException );
|
|
|
|
};
|
|
|
|
|
|
|
|
LinguMgrAppExitLstnr::LinguMgrAppExitLstnr()
|
|
|
|
{
|
|
|
|
// add object to frame::Desktop EventListeners in order to properly call
|
|
|
|
// the AtExit function at appliction exit.
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XMultiServiceFactory > xMgr = getProcessServiceFactory();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( xMgr.is() )
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
xDesktop = uno::Reference< XComponent > ( xMgr->createInstance(
|
2000-10-24 10:38:57 +00:00
|
|
|
OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) ) ), UNO_QUERY ) ;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xDesktop.is())
|
|
|
|
xDesktop->addEventListener( this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LinguMgrAppExitLstnr::~LinguMgrAppExitLstnr()
|
|
|
|
{
|
|
|
|
if (xDesktop.is())
|
|
|
|
{
|
|
|
|
xDesktop->removeEventListener( this );
|
|
|
|
xDesktop = NULL; //! release reference to desktop
|
|
|
|
}
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE(!xDesktop.is(), "reference to desktop should be realeased");
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LinguMgrAppExitLstnr::disposing(const EventObject& rSource)
|
|
|
|
throw( RuntimeException )
|
|
|
|
{
|
|
|
|
if (xDesktop.is() && rSource.Source == xDesktop)
|
|
|
|
{
|
|
|
|
xDesktop->removeEventListener( this );
|
|
|
|
xDesktop = NULL; //! release reference to desktop
|
|
|
|
|
|
|
|
AtExit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LinguMgrExitLstnr : public LinguMgrAppExitLstnr
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void AtExit();
|
|
|
|
};
|
|
|
|
|
|
|
|
void LinguMgrExitLstnr::AtExit()
|
|
|
|
{
|
|
|
|
// release references
|
2000-10-27 09:25:31 +00:00
|
|
|
LinguMgr::xLngSvcMgr = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
LinguMgr::xSpell = 0;
|
|
|
|
LinguMgr::xHyph = 0;
|
|
|
|
LinguMgr::xThes = 0;
|
|
|
|
LinguMgr::xDicList = 0;
|
|
|
|
LinguMgr::xProp = 0;
|
|
|
|
LinguMgr::xIgnoreAll = 0;
|
|
|
|
LinguMgr::xChangeAll = 0;
|
|
|
|
|
|
|
|
LinguMgr::bExiting = sal_True;
|
|
|
|
|
|
|
|
LinguMgr::pExitLstnr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LinguMgrExitLstnr * LinguMgr::pExitLstnr = 0;
|
|
|
|
sal_Bool LinguMgr::bExiting = sal_False;
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XLinguServiceManager > LinguMgr::xLngSvcMgr = 0;
|
|
|
|
uno::Reference< XSpellChecker1 > LinguMgr::xSpell = 0;
|
|
|
|
uno::Reference< XHyphenator > LinguMgr::xHyph = 0;
|
|
|
|
uno::Reference< XThesaurus > LinguMgr::xThes = 0;
|
|
|
|
uno::Reference< XDictionaryList > LinguMgr::xDicList = 0;
|
|
|
|
uno::Reference< XPropertySet > LinguMgr::xProp = 0;
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > LinguMgr::xIgnoreAll = 0;
|
|
|
|
uno::Reference< XDictionary > LinguMgr::xChangeAll = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-10-27 09:25:31 +00:00
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XLinguServiceManager > LinguMgr::GetLngSvcMgr()
|
2001-03-22 07:31:30 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
|
|
|
if (!xLngSvcMgr.is())
|
|
|
|
xLngSvcMgr = GetLngSvcMgr_Impl();
|
|
|
|
|
|
|
|
return xLngSvcMgr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XSpellChecker1 > LinguMgr::GetSpellChecker()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return xSpell.is() ? xSpell : GetSpell();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XHyphenator > LinguMgr::GetHyphenator()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return xHyph.is() ? xHyph : GetHyph();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XThesaurus > LinguMgr::GetThesaurus()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return xThes.is() ? xThes : GetThes();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionaryList > LinguMgr::GetDictionaryList()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return xDicList.is() ? xDicList : GetDicList();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XPropertySet > LinguMgr::GetLinguPropertySet()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return xProp.is() ? xProp : GetProp();
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > LinguMgr::GetStandardDic()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
//! don't hold reference to this
|
|
|
|
//! (it may be removed from dictionary list and needs to be
|
|
|
|
//! created empty if accessed again)
|
|
|
|
return GetStandard();
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > LinguMgr::GetIgnoreAllList()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return xIgnoreAll.is() ? xIgnoreAll : GetIgnoreAll();
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > LinguMgr::GetChangeAllList()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return xChangeAll.is() ? xChangeAll : GetChangeAll();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XSpellChecker1 > LinguMgr::GetSpell()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
2002-02-20 09:41:36 +00:00
|
|
|
//! use dummy implementation in order to avoid loading of lingu DLL
|
|
|
|
xSpell = new SpellDummy_Impl;
|
2000-09-18 16:07:07 +00:00
|
|
|
return xSpell;
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XHyphenator > LinguMgr::GetHyph()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
2002-02-20 09:41:36 +00:00
|
|
|
//! use dummy implementation in order to avoid loading of lingu DLL
|
|
|
|
xHyph = new HyphDummy_Impl;
|
2000-09-18 16:07:07 +00:00
|
|
|
return xHyph;
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XThesaurus > LinguMgr::GetThes()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
2002-02-19 12:25:41 +00:00
|
|
|
//! use dummy implementation in order to avoid loading of lingu DLL
|
|
|
|
//! when only the XSupportedLocales interface is used.
|
|
|
|
//! The dummy accesses the real implementation (and thus loading the DLL)
|
|
|
|
//! when "real" work needs to be done only.
|
|
|
|
xThes = new ThesDummy_Impl;
|
2000-09-18 16:07:07 +00:00
|
|
|
return xThes;
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionaryList > LinguMgr::GetDicList()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xMgr.is())
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
xDicList = uno::Reference< XDictionaryList > ( xMgr->createInstance(
|
2002-12-04 12:05:00 +00:00
|
|
|
A2OU("com.sun.star.linguistic2.DictionaryList") ), UNO_QUERY );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return xDicList;
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XPropertySet > LinguMgr::GetProp()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xMgr.is())
|
|
|
|
{
|
2007-06-05 13:34:53 +00:00
|
|
|
xProp = uno::Reference< XPropertySet > ( xMgr->createInstance(
|
2002-12-04 12:05:00 +00:00
|
|
|
A2OU("com.sun.star.linguistic2.LinguProperties") ), UNO_QUERY );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return xProp;
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > LinguMgr::GetIgnoreAll()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionaryList > xTmpDicList( GetDictionaryList() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xTmpDicList.is())
|
|
|
|
{
|
2008-12-15 12:01:46 +00:00
|
|
|
xIgnoreAll = uno::Reference< XDictionary > ( xTmpDicList->getDictionaryByName(
|
2002-12-04 12:05:00 +00:00
|
|
|
A2OU("IgnoreAllList") ), UNO_QUERY );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return xIgnoreAll;
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > LinguMgr::GetChangeAll()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!pExitLstnr)
|
|
|
|
pExitLstnr = new LinguMgrExitLstnr;
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionaryList > _xDicList( GetDictionaryList() , UNO_QUERY );
|
2006-10-12 11:41:07 +00:00
|
|
|
if (_xDicList.is())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2008-12-15 12:01:46 +00:00
|
|
|
xChangeAll = uno::Reference< XDictionary > (
|
2006-10-12 11:41:07 +00:00
|
|
|
_xDicList->createDictionary(
|
2002-12-04 12:05:00 +00:00
|
|
|
A2OU("ChangeAllList"),
|
2000-09-18 16:07:07 +00:00
|
|
|
SvxCreateLocale( LANGUAGE_NONE ),
|
|
|
|
DictionaryType_NEGATIVE, String() ), UNO_QUERY );
|
|
|
|
}
|
|
|
|
return xChangeAll;
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > LinguMgr::GetStandard()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// Tries to return a dictionary which may hold positive entries is
|
|
|
|
// persistent and not read-only.
|
|
|
|
|
|
|
|
if (bExiting)
|
|
|
|
return 0;
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionaryList > xTmpDicList( GetDictionaryList() );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!xTmpDicList.is())
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
const OUString aDicName( RTL_CONSTASCII_USTRINGPARAM( "standard.dic" ) );
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > xDic( xTmpDicList->getDictionaryByName( aDicName ),
|
2000-09-18 16:07:07 +00:00
|
|
|
UNO_QUERY );
|
2001-06-18 10:24:13 +00:00
|
|
|
if (!xDic.is())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-10-27 09:25:31 +00:00
|
|
|
// try to create standard dictionary
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionary > xTmp;
|
2000-10-27 09:25:31 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
xTmp = xTmpDicList->createDictionary( aDicName,
|
|
|
|
SvxCreateLocale( LANGUAGE_NONE ),
|
|
|
|
DictionaryType_POSITIVE,
|
2008-03-25 15:42:43 +00:00
|
|
|
linguistic::GetWritableDictionaryURL( aDicName ) );
|
2000-10-27 09:25:31 +00:00
|
|
|
}
|
2011-12-09 02:56:30 +09:00
|
|
|
catch(const com::sun::star::uno::Exception &)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// add new dictionary to list
|
|
|
|
if (xTmp.is())
|
2010-06-24 09:08:52 +02:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
xTmpDicList->addDictionary( xTmp );
|
2010-06-24 09:08:52 +02:00
|
|
|
xTmp->setActive( sal_True );
|
|
|
|
}
|
2008-12-15 12:01:46 +00:00
|
|
|
xDic = uno::Reference< XDictionary > ( xTmp, UNO_QUERY );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2003-04-15 16:30:17 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XStorable > xStor( xDic, UNO_QUERY );
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( xDic.is() && xDic->getDictionaryType() == DictionaryType_POSITIVE,
|
2001-06-18 10:24:13 +00:00
|
|
|
"wrong dictionary type");
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( xDic.is() && SvxLocaleToLanguage( xDic->getLocale() ) == LANGUAGE_NONE,
|
2001-06-18 10:24:13 +00:00
|
|
|
"wrong dictionary language");
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_ENSURE( !xStor.is() || (xStor->hasLocation() && !xStor->isReadonly()),
|
2001-06-18 10:24:13 +00:00
|
|
|
"dictionary not editable" );
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return xDic;
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XSpellChecker1 > SvxGetSpellChecker()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetSpellChecker();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XHyphenator > SvxGetHyphenator()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetHyphenator();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XThesaurus > SvxGetThesaurus()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetThesaurus();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionaryList > SvxGetDictionaryList()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetDictionaryList();
|
|
|
|
}
|
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XPropertySet > SvxGetLinguPropertySet()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetLinguPropertySet();
|
|
|
|
}
|
|
|
|
|
2011-02-16 16:34:02 -05:00
|
|
|
//TODO: remove argument or provide SvxGetIgnoreAllList with the same one
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > SvxGetOrCreatePosDic(
|
2007-06-05 13:34:53 +00:00
|
|
|
uno::Reference< XDictionaryList > /* xDicList */ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetStandardDic();
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > SvxGetIgnoreAllList()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetIgnoreAllList();
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
uno::Reference< XDictionary > SvxGetChangeAllList()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return LinguMgr::GetChangeAllList();
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
|
|
|
|
|
|
|
|
SvxAlternativeSpelling SvxGetAltSpelling(
|
|
|
|
const ::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::linguistic2::XHyphenatedWord > & rHyphWord )
|
|
|
|
{
|
|
|
|
SvxAlternativeSpelling aRes;
|
|
|
|
if (rHyphWord.is() && rHyphWord->isAlternativeSpelling())
|
|
|
|
{
|
|
|
|
OUString aWord( rHyphWord->getWord() ),
|
2002-09-19 07:41:29 +00:00
|
|
|
aAltWord( rHyphWord->getHyphenatedWord() );
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int16 nHyphenationPos = rHyphWord->getHyphenationPos(),
|
2000-09-18 16:07:07 +00:00
|
|
|
nHyphenPos = rHyphWord->getHyphenPos();
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int16 nLen = (sal_Int16)aWord.getLength();
|
|
|
|
sal_Int16 nAltLen = (sal_Int16)aAltWord.getLength();
|
2000-09-18 16:07:07 +00:00
|
|
|
const sal_Unicode *pWord = aWord.getStr(),
|
2002-09-19 07:41:29 +00:00
|
|
|
*pAltWord = aAltWord.getStr();
|
|
|
|
|
|
|
|
// count number of chars from the left to the
|
|
|
|
// hyphenation pos / hyphen pos that are equal
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int16 nL = 0;
|
2002-09-19 07:41:29 +00:00
|
|
|
while (nL <= nHyphenationPos && nL <= nHyphenPos
|
|
|
|
&& pWord[ nL ] == pAltWord[ nL ])
|
|
|
|
++nL;
|
|
|
|
// count number of chars from the right to the
|
|
|
|
// hyphenation pos / hyphen pos that are equal
|
2011-01-13 14:12:48 +01:00
|
|
|
sal_Int16 nR = 0;
|
|
|
|
sal_Int32 nIdx = nLen - 1;
|
|
|
|
sal_Int32 nAltIdx = nAltLen - 1;
|
2002-09-19 07:41:29 +00:00
|
|
|
while (nIdx > nHyphenationPos && nAltIdx > nHyphenPos
|
|
|
|
&& pWord[ nIdx-- ] == pAltWord[ nAltIdx-- ])
|
|
|
|
++nR;
|
|
|
|
|
|
|
|
aRes.aReplacement = OUString( aAltWord.copy( nL, nAltLen - nL - nR ) );
|
2011-01-13 14:12:48 +01:00
|
|
|
aRes.nChangedPos = (sal_Int16) nL;
|
2002-09-19 07:41:29 +00:00
|
|
|
aRes.nChangedLength = nLen - nL - nR;
|
2011-01-13 14:12:48 +01:00
|
|
|
aRes.bIsAltSpelling = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
aRes.xHyphWord = rHyphWord;
|
|
|
|
}
|
|
|
|
return aRes;
|
|
|
|
}
|
2000-10-27 09:25:31 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-06-05 13:34:53 +00:00
|
|
|
SvxDicListChgClamp::SvxDicListChgClamp( uno::Reference< XDictionaryList > &rxDicList ) :
|
2000-09-18 16:07:07 +00:00
|
|
|
xDicList ( rxDicList )
|
|
|
|
{
|
|
|
|
if (xDicList.is())
|
|
|
|
{
|
|
|
|
xDicList->beginCollectEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SvxDicListChgClamp::~SvxDicListChgClamp()
|
|
|
|
{
|
|
|
|
if (xDicList.is())
|
|
|
|
{
|
|
|
|
xDicList->endCollectEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
short SvxDicError( Window *pParent, sal_Int16 nError )
|
|
|
|
{
|
|
|
|
short nRes = 0;
|
|
|
|
if (DIC_ERR_NONE != nError)
|
|
|
|
{
|
|
|
|
int nRid;
|
|
|
|
switch (nError)
|
|
|
|
{
|
|
|
|
case DIC_ERR_FULL : nRid = RID_SVXSTR_DIC_ERR_FULL; break;
|
|
|
|
case DIC_ERR_READONLY : nRid = RID_SVXSTR_DIC_ERR_READONLY; break;
|
|
|
|
default:
|
|
|
|
nRid = RID_SVXSTR_DIC_ERR_UNKNOWN;
|
2011-03-29 19:12:39 +02:00
|
|
|
OSL_FAIL("unexpected case");
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2010-01-06 19:26:54 +01:00
|
|
|
nRes = InfoBox( pParent, EE_RESSTR( nRid ) ).Execute();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return nRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
LanguageType SvxLocaleToLanguage( const Locale& rLocale )
|
|
|
|
{
|
|
|
|
if ( rLocale.Language.getLength() == 0 )
|
|
|
|
return LANGUAGE_NONE;
|
|
|
|
|
2006-04-07 13:04:17 +00:00
|
|
|
return MsLangId::convertLocaleToLanguage( rLocale );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Locale& SvxLanguageToLocale( Locale& rLocale, LanguageType eLang )
|
|
|
|
{
|
2011-02-13 18:43:56 +01:00
|
|
|
if ( eLang != LANGUAGE_NONE )
|
2006-04-07 13:04:17 +00:00
|
|
|
MsLangId::convertLanguageToLocale( eLang, rLocale );
|
|
|
|
else
|
|
|
|
rLocale = Locale();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
return rLocale;
|
|
|
|
}
|
|
|
|
|
|
|
|
Locale SvxCreateLocale( LanguageType eLang )
|
|
|
|
{
|
2006-04-07 13:04:17 +00:00
|
|
|
Locale aLocale;
|
2011-02-13 18:43:56 +01:00
|
|
|
if ( eLang != LANGUAGE_NONE )
|
2006-04-07 13:04:17 +00:00
|
|
|
MsLangId::convertLanguageToLocale( eLang, aLocale );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-04-07 13:04:17 +00:00
|
|
|
return aLocale;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|