Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / svdopath.hxx
blobea1bd16ff902b3f1a5a6fbb354db1d3a3d966380
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDOPATH_HXX
21 #define INCLUDED_SVX_SVDOPATH_HXX
23 #include <svx/svdotext.hxx>
24 #include <svx/xpoly.hxx>
25 #include <svx/svxdllapi.h>
26 #include <basegfx/vector/b2enums.hxx>
28 class ImpPathForDragAndCreate;
30 // Helper class SdrPathObjGeoData
31 // used for undo/redo
33 class SdrPathObjGeoData : public SdrTextObjGeoData
35 public:
36 basegfx::B2DPolyPolygon maPathPolygon;
37 SdrObjKind meKind;
39 SdrPathObjGeoData();
40 virtual ~SdrPathObjGeoData();
44 class SVX_DLLPUBLIC SdrPathObj : public SdrTextObj
46 private:
47 friend class ImpPathForDragAndCreate;
49 protected:
50 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE;
52 basegfx::B2DPolyPolygon maPathPolygon;
53 SdrObjKind meKind;
55 // for isolation of old Drag/Create code
56 ImpPathForDragAndCreate* mpDAC;
58 // brightness - used in EnhancedCustomShapes2d.cxx for DARKEN[LESS] and LIGHTEN[LESS] segments implementation
59 double mdBrightness;
61 protected:
62 // helper functions for GET, SET, INS etc. PNT
63 void ImpSetClosed(bool bClose);
64 void ImpForceKind();
65 void ImpForceLineAngle();
66 ImpPathForDragAndCreate& impGetDAC() const;
67 void impDeleteDAC() const;
69 public:
70 static bool ImpFindPolyPnt(const basegfx::B2DPolyPolygon& rPoly, sal_uInt32 nAbsPnt, sal_uInt32& rPolyNum, sal_uInt32& rPointNum);
71 virtual void SetRectsDirty(bool bNotMyself = false) SAL_OVERRIDE;
72 double GetBrightness() { return mdBrightness; }
74 public:
75 TYPEINFO_OVERRIDE();
76 SdrPathObj(SdrObjKind eNewKind);
77 SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly, double dBrightness = 1.0);
78 virtual ~SdrPathObj();
80 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const SAL_OVERRIDE;
81 virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
82 virtual void TakeUnrotatedSnapRect(Rectangle& rRect) const SAL_OVERRIDE;
83 virtual SdrPathObj* Clone() const SAL_OVERRIDE;
84 SdrPathObj& operator=(const SdrPathObj& rObj);
86 virtual OUString TakeObjNameSingul() const SAL_OVERRIDE;
87 virtual OUString TakeObjNamePlural() const SAL_OVERRIDE;
88 virtual basegfx::B2DPolyPolygon TakeXorPoly() const SAL_OVERRIDE;
89 virtual void RecalcSnapRect() SAL_OVERRIDE;
90 virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE;
91 virtual sal_uInt32 GetHdlCount() const SAL_OVERRIDE;
92 virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const SAL_OVERRIDE;
93 virtual sal_uInt32 GetPlusHdlCount(const SdrHdl& rHdl) const SAL_OVERRIDE;
94 virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const SAL_OVERRIDE;
95 virtual void AddToHdlList(SdrHdlList& rHdlList) const SAL_OVERRIDE;
97 // special drag methods
98 virtual bool hasSpecialDrag() const SAL_OVERRIDE;
99 virtual bool beginSpecialDrag(SdrDragStat& rDrag) const SAL_OVERRIDE;
100 virtual bool applySpecialDrag(SdrDragStat& rDrag) SAL_OVERRIDE;
101 virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const SAL_OVERRIDE;
102 virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const SAL_OVERRIDE;
104 virtual bool BegCreate(SdrDragStat& rStat) SAL_OVERRIDE;
105 virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE;
106 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
107 virtual bool BckCreate(SdrDragStat& rStat) SAL_OVERRIDE;
108 virtual void BrkCreate(SdrDragStat& rStat) SAL_OVERRIDE;
109 virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const SAL_OVERRIDE;
110 Pointer GetCreatePointer() const SAL_OVERRIDE;
112 // during drag or create, allow accessing the so-far created/modified polyPolygon
113 basegfx::B2DPolyPolygon getObjectPolyPolygon(const SdrDragStat& rDrag) const;
114 basegfx::B2DPolyPolygon getDragPolyPolygon(const SdrDragStat& rDrag) const;
116 virtual void NbcMove(const Size& aSize) SAL_OVERRIDE;
117 virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact) SAL_OVERRIDE;
118 virtual void NbcRotate(const Point& rRefPnt, long nAngle, double fSin, double fCos) SAL_OVERRIDE;
119 virtual void NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2) SAL_OVERRIDE;
120 virtual void NbcShear(const Point& rRefPnt, long nAngle, double fTan, bool bVShear) SAL_OVERRIDE;
122 virtual sal_uInt32 GetSnapPointCount() const SAL_OVERRIDE;
123 virtual Point GetSnapPoint(sal_uInt32 i) const SAL_OVERRIDE;
125 virtual bool IsPolyObj() const SAL_OVERRIDE;
126 virtual sal_uInt32 GetPointCount() const SAL_OVERRIDE;
127 virtual Point GetPoint(sal_uInt32 nHdlNum) const SAL_OVERRIDE;
128 virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum) SAL_OVERRIDE;
130 // insert point
131 sal_uInt32 NbcInsPointOld(const Point& rPos, bool bNewObj, bool bHideHim);
132 sal_uInt32 NbcInsPoint(sal_uInt32 i, const Point& rPos, bool bNewObj, bool bHideHim);
134 // rip at given point
135 SdrObject* RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index);
137 protected:
138 virtual SdrObjGeoData* NewGeoData() const SAL_OVERRIDE;
139 virtual void SaveGeoData(SdrObjGeoData& rGeo) const SAL_OVERRIDE;
140 virtual void RestGeoData(const SdrObjGeoData& rGeo) SAL_OVERRIDE;
142 public:
143 virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const SAL_OVERRIDE;
145 // Bezier-polygon getter/setter
146 const basegfx::B2DPolyPolygon& GetPathPoly() const { return maPathPolygon; }
147 void SetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
148 void NbcSetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly);
150 // special functions for Bezier-polygon handling
151 bool IsClosed() const { return meKind==OBJ_POLY || meKind==OBJ_PATHPOLY || meKind==OBJ_PATHFILL || meKind==OBJ_FREEFILL || meKind==OBJ_SPLNFILL; }
152 bool IsLine() const { return meKind==OBJ_PLIN || meKind==OBJ_PATHPLIN || meKind==OBJ_PATHLINE || meKind==OBJ_FREELINE || meKind==OBJ_SPLNLINE || meKind==OBJ_LINE; }
153 bool IsFreeHand() const { return meKind==OBJ_FREELINE || meKind==OBJ_FREEFILL; }
154 bool IsBezier() const { return meKind==OBJ_PATHLINE || meKind==OBJ_PATHFILL; }
155 bool IsSpline() const { return meKind==OBJ_SPLNLINE || meKind==OBJ_SPLNFILL; }
157 // close/open path
158 // if opening, move end point by "nOpenDistance"
159 void ToggleClosed(); // long nOpenDistance);
161 // transformation interface for StarOfficeAPI. This implements support for
162 // homogen 3x3 matrices containing the transformation of the SdrObject. At the
163 // moment it contains a shearX, rotation and translation, but for setting all linear
164 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
166 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
167 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
168 virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const SAL_OVERRIDE;
169 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
170 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
171 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
172 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) SAL_OVERRIDE;
175 #endif // INCLUDED_SVX_SVDOPATH_HXX
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */