fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / inc / gridwin.hxx
blobe4bb56aac1f0152509f7e0ed87a2368ea9d92821
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 INCLUDED_SC_SOURCE_UI_INC_GRIDWIN_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_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 <boost/ptr_container/ptr_map.hpp>
32 #include <boost/ptr_container/ptr_vector.hpp>
33 #include <vector>
35 namespace editeng {
36 struct MisspellRanges;
39 namespace sc {
40 struct SpellCheckContext;
43 struct ScTableInfo;
44 class ScDPObject;
45 class ScCheckListMenuWindow;
46 class ScDPFieldButton;
47 class ScOutputData;
48 class ScFilterListBox;
49 class SdrObject;
50 class SdrEditView;
51 class ScNoteMarker;
52 class FloatingWindow;
53 class SdrHdlList;
54 class ScTransferObj;
55 struct SpellCallbackInfo;
57 // Maus-Status (nMouseStatus)
59 #define SC_GM_NONE 0
60 #define SC_GM_TABDOWN 1
61 #define SC_GM_DBLDOWN 2
62 #define SC_GM_FILTER 3
63 #define SC_GM_IGNORE 4
64 #define SC_GM_WATERUNDO 5
65 #define SC_GM_URLDOWN 6
67 // Page-Drag-Modus
69 #define SC_PD_NONE 0
70 #define SC_PD_RANGE_L 1
71 #define SC_PD_RANGE_R 2
72 #define SC_PD_RANGE_T 4
73 #define SC_PD_RANGE_B 8
74 #define SC_PD_RANGE_TL (SC_PD_RANGE_T|SC_PD_RANGE_L)
75 #define SC_PD_RANGE_TR (SC_PD_RANGE_T|SC_PD_RANGE_R)
76 #define SC_PD_RANGE_BL (SC_PD_RANGE_B|SC_PD_RANGE_L)
77 #define SC_PD_RANGE_BR (SC_PD_RANGE_B|SC_PD_RANGE_R)
78 #define SC_PD_BREAK_H 16
79 #define SC_PD_BREAK_V 32
81 // predefines
82 namespace sdr { namespace overlay { class OverlayObjectList; }}
84 class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSourceHelper
86 // ScFilterListBox is always used for selection list
87 friend class ScFilterListBox;
89 enum RfCorner
91 NONE,
92 LEFT_UP,
93 RIGHT_UP,
94 LEFT_DOWN,
95 RIGHT_DOWN
98 // #114409#
99 std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOCursors;
100 std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOSelection;
101 std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOSelectionBorder;
102 std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOAutoFill;
103 std::unique_ptr<sdr::overlay::OverlayObjectList> mpOODragRect;
104 std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOHeader;
105 std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOShrink;
107 std::unique_ptr<Rectangle> mpAutoFillRect;
109 struct MouseEventState;
112 * Stores current visible column and row ranges, used to avoid expensive
113 * operations on objects that are outside visible area.
115 struct VisibleRange
117 SCCOL mnCol1;
118 SCCOL mnCol2;
119 SCROW mnRow1;
120 SCROW mnRow2;
122 VisibleRange();
124 bool isInside(SCCOL nCol, SCROW nRow) const;
125 bool set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
128 VisibleRange maVisibleRange;
130 std::unique_ptr<sc::SpellCheckContext> mpSpellCheckCxt;
132 ScViewData* pViewData;
133 ScSplitPos eWhich;
134 ScHSplitPos eHWhich;
135 ScVSplitPos eVWhich;
137 std::unique_ptr<ScNoteMarker> mpNoteMarker;
139 VclPtr<ScFilterListBox> mpFilterBox;
140 VclPtr<FloatingWindow> mpFilterFloat;
141 VclPtr<ScCheckListMenuWindow> mpAutoFilterPopup;
142 VclPtr<ScCheckListMenuWindow> mpDPFieldPopup;
143 std::unique_ptr<ScDPFieldButton> mpFilterButton;
145 sal_uInt16 nCursorHideCount;
147 sal_uInt16 nButtonDown;
148 sal_uInt8 nMouseStatus;
149 sal_uInt8 nNestedButtonState; // track nested button up/down calls
151 long nDPField;
152 ScDPObject* pDragDPObj; //! name?
154 sal_uInt16 nRFIndex;
155 SCsCOL nRFAddX;
156 SCsROW nRFAddY;
158 sal_uInt16 nPagebreakMouse; // Page break mode, Drag
159 SCCOLROW nPagebreakBreak;
160 SCCOLROW nPagebreakPrev;
161 ScRange aPagebreakSource;
162 ScRange aPagebreakDrag;
164 SvtScriptType nPageScript;
166 long nLastClickX;
167 long nLastClickY;
169 SCCOL nDragStartX;
170 SCROW nDragStartY;
171 SCCOL nDragEndX;
172 SCROW nDragEndY;
173 InsCellCmd meDragInsertMode;
175 sal_uInt16 nCurrentPointer;
177 ScDDComboBoxButton aComboButton;
179 Point aCurMousePos;
181 sal_uInt16 nPaintCount;
182 Rectangle aRepaintPixel;
184 ScAddress aAutoMarkPos;
185 ScAddress aListValPos;
187 Rectangle aInvertRect;
189 RfCorner aRFSelectedCorned;
191 bool bEEMouse:1; // Edit Engine has mouse
192 bool bDPMouse:1; // DataPilot D&D (new Pivot table)
193 bool bRFMouse:1; // RangeFinder drag
194 bool bRFSize:1;
195 bool bPagebreakDrawn:1;
196 bool bDragRect:1;
197 bool bIsInScroll:1;
198 bool bIsInPaint:1;
199 bool bNeedsRepaint:1;
200 bool bAutoMarkVisible:1;
201 bool bListValButton:1;
203 DECL_LINK( PopupModeEndHdl, void* );
204 DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* );
206 bool TestMouse( const MouseEvent& rMEvt, bool bAction );
208 bool DoPageFieldSelection( SCCOL nCol, SCROW nRow );
209 bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
210 void DoPushPivotButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt, bool bButton, bool bPopup );
212 void DPMouseMove( const MouseEvent& rMEvt );
213 void DPMouseButtonUp( const MouseEvent& rMEvt );
214 void DPTestMouse( const MouseEvent& rMEvt, bool bMove );
217 * Check if the mouse click is on a field popup button.
219 * @return true if the field popup menu has been launched and no further
220 * mouse event handling is necessary, false otherwise.
222 bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, const ScAddress& rDimPos, ScDPObject* pDPObj);
223 void DPLaunchFieldPopupMenu(
224 const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj);
226 void RFMouseMove( const MouseEvent& rMEvt, bool bUp );
228 void PagebreakMove( const MouseEvent& rMEvt, bool bUp );
230 void UpdateDragRect( bool bShowRange, const Rectangle& rPosRect );
232 bool IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab );
233 void ExecFilter( sal_uLong nSel, SCCOL nCol, SCROW nRow,
234 const OUString& aValue, bool bCheckForDates );
235 void FilterSelect( sal_uLong nSel );
237 void ExecDataSelect( SCCOL nCol, SCROW nRow, const OUString& rStr );
239 void ExecPageFieldSelect( SCCOL nCol, SCROW nRow, bool bHasSelection, const OUString& rStr );
241 bool HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange );
243 bool DropScroll( const Point& rMousePos );
245 sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt );
246 sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt );
247 sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY,
248 const Point& rLogicPos, sal_Int8 nDndAction );
250 void HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventState& rState );
252 bool DrawMouseButtonDown(const MouseEvent& rMEvt);
253 bool DrawMouseButtonUp(const MouseEvent& rMEvt);
254 bool DrawMouseMove(const MouseEvent& rMEvt);
255 bool DrawKeyInput(const KeyEvent& rKEvt);
256 bool DrawCommand(const CommandEvent& rCEvt);
257 bool DrawHasMarkedObj();
258 void DrawEndAction();
259 void DrawMarkDropObj( SdrObject* pObj );
260 SdrObject* GetEditObject();
261 bool IsMyModel(SdrEditView* pSdrView);
263 void DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer );
264 void DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev );
265 void DrawAfterScroll();
266 Rectangle GetListValButtonRect( const ScAddress& rButtonPos );
268 void DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev );
270 bool GetEditUrl( const Point& rPos,
271 OUString* pName=0, OUString* pUrl=0, OUString* pTarget=0 );
273 bool IsSpellErrorAtPos( const Point& rPos, SCCOL nCol1, SCROW nRow );
275 bool HitRangeFinder( const Point& rMouse, RfCorner& rCorner, sal_uInt16* pIndex = NULL,
276 SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL );
278 sal_uInt16 HitPageBreak( const Point& rMouse, ScRange* pSource = NULL,
279 SCCOLROW* pBreak = NULL, SCCOLROW* pPrev = NULL );
281 /** The cell may be covered by text that overflows from a previous cell.
283 @return if true, the given cell is covered by (overflowing) text and
284 rTextStartPosX returns the column where the text that overflows
285 starts.
287 bool IsCellCoveredByText(SCsCOL nPosX, SCsROW nPosY, SCTAB nTab, SCsCOL &rTextStartPosX);
289 void PasteSelection( const Point& rPosPixel );
291 void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY );
293 void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
295 protected:
296 virtual void PrePaint(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
297 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
298 virtual void GetFocus() SAL_OVERRIDE;
299 virtual void LoseFocus() SAL_OVERRIDE;
301 virtual void RequestHelp( const HelpEvent& rEvt ) SAL_OVERRIDE;
302 virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
304 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
305 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
306 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
308 public:
309 enum AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty, SortAscending, SortDescending };
311 ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
312 virtual ~ScGridWindow();
313 virtual void dispose() SAL_OVERRIDE;
315 virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
316 // #i70788# flush and get overlay
317 rtl::Reference<sdr::overlay::OverlayManager> getOverlayManager();
318 void flushOverlayManager();
320 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
322 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
323 virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
324 virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
325 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
326 virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
328 void PaintTile( VirtualDevice& rDevice,
329 int nOutputWidth, int nOutputHeight,
330 int nTilePosX, int nTilePosY,
331 long nTileWidth, long nTileHeight );
333 /// @see OutputDevice::LogicInvalidate().
334 void LogicInvalidate(const Rectangle* pRectangle) SAL_OVERRIDE;
336 /// Update the cell selection according to what handles have been dragged.
337 /// @see vcl::ITiledRenderable::setTextSelection() for the values of nType.
338 /// Coordinates are in pixels.
339 void SetCellSelectionPixel(int nType, int nPixelX, int nPixelY);
341 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
343 void FakeButtonUp();
345 Point GetMousePosPixel() const { return aCurMousePos; }
346 void UpdateStatusPosSize();
348 void ClickExtern();
350 void SetPointer( const Pointer& rPointer );
352 void MoveMouseStatus( ScGridWindow &rDestWin );
354 void ScrollPixel( long nDifX, long nDifY );
355 void UpdateEditViewPos();
357 void UpdateFormulas();
359 void LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect );
360 void DoScenarioMenu( const ScRange& rScenRange );
362 void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
363 void RefreshAutoFilterButton(const ScAddress& rPos);
364 void UpdateAutoFilterFromMenu(AutoFilterMode eMode);
366 void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
367 void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
369 ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const;
371 void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, OutputDevice* pContentDev);
373 using Window::Draw;
374 void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
375 ScUpdateMode eMode = SC_UPDATE_ALL );
377 /// Draw content of the gridwindow; shared between the desktop and the tiled rendering.
378 void DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableInfo, ScOutputData& aOutputData, bool bLogicText, ScUpdateMode eMode);
380 void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
382 void HideCursor();
383 void ShowCursor();
384 void UpdateAutoFillMark(bool bMarked, const ScRange& rMarkRange);
386 void UpdateListValPos( bool bVisible, const ScAddress& rPos );
388 bool ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard );
389 void HideNoteMarker();
391 /// MapMode for the drawinglayer objects.
392 MapMode GetDrawMapMode( bool bForce = false );
394 void ContinueDrag();
396 void StopMarking();
397 void UpdateInputContext();
399 bool NeedsRepaint() { return bNeedsRepaint; }
401 void DoInvertRect( const Rectangle& rPixel );
403 void CheckNeedsRepaint();
405 void UpdateDPFromFieldPopupMenu();
406 bool UpdateVisibleRange();
408 void SetInRefMode( bool bRefMode );
410 // #114409#
411 void CursorChanged();
412 void DrawLayerCreated();
413 bool ContinueOnlineSpelling();
414 void EnableAutoSpell( bool bEnable );
415 void ResetAutoSpell();
416 void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
417 const std::vector<editeng::MisspellRanges>* GetAutoSpellData( SCCOL nPosX, SCROW nPosY );
418 bool InsideVisibleRange( SCCOL nPosX, SCROW nPosY );
420 void DeleteCopySourceOverlay();
421 void UpdateCopySourceOverlay();
422 void DeleteCursorOverlay();
423 void UpdateCursorOverlay();
424 void DeleteSelectionOverlay();
425 void UpdateSelectionOverlay();
426 void DeleteAutoFillOverlay();
427 void UpdateAutoFillOverlay();
428 void DeleteDragRectOverlay();
429 void UpdateDragRectOverlay();
430 void DeleteHeaderOverlay();
431 void UpdateHeaderOverlay();
432 void DeleteShrinkOverlay();
433 void UpdateShrinkOverlay();
434 void UpdateAllOverlays();
436 protected:
437 // #114409#
438 void ImpCreateOverlayObjects();
439 void ImpDestroyOverlayObjects();
443 #endif
445 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */