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