Bump version to 6.4-15
[LibreOffice.git] / svtools / inc / table / tablecontrol.hxx
blob41b1491af34c0fedafa4b14c8f0d5ae09106ba30
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <vcl/accessibletable.hxx>
27 #include <vcl/ctrl.hxx>
28 #include <vcl/seleng.hxx>
30 #include <memory>
32 namespace svt { namespace table
34 class TableControl_Impl;
37 //= TableControl
39 /** a basic control which manages table-like data, i.e. a number of cells
40 organized in <code>m</code> rows and <code>n</code> columns.
42 The control itself does not do any assumptions about the concrete data
43 it displays, this is encapsulated in an instance supporting the
44 ->ITableModel interface.
46 Also, the control does not do any assumptions about how the model's
47 content is rendered. This is the responsibility of a component
48 supporting the ->ITableRenderer interface (the renderer is obtained from
49 the model).
51 The control supports the concept of a <em>current</em> (or <em>active</em>
52 cell).
53 The control supports accessibility, this is encapsulated in IAccessibleTable
55 class SVT_DLLPUBLIC TableControl : public Control, public vcl::table::IAccessibleTable
57 private:
58 std::shared_ptr<TableControl_Impl> m_pImpl;
61 public:
62 TableControl( vcl::Window* _pParent, WinBits _nStyle );
63 virtual ~TableControl() override;
64 virtual void dispose() override;
66 /// sets a new table model
67 void SetModel( const PTableModel& _pModel );
68 /// retrieves the current table model
69 PTableModel GetModel() const;
71 /** retrieves the current row
73 The current row is the one which contains the active cell.
75 @return
76 the row index of the active cell, or ->ROW_INVALID
77 if there is no active cell, e.g. because the table does
78 not contain any rows or columns.
80 sal_Int32 GetCurrentRow() const override;
82 ITableControl&
83 getTableControlInterface();
85 /** retrieves the current column
87 The current col is the one which contains the active cell.
89 @return
90 the column index of the active cell, or ->COL_INVALID
91 if there is no active cell, e.g. because the table does
92 not contain any rows or columns.
94 sal_Int32 GetCurrentColumn() const override;
96 /** activates the cell at the given position
98 void GoTo( ColPos _nColumnPos, RowPos _nRow);
100 SVT_DLLPRIVATE virtual void Resize() override;
101 void Select();
103 /**after removing a row, updates the vector which contains the selected rows
104 if the row, which should be removed, is selected, it will be erased from the vector
106 SelectionEngine* getSelEngine();
107 vcl::Window& getDataWindow();
109 // Window overridables
110 virtual void GetFocus() override;
111 virtual void LoseFocus() override;
112 virtual void KeyInput( const KeyEvent& rKEvt ) override;
113 virtual void StateChanged( StateChangedType i_nStateChange ) override;
115 /** Creates and returns the accessible object of the whole GridControl. */
116 SVT_DLLPRIVATE virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
117 SVT_DLLPRIVATE virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) override;
118 SVT_DLLPRIVATE virtual OUString GetAccessibleObjectName(vcl::table::AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const override;
119 SVT_DLLPRIVATE virtual void GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ) override;
120 SVT_DLLPRIVATE virtual OUString GetAccessibleObjectDescription(vcl::table::AccessibleTableControlObjType eObjType) const override;
121 SVT_DLLPRIVATE virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, vcl::table::AccessibleTableControlObjType eObjType ) const override;
123 // temporary methods
124 // Those do not really belong into the public API - they're intended for firing A11Y-related events. However,
125 // firing those events should be an implementation internal to the TableControl resp. TableControl_Impl,
126 // instead of something triggered externally.
127 void commitCellEventIfAccessibleAlive( sal_Int16 const i_eventID, const css::uno::Any& i_newValue, const css::uno::Any& i_oldValue );
128 void commitTableEventIfAccessibleAlive( sal_Int16 const i_eventID, const css::uno::Any& i_newValue, const css::uno::Any& i_oldValue );
131 // IAccessibleTable
132 virtual tools::Rectangle GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const override;
133 virtual void GrabFocus() override;
134 virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() override;
135 virtual vcl::Window* GetAccessibleParentWindow() const override;
136 virtual vcl::Window* GetWindowInstance() override;
137 virtual sal_Int32 GetAccessibleControlCount() const override;
138 virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) override;
139 virtual long GetRowCount() const override;
140 virtual long GetColumnCount() const override;
141 virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ) override;
142 virtual tools::Rectangle calcHeaderRect( bool _bIsColumnBar ) override;
143 virtual tools::Rectangle calcHeaderCellRect( bool _bIsColumnBar, sal_Int32 nPos) override;
144 virtual tools::Rectangle calcTableRect() override;
145 virtual tools::Rectangle calcCellRect( sal_Int32 _nRowPos, sal_Int32 _nColPos ) override;
146 virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) override;
147 virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override;
148 virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const override;
149 virtual OUString GetRowName(sal_Int32 _nIndex) const override;
150 virtual OUString GetColumnName( sal_Int32 _nIndex ) const override;
151 virtual bool HasRowHeader() override;
152 virtual bool HasColHeader() override;
153 virtual OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const override;
155 virtual sal_Int32 GetSelectedRowCount() const override;
156 virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const override;
157 virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const override;
158 virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select ) override;
159 virtual void SelectAllRows( bool const i_select ) override;
162 private:
163 DECL_DLLPRIVATE_LINK( ImplSelectHdl, LinkParamNone*, void );
165 private:
166 TableControl( const TableControl& ) = delete;
167 TableControl& operator=( const TableControl& ) = delete;
171 } } // namespace svt::table
174 #endif // INCLUDED_SVTOOLS_INC_TABLE_TABLECONTROL_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */