1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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 // MARKER(update_precomp.py): autogen include statement, do not remove
27 #include "precompiled_svtools.hxx"
30 #include "tablegeometry.hxx"
31 #include "tablecontrol_impl.hxx"
33 #include <tools/debug.hxx>
35 //........................................................................
36 namespace svt
{ namespace table
38 //........................................................................
40 //====================================================================
42 //====================================================================
43 //--------------------------------------------------------------------
44 TableRowGeometry::TableRowGeometry( const TableControl_Impl
& _rControl
, const Rectangle
& _rBoundaries
,
46 :TableGeometry( _rControl
, _rBoundaries
)
49 if ( m_nRowPos
== ROW_COL_HEADERS
)
51 DBG_ASSERT( m_rControl
.m_pModel
->hasColumnHeaders(),
52 "TableRowGeometry::TableRowGeometry: why asking for the geoemtry of the non-existent column header row?" );
54 m_aRect
.Bottom() = m_rControl
.m_nColHeaderHeightPixel
- 1;
58 if ( ( m_nRowPos
>= m_rControl
.m_nTopRow
) && ( m_nRowPos
< m_rControl
.m_pModel
->getRowCount() ) )
60 m_aRect
.Top() = m_rControl
.m_nColHeaderHeightPixel
+ ( m_nRowPos
- m_rControl
.m_nTopRow
) * m_rControl
.m_nRowHeightPixel
;
61 m_aRect
.Bottom() = m_aRect
.Top() + m_rControl
.m_nRowHeightPixel
- 1;
68 //--------------------------------------------------------------------
69 bool TableRowGeometry::moveDown()
71 if ( ++m_nRowPos
< m_rControl
.m_pModel
->getRowCount() )
72 m_aRect
.Move( 0, m_rControl
.m_nRowHeightPixel
);
78 //====================================================================
79 //= TableColumnGeometry
80 //====================================================================
81 //--------------------------------------------------------------------
82 TableColumnGeometry::TableColumnGeometry( const TableControl_Impl
& _rControl
, const Rectangle
& _rBoundaries
,
84 :TableGeometry( _rControl
, _rBoundaries
)
87 if ( m_nColPos
== COL_ROW_HEADERS
)
89 DBG_ASSERT( m_rControl
.m_pModel
->hasRowHeaders(),
90 "TableColumnGeometry::TableColumnGeometry: why asking for the geoemtry of the non-existent row header column?" );
92 m_aRect
.Right() = m_rControl
.m_nRowHeaderWidthPixel
- 1;
96 ColPos nLeftColumn
= m_rControl
.m_nLeftColumn
;
97 if ( ( m_nColPos
>= nLeftColumn
) && ( m_nColPos
< (ColPos
)m_rControl
.m_aColumnWidthsPixel
.size() ) )
99 m_aRect
.Left() = m_rControl
.m_nRowHeaderWidthPixel
;
100 // TODO: take into account any possibly frozen columns
102 for ( ColPos col
= nLeftColumn
; col
< m_nColPos
; ++col
)
103 m_aRect
.Left() += m_rControl
.m_aColumnWidthsPixel
[ col
];
104 m_aRect
.Right() = m_aRect
.Left() + m_rControl
.m_aColumnWidthsPixel
[ m_nColPos
] - 1;
111 //--------------------------------------------------------------------
112 bool TableColumnGeometry::moveRight()
114 DBG_ASSERT( m_nColPos
!= COL_ROW_HEADERS
, "TableColumnGeometry::moveRight: cannot move the row header column!" );
115 // what would be COL_ROW_HEADERS + 1?
117 if ( ++m_nColPos
< (ColPos
)m_rControl
.m_aColumnWidthsPixel
.size() )
119 m_aRect
.Left() = m_aRect
.Right() + 1;
120 m_aRect
.Right() += m_rControl
.m_aColumnWidthsPixel
[ m_nColPos
];
128 //........................................................................
129 } } // namespace svt::table
130 //........................................................................