1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVTOOLS_INC_TABLE_TABLECONTROL_HXX
21 #define INCLUDED_SVTOOLS_INC_TABLE_TABLECONTROL_HXX
23 #include <svtools/svtdllapi.h>
24 #include <svtools/table/tablemodel.hxx>
25 #include <svtools/accessibletable.hxx>
26 #include <svtools/accessiblefactory.hxx>
28 #include <vcl/ctrl.hxx>
29 #include <vcl/seleng.hxx>
33 namespace svt
{ namespace table
37 class TableControl_Impl
;
42 /** a basic control which manages table-like data, i.e. a number of cells
43 organized in <code>m</code> rows and <code>n</code> columns.
45 The control itself does not do any assumptions about the concrete data
46 it displays, this is encapsulated in an instance supporting the
47 ->ITableModel interface.
49 Also, the control does not do any assumptions about how the model's
50 content is rendered. This is the responsibility of a component
51 supporting the ->ITableRenderer interface (the renderer is obtained from
54 The control supports the concept of a <em>current</em> (or <em>active</em>
56 The control supports accessibility, this is encapsulated in IAccessibleTable
58 class SVT_DLLPUBLIC TableControl
: public Control
, public IAccessibleTable
61 std::shared_ptr
<TableControl_Impl
> m_pImpl
;
65 TableControl( vcl::Window
* _pParent
, WinBits _nStyle
);
66 virtual ~TableControl();
67 virtual void dispose() SAL_OVERRIDE
;
69 /// sets a new table model
70 void SetModel( PTableModel _pModel
);
71 /// retrieves the current table model
72 PTableModel
GetModel() const;
74 /** retrieves the current row
76 The current row is the one which contains the active cell.
79 the row index of the active cell, or ->ROW_INVALID
80 if there is no active cell, e.g. because the table does
81 not contain any rows or columns.
83 sal_Int32
GetCurrentRow() const SAL_OVERRIDE
;
86 getTableControlInterface();
88 /** retrieves the current column
90 The current col is the one which contains the active cell.
93 the column index of the active cell, or ->COL_INVALID
94 if there is no active cell, e.g. because the table does
95 not contain any rows or columns.
97 sal_Int32
GetCurrentColumn() const SAL_OVERRIDE
;
99 /** activates the cell at the given position
102 <sal_True/> if the move was successful, <FALSE/> otherwise. Usual
103 failure conditions include some other instance vetoing the move,
104 or impossibility to execute the move at all (for instance because
105 of invalid coordinates).
107 bool GoTo( ColPos _nColumnPos
, RowPos _nRow
);
109 /** moves the active cell to the given column, by keeping the active row
112 <sal_True/> if the move was successful, <FALSE/> otherwise. Usual
113 failure conditions include some other instance vetoing the move,
114 or impossibility to execute the move at all (for instance because
115 of invalid coordinates).
117 inline bool GoToColumn( ColPos _nColumn
)
119 return GoTo( _nColumn
, GetCurrentRow() );
122 /** moves the active cell to the given row, by keeping the active column
125 <sal_True/> if the move was successful, <FALSE/> otherwise. Usual
126 failure conditions include some other instance vetoing the move,
127 or impossibility to execute the move at all (for instance because
128 of invalid coordinates).
130 bool GoToRow( RowPos _nRow
)
132 return GoTo( GetCurrentColumn(), _nRow
);
135 SVT_DLLPRIVATE
virtual void Resize() SAL_OVERRIDE
;
138 /**after removing a row, updates the vector which contains the selected rows
139 if the row, which should be removed, is selected, it will be erased from the vector
141 SelectionEngine
* getSelEngine();
142 vcl::Window
& getDataWindow();
144 // Window overridables
145 virtual void GetFocus() SAL_OVERRIDE
;
146 virtual void LoseFocus() SAL_OVERRIDE
;
147 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
148 virtual void StateChanged( StateChangedType i_nStateChange
) SAL_OVERRIDE
;
150 /** Creates and returns the accessible object of the whole GridControl. */
151 SVT_DLLPRIVATE
virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() SAL_OVERRIDE
;
152 SVT_DLLPRIVATE
virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleControl( sal_Int32 _nIndex
) SAL_OVERRIDE
;
153 SVT_DLLPRIVATE
virtual OUString
GetAccessibleObjectName(AccessibleTableControlObjType eObjType
, sal_Int32 _nRow
, sal_Int32 _nCol
) const SAL_OVERRIDE
;
154 SVT_DLLPRIVATE
virtual bool GoToCell( sal_Int32 _nColumnPos
, sal_Int32 _nRow
) SAL_OVERRIDE
;
155 SVT_DLLPRIVATE
virtual OUString
GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType
, sal_Int32 _nPosition
= -1) const SAL_OVERRIDE
;
156 SVT_DLLPRIVATE
virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper
& rStateSet
, AccessibleTableControlObjType eObjType
) const SAL_OVERRIDE
;
159 // Those do not really belong into the public API - they're intended for firing A11Y-related events. However,
160 // firing those events should be an implementation internal to the TableControl resp. TableControl_Impl,
161 // instead of something triggered externally.
162 void commitCellEventIfAccessibleAlive( sal_Int16
const i_eventID
, const css::uno::Any
& i_newValue
, const css::uno::Any
& i_oldValue
);
163 void commitTableEventIfAccessibleAlive( sal_Int16
const i_eventID
, const css::uno::Any
& i_newValue
, const css::uno::Any
& i_oldValue
);
167 virtual Rectangle
GetWindowExtentsRelative( vcl::Window
*pRelativeWindow
) const SAL_OVERRIDE
;
168 virtual void GrabFocus() SAL_OVERRIDE
;
169 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetAccessible( bool bCreate
= true ) SAL_OVERRIDE
;
170 virtual vcl::Window
* GetAccessibleParentWindow() const SAL_OVERRIDE
;
171 virtual vcl::Window
* GetWindowInstance() SAL_OVERRIDE
;
172 virtual sal_Int32
GetAccessibleControlCount() const SAL_OVERRIDE
;
173 virtual bool ConvertPointToControlIndex( sal_Int32
& _rnIndex
, const Point
& _rPoint
) SAL_OVERRIDE
;
174 virtual long GetRowCount() const SAL_OVERRIDE
;
175 virtual long GetColumnCount() const SAL_OVERRIDE
;
176 virtual bool HasRowHeader() const SAL_OVERRIDE
;
177 virtual bool ConvertPointToCellAddress( sal_Int32
& _rnRow
, sal_Int32
& _rnColPos
, const Point
& _rPoint
) SAL_OVERRIDE
;
178 virtual Rectangle
calcHeaderRect( bool _bIsColumnBar
, bool _bOnScreen
= true ) SAL_OVERRIDE
;
179 virtual Rectangle
calcHeaderCellRect( bool _bIsColumnBar
, sal_Int32 nPos
) SAL_OVERRIDE
;
180 virtual Rectangle
calcTableRect( bool _bOnScreen
= true ) SAL_OVERRIDE
;
181 virtual Rectangle
calcCellRect( sal_Int32 _nRowPos
, sal_Int32 _nColPos
) SAL_OVERRIDE
;
182 virtual Rectangle
GetFieldCharacterBounds(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,sal_Int32 nIndex
) SAL_OVERRIDE
;
183 virtual sal_Int32
GetFieldIndexAtPoint(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,const Point
& _rPoint
) SAL_OVERRIDE
;
184 virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper
& _rStateSet
, sal_Int32 _nRow
, sal_uInt16 _nColumnPos
) const SAL_OVERRIDE
;
185 virtual OUString
GetRowDescription( sal_Int32 _nRow
) const SAL_OVERRIDE
;
186 virtual OUString
GetRowName(sal_Int32 _nIndex
) const SAL_OVERRIDE
;
187 virtual OUString
GetColumnDescription( sal_uInt16 _nColumnPos
) const SAL_OVERRIDE
;
188 virtual OUString
GetColumnName( sal_Int32 _nIndex
) const SAL_OVERRIDE
;
189 virtual css::uno::Any
GetCellContent( sal_Int32 _nRowPos
, sal_Int32 _nColPos
) const SAL_OVERRIDE
;
190 virtual bool HasRowHeader() SAL_OVERRIDE
;
191 virtual bool HasColHeader() SAL_OVERRIDE
;
192 virtual OUString
GetAccessibleCellText(sal_Int32 _nRowPos
, sal_Int32 _nColPos
) const SAL_OVERRIDE
;
194 virtual sal_Int32
GetSelectedRowCount() const SAL_OVERRIDE
;
195 virtual sal_Int32
GetSelectedRowIndex( sal_Int32
const i_selectionIndex
) const SAL_OVERRIDE
;
196 virtual bool IsRowSelected( sal_Int32
const i_rowIndex
) const SAL_OVERRIDE
;
197 virtual void SelectRow( sal_Int32
const i_rowIndex
, bool const i_select
) SAL_OVERRIDE
;
198 virtual void SelectAllRows( bool const i_select
) SAL_OVERRIDE
;
202 DECL_DLLPRIVATE_LINK( ImplSelectHdl
, void* );
205 TableControl( const TableControl
& ) SAL_DELETED_FUNCTION
;
206 TableControl
& operator=( const TableControl
& ) SAL_DELETED_FUNCTION
;
210 } } // namespace svt::table
213 #endif // INCLUDED_SVTOOLS_INC_TABLE_TABLECONTROL_HXX
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */