LibreOffice Module sc (master) 1
|
Progress bar for complex progress representation. More...
#include <fprogressbar.hxx>
Classes | |
struct | ScfProgressSegment |
Contains all data of a segment of the progress bar. More... | |
Public Member Functions | |
ScfProgressBar (const ScfProgressBar &)=delete | |
const ScfProgressBar | operator= (const ScfProgressBar &)=delete |
ScfProgressBar (SfxObjectShell *pDocShell, OUString aText) | |
ScfProgressBar (SfxObjectShell *pDocShell, TranslateId pResId) | |
~ScfProgressBar () | |
sal_Int32 | AddSegment (std::size_t nSize) |
Adds a new segment to the progress bar. More... | |
ScfProgressBar & | GetSegmentProgressBar (sal_Int32 nSegment) |
Returns a complete progress bar for the specified segment. More... | |
bool | IsFull () const |
Returns true, if the current progress segment is already full. More... | |
void | ActivateSegment (sal_Int32 nSegment) |
Starts the progress bar or activates another segment. More... | |
void | Activate () |
Starts the progress bar (with first segment). More... | |
void | ProgressAbs (std::size_t nPos) |
Set current segment to the specified absolute position. More... | |
void | Progress (std::size_t nDelta=1) |
Increase current segment by the passed value. More... | |
Private Types | |
typedef ::std::unique_ptr< ScProgress > | ScProgressPtr |
typedef std::vector< std::unique_ptr< ScfProgressSegment > > | ScfSegmentList |
Private Member Functions | |
ScfProgressBar (ScfProgressBar &rParProgress, ScfProgressSegment *pParSegment) | |
Used to create sub progress bars. More... | |
void | Init (SfxObjectShell *pDocShell) |
Initializes all members on construction. More... | |
ScfProgressSegment * | GetSegment (sal_Int32 nSegment) |
Returns the segment specified by list index. More... | |
void | SetCurrSegment (ScfProgressSegment *pSegment) |
Activates progress bar and sets current segment. More... | |
void | IncreaseProgressBar (std::size_t nDelta) |
Increases mnTotalPos and calls the system progress bar. More... | |
Private Attributes | |
ScfSegmentList | maSegments |
OUString | maText |
List of progress segments. More... | |
ScProgressPtr | mxSysProgress |
UI string for system progress. More... | |
SfxObjectShell * | mpDocShell |
System progress bar. More... | |
ScfProgressBar * | mpParentProgress |
The document shell for the progress bar. More... | |
ScfProgressSegment * | mpParentSegment |
Parent progress bar, if this is a segment progress bar. More... | |
ScfProgressSegment * | mpCurrSegment |
Parent segment, if this is a segment progress bar. More... | |
std::size_t | mnTotalSize |
Current segment for progress. More... | |
std::size_t | mnTotalPos |
Total size of all segments. More... | |
std::size_t | mnUnitSize |
Sum of positions of all segments. More... | |
std::size_t | mnNextUnitPos |
Size between two calls of system progress. More... | |
std::size_t | mnSysProgressScale |
Limit for next system progress call. More... | |
bool | mbInProgress |
Additionally scaling factor for system progress. More... | |
Progress bar for complex progress representation.
The progress bar contains one or more segments, each with customizable size. Each segment is represented by a unique identifier. While showing the progress bar, several segments can be started simultaneously. The progress bar displays the sum of all started segments on screen.
It is possible to create a full featured ScfProgressBar object from any segment. This sub progress bar works only on that parent segment, with the effect, that if the sub progress bar reaches 100%, the parent segment is filled completely.
After adding segments, the progress bar has to be activated. In this step the total size of all segments is calculated. Therefore it is not possible to add more segments from here.
If a sub progress bar is created from a segment, and the main progress bar has been started (but not the sub progress bar), it is still possible to add segments to the sub progress bar. It is not allowed to get the sub progress bar of a started segment. And it is not allowed to modify the segment containing a sub progress bar directly.
Following a few code examples, how to use the progress bar.
Example 1: Simple progress bar (see also ScfSimpleProgressBar below).
ScfProgressBar aProgress( ... ); sal_Int32 nSeg = aProgress.AddSegment( 50 ); // segment with 50 steps (1 step = 2%) aProgress.ActivateSegment( nSeg ); // start segment nSeg aProgress.Progress(); // 0->1; display: 2% aProgress.ProgressAbs( 9 ); // 1->9; display: 18%
Example 2: Progress bar with 2 segments.
ScfProgressBar aProgress( ... ); sal_Int32 nSeg1 = aProgress.AddSegment( 70 ); // segment with 70 steps sal_Int32 nSeg2 = aProgress.AddSegment( 30 ); // segment with 30 steps
both segments: 100 steps (1 step = 1%)
aProgress.ActivateSegment( nSeg1 ); // start first segment aProgress.Progress(); // 0->1, display: 1% aProgress.Progress( 2 ); // 1->3, display: 3% aProgress.ActivateSegment( nSeg2 ); // start second segment aProgress.Progress( 5 ); // 0->5, display: 8% (5+3 steps) aProgress.ActivateSegment( nSeg1 ); // continue with first segment aProgress.Progress(); // 3->4, display: 9% (5+4 steps) Example 3: Progress bar with 2 segments, one contains a sub progress bar. ScfProgressBar aProgress( ... ); sal_Int32 nSeg1 = aProgress.AddSegment( 75 ); // segment with 75 steps sal_Int32 nSeg2 = aProgress.AddSegment( 25 ); // segment with 25 steps
both segments: 100 steps (1 step = 1%)
aProgress.ActivateSegment( nSeg1 ); // start first segment aProgress.Progress(); // 0->1, display: 1% ScfProgressBar& rSubProgress = aProgress.GetSegmentProgressBar( nSeg2 );
sub progress bar from second segment sal_Int32 nSubSeg = rSubProgress.AddSegment( 5 ); // 5 steps, mapped to second segment => 1 step = 5 steps in parent = 5%
rSubProgress.ActivateSegment( nSubSeg ); // start the segment (auto activate parent segment) rSubProgress.Progress(); // 0->1 (0->5 in parent); display: 6% (1+5)
not allowed (second segment active): aProgress.Progress(); not allowed (first segment not empty): aProgress.GetSegmentProgressBar( nSeg1 );
Definition at line 102 of file fprogressbar.hxx.
|
private |
Definition at line 166 of file fprogressbar.hxx.
|
private |
Definition at line 165 of file fprogressbar.hxx.
|
delete |
Referenced by GetSegmentProgressBar().
|
explicit |
Definition at line 40 of file fprogressbar.cxx.
References Init().
|
explicit |
Definition at line 46 of file fprogressbar.cxx.
ScfProgressBar::~ScfProgressBar | ( | ) |
Definition at line 59 of file fprogressbar.cxx.
|
explicitprivate |
Used to create sub progress bars.
Definition at line 52 of file fprogressbar.cxx.
References Init(), mpDocShell, mpParentProgress, and mpParentSegment.
|
inline |
Starts the progress bar (with first segment).
Definition at line 127 of file fprogressbar.hxx.
References ActivateSegment().
Referenced by XclExpProgressBar::ActivateFinalRowsSegment().
void ScfProgressBar::ActivateSegment | ( | sal_Int32 | nSegment | ) |
Starts the progress bar or activates another segment.
Definition at line 171 of file fprogressbar.cxx.
References GetSegment(), mnTotalSize, and SetCurrSegment().
Referenced by Activate(), XclExpProgressBar::ActivateCreateRowsSegment(), and ScfSimpleProgressBar::Init().
sal_Int32 ScfProgressBar::AddSegment | ( | std::size_t | nSize | ) |
Adds a new segment to the progress bar.
Definition at line 141 of file fprogressbar.cxx.
References maSegments, mbInProgress, mnTotalSize, and SCF_INV_SEGMENT.
Referenced by XclExpProgressBar::ActivateFinalRowsSegment(), ScfSimpleProgressBar::Init(), and XclExpProgressBar::Initialize().
|
private |
Returns the segment specified by list index.
Definition at line 73 of file fprogressbar.cxx.
References maSegments.
Referenced by ActivateSegment(), and GetSegmentProgressBar().
ScfProgressBar & ScfProgressBar::GetSegmentProgressBar | ( | sal_Int32 | nSegment | ) |
Returns a complete progress bar for the specified segment.
@descr The progress bar can be used to create sub segments inside of the segment. Do not delete it (done by root progress bar)!
Definition at line 152 of file fprogressbar.cxx.
References GetSegment(), ScfProgressBar::ScfProgressSegment::mnPos, ScfProgressBar::ScfProgressSegment::mxProgress, and ScfProgressBar().
|
private |
Increases mnTotalPos and calls the system progress bar.
Definition at line 112 of file fprogressbar.cxx.
References mnNextUnitPos, ScfProgressBar::ScfProgressSegment::mnSize, mnSysProgressScale, mnTotalPos, mnTotalSize, mnUnitSize, mpParentProgress, mpParentSegment, mxSysProgress, and ProgressAbs().
Referenced by ProgressAbs().
|
private |
Initializes all members on construction.
Definition at line 63 of file fprogressbar.cxx.
References mbInProgress, mnNextUnitPos, mnSysProgressScale, mnTotalPos, mnTotalSize, mnUnitSize, mpCurrSegment, mpDocShell, mpParentProgress, and mpParentSegment.
Referenced by ScfProgressBar().
bool ScfProgressBar::IsFull | ( | ) | const |
Returns true, if the current progress segment is already full.
Definition at line 165 of file fprogressbar.cxx.
References mbInProgress, ScfProgressBar::ScfProgressSegment::mnPos, ScfProgressBar::ScfProgressSegment::mnSize, and mpCurrSegment.
Referenced by XclExpProgressBar::Progress().
|
delete |
void ScfProgressBar::Progress | ( | std::size_t | nDelta = 1 | ) |
Increase current segment by the passed value.
Definition at line 193 of file fprogressbar.cxx.
References ScfProgressBar::ScfProgressSegment::mnPos, mpCurrSegment, and ProgressAbs().
Referenced by XclExpProgressBar::Progress().
void ScfProgressBar::ProgressAbs | ( | std::size_t | nPos | ) |
Set current segment to the specified absolute position.
Definition at line 178 of file fprogressbar.cxx.
References IncreaseProgressBar(), mbInProgress, ScfProgressBar::ScfProgressSegment::mnPos, mnSize, mpCurrSegment, and nPos.
Referenced by IncreaseProgressBar(), Progress(), and ScfSimpleProgressBar::ProgressAbs().
|
private |
Activates progress bar and sets current segment.
Definition at line 80 of file fprogressbar.cxx.
References maText, mbInProgress, mnNextUnitPos, mnSysProgressScale, mnTotalSize, mnUnitSize, mpCurrSegment, mpDocShell, mpParentProgress, mpParentSegment, mxSysProgress, and SetCurrSegment().
Referenced by ActivateSegment(), and SetCurrSegment().
|
private |
Definition at line 168 of file fprogressbar.hxx.
Referenced by AddSegment(), and GetSegment().
|
private |
List of progress segments.
Definition at line 169 of file fprogressbar.hxx.
Referenced by SetCurrSegment().
|
private |
Additionally scaling factor for system progress.
Definition at line 182 of file fprogressbar.hxx.
Referenced by AddSegment(), Init(), IsFull(), ProgressAbs(), and SetCurrSegment().
|
private |
Size between two calls of system progress.
Definition at line 180 of file fprogressbar.hxx.
Referenced by IncreaseProgressBar(), Init(), and SetCurrSegment().
|
private |
Limit for next system progress call.
Definition at line 181 of file fprogressbar.hxx.
Referenced by IncreaseProgressBar(), Init(), and SetCurrSegment().
|
private |
Total size of all segments.
Definition at line 178 of file fprogressbar.hxx.
Referenced by IncreaseProgressBar(), and Init().
|
private |
Current segment for progress.
Definition at line 177 of file fprogressbar.hxx.
Referenced by ActivateSegment(), AddSegment(), IncreaseProgressBar(), Init(), and SetCurrSegment().
|
private |
Sum of positions of all segments.
Definition at line 179 of file fprogressbar.hxx.
Referenced by IncreaseProgressBar(), Init(), and SetCurrSegment().
|
private |
Parent segment, if this is a segment progress bar.
Definition at line 175 of file fprogressbar.hxx.
Referenced by Init(), IsFull(), Progress(), ProgressAbs(), and SetCurrSegment().
|
private |
System progress bar.
Definition at line 172 of file fprogressbar.hxx.
Referenced by Init(), ScfProgressBar(), and SetCurrSegment().
|
private |
The document shell for the progress bar.
Definition at line 173 of file fprogressbar.hxx.
Referenced by IncreaseProgressBar(), Init(), ScfProgressBar(), and SetCurrSegment().
|
private |
Parent progress bar, if this is a segment progress bar.
Definition at line 174 of file fprogressbar.hxx.
Referenced by IncreaseProgressBar(), Init(), ScfProgressBar(), and SetCurrSegment().
|
private |
UI string for system progress.
Definition at line 171 of file fprogressbar.hxx.
Referenced by IncreaseProgressBar(), and SetCurrSegment().