fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / helper / statusindicator.cxx
blob5c9dafc5ba8149e8744abe1c1dd4e8a14e0d2b5b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
23 namespace framework{
25 StatusIndicator::StatusIndicator(StatusIndicatorFactory* pFactory)
26 : m_xFactory(pFactory)
27 , m_nRange(100)
28 , m_nLastCallbackPercent(-1)
32 StatusIndicator::~StatusIndicator()
36 void SAL_CALL StatusIndicator::start(const OUString& sText ,
37 sal_Int32 nRange)
38 throw(css::uno::RuntimeException, std::exception)
40 if (comphelper::LibreOfficeKit::isActive())
42 m_nRange = nRange;
43 m_nLastCallbackPercent = -1;
45 comphelper::LibreOfficeKit::statusIndicatorStart();
46 return;
49 css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
50 if (xFactory.is())
52 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
53 pFactory->start(this, sText, nRange);
57 void SAL_CALL StatusIndicator::end()
58 throw(css::uno::RuntimeException, std::exception)
60 if (comphelper::LibreOfficeKit::isActive())
62 comphelper::LibreOfficeKit::statusIndicatorFinish();
63 return;
66 css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
67 if (xFactory.is())
69 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
70 pFactory->end(this);
74 void SAL_CALL StatusIndicator::reset()
75 throw(css::uno::RuntimeException, std::exception)
77 if (comphelper::LibreOfficeKit::isActive())
78 return;
80 css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
81 if (xFactory.is())
83 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
84 pFactory->reset(this);
88 void SAL_CALL StatusIndicator::setText(const OUString& sText)
89 throw(css::uno::RuntimeException, std::exception)
91 if (comphelper::LibreOfficeKit::isActive())
92 return;
94 css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
95 if (xFactory.is())
97 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
98 pFactory->setText(this, sText);
102 void SAL_CALL StatusIndicator::setValue(sal_Int32 nValue)
103 throw(css::uno::RuntimeException, std::exception)
105 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;
113 return;
116 css::uno::Reference< css::task::XStatusIndicatorFactory > xFactory(m_xFactory);
117 if (xFactory.is())
119 StatusIndicatorFactory* pFactory = static_cast<StatusIndicatorFactory*>(xFactory.get());
120 pFactory->setValue(this, nValue);
124 } // namespace framework
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */