LibreOffice Module sc (master) 1
fprogressbar.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 <vector>
23#include <memory>
24#include <rtl/ustring.hxx>
25#include <progress.hxx>
26#include <unotools/resmgr.hxx>
27
28class SfxObjectShell;
29class SvStream;
30
31const sal_Int32 SCF_INV_SEGMENT = -1;
32
102class ScfProgressBar final
103{
104public:
107
108 explicit ScfProgressBar(SfxObjectShell* pDocShell, OUString aText);
109 explicit ScfProgressBar(SfxObjectShell* pDocShell, TranslateId pResId);
111
114 sal_Int32 AddSegment( std::size_t nSize );
119 ScfProgressBar& GetSegmentProgressBar( sal_Int32 nSegment );
120
122 bool IsFull() const;
123
125 void ActivateSegment( sal_Int32 nSegment );
127 void Activate() { ActivateSegment( 0 ); }
129 void ProgressAbs( std::size_t nPos );
131 void Progress( std::size_t nDelta = 1 );
132
133private:
134 struct ScfProgressSegment;
135
137 explicit ScfProgressBar(
138 ScfProgressBar& rParProgress,
139 ScfProgressSegment* pParSegment );
140
142 void Init( SfxObjectShell* pDocShell );
143
145 ScfProgressSegment* GetSegment( sal_Int32 nSegment );
147 void SetCurrSegment( ScfProgressSegment* pSegment );
149 void IncreaseProgressBar( std::size_t nDelta );
150
151private:
154 {
155 typedef ::std::unique_ptr< ScfProgressBar > ScfProgressBarPtr;
156
158 std::size_t mnSize;
159 std::size_t mnPos;
160
161 explicit ScfProgressSegment( std::size_t nSize );
163 };
164
165 typedef ::std::unique_ptr< ScProgress > ScProgressPtr;
166 typedef std::vector< std::unique_ptr<ScfProgressSegment> > ScfSegmentList;
167
169 OUString maText;
170
176
177 std::size_t mnTotalSize;
178 std::size_t mnTotalPos;
179 std::size_t mnUnitSize;
180 std::size_t mnNextUnitPos;
181 std::size_t mnSysProgressScale;
183};
184
187{
188public:
189 explicit ScfSimpleProgressBar(std::size_t nSize, SfxObjectShell* pDocShell, const OUString& rText);
190 explicit ScfSimpleProgressBar(std::size_t nSize, SfxObjectShell* pDocShell, TranslateId pResId);
191
193 void ProgressAbs( std::size_t nPos ) { maProgress.ProgressAbs( nPos ); }
194
195private:
197 void Init( std::size_t nSize );
198
199private:
201};
202
205{
206public:
207 explicit ScfStreamProgressBar( SvStream& rStrm, SfxObjectShell* pDocShell );
208
210 void Progress();
211
212private:
214 void Init( SfxObjectShell* pDocShell, const OUString& rText );
215
216private:
217 typedef ::std::unique_ptr< ScfSimpleProgressBar > ScfSimpleProgressBarPtr;
218
221};
222
223/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Progress bar for complex progress representation.
std::vector< std::unique_ptr< ScfProgressSegment > > ScfSegmentList
sal_Int32 AddSegment(std::size_t nSize)
Adds a new segment to the progress bar.
std::size_t mnNextUnitPos
Size between two calls of system progress.
ScfProgressSegment * mpParentSegment
Parent progress bar, if this is a segment progress bar.
bool mbInProgress
Additionally scaling factor for system progress.
std::size_t mnUnitSize
Sum of positions of all segments.
void ProgressAbs(std::size_t nPos)
Set current segment to the specified absolute position.
ScfSegmentList maSegments
void ActivateSegment(sal_Int32 nSegment)
Starts the progress bar or activates another segment.
ScProgressPtr mxSysProgress
UI string for system progress.
bool IsFull() const
Returns true, if the current progress segment is already full.
::std::unique_ptr< ScProgress > ScProgressPtr
SfxObjectShell * mpDocShell
System progress bar.
ScfProgressBar & GetSegmentProgressBar(sal_Int32 nSegment)
Returns a complete progress bar for the specified segment.
void Progress(std::size_t nDelta=1)
Increase current segment by the passed value.
std::size_t mnSysProgressScale
Limit for next system progress call.
ScfProgressSegment * mpCurrSegment
Parent segment, if this is a segment progress bar.
void Activate()
Starts the progress bar (with first segment).
ScfProgressBar * mpParentProgress
The document shell for the progress bar.
void SetCurrSegment(ScfProgressSegment *pSegment)
Activates progress bar and sets current segment.
OUString maText
List of progress segments.
void Init(SfxObjectShell *pDocShell)
Initializes all members on construction.
const ScfProgressBar operator=(const ScfProgressBar &)=delete
std::size_t mnTotalSize
Current segment for progress.
void IncreaseProgressBar(std::size_t nDelta)
Increases mnTotalPos and calls the system progress bar.
ScfProgressBar(const ScfProgressBar &)=delete
ScfProgressSegment * GetSegment(sal_Int32 nSegment)
Returns the segment specified by list index.
std::size_t mnTotalPos
Total size of all segments.
A simplified progress bar with only one segment.
ScfSimpleProgressBar(std::size_t nSize, SfxObjectShell *pDocShell, const OUString &rText)
void Init(std::size_t nSize)
Initializes and starts the progress bar.
ScfProgressBar maProgress
void ProgressAbs(std::size_t nPos)
Set progress bar to the specified position.
A simplified progress bar based on the stream position of an existing stream.
void Progress()
Sets the progress bar to the current stream position.
SvStream & mrStrm
The used progress bar.
void Init(SfxObjectShell *pDocShell, const OUString &rText)
Initializes and starts the progress bar.
::std::unique_ptr< ScfSimpleProgressBar > ScfSimpleProgressBarPtr
ScfSimpleProgressBarPtr mxProgress
ScfStreamProgressBar(SvStream &rStrm, SfxObjectShell *pDocShell)
const sal_Int32 SCF_INV_SEGMENT
sal_uInt16 nPos
void SvStream & rStrm
Contains all data of a segment of the progress bar.
::std::unique_ptr< ScfProgressBar > ScfProgressBarPtr
std::size_t mnSize
Pointer to sub progress bar for this segment.
std::size_t mnPos
Size of this segment.
ScfProgressSegment(std::size_t nSize)
Current position of this segment.