merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / table / tablegeometry.hxx
blobf6014863baa770a368bcfed48bc50f04c210a4d9
1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * Copyright 2009 by Sun Microsystems, Inc.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * This file is part of OpenOffice.org.
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org. If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
26 #ifndef SVTOOLS_TABLEGEOMETRY_HXX
27 #define SVTOOLS_TABLEGEOMETRY_HXX
29 #ifndef SVTOOLS_INC_TABLE_TABLETYPES_HXX
30 #include <svtools/table/tabletypes.hxx>
31 #endif
33 #ifndef _SV_GEN_HXX
34 #include <tools/gen.hxx>
35 #endif
37 //........................................................................
38 namespace svt { namespace table
40 //........................................................................
42 class TableControl_Impl;
44 //====================================================================
45 //= TableGeometry
46 //====================================================================
47 class TableGeometry
49 protected:
50 const TableControl_Impl& m_rControl;
51 const Rectangle& m_rBoundaries;
52 Rectangle m_aRect;
54 protected:
55 TableGeometry(
56 const TableControl_Impl& _rControl,
57 const Rectangle& _rBoundaries
59 :m_rControl( _rControl )
60 ,m_rBoundaries( _rBoundaries )
61 ,m_aRect( _rBoundaries )
65 public:
66 // attribute access
67 const TableControl_Impl& getControl() const { return m_rControl; }
69 // status
70 const Rectangle& getRect() const { return m_aRect; }
71 bool isValid() const { return !m_aRect.GetIntersection( m_rBoundaries ).IsEmpty(); }
74 //====================================================================
75 //= TableRowGeometry
76 //====================================================================
77 class TableRowGeometry : public TableGeometry
79 protected:
80 RowPos m_nRowPos;
82 public:
83 TableRowGeometry(
84 const TableControl_Impl& _rControl,
85 const Rectangle& _rBoundaries,
86 RowPos _nRow
89 // status
90 RowPos getRow() const { return m_nRowPos; }
91 // operations
92 bool moveDown();
95 //====================================================================
96 //= TableColumnGeometry
97 //====================================================================
98 class TableColumnGeometry : public TableGeometry
100 protected:
101 ColPos m_nColPos;
103 public:
104 TableColumnGeometry(
105 const TableControl_Impl& _rControl,
106 const Rectangle& _rBoundaries,
107 ColPos _nCol
110 // status
111 ColPos getCol() const { return m_nColPos; }
112 // operations
113 bool moveRight();
116 //====================================================================
117 //= TableCellGeometry
118 //====================================================================
119 /** a helper representing geometry information of a cell
121 class TableCellGeometry
123 private:
124 TableRowGeometry m_aRow;
125 TableColumnGeometry m_aCol;
127 public:
128 TableCellGeometry(
129 const TableControl_Impl& _rControl,
130 const Rectangle& _rBoundaries,
131 ColPos _nCol,
132 RowPos _nRow
134 :m_aRow( _rControl, _rBoundaries, _nRow )
135 ,m_aCol( _rControl, _rBoundaries, _nCol )
139 TableCellGeometry(
140 const TableRowGeometry& _rRow,
141 ColPos _nCol
143 :m_aRow( _rRow )
144 ,m_aCol( _rRow.getControl(), _rRow.getRect(), _nCol )
148 inline Rectangle getRect() const { return m_aRow.getRect().GetIntersection( m_aCol.getRect() ); }
149 inline RowPos getRow() const { return m_aRow.getRow(); }
150 inline ColPos getColumn() const { return m_aCol.getCol(); }
151 inline bool isValid() const { return !getRect().IsEmpty(); }
153 inline bool moveDown() {return m_aRow.moveDown(); }
154 inline bool moveRight() {return m_aCol.moveRight(); }
157 //........................................................................
158 } } // namespace svt::table
159 //........................................................................
161 #endif // SVTOOLS_TABLEGEOMETRY_HXX