1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <comphelper/lok.hxx>
21 #include <helper/statusindicator.hxx>
25 StatusIndicator::StatusIndicator(StatusIndicatorFactory
* pFactory
)
26 : m_xFactory(pFactory
)
28 , m_nLastCallbackPercent(-1)
32 StatusIndicator::~StatusIndicator() {}
34 void SAL_CALL
StatusIndicator::start(const OUString
& sText
, sal_Int32 nRange
)
36 if (comphelper::LibreOfficeKit::isActive())
39 m_nLastCallbackPercent
= -1;
41 comphelper::LibreOfficeKit::statusIndicatorStart();
43 #if !defined(IOS) && !defined(ANDROID)
44 css::uno::Reference
<css::task::XStatusIndicatorFactory
> xFactory(m_xFactory
);
47 StatusIndicatorFactory
* pFactory
= static_cast<StatusIndicatorFactory
*>(xFactory
.get());
48 pFactory
->start(this, sText
, nRange
);
55 void SAL_CALL
StatusIndicator::end()
57 if (comphelper::LibreOfficeKit::isActive())
59 comphelper::LibreOfficeKit::statusIndicatorFinish();
61 #if !defined(IOS) && !defined(ANDROID)
62 css::uno::Reference
<css::task::XStatusIndicatorFactory
> xFactory(m_xFactory
);
65 StatusIndicatorFactory
* pFactory
= static_cast<StatusIndicatorFactory
*>(xFactory
.get());
71 void SAL_CALL
StatusIndicator::reset()
73 if (comphelper::LibreOfficeKit::isActive())
75 #if !defined(IOS) && !defined(ANDROID)
76 css::uno::Reference
<css::task::XStatusIndicatorFactory
> xFactory(m_xFactory
);
79 StatusIndicatorFactory
* pFactory
= static_cast<StatusIndicatorFactory
*>(xFactory
.get());
80 pFactory
->reset(this);
85 void SAL_CALL
StatusIndicator::setText(const OUString
& sText
)
87 if (comphelper::LibreOfficeKit::isActive())
89 #if !defined(IOS) && !defined(ANDROID)
90 css::uno::Reference
<css::task::XStatusIndicatorFactory
> xFactory(m_xFactory
);
93 StatusIndicatorFactory
* pFactory
= static_cast<StatusIndicatorFactory
*>(xFactory
.get());
94 pFactory
->setText(this, sText
);
101 void SAL_CALL
StatusIndicator::setValue(sal_Int32 nValue
)
103 if (comphelper::LibreOfficeKit::isActive())
107 int nPercent
= (100 * nValue
) / m_nRange
;
108 if (nPercent
>= m_nLastCallbackPercent
)
110 comphelper::LibreOfficeKit::statusIndicatorSetValue(nPercent
);
111 m_nLastCallbackPercent
= nPercent
;
116 #if !defined(IOS) && !defined(ANDROID)
117 css::uno::Reference
<css::task::XStatusIndicatorFactory
> xFactory(m_xFactory
);
120 StatusIndicatorFactory
* pFactory
= static_cast<StatusIndicatorFactory
*>(xFactory
.get());
121 pFactory
->setValue(this, nValue
);
126 } // namespace framework
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */