1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gridwin.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_GRIDWIN_HXX
32 #define SC_GRIDWIN_HXX
34 #include <tools/string.hxx>
35 #include <svtools/transfer.hxx>
36 #include "viewutil.hxx"
37 #include "viewdata.hxx"
38 #include "cbutton.hxx"
39 #include <svx/sdr/overlay/overlayobject.hxx>
40 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
41 #include <basegfx/matrix/b2dhommatrix.hxx>
45 #include <boost/shared_ptr.hpp>
47 // ---------------------------------------------------------------------------
50 class ScViewSelectionEngine
;
52 class ScDPFieldPopupWindow
;
53 class ScDPFieldButton
;
55 class ScFilterListBox
;
56 class AutoFilterPopup
;
63 struct SpellCallbackInfo
;
65 // Maus-Status (nMouseStatus)
68 #define SC_GM_TABDOWN 1
69 #define SC_GM_DBLDOWN 2
70 #define SC_GM_FILTER 3
71 #define SC_GM_IGNORE 4
72 #define SC_GM_WATERUNDO 5
73 #define SC_GM_URLDOWN 6
78 #define SC_PD_RANGE_L 1
79 #define SC_PD_RANGE_R 2
80 #define SC_PD_RANGE_T 4
81 #define SC_PD_RANGE_B 8
82 #define SC_PD_RANGE_TL (SC_PD_RANGE_T|SC_PD_RANGE_L)
83 #define SC_PD_RANGE_TR (SC_PD_RANGE_T|SC_PD_RANGE_R)
84 #define SC_PD_RANGE_BL (SC_PD_RANGE_B|SC_PD_RANGE_L)
85 #define SC_PD_RANGE_BR (SC_PD_RANGE_B|SC_PD_RANGE_R)
86 #define SC_PD_BREAK_H 16
87 #define SC_PD_BREAK_V 32
90 class ScHideTextCursor
93 ScViewData
* pViewData
;
97 ScHideTextCursor( ScViewData
* pData
, ScSplitPos eW
);
101 // ---------------------------------------------------------------------------
103 namespace sdr
{ namespace overlay
{ class OverlayObjectList
; }}
105 class ScGridWindow
: public Window
, public DropTargetHelper
, public DragSourceHelper
107 // ScFilterListBox wird immer fuer Auswahlliste benutzt
108 friend class ScFilterListBox
;
112 ::sdr::overlay::OverlayObjectList
* mpOOCursors
;
113 ::sdr::overlay::OverlayObjectList
* mpOOSelection
;
114 ::sdr::overlay::OverlayObjectList
* mpOOSelectionBorder
;
115 ::sdr::overlay::OverlayObjectList
* mpOOAutoFill
;
116 ::sdr::overlay::OverlayObjectList
* mpOODragRect
;
117 ::sdr::overlay::OverlayObjectList
* mpOOHeader
;
118 ::sdr::overlay::OverlayObjectList
* mpOOShrink
;
120 ::boost::shared_ptr
<Rectangle
> mpAutoFillRect
;
123 * Stores current visible column and row ranges, used to avoid expensive
124 * operations on objects that are outside visible area.
135 bool isInside(SCCOL nCol
, SCROW nRow
) const;
137 VisibleRange maVisibleRange
;
140 ScViewData
* pViewData
;
145 ScNoteMarker
* pNoteMarker
;
147 ScFilterListBox
* pFilterBox
;
148 FloatingWindow
* pFilterFloat
;
149 ::std::auto_ptr
<ScDPFieldPopupWindow
> mpDPFieldPopup
;
150 ::std::auto_ptr
<ScDPFieldButton
> mpFilterButton
;
152 USHORT nCursorHideCount
;
157 BOOL bEEMouse
; // Edit-Engine hat Maus
159 BYTE nNestedButtonState
; // track nested button up/down calls
161 BOOL bDPMouse
; // DataPilot-D&D (neue Pivottabellen)
163 ScDPObject
* pDragDPObj
; //! name?
165 BOOL bRFMouse
; // RangeFinder-Drag
171 USHORT nPagebreakMouse
; // Pagebreak-Modus Drag
172 SCCOLROW nPagebreakBreak
;
173 SCCOLROW nPagebreakPrev
;
174 ScRange aPagebreakSource
;
175 ScRange aPagebreakDrag
;
176 BOOL bPagebreakDrawn
;
188 InsCellCmd meDragInsertMode
;
190 USHORT nCurrentPointer
;
195 ScDDComboBoxButton aComboButton
;
200 Rectangle aRepaintPixel
;
203 BOOL bAutoMarkVisible
;
204 ScAddress aAutoMarkPos
;
207 ScAddress aListValPos
;
209 Rectangle aInvertRect
;
211 DECL_LINK( PopupModeEndHdl
, FloatingWindow
* );
212 DECL_LINK( PopupSpellingHdl
, SpellCallbackInfo
* );
214 BOOL
TestMouse( const MouseEvent
& rMEvt
, BOOL bAction
);
216 BOOL
DoPageFieldSelection( SCCOL nCol
, SCROW nRow
);
217 bool DoAutoFilterButton( SCCOL nCol
, SCROW nRow
, const MouseEvent
& rMEvt
);
218 void DoPushButton( SCCOL nCol
, SCROW nRow
, const MouseEvent
& rMEvt
);
220 void DPMouseMove( const MouseEvent
& rMEvt
);
221 void DPMouseButtonUp( const MouseEvent
& rMEvt
);
222 void DPTestMouse( const MouseEvent
& rMEvt
, BOOL bMove
);
225 * Check if the mouse click is on a field popup button.
227 * @return bool true if the field popup menu has been launched and no
228 * further mouse event handling is necessary, false otherwise.
230 bool DPTestFieldPopupArrow(const MouseEvent
& rMEvt
, const ScAddress
& rPos
, ScDPObject
* pDPObj
);
231 void DPLaunchFieldPopupMenu(
232 const Point
& rScrPos
, const Size
& rScrSize
, const ScAddress
& rPos
, ScDPObject
* pDPObj
);
234 void RFMouseMove( const MouseEvent
& rMEvt
, BOOL bUp
);
236 void PagebreakMove( const MouseEvent
& rMEvt
, BOOL bUp
);
238 void UpdateDragRect( BOOL bShowRange
, const Rectangle
& rPosRect
);
240 BOOL
IsAutoFilterActive( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
241 void ExecFilter( ULONG nSel
, SCCOL nCol
, SCROW nRow
,
242 const String
& aValue
, bool bCheckForDates
);
243 void FilterSelect( ULONG nSel
);
245 void ExecDataSelect( SCCOL nCol
, SCROW nRow
, const String
& rStr
);
247 void ExecPageFieldSelect( SCCOL nCol
, SCROW nRow
, BOOL bHasSelection
, const String
& rStr
);
249 BOOL
HasScenarioButton( const Point
& rPosPixel
, ScRange
& rScenRange
);
251 BOOL
DropScroll( const Point
& rMousePos
);
253 sal_Int8
AcceptPrivateDrop( const AcceptDropEvent
& rEvt
);
254 sal_Int8
ExecutePrivateDrop( const ExecuteDropEvent
& rEvt
);
255 sal_Int8
DropTransferObj( ScTransferObj
* pTransObj
, SCCOL nDestPosX
, SCROW nDestPosY
,
256 const Point
& rLogicPos
, sal_Int8 nDndAction
);
258 void HandleMouseButtonDown( const MouseEvent
& rMEvt
);
260 BOOL
DrawMouseButtonDown(const MouseEvent
& rMEvt
);
261 BOOL
DrawMouseButtonUp(const MouseEvent
& rMEvt
);
262 BOOL
DrawMouseMove(const MouseEvent
& rMEvt
);
263 BOOL
DrawKeyInput(const KeyEvent
& rKEvt
);
264 BOOL
DrawCommand(const CommandEvent
& rCEvt
);
265 BOOL
DrawHasMarkedObj();
266 void DrawEndAction();
267 void DrawMarkDropObj( SdrObject
* pObj
);
268 SdrObject
* GetEditObject();
269 BOOL
IsMyModel(SdrEditView
* pSdrView
);
270 //void DrawStartTimer();
272 void DrawRedraw( ScOutputData
& rOutputData
, ScUpdateMode eMode
, ULONG nLayer
);
273 void DrawSdrGrid( const Rectangle
& rDrawingRect
, OutputDevice
* pContentDev
);
274 //BOOL DrawBeforeScroll();
275 void DrawAfterScroll(/*BOOL bVal*/);
277 //BOOL NeedDrawMarks();
278 void DrawComboButton( const Point
& rCellPos
,
282 BOOL bBtnIn
= FALSE
);
283 Rectangle
GetListValButtonRect( const ScAddress
& rButtonPos
);
285 void DrawPagePreview( SCCOL nX1
, SCROW nY1
, SCCOL nX2
, SCROW nY2
, OutputDevice
* pContentDev
);
287 BOOL
GetEditUrl( const Point
& rPos
,
288 String
* pName
=0, String
* pUrl
=0, String
* pTarget
=0 );
289 BOOL
GetEditUrlOrError( BOOL bSpellErr
, const Point
& rPos
,
290 String
* pName
=0, String
* pUrl
=0, String
* pTarget
=0 );
292 BOOL
HitRangeFinder( const Point
& rMouse
, BOOL
& rCorner
, USHORT
* pIndex
= NULL
,
293 SCsCOL
* pAddX
= NULL
, SCsROW
* pAddY
= NULL
);
295 USHORT
HitPageBreak( const Point
& rMouse
, ScRange
* pSource
= NULL
,
296 SCCOLROW
* pBreak
= NULL
, SCCOLROW
* pPrev
= NULL
);
298 void PasteSelection( const Point
& rPosPixel
);
300 void SelectForContextMenu( const Point
& rPosPixel
, SCsCOL nCellX
, SCsROW nCellY
);
302 void GetSelectionRects( ::std::vector
< Rectangle
>& rPixelRects
);
305 using Window::Resize
;
306 virtual void Resize( const Size
& rSize
);
307 virtual void PrePaint();
308 virtual void Paint( const Rectangle
& rRect
);
309 virtual void KeyInput(const KeyEvent
& rKEvt
);
310 virtual void GetFocus();
311 virtual void LoseFocus();
313 virtual void RequestHelp( const HelpEvent
& rEvt
);
314 virtual void Command( const CommandEvent
& rCEvt
);
316 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
317 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
318 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
321 ScGridWindow( Window
* pParent
, ScViewData
* pData
, ScSplitPos eWhichPos
);
324 // #i70788# flush and get overlay
325 ::sdr::overlay::OverlayManager
* getOverlayManager();
326 void flushOverlayManager();
328 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
330 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
331 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
332 virtual void MouseMove( const MouseEvent
& rMEvt
);
333 virtual long PreNotify( NotifyEvent
& rNEvt
);
334 virtual void Tracking( const TrackingEvent
& rTEvt
);
336 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
340 Point
GetMousePosPixel() const;
341 void UpdateStatusPosSize();
345 void SetPointer( const Pointer
& rPointer
);
347 void MoveMouseStatus( ScGridWindow
&rDestWin
);
349 void ScrollPixel( long nDifX
, long nDifY
);
350 void UpdateEditViewPos();
352 void UpdateFormulas();
354 void DoAutoFilterMenue( SCCOL nCol
, SCROW nRow
, BOOL bDataSelect
);
355 void DoScenarioMenue( const ScRange
& rScenRange
);
357 void LaunchPageFieldMenu( SCCOL nCol
, SCROW nRow
);
358 void LaunchDPFieldMenu( SCCOL nCol
, SCROW nRow
);
360 ::com::sun::star::sheet::DataPilotFieldOrientation
GetDPFieldOrientation( SCCOL nCol
, SCROW nRow
) const;
362 void DrawButtons( SCCOL nX1
, SCROW nY1
, SCCOL nX2
, SCROW nY2
,
363 ScTableInfo
& rTabInfo
, OutputDevice
* pContentDev
);
366 void Draw( SCCOL nX1
, SCROW nY1
, SCCOL nX2
, SCROW nY2
,
367 ScUpdateMode eMode
= SC_UPDATE_ALL
);
369 void InvertSimple( SCCOL nX1
, SCROW nY1
, SCCOL nX2
, SCROW nY2
,
370 BOOL bTestMerge
= FALSE
, BOOL bRepeat
= FALSE
);
372 //UNUSED2008-05 void DrawDragRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
374 void CreateAnchorHandle(SdrHdlList
& rHdl
, const ScAddress
& rAddress
);
379 void DrawAutoFillMark();
380 void UpdateAutoFillMark(BOOL bMarked
, const ScRange
& rMarkRange
);
382 void UpdateListValPos( BOOL bVisible
, const ScAddress
& rPos
);
384 BOOL
ShowNoteMarker( SCsCOL nPosX
, SCsROW nPosY
, BOOL bKeyboard
);
385 void HideNoteMarker();
387 MapMode
GetDrawMapMode( BOOL bForce
= FALSE
);
392 void UpdateInputContext();
394 void CheckInverted() { if (nPaintCount
) bNeedsRepaint
= TRUE
; }
396 void DoInvertRect( const Rectangle
& rPixel
);
398 void CheckNeedsRepaint();
400 void UpdateDPFromFieldPopupMenu();
403 void CursorChanged();
404 void DrawLayerCreated();
406 void DeleteCopySourceOverlay();
407 void UpdateCopySourceOverlay();
408 void DeleteCursorOverlay();
409 void UpdateCursorOverlay();
410 void DeleteSelectionOverlay();
411 void UpdateSelectionOverlay();
412 void DeleteAutoFillOverlay();
413 void UpdateAutoFillOverlay();
414 void DeleteDragRectOverlay();
415 void UpdateDragRectOverlay();
416 void DeleteHeaderOverlay();
417 void UpdateHeaderOverlay();
418 void DeleteShrinkOverlay();
419 void UpdateShrinkOverlay();
420 void UpdateAllOverlays();
424 void ImpCreateOverlayObjects();
425 void ImpDestroyOverlayObjects();