/src/libreoffice/include/svtools/brwbox.hxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #pragma once |
20 | | |
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/accessibility/AccessibleBrowseBox.hxx> |
30 | | #include <vcl/accessibility/AccessibleBrowseBoxObjType.hxx> |
31 | | #include <vcl/accessibletableprovider.hxx> |
32 | | #include <vector> |
33 | | #include <stack> |
34 | | |
35 | | #include <limits.h> |
36 | | #include <map> |
37 | | #include <memory> |
38 | | #include <o3tl/typed_flags_set.hxx> |
39 | | |
40 | | class BrowserColumn; |
41 | | class BrowserHeader; |
42 | | class ScrollAdaptor; |
43 | | class MeasureStatusBar; |
44 | | |
45 | | namespace weld { |
46 | | class Scrollbar; |
47 | | } |
48 | | |
49 | 0 | #define BROWSER_INVALIDID SAL_MAX_UINT16 |
50 | | constexpr sal_Int32 BROWSER_ENDOFSELECTION = SFX_ENDOFSELECTION; |
51 | | |
52 | | enum class BrowserMode |
53 | | { |
54 | | NONE = 0x000000, |
55 | | COLUMNSELECTION = 0x000001, |
56 | | MULTISELECTION = 0x000002, |
57 | | KEEPHIGHLIGHT = 0x000008, |
58 | | HLINES = 0x000010, |
59 | | VLINES = 0x000020, |
60 | | |
61 | | HIDESELECT = 0x000100, |
62 | | HIDECURSOR = 0x000200, |
63 | | |
64 | | NO_HSCROLL = 0x000400, |
65 | | |
66 | | AUTO_VSCROLL = 0x001000, |
67 | | AUTO_HSCROLL = 0x002000, |
68 | | |
69 | | TRACKING_TIPS = 0x004000, |
70 | | |
71 | | NO_VSCROLL = 0x008000, |
72 | | |
73 | | HEADERBAR_NEW = 0x040000, |
74 | | AUTOSIZE_LASTCOL = 0x080000, |
75 | | |
76 | | CURSOR_WO_FOCUS = 0x200000, |
77 | | // Allows a cursor which is shown even if the control does not have the focus. This does not affect other |
78 | | // situations which require to temporarily hide the cursor (such as scrolling). |
79 | | |
80 | | }; |
81 | | namespace o3tl |
82 | | { |
83 | | template<> struct typed_flags<BrowserMode> : is_typed_flags<BrowserMode, 0x2cf73b> {}; |
84 | | } |
85 | | |
86 | | enum class BrowserDispatchId |
87 | | { |
88 | | NONE, |
89 | | SELECT, |
90 | | ENHANCESELECTION, |
91 | | SELECTDOWN, |
92 | | SELECTUP, |
93 | | CURSORDOWN, |
94 | | CURSORUP, |
95 | | CURSORLEFT, |
96 | | CURSORRIGHT, |
97 | | CURSORPAGEDOWN, |
98 | | CURSORPAGEUP, |
99 | | CURSORENDOFFILE, |
100 | | CURSORTOPOFFILE, |
101 | | CURSORENDOFSCREEN, |
102 | | CURSORTOPOFSCREEN, |
103 | | CURSORHOME, |
104 | | CURSOREND, |
105 | | SCROLLDOWN, |
106 | | SCROLLUP, |
107 | | SELECTHOME, |
108 | | SELECTEND, |
109 | | SELECTCOLUMN, |
110 | | MOVECOLUMNLEFT, |
111 | | MOVECOLUMNRIGHT, |
112 | | }; |
113 | | |
114 | | class BrowseEvent |
115 | | { |
116 | | VclPtr<vcl::Window> pWin; |
117 | | tools::Rectangle aRect; |
118 | | sal_Int32 nRow; |
119 | | sal_uInt16 nCol; |
120 | | sal_uInt16 nColId; |
121 | | |
122 | | public: |
123 | | BrowseEvent( vcl::Window* pWindow, |
124 | | sal_Int32 nAbsRow, |
125 | | sal_uInt16 nColumn, sal_uInt16 nColumnId, |
126 | | const tools::Rectangle& rRect ); |
127 | | |
128 | 0 | vcl::Window* GetWindow() const { return pWin; } |
129 | 0 | sal_Int32 GetRow() const { return nRow; } |
130 | 0 | sal_uInt16 GetColumn() const { return nCol; } |
131 | 0 | sal_uInt16 GetColumnId() const { return nColId; } |
132 | 0 | const tools::Rectangle& GetRect() const { return aRect; } |
133 | | }; |
134 | | |
135 | | class BrowseBox; |
136 | | class BrowserMouseEvent; |
137 | | |
138 | | class BrowserDataWin final |
139 | | :public Control |
140 | | ,public DragSourceHelper |
141 | | ,public DropTargetHelper |
142 | | { |
143 | | public: |
144 | | VclPtr<BrowserHeader> pHeaderBar; // only for BrowserMode::HEADERBAR_NEW |
145 | | bool bInDtor; |
146 | | AutoTimer aMouseTimer; // recalls MouseMove on dragging out |
147 | | MouseEvent aRepeatEvt; // a MouseEvent to repeat |
148 | | Point aLastMousePos; // prevents pseudo-MouseMoves |
149 | | |
150 | | OUString aRealRowCount; // to show in VScrollBar |
151 | | |
152 | | std::vector<tools::Rectangle> aInvalidRegion; // invalidated Rectangles during !UpdateMode |
153 | | bool bInPaint; // TRUE while in Paint |
154 | | bool bInCommand; // TRUE while in Command |
155 | | bool bNoHScroll; // no horizontal scrollbar |
156 | | bool bNoVScroll; // no vertical scrollbar |
157 | | bool bAutoHScroll; // autohide horizontaler Scrollbar |
158 | | bool bAutoVScroll; // autohide horizontaler Scrollbar |
159 | | bool bUpdateMode; // not SV-UpdateMode because of Invalidate() |
160 | | bool bAutoSizeLastCol; // last column always fills up window |
161 | | bool bResizeOnPaint; // outstanding resize-event |
162 | | bool bUpdateOnUnlock; // Update() while locked |
163 | | bool bInUpdateScrollbars; // prevents recursions |
164 | | bool bHadRecursion; // a recursion occurred |
165 | | bool bCallingDropCallback; // we're in a callback to AcceptDrop or ExecuteDrop currently |
166 | | sal_uInt16 nUpdateLock; // lock count, don't call Control::Update()! |
167 | | short nCursorHidden; // new counter for DoHide/ShowCursor |
168 | | |
169 | | tools::Long m_nDragRowDividerLimit; |
170 | | tools::Long m_nDragRowDividerOffset; |
171 | | |
172 | | public: |
173 | | explicit BrowserDataWin( BrowseBox* pParent ); |
174 | | virtual ~BrowserDataWin() override; |
175 | | virtual void dispose() override; |
176 | | |
177 | | virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; |
178 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
179 | | virtual void RequestHelp( const HelpEvent& rHEvt ) override; |
180 | | virtual void Command( const CommandEvent& rEvt ) override; |
181 | | virtual void MouseButtonDown( const MouseEvent& rEvt ) override; |
182 | | virtual void MouseMove( const MouseEvent& rEvt ) override; |
183 | | DECL_LINK( RepeatedMouseMove, Timer *, void ); |
184 | | |
185 | | virtual void MouseButtonUp( const MouseEvent& rEvt ) override; |
186 | | virtual void KeyInput( const KeyEvent& rEvt ) override; |
187 | | virtual void Tracking( const TrackingEvent& rTEvt ) override; |
188 | | |
189 | | // DropTargetHelper overridables |
190 | | virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; |
191 | | virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; |
192 | | |
193 | | // DragSourceHelper overridables |
194 | | virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) override; |
195 | | |
196 | | |
197 | | BrowseEvent CreateBrowseEvent( const Point& rPosPixel ); |
198 | | BrowseBox* GetParent() const; |
199 | 0 | const OUString& GetRealRowCount() const { return aRealRowCount; } |
200 | | |
201 | | void SetUpdateMode( bool bMode ); |
202 | 0 | bool GetUpdateMode() const { return bUpdateMode; } |
203 | 0 | void EnterUpdateLock() { ++nUpdateLock; } |
204 | | void LeaveUpdateLock(); |
205 | | void Update(); |
206 | | void DoOutstandingInvalidations(); |
207 | | |
208 | | private: |
209 | | virtual void ImplInvalidate( const vcl::Region* pRegion, InvalidateFlags nFlags ) override; |
210 | | void StartRowDividerDrag( const Point& _rStartPos ); |
211 | | bool ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent ) const; |
212 | | }; |
213 | | |
214 | | class BrowserMouseEvent: public MouseEvent, public BrowseEvent |
215 | | { |
216 | | public: |
217 | | BrowserMouseEvent( BrowserDataWin* pWin, const MouseEvent& rEvt ); |
218 | | BrowserMouseEvent( vcl::Window* pWin, const MouseEvent& rEvt, |
219 | | sal_Int32 nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId, |
220 | | const tools::Rectangle& rRect ); |
221 | | }; |
222 | | |
223 | | |
224 | | class BrowserAcceptDropEvent : public AcceptDropEvent, public BrowseEvent |
225 | | { |
226 | | public: |
227 | | BrowserAcceptDropEvent( BrowserDataWin* pWin, const AcceptDropEvent& rEvt ); |
228 | | }; |
229 | | |
230 | | |
231 | | class BrowserExecuteDropEvent : public ExecuteDropEvent, public BrowseEvent |
232 | | { |
233 | | public: |
234 | | BrowserExecuteDropEvent( BrowserDataWin* pWin, const ExecuteDropEvent& rEvt ); |
235 | | }; |
236 | | |
237 | | // TODO |
238 | | // The whole selection thingie in this class is somewhat... suspicious to me. |
239 | | // some oddities: |
240 | | // * method parameters named like members (and used in both semantics within the method!) |
241 | | // * the multi selection flag is sometimes used as if it is for row selection, sometimes as if |
242 | | // it's for column selection, too (and sometimes in an even stranger way :) |
243 | | // * it is not really defined like all these hundreds selection related flags/methods work together |
244 | | // and influence each other. I do not understand it very well, but this may be my fault :) |
245 | | // * There is a GetColumnSelection, but it can't be used to determine the selected columns (at least |
246 | | // not without a const_cast) |
247 | | // |
248 | | // We should clearly define this somewhere in the future. Or, even better, we should re-implement this |
249 | | // whole class, which is planned for a long time :) |
250 | | // |
251 | | // sorry for the ranting. could not resist |
252 | | |
253 | | class SVT_DLLPUBLIC BrowseBox |
254 | | :public Control |
255 | | ,public DragSourceHelper |
256 | | ,public DropTargetHelper |
257 | | ,public vcl::IAccessibleTableProvider |
258 | | { |
259 | | friend class BrowserDataWin; |
260 | | |
261 | | public: |
262 | | typedef ::std::map<sal_Int32, css::uno::Reference<css::accessibility::XAccessible>> THeaderCellMap; |
263 | | |
264 | | static const sal_uInt16 HandleColumnId = 0; |
265 | | |
266 | | private: |
267 | | VclPtr<BrowserDataWin> pDataWin; // window to display data rows |
268 | | VclPtr<ScrollAdaptor> pVScroll; // vertical scrollbar |
269 | | VclPtr<ScrollAdaptor> aHScroll; // horizontal scrollbar |
270 | | VclPtr<MeasureStatusBar> aStatusBarHeight; // statusbar, just to measure its height |
271 | | |
272 | | tools::Long m_nDataRowHeight; // height of a single data-row |
273 | | tools::Long m_nCornerHeight; // height of scrollbox corner |
274 | | tools::Long m_nCornerWidth; // width of scrollbox corner |
275 | | tools::Long m_nActualCornerWidth; // size of scrollbox corner |
276 | | sal_uInt16 nTitleLines; // number of lines in title row |
277 | | sal_uInt16 nControlAreaWidth; // width of fixed area beneath hscroll |
278 | | bool bColumnCursor; // single columns and fields selectable |
279 | | bool bMultiSelection;// allow multiple selected rows |
280 | | bool bKeepHighlight; // don't hide selection on LoseFocus |
281 | | |
282 | | bool bHLines; // draw lines between rows |
283 | | bool bVLines; // draw lines between columns |
284 | | bool bBootstrapped; // child windows resized etc. |
285 | | sal_Int32 nTopRow; // no. of first visible row (0...) |
286 | | sal_Int32 nCurRow; // no. of row with cursor |
287 | | sal_Int32 nRowCount; // total number of rows in model |
288 | | sal_uInt16 nFirstCol; // no. of first visible scrollable column |
289 | | sal_uInt16 nCurColId; // column id of cursor |
290 | | |
291 | | bool bSelecting; |
292 | | bool bRowDividerDrag; |
293 | | bool bHit; |
294 | | bool mbInteractiveRowHeight; |
295 | | |
296 | | tools::Long nResizeX; // mouse position at start of resizing |
297 | | tools::Long nMinResizeX; // never drag more left |
298 | | tools::Long nDragX; // last dragged column (MouseMove) |
299 | | sal_uInt16 nResizeCol; // resize this column in MouseMove |
300 | | bool bResizing; // mouse captured for column resizing |
301 | | |
302 | | bool bSelect; /// select or deselect |
303 | | bool bSelectionIsVisible; // depending on focus |
304 | | bool bScrolling; // hidden cursor while scrolling |
305 | | bool bNotToggleSel; // set while in ToggleSelection() etc. |
306 | | bool bHasFocus; // set/unset in Get/LoseFocus |
307 | | bool bHideSelect; // hide selection (highlight) |
308 | | TriState bHideCursor; // hide cursor (frame) |
309 | | Range aSelRange; // for selection expansion |
310 | | |
311 | | ::std::vector< std::unique_ptr<BrowserColumn> > mvCols; // array of column-descriptions |
312 | | union |
313 | | { |
314 | | MultiSelection* pSel; // selected rows for multi-selection |
315 | | sal_Int32 nSel; // selected row for single-selection |
316 | | } uRow; |
317 | | std::unique_ptr<MultiSelection> pColSel; // selected column-ids |
318 | | |
319 | | // fdo#83943, detect if making the cursor position visible is impossible to achieve |
320 | | struct CursorMoveAttempt |
321 | | { |
322 | | sal_Int32 m_nCol; |
323 | | sal_Int32 m_nRow; |
324 | | bool m_bScrolledToReachCell; |
325 | | CursorMoveAttempt(sal_Int32 nCol, sal_Int32 nRow, bool bScrolledToReachCell) |
326 | 0 | : m_nCol(nCol) |
327 | 0 | , m_nRow(nRow) |
328 | 0 | , m_bScrolledToReachCell(bScrolledToReachCell) |
329 | 0 | { |
330 | 0 | } |
331 | | bool operator==(const CursorMoveAttempt& r) const |
332 | 0 | { |
333 | 0 | return m_nCol == r.m_nCol && |
334 | 0 | m_nRow == r.m_nRow && |
335 | 0 | m_bScrolledToReachCell == r.m_bScrolledToReachCell; |
336 | 0 | } |
337 | 0 | bool operator!=(const CursorMoveAttempt& r) const { return !(*this == r); } |
338 | | }; |
339 | | std::stack<CursorMoveAttempt> |
340 | | m_aGotoStack; |
341 | | |
342 | | bool m_bFocusOnlyCursor; // hide cursor if we don't have the focus |
343 | | Color m_aCursorColor; // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor |
344 | | BrowserMode m_nCurrentMode; // last argument of SetMode (redundant, as our other members represent the current settings, too) |
345 | | |
346 | | rtl::Reference<AccessibleBrowseBox> m_xAccessible; |
347 | | |
348 | | THeaderCellMap m_aColHeaderCellMap; |
349 | | THeaderCellMap m_aRowHeaderCellMap; |
350 | | |
351 | | private: |
352 | | SVT_DLLPRIVATE void ExpandRowSelection( const BrowserMouseEvent& rEvt ); |
353 | | SVT_DLLPRIVATE void ToggleSelection(); |
354 | | |
355 | | SVT_DLLPRIVATE void UpdateScrollbars(); |
356 | | SVT_DLLPRIVATE void AutoSizeLastColumn(); |
357 | | |
358 | | SVT_DLLPRIVATE tools::Long ImpGetDataRowHeight() const; |
359 | | SVT_DLLPRIVATE tools::Rectangle ImplFieldRectPixel( sal_Int32 nRow, sal_uInt16 nColId ) const; |
360 | | SVT_DLLPRIVATE sal_uInt16 FrozenColCount() const; |
361 | | |
362 | | SVT_DLLPRIVATE void ColumnInserted( sal_uInt16 nPos ); |
363 | | |
364 | | DECL_DLLPRIVATE_LINK(VertScrollHdl, weld::Scrollbar&, void); |
365 | | DECL_DLLPRIVATE_LINK(HorzScrollHdl, weld::Scrollbar&, void); |
366 | | DECL_DLLPRIVATE_LINK( StartDragHdl, HeaderBar*, void ); |
367 | | |
368 | | SVT_DLLPRIVATE tools::Long GetFrozenWidth() const; |
369 | | |
370 | | SVT_DLLPRIVATE tools::Long GetBarHeight() const; |
371 | | |
372 | | bool GoToRow(sal_Int32 nRow, bool bRowColMove, bool bDoNotModifySelection = false ); |
373 | | |
374 | | bool GoToColumnId( sal_uInt16 nColId, bool bMakeVisible, bool bRowColMove = false); |
375 | | void SelectColumnPos( sal_uInt16 nCol, bool _bSelect, bool bMakeVisible); |
376 | | |
377 | | SAL_DLLPRIVATE void ImplPaintData(OutputDevice& _rOut, const tools::Rectangle& _rRect, bool _bForeignDevice); |
378 | | |
379 | 0 | bool PaintCursorIfHiddenOnce() const { return !m_bFocusOnlyCursor && !HasFocus(); } |
380 | | |
381 | | SAL_DLLPRIVATE sal_uInt16 ToggleSelectedColumn(); |
382 | | SAL_DLLPRIVATE void SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId); |
383 | | |
384 | | /// @see AccessibleBrowseBox::getHeaderBar |
385 | | css::uno::Reference<css::accessibility::XAccessible> |
386 | | getAccessibleHeaderBar(AccessibleBrowseBoxObjType _eObjType); |
387 | | |
388 | | css::uno::Reference<css::accessibility::XAccessible> |
389 | | getAccessibleHeaderCell(BrowseBox::THeaderCellMap& _raHeaderCells, sal_Int32 _nPos, |
390 | | AccessibleBrowseBoxObjType _eType, |
391 | | const css::uno::Reference<css::accessibility::XAccessible>& _rParent); |
392 | | |
393 | | /// @see AccessibleBrowseBox::getTable |
394 | | css::uno::Reference<css::accessibility::XAccessible> |
395 | | getAccessibleTable(); |
396 | | |
397 | | protected: |
398 | | bool m_bNavigationBar; |
399 | | |
400 | | sal_uInt16 ColCount() const; |
401 | | |
402 | | // software plug for database access |
403 | | // RowCount is counted automatically |
404 | | // (with the help of RowInserted and RowRemoved), so overriding of |
405 | | // the method is needless |
406 | | public: |
407 | | virtual sal_Int32 GetRowCount() const override; |
408 | | |
409 | | protected: |
410 | | // for display in VScrollBar set it e.g. on "?" |
411 | | void SetRealRowCount( const OUString &rRealRowCount ); |
412 | | |
413 | | // Return Value has to be sal_True always - SeekRow *has* to work! |
414 | | // (else ASSERT) MI: who integrated that? It must not be like that! |
415 | | |
416 | | /** seeks for the given row position |
417 | | @param nRow |
418 | | nRow starts at 0 |
419 | | */ |
420 | | virtual bool SeekRow( sal_Int32 nRow ) = 0; |
421 | | SAL_DLLPRIVATE void DrawCursor(); |
422 | | SAL_DLLPRIVATE void PaintData(vcl::Window const & rWin, vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); |
423 | | virtual void PaintField(vcl::RenderContext& rDev, const tools::Rectangle& rRect, sal_uInt16 nColumnId) const = 0; |
424 | | // Advice for the subclass: the visible scope of rows has changed. |
425 | | // The subclass is able to announce changes of the model with the |
426 | | // help of the methods RowInserted and RowRemoved. Because of the |
427 | | // new status a paint is induced (SeekRow is called etc). |
428 | | // |
429 | | // parameters: nNewTopRow: number of the new TopRow (can get changed from |
430 | | // VisibleRowsChanged by request of RowInserted and RowDeleted). |
431 | | // nNumRows: number of visible rows (a partial visible row is counted too) |
432 | | // |
433 | | // Possible reason for changing the visible scope: |
434 | | // - in front of the visible scope rows were inserted or removed, so the |
435 | | // numbering of the visible scope has changed |
436 | | // - Scrolling (and thereof resulting in another first visible row) |
437 | | // - Resize the window |
438 | | virtual void VisibleRowsChanged( sal_Int32 nNewTopRow, sal_uInt16 nNumRows); |
439 | | |
440 | | // number of visible rows in the window (incl. "truncated" rows) |
441 | | sal_uInt16 GetVisibleRows() const; |
442 | 0 | sal_Int32 GetTopRow() const { return nTopRow; } |
443 | 0 | sal_uInt16 GetFirstVisibleColNumber() const { return nFirstCol; } |
444 | | |
445 | | // Focus-Rect enable / disable |
446 | | SAL_DLLPRIVATE void DoShowCursor(); |
447 | | SAL_DLLPRIVATE void DoHideCursor(); |
448 | | SAL_DLLPRIVATE short GetCursorHideCount() const; |
449 | | |
450 | | virtual VclPtr<BrowserHeader> CreateHeaderBar( BrowseBox* pParent ); |
451 | | |
452 | | // HACK(virtual create is not called in Ctor) |
453 | | void SetHeaderBar( BrowserHeader* ); |
454 | | |
455 | | tools::Long CalcReverseZoom(tools::Long nVal) const; |
456 | | |
457 | | const DataFlavorExVector& |
458 | | GetDataFlavors() const; |
459 | | |
460 | | bool IsDropFormatSupported( SotClipboardFormatId nFormat ) const; // need this because the base class' IsDropFormatSupported is not const ... |
461 | | |
462 | | void DisposeAccessible(); |
463 | | |
464 | | protected: |
465 | | // callbacks for the data window |
466 | | virtual void ImplStartTracking(); |
467 | | virtual void ImplEndTracking(); |
468 | | |
469 | | public: |
470 | | SAL_DLLPRIVATE BrowseBox( vcl::Window* pParent, WinBits nBits, |
471 | | BrowserMode nMode = BrowserMode::NONE ); |
472 | | virtual ~BrowseBox() override; |
473 | | virtual void dispose() override; |
474 | | |
475 | | // override inherited handler |
476 | | virtual void StateChanged( StateChangedType nStateChange ) override; |
477 | | virtual void MouseButtonDown( const MouseEvent& rEvt ) override; |
478 | | virtual void MouseMove( const MouseEvent& rEvt ) override; |
479 | | virtual void MouseButtonUp( const MouseEvent& rEvt ) override; |
480 | | virtual void KeyInput( const KeyEvent& rEvt ) override; |
481 | | virtual void LoseFocus() override; |
482 | | virtual void GetFocus() override; |
483 | | virtual void Resize() override; |
484 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; |
485 | | virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override; |
486 | | virtual void Command( const CommandEvent& rEvt ) override; |
487 | | virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) override; |
488 | | |
489 | | virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; // will forward everything got to the second AcceptDrop method |
490 | | virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; // will forward everything got to the second ExecuteDrop method |
491 | | |
492 | | virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt ); |
493 | | virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt ); |
494 | | |
495 | | // new handlers |
496 | | virtual void MouseButtonDown( const BrowserMouseEvent& rEvt ); |
497 | | virtual void MouseButtonUp( const BrowserMouseEvent& rEvt ); |
498 | | SAL_DLLPRIVATE void StartScroll(); |
499 | | virtual void EndScroll(); |
500 | | virtual void Select(); |
501 | | virtual void DoubleClick( const BrowserMouseEvent& rEvt ); |
502 | | virtual bool IsCursorMoveAllowed( sal_Int32 nNewRow, sal_uInt16 nNewColId ) const; |
503 | | virtual void CursorMoved(); |
504 | | virtual void ColumnMoved( sal_uInt16 nColId ); |
505 | | virtual void ColumnResized( sal_uInt16 nColId ); |
506 | | /// called when the row height has been changed interactively |
507 | | virtual void RowHeightChanged(); |
508 | | virtual tools::Long QueryMinimumRowHeight(); |
509 | | |
510 | | // Window-Control (pass to DataWindow) |
511 | | void SetUpdateMode( bool bUpdate ); |
512 | | bool GetUpdateMode() const; |
513 | | |
514 | | // map-mode and font control |
515 | | void SetFont( const vcl::Font& rNewFont ); |
516 | | const vcl::Font& GetFont() const; |
517 | | void SetTitleFont( const vcl::Font& rNewFont ) |
518 | 0 | { Control::SetFont( rNewFont ); } |
519 | | |
520 | | // inserting, changing, removing and freezing of columns |
521 | | void InsertHandleColumn( tools::Long nWidth ); |
522 | | void InsertDataColumn( sal_uInt16 nItemId, const OUString& rText, |
523 | | tools::Long nSize, HeaderBarItemBits nBits = HeaderBarItemBits::STDSTYLE, |
524 | | sal_uInt16 nPos = HEADERBAR_APPEND ); |
525 | | void SetColumnTitle( sal_uInt16 nColumnId, const OUString &rTitle ); |
526 | | void SetColumnWidth( sal_uInt16 nColumnId, tools::Long nWidth ); |
527 | | void SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos ); |
528 | | void FreezeColumn( sal_uInt16 nColumnId ); |
529 | | void RemoveColumn( sal_uInt16 nColumnId ); |
530 | | void RemoveColumns(); |
531 | | |
532 | | // control of title and data row height |
533 | | void SetDataRowHeight( tools::Long nPixel ); |
534 | | tools::Long GetDataRowHeight() const; |
535 | | void SetTitleLines( sal_uInt16 nLines ); |
536 | | tools::Long GetTitleHeight() const; |
537 | | |
538 | | // access to dynamic values of cursor row |
539 | | const OUString & GetColumnTitle( sal_uInt16 nColumnId ) const; |
540 | | tools::Rectangle GetFieldRect( sal_uInt16 nColumnId ) const; |
541 | | tools::Long GetColumnWidth( sal_uInt16 nColumnId ) const; |
542 | | sal_uInt16 GetColumnId( sal_uInt16 nPos ) const; |
543 | | sal_uInt16 GetColumnPos( sal_uInt16 nColumnId ) const; |
544 | | SAL_DLLPRIVATE bool IsFrozen( sal_uInt16 nColumnId ) const; |
545 | | |
546 | | // movement of visible area |
547 | | SAL_DLLPRIVATE sal_Int32 ScrollColumns( sal_Int32 nColumns ); |
548 | | SAL_DLLPRIVATE sal_Int32 ScrollRows( sal_Int32 nRows ); |
549 | | void MakeFieldVisible( sal_Int32 nRow, sal_uInt16 nColId ); |
550 | | |
551 | | // access and movement of cursor |
552 | 0 | sal_Int32 GetCurRow() const { return nCurRow; } |
553 | 0 | sal_uInt16 GetCurColumnId() const { return nCurColId; } |
554 | | bool GoToRow( sal_Int32 nRow ); |
555 | | bool GoToColumnId( sal_uInt16 nColId ); |
556 | | bool GoToRowColumnId( sal_Int32 nRow, sal_uInt16 nColId ); |
557 | | |
558 | | // selections |
559 | | virtual void SetNoSelection() override; |
560 | | virtual void SelectAll() override; |
561 | | virtual void SelectRow( sal_Int32 nRow, bool _bSelect = true, bool bExpand = true ) override; |
562 | | void SelectColumnPos( sal_uInt16 nCol, bool _bSelect = true ) |
563 | 0 | { SelectColumnPos( nCol, _bSelect, true); } |
564 | | void SelectColumnId( sal_uInt16 nColId ) |
565 | 0 | { SelectColumnPos( GetColumnPos(nColId), true, true); } |
566 | | sal_Int32 GetSelectRowCount() const; |
567 | | sal_uInt16 GetSelectColumnCount() const; |
568 | | virtual bool IsRowSelected( sal_Int32 nRow ) const override; |
569 | | bool IsColumnSelected( sal_uInt16 nColumnId ) const; |
570 | | sal_Int32 FirstSelectedRow(); |
571 | | sal_Int32 LastSelectedRow(); |
572 | | sal_Int32 NextSelectedRow(); |
573 | 0 | const MultiSelection* GetColumnSelection() const { return pColSel.get(); } |
574 | | const MultiSelection* GetSelection() const |
575 | 0 | { return bMultiSelection ? uRow.pSel : nullptr; } |
576 | | |
577 | | sal_Int32 FirstSelectedColumn( ) const; |
578 | | |
579 | 0 | bool IsResizing() const { return bResizing; } |
580 | | |
581 | | // access to positions of fields, column and rows |
582 | | BrowserDataWin& GetDataWindow() const; |
583 | | tools::Rectangle GetRowRectPixel( sal_Int32 nRow ) const; |
584 | | tools::Rectangle GetFieldRectPixel( sal_Int32 nRow, sal_uInt16 nColId, |
585 | | bool bRelToBrowser = true) const; |
586 | | SAL_DLLPRIVATE bool IsFieldVisible( sal_Int32 nRow, sal_uInt16 nColId, |
587 | | bool bComplete = false ) const; |
588 | | sal_Int32 GetRowAtYPosPixel( tools::Long nY, |
589 | | bool bRelToBrowser = true ) const; |
590 | | sal_uInt16 GetColumnAtXPosPixel( tools::Long nX ) const; |
591 | | |
592 | | // invalidations |
593 | | SAL_DLLPRIVATE void Clear(); |
594 | | void RowRemoved( sal_Int32 nRow, sal_Int32 nNumRows = 1, bool bDoPaint = true ); |
595 | | void RowModified( sal_Int32 nRow, sal_uInt16 nColId = BROWSER_INVALIDID ); |
596 | | void RowInserted( sal_Int32 nRow, sal_Int32 nNumRows = 1, bool bDoPaint = true, bool bKeepSelection = false ); |
597 | | |
598 | | // miscellaneous |
599 | | bool ReserveControlArea(sal_uInt16 nWidth = USHRT_MAX); |
600 | | tools::Rectangle GetControlArea() const; |
601 | | virtual bool ProcessKey(const KeyEvent& rEvt); |
602 | | virtual void ChildFocusIn(); |
603 | | virtual void ChildFocusOut(); |
604 | | SAL_DLLPRIVATE void Dispatch(BrowserDispatchId eId); |
605 | | void SetMode( BrowserMode nMode ); |
606 | 0 | BrowserMode GetMode( ) const { return m_nCurrentMode; } |
607 | | |
608 | | void SetCursorColor(const Color& _rCol); |
609 | | |
610 | | /** specifies that the user is allowed to interactively change the height of a row, |
611 | | by simply dragging an arbitrary row separator. |
612 | | |
613 | | Note that this works only if there's a handle column, since only in this case, |
614 | | there *is* something for the user to click onto |
615 | | */ |
616 | 0 | void EnableInteractiveRowHeight() { mbInteractiveRowHeight = true; } |
617 | 0 | bool IsInteractiveRowHeightEnabled( ) const { return mbInteractiveRowHeight; } |
618 | | |
619 | | /// access to selected methods, to be granted to the BrowserColumn |
620 | 0 | struct BrowserColumnAccess { friend class BrowserColumn; private: BrowserColumnAccess() { } }; |
621 | | /** public version of PaintField, with selected access rights for the BrowserColumn |
622 | | */ |
623 | | void DoPaintField( OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColumnId, BrowserColumnAccess ) const |
624 | 0 | { PaintField( rDev, rRect, nColumnId ); } |
625 | | |
626 | | /** suggests a default width for a column containing a given text |
627 | | |
628 | | The width is calculated so that the text fits completely, plus some margin. |
629 | | */ |
630 | | tools::Long GetDefaultColumnWidth( const OUString& _rText ) const; |
631 | | |
632 | | /** GetCellText returns the text at the given position |
633 | | @param _nRow |
634 | | the number of the row |
635 | | @param _nColId |
636 | | the ID of the column |
637 | | @return |
638 | | the text out of the cell |
639 | | */ |
640 | | virtual OUString GetCellText(sal_Int32 _nRow, sal_uInt16 _nColId) const; |
641 | | |
642 | | /** @return |
643 | | the current column count |
644 | | */ |
645 | 0 | sal_uInt16 GetColumnCount() const override { return ColCount(); } |
646 | | |
647 | | /** commitBrowseBoxEvent commit the event at all listeners of the browsebox |
648 | | @param nEventId |
649 | | the event id |
650 | | @param rNewValue |
651 | | the new value |
652 | | @param rOldValue |
653 | | the old value |
654 | | */ |
655 | | SAL_DLLPRIVATE void commitBrowseBoxEvent(sal_Int16 nEventId, |
656 | | const css::uno::Any& rNewValue, |
657 | | const css::uno::Any& rOldValue); |
658 | | |
659 | | /** commitTableEvent commit the event at all listeners of the table |
660 | | @param nEventId |
661 | | the event id |
662 | | @param rNewValue |
663 | | the new value |
664 | | @param rOldValue |
665 | | the old value |
666 | | */ |
667 | | SAL_DLLPRIVATE void commitTableEvent(sal_Int16 nEventId, |
668 | | const css::uno::Any& rNewValue, |
669 | | const css::uno::Any& rOldValue); |
670 | | |
671 | | /** fires an AccessibleEvent relative to a header bar AccessibleContext |
672 | | |
673 | | @param nEventId |
674 | | the event id |
675 | | @param rNewValue |
676 | | the new value |
677 | | @param rOldValue |
678 | | the old value |
679 | | */ |
680 | | SAL_DLLPRIVATE void commitHeaderBarEvent(sal_Int16 nEventId, |
681 | | const css::uno::Any& rNewValue, |
682 | | const css::uno::Any& rOldValue, |
683 | | bool _bColumnHeaderBar |
684 | | ); |
685 | | |
686 | | /** returns the Rectangle for either the column header bar or the row header bar |
687 | | @param _bIsColumnBar |
688 | | <TRUE/> when column header bar is used |
689 | | @return |
690 | | the Rectangle |
691 | | */ |
692 | | virtual tools::Rectangle calcHeaderRect(bool _bIsColumnBar) override; |
693 | | |
694 | | /** calculates the Rectangle of the table relative to the BrowseBox. |
695 | | @return |
696 | | the Rectangle |
697 | | */ |
698 | | virtual tools::Rectangle calcTableRect() override; |
699 | | |
700 | | virtual tools::Rectangle calcFieldRectPixel(sal_Int32 _nRowId, sal_uInt16 _nColId, bool _bIsHeader) override; |
701 | | |
702 | | /// return <TRUE/> if and only if the accessible object for this instance has been created and is alive |
703 | | SAL_DLLPRIVATE bool isAccessibleAlive( ) const; |
704 | | |
705 | | public: |
706 | | /** Creates and returns the accessible object of the whole BrowseBox. */ |
707 | | virtual css::uno::Reference< |
708 | | css::accessibility::XAccessible > CreateAccessible() override; |
709 | | |
710 | | // Children --------------------------------------------------------------- |
711 | | |
712 | | /** Creates the accessible object of a data table cell. |
713 | | @param nRow The row index of the cell. |
714 | | @param nColumnId The column pos of the cell. |
715 | | @return The XAccessible interface of the specified cell. */ |
716 | | virtual css::uno::Reference< |
717 | | css::accessibility::XAccessible > |
718 | | CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnPos ) override; |
719 | | |
720 | | /** Creates the accessible object of a row header. |
721 | | @param nRow The row index of the header. |
722 | | @return The XAccessible interface of the specified row header. */ |
723 | | virtual css::uno::Reference< |
724 | | css::accessibility::XAccessible > |
725 | | CreateAccessibleRowHeader( sal_Int32 nRow ) override; |
726 | | |
727 | | /** Creates the accessible object of a column header. |
728 | | @param nColumnId The column ID of the header. |
729 | | @return The XAccessible interface of the specified column header. */ |
730 | | virtual css::uno::Reference< |
731 | | css::accessibility::XAccessible > |
732 | | CreateAccessibleColumnHeader( sal_uInt16 nColumnPos ) override; |
733 | | |
734 | | /** Converts a point relative to the data window origin to a cell address. |
735 | | @param rnRow Out-parameter that takes the row index. |
736 | | @param rnColumnId Out-parameter that takes the column ID. |
737 | | @param rPoint The position in pixels relative to the data window. |
738 | | @return <TRUE/>, if the point could be converted to a valid address. */ |
739 | | virtual bool ConvertPointToCellAddress( |
740 | | sal_Int32& rnRow, sal_uInt16& rnColumnId, const Point& rPoint ) override; |
741 | | |
742 | | /** Converts a point relative to the row header bar origin to a row header |
743 | | index. |
744 | | @param rnRow Out-parameter that takes the row index. |
745 | | @param rPoint The position in pixels relative to the header bar. |
746 | | @return <TRUE/>, if the point could be converted to a valid index. */ |
747 | | virtual bool ConvertPointToRowHeader( sal_Int32& rnRow, const Point& rPoint ) override; |
748 | | |
749 | | /** Converts a point relative to the column header bar origin to a column |
750 | | header index. |
751 | | @param rnColumnId Out-parameter that takes the column ID. |
752 | | @param rPoint The position in pixels relative to the header bar. |
753 | | @return <TRUE/>, if the point could be converted to a valid index. */ |
754 | | virtual bool ConvertPointToColumnHeader( sal_uInt16& rnColumnPos, const Point& rPoint ) override; |
755 | | |
756 | | /** Converts a point relative to the BrowseBox origin to the index of an |
757 | | existing control. |
758 | | @param rnRow Out-parameter that takes the 0-based control index. |
759 | | @param rPoint The position in pixels relative to the BrowseBox. |
760 | | @return <TRUE/>, if the point could be converted to a valid index. */ |
761 | | virtual bool ConvertPointToControlIndex( sal_Int32& rnIndex, const Point& rPoint ) override; |
762 | | |
763 | | /** return the name of the specified object. |
764 | | @param eObjType |
765 | | The type to ask for |
766 | | @param _nPosition |
767 | | The position of a tablecell (index position), header bar column/row cell |
768 | | @return |
769 | | The name of the specified object. |
770 | | */ |
771 | | virtual OUString GetAccessibleObjectName( AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const override; |
772 | | |
773 | | /** return the description of the specified object. |
774 | | @param eObjType |
775 | | The type to ask for |
776 | | @param _nPosition |
777 | | The position of a tablecell (index position), header bar column/row cell |
778 | | @return |
779 | | The description of the specified object. |
780 | | */ |
781 | | virtual OUString GetAccessibleObjectDescription( AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const override; |
782 | | |
783 | | /** @return The header text of the specified row. */ |
784 | | virtual OUString GetRowDescription( sal_Int32 nRow ) const override; |
785 | | |
786 | | /** @return The header text of the specified column. */ |
787 | | virtual OUString GetColumnDescription( sal_uInt16 _nColumn ) const override; |
788 | | |
789 | | /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by |
790 | | the accessible object), depending on the specified object type. */ |
791 | | virtual void FillAccessibleStateSet( |
792 | | sal_Int64& rStateSet, |
793 | | AccessibleBrowseBoxObjType eObjType ) const override; |
794 | | |
795 | | /** Fills the StateSet with all states for one cell (except DEFUNC and SHOWING, done by |
796 | | the accessible object). */ |
797 | | virtual void FillAccessibleStateSetForCell( |
798 | | sal_Int64& _rStateSet, |
799 | | sal_Int32 _nRow, sal_uInt16 _nColumn ) const override; |
800 | | |
801 | | /** Sets focus to current cell of the data table. */ |
802 | | virtual void GrabTableFocus() override; |
803 | | |
804 | | // IAccessibleTableProvider |
805 | | virtual sal_Int32 GetCurrRow() const override; |
806 | | virtual sal_uInt16 GetCurrColumn() const override; |
807 | | virtual bool HasRowHeader() const override; |
808 | | virtual bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override; |
809 | | virtual void SelectColumn( sal_uInt16 _nColumn, bool _bSelect = true ) override; |
810 | | virtual bool IsColumnSelected( sal_Int32 _nColumn ) const override; |
811 | | virtual sal_Int32 GetSelectedRowCount() const override; |
812 | | virtual sal_Int32 GetSelectedColumnCount() const override; |
813 | | virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const override; |
814 | | virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const override; |
815 | | virtual bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const override; |
816 | | virtual OUString GetAccessibleCellText(sal_Int32 _nRow, sal_uInt16 _nColPos) const override; |
817 | | virtual bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, std::vector< tools::Rectangle >& rVector ) override; |
818 | | virtual tools::Rectangle GetWindowExtentsRelative(const vcl::Window& rRelativeWindow) const override; |
819 | | virtual void GrabFocus() override; |
820 | | virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() override; |
821 | | virtual vcl::Window* GetAccessibleParentWindow() const override; |
822 | | virtual vcl::Window* GetWindowInstance() override; |
823 | | |
824 | | private: |
825 | | // the following declares some Window/OutputDevice methods private. This happened in the course |
826 | | // of CWS warnings01, which pointed out nameclashs in those methods. If the build breaks in some |
827 | | // upper module, you should investigate whether you really wanted to call base class methods, |
828 | | // or the versions at this class. In the latter case, use the renamed versions above. |
829 | | |
830 | | // ToTop/ToBottom were never property implemented. If you currently call it, this is most probably wrong |
831 | | // and not doing as intended |
832 | | using Window::ToTop; |
833 | | }; |
834 | | |
835 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |