LibreOffice Module UnoControls (master) 1
progressmonitor.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 <com/sun/star/awt/XProgressMonitor.hpp>
23#include <com/sun/star/awt/XButton.hpp>
24#include <com/sun/star/awt/XLayoutConstrains.hpp>
25#include <rtl/ref.hxx>
26
27#include <vector>
28
30
31namespace com::sun::star::awt { class XFixedText; }
32namespace com::sun::star::awt { class XControlModel; }
33
34namespace unocontrols {
35
36class ProgressBar;
37
38#define PROGRESSMONITOR_FREEBORDER 10 // border around and between the controls
39inline constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TOPIC = u"";
40inline constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TEXT = u"";
41#define PROGRESSMONITOR_LINECOLOR_BRIGHT sal_Int32(Color( 0xFF, 0xFF, 0xFF )) // white
42#define PROGRESSMONITOR_LINECOLOR_SHADOW sal_Int32(Color( 0x00, 0x00, 0x00 )) // black
43#define PROGRESSMONITOR_DEFAULT_WIDTH 350
44#define PROGRESSMONITOR_DEFAULT_HEIGHT 100
45
48{
49 OUString sTopic;
50 OUString sText;
51};
52
53class ProgressMonitor final : public css::awt::XLayoutConstrains
54 , public css::awt::XButton
55 , public css::awt::XProgressMonitor
57{
58public:
59 ProgressMonitor( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
60
61 virtual ~ProgressMonitor() override;
62
63 // XInterface
64
78 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
79
87 virtual void SAL_CALL acquire() noexcept override;
88
96 virtual void SAL_CALL release() noexcept override;
97
98 // XTypeProvider
99
108 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
109
110 // XProgressMonitor
111
129 virtual void SAL_CALL addText(
130 const OUString& sTopic ,
131 const OUString& sText ,
132 sal_Bool bbeforeProgress
133 ) override;
134
135 virtual void SAL_CALL removeText(
136 const OUString& sTopic ,
137 sal_Bool bbeforeProgress
138 ) override;
139
140 virtual void SAL_CALL updateText(
141 const OUString& sTopic ,
142 const OUString& sText ,
143 sal_Bool bbeforeProgress
144 ) override;
145
146 // XProgressBar
147
148 virtual void SAL_CALL setForegroundColor( sal_Int32 nColor ) override;
149
150 virtual void SAL_CALL setBackgroundColor( sal_Int32 nColor ) override;
151
152 virtual void SAL_CALL setValue( sal_Int32 nValue ) override;
153
154 virtual void SAL_CALL setRange( sal_Int32 nMin ,
155 sal_Int32 nMax ) override;
156
157 virtual sal_Int32 SAL_CALL getValue() override;
158
159 // XButton
160
161 virtual void SAL_CALL addActionListener(
162 const css::uno::Reference< css::awt::XActionListener >& xListener
163 ) override;
164
165 virtual void SAL_CALL removeActionListener(
166 const css::uno::Reference< css::awt::XActionListener >& xListener
167 ) override;
168
169 virtual void SAL_CALL setLabel( const OUString& sLabel ) override;
170
171 virtual void SAL_CALL setActionCommand( const OUString& sCommand ) override;
172
173 // XLayoutConstrains
174
175 virtual css::awt::Size SAL_CALL getMinimumSize() override;
176
177 virtual css::awt::Size SAL_CALL getPreferredSize() override;
178
179 virtual css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override;
180
181 // XControl
182
183 virtual void SAL_CALL createPeer(
184 const css::uno::Reference< css::awt::XToolkit >& xToolkit ,
185 const css::uno::Reference< css::awt::XWindowPeer >& xParent
186 ) override;
187
188 virtual sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& xModel ) override;
189
190 virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override;
191
192 // XComponent
193
194 virtual void SAL_CALL dispose() override;
195
196 // XWindow
197
198 virtual void SAL_CALL setPosSize( sal_Int32 nX ,
199 sal_Int32 nY ,
200 sal_Int32 nWidth ,
201 sal_Int32 nHeight ,
202 sal_Int16 nFlags ) override;
203
204private:
205 virtual void impl_paint( sal_Int32 nX ,
206 sal_Int32 nY ,
207 const css::uno::Reference< css::awt::XGraphics >& xGraphics ) override;
208
210
211 void impl_recalcLayout();
212
214
215 void impl_cleanMemory();
216
217 IMPL_TextlistItem* impl_searchTopic( std::u16string_view sTopic , bool bbeforeProgress );
218
219// debug methods
220
221 static bool impl_debug_checkParameter( std::u16string_view sTopic, std::u16string_view sText ); // addText, updateText
222 static bool impl_debug_checkParameter( std::u16string_view rTopic ); // removeText
223
224// private variables
225
226private:
227 ::std::vector < IMPL_TextlistItem > maTextlist_Top; // Elements before progress
228 css::uno::Reference< css::awt::XFixedText > m_xTopic_Top; // (used, if parameter "beforeProgress"=true in "addText, updateText, removeText")
229 css::uno::Reference< css::awt::XFixedText > m_xText_Top;
230
231 ::std::vector < IMPL_TextlistItem > maTextlist_Bottom; // Elements below of progress
232 css::uno::Reference< css::awt::XFixedText > m_xTopic_Bottom; // (used, if parameter "beforeProgress"=false in "addText, updateText, removeText")
233 css::uno::Reference< css::awt::XFixedText > m_xText_Bottom;
234
236 css::uno::Reference< css::awt::XButton > m_xButton;
237 css::awt::Rectangle m_a3DLine;
238};
239
240}
241
242
243/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void impl_recalcLayout(const css::awt::WindowEvent &aEvent)
virtual void SAL_CALL setBackgroundColor(sal_Int32 nColor) override
css::uno::Reference< css::awt::XFixedText > m_xTopic_Top
virtual css::awt::Size SAL_CALL getMinimumSize() override
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override
virtual void SAL_CALL release() noexcept override
decrement refcount @seealso XInterface @seealso acquire() @onerror A RuntimeException is thrown.
virtual css::awt::Size SAL_CALL calcAdjustedSize(const css::awt::Size &aNewSize) override
virtual ~ProgressMonitor() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
give answer, if interface is supported @descr The interfaces are searched by type.
ProgressMonitor(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
get information about supported interfaces @seealso XTypeProvider
virtual void SAL_CALL removeText(const OUString &sTopic, sal_Bool bbeforeProgress) override
virtual sal_Bool SAL_CALL setModel(const css::uno::Reference< css::awt::XControlModel > &xModel) override
virtual void SAL_CALL setPosSize(sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nFlags) override
::std::vector< IMPL_TextlistItem > maTextlist_Bottom
virtual css::awt::Size SAL_CALL getPreferredSize() override
virtual void SAL_CALL setForegroundColor(sal_Int32 nColor) override
virtual void SAL_CALL removeActionListener(const css::uno::Reference< css::awt::XActionListener > &xListener) override
css::uno::Reference< css::awt::XFixedText > m_xText_Bottom
virtual void SAL_CALL addText(const OUString &sTopic, const OUString &sText, sal_Bool bbeforeProgress) override
add topic to dialog @descr Add a topic with a text in right textlist (used for FixedText-member).
virtual void SAL_CALL addActionListener(const css::uno::Reference< css::awt::XActionListener > &xListener) override
virtual void SAL_CALL dispose() override
::std::vector< IMPL_TextlistItem > maTextlist_Top
virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &xToolkit, const css::uno::Reference< css::awt::XWindowPeer > &xParent) override
virtual sal_Int32 SAL_CALL getValue() override
virtual void impl_paint(sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< css::awt::XGraphics > &xGraphics) override
virtual void SAL_CALL setRange(sal_Int32 nMin, sal_Int32 nMax) override
css::uno::Reference< css::awt::XFixedText > m_xTopic_Bottom
css::uno::Reference< css::awt::XButton > m_xButton
virtual void SAL_CALL setActionCommand(const OUString &sCommand) override
css::uno::Reference< css::awt::XFixedText > m_xText_Top
virtual void SAL_CALL setLabel(const OUString &sLabel) override
IMPL_TextlistItem * impl_searchTopic(std::u16string_view sTopic, bool bbeforeProgress)
virtual void SAL_CALL setValue(sal_Int32 nValue) override
static bool impl_debug_checkParameter(std::u16string_view sTopic, std::u16string_view sText)
rtl::Reference< ProgressBar > m_xProgressBar
virtual void SAL_CALL updateText(const OUString &sTopic, const OUString &sText, sal_Bool bbeforeProgress) override
virtual void SAL_CALL acquire() noexcept override
increment refcount @seealso XInterface @seealso release() @onerror A RuntimeException is thrown.
float u
sal_Int16 nValue
constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TEXT
constexpr OUStringLiteral PROGRESSMONITOR_DEFAULT_TOPIC
OUString sText
Left site of textline in dialog.
Reference< XModel > xModel
unsigned char sal_Bool