xref: /aoo42x/main/svtools/inc/svtools/svtabbx.hxx (revision 01aa44aa)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVTABBX_HXX
24 #define _SVTABBX_HXX
25 
26 #include "svtools/svtdllapi.h"
27 #include <svtools/svtreebx.hxx>
28 #include <svtools/accessibletableprovider.hxx>
29 
30 #ifndef INCLUDED_VECTOR
31 #include <vector>
32 #define INCLUDED_VECTOR
33 #endif
34 
35 enum SvTabJustify
36 {
37 	AdjustRight = SV_LBOXTAB_ADJUST_RIGHT,
38 	AdjustLeft = SV_LBOXTAB_ADJUST_LEFT,
39 	AdjustCenter = SV_LBOXTAB_ADJUST_CENTER,
40 	AdjustNumeric = SV_LBOXTAB_ADJUST_NUMERIC
41 };
42 
43 struct TabListBoxEventData
44 {
45     SvLBoxEntry*    m_pEntry;
46     sal_uInt16          m_nColumn;
47     String          m_sOldText;
48 
TabListBoxEventDataTabListBoxEventData49     TabListBoxEventData( SvLBoxEntry* pEntry, sal_uInt16 nColumn, const String& rOldText ) :
50         m_pEntry( pEntry ), m_nColumn( nColumn ), m_sOldText( rOldText ) {}
51 };
52 
53 class SVT_DLLPUBLIC SvTabListBox : public SvTreeListBox
54 {
55 private:
56 	SvLBoxTab*					pTabList;
57 	sal_uInt16						nTabCount;
58 	XubString					aCurEntry;
59 	sal_uLong						nDummy1;
60 	sal_uLong						nDummy2;
61 
62 protected:
63 	SvLBoxEntry*				pViewParent;
64 
65 	static const xub_Unicode*	GetToken( const xub_Unicode* pPtr, sal_uInt16& rLen );
66 
67 	virtual void				SetTabs();
68 	virtual void				InitEntry( SvLBoxEntry*, const XubString&, const Image&, const Image&, SvLBoxButtonKind );
69 
70 	String						GetTabEntryText( sal_uLong nPos, sal_uInt16 nCol ) const;
71 	SvLBoxEntry*				GetEntryOnPos( sal_uLong _nEntryPos ) const;
72 	SvLBoxEntry*				GetChildOnPos( SvLBoxEntry* _pParent, sal_uLong _nEntryPos, sal_uLong& _rPos ) const;
73 
74 public:
75 	SvTabListBox( Window* pParent, WinBits = WB_BORDER );
76 	SvTabListBox( Window* pParent, const ResId& );
77 	~SvTabListBox();
78 	void			SetTabs( long* pTabs, MapUnit = MAP_APPFONT );
TabCount() const79 	sal_uInt16			TabCount() const { return (sal_uInt16)nTabCount; }
80     using SvTreeListBox::GetTab;
81 	long 			GetTab( sal_uInt16 nTab ) const;
82 	void			SetTab( sal_uInt16 nTab, long nValue, MapUnit = MAP_APPFONT );
83 	long			GetLogicTab( sal_uInt16 nTab );
84 
85     virtual SvLBoxEntry*	InsertEntry( const XubString& rText, SvLBoxEntry* pParent = 0,
86 						                 sal_Bool bChildsOnDemand = sal_False,
87                                          sal_uLong nPos=LIST_APPEND, void* pUserData = 0,
88                                          SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
89 
90 	virtual SvLBoxEntry*	InsertEntry( const XubString& rText,
91 						                 const Image& rExpandedEntryBmp,
92                                          const Image& rCollapsedEntryBmp,
93                                          SvLBoxEntry* pParent = 0,
94                                          sal_Bool bChildsOnDemand = sal_False,
95                                          sal_uLong nPos = LIST_APPEND, void* pUserData = 0,
96                                          SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox );
97 
98 	virtual SvLBoxEntry* InsertEntryToColumn( const XubString&, sal_uLong nPos = LIST_APPEND,
99 								 sal_uInt16 nCol = 0xffff, void* pUserData = NULL );
100 	virtual SvLBoxEntry* InsertEntryToColumn( const XubString&, SvLBoxEntry* pParent,
101 								 sal_uLong nPos, sal_uInt16 nCol, void* pUserData = NULL );
102 	virtual SvLBoxEntry* InsertEntryToColumn( const XubString&, const Image& rExpandedEntryBmp,
103 								 const Image& rCollapsedEntryBmp, SvLBoxEntry* pParent = NULL,
104 								 sal_uLong nPos = LIST_APPEND, sal_uInt16 nCol = 0xffff, void* pUserData = NULL );
105 
106 	virtual	String	GetEntryText( SvLBoxEntry* pEntry ) const;
107 	String			GetEntryText( SvLBoxEntry*, sal_uInt16 nCol ) const;
108 	String			GetEntryText( sal_uLong nPos, sal_uInt16 nCol = 0xffff ) const;
109     using SvTreeListBox::SetEntryText;
110 	void			SetEntryText( const XubString&, sal_uLong, sal_uInt16 nCol=0xffff );
111 	void			SetEntryText(const XubString&,SvLBoxEntry*,sal_uInt16 nCol=0xffff);
112     String          GetCellText( sal_uLong nPos, sal_uInt16 nCol ) const;
113 	sal_uLong			GetEntryPos( const XubString&, sal_uInt16 nCol = 0xffff );
114 	sal_uLong			GetEntryPos( const SvLBoxEntry* pEntry ) const;
115 
116 	virtual void	Resize();
117 	void			SetTabJustify( sal_uInt16 nTab, SvTabJustify );
118 	SvTabJustify	GetTabJustify( sal_uInt16 nTab ) const;
119 };
120 
GetTab(sal_uInt16 nTab) const121 inline long SvTabListBox::GetTab( sal_uInt16 nTab ) const
122 {
123 	DBG_ASSERT( nTab < nTabCount, "GetTabPos:Invalid Tab" );
124 	return pTabList[nTab].GetPos();
125 }
126 
127 // class SvHeaderTabListBox ---------------------------------------------------
128 
129 class HeaderBar;
130 namespace svt {
131     class AccessibleTabListBox;
132     class IAccessibleTabListBox;
133     struct SvHeaderTabListBoxImpl;
134 }
135 
136 class SVT_DLLPUBLIC SvHeaderTabListBox : public SvTabListBox, public svt::IAccessibleTableProvider
137 {
138 private:
139 	typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >	> AccessibleChildren;
140 
141 	sal_Bool					    m_bFirstPaint;
142     ::svt::SvHeaderTabListBoxImpl*  m_pImpl;
143     ::svt::IAccessibleTabListBox*   m_pAccessible;
144 	AccessibleChildren			    m_aAccessibleChildren;
145 
146 	DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, SvTabListBox* );
147 	DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, HeaderBar* );
148 
149     void            RecalculateAccessibleChildren();
150 
151 public:
152 	SvHeaderTabListBox( Window* pParent, WinBits nBits );
153 	SvHeaderTabListBox( Window* pParent, const ResId& );
154 	~SvHeaderTabListBox();
155 
156 	virtual void	Paint( const Rectangle& );
157 
158 	void			InitHeaderBar( HeaderBar* pHeaderBar );
159     sal_Bool        IsItemChecked( SvLBoxEntry* pEntry, sal_uInt16 nCol ) const;
160 
161     virtual SvLBoxEntry* InsertEntryToColumn( const XubString&, sal_uLong nPos = LIST_APPEND,
162                                  sal_uInt16 nCol = 0xffff, void* pUserData = NULL );
163     virtual SvLBoxEntry* InsertEntryToColumn( const XubString&, SvLBoxEntry* pParent,
164                                  sal_uLong nPos, sal_uInt16 nCol, void* pUserData = NULL );
165     virtual SvLBoxEntry* InsertEntryToColumn( const XubString&, const Image& rExpandedEntryBmp,
166                                  const Image& rCollapsedEntryBmp, SvLBoxEntry* pParent = NULL,
167                                  sal_uLong nPos = LIST_APPEND, sal_uInt16 nCol = 0xffff, void* pUserData = NULL );
168 	virtual sal_uLong Insert( SvLBoxEntry* pEnt,SvLBoxEntry* pPar,sal_uLong nPos=LIST_APPEND);
169     virtual sal_uLong Insert( SvLBoxEntry* pEntry, sal_uLong nRootPos = LIST_APPEND );
170     void            RemoveEntry( SvLBoxEntry* _pEntry );
171     void            Clear();
172 
173 	// Accessible -------------------------------------------------------------
174 
DisableTransientChildren()175     inline void     DisableTransientChildren()          { SetChildrenNotTransient(); }
IsTransientChildrenDisabled() const176     inline sal_Bool IsTransientChildrenDisabled() const { return !AreChildrenTransient(); }
177 
178     sal_Bool        IsCellCheckBox( long _nRow, sal_uInt16 _nColumn, TriState& _rState );
179 
180     /** @return  The count of the rows. */
181 	virtual	long					GetRowCount() const;
182     /** @return  The count of the columns. */
183 	virtual sal_uInt16				GetColumnCount() const;
184 
185     /** @return  The position of the current row. */
186 	virtual sal_Int32				GetCurrRow() const;
187     /** @return  The position of the current column. */
188 	virtual sal_uInt16				GetCurrColumn() const;
189 
190     /** @return  The description of a row.
191         @param _nRow The row which description is in demand. */
192     virtual ::rtl::OUString			GetRowDescription( sal_Int32 _nRow ) const;
193     /** @return  The description of a column.
194         @param _nColumn The column which description is in demand. */
195 	virtual ::rtl::OUString			GetColumnDescription( sal_uInt16 _nColumn ) const;
196 
197     /** @return  <TRUE/>, if the object has a row header. */
198 	virtual sal_Bool				HasRowHeader() const; //GetColumnId
199     /** @return  <TRUE/>, if the object can focus a cell. */
200 	virtual sal_Bool				IsCellFocusable() const;
201 	virtual sal_Bool				GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn );
202 
203 	virtual void					SetNoSelection();
204     using SvListView::SelectAll;
205 	virtual void					SelectAll();
206 	virtual void					SelectAll( sal_Bool bSelect, sal_Bool bPaint = sal_True );
207 	virtual void					SelectRow( long _nRow, sal_Bool _bSelect = sal_True, sal_Bool bExpand = sal_True );
208 	virtual void					SelectColumn( sal_uInt16 _nColumn, sal_Bool _bSelect = sal_True );
209 	virtual sal_Int32				GetSelectedRowCount() const;
210 	virtual sal_Int32				GetSelectedColumnCount() const;
211     /** @return  <TRUE/>, if the row is selected. */
212 	virtual bool					IsRowSelected( long _nRow ) const;
213 	virtual sal_Bool				IsColumnSelected( long _nColumn ) const;
214 	virtual void					GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& _rRows ) const;
215 	virtual void					GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& _rColumns ) const;
216 
217     /** @return  <TRUE/>, if the cell is visible. */
218 	virtual sal_Bool				IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const;
219 	virtual String					GetAccessibleCellText( long _nRow, sal_uInt16 _nColumnPos ) const;
220 
221 	virtual Rectangle				calcHeaderRect( sal_Bool _bIsColumnBar, sal_Bool _bOnScreen = sal_True );
222 	virtual Rectangle				calcTableRect( sal_Bool _bOnScreen = sal_True );
223 	virtual Rectangle				GetFieldRectPixelAbs( sal_Int32 _nRow, sal_uInt16 _nColumn, sal_Bool _bIsHeader, sal_Bool _bOnScreen = sal_True );
224 
225 	virtual XACC					CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumn );
226     virtual XACC					CreateAccessibleRowHeader( sal_Int32 _nRow );
227     virtual XACC					CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos );
228 
229 	virtual sal_Int32				GetAccessibleControlCount() const;
230     virtual XACC					CreateAccessibleControl( sal_Int32 _nIndex );
231     virtual sal_Bool				ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint );
232 
233 	virtual sal_Bool				ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint );
234     virtual sal_Bool				ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint );
235     virtual sal_Bool				ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint );
236 
237 	virtual ::rtl::OUString			GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const;
238     virtual ::rtl::OUString			GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const;
239     virtual Window*					GetWindowInstance();
240 
241     using SvTreeListBox::FillAccessibleStateSet;
242 	virtual void					FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& _rStateSet, ::svt::AccessibleBrowseBoxObjType _eType ) const;
243 	virtual void					FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumn ) const;
244     virtual void					GrabTableFocus();
245 
246 	// OutputDevice
247 	virtual sal_Bool					GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector );
248 
249 	// Window
250     virtual Rectangle				GetWindowExtentsRelative( Window *pRelativeWindow ) const;
251     virtual void					GrabFocus();
252     virtual XACC					GetAccessible( sal_Bool bCreate = sal_True );
253     virtual Window*					GetAccessibleParentWindow() const;
254 
255 	/** Creates and returns the accessible object of the whole BrowseBox. */
256     virtual XACC					CreateAccessible();
257 
258 	virtual Rectangle				GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex);
259 	virtual sal_Int32				GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint);
260 };
261 
262 #endif // #ifndef _SVTABBX_HXX
263 
264 
265