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