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