xref: /aoo4110/main/oox/inc/oox/helper/progressbar.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef OOX_HELPER_PROGRESSBAR_HXX
25 #define OOX_HELPER_PROGRESSBAR_HXX
26 
27 #include <boost/shared_ptr.hpp>
28 #include <com/sun/star/uno/Reference.hxx>
29 
30 namespace rtl { class OUString; }
31 
32 namespace com { namespace sun { namespace star {
33     namespace task { class XStatusIndicator; }
34 } } }
35 
36 namespace oox {
37 
38 // Interfaces =================================================================
39 
40 /** Interface for progress bar classes.
41  */
42 class IProgressBar
43 {
44 public:
45     virtual             ~IProgressBar();
46 
47     /** Returns the current position of the progress bar.
48 
49         @return  Position of the progress bar, in the range from 0.0 (beginning
50         of the progress bar) to 1.0 (end of the progress bar) inclusive.
51      */
52     virtual double      getPosition() const = 0;
53 
54     /** Sets the current position of the progress bar.
55 
56         @param fPosition  New position of the progress bar, in the range from
57         0.0 (beginning of the progress bar) to 1.0 (end of the progress bar)
58         inclusive.
59      */
60     virtual void        setPosition( double fPosition ) = 0;
61 };
62 
63 typedef ::boost::shared_ptr< IProgressBar > IProgressBarRef;
64 
65 // ----------------------------------------------------------------------------
66 
67 class ISegmentProgressBar;
68 typedef ::boost::shared_ptr< ISegmentProgressBar > ISegmentProgressBarRef;
69 
70 /** Interface for a segment in a progress bar, that is able to create sub
71     segments from itself.
72  */
73 class ISegmentProgressBar : public IProgressBar
74 {
75 public:
76     virtual             ~ISegmentProgressBar();
77 
78     /** Returns the length that is still free for creating sub segments. */
79     virtual double      getFreeLength() const = 0;
80 
81     /** Adds a new segment with the specified length. */
82     virtual ISegmentProgressBarRef createSegment( double fLength ) = 0;
83 };
84 
85 // ============================================================================
86 // ============================================================================
87 
88 /** A simple progress bar.
89  */
90 class ProgressBar : public IProgressBar
91 {
92 public:
93     explicit            ProgressBar(
94                             const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& rxIndicator,
95                             const ::rtl::OUString& rText );
96 
97     virtual             ~ProgressBar();
98 
99     /** Returns the current position of the progress bar. */
100     virtual double      getPosition() const;
101     /** Sets the current position of the progress bar. */
102     virtual void        setPosition( double fPosition );
103 
104 private:
105     ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >
106                         mxIndicator;
107     double              mfPosition;
108 };
109 
110 // ============================================================================
111 
112 /** A progress bar containing several independent segments.
113  */
114 class SegmentProgressBar : public ISegmentProgressBar
115 {
116 public:
117     explicit            SegmentProgressBar(
118                             const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& rxIndicator,
119                             const ::rtl::OUString& rText );
120 
121     /** Returns the current position of the progress bar segment. */
122     virtual double      getPosition() const;
123     /** Sets the current position of the progress bar segment. */
124     virtual void        setPosition( double fPosition );
125 
126     /** Returns the length that is still free for creating sub segments. */
127     virtual double      getFreeLength() const;
128     /** Adds a new segment with the specified length. */
129     virtual ISegmentProgressBarRef createSegment( double fLength );
130 
131 private:
132     ProgressBar         maProgress;
133     double              mfFreeStart;
134 };
135 
136 // ============================================================================
137 
138 } // namespace oox
139 
140 #endif
141