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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_FPROGRESSBAR_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_FPROGRESSBAR_HXX
22 
23 #include <vector>
24 #include <memory>
25 #include <rtl/ustring.hxx>
26 #include <progress.hxx>
27 
28 class SfxObjectShell;
29 class SvStream;
30 
31 const sal_Int32 SCF_INV_SEGMENT = -1;
32 
102 class ScfProgressBar final
103 {
104 public:
105  ScfProgressBar(const ScfProgressBar&) = delete;
106  const ScfProgressBar operator=(const ScfProgressBar&) = delete;
107 
108  explicit ScfProgressBar(SfxObjectShell* pDocShell, const OUString& rText);
109  explicit ScfProgressBar(SfxObjectShell* pDocShell, const char* pResId);
110  ~ScfProgressBar();
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 
133 private:
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 
151 private:
154  {
155  typedef ::std::unique_ptr< ScfProgressBar > ScfProgressBarPtr;
156 
157  ScfProgressBarPtr mxProgress;
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 
168  ScfSegmentList maSegments;
169  OUString maText;
170 
171  ScProgressPtr mxSysProgress;
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 {
188 public:
189  explicit ScfSimpleProgressBar(std::size_t nSize, SfxObjectShell* pDocShell, const OUString& rText);
190  explicit ScfSimpleProgressBar(std::size_t nSize, SfxObjectShell* pDocShell, const char* pResId);
191 
193  void ProgressAbs( std::size_t nPos ) { maProgress.ProgressAbs( nPos ); }
194 
195 private:
197  void Init( std::size_t nSize );
198 
199 private:
201 };
202 
205 {
206 public:
207  explicit ScfStreamProgressBar( SvStream& rStrm, SfxObjectShell* pDocShell );
208 
210  void Progress();
211 
212 private:
214  void Init( SfxObjectShell* pDocShell, const OUString& rText );
215 
216 private:
217  typedef ::std::unique_ptr< ScfSimpleProgressBar > ScfSimpleProgressBarPtr;
218 
219  ScfSimpleProgressBarPtr mxProgress;
221 };
222 
223 #endif
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ActivateSegment(sal_Int32 nSegment)
Starts the progress bar or activates another segment.
ScfProgressSegment * mpCurrSegment
Parent segment, if this is a segment progress bar.
ScfSimpleProgressBarPtr mxProgress
ScProgressPtr mxSysProgress
UI string for system progress.
A simplified progress bar based on the stream position of an existing stream.
ScfProgressBar maProgress
std::size_t mnSysProgressScale
Limit for next system progress call.
std::size_t mnNextUnitPos
Size between two calls of system progress.
ScfStreamProgressBar(SvStream &rStrm, SfxObjectShell *pDocShell)
A simplified progress bar with only one segment.
SfxObjectShell * mpDocShell
System progress bar.
std::size_t mnTotalSize
Current segment for progress.
ScfProgressBar * mpParentProgress
The document shell for the progress bar.
void IncreaseProgressBar(std::size_t nDelta)
Increases mnTotalPos and calls the system progress bar.
ScfProgressSegment * mpParentSegment
Parent progress bar, if this is a segment progress bar.
ScfProgressBar(const ScfProgressBar &)=delete
const ScfProgressBar operator=(const ScfProgressBar &)=delete
std::size_t mnUnitSize
Sum of positions of all segments.
ScfProgressBar & GetSegmentProgressBar(sal_Int32 nSegment)
Returns a complete progress bar for the specified segment.
OUString maText
List of progress segments.
::std::unique_ptr< ScfSimpleProgressBar > ScfSimpleProgressBarPtr
bool IsFull() const
Returns true, if the current progress segment is already full.
ScfSegmentList maSegments
bool mbInProgress
Additionally scaling factor for system progress.
const sal_Int32 SCF_INV_SEGMENT
ScfProgressSegment * GetSegment(sal_Int32 nSegment)
Returns the segment specified by list index.
void Progress(std::size_t nDelta=1)
Increase current segment by the passed value.
void ProgressAbs(std::size_t nPos)
Set progress bar to the specified position.
void Activate()
Starts the progress bar (with first segment).
Contains all data of a segment of the progress bar.
::std::unique_ptr< ScfProgressBar > ScfProgressBarPtr
void Init(SfxObjectShell *pDocShell)
Initializes all members on construction.
std::size_t mnPos
Size of this segment.
void Init(SfxObjectShell *pDocShell, const OUString &rText)
Initializes and starts the progress bar.
std::size_t mnTotalPos
Total size of all segments.
std::size_t mnSize
Pointer to sub progress bar for this segment.
void Progress()
Sets the progress bar to the current stream position.
::std::unique_ptr< ScProgress > ScProgressPtr
Progress bar for complex progress representation.
void ProgressAbs(std::size_t nPos)
Set current segment to the specified absolute position.
ScfProgressSegment(std::size_t nSize)
Current position of this segment.
std::vector< std::unique_ptr< ScfProgressSegment > > ScfSegmentList
void SetCurrSegment(ScfProgressSegment *pSegment)
Activates progress bar and sets current segment.
ScfSimpleProgressBar(std::size_t nSize, SfxObjectShell *pDocShell, const OUString &rText)
void SvStream & rStrm
sal_Int32 AddSegment(std::size_t nSize)
Adds a new segment to the progress bar.
SvStream & mrStrm
The used progress bar.
void Init(std::size_t nSize)
Initializes and starts the progress bar.