Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVX_CELLTYPES_HXX_
30 : : #define _SVX_CELLTYPES_HXX_
31 : :
32 : : #include <rtl/ref.hxx>
33 : : #include <vector>
34 : :
35 : : namespace sdr { namespace table {
36 : :
37 : : class Cell;
38 : : class TableModel;
39 : : class TableRow;
40 : : class TableColumn;
41 : : class TableRows;
42 : : class TableColumns;
43 : : typedef rtl::Reference< Cell > CellRef;
44 : : typedef rtl::Reference< TableModel > TableModelRef;
45 : : typedef rtl::Reference< TableRow > TableRowRef;
46 : : typedef rtl::Reference< TableColumn > TableColumnRef;
47 : : typedef rtl::Reference< TableRows > TableRowsRef;
48 : : typedef rtl::Reference< TableColumns > TableColumnsRef;
49 : : typedef std::vector< CellRef > CellVector;
50 : : typedef std::vector< TableRowRef > RowVector;
51 : : typedef std::vector< TableColumnRef > ColumnVector;
52 : :
53 : 6 : class TableDesignUser
54 : : {
55 : : public:
56 : : virtual bool isInUse() = 0;
57 : :
58 : : protected:
59 : 6 : ~TableDesignUser() {}
60 : : };
61 : :
62 : : template< typename T >
63 : : class RangeIterator
64 : : {
65 : : public:
66 : : /** creates an iterator from rStart (including) to rEnd (excluding) if
67 : : bForeward is true or from nEnd (excluding to nStart (including).
68 : : rStart must be <= rEnd.
69 : : */
70 : 90 : RangeIterator( const T& rStart, const T& rEnd, bool bForeward = true )
71 : : {
72 [ + - ]: 90 : if( bForeward )
73 : : {
74 : 90 : maIter = rStart;
75 : 90 : maEnd = rEnd;
76 : : }
77 : : else
78 : : {
79 : 0 : maIter = rEnd-1;
80 : 0 : maEnd = rStart-1;
81 : : }
82 : 90 : }
83 : :
84 : : /* returns true if the next call to next() will return true also. */
85 : : bool hasNext() const
86 : : {
87 : : return maIter != maEnd;
88 : : }
89 : :
90 : : /* iterates in the configured direction and returns true if rValue
91 : : now contains a valid positon in the range of this iterator */
92 : 234 : bool next( T& rValue )
93 : : {
94 [ + + ]: 234 : if( maIter == maEnd )
95 : 90 : return false;
96 : :
97 : 144 : rValue = maIter;
98 [ + - ]: 144 : if( maIter < maEnd )
99 : 144 : maIter++;
100 : : else
101 : 0 : maIter--;
102 : 234 : return true;
103 : : }
104 : :
105 : : private:
106 : : T maEnd;
107 : : T maIter;
108 : : };
109 : :
110 : : } }
111 : :
112 : : #endif
113 : :
114 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|