1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <svtools/svtdllapi.h>
22 #include <vcl/ctrl.hxx>
23 #include <vcl/vclptr.hxx>
24 #include <tools/multisel.hxx>
25 #include <vcl/event.hxx>
26 #include <vcl/headbar.hxx>
27 #include <vcl/transfer.hxx>
28 #include <vcl/timer.hxx>
29 #include <vcl/AccessibleBrowseBoxObjType.hxx>
30 #include <vcl/accessibletableprovider.hxx>
36 #include <o3tl/typed_flags_set.hxx>
41 class MeasureStatusBar
;
48 class IAccessibleFactory
;
55 #define BROWSER_INVALIDID SAL_MAX_UINT16
56 constexpr sal_Int32 BROWSER_ENDOFSELECTION
= SFX_ENDOFSELECTION
;
58 enum class BrowserMode
61 COLUMNSELECTION
= 0x000001,
62 MULTISELECTION
= 0x000002,
63 KEEPHIGHLIGHT
= 0x000008,
67 HIDESELECT
= 0x000100,
68 HIDECURSOR
= 0x000200,
70 NO_HSCROLL
= 0x000400,
72 AUTO_VSCROLL
= 0x001000,
73 AUTO_HSCROLL
= 0x002000,
75 TRACKING_TIPS
= 0x004000,
77 NO_VSCROLL
= 0x008000,
79 HEADERBAR_NEW
= 0x040000,
80 AUTOSIZE_LASTCOL
= 0x080000,
82 CURSOR_WO_FOCUS
= 0x200000,
83 // Allows a cursor which is shown even if the control does not have the focus. This does not affect other
84 // situations which require to temporarily hide the cursor (such as scrolling).
89 template<> struct typed_flags
<BrowserMode
> : is_typed_flags
<BrowserMode
, 0x2cf73b> {};
92 #define BROWSER_NONE 0
93 #define BROWSER_SELECT 720
94 #define BROWSER_ENHANCESELECTION 722
95 #define BROWSER_SELECTDOWN 724
96 #define BROWSER_SELECTUP 725
97 #define BROWSER_CURSORDOWN 731
98 #define BROWSER_CURSORUP 732
99 #define BROWSER_CURSORLEFT 733
100 #define BROWSER_CURSORRIGHT 734
101 #define BROWSER_CURSORPAGEDOWN 735
102 #define BROWSER_CURSORPAGEUP 736
103 #define BROWSER_CURSORENDOFFILE 741
104 #define BROWSER_CURSORTOPOFFILE 742
105 #define BROWSER_CURSORENDOFSCREEN 743
106 #define BROWSER_CURSORTOPOFSCREEN 744
107 #define BROWSER_CURSORHOME 745
108 #define BROWSER_CURSOREND 746
109 #define BROWSER_SCROLLDOWN 751
110 #define BROWSER_SCROLLUP 752
111 #define BROWSER_SELECTHOME 753
112 #define BROWSER_SELECTEND 754
113 #define BROWSER_SELECTCOLUMN 755
114 #define BROWSER_MOVECOLUMNLEFT 756
115 #define BROWSER_MOVECOLUMNRIGHT 757
120 VclPtr
<vcl::Window
> pWin
;
121 tools::Rectangle aRect
;
127 BrowseEvent( vcl::Window
* pWindow
,
129 sal_uInt16 nColumn
, sal_uInt16 nColumnId
,
130 const tools::Rectangle
& rRect
);
132 vcl::Window
* GetWindow() const { return pWin
; }
133 sal_Int32
GetRow() const { return nRow
; }
134 sal_uInt16
GetColumn() const { return nCol
; }
135 sal_uInt16
GetColumnId() const { return nColId
; }
136 const tools::Rectangle
& GetRect() const { return aRect
; }
140 class BrowserMouseEvent
;
142 class BrowserDataWin final
144 ,public DragSourceHelper
145 ,public DropTargetHelper
148 VclPtr
<BrowserHeader
> pHeaderBar
; // only for BrowserMode::HEADERBAR_NEW
150 AutoTimer aMouseTimer
; // recalls MouseMove on dragging out
151 MouseEvent aRepeatEvt
; // a MouseEvent to repeat
152 Point aLastMousePos
; // prevents pseudo-MouseMoves
154 OUString aRealRowCount
; // to show in VScrollBar
156 std::vector
<tools::Rectangle
> aInvalidRegion
; // invalidated Rectangles during !UpdateMode
157 bool bInPaint
; // TRUE while in Paint
158 bool bInCommand
; // TRUE while in Command
159 bool bNoHScroll
; // no horizontal scrollbar
160 bool bNoVScroll
; // no vertical scrollbar
161 bool bAutoHScroll
; // autohide horizontaler Scrollbar
162 bool bAutoVScroll
; // autohide horizontaler Scrollbar
163 bool bUpdateMode
; // not SV-UpdateMode because of Invalidate()
164 bool bAutoSizeLastCol
; // last column always fills up window
165 bool bResizeOnPaint
; // outstanding resize-event
166 bool bUpdateOnUnlock
; // Update() while locked
167 bool bInUpdateScrollbars
; // prevents recursions
168 bool bHadRecursion
; // a recursion occurred
169 bool bCallingDropCallback
; // we're in a callback to AcceptDrop or ExecuteDrop currently
170 sal_uInt16 nUpdateLock
; // lock count, don't call Control::Update()!
171 short nCursorHidden
; // new counter for DoHide/ShowCursor
173 tools::Long m_nDragRowDividerLimit
;
174 tools::Long m_nDragRowDividerOffset
;
177 explicit BrowserDataWin( BrowseBox
* pParent
);
178 virtual ~BrowserDataWin() override
;
179 virtual void dispose() override
;
181 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
182 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
183 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
184 virtual void Command( const CommandEvent
& rEvt
) override
;
185 virtual void MouseButtonDown( const MouseEvent
& rEvt
) override
;
186 virtual void MouseMove( const MouseEvent
& rEvt
) override
;
187 DECL_LINK( RepeatedMouseMove
, Timer
*, void );
189 virtual void MouseButtonUp( const MouseEvent
& rEvt
) override
;
190 virtual void KeyInput( const KeyEvent
& rEvt
) override
;
191 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
193 // DropTargetHelper overridables
194 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
195 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
197 // DragSourceHelper overridables
198 virtual void StartDrag( sal_Int8 _nAction
, const Point
& _rPosPixel
) override
;
201 BrowseEvent
CreateBrowseEvent( const Point
& rPosPixel
);
202 BrowseBox
* GetParent() const;
203 const OUString
& GetRealRowCount() const { return aRealRowCount
; }
205 void SetUpdateMode( bool bMode
);
206 bool GetUpdateMode() const { return bUpdateMode
; }
207 void EnterUpdateLock() { ++nUpdateLock
; }
208 void LeaveUpdateLock();
210 void DoOutstandingInvalidations();
211 void Invalidate( InvalidateFlags nFlags
= InvalidateFlags::NONE
) override
;
212 void Invalidate( const tools::Rectangle
& rRect
, InvalidateFlags nFlags
= InvalidateFlags::NONE
) override
;
213 using Control::Invalidate
;
216 void StartRowDividerDrag( const Point
& _rStartPos
);
217 bool ImplRowDividerHitTest( const BrowserMouseEvent
& _rEvent
) const;
220 class BrowserMouseEvent
: public MouseEvent
, public BrowseEvent
223 BrowserMouseEvent( BrowserDataWin
* pWin
, const MouseEvent
& rEvt
);
224 BrowserMouseEvent( vcl::Window
* pWin
, const MouseEvent
& rEvt
,
225 sal_Int32 nAbsRow
, sal_uInt16 nColumn
, sal_uInt16 nColumnId
,
226 const tools::Rectangle
& rRect
);
230 class BrowserAcceptDropEvent
: public AcceptDropEvent
, public BrowseEvent
233 BrowserAcceptDropEvent( BrowserDataWin
* pWin
, const AcceptDropEvent
& rEvt
);
237 class BrowserExecuteDropEvent
: public ExecuteDropEvent
, public BrowseEvent
240 BrowserExecuteDropEvent( BrowserDataWin
* pWin
, const ExecuteDropEvent
& rEvt
);
244 // The whole selection thingie in this class is somewhat... suspicious to me.
246 // * method parameters named like members (and used in both semantics within the method!)
247 // * the multi selection flag is sometimes used as if it is for row selection, sometimes as if
248 // it's for column selection, too (and sometimes in an even stranger way :)
249 // * it is not really defined like all these hundreds selection related flags/methods work together
250 // and influence each other. I do not understand it very well, but this may be my fault :)
251 // * There is a GetColumnSelection, but it can't be used to determine the selected columns (at least
252 // not without a const_cast)
254 // We should clearly define this somewhere in the future. Or, even better, we should re-implement this
255 // whole class, which is planned for a long time :)
257 // sorry for the ranting. could not resist
259 class SVT_DLLPUBLIC BrowseBox
261 ,public DragSourceHelper
262 ,public DropTargetHelper
263 ,public vcl::IAccessibleTableProvider
265 friend class BrowserDataWin
;
266 friend class ::svt::BrowseBoxImpl
;
269 static const sal_uInt16 HandleColumnId
= 0;
272 VclPtr
<BrowserDataWin
> pDataWin
; // window to display data rows
273 VclPtr
<ScrollAdaptor
> pVScroll
; // vertical scrollbar
274 VclPtr
<ScrollAdaptor
> aHScroll
; // horizontal scrollbar
275 VclPtr
<MeasureStatusBar
> aStatusBarHeight
; // statusbar, just to measure its height
277 tools::Long m_nDataRowHeight
; // height of a single data-row
278 tools::Long m_nCornerHeight
; // height of scrollbox corner
279 tools::Long m_nCornerWidth
; // width of scrollbox corner
280 tools::Long m_nActualCornerWidth
; // size of scrollbox corner
281 sal_uInt16 nTitleLines
; // number of lines in title row
282 sal_uLong nControlAreaWidth
; // width of fixed area beneath hscroll
283 bool bColumnCursor
; // single columns and fields selectable
284 bool bMultiSelection
;// allow multiple selected rows
285 bool bKeepHighlight
; // don't hide selection on LoseFocus
287 bool bHLines
; // draw lines between rows
288 bool bVLines
; // draw lines between columns
289 bool bBootstrapped
; // child windows resized etc.
290 sal_Int32 nTopRow
; // no. of first visible row (0...)
291 sal_Int32 nCurRow
; // no. of row with cursor
292 sal_Int32 nRowCount
; // total number of rows in model
293 sal_uInt16 nFirstCol
; // no. of first visible scrollable column
294 sal_uInt16 nCurColId
; // column id of cursor
297 bool bRowDividerDrag
;
299 bool mbInteractiveRowHeight
;
301 tools::Long nResizeX
; // mouse position at start of resizing
302 tools::Long nMinResizeX
; // never drag more left
303 tools::Long nDragX
; // last dragged column (MouseMove)
304 sal_uInt16 nResizeCol
; // resize this column in MouseMove
305 bool bResizing
; // mouse captured for column resizing
307 bool bSelect
; /// select or deselect
308 bool bSelectionIsVisible
; // depending on focus
309 bool bScrolling
; // hidden cursor while scrolling
310 bool bNotToggleSel
; // set while in ToggleSelection() etc.
311 bool bHasFocus
; // set/unset in Get/LoseFocus
312 bool bHideSelect
; // hide selection (highlight)
313 TriState bHideCursor
; // hide cursor (frame)
314 Range aSelRange
; // for selection expansion
316 ::std::vector
< std::unique_ptr
<BrowserColumn
> > mvCols
; // array of column-descriptions
319 MultiSelection
* pSel
; // selected rows for multi-selection
320 sal_Int32 nSel
; // selected row for single-selection
322 std::unique_ptr
<MultiSelection
> pColSel
; // selected column-ids
324 // fdo#83943, detect if making the cursor position visible is impossible to achieve
325 struct CursorMoveAttempt
329 bool m_bScrolledToReachCell
;
330 CursorMoveAttempt(sal_Int32 nCol
, sal_Int32 nRow
, bool bScrolledToReachCell
)
333 , m_bScrolledToReachCell(bScrolledToReachCell
)
336 bool operator==(const CursorMoveAttempt
& r
) const
338 return m_nCol
== r
.m_nCol
&&
339 m_nRow
== r
.m_nRow
&&
340 m_bScrolledToReachCell
== r
.m_bScrolledToReachCell
;
342 bool operator!=(const CursorMoveAttempt
& r
) const { return !(*this == r
); }
344 std::stack
<CursorMoveAttempt
>
347 ::std::unique_ptr
< ::svt::BrowseBoxImpl
> m_pImpl
; // impl structure of the BrowseBox object
349 bool m_bFocusOnlyCursor
; // hide cursor if we don't have the focus
350 Color m_aCursorColor
; // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor
351 BrowserMode m_nCurrentMode
; // last argument of SetMode (redundant, as our other members represent the current settings, too)
354 SVT_DLLPRIVATE
void ConstructImpl(BrowserMode nMode
);
355 SVT_DLLPRIVATE
void ExpandRowSelection( const BrowserMouseEvent
& rEvt
);
356 SVT_DLLPRIVATE
void ToggleSelection();
358 SVT_DLLPRIVATE
void UpdateScrollbars();
359 SVT_DLLPRIVATE
void AutoSizeLastColumn();
361 SVT_DLLPRIVATE
tools::Long
ImpGetDataRowHeight() const;
362 SVT_DLLPRIVATE
tools::Rectangle
ImplFieldRectPixel( sal_Int32 nRow
, sal_uInt16 nColId
) const;
363 SVT_DLLPRIVATE sal_uInt16
FrozenColCount() const;
365 SVT_DLLPRIVATE
void ColumnInserted( sal_uInt16 nPos
);
367 DECL_DLLPRIVATE_LINK(VertScrollHdl
, weld::Scrollbar
&, void);
368 DECL_DLLPRIVATE_LINK(HorzScrollHdl
, weld::Scrollbar
&, void);
369 DECL_DLLPRIVATE_LINK( StartDragHdl
, HeaderBar
*, void );
371 SVT_DLLPRIVATE
tools::Long
GetFrozenWidth() const;
373 SVT_DLLPRIVATE
tools::Long
GetBarHeight() const;
375 bool GoToRow(sal_Int32 nRow
, bool bRowColMove
, bool bDoNotModifySelection
= false );
377 bool GoToColumnId( sal_uInt16 nColId
, bool bMakeVisible
, bool bRowColMove
= false);
378 void SelectColumnPos( sal_uInt16 nCol
, bool _bSelect
, bool bMakeVisible
);
380 void ImplPaintData(OutputDevice
& _rOut
, const tools::Rectangle
& _rRect
, bool _bForeignDevice
);
382 bool PaintCursorIfHiddenOnce() const { return !m_bFocusOnlyCursor
&& !HasFocus(); }
384 sal_uInt16
ToggleSelectedColumn();
385 void SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId
);
388 /// retrieves the XAccessible implementation associated with the BrowseBox instance
389 ::vcl::IAccessibleFactory
& getAccessibleFactory();
392 bool m_bNavigationBar
;
394 sal_uInt16
ColCount() const;
396 // software plug for database access
397 // RowCount is counted automatically
398 // (with the help of RowInserted and RowRemoved), so overriding of
399 // the method is needless
401 virtual sal_Int32
GetRowCount() const override
;
404 // for display in VScrollBar set it e.g. on "?"
405 void SetRealRowCount( const OUString
&rRealRowCount
);
407 // Return Value has to be sal_True always - SeekRow *has* to work!
408 // (else ASSERT) MI: who integrated that? It must not be like that!
410 /** seeks for the given row position
414 virtual bool SeekRow( sal_Int32 nRow
) = 0;
416 void PaintData(vcl::Window
const & rWin
, vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
);
417 virtual void PaintField(vcl::RenderContext
& rDev
, const tools::Rectangle
& rRect
, sal_uInt16 nColumnId
) const = 0;
418 // Advice for the subclass: the visible scope of rows has changed.
419 // The subclass is able to announce changes of the model with the
420 // help of the methods RowInserted and RowRemoved. Because of the
421 // new status a paint is induced (SeekRow is called etc).
423 // parameters: nNewTopRow: number of the new TopRow (can get changed from
424 // VisibleRowsChanged by request of RowInserted and RowDeleted).
425 // nNumRows: number of visible rows (a partial visible row is counted too)
427 // Possible reason for changing the visible scope:
428 // - in front of the visible scope rows were inserted or removed, so the
429 // numbering of the visible scope has changed
430 // - Scrolling (and thereof resulting in another first visible row)
431 // - Resize the window
432 virtual void VisibleRowsChanged( sal_Int32 nNewTopRow
, sal_uInt16 nNumRows
);
434 // number of visible rows in the window (incl. "truncated" rows)
435 sal_uInt16
GetVisibleRows() const;
436 sal_Int32
GetTopRow() const { return nTopRow
; }
437 sal_uInt16
GetFirstVisibleColNumber() const { return nFirstCol
; }
439 // Focus-Rect enable / disable
442 short GetCursorHideCount() const;
444 virtual VclPtr
<BrowserHeader
> CreateHeaderBar( BrowseBox
* pParent
);
446 // HACK(virtual create is not called in Ctor)
447 void SetHeaderBar( BrowserHeader
* );
449 tools::Long
CalcReverseZoom(tools::Long nVal
) const;
451 const DataFlavorExVector
&
452 GetDataFlavors() const;
454 bool IsDropFormatSupported( SotClipboardFormatId nFormat
) const; // need this because the base class' IsDropFormatSupported is not const ...
456 void DisposeAccessible();
459 // callbacks for the data window
460 virtual void ImplStartTracking();
461 virtual void ImplEndTracking();
464 BrowseBox( vcl::Window
* pParent
, WinBits nBits
,
465 BrowserMode nMode
= BrowserMode::NONE
);
466 virtual ~BrowseBox() override
;
467 virtual void dispose() override
;
469 // override inherited handler
470 virtual void StateChanged( StateChangedType nStateChange
) override
;
471 virtual void MouseButtonDown( const MouseEvent
& rEvt
) override
;
472 virtual void MouseMove( const MouseEvent
& rEvt
) override
;
473 virtual void MouseButtonUp( const MouseEvent
& rEvt
) override
;
474 virtual void KeyInput( const KeyEvent
& rEvt
) override
;
475 virtual void LoseFocus() override
;
476 virtual void GetFocus() override
;
477 virtual void Resize() override
;
478 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
479 virtual void Draw( OutputDevice
* pDev
, const Point
& rPos
, SystemTextColorFlags nFlags
) override
;
480 virtual void Command( const CommandEvent
& rEvt
) override
;
481 virtual void StartDrag( sal_Int8 _nAction
, const Point
& _rPosPixel
) override
;
483 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
; // will forward everything got to the second AcceptDrop method
484 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
; // will forward everything got to the second ExecuteDrop method
486 virtual sal_Int8
AcceptDrop( const BrowserAcceptDropEvent
& rEvt
);
487 virtual sal_Int8
ExecuteDrop( const BrowserExecuteDropEvent
& rEvt
);
490 virtual void MouseButtonDown( const BrowserMouseEvent
& rEvt
);
491 virtual void MouseButtonUp( const BrowserMouseEvent
& rEvt
);
493 virtual void EndScroll();
494 virtual void Select();
495 virtual void DoubleClick( const BrowserMouseEvent
& rEvt
);
496 virtual bool IsCursorMoveAllowed( sal_Int32 nNewRow
, sal_uInt16 nNewColId
) const;
497 virtual void CursorMoved();
498 virtual void ColumnMoved( sal_uInt16 nColId
);
499 virtual void ColumnResized( sal_uInt16 nColId
);
500 /// called when the row height has been changed interactively
501 virtual void RowHeightChanged();
502 virtual tools::Long
QueryMinimumRowHeight();
504 // Window-Control (pass to DataWindow)
505 void SetUpdateMode( bool bUpdate
);
506 bool GetUpdateMode() const;
508 // map-mode and font control
509 void SetFont( const vcl::Font
& rNewFont
);
510 const vcl::Font
& GetFont() const;
511 void SetTitleFont( const vcl::Font
& rNewFont
)
512 { Control::SetFont( rNewFont
); }
514 // inserting, changing, removing and freezing of columns
515 void InsertHandleColumn( sal_uLong nWidth
);
516 void InsertDataColumn( sal_uInt16 nItemId
, const OUString
& rText
,
517 tools::Long nSize
, HeaderBarItemBits nBits
= HeaderBarItemBits::STDSTYLE
,
518 sal_uInt16 nPos
= HEADERBAR_APPEND
);
519 void SetColumnTitle( sal_uInt16 nColumnId
, const OUString
&rTitle
);
520 void SetColumnWidth( sal_uInt16 nColumnId
, sal_uLong nWidth
);
521 void SetColumnPos( sal_uInt16 nColumnId
, sal_uInt16 nPos
);
522 void FreezeColumn( sal_uInt16 nColumnId
);
523 void RemoveColumn( sal_uInt16 nColumnId
);
524 void RemoveColumns();
526 // control of title and data row height
527 void SetDataRowHeight( tools::Long nPixel
);
528 tools::Long
GetDataRowHeight() const;
529 void SetTitleLines( sal_uInt16 nLines
);
530 tools::Long
GetTitleHeight() const;
532 // access to dynamic values of cursor row
533 OUString
GetColumnTitle( sal_uInt16 nColumnId
) const;
534 tools::Rectangle
GetFieldRect( sal_uInt16 nColumnId
) const;
535 sal_uLong
GetColumnWidth( sal_uInt16 nColumnId
) const;
536 sal_uInt16
GetColumnId( sal_uInt16 nPos
) const;
537 sal_uInt16
GetColumnPos( sal_uInt16 nColumnId
) const;
538 bool IsFrozen( sal_uInt16 nColumnId
) const;
540 // movement of visible area
541 sal_Int32
ScrollColumns( sal_Int32 nColumns
);
542 sal_Int32
ScrollRows( sal_Int32 nRows
);
543 void MakeFieldVisible( sal_Int32 nRow
, sal_uInt16 nColId
);
545 // access and movement of cursor
546 sal_Int32
GetCurRow() const { return nCurRow
; }
547 sal_uInt16
GetCurColumnId() const { return nCurColId
; }
548 bool GoToRow( sal_Int32 nRow
);
549 bool GoToColumnId( sal_uInt16 nColId
);
550 bool GoToRowColumnId( sal_Int32 nRow
, sal_uInt16 nColId
);
553 virtual void SetNoSelection() override
;
554 virtual void SelectAll() override
;
555 virtual void SelectRow( sal_Int32 nRow
, bool _bSelect
= true, bool bExpand
= true ) override
;
556 void SelectColumnPos( sal_uInt16 nCol
, bool _bSelect
= true )
557 { SelectColumnPos( nCol
, _bSelect
, true); }
558 void SelectColumnId( sal_uInt16 nColId
)
559 { SelectColumnPos( GetColumnPos(nColId
), true, true); }
560 sal_Int32
GetSelectRowCount() const;
561 sal_uInt16
GetSelectColumnCount() const;
562 virtual bool IsRowSelected( sal_Int32 nRow
) const override
;
563 bool IsColumnSelected( sal_uInt16 nColumnId
) const;
564 sal_Int32
FirstSelectedRow();
565 sal_Int32
LastSelectedRow();
566 sal_Int32
NextSelectedRow();
567 const MultiSelection
* GetColumnSelection() const { return pColSel
.get(); }
568 const MultiSelection
* GetSelection() const
569 { return bMultiSelection
? uRow
.pSel
: nullptr; }
571 sal_Int32
FirstSelectedColumn( ) const;
573 bool IsResizing() const { return bResizing
; }
575 // access to positions of fields, column and rows
576 BrowserDataWin
& GetDataWindow() const;
577 tools::Rectangle
GetRowRectPixel( sal_Int32 nRow
) const;
578 tools::Rectangle
GetFieldRectPixel( sal_Int32 nRow
, sal_uInt16 nColId
,
579 bool bRelToBrowser
= true) const;
580 bool IsFieldVisible( sal_Int32 nRow
, sal_uInt16 nColId
,
581 bool bComplete
= false ) const;
582 sal_Int32
GetRowAtYPosPixel( tools::Long nY
,
583 bool bRelToBrowser
= true ) const;
584 sal_uInt16
GetColumnAtXPosPixel( tools::Long nX
) const;
588 void RowRemoved( sal_Int32 nRow
, sal_Int32 nNumRows
= 1, bool bDoPaint
= true );
589 void RowModified( sal_Int32 nRow
, sal_uInt16 nColId
= BROWSER_INVALIDID
);
590 void RowInserted( sal_Int32 nRow
, sal_Int32 nNumRows
= 1, bool bDoPaint
= true, bool bKeepSelection
= false );
593 bool ReserveControlArea(sal_uInt16 nWidth
= USHRT_MAX
);
594 tools::Rectangle
GetControlArea() const;
595 virtual bool ProcessKey(const KeyEvent
& rEvt
);
596 virtual void ChildFocusIn();
597 virtual void ChildFocusOut();
598 void Dispatch( sal_uInt16 nId
);
599 void SetMode( BrowserMode nMode
);
600 BrowserMode
GetMode( ) const { return m_nCurrentMode
; }
602 void SetCursorColor(const Color
& _rCol
);
604 /** specifies that the user is allowed to interactively change the height of a row,
605 by simply dragging an arbitrary row separator.
607 Note that this works only if there's a handle column, since only in this case,
608 there *is* something for the user to click onto
610 void EnableInteractiveRowHeight() { mbInteractiveRowHeight
= true; }
611 bool IsInteractiveRowHeightEnabled( ) const { return mbInteractiveRowHeight
; }
613 /// access to selected methods, to be granted to the BrowserColumn
614 struct BrowserColumnAccess
{ friend class BrowserColumn
; private: BrowserColumnAccess() { } };
615 /** public version of PaintField, with selected access rights for the BrowserColumn
617 void DoPaintField( OutputDevice
& rDev
, const tools::Rectangle
& rRect
, sal_uInt16 nColumnId
, BrowserColumnAccess
) const
618 { PaintField( rDev
, rRect
, nColumnId
); }
620 /** suggests a default width for a column containing a given text
622 The width is calculated so that the text fits completely, plus some margin.
624 sal_uLong
GetDefaultColumnWidth( const OUString
& _rText
) const;
626 /** GetCellText returns the text at the given position
628 the number of the row
632 the text out of the cell
634 virtual OUString
GetCellText(sal_Int32 _nRow
, sal_uInt16 _nColId
) const;
637 the current column count
639 sal_uInt16
GetColumnCount() const override
{ return ColCount(); }
641 /** commitBrowseBoxEvent commit the event at all listeners of the browsebox
649 void commitBrowseBoxEvent(sal_Int16 nEventId
,
650 const css::uno::Any
& rNewValue
,
651 const css::uno::Any
& rOldValue
);
653 /** commitTableEvent commit the event at all listeners of the table
661 void commitTableEvent(sal_Int16 nEventId
,
662 const css::uno::Any
& rNewValue
,
663 const css::uno::Any
& rOldValue
);
665 /** fires an AccessibleEvent relative to a header bar AccessibleContext
674 void commitHeaderBarEvent(sal_Int16 nEventId
,
675 const css::uno::Any
& rNewValue
,
676 const css::uno::Any
& rOldValue
,
677 bool _bColumnHeaderBar
680 /** returns the Rectangle for either the column header bar or the row header bar
682 <TRUE/> when column header bar is used
684 <TRUE/> when the rectangle should be calculated OnScreen
688 virtual tools::Rectangle
calcHeaderRect(bool _bIsColumnBar
, bool _bOnScreen
= true) override
;
690 /** calculates the Rectangle of the table
692 <TRUE/> when the rectangle should be calculated OnScreen
696 virtual tools::Rectangle
calcTableRect(bool _bOnScreen
= true) override
;
704 <TRUE/> when the rectangle should be calculated OnScreen
708 virtual tools::Rectangle
GetFieldRectPixelAbs(sal_Int32 _nRowId
, sal_uInt16 _nColId
, bool _bIsHeader
, bool _bOnScreen
= true) override
;
710 /// return <TRUE/> if and only if the accessible object for this instance has been created and is alive
711 bool isAccessibleAlive( ) const;
714 /** Creates and returns the accessible object of the whole BrowseBox. */
715 virtual css::uno::Reference
<
716 css::accessibility::XAccessible
> CreateAccessible() override
;
718 // Children ---------------------------------------------------------------
720 /** Creates the accessible object of a data table cell.
721 @param nRow The row index of the cell.
722 @param nColumnId The column pos of the cell.
723 @return The XAccessible interface of the specified cell. */
724 virtual css::uno::Reference
<
725 css::accessibility::XAccessible
>
726 CreateAccessibleCell( sal_Int32 nRow
, sal_uInt16 nColumnPos
) override
;
728 /** Creates the accessible object of a row header.
729 @param nRow The row index of the header.
730 @return The XAccessible interface of the specified row header. */
731 virtual css::uno::Reference
<
732 css::accessibility::XAccessible
>
733 CreateAccessibleRowHeader( sal_Int32 nRow
) override
;
735 /** Creates the accessible object of a column header.
736 @param nColumnId The column ID of the header.
737 @return The XAccessible interface of the specified column header. */
738 virtual css::uno::Reference
<
739 css::accessibility::XAccessible
>
740 CreateAccessibleColumnHeader( sal_uInt16 nColumnPos
) override
;
742 /** @return The count of additional controls of the control area. */
743 virtual sal_Int32
GetAccessibleControlCount() const override
;
745 /** Creates the accessible object of an additional control.
746 @param nIndex The 0-based index of the control.
747 @return The XAccessible interface of the specified control. */
748 virtual css::uno::Reference
<
749 css::accessibility::XAccessible
>
750 CreateAccessibleControl( sal_Int32 nIndex
) override
;
752 /** Converts a point relative to the data window origin to a cell address.
753 @param rnRow Out-parameter that takes the row index.
754 @param rnColumnId Out-parameter that takes the column ID.
755 @param rPoint The position in pixels relative to the data window.
756 @return <TRUE/>, if the point could be converted to a valid address. */
757 virtual bool ConvertPointToCellAddress(
758 sal_Int32
& rnRow
, sal_uInt16
& rnColumnId
, const Point
& rPoint
) override
;
760 /** Converts a point relative to the row header bar origin to a row header
762 @param rnRow Out-parameter that takes the row index.
763 @param rPoint The position in pixels relative to the header bar.
764 @return <TRUE/>, if the point could be converted to a valid index. */
765 virtual bool ConvertPointToRowHeader( sal_Int32
& rnRow
, const Point
& rPoint
) override
;
767 /** Converts a point relative to the column header bar origin to a column
769 @param rnColumnId Out-parameter that takes the column ID.
770 @param rPoint The position in pixels relative to the header bar.
771 @return <TRUE/>, if the point could be converted to a valid index. */
772 virtual bool ConvertPointToColumnHeader( sal_uInt16
& rnColumnPos
, const Point
& rPoint
) override
;
774 /** Converts a point relative to the BrowseBox origin to the index of an
776 @param rnRow Out-parameter that takes the 0-based control index.
777 @param rPoint The position in pixels relative to the BrowseBox.
778 @return <TRUE/>, if the point could be converted to a valid index. */
779 virtual bool ConvertPointToControlIndex( sal_Int32
& rnIndex
, const Point
& rPoint
) override
;
781 /** return the name of the specified object.
785 The position of a tablecell (index position), header bar column/row cell
787 The name of the specified object.
789 virtual OUString
GetAccessibleObjectName( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const override
;
791 /** return the description of the specified object.
795 The position of a tablecell (index position), header bar column/row cell
797 The description of the specified object.
799 virtual OUString
GetAccessibleObjectDescription( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const override
;
801 /** @return The header text of the specified row. */
802 virtual OUString
GetRowDescription( sal_Int32 nRow
) const override
;
804 /** @return The header text of the specified column. */
805 virtual OUString
GetColumnDescription( sal_uInt16 _nColumn
) const override
;
807 /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by
808 the accessible object), depending on the specified object type. */
809 virtual void FillAccessibleStateSet(
810 sal_Int64
& rStateSet
,
811 AccessibleBrowseBoxObjType eObjType
) const override
;
813 /** Fills the StateSet with all states for one cell (except DEFUNC and SHOWING, done by
814 the accessible object). */
815 virtual void FillAccessibleStateSetForCell(
816 sal_Int64
& _rStateSet
,
817 sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
819 /** Sets focus to current cell of the data table. */
820 virtual void GrabTableFocus() override
;
822 // IAccessibleTableProvider
823 virtual sal_Int32
GetCurrRow() const override
;
824 virtual sal_uInt16
GetCurrColumn() const override
;
825 virtual bool HasRowHeader() const override
;
826 virtual bool GoToCell( sal_Int32 _nRow
, sal_uInt16 _nColumn
) override
;
827 virtual void SelectColumn( sal_uInt16 _nColumn
, bool _bSelect
= true ) override
;
828 virtual bool IsColumnSelected( sal_Int32 _nColumn
) const override
;
829 virtual sal_Int32
GetSelectedRowCount() const override
;
830 virtual sal_Int32
GetSelectedColumnCount() const override
;
831 virtual void GetAllSelectedRows( css::uno::Sequence
< sal_Int32
>& _rRows
) const override
;
832 virtual void GetAllSelectedColumns( css::uno::Sequence
< sal_Int32
>& _rColumns
) const override
;
833 virtual bool IsCellVisible( sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
834 virtual OUString
GetAccessibleCellText(sal_Int32 _nRow
, sal_uInt16 _nColPos
) const override
;
835 virtual bool GetGlyphBoundRects( const Point
& rOrigin
, const OUString
& rStr
, int nIndex
, int nLen
, std::vector
< tools::Rectangle
>& rVector
) override
;
836 virtual tools::Rectangle
GetWindowExtentsRelative(const vcl::Window
*pRelativeWindow
) const override
;
837 virtual void GrabFocus() override
;
838 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetAccessible() override
;
839 virtual vcl::Window
* GetAccessibleParentWindow() const override
;
840 virtual vcl::Window
* GetWindowInstance() override
;
843 // the following declares some Window/OutputDevice methods private. This happened in the course
844 // of CWS warnings01, which pointed out nameclashs in those methods. If the build breaks in some
845 // upper module, you should investigate whether you really wanted to call base class methods,
846 // or the versions at this class. In the latter case, use the renamed versions above.
848 // ToTop/ToBottom were never property implemented. If you currently call it, this is most probably wrong
849 // and not doing as intended
853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */