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 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
26 #include <config_options.h>
27 #include <vcl/dllapi.h>
28 #include <vcl/toolkit/treelistbox.hxx>
29 #include <vcl/accessibletableprovider.hxx>
31 #include <tools/debug.hxx>
36 enum class SvTabJustify
38 AdjustRight
= static_cast<int>(SvLBoxTabFlags::ADJUST_RIGHT
),
39 AdjustLeft
= static_cast<int>(SvLBoxTabFlags::ADJUST_LEFT
),
40 AdjustCenter
= static_cast<int>(SvLBoxTabFlags::ADJUST_CENTER
)
43 class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC
) SvTabListBox
: public SvTreeListBox
46 std::vector
<SvLBoxTab
> mvTabList
;
50 static std::u16string_view
GetToken( std::u16string_view sStr
, sal_Int32
&nIndex
);
52 virtual void SetTabs() override
;
53 virtual void InitEntry(SvTreeListEntry
*, const OUString
&, const Image
&, const Image
&) override
;
55 OUString
GetTabEntryText( sal_uInt32 nPos
, sal_uInt16 nCol
) const;
56 SvTreeListEntry
* GetEntryOnPos( sal_uInt32 _nEntryPos
) const;
57 SvTreeListEntry
* GetChildOnPos( SvTreeListEntry
* _pParent
, sal_uInt32 _nEntryPos
, sal_uInt32
& _rPos
) const;
60 SvTabListBox( vcl::Window
* pParent
, WinBits
);
61 virtual ~SvTabListBox() override
;
62 virtual void dispose() override
;
63 void SetTabs(sal_uInt16 nTabs
, tools::Long
const pTabPositions
[], MapUnit
= MapUnit::MapAppFont
);
64 using SvTreeListBox::GetTab
;
65 tools::Long
GetLogicTab( sal_uInt16 nTab
);
67 virtual SvTreeListEntry
* InsertEntry( const OUString
& rText
, SvTreeListEntry
* pParent
= nullptr,
68 bool bChildrenOnDemand
= false,
69 sal_uInt32 nPos
=TREELIST_APPEND
, void* pUserData
= nullptr ) override
;
71 virtual SvTreeListEntry
* InsertEntryToColumn( const OUString
&, SvTreeListEntry
* pParent
,
72 sal_uInt32 nPos
, sal_uInt16 nCol
, void* pUserData
= nullptr );
74 virtual OUString
GetEntryText( SvTreeListEntry
* pEntry
) const override
;
75 static OUString
GetEntryText( const SvTreeListEntry
*, sal_uInt16 nCol
);
76 OUString
GetEntryText( sal_uInt32 nPos
, sal_uInt16 nCol
= 0xffff ) const;
77 using SvTreeListBox::SetEntryText
;
78 OUString
GetCellText( sal_uInt32 nPos
, sal_uInt16 nCol
) const;
79 sal_uInt32
GetEntryPos( const SvTreeListEntry
* pEntry
) const;
81 void SetTabJustify( sal_uInt16 nTab
, SvTabJustify
);
82 void SetTabEditable( sal_uInt16 nTab
, bool bEditable
);
84 virtual void DumpAsPropertyTree(tools::JsonWriter
& rJsonWriter
) override
;
87 // class SvHeaderTabListBox ---------------------------------------------------
91 struct SvHeaderTabListBoxImpl
;
94 class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC
) SvHeaderTabListBox
: public SvTabListBox
, public vcl::IAccessibleTableProvider
98 std::unique_ptr
<::vcl::SvHeaderTabListBoxImpl
> m_pImpl
;
99 ::vcl::IAccessibleTabListBox
* m_pAccessible
;
100 std::vector
<css::uno::Reference
<css::accessibility::XAccessible
>> m_aAccessibleChildren
;
102 DECL_DLLPRIVATE_LINK( ScrollHdl_Impl
, SvTreeListBox
*, void );
103 DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl
, HeaderBar
*, void );
105 void RecalculateAccessibleChildren();
108 SvHeaderTabListBox( vcl::Window
* pParent
, WinBits nBits
);
109 virtual ~SvHeaderTabListBox() override
;
110 virtual void dispose() override
;
112 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& ) override
;
114 void InitHeaderBar(HeaderBar
* pHeaderBar
);
115 HeaderBar
* GetHeaderBar();
116 static bool IsItemChecked( SvTreeListEntry
* pEntry
, sal_uInt16 nCol
);
118 virtual SvTreeListEntry
* InsertEntryToColumn( const OUString
&, SvTreeListEntry
* pParent
,
119 sal_uInt32 nPos
, sal_uInt16 nCol
, void* pUserData
= nullptr ) override
;
120 virtual sal_uInt32
Insert( SvTreeListEntry
* pEnt
,SvTreeListEntry
* pPar
,sal_uInt32 nPos
=TREELIST_APPEND
) override
;
121 virtual sal_uInt32
Insert( SvTreeListEntry
* pEntry
, sal_uInt32 nRootPos
= TREELIST_APPEND
) override
;
123 // Accessible -------------------------------------------------------------
125 bool IsCellCheckBox( sal_Int32 _nRow
, sal_uInt16 _nColumn
, TriState
& _rState
) const;
127 /** @return The count of the rows. */
128 virtual sal_Int32
GetRowCount() const override
;
129 /** @return The count of the columns. */
130 virtual sal_uInt16
GetColumnCount() const override
;
132 /** @return The position of the current row. */
133 virtual sal_Int32
GetCurrRow() const override
;
134 /** @return The position of the current column. */
135 virtual sal_uInt16
GetCurrColumn() const override
;
137 /** @return The description of a row.
138 @param _nRow The row which description is in demand. */
139 virtual OUString
GetRowDescription( sal_Int32 _nRow
) const override
;
140 /** @return The description of a column.
141 @param _nColumn The column which description is in demand. */
142 virtual OUString
GetColumnDescription( sal_uInt16 _nColumn
) const override
;
144 /** @return <TRUE/>, if the object has a row header. */
145 virtual bool HasRowHeader() const override
; //GetColumnId
146 /** @return <TRUE/>, if the object can focus a cell. */
147 virtual bool GoToCell( sal_Int32 _nRow
, sal_uInt16 _nColumn
) override
;
149 virtual void SetNoSelection() override
;
150 using SvTabListBox::SelectAll
;
151 virtual void SelectAll() override
;
152 virtual void SelectRow( sal_Int32 _nRow
, bool _bSelect
= true, bool bExpand
= true ) override
;
153 virtual void SelectColumn( sal_uInt16 _nColumn
, bool _bSelect
= true ) override
;
154 virtual sal_Int32
GetSelectedRowCount() const override
;
155 virtual sal_Int32
GetSelectedColumnCount() const override
;
156 /** @return <TRUE/>, if the row is selected. */
157 virtual bool IsRowSelected( sal_Int32 _nRow
) const override
;
158 virtual bool IsColumnSelected( sal_Int32 _nColumn
) const override
;
159 virtual void GetAllSelectedRows( css::uno::Sequence
< sal_Int32
>& _rRows
) const override
;
160 virtual void GetAllSelectedColumns( css::uno::Sequence
< sal_Int32
>& _rColumns
) const override
;
162 /** @return <TRUE/>, if the cell is visible. */
163 virtual bool IsCellVisible( sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
164 virtual OUString
GetAccessibleCellText( sal_Int32 _nRow
, sal_uInt16 _nColumnPos
) const override
;
166 virtual tools::Rectangle
calcHeaderRect( bool _bIsColumnBar
, bool _bOnScreen
= true ) override
;
167 virtual tools::Rectangle
calcTableRect( bool _bOnScreen
= true ) override
;
168 virtual tools::Rectangle
GetFieldRectPixel( sal_Int32 _nRow
, sal_uInt16 _nColumn
, bool _bIsHeader
, bool _bOnScreen
) override
;
170 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleCell( sal_Int32 _nRow
, sal_uInt16 _nColumn
) override
;
171 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleRowHeader( sal_Int32 _nRow
) override
;
172 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos
) override
;
174 virtual sal_Int32
GetAccessibleControlCount() const override
;
175 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessibleControl( sal_Int32 _nIndex
) override
;
176 virtual bool ConvertPointToControlIndex( sal_Int32
& _rnIndex
, const Point
& _rPoint
) override
;
178 virtual bool ConvertPointToCellAddress( sal_Int32
& _rnRow
, sal_uInt16
& _rnColPos
, const Point
& _rPoint
) override
;
179 virtual bool ConvertPointToRowHeader( sal_Int32
& _rnRow
, const Point
& _rPoint
) override
;
180 virtual bool ConvertPointToColumnHeader( sal_uInt16
& _rnColPos
, const Point
& _rPoint
) override
;
182 virtual OUString
GetAccessibleObjectName( AccessibleBrowseBoxObjType _eType
, sal_Int32 _nPos
= -1 ) const override
;
183 virtual OUString
GetAccessibleObjectDescription( AccessibleBrowseBoxObjType _eType
, sal_Int32 _nPos
= -1 ) const override
;
184 virtual vcl::Window
* GetWindowInstance() override
;
186 virtual void FillAccessibleStateSet( sal_Int64
& _rStateSet
, AccessibleBrowseBoxObjType _eType
) const override
;
187 virtual void FillAccessibleStateSetForCell( sal_Int64
& _rStateSet
, sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
188 virtual void GrabTableFocus() override
;
191 virtual bool GetGlyphBoundRects( const Point
& rOrigin
, const OUString
& rStr
, int nIndex
, int nLen
, std::vector
< tools::Rectangle
>& rVector
) override
;
194 virtual AbsoluteScreenPixelRectangle
GetWindowExtentsAbsolute() const override
;
195 virtual tools::Rectangle
GetWindowExtentsRelative(const vcl::Window
& rRelativeWindow
) const override
;
196 virtual void GrabFocus() override
;
197 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetAccessible() override
;
198 /** Creates and returns the accessible object of the whole BrowseBox. */
199 virtual css::uno::Reference
< css::accessibility::XAccessible
> CreateAccessible() override
;
200 virtual vcl::Window
* GetAccessibleParentWindow() const override
;
202 virtual tools::Rectangle
GetFieldCharacterBounds(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,sal_Int32 nIndex
) override
;
203 virtual sal_Int32
GetFieldIndexAtPoint(sal_Int32 _nRow
,sal_Int32 _nColumnPos
,const Point
& _rPoint
) override
;
205 virtual void DumpAsPropertyTree(tools::JsonWriter
& rJsonWriter
) override
;
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */