LibreOffice Module svx (master)  1
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
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 .
18  */
20 #pragma once
22 #include <svx/svdotext.hxx>
23 #include <svx/svxdllapi.h>
24 #include <memory>
28 // Helper class SdrPathObjGeoData
29 // used for undo/redo
32 {
33 public:
38  virtual ~SdrPathObjGeoData() override;
39 };
43 {
44 private:
47  virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
51  bool mbHandleScale = false;
53  // for isolation of old Drag/Create code
54  std::unique_ptr<ImpPathForDragAndCreate> mpDAC;
56  // helper functions for GET, SET, INS etc. PNT
57  void ImpSetClosed(bool bClose);
58  void ImpForceKind();
59  void ImpForceLineAngle();
60  ImpPathForDragAndCreate& impGetDAC() const;
62 private:
63  // protected destructor - due to final, make private
64  virtual ~SdrPathObj() override;
66 public:
67  SdrPathObj(
68  SdrModel& rSdrModel,
69  SdrObjKind eNewKind);
70  // Copy constructor
71  SdrPathObj(SdrModel& rSdrModel, SdrPathObj const & rSource);
72  SdrPathObj(
73  SdrModel& rSdrModel,
74  SdrObjKind eNewKind,
75  const basegfx::B2DPolyPolygon& rPathPoly);
77  virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
78  virtual SdrObjKind GetObjIdentifier() const override;
79  virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override;
80  virtual SdrPathObj* CloneSdrObject(SdrModel& rTargetModel) const override;
82  virtual OUString TakeObjNameSingul() const override;
83  virtual OUString TakeObjNamePlural() const override;
84  virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
85  virtual void RecalcSnapRect() override;
86  virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
87  virtual sal_uInt32 GetHdlCount() const override;
88  virtual void AddToHdlList(SdrHdlList& rHdlList) const override;
89  virtual void AddToPlusHdlList(SdrHdlList& rHdlList, SdrHdl& rHdl) const override;
90  virtual const tools::Rectangle& GetLogicRect() const override;
92  // special drag methods
93  virtual bool hasSpecialDrag() const override;
94  virtual bool beginSpecialDrag(SdrDragStat& rDrag) const override;
95  virtual bool applySpecialDrag(SdrDragStat& rDrag) override;
96  virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const override;
97  virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const override;
99  virtual bool BegCreate(SdrDragStat& rStat) override;
100  virtual bool MovCreate(SdrDragStat& rStat) override;
101  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
102  virtual bool BckCreate(SdrDragStat& rStat) override;
103  virtual void BrkCreate(SdrDragStat& rStat) override;
104  virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
105  PointerStyle GetCreatePointer() const override;
107  // during drag or create, allow accessing the so-far created/modified polyPolygon
108  basegfx::B2DPolyPolygon getObjectPolyPolygon(const SdrDragStat& rDrag) const;
109  basegfx::B2DPolyPolygon getDragPolyPolygon(const SdrDragStat& rDrag) const;
111  virtual void NbcMove(const Size& aSize) override;
112  virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact) override;
113  virtual void NbcRotate(const Point& rRefPnt, Degree100 nAngle, double fSin, double fCos) override;
114  virtual void NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2) override;
115  virtual void NbcShear(const Point& rRefPnt, Degree100 nAngle, double fTan, bool bVShear) override;
117  virtual sal_uInt32 GetSnapPointCount() const override;
118  virtual Point GetSnapPoint(sal_uInt32 i) const override;
120  virtual bool IsPolyObj() const override;
121  virtual sal_uInt32 GetPointCount() const override;
122  virtual Point GetPoint(sal_uInt32 nHdlNum) const override;
123  virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum) override;
125  // insert point
126  sal_uInt32 NbcInsPointOld(const Point& rPos, bool bNewObj);
127  sal_uInt32 NbcInsPoint(const Point& rPos, bool bNewObj);
129  // rip at given point
130  SdrObject* RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index);
132 private:
133  virtual std::unique_ptr<SdrObjGeoData> NewGeoData() const override;
134  virtual void SaveGeoData(SdrObjGeoData& rGeo) const override;
135  virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override;
137 public:
138  virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
140  // Bezier-polygon getter/setter
141  const basegfx::B2DPolyPolygon& GetPathPoly() const { return maPathPolygon; }
142  void SetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
143  void NbcSetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
145  // special functions for Bezier-polygon handling
146  bool IsClosed() const { return meKind==OBJ_POLY || meKind==OBJ_PATHPOLY || meKind==OBJ_PATHFILL || meKind==OBJ_FREEFILL || meKind==OBJ_SPLNFILL; }
147  bool IsLine() const { return meKind==OBJ_PLIN || meKind==OBJ_PATHPLIN || meKind==OBJ_PATHLINE || meKind==OBJ_FREELINE || meKind==OBJ_SPLNLINE || meKind==OBJ_LINE; }
148  bool IsBezier() const { return meKind==OBJ_PATHLINE || meKind==OBJ_PATHFILL; }
149  bool IsSpline() const { return meKind==OBJ_SPLNLINE || meKind==OBJ_SPLNFILL; }
151  // close/open path
152  // if opening, move end point by "nOpenDistance"
153  void ToggleClosed(); // long nOpenDistance);
155  // transformation interface for StarOfficeAPI. This implements support for
156  // homogen 3x3 matrices containing the transformation of the SdrObject. At the
157  // moment it contains a shearX, rotation and translation, but for setting all linear
158  // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
159  //
160  // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
161  // with the base geometry and returns TRUE. Otherwise it returns FALSE.
162  virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
163  // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
164  // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
165  // to use (0,0) as upper left and will be scaled to the given size in the matrix.
166  virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) override;
172  void SetHandleScale(bool bHandleScale);
173 };
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
caption object
Definition: svdobjkind.hxx:49
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdotxtr.cxx:102
Polygon/PolyPolygon represented by SdrPathObj.
Definition: svdobjkind.hxx:50
virtual sal_uInt32 GetSnapPointCount() const override
snap to special points of an Object (polygon points, center of circle)
Definition: svdotext.cxx:1123
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdotext.cxx:462
basegfx::B2DPolyPolygon maPathPolygon
Definition: svdopath.hxx:34
virtual bool IsPolyObj() const
Definition: svdobj.cxx:1729
object group
Definition: svdobjkind.hxx:28
circle cut
Definition: svdobjkind.hxx:34
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:993
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:1597
virtual sal_uInt32 GetPointCount() const
Definition: svdobj.cxx:1734
virtual void RecalcSnapRect() override
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdotext.cxx:1113
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:174
Definition: svdobjkind.hxx:24
virtual void AddToPlusHdlList(SdrHdlList &rHdlList, SdrHdl &rHdl) const
Definition: svdobj.cxx:1248
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:232
SdrObjKind meKind
Definition: svdopath.hxx:35
Provides information about various ZObject properties.
Definition: svdobj.hxx:196
virtual bool BckCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:225
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override
Definition: svdotext.cxx:1407
bool IsClosed() const
Definition: svdopath.hxx:146
virtual void NbcShear(const Point &rRef, Degree100 nAngle, double tn, bool bVShear) override
Definition: svdotxtr.cxx:210
virtual ~SdrPathObjGeoData() override
Definition: svdopath.cxx:1609
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdotext.cxx:438
virtual SdrTextObj * CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdotext.cxx:1070
virtual void NbcSetPoint(const Point &rPnt, sal_uInt32 i)
Definition: svdobj.cxx:1753
open Bezier-curve
Definition: svdobjkind.hxx:37
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:149
virtual void BrkCreate(SdrDragStat &rStat) override
Definition: svdotxdr.cxx:221
virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat &rDrag) const
Definition: svdobj.cxx:1372
open free-hand line
Definition: svdobjkind.hxx:39
polygon, PolyPolygon
Definition: svdobjkind.hxx:35
closed Bezier-curve
Definition: svdobjkind.hxx:38
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdotxtr.cxx:94
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs) override
Definition: svdotxtr.cxx:186
SdrObjKind meKind
Definition: svdopath.hxx:50
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat &rDrag) const override
Polygon dragged by the user when creating the object.
Definition: svdotxdr.cxx:230
natural cubic Spline (ni)
Definition: svdobjkind.hxx:41
bool IsLine() const
Definition: svdopath.hxx:147
closed free-hand line
Definition: svdobjkind.hxx:40
Definition: svxdllapi.h:35
bool IsBezier() const
Definition: svdopath.hxx:148
virtual void RestoreGeoData(const SdrObjGeoData &rGeo) override
Definition: svdotext.cxx:1415
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
Definition: svdobj.hxx:98
virtual bool beginSpecialDrag(SdrDragStat &rDrag) const
Definition: svdobj.cxx:1344
const basegfx::B2DPolyPolygon & GetPathPoly() const
Definition: svdopath.hxx:141
virtual Point GetSnapPoint(sal_uInt32 i) const override
Definition: svdotext.cxx:1128
Definition: svdobjkind.hxx:36
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:1562
Definition: svdtypes.hxx:26
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdotext.cxx:65
basegfx::B2DPolyPolygon maPathPolygon
Definition: svdopath.hxx:49
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:1075
virtual void TakeUnrotatedSnapRect(tools::Rectangle &rRect) const
Definition: svdotext.cxx:627
virtual Point GetPoint(sal_uInt32 i) const
Definition: svdobj.cxx:1739
virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdotxtr.cxx:414
virtual void AddToHdlList(SdrHdlList &rHdlList) const override
Definition: svdotxdr.cxx:41
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdotxtr.cxx:42
virtual std::unique_ptr< 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:1402
virtual const tools::Rectangle & GetLogicRect() const override
Definition: svdotxtr.cxx:69
virtual OUString TakeObjNamePlural() const override
Definition: svdotext.cxx:1052
virtual PointerStyle GetCreatePointer() const override
get the cursor/pointer that signals creating this object
Definition: svdotxdr.cxx:242