/src/libreoffice/include/vcl/toolkit/svtabbx.hxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) |
23 | | #error "don't use this in new code" |
24 | | #endif |
25 | | |
26 | | #include <config_options.h> |
27 | | #include <accessibility/accessibletablistbox.hxx> |
28 | | #include <vcl/dllapi.h> |
29 | | #include <vcl/toolkit/treelistbox.hxx> |
30 | | #include <vcl/accessibletableprovider.hxx> |
31 | | |
32 | | #include <tools/debug.hxx> |
33 | | |
34 | | #include <memory> |
35 | | #include <vector> |
36 | | |
37 | | class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTabListBox : public SvTreeListBox |
38 | | { |
39 | | private: |
40 | | std::vector<SvLBoxTab> mvTabList; |
41 | | OUString aCurEntry; |
42 | | |
43 | | protected: |
44 | | static std::u16string_view GetToken( std::u16string_view sStr, sal_Int32 &nIndex ); |
45 | | |
46 | | virtual void SetTabs() override; |
47 | | virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&) override; |
48 | | |
49 | | OUString GetTabEntryText( sal_uInt32 nPos, sal_uInt16 nCol ) const; |
50 | | SvTreeListEntry* GetEntryOnPos( sal_uInt32 _nEntryPos ) const; |
51 | | SvTreeListEntry* GetChildOnPos( SvTreeListEntry* _pParent, sal_uInt32 _nEntryPos, sal_uInt32& _rPos ) const; |
52 | | |
53 | | public: |
54 | | SvTabListBox( vcl::Window* pParent, WinBits ); |
55 | | virtual ~SvTabListBox() override; |
56 | | virtual void dispose() override; |
57 | | void SetTabs(const std::vector<tools::Long>& rTabPositions, MapUnit = MapUnit::MapAppFont); |
58 | | using SvTreeListBox::GetTab; |
59 | | tools::Long GetLogicTab( sal_uInt16 nTab ); |
60 | | |
61 | | virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr, |
62 | | bool bChildrenOnDemand = false, |
63 | | sal_uInt32 nPos=TREELIST_APPEND, void* pUserData = nullptr ) override; |
64 | | |
65 | | virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent, |
66 | | sal_uInt32 nPos, sal_uInt16 nCol, void* pUserData = nullptr ); |
67 | | |
68 | | virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const override; |
69 | | static OUString GetEntryText( const SvTreeListEntry*, sal_uInt16 nCol ); |
70 | | OUString GetEntryText( sal_uInt32 nPos, sal_uInt16 nCol = 0xffff ) const; |
71 | | using SvTreeListBox::SetEntryText; |
72 | | OUString GetCellText( sal_uInt32 nPos, sal_uInt16 nCol ) const; |
73 | | sal_uInt32 GetEntryPos( const SvTreeListEntry* pEntry ) const; |
74 | | |
75 | | void SetTabAlignCenter(sal_uInt16 nTab); |
76 | | void SetTabEditable( sal_uInt16 nTab, bool bEditable ); |
77 | | |
78 | | virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override; |
79 | | }; |
80 | | |
81 | | // class SvHeaderTabListBox --------------------------------------------------- |
82 | | |
83 | | class HeaderBar; |
84 | | namespace vcl { |
85 | | struct SvHeaderTabListBoxImpl; |
86 | | } |
87 | | class AccessibleBrowseBoxHeaderCell; |
88 | | |
89 | | class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvHeaderTabListBox final : public SvTabListBox, public vcl::IAccessibleTableProvider |
90 | | { |
91 | | private: |
92 | | bool m_bFirstPaint; |
93 | | VclPtr<HeaderBar> m_xHeaderBar; |
94 | | rtl::Reference<AccessibleTabListBox> m_xAccessible; |
95 | | std::vector<rtl::Reference<AccessibleBrowseBoxHeaderCell>> m_aAccessibleChildren; |
96 | | |
97 | | Link<SvTreeListEntry*, bool> m_aEditingEntryHdl; |
98 | | Link<const IterString&, bool> m_aEditedEntryHdl; |
99 | | |
100 | | DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, SvTreeListBox*, void ); |
101 | | DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, HeaderBar*, void ); |
102 | | |
103 | | void RecalculateAccessibleChildren(); |
104 | | |
105 | | public: |
106 | | SvHeaderTabListBox(vcl::Window* pParent, WinBits nBits, HeaderBar* pHeaderBar); |
107 | | virtual ~SvHeaderTabListBox() override; |
108 | | virtual void dispose() override; |
109 | | |
110 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; |
111 | | |
112 | | HeaderBar* GetHeaderBar(); |
113 | | static bool IsItemChecked( SvTreeListEntry* pEntry, sal_uInt16 nCol ); |
114 | | |
115 | | virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent, |
116 | | sal_uInt32 nPos, sal_uInt16 nCol, void* pUserData = nullptr ) override; |
117 | | virtual sal_uInt32 Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uInt32 nPos=TREELIST_APPEND) override; |
118 | | virtual sal_uInt32 Insert( SvTreeListEntry* pEntry, sal_uInt32 nRootPos = TREELIST_APPEND ) override; |
119 | | |
120 | | // Accessible ------------------------------------------------------------- |
121 | | |
122 | | bool IsCellCheckBox( sal_Int32 _nRow, sal_uInt16 _nColumn, TriState& _rState ) const; |
123 | | |
124 | | /** @return The count of the rows. */ |
125 | | virtual sal_Int32 GetRowCount() const override; |
126 | | /** @return The count of the columns. */ |
127 | | virtual sal_uInt16 GetColumnCount() const override; |
128 | | |
129 | | /** @return The position of the current row. */ |
130 | | virtual sal_Int32 GetCurrRow() const override; |
131 | | /** @return The position of the current column. */ |
132 | | virtual sal_uInt16 GetCurrColumn() const override; |
133 | | |
134 | | /** @return The description of a row. |
135 | | @param _nRow The row which description is in demand. */ |
136 | | virtual OUString GetRowDescription( sal_Int32 _nRow ) const override; |
137 | | /** @return The description of a column. |
138 | | @param _nColumn The column which description is in demand. */ |
139 | | virtual OUString GetColumnDescription( sal_uInt16 _nColumn ) const override; |
140 | | |
141 | | /** @return <TRUE/>, if the object has a row header. */ |
142 | | virtual bool HasRowHeader() const override; //GetColumnId |
143 | | /** @return <TRUE/>, if the object can focus a cell. */ |
144 | | virtual bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override; |
145 | | |
146 | | virtual void SetNoSelection() override; |
147 | | using SvTabListBox::SelectAll; |
148 | | virtual void SelectAll() override; |
149 | | virtual void SelectRow( sal_Int32 _nRow, bool _bSelect = true, bool bExpand = true ) override; |
150 | | virtual void SelectColumn( sal_uInt16 _nColumn, bool _bSelect = true ) override; |
151 | | virtual sal_Int32 GetSelectedRowCount() const override; |
152 | | virtual sal_Int32 GetSelectedColumnCount() const override; |
153 | | /** @return <TRUE/>, if the row is selected. */ |
154 | | virtual bool IsRowSelected( sal_Int32 _nRow ) const override; |
155 | | virtual bool IsColumnSelected( sal_Int32 _nColumn ) const override; |
156 | | virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const override; |
157 | | virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const override; |
158 | | |
159 | | /** @return <TRUE/>, if the cell is visible. */ |
160 | | virtual bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const override; |
161 | | virtual OUString GetAccessibleCellText( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const override; |
162 | | |
163 | | virtual tools::Rectangle calcHeaderRect(bool _bIsColumnBar) override; |
164 | | virtual tools::Rectangle calcTableRect() override; |
165 | | virtual tools::Rectangle calcFieldRectPixel(sal_Int32 _nRow, sal_uInt16 _nColumn, bool _bIsHeader) override; |
166 | | |
167 | | virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override; |
168 | | virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleRowHeader( sal_Int32 _nRow ) override; |
169 | | virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) override; |
170 | | |
171 | | virtual sal_Int32 GetAccessibleControlCount() const override; |
172 | | virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) override; |
173 | | virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) override; |
174 | | |
175 | | virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint ) override; |
176 | | virtual bool ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint ) override; |
177 | | virtual bool ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint ) override; |
178 | | |
179 | | virtual OUString GetAccessibleObjectName( AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override; |
180 | | virtual OUString GetAccessibleObjectDescription( AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override; |
181 | | virtual vcl::Window* GetWindowInstance() override; |
182 | | |
183 | | virtual void FillAccessibleStateSet( sal_Int64& _rStateSet, AccessibleBrowseBoxObjType _eType ) const override; |
184 | | virtual void FillAccessibleStateSetForCell( sal_Int64& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumn ) const override; |
185 | | virtual void GrabTableFocus() override; |
186 | | |
187 | | // OutputDevice |
188 | | virtual bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, std::vector< tools::Rectangle >& rVector ) override; |
189 | | |
190 | | // Window |
191 | | virtual tools::Rectangle GetWindowExtentsRelative(const vcl::Window& rRelativeWindow) const override; |
192 | | virtual void GrabFocus() override; |
193 | | virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() override; |
194 | | /** Creates and returns the accessible object of the whole BrowseBox. */ |
195 | | virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; |
196 | | virtual vcl::Window* GetAccessibleParentWindow() const override; |
197 | | |
198 | | virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) override; |
199 | | virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override; |
200 | | |
201 | | virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override; |
202 | | |
203 | | void SetEditingEntryHdl(const Link<SvTreeListEntry*, bool>& rLink) |
204 | 0 | { |
205 | 0 | m_aEditingEntryHdl = rLink; |
206 | 0 | } |
207 | | |
208 | | void SetEditedEntryHdl(const Link<const IterString&, bool>& rLink) |
209 | 0 | { |
210 | 0 | m_aEditedEntryHdl = rLink; |
211 | 0 | } |
212 | | |
213 | | //the default NotifyStartDrag is weird to me, and defaults to enabling all |
214 | | //possibilities when drag starts, while restricting it to some subset of |
215 | | //the configured drag drop mode would make more sense to me, but I'm not |
216 | | //going to change the baseclass |
217 | 0 | virtual DragDropMode NotifyStartDrag() override { return GetDragDropMode(); } |
218 | | |
219 | | virtual bool EditingEntry(SvTreeListEntry* pEntry) override |
220 | 0 | { |
221 | 0 | return m_aEditingEntryHdl.Call(pEntry); |
222 | 0 | } |
223 | | |
224 | | virtual bool EditedEntry(SvTreeListEntry* pEntry, const OUString& rNewText) override |
225 | 0 | { |
226 | 0 | return m_aEditedEntryHdl.Call(IterString(pEntry, rNewText)); |
227 | 0 | } |
228 | | }; |
229 | | |
230 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |