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