diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-13 10:43:34 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-05-14 08:08:25 +0200 |
commit | ef0af5032ad283ffb3b4521eb097a118d58f332a (patch) | |
tree | 823553af06bf42a914d38e19beb3e3fc25f3bc52 /linguistic | |
parent | bd27671c0ccc3505efb9fc493e0cfc63df449856 (diff) |
fdo#46808, Convert linguistic2::LingProperties to new style
API-CHANGE:
Removed the following interfaces from the IDL because no-one was
using them:
interface com::sun::star::beans::XFastPropertySet;
interface com::sun::star::lang::XComponent;
But the service still implements them, so old code should keep on
working.
Change-Id: Iab058fb42bd1a54e0b9632e99e564fdc0869fe6e
Diffstat (limited to 'linguistic')
-rw-r--r-- | linguistic/inc/iprcache.hxx | 5 | ||||
-rw-r--r-- | linguistic/source/hyphdsp.hxx | 6 | ||||
-rw-r--r-- | linguistic/source/iprcache.cxx | 10 | ||||
-rw-r--r-- | linguistic/source/lngopt.cxx | 26 | ||||
-rw-r--r-- | linguistic/source/lngopt.hxx | 81 | ||||
-rw-r--r-- | linguistic/source/misc.cxx | 33 |
6 files changed, 122 insertions, 39 deletions
diff --git a/linguistic/inc/iprcache.hxx b/linguistic/inc/iprcache.hxx index c38264f29dbc..0d3b8a5895a5 100644 --- a/linguistic/inc/iprcache.hxx +++ b/linguistic/inc/iprcache.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp> #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> +#include <com/sun/star/linguistic2/XLinguProperties.hpp> #include <rtl/string.hxx> #include <i18nlangtag/lang.h> @@ -61,7 +62,7 @@ class FlushListener : ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > xDicList; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > xPropSet; + ::com::sun::star::linguistic2::XLinguProperties > xPropSet; Flushable *pFlushObj; // don't allow to use copy-constructor and assignment-operator @@ -75,7 +76,7 @@ public: inline void SetFlushObj( Flushable *pFO) { pFlushObj = pFO; } void SetDicList( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > &rDL ); - void SetPropSet( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &rPS ); + void SetPropSet( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLinguProperties > &rPS ); //XEventListener virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw(::com::sun::star::uno::RuntimeException); diff --git a/linguistic/source/hyphdsp.hxx b/linguistic/source/hyphdsp.hxx index 6bcc72b23b1d..cebfbd3bafcb 100644 --- a/linguistic/source/hyphdsp.hxx +++ b/linguistic/source/hyphdsp.hxx @@ -55,7 +55,7 @@ class HyphenatorDispatcher : HyphSvcByLangMap_t aSvcMap; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > xPropSet; + ::com::sun::star::linguistic2::XLinguProperties > xPropSet; ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > xDicList; @@ -66,7 +66,7 @@ class HyphenatorDispatcher : HyphenatorDispatcher & operator = (const HyphenatorDispatcher &); inline ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > + ::com::sun::star::linguistic2::XLinguProperties > GetPropSet(); inline ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > @@ -139,7 +139,7 @@ public: inline ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > + ::com::sun::star::linguistic2::XLinguProperties > HyphenatorDispatcher::GetPropSet() { return xPropSet.is() ? diff --git a/linguistic/source/iprcache.cxx b/linguistic/source/iprcache.cxx index 327203473ff3..2b5a37ce03d8 100644 --- a/linguistic/source/iprcache.cxx +++ b/linguistic/source/iprcache.cxx @@ -59,7 +59,7 @@ static const struct static void lcl_AddAsPropertyChangeListener( Reference< XPropertyChangeListener > xListener, - Reference< XPropertySet > &rPropSet ) + Reference< XLinguProperties > &rPropSet ) { if (xListener.is() && rPropSet.is()) { @@ -74,7 +74,7 @@ static void lcl_AddAsPropertyChangeListener( static void lcl_RemoveAsPropertyChangeListener( Reference< XPropertyChangeListener > xListener, - Reference< XPropertySet > &rPropSet ) + Reference< XLinguProperties > &rPropSet ) { if (xListener.is() && rPropSet.is()) { @@ -126,7 +126,7 @@ void FlushListener::SetDicList( Reference<XSearchableDictionaryList> &rDL ) } -void FlushListener::SetPropSet( Reference< XPropertySet > &rPS ) +void FlushListener::SetPropSet( Reference< XLinguProperties > &rPS ) { MutexGuard aGuard( GetLinguMutex() ); @@ -207,14 +207,14 @@ SpellCache::SpellCache() xFlushLstnr = pFlushLstnr; Reference<XSearchableDictionaryList> aDictionaryList(GetDictionaryList()); pFlushLstnr->SetDicList( aDictionaryList ); //! after reference is established - Reference<XPropertySet> aPropertySet(GetLinguProperties()); + Reference<XLinguProperties> aPropertySet(GetLinguProperties()); pFlushLstnr->SetPropSet( aPropertySet ); //! after reference is established } SpellCache::~SpellCache() { Reference<XSearchableDictionaryList> aEmptyList; - Reference<XPropertySet> aEmptySet; + Reference<XLinguProperties> aEmptySet; pFlushLstnr->SetDicList( aEmptyList ); pFlushLstnr->SetPropSet( aEmptySet ); } diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx index fc69367d75be..75babc93dfce 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -458,10 +458,34 @@ uno::Sequence< OUString > LinguProps::getSupportedServiceNames_Static() MutexGuard aGuard( GetLinguMutex() ); uno::Sequence< OUString > aSNS( 1 ); // more than 1 service possible - aSNS.getArray()[0] = SN_LINGU_PROPERTIES; + aSNS.getArray()[0] = "com.sun.star.linguistic2.LinguProperties"; return aSNS; } +sal_Bool LinguProps::getPropertyBool(const OUString& aPropertyName) throw (css::uno::RuntimeException) +{ + uno::Any any = getPropertyValue(aPropertyName); + sal_Bool b = sal_False; + any >>= b; + return b; +} + +sal_Int16 LinguProps::getPropertyInt16(const OUString& aPropertyName) throw (css::uno::RuntimeException) +{ + uno::Any any = getPropertyValue(aPropertyName); + sal_Int16 b = sal_False; + any >>= b; + return b; +} + +Locale LinguProps::getPropertyLocale(const OUString& aPropertyName) throw (css::uno::RuntimeException) +{ + uno::Any any = getPropertyValue(aPropertyName); + css::lang::Locale b; + any >>= b; + return b; +} + void * SAL_CALL LinguProps_getFactory( const sal_Char * pImplName, XMultiServiceFactory *pServiceManager, void * ) { diff --git a/linguistic/source/lngopt.hxx b/linguistic/source/lngopt.hxx index bc46e0c59ac2..c4bbc6ce5550 100644 --- a/linguistic/source/lngopt.hxx +++ b/linguistic/source/lngopt.hxx @@ -27,12 +27,14 @@ #include <cppuhelper/interfacecontainer.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XFastPropertySet.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/linguistic2/XLinguProperties.hpp> #include <unotools/lingucfg.hxx> #include <svl/itemprop.hxx> #include <unotools/configitem.hxx> +#include <unotools/linguprops.hxx> #include <com/sun/star/uno/Any.h> #include <tools/solar.h> @@ -92,7 +94,7 @@ typedef cppu::OMultiTypeInterfaceContainerHelperVar class LinguProps : public cppu::WeakImplHelper5 < - com::sun::star::beans::XPropertySet, + com::sun::star::linguistic2::XLinguProperties, com::sun::star::beans::XFastPropertySet, com::sun::star::beans::XPropertyAccess, com::sun::star::lang::XComponent, @@ -113,9 +115,84 @@ class LinguProps : void launchEvent( const ::com::sun::star::beans::PropertyChangeEvent &rEvt ) const; + sal_Bool getPropertyBool(const OUString& aPropertyName) throw (css::uno::RuntimeException); + sal_Int16 getPropertyInt16(const OUString& aPropertyName) throw (css::uno::RuntimeException); + css::lang::Locale getPropertyLocale(const OUString& aPropertyName) throw (css::uno::RuntimeException); + void setProperty(const OUString& aPropertyName, sal_Bool p1) throw (css::uno::RuntimeException) + { setPropertyValue( aPropertyName, css::uno::Any(p1) ); } + void setProperty(const OUString& aPropertyName, sal_Int16 p1) throw (css::uno::RuntimeException) + { setPropertyValue( aPropertyName, css::uno::Any(p1) ); } + void setProperty(const OUString& aPropertyName, css::lang::Locale p1) throw (css::uno::RuntimeException) + { setPropertyValue( aPropertyName, css::uno::Any(p1) ); } + public: LinguProps(); + virtual sal_Bool SAL_CALL getIsUseDictionaryList() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_USE_DICTIONARY_LIST); } + virtual void SAL_CALL setIsUseDictionaryList(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_USE_DICTIONARY_LIST, p1); } + virtual sal_Bool SAL_CALL getIsIgnoreControlCharacters() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_IGNORE_CONTROL_CHARACTERS); } + virtual void SAL_CALL setIsIgnoreControlCharacters(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_IGNORE_CONTROL_CHARACTERS, p1); } + virtual sal_Bool SAL_CALL getIsSpellUpperCase() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_SPELL_UPPER_CASE); } + virtual void SAL_CALL setIsSpellUpperCase(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_SPELL_UPPER_CASE, p1); } + virtual sal_Bool SAL_CALL getIsSpellWithDigits() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_SPELL_WITH_DIGITS); } + virtual void SAL_CALL setIsSpellWithDigits(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_SPELL_WITH_DIGITS, p1); } + virtual sal_Bool SAL_CALL getIsSpellCapitalization() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_SPELL_CAPITALIZATION); } + virtual void SAL_CALL setIsSpellCapitalization(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_SPELL_CAPITALIZATION, p1); } + virtual sal_Int16 SAL_CALL getHyphMinLeading() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_HYPH_MIN_LEADING); } + virtual void SAL_CALL setHyphMinLeading(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty(UPN_HYPH_MIN_LEADING, p1); } + virtual sal_Int16 SAL_CALL getHyphMinTrailing() throw (css::uno::RuntimeException) + { return getPropertyInt16(UPN_HYPH_MIN_TRAILING); } + virtual void SAL_CALL setHyphMinTrailing(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty(UPN_HYPH_MIN_TRAILING, p1); } + virtual sal_Int16 SAL_CALL getHyphMinWordLength() throw (css::uno::RuntimeException) + { return getPropertyInt16(UPN_HYPH_MIN_WORD_LENGTH); } + virtual void SAL_CALL setHyphMinWordLength(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty(UPN_HYPH_MIN_WORD_LENGTH, p1); } + virtual com::sun::star::lang::Locale SAL_CALL getDefaultLocale() throw (css::uno::RuntimeException) + { return getPropertyLocale(UPN_DEFAULT_LOCALE); } + virtual void SAL_CALL setDefaultLocale(const com::sun::star::lang::Locale& p1) throw (css::uno::RuntimeException) + { setProperty(UPN_DEFAULT_LOCALE, p1); } + virtual sal_Bool SAL_CALL getIsHyphAuto() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_HYPH_AUTO); } + virtual void SAL_CALL setIsHyphAuto(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_HYPH_AUTO, p1); } + virtual sal_Bool SAL_CALL getIsHyphSpecial() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_HYPH_SPECIAL); } + virtual void SAL_CALL setIsHyphSpecial(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_HYPH_SPECIAL, p1); } + virtual sal_Bool SAL_CALL getIsSpellAuto() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_SPELL_AUTO); } + virtual void SAL_CALL setIsSpellAuto(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_SPELL_AUTO, p1); } + virtual sal_Bool SAL_CALL getIsSpellSpecial() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_SPELL_SPECIAL); } + virtual void SAL_CALL setIsSpellSpecial(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_SPELL_SPECIAL, p1); } + virtual sal_Bool SAL_CALL getIsWrapReverse() throw (css::uno::RuntimeException) + { return getPropertyBool(UPN_IS_WRAP_REVERSE); } + virtual void SAL_CALL setIsWrapReverse(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty(UPN_IS_WRAP_REVERSE, p1); } + virtual com::sun::star::lang::Locale SAL_CALL getDefaultLocale_CJK() throw (css::uno::RuntimeException) + { return getPropertyLocale(UPN_DEFAULT_LOCALE_CJK); } + virtual void SAL_CALL setDefaultLocale_CJK(const com::sun::star::lang::Locale& p1) throw (css::uno::RuntimeException) + { setProperty(UPN_DEFAULT_LOCALE_CJK, p1); } + virtual css::lang::Locale SAL_CALL getDefaultLocale_CTL() throw (css::uno::RuntimeException) + { return getPropertyLocale(UPN_DEFAULT_LOCALE_CTL); } + virtual void SAL_CALL setDefaultLocale_CTL(const com::sun::star::lang::Locale& p1) throw (css::uno::RuntimeException) + { setProperty(UPN_DEFAULT_LOCALE_CTL, p1); } + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index 10e343f756e6..91c59b5bae7b 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -24,19 +24,19 @@ #include <svl/lngmisc.hxx> #include <ucbhelper/content.hxx> #include <i18nlangtag/languagetag.hxx> -#include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XFastPropertySet.hpp> #include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/PropertyValues.hpp> #include <com/sun/star/frame/XTerminateListener.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XStorable.hpp> - -#include <com/sun/star/beans/PropertyValues.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/Reference.h> #include <com/sun/star/linguistic2/DictionaryType.hpp> #include <com/sun/star/linguistic2/DictionaryList.hpp> +#include <com/sun/star/linguistic2/LinguProperties.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Reference.h> #include <comphelper/processfactory.hxx> #include <unotools/localedatawrapper.hxx> #include <unotools/syslocale.hxx> @@ -741,28 +741,9 @@ sal_Bool IsNumeric( const String &rText ) -uno::Reference< XInterface > GetOneInstanceService( const char *pServiceName ) -{ - uno::Reference< XInterface > xRef; - - uno::Reference< XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory() ); - try - { - xRef = xMgr->createInstance( OUString::createFromAscii( pServiceName ) ); - } - catch (const uno::Exception &) - { - DBG_ASSERT( 0, "createInstance failed" ); - } - - return xRef; -} - -uno::Reference< XPropertySet > GetLinguProperties() +uno::Reference< XLinguProperties > GetLinguProperties() { - return uno::Reference< XPropertySet > ( - GetOneInstanceService( SN_LINGU_PROPERTIES ), UNO_QUERY ); + return LinguProperties::create( comphelper::getProcessComponentContext() ); } uno::Reference< XSearchableDictionaryList > GetDictionaryList() |