LCOV - code coverage report
Current view: top level - include/svx - svddrgmt.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 36 41.7 %
Date: 2015-06-13 12:38:46 Functions: 15 35 42.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_SVDDRGMT_HXX
      21             : #define INCLUDED_SVX_SVDDRGMT_HXX
      22             : 
      23             : #include <svx/svddrgv.hxx>
      24             : #include <svx/svxdllapi.h>
      25             : #include <svx/sdr/contact/objectcontact.hxx>
      26             : 
      27             : class SdrDragView;
      28             : class SdrDragStat;
      29             : 
      30             : class SVX_DLLPUBLIC SdrDragEntry
      31             : {
      32             : private:
      33             :     // bitfield
      34             :     bool                        mbAddToTransparent : 1;
      35             : 
      36             : protected:
      37             :     // access for derived classes
      38           2 :     void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; }
      39             : 
      40             : public:
      41             :     SdrDragEntry();
      42             :     virtual ~SdrDragEntry();
      43             : 
      44             :     virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0;
      45             : 
      46             :     // data read access
      47           2 :     bool getAddToTransparent() const { return mbAddToTransparent; }
      48             : };
      49             : 
      50             : 
      51             : 
      52             : class SVX_DLLPUBLIC SdrDragEntryPolyPolygon : public SdrDragEntry
      53             : {
      54             : private:
      55             :     basegfx::B2DPolyPolygon             maOriginalPolyPolygon;
      56             : 
      57             : public:
      58             :     SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon);
      59             :     virtual ~SdrDragEntryPolyPolygon();
      60             : 
      61             :     virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) SAL_OVERRIDE;
      62             : };
      63             : 
      64             : 
      65             : 
      66             : class SdrDragEntrySdrObject : public SdrDragEntry
      67             : {
      68             : private:
      69             :     const SdrObject&                                maOriginal;
      70             :     SdrObject*                                      mpClone;
      71             :     sdr::contact::ObjectContact&                    mrObjectContact;
      72             :     bool                                            mbModify;
      73             : 
      74             : public:
      75             :     SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
      76             :     virtual ~SdrDragEntrySdrObject();
      77             : 
      78             :     // #i54102# Split createPrimitive2DSequenceInCurrentState in prepareCurrentState and processing,
      79             :     // added accessors to original and clone
      80             :     void prepareCurrentState(SdrDragMethod& rDragMethod);
      81           0 :     const SdrObject& getOriginal() const { return maOriginal; }
      82           4 :     SdrObject* getClone() { return mpClone; }
      83             : 
      84             :     virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) SAL_OVERRIDE;
      85             : };
      86             : 
      87             : 
      88             : 
      89             : class SdrDragEntryPrimitive2DSequence : public SdrDragEntry
      90             : {
      91             : private:
      92             :     drawinglayer::primitive2d::Primitive2DSequence  maPrimitive2DSequence;
      93             : 
      94             : public:
      95             :     SdrDragEntryPrimitive2DSequence(
      96             :         const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
      97             :         bool bAddToTransparent);
      98             :     virtual ~SdrDragEntryPrimitive2DSequence();
      99             : 
     100             :     virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) SAL_OVERRIDE;
     101             : };
     102             : 
     103             : 
     104             : 
     105             : class SdrDragEntryPointGlueDrag : public SdrDragEntry
     106             : {
     107             : private:
     108             :     std::vector< basegfx::B2DPoint >                maPositions;
     109             :     bool                                            mbIsPointDrag;
     110             : 
     111             : public:
     112             :     SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag);
     113             :     virtual ~SdrDragEntryPointGlueDrag();
     114             : 
     115             :     virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) SAL_OVERRIDE;
     116             : };
     117             : 
     118             : 
     119             : 
     120             : class SVX_DLLPUBLIC SdrDragMethod
     121             : {
     122             : private:
     123             :     std::vector< SdrDragEntry* >            maSdrDragEntries;
     124             :     sdr::overlay::OverlayObjectList         maOverlayObjectList;
     125             :     SdrDragView&                            mrSdrDragView;
     126             : 
     127             :     // bitfield
     128             :     bool                                    mbMoveOnly : 1;
     129             :     bool                                    mbSolidDraggingActive : 1;
     130             :     bool                                    mbShiftPressed : 1;
     131             : 
     132             : protected:
     133             :     // access for derivated classes to maSdrDragEntries
     134             :     void clearSdrDragEntries();
     135             :     void addSdrDragEntry(SdrDragEntry* pNew);
     136             :     virtual void createSdrDragEntries();
     137             :     virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify);
     138             : 
     139             :     // access for derivated classes to maOverlayObjectList
     140           2 :     void clearOverlayObjectList() { maOverlayObjectList.clear(); }
     141           2 :     void addToOverlayObjectList(sdr::overlay::OverlayObject& rNew) { maOverlayObjectList.append(rNew); }
     142           9 :     basegfx::B2DRange getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList.getBaseRange(); }
     143             : 
     144             :     // access for derivated classes to mrSdrDragView
     145          53 :     SdrDragView& getSdrDragView() { return mrSdrDragView; }
     146          36 :     const SdrDragView& getSdrDragView() const { return mrSdrDragView; }
     147             : 
     148             :     // access for derivated classes for bools
     149           0 :     void setMoveOnly(bool bNew) { mbMoveOnly = bNew; }
     150           2 :     void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; }
     151             : 
     152             :     // internal helpers for creation of standard drag entries
     153             :     void createSdrDragEntries_SolidDrag();
     154             :     void createSdrDragEntries_PolygonDrag();
     155             :     void createSdrDragEntries_PointDrag();
     156             :     void createSdrDragEntries_GlueDrag();
     157             : 
     158             :     // old call forwarders to the SdrDragView
     159             :     void               ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, sal_uInt16 nVal=0) const;
     160           5 :     SdrHdl*            GetDragHdl() const              { return getSdrDragView().mpDragHdl; }
     161           0 :     SdrHdlKind         GetDragHdlKind() const          { return getSdrDragView().meDragHdl; }
     162          20 :     SdrDragStat&       DragStat()                      { return getSdrDragView().aDragStat; }
     163           1 :     const SdrDragStat& DragStat() const                { return getSdrDragView().aDragStat; }
     164           0 :     Point&             Ref1() const                    { return mrSdrDragView.aRef1; }
     165           0 :     Point&             Ref2() const                    { return mrSdrDragView.aRef2; }
     166           0 :     const SdrHdlList&  GetHdlList() const              { return getSdrDragView().GetHdlList(); }
     167           0 :     void               AddUndo(SdrUndoAction* pUndo)   { getSdrDragView().AddUndo(pUndo); }
     168           0 :     bool               IsDragLimit()                   { return getSdrDragView().mbDragLimit; }
     169           0 :     const Rectangle&   GetDragLimitRect()              { return getSdrDragView().maDragLimit; }
     170           0 :     const SdrMarkList& GetMarkedObjectList()                   { return getSdrDragView().GetMarkedObjectList(); }
     171           0 :     Point              GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); }
     172           3 :     SdrSnap            SnapPos(Point& rPt) const       { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
     173             :     inline const Rectangle& GetMarkedRect() const;
     174             :     SdrPageView*       GetDragPV() const;
     175             :     SdrObject*         GetDragObj() const;
     176             :     OutputDevice*      GetDragWin() const              { return getSdrDragView().pDragWin; }
     177           0 :     bool               IsDraggingPoints() const        { return getSdrDragView().IsDraggingPoints(); }
     178           0 :     bool               IsDraggingGluePoints() const    { return getSdrDragView().IsDraggingGluePoints(); }
     179             : 
     180             :     bool DoAddConnectorOverlays();
     181             :     drawinglayer::primitive2d::Primitive2DSequence AddConnectorOverlays();
     182             : 
     183             : public:
     184             :     TYPEINFO();
     185             : 
     186             :     void resetSdrDragEntries();
     187             :     basegfx::B2DRange getCurrentRange() const;
     188             : 
     189             :     // #i58950# also moved constructor implementation to cxx
     190             :     SdrDragMethod(SdrDragView& rNewView);
     191             : 
     192             :     // #i58950# virtual destructor was missing
     193             :     virtual ~SdrDragMethod();
     194             : 
     195             :     void Show();
     196             :     void Hide();
     197           0 :     bool IsShiftPressed() { return mbShiftPressed; }
     198           1 :     void SetShiftPressed(bool bShiftPressed) { mbShiftPressed = bShiftPressed; }
     199             :     virtual void TakeSdrDragComment(OUString& rStr) const=0;
     200             :     virtual bool BeginSdrDrag()=0;
     201             :     virtual void MoveSdrDrag(const Point& rPnt)=0;
     202             :     virtual bool EndSdrDrag(bool bCopy)=0;
     203             :     virtual void CancelSdrDrag();
     204             :     virtual Pointer GetSdrDragPointer() const=0;
     205             : 
     206             :     virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager);
     207             :     void destroyOverlayGeometry();
     208             : 
     209             :     virtual basegfx::B2DHomMatrix getCurrentTransformation();
     210             :     virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
     211             :     virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
     212             : 
     213             :     // data read access
     214           0 :     bool getMoveOnly() const { return mbMoveOnly; }
     215           2 :     bool getSolidDraggingActive() const { return mbSolidDraggingActive; }
     216             : };
     217             : 
     218           0 : inline const Rectangle& SdrDragMethod::GetMarkedRect() const
     219             : {
     220           0 :     return getSdrDragView().meDragHdl==HDL_POLY ? getSdrDragView().GetMarkedPointsRect() :
     221           0 :            getSdrDragView().meDragHdl==HDL_GLUE ? getSdrDragView().GetMarkedGluePointsRect() :
     222           0 :            getSdrDragView().GetMarkedObjRect();
     223             : }
     224             : 
     225             : 
     226             : //   SdrDragMove
     227             : 
     228           0 : class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod
     229             : {
     230             : private:
     231             :     long                        nBestXSnap;
     232             :     long                        nBestYSnap;
     233             :     bool                        bXSnapped;
     234             :     bool                        bYSnapped;
     235             : 
     236             :     void ImpCheckSnap(const Point& rPt);
     237             : 
     238             : protected:
     239             :     virtual void createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify) SAL_OVERRIDE;
     240             : 
     241             : public:
     242             :     TYPEINFO_OVERRIDE();
     243             :     SdrDragMove(SdrDragView& rNewView);
     244             : 
     245             :     virtual void TakeSdrDragComment(OUString& rStr) const SAL_OVERRIDE;
     246             :     virtual bool BeginSdrDrag() SAL_OVERRIDE;
     247             :     virtual void MoveSdrDrag(const Point& rPnt) SAL_OVERRIDE;
     248             :     virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
     249             :     virtual Pointer GetSdrDragPointer() const SAL_OVERRIDE;
     250             : 
     251             :     virtual basegfx::B2DHomMatrix getCurrentTransformation() SAL_OVERRIDE;
     252             :     virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) SAL_OVERRIDE;
     253             : };
     254             : 
     255             : 
     256             : //   SdrDragResize
     257             : 
     258           0 : class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod
     259             : {
     260             : protected:
     261             :     Fraction                    aXFact;
     262             :     Fraction                    aYFact;
     263             : 
     264             : public:
     265             :     TYPEINFO_OVERRIDE();
     266             :     SdrDragResize(SdrDragView& rNewView);
     267             : 
     268             :     virtual void TakeSdrDragComment(OUString& rStr) const SAL_OVERRIDE;
     269             :     virtual bool BeginSdrDrag() SAL_OVERRIDE;
     270             :     virtual void MoveSdrDrag(const Point& rPnt) SAL_OVERRIDE;
     271             :     virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
     272             :     virtual Pointer GetSdrDragPointer() const SAL_OVERRIDE;
     273             : 
     274             :     virtual basegfx::B2DHomMatrix getCurrentTransformation() SAL_OVERRIDE;
     275             :     virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget) SAL_OVERRIDE;
     276             : };
     277             : 
     278             : 
     279             : //   SdrDragObjOwn
     280             : 
     281             : class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod
     282             : {
     283             : private:
     284             :     // SdrDragObjOwn always works on a clone since it has no transformation
     285             :     // mechanism to modify wireframe visualisations, but uses the
     286             :     // SdrObject::applySpecialDrag() method to change a clone of the
     287             :     // SdrObject
     288             :     SdrObject*                  mpClone;
     289             : 
     290             : protected:
     291             :     virtual void createSdrDragEntries() SAL_OVERRIDE;
     292             : 
     293             : public:
     294             :     TYPEINFO_OVERRIDE();
     295             :     SdrDragObjOwn(SdrDragView& rNewView);
     296             :     virtual ~SdrDragObjOwn();
     297             : 
     298             :     virtual void TakeSdrDragComment(OUString& rStr) const SAL_OVERRIDE;
     299             :     virtual bool BeginSdrDrag() SAL_OVERRIDE;
     300             :     virtual void MoveSdrDrag(const Point& rPnt) SAL_OVERRIDE;
     301             :     virtual bool EndSdrDrag(bool bCopy) SAL_OVERRIDE;
     302             :     virtual Pointer GetSdrDragPointer() const SAL_OVERRIDE;
     303             : };
     304             : 
     305             : #endif // INCLUDED_SVX_SVDDRGMT_HXX
     306             : 
     307             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11