LibreOffice Module framework (master) 1
statusindicator.cxx
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#include <comphelper/lok.hxx>
22
23namespace framework
24{
26 : m_xFactory(pFactory)
27 , m_nRange(100)
28 , m_nLastCallbackPercent(-1)
29{
30}
31
33
34void SAL_CALL StatusIndicator::start(const OUString& sText, sal_Int32 nRange)
35{
37 {
38 m_nRange = nRange;
40
42 }
43#if !defined(IOS) && !defined(ANDROID)
44 css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory);
45 if (xFactory.is())
46 {
47 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
48 pFactory->start(this, sText, nRange);
49 }
50#else
51 (void)sText;
52#endif
53}
54
55void SAL_CALL StatusIndicator::end()
56{
58 {
60 }
61#if !defined(IOS) && !defined(ANDROID)
62 css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory);
63 if (xFactory.is())
64 {
65 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
66 pFactory->end(this);
67 }
68#endif
69}
70
72{
74 return;
75#if !defined(IOS) && !defined(ANDROID)
76 css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory);
77 if (xFactory.is())
78 {
79 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
80 pFactory->reset(this);
81 }
82#endif
83}
84
85void SAL_CALL StatusIndicator::setText(const OUString& sText)
86{
88 return;
89#if !defined(IOS) && !defined(ANDROID)
90 css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory);
91 if (xFactory.is())
92 {
93 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
94 pFactory->setText(this, sText);
95 }
96#else
97 (void)sText;
98#endif
99}
100
101void SAL_CALL StatusIndicator::setValue(sal_Int32 nValue)
102{
104 {
105 if (m_nRange > 0)
106 {
107 int nPercent = (100 * nValue) / m_nRange;
108 if (nPercent >= m_nLastCallbackPercent)
109 {
111 m_nLastCallbackPercent = nPercent;
112 }
113 }
114 return;
115 }
116#if !defined(IOS) && !defined(ANDROID)
117 css::uno::Reference<css::task::XStatusIndicatorFactory> xFactory(m_xFactory);
118 if (xFactory.is())
119 {
120 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
121 pFactory->setValue(this, nValue);
122 }
123#endif
124}
125
126} // namespace framework
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
implement a factory service to create new status indicator objects
void setText(const css::uno::Reference< css::task::XStatusIndicator > &xChild, const OUString &sText)
void end(const css::uno::Reference< css::task::XStatusIndicator > &xChild)
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)
void reset(const css::uno::Reference< css::task::XStatusIndicator > &xChild)
virtual void SAL_CALL start(const OUString &sText, sal_Int32 nRange) override
virtual void SAL_CALL setText(const OUString &sText) override
virtual void SAL_CALL reset() override
virtual void SAL_CALL end() override
virtual ~StatusIndicator() override
does nothing real...
css::uno::WeakReference< css::task::XStatusIndicatorFactory > m_xFactory
weak reference to our factory @descr All our interface calls will be forwarded to a suitable c++ inte...
StatusIndicator(StatusIndicatorFactory *pFactory)
initialize new instance of this class.
virtual void SAL_CALL setValue(sal_Int32 nValue) override
Reference< XSingleServiceFactory > xFactory
sal_Int16 nValue
void statusIndicatorStart(const OUString &sText)
void statusIndicatorSetValue(int percent)