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