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