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 :
20 : #ifndef INCLUDED_SC_SOURCE_UI_INC_GRIDWIN_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_GRIDWIN_HXX
22 :
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>
30 :
31 : #include <vector>
32 : #include <boost/scoped_ptr.hpp>
33 : #include <boost/unordered_map.hpp>
34 : #include <boost/ptr_container/ptr_map.hpp>
35 : #include <boost/ptr_container/ptr_vector.hpp>
36 :
37 : namespace editeng {
38 : struct MisspellRanges;
39 : }
40 :
41 : namespace sc {
42 : struct SpellCheckContext;
43 : }
44 :
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;
58 :
59 : // Maus-Status (nMouseStatus)
60 :
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
68 :
69 : // Page-Drag-Modus
70 :
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
82 :
83 : // predefines
84 : namespace sdr { namespace overlay { class OverlayObjectList; }}
85 :
86 : class ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSourceHelper
87 : {
88 : // ScFilterListBox is always used for selection list
89 : friend class ScFilterListBox;
90 :
91 : enum RfCorner
92 : {
93 : NONE,
94 : LEFT_UP,
95 : RIGHT_UP,
96 : LEFT_DOWN,
97 : RIGHT_DOWN
98 : };
99 :
100 : // #114409#
101 : ::sdr::overlay::OverlayObjectList* mpOOCursors;
102 : ::sdr::overlay::OverlayObjectList* mpOOSelection;
103 : ::sdr::overlay::OverlayObjectList* mpOOSelectionBorder;
104 : ::sdr::overlay::OverlayObjectList* mpOOAutoFill;
105 : ::sdr::overlay::OverlayObjectList* mpOODragRect;
106 : ::sdr::overlay::OverlayObjectList* mpOOHeader;
107 : ::sdr::overlay::OverlayObjectList* mpOOShrink;
108 :
109 : boost::scoped_ptr<Rectangle> mpAutoFillRect;
110 :
111 : struct MouseEventState;
112 :
113 : /**
114 : * Stores current visible column and row ranges, used to avoid expensive
115 : * operations on objects that are outside visible area.
116 : */
117 : struct VisibleRange
118 : {
119 : SCCOL mnCol1;
120 : SCCOL mnCol2;
121 : SCROW mnRow1;
122 : SCROW mnRow2;
123 :
124 : VisibleRange();
125 :
126 : bool isInside(SCCOL nCol, SCROW nRow) const;
127 : bool set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
128 : };
129 :
130 : VisibleRange maVisibleRange;
131 :
132 : boost::scoped_ptr<sc::SpellCheckContext> mpSpellCheckCxt;
133 :
134 : ScViewData* pViewData;
135 : ScSplitPos eWhich;
136 : ScHSplitPos eHWhich;
137 : ScVSplitPos eVWhich;
138 :
139 : ScNoteMarker* pNoteMarker;
140 :
141 : ScFilterListBox* pFilterBox;
142 : FloatingWindow* pFilterFloat;
143 : boost::scoped_ptr<ScCheckListMenuWindow> mpAutoFilterPopup;
144 : boost::scoped_ptr<ScCheckListMenuWindow> mpDPFieldPopup;
145 : boost::scoped_ptr<ScDPFieldButton> mpFilterButton;
146 :
147 : sal_uInt16 nCursorHideCount;
148 :
149 : sal_uInt16 nButtonDown;
150 : sal_uInt8 nMouseStatus;
151 : sal_uInt8 nNestedButtonState; // track nested button up/down calls
152 :
153 : long nDPField;
154 : ScDPObject* pDragDPObj; //! name?
155 :
156 : sal_uInt16 nRFIndex;
157 : SCsCOL nRFAddX;
158 : SCsROW nRFAddY;
159 :
160 : sal_uInt16 nPagebreakMouse; // Page break mode, Drag
161 : SCCOLROW nPagebreakBreak;
162 : SCCOLROW nPagebreakPrev;
163 : ScRange aPagebreakSource;
164 : ScRange aPagebreakDrag;
165 :
166 : sal_uInt8 nPageScript;
167 :
168 : long nLastClickX;
169 : long nLastClickY;
170 :
171 : SCCOL nDragStartX;
172 : SCROW nDragStartY;
173 : SCCOL nDragEndX;
174 : SCROW nDragEndY;
175 : InsCellCmd meDragInsertMode;
176 :
177 : sal_uInt16 nCurrentPointer;
178 :
179 : ScDDComboBoxButton aComboButton;
180 :
181 : Point aCurMousePos;
182 :
183 : sal_uInt16 nPaintCount;
184 : Rectangle aRepaintPixel;
185 :
186 : ScAddress aAutoMarkPos;
187 : ScAddress aListValPos;
188 :
189 : Rectangle aInvertRect;
190 :
191 : RfCorner aRFSelectedCorned;
192 :
193 : bool bEEMouse:1; // Edit Engine has mouse
194 : bool bDPMouse:1; // DataPilot D&D (new Pivot table)
195 : bool bRFMouse:1; // RangeFinder drag
196 : bool bRFSize:1;
197 : bool bPagebreakDrawn:1;
198 : bool bDragRect:1;
199 : bool bIsInScroll:1;
200 : bool bIsInPaint:1;
201 : bool bNeedsRepaint:1;
202 : bool bAutoMarkVisible:1;
203 : bool bListValButton:1;
204 :
205 : DECL_LINK( PopupModeEndHdl, void* );
206 : DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* );
207 :
208 : bool TestMouse( const MouseEvent& rMEvt, bool bAction );
209 :
210 : bool DoPageFieldSelection( SCCOL nCol, SCROW nRow );
211 : bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
212 : void DoPushPivotButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt, bool bButton, bool bPopup );
213 :
214 : void DPMouseMove( const MouseEvent& rMEvt );
215 : void DPMouseButtonUp( const MouseEvent& rMEvt );
216 : void DPTestMouse( const MouseEvent& rMEvt, bool bMove );
217 :
218 : /**
219 : * Check if the mouse click is on a field popup button.
220 : *
221 : * @return true if the field popup menu has been launched and no further
222 : * mouse event handling is necessary, false otherwise.
223 : */
224 : bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, const ScAddress& rDimPos, ScDPObject* pDPObj);
225 : void DPLaunchFieldPopupMenu(
226 : const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj);
227 :
228 : void RFMouseMove( const MouseEvent& rMEvt, bool bUp );
229 :
230 : void PagebreakMove( const MouseEvent& rMEvt, bool bUp );
231 :
232 : void UpdateDragRect( bool bShowRange, const Rectangle& rPosRect );
233 :
234 : bool IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab );
235 : void ExecFilter( sal_uLong nSel, SCCOL nCol, SCROW nRow,
236 : const OUString& aValue, bool bCheckForDates );
237 : void FilterSelect( sal_uLong nSel );
238 :
239 : void ExecDataSelect( SCCOL nCol, SCROW nRow, const OUString& rStr );
240 :
241 : void ExecPageFieldSelect( SCCOL nCol, SCROW nRow, bool bHasSelection, const OUString& rStr );
242 :
243 : bool HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange );
244 :
245 : bool DropScroll( const Point& rMousePos );
246 :
247 : sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt );
248 : sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt );
249 : sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY,
250 : const Point& rLogicPos, sal_Int8 nDndAction );
251 :
252 : void HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventState& rState );
253 :
254 : bool DrawMouseButtonDown(const MouseEvent& rMEvt);
255 : bool DrawMouseButtonUp(const MouseEvent& rMEvt);
256 : bool DrawMouseMove(const MouseEvent& rMEvt);
257 : bool DrawKeyInput(const KeyEvent& rKEvt);
258 : bool DrawCommand(const CommandEvent& rCEvt);
259 : bool DrawHasMarkedObj();
260 : void DrawEndAction();
261 : void DrawMarkDropObj( SdrObject* pObj );
262 : SdrObject* GetEditObject();
263 : bool IsMyModel(SdrEditView* pSdrView);
264 :
265 : void DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer );
266 : void DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev );
267 : void DrawAfterScroll();
268 : Rectangle GetListValButtonRect( const ScAddress& rButtonPos );
269 :
270 : void DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev );
271 :
272 : bool GetEditUrl( const Point& rPos,
273 : OUString* pName=0, OUString* pUrl=0, OUString* pTarget=0 );
274 :
275 : bool IsSpellErrorAtPos( const Point& rPos, SCCOL nCol1, SCROW nRow );
276 :
277 : bool HitRangeFinder( const Point& rMouse, RfCorner& rCorner, sal_uInt16* pIndex = NULL,
278 : SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL );
279 :
280 : sal_uInt16 HitPageBreak( const Point& rMouse, ScRange* pSource = NULL,
281 : SCCOLROW* pBreak = NULL, SCCOLROW* pPrev = NULL );
282 :
283 : void PasteSelection( const Point& rPosPixel );
284 :
285 : void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY );
286 :
287 : void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
288 :
289 : protected:
290 : using Window::Resize;
291 : virtual void Resize( const Size& rSize );
292 : virtual void PrePaint() SAL_OVERRIDE;
293 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
294 : virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
295 : virtual void GetFocus() SAL_OVERRIDE;
296 : virtual void LoseFocus() SAL_OVERRIDE;
297 :
298 : virtual void RequestHelp( const HelpEvent& rEvt ) SAL_OVERRIDE;
299 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
300 :
301 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
302 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
303 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
304 :
305 : public:
306 : enum AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty, SortAscending, SortDescending };
307 :
308 : ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
309 : virtual ~ScGridWindow();
310 :
311 : // #i70788# flush and get overlay
312 : rtl::Reference<sdr::overlay::OverlayManager> getOverlayManager();
313 : void flushOverlayManager();
314 :
315 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
316 :
317 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
318 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
319 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
320 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
321 : virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
322 :
323 : void PaintTile( VirtualDevice& rDevice,
324 : int nOutputWidth, int nOutputHeight,
325 : int nTilePosX, int nTilePosY,
326 : long nTileWidth, long nTileHeight );
327 :
328 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
329 :
330 : void FakeButtonUp();
331 :
332 0 : Point GetMousePosPixel() const { return aCurMousePos; }
333 : void UpdateStatusPosSize();
334 :
335 : void ClickExtern();
336 :
337 : void SetPointer( const Pointer& rPointer );
338 :
339 : void MoveMouseStatus( ScGridWindow &rDestWin );
340 :
341 : void ScrollPixel( long nDifX, long nDifY );
342 : void UpdateEditViewPos();
343 :
344 : void UpdateFormulas();
345 :
346 : void LaunchDataSelectMenu( SCCOL nCol, SCROW nRow, bool bDataSelect );
347 : void DoScenarioMenu( const ScRange& rScenRange );
348 :
349 : void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
350 : void RefreshAutoFilterButton(const ScAddress& rPos);
351 : void UpdateAutoFilterFromMenu(AutoFilterMode eMode);
352 :
353 : void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
354 : void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
355 :
356 : ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const;
357 :
358 : void DrawButtons( SCCOL nX1, SCCOL nX2, ScTableInfo& rTabInfo, OutputDevice* pContentDev);
359 :
360 : using Window::Draw;
361 : void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
362 : ScUpdateMode eMode = SC_UPDATE_ALL );
363 :
364 : void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
365 :
366 : void HideCursor();
367 : void ShowCursor();
368 : void UpdateAutoFillMark(bool bMarked, const ScRange& rMarkRange);
369 :
370 : void UpdateListValPos( bool bVisible, const ScAddress& rPos );
371 :
372 : bool ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, bool bKeyboard );
373 : void HideNoteMarker();
374 :
375 : MapMode GetDrawMapMode( bool bForce = false );
376 :
377 : void ContinueDrag();
378 :
379 : void StopMarking();
380 : void UpdateInputContext();
381 :
382 0 : bool NeedsRepaint() { return bNeedsRepaint; }
383 :
384 : void DoInvertRect( const Rectangle& rPixel );
385 :
386 : void CheckNeedsRepaint();
387 : virtual void SwitchView();
388 :
389 : void UpdateDPFromFieldPopupMenu();
390 : bool UpdateVisibleRange();
391 :
392 : void SetInRefMode( bool bRefMode );
393 :
394 : // #114409#
395 : void CursorChanged();
396 : void DrawLayerCreated();
397 : bool ContinueOnlineSpelling();
398 : void EnableAutoSpell( bool bEnable );
399 : void ResetAutoSpell();
400 : void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
401 :
402 : void DeleteCopySourceOverlay();
403 : void UpdateCopySourceOverlay();
404 : void DeleteCursorOverlay();
405 : void UpdateCursorOverlay();
406 : void DeleteSelectionOverlay();
407 : void UpdateSelectionOverlay();
408 : void DeleteAutoFillOverlay();
409 : void UpdateAutoFillOverlay();
410 : void DeleteDragRectOverlay();
411 : void UpdateDragRectOverlay();
412 : void DeleteHeaderOverlay();
413 : void UpdateHeaderOverlay();
414 : void DeleteShrinkOverlay();
415 : void UpdateShrinkOverlay();
416 : void UpdateAllOverlays();
417 :
418 : protected:
419 : // #114409#
420 : void ImpCreateOverlayObjects();
421 : void ImpDestroyOverlayObjects();
422 :
423 : };
424 :
425 : #endif
426 :
427 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|