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