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>
31 #include <vcl/svtaccessiblefactory.hxx>
38 #include <o3tl/typed_flags_set.hxx>
43 class MeasureStatusBar
;
50 class IAccessibleFactory
;
57 #define BROWSER_INVALIDID SAL_MAX_UINT16
58 constexpr sal_Int32 BROWSER_ENDOFSELECTION
= SFX_ENDOFSELECTION
;
60 enum class BrowserMode
63 COLUMNSELECTION
= 0x000001,
64 MULTISELECTION
= 0x000002,
65 KEEPHIGHLIGHT
= 0x000008,
69 HIDESELECT
= 0x000100,
70 HIDECURSOR
= 0x000200,
72 NO_HSCROLL
= 0x000400,
74 AUTO_VSCROLL
= 0x001000,
75 AUTO_HSCROLL
= 0x002000,
77 TRACKING_TIPS
= 0x004000,
79 NO_VSCROLL
= 0x008000,
81 HEADERBAR_NEW
= 0x040000,
82 AUTOSIZE_LASTCOL
= 0x080000,
84 CURSOR_WO_FOCUS
= 0x200000,
85 // Allows a cursor which is shown even if the control does not have the focus. This does not affect other
86 // situations which require to temporarily hide the cursor (such as scrolling).
91 template<> struct typed_flags
<BrowserMode
> : is_typed_flags
<BrowserMode
, 0x2cf73b> {};
94 #define BROWSER_NONE 0
95 #define BROWSER_SELECT 720
96 #define BROWSER_ENHANCESELECTION 722
97 #define BROWSER_SELECTDOWN 724
98 #define BROWSER_SELECTUP 725
99 #define BROWSER_CURSORDOWN 731
100 #define BROWSER_CURSORUP 732
101 #define BROWSER_CURSORLEFT 733
102 #define BROWSER_CURSORRIGHT 734
103 #define BROWSER_CURSORPAGEDOWN 735
104 #define BROWSER_CURSORPAGEUP 736
105 #define BROWSER_CURSORENDOFFILE 741
106 #define BROWSER_CURSORTOPOFFILE 742
107 #define BROWSER_CURSORENDOFSCREEN 743
108 #define BROWSER_CURSORTOPOFSCREEN 744
109 #define BROWSER_CURSORHOME 745
110 #define BROWSER_CURSOREND 746
111 #define BROWSER_SCROLLDOWN 751
112 #define BROWSER_SCROLLUP 752
113 #define BROWSER_SELECTHOME 753
114 #define BROWSER_SELECTEND 754
115 #define BROWSER_SELECTCOLUMN 755
116 #define BROWSER_MOVECOLUMNLEFT 756
117 #define BROWSER_MOVECOLUMNRIGHT 757
122 VclPtr
<vcl::Window
> pWin
;
123 tools::Rectangle aRect
;
129 BrowseEvent( vcl::Window
* pWindow
,
131 sal_uInt16 nColumn
, sal_uInt16 nColumnId
,
132 const tools::Rectangle
& rRect
);
134 vcl::Window
* GetWindow() const { return pWin
; }
135 sal_Int32
GetRow() const { return nRow
; }
136 sal_uInt16
GetColumn() const { return nCol
; }
137 sal_uInt16
GetColumnId() const { return nColId
; }
138 const tools::Rectangle
& GetRect() const { return aRect
; }
142 class BrowserMouseEvent
;
144 class BrowserDataWin final
146 ,public DragSourceHelper
147 ,public DropTargetHelper
150 VclPtr
<BrowserHeader
> pHeaderBar
; // only for BrowserMode::HEADERBAR_NEW
152 AutoTimer aMouseTimer
; // recalls MouseMove on dragging out
153 MouseEvent aRepeatEvt
; // a MouseEvent to repeat
154 Point aLastMousePos
; // prevents pseudo-MouseMoves
156 OUString aRealRowCount
; // to show in VScrollBar
158 std::vector
<tools::Rectangle
> aInvalidRegion
; // invalidated Rectangles during !UpdateMode
159 bool bInPaint
; // TRUE while in Paint
160 bool bInCommand
; // TRUE while in Command
161 bool bNoHScroll
; // no horizontal scrollbar
162 bool bNoVScroll
; // no vertical scrollbar
163 bool bAutoHScroll
; // autohide horizontaler Scrollbar
164 bool bAutoVScroll
; // autohide horizontaler Scrollbar
165 bool bUpdateMode
; // not SV-UpdateMode because of Invalidate()
166 bool bAutoSizeLastCol
; // last column always fills up window
167 bool bResizeOnPaint
; // outstanding resize-event
168 bool bUpdateOnUnlock
; // Update() while locked
169 bool bInUpdateScrollbars
; // prevents recursions
170 bool bHadRecursion
; // a recursion occurred
171 bool bCallingDropCallback
; // we're in a callback to AcceptDrop or ExecuteDrop currently
172 sal_uInt16 nUpdateLock
; // lock count, don't call Control::Update()!
173 short nCursorHidden
; // new counter for DoHide/ShowCursor
175 tools::Long m_nDragRowDividerLimit
;
176 tools::Long m_nDragRowDividerOffset
;
179 explicit BrowserDataWin( BrowseBox
* pParent
);
180 virtual ~BrowserDataWin() override
;
181 virtual void dispose() override
;
183 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
184 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
185 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
186 virtual void Command( const CommandEvent
& rEvt
) override
;
187 virtual void MouseButtonDown( const MouseEvent
& rEvt
) override
;
188 virtual void MouseMove( const MouseEvent
& rEvt
) override
;
189 DECL_LINK( RepeatedMouseMove
, Timer
*, void );
191 virtual void MouseButtonUp( const MouseEvent
& rEvt
) override
;
192 virtual void KeyInput( const KeyEvent
& rEvt
) override
;
193 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
195 // DropTargetHelper overridables
196 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
197 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
199 // DragSourceHelper overridables
200 virtual void StartDrag( sal_Int8 _nAction
, const Point
& _rPosPixel
) override
;
203 BrowseEvent
CreateBrowseEvent( const Point
& rPosPixel
);
204 BrowseBox
* GetParent() const;
205 const OUString
& GetRealRowCount() const { return aRealRowCount
; }
207 void SetUpdateMode( bool bMode
);
208 bool GetUpdateMode() const { return bUpdateMode
; }
209 void EnterUpdateLock() { ++nUpdateLock
; }
210 void LeaveUpdateLock();
212 void DoOutstandingInvalidations();
215 virtual void ImplInvalidate( const vcl::Region
* pRegion
, InvalidateFlags nFlags
) override
;
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
;
268 typedef ::std::map
<sal_Int32
, css::uno::Reference
<css::accessibility::XAccessible
>> THeaderCellMap
;
270 static const sal_uInt16 HandleColumnId
= 0;
273 VclPtr
<BrowserDataWin
> pDataWin
; // window to display data rows
274 VclPtr
<ScrollAdaptor
> pVScroll
; // vertical scrollbar
275 VclPtr
<ScrollAdaptor
> aHScroll
; // horizontal scrollbar
276 VclPtr
<MeasureStatusBar
> aStatusBarHeight
; // statusbar, just to measure its height
278 tools::Long m_nDataRowHeight
; // height of a single data-row
279 tools::Long m_nCornerHeight
; // height of scrollbox corner
280 tools::Long m_nCornerWidth
; // width of scrollbox corner
281 tools::Long m_nActualCornerWidth
; // size of scrollbox corner
282 sal_uInt16 nTitleLines
; // number of lines in title row
283 sal_uInt16 nControlAreaWidth
; // width of fixed area beneath hscroll
284 bool bColumnCursor
; // single columns and fields selectable
285 bool bMultiSelection
;// allow multiple selected rows
286 bool bKeepHighlight
; // don't hide selection on LoseFocus
288 bool bHLines
; // draw lines between rows
289 bool bVLines
; // draw lines between columns
290 bool bBootstrapped
; // child windows resized etc.
291 sal_Int32 nTopRow
; // no. of first visible row (0...)
292 sal_Int32 nCurRow
; // no. of row with cursor
293 sal_Int32 nRowCount
; // total number of rows in model
294 sal_uInt16 nFirstCol
; // no. of first visible scrollable column
295 sal_uInt16 nCurColId
; // column id of cursor
298 bool bRowDividerDrag
;
300 bool mbInteractiveRowHeight
;
302 tools::Long nResizeX
; // mouse position at start of resizing
303 tools::Long nMinResizeX
; // never drag more left
304 tools::Long nDragX
; // last dragged column (MouseMove)
305 sal_uInt16 nResizeCol
; // resize this column in MouseMove
306 bool bResizing
; // mouse captured for column resizing
308 bool bSelect
; /// select or deselect
309 bool bSelectionIsVisible
; // depending on focus
310 bool bScrolling
; // hidden cursor while scrolling
311 bool bNotToggleSel
; // set while in ToggleSelection() etc.
312 bool bHasFocus
; // set/unset in Get/LoseFocus
313 bool bHideSelect
; // hide selection (highlight)
314 TriState bHideCursor
; // hide cursor (frame)
315 Range aSelRange
; // for selection expansion
317 ::std::vector
< std::unique_ptr
<BrowserColumn
> > mvCols
; // array of column-descriptions
320 MultiSelection
* pSel
; // selected rows for multi-selection
321 sal_Int32 nSel
; // selected row for single-selection
323 std::unique_ptr
<MultiSelection
> pColSel
; // selected column-ids
325 // fdo#83943, detect if making the cursor position visible is impossible to achieve
326 struct CursorMoveAttempt
330 bool m_bScrolledToReachCell
;
331 CursorMoveAttempt(sal_Int32 nCol
, sal_Int32 nRow
, bool bScrolledToReachCell
)
334 , m_bScrolledToReachCell(bScrolledToReachCell
)
337 bool operator==(const CursorMoveAttempt
& r
) const
339 return m_nCol
== r
.m_nCol
&&
340 m_nRow
== r
.m_nRow
&&
341 m_bScrolledToReachCell
== r
.m_bScrolledToReachCell
;
343 bool operator!=(const CursorMoveAttempt
& r
) const { return !(*this == r
); }
345 std::stack
<CursorMoveAttempt
>
348 bool m_bFocusOnlyCursor
; // hide cursor if we don't have the focus
349 Color m_aCursorColor
; // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor
350 BrowserMode m_nCurrentMode
; // last argument of SetMode (redundant, as our other members represent the current settings, too)
352 vcl::AccessibleFactoryAccess m_aFactoryAccess
;
353 rtl::Reference
<vcl::IAccessibleBrowseBox
> m_pAccessible
;
355 THeaderCellMap m_aColHeaderCellMap
;
356 THeaderCellMap m_aRowHeaderCellMap
;
359 SVT_DLLPRIVATE
void ExpandRowSelection( const BrowserMouseEvent
& rEvt
);
360 SVT_DLLPRIVATE
void ToggleSelection();
362 SVT_DLLPRIVATE
void UpdateScrollbars();
363 SVT_DLLPRIVATE
void AutoSizeLastColumn();
365 SVT_DLLPRIVATE
tools::Long
ImpGetDataRowHeight() const;
366 SVT_DLLPRIVATE
tools::Rectangle
ImplFieldRectPixel( sal_Int32 nRow
, sal_uInt16 nColId
) const;
367 SVT_DLLPRIVATE sal_uInt16
FrozenColCount() const;
369 SVT_DLLPRIVATE
void ColumnInserted( sal_uInt16 nPos
);
371 DECL_DLLPRIVATE_LINK(VertScrollHdl
, weld::Scrollbar
&, void);
372 DECL_DLLPRIVATE_LINK(HorzScrollHdl
, weld::Scrollbar
&, void);
373 DECL_DLLPRIVATE_LINK( StartDragHdl
, HeaderBar
*, void );
375 SVT_DLLPRIVATE
tools::Long
GetFrozenWidth() const;
377 SVT_DLLPRIVATE
tools::Long
GetBarHeight() const;
379 bool GoToRow(sal_Int32 nRow
, bool bRowColMove
, bool bDoNotModifySelection
= false );
381 bool GoToColumnId( sal_uInt16 nColId
, bool bMakeVisible
, bool bRowColMove
= false);
382 void SelectColumnPos( sal_uInt16 nCol
, bool _bSelect
, bool bMakeVisible
);
384 SAL_DLLPRIVATE
void ImplPaintData(OutputDevice
& _rOut
, const tools::Rectangle
& _rRect
, bool _bForeignDevice
);
386 bool PaintCursorIfHiddenOnce() const { return !m_bFocusOnlyCursor
&& !HasFocus(); }
388 SAL_DLLPRIVATE sal_uInt16
ToggleSelectedColumn();
389 SAL_DLLPRIVATE
void SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId
);
391 /// @see AccessibleBrowseBox::getHeaderBar
392 css::uno::Reference
<css::accessibility::XAccessible
>
393 getAccessibleHeaderBar(AccessibleBrowseBoxObjType _eObjType
);
395 /// @see AccessibleBrowseBox::getTable
396 css::uno::Reference
<css::accessibility::XAccessible
>
397 getAccessibleTable();
400 /// retrieves the XAccessible implementation associated with the BrowseBox instance
401 SAL_DLLPRIVATE ::vcl::IAccessibleFactory
& getAccessibleFactory();
404 bool m_bNavigationBar
;
406 sal_uInt16
ColCount() const;
408 // software plug for database access
409 // RowCount is counted automatically
410 // (with the help of RowInserted and RowRemoved), so overriding of
411 // the method is needless
413 virtual sal_Int32
GetRowCount() const override
;
416 // for display in VScrollBar set it e.g. on "?"
417 void SetRealRowCount( const OUString
&rRealRowCount
);
419 // Return Value has to be sal_True always - SeekRow *has* to work!
420 // (else ASSERT) MI: who integrated that? It must not be like that!
422 /** seeks for the given row position
426 virtual bool SeekRow( sal_Int32 nRow
) = 0;
427 SAL_DLLPRIVATE
void DrawCursor();
428 SAL_DLLPRIVATE
void PaintData(vcl::Window
const & rWin
, vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
);
429 virtual void PaintField(vcl::RenderContext
& rDev
, const tools::Rectangle
& rRect
, sal_uInt16 nColumnId
) const = 0;
430 // Advice for the subclass: the visible scope of rows has changed.
431 // The subclass is able to announce changes of the model with the
432 // help of the methods RowInserted and RowRemoved. Because of the
433 // new status a paint is induced (SeekRow is called etc).
435 // parameters: nNewTopRow: number of the new TopRow (can get changed from
436 // VisibleRowsChanged by request of RowInserted and RowDeleted).
437 // nNumRows: number of visible rows (a partial visible row is counted too)
439 // Possible reason for changing the visible scope:
440 // - in front of the visible scope rows were inserted or removed, so the
441 // numbering of the visible scope has changed
442 // - Scrolling (and thereof resulting in another first visible row)
443 // - Resize the window
444 virtual void VisibleRowsChanged( sal_Int32 nNewTopRow
, sal_uInt16 nNumRows
);
446 // number of visible rows in the window (incl. "truncated" rows)
447 sal_uInt16
GetVisibleRows() const;
448 sal_Int32
GetTopRow() const { return nTopRow
; }
449 sal_uInt16
GetFirstVisibleColNumber() const { return nFirstCol
; }
451 // Focus-Rect enable / disable
452 SAL_DLLPRIVATE
void DoShowCursor();
453 SAL_DLLPRIVATE
void DoHideCursor();
454 SAL_DLLPRIVATE
short GetCursorHideCount() const;
456 virtual VclPtr
<BrowserHeader
> CreateHeaderBar( BrowseBox
* pParent
);
458 // HACK(virtual create is not called in Ctor)
459 void SetHeaderBar( BrowserHeader
* );
461 tools::Long
CalcReverseZoom(tools::Long nVal
) const;
463 const DataFlavorExVector
&
464 GetDataFlavors() const;
466 bool IsDropFormatSupported( SotClipboardFormatId nFormat
) const; // need this because the base class' IsDropFormatSupported is not const ...
468 void DisposeAccessible();
471 // callbacks for the data window
472 virtual void ImplStartTracking();
473 virtual void ImplEndTracking();
476 SAL_DLLPRIVATE
BrowseBox( vcl::Window
* pParent
, WinBits nBits
,
477 BrowserMode nMode
= BrowserMode::NONE
);
478 virtual ~BrowseBox() override
;
479 virtual void dispose() override
;
481 // override inherited handler
482 virtual void StateChanged( StateChangedType nStateChange
) override
;
483 virtual void MouseButtonDown( const MouseEvent
& rEvt
) override
;
484 virtual void MouseMove( const MouseEvent
& rEvt
) override
;
485 virtual void MouseButtonUp( const MouseEvent
& rEvt
) override
;
486 virtual void KeyInput( const KeyEvent
& rEvt
) override
;
487 virtual void LoseFocus() override
;
488 virtual void GetFocus() override
;
489 virtual void Resize() override
;
490 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
491 virtual void Draw( OutputDevice
* pDev
, const Point
& rPos
, SystemTextColorFlags nFlags
) override
;
492 virtual void Command( const CommandEvent
& rEvt
) override
;
493 virtual void StartDrag( sal_Int8 _nAction
, const Point
& _rPosPixel
) override
;
495 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
; // will forward everything got to the second AcceptDrop method
496 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
; // will forward everything got to the second ExecuteDrop method
498 virtual sal_Int8
AcceptDrop( const BrowserAcceptDropEvent
& rEvt
);
499 virtual sal_Int8
ExecuteDrop( const BrowserExecuteDropEvent
& rEvt
);
502 virtual void MouseButtonDown( const BrowserMouseEvent
& rEvt
);
503 virtual void MouseButtonUp( const BrowserMouseEvent
& rEvt
);
504 SAL_DLLPRIVATE
void StartScroll();
505 virtual void EndScroll();
506 virtual void Select();
507 virtual void DoubleClick( const BrowserMouseEvent
& rEvt
);
508 virtual bool IsCursorMoveAllowed( sal_Int32 nNewRow
, sal_uInt16 nNewColId
) const;
509 virtual void CursorMoved();
510 virtual void ColumnMoved( sal_uInt16 nColId
);
511 virtual void ColumnResized( sal_uInt16 nColId
);
512 /// called when the row height has been changed interactively
513 virtual void RowHeightChanged();
514 virtual tools::Long
QueryMinimumRowHeight();
516 // Window-Control (pass to DataWindow)
517 void SetUpdateMode( bool bUpdate
);
518 bool GetUpdateMode() const;
520 // map-mode and font control
521 void SetFont( const vcl::Font
& rNewFont
);
522 const vcl::Font
& GetFont() const;
523 void SetTitleFont( const vcl::Font
& rNewFont
)
524 { Control::SetFont( rNewFont
); }
526 // inserting, changing, removing and freezing of columns
527 void InsertHandleColumn( tools::Long nWidth
);
528 void InsertDataColumn( sal_uInt16 nItemId
, const OUString
& rText
,
529 tools::Long nSize
, HeaderBarItemBits nBits
= HeaderBarItemBits::STDSTYLE
,
530 sal_uInt16 nPos
= HEADERBAR_APPEND
);
531 void SetColumnTitle( sal_uInt16 nColumnId
, const OUString
&rTitle
);
532 void SetColumnWidth( sal_uInt16 nColumnId
, tools::Long nWidth
);
533 void SetColumnPos( sal_uInt16 nColumnId
, sal_uInt16 nPos
);
534 void FreezeColumn( sal_uInt16 nColumnId
);
535 void RemoveColumn( sal_uInt16 nColumnId
);
536 void RemoveColumns();
538 // control of title and data row height
539 void SetDataRowHeight( tools::Long nPixel
);
540 tools::Long
GetDataRowHeight() const;
541 void SetTitleLines( sal_uInt16 nLines
);
542 tools::Long
GetTitleHeight() const;
544 // access to dynamic values of cursor row
545 const OUString
& GetColumnTitle( sal_uInt16 nColumnId
) const;
546 tools::Rectangle
GetFieldRect( sal_uInt16 nColumnId
) const;
547 tools::Long
GetColumnWidth( sal_uInt16 nColumnId
) const;
548 sal_uInt16
GetColumnId( sal_uInt16 nPos
) const;
549 sal_uInt16
GetColumnPos( sal_uInt16 nColumnId
) const;
550 SAL_DLLPRIVATE
bool IsFrozen( sal_uInt16 nColumnId
) const;
552 // movement of visible area
553 SAL_DLLPRIVATE sal_Int32
ScrollColumns( sal_Int32 nColumns
);
554 SAL_DLLPRIVATE sal_Int32
ScrollRows( sal_Int32 nRows
);
555 void MakeFieldVisible( sal_Int32 nRow
, sal_uInt16 nColId
);
557 // access and movement of cursor
558 sal_Int32
GetCurRow() const { return nCurRow
; }
559 sal_uInt16
GetCurColumnId() const { return nCurColId
; }
560 bool GoToRow( sal_Int32 nRow
);
561 bool GoToColumnId( sal_uInt16 nColId
);
562 bool GoToRowColumnId( sal_Int32 nRow
, sal_uInt16 nColId
);
565 virtual void SetNoSelection() override
;
566 virtual void SelectAll() override
;
567 virtual void SelectRow( sal_Int32 nRow
, bool _bSelect
= true, bool bExpand
= true ) override
;
568 void SelectColumnPos( sal_uInt16 nCol
, bool _bSelect
= true )
569 { SelectColumnPos( nCol
, _bSelect
, true); }
570 void SelectColumnId( sal_uInt16 nColId
)
571 { SelectColumnPos( GetColumnPos(nColId
), true, true); }
572 sal_Int32
GetSelectRowCount() const;
573 sal_uInt16
GetSelectColumnCount() const;
574 virtual bool IsRowSelected( sal_Int32 nRow
) const override
;
575 bool IsColumnSelected( sal_uInt16 nColumnId
) const;
576 sal_Int32
FirstSelectedRow();
577 sal_Int32
LastSelectedRow();
578 sal_Int32
NextSelectedRow();
579 const MultiSelection
* GetColumnSelection() const { return pColSel
.get(); }
580 const MultiSelection
* GetSelection() const
581 { return bMultiSelection
? uRow
.pSel
: nullptr; }
583 sal_Int32
FirstSelectedColumn( ) const;
585 bool IsResizing() const { return bResizing
; }
587 // access to positions of fields, column and rows
588 BrowserDataWin
& GetDataWindow() const;
589 tools::Rectangle
GetRowRectPixel( sal_Int32 nRow
) const;
590 tools::Rectangle
GetFieldRectPixel( sal_Int32 nRow
, sal_uInt16 nColId
,
591 bool bRelToBrowser
= true) const;
592 SAL_DLLPRIVATE
bool IsFieldVisible( sal_Int32 nRow
, sal_uInt16 nColId
,
593 bool bComplete
= false ) const;
594 sal_Int32
GetRowAtYPosPixel( tools::Long nY
,
595 bool bRelToBrowser
= true ) const;
596 sal_uInt16
GetColumnAtXPosPixel( tools::Long nX
) const;
599 SAL_DLLPRIVATE
void Clear();
600 void RowRemoved( sal_Int32 nRow
, sal_Int32 nNumRows
= 1, bool bDoPaint
= true );
601 void RowModified( sal_Int32 nRow
, sal_uInt16 nColId
= BROWSER_INVALIDID
);
602 void RowInserted( sal_Int32 nRow
, sal_Int32 nNumRows
= 1, bool bDoPaint
= true, bool bKeepSelection
= false );
605 bool ReserveControlArea(sal_uInt16 nWidth
= USHRT_MAX
);
606 tools::Rectangle
GetControlArea() const;
607 virtual bool ProcessKey(const KeyEvent
& rEvt
);
608 virtual void ChildFocusIn();
609 virtual void ChildFocusOut();
610 SAL_DLLPRIVATE
void Dispatch( sal_uInt16 nId
);
611 void SetMode( BrowserMode nMode
);
612 BrowserMode
GetMode( ) const { return m_nCurrentMode
; }
614 void SetCursorColor(const Color
& _rCol
);
616 /** specifies that the user is allowed to interactively change the height of a row,
617 by simply dragging an arbitrary row separator.
619 Note that this works only if there's a handle column, since only in this case,
620 there *is* something for the user to click onto
622 void EnableInteractiveRowHeight() { mbInteractiveRowHeight
= true; }
623 bool IsInteractiveRowHeightEnabled( ) const { return mbInteractiveRowHeight
; }
625 /// access to selected methods, to be granted to the BrowserColumn
626 struct BrowserColumnAccess
{ friend class BrowserColumn
; private: BrowserColumnAccess() { } };
627 /** public version of PaintField, with selected access rights for the BrowserColumn
629 void DoPaintField( OutputDevice
& rDev
, const tools::Rectangle
& rRect
, sal_uInt16 nColumnId
, BrowserColumnAccess
) const
630 { PaintField( rDev
, rRect
, nColumnId
); }
632 /** suggests a default width for a column containing a given text
634 The width is calculated so that the text fits completely, plus some margin.
636 tools::Long
GetDefaultColumnWidth( const OUString
& _rText
) const;
638 /** GetCellText returns the text at the given position
640 the number of the row
644 the text out of the cell
646 virtual OUString
GetCellText(sal_Int32 _nRow
, sal_uInt16 _nColId
) const;
649 the current column count
651 sal_uInt16
GetColumnCount() const override
{ return ColCount(); }
653 /** commitBrowseBoxEvent commit the event at all listeners of the browsebox
661 SAL_DLLPRIVATE
void commitBrowseBoxEvent(sal_Int16 nEventId
,
662 const css::uno::Any
& rNewValue
,
663 const css::uno::Any
& rOldValue
);
665 /** commitTableEvent commit the event at all listeners of the table
673 SAL_DLLPRIVATE
void commitTableEvent(sal_Int16 nEventId
,
674 const css::uno::Any
& rNewValue
,
675 const css::uno::Any
& rOldValue
);
677 /** fires an AccessibleEvent relative to a header bar AccessibleContext
686 SAL_DLLPRIVATE
void commitHeaderBarEvent(sal_Int16 nEventId
,
687 const css::uno::Any
& rNewValue
,
688 const css::uno::Any
& rOldValue
,
689 bool _bColumnHeaderBar
692 /** returns the Rectangle for either the column header bar or the row header bar
694 <TRUE/> when column header bar is used
696 <TRUE/> when the rectangle should be calculated OnScreen
700 virtual tools::Rectangle
calcHeaderRect(bool _bIsColumnBar
, bool _bOnScreen
= true) override
;
702 /** calculates the Rectangle of the table
704 <TRUE/> when the rectangle should be calculated OnScreen
708 virtual tools::Rectangle
calcTableRect(bool _bOnScreen
= true) override
;
716 <TRUE/> when the rectangle should be calculated OnScreen
720 virtual tools::Rectangle
GetFieldRectPixel(sal_Int32 _nRowId
, sal_uInt16 _nColId
, bool _bIsHeader
, bool _bOnScreen
) override
;
722 /// return <TRUE/> if and only if the accessible object for this instance has been created and is alive
723 SAL_DLLPRIVATE
bool isAccessibleAlive( ) const;
726 /** Creates and returns the accessible object of the whole BrowseBox. */
727 virtual css::uno::Reference
<
728 css::accessibility::XAccessible
> CreateAccessible() override
;
730 // Children ---------------------------------------------------------------
732 /** Creates the accessible object of a data table cell.
733 @param nRow The row index of the cell.
734 @param nColumnId The column pos of the cell.
735 @return The XAccessible interface of the specified cell. */
736 virtual css::uno::Reference
<
737 css::accessibility::XAccessible
>
738 CreateAccessibleCell( sal_Int32 nRow
, sal_uInt16 nColumnPos
) override
;
740 /** Creates the accessible object of a row header.
741 @param nRow The row index of the header.
742 @return The XAccessible interface of the specified row header. */
743 virtual css::uno::Reference
<
744 css::accessibility::XAccessible
>
745 CreateAccessibleRowHeader( sal_Int32 nRow
) override
;
747 /** Creates the accessible object of a column header.
748 @param nColumnId The column ID of the header.
749 @return The XAccessible interface of the specified column header. */
750 virtual css::uno::Reference
<
751 css::accessibility::XAccessible
>
752 CreateAccessibleColumnHeader( sal_uInt16 nColumnPos
) override
;
754 /** @return The count of additional controls of the control area. */
755 virtual sal_Int32
GetAccessibleControlCount() const override
;
757 /** Creates the accessible object of an additional control.
758 @param nIndex The 0-based index of the control.
759 @return The XAccessible interface of the specified control. */
760 virtual css::uno::Reference
<
761 css::accessibility::XAccessible
>
762 CreateAccessibleControl( sal_Int32 nIndex
) override
;
764 /** Converts a point relative to the data window origin to a cell address.
765 @param rnRow Out-parameter that takes the row index.
766 @param rnColumnId Out-parameter that takes the column ID.
767 @param rPoint The position in pixels relative to the data window.
768 @return <TRUE/>, if the point could be converted to a valid address. */
769 virtual bool ConvertPointToCellAddress(
770 sal_Int32
& rnRow
, sal_uInt16
& rnColumnId
, const Point
& rPoint
) override
;
772 /** Converts a point relative to the row header bar origin to a row header
774 @param rnRow Out-parameter that takes the row index.
775 @param rPoint The position in pixels relative to the header bar.
776 @return <TRUE/>, if the point could be converted to a valid index. */
777 virtual bool ConvertPointToRowHeader( sal_Int32
& rnRow
, const Point
& rPoint
) override
;
779 /** Converts a point relative to the column header bar origin to a column
781 @param rnColumnId Out-parameter that takes the column ID.
782 @param rPoint The position in pixels relative to the header bar.
783 @return <TRUE/>, if the point could be converted to a valid index. */
784 virtual bool ConvertPointToColumnHeader( sal_uInt16
& rnColumnPos
, const Point
& rPoint
) override
;
786 /** Converts a point relative to the BrowseBox origin to the index of an
788 @param rnRow Out-parameter that takes the 0-based control index.
789 @param rPoint The position in pixels relative to the BrowseBox.
790 @return <TRUE/>, if the point could be converted to a valid index. */
791 virtual bool ConvertPointToControlIndex( sal_Int32
& rnIndex
, const Point
& rPoint
) override
;
793 /** return the name of the specified object.
797 The position of a tablecell (index position), header bar column/row cell
799 The name of the specified object.
801 virtual OUString
GetAccessibleObjectName( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const override
;
803 /** return the description of the specified object.
807 The position of a tablecell (index position), header bar column/row cell
809 The description of the specified object.
811 virtual OUString
GetAccessibleObjectDescription( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const override
;
813 /** @return The header text of the specified row. */
814 virtual OUString
GetRowDescription( sal_Int32 nRow
) const override
;
816 /** @return The header text of the specified column. */
817 virtual OUString
GetColumnDescription( sal_uInt16 _nColumn
) const override
;
819 /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by
820 the accessible object), depending on the specified object type. */
821 virtual void FillAccessibleStateSet(
822 sal_Int64
& rStateSet
,
823 AccessibleBrowseBoxObjType eObjType
) const override
;
825 /** Fills the StateSet with all states for one cell (except DEFUNC and SHOWING, done by
826 the accessible object). */
827 virtual void FillAccessibleStateSetForCell(
828 sal_Int64
& _rStateSet
,
829 sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
831 /** Sets focus to current cell of the data table. */
832 virtual void GrabTableFocus() override
;
834 // IAccessibleTableProvider
835 virtual sal_Int32
GetCurrRow() const override
;
836 virtual sal_uInt16
GetCurrColumn() const override
;
837 virtual bool HasRowHeader() const override
;
838 virtual bool GoToCell( sal_Int32 _nRow
, sal_uInt16 _nColumn
) override
;
839 virtual void SelectColumn( sal_uInt16 _nColumn
, bool _bSelect
= true ) override
;
840 virtual bool IsColumnSelected( sal_Int32 _nColumn
) const override
;
841 virtual sal_Int32
GetSelectedRowCount() const override
;
842 virtual sal_Int32
GetSelectedColumnCount() const override
;
843 virtual void GetAllSelectedRows( css::uno::Sequence
< sal_Int32
>& _rRows
) const override
;
844 virtual void GetAllSelectedColumns( css::uno::Sequence
< sal_Int32
>& _rColumns
) const override
;
845 virtual bool IsCellVisible( sal_Int32 _nRow
, sal_uInt16 _nColumn
) const override
;
846 virtual OUString
GetAccessibleCellText(sal_Int32 _nRow
, sal_uInt16 _nColPos
) const override
;
847 virtual bool GetGlyphBoundRects( const Point
& rOrigin
, const OUString
& rStr
, int nIndex
, int nLen
, std::vector
< tools::Rectangle
>& rVector
) override
;
848 virtual AbsoluteScreenPixelRectangle
GetWindowExtentsAbsolute() const override
;
849 virtual tools::Rectangle
GetWindowExtentsRelative(const vcl::Window
& rRelativeWindow
) const override
;
850 virtual void GrabFocus() override
;
851 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetAccessible() override
;
852 virtual vcl::Window
* GetAccessibleParentWindow() const override
;
853 virtual vcl::Window
* GetWindowInstance() override
;
856 // the following declares some Window/OutputDevice methods private. This happened in the course
857 // of CWS warnings01, which pointed out nameclashs in those methods. If the build breaks in some
858 // upper module, you should investigate whether you really wanted to call base class methods,
859 // or the versions at this class. In the latter case, use the renamed versions above.
861 // ToTop/ToBottom were never property implemented. If you currently call it, this is most probably wrong
862 // and not doing as intended
866 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */