lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / svtools / inc / table / tablecontrol.hxx
blobe57801b6b0a5998e7ad9d149d6e7c37712da4826
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>
26 #include <vcl/accessiblefactory.hxx>
28 #include <vcl/ctrl.hxx>
29 #include <vcl/seleng.hxx>
31 #include <memory>
33 namespace svt { namespace table
35 class TableControl_Impl;
38 //= TableControl
40 /** a basic control which manages table-like data, i.e. a number of cells
41 organized in <code>m</code> rows and <code>n</code> columns.
43 The control itself does not do any assumptions about the concrete data
44 it displays, this is encapsulated in an instance supporting the
45 ->ITableModel interface.
47 Also, the control does not do any assumptions about how the model's
48 content is rendered. This is the responsibility of a component
49 supporting the ->ITableRenderer interface (the renderer is obtained from
50 the model).
52 The control supports the concept of a <em>current</em> (or <em>active</em>
53 cell).
54 The control supports accessibility, this is encapsulated in IAccessibleTable
56 class SVT_DLLPUBLIC TableControl : public Control, public vcl::table::IAccessibleTable
58 private:
59 std::shared_ptr<TableControl_Impl> m_pImpl;
62 public:
63 TableControl( vcl::Window* _pParent, WinBits _nStyle );
64 virtual ~TableControl() override;
65 virtual void dispose() override;
67 /// sets a new table model
68 void SetModel( const PTableModel& _pModel );
69 /// retrieves the current table model
70 PTableModel GetModel() const;
72 /** retrieves the current row
74 The current row is the one which contains the active cell.
76 @return
77 the row index of the active cell, or ->ROW_INVALID
78 if there is no active cell, e.g. because the table does
79 not contain any rows or columns.
81 sal_Int32 GetCurrentRow() const override;
83 ITableControl&
84 getTableControlInterface();
86 /** retrieves the current column
88 The current col is the one which contains the active cell.
90 @return
91 the column index of the active cell, or ->COL_INVALID
92 if there is no active cell, e.g. because the table does
93 not contain any rows or columns.
95 sal_Int32 GetCurrentColumn() const override;
97 /** activates the cell at the given position
99 void GoTo( ColPos _nColumnPos, RowPos _nRow);
101 SVT_DLLPRIVATE virtual void Resize() override;
102 void Select();
104 /**after removing a row, updates the vector which contains the selected rows
105 if the row, which should be removed, is selected, it will be erased from the vector
107 SelectionEngine* getSelEngine();
108 vcl::Window& getDataWindow();
110 // Window overridables
111 virtual void GetFocus() override;
112 virtual void LoseFocus() override;
113 virtual void KeyInput( const KeyEvent& rKEvt ) override;
114 virtual void StateChanged( StateChangedType i_nStateChange ) override;
116 /** Creates and returns the accessible object of the whole GridControl. */
117 SVT_DLLPRIVATE virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
118 SVT_DLLPRIVATE virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) override;
119 SVT_DLLPRIVATE virtual OUString GetAccessibleObjectName(vcl::table::AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const override;
120 SVT_DLLPRIVATE virtual void GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ) override;
121 SVT_DLLPRIVATE virtual OUString GetAccessibleObjectDescription(vcl::table::AccessibleTableControlObjType eObjType) const override;
122 SVT_DLLPRIVATE virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, vcl::table::AccessibleTableControlObjType eObjType ) const override;
124 // temporary methods
125 // Those do not really belong into the public API - they're intended for firing A11Y-related events. However,
126 // firing those events should be an implementation internal to the TableControl resp. TableControl_Impl,
127 // instead of something triggered externally.
128 void commitCellEventIfAccessibleAlive( sal_Int16 const i_eventID, const css::uno::Any& i_newValue, const css::uno::Any& i_oldValue );
129 void commitTableEventIfAccessibleAlive( sal_Int16 const i_eventID, const css::uno::Any& i_newValue, const css::uno::Any& i_oldValue );
132 // IAccessibleTable
133 virtual tools::Rectangle GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const override;
134 virtual void GrabFocus() override;
135 virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() override;
136 virtual vcl::Window* GetAccessibleParentWindow() const override;
137 virtual vcl::Window* GetWindowInstance() override;
138 virtual sal_Int32 GetAccessibleControlCount() const override;
139 virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) override;
140 virtual long GetRowCount() const override;
141 virtual long GetColumnCount() const override;
142 virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ) override;
143 virtual tools::Rectangle calcHeaderRect( bool _bIsColumnBar ) override;
144 virtual tools::Rectangle calcHeaderCellRect( bool _bIsColumnBar, sal_Int32 nPos) override;
145 virtual tools::Rectangle calcTableRect() override;
146 virtual tools::Rectangle calcCellRect( sal_Int32 _nRowPos, sal_Int32 _nColPos ) override;
147 virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) override;
148 virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override;
149 virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const override;
150 virtual OUString GetRowDescription( sal_Int32 _nRow ) const override;
151 virtual OUString GetRowName(sal_Int32 _nIndex) const override;
152 virtual OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const override;
153 virtual OUString GetColumnName( sal_Int32 _nIndex ) const override;
154 virtual bool HasRowHeader() override;
155 virtual bool HasColHeader() override;
156 virtual OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const override;
158 virtual sal_Int32 GetSelectedRowCount() const override;
159 virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const override;
160 virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const override;
161 virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select ) override;
162 virtual void SelectAllRows( bool const i_select ) override;
165 private:
166 DECL_DLLPRIVATE_LINK( ImplSelectHdl, LinkParamNone*, void );
168 private:
169 TableControl( const TableControl& ) = delete;
170 TableControl& operator=( const TableControl& ) = delete;
174 } } // namespace svt::table
177 #endif // INCLUDED_SVTOOLS_INC_TABLE_TABLECONTROL_HXX
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */