1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #if !defined INCLUDED_SFX2_APPL_IMESTATUSWINDOW_HXX
25 #define INCLUDED_SFX2_APPL_IMESTATUSWINDOW_HXX
26 
27 #include "com/sun/star/beans/XPropertyChangeListener.hpp"
28 #include "com/sun/star/uno/Reference.hxx"
29 #include "cppuhelper/implbase1.hxx"
30 #include "osl/mutex.hxx"
31 
32 namespace com { namespace sun { namespace star {
33     namespace beans { class XPropertySet; }
34     namespace lang { class XMultiServiceFactory; }
35 } } }
36 
37 namespace sfx2 { namespace appl {
38 
39 // The MS compiler needs this typedef work-around to accept the using
40 // declarations within ImeStatusWindow:
41 typedef cppu::WeakImplHelper1< com::sun::star::beans::XPropertyChangeListener >
42 ImeStatusWindow_Impl;
43 
44 /** Control the behavior of any (platform-dependent) IME status windows.
45 
46     The decision of whether a status window shall be displayed or not can be
47     stored permanently in the configuration (under key
48     org.openoffice.office.Common/I18N/InputMethod/ShowStatusWindow; if that
49     entry is nil, VCL is asked for a default).
50  */
51 class ImeStatusWindow: private ImeStatusWindow_Impl
52 {
53 public:
54     ImeStatusWindow( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > const& rServiceFactory );
55 
56     /** Set up VCL according to the configuration.
57 
58         Is it not strictly required that this method is called exactly once
59         (though that will be the typical use).
60 
61         Must only be called with the Solar mutex locked.
62      */
63     void init();
64 
65     /** Return true if the status window is toggled on.
66 
67         This is only meaningful when canToggle returns true.
68 
69         Can be called without the Solar mutex locked.
70      */
71     bool isShowing();
72 
73     /** Toggle the status window on or off.
74 
75         This only works if canToggle returns true (otherwise, any calls of this
76         method are ignored).
77 
78         Must only be called with the Solar mutex locked.
79      */
80     void show(bool bShow);
81 
82     /** Return true if the status window can be toggled on and off externally.
83 
84         Must only be called with the Solar mutex locked.
85      */
86     bool canToggle() const;
87 
88     using ImeStatusWindow_Impl::acquire;
89     using ImeStatusWindow_Impl::release;
90     using ImeStatusWindow_Impl::operator new;
91     using ImeStatusWindow_Impl::operator delete;
92 
93 private:
94     ImeStatusWindow(ImeStatusWindow &); // not implemented
95     void operator =(ImeStatusWindow); // not implemented
96 
97     virtual ~ImeStatusWindow();
98 
99     virtual void SAL_CALL
100     disposing(com::sun::star::lang::EventObject const & rSource)
101         throw (com::sun::star::uno::RuntimeException);
102 
103     virtual void SAL_CALL
104     propertyChange(com::sun::star::beans::PropertyChangeEvent const & rEvent)
105         throw (com::sun::star::uno::RuntimeException);
106 
107     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >
108     getConfig();
109 
110     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
111         m_xServiceFactory;
112 
113     osl::Mutex m_aMutex;
114     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >
115         m_xConfig;
116     bool m_bDisposed;
117 };
118 
119 } }
120 
121 #endif // INCLUDED_SFX2_APPL_IMESTATUSWINDOW_HXX
122