tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / svx / source / unodialogs / textconversiondlgs / chinese_translation_unodialog.cxx
blobffd2c19960f506af07bd695b89d19c53eeba8a1e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "chinese_translation_unodialog.hxx"
22 #include "chinese_translationdialog.hxx"
23 #include <vcl/svapp.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
28 namespace textconversiondlgs
30 using namespace ::com::sun::star;
32 ChineseTranslation_UnoDialog::ChineseTranslation_UnoDialog()
33 : m_bDisposed(false)
34 , m_bInDispose(false)
38 ChineseTranslation_UnoDialog::~ChineseTranslation_UnoDialog()
40 SolarMutexGuard aSolarGuard;
41 impl_DeleteDialog();
44 void ChineseTranslation_UnoDialog::impl_DeleteDialog()
46 if (m_xDialog)
48 m_xDialog->response(RET_CANCEL);
49 m_xDialog.reset();
53 // lang::XServiceInfo
54 OUString SAL_CALL ChineseTranslation_UnoDialog::getImplementationName()
56 return u"com.sun.star.comp.linguistic2.ChineseTranslationDialog"_ustr;
59 sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const OUString& ServiceName )
61 return cppu::supportsService(this, ServiceName);
64 uno::Sequence< OUString > SAL_CALL ChineseTranslation_UnoDialog::getSupportedServiceNames()
66 return { u"com.sun.star.linguistic2.ChineseTranslationDialog"_ustr };
69 // ui::dialogs::XExecutableDialog
70 void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const OUString& )
72 //not implemented - fell free to do so, if you do need this
76 void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< uno::Any >& aArguments )
78 SolarMutexGuard aSolarGuard;
79 if( m_bDisposed || m_bInDispose )
80 return;
82 for(const uno::Any& rArgument : aArguments)
84 beans::PropertyValue aProperty;
85 if(rArgument >>= aProperty)
87 if( aProperty.Name == "ParentWindow" )
89 aProperty.Value >>= m_xParentWindow;
95 sal_Int16 SAL_CALL ChineseTranslation_UnoDialog::execute()
97 sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
99 SolarMutexGuard aSolarGuard;
100 if (m_bDisposed || m_bInDispose)
101 return nRet;
102 if (!m_xDialog)
103 m_xDialog.reset(new ChineseTranslationDialog(Application::GetFrameWeld(m_xParentWindow)));
104 nRet = m_xDialog->run();
105 if (nRet == RET_OK)
106 nRet=ui::dialogs::ExecutableDialogResults::OK;
108 return nRet;
111 // lang::XComponent
112 void SAL_CALL ChineseTranslation_UnoDialog::dispose()
114 lang::EventObject aEvt;
116 SolarMutexGuard aSolarGuard;
117 if( m_bDisposed || m_bInDispose )
118 return;
119 m_bInDispose = true;
121 impl_DeleteDialog();
122 m_xParentWindow = nullptr;
123 m_bDisposed = true;
125 aEvt.Source = static_cast< XComponent * >( this );
127 std::unique_lock aGuard(m_aContainerMutex);
128 m_aDisposeEventListeners.disposeAndClear( aGuard, aEvt );
131 void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
133 SolarMutexGuard aSolarGuard;
134 if( m_bDisposed || m_bInDispose )
135 return;
136 std::unique_lock aGuard(m_aContainerMutex);
137 m_aDisposeEventListeners.addInterface( aGuard, xListener );
140 void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
142 SolarMutexGuard aSolarGuard;
143 if( m_bDisposed || m_bInDispose )
144 return;
145 std::unique_lock aGuard(m_aContainerMutex);
146 m_aDisposeEventListeners.removeInterface( aGuard, xListener );
150 // XPropertySet
152 uno::Reference< beans::XPropertySetInfo > SAL_CALL ChineseTranslation_UnoDialog::getPropertySetInfo( )
154 return nullptr;
157 void SAL_CALL ChineseTranslation_UnoDialog::setPropertyValue( const OUString&, const uno::Any& )
159 //only read only properties
160 throw beans::PropertyVetoException();
163 uno::Any SAL_CALL ChineseTranslation_UnoDialog::getPropertyValue( const OUString& rPropertyName )
165 uno::Any aRet;
167 bool bDirectionToSimplified = true;
168 bool bTranslateCommonTerms = false;
171 SolarMutexGuard aSolarGuard;
172 if (m_bDisposed || m_bInDispose || !m_xDialog)
173 return aRet;
174 m_xDialog->getSettings(bDirectionToSimplified, bTranslateCommonTerms);
177 if( rPropertyName == "IsDirectionToSimplified" )
179 aRet <<= bDirectionToSimplified;
181 else if( rPropertyName == "IsUseCharacterVariants" )
183 aRet <<= false;
185 else if( rPropertyName == "IsTranslateCommonTerms" )
187 aRet <<= bTranslateCommonTerms;
189 else
191 throw beans::UnknownPropertyException( rPropertyName, getXWeak());
193 return aRet;
197 void SAL_CALL ChineseTranslation_UnoDialog::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
199 //only not bound properties -> ignore listener
202 void SAL_CALL ChineseTranslation_UnoDialog::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
204 //only not bound properties -> ignore listener
207 void SAL_CALL ChineseTranslation_UnoDialog::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
209 //only not bound properties -> ignore listener
212 void SAL_CALL ChineseTranslation_UnoDialog::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
214 //only not bound properties -> ignore listener
217 } //end namespace
220 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
221 svx_ChineseTranslation_UnoDialog_get_implementation(
222 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
224 return cppu::acquire(new textconversiondlgs::ChineseTranslation_UnoDialog());
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */