LibreOffice Module sc (master) 1
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ScfProgressBar Class Referencefinal

Progress bar for complex progress representation. More...

#include <fprogressbar.hxx>

Collaboration diagram for ScfProgressBar:
[legend]

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...
 
ScfProgressBarGetSegmentProgressBar (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< ScProgressScProgressPtr
 
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...
 
ScfProgressSegmentGetSegment (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...
 
SfxObjectShellmpDocShell
 System progress bar. More...
 
ScfProgressBarmpParentProgress
 The document shell for the progress bar. More...
 
ScfProgressSegmentmpParentSegment
 Parent progress bar, if this is a segment progress bar. More...
 
ScfProgressSegmentmpCurrSegment
 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...
 

Detailed Description

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.

Member Typedef Documentation

◆ ScfSegmentList

typedef std::vector< std::unique_ptr<ScfProgressSegment> > ScfProgressBar::ScfSegmentList
private

Definition at line 166 of file fprogressbar.hxx.

◆ ScProgressPtr

typedef ::std::unique_ptr< ScProgress > ScfProgressBar::ScProgressPtr
private

Definition at line 165 of file fprogressbar.hxx.

Constructor & Destructor Documentation

◆ ScfProgressBar() [1/4]

ScfProgressBar::ScfProgressBar ( const ScfProgressBar )
delete

Referenced by GetSegmentProgressBar().

◆ ScfProgressBar() [2/4]

ScfProgressBar::ScfProgressBar ( SfxObjectShell pDocShell,
OUString  aText 
)
explicit

Definition at line 40 of file fprogressbar.cxx.

References Init().

◆ ScfProgressBar() [3/4]

ScfProgressBar::ScfProgressBar ( SfxObjectShell pDocShell,
TranslateId  pResId 
)
explicit

Definition at line 46 of file fprogressbar.cxx.

References Init(), and maText.

◆ ~ScfProgressBar()

ScfProgressBar::~ScfProgressBar ( )

Definition at line 59 of file fprogressbar.cxx.

◆ ScfProgressBar() [4/4]

ScfProgressBar::ScfProgressBar ( ScfProgressBar rParProgress,
ScfProgressSegment pParSegment 
)
explicitprivate

Used to create sub progress bars.

Definition at line 52 of file fprogressbar.cxx.

References Init(), mpDocShell, mpParentProgress, and mpParentSegment.

Member Function Documentation

◆ Activate()

void ScfProgressBar::Activate ( )
inline

Starts the progress bar (with first segment).

Definition at line 127 of file fprogressbar.hxx.

References ActivateSegment().

Referenced by XclExpProgressBar::ActivateFinalRowsSegment().

◆ ActivateSegment()

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().

◆ AddSegment()

sal_Int32 ScfProgressBar::AddSegment ( std::size_t  nSize)

Adds a new segment to the progress bar.

Returns
the identifier of the segment.

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().

◆ GetSegment()

ScfProgressBar::ScfProgressSegment * ScfProgressBar::GetSegment ( sal_Int32  nSegment)
private

Returns the segment specified by list index.

Definition at line 73 of file fprogressbar.cxx.

References maSegments.

Referenced by ActivateSegment(), and GetSegmentProgressBar().

◆ 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)!

Returns
A reference to an ScfProgressBar connected to the segment.

Definition at line 152 of file fprogressbar.cxx.

References GetSegment(), ScfProgressBar::ScfProgressSegment::mnPos, ScfProgressBar::ScfProgressSegment::mxProgress, and ScfProgressBar().

◆ IncreaseProgressBar()

void ScfProgressBar::IncreaseProgressBar ( std::size_t  nDelta)
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().

◆ Init()

void ScfProgressBar::Init ( SfxObjectShell pDocShell)
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().

◆ IsFull()

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().

◆ operator=()

const ScfProgressBar ScfProgressBar::operator= ( const ScfProgressBar )
delete

◆ Progress()

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().

◆ ProgressAbs()

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().

◆ SetCurrSegment()

void ScfProgressBar::SetCurrSegment ( ScfProgressSegment pSegment)
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().

Member Data Documentation

◆ maSegments

ScfSegmentList ScfProgressBar::maSegments
private

Definition at line 168 of file fprogressbar.hxx.

Referenced by AddSegment(), and GetSegment().

◆ maText

OUString ScfProgressBar::maText
private

List of progress segments.

Definition at line 169 of file fprogressbar.hxx.

Referenced by SetCurrSegment().

◆ mbInProgress

bool ScfProgressBar::mbInProgress
private

Additionally scaling factor for system progress.

Definition at line 182 of file fprogressbar.hxx.

Referenced by AddSegment(), Init(), IsFull(), ProgressAbs(), and SetCurrSegment().

◆ mnNextUnitPos

std::size_t ScfProgressBar::mnNextUnitPos
private

Size between two calls of system progress.

Definition at line 180 of file fprogressbar.hxx.

Referenced by IncreaseProgressBar(), Init(), and SetCurrSegment().

◆ mnSysProgressScale

std::size_t ScfProgressBar::mnSysProgressScale
private

Limit for next system progress call.

Definition at line 181 of file fprogressbar.hxx.

Referenced by IncreaseProgressBar(), Init(), and SetCurrSegment().

◆ mnTotalPos

std::size_t ScfProgressBar::mnTotalPos
private

Total size of all segments.

Definition at line 178 of file fprogressbar.hxx.

Referenced by IncreaseProgressBar(), and Init().

◆ mnTotalSize

std::size_t ScfProgressBar::mnTotalSize
private

Current segment for progress.

Definition at line 177 of file fprogressbar.hxx.

Referenced by ActivateSegment(), AddSegment(), IncreaseProgressBar(), Init(), and SetCurrSegment().

◆ mnUnitSize

std::size_t ScfProgressBar::mnUnitSize
private

Sum of positions of all segments.

Definition at line 179 of file fprogressbar.hxx.

Referenced by IncreaseProgressBar(), Init(), and SetCurrSegment().

◆ mpCurrSegment

ScfProgressSegment* ScfProgressBar::mpCurrSegment
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().

◆ mpDocShell

SfxObjectShell* ScfProgressBar::mpDocShell
private

System progress bar.

Definition at line 172 of file fprogressbar.hxx.

Referenced by Init(), ScfProgressBar(), and SetCurrSegment().

◆ mpParentProgress

ScfProgressBar* ScfProgressBar::mpParentProgress
private

The document shell for the progress bar.

Definition at line 173 of file fprogressbar.hxx.

Referenced by IncreaseProgressBar(), Init(), ScfProgressBar(), and SetCurrSegment().

◆ mpParentSegment

ScfProgressSegment* ScfProgressBar::mpParentSegment
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().

◆ mxSysProgress

ScProgressPtr ScfProgressBar::mxSysProgress
private

UI string for system progress.

Definition at line 171 of file fprogressbar.hxx.

Referenced by IncreaseProgressBar(), and SetCurrSegment().


The documentation for this class was generated from the following files: