1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVDOPATH_HXX 25 #define _SVDOPATH_HXX 26 27 #include <svx/svdotext.hxx> 28 #include <svx/xpoly.hxx> 29 #include "svx/svxdllapi.h" 30 #include <basegfx/vector/b2enums.hxx> 31 32 //************************************************************ 33 // Vorausdeklarationen 34 //************************************************************ 35 36 class ImpPathForDragAndCreate; 37 38 //************************************************************ 39 // Hilfsklasse SdrPathObjGeoData 40 // 41 // fuer Undo/Redo 42 // 43 //************************************************************ 44 45 class SdrPathObjGeoData : public SdrTextObjGeoData 46 { 47 public: 48 basegfx::B2DPolyPolygon maPathPolygon; 49 SdrObjKind meKind; 50 51 SdrPathObjGeoData(); 52 virtual ~SdrPathObjGeoData(); 53 }; 54 55 //************************************************************ 56 // SdrPathObj 57 //************************************************************ 58 59 class SVX_DLLPUBLIC SdrPathObj : public SdrTextObj 60 { 61 private: 62 friend class ImpPathForDragAndCreate; 63 64 protected: 65 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact(); 66 67 basegfx::B2DPolyPolygon maPathPolygon; 68 SdrObjKind meKind; 69 70 // for isolation of old Drag/Create code 71 ImpPathForDragAndCreate* mpDAC; 72 73 protected: 74 // Hilfsfunktion fuer GET/SET/INS/etc. PNT 75 void ImpSetClosed(sal_Bool bClose); 76 void ImpForceKind(); 77 void ImpForceLineWink(); 78 ImpPathForDragAndCreate& impGetDAC() const; 79 void impDeleteDAC() const; 80 81 public: 82 static sal_Bool ImpFindPolyPnt(const basegfx::B2DPolyPolygon& rPoly, sal_uInt32 nAbsPnt, sal_uInt32& rPolyNum, sal_uInt32& rPointNum); 83 virtual void SetRectsDirty(sal_Bool bNotMyself = sal_False); 84 85 public: 86 TYPEINFO(); 87 SdrPathObj(SdrObjKind eNewKind); 88 SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly); 89 virtual ~SdrPathObj(); 90 91 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const; 92 virtual sal_uInt16 GetObjIdentifier() const; 93 virtual void TakeUnrotatedSnapRect(Rectangle& rRect) const; 94 virtual void operator=(const SdrObject& rObj); 95 96 virtual void TakeObjNameSingul(String& rName) const; 97 virtual void TakeObjNamePlural(String& rName) const; 98 virtual basegfx::B2DPolyPolygon TakeXorPoly() const; 99 virtual void RecalcSnapRect(); 100 virtual void NbcSetSnapRect(const Rectangle& rRect); 101 virtual sal_uInt32 GetHdlCount() const; 102 virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; 103 virtual sal_uInt32 GetPlusHdlCount(const SdrHdl& rHdl) const; 104 virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const; 105 virtual void AddToHdlList(SdrHdlList& rHdlList) const; 106 107 // special drag methods 108 virtual bool hasSpecialDrag() const; 109 virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; 110 virtual bool applySpecialDrag(SdrDragStat& rDrag); 111 virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; 112 virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const; 113 114 virtual FASTBOOL BegCreate(SdrDragStat& rStat); 115 virtual FASTBOOL MovCreate(SdrDragStat& rStat); 116 virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd); 117 virtual FASTBOOL BckCreate(SdrDragStat& rStat); 118 virtual void BrkCreate(SdrDragStat& rStat); 119 virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const; 120 Pointer GetCreatePointer() const; 121 122 // during drag or create, allow accessing the so-far created/modified polyPolygon 123 basegfx::B2DPolyPolygon getObjectPolyPolygon(const SdrDragStat& rDrag) const; 124 basegfx::B2DPolyPolygon getDragPolyPolygon(const SdrDragStat& rDrag) const; 125 126 virtual void NbcMove(const Size& aSize); 127 virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact); 128 virtual void NbcRotate(const Point& rRefPnt, long nAngle, double fSin, double fCos); 129 virtual void NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2); 130 virtual void NbcShear(const Point& rRefPnt, long nAngle, double fTan, FASTBOOL bVShear); 131 132 virtual sal_uInt32 GetSnapPointCount() const; 133 virtual Point GetSnapPoint(sal_uInt32 i) const; 134 135 virtual sal_Bool IsPolyObj() const; 136 virtual sal_uInt32 GetPointCount() const; 137 virtual Point GetPoint(sal_uInt32 nHdlNum) const; 138 virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum); 139 140 // Punkt einfuegen 141 sal_uInt32 NbcInsPointOld(const Point& rPos, sal_Bool bNewObj, sal_Bool bHideHim); 142 sal_uInt32 NbcInsPoint(sal_uInt32 i, const Point& rPos, sal_Bool bNewObj, sal_Bool bHideHim); 143 144 // An diesem Punkt auftrennen 145 SdrObject* RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index); 146 147 protected: 148 virtual SdrObjGeoData* NewGeoData() const; 149 virtual void SaveGeoData(SdrObjGeoData& rGeo) const; 150 virtual void RestGeoData(const SdrObjGeoData& rGeo); 151 152 public: 153 virtual SdrObject* DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const; 154 155 // Bezierpolygon holen/setzen GetPathPoly() const156 const basegfx::B2DPolyPolygon& GetPathPoly() const { return maPathPolygon; } 157 void SetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly); 158 void NbcSetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly); 159 160 // Spezialfunktionen fuer Bezierpolygon-Bearbeitung IsClosed() const161 sal_Bool IsClosed() const { return meKind==OBJ_POLY || meKind==OBJ_PATHPOLY || meKind==OBJ_PATHFILL || meKind==OBJ_FREEFILL || meKind==OBJ_SPLNFILL; } IsLine() const162 sal_Bool IsLine() const { return meKind==OBJ_PLIN || meKind==OBJ_PATHPLIN || meKind==OBJ_PATHLINE || meKind==OBJ_FREELINE || meKind==OBJ_SPLNLINE || meKind==OBJ_LINE; } IsFreeHand() const163 sal_Bool IsFreeHand() const { return meKind==OBJ_FREELINE || meKind==OBJ_FREEFILL; } IsBezier() const164 sal_Bool IsBezier() const { return meKind==OBJ_PATHLINE || meKind==OBJ_PATHFILL; } IsSpline() const165 sal_Bool IsSpline() const { return meKind==OBJ_SPLNLINE || meKind==OBJ_SPLNFILL; } 166 167 // Pfad schliessen bzw. oeffnen; im letzteren Fall den Endpunkt um 168 // "nOpenDistance" verschieben 169 void ToggleClosed(); // long nOpenDistance); 170 171 //////////////////////////////////////////////////////////////////////////////////////////////////// 172 // 173 // transformation interface for StarOfficeAPI. This implements support for 174 // homogen 3x3 matrices containing the transformation of the SdrObject. At the 175 // moment it contains a shearX, rotation and translation, but for setting all linear 176 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported. 177 // 178 //////////////////////////////////////////////////////////////////////////////////////////////////// 179 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon 180 // with the base geometry and returns TRUE. Otherwise it returns FALSE. 181 virtual sal_Bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const; 182 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix. 183 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has 184 // to use (0,0) as upper left and will be scaled to the given size in the matrix. 185 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon); 186 }; 187 188 //////////////////////////////////////////////////////////////////////////////////////////////////// 189 190 #endif //_SVDOPATH_HXX 191 192