Debian Codegraph @

toolkit/source/controls/table/tablegeometry.hxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #pragma once
21
22 #include <controls/table/tabletypes.hxx>
23 #include <tools/gen.hxx>
24
25 namespace svt::table
26 {
27
28
29 class TableControl_Impl;
30
31
32 //= TableGeometry
33
34 class TableGeometry
35 {
36 protected:
37 const TableControl_Impl& m_rControl;
38 const tools::Rectangle& m_rBoundaries;
39 tools::Rectangle m_aRect;
40
41 protected:
42 TableGeometry(
43 const TableControl_Impl& _rControl,
44 const tools::Rectangle& _rBoundaries
45 )
46 :m_rControl( _rControl )
47 ,m_rBoundaries( _rBoundaries )
48 ,m_aRect( _rBoundaries )
49 {
50 }
51
52 public:
53 // attribute access
54 const TableControl_Impl& getControl() const { return m_rControl; }
55
56 // status
57 const tools::Rectangle& getRect() const { return m_aRect; }
58 bool isValid() const { return !m_aRect.GetIntersection( m_rBoundaries ).IsEmpty(); }
59 };
60
61
62 //= TableRowGeometry
63
64 class TableRowGeometry final : public TableGeometry
65 {
66 public:
67 TableRowGeometry(
68 TableControl_Impl const & _rControl,
69 tools::Rectangle const & _rBoundaries,
70 RowPos const _nRow,
71 bool const i_allowVirtualRows = false
72 // allow rows >= getRowCount()?
73 );
74
75 // status
76 RowPos getRow() const { return m_nRowPos; }
77 // operations
78 bool moveDown();
79
80 private:
81 void impl_initRect();
82 bool impl_isValidRow( RowPos const i_row ) const;
83
84 RowPos m_nRowPos;
85 bool m_bAllowVirtualRows;
86 };
87
88
89 //= TableColumnGeometry
90
91 class TableColumnGeometry final : public TableGeometry
92 {
93 public:
94 TableColumnGeometry(
95 TableControl_Impl const & _rControl,
96 tools::Rectangle const & _rBoundaries,
97 ColPos const _nCol
98 );
99
100 // status
101 ColPos getCol() const { return m_nColPos; }
102 // operations
103 bool moveRight();
104
105 private:
106 void impl_initRect();
107 bool impl_isValidColumn( ColPos const i_column ) const;
108
109 ColPos m_nColPos;
110 };
111
112
113 //= TableCellGeometry
114
115 /** a helper representing geometry information of a cell
116 */
117 class TableCellGeometry
118 {
119 private:
120 TableRowGeometry m_aRow;
121 TableColumnGeometry m_aCol;
122
123 public:
124 TableCellGeometry(
125 TableControl_Impl const & _rControl,
126 tools::Rectangle const & _rBoundaries,
127 ColPos const _nCol,
128 RowPos const _nRow
129 )
130 :m_aRow( _rControl, _rBoundaries, _nRow, false/*allowVirtualCells*/ )
131 ,m_aCol( _rControl, _rBoundaries, _nCol )
132 {
133 }
134
135 TableCellGeometry(
136 const TableRowGeometry& _rRow,
137 ColPos _nCol
138 )
139 :m_aRow( _rRow )
140 ,m_aCol( _rRow.getControl(), _rRow.getRect(), _nCol )
141 {
142 }
143
144 tools::Rectangle getRect() const { return m_aRow.getRect().GetIntersection( m_aCol.getRect() ); }
145 ColPos getColumn() const { return m_aCol.getCol(); }
146 bool isValid() const { return !getRect().IsEmpty(); }
147
148 bool moveRight() {return m_aCol.moveRight(); }
149 };
150
151
152 } // namespace svt::table
153
154
155
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */