1*01aa44aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*01aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*01aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*01aa44aaSAndrew Rist * distributed with this work for additional information 6*01aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*01aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*01aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 9*01aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 10*01aa44aaSAndrew Rist * 11*01aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*01aa44aaSAndrew Rist * 13*01aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*01aa44aaSAndrew Rist * software distributed under the License is distributed on an 15*01aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*01aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 17*01aa44aaSAndrew Rist * specific language governing permissions and limitations 18*01aa44aaSAndrew Rist * under the License. 19*01aa44aaSAndrew Rist * 20*01aa44aaSAndrew Rist *************************************************************/ 21*01aa44aaSAndrew Rist 22*01aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SVTOOLS_TABLEGEOMETRY_HXX 25cdf0e10cSrcweir #define SVTOOLS_TABLEGEOMETRY_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svtools/table/tabletypes.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <tools/gen.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir //........................................................................ 32cdf0e10cSrcweir namespace svt { namespace table 33cdf0e10cSrcweir { 34cdf0e10cSrcweir //........................................................................ 35cdf0e10cSrcweir 36cdf0e10cSrcweir class TableControl_Impl; 37cdf0e10cSrcweir 38cdf0e10cSrcweir //==================================================================== 39cdf0e10cSrcweir //= TableGeometry 40cdf0e10cSrcweir //==================================================================== 41cdf0e10cSrcweir class TableGeometry 42cdf0e10cSrcweir { 43cdf0e10cSrcweir protected: 44cdf0e10cSrcweir const TableControl_Impl& m_rControl; 45cdf0e10cSrcweir const Rectangle& m_rBoundaries; 46cdf0e10cSrcweir Rectangle m_aRect; 47cdf0e10cSrcweir 48cdf0e10cSrcweir protected: TableGeometry(const TableControl_Impl & _rControl,const Rectangle & _rBoundaries)49cdf0e10cSrcweir TableGeometry( 50cdf0e10cSrcweir const TableControl_Impl& _rControl, 51cdf0e10cSrcweir const Rectangle& _rBoundaries 52cdf0e10cSrcweir ) 53cdf0e10cSrcweir :m_rControl( _rControl ) 54cdf0e10cSrcweir ,m_rBoundaries( _rBoundaries ) 55cdf0e10cSrcweir ,m_aRect( _rBoundaries ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir public: 60cdf0e10cSrcweir // attribute access getControl() const61cdf0e10cSrcweir const TableControl_Impl& getControl() const { return m_rControl; } 62cdf0e10cSrcweir 63cdf0e10cSrcweir // status getRect() const64cdf0e10cSrcweir const Rectangle& getRect() const { return m_aRect; } isValid() const65cdf0e10cSrcweir bool isValid() const { return !m_aRect.GetIntersection( m_rBoundaries ).IsEmpty(); } 66cdf0e10cSrcweir }; 67cdf0e10cSrcweir 68cdf0e10cSrcweir //==================================================================== 69cdf0e10cSrcweir //= TableRowGeometry 70cdf0e10cSrcweir //==================================================================== 71cdf0e10cSrcweir class TableRowGeometry : public TableGeometry 72cdf0e10cSrcweir { 73cdf0e10cSrcweir protected: 74cdf0e10cSrcweir RowPos m_nRowPos; 75cdf0e10cSrcweir bool m_bAllowVirtualRows; 76cdf0e10cSrcweir 77cdf0e10cSrcweir public: 78cdf0e10cSrcweir TableRowGeometry( 79cdf0e10cSrcweir TableControl_Impl const & _rControl, 80cdf0e10cSrcweir Rectangle const & _rBoundaries, 81cdf0e10cSrcweir RowPos const _nRow, 82cdf0e10cSrcweir bool const i_allowVirtualRows = false 83cdf0e10cSrcweir // allow rows >= getRowCount()? 84cdf0e10cSrcweir ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir // status getRow() const87cdf0e10cSrcweir RowPos getRow() const { return m_nRowPos; } 88cdf0e10cSrcweir // operations 89cdf0e10cSrcweir bool moveDown(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir private: 92cdf0e10cSrcweir void impl_initRect(); 93cdf0e10cSrcweir bool impl_isValidRow( RowPos const i_row ) const; 94cdf0e10cSrcweir }; 95cdf0e10cSrcweir 96cdf0e10cSrcweir //==================================================================== 97cdf0e10cSrcweir //= TableColumnGeometry 98cdf0e10cSrcweir //==================================================================== 99cdf0e10cSrcweir class TableColumnGeometry : public TableGeometry 100cdf0e10cSrcweir { 101cdf0e10cSrcweir protected: 102cdf0e10cSrcweir ColPos m_nColPos; 103cdf0e10cSrcweir bool m_bAllowVirtualColumns; 104cdf0e10cSrcweir 105cdf0e10cSrcweir public: 106cdf0e10cSrcweir TableColumnGeometry( 107cdf0e10cSrcweir TableControl_Impl const & _rControl, 108cdf0e10cSrcweir Rectangle const & _rBoundaries, 109cdf0e10cSrcweir ColPos const _nCol, 110cdf0e10cSrcweir bool const i_allowVirtualColumns = false 111cdf0e10cSrcweir ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir // status getCol() const114cdf0e10cSrcweir ColPos getCol() const { return m_nColPos; } 115cdf0e10cSrcweir // operations 116cdf0e10cSrcweir bool moveRight(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir private: 119cdf0e10cSrcweir void impl_initRect(); 120cdf0e10cSrcweir bool impl_isValidColumn( ColPos const i_column ) const; 121cdf0e10cSrcweir }; 122cdf0e10cSrcweir 123cdf0e10cSrcweir //==================================================================== 124cdf0e10cSrcweir //= TableCellGeometry 125cdf0e10cSrcweir //==================================================================== 126cdf0e10cSrcweir /** a helper representing geometry information of a cell 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir class TableCellGeometry 129cdf0e10cSrcweir { 130cdf0e10cSrcweir private: 131cdf0e10cSrcweir TableRowGeometry m_aRow; 132cdf0e10cSrcweir TableColumnGeometry m_aCol; 133cdf0e10cSrcweir 134cdf0e10cSrcweir public: TableCellGeometry(TableControl_Impl const & _rControl,Rectangle const & _rBoundaries,ColPos const _nCol,RowPos const _nRow,bool const i_alllowVirtualCells=false)135cdf0e10cSrcweir TableCellGeometry( 136cdf0e10cSrcweir TableControl_Impl const & _rControl, 137cdf0e10cSrcweir Rectangle const & _rBoundaries, 138cdf0e10cSrcweir ColPos const _nCol, 139cdf0e10cSrcweir RowPos const _nRow, 140cdf0e10cSrcweir bool const i_alllowVirtualCells = false 141cdf0e10cSrcweir ) 142cdf0e10cSrcweir :m_aRow( _rControl, _rBoundaries, _nRow, i_alllowVirtualCells ) 143cdf0e10cSrcweir ,m_aCol( _rControl, _rBoundaries, _nCol, i_alllowVirtualCells ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir } 146cdf0e10cSrcweir TableCellGeometry(const TableRowGeometry & _rRow,ColPos _nCol)147cdf0e10cSrcweir TableCellGeometry( 148cdf0e10cSrcweir const TableRowGeometry& _rRow, 149cdf0e10cSrcweir ColPos _nCol 150cdf0e10cSrcweir ) 151cdf0e10cSrcweir :m_aRow( _rRow ) 152cdf0e10cSrcweir ,m_aCol( _rRow.getControl(), _rRow.getRect(), _nCol ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir } 155cdf0e10cSrcweir getRect() const156cdf0e10cSrcweir inline Rectangle getRect() const { return m_aRow.getRect().GetIntersection( m_aCol.getRect() ); } getRow() const157cdf0e10cSrcweir inline RowPos getRow() const { return m_aRow.getRow(); } getColumn() const158cdf0e10cSrcweir inline ColPos getColumn() const { return m_aCol.getCol(); } isValid() const159cdf0e10cSrcweir inline bool isValid() const { return !getRect().IsEmpty(); } 160cdf0e10cSrcweir moveDown()161cdf0e10cSrcweir inline bool moveDown() {return m_aRow.moveDown(); } moveRight()162cdf0e10cSrcweir inline bool moveRight() {return m_aCol.moveRight(); } 163cdf0e10cSrcweir }; 164cdf0e10cSrcweir 165cdf0e10cSrcweir //........................................................................ 166cdf0e10cSrcweir } } // namespace svt::table 167cdf0e10cSrcweir //........................................................................ 168cdf0e10cSrcweir 169cdf0e10cSrcweir #endif // SVTOOLS_TABLEGEOMETRY_HXX 170