LibreOffice Module toolkit (master) 1
tablegeometry.hxx
Go to the documentation of this file.
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
23#include <tools/gen.hxx>
24
25namespace svt::table
26{
27
28
29 class TableControl_Impl;
30
31
32 //= TableGeometry
33
35 {
36 protected:
40
41 protected:
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:
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
86 };
87
88
89 //= TableColumnGeometry
90
92 {
93 public:
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
110 };
111
112
113 //= TableCellGeometry
114
118 {
119 private:
122
123 public:
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
136 const TableRowGeometry& _rRow,
137 ColPos _nCol
138 )
139 :m_aRow( _rRow )
140 ,m_aCol( _rRow.getControl(), _rRow.getRect(), _nCol )
141 {
142 }
143
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: */
a helper representing geometry information of a cell
TableCellGeometry(TableControl_Impl const &_rControl, tools::Rectangle const &_rBoundaries, ColPos const _nCol, RowPos const _nRow)
tools::Rectangle getRect() const
TableCellGeometry(const TableRowGeometry &_rRow, ColPos _nCol)
bool impl_isValidColumn(ColPos const i_column) const
TableColumnGeometry(TableControl_Impl const &_rControl, tools::Rectangle const &_rBoundaries, ColPos const _nCol)
TableGeometry(const TableControl_Impl &_rControl, const tools::Rectangle &_rBoundaries)
const tools::Rectangle & m_rBoundaries
const TableControl_Impl & m_rControl
const tools::Rectangle & getRect() const
tools::Rectangle m_aRect
const TableControl_Impl & getControl() const
bool impl_isValidRow(RowPos const i_row) const
TableRowGeometry(TableControl_Impl const &_rControl, tools::Rectangle const &_rBoundaries, RowPos const _nRow, bool const i_allowVirtualRows=false)
tools::Rectangle GetIntersection(const tools::Rectangle &rRect) const
constexpr bool IsEmpty() const
sal_Int32 RowPos
a value denoting a row position within a table
Definition: tabletypes.hxx:34
sal_Int32 ColPos
a value denoting a column position within a table
Definition: tabletypes.hxx:32