include/svx/chinese_translation_unodialog.hxx                              |   
83 +++++
 include/svx/svxdllapi.h                                                    |   
 7 
 sc/Library_sc.mk                                                           |   
 1 
 sc/source/ui/view/cellsh1.cxx                                              |   
87 +----
 sc/ucalc_setup.mk                                                          |   
 1 
 sd/CppunitTest_sd_uimpress.mk                                              |   
 1 
 sd/Library_sd.mk                                                           |   
 1 
 sd/source/ui/func/fuhhconv.cxx                                             |   
82 +----
 solenv/clang-format/excludelist                                            |   
 2 
 svx/Library_textconversiondlgs.mk                                          |   
 6 
 svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx |  
161 ----------
 svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx |  
119 -------
 svx/util/textconversiondlgs.component                                      |   
26 -
 sw/CppunitTest_sw_uwriter.mk                                               |   
 1 
 sw/Library_sw.mk                                                           |   
 1 
 sw/source/uibase/shells/annotsh.cxx                                        |   
86 +----
 sw/source/uibase/shells/drwtxtsh.cxx                                       |   
47 --
 sw/source/uibase/uiview/viewling.cxx                                       |  
134 +++-----
 18 files changed, 241 insertions(+), 605 deletions(-)

New commits:
commit f9a01110b56775a3798efddf080773145a7723bb
Author:     Noel Grandin <[email protected]>
AuthorDate: Sat Jun 14 15:35:46 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Jun 14 19:34:28 2025 +0200

    no need to use UNO to get to ChineseTranslation_UnoDialog
    
    Change-Id: Ibcae13ba0b96b283d595e2e9f3dc8e99548c892d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186498
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/include/svx/chinese_translation_unodialog.hxx 
b/include/svx/chinese_translation_unodialog.hxx
new file mode 100644
index 000000000000..199896022cb6
--- /dev/null
+++ b/include/svx/chinese_translation_unodialog.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <sal/config.h>
+#include <svx/svxdllapi.h>
+
+#include <memory>
+
+#include <com/sun/star/awt/XWindow.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer4.hxx>
+#include <mutex>
+
+
+namespace textconversiondlgs
+{
+
+
+/** This class provides the chinese translation dialog as a uno component.
+
+It can be created via lang::XMultiComponentFactory::createInstanceWithContext
+with servicename "com.sun.star.linguistic2.ChineseTranslationDialog"
+or implementation name "com.sun.star.comp.linguistic2.ChineseTranslationDialog"
+
+It can be initialized via the XInitialization interface with the following 
single parameter:
+PropertyValue-Parameter: Name="ParentWindow" Type="awt::XWindow".
+
+It can be executed via the ui::dialogs::XExecutableDialog interface.
+
+Made settings can be retrieved via beans::XPropertySet interface.
+Following properties are available (read only and not bound):
+1) Name="IsDirectionToSimplified" Type="sal_Bool"
+2) Name="IsUseCharacterVariants" Type="sal_Bool"
+3) Name="IsTranslateCommonTerms" Type="sal_Bool"
+
+The dialog gets this information from the registry on execute and writes it 
back to the registry if ended with OK.
+*/
+
+class ChineseTranslationDialog;
+
+class TEXTCONVERSIONDLGS_DLLPUBLIC ChineseTranslation_UnoDialog : public 
::cppu::WeakImplHelper <>
+{
+public:
+    ChineseTranslation_UnoDialog(const css::uno::Reference< css::awt::XWindow 
>& xParentWindow);
+    virtual ~ChineseTranslation_UnoDialog() override;
+
+    sal_Int16 execute();
+
+    bool getIsDirectionToSimplified();
+    bool getIsTranslateCommonTerms();
+
+private:
+
+    void impl_DeleteDialog();
+
+private:
+    css::uno::Reference< css::awt::XWindow > m_xParentWindow;
+
+    std::unique_ptr<ChineseTranslationDialog> m_xDialog;
+};
+
+
+} //end namespace textconversiondlgs
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/svxdllapi.h b/include/svx/svxdllapi.h
index f799f3d50838..9d4a50525c98 100644
--- a/include/svx/svxdllapi.h
+++ b/include/svx/svxdllapi.h
@@ -36,6 +36,13 @@
 #endif
 #define SVXCORE_DLLPRIVATE SAL_DLLPRIVATE
 
+#if defined(TEXTCONVERSIONDLGS_DLLIMPLEMENTATION)
+#define TEXTCONVERSIONDLGS_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define TEXTCONVERSIONDLGS_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+#define TEXTCONVERSIONDLGS_DLLPRIVATE SAL_DLLPRIVATE
+
 #endif // INCLUDED_SVX_SVXDLLAPI_H
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 5a0aa6107562..4bf6ee233f1d 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -90,6 +90,7 @@ $(eval $(call gb_Library_use_libraries,sc,\
     svt \
     svx \
     svxcore \
+       textconversiondlgs \
     tk \
     tl \
     ucbhelper \
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index b0a6c605714f..6d75b512a797 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -40,6 +40,7 @@
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
 #include <svx/svxdlg.hxx>
+#include <svx/chinese_translation_unodialog.hxx>
 #include <sot/formats.hxx>
 #include <svx/postattr.hxx>
 #include <editeng/fontitem.hxx>
@@ -2010,68 +2011,30 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
         case SID_CHINESE_CONVERSION:
             {
                 //open ChineseTranslationDialog
-                uno::Reference< uno::XComponentContext > 
xContext(::comphelper::getProcessComponentContext());
-                if(xContext.is())
-                {
-                    Reference< lang::XMultiComponentFactory > xMCF( 
xContext->getServiceManager() );
-                    if(xMCF.is())
-                    {
-                        Reference< ui::dialogs::XExecutableDialog > xDialog(
-                                xMCF->createInstanceWithContext(
-                                    
u"com.sun.star.linguistic2.ChineseTranslationDialog"_ustr
-                                    , xContext),
-                                UNO_QUERY);
-                        Reference< lang::XInitialization > xInit( xDialog, 
UNO_QUERY );
-                        if( xInit.is() )
-                        {
-                            //  initialize dialog
-                            uno::Sequence<uno::Any> 
aSeq(comphelper::InitAnyPropertySequence(
-                            {
-                                {"ParentWindow", uno::Any(Reference< 
awt::XWindow >())}
-                            }));
-                            xInit->initialize( aSeq );
-
-                            //execute dialog
-                            sal_Int16 nDialogRet = xDialog->execute();
-                            if( RET_OK == nDialogRet )
-                            {
-                                //get some parameters from the dialog
-                                bool bToSimplified = true;
-                                bool bUseVariants = true;
-                                bool bCommonTerms = true;
-                                Reference< beans::XPropertySet >  xProp( 
xDialog, UNO_QUERY );
-                                if( xProp.is() )
-                                {
-                                    try
-                                    {
-                                        
xProp->getPropertyValue(u"IsDirectionToSimplified"_ustr) >>= bToSimplified;
-                                        
xProp->getPropertyValue(u"IsUseCharacterVariants"_ustr) >>= bUseVariants;
-                                        
xProp->getPropertyValue(u"IsTranslateCommonTerms"_ustr) >>= bCommonTerms;
-                                    }
-                                    catch( Exception& )
-                                    {
-                                    }
-                                }
-
-                                //execute translation
-                                LanguageType eSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
-                                LanguageType eTargetLang = bToSimplified ? 
LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
-                                sal_Int32 nOptions = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
-                                if( !bCommonTerms )
-                                    nOptions |= 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
-
-                                vcl::Font aTargetFont = 
OutputDevice::GetDefaultFont(
-                                                    
DefaultFontType::CJK_SPREADSHEET,
-                                                    eTargetLang, 
GetDefaultFontFlags::OnlyOne );
-                                ScConversionParam aConvParam( 
SC_CONVERSION_CHINESE_TRANSL,
-                                    eSourceLang, eTargetLang, 
std::move(aTargetFont), nOptions, false );
-                                pTabViewShell->DoSheetConversion( aConvParam );
-                            }
-                        }
-                        Reference< lang::XComponent > xComponent( xDialog, 
UNO_QUERY );
-                        if( xComponent.is() )
-                            xComponent->dispose();
-                    }
+                rtl::Reference< 
textconversiondlgs::ChineseTranslation_UnoDialog > xDialog(new 
textconversiondlgs::ChineseTranslation_UnoDialog({}));
+
+                //execute dialog
+                sal_Int16 nDialogRet = xDialog->execute();
+                if( RET_OK == nDialogRet )
+                {
+                    //get some parameters from the dialog
+                    bool bToSimplified = xDialog->getIsDirectionToSimplified();
+                    bool bUseVariants = false;
+                    bool bCommonTerms = xDialog->getIsTranslateCommonTerms();
+
+                    //execute translation
+                    LanguageType eSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+                    LanguageType eTargetLang = bToSimplified ? 
LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+                    sal_Int32 nOptions = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+                    if( !bCommonTerms )
+                        nOptions |= 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+                    vcl::Font aTargetFont = OutputDevice::GetDefaultFont(
+                                        DefaultFontType::CJK_SPREADSHEET,
+                                        eTargetLang, 
GetDefaultFontFlags::OnlyOne );
+                    ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL,
+                        eSourceLang, eTargetLang, std::move(aTargetFont), 
nOptions, false );
+                    pTabViewShell->DoSheetConversion( aConvParam );
                 }
             }
             break;
diff --git a/sc/ucalc_setup.mk b/sc/ucalc_setup.mk
index 63351a87aa28..af400da43014 100644
--- a/sc/ucalc_setup.mk
+++ b/sc/ucalc_setup.mk
@@ -67,6 +67,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ucalc$(1), \
     svx \
     svxcore \
        test \
+       textconversiondlgs \
     tk \
     tl \
     ucbhelper \
diff --git a/sd/CppunitTest_sd_uimpress.mk b/sd/CppunitTest_sd_uimpress.mk
index bff68b0386d0..4577e4b4ee4c 100644
--- a/sd/CppunitTest_sd_uimpress.mk
+++ b/sd/CppunitTest_sd_uimpress.mk
@@ -46,6 +46,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\
     svxcore \
     svx \
        test \
+       textconversiondlgs \
     tk \
     tl \
     ucbhelper \
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index a05aba888eb6..d4a8c3a277a3 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -94,6 +94,7 @@ $(eval $(call gb_Library_use_libraries,sd,\
        svt \
        svxcore \
        svx \
+       textconversiondlgs \
        tk \
        tl \
        ucbhelper \
diff --git a/sd/source/ui/func/fuhhconv.cxx b/sd/source/ui/func/fuhhconv.cxx
index f6de081cfffe..3a0df5ea426f 100644
--- a/sd/source/ui/func/fuhhconv.cxx
+++ b/sd/source/ui/func/fuhhconv.cxx
@@ -27,6 +27,7 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <svl/style.hxx>
+#include <svx/chinese_translation_unodialog.hxx>
 #include <editeng/eeitem.hxx>
 #include <editeng/langitem.hxx>
 #include <editeng/fontitem.hxx>
@@ -183,68 +184,31 @@ void FuHangulHanjaConversion::ConvertStyles( LanguageType 
nTargetLanguage, const
 void FuHangulHanjaConversion::StartChineseConversion()
 {
     //open ChineseTranslationDialog
-    uno::Reference< uno::XComponentContext > 
xContext(::comphelper::getProcessComponentContext());
-    if(!xContext.is())
-        return;
-
-    Reference< lang::XMultiComponentFactory > xMCF( 
xContext->getServiceManager() );
-    if(!xMCF.is())
-        return;
+    rtl::Reference< textconversiondlgs::ChineseTranslation_UnoDialog > 
xDialog(new textconversiondlgs::ChineseTranslation_UnoDialog({}));
 
-    Reference< ui::dialogs::XExecutableDialog > xDialog(
-            
xMCF->createInstanceWithContext(u"com.sun.star.linguistic2.ChineseTranslationDialog"_ustr
-                , xContext), UNO_QUERY);
-    Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
-    if( xInit.is() )
+    //execute dialog
+    sal_Int16 nDialogRet = xDialog->execute();
+    if( RET_OK == nDialogRet )
     {
-        //  initialize dialog
-        Reference< awt::XWindow > xDialogParentWindow;
-        Sequence<Any> aSeq(comphelper::InitAnyPropertySequence(
-        {
-            {"ParentWindow", uno::Any(xDialogParentWindow)}
-        }));
-        xInit->initialize( aSeq );
-
-        //execute dialog
-        sal_Int16 nDialogRet = xDialog->execute();
-        if( RET_OK == nDialogRet )
-        {
-            //get some parameters from the dialog
-            bool bToSimplified = true;
-            bool bUseVariants = true;
-            bool bCommonTerms = true;
-            Reference< beans::XPropertySet >  xProp( xDialog, UNO_QUERY );
-            if( xProp.is() )
-            {
-                try
-                {
-                    xProp->getPropertyValue( u"IsDirectionToSimplified"_ustr ) 
>>= bToSimplified;
-                    xProp->getPropertyValue( u"IsUseCharacterVariants"_ustr ) 
>>= bUseVariants;
-                    xProp->getPropertyValue( u"IsTranslateCommonTerms"_ustr ) 
>>= bCommonTerms;
-                }
-                catch( Exception& )
-                {
-                }
-            }
-
-            //execute translation
-            LanguageType nSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
-            LanguageType nTargetLang = bToSimplified ? 
LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
-            sal_Int32 nOptions       = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
-            if( !bCommonTerms )
-                nOptions = nOptions | 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
-
-            vcl::Font aTargetFont = OutputDevice::GetDefaultFont(
-                                DefaultFontType::CJK_PRESENTATION,
-                                nTargetLang, GetDefaultFontFlags::OnlyOne );
-
-            StartConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, 
false );
-            ConvertStyles( nTargetLang, &aTargetFont );
-        }
+        //get some parameters from the dialog
+        bool bToSimplified = xDialog->getIsDirectionToSimplified();
+        bool bUseVariants = false;
+        bool bCommonTerms = xDialog->getIsTranslateCommonTerms();
+
+        //execute translation
+        LanguageType nSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+        LanguageType nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED 
: LANGUAGE_CHINESE_TRADITIONAL;
+        sal_Int32 nOptions       = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+        if( !bCommonTerms )
+            nOptions = nOptions | 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+        vcl::Font aTargetFont = OutputDevice::GetDefaultFont(
+                            DefaultFontType::CJK_PRESENTATION,
+                            nTargetLang, GetDefaultFontFlags::OnlyOne );
+
+        StartConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, 
false );
+        ConvertStyles( nTargetLang, &aTargetFont );
     }
-    Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
-    if( xComponent.is() )
-        xComponent->dispose();
 }
 } // end of namespace
 
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 83e205857453..4c5c190a82e2 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -5630,6 +5630,7 @@ include/svx/autoformathelper.hxx
 include/svx/bmpmask.hxx
 include/svx/charmap.hxx
 include/svx/charthelper.hxx
+include/svx/chinese_translation_unodialog.hxx
 include/svx/chrtitem.hxx
 include/svx/clipboardctl.hxx
 include/svx/colorwindow.hxx
@@ -11687,7 +11688,6 @@ svx/source/uitest/uiobject.cxx
 svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx
 svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx
 svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
-svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx
 svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx
 svx/source/unodraw/UnoGraphicExporter.cxx
 svx/source/unodraw/UnoNameItemTable.cxx
diff --git a/svx/Library_textconversiondlgs.mk 
b/svx/Library_textconversiondlgs.mk
index dcf88536904b..0da4e9520341 100644
--- a/svx/Library_textconversiondlgs.mk
+++ b/svx/Library_textconversiondlgs.mk
@@ -19,8 +19,6 @@
 
 $(eval $(call gb_Library_Library,textconversiondlgs))
 
-$(eval $(call 
gb_Library_set_componentfile,textconversiondlgs,svx/util/textconversiondlgs,services))
-
 $(eval $(call gb_Library_set_include,textconversiondlgs,\
     -I$(SRCDIR)/svx/inc \
     $$(INCLUDE) \
@@ -30,6 +28,10 @@ $(eval $(call 
gb_Library_use_external,textconversiondlgs,boost_headers))
 
 $(eval $(call gb_Library_use_sdk_api,textconversiondlgs))
 
+$(eval $(call gb_Library_add_defs,textconversiondlgs,\
+    -DTEXTCONVERSIONDLGS_DLLIMPLEMENTATION \
+))
+
 $(eval $(call gb_Library_use_libraries,textconversiondlgs,\
     comphelper \
     cppuhelper \
diff --git 
a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx 
b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
index ffd2c19960f5..d57e77b5b48b 100644
--- a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
@@ -18,7 +18,7 @@
  */
 
 
-#include "chinese_translation_unodialog.hxx"
+#include <svx/chinese_translation_unodialog.hxx>
 #include "chinese_translationdialog.hxx"
 #include <vcl/svapp.hxx>
 #include <cppuhelper/supportsservice.hxx>
@@ -29,10 +29,9 @@ namespace textconversiondlgs
 {
 using namespace ::com::sun::star;
 
-ChineseTranslation_UnoDialog::ChineseTranslation_UnoDialog()
-                    : m_bDisposed(false)
-                    , m_bInDispose(false)
+ChineseTranslation_UnoDialog::ChineseTranslation_UnoDialog(const 
css::uno::Reference< css::awt::XWindow >& xParentWindow)
 {
+    m_xParentWindow = xParentWindow;
 }
 
 ChineseTranslation_UnoDialog::~ChineseTranslation_UnoDialog()
@@ -50,55 +49,11 @@ void ChineseTranslation_UnoDialog::impl_DeleteDialog()
     }
 }
 
-// lang::XServiceInfo
-OUString SAL_CALL ChineseTranslation_UnoDialog::getImplementationName()
-{
-    return u"com.sun.star.comp.linguistic2.ChineseTranslationDialog"_ustr;
-}
-
-sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const 
OUString& ServiceName )
-{
-    return cppu::supportsService(this, ServiceName);
-}
-
-uno::Sequence< OUString > SAL_CALL 
ChineseTranslation_UnoDialog::getSupportedServiceNames()
-{
-    return { u"com.sun.star.linguistic2.ChineseTranslationDialog"_ustr };
-}
-
-// ui::dialogs::XExecutableDialog
-void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const OUString& )
-{
-    //not implemented - fell free to do so, if you do need this
-}
-
-
-void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< 
uno::Any >& aArguments )
-{
-    SolarMutexGuard aSolarGuard;
-    if( m_bDisposed || m_bInDispose )
-        return;
-
-    for(const uno::Any& rArgument : aArguments)
-    {
-        beans::PropertyValue aProperty;
-        if(rArgument >>= aProperty)
-        {
-            if( aProperty.Name == "ParentWindow" )
-            {
-                aProperty.Value >>= m_xParentWindow;
-            }
-        }
-    }
-}
-
-sal_Int16 SAL_CALL ChineseTranslation_UnoDialog::execute()
+sal_Int16 ChineseTranslation_UnoDialog::execute()
 {
     sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
     {
         SolarMutexGuard aSolarGuard;
-        if (m_bDisposed || m_bInDispose)
-            return nRet;
         if (!m_xDialog)
             m_xDialog.reset(new 
ChineseTranslationDialog(Application::GetFrameWeld(m_xParentWindow)));
         nRet = m_xDialog->run();
@@ -108,120 +63,30 @@ sal_Int16 SAL_CALL ChineseTranslation_UnoDialog::execute()
     return nRet;
 }
 
-// lang::XComponent
-void SAL_CALL ChineseTranslation_UnoDialog::dispose()
+bool ChineseTranslation_UnoDialog::getIsDirectionToSimplified()
 {
-    lang::EventObject aEvt;
+    bool bDirectionToSimplified = true;
+    bool bTranslateCommonTerms = false;
+
     {
         SolarMutexGuard aSolarGuard;
-        if( m_bDisposed || m_bInDispose )
-            return;
-        m_bInDispose = true;
-
-        impl_DeleteDialog();
-        m_xParentWindow = nullptr;
-        m_bDisposed = true;
-
-        aEvt.Source = static_cast< XComponent * >( this );
+        m_xDialog->getSettings(bDirectionToSimplified, bTranslateCommonTerms);
     }
-    std::unique_lock aGuard(m_aContainerMutex);
-    m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
+    return bDirectionToSimplified;
 }
 
-void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const 
uno::Reference< lang::XEventListener > & xListener )
+bool ChineseTranslation_UnoDialog::getIsTranslateCommonTerms()
 {
-    SolarMutexGuard aSolarGuard;
-    if( m_bDisposed || m_bInDispose )
-        return;
-    std::unique_lock aGuard(m_aContainerMutex);
-    m_aDisposeEventListeners.addInterface( aGuard, xListener );
-}
-
-void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const 
uno::Reference< lang::XEventListener > & xListener )
-{
-    SolarMutexGuard aSolarGuard;
-    if( m_bDisposed || m_bInDispose )
-        return;
-    std::unique_lock aGuard(m_aContainerMutex);
-    m_aDisposeEventListeners.removeInterface( aGuard, xListener );
-}
-
-
-// XPropertySet
-
-uno::Reference< beans::XPropertySetInfo > SAL_CALL 
ChineseTranslation_UnoDialog::getPropertySetInfo(  )
-{
-    return nullptr;
-}
-
-void SAL_CALL ChineseTranslation_UnoDialog::setPropertyValue( const OUString&, 
const uno::Any& )
-{
-    //only read only properties
-    throw beans::PropertyVetoException();
-}
-
-uno::Any SAL_CALL ChineseTranslation_UnoDialog::getPropertyValue( const 
OUString& rPropertyName )
-{
-    uno::Any aRet;
-
     bool bDirectionToSimplified = true;
     bool bTranslateCommonTerms = false;
 
     {
         SolarMutexGuard aSolarGuard;
-        if (m_bDisposed || m_bInDispose || !m_xDialog)
-            return aRet;
         m_xDialog->getSettings(bDirectionToSimplified, bTranslateCommonTerms);
     }
-
-    if( rPropertyName == "IsDirectionToSimplified" )
-    {
-        aRet <<= bDirectionToSimplified;
-    }
-    else if( rPropertyName == "IsUseCharacterVariants" )
-    {
-        aRet <<= false;
-    }
-    else if( rPropertyName == "IsTranslateCommonTerms" )
-    {
-        aRet <<= bTranslateCommonTerms;
-    }
-    else
-    {
-        throw beans::UnknownPropertyException( rPropertyName, getXWeak());
-    }
-    return aRet;
-
+    return bTranslateCommonTerms;
 }
 
-void SAL_CALL ChineseTranslation_UnoDialog::addPropertyChangeListener( const 
OUString& , const uno::Reference< beans::XPropertyChangeListener >&  )
-{
-    //only not bound properties -> ignore listener
-}
-
-void SAL_CALL ChineseTranslation_UnoDialog::removePropertyChangeListener( 
const OUString& , const uno::Reference< beans::XPropertyChangeListener >&  )
-{
-    //only not bound properties -> ignore listener
-}
-
-void SAL_CALL ChineseTranslation_UnoDialog::addVetoableChangeListener( const 
OUString& , const uno::Reference< beans::XVetoableChangeListener >&  )
-{
-    //only not bound properties -> ignore listener
-}
-
-void SAL_CALL ChineseTranslation_UnoDialog::removeVetoableChangeListener( 
const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  )
-{
-    //only not bound properties -> ignore listener
-}
-
-} //end namespace
-
-
-extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
-svx_ChineseTranslation_UnoDialog_get_implementation(
-    css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
-{
-    return cppu::acquire(new 
textconversiondlgs::ChineseTranslation_UnoDialog());
-}
+} //namespace textconversiondlgs
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git 
a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx 
b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx
deleted file mode 100644
index 0d40e1227ef5..000000000000
--- a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx
+++ /dev/null
@@ -1,119 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#pragma once
-
-#include <sal/config.h>
-
-#include <memory>
-
-#include <com/sun/star/awt/XWindow.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/interfacecontainer4.hxx>
-#include <mutex>
-
-
-namespace textconversiondlgs
-{
-
-
-/** This class provides the chinese translation dialog as a uno component.
-
-It can be created via lang::XMultiComponentFactory::createInstanceWithContext
-with servicename "com.sun.star.linguistic2.ChineseTranslationDialog"
-or implementation name "com.sun.star.comp.linguistic2.ChineseTranslationDialog"
-
-It can be initialized via the XInitialization interface with the following 
single parameter:
-PropertyValue-Parameter: Name="ParentWindow" Type="awt::XWindow".
-
-It can be executed via the ui::dialogs::XExecutableDialog interface.
-
-Made settings can be retrieved via beans::XPropertySet interface.
-Following properties are available (read only and not bound):
-1) Name="IsDirectionToSimplified" Type="sal_Bool"
-2) Name="IsUseCharacterVariants" Type="sal_Bool"
-3) Name="IsTranslateCommonTerms" Type="sal_Bool"
-
-The dialog gets this information from the registry on execute and writes it 
back to the registry if ended with OK.
-*/
-
-class ChineseTranslationDialog;
-
-class ChineseTranslation_UnoDialog : public ::cppu::WeakImplHelper <
-                              css::ui::dialogs::XExecutableDialog
-                            , css::lang::XInitialization
-                            , css::beans::XPropertySet
-                            , css::lang::XComponent
-                            , css::lang::XServiceInfo
-                            >
-{
-public:
-    ChineseTranslation_UnoDialog();
-    virtual ~ChineseTranslation_UnoDialog() override;
-
-    // lang::XServiceInfo
-    virtual OUString SAL_CALL getImplementationName() override;
-    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
-    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
-
-    // lang::XInitialization
-    virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any 
>& aArguments ) override;
-
-    // ui::dialogs::XExecutableDialog
-    virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
-    virtual sal_Int16 SAL_CALL execute(  ) override;
-
-    // beans::XPropertySet
-    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL 
getPropertySetInfo(  ) override;
-    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, 
const css::uno::Any& aValue ) override;
-    virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& 
PropertyName ) override;
-    virtual void SAL_CALL addPropertyChangeListener( const OUString& 
aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener 
>& xListener ) override;
-    virtual void SAL_CALL removePropertyChangeListener( const OUString& 
aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener 
>& aListener ) override;
-    virtual void SAL_CALL addVetoableChangeListener( const OUString& 
PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& 
aListener ) override;
-    virtual void SAL_CALL removeVetoableChangeListener( const OUString& 
PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& 
aListener ) override;
-
-    // lang::XComponent
-    virtual void SAL_CALL dispose() override;
-    virtual void SAL_CALL addEventListener( const css::uno::Reference< 
css::lang::XEventListener > & xListener ) override;
-    virtual void SAL_CALL removeEventListener( const css::uno::Reference< 
css::lang::XEventListener > & xListener ) override;
-
-private:
-
-    void impl_DeleteDialog();
-
-private:
-    css::uno::Reference<
-        css::awt::XWindow >              m_xParentWindow;
-
-    std::unique_ptr<ChineseTranslationDialog> m_xDialog;
-
-    bool m_bDisposed; ///Dispose call ready.
-    bool m_bInDispose;///In dispose call
-    std::mutex                      m_aContainerMutex;
-    comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> 
m_aDisposeEventListeners;
-};
-
-
-} //end namespace
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/util/textconversiondlgs.component 
b/svx/util/textconversiondlgs.component
deleted file mode 100644
index 81798f2dd061..000000000000
--- a/svx/util/textconversiondlgs.component
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- -->
-
-<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    xmlns="http://openoffice.org/2010/uno-components";>
-  <implementation name="com.sun.star.comp.linguistic2.ChineseTranslationDialog"
-    constructor="svx_ChineseTranslation_UnoDialog_get_implementation">
-    <service name="com.sun.star.linguistic2.ChineseTranslationDialog"/>
-  </implementation>
-</component>
diff --git a/sw/CppunitTest_sw_uwriter.mk b/sw/CppunitTest_sw_uwriter.mk
index 479008933640..0fdf9355bd4a 100644
--- a/sw/CppunitTest_sw_uwriter.mk
+++ b/sw/CppunitTest_sw_uwriter.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uwriter, \
     svxcore \
     swd \
        test \
+       textconversiondlgs \
     tk \
     tl \
     ucbhelper \
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 6aecbaf797d9..14dada067431 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -76,6 +76,7 @@ $(eval $(call gb_Library_use_libraries,sw,\
     svt \
     svx \
     svxcore \
+    textconversiondlgs \
     tk \
     tl \
     ucbhelper \
diff --git a/sw/source/uibase/shells/annotsh.cxx 
b/sw/source/uibase/shells/annotsh.cxx
index 4ad8169bc737..5614736ca010 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -52,6 +52,7 @@
 #include <editeng/udlnitem.hxx>
 #include <editeng/fontitem.hxx>
 #include <svx/clipfmtitem.hxx>
+#include <svx/chinese_translation_unodialog.hxx>
 #include <svl/stritem.hxx>
 #include <svl/slstitm.hxx>
 #include <editeng/frmdiritem.hxx>
@@ -1357,69 +1358,32 @@ void SwAnnotationShell::ExecLingu(SfxRequest &rReq)
 
         case SID_CHINESE_CONVERSION:
         {
-                //open ChineseTranslationDialog
-                uno::Reference< uno::XComponentContext > 
xContext(::comphelper::getProcessComponentContext());
-                if(xContext.is())
-                {
-                    Reference< lang::XMultiComponentFactory > xMCF( 
xContext->getServiceManager() );
-                    if(xMCF.is())
-                    {
-                        Reference< ui::dialogs::XExecutableDialog > xDialog(
-                                xMCF->createInstanceWithContext(
-                                    
u"com.sun.star.linguistic2.ChineseTranslationDialog"_ustr, xContext),
-                                UNO_QUERY);
-                        Reference< lang::XInitialization > xInit( xDialog, 
UNO_QUERY );
-                        if( xInit.is() )
-                        {
-                            //  initialize dialog
-                            uno::Sequence<uno::Any> 
aSeq(comphelper::InitAnyPropertySequence(
-                            {
-                                {"ParentWindow", 
uno::Any(Reference<awt::XWindow>())}
-                            }));
-                            xInit->initialize( aSeq );
+            //open ChineseTranslationDialog
+            rtl::Reference< textconversiondlgs::ChineseTranslation_UnoDialog > 
xDialog(new textconversiondlgs::ChineseTranslation_UnoDialog({}));
 
-                            //execute dialog
-                            sal_Int16 nDialogRet = xDialog->execute();
-                            if( RET_OK == nDialogRet )
-                            {
-                                //get some parameters from the dialog
-                                bool bToSimplified = true;
-                                bool bUseVariants = true;
-                                bool bCommonTerms = true;
-                                Reference< beans::XPropertySet >  xProp( 
xDialog, UNO_QUERY );
-                                if( xProp.is() )
-                                {
-                                    try
-                                    {
-                                        xProp->getPropertyValue( 
u"IsDirectionToSimplified"_ustr ) >>= bToSimplified;
-                                        xProp->getPropertyValue( 
u"IsUseCharacterVariants"_ustr ) >>= bUseVariants;
-                                        xProp->getPropertyValue( 
u"IsTranslateCommonTerms"_ustr ) >>= bCommonTerms;
-                                    }
-                                    catch (const Exception&)
-                                    {
-                                    }
-                                }
-
-                                //execute translation
-                                LanguageType nSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
-                                LanguageType nTargetLang = bToSimplified ? 
LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
-                                sal_Int32 nOptions       = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
-                                if( !bCommonTerms )
-                                    nOptions = nOptions | 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
-
-                                vcl::Font aTargetFont = 
OutputDevice::GetDefaultFont( DefaultFontType::CJK_TEXT,
-                                            nTargetLang, 
GetDefaultFontFlags::OnlyOne );
-
-                                pOLV->StartTextConversion(rReq.GetFrameWeld(), 
nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false);
-                            }
-                        }
-                        Reference< lang::XComponent > xComponent( xDialog, 
UNO_QUERY );
-                        if( xComponent.is() )
-                            xComponent->dispose();
-                    }
-                }
+            //execute dialog
+            sal_Int16 nDialogRet = xDialog->execute();
+            if( RET_OK == nDialogRet )
+            {
+                //get some parameters from the dialog
+                bool bToSimplified = xDialog->getIsDirectionToSimplified();
+                bool bUseVariants = false;
+                bool bCommonTerms = xDialog->getIsTranslateCommonTerms();
+
+                //execute translation
+                LanguageType nSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+                LanguageType nTargetLang = bToSimplified ? 
LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+                sal_Int32 nOptions       = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+                if( !bCommonTerms )
+                    nOptions = nOptions | 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+                vcl::Font aTargetFont = OutputDevice::GetDefaultFont( 
DefaultFontType::CJK_TEXT,
+                            nTargetLang, GetDefaultFontFlags::OnlyOne );
+
+                pOLV->StartTextConversion(rReq.GetFrameWeld(), nSourceLang, 
nTargetLang, &aTargetFont, nOptions, false, false);
             }
-            break;
+        }
+        break;
     }
 
     if (bRestoreSelection)
diff --git a/sw/source/uibase/shells/drwtxtsh.cxx 
b/sw/source/uibase/shells/drwtxtsh.cxx
index ace19fee904c..8535ecd63411 100644
--- a/sw/source/uibase/shells/drwtxtsh.cxx
+++ b/sw/source/uibase/shells/drwtxtsh.cxx
@@ -30,6 +30,7 @@
 #include <sfx2/objface.hxx>
 #include <svx/svdotext.hxx>
 #include <svx/sdooitm.hxx>
+#include <svx/chinese_translation_unodialog.hxx>
 #include <editeng/editeng.hxx>
 #include <editeng/editview.hxx>
 #include <editeng/eeitem.hxx>
@@ -284,50 +285,16 @@ void SwDrawTextShell::ExecDrawLingu(SfxRequest const 
&rReq)
     case SID_CHINESE_CONVERSION:
         {
             //open ChineseTranslationDialog
-            const Reference<XComponentContext>& xContext = 
comphelper::getProcessComponentContext();
-            if (!xContext.is())
-                return;
-
-            Reference<lang::XMultiComponentFactory> 
xMCF(xContext->getServiceManager());
-            if (!xMCF.is())
-                return;
-
-            Reference<ui::dialogs::XExecutableDialog> xDialog(
-                    
xMCF->createInstanceWithContext(u"com.sun.star.linguistic2.ChineseTranslationDialog"_ustr,
 xContext), UNO_QUERY);
-
-            Reference<lang::XInitialization> xInit(xDialog, UNO_QUERY);
-
-            if (!xInit.is())
-                return;
-
-            //  initialize dialog
-            uno::Sequence<uno::Any> 
aSequence(comphelper::InitAnyPropertySequence(
-            {
-                {"ParentWindow", uno::Any(Reference<awt::XWindow>())}
-            }));
-            xInit->initialize( aSequence );
+            rtl::Reference<textconversiondlgs::ChineseTranslation_UnoDialog> 
xDialog(new textconversiondlgs::ChineseTranslation_UnoDialog({}));
 
             //execute dialog
             sal_Int16 nDialogRet = xDialog->execute();
             if(RET_OK == nDialogRet)
             {
                 //get some parameters from the dialog
-                bool bToSimplified = true;
-                bool bUseVariants = true;
-                bool bCommonTerms = true;
-                Reference<beans::XPropertySet> xPropertySet(xDialog, 
UNO_QUERY);
-                if (xPropertySet.is())
-                {
-                    try
-                    {
-                        
xPropertySet->getPropertyValue(u"IsDirectionToSimplified"_ustr) >>= 
bToSimplified;
-                        
xPropertySet->getPropertyValue(u"IsUseCharacterVariants"_ustr) >>= bUseVariants;
-                        
xPropertySet->getPropertyValue(u"IsTranslateCommonTerms"_ustr) >>= bCommonTerms;
-                    }
-                    catch (const Exception&)
-                    {
-                    }
-                }
+                bool bToSimplified = xDialog->getIsDirectionToSimplified();
+                bool bUseVariants = false;
+                bool bCommonTerms = xDialog->getIsTranslateCommonTerms();
 
                 //execute translation
                 LanguageType nSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
@@ -340,10 +307,6 @@ void SwDrawTextShell::ExecDrawLingu(SfxRequest const &rReq)
 
                 pOutlinerView->StartTextConversion(rReq.GetFrameWeld(), 
nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false);
             }
-
-            Reference<lang::XComponent> xComponent(xDialog, UNO_QUERY);
-            if (xComponent.is())
-                xComponent->dispose();
         }
         break;
 
diff --git a/sw/source/uibase/uiview/viewling.cxx 
b/sw/source/uibase/uiview/viewling.cxx
index bf32181ce7ab..02b9c38d55b7 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -38,6 +38,7 @@
 #include <svx/ehdl.hxx>
 #include <svx/svxerr.hxx>
 #include <svx/svxdlg.hxx>
+#include <svx/chinese_translation_unodialog.hxx>
 #include <osl/diagnose.h>
 #include <swwait.hxx>
 #include <uitool.hxx>
@@ -106,101 +107,64 @@ void SwView::ExecLingu(SfxRequest &rReq)
         case SID_CHINESE_CONVERSION:
         {
             //open ChineseTranslationDialog
-            uno::Reference< uno::XComponentContext > 
xContext(::comphelper::getProcessComponentContext());
-            if(xContext.is())
+            Reference<awt::XWindow> xParentWindow;
+            if (weld::Window* pParentWindow = rReq.GetFrameWeld())
+                xParentWindow = pParentWindow->GetXWindow();
+            rtl::Reference< textconversiondlgs::ChineseTranslation_UnoDialog > 
xDialog(new textconversiondlgs::ChineseTranslation_UnoDialog(xParentWindow));
+
+            //execute dialog
+            sal_Int16 nDialogRet = xDialog->execute();
+            if( RET_OK == nDialogRet )
             {
-                Reference< lang::XMultiComponentFactory > xMCF( 
xContext->getServiceManager() );
-                if(xMCF.is())
-                {
-                    Reference< ui::dialogs::XExecutableDialog > xDialog(
-                            xMCF->createInstanceWithContext(
-                                
u"com.sun.star.linguistic2.ChineseTranslationDialog"_ustr, xContext),
-                            UNO_QUERY);
-                    Reference< lang::XInitialization > xInit( xDialog, 
UNO_QUERY );
-                    if( xInit.is() )
-                    {
-                        Reference<awt::XWindow> xParentWindow;
-                        if (weld::Window* pParentWindow = rReq.GetFrameWeld())
-                            xParentWindow = pParentWindow->GetXWindow();
-                        //  initialize dialog
-                        uno::Sequence<uno::Any> 
aSeq(comphelper::InitAnyPropertySequence(
-                        {
-                            {"ParentWindow", uno::Any(xParentWindow)}
-                        }));
-                        xInit->initialize( aSeq );
+                //get some parameters from the dialog
+                bool bToSimplified = xDialog->getIsDirectionToSimplified();
+                bool bUseVariants = false;
+                bool bCommonTerms = xDialog->getIsTranslateCommonTerms();
 
-                        //execute dialog
-                        sal_Int16 nDialogRet = xDialog->execute();
-                        if( RET_OK == nDialogRet )
-                        {
-                            //get some parameters from the dialog
-                            bool bToSimplified = true;
-                            bool bUseVariants = true;
-                            bool bCommonTerms = true;
-                            Reference< beans::XPropertySet >  xProp( xDialog, 
UNO_QUERY );
-                            if( xProp.is() )
-                            {
-                                try
-                                {
-                                    xProp->getPropertyValue( 
u"IsDirectionToSimplified"_ustr ) >>= bToSimplified;
-                                    xProp->getPropertyValue( 
u"IsUseCharacterVariants"_ustr ) >>= bUseVariants;
-                                    xProp->getPropertyValue( 
u"IsTranslateCommonTerms"_ustr ) >>= bCommonTerms;
-                                }
-                                catch (const Exception&)
-                                {
-                                }
-                            }
+                //execute translation
+                LanguageType nSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+                LanguageType nTargetLang = bToSimplified ? 
LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+                sal_Int32 nOptions       = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+                if( !bCommonTerms )
+                    nOptions = nOptions | 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
 
-                            //execute translation
-                            LanguageType nSourceLang = bToSimplified ? 
LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
-                            LanguageType nTargetLang = bToSimplified ? 
LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
-                            sal_Int32 nOptions       = bUseVariants ? 
i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
-                            if( !bCommonTerms )
-                                nOptions = nOptions | 
i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+                vcl::Font aTargetFont = OutputDevice::GetDefaultFont( 
DefaultFontType::CJK_TEXT,
+                                        nTargetLang, 
GetDefaultFontFlags::OnlyOne );
 
-                            vcl::Font aTargetFont = 
OutputDevice::GetDefaultFont( DefaultFontType::CJK_TEXT,
-                                                    nTargetLang, 
GetDefaultFontFlags::OnlyOne );
+                // disallow formatting, updating the view, ... while
+                // converting the document. (saves time)
+                // Also remember the current view and cursor position for later
+                m_pWrtShell->StartAction();
 
-                            // disallow formatting, updating the view, ... 
while
-                            // converting the document. (saves time)
-                            // Also remember the current view and cursor 
position for later
-                            m_pWrtShell->StartAction();
+                // remember cursor position data for later restoration of the 
cursor
+                const SwPosition *pPoint = 
m_pWrtShell->GetCursor()->GetPoint();
+                bool bRestoreCursor = pPoint->GetNode().IsTextNode();
+                const SwNodeIndex aPointNodeIndex( pPoint->GetNode() );
+                sal_Int32 nPointIndex = pPoint->GetContentIndex();
 
-                            // remember cursor position data for later 
restoration of the cursor
-                            const SwPosition *pPoint = 
m_pWrtShell->GetCursor()->GetPoint();
-                            bool bRestoreCursor = 
pPoint->GetNode().IsTextNode();
-                            const SwNodeIndex aPointNodeIndex( 
pPoint->GetNode() );
-                            sal_Int32 nPointIndex = pPoint->GetContentIndex();
+                // since this conversion is not interactive the whole converted
+                // document should be undone in a single undo step.
+                m_pWrtShell->StartUndo( SwUndoId::OVERWRITE );
 
-                            // since this conversion is not interactive the 
whole converted
-                            // document should be undone in a single undo step.
-                            m_pWrtShell->StartUndo( SwUndoId::OVERWRITE );
+                StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, 
nOptions, false );
 
-                            StartTextConversion( nSourceLang, nTargetLang, 
&aTargetFont, nOptions, false );
+                m_pWrtShell->EndUndo( SwUndoId::OVERWRITE );
 
-                            m_pWrtShell->EndUndo( SwUndoId::OVERWRITE );
-
-                            if (bRestoreCursor)
-                            {
-                                SwTextNode *pTextNode = 
aPointNodeIndex.GetNode().GetTextNode();
-                                // check for unexpected error case
-                                OSL_ENSURE(pTextNode && 
pTextNode->GetText().getLength() >= nPointIndex,
-                                    "text missing: corrupted node?" );
-                                // restore cursor to its original position
-                                if (!pTextNode || 
pTextNode->GetText().getLength() < nPointIndex)
-                                    
m_pWrtShell->GetCursor()->GetPoint()->Assign( aPointNodeIndex );
-                                else
-                                    
m_pWrtShell->GetCursor()->GetPoint()->Assign( *pTextNode, nPointIndex );
-                            }
-
-                            // enable all, restore view and cursor position
-                            m_pWrtShell->EndAction();
-                        }
-                    }
-                    Reference< lang::XComponent > xComponent( xDialog, 
UNO_QUERY );
-                    if( xComponent.is() )
-                        xComponent->dispose();
+                if (bRestoreCursor)
+                {
+                    SwTextNode *pTextNode = 
aPointNodeIndex.GetNode().GetTextNode();
+                    // check for unexpected error case
+                    OSL_ENSURE(pTextNode && pTextNode->GetText().getLength() 
>= nPointIndex,
+                        "text missing: corrupted node?" );
+                    // restore cursor to its original position
+                    if (!pTextNode || pTextNode->GetText().getLength() < 
nPointIndex)
+                        m_pWrtShell->GetCursor()->GetPoint()->Assign( 
aPointNodeIndex );
+                    else
+                        m_pWrtShell->GetCursor()->GetPoint()->Assign( 
*pTextNode, nPointIndex );
                 }
+
+                // enable all, restore view and cursor position
+                m_pWrtShell->EndAction();
             }
             break;
         }

Reply via email to