1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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()
36 , m_aDisposeEventListeners(m_aContainerMutex
)
40 ChineseTranslation_UnoDialog::~ChineseTranslation_UnoDialog()
42 SolarMutexGuard aSolarGuard
;
46 void ChineseTranslation_UnoDialog::impl_DeleteDialog()
50 m_xDialog
->response(RET_CANCEL
);
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
)
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
)
105 m_xDialog
.reset(new ChineseTranslationDialog(Application::GetFrameWeld(m_xParentWindow
)));
106 nRet
= m_xDialog
->run();
108 nRet
=ui::dialogs::ExecutableDialogResults::OK
;
114 void SAL_CALL
ChineseTranslation_UnoDialog::dispose()
116 lang::EventObject aEvt
;
118 SolarMutexGuard aSolarGuard
;
119 if( m_bDisposed
|| m_bInDispose
)
124 m_xParentWindow
= nullptr;
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
)
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
)
146 m_aDisposeEventListeners
.removeInterface( xListener
);
152 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
ChineseTranslation_UnoDialog::getPropertySetInfo( )
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
)
167 bool bDirectionToSimplified
= true;
168 bool bTranslateCommonTerms
= false;
171 SolarMutexGuard aSolarGuard
;
172 if (m_bDisposed
|| m_bInDispose
|| !m_xDialog
)
174 m_xDialog
->getSettings(bDirectionToSimplified
, bTranslateCommonTerms
);
177 if( rPropertyName
== "IsDirectionToSimplified" )
179 aRet
<<= bDirectionToSimplified
;
181 else if( rPropertyName
== "IsUseCharacterVariants" )
185 else if( rPropertyName
== "IsTranslateCommonTerms" )
187 aRet
<<= bTranslateCommonTerms
;
191 throw beans::UnknownPropertyException( rPropertyName
, static_cast<cppu::OWeakObject
*>(this));
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
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: */