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