xref: /trunk/main/sc/source/ui/inc/gridwin.hxx (revision 69a743679e823ad8f875be547552acb607b8ada5)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_GRIDWIN_HXX
25 #define SC_GRIDWIN_HXX
26 
27 #include <tools/string.hxx>
28 #include <svtools/transfer.hxx>
29 #include "viewutil.hxx"
30 #include "viewdata.hxx"
31 #include "cbutton.hxx"
32 #include <svx/sdr/overlay/overlayobject.hxx>
33 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
34 #include <basegfx/matrix/b2dhommatrix.hxx>
35 
36 #include <vector>
37 #include <memory>
38 #include <boost/shared_ptr.hpp>
39 
40 // ---------------------------------------------------------------------------
41 
42 struct ScTableInfo;
43 class ScViewSelectionEngine;
44 class ScDPObject;
45 class ScDPFieldPopupWindow;
46 class ScDPFieldButton;
47 class ScOutputData;
48 class ScFilterListBox;
49 class AutoFilterPopup;
50 class SdrObject;
51 class SdrEditView;
52 class ScNoteMarker;
53 class FloatingWindow;
54 class SdrHdlList;
55 class ScTransferObj;
56 struct SpellCallbackInfo;
57 
58         //  Maus-Status (nMouseStatus)
59 
60 #define SC_GM_NONE          0
61 #define SC_GM_TABDOWN       1
62 #define SC_GM_DBLDOWN       2
63 #define SC_GM_FILTER        3
64 #define SC_GM_IGNORE        4
65 #define SC_GM_WATERUNDO     5
66 #define SC_GM_URLDOWN       6
67 
68         //  Page-Drag-Modus
69 
70 #define SC_PD_NONE          0
71 #define SC_PD_RANGE_L       1
72 #define SC_PD_RANGE_R       2
73 #define SC_PD_RANGE_T       4
74 #define SC_PD_RANGE_B       8
75 #define SC_PD_RANGE_TL      (SC_PD_RANGE_T|SC_PD_RANGE_L)
76 #define SC_PD_RANGE_TR      (SC_PD_RANGE_T|SC_PD_RANGE_R)
77 #define SC_PD_RANGE_BL      (SC_PD_RANGE_B|SC_PD_RANGE_L)
78 #define SC_PD_RANGE_BR      (SC_PD_RANGE_B|SC_PD_RANGE_R)
79 #define SC_PD_BREAK_H       16
80 #define SC_PD_BREAK_V       32
81 
82 
83 class ScHideTextCursor
84 {
85 private:
86     ScViewData* pViewData;
87     ScSplitPos  eWhich;
88 
89 public:
90             ScHideTextCursor( ScViewData* pData, ScSplitPos eW );
91             ~ScHideTextCursor();
92 };
93 
94 // ---------------------------------------------------------------------------
95 // predefines
96 namespace sdr { namespace overlay { class OverlayObjectList; }}
97 
98 class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHelper
99 {
100     //  ScFilterListBox wird immer fuer Auswahlliste benutzt
101     friend class ScFilterListBox;
102 
103 private:
104     // #114409#
105     ::sdr::overlay::OverlayObjectList*              mpOOCursors;
106     ::sdr::overlay::OverlayObjectList*              mpOOSelection;
107     ::sdr::overlay::OverlayObjectList*              mpOOAutoFill;
108     ::sdr::overlay::OverlayObjectList*              mpOODragRect;
109     ::sdr::overlay::OverlayObjectList*              mpOOHeader;
110     ::sdr::overlay::OverlayObjectList*              mpOOShrink;
111 
112     ::boost::shared_ptr<Rectangle> mpAutoFillRect;
113 
114     /**
115      * Stores current visible column and row ranges, used to avoid expensive
116      * operations on objects that are outside visible area.
117      */
118     struct VisibleRange
119     {
120         SCCOL mnCol1;
121         SCCOL mnCol2;
122         SCROW mnRow1;
123         SCROW mnRow2;
124 
125         VisibleRange();
126 
127         bool isInside(SCCOL nCol, SCROW nRow) const;
128     };
129     VisibleRange maVisibleRange;
130 
131 private:
132     ScViewData*             pViewData;
133     ScSplitPos              eWhich;
134     ScHSplitPos             eHWhich;
135     ScVSplitPos             eVWhich;
136 
137     ScNoteMarker*           pNoteMarker;
138 
139     ScFilterListBox*        pFilterBox;
140     FloatingWindow*         pFilterFloat;
141     ::std::auto_ptr<ScDPFieldPopupWindow> mpDPFieldPopup;
142     ::std::auto_ptr<ScDPFieldButton>      mpFilterButton;
143 
144     sal_uInt16                  nCursorHideCount;
145 
146     sal_Bool                    bMarking;
147 
148     sal_uInt16                  nButtonDown;
149     sal_Bool                    bEEMouse;               // Edit-Engine hat Maus
150     sal_uInt8                   nMouseStatus;
151     sal_uInt8                    nNestedButtonState;     // track nested button up/down calls
152 
153     sal_Bool                    bDPMouse;               // DataPilot-D&D (neue Pivottabellen)
154     long                    nDPField;
155     ScDPObject*             pDragDPObj; //! name?
156 
157     sal_Bool                    bRFMouse;               // RangeFinder-Drag
158     sal_Bool                    bRFSize;
159     sal_uInt16                  nRFIndex;
160     SCsCOL                  nRFAddX;
161     SCsROW                  nRFAddY;
162 
163     sal_uInt16                  nPagebreakMouse;        // Pagebreak-Modus Drag
164     SCCOLROW                nPagebreakBreak;
165     SCCOLROW                nPagebreakPrev;
166     ScRange                 aPagebreakSource;
167     ScRange                 aPagebreakDrag;
168     sal_Bool                    bPagebreakDrawn;
169 
170     sal_uInt8                   nPageScript;
171 
172     long                    nLastClickX;
173     long                    nLastClickY;
174 
175     sal_Bool                    bDragRect;
176     SCCOL                   nDragStartX;
177     SCROW                   nDragStartY;
178     SCCOL                   nDragEndX;
179     SCROW                   nDragEndY;
180     InsCellCmd              meDragInsertMode;
181 
182     sal_uInt16                  nCurrentPointer;
183 
184     sal_Bool                    bIsInScroll;
185     sal_Bool                    bIsInPaint;
186 
187     ScDDComboBoxButton      aComboButton;
188 
189     Point                   aCurMousePos;
190 
191     sal_uInt16                  nPaintCount;
192     Rectangle               aRepaintPixel;
193     sal_Bool                    bNeedsRepaint;
194 
195     sal_Bool                    bAutoMarkVisible;
196     ScAddress               aAutoMarkPos;
197 
198     sal_Bool                    bListValButton;
199     ScAddress               aListValPos;
200 
201     Rectangle               aInvertRect;
202 
203     DECL_LINK( PopupModeEndHdl, FloatingWindow* );
204     DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* );
205 
206     sal_Bool            TestMouse( const MouseEvent& rMEvt, sal_Bool bAction );
207 
208     sal_Bool            DoPageFieldSelection( SCCOL nCol, SCROW nRow );
209     bool            DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
210     void            DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
211 
212     void            DPMouseMove( const MouseEvent& rMEvt );
213     void            DPMouseButtonUp( const MouseEvent& rMEvt );
214     void            DPTestMouse( const MouseEvent& rMEvt, sal_Bool bMove );
215 
216     /**
217      * Check if the mouse click is on a field popup button.
218      *
219      * @return bool true if the field popup menu has been launched and no
220      *         further mouse event handling is necessary, false otherwise.
221      */
222     bool            DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj);
223     void            DPLaunchFieldPopupMenu(
224         const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj);
225 
226     void            RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp );
227 
228     void            PagebreakMove( const MouseEvent& rMEvt, sal_Bool bUp );
229 
230     void            UpdateDragRect( sal_Bool bShowRange, const Rectangle& rPosRect );
231 
232     sal_Bool            IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab );
233     void            ExecFilter( sal_uLong nSel, SCCOL nCol, SCROW nRow,
234                                 const String& aValue, bool bCheckForDates );
235     void            FilterSelect( sal_uLong nSel );
236 
237     void            ExecDataSelect( SCCOL nCol, SCROW nRow, const String& rStr );
238 
239     void            ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSelection, const String& rStr );
240 
241     sal_Bool            HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange );
242 //IAccessibility2 Implementation 2009-----
243     sal_Bool            HasScenarioRange( sal_uInt16 nCol, sal_Int32 nRow, ScRange& rScenRange );
244 //-----IAccessibility2 Implementation 2009
245     sal_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 );
253 
254     sal_Bool            DrawMouseButtonDown(const MouseEvent& rMEvt);
255     sal_Bool            DrawMouseButtonUp(const MouseEvent& rMEvt);
256     sal_Bool            DrawMouseMove(const MouseEvent& rMEvt);
257     sal_Bool            DrawKeyInput(const KeyEvent& rKEvt);
258     sal_Bool            DrawCommand(const CommandEvent& rCEvt);
259     sal_Bool            DrawHasMarkedObj();
260     void            DrawEndAction();
261     void            DrawMarkDropObj( SdrObject* pObj );
262     SdrObject*      GetEditObject();
263     sal_Bool            IsMyModel(SdrEditView* pSdrView);
264     //void          DrawStartTimer();
265 
266     void            DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer );
267     void            DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev );
268     //sal_Bool          DrawBeforeScroll();
269     void            DrawAfterScroll(/*sal_Bool bVal*/);
270     //void          DrawMarks();
271     //sal_Bool          NeedDrawMarks();
272     void            DrawComboButton( const Point&   rCellPos,
273                                      long           nCellSizeX,
274                                      long           nCellSizeY,
275                                      sal_Bool           bArrowState,
276                                      sal_Bool           bBtnIn  = sal_False );
277     Rectangle       GetListValButtonRect( const ScAddress& rButtonPos );
278 
279     void            DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev );
280 
281     sal_Bool            GetEditUrl( const Point& rPos,
282                                 String* pName=0, String* pUrl=0, String* pTarget=0 );
283     sal_Bool            GetEditUrlOrError( sal_Bool bSpellErr, const Point& rPos,
284                                 String* pName=0, String* pUrl=0, String* pTarget=0 );
285 
286     sal_Bool            HitRangeFinder( const Point& rMouse, sal_Bool& rCorner, sal_uInt16* pIndex = NULL,
287                                         SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL );
288 
289     sal_uInt16          HitPageBreak( const Point& rMouse, ScRange* pSource = NULL,
290                                     SCCOLROW* pBreak = NULL, SCCOLROW* pPrev = NULL );
291 
292     void            PasteSelection( const Point& rPosPixel );
293 
294     void            SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY );
295 
296     void            GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
297 
298 protected:
299     using Window::Resize;
300     virtual void    Resize( const Size& rSize );
301     virtual void    PrePaint();
302     virtual void    Paint( const Rectangle& rRect );
303     virtual void    KeyInput(const KeyEvent& rKEvt);
304     virtual void    GetFocus();
305     virtual void    LoseFocus();
306 
307     virtual void    RequestHelp( const HelpEvent& rEvt );
308     virtual void    Command( const CommandEvent& rCEvt );
309 
310     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
311     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
312     virtual void    StartDrag( sal_Int8 nAction, const Point& rPosPixel );
313 
314 public:
315     ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
316     ~ScGridWindow();
317 
318     // #i70788# flush and get overlay
319     ::sdr::overlay::OverlayManager* getOverlayManager();
320     void flushOverlayManager();
321 
322     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
323 
324     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
325     virtual void    MouseButtonUp( const MouseEvent& rMEvt );
326     virtual void    MouseMove( const MouseEvent& rMEvt );
327     virtual long    PreNotify( NotifyEvent& rNEvt );
328     virtual void    Tracking( const TrackingEvent& rTEvt );
329 
330     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
331 
332     void            FakeButtonUp();
333 
334     Point           GetMousePosPixel() const;
335     void            UpdateStatusPosSize();
336 
337     void            ClickExtern();
338 
339     void            SetPointer( const Pointer& rPointer );
340 
341     void            MoveMouseStatus( ScGridWindow &rDestWin );
342 
343     void            ScrollPixel( long nDifX, long nDifY );
344     void            UpdateEditViewPos();
345 
346     void            UpdateFormulas();
347 
348     void            DoAutoFilterMenue( SCCOL nCol, SCROW nRow, sal_Bool bDataSelect );
349     void            DoScenarioMenue( const ScRange& rScenRange );
350 
351     void            LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
352     void            LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
353 
354     ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const;
355 
356     void            DrawButtons( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
357                                     ScTableInfo& rTabInfo, OutputDevice* pContentDev );
358 
359     using Window::Draw;
360     void            Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
361                         ScUpdateMode eMode = SC_UPDATE_ALL );
362 
363     void            InvertSimple( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
364                                     sal_Bool bTestMerge = sal_False, sal_Bool bRepeat = sal_False );
365 
366 //UNUSED2008-05  void           DrawDragRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
367 
368     void            CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
369 
370     void            HideCursor();
371     void            ShowCursor();
372     void            DrawCursor();
373     void            DrawAutoFillMark();
374     void            UpdateAutoFillMark(sal_Bool bMarked, const ScRange& rMarkRange);
375 
376     void            UpdateListValPos( sal_Bool bVisible, const ScAddress& rPos );
377 
378     sal_Bool            ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, sal_Bool bKeyboard );
379     void            HideNoteMarker();
380 
381     MapMode         GetDrawMapMode( sal_Bool bForce = sal_False );
382 
383     void            ContinueDrag();
384 
385     void            StopMarking();
386     void            UpdateInputContext();
387 
388     void            CheckInverted()     { if (nPaintCount) bNeedsRepaint = sal_True; }
389 
390     void            DoInvertRect( const Rectangle& rPixel );
391 
392     void            CheckNeedsRepaint();
393 //IAccessibility2 Implementation 2009-----
394     virtual void SwitchView();
395 //-----IAccessibility2 Implementation 2009
396 
397     void            UpdateDPFromFieldPopupMenu();
398 
399     void            UpdateVisibleRange();
400 
401     // #114409#
402     void CursorChanged();
403     void DrawLayerCreated();
404 
405     void            DeleteCursorOverlay();
406     void            UpdateCursorOverlay();
407     void            DeleteSelectionOverlay();
408     void            UpdateSelectionOverlay();
409     void            DeleteAutoFillOverlay();
410     void            UpdateAutoFillOverlay();
411     void            DeleteDragRectOverlay();
412     void            UpdateDragRectOverlay();
413     void            DeleteHeaderOverlay();
414     void            UpdateHeaderOverlay();
415     void            DeleteShrinkOverlay();
416     void            UpdateShrinkOverlay();
417     void            UpdateAllOverlays();
418 
419 protected:
420     // #114409#
421     void ImpCreateOverlayObjects();
422     void ImpDestroyOverlayObjects();
423 
424 };
425 
426 
427 
428 #endif
429 
430