diff options
author | Noel Grandin <noel@peralex.com> | 2013-01-16 16:28:45 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-02-11 08:02:11 +0200 |
commit | c4d051c5dbee532264e1bfc2ccdb337c6dcf83ed (patch) | |
tree | d6a6bd49e9cfcfc46e3cd8fd905526fc97e2ed85 | |
parent | a00fe5cd4aa115e131919c4dbfea87c94b51e044 (diff) |
fdo#46808, Adapt ConversionDictionaryList UNO service to new style
Change-Id: I16efc7466a2dbcccb4dddefdccada8549e7252f8
-rw-r--r-- | cui/source/dialogs/hangulhanjadlg.cxx | 43 | ||||
-rw-r--r-- | i18npool/source/textconversion/textconversion_ko.cxx | 7 | ||||
-rw-r--r-- | i18npool/source/textconversion/textconversion_zh.cxx | 6 | ||||
-rw-r--r-- | offapi/UnoApi_offapi.mk | 2 | ||||
-rw-r--r-- | offapi/com/sun/star/linguistic2/ConversionDictionaryList.idl | 7 | ||||
-rw-r--r-- | offapi/type_reference/types.rdb | bin | 7440384 -> 7440384 bytes | |||
-rw-r--r-- | svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx | 86 | ||||
-rw-r--r-- | svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx | 3 |
8 files changed, 61 insertions, 93 deletions
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index 0c623d38ec4b..d994258066f2 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -32,7 +32,7 @@ #include <unotools/linguprops.hxx> #include <com/sun/star/linguistic2/ConversionDictionaryType.hpp> #include <com/sun/star/linguistic2/ConversionDirection.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/linguistic2/ConversionDictionaryList.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/util/XFlushable.hpp> @@ -932,41 +932,32 @@ namespace svx { if( !m_xConversionDictionaryList.is() ) { - Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) - { - m_xConversionDictionaryList = Reference< XConversionDictionaryList >( xMgr->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.ConversionDictionaryList")) ), - UNO_QUERY ); - } + m_xConversionDictionaryList = ConversionDictionaryList::create( ::comphelper::getProcessComponentContext() ); } m_aDictList.clear(); m_aDictsLB.Clear(); - if( m_xConversionDictionaryList.is() ) + Reference< XNameContainer > xNameCont = m_xConversionDictionaryList->getDictionaryContainer(); + Reference< XNameAccess > xNameAccess = Reference< XNameAccess >( xNameCont, UNO_QUERY ); + if( xNameAccess.is() ) { - Reference< XNameContainer > xNameCont = m_xConversionDictionaryList->getDictionaryContainer(); - Reference< XNameAccess > xNameAccess = Reference< XNameAccess >( xNameCont, UNO_QUERY ); - if( xNameAccess.is() ) - { - Sequence< ::rtl::OUString > aDictNames( xNameAccess->getElementNames() ); + Sequence< ::rtl::OUString > aDictNames( xNameAccess->getElementNames() ); - const ::rtl::OUString* pDic = aDictNames.getConstArray(); - sal_Int32 nCount = aDictNames.getLength(); + const ::rtl::OUString* pDic = aDictNames.getConstArray(); + sal_Int32 nCount = aDictNames.getLength(); - sal_Int32 i; - for( i = 0 ; i < nCount ; ++i ) + sal_Int32 i; + for( i = 0 ; i < nCount ; ++i ) + { + Any aAny( xNameAccess->getByName( pDic[ i ] ) ); + Reference< XConversionDictionary > xDic; + if( ( aAny >>= xDic ) && xDic.is() ) { - Any aAny( xNameAccess->getByName( pDic[ i ] ) ); - Reference< XConversionDictionary > xDic; - if( ( aAny >>= xDic ) && xDic.is() ) + if( LANGUAGE_KOREAN == LanguageTag( xDic->getLocale() ).getLanguageType() ) { - if( LANGUAGE_KOREAN == LanguageTag( xDic->getLocale() ).getLanguageType() ) - { - m_aDictList.push_back( xDic ); - AddDict( xDic->getName(), xDic->isActive() ); - } + m_aDictList.push_back( xDic ); + AddDict( xDic->getName(), xDic->isActive() ); } } } diff --git a/i18npool/source/textconversion/textconversion_ko.cxx b/i18npool/source/textconversion/textconversion_ko.cxx index 84534296882d..bb86903f41c9 100644 --- a/i18npool/source/textconversion/textconversion_ko.cxx +++ b/i18npool/source/textconversion/textconversion_ko.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/linguistic2/ConversionDirection.hpp> #include <com/sun/star/linguistic2/ConversionDictionaryType.hpp> +#include <com/sun/star/linguistic2/ConversionDictionaryList.hpp> #include <rtl/ustrbuf.hxx> #include <unicode/uchar.h> @@ -50,11 +51,7 @@ TextConversion_ko::TextConversion_ko( const Reference < XComponentContext >& xCo if ( xI.is() ) xI->queryInterface( getCppuType((const Reference< XConversionDictionary>*)0) ) >>= xCD; - xI = xContext->getServiceManager()->createInstanceWithContext( - OUString("com.sun.star.linguistic2.ConversionDictionaryList"), xContext); - - if ( xI.is() ) - xI->queryInterface( getCppuType((const Reference< XConversionDictionaryList>*)0) ) >>= xCDL; + xCDL = ConversionDictionaryList::create(xContext); maxLeftLength = maxRightLength = 1; diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx index ae57063af1c8..94c1cd85e1af 100644 --- a/i18npool/source/textconversion/textconversion_zh.cxx +++ b/i18npool/source/textconversion/textconversion_zh.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/linguistic2/ConversionDirection.hpp> #include <com/sun/star/linguistic2/ConversionDictionaryType.hpp> +#include <com/sun/star/linguistic2/ConversionDictionaryList.hpp> #include <comphelper/string.hxx> using namespace com::sun::star::lang; @@ -37,10 +38,7 @@ namespace com { namespace sun { namespace star { namespace i18n { TextConversion_zh::TextConversion_zh( const Reference < XComponentContext >& xContext ) { - Reference < XInterface > xI = xContext->getServiceManager()->createInstanceWithContext( - OUString("com.sun.star.linguistic2.ConversionDictionaryList"), xContext); - if ( xI.is() ) - xI->queryInterface( getCppuType((const Reference< XConversionDictionaryList>*)0) ) >>= xCDL; + xCDL = ConversionDictionaryList::create(xContext); implementationName = "com.sun.star.i18n.TextConversion_zh"; } diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index eda41014c68d..6788d86f49bd 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -172,6 +172,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/i18n,\ Transliteration \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/linguistic2,\ + ConversionDictionaryList \ LanguageGuessing \ LinguServiceManager \ Proofreader \ @@ -899,7 +900,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/image,\ )) $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/linguistic2,\ ConversionDictionary \ - ConversionDictionaryList \ Dictionary \ DictionaryList \ HangulHanjaConversionDictionary \ diff --git a/offapi/com/sun/star/linguistic2/ConversionDictionaryList.idl b/offapi/com/sun/star/linguistic2/ConversionDictionaryList.idl index 598f10f24ceb..1a722b8fd952 100644 --- a/offapi/com/sun/star/linguistic2/ConversionDictionaryList.idl +++ b/offapi/com/sun/star/linguistic2/ConversionDictionaryList.idl @@ -20,7 +20,6 @@ #define __com_sun_star_linguistic2_ConversionDictionaryList_idl__ #include <com/sun/star/linguistic2/XConversionDictionaryList.idl> -#include <com/sun/star/lang/XComponent.idl> module com { module sun { module star { module linguistic2 { @@ -42,11 +41,7 @@ module com { module sun { module star { module linguistic2 { @since OOo 1.1.2 */ -published service ConversionDictionaryList -{ - interface com::sun::star::linguistic2::XConversionDictionaryList; - interface com::sun::star::lang::XComponent; -}; +published service ConversionDictionaryList : XConversionDictionaryList; }; }; }; }; diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb Binary files differindex 3528bb76df75..a80baa46eadb 100644 --- a/offapi/type_reference/types.rdb +++ b/offapi/type_reference/types.rdb diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx index 265afdf48478..cd6d963fd71f 100644 --- a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx +++ b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx @@ -25,7 +25,7 @@ #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/linguistic2/ConversionDictionaryType.hpp> #include <com/sun/star/linguistic2/ConversionPropertyType.hpp> -#include <com/sun/star/linguistic2/XConversionDictionaryList.hpp> +#include <com/sun/star/linguistic2/ConversionDictionaryList.hpp> #include <com/sun/star/linguistic2/XConversionPropertyType.hpp> #include <com/sun/star/util/XFlushable.hpp> #include <com/sun/star/lang/Locale.hpp> @@ -469,7 +469,6 @@ ChineseDictionaryDialog::ChineseDictionaryDialog( Window* pParent ) , m_aBP_Cancel( this, TextConversionDlgs_ResId( PB_CANCEL ) ) , m_aBP_Help( this, TextConversionDlgs_ResId( PB_HELP ) ) , m_xContext( 0 ) - , m_xFactory( 0 ) { FreeResource(); @@ -497,58 +496,50 @@ ChineseDictionaryDialog::ChineseDictionaryDialog( Window* pParent ) if(!m_xContext.is()) m_xContext = Reference< XComponentContext >( ::cppu::defaultBootstrap_InitialComponentContext() ); if(m_xContext.is()) - m_xFactory = Reference< lang::XMultiComponentFactory >( m_xContext->getServiceManager() ); - if(m_xFactory.is()) { - Reference< linguistic2::XConversionDictionaryList > xDictionaryList( - m_xFactory->createInstanceWithContext( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.ConversionDictionaryList")) - , m_xContext), uno::UNO_QUERY); - if( xDictionaryList.is() ) + Reference< linguistic2::XConversionDictionaryList > xDictionaryList = linguistic2::ConversionDictionaryList::create(m_xContext); + Reference< container::XNameContainer > xContainer( xDictionaryList->getDictionaryContainer() ); + if(xContainer.is()) { - Reference< container::XNameContainer > xContainer( xDictionaryList->getDictionaryContainer() ); - if(xContainer.is()) + try { - try + rtl::OUString aNameTo_Simplified( RTL_CONSTASCII_USTRINGPARAM("ChineseT2S") ); + rtl::OUString aNameTo_Traditional( RTL_CONSTASCII_USTRINGPARAM("ChineseS2T") ); + lang::Locale aLocale; + aLocale.Language = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("zh") ); + + if( xContainer->hasByName( aNameTo_Simplified ) ) + xDictionary_To_Simplified = Reference< linguistic2::XConversionDictionary >( + xContainer->getByName( aNameTo_Simplified ), UNO_QUERY ); + else { - rtl::OUString aNameTo_Simplified( RTL_CONSTASCII_USTRINGPARAM("ChineseT2S") ); - rtl::OUString aNameTo_Traditional( RTL_CONSTASCII_USTRINGPARAM("ChineseS2T") ); - lang::Locale aLocale; - aLocale.Language = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("zh") ); - - if( xContainer->hasByName( aNameTo_Simplified ) ) - xDictionary_To_Simplified = Reference< linguistic2::XConversionDictionary >( - xContainer->getByName( aNameTo_Simplified ), UNO_QUERY ); - else - { - aLocale.Country = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TW") ); - xDictionary_To_Simplified = Reference< linguistic2::XConversionDictionary >( - xDictionaryList->addNewDictionary( aNameTo_Simplified - , aLocale, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE - ), UNO_QUERY ); - } - if (xDictionary_To_Simplified.is()) - xDictionary_To_Simplified->setActive( sal_True ); - - - if( xContainer->hasByName( aNameTo_Traditional ) ) - xDictionary_To_Traditional = Reference< linguistic2::XConversionDictionary >( - xContainer->getByName( aNameTo_Traditional ), UNO_QUERY ); - else - { - aLocale.Country = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CN") ); - xDictionary_To_Traditional = Reference< linguistic2::XConversionDictionary >( - xDictionaryList->addNewDictionary( aNameTo_Traditional - , aLocale, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE - ), UNO_QUERY ); - } - if (xDictionary_To_Traditional.is()) - xDictionary_To_Traditional->setActive( sal_True ); - + aLocale.Country = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TW") ); + xDictionary_To_Simplified = Reference< linguistic2::XConversionDictionary >( + xDictionaryList->addNewDictionary( aNameTo_Simplified + , aLocale, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE + ), UNO_QUERY ); } - catch( uno::Exception& ) + if (xDictionary_To_Simplified.is()) + xDictionary_To_Simplified->setActive( sal_True ); + + + if( xContainer->hasByName( aNameTo_Traditional ) ) + xDictionary_To_Traditional = Reference< linguistic2::XConversionDictionary >( + xContainer->getByName( aNameTo_Traditional ), UNO_QUERY ); + else { + aLocale.Country = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CN") ); + xDictionary_To_Traditional = Reference< linguistic2::XConversionDictionary >( + xDictionaryList->addNewDictionary( aNameTo_Traditional + , aLocale, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE + ), UNO_QUERY ); } + if (xDictionary_To_Traditional.is()) + xDictionary_To_Traditional->setActive( sal_True ); + + } + catch( uno::Exception& ) + { } } } @@ -605,7 +596,6 @@ ChineseDictionaryDialog::ChineseDictionaryDialog( Window* pParent ) ChineseDictionaryDialog::~ChineseDictionaryDialog() { m_xContext=0; - m_xFactory=0; delete m_pHeaderBar; } diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx index ef45cebdbea2..98de4dba436b 100644 --- a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx +++ b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx @@ -32,7 +32,6 @@ // header for class SvHeaderTabListBox #include <svtools/svtabbx.hxx> #include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/linguistic2/XConversionDictionary.hpp> #include <vector> @@ -181,8 +180,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; - ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiComponentFactory> m_xFactory; }; //............................................................................. |