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 
28 namespace textconversiondlgs
29 {
30 using namespace ::com::sun::star;
31 
33  : m_bDisposed(false)
34  , m_bInDispose(false)
35  , m_aDisposeEventListeners(m_aContainerMutex)
36 {
37 }
38 
40 {
41  SolarMutexGuard aSolarGuard;
43 }
44 
46 {
47  if (m_xDialog)
48  {
49  m_xDialog->response(RET_CANCEL);
50  m_xDialog.reset();
51  }
52 }
53 
54 // lang::XServiceInfo
56 {
57  return "com.sun.star.comp.linguistic2.ChineseTranslationDialog";
58 }
59 
60 sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const OUString& ServiceName )
61 {
62  return cppu::supportsService(this, ServiceName);
63 }
64 
65 uno::Sequence< OUString > SAL_CALL ChineseTranslation_UnoDialog::getSupportedServiceNames()
66 {
67  return { "com.sun.star.linguistic2.ChineseTranslationDialog" };
68 }
69 
70 // ui::dialogs::XExecutableDialog
71 void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const OUString& )
72 {
73  //not implemented - fell free to do so, if you do need this
74 }
75 
76 
77 void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< uno::Any >& aArguments )
78 {
79  SolarMutexGuard aSolarGuard;
80  if( m_bDisposed || m_bInDispose )
81  return;
82 
83  for(const uno::Any& rArgument : aArguments)
84  {
85  beans::PropertyValue aProperty;
86  if(rArgument >>= aProperty)
87  {
88  if( aProperty.Name == "ParentWindow" )
89  {
90  aProperty.Value >>= m_xParentWindow;
91  }
92  }
93  }
94 }
95 
97 {
98  sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
99  {
100  SolarMutexGuard aSolarGuard;
101  if (m_bDisposed || m_bInDispose)
102  return nRet;
103  if (!m_xDialog)
105  nRet = m_xDialog->run();
106  if (nRet == RET_OK)
107  nRet=ui::dialogs::ExecutableDialogResults::OK;
108  }
109  return nRet;
110 }
111 
112 // lang::XComponent
114 {
115  lang::EventObject aEvt;
116  {
117  SolarMutexGuard aSolarGuard;
118  if( m_bDisposed || m_bInDispose )
119  return;
120  m_bInDispose = true;
121 
123  m_xParentWindow = nullptr;
124  m_bDisposed = true;
125 
126  aEvt.Source = static_cast< XComponent * >( this );
127  }
130 }
131 
132 void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
133 {
134  SolarMutexGuard aSolarGuard;
135  if( m_bDisposed || m_bInDispose )
136  return;
138 }
139 
140 void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
141 {
142  SolarMutexGuard aSolarGuard;
143  if( m_bDisposed || m_bInDispose )
144  return;
146 }
147 
148 
149 // XPropertySet
150 
151 uno::Reference< beans::XPropertySetInfo > SAL_CALL ChineseTranslation_UnoDialog::getPropertySetInfo( )
152 {
153  return nullptr;
154 }
155 
156 void SAL_CALL ChineseTranslation_UnoDialog::setPropertyValue( const OUString&, const uno::Any& )
157 {
158  //only read only properties
159  throw beans::PropertyVetoException();
160 }
161 
162 uno::Any SAL_CALL ChineseTranslation_UnoDialog::getPropertyValue( const OUString& rPropertyName )
163 {
164  uno::Any aRet;
165 
166  bool bDirectionToSimplified = true;
167  bool bTranslateCommonTerms = false;
168 
169  {
170  SolarMutexGuard aSolarGuard;
172  return aRet;
173  m_xDialog->getSettings(bDirectionToSimplified, bTranslateCommonTerms);
174  }
175 
176  if( rPropertyName == "IsDirectionToSimplified" )
177  {
178  aRet <<= bDirectionToSimplified;
179  }
180  else if( rPropertyName == "IsUseCharacterVariants" )
181  {
182  aRet <<= false;
183  }
184  else if( rPropertyName == "IsTranslateCommonTerms" )
185  {
186  aRet <<= bTranslateCommonTerms;
187  }
188  else
189  {
190  throw beans::UnknownPropertyException( rPropertyName, static_cast<cppu::OWeakObject*>(this));
191  }
192  return aRet;
193 
194 }
195 
196 void SAL_CALL ChineseTranslation_UnoDialog::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
197 {
198  //only not bound properties -> ignore listener
199 }
200 
201 void SAL_CALL ChineseTranslation_UnoDialog::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
202 {
203  //only not bound properties -> ignore listener
204 }
205 
206 void SAL_CALL ChineseTranslation_UnoDialog::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
207 {
208  //only not bound properties -> ignore listener
209 }
210 
211 void SAL_CALL ChineseTranslation_UnoDialog::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
212 {
213  //only not bound properties -> ignore listener
214 }
215 
216 } //end namespace
217 
218 
219 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
221  css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
222 {
223  return cppu::acquire(new textconversiondlgs::ChineseTranslation_UnoDialog());
224 }
225 
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
bool m_bDisposed
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
comphelper::OInterfaceContainerHelper2 m_aDisposeEventListeners
sal_Int32 addInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * svx_ChineseTranslation_UnoDialog_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
void disposeAndClear(const css::lang::EventObject &rEvt)
virtual void SAL_CALL setTitle(const OUString &aTitle) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
RET_CANCEL
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
unsigned char sal_Bool
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
std::unique_ptr< ChineseTranslationDialog > m_xDialog
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
css::uno::Reference< css::awt::XWindow > m_xParentWindow
RET_OK