merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / table / tablecontrol.cxx
blobc3fb5ace083ba6d2f99d5c28023ab48ea2c6cf1b
1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
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"
29 #include "svtools/table/tablecontrol.hxx"
30 #include "tablegeometry.hxx"
31 #include "tablecontrol_impl.hxx"
32 #include "svtools/table/tabledatawindow.hxx"
33 //........................................................................
34 namespace svt { namespace table
36 //........................................................................
38 //====================================================================
39 //= TableControl
40 //====================================================================
41 //--------------------------------------------------------------------
42 TableControl::TableControl( Window* _pParent, WinBits _nStyle )
43 :Control( _pParent, _nStyle )
44 ,m_pImpl( new TableControl_Impl( *this ) )
46 m_pImpl->getDataWindow()->SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) );
47 m_pImpl->getDataWindow()->SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) );
50 //--------------------------------------------------------------------
51 TableControl::~TableControl()
53 DELETEZ( m_pImpl );
56 //--------------------------------------------------------------------
57 void TableControl::GetFocus()
59 if ( !m_pImpl->getInputHandler()->GetFocus( *m_pImpl ) )
61 Control::GetFocus();
62 GrabFocus();
66 //--------------------------------------------------------------------
67 void TableControl::LoseFocus()
69 if ( !m_pImpl->getInputHandler()->LoseFocus( *m_pImpl ) )
70 Control::LoseFocus();
73 //--------------------------------------------------------------------
74 void TableControl::KeyInput( const KeyEvent& rKEvt )
76 if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) )
77 Control::KeyInput( rKEvt );
79 //--------------------------------------------------------------------
80 void TableControl::Resize()
82 Control::Resize();
83 m_pImpl->onResize();
86 //--------------------------------------------------------------------
87 void TableControl::SetModel( PTableModel _pModel )
89 m_pImpl->setModel( _pModel );
92 //--------------------------------------------------------------------
93 PTableModel TableControl::GetModel() const
95 return m_pImpl->getModel();
98 //--------------------------------------------------------------------
99 RowPos TableControl::GetTopRow() const
101 return m_pImpl->getTopRow();
104 //--------------------------------------------------------------------
105 void TableControl::SetTopRow( RowPos _nRow )
107 // TODO
108 (void)_nRow;
111 //--------------------------------------------------------------------
112 RowPos TableControl::GetCurrentRow() const
114 return m_pImpl->getCurRow();
117 //--------------------------------------------------------------------
118 ColPos TableControl::GetCurrentColumn() const
120 return m_pImpl->getCurColumn();
123 //--------------------------------------------------------------------
124 bool TableControl::GoTo( ColPos _nColumn, RowPos _nRow )
126 return m_pImpl->goTo( _nColumn, _nRow );
128 //--------------------------------------------------------------------
129 void TableControl::InvalidateDataWindow(RowPos _nRowStart, bool _bRemoved)
131 Rectangle _rRect;
132 if(_bRemoved)
133 return m_pImpl->invalidateRows(_nRowStart, _rRect);
134 else
135 return m_pImpl->invalidateRow(_nRowStart, _rRect);
137 //--------------------------------------------------------------------
138 std::vector<RowPos> TableControl::getSelectedRows()
140 return m_pImpl->getSelectedRows();
142 //--------------------------------------------------------------------
143 void TableControl::removeSelectedRow(RowPos _nRowPos)
145 m_pImpl->removeSelectedRow(_nRowPos);
147 //--------------------------------------------------------------------
149 RowPos TableControl::GetCurrentRow(const Point& rPoint)
151 return m_pImpl->getCurrentRow( rPoint );
154 //--------------------------------------------------------------------
156 IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData )
158 CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData );
159 return 1;
162 IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData )
164 CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData );
165 return 1;
168 SelectionEngine* TableControl::getSelEngine()
170 return m_pImpl->getSelEngine();
173 TableDataWindow* TableControl::getDataWindow()
175 return m_pImpl->getDataWindow();
177 //........................................................................
178 } } // namespace svt::table
179 //........................................................................