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