LibreOffice Module svx (master) 1
chinese_translation_unodialog.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
23#include <vcl/svapp.hxx>
25#include <com/sun/star/beans/PropertyValue.hpp>
26#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
27
28namespace textconversiondlgs
29{
30using namespace ::com::sun::star;
31
33 : m_bDisposed(false)
34 , m_bInDispose(false)
35{
36}
37
39{
40 SolarMutexGuard aSolarGuard;
42}
43
45{
46 if (m_xDialog)
47 {
48 m_xDialog->response(RET_CANCEL);
49 m_xDialog.reset();
50 }
51}
52
53// lang::XServiceInfo
55{
56 return "com.sun.star.comp.linguistic2.ChineseTranslationDialog";
57}
58
59sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const OUString& ServiceName )
60{
62}
63
65{
66 return { "com.sun.star.linguistic2.ChineseTranslationDialog" };
67}
68
69// ui::dialogs::XExecutableDialog
70void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const OUString& )
71{
72 //not implemented - fell free to do so, if you do need this
73}
74
75
76void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< uno::Any >& aArguments )
77{
78 SolarMutexGuard aSolarGuard;
80 return;
81
82 for(const uno::Any& rArgument : aArguments)
83 {
84 beans::PropertyValue aProperty;
85 if(rArgument >>= aProperty)
86 {
87 if( aProperty.Name == "ParentWindow" )
88 {
89 aProperty.Value >>= m_xParentWindow;
90 }
91 }
92 }
93}
94
96{
97 sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
98 {
99 SolarMutexGuard aSolarGuard;
101 return nRet;
102 if (!m_xDialog)
104 nRet = m_xDialog->run();
105 if (nRet == RET_OK)
106 nRet=ui::dialogs::ExecutableDialogResults::OK;
107 }
108 return nRet;
109}
110
111// lang::XComponent
113{
114 lang::EventObject aEvt;
115 {
116 SolarMutexGuard aSolarGuard;
118 return;
119 m_bInDispose = true;
120
122 m_xParentWindow = nullptr;
123 m_bDisposed = true;
124
125 aEvt.Source = static_cast< XComponent * >( this );
126 }
127 std::unique_lock aGuard(m_aContainerMutex);
129}
130
131void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
132{
133 SolarMutexGuard aSolarGuard;
135 return;
136 std::unique_lock aGuard(m_aContainerMutex);
137 m_aDisposeEventListeners.addInterface( aGuard, xListener );
138}
139
140void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
141{
142 SolarMutexGuard aSolarGuard;
144 return;
145 std::unique_lock aGuard(m_aContainerMutex);
146 m_aDisposeEventListeners.removeInterface( aGuard, xListener );
147}
148
149
150// XPropertySet
151
152uno::Reference< beans::XPropertySetInfo > SAL_CALL ChineseTranslation_UnoDialog::getPropertySetInfo( )
153{
154 return nullptr;
155}
156
157void SAL_CALL ChineseTranslation_UnoDialog::setPropertyValue( const OUString&, const uno::Any& )
158{
159 //only read only properties
160 throw beans::PropertyVetoException();
161}
162
163uno::Any SAL_CALL ChineseTranslation_UnoDialog::getPropertyValue( const OUString& rPropertyName )
164{
165 uno::Any aRet;
166
167 bool bDirectionToSimplified = true;
168 bool bTranslateCommonTerms = false;
169
170 {
171 SolarMutexGuard aSolarGuard;
173 return aRet;
174 m_xDialog->getSettings(bDirectionToSimplified, bTranslateCommonTerms);
175 }
176
177 if( rPropertyName == "IsDirectionToSimplified" )
178 {
179 aRet <<= bDirectionToSimplified;
180 }
181 else if( rPropertyName == "IsUseCharacterVariants" )
182 {
183 aRet <<= false;
184 }
185 else if( rPropertyName == "IsTranslateCommonTerms" )
186 {
187 aRet <<= bTranslateCommonTerms;
188 }
189 else
190 {
191 throw beans::UnknownPropertyException( rPropertyName, getXWeak());
192 }
193 return aRet;
194
195}
196
197void SAL_CALL ChineseTranslation_UnoDialog::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
198{
199 //only not bound properties -> ignore listener
200}
201
202void SAL_CALL ChineseTranslation_UnoDialog::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
203{
204 //only not bound properties -> ignore listener
205}
206
207void SAL_CALL ChineseTranslation_UnoDialog::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
208{
209 //only not bound properties -> ignore listener
210}
211
212void SAL_CALL ChineseTranslation_UnoDialog::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
213{
214 //only not bound properties -> ignore listener
215}
216
217} //end namespace
218
219
220extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
222 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
223{
224 return cppu::acquire(new textconversiondlgs::ChineseTranslation_UnoDialog());
225}
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * svx_ChineseTranslation_UnoDialog_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL setTitle(const OUString &aTitle) override
css::uno::Reference< css::awt::XWindow > m_xParentWindow
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_aDisposeEventListeners
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
std::unique_ptr< ChineseTranslationDialog > m_xDialog
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
bool m_bDisposed
Sequence< PropertyValue > aArguments
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
RET_OK
RET_CANCEL