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 <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>
|
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>
|
2012-10-26 14:24:46 +02:00
|
|
|
#include <com/sun/star/linguistic2/LinguServiceManager.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/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>
|
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
|
|
|
|
2012-10-26 14:24:46 +02:00
|
|
|
static uno::Reference< XLinguServiceManager2 > GetLngSvcMgr_Impl()
|
2002-02-19 12:25:41 +00:00
|
|
|
{
|
2012-10-26 14:24:46 +02:00
|
|
|
uno::Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
|
|
|
|
uno::Reference< XLinguServiceManager2 > xRes = LinguServiceManager::create(xContext);
|
2002-02-19 12:25:41 +00:00
|
|
|
return xRes;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! 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()
|
|
|
|
{
|
|
|
|
if (!xThes.is())
|
|
|
|
{
|
2012-10-26 14:24:46 +02:00
|
|
|
uno::Reference< XLinguServiceManager2 > xLngSvcMgr( GetLngSvcMgr_Impl() );
|
|
|
|
xThes = xLngSvcMgr->getThesaurus();
|
2002-12-04 12:05:00 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2012-07-11 09:50:49 +01: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)
|
|
|
|
{
|
2012-07-11 09:50:49 +01: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()
|
|
|
|
{
|
|
|
|
if (!xSpell.is())
|
|
|
|
{
|
2012-10-26 14:24:46 +02:00
|
|
|
uno::Reference< XLinguServiceManager2 > xLngSvcMgr( GetLngSvcMgr_Impl() );
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
if (!xHyph.is())
|
|
|
|
{
|
2012-10-26 14:24:46 +02:00
|
|
|
uno::Reference< XLinguServiceManager2 > xLngSvcMgr( GetLngSvcMgr_Impl() );
|
|
|
|
xHyph = xLngSvcMgr->getHyphenator();
|
2002-02-20 09:41:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
2012-10-26 14:24:46 +02:00
|
|
|
uno::Reference< XLinguServiceManager2 > LinguMgr::xLngSvcMgr = 0;
|
2007-06-05 13:34:53 +00:00
|
|
|
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
|
|
|
|
2012-10-26 14:24:46 +02:00
|
|
|
uno::Reference< XLinguServiceManager2 > 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 )
|
|
|
|
{
|
2011-12-23 10:25:18 -02:00
|
|
|
if ( rLocale.Language.isEmpty() )
|
2000-09-18 16:07:07 +00:00
|
|
|
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: */
|