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_aContainerMutex()
36  , m_aDisposeEventListeners(m_aContainerMutex)
37 {
38 }
39 
41 {
42  SolarMutexGuard aSolarGuard;
44 }
45 
47 {
48  if (m_xDialog)
49  {
50  m_xDialog->response(RET_CANCEL);
51  m_xDialog.reset();
52  }
53 }
54 
55 // lang::XServiceInfo
57 {
58  return "com.sun.star.comp.linguistic2.ChineseTranslationDialog";
59 }
60 
61 sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const OUString& ServiceName )
62 {
63  return cppu::supportsService(this, ServiceName);
64 }
65 
66 uno::Sequence< OUString > SAL_CALL ChineseTranslation_UnoDialog::getSupportedServiceNames()
67 {
68  return { "com.sun.star.linguistic2.ChineseTranslationDialog" };
69 }
70 
71 // ui::dialogs::XExecutableDialog
72 void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const OUString& )
73 {
74  //not implemented - fell free to do so, if you do need this
75 }
76 
77 
78 void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< uno::Any >& aArguments )
79 {
80  SolarMutexGuard aSolarGuard;
81  if( m_bDisposed || m_bInDispose )
82  return;
83 
84  for(const uno::Any& rArgument : aArguments)
85  {
86  beans::PropertyValue aProperty;
87  if(rArgument >>= aProperty)
88  {
89  if( aProperty.Name == "ParentWindow" )
90  {
91  aProperty.Value >>= m_xParentWindow;
92  }
93  }
94  }
95 }
96 
98 {
99  sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
100  {
101  SolarMutexGuard aSolarGuard;
102  if (m_bDisposed || m_bInDispose)
103  return nRet;
104  if (!m_xDialog)
106  nRet = m_xDialog->run();
107  if (nRet == RET_OK)
108  nRet=ui::dialogs::ExecutableDialogResults::OK;
109  }
110  return nRet;
111 }
112 
113 // lang::XComponent
115 {
116  lang::EventObject aEvt;
117  {
118  SolarMutexGuard aSolarGuard;
119  if( m_bDisposed || m_bInDispose )
120  return;
121  m_bInDispose = true;
122 
124  m_xParentWindow = nullptr;
125  m_bDisposed = true;
126 
127  aEvt.Source = static_cast< XComponent * >( this );
128  }
131 }
132 
133 void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
134 {
135  SolarMutexGuard aSolarGuard;
136  if( m_bDisposed || m_bInDispose )
137  return;
139 }
140 
141 void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
142 {
143  SolarMutexGuard aSolarGuard;
144  if( m_bDisposed || m_bInDispose )
145  return;
147 }
148 
149 
150 // XPropertySet
151 
152 uno::Reference< beans::XPropertySetInfo > SAL_CALL ChineseTranslation_UnoDialog::getPropertySetInfo( )
153 {
154  return nullptr;
155 }
156 
157 void SAL_CALL ChineseTranslation_UnoDialog::setPropertyValue( const OUString&, const uno::Any& )
158 {
159  //only read only properties
160  throw beans::PropertyVetoException();
161 }
162 
163 uno::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, static_cast<cppu::OWeakObject*>(this));
192  }
193  return aRet;
194 
195 }
196 
197 void SAL_CALL ChineseTranslation_UnoDialog::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
198 {
199  //only not bound properties -> ignore listener
200 }
201 
202 void SAL_CALL ChineseTranslation_UnoDialog::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
203 {
204  //only not bound properties -> ignore listener
205 }
206 
207 void SAL_CALL ChineseTranslation_UnoDialog::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
208 {
209  //only not bound properties -> ignore listener
210 }
211 
212 void 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 
220 extern "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: */
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