xref: /trunk/main/svtools/inc/svtools/brwbox.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 _SVX_BRWBOX_HXX
28 #define _SVX_BRWBOX_HXX
29 
30 #include "svtools/svtdllapi.h"
31 #include <vcl/scrbar.hxx>
32 #include <vcl/ctrl.hxx>
33 #include <tools/multisel.hxx>
34 #include <svtools/headbar.hxx>
35 #include <svtools/transfer.hxx>
36 #include <svtools/AccessibleBrowseBoxObjType.hxx>
37 #include <svtools/accessibletableprovider.hxx>
38 
39 #ifndef INCLUDED_LIMITS_H
40 #include <limits.h>
41 #define INCLUDED_LIMITS_H
42 #endif
43 
44 #ifndef INCLUDED_MEMORY
45 #include <memory>
46 #define INCLUDED_MEMORY
47 #endif
48 
49 class BrowserColumn;
50 class BrowserColumns;
51 class BrowserDataWin;
52 class MultiSelection;
53 class BrowserHeader;
54 
55 namespace svt {
56     class BrowseBoxImpl;
57     class IAccessibleFactory;
58 }
59 namespace utl {
60     class AccessibleStateSetHelper;
61 }
62 
63 // -------------------
64 // - BrowseBox-Types -
65 // -------------------
66 
67 #define BROWSER_INVALIDID           USHRT_MAX
68 #define BROWSER_ENDOFSELECTION      (long)(SFX_ENDOFSELECTION)
69 
70 typedef sal_uLong BrowserMode;
71 
72 #define BROWSER_COLUMNSELECTION      0x0001
73 #define BROWSER_MULTISELECTION       0x0002
74 #define BROWSER_THUMBDRAGGING        0x0004
75 #define BROWSER_KEEPHIGHLIGHT        0x0008
76 #define BROWSER_KEEPSELECTION        BROWSER_KEEPHIGHLIGHT  // old, dont use!
77 #define BROWSER_HLINES               0x0010
78 #define BROWSER_VLINES               0x0020
79 #define BROWSER_HLINESFULL           BROWSER_HLINES // old, dont use!
80 #define BROWSER_VLINESFULL           BROWSER_VLINES // old, dont use!
81 #define BROWSER_HLINESDOTS           0x0000 // old => dont use!
82 #define BROWSER_VLINESDOTS           0x0000 // old => dont use!
83 
84 #define BROWSER_HIDESELECT           0x0100 // old => dont use!
85 #define BROWSER_HIDECURSOR           0x0200
86 
87 #define BROWSER_NO_HSCROLL           0x0400
88 #define BROWSER_NO_SCROLLBACK        0x0800
89 
90 #define BROWSER_AUTO_VSCROLL         0x1000
91 #define BROWSER_AUTO_HSCROLL         0x2000
92 
93 #define BROWSER_TRACKING_TIPS        0x4000
94 
95 #define BROWSER_NO_VSCROLL           0x8000
96 
97 #define BROWSER_HIGHLIGHT_NONE       0x0100 // == BROWSER_HIDESELECT
98 #define BROWSER_HIGHLIGHT_TOGGLE 0x00000000 // old default => NULL, dont use!
99 
100 #define BROWSER_HEADERBAR_NEW    0x00040000
101 #define BROWSER_AUTOSIZE_LASTCOL 0x00080000
102 #define BROWSER_OWN_DATACHANGED  0x00100000
103 
104 #define BROWSER_CURSOR_WO_FOCUS  0x00200000
105     // Allows a cursor which is shown even if the control does not have the focus. This does not affect other
106     // situations which require to temporarily hide the cursor (such as scrolling).
107 
108 #define BROWSER_SMART_HIDECURSOR 0x00400000
109     // is an enhanced version of BROWSER_HIDECURSOR.
110     // When set, BROWSER_HIDECURSOR is overruled, and the cursor is hidden as long as no selection exists,
111     // but shown otherwise. This does not affect other situations which require to temporarily hide the
112     // cursor (such as scrolling).
113 
114 typedef int BrowserColumnMode;
115 #define BROWSER_COLUMN_TITLEABBREVATION   1
116 #define BROWSER_COLUMN_STANDARD             BROWSER_COLUMN_TITLEABBREVATION
117 
118 #define BROWSER_NONE                      0
119 #define BROWSER_SELECT                  720
120 #define BROWSER_EXPANDSELECTION         721
121 #define BROWSER_ENHANCESELECTION        722
122 #define BROWSER_SELECTALL               723
123 #define BROWSER_SELECTDOWN              724
124 #define BROWSER_SELECTUP                725
125 #define BROWSER_CURSORDOWN              731
126 #define BROWSER_CURSORUP                732
127 #define BROWSER_CURSORLEFT              733
128 #define BROWSER_CURSORRIGHT             734
129 #define BROWSER_CURSORPAGEDOWN          735
130 #define BROWSER_CURSORPAGEUP            736
131 #define BROWSER_CURSORPAGERIGHT         735
132 #define BROWSER_CURSORPAGELEFT          736
133 #define BROWSER_CURSORENDOFFILE         741
134 #define BROWSER_CURSORTOPOFFILE         742
135 #define BROWSER_CURSORENDOFSCREEN       743
136 #define BROWSER_CURSORTOPOFSCREEN       744
137 #define BROWSER_CURSORHOME              745
138 #define BROWSER_CURSOREND               746
139 #define BROWSER_SCROLLDOWN              751
140 #define BROWSER_SCROLLUP                752
141 #define BROWSER_SELECTHOME              753
142 #define BROWSER_SELECTEND               754
143 #define BROWSER_SELECTCOLUMN            755
144 #define BROWSER_MOVECOLUMNLEFT          756
145 #define BROWSER_MOVECOLUMNRIGHT         757
146 
147 // ---------------
148 // - BrowseEvent -
149 // ---------------
150 
151 class BrowseEvent
152 {
153     Window*             pWin;
154     long                nRow;
155     Rectangle           aRect;
156     sal_uInt16              nCol;
157     sal_uInt16              nColId;
158 
159 public:
160                         BrowseEvent();
161                         BrowseEvent( Window* pWindow,
162                                      long nAbsRow,
163                                      sal_uInt16 nColumn, sal_uInt16 nColumnId,
164                                      const Rectangle& rRect );
165 
166     Window*             GetWindow() const { return pWin; }
167     long                GetRow() const { return nRow; }
168     sal_uInt16              GetColumn() const { return nCol; }
169     sal_uInt16              GetColumnId() const { return nColId; }
170     const Rectangle&    GetRect() const { return aRect; }
171 };
172 
173 // ---------------------
174 // - BrowserMouseEvent -
175 // ---------------------
176 
177 class BrowserMouseEvent: public MouseEvent, public BrowseEvent
178 {
179 public:
180     BrowserMouseEvent();
181     BrowserMouseEvent( BrowserDataWin* pWin, const MouseEvent& rEvt );
182     BrowserMouseEvent( Window* pWin, const MouseEvent& rEvt,
183                        long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
184                        const Rectangle& rRect );
185 };
186 
187 // --------------------------
188 // - BrowserAcceptDropEvent -
189 // --------------------------
190 
191 class BrowserAcceptDropEvent : public AcceptDropEvent, public BrowseEvent
192 {
193 public:
194     BrowserAcceptDropEvent();
195     BrowserAcceptDropEvent( BrowserDataWin* pWin, const AcceptDropEvent& rEvt );
196 };
197 
198 // ---------------------------
199 // - BrowserExecuteDropEvent -
200 // ---------------------------
201 
202 class BrowserExecuteDropEvent : public ExecuteDropEvent, public BrowseEvent
203 {
204 public:
205     BrowserExecuteDropEvent();
206     BrowserExecuteDropEvent( BrowserDataWin* pWin, const ExecuteDropEvent& rEvt );
207 };
208 
209 // -------------
210 // - BrowseBox -
211 // -------------
212 
213 // TODO
214 // The whole selection thingie in this class is somewhat .... suspicious to me.
215 // some oddities:
216 // * method parameters named like members (and used in both semantics within the method!)
217 // * the multi selection flag is sometimes used as if it is for row selection, sometimes as if
218 //   it's for column selection, too (and sometimes in an even stranger way :)
219 // * it is not really defined like all these hundreds selection related flags/methods work together
220 //   and influence each other. I do not understand it very well, but this may be my fault :)
221 // * There is a GetColumnSelection, but it can't be used to determine the selected columns (at least
222 //   not without a const_cast)
223 //
224 // We should clearly define this somewhere in the future. Or, even better, we should re-implement this
225 // whole class, which is planned for a long time :)
226 //
227 // sorry for the ranting. could not resist
228 // 98483 - 11.04.2002 - fs@openoffice.org
229 
230 class SVT_DLLPUBLIC BrowseBox
231         :public Control
232         ,public DragSourceHelper
233         ,public DropTargetHelper
234         ,public svt::IAccessibleTableProvider
235 {
236     #define NO_CURSOR_HIDE      0
237     #define HARD_CURSOR_HIDE    1
238     #define SMART_CURSOR_HIDE   2
239 
240     friend class BrowserDataWin;
241     friend class ::svt::BrowseBoxImpl;
242 
243 #ifdef DBG_MI
244     friend void DoLog_Impl( const BrowseBox *pThis, const char *pWhat, const char *pWho );
245 #endif
246 
247 #ifdef DBG_UTIL
248     friend const char* BrowseBoxCheckInvariants( const void * pVoid );
249 #endif
250 
251     Window*         pDataWin;       // window to display data rows
252     ScrollBar*      pVScroll;       // vertical scrollbar
253     ScrollBar       aHScroll;       // horizontal scrollbar
254 
255     long            nDataRowHeight; // height of a single data-row
256     sal_uInt16          nTitleLines;    // number of lines in title row
257     sal_uLong           nControlAreaWidth; // width of fixed area beneeth hscroll
258     sal_Bool            bThumbDragging; // handle thumb dragging
259     sal_Bool            bColumnCursor;  // single columns and fields selectable
260     sal_Bool            bMultiSelection;// allow multiple selected rows
261     sal_Bool            bKeepHighlight; // don't hide selection on LoseFocus
262 
263     sal_Bool            bHLines;        // draw lines between rows
264     sal_Bool            bVLines;        // draw lines between columns
265     sal_Bool            bHDots;         // draw lines between rows dotted
266     sal_Bool            bVDots;         // draw lines between columns dotted
267     Color           aGridLineColor;     // color for lines, default dark grey
268     sal_Bool            bBootstrapped;  // child windows resized etc.
269     long            nTopRow;        // no. of first visible row (0...)
270     long            nCurRow;        // no. of row with cursor
271     long            nRowCount;      // total number of rows in model
272     sal_uInt16          nFirstCol;      // no. of first visible scrollable column
273     sal_uInt16          nCurColId;      // column id of cursor
274 
275     sal_Bool            bSelecting;
276     sal_Bool            bRowDividerDrag;
277     sal_Bool            bHit;
278     sal_Bool            mbInteractiveRowHeight;
279     Point           a1stPoint;
280     Point           a2ndPoint;
281 
282     long            nResizeX;       // mouse position at start of resizing
283     long            nMinResizeX;    // never drag more left
284     long            nDragX;         // last dragged column (MouseMove)
285     sal_uInt16          nResizeCol;     // resize this column in MouseMove
286     sal_Bool            bResizing;      // mouse captured for column resizing
287 
288     sal_Bool            bSelect;        // select or deselect
289     sal_Bool            bSelectionIsVisible; // depending on focus
290     sal_Bool            bScrolling;     // hidden cursor while scrolling
291     sal_Bool            bNotToggleSel;  // set while in ToggleSelection() etc.
292     sal_Bool            bHasFocus;      // set/unset in Get/LoseFocus
293     sal_Bool            bHideSelect;    // hide selection (highlight)
294     sal_Bool            bHideCursor;    // hide cursor (frame)
295     Range           aSelRange;      // for selection expansion
296 
297     BrowserColumns* pCols;          // array of column-descriptions
298     union
299     {
300         MultiSelection* pSel;       // selected rows for multi-selection
301         long            nSel;       // selected row for single-selection
302     }               uRow;
303     MultiSelection* pColSel;        // selected column-ids
304 
305     ::std::auto_ptr< ::svt::BrowseBoxImpl >  m_pImpl;       // impl structure of the BrowseBox object
306 
307     sal_Bool            m_bFocusOnlyCursor; // hide cursor if we don't have the focus
308     Color           m_aCursorColor;     // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor
309     BrowserMode     m_nCurrentMode;     // last argument of SetMode (redundant, as our other members represent the current settings, too)
310 
311 private:
312 //#if 0 // _SOLAR__PRIVATE
313     SVT_DLLPRIVATE void            ConstructImpl(BrowserMode nMode);
314     SVT_DLLPRIVATE void            ExpandRowSelection( const BrowserMouseEvent& rEvt );
315     SVT_DLLPRIVATE void            ToggleSelection( sal_Bool bForce = sal_False );
316 
317     SVT_DLLPRIVATE void            UpdateScrollbars();
318     SVT_DLLPRIVATE void            AutoSizeLastColumn();
319 
320     SVT_DLLPRIVATE long            ImpGetDataRowHeight() const;
321     SVT_DLLPRIVATE Rectangle       ImplFieldRectPixel( long nRow, sal_uInt16 nColId ) const;
322     SVT_DLLPRIVATE sal_uInt16          FrozenColCount() const;
323 
324     SVT_DLLPRIVATE void            ColumnInserted( sal_uInt16 nPos );
325 
326     DECL_DLLPRIVATE_LINK(       ScrollHdl, ScrollBar * );
327     DECL_DLLPRIVATE_LINK(       EndScrollHdl, ScrollBar * );
328     DECL_DLLPRIVATE_LINK(       StartDragHdl, HeaderBar * );
329 
330     SVT_DLLPRIVATE long            GetFrozenWidth() const;
331 //#endif
332 
333     sal_Bool            GoToRow(long nRow, sal_Bool bRowColMove, sal_Bool bDoNotModifySelection = sal_False );
334 
335     sal_Bool            GoToColumnId( sal_uInt16 nColId, sal_Bool bMakeVisible, sal_Bool bRowColMove = sal_False);
336     void            SelectColumnPos( sal_uInt16 nCol, sal_Bool _bSelect, sal_Bool bMakeVisible);
337     void            SelectColumnId( sal_uInt16 nColId, sal_Bool _bSelect, sal_Bool bMakeVisible)
338                         { SelectColumnPos( GetColumnPos(nColId), _bSelect, bMakeVisible); }
339 
340     void            ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, sal_Bool _bForeignDevice, sal_Bool _bDrawSelections);
341 
342     sal_Bool            PaintCursorIfHiddenOnce() const { return !m_bFocusOnlyCursor && !HasFocus(); }
343 
344     sal_uInt16          ToggleSelectedColumn();
345     void            SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId);
346 
347 protected:
348     /// retrieves the XAccessible implementation associated with the BrowseBox instance
349     ::svt::IAccessibleFactory&   getAccessibleFactory();
350 
351 protected:
352     sal_uInt16          ColCount() const;
353 
354     // software plug for database access
355     // Der RowCount wird jetzt intern automatisch gezaehlt
356     // (ueber RowInserted und RowRemoved), daher ist das Ueberladen
357     // dieser Methode ueberfluessig!
358 public:
359     virtual long    GetRowCount() const;
360 
361 protected:
362     // fuer Anzeige im VScrollBar z.B. auf "?" oder setzen
363     void            SetRealRowCount( const String &rRealRowCount );
364 
365     // Return Value muss immer sal_True sein - SeekRow *muss* klappen!
366     // (sonst ASSERT) MI: wer hat das eingebaut? Das darf nicht so sein!
367 
368     /** seeks for the given row position
369         @param nRow
370             nRow starts at 0
371     */
372     virtual sal_Bool    SeekRow( long nRow ) = 0;
373     virtual void    DrawCursor();
374     virtual void    PaintRow( OutputDevice &rDev, const Rectangle &rRect );
375     virtual void    PaintData( Window& rWin, const Rectangle& rRect );
376     virtual void    PaintField( OutputDevice& rDev, const Rectangle& rRect,
377                                 sal_uInt16 nColumnId ) const = 0;
378     // Benachrichtigung an die abgeleitete Klasse, dass sich der sichtbare
379     // Bereich von Rows geaendert hat. Aus dieser Methode heraus darf
380     // die abgeleitete Klasse Aenderungen des Model mit Hilfe der Methoden
381     // RowInserted und RowRemoved bekanntgeben. Mit sich daraus ergebenden
382     // neuen Zustand wird anschliessend ein Paint veranlasst (und entsprechend
383     // SeekRow etc. gerufen).
384     //
385     // Parameter: nNewTopRow: Nr. der neuen TopRow (kann von VisibleRowsChanged
386     // durch Aufruf von RowInserted und RowDeleted noch veraendert werden).
387     // nNumRows: Anzahl der sichtbaren Rows (auch eine teilweise sichtbare Row
388     // wird mitgezaehlt).
389     //
390     // Moegliche Ursachen fuer die Aenderung des sichtbaren Bereiches:
391     // - Vor dem sichtbaren Bereich sind Rows eingefuegt oder geloescht worden,
392     //   dadurch aendert sich nur die Numerierung der sichtbaren Rows
393     // - Scrollen (und daraus resultierend eine andere erste sichtbare Row)
394     // - Resize des Fensters
395     virtual void    VisibleRowsChanged( long nNewTopRow, sal_uInt16 nNumRows);
396 
397     // Anzahl sichtbarer Rows in dem Fenster (inkl. "angeschnittener" Rows)
398     sal_uInt16          GetVisibleRows()
399                         { return (sal_uInt16)((pDataWin->GetOutputSizePixel().Height() - 1 )/ GetDataRowHeight() + 1); }
400     long            GetTopRow() { return nTopRow; }
401     sal_uInt16          GetFirstVisibleColNumber() const { return nFirstCol; }
402 
403     // Focus-Rect ein-/ausschalten
404     void            DoShowCursor( const char *pWhoLog );
405     void            DoHideCursor( const char *pWhoLog );
406     short           GetCursorHideCount() const;
407 
408     virtual BrowserHeader*  CreateHeaderBar( BrowseBox* pParent );
409 
410     // HACK(virtuelles Create wird im Ctor nicht gerufen)
411     void            SetHeaderBar( BrowserHeader* );
412 
413     long            CalcReverseZoom(long nVal);
414 
415     HeaderBar*      GetHeaderBar() const;
416         // header bar access for derived classes
417 
418     inline const DataFlavorExVector&
419                     GetDataFlavors() const;
420 
421     sal_Bool        IsDropFormatSupported( SotFormatStringId nFormat );     // need this because the base class' IsDropFormatSupported is not const ...
422     sal_Bool        IsDropFormatSupported( SotFormatStringId nFormat ) const;
423 
424     sal_Bool        IsDropFormatSupported( const ::com::sun::star::datatransfer::DataFlavor& _rFlavor );        // need this because the base class' IsDropFormatSupported is not const ...
425     sal_Bool        IsDropFormatSupported( const ::com::sun::star::datatransfer::DataFlavor& _rFlavor ) const;
426 
427 private:
428     void*           implGetDataFlavors() const;
429         // with this we can make GetDataFlavors() inline, which is strongly needed as SVTOOLS does not export
430         // any sysbols containing an "_STL", so a non-inlined method would not be exported ....
431 
432 protected:
433     // callbacks for the data window
434     virtual void    ImplStartTracking();
435     virtual void    ImplTracking();
436     virtual void    ImplEndTracking();
437 
438 public:
439                     BrowseBox( Window* pParent, WinBits nBits = 0,
440                                BrowserMode nMode = 0 );
441                     BrowseBox( Window* pParent, const ResId& rId,
442                                BrowserMode nMode = 0 );
443                     ~BrowseBox();
444 
445     // ererbte ueberladene Handler
446     virtual void    StateChanged( StateChangedType nStateChange );
447     virtual void    MouseButtonDown( const MouseEvent& rEvt );
448     virtual void    MouseMove( const MouseEvent& rEvt );
449     virtual void    MouseButtonUp( const MouseEvent& rEvt );
450     virtual void    KeyInput( const KeyEvent& rEvt );
451     virtual void    LoseFocus();
452     virtual void    GetFocus();
453     virtual void    Resize();
454     virtual void    Paint( const Rectangle& rRect );
455     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
456     virtual void    Command( const CommandEvent& rEvt );
457     virtual void    StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
458 
459     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );     // will forward everything got to the second AcceptDrop method
460     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );   // will forward everything got to the second ExecuteDrop method
461 
462     virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt );
463     virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
464 
465     // neue Handler
466     virtual void    MouseButtonDown( const BrowserMouseEvent& rEvt );
467     virtual void    MouseMove( const BrowserMouseEvent& rEvt );
468     virtual void    MouseButtonUp( const BrowserMouseEvent& rEvt );
469     virtual void    StartScroll();
470     virtual void    EndScroll();
471     virtual void    Select();
472     virtual void    DoubleClick( const BrowserMouseEvent& rEvt );
473     virtual sal_Bool    IsCursorMoveAllowed( long nNewRow, sal_uInt16 nNewColId ) const;
474     virtual void    CursorMoved();
475     virtual void    ColumnMoved( sal_uInt16 nColId );
476     virtual void    ColumnResized( sal_uInt16 nColId );
477     virtual long    QueryColumnResize( sal_uInt16 nColId, long nWidth );
478     /// called when the row height has been changed interactively
479     virtual void    RowHeightChanged();
480     virtual long    QueryMinimumRowHeight();
481 
482     // Window-Control (pass to DataWindow)
483     void            SetUpdateMode( sal_Bool bUpdate );
484     sal_Bool            GetUpdateMode() const;
485 
486     // map-mode and font control
487     void            SetFont( const Font& rNewFont );
488     const Font&     GetFont() const { return pDataWin->GetFont(); }
489     void            SetTitleFont( const Font& rNewFont )
490                         { Control::SetFont( rNewFont ); }
491     const Font&     GetTitleFont() const { return Control::GetFont(); }
492 
493     // color for line painting
494     void            SetGridLineColor(const Color& rColor) {aGridLineColor = rColor;}
495     const Color&    GetGridLineColor() const {return aGridLineColor;}
496 
497     // inserting, changing, removing and freezing of columns
498     void            InsertHandleColumn( sal_uLong nWidth );
499     void            InsertDataColumn( sal_uInt16 nItemId, const Image& rImage,
500                                     long nSize, HeaderBarItemBits nBits = HIB_STDSTYLE,
501                                     sal_uInt16 nPos = HEADERBAR_APPEND );
502     void            InsertDataColumn( sal_uInt16 nItemId, const XubString& rText,
503                                     long nSize, HeaderBarItemBits nBits = HIB_STDSTYLE,
504                                     sal_uInt16 nPos = HEADERBAR_APPEND );
505     void            InsertDataColumn( sal_uInt16 nItemId,
506                                     const Image& rImage, const XubString& rText,
507                                     long nSize, HeaderBarItemBits nBits = HIB_STDSTYLE,
508                                     sal_uInt16 nPos = HEADERBAR_APPEND,
509                                     // Hilfstext bei leerem rText
510                                     const String* pHelpText = 0 );
511     void            SetColumnTitle( sal_uInt16 nColumnId, const String &rTitle );
512     void            SetColumnMode( sal_uInt16 nColumnId, BrowserColumnMode nFlags );
513     void            SetColumnWidth( sal_uInt16 nColumnId, sal_uLong nWidth );
514     void            SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos );
515     void            FreezeColumn( sal_uInt16 nColumnId, sal_Bool bFreeze = sal_True );
516     void            UnfreezeColumns();
517     void            RemoveColumn( sal_uInt16 nColumnId );
518     void            RemoveColumns();
519 
520     // control of title and data row height
521     void            SetDataRowHeight( long nPixel );
522     long            GetDataRowHeight() const;
523     void            SetTitleLines( sal_uInt16 nLines );
524     sal_uInt16          GetTitleLines() const { return nTitleLines; }
525     virtual long    GetTitleHeight() const;
526 
527     // access to dynamic values of cursor row
528     String          GetColumnTitle( sal_uInt16 nColumnId ) const;
529     BrowserColumnMode GetColumnMode( sal_uInt16 nColumnId ) const;
530     Rectangle       GetFieldRect( sal_uInt16 nColumnId ) const;
531     sal_uLong           GetColumnWidth( sal_uInt16 nColumnId ) const;
532     sal_uInt16          GetColumnId( sal_uInt16 nPos ) const;
533     sal_uInt16          GetColumnPos( sal_uInt16 nColumnId ) const;
534     sal_Bool            IsFrozen( sal_uInt16 nColumnId ) const;
535 
536     // movement of visible area
537     void            ResetScroll();
538     long            ScrollColumns( long nColumns );
539     long            ScrollRows( long nRows );
540     long            ScrollPages( long nPagesY );
541     sal_Bool            MakeFieldVisible( long nRow, sal_uInt16 nColId, sal_Bool bComplete = sal_False );
542 
543     // access and movement of cursor
544     long            GetCurRow() const { return nCurRow; }
545     sal_uInt16          GetCurColumnId() const { return nCurColId; }
546     sal_Bool            GoToRow( long nRow );
547     sal_Bool            GoToRowAndDoNotModifySelection( long nRow );
548     sal_Bool            GoToColumnId( sal_uInt16 nColId );
549     sal_Bool            GoToRowColumnId( long nRow, sal_uInt16 nColId );
550 
551     // selections
552     virtual void    SetNoSelection();
553     virtual void    SelectAll();
554     virtual void    SelectRow( long nRow, sal_Bool _bSelect = sal_True, sal_Bool bExpand = sal_True );
555     void            SelectColumnPos( sal_uInt16 nCol, sal_Bool _bSelect = sal_True )
556                         { SelectColumnPos( nCol, _bSelect, sal_True); }
557     void            SelectColumnId( sal_uInt16 nColId, sal_Bool _bSelect = sal_True )
558                         { SelectColumnPos( GetColumnPos(nColId), _bSelect, sal_True); }
559     long            GetSelectRowCount() const;
560     sal_uInt16          GetSelectColumnCount() const;
561     virtual bool    IsRowSelected( long nRow ) const;
562     bool            IsColumnSelected( sal_uInt16 nColumnId ) const;
563     sal_Bool        IsAllSelected() const;
564     long            FirstSelectedRow( sal_Bool bInverse = sal_False );
565     long            LastSelectedRow();
566     long            PrevSelectedRow();
567     long            NextSelectedRow();
568     const MultiSelection* GetColumnSelection() const { return pColSel; }
569     const MultiSelection* GetSelection() const
570                     { return bMultiSelection ? uRow.pSel : 0; }
571     void            SetSelection( const MultiSelection &rSelection );
572 
573     long            FirstSelectedColumn( ) const;
574     long            NextSelectedColumn( ) const;
575 
576     sal_Bool            IsResizing() const { return bResizing; }
577 
578     // access to positions of fields, column and rows
579     Window&         GetEventWindow() const;
580     Window&         GetDataWindow() const { return *pDataWin; }
581     Rectangle       GetRowRectPixel( long nRow,
582                                      sal_Bool bRelToBrowser = sal_True ) const;
583     Rectangle       GetFieldRectPixel( long nRow, sal_uInt16 nColId,
584                                        sal_Bool bRelToBrowser = sal_True) const;
585     sal_Bool            IsFieldVisible( long nRow, sal_uInt16 nColId,
586                                     sal_Bool bComplete = sal_False ) const;
587     long            GetRowAtYPosPixel( long nY,
588                                         sal_Bool bRelToBrowser = sal_True  ) const;
589     sal_uInt16          GetColumnAtXPosPixel( long nX,
590                                           sal_Bool bRelToBrowser = sal_True  ) const;
591 
592     // invalidations
593     void            Clear();
594     void            RowRemoved( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True );
595     void            RowModified( long nRow, sal_uInt16 nColId = USHRT_MAX );
596     void            RowInserted( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True, sal_Bool bKeepSelection = sal_False );
597 
598     // miscellanous
599     void            ReserveControlArea( sal_uInt16 nWidth = USHRT_MAX );
600     Rectangle       GetControlArea() const;
601     sal_Bool            ProcessKey( const KeyEvent& rEvt );
602     void            Dispatch( sal_uInt16 nId );
603     void            SetMode( BrowserMode nMode = 0 );
604     BrowserMode     GetMode( ) const { return m_nCurrentMode; }
605     bool            IsInCommandEvent() const;
606 
607     void            SetCursorColor(const Color& _rCol);
608     Color           GetCursorColor() const { return m_aCursorColor; }
609     void            ResetSelecting() { bSelecting = sal_False; }
610 
611     /** specifies that the user is allowed to interactively change the height of a row,
612         by simply dragging an arbitrary row separator.
613 
614         Note that this works only if there's a handle column, since only in this case,
615         there *is* something for the user to click onto
616     */
617     void            EnableInteractiveRowHeight( sal_Bool _bEnable = sal_True ) { mbInteractiveRowHeight = _bEnable; }
618     sal_Bool            IsInteractiveRowHeightEnabled( ) const { return mbInteractiveRowHeight; }
619 
620     /// access to selected methods, to be granted to the BrowserColumn
621     struct BrowserColumnAccess { friend class BrowserColumn; private: BrowserColumnAccess() { } };
622     /** public version of PaintField, with selected access rights for the BrowserColumn
623     */
624     void            DoPaintField( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId, BrowserColumnAccess ) const
625                     { PaintField( rDev, rRect, nColumnId ); }
626 
627     /** suggests a default width for a column containing a given text
628 
629         The width is calculated so that the text fits completely, plus som margin.
630     */
631     sal_uLong           GetDefaultColumnWidth( const String& _rText ) const;
632 
633     /** GetCellText returns the text at the given position
634         @param  _nRow
635             the number of the row
636         @param  _nColId
637             the ID of the column
638         @return
639             the text out of the cell
640     */
641     virtual String  GetCellText(long _nRow, sal_uInt16 _nColId) const;
642 
643     /** @return
644             the current column count
645     */
646     sal_uInt16 GetColumnCount() const { return ColCount(); }
647 
648     /** commitBrowseBoxEvent commit the event at all listeners of the browsebox
649         @param nEventId
650             the event id
651         @param rNewValue
652             the new value
653         @param rOldValue
654             the old value
655     */
656     void commitBrowseBoxEvent(sal_Int16 nEventId,
657             const ::com::sun::star::uno::Any& rNewValue,
658             const ::com::sun::star::uno::Any& rOldValue);
659 
660     /** commitTableEvent commit the event at all listeners of the table
661         @param nEventId
662             the event id
663         @param rNewValue
664             the new value
665         @param rOldValue
666             the old value
667     */
668     void commitTableEvent(sal_Int16 nEventId,
669             const ::com::sun::star::uno::Any& rNewValue,
670             const ::com::sun::star::uno::Any& rOldValue);
671 
672     /** fires an AccessibleEvent relative to a header bar AccessibleContext
673 
674         @param nEventId
675             the event id
676         @param rNewValue
677             the new value
678         @param rOldValue
679             the old value
680     */
681     void commitHeaderBarEvent(sal_Int16 nEventId,
682             const ::com::sun::star::uno::Any& rNewValue,
683             const ::com::sun::star::uno::Any& rOldValue,
684             sal_Bool _bColumnHeaderBar
685          );
686 
687     /** returns the Rectangle for either the column header bar ot the row header bar
688         @param  _bIsColumnBar
689             <TRUE/> when column header bar is used
690         @param  _bOnScreen
691             <TRUE/> when the rectangle should be calculated OnScreen
692         @return
693             the Rectangle
694     */
695     virtual Rectangle calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen = sal_True);
696 
697     /** calculates the Rectangle of the table
698         @param  _bOnScreen
699             <TRUE/> when the rectangle should be calculated OnScreen
700         @return
701             the Rectangle
702     */
703     virtual Rectangle calcTableRect(sal_Bool _bOnScreen = sal_True);
704 
705     /**
706         @param  _nRowId
707             the current row
708         @param  _nColId
709             teh column id
710         @param  _bOnScreen
711             <TRUE/> when the rectangle should be calculated OnScreen
712         @return
713             the Rectangle
714     */
715     virtual Rectangle GetFieldRectPixelAbs(sal_Int32 _nRowId,sal_uInt16 _nColId, sal_Bool _bIsHeader, sal_Bool _bOnScreen = sal_True);
716 
717     /// return <TRUE/> if and only if the accessible object for this instance has been created and is alive
718     sal_Bool isAccessibleAlive( ) const;
719 
720     // ACCESSIBILITY ==========================================================
721 public:
722     /** Creates and returns the accessible object of the whole BrowseBox. */
723     virtual ::com::sun::star::uno::Reference<
724         ::com::sun::star::accessibility::XAccessible > CreateAccessible();
725 
726     // Children ---------------------------------------------------------------
727 
728     /** Creates the accessible object of a data table cell.
729         @param nRow  The row index of the cell.
730         @param nColumnId  The column pos of the cell.
731         @return  The XAccessible interface of the specified cell. */
732     virtual ::com::sun::star::uno::Reference<
733         ::com::sun::star::accessibility::XAccessible >
734     CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnPos );
735 
736     /** Creates the accessible object of a row header.
737         @param nRow  The row index of the header.
738         @return  The XAccessible interface of the specified row header. */
739     virtual ::com::sun::star::uno::Reference<
740         ::com::sun::star::accessibility::XAccessible >
741     CreateAccessibleRowHeader( sal_Int32 nRow );
742 
743     /** Creates the accessible object of a column header.
744         @param nColumnId  The column ID of the header.
745         @return  The XAccessible interface of the specified column header. */
746     virtual ::com::sun::star::uno::Reference<
747         ::com::sun::star::accessibility::XAccessible >
748     CreateAccessibleColumnHeader( sal_uInt16 nColumnPos );
749 
750     /** @return  The count of additional controls of the control area. */
751     virtual sal_Int32 GetAccessibleControlCount() const;
752 
753     /** Creates the accessible object of an additional control.
754         @param nIndex  The 0-based index of the control.
755         @return  The XAccessible interface of the specified control. */
756     virtual ::com::sun::star::uno::Reference<
757         ::com::sun::star::accessibility::XAccessible >
758     CreateAccessibleControl( sal_Int32 nIndex );
759 
760     // Conversions ------------------------------------------------------------
761 
762     /** Converts a point relative to the data window origin to a cell address.
763         @param rnRow  Out-paramater that takes the row index.
764         @param rnColumnId  Out-paramater that takes the column ID.
765         @param rPoint  The position in pixels relative to the data window.
766         @return <TRUE/>, if the point could be converted to a valid address. */
767     virtual sal_Bool ConvertPointToCellAddress(
768         sal_Int32& rnRow, sal_uInt16& rnColumnId, const Point& rPoint );
769 
770     /** Converts a point relative to the row header bar origin to a row header
771         index.
772         @param rnRow  Out-paramater that takes the row index.
773         @param rPoint  The position in pixels relative to the header bar.
774         @return <TRUE/>, if the point could be converted to a valid index. */
775     virtual sal_Bool ConvertPointToRowHeader( sal_Int32& rnRow, const Point& rPoint );
776 
777     /** Converts a point relative to the column header bar origin to a column
778         header index.
779         @param rnColumnId  Out-paramater that takes the column ID.
780         @param rPoint  The position in pixels relative to the header bar.
781         @return <TRUE/>, if the point could be converted to a valid index. */
782     virtual sal_Bool ConvertPointToColumnHeader( sal_uInt16& rnColumnPos, const Point& rPoint );
783 
784     /** Converts a point relative to the BrowseBox origin to the index of an
785         existing control.
786         @param rnRow  Out-paramater that takes the 0-based control index.
787         @param rPoint  The position in pixels relative to the BrowseBox.
788         @return <TRUE/>, if the point could be converted to a valid index. */
789     virtual sal_Bool ConvertPointToControlIndex( sal_Int32& rnIndex, const Point& rPoint );
790 
791     // Object data and state --------------------------------------------------
792 
793     /** return the name of the specified object.
794         @param  eObjType
795             The type to ask for
796         @param  _nPosition
797             The position of a tablecell (index position), header bar  colum/row cell
798         @return
799             The name of the specified object.
800     */
801     virtual ::rtl::OUString GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
802 
803     /** return the description of the specified object.
804         @param  eObjType
805             The type to ask for
806         @param  _nPosition
807             The position of a tablecell (index position), header bar  colum/row cell
808         @return
809             The description of the specified object.
810     */
811     virtual ::rtl::OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
812 
813     /** @return  The header text of the specified row. */
814     virtual ::rtl::OUString GetRowDescription( sal_Int32 nRow ) const;
815 
816     /** @return  The header text of the specified column. */
817     virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumn ) const;
818 
819     /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by
820         the accessible object), depending on the specified object type. */
821     virtual void FillAccessibleStateSet(
822             ::utl::AccessibleStateSetHelper& rStateSet,
823             ::svt::AccessibleBrowseBoxObjType eObjType ) const;
824 
825     /** Fills the StateSet with all states for one cell (except DEFUNC and SHOWING, done by
826         the accessible object). */
827     virtual void FillAccessibleStateSetForCell(
828             ::utl::AccessibleStateSetHelper& _rStateSet,
829             sal_Int32 _nRow, sal_uInt16 _nColumn ) const;
830 
831     /** Sets focus to current cell of the data table. */
832     virtual void GrabTableFocus();
833 
834     // IAccessibleTableProvider
835     virtual sal_Int32               GetCurrRow() const;
836     virtual sal_uInt16              GetCurrColumn() const;
837     virtual sal_Bool                HasRowHeader() const;
838     virtual sal_Bool                IsCellFocusable() const;
839     virtual sal_Bool                    GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn );
840     virtual void                    SelectColumn( sal_uInt16 _nColumn, sal_Bool _bSelect = sal_True );
841     virtual sal_Bool                IsColumnSelected( long _nColumn ) const;
842     virtual sal_Int32               GetSelectedRowCount() const;
843     virtual sal_Int32               GetSelectedColumnCount() const;
844     virtual void                    GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& _rRows ) const;
845     virtual void                    GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& _rColumns ) const;
846     virtual sal_Bool                IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const;
847     virtual String                  GetAccessibleCellText(long _nRow, sal_uInt16 _nColPos) const;
848     virtual sal_Bool                    GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector );
849     virtual Rectangle               GetWindowExtentsRelative( Window *pRelativeWindow ) const;
850     virtual void                    GrabFocus();
851     virtual XACC                    GetAccessible( sal_Bool bCreate = sal_True );
852     virtual Window*                 GetAccessibleParentWindow() const;
853     virtual Window*                 GetWindowInstance();
854 
855 private:
856     // the following declares some Window/OutputDevice methods private. This happened in the course
857     // of CWS warnings01, which pointed out nameclashs in those methods. If the build breaks in some
858     // upper module, you should investigate whether you really wanted to call base class methods,
859     // or the versions at this class. In the latter case, use the renamed versions above.
860 
861     // Set/GetLineColor - superseded by Set/GetGridLineColor
862     using OutputDevice::SetLineColor;
863     using OutputDevice::GetLineColor;
864 
865     // ToTop/ToBottom were never property implemented. If you currently call it, this is most probably wrong
866     // and not doing as intended
867     using Window::ToTop;
868 };
869 
870 //-------------------------------------------------------------------
871 inline const DataFlavorExVector& BrowseBox::GetDataFlavors() const
872 {
873     return *reinterpret_cast<DataFlavorExVector*>(implGetDataFlavors());
874 }
875 
876 #endif
877 
878