1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _TEXTCONVERSIONDLGS_CHINESE_TRANSLATION_UNODIALOG_HXX
29 #define _TEXTCONVERSIONDLGS_CHINESE_TRANSLATION_UNODIALOG_HXX
30 
31 #include <cppuhelper/component.hxx>
32 #include <com/sun/star/awt/XWindow.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/frame/XModel.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <cppuhelper/implbase5.hxx>
40 
41 //.............................................................................
42 namespace textconversiondlgs
43 {
44 //.............................................................................
45 
46 //-------------------------------------------------------------------------
47 /** This class provides the chinese translation dialog as an uno component.
48 
49 It can be created via lang::XMultiComponentFactory::createInstanceWithContext
50 with servicename "com.sun.star.linguistic2.ChineseTranslationDialog"
51 or implemenation name "com.sun.star.comp.linguistic2.ChineseTranslationDialog"
52 
53 It can be initialized via the XInitialization interface with the following single parameter:
54 PropertyValue-Parameter: Name="ParentWindow" Type="awt::XWindow".
55 
56 It can be executed via the ui::dialogs::XExecutableDialog interface.
57 
58 Made settings can be retrieved via beans::XPropertySet interface.
59 Following properties are available (read only and not bound):
60 1) Name="IsDirectionToSimplified" Type="sal_Bool"
61 2) Name="IsUseCharacterVariants" Type="sal_Bool"
62 3) Name="IsTranslateCommonTerms" Type="sal_Bool"
63 
64 The dialog gets this information from the registry on execute and writes it back to the registry if ended with OK.
65 */
66 
67 class ChineseTranslationDialog;
68 
69 class ChineseTranslation_UnoDialog : public ::cppu::WeakImplHelper5 <
70 						      ::com::sun::star::ui::dialogs::XExecutableDialog
71                             , ::com::sun::star::lang::XInitialization
72                             , ::com::sun::star::beans::XPropertySet
73                             , ::com::sun::star::lang::XComponent
74                             , ::com::sun::star::lang::XServiceInfo
75                             >
76                             //	,public ::com::sun::star::uno::XWeak			// implemented by WeakImplHelper(optional interface)
77 	                        //	,public ::com::sun::star::uno::XInterface		// implemented by WeakImplHelper(optional interface)
78 	                        //	,public ::com::sun::star::lang::XTypeProvider	// implemented by WeakImplHelper
79 {
80 public:
81     ChineseTranslation_UnoDialog( const ::com::sun::star::uno::Reference<
82         ::com::sun::star::uno::XComponentContext >& xContext );
83     virtual ~ChineseTranslation_UnoDialog();
84 
85 	// lang::XServiceInfo
86     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
87     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
88 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
89 
90 	static ::rtl::OUString getImplementationName_Static();
91     static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static();
92 
93     static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
94 	        create( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext) throw(::com::sun::star::uno::Exception)
95     {
96 	    return (::cppu::OWeakObject *)new ChineseTranslation_UnoDialog( xContext );
97     }
98 
99     // lang::XInitialization
100 	virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
101 
102     // ui::dialogs::XExecutableDialog
103 	virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle ) throw (::com::sun::star::uno::RuntimeException);
104     virtual sal_Int16 SAL_CALL execute(  ) throw (::com::sun::star::uno::RuntimeException);
105 
106     // beans::XPropertySet
107     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw (::com::sun::star::uno::RuntimeException);
108     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
109     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
110     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
111     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
112     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
113     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
114 
115     // lang::XComponent
116 	virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
117 	virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException);
118 	virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException);
119 
120 private:
121     //no default constructor
122     ChineseTranslation_UnoDialog();
123 
124     void impl_DeleteDialog();
125 
126 private:
127     ::com::sun::star::uno::Reference<
128         ::com::sun::star::uno::XComponentContext>    m_xCC;
129     com::sun::star::uno::Reference<
130         com::sun::star::awt::XWindow >               m_xParentWindow;
131 
132 	ChineseTranslationDialog*     m_pDialog;
133 
134 	sal_Bool m_bDisposed; ///Dispose call ready.
135 	sal_Bool m_bInDispose;///In dispose call
136     osl::Mutex				        m_aContainerMutex;
137     cppu::OInterfaceContainerHelper m_aDisposeEventListeners;
138 };
139 
140 //.............................................................................
141 } //end namespace
142 //.............................................................................
143 #endif
144