/src/libreoffice/framework/source/helper/statusindicator.cxx
Line | Count | Source |
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> |
21 | | #include <helper/statusindicator.hxx> |
22 | | |
23 | | namespace framework |
24 | | { |
25 | | StatusIndicator::StatusIndicator(StatusIndicatorFactory* pFactory) |
26 | 0 | : m_xFactory(pFactory) |
27 | 0 | , m_nRange(100) |
28 | 0 | , m_nLastCallbackPercent(-1) |
29 | 0 | { |
30 | 0 | } |
31 | | |
32 | 0 | StatusIndicator::~StatusIndicator() {} |
33 | | |
34 | | void SAL_CALL StatusIndicator::start(const OUString& sText, sal_Int32 nRange) |
35 | 0 | { |
36 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
37 | 0 | { |
38 | 0 | m_nRange = nRange; |
39 | 0 | m_nLastCallbackPercent = -1; |
40 | |
|
41 | 0 | comphelper::LibreOfficeKit::statusIndicatorStart(sText); |
42 | 0 | } |
43 | 0 | #if !defined(IOS) && !defined(ANDROID) |
44 | 0 | rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); |
45 | 0 | if (xFactory.is()) |
46 | 0 | xFactory->start(this, sText, nRange); |
47 | | #else |
48 | | (void)sText; |
49 | | #endif |
50 | 0 | } |
51 | | |
52 | | void SAL_CALL StatusIndicator::end() |
53 | 0 | { |
54 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
55 | 0 | { |
56 | 0 | comphelper::LibreOfficeKit::statusIndicatorFinish(); |
57 | 0 | } |
58 | 0 | #if !defined(IOS) && !defined(ANDROID) |
59 | 0 | rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); |
60 | 0 | if (xFactory.is()) |
61 | 0 | xFactory->end(this); |
62 | 0 | #endif |
63 | 0 | } |
64 | | |
65 | | void SAL_CALL StatusIndicator::reset() |
66 | 0 | { |
67 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
68 | 0 | return; |
69 | 0 | #if !defined(IOS) && !defined(ANDROID) |
70 | 0 | rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); |
71 | 0 | if (xFactory.is()) |
72 | 0 | xFactory->reset(this); |
73 | 0 | #endif |
74 | 0 | } |
75 | | |
76 | | void SAL_CALL StatusIndicator::setText(const OUString& sText) |
77 | 0 | { |
78 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
79 | 0 | return; |
80 | 0 | #if !defined(IOS) && !defined(ANDROID) |
81 | 0 | rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); |
82 | 0 | if (xFactory.is()) |
83 | 0 | xFactory->setText(this, sText); |
84 | | #else |
85 | | (void)sText; |
86 | | #endif |
87 | 0 | } |
88 | | |
89 | | void SAL_CALL StatusIndicator::setValue(sal_Int32 nValue) |
90 | 0 | { |
91 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
92 | 0 | { |
93 | 0 | if (m_nRange > 0) |
94 | 0 | { |
95 | 0 | int nPercent = (100 * nValue) / m_nRange; |
96 | 0 | if (nPercent >= m_nLastCallbackPercent) |
97 | 0 | { |
98 | 0 | comphelper::LibreOfficeKit::statusIndicatorSetValue(nPercent); |
99 | 0 | m_nLastCallbackPercent = nPercent; |
100 | 0 | } |
101 | 0 | } |
102 | 0 | return; |
103 | 0 | } |
104 | 0 | #if !defined(IOS) && !defined(ANDROID) |
105 | 0 | rtl::Reference<StatusIndicatorFactory> xFactory(m_xFactory); |
106 | 0 | if (xFactory.is()) |
107 | 0 | xFactory->setValue(this, nValue); |
108 | 0 | #endif |
109 | 0 | } |
110 | | |
111 | | } // namespace framework |
112 | | |
113 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |