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 __FRAMEWORK_HELPER_VCLSTATUSINDICATOR_HXX_
29 #define __FRAMEWORK_HELPER_VCLSTATUSINDICATOR_HXX_
30 
31 //-----------------------------------------------
32 // includes of own modules
33 
34 #include <threadhelp/threadhelpbase.hxx>
35 #include <macros/generic.hxx>
36 #include <macros/xinterface.hxx>
37 #include <general.h>
38 
39 //-----------------------------------------------
40 // includes of interfaces
41 #include <com/sun/star/task/XStatusIndicator.hpp>
42 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 #include <com/sun/star/awt/XWindow.hpp>
44 
45 //-----------------------------------------------
46 // includes of external modules
47 #include <cppuhelper/weak.hxx>
48 #include <vcl/status.hxx>
49 
50 //-----------------------------------------------
51 // namespace
52 
53 namespace framework {
54 
55 //-----------------------------------------------
56 // declaration
57 
58 class VCLStatusIndicator : public  css::task::XStatusIndicator
59                          , private ThreadHelpBase // must be the first real base class!
60                          , public  ::cppu::OWeakObject
61 {
62     //-------------------------------------------
63     // member
64 
65     private:
66 
67         /** can be used to create own needed uno resources. */
68         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
69 
70         /** points to the parent window of this progress and
71             hold it alive. */
72         css::uno::Reference< css::awt::XWindow > m_xParentWindow;
73 
74         /** shows the progress.
75 
76             @attention  This member isnt synchronized using our own mutex!
77                         Its guarded by the solarmutex only. Otherwhise
78                         we have to lock two of them, which can force a deadlock ...
79             */
80         StatusBar* m_pStatusBar;
81 
82         /** knows the current info text of the progress. */
83         ::rtl::OUString m_sText;
84 
85         /** knows the current range of the progress. */
86         sal_Int32 m_nRange;
87 
88         /** knows the current value of the progress. */
89         sal_Int32 m_nValue;
90 
91     //-------------------------------------------
92     // interface
93 
94     public:
95 
96         FWK_DECLARE_XINTERFACE
97 
98         /// ctor
99         VCLStatusIndicator(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR        ,
100                            const css::uno::Reference< css::awt::XWindow >&               xParentWindow);
101 
102         /// dtor
103         virtual ~VCLStatusIndicator();
104 
105         /// XStatusIndicator
106         virtual void SAL_CALL start(const ::rtl::OUString& sText ,
107                                           sal_Int32        nRange)
108             throw(css::uno::RuntimeException);
109 
110         virtual void SAL_CALL reset()
111             throw(css::uno::RuntimeException);
112 
113         virtual void SAL_CALL end()
114             throw(css::uno::RuntimeException);
115 
116         virtual void SAL_CALL setText(const ::rtl::OUString& sText)
117             throw(css::uno::RuntimeException);
118 
119         virtual void SAL_CALL setValue(sal_Int32 nValue)
120             throw(css::uno::RuntimeException);
121 
122     //-------------------------------------------
123     // helper
124 
125     private:
126 
127         static void impl_recalcLayout(Window* pStatusBar   ,
128                                       Window* pParentWindow);
129 };
130 
131 } // namespace framework
132 
133 #endif // __FRAMEWORK_HELPER_VCLSTATUSINDICATOR_HXX_
134