bump product version to 7.2.5.1
[LibreOffice.git] / svx / source / unodialogs / textconversiondlgs / chinese_translation_unodialog.cxx
blobfe0e3a46a78f0d0a91ef6751087db2ae8656ba56
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)
35 , m_aContainerMutex()
36 , m_aDisposeEventListeners(m_aContainerMutex)
40 ChineseTranslation_UnoDialog::~ChineseTranslation_UnoDialog()
42 SolarMutexGuard aSolarGuard;
43 impl_DeleteDialog();
46 void ChineseTranslation_UnoDialog::impl_DeleteDialog()
48 if (m_xDialog)
50 m_xDialog->response(RET_CANCEL);
51 m_xDialog.reset();
55 // lang::XServiceInfo
56 OUString SAL_CALL ChineseTranslation_UnoDialog::getImplementationName()
58 return "com.sun.star.comp.linguistic2.ChineseTranslationDialog";
61 sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const OUString& ServiceName )
63 return cppu::supportsService(this, ServiceName);
66 uno::Sequence< OUString > SAL_CALL ChineseTranslation_UnoDialog::getSupportedServiceNames()
68 return { "com.sun.star.linguistic2.ChineseTranslationDialog" };
71 // ui::dialogs::XExecutableDialog
72 void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const OUString& )
74 //not implemented - fell free to do so, if you do need this
78 void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< uno::Any >& aArguments )
80 SolarMutexGuard aSolarGuard;
81 if( m_bDisposed || m_bInDispose )
82 return;
84 for(const uno::Any& rArgument : aArguments)
86 beans::PropertyValue aProperty;
87 if(rArgument >>= aProperty)
89 if( aProperty.Name == "ParentWindow" )
91 aProperty.Value >>= m_xParentWindow;
97 sal_Int16 SAL_CALL ChineseTranslation_UnoDialog::execute()
99 sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
101 SolarMutexGuard aSolarGuard;
102 if (m_bDisposed || m_bInDispose)
103 return nRet;
104 if (!m_xDialog)
105 m_xDialog.reset(new ChineseTranslationDialog(Application::GetFrameWeld(m_xParentWindow)));
106 nRet = m_xDialog->run();
107 if (nRet == RET_OK)
108 nRet=ui::dialogs::ExecutableDialogResults::OK;
110 return nRet;
113 // lang::XComponent
114 void SAL_CALL ChineseTranslation_UnoDialog::dispose()
116 lang::EventObject aEvt;
118 SolarMutexGuard aSolarGuard;
119 if( m_bDisposed || m_bInDispose )
120 return;
121 m_bInDispose = true;
123 impl_DeleteDialog();
124 m_xParentWindow = nullptr;
125 m_bDisposed = true;
127 aEvt.Source = static_cast< XComponent * >( this );
129 if( m_aDisposeEventListeners.getLength() )
130 m_aDisposeEventListeners.disposeAndClear( aEvt );
133 void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
135 SolarMutexGuard aSolarGuard;
136 if( m_bDisposed || m_bInDispose )
137 return;
138 m_aDisposeEventListeners.addInterface( xListener );
141 void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
143 SolarMutexGuard aSolarGuard;
144 if( m_bDisposed || m_bInDispose )
145 return;
146 m_aDisposeEventListeners.removeInterface( 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, static_cast<cppu::OWeakObject*>(this));
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: */