diff options
Diffstat (limited to 'linguistic/source/convdiclist.cxx')
-rw-r--r-- | linguistic/source/convdiclist.cxx | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/linguistic/source/convdiclist.cxx b/linguistic/source/convdiclist.cxx index 1d5729b34b..37a536ba87 100644 --- a/linguistic/source/convdiclist.cxx +++ b/linguistic/source/convdiclist.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -33,11 +33,9 @@ #include <tools/fsys.hxx> #include <tools/stream.hxx> #include <tools/urlobj.hxx> -#include <svtools/pathoptions.hxx> -#include <svtools/useroptions.hxx> -#include <svtools/lingucfg.hxx> -#include <sfx2/docfile.hxx> -#include <vcl/svapp.hxx> +#include <unotools/pathoptions.hxx> +#include <unotools/useroptions.hxx> +#include <unotools/lingucfg.hxx> #include <rtl/instance.hxx> #include <cppuhelper/factory.hxx> // helper for factories #include <unotools/localfilehelper.hxx> @@ -98,7 +96,7 @@ String GetConvDicMainURL( const String &rDicName, const String &rDirectoryURL ) DBG_ASSERT(!aURLObj.HasError(), "invalid URL"); if (aURLObj.HasError()) return String(); - else + else return aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); } @@ -139,7 +137,7 @@ public: virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - + // looks for conversion dictionaries with the specified extension // in the directory and adds them to the container void AddConvDics( const String &rSearchDirPathURL, const String &rExtension ); @@ -149,10 +147,10 @@ public: INT32 GetCount() const { return aConvDics.getLength(); } uno::Reference< XConversionDictionary > GetByName( const OUString& rName ); - + const uno::Reference< XConversionDictionary > GetByIndex( INT32 nIdx ) - { - return aConvDics.getConstArray()[nIdx]; + { + return aConvDics.getConstArray()[nIdx]; } }; @@ -190,7 +188,7 @@ void ConvDicNameContainer::FlushDics() const } -INT32 ConvDicNameContainer::GetIndexByName_Impl( +INT32 ConvDicNameContainer::GetIndexByName_Impl( const OUString& rName ) { INT32 nRes = -1; @@ -205,7 +203,7 @@ INT32 ConvDicNameContainer::GetIndexByName_Impl( } -uno::Reference< XConversionDictionary > ConvDicNameContainer::GetByName( +uno::Reference< XConversionDictionary > ConvDicNameContainer::GetByName( const OUString& rName ) { uno::Reference< XConversionDictionary > xRes; @@ -216,7 +214,7 @@ uno::Reference< XConversionDictionary > ConvDicNameContainer::GetByName( } -uno::Type SAL_CALL ConvDicNameContainer::getElementType( ) +uno::Type SAL_CALL ConvDicNameContainer::getElementType( ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -224,7 +222,7 @@ uno::Type SAL_CALL ConvDicNameContainer::getElementType( ) } -sal_Bool SAL_CALL ConvDicNameContainer::hasElements( ) +sal_Bool SAL_CALL ConvDicNameContainer::hasElements( ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -232,7 +230,7 @@ sal_Bool SAL_CALL ConvDicNameContainer::hasElements( ) } -uno::Any SAL_CALL ConvDicNameContainer::getByName( const OUString& rName ) +uno::Any SAL_CALL ConvDicNameContainer::getByName( const OUString& rName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -243,7 +241,7 @@ uno::Any SAL_CALL ConvDicNameContainer::getByName( const OUString& rName ) } -uno::Sequence< OUString > SAL_CALL ConvDicNameContainer::getElementNames( ) +uno::Sequence< OUString > SAL_CALL ConvDicNameContainer::getElementNames( ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -258,7 +256,7 @@ uno::Sequence< OUString > SAL_CALL ConvDicNameContainer::getElementNames( ) } -sal_Bool SAL_CALL ConvDicNameContainer::hasByName( const OUString& rName ) +sal_Bool SAL_CALL ConvDicNameContainer::hasByName( const OUString& rName ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -266,9 +264,9 @@ sal_Bool SAL_CALL ConvDicNameContainer::hasByName( const OUString& rName ) } -void SAL_CALL ConvDicNameContainer::replaceByName( - const OUString& rName, - const uno::Any& rElement ) +void SAL_CALL ConvDicNameContainer::replaceByName( + const OUString& rName, + const uno::Any& rElement ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -284,27 +282,27 @@ void SAL_CALL ConvDicNameContainer::replaceByName( } -void SAL_CALL ConvDicNameContainer::insertByName( - const OUString& rName, - const Any& rElement ) +void SAL_CALL ConvDicNameContainer::insertByName( + const OUString& rName, + const Any& rElement ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - + if (GetByName( rName ).is()) throw ElementExistException(); uno::Reference< XConversionDictionary > xNew; rElement >>= xNew; if (!xNew.is() || xNew->getName() != rName) throw IllegalArgumentException(); - + INT32 nLen = aConvDics.getLength(); aConvDics.realloc( nLen + 1 ); aConvDics.getArray()[ nLen ] = xNew; } -void SAL_CALL ConvDicNameContainer::removeByName( const OUString& rName ) +void SAL_CALL ConvDicNameContainer::removeByName( const OUString& rName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -345,11 +343,11 @@ void SAL_CALL ConvDicNameContainer::removeByName( const OUString& rName ) } -void ConvDicNameContainer::AddConvDics( - const String &rSearchDirPathURL, +void ConvDicNameContainer::AddConvDics( + const String &rSearchDirPathURL, const String &rExtension ) { - const Sequence< OUString > aDirCnt( + const Sequence< OUString > aDirCnt( utl::LocalFileHelper::GetFolderContents( rSearchDirPathURL, FALSE ) ); const OUString *pDirCnt = aDirCnt.getConstArray(); INT32 nEntries = aDirCnt.getLength(); @@ -372,8 +370,8 @@ void ConvDicNameContainer::AddConvDics( { // get decoded dictionary file name INetURLObject aURLObj( aURL ); - String aDicName = aURLObj.getBase( INetURLObject::LAST_SEGMENT, - true, INetURLObject::DECODE_WITH_CHARSET, + String aDicName = aURLObj.getBase( INetURLObject::LAST_SEGMENT, + true, INetURLObject::DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8 ); uno::Reference < XConversionDictionary > xDic; @@ -408,7 +406,7 @@ class StaticWithInit_ { public: /** Gets the static. Mutual exclusion is performed using the osl global mutex. - + @return static variable */ @@ -466,7 +464,7 @@ ConvDicList::~ConvDicList() if (!bDisposing && pNameContainer) pNameContainer->FlushDics(); - + pExitListener->Deactivate(); } @@ -485,7 +483,7 @@ ConvDicNameContainer & ConvDicList::GetNameContainer() if (!pNameContainer) { pNameContainer = new ConvDicNameContainer( *this ); - pNameContainer->AddConvDics( GetDictionaryWriteablePath(), + pNameContainer->AddConvDics( GetDictionaryWriteablePath(), A2OU( CONV_DIC_EXT ) ); xNameContainer = pNameContainer; @@ -496,7 +494,7 @@ ConvDicNameContainer & ConvDicList::GetNameContainer() const OUString *pActiveConvDics = aOpt.aActiveConvDics.getConstArray(); for (INT32 i = 0; i < nLen; ++i) { - uno::Reference< XConversionDictionary > xDic = + uno::Reference< XConversionDictionary > xDic = pNameContainer->GetByName( pActiveConvDics[i] ); if (xDic.is()) xDic->setActive( sal_True ); @@ -527,10 +525,10 @@ uno::Reference< container::XNameContainer > SAL_CALL ConvDicList::getDictionaryC } -uno::Reference< XConversionDictionary > SAL_CALL ConvDicList::addNewDictionary( - const OUString& rName, - const Locale& rLocale, - sal_Int16 nConvDicType ) +uno::Reference< XConversionDictionary > SAL_CALL ConvDicList::addNewDictionary( + const OUString& rName, + const Locale& rLocale, + sal_Int16 nConvDicType ) throw (NoSupportException, ElementExistException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -539,7 +537,7 @@ uno::Reference< XConversionDictionary > SAL_CALL ConvDicList::addNewDictionary( if (GetNameContainer().hasByName( rName )) throw ElementExistException(); - + uno::Reference< XConversionDictionary > xRes; String aDicMainURL( GetConvDicMainURL( rName, GetDictionaryWriteablePath() ) ); if (nLang == LANGUAGE_KOREAN && @@ -552,7 +550,7 @@ uno::Reference< XConversionDictionary > SAL_CALL ConvDicList::addNewDictionary( { xRes = new ConvDic( rName, nLang, nConvDicType, FALSE, aDicMainURL ); } - + if (!xRes.is()) throw NoSupportException(); else @@ -566,20 +564,20 @@ uno::Reference< XConversionDictionary > SAL_CALL ConvDicList::addNewDictionary( } -uno::Sequence< OUString > SAL_CALL ConvDicList::queryConversions( - const OUString& rText, - sal_Int32 nStartPos, - sal_Int32 nLength, - const Locale& rLocale, - sal_Int16 nConversionDictionaryType, - ConversionDirection eDirection, - sal_Int32 nTextConversionOptions ) +uno::Sequence< OUString > SAL_CALL ConvDicList::queryConversions( + const OUString& rText, + sal_Int32 nStartPos, + sal_Int32 nLength, + const Locale& rLocale, + sal_Int16 nConversionDictionaryType, + ConversionDirection eDirection, + sal_Int32 nTextConversionOptions ) throw (IllegalArgumentException, NoSupportException, RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); /*INT16 nLang = LocaleToLanguage( rLocale );*/ - + INT32 nCount = 0; uno::Sequence< OUString > aRes( 20 ); OUString *pRes = aRes.getArray(); @@ -595,7 +593,7 @@ uno::Sequence< OUString > SAL_CALL ConvDicList::queryConversions( bSupported |= bMatch; if (bMatch && xDic->isActive()) { - Sequence< OUString > aNewConv( xDic->getConversions( + Sequence< OUString > aNewConv( xDic->getConversions( rText, nStartPos, nLength, eDirection, nTextConversionOptions ) ); INT32 nNewLen = aNewConv.getLength(); @@ -621,21 +619,21 @@ uno::Sequence< OUString > SAL_CALL ConvDicList::queryConversions( } -sal_Int16 SAL_CALL ConvDicList::queryMaxCharCount( - const Locale& rLocale, - sal_Int16 nConversionDictionaryType, - ConversionDirection eDirection ) +sal_Int16 SAL_CALL ConvDicList::queryMaxCharCount( + const Locale& rLocale, + sal_Int16 nConversionDictionaryType, + ConversionDirection eDirection ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - + sal_Int16 nRes = 0; GetNameContainer(); INT32 nLen = GetNameContainer().GetCount(); for (INT32 i = 0; i < nLen; ++i) { const uno::Reference< XConversionDictionary > xDic( GetNameContainer().GetByIndex(i) ); - if (xDic.is() && + if (xDic.is() && xDic->getLocale() == rLocale && xDic->getConversionType() == nConversionDictionaryType) { @@ -648,7 +646,7 @@ sal_Int16 SAL_CALL ConvDicList::queryMaxCharCount( } -void SAL_CALL ConvDicList::dispose( ) +void SAL_CALL ConvDicList::dispose( ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -663,8 +661,8 @@ void SAL_CALL ConvDicList::dispose( ) } -void SAL_CALL ConvDicList::addEventListener( - const uno::Reference< XEventListener >& rxListener ) +void SAL_CALL ConvDicList::addEventListener( + const uno::Reference< XEventListener >& rxListener ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -673,8 +671,8 @@ void SAL_CALL ConvDicList::addEventListener( } -void SAL_CALL ConvDicList::removeEventListener( - const uno::Reference< XEventListener >& rxListener ) +void SAL_CALL ConvDicList::removeEventListener( + const uno::Reference< XEventListener >& rxListener ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -683,7 +681,7 @@ void SAL_CALL ConvDicList::removeEventListener( } -OUString SAL_CALL ConvDicList::getImplementationName( ) +OUString SAL_CALL ConvDicList::getImplementationName( ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -691,7 +689,7 @@ OUString SAL_CALL ConvDicList::getImplementationName( ) } -sal_Bool SAL_CALL ConvDicList::supportsService( const OUString& rServiceName ) +sal_Bool SAL_CALL ConvDicList::supportsService( const OUString& rServiceName ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -699,7 +697,7 @@ sal_Bool SAL_CALL ConvDicList::supportsService( const OUString& rServiceName ) } -uno::Sequence< OUString > SAL_CALL ConvDicList::getSupportedServiceNames( ) +uno::Sequence< OUString > SAL_CALL ConvDicList::getSupportedServiceNames( ) throw (RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); @@ -707,7 +705,7 @@ uno::Sequence< OUString > SAL_CALL ConvDicList::getSupportedServiceNames( ) } -uno::Sequence< OUString > ConvDicList::getSupportedServiceNames_Static() +uno::Sequence< OUString > ConvDicList::getSupportedServiceNames_Static() throw() { uno::Sequence< OUString > aSNS( 1 ); @@ -718,7 +716,7 @@ uno::Sequence< OUString > ConvDicList::getSupportedServiceNames_Static() /////////////////////////////////////////////////////////////////////////// -uno::Reference< uno::XInterface > SAL_CALL ConvDicList_CreateInstance( +uno::Reference< uno::XInterface > SAL_CALL ConvDicList_CreateInstance( const uno::Reference< XMultiServiceFactory > & /*rSMgr*/ ) throw(Exception) { @@ -750,7 +748,7 @@ sal_Bool SAL_CALL ConvDicList_writeInfo( } -void * SAL_CALL ConvDicList_getFactory( +void * SAL_CALL ConvDicList_getFactory( const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * ) { |