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 #if !defined INCLUDED_SFX2_APPL_IMESTATUSWINDOW_HXX
29 #define INCLUDED_SFX2_APPL_IMESTATUSWINDOW_HXX
30 
31 #include "com/sun/star/beans/XPropertyChangeListener.hpp"
32 #include "com/sun/star/uno/Reference.hxx"
33 #include "cppuhelper/implbase1.hxx"
34 #include "osl/mutex.hxx"
35 
36 namespace com { namespace sun { namespace star {
37     namespace beans { class XPropertySet; }
38     namespace lang { class XMultiServiceFactory; }
39 } } }
40 
41 namespace sfx2 { namespace appl {
42 
43 // The MS compiler needs this typedef work-around to accept the using
44 // declarations within ImeStatusWindow:
45 typedef cppu::WeakImplHelper1< com::sun::star::beans::XPropertyChangeListener >
46 ImeStatusWindow_Impl;
47 
48 /** Control the behavior of any (platform-dependent) IME status windows.
49 
50     The decision of whether a status window shall be displayed or not can be
51     stored permanently in the configuration (under key
52     org.openoffice.office.Common/I18N/InputMethod/ShowStatusWindow; if that
53     entry is nil, VCL is asked for a default).
54  */
55 class ImeStatusWindow: private ImeStatusWindow_Impl
56 {
57 public:
58     ImeStatusWindow( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > const& rServiceFactory );
59 
60     /** Set up VCL according to the configuration.
61 
62         Is it not strictly required that this method is called exactly once
63         (though that will be the typical use).
64 
65         Must only be called with the Solar mutex locked.
66      */
67     void init();
68 
69     /** Return true if the status window is toggled on.
70 
71         This is only meaningful when canToggle returns true.
72 
73         Can be called without the Solar mutex locked.
74      */
75     bool isShowing();
76 
77     /** Toggle the status window on or off.
78 
79         This only works if canToggle returns true (otherwise, any calls of this
80         method are ignored).
81 
82         Must only be called with the Solar mutex locked.
83      */
84     void show(bool bShow);
85 
86     /** Return true if the status window can be toggled on and off externally.
87 
88         Must only be called with the Solar mutex locked.
89      */
90     bool canToggle() const;
91 
92     using ImeStatusWindow_Impl::acquire;
93     using ImeStatusWindow_Impl::release;
94     using ImeStatusWindow_Impl::operator new;
95     using ImeStatusWindow_Impl::operator delete;
96 
97 private:
98     ImeStatusWindow(ImeStatusWindow &); // not implemented
99     void operator =(ImeStatusWindow); // not implemented
100 
101     virtual ~ImeStatusWindow();
102 
103     virtual void SAL_CALL
104     disposing(com::sun::star::lang::EventObject const & rSource)
105         throw (com::sun::star::uno::RuntimeException);
106 
107     virtual void SAL_CALL
108     propertyChange(com::sun::star::beans::PropertyChangeEvent const & rEvent)
109         throw (com::sun::star::uno::RuntimeException);
110 
111     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >
112     getConfig();
113 
114     com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
115         m_xServiceFactory;
116 
117     osl::Mutex m_aMutex;
118     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >
119         m_xConfig;
120     bool m_bDisposed;
121 };
122 
123 } }
124 
125 #endif // INCLUDED_SFX2_APPL_IMESTATUSWINDOW_HXX
126