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