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 .
22 #include <controls/table/tablemodel.hxx>
23 #include <vcl/accessibletable.hxx>
25 #include <vcl/ctrl.hxx>
26 #include <vcl/seleng.hxx>
32 class TableControl_Impl
;
37 /** a basic control which manages table-like data, i.e. a number of cells
38 organized in <code>m</code> rows and <code>n</code> columns.
40 The control itself does not do any assumptions about the concrete data
41 it displays, this is encapsulated in an instance supporting the
42 ->ITableModel interface.
44 Also, the control does not do any assumptions about how the model's
45 content is rendered. This is the responsibility of a component
46 supporting the ->ITableRenderer interface (the renderer is obtained from
49 The control supports the concept of a <em>current</em> (or <em>active</em>
51 The control supports accessibility, this is encapsulated in IAccessibleTable
53 class TableControl final
: public Control
, public vcl::table::IAccessibleTable
56 std::shared_ptr
<TableControl_Impl
> m_pImpl
;
60 TableControl( vcl::Window
* _pParent
, WinBits _nStyle
);
61 virtual ~TableControl() override
;
62 virtual void dispose() override
;
64 /// sets a new table model
65 void SetModel( const PTableModel
& _pModel
);
66 /// retrieves the current table model
67 PTableModel
GetModel() const;
69 /** retrieves the current row
71 The current row is the one which contains the active cell.
74 the row index of the active cell, or ->ROW_INVALID
75 if there is no active cell, e.g. because the table does
76 not contain any rows or columns.
78 sal_Int32
GetCurrentRow() const override
;
81 getTableControlInterface();
83 /** retrieves the current column
85 The current col is the one which contains the active cell.
88 the column index of the active cell, or ->COL_INVALID
89 if there is no active cell, e.g. because the table does
90 not contain any rows or columns.
92 sal_Int32
GetCurrentColumn() const override
;
94 /** activates the cell at the given position
96 void GoTo( ColPos _nColumnPos
, RowPos _nRow
);
98 virtual void Resize() override
;
101 /**after removing a row, updates the vector which contains the selected rows
102 if the row, which should be removed, is selected, it will be erased from the vector
104 SelectionEngine
* getSelEngine();
105 vcl::Window
& getDataWindow();
107 // Window overridables
108 virtual void GetFocus() override
;
109 virtual void LoseFocus() override
;
110 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
111 virtual void StateChanged( StateChangedType i_nStateChange
) override
;
113 /** Creates and returns the accessible object of the whole GridControl. */
114 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() override
;
115 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleControl( sal_Int32 _nIndex
) override
;
116 virtual OUString
GetAccessibleObjectName(vcl::table::AccessibleTableControlObjType eObjType
, sal_Int32 _nRow
, sal_Int32 _nCol
) const override
;
117 virtual void GoToCell( sal_Int32 _nColumnPos
, sal_Int32 _nRow
) override
;
118 virtual OUString
GetAccessibleObjectDescription(vcl::table::AccessibleTableControlObjType eObjType
) const override
;
119 virtual void FillAccessibleStateSet( sal_Int64
& rStateSet
, vcl::table::AccessibleTableControlObjType eObjType
) const override
;
122 // Those do not really belong into the public API - they're intended for firing A11Y-related events. However,
123 // firing those events should be an implementation internal to the TableControl resp. TableControl_Impl,
124 // instead of something triggered externally.
125 void commitCellEventIfAccessibleAlive( sal_Int16
const i_eventID
, const css::uno::Any
& i_newValue
, const css::uno::Any
& i_oldValue
);
126 void commitTableEventIfAccessibleAlive( sal_Int16
const i_eventID
, const css::uno::Any
& i_newValue
, const css::uno::Any
& i_oldValue
);
130 virtual tools::Rectangle
GetWindowExtentsRelative(const vcl::Window
*pRelativeWindow
) const override
;
131 virtual void GrabFocus() override
;
132 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetAccessible() override
;
133 virtual vcl::Window
* GetAccessibleParentWindow() const override
;
134 virtual vcl::Window
* GetWindowInstance() override
;
135 virtual sal_Int32
GetAccessibleControlCount() const override
;
136 virtual bool ConvertPointToControlIndex( sal_Int32
& _rnIndex
, const Point
& _rPoint
) override
;
137 virtual sal_Int32
GetRowCount() const override
;
138 virtual sal_Int32
GetColumnCount() const override
;
139 virtual bool ConvertPointToCellAddress( sal_Int32
& _rnRow
, sal_Int32
& _rnColPos
, const Point
& _rPoint
) override
;
140 virtual tools::Rectangle
calcHeaderRect( bool _bIsColumnBar
) override
;
141 virtual tools::Rectangle
calcHeaderCellRect( bool _bIsColumnBar
, sal_Int32 nPos
) override
;
142 virtual tools::Rectangle
calcTableRect() override
;
143 virtual tools::Rectangle
calcCellRect( sal_Int32 _nRowPos
, sal_Int32 _nColPos
) override
;
144 virtual tools::Rectangle
GetFieldCharacterBounds(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,sal_Int32 nIndex
) override
;
145 virtual sal_Int32
GetFieldIndexAtPoint(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,const Point
& _rPoint
) override
;
146 virtual void FillAccessibleStateSetForCell( sal_Int64
& _rStateSet
, sal_Int32 _nRow
, sal_uInt16 _nColumnPos
) const override
;
147 virtual OUString
GetRowName(sal_Int32 _nIndex
) const override
;
148 virtual OUString
GetColumnName( sal_Int32 _nIndex
) const override
;
149 virtual bool HasRowHeader() override
;
150 virtual bool HasColHeader() override
;
151 virtual OUString
GetAccessibleCellText(sal_Int32 _nRowPos
, sal_Int32 _nColPos
) const override
;
153 virtual sal_Int32
GetSelectedRowCount() const override
;
154 virtual sal_Int32
GetSelectedRowIndex( sal_Int32
const i_selectionIndex
) const override
;
155 virtual bool IsRowSelected( sal_Int32
const i_rowIndex
) const override
;
156 virtual void SelectRow( sal_Int32
const i_rowIndex
, bool const i_select
) override
;
157 virtual void SelectAllRows( bool const i_select
) override
;
161 DECL_LINK( ImplSelectHdl
, LinkParamNone
*, void );
164 TableControl( const TableControl
& ) = delete;
165 TableControl
& operator=( const TableControl
& ) = delete;
169 } // namespace svt::table
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */