1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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>
31 #include <o3tl/typed_flags_set.hxx>
34 // Initial Declarations
45 class CustomShapeProperties
;
46 } // end of namespace properties
47 } // end of namespace sdr
49 class SdrAShapeObjGeoData
: public SdrTextObjGeoData
55 double fObjectRotation
;
57 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
>
61 enum class CustomShapeHandleModes
66 RESIZE_ABSOLUTE_X
= 4,
67 RESIZE_ABSOLUTE_Y
= 8,
73 template<> struct typed_flags
<CustomShapeHandleModes
> : is_typed_flags
<CustomShapeHandleModes
, 63> {};
76 struct SdrCustomShapeInteraction
78 com::sun::star::uno::Reference
< com::sun::star::drawing::XCustomShapeHandle
> xInteraction
;
79 com::sun::star::awt::Point aPosition
;
80 CustomShapeHandleModes nMode
;
87 class SVX_DLLPUBLIC SdrObjCustomShape
: public SdrTextObj
90 // fObjectRotation is containing the object rotation in degrees.
91 double fObjectRotation
;
94 virtual sdr::contact::ViewContact
* CreateObjectSpecificViewContact() SAL_OVERRIDE
;
95 virtual void impl_setUnoShape(const com::sun::star::uno::Reference
<com::sun::star::uno::XInterface
>& rxUnoShape
) SAL_OVERRIDE
;
98 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties() SAL_OVERRIDE
;
100 // to allow sdr::properties::CustomShapeProperties access
101 friend class sdr::properties::CustomShapeProperties
;
103 com::sun::star::uno::Reference
< com::sun::star::drawing::XShape
> mXRenderedCustomShape
;
105 mutable com::sun::star::uno::Reference
< com::sun::star::drawing::XCustomShapeEngine
> mxCustomShapeEngine
;
107 // #i37011# render geometry shadow
108 SdrObject
* mpLastShadowGeometry
;
110 com::sun::star::uno::Reference
< com::sun::star::drawing::XCustomShapeEngine
> GetCustomShapeEngine() const;
112 // SVX_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > >
113 // SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const;
115 // SVX_DLLPRIVATE std::vector< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > > GetFixedInteractionHandle() const;
117 SVX_DLLPRIVATE
std::vector
< SdrCustomShapeInteraction
> GetInteractionHandles() const;
119 SVX_DLLPRIVATE
void DragCreateObject( SdrDragStat
& rDrag
);
121 SVX_DLLPRIVATE
void DragResizeCustomShape( const Rectangle
& rNewRect
);
122 SVX_DLLPRIVATE
void DragMoveCustomShapeHdl( const Point
& rDestination
,
123 const sal_uInt16 nCustomShapeHdlNum
, bool bMoveCalloutRectangle
);
125 // #i37011# centralize throw-away of render geometry
126 void InvalidateRenderGeometry();
129 void ImpCheckCustomGluePointsAreAdded();
131 // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed.
132 Rectangle
ImpCalculateTextFrame( const bool bHgt
, const bool bWdt
);
136 const SdrObject
* GetSdrObjectFromCustomShape() const;
137 const SdrObject
* GetSdrObjectShadowFromCustomShape() const;
138 bool GetTextBounds( Rectangle
& rTextBound
) const;
139 bool IsTextPath() const;
140 basegfx::B2DPolyPolygon
GetLineGeometry( const bool bBezierAllowed
) const;
143 // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set
144 // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities
146 virtual void AdaptTextMinSize() SAL_OVERRIDE
;
149 Size m_aSuggestedTextFrameSize
;
153 bool UseNoFillStyle() const;
155 bool IsMirroredX() const;
156 bool IsMirroredY() const;
157 bool IsPostRotate() const;
158 void SetMirroredX( const bool bMirroredX
);
159 void SetMirroredY( const bool bMirroredY
);
161 double GetObjectRotation() const { return fObjectRotation
;}
162 double GetExtraTextRotation( const bool bPreRotation
= false ) const;
166 virtual ~SdrObjCustomShape();
168 /* is merging default attributes from type-shype into the SdrCustomShapeGeometryItem. If pType
169 is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem.
170 MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */
171 void MergeDefaultAttributes( const OUString
* pType
= NULL
);
173 /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
186 bool IsDefaultGeometry( const DefaultType eDefaultType
) const;
188 virtual sal_uInt16
GetObjIdentifier() const SAL_OVERRIDE
;
189 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const SAL_OVERRIDE
;
191 virtual void SetModel(SdrModel
* pNewModel
) SAL_OVERRIDE
;
193 virtual void RecalcSnapRect() SAL_OVERRIDE
;
195 virtual const Rectangle
& GetSnapRect() const SAL_OVERRIDE
;
196 virtual const Rectangle
& GetCurrentBoundRect() const SAL_OVERRIDE
;
197 virtual const Rectangle
& GetLogicRect() const SAL_OVERRIDE
;
199 virtual void Move(const Size
& rSiz
) SAL_OVERRIDE
;
200 virtual void Resize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
, bool bUnsetRelative
= true) SAL_OVERRIDE
;
201 virtual void Shear(const Point
& rRef
, long nAngle
, double tn
, bool bVShear
) SAL_OVERRIDE
;
202 virtual void SetSnapRect(const Rectangle
& rRect
) SAL_OVERRIDE
;
203 virtual void SetLogicRect(const Rectangle
& rRect
) SAL_OVERRIDE
;
205 virtual void NbcMove(const Size
& rSiz
) SAL_OVERRIDE
;
206 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) SAL_OVERRIDE
;
207 virtual void NbcRotate(const Point
& rRef
, long nAngle
, double sn
, double cs
) SAL_OVERRIDE
;
208 virtual void NbcMirror(const Point
& rRef1
, const Point
& rRef2
) SAL_OVERRIDE
;
209 virtual void NbcShear(const Point
& rRef
, long nAngle
, double tn
, bool bVShear
) SAL_OVERRIDE
;
210 virtual void NbcSetSnapRect(const Rectangle
& rRect
) SAL_OVERRIDE
;
211 virtual void NbcSetLogicRect(const Rectangle
& rRect
) SAL_OVERRIDE
;
213 virtual SdrGluePoint
GetVertexGluePoint(sal_uInt16 nNum
) const SAL_OVERRIDE
;
215 virtual void NbcSetStyleSheet( SfxStyleSheet
* pNewStyleSheet
, bool bDontRemoveHardAttr
) SAL_OVERRIDE
;
217 // special drag methods
218 virtual bool hasSpecialDrag() const SAL_OVERRIDE
;
219 virtual bool beginSpecialDrag(SdrDragStat
& rDrag
) const SAL_OVERRIDE
;
220 virtual bool applySpecialDrag(SdrDragStat
& rDrag
) SAL_OVERRIDE
;
222 virtual bool BegCreate( SdrDragStat
& rStat
) SAL_OVERRIDE
;
223 virtual bool MovCreate(SdrDragStat
& rStat
) SAL_OVERRIDE
; // #i37448#
224 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) SAL_OVERRIDE
;
227 * Allows suggesting the text frame size: in case the application has its
228 * own text associated to the shape, instead of using the shape's editeng
231 void SuggestTextFrameSize(Size aSuggestedTextFrameSize
);
232 virtual bool AdjustTextFrameWidthAndHeight(Rectangle
& rR
, bool bHgt
= true, bool bWdt
= true) const SAL_OVERRIDE
;
233 virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt
= true, bool bWdt
= true) SAL_OVERRIDE
;
234 virtual bool AdjustTextFrameWidthAndHeight(bool bHgt
= true, bool bWdt
= true) SAL_OVERRIDE
;
235 virtual bool IsAutoGrowHeight() const SAL_OVERRIDE
;
236 virtual bool IsAutoGrowWidth() const SAL_OVERRIDE
;
237 virtual void SetVerticalWriting( bool bVertical
) SAL_OVERRIDE
;
238 virtual bool BegTextEdit( SdrOutliner
& rOutl
) SAL_OVERRIDE
;
239 virtual void TakeTextEditArea(Size
* pPaperMin
, Size
* pPaperMax
, Rectangle
* pViewInit
, Rectangle
* pViewMin
) const SAL_OVERRIDE
;
240 virtual void EndTextEdit( SdrOutliner
& rOutl
) SAL_OVERRIDE
;
241 virtual void TakeTextAnchorRect( Rectangle
& rAnchorRect
) const SAL_OVERRIDE
;
242 virtual void TakeTextRect( SdrOutliner
& rOutliner
, Rectangle
& rTextRect
, bool bNoEditText
= false,
243 Rectangle
* pAnchorRect
=NULL
, bool bLineWidth
= true ) const SAL_OVERRIDE
;
244 virtual SdrObjCustomShape
* Clone() const SAL_OVERRIDE
;
245 SdrObjCustomShape
& operator=(const SdrObjCustomShape
& rObj
);
247 virtual OUString
TakeObjNameSingul() const SAL_OVERRIDE
;
248 virtual OUString
TakeObjNamePlural() const SAL_OVERRIDE
;
250 virtual basegfx::B2DPolyPolygon
TakeCreatePoly( const SdrDragStat
& rDrag
) const SAL_OVERRIDE
;
252 virtual basegfx::B2DPolyPolygon
TakeXorPoly() const SAL_OVERRIDE
;
253 virtual basegfx::B2DPolyPolygon
TakeContour() const SAL_OVERRIDE
;
255 virtual void NbcSetOutlinerParaObject(OutlinerParaObject
* pTextObject
) SAL_OVERRIDE
;
257 virtual SdrObject
* DoConvertToPolyObj(bool bBezier
, bool bAddText
) const SAL_OVERRIDE
;
259 virtual void SetPage( SdrPage
* pNewPage
) SAL_OVERRIDE
;
261 virtual SdrObjGeoData
*NewGeoData() const SAL_OVERRIDE
;
262 virtual void SaveGeoData(SdrObjGeoData
&rGeo
) const SAL_OVERRIDE
;
263 virtual void RestGeoData(const SdrObjGeoData
&rGeo
) SAL_OVERRIDE
;
265 // need to take fObjectRotation instead of aGeo.nAngle, replace it temporary
266 virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix
& rMatrix
, basegfx::B2DPolyPolygon
& rPolyPolygon
) const SAL_OVERRIDE
;
267 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix
& rMatrix
, const basegfx::B2DPolyPolygon
& rPolyPolygon
) SAL_OVERRIDE
;
269 virtual const SdrGluePointList
* GetGluePointList() const SAL_OVERRIDE
;
270 //virtual SdrGluePointList* GetGluePointList();
271 virtual SdrGluePointList
* ForceGluePointList() SAL_OVERRIDE
;
273 virtual sal_uInt32
GetHdlCount() const SAL_OVERRIDE
;
274 virtual SdrHdl
* GetHdl( sal_uInt32 nHdlNum
) const SAL_OVERRIDE
;
277 static bool doConstructOrthogonal(const OUString
& rName
);
279 using SdrTextObj::NbcSetOutlinerParaObject
;
281 OUString
GetCustomShapeName();
284 #endif // INCLUDED_SVX_SVDOASHP_HXX
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */