Line data Source code
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 : #ifndef INCLUDED_SVTOOLS_SVTABBX_HXX
20 : #define INCLUDED_SVTOOLS_SVTABBX_HXX
21 :
22 : #include <svtools/svtdllapi.h>
23 : #include <svtools/treelistbox.hxx>
24 : #include <svtools/accessibletableprovider.hxx>
25 :
26 : #include <vector>
27 :
28 : enum SvTabJustify
29 : {
30 : AdjustRight = SV_LBOXTAB_ADJUST_RIGHT,
31 : AdjustLeft = SV_LBOXTAB_ADJUST_LEFT,
32 : AdjustCenter = SV_LBOXTAB_ADJUST_CENTER,
33 : AdjustNumeric = SV_LBOXTAB_ADJUST_NUMERIC
34 : };
35 :
36 0 : struct TabListBoxEventData
37 : {
38 : SvTreeListEntry* m_pEntry;
39 : sal_uInt16 m_nColumn;
40 : OUString m_sOldText;
41 :
42 0 : TabListBoxEventData( SvTreeListEntry* pEntry, sal_uInt16 nColumn, const OUString& rOldText ) :
43 0 : m_pEntry( pEntry ), m_nColumn( nColumn ), m_sOldText( rOldText ) {}
44 : };
45 :
46 : class SVT_DLLPUBLIC SvTabListBox : public SvTreeListBox
47 : {
48 : private:
49 : SvLBoxTab* pTabList;
50 : sal_uInt16 nTabCount;
51 : OUString aCurEntry;
52 :
53 : protected:
54 : SvTreeListEntry* pViewParent;
55 :
56 : static OUString GetToken( const OUString &sStr, sal_Int32 &nIndex );
57 :
58 : virtual void SetTabs() SAL_OVERRIDE;
59 : virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind) SAL_OVERRIDE;
60 :
61 : OUString GetTabEntryText( sal_uLong nPos, sal_uInt16 nCol ) const;
62 : SvTreeListEntry* GetEntryOnPos( sal_uLong _nEntryPos ) const;
63 : SvTreeListEntry* GetChildOnPos( SvTreeListEntry* _pParent, sal_uLong _nEntryPos, sal_uLong& _rPos ) const;
64 :
65 : public:
66 : SvTabListBox( vcl::Window* pParent, WinBits = WB_BORDER );
67 : virtual ~SvTabListBox();
68 : void SetTabs( long* pTabs, MapUnit = MAP_APPFONT );
69 0 : sal_uInt16 TabCount() const { return (sal_uInt16)nTabCount; }
70 : using SvTreeListBox::GetTab;
71 : long GetTab( sal_uInt16 nTab ) const;
72 : void SetTab( sal_uInt16 nTab, long nValue, MapUnit = MAP_APPFONT );
73 : long GetLogicTab( sal_uInt16 nTab );
74 :
75 : virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = 0,
76 : bool bChildrenOnDemand = false,
77 : sal_uLong nPos=TREELIST_APPEND, void* pUserData = 0,
78 : SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox ) SAL_OVERRIDE;
79 :
80 : virtual SvTreeListEntry* InsertEntry( const OUString& rText,
81 : const Image& rExpandedEntryBmp,
82 : const Image& rCollapsedEntryBmp,
83 : SvTreeListEntry* pParent = 0,
84 : bool bChildrenOnDemand = false,
85 : sal_uLong nPos = TREELIST_APPEND, void* pUserData = 0,
86 : SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox ) SAL_OVERRIDE;
87 :
88 : virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, sal_uLong nPos = TREELIST_APPEND,
89 : sal_uInt16 nCol = 0xffff, void* pUserData = NULL );
90 : virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent,
91 : sal_uLong nPos, sal_uInt16 nCol, void* pUserData = NULL );
92 : virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, const Image& rExpandedEntryBmp,
93 : const Image& rCollapsedEntryBmp, SvTreeListEntry* pParent = NULL,
94 : sal_uLong nPos = TREELIST_APPEND, sal_uInt16 nCol = 0xffff, void* pUserData = NULL );
95 :
96 : virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const SAL_OVERRIDE;
97 : OUString GetEntryText( SvTreeListEntry*, sal_uInt16 nCol ) const;
98 : OUString GetEntryText( sal_uLong nPos, sal_uInt16 nCol = 0xffff ) const;
99 : using SvTreeListBox::SetEntryText;
100 : void SetEntryText(const OUString&, sal_uLong, sal_uInt16 nCol=0xffff);
101 : void SetEntryText(const OUString&, SvTreeListEntry*, sal_uInt16 nCol=0xffff);
102 : OUString GetCellText( sal_uLong nPos, sal_uInt16 nCol ) const;
103 : sal_uLong GetEntryPos( const OUString&, sal_uInt16 nCol = 0xffff );
104 : sal_uLong GetEntryPos( const SvTreeListEntry* pEntry ) const;
105 :
106 : virtual void Resize() SAL_OVERRIDE;
107 : void SetTabJustify( sal_uInt16 nTab, SvTabJustify );
108 : };
109 :
110 0 : inline long SvTabListBox::GetTab( sal_uInt16 nTab ) const
111 : {
112 : DBG_ASSERT( nTab < nTabCount, "GetTabPos:Invalid Tab" );
113 0 : return pTabList[nTab].GetPos();
114 : }
115 :
116 : // class SvHeaderTabListBox ---------------------------------------------------
117 :
118 : class HeaderBar;
119 : namespace svt {
120 : class IAccessibleTabListBox;
121 : struct SvHeaderTabListBoxImpl;
122 : }
123 :
124 : class SVT_DLLPUBLIC SvHeaderTabListBox : public SvTabListBox, public svt::IAccessibleTableProvider
125 : {
126 : private:
127 : typedef ::std::vector< css::uno::Reference< css::accessibility::XAccessible > > AccessibleChildren;
128 :
129 : bool m_bFirstPaint;
130 : ::svt::SvHeaderTabListBoxImpl* m_pImpl;
131 : ::svt::IAccessibleTabListBox* m_pAccessible;
132 : AccessibleChildren m_aAccessibleChildren;
133 :
134 : DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, void* );
135 : DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, void* );
136 :
137 : void RecalculateAccessibleChildren();
138 :
139 : public:
140 : SvHeaderTabListBox( vcl::Window* pParent, WinBits nBits );
141 : virtual ~SvHeaderTabListBox();
142 :
143 : virtual void Paint( const Rectangle& ) SAL_OVERRIDE;
144 :
145 : void InitHeaderBar( HeaderBar* pHeaderBar );
146 : bool IsItemChecked( SvTreeListEntry* pEntry, sal_uInt16 nCol ) const;
147 :
148 : virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, sal_uLong nPos = TREELIST_APPEND,
149 : sal_uInt16 nCol = 0xffff, void* pUserData = NULL ) SAL_OVERRIDE;
150 : virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent,
151 : sal_uLong nPos, sal_uInt16 nCol, void* pUserData = NULL ) SAL_OVERRIDE;
152 : virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, const Image& rExpandedEntryBmp,
153 : const Image& rCollapsedEntryBmp, SvTreeListEntry* pParent = NULL,
154 : sal_uLong nPos = TREELIST_APPEND, sal_uInt16 nCol = 0xffff, void* pUserData = NULL ) SAL_OVERRIDE;
155 : virtual sal_uLong Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uLong nPos=TREELIST_APPEND) SAL_OVERRIDE;
156 : virtual sal_uLong Insert( SvTreeListEntry* pEntry, sal_uLong nRootPos = TREELIST_APPEND ) SAL_OVERRIDE;
157 : void RemoveEntry( SvTreeListEntry* _pEntry );
158 : void Clear();
159 :
160 : // Accessible -------------------------------------------------------------
161 :
162 0 : inline void DisableTransientChildren() { SetChildrenNotTransient(); }
163 0 : inline bool IsTransientChildrenDisabled() const { return !AreChildrenTransient(); }
164 :
165 : bool IsCellCheckBox( long _nRow, sal_uInt16 _nColumn, TriState& _rState );
166 :
167 : /** @return The count of the rows. */
168 : virtual long GetRowCount() const SAL_OVERRIDE;
169 : /** @return The count of the columns. */
170 : virtual sal_uInt16 GetColumnCount() const SAL_OVERRIDE;
171 :
172 : /** @return The position of the current row. */
173 : virtual sal_Int32 GetCurrRow() const SAL_OVERRIDE;
174 : /** @return The position of the current column. */
175 : virtual sal_uInt16 GetCurrColumn() const SAL_OVERRIDE;
176 :
177 : /** @return The description of a row.
178 : @param _nRow The row which description is in demand. */
179 : virtual OUString GetRowDescription( sal_Int32 _nRow ) const SAL_OVERRIDE;
180 : /** @return The description of a column.
181 : @param _nColumn The column which description is in demand. */
182 : virtual OUString GetColumnDescription( sal_uInt16 _nColumn ) const SAL_OVERRIDE;
183 :
184 : /** @return <TRUE/>, if the object has a row header. */
185 : virtual bool HasRowHeader() const SAL_OVERRIDE; //GetColumnId
186 : /** @return <TRUE/>, if the object can focus a cell. */
187 : virtual bool IsCellFocusable() const SAL_OVERRIDE;
188 : virtual bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) SAL_OVERRIDE;
189 :
190 : virtual void SetNoSelection() SAL_OVERRIDE;
191 : using SvListView::SelectAll;
192 : virtual void SelectAll() SAL_OVERRIDE;
193 : virtual void SelectAll( bool bSelect, bool bPaint = true ) SAL_OVERRIDE;
194 : virtual void SelectRow( long _nRow, bool _bSelect = true, bool bExpand = true ) SAL_OVERRIDE;
195 : virtual void SelectColumn( sal_uInt16 _nColumn, bool _bSelect = true ) SAL_OVERRIDE;
196 : virtual sal_Int32 GetSelectedRowCount() const SAL_OVERRIDE;
197 : virtual sal_Int32 GetSelectedColumnCount() const SAL_OVERRIDE;
198 : /** @return <TRUE/>, if the row is selected. */
199 : virtual bool IsRowSelected( long _nRow ) const SAL_OVERRIDE;
200 : virtual bool IsColumnSelected( long _nColumn ) const SAL_OVERRIDE;
201 : virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const SAL_OVERRIDE;
202 : virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const SAL_OVERRIDE;
203 :
204 : /** @return <TRUE/>, if the cell is visible. */
205 : virtual bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const SAL_OVERRIDE;
206 : virtual OUString GetAccessibleCellText( long _nRow, sal_uInt16 _nColumnPos ) const SAL_OVERRIDE;
207 :
208 : virtual Rectangle calcHeaderRect( bool _bIsColumnBar, bool _bOnScreen = true ) SAL_OVERRIDE;
209 : virtual Rectangle calcTableRect( bool _bOnScreen = true ) SAL_OVERRIDE;
210 : virtual Rectangle GetFieldRectPixelAbs( sal_Int32 _nRow, sal_uInt16 _nColumn, bool _bIsHeader, bool _bOnScreen = true ) SAL_OVERRIDE;
211 :
212 : virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) SAL_OVERRIDE;
213 : virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleRowHeader( sal_Int32 _nRow ) SAL_OVERRIDE;
214 : virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) SAL_OVERRIDE;
215 :
216 : virtual sal_Int32 GetAccessibleControlCount() const SAL_OVERRIDE;
217 : virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) SAL_OVERRIDE;
218 : virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) SAL_OVERRIDE;
219 :
220 : virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint ) SAL_OVERRIDE;
221 : virtual bool ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint ) SAL_OVERRIDE;
222 : virtual bool ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint ) SAL_OVERRIDE;
223 :
224 : virtual OUString GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const SAL_OVERRIDE;
225 : virtual OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const SAL_OVERRIDE;
226 : virtual vcl::Window* GetWindowInstance() SAL_OVERRIDE;
227 :
228 : using SvTreeListBox::FillAccessibleStateSet;
229 : virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& _rStateSet, ::svt::AccessibleBrowseBoxObjType _eType ) const SAL_OVERRIDE;
230 : virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumn ) const SAL_OVERRIDE;
231 : virtual void GrabTableFocus() SAL_OVERRIDE;
232 :
233 : // OutputDevice
234 : virtual bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ) SAL_OVERRIDE;
235 :
236 : // Window
237 : virtual Rectangle GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const SAL_OVERRIDE;
238 : virtual void GrabFocus() SAL_OVERRIDE;
239 : virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible( bool bCreate = true ) SAL_OVERRIDE;
240 : virtual vcl::Window* GetAccessibleParentWindow() const SAL_OVERRIDE;
241 :
242 : /** Creates and returns the accessible object of the whole BrowseBox. */
243 : virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
244 :
245 : virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) SAL_OVERRIDE;
246 : virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) SAL_OVERRIDE;
247 : };
248 :
249 : #endif // INCLUDED_SVTOOLS_SVTABBX_HXX
250 :
251 :
252 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|