Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / gridwin.hxx
blob5ac059c739d83b70d396ef728e5134f7af8ba1f9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SC_GRIDWIN_HXX
21 #define SC_GRIDWIN_HXX
23 #include <svtools/transfer.hxx>
24 #include "viewutil.hxx"
25 #include "viewdata.hxx"
26 #include "cbutton.hxx"
27 #include <svx/sdr/overlay/overlayobject.hxx>
28 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
31 #include <vector>
32 #include <memory>
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/unordered_map.hpp>
35 #include <boost/ptr_container/ptr_map.hpp>
37 namespace editeng {
38 struct MisspellRanges;
41 namespace sc {
42 struct SpellCheckContext;
45 struct ScTableInfo;
46 class ScDPObject;
47 class ScCheckListMenuWindow;
48 class ScDPFieldButton;
49 class ScOutputData;
50 class ScFilterListBox;
51 class SdrObject;
52 class SdrEditView;
53 class ScNoteMarker;
54 class FloatingWindow;
55 class SdrHdlList;
56 class ScTransferObj;
57 struct SpellCallbackInfo;
59 // Maus-Status (nMouseStatus)
61 #define SC_GM_NONE 0
62 #define SC_GM_TABDOWN 1
63 #define SC_GM_DBLDOWN 2
64 #define SC_GM_FILTER 3
65 #define SC_GM_IGNORE 4
66 #define SC_GM_WATERUNDO 5
67 #define SC_GM_URLDOWN 6
69 // Page-Drag-Modus
71 #define SC_PD_NONE 0
72 #define SC_PD_RANGE_L 1
73 #define SC_PD_RANGE_R 2
74 #define SC_PD_RANGE_T 4
75 #define SC_PD_RANGE_B 8
76 #define SC_PD_RANGE_TL (SC_PD_RANGE_T|SC_PD_RANGE_L)
77 #define SC_PD_RANGE_TR (SC_PD_RANGE_T|SC_PD_RANGE_R)
78 #define SC_PD_RANGE_BL (SC_PD_RANGE_B|SC_PD_RANGE_L)
79 #define SC_PD_RANGE_BR (SC_PD_RANGE_B|SC_PD_RANGE_R)
80 #define SC_PD_BREAK_H 16
81 #define SC_PD_BREAK_V 32
84 // ---------------------------------------------------------------------------
85 // predefines
86 namespace sdr { namespace overlay { class OverlayObjectList; }}
88 class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHelper
90 // ScFilterListBox is always used for selection list
91 friend class ScFilterListBox;
93 enum RfCorner
95 NONE,
96 LEFT_UP,
97 RIGHT_UP,
98 LEFT_DOWN,
99 RIGHT_DOWN
102 // #114409#
103 ::sdr::overlay::OverlayObjectList* mpOOCursors;
104 ::sdr::overlay::OverlayObjectList* mpOOSelection;
105 ::sdr::overlay::OverlayObjectList* mpOOSelectionBorder;
106 ::sdr::overlay::OverlayObjectList* mpOOAutoFill;
107 ::sdr::overlay::OverlayObjectList* mpOODragRect;
108 ::sdr::overlay::OverlayObjectList* mpOOHeader;
109 ::sdr::overlay::OverlayObjectList* mpOOShrink;
111 boost::scoped_ptr<Rectangle> mpAutoFillRect;
113 struct MouseEventState;
116 * Stores current visible column and row ranges, used to avoid expensive
117 * operations on objects that are outside visible area.
119 struct VisibleRange
121 SCCOL mnCol1;
122 SCCOL mnCol2;
123 SCROW mnRow1;
124 SCROW mnRow2;
126 VisibleRange();
128 bool isInside(SCCOL nCol, SCROW nRow) const;
129 bool set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
132 VisibleRange maVisibleRange;
134 boost::scoped_ptr<sc::SpellCheckContext> mpSpellCheckCxt;
136 ScViewData* pViewData;
137 ScSplitPos eWhich;
138 ScHSplitPos eHWhich;
139 ScVSplitPos eVWhich;
141 ScNoteMarker* pNoteMarker;
143 ScFilterListBox* pFilterBox;
144 FloatingWindow* pFilterFloat;
145 boost::scoped_ptr<ScCheckListMenuWindow> mpAutoFilterPopup;
146 boost::scoped_ptr<ScCheckListMenuWindow> mpDPFieldPopup;
147 boost::scoped_ptr<ScDPFieldButton> mpFilterButton;
149 sal_uInt16 nCursorHideCount;
151 sal_uInt16 nButtonDown;
152 sal_uInt8 nMouseStatus;
153 sal_uInt8 nNestedButtonState; // track nested button up/down calls
155 long nDPField;
156 ScDPObject* pDragDPObj; //! name?
158 sal_uInt16 nRFIndex;
159 SCsCOL nRFAddX;
160 SCsROW nRFAddY;
162 sal_uInt16 nPagebreakMouse; // Page break mode, Drag
163 SCCOLROW nPagebreakBreak;
164 SCCOLROW nPagebreakPrev;
165 ScRange aPagebreakSource;
166 ScRange aPagebreakDrag;
168 sal_uInt8 nPageScript;
170 long nLastClickX;
171 long nLastClickY;
173 SCCOL nDragStartX;
174 SCROW nDragStartY;
175 SCCOL nDragEndX;
176 SCROW nDragEndY;
177 InsCellCmd meDragInsertMode;
179 sal_uInt16 nCurrentPointer;
181 ScDDComboBoxButton aComboButton;
183 Point aCurMousePos;
185 sal_uInt16 nPaintCount;
186 Rectangle aRepaintPixel;
188 ScAddress aAutoMarkPos;
189 ScAddress aListValPos;
191 Rectangle aInvertRect;
193 RfCorner aRFSelectedCorned;
195 bool bEEMouse:1; // Edit Engine has mouse
196 bool bDPMouse:1; // DataPilot D&D (new Pivot table)
197 bool bRFMouse:1; // RangeFinder drag
198 bool bRFSize:1;
199 bool bPagebreakDrawn:1;
200 bool bDragRect:1;
201 bool bIsInScroll:1;
202 bool bIsInPaint:1;
203 bool bNeedsRepaint:1;
204 bool bAutoMarkVisible:1;
205 bool bListValButton:1;
207 DECL_LINK( PopupModeEndHdl, void* );
208 DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* );
210 bool TestMouse( const MouseEvent& rMEvt, bool bAction );
212 bool DoPageFieldSelection( SCCOL nCol, SCROW nRow );
213 bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
214 void DoPushPivotButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt, bool bButton, bool bPopup );
216 void DPMouseMove( const MouseEvent& rMEvt );
217 void DPMouseButtonUp( const MouseEvent& rMEvt );
218 void DPTestMouse( const MouseEvent& rMEvt, sal_Bool bMove );
221 * Check if the mouse click is on a field popup button.
223 * @return true if the field popup menu has been launched and no further
224 * mouse event handling is necessary, false otherwise.
226 bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, const ScAddress& rDimPos, ScDPObject* pDPObj);
227 void DPLaunchFieldPopupMenu(
228 const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj);
230 void RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp );
232 void PagebreakMove( const MouseEvent& rMEvt, sal_Bool bUp );
234 void UpdateDragRect( bool bShowRange, const Rectangle& rPosRect );
236 bool IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab );
237 void ExecFilter( sal_uLong nSel, SCCOL nCol, SCROW nRow,
238 const OUString& aValue, bool bCheckForDates );
239 void FilterSelect( sal_uLong nSel );
241 void ExecDataSelect( SCCOL nCol, SCROW nRow, const OUString& rStr );
243 void ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSelection, const OUString& rStr );
245 bool HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange );
247 bool DropScroll( const Point& rMousePos );
249 sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt );
250 sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt );
251 sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY,
252 const Point& rLogicPos, sal_Int8 nDndAction );
254 void HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventState& rState );
256 bool DrawMouseButtonDown(const MouseEvent& rMEvt);
257 bool DrawMouseButtonUp(const MouseEvent& rMEvt);
258 bool DrawMouseMove(const MouseEvent& rMEvt);
259 bool DrawKeyInput(const KeyEvent& rKEvt);
260 bool DrawCommand(const CommandEvent& rCEvt);
261 bool DrawHasMarkedObj();
262 void DrawEndAction();
263 void DrawMarkDropObj( SdrObject* pObj );
264 SdrObject* GetEditObject();
265 bool IsMyModel(SdrEditView* pSdrView);
267 void DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer );
268 void DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev );
269 void DrawAfterScroll();
270 Rectangle GetListValButtonRect( const ScAddress& rButtonPos );
272 void DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev );
274 bool GetEditUrl( const Point& rPos,
275 OUString* pName=0, OUString* pUrl=0, OUString* pTarget=0 );
277 bool HitRangeFinder( const Point& rMouse, RfCorner& rCorner, sal_uInt16* pIndex = NULL,
278 SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL );
280 sal_uInt16 HitPageBreak( const Point& rMouse, ScRange* pSource = NULL,
281 SCCOLROW* pBreak = NULL, SCCOLROW* pPrev = NULL );
283 void PasteSelection( const Point& rPosPixel );
285 void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY );
287 void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
289 protected:
290 using Window::Resize;
291 virtual void Resize( const Size& rSize );
292 virtual void PrePaint();
293 virtual void Paint( const Rectangle& rRect );
294 virtual void KeyInput(const KeyEvent& rKEvt);
295 virtual void GetFocus();
296 virtual void LoseFocus();
298 virtual void RequestHelp( const HelpEvent& rEvt );
299 virtual void Command( const CommandEvent& rCEvt );
301 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
302 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
303 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
305 public:
306 enum AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty, SortAscending, SortDescending };
308 ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
309 ~ScGridWindow();
311 // #i70788# flush and get overlay
312 rtl::Reference<sdr::overlay::OverlayManager> getOverlayManager();
313 void flushOverlayManager();
315 virtual void DataChanged( const DataChangedEvent& rDCEvt );
317 virtual void MouseButtonDown( const MouseEvent& rMEvt );
318 virtual void MouseButtonUp( const MouseEvent& rMEvt );
319 virtual void MouseMove( const MouseEvent& rMEvt );
320 virtual long PreNotify( NotifyEvent& rNEvt );
321 virtual void Tracking( const TrackingEvent& rTEvt );
323 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
325 void FakeButtonUp();
327 Point GetMousePosPixel() const;
328 void UpdateStatusPosSize();
330 void ClickExtern();
332 void SetPointer( const Pointer& rPointer );
334 void MoveMouseStatus( ScGridWindow &rDestWin );
336 void ScrollPixel( long nDifX, long nDifY );
337 void UpdateEditViewPos();
339 void UpdateFormulas();
341 void LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect );
342 void DoScenarioMenu( const ScRange& rScenRange );
344 void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
345 void RefreshAutoFilterButton(const ScAddress& rPos);
346 void UpdateAutoFilterFromMenu(AutoFilterMode eMode);
348 void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
349 void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
351 ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const;
353 void DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, OutputDevice* pContentDev);
355 using Window::Draw;
356 void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
357 ScUpdateMode eMode = SC_UPDATE_ALL );
359 void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
361 void HideCursor();
362 void ShowCursor();
363 void UpdateAutoFillMark(bool bMarked, const ScRange& rMarkRange);
365 void UpdateListValPos( bool bVisible, const ScAddress& rPos );
367 bool ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard );
368 void HideNoteMarker();
370 MapMode GetDrawMapMode( bool bForce = false );
372 void ContinueDrag();
374 void StopMarking();
375 void UpdateInputContext();
376 bool NeedsRepaint() { return bNeedsRepaint; }
378 void CheckInverted() { if (nPaintCount) bNeedsRepaint = true; }
380 void DoInvertRect( const Rectangle& rPixel );
382 void CheckNeedsRepaint();
384 void UpdateDPFromFieldPopupMenu();
385 bool UpdateVisibleRange();
387 void SetInRefMode( bool bRefMode );
389 // #114409#
390 void CursorChanged();
391 void DrawLayerCreated();
392 bool ContinueOnlineSpelling();
393 void EnableAutoSpell( bool bEnable );
394 void ResetAutoSpell();
395 void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
397 void DeleteCopySourceOverlay();
398 void UpdateCopySourceOverlay();
399 void DeleteCursorOverlay();
400 void UpdateCursorOverlay();
401 void DeleteSelectionOverlay();
402 void UpdateSelectionOverlay();
403 void DeleteAutoFillOverlay();
404 void UpdateAutoFillOverlay();
405 void DeleteDragRectOverlay();
406 void UpdateDragRectOverlay();
407 void DeleteHeaderOverlay();
408 void UpdateHeaderOverlay();
409 void DeleteShrinkOverlay();
410 void UpdateShrinkOverlay();
411 void UpdateAllOverlays();
413 protected:
414 // #114409#
415 void ImpCreateOverlayObjects();
416 void ImpDestroyOverlayObjects();
422 #endif
424 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */