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