Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / include / svx / svdoashp.hxx
blobc7be3585c6799afd64cd154a819b83015a88b694
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_SVDOASHP_HXX
21 #define INCLUDED_SVX_SVDOASHP_HXX
23 #include <svx/svdobj.hxx>
24 #include <svx/svdotext.hxx>
25 #include <svx/svdhdl.hxx>
26 #include <vector>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
29 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
30 #include <svx/svxdllapi.h>
33 // Initial Declarations
36 class SdrObjList;
37 class SdrObjListIter;
38 class SfxItemSet;
40 namespace sdr
42 namespace properties
44 class CustomShapeProperties;
45 } // end of namespace properties
46 } // end of namespace sdr
48 class SdrAShapeObjGeoData : public SdrTextObjGeoData
50 public:
52 bool bMirroredX;
53 bool bMirroredY;
54 double fObjectRotation;
56 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >
57 aAdjustmentSeq;
60 #define CUSTOMSHAPE_HANDLE_RESIZE_FIXED 1
61 #define CUSTOMSHAPE_HANDLE_CREATE_FIXED 2
62 #define CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X 4
63 #define CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y 8
64 #define CUSTOMSHAPE_HANDLE_MOVE_SHAPE 16
65 #define CUSTOMSHAPE_HANDLE_ORTHO4 32
67 struct SdrCustomShapeInteraction
69 com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > xInteraction;
70 com::sun::star::awt::Point aPosition;
71 sal_Int32 nMode;
75 // SdrObjCustomShape
78 class SVX_DLLPUBLIC SdrObjCustomShape : public SdrTextObj
80 private:
81 // fObjectRotation is containing the object rotation in degrees.
82 double fObjectRotation;
84 protected:
85 virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE;
86 virtual void impl_setUnoShape(const com::sun::star::uno::Reference<com::sun::star::uno::XInterface>& rxUnoShape) SAL_OVERRIDE;
88 public:
89 virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() SAL_OVERRIDE;
91 // to allow sdr::properties::CustomShapeProperties access
92 friend class sdr::properties::CustomShapeProperties;
94 com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mXRenderedCustomShape;
96 mutable com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > mxCustomShapeEngine;
98 // #i37011# render geometry shadow
99 SdrObject* mpLastShadowGeometry;
101 com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > GetCustomShapeEngine() const;
103 // SVX_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > >
104 // SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const;
105 // #i47293#
106 // SVX_DLLPRIVATE std::vector< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > > GetFixedInteractionHandle() const;
108 SVX_DLLPRIVATE std::vector< SdrCustomShapeInteraction > GetInteractionHandles( const SdrObjCustomShape* pCustomShape ) const;
110 SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag );
112 SVX_DLLPRIVATE void DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const;
113 SVX_DLLPRIVATE void DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const;
115 // #i37011# centralize throw-away of render geometry
116 void InvalidateRenderGeometry();
118 // #i38892#
119 void ImpCheckCustomGluePointsAreAdded();
121 // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed.
122 Rectangle ImpCalculateTextFrame( const bool bHgt, const bool bWdt );
124 public:
125 // #i37011#
126 const SdrObject* GetSdrObjectFromCustomShape() const;
127 const SdrObject* GetSdrObjectShadowFromCustomShape() const;
128 bool GetTextBounds( Rectangle& rTextBound ) const;
129 bool IsTextPath() const;
130 static basegfx::B2DPolyPolygon GetLineGeometry( const SdrObjCustomShape* pCustomShape, const bool bBezierAllowed );
132 protected:
133 // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set
134 // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities
135 // and object sizes
136 virtual void AdaptTextMinSize() SAL_OVERRIDE;
138 OUString aName;
140 public:
142 bool UseNoFillStyle() const;
144 bool IsMirroredX() const;
145 bool IsMirroredY() const;
146 bool IsPostRotate() const;
147 void SetMirroredX( const bool bMirroredX );
148 void SetMirroredY( const bool bMirroredY );
150 double GetObjectRotation() const;
151 double GetExtraTextRotation( const bool bPreRotation = false ) const;
153 TYPEINFO_OVERRIDE();
154 SdrObjCustomShape();
155 virtual ~SdrObjCustomShape();
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 OUString* pType = NULL );
162 /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
163 enum DefaultType
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
175 bool IsDefaultGeometry( const DefaultType eDefaultType ) const;
177 virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
178 virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const SAL_OVERRIDE;
180 virtual void SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
182 virtual void RecalcSnapRect() SAL_OVERRIDE;
184 virtual const Rectangle& GetSnapRect() const SAL_OVERRIDE;
185 virtual const Rectangle& GetCurrentBoundRect() const SAL_OVERRIDE;
186 virtual const Rectangle& GetLogicRect() const SAL_OVERRIDE;
188 virtual void Move(const Size& rSiz) SAL_OVERRIDE;
189 virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) SAL_OVERRIDE;
190 virtual void Shear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE;
191 virtual void SetSnapRect(const Rectangle& rRect) SAL_OVERRIDE;
192 virtual void SetLogicRect(const Rectangle& rRect) SAL_OVERRIDE;
194 virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE;
195 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
196 virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs) SAL_OVERRIDE;
197 virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE;
198 virtual void NbcShear(const Point& rRef, long nWink, double tn, bool bVShear) SAL_OVERRIDE;
199 virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE;
200 virtual void NbcSetLogicRect(const Rectangle& rRect) SAL_OVERRIDE;
202 virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const SAL_OVERRIDE;
204 virtual void NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr ) SAL_OVERRIDE;
206 // special drag methods
207 virtual bool hasSpecialDrag() const SAL_OVERRIDE;
208 virtual bool beginSpecialDrag(SdrDragStat& rDrag) const SAL_OVERRIDE;
209 virtual bool applySpecialDrag(SdrDragStat& rDrag) SAL_OVERRIDE;
211 virtual bool BegCreate( SdrDragStat& rStat ) SAL_OVERRIDE;
212 virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE; // #i37448#
213 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
215 virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = true, bool bWdt = true) const SAL_OVERRIDE;
216 virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
217 virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
218 virtual bool IsAutoGrowHeight() const SAL_OVERRIDE;
219 virtual bool IsAutoGrowWidth() const SAL_OVERRIDE;
220 virtual void SetVerticalWriting( bool bVertical ) SAL_OVERRIDE;
221 virtual bool BegTextEdit( SdrOutliner& rOutl ) SAL_OVERRIDE;
222 virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const SAL_OVERRIDE;
223 virtual void EndTextEdit( SdrOutliner& rOutl ) SAL_OVERRIDE;
224 virtual void TakeTextAnchorRect( Rectangle& rAnchorRect ) const SAL_OVERRIDE;
225 virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText = false,
226 Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const SAL_OVERRIDE;
227 virtual SdrObjCustomShape* Clone() const SAL_OVERRIDE;
228 SdrObjCustomShape& operator=(const SdrObjCustomShape& rObj);
230 virtual OUString TakeObjNameSingul() const SAL_OVERRIDE;
231 virtual OUString TakeObjNamePlural() const SAL_OVERRIDE;
233 virtual basegfx::B2DPolyPolygon TakeCreatePoly( const SdrDragStat& rDrag) const SAL_OVERRIDE;
235 virtual basegfx::B2DPolyPolygon TakeXorPoly() const SAL_OVERRIDE;
236 virtual basegfx::B2DPolyPolygon TakeContour() const SAL_OVERRIDE;
238 virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) SAL_OVERRIDE;
240 virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const SAL_OVERRIDE;
242 virtual void SetPage( SdrPage* pNewPage ) SAL_OVERRIDE;
244 virtual SdrObjGeoData *NewGeoData() const SAL_OVERRIDE;
245 virtual void SaveGeoData(SdrObjGeoData &rGeo) const SAL_OVERRIDE;
246 virtual void RestGeoData(const SdrObjGeoData &rGeo) SAL_OVERRIDE;
248 // need to take fObjectRotation instead of aGeo.nWink, replace it temporary
249 virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const SAL_OVERRIDE;
250 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) SAL_OVERRIDE;
252 virtual const SdrGluePointList* GetGluePointList() const SAL_OVERRIDE;
253 //virtual SdrGluePointList* GetGluePointList();
254 virtual SdrGluePointList* ForceGluePointList() SAL_OVERRIDE;
256 virtual sal_uInt32 GetHdlCount() const SAL_OVERRIDE;
257 virtual SdrHdl* GetHdl( sal_uInt32 nHdlNum ) const SAL_OVERRIDE;
259 // #i33136#
260 static bool doConstructOrthogonal(const OUString& rName);
262 using SdrTextObj::NbcSetOutlinerParaObject;
264 OUString GetCustomShapeName();
267 #endif // INCLUDED_SVX_SVDOASHP_HXX
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */