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