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 _SVDOASHP_HXX 25 #define _SVDOASHP_HXX 26 27 #include <svx/svdobj.hxx> 28 #include <svx/svdotext.hxx> 29 #include <svx/svdhdl.hxx> 30 #include <vector> 31 #include <com/sun/star/uno/Reference.h> 32 #include <com/sun/star/drawing/XCustomShapeEngine.hpp> 33 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> 34 #include "svx/svxdllapi.h" 35 36 //************************************************************ 37 // Vorausdeklarationen 38 //************************************************************ 39 40 class SdrObjList; 41 class SdrObjListIter; 42 class SfxItemSet; 43 44 namespace sdr 45 { 46 namespace properties 47 { 48 class CustomShapeProperties; 49 } // end of namespace properties 50 } // end of namespace sdr 51 52 class SdrAShapeObjGeoData : public SdrTextObjGeoData 53 { 54 public: 55 56 sal_Bool bMirroredX; 57 sal_Bool bMirroredY; 58 double fObjectRotation; 59 60 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > 61 aAdjustmentSeq; 62 }; 63 64 #define CUSTOMSHAPE_HANDLE_RESIZE_FIXED 1 65 #define CUSTOMSHAPE_HANDLE_CREATE_FIXED 2 66 #define CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X 4 67 #define CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y 8 68 #define CUSTOMSHAPE_HANDLE_MOVE_SHAPE 16 69 #define CUSTOMSHAPE_HANDLE_ORTHO4 32 70 71 struct SdrCustomShapeInteraction 72 { 73 com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > xInteraction; 74 com::sun::star::awt::Point aPosition; 75 sal_Int32 nMode; 76 }; 77 78 //************************************************************ 79 // SdrObjCustomShape 80 //************************************************************ 81 82 class SVX_DLLPUBLIC SdrObjCustomShape : public SdrTextObj 83 { 84 private: 85 // fObjectRotation is containing the object rotation in degrees. 86 double fObjectRotation; 87 88 protected: 89 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact(); 90 91 public: 92 virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties(); 93 94 // to allow sdr::properties::CustomShapeProperties access 95 friend class sdr::properties::CustomShapeProperties; 96 97 com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mXRenderedCustomShape; 98 99 // #i37011# render geometry shadow 100 SdrObject* mpLastShadowGeometry; 101 102 static com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > GetCustomShapeEngine( const SdrObjCustomShape* pCustomShape ); 103 104 // SVX_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > > 105 // SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const; 106 // #i47293# 107 // SVX_DLLPRIVATE std::vector< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > > GetFixedInteractionHandle() const; 108 109 SVX_DLLPRIVATE std::vector< SdrCustomShapeInteraction > GetInteractionHandles( const SdrObjCustomShape* pCustomShape ) const; 110 111 SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag ); 112 113 SVX_DLLPRIVATE void DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const; 114 SVX_DLLPRIVATE void DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const; 115 116 // #i37011# centralize throw-away of render geometry 117 void InvalidateRenderGeometry(); 118 119 // #i38892# 120 void ImpCheckCustomGluePointsAreAdded(); 121 122 // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed. 123 Rectangle ImpCalculateTextFrame( const FASTBOOL bHgt, const FASTBOOL bWdt ); 124 125 public: 126 // #i37011# 127 const SdrObject* GetSdrObjectFromCustomShape() const; 128 const SdrObject* GetSdrObjectShadowFromCustomShape() const; 129 sal_Bool GetTextBounds( Rectangle& rTextBound ) const; 130 sal_Bool IsTextPath() const; 131 static basegfx::B2DPolyPolygon GetLineGeometry( const SdrObjCustomShape* pCustomShape, const sal_Bool bBezierAllowed ); 132 133 protected: 134 135 String aName; 136 137 public: 138 139 sal_Bool UseNoFillStyle() const; 140 141 sal_Bool IsMirroredX() const; 142 sal_Bool IsMirroredY() const; 143 void SetMirroredX( const sal_Bool bMirroredX ); 144 void SetMirroredY( const sal_Bool bMirroredY ); 145 146 double GetObjectRotation() const; 147 double GetExtraTextRotation() const; 148 149 TYPEINFO(); 150 SdrObjCustomShape(); 151 virtual ~SdrObjCustomShape(); 152 153 /* is merging default attributes from type-shype into the SdrCustomShapeGeometryItem. If pType 154 is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem. 155 MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */ 156 void MergeDefaultAttributes( const rtl::OUString* pType = NULL ); 157 158 /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */ 159 enum DefaultType 160 { 161 DEFAULT_PATH, 162 DEFAULT_VIEWBOX, 163 DEFAULT_SEGMENTS, 164 DEFAULT_GLUEPOINTS, 165 DEFAULT_STRETCHX, 166 DEFAULT_STRETCHY, 167 DEFAULT_EQUATIONS, 168 DEFAULT_HANDLES, 169 DEFAULT_TEXTFRAMES 170 }; 171 sal_Bool IsDefaultGeometry( const DefaultType eDefaultType ) const; 172 173 virtual sal_uInt16 GetObjIdentifier() const; 174 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const; 175 176 virtual void SetModel(SdrModel* pNewModel); 177 178 virtual void RecalcSnapRect(); 179 180 virtual const Rectangle& GetSnapRect() const; 181 virtual const Rectangle& GetCurrentBoundRect() const; 182 virtual const Rectangle& GetLogicRect() const; 183 184 virtual void Move(const Size& rSiz); 185 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); 186 virtual void Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear); 187 virtual void SetSnapRect(const Rectangle& rRect); 188 virtual void SetLogicRect(const Rectangle& rRect); 189 190 virtual void NbcMove(const Size& rSiz); 191 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); 192 virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs); 193 virtual void NbcMirror(const Point& rRef1, const Point& rRef2); 194 virtual void NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear); 195 virtual void NbcSetSnapRect(const Rectangle& rRect); 196 virtual void NbcSetLogicRect(const Rectangle& rRect); 197 198 virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const; 199 200 virtual void NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr ); 201 202 // special drag methods 203 virtual bool hasSpecialDrag() const; 204 virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; 205 virtual bool applySpecialDrag(SdrDragStat& rDrag); 206 207 virtual FASTBOOL BegCreate( SdrDragStat& rStat ); 208 virtual FASTBOOL MovCreate(SdrDragStat& rStat); // #i37448# 209 virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd); 210 211 virtual FASTBOOL AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHgt=sal_True, FASTBOOL bWdt=sal_True) const; 212 virtual FASTBOOL NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt=sal_True, FASTBOOL bWdt=sal_True); 213 virtual FASTBOOL AdjustTextFrameWidthAndHeight(FASTBOOL bHgt=sal_True, FASTBOOL bWdt=sal_True); 214 virtual FASTBOOL IsAutoGrowHeight() const; 215 virtual FASTBOOL IsAutoGrowWidth() const; 216 virtual void SetVerticalWriting( sal_Bool bVertical ); 217 virtual sal_Bool BegTextEdit( SdrOutliner& rOutl ); 218 virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const; 219 virtual void EndTextEdit( SdrOutliner& rOutl ); 220 virtual void TakeTextAnchorRect( Rectangle& rAnchorRect ) const; 221 virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText=sal_False, 222 Rectangle* pAnchorRect=NULL, sal_Bool bLineWidth=sal_True ) const; 223 virtual void operator=(const SdrObject& rObj); 224 225 virtual void TakeObjNameSingul(String& rName) const; 226 virtual void TakeObjNamePlural(String& rName) const; 227 228 virtual basegfx::B2DPolyPolygon TakeCreatePoly( const SdrDragStat& rDrag) const; 229 230 virtual basegfx::B2DPolyPolygon TakeXorPoly() const; 231 virtual basegfx::B2DPolyPolygon TakeContour() const; 232 233 virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject); 234 235 virtual SdrObject* DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const; 236 237 virtual void SetPage( SdrPage* pNewPage ); 238 239 virtual SdrObjGeoData *NewGeoData() const; 240 virtual void SaveGeoData(SdrObjGeoData &rGeo) const; 241 virtual void RestGeoData(const SdrObjGeoData &rGeo); 242 243 // need to take fObjectRotation instead of aGeo.nWink, replace it temporary 244 virtual sal_Bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const; 245 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon); 246 247 virtual const SdrGluePointList* GetGluePointList() const; 248 //virtual SdrGluePointList* GetGluePointList(); 249 virtual SdrGluePointList* ForceGluePointList(); 250 251 virtual sal_uInt32 GetHdlCount() const; 252 virtual SdrHdl* GetHdl( sal_uInt32 nHdlNum ) const; 253 254 // #i33136# 255 static bool doConstructOrthogonal(const ::rtl::OUString& rName); 256 257 using SdrTextObj::NbcSetOutlinerParaObject; 258 }; 259 260 #endif //_SVDOASHP_HXX 261 262