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 bool bPurposeFlipX; 139 bool bPurposeFlipY; 140 141 sal_Bool UseNoFillStyle() const; 142 143 sal_Bool IsMirroredX() const; 144 sal_Bool IsMirroredY() const; 145 void SetMirroredX( const sal_Bool bMirroredX ); 146 void SetMirroredY( const sal_Bool bMirroredY ); 147 148 double GetObjectRotation() const; 149 double GetExtraTextRotation() const; 150 151 TYPEINFO(); 152 SdrObjCustomShape(); 153 virtual ~SdrObjCustomShape(); 154 155 /* is merging default attributes from type-shype into the SdrCustomShapeGeometryItem. If pType 156 is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem. 157 MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */ 158 void MergeDefaultAttributes( const rtl::OUString* pType = NULL ); 159 160 /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */ 161 enum DefaultType 162 { 163 DEFAULT_PATH, 164 DEFAULT_VIEWBOX, 165 DEFAULT_SEGMENTS, 166 DEFAULT_GLUEPOINTS, 167 DEFAULT_STRETCHX, 168 DEFAULT_STRETCHY, 169 DEFAULT_EQUATIONS, 170 DEFAULT_HANDLES, 171 DEFAULT_TEXTFRAMES 172 }; 173 sal_Bool IsDefaultGeometry( const DefaultType eDefaultType ) const; 174 175 virtual sal_uInt16 GetObjIdentifier() const; 176 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const; 177 178 virtual void SetModel(SdrModel* pNewModel); 179 180 virtual void RecalcSnapRect(); 181 182 virtual const Rectangle& GetSnapRect() const; 183 virtual const Rectangle& GetCurrentBoundRect() const; 184 virtual const Rectangle& GetLogicRect() const; 185 186 virtual void Move(const Size& rSiz); 187 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); 188 virtual void Shear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear); 189 virtual void SetSnapRect(const Rectangle& rRect); 190 virtual void SetLogicRect(const Rectangle& rRect); 191 192 virtual void NbcMove(const Size& rSiz); 193 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); 194 virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs); 195 virtual void NbcMirror(const Point& rRef1, const Point& rRef2); 196 virtual void NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear); 197 virtual void NbcSetSnapRect(const Rectangle& rRect); 198 virtual void NbcSetLogicRect(const Rectangle& rRect); 199 200 virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const; 201 202 virtual void NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr ); 203 204 // special drag methods 205 virtual bool hasSpecialDrag() const; 206 virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; 207 virtual bool applySpecialDrag(SdrDragStat& rDrag); 208 209 virtual FASTBOOL BegCreate( SdrDragStat& rStat ); 210 virtual FASTBOOL MovCreate(SdrDragStat& rStat); // #i37448# 211 virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd); 212 213 virtual FASTBOOL AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHgt=sal_True, FASTBOOL bWdt=sal_True) const; 214 virtual FASTBOOL NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt=sal_True, FASTBOOL bWdt=sal_True); 215 virtual FASTBOOL AdjustTextFrameWidthAndHeight(FASTBOOL bHgt=sal_True, FASTBOOL bWdt=sal_True); 216 virtual FASTBOOL IsAutoGrowHeight() const; 217 virtual FASTBOOL IsAutoGrowWidth() const; 218 virtual void SetVerticalWriting( sal_Bool bVertical ); 219 virtual sal_Bool BegTextEdit( SdrOutliner& rOutl ); 220 virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const; 221 virtual void EndTextEdit( SdrOutliner& rOutl ); 222 virtual void TakeTextAnchorRect( Rectangle& rAnchorRect ) const; 223 virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText=sal_False, 224 Rectangle* pAnchorRect=NULL, sal_Bool bLineWidth=sal_True ) const; 225 virtual void operator=(const SdrObject& rObj); 226 227 virtual void TakeObjNameSingul(String& rName) const; 228 virtual void TakeObjNamePlural(String& rName) const; 229 230 virtual basegfx::B2DPolyPolygon TakeCreatePoly( const SdrDragStat& rDrag) const; 231 232 virtual basegfx::B2DPolyPolygon TakeXorPoly() const; 233 virtual basegfx::B2DPolyPolygon TakeContour() const; 234 235 virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject); 236 237 virtual SdrObject* DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const; 238 239 virtual void SetPage( SdrPage* pNewPage ); 240 241 virtual SdrObjGeoData *NewGeoData() const; 242 virtual void SaveGeoData(SdrObjGeoData &rGeo) const; 243 virtual void RestGeoData(const SdrObjGeoData &rGeo); 244 245 // need to take fObjectRotation instead of aGeo.nWink, replace it temporary 246 virtual sal_Bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const; 247 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon); 248 249 virtual const SdrGluePointList* GetGluePointList() const; 250 //virtual SdrGluePointList* GetGluePointList(); 251 virtual SdrGluePointList* ForceGluePointList(); 252 253 virtual sal_uInt32 GetHdlCount() const; 254 virtual SdrHdl* GetHdl( sal_uInt32 nHdlNum ) const; 255 256 // #i33136# 257 static bool doConstructOrthogonal(const ::rtl::OUString& rName); 258 259 using SdrTextObj::NbcSetOutlinerParaObject; 260 }; 261 262 #endif //_SVDOASHP_HXX 263 264