Bump version to 5.0-14
[LibreOffice.git] / svtools / source / table / tablegeometry.hxx
blob78d1079beb979fb31e620b49cfb0f3954bbbb809
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_SOURCE_TABLE_TABLEGEOMETRY_HXX
21 #define INCLUDED_SVTOOLS_SOURCE_TABLE_TABLEGEOMETRY_HXX
23 #include <svtools/table/tabletypes.hxx>
25 #include <tools/gen.hxx>
28 namespace svt { namespace table
32 class TableControl_Impl;
35 //= TableGeometry
37 class TableGeometry
39 protected:
40 const TableControl_Impl& m_rControl;
41 const Rectangle& m_rBoundaries;
42 Rectangle m_aRect;
44 protected:
45 TableGeometry(
46 const TableControl_Impl& _rControl,
47 const Rectangle& _rBoundaries
49 :m_rControl( _rControl )
50 ,m_rBoundaries( _rBoundaries )
51 ,m_aRect( _rBoundaries )
55 public:
56 // attribute access
57 const TableControl_Impl& getControl() const { return m_rControl; }
59 // status
60 const Rectangle& getRect() const { return m_aRect; }
61 bool isValid() const { return !m_aRect.GetIntersection( m_rBoundaries ).IsEmpty(); }
65 //= TableRowGeometry
67 class TableRowGeometry : public TableGeometry
69 protected:
70 RowPos m_nRowPos;
71 bool m_bAllowVirtualRows;
73 public:
74 TableRowGeometry(
75 TableControl_Impl const & _rControl,
76 Rectangle const & _rBoundaries,
77 RowPos const _nRow,
78 bool const i_allowVirtualRows = false
79 // allow rows >= getRowCount()?
82 // status
83 RowPos getRow() const { return m_nRowPos; }
84 // operations
85 bool moveDown();
87 private:
88 void impl_initRect();
89 bool impl_isValidRow( RowPos const i_row ) const;
93 //= TableColumnGeometry
95 class TableColumnGeometry : public TableGeometry
97 protected:
98 ColPos m_nColPos;
99 bool m_bAllowVirtualColumns;
101 public:
102 TableColumnGeometry(
103 TableControl_Impl const & _rControl,
104 Rectangle const & _rBoundaries,
105 ColPos const _nCol,
106 bool const i_allowVirtualColumns = false
109 // status
110 ColPos getCol() const { return m_nColPos; }
111 // operations
112 bool moveRight();
114 private:
115 void impl_initRect();
116 bool impl_isValidColumn( ColPos const i_column ) const;
120 //= TableCellGeometry
122 /** a helper representing geometry information of a cell
124 class TableCellGeometry
126 private:
127 TableRowGeometry m_aRow;
128 TableColumnGeometry m_aCol;
130 public:
131 TableCellGeometry(
132 TableControl_Impl const & _rControl,
133 Rectangle const & _rBoundaries,
134 ColPos const _nCol,
135 RowPos const _nRow,
136 bool const i_alllowVirtualCells = false
138 :m_aRow( _rControl, _rBoundaries, _nRow, i_alllowVirtualCells )
139 ,m_aCol( _rControl, _rBoundaries, _nCol, i_alllowVirtualCells )
143 TableCellGeometry(
144 const TableRowGeometry& _rRow,
145 ColPos _nCol
147 :m_aRow( _rRow )
148 ,m_aCol( _rRow.getControl(), _rRow.getRect(), _nCol )
152 inline Rectangle getRect() const { return m_aRow.getRect().GetIntersection( m_aCol.getRect() ); }
153 inline RowPos getRow() const { return m_aRow.getRow(); }
154 inline ColPos getColumn() const { return m_aCol.getCol(); }
155 inline bool isValid() const { return !getRect().IsEmpty(); }
157 inline bool moveDown() {return m_aRow.moveDown(); }
158 inline bool moveRight() {return m_aCol.moveRight(); }
162 } } // namespace svt::table
165 #endif // INCLUDED_SVTOOLS_SOURCE_TABLE_TABLEGEOMETRY_HXX
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */