From c4d051c5dbee532264e1bfc2ccdb337c6dcf83ed Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 16 Jan 2013 16:28:45 +0200 Subject: fdo#46808, Adapt ConversionDictionaryList UNO service to new style Change-Id: I16efc7466a2dbcccb4dddefdccada8549e7252f8 --- .../chinese_dictionarydialog.cxx | 86 ++++++++++------------ .../chinese_dictionarydialog.hxx | 3 - 2 files changed, 38 insertions(+), 51 deletions(-) (limited to 'svx') 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 #include #include -#include +#include #include #include #include @@ -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 #include -#include #include #include @@ -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; }; //............................................................................. -- cgit