xref: /AOO41X/main/svx/source/table/celltypes.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
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 _SVX_CELLTYPES_HXX_
25 #define _SVX_CELLTYPES_HXX_
26 
27 #include <rtl/ref.hxx>
28 #include <vector>
29 
30 namespace sdr { namespace table {
31 
32 class Cell;
33 class TableModel;
34 class TableRow;
35 class TableColumn;
36 class TableRows;
37 class TableColumns;
38 typedef rtl::Reference< Cell > CellRef;
39 typedef rtl::Reference< TableModel > TableModelRef;
40 typedef rtl::Reference< TableRow > TableRowRef;
41 typedef rtl::Reference< TableColumn > TableColumnRef;
42 typedef rtl::Reference< TableRows > TableRowsRef;
43 typedef rtl::Reference< TableColumns > TableColumnsRef;
44 typedef std::vector< CellRef > CellVector;
45 typedef std::vector< TableRowRef > RowVector;
46 typedef std::vector< TableColumnRef > ColumnVector;
47 
48 class TableDesignUser
49 {
50 public:
51     virtual bool isInUse() = 0;
52 };
53 
54 template< typename T >
55 class RangeIterator
56 {
57 public:
58     /** creates an iterator from rStart (including) to rEnd (excluding) if
59         bForeward is true or from nEnd (excluding to nStart (including).
60         rStart must be <= rEnd.
61     */
RangeIterator(const T & rStart,const T & rEnd,bool bForeward=true)62     RangeIterator( const T& rStart, const T& rEnd, bool bForeward = true )
63     {
64         if( bForeward )
65         {
66             maIter = rStart;
67             maEnd = rEnd;
68         }
69         else
70         {
71             maIter = rEnd-1;
72             maEnd = rStart-1;
73         }
74     }
75 
76     /* returns true if the next call to next() will return true also. */
hasNext() const77     bool hasNext() const
78     {
79         return maIter != maEnd;
80     }
81 
82     /* iterates in the configured direction and returns true if rValue
83        now contains a valid positon in the range of this iterator */
next(T & rValue)84     bool next( T& rValue )
85     {
86         if( maIter == maEnd )
87             return false;
88 
89         rValue = maIter;
90         if( maIter < maEnd )
91             maIter++;
92         else
93             maIter--;
94         return true;
95     }
96 
97 private:
98     T maEnd;
99     T maIter;
100 };
101 
102 } }
103 
104 #endif
105 
106