LibreOffice Module framework (master) 1
statusindicatorfactory.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <vector>
25#include <mutex>
26
27// include files of own module
29
30// include uno interfaces
31#include <com/sun/star/lang/XServiceInfo.hpp>
32#include <com/sun/star/lang/XInitialization.hpp>
33#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
34#include <com/sun/star/task/XStatusIndicator.hpp>
35#include <com/sun/star/awt/XWindow.hpp>
36#include <com/sun/star/frame/XFrame.hpp>
37#include <com/sun/star/util/XUpdatable.hpp>
38#include <com/sun/star/uno/XComponentContext.hpp>
39
42#include <rtl/ref.hxx>
43
44namespace framework{
45
52{
53
54 // member
55 public:
56
59 css::uno::Reference< css::task::XStatusIndicator > m_xIndicator;
60
62 OUString m_sText;
63
65 sal_Int32 m_nValue;
66
67 // interface
68 public:
69
81 IndicatorInfo(const css::uno::Reference< css::task::XStatusIndicator >& xIndicator,
82 const OUString& sText )
83 {
84 m_xIndicator = xIndicator;
85 m_sText = sText;
86 m_nValue = 0;
87 }
88
95 bool operator==(const css::uno::Reference< css::task::XStatusIndicator >& xIndicator) const
96 {
97 return (m_xIndicator == xIndicator);
98 }
99};
100
102typedef ::std::vector< IndicatorInfo > IndicatorStack;
103
119class StatusIndicatorFactory final : public ::cppu::WeakImplHelper<
120 css::lang::XServiceInfo
121 , css::lang::XInitialization
122 , css::task::XStatusIndicatorFactory
123 , css::util::XUpdatable >
124{
125
126 // member
127 private:
128 std::mutex m_mutex;
129
132
134 css::uno::Reference< css::uno::XComponentContext > m_xContext;
135
137 css::uno::Reference< css::task::XStatusIndicator > m_xActiveChild;
138
141 css::uno::Reference< css::task::XStatusIndicator > m_xProgress;
142
145 css::uno::WeakReference< css::frame::XFrame > m_xFrame;
146
149 css::uno::WeakReference< css::awt::XWindow > m_xPluggWindow;
150
154
160
163
166
168 static sal_Int32 m_nInReschedule;
169
170 // interface
171
172 public:
173 StatusIndicatorFactory(css::uno::Reference< css::uno::XComponentContext > xContext);
174
175 virtual OUString SAL_CALL getImplementationName() override
176 {
177 return "com.sun.star.comp.framework.StatusIndicatorFactory";
178 }
179
180 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
181 {
183 }
184
185 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
186 {
187 return { "com.sun.star.task.StatusIndicatorFactory" };
188 }
189
190 // XInitialization
191 virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override;
192
193 // XStatusIndicatorFactory
194 virtual css::uno::Reference< css::task::XStatusIndicator > SAL_CALL createStatusIndicator() override;
195
196 // XUpdatable
197 virtual void SAL_CALL update() override;
198
199 // similar (XStatusIndicator)
200 void start(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
201 const OUString& sText ,
202 sal_Int32 nRange);
203
204 void reset(const css::uno::Reference< css::task::XStatusIndicator >& xChild);
205
206 void end(const css::uno::Reference< css::task::XStatusIndicator >& xChild);
207
208 void setText(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
209 const OUString& sText );
210
211 void setValue(const css::uno::Reference< css::task::XStatusIndicator >& xChild,
212 sal_Int32 nValue);
213
214 // specials
215
216 private:
217
218 virtual ~StatusIndicatorFactory() override;
219
220 // helper
221
234
240 void impl_createProgress();
241
247 void impl_showProgress();
248
254 void impl_hideProgress();
255
261 void impl_reschedule(bool bForceUpdate);
262
265
266}; // class StatusIndicatorFactory
267
268} // namespace framework
269
270/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
implement a factory service to create new status indicator objects
virtual void SAL_CALL update() override
void setText(const css::uno::Reference< css::task::XStatusIndicator > &xChild, const OUString &sText)
bool m_bDisableReschedule
enable/disable rescheduling.
bool m_bAllowReschedule
Our WakeUpThread calls us in our interface method "XUpdatable::update().
void end(const css::uno::Reference< css::task::XStatusIndicator > &xChild)
static sal_Int32 m_nInReschedule
prevent recursive calling of Application::Reschedule().
css::uno::Reference< css::task::XStatusIndicator > m_xActiveChild
most active indicator child, which could work with our shared indicator window only.
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &lArguments) override
IndicatorStack m_aStack
stack with all current indicator children.
void setValue(const css::uno::Reference< css::task::XStatusIndicator > &xChild, sal_Int32 nValue)
void start(const css::uno::Reference< css::task::XStatusIndicator > &xChild, const OUString &sText, sal_Int32 nRange)
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
StatusIndicatorFactory(css::uno::Reference< css::uno::XComponentContext > xContext)
virtual OUString SAL_CALL getImplementationName() override
void impl_reschedule(bool bForceUpdate)
try to "share the current thread in an intelligent manner" :-)
void impl_showProgress()
shows the internal used progress.
css::uno::WeakReference< css::frame::XFrame > m_xFrame
points to the frame, where we show the progress (in case m_xProgress points to a frame progress.
css::uno::Reference< css::task::XStatusIndicator > m_xProgress
used to show the progress on the frame (layouted!) or as a plugged vcl window.
virtual css::uno::Reference< css::task::XStatusIndicator > SAL_CALL createStatusIndicator() override
rtl::Reference< WakeUpThread > m_pWakeUp
Notify us if a fix time is over.
void implts_makeParentVisibleIfAllowed()
show the parent window of this progress ... if it's allowed to do so.
void impl_createProgress()
creates a new internal used progress.
css::uno::WeakReference< css::awt::XWindow > m_xPluggWindow
points to an outside window, where we show the progress (in case we are plugged into such window).
void impl_hideProgress()
hides the internal used progress.
void reset(const css::uno::Reference< css::task::XStatusIndicator > &xChild)
bool m_bAllowParentShow
enable/disable automatic showing of our parent window.
css::uno::Reference< css::uno::XComponentContext > m_xContext
uno service manager to create own needed uno resources.
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
::std::vector< IndicatorInfo > IndicatorStack
@descr Define a list of child indicator objects and its data.
@descr This struct hold some information about all currently running progress processes.
bool operator==(const css::uno::Reference< css::task::XStatusIndicator > &xIndicator) const
Used to locate an info struct inside a stl structure...
css::uno::Reference< css::task::XStatusIndicator > m_xIndicator
points to the indicator child, where we hold its states alive here.
sal_Int32 m_nValue
the last set value for this indicator
OUString m_sText
the last set text for this indicator
IndicatorInfo(const css::uno::Reference< css::task::XStatusIndicator > &xIndicator, const OUString &sText)
initialize new instance of this class
unsigned char sal_Bool