LibreOffice Module svx (master)  1
svdopath.hxx
Go to the documentation of this file.
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_SVDOPATH_HXX
21 #define INCLUDED_SVX_SVDOPATH_HXX
22 
23 #include <svx/svdotext.hxx>
24 #include <svx/svxdllapi.h>
25 #include <memory>
26 
28 
29 // Helper class SdrPathObjGeoData
30 // used for undo/redo
31 
33 {
34 public:
37 
39  virtual ~SdrPathObjGeoData() override;
40 };
41 
42 
43 class SVX_DLLPUBLIC SdrPathObj final : public SdrTextObj
44 {
45 private:
47 
48  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
49 
52 
53  // for isolation of old Drag/Create code
54  std::unique_ptr<ImpPathForDragAndCreate> mpDAC;
55 
56  // helper functions for GET, SET, INS etc. PNT
57  void ImpSetClosed(bool bClose);
58  void ImpForceKind();
59  void ImpForceLineAngle();
60  ImpPathForDragAndCreate& impGetDAC() const;
61 
62 private:
63  // protected destructor - due to final, make private
64  virtual ~SdrPathObj() override;
65 
66 public:
67  SdrPathObj(
68  SdrModel& rSdrModel,
69  SdrObjKind eNewKind);
70  SdrPathObj(
71  SdrModel& rSdrModel,
72  SdrObjKind eNewKind,
73  const basegfx::B2DPolyPolygon& rPathPoly);
74 
75  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
76  virtual sal_uInt16 GetObjIdentifier() const override;
77  virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
78  virtual SdrPathObj* CloneSdrObject(SdrModel& rTargetModel) const override;
79  SdrPathObj& operator=(const SdrPathObj& rObj);
80 
81  virtual OUString TakeObjNameSingul() const override;
82  virtual OUString TakeObjNamePlural() const override;
83  virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
84  virtual void RecalcSnapRect() override;
85  virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
86  virtual sal_uInt32 GetHdlCount() const override;
87  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
88  virtual void AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const override;
89 
90  // special drag methods
91  virtual bool hasSpecialDrag() const override;
92  virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
93  virtual bool applySpecialDrag(SdrDragStat& rDrag) override;
94  virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const override;
95  virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const override;
96 
97  virtual bool BegCreate(SdrDragStat& rStat) override;
98  virtual bool MovCreate(SdrDragStat& rStat) override;
99  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
100  virtual bool BckCreate(SdrDragStat& rStat) override;
101  virtual void BrkCreate(SdrDragStat& rStat) override;
102  virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
103  PointerStyle GetCreatePointer() const override;
104 
105  // during drag or create, allow accessing the so-far created/modified polyPolygon
106  basegfx::B2DPolyPolygon getObjectPolyPolygon(const SdrDragStat& rDrag) const;
107  basegfx::B2DPolyPolygon getDragPolyPolygon(const SdrDragStat& rDrag) const;
108 
109  virtual void NbcMove(const Size& aSize) override;
110  virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact) override;
111  virtual void NbcRotate(const Point& rRefPnt, long nAngle, double fSin, double fCos) override;
112  virtual void NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2) override;
113  virtual void NbcShear(const Point& rRefPnt, long nAngle, double fTan, bool bVShear) override;
114 
115  virtual sal_uInt32 GetSnapPointCount() const override;
116  virtual Point GetSnapPoint(sal_uInt32 i) const override;
117 
118  virtual bool IsPolyObj() const override;
119  virtual sal_uInt32 GetPointCount() const override;
120  virtual Point GetPoint(sal_uInt32 nHdlNum) const override;
121  virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum) override;
122 
123  // insert point
124  sal_uInt32 NbcInsPointOld(const Point& rPos, bool bNewObj);
125  sal_uInt32 NbcInsPoint(const Point& rPos, bool bNewObj);
126 
127  // rip at given point
128  SdrObject* RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index);
129 
130 private:
131  virtual SdrObjGeoData* NewGeoData() const override;
132  virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
133  virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
134 
135 public:
136  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
137 
138  // Bezier-polygon getter/setter
139  const basegfx::B2DPolyPolygon& GetPathPoly() const { return maPathPolygon; }
140  void SetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
141  void NbcSetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
142 
143  // special functions for Bezier-polygon handling
144  bool IsClosed() const { return meKind==OBJ_POLY || meKind==OBJ_PATHPOLY || meKind==OBJ_PATHFILL || meKind==OBJ_FREEFILL || meKind==OBJ_SPLNFILL; }
145  bool IsLine() const { return meKind==OBJ_PLIN || meKind==OBJ_PATHPLIN || meKind==OBJ_PATHLINE || meKind==OBJ_FREELINE || meKind==OBJ_SPLNLINE || meKind==OBJ_LINE; }
146  bool IsBezier() const { return meKind==OBJ_PATHLINE || meKind==OBJ_PATHFILL; }
147  bool IsSpline() const { return meKind==OBJ_SPLNLINE || meKind==OBJ_SPLNFILL; }
148 
149  // close/open path
150  // if opening, move end point by "nOpenDistance"
151  void ToggleClosed(); // long nOpenDistance);
152 
153  // transformation interface for StarOfficeAPI. This implements support for
154  // homogen 3x3 matrices containing the transformation of the SdrObject. At the
155  // moment it contains a shearX, rotation and translation, but for setting all linear
156  // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
157  //
158  // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
159  // with the base geometry and returns TRUE. Otherwise it returns FALSE.
160  virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
161  // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
162  // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
163  // to use (0,0) as upper left and will be scaled to the given size in the matrix.
164  virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) override;
165 };
166 
167 #endif // INCLUDED_SVX_SVDOPATH_HXX
168 
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdotxtr.cxx:106
virtual sal_uInt32 GetSnapPointCount() const override
snap to special points of an Object (polygon points, center of circle)
Definition: svdotext.cxx:1121
natural cubic Spline (ni)
Definition: svdobj.hxx:132
basegfx::B2DPolyPolygon maPathPolygon
Definition: svdopath.hxx:35
virtual bool IsPolyObj() const
Definition: svdobj.cxx:1687
caption object
Definition: svdobj.hxx:140
virtual sal_uInt32 GetHdlCount() const override
Via GetHdlCount the number of Handles can be retrieved.
Definition: svdotxdr.cxx:36
virtual OUString TakeObjNameSingul() const override
Definition: svdotext.cxx:938
virtual bool hasSpecialDrag() const override
The standard transformations (Move,Resize,Rotate,Mirror,Shear) are taken over by the View (TakeXorPol...
Definition: svdotxdr.cxx:67
virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix &rMatrix, const basegfx::B2DPolyPolygon &rPolyPolygon) override
Definition: svdotext.cxx:1629
circle cut
Definition: svdobj.hxx:125
virtual sal_uInt32 GetPointCount() const
Definition: svdobj.cxx:1692
open free-hand line
Definition: svdobj.hxx:130
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdotext.cxx:1108
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:226
polygon, PolyPolygon
Definition: svdobj.hxx:126
virtual void AddToPlusHdlList(SdrHdlList &rHdlList, SdrHdl &rHdl) const
Definition: svdobj.cxx:1216
virtual bool BegCreate(SdrDragStat &rStat) override
Every object must be able to create itself interactively.
Definition: svdotxdr.cxx:182
virtual void NbcMirror(const Point &rRef1, const Point &rRef2) override
Definition: svdotxtr.cxx:236
virtual SdrObjGeoData * NewGeoData() const override
A derived class must override these 3 methods if it has own geometric data that must be saved for Und...
Definition: svdotext.cxx:1444
SdrObjKind meKind
Definition: svdopath.hxx:36
Provides information about various ZObject properties.
Definition: svdobj.hxx:248
Polygon/PolyPolygon represented by SdrPathObj.
Definition: svdobj.hxx:141
virtual bool BckCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:225
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1449
bool IsClosed() const
Definition: svdopath.hxx:144
PolyLine.
Definition: svdobj.hxx:127
virtual ~SdrPathObjGeoData() override
Definition: svdopath.cxx:1614
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdotext.cxx:408
virtual SdrTextObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdotext.cxx:1019
virtual void NbcSetPoint(const Point &rPnt, sal_uInt32 i)
Definition: svdobj.cxx:1711
object group
Definition: svdobj.hxx:119
virtual bool applySpecialDrag(SdrDragStat &rDrag) override
Definition: svdotxdr.cxx:149
virtual OUString getSpecialDragComment(const SdrDragStat &rDrag) const override
Definition: svdotxdr.cxx:174
std::unique_ptr< ImpPathForDragAndCreate > mpDAC
Definition: svdopath.hxx:54
bool IsSpline() const
Definition: svdopath.hxx:147
virtual void BrkCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:221
virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat &rDrag) const
Definition: svdobj.cxx:1340
SdrTextObj & operator=(const SdrTextObj &rObj)
Definition: svdotext.cxx:1024
virtual sal_uInt16 GetObjIdentifier() const override
Definition: svdotext.cxx:432
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdotxtr.cxx:98
SdrObjKind meKind
Definition: svdopath.hxx:51
Abstract DrawObject.
Definition: svdobj.hxx:312
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const override
Polygon dragged by the user when creating the object.
Definition: svdotxdr.cxx:230
closed Bezier-curve
Definition: svdobj.hxx:129
bool IsLine() const
Definition: svdopath.hxx:145
virtual void RestGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotext.cxx:1457
SdrObjKind
Definition: svdobj.hxx:116
bool IsBezier() const
Definition: svdopath.hxx:146
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:114
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const
Definition: svdobj.cxx:1312
PointerStyle
const basegfx::B2DPolyPolygon & GetPathPoly() const
Definition: svdopath.hxx:139
virtual Point GetSnapPoint(sal_uInt32 i) const override
Definition: svdotext.cxx:1126
virtual bool EndCreate(SdrDragStat &rStat, SdrCreateCmd eCmd) override
Definition: svdotxdr.cxx:207
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix &rMatrix, basegfx::B2DPolyPolygon &rPolyPolygon) const override
Definition: svdotext.cxx:1594
virtual void NbcRotate(const Point &rRef, long nAngle, double sn, double cs) override
Definition: svdotxtr.cxx:190
SdrCreateCmd
Definition: svdtypes.hxx:27
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdotext.cxx:81
basegfx::B2DPolyPolygon maPathPolygon
Definition: svdopath.hxx:50
virtual bool MovCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:192
virtual basegfx::B2DPolyPolygon TakeXorPoly() const override
The Xor-Polygon is required by the View to drag the object.
Definition: svdotext.cxx:1070
virtual void NbcShear(const Point &rRef, long nAngle, double tn, bool bVShear) override
Definition: svdotxtr.cxx:214
virtual void TakeUnrotatedSnapRect(tools::Rectangle &rRect) const
Definition: svdotext.cxx:598
virtual Point GetPoint(sal_uInt32 i) const
Definition: svdobj.cxx:1697
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdotxtr.cxx:418
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdotxdr.cxx:41
open Bezier-curve
Definition: svdobj.hxx:128
closed free-hand line
Definition: svdobj.hxx:131
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdotxtr.cxx:46
virtual OUString TakeObjNamePlural() const override
Definition: svdotext.cxx:1002
virtual PointerStyle GetCreatePointer() const override
get the cursor/pointer that signals creating this object
Definition: svdotxdr.cxx:242