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