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