LCOV - code coverage report
Current view: top level - include/svx - svddrgv.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 18 34 52.9 %
Date: 2015-06-13 12:38:46 Functions: 18 34 52.9 %
Legend: Lines: hit not hit

          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_SVX_SVDDRGV_HXX
      21             : #define INCLUDED_SVX_SVDDRGV_HXX
      22             : 
      23             : #include <svx/svxdllapi.h>
      24             : #include <svx/svdxcgv.hxx>
      25             : 
      26             : class SdrUndoGeoObj;
      27             : 
      28             : class SVX_DLLPUBLIC SdrDragView: public SdrExchangeView
      29             : {
      30             :     friend class                SdrPageView;
      31             :     friend class                SdrDragMethod;
      32             : 
      33             : protected:
      34             :     SdrHdl*                     mpDragHdl;
      35             :     SdrDragMethod*              mpCurrentSdrDragMethod;
      36             :     SdrUndoGeoObj*              mpInsPointUndo;
      37             :     Rectangle                   maDragLimit;
      38             :     OUString               maInsPointUndoStr;
      39             :     SdrMarkList                 maFollowingEdges; // If nodes are dragged, all edges should follow as Xor
      40             :     SdrHdlKind                  meDragHdl;
      41             : 
      42             :     sal_uIntPtr                     mnDragXorPolyLimit;
      43             :     sal_uIntPtr                     mnDragXorPointLimit;
      44             :     sal_uInt16                      mnDetailedEdgeDraggingLimit;
      45             : 
      46             :     bool                        mbFramDrag : 1;        // currently frame dragging
      47             :     bool                        mbDragSpecial : 1;     // currently Special Obj-dragging
      48             :     bool                        mbMarkedHitMovesAlways : 1; // Persistent
      49             :     bool                        mbDragLimit : 1;      // Limit on SnapRect instead of BoundRect
      50             :     bool                        mbDragHdl : 1;        // TRUE: RefPt is slid
      51             :     bool                        mbDragStripes : 1;    // Persistent
      52             :     bool                        mbMirrRefDragObj : 1; // Persistent - During the drag, show the mirror axis of the mirrored objects as Xor
      53             :     bool                        mbSolidDragging : 1;  // allow solid create/drag of objects
      54             :     bool                        mbMouseHideWhileDraggingPoints : 1;
      55             :     bool                        mbResizeAtCenter : 1;
      56             :     bool                        mbCrookAtCenter : 1;
      57             :     bool                        mbDragWithCopy : 1;
      58             :     bool                        mbInsGluePoint : 1;
      59             :     bool                        mbInsObjPointMode : 1;
      60             :     bool                        mbInsGluePointMode : 1;
      61             :     bool                        mbNoDragXorPolys : 1;
      62             :     bool                        mbAutoVertexCon : 1;  // automatic generation of connectors at the vertices
      63             :     bool                        mbAutoCornerCon : 1;  // automatic geneartion of connectors at the corners
      64             :     bool                        mbRubberEdgeDragging : 1;
      65             :     bool                        mbDetailedEdgeDragging : 1;
      66             : 
      67             : private:
      68             :     SVX_DLLPRIVATE void ImpClearVars();
      69             : 
      70             : protected:
      71             :     virtual void SetMarkHandles() SAL_OVERRIDE;
      72             :     void ShowDragObj();
      73             :     void HideDragObj();
      74             :     bool ImpBegInsObjPoint(bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, bool bNewObj, OutputDevice* pOut);
      75             : 
      76             : protected:
      77             :     // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
      78             :     SdrDragView(SdrModel* pModel1, OutputDevice* pOut = 0L);
      79             :     virtual ~SdrDragView();
      80             : 
      81             : public:
      82             :     virtual bool IsAction() const SAL_OVERRIDE;
      83             :     virtual void MovAction(const Point& rPnt) SAL_OVERRIDE;
      84             :     virtual void EndAction() SAL_OVERRIDE;
      85             :     virtual void BckAction() SAL_OVERRIDE;
      86             :     virtual void BrkAction() SAL_OVERRIDE;
      87             :     virtual void TakeActionRect(Rectangle& rRect) const SAL_OVERRIDE;
      88             : 
      89             :     // special implementation for Writer:
      90             :     // TakeDragObjAnchorPos() returns the position at which an object
      91             :     // approximately ends up during dragging when it is "released"
      92             :     // (EndDrag).
      93             :     // As a general rule, this is the left upper corner of the expected
      94             :     // new SnapRect. Exception: CaptionObj. There, it is the position
      95             :     // of the "tail end".
      96             :     // In case of return value 'false', the position could not be
      97             :     // determined (e.g. point shift, multiple selection, shift of the
      98             :     // mirror axis,...)
      99             :     bool TakeDragObjAnchorPos(Point& rPos, bool bTopRight = false ) const;
     100             : 
     101             :     // If pForcedMeth is passed, then pHdl, ... is not evaluated, but this Drag
     102             :     // method is used. In this, the ownership of the instance passes
     103             :     // to the View and is destroyed at the end of the dragging.
     104             :     virtual bool BegDragObj(const Point& rPnt, OutputDevice* pOut=NULL, SdrHdl* pHdl=NULL, short nMinMov=-3, SdrDragMethod* pForcedMeth=NULL);
     105             :     void MovDragObj(const Point& rPnt);
     106             :     bool EndDragObj(bool bCopy=false);
     107             :     void BrkDragObj();
     108    26779110 :     bool IsDragObj() const { return mpCurrentSdrDragMethod && !bInsPolyPoint && !mbInsGluePoint; }
     109           0 :     SdrHdl* GetDragHdl() const { return mpDragHdl; }
     110           1 :     SdrDragMethod* GetDragMethod() const { return mpCurrentSdrDragMethod; }
     111           6 :     bool IsDraggingPoints() const { return meDragHdl==HDL_POLY; }
     112           6 :     bool IsDraggingGluePoints() const { return meDragHdl==HDL_GLUE; }
     113             : 
     114             :     // If you want to define that already during BegDrag
     115             :     // or in the middle.
     116             :     // (Is reset to 'false' on each BegDrag, so set it after BegDrag.)
     117         240 :     void SetDragWithCopy(bool bOn) { mbDragWithCopy = bOn; }
     118           3 :     bool IsDragWithCopy() const { return mbDragWithCopy; }
     119             : 
     120           2 :     void SetInsertGluePoint(bool bOn) { mbInsGluePoint = bOn; }
     121           8 :     bool IsInsertGluePoint() const { return mbInsGluePoint; }
     122             : 
     123             :     // Interactive insertion of a new point. nIdx=0 => in front of the first point
     124             :     bool IsInsObjPointPossible() const;
     125           0 :     bool BegInsObjPoint(const Point& rPnt, bool bNewObj) { return ImpBegInsObjPoint(false, 0L, rPnt, bNewObj, 0L); }
     126           0 :     void MovInsObjPoint(const Point& rPnt) { MovDragObj(rPnt); }
     127             :     bool EndInsObjPoint(SdrCreateCmd eCmd);
     128             :     void BrkInsObjPoint() { BrkDragObj(); }
     129        3703 :     bool IsInsObjPoint() const { return mpCurrentSdrDragMethod && bInsPolyPoint; }
     130             : 
     131             :     // For the app to manage the status. GetPreferredPointer() is
     132             :     // possibly going to deliver a matching pointer for it.
     133           0 :     void SetInsObjPointMode(bool bOn) { mbInsObjPointMode = bOn; }
     134           0 :     bool IsInsObjPointMode() const { return mbInsObjPointMode; }
     135             : 
     136             :     bool IsInsGluePointPossible() const;
     137             :     bool BegInsGluePoint(const Point& rPnt);
     138             :     void MovInsGluePoint(const Point& rPnt) { MovDragObj(rPnt); }
     139             :     bool EndInsGluePoint() { return EndDragObj(); }
     140             :     void BrkInsGluePoint() { BrkDragObj(); }
     141           0 :     bool IsInsGluePoint() const { return mpCurrentSdrDragMethod && mbInsGluePoint; }
     142             : 
     143             :     // For the app to manage the status. GetPreferredPointer() is
     144             :     // possibly going to deliver a matching pointer for it.
     145           0 :     void SetInsGluePointMode(bool bOn) { mbInsGluePointMode = bOn; }
     146         171 :     bool IsInsGluePointMode() const { return mbInsGluePointMode; }
     147             : 
     148             :     // border lines over the whole win persistent during the
     149             :     // whole dragging. Default=FALSE.
     150             :     void SetDragStripes(bool bOn);
     151        3031 :     bool IsDragStripes() const { return mbDragStripes; }
     152             : 
     153             :     // hide handles during dragging
     154             :     //HMHvoid SetDragHdlHide(bool bOn);
     155             :     //HMHBOOL IsDragHdlHide() const { return bNoDragHdl; }
     156             : 
     157             :     // Hide the mouse when dragging polygon points or glue points.
     158             :     // Default=false
     159             :     void SetMouseHideWhileDraggingPoints(bool bOn) { mbMouseHideWhileDraggingPoints = bOn; }
     160           0 :     bool IsMouseHideWhileDraggingPoints() const { return mbMouseHideWhileDraggingPoints; }
     161             : 
     162             :     // As a general rule, the contours of the selected objects
     163             :     // are displayed as Xor-polygons. If this flag is set, only one
     164             :     // Xor-Frame is drawn (e.g. in case of multiple selection).
     165             :     // In case of object-specific dragging (polygon points, corner radius,...),
     166             :     // this setting has no influence.
     167             :     // Also changeable during the dragging.
     168             :     // Default=Off
     169             :     void SetNoDragXorPolys(bool bOn);
     170        3485 :     bool IsNoDragXorPolys() const { return mbNoDragXorPolys; }
     171             : 
     172             :     // If the number of selected objects exceeds te value set here,
     173             :     // NoDragPolys is (temporarily) activated implicitely.
     174             :     // PolyPolygons etc. are regarded as multiple objects respectively.
     175             :     // Default=100
     176             :     void  SetDragXorPolyLimit(sal_uIntPtr nLimit) { mnDragXorPolyLimit=nLimit; }
     177           0 :     sal_uIntPtr GetDragXorPolyLimit() const { return mnDragXorPolyLimit; }
     178             : 
     179             :     // Like DragXorPolyLimit, but in respect to the total number of
     180             :     // all polygons. Default=500.
     181             :     // NoDragPolys is (temporarily) activated, if one of the limits
     182             :     // is exceeded.
     183             :     void  SetDragXorPointLimit(sal_uIntPtr nPointCount) { mnDragXorPointLimit=nPointCount; }
     184           0 :     sal_uIntPtr GetDragXorPointLimit() const { return mnDragXorPointLimit; }
     185             : 
     186             :     void SetSolidDragging(bool bOn);
     187             :     bool IsSolidDragging() const;
     188             : 
     189             :     // Dragging/Creation of connectors:
     190             :     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     191             :     // Stick Connectors to vertices
     192             :     // Default=true=Yes
     193             :     void SetAutoVertexConnectors(bool bOn) { mbAutoVertexCon = bOn; }
     194           0 :     bool IsAutoVertexConnectors() const { return mbAutoVertexCon; }
     195             : 
     196             :     // Stick Connectors to Corners
     197             :     // Default=false=No
     198             :     void SetAutoCornerConnectors(bool bOn) { mbAutoCornerCon = bOn; }
     199           0 :     bool IsAutoCornerConnectors() const { return mbAutoCornerCon; }
     200             : 
     201             :     // Dragging of connected objects (Nodes):
     202             :     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     203             :     // DetailedEdgeDraggingLimit: like RubberEdgeDraggingLimit,
     204             :     // but this limit refers to the detailed depiction, i.e. not
     205             :     // only rubber bands but total recalculations are visible while
     206             :     // dragging. This detailed depiction is only possible in MoveDrag.
     207             :     // Default value: 10
     208           0 :     bool IsDetailedEdgeDragging() const { return mbDetailedEdgeDragging; }
     209             : 
     210             :     sal_uInt16 GetDetailedEdgeDraggingLimit() const { return mnDetailedEdgeDraggingLimit; }
     211             : 
     212             :     // EdgeDraggingLimit: If more than nEdgeObjCount edges are affected,
     213             :     // they are not shown in the interactive dragging.
     214             :     // This here talks about the "rubber bands", which take less computing time
     215             :     // than the complete recalculations in the DetailedEdgeDragging.
     216             :     // default value: 100
     217           0 :     bool IsRubberEdgeDragging() const { return mbRubberEdgeDragging; }
     218             : 
     219             :     // Connector handling is thus as follows (when using default settings):
     220             :     // - If at most 10 Connectors are affected, they are recalculated
     221             :     //   on each MouseMove.
     222             :     // - If 11 to 100 Connectors are affected, the connections
     223             :     //   are shown as straight lines while dragging.
     224             :     // - In case of more than 100 affected Connectors, nothing that refers
     225             :     //   to the Connectors is drawn while dragging.
     226             : 
     227             :     // If a special drag mode like Rotate, Mirror or Crook is enabled,
     228             :     // then a Hit on the selected object triggers exactly this dragging.
     229             :     // If MarkedHitMovesAlways is set to 'true', a Hit on the selected
     230             :     // object always triggers a Move, independent of the DragMode that is
     231             :     // set. This flag is persistent and should be configurable in the app
     232             :     // by the user!
     233        1141 :     void SetMarkedHitMovesAlways(bool bOn) { mbMarkedHitMovesAlways = bOn; }
     234        1830 :     bool IsMarkedHitMovesAlways() const { return mbMarkedHitMovesAlways; }
     235             : 
     236             :     // Show the mirror image of the selected objects as Xor while dragging
     237             :     // the mirror axis? Persistent. Not yet implemented. Default: true
     238             :     void SetMirrRefDragObj(bool bOn) { mbMirrRefDragObj = bOn; }
     239             :     bool IsMirrRefDragObj() const { return mbMirrRefDragObj; }
     240             : 
     241             :     bool IsOrthoDesired() const;
     242             : 
     243             :     // center as reference on Resize
     244             :     // Default=FALSE.
     245           4 :     bool IsResizeAtCenter() const { return mbResizeAtCenter; }
     246           1 :     void SetResizeAtCenter(bool bOn) { mbResizeAtCenter = bOn; }
     247             : 
     248             :     // symmetric Crook
     249             :     // Default=FALSE.
     250           0 :     bool IsCrookAtCenter() const { return mbCrookAtCenter; }
     251           0 :     void SetCrookAtCenter(bool bOn) { mbCrookAtCenter = bOn; }
     252             : 
     253             :     // Limitation of the working area. The limitation refers to the View,
     254             :     // not to the single PageViews. This limitation is only evaluated by
     255             :     // the View on interactions like Dragging and Create.
     256             :     // In case of actions controlled by the app through algorithms or
     257             :     // UI-controlled actions (SetGeoAttr, MoveMarkedObj, ...), the
     258             :     // app must honor this limit itself.
     259             :     // Furthermore, this limit is to be seen as a rough limit. In certain
     260             :     // cases (e.g. while rotating), objects cannot be dragged exactly
     261             :     // up to this limit, objects can overlap a bit because of rounding
     262             :     // errors,...
     263             :     // Default=EmptyRect=no limitation
     264             :     // only partially implemented
     265        6723 :     void SetWorkArea(const Rectangle& rRect) { aMaxWorkArea=rRect; }
     266        1026 :     const Rectangle& GetWorkArea() const { return aMaxWorkArea; }
     267             : 
     268             : 
     269             :     // The DragLimit refers to the Page of the object.
     270             :     // (TODO or to the View?? - must be researched...)
     271             :     // 'false' = no limit
     272             :     // The return Rect must contain absolute coordinates. The maximum
     273             :     // drag area is then selected by the View in a way that the object's
     274             :     // SnapRect is moved or resized at most up to the corner of the
     275             :     // LimitRect. For objects like Bezier curves, rotated rectangles,
     276             :     // it must be taken into account that because of subsequent
     277             :     // recalculation of the SnapRect (on Resize), rounding errors can
     278             :     // occur, because of which the LimitRect might be exceeded by a
     279             :     // very small extent....
     280             :     // Implemented for Move and Resize
     281             :     virtual bool TakeDragLimit(SdrDragMode eMode, Rectangle& rRect) const;
     282             : };
     283             : 
     284             : #endif // INCLUDED_SVX_SVDDRGV_HXX
     285             : 
     286             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11