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 .
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"
32 //************************************************************
33 // Vorausdeklarationen
34 //************************************************************
44 class CustomShapeProperties
;
45 } // end of namespace properties
46 } // end of namespace sdr
48 class SdrAShapeObjGeoData
: public SdrTextObjGeoData
54 double fObjectRotation
;
56 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
>
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
;
74 //************************************************************
76 //************************************************************
78 class SVX_DLLPUBLIC SdrObjCustomShape
: public SdrTextObj
81 // fObjectRotation is containing the object rotation in degrees.
82 double fObjectRotation
;
85 virtual sdr::contact::ViewContact
* CreateObjectSpecificViewContact();
86 virtual void impl_setUnoShape(const com::sun::star::uno::Reference
<com::sun::star::uno::XInterface
>& rxUnoShape
);
89 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties();
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;
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();
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
);
126 const SdrObject
* GetSdrObjectFromCustomShape() const;
127 const SdrObject
* GetSdrObjectShadowFromCustomShape() const;
128 sal_Bool
GetTextBounds( Rectangle
& rTextBound
) const;
129 sal_Bool
IsTextPath() const;
130 static basegfx::B2DPolyPolygon
GetLineGeometry( const SdrObjCustomShape
* pCustomShape
, const sal_Bool bBezierAllowed
);
138 sal_Bool
UseNoFillStyle() const;
140 sal_Bool
IsMirroredX() const;
141 sal_Bool
IsMirroredY() const;
142 bool IsPostRotate() const;
143 void SetMirroredX( const sal_Bool bMirroredX
);
144 void SetMirroredY( const sal_Bool bMirroredY
);
146 double GetObjectRotation() const;
147 double GetExtraTextRotation( const bool bPreRotation
= false ) const;
151 virtual ~SdrObjCustomShape();
153 /* is merging default attributes from type-shype into the SdrCustomShapeGeometryItem. If pType
154 is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem.
155 MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */
156 void MergeDefaultAttributes( const OUString
* pType
= NULL
);
158 /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
171 sal_Bool
IsDefaultGeometry( const DefaultType eDefaultType
) const;
173 virtual sal_uInt16
GetObjIdentifier() const;
174 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const;
176 virtual void SetModel(SdrModel
* pNewModel
);
178 virtual void RecalcSnapRect();
180 virtual const Rectangle
& GetSnapRect() const;
181 virtual const Rectangle
& GetCurrentBoundRect() const;
182 virtual const Rectangle
& GetLogicRect() const;
184 virtual void Move(const Size
& rSiz
);
185 virtual void Resize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
, bool bUnsetRelative
= true);
186 virtual void Shear(const Point
& rRef
, long nWink
, double tn
, bool bVShear
);
187 virtual void SetSnapRect(const Rectangle
& rRect
);
188 virtual void SetLogicRect(const Rectangle
& rRect
);
190 virtual void NbcMove(const Size
& rSiz
);
191 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
192 virtual void NbcRotate(const Point
& rRef
, long nWink
, double sn
, double cs
);
193 virtual void NbcMirror(const Point
& rRef1
, const Point
& rRef2
);
194 virtual void NbcShear(const Point
& rRef
, long nWink
, double tn
, bool bVShear
);
195 virtual void NbcSetSnapRect(const Rectangle
& rRect
);
196 virtual void NbcSetLogicRect(const Rectangle
& rRect
);
198 virtual SdrGluePoint
GetVertexGluePoint(sal_uInt16 nNum
) const;
200 virtual void NbcSetStyleSheet( SfxStyleSheet
* pNewStyleSheet
, sal_Bool bDontRemoveHardAttr
);
202 // special drag methods
203 virtual bool hasSpecialDrag() const;
204 virtual bool beginSpecialDrag(SdrDragStat
& rDrag
) const;
205 virtual bool applySpecialDrag(SdrDragStat
& rDrag
);
207 virtual bool BegCreate( SdrDragStat
& rStat
);
208 virtual bool MovCreate(SdrDragStat
& rStat
); // #i37448#
209 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
);
211 virtual bool AdjustTextFrameWidthAndHeight(Rectangle
& rR
, bool bHgt
= true, bool bWdt
= true) const;
212 virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt
= true, bool bWdt
= true);
213 virtual bool AdjustTextFrameWidthAndHeight(bool bHgt
= true, bool bWdt
= true);
214 virtual bool IsAutoGrowHeight() const;
215 virtual bool IsAutoGrowWidth() const;
216 virtual void SetVerticalWriting( sal_Bool bVertical
);
217 virtual sal_Bool
BegTextEdit( SdrOutliner
& rOutl
);
218 virtual void TakeTextEditArea(Size
* pPaperMin
, Size
* pPaperMax
, Rectangle
* pViewInit
, Rectangle
* pViewMin
) const;
219 virtual void EndTextEdit( SdrOutliner
& rOutl
);
220 virtual void TakeTextAnchorRect( Rectangle
& rAnchorRect
) const;
221 virtual void TakeTextRect( SdrOutliner
& rOutliner
, Rectangle
& rTextRect
, bool bNoEditText
= false,
222 Rectangle
* pAnchorRect
=NULL
, bool bLineWidth
= true ) const;
223 virtual SdrObjCustomShape
* Clone() const;
224 SdrObjCustomShape
& operator=(const SdrObjCustomShape
& rObj
);
226 virtual void TakeObjNameSingul(String
& rName
) const;
227 virtual void TakeObjNamePlural(String
& rName
) const;
229 virtual basegfx::B2DPolyPolygon
TakeCreatePoly( const SdrDragStat
& rDrag
) const;
231 virtual basegfx::B2DPolyPolygon
TakeXorPoly() const;
232 virtual basegfx::B2DPolyPolygon
TakeContour() const;
234 virtual void NbcSetOutlinerParaObject(OutlinerParaObject
* pTextObject
);
236 virtual SdrObject
* DoConvertToPolyObj(sal_Bool bBezier
, bool bAddText
) const;
238 virtual void SetPage( SdrPage
* pNewPage
);
240 virtual SdrObjGeoData
*NewGeoData() const;
241 virtual void SaveGeoData(SdrObjGeoData
&rGeo
) const;
242 virtual void RestGeoData(const SdrObjGeoData
&rGeo
);
244 // need to take fObjectRotation instead of aGeo.nWink, replace it temporary
245 virtual sal_Bool
TRGetBaseGeometry(basegfx::B2DHomMatrix
& rMatrix
, basegfx::B2DPolyPolygon
& rPolyPolygon
) const;
246 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix
& rMatrix
, const basegfx::B2DPolyPolygon
& rPolyPolygon
);
248 virtual const SdrGluePointList
* GetGluePointList() const;
249 //virtual SdrGluePointList* GetGluePointList();
250 virtual SdrGluePointList
* ForceGluePointList();
252 virtual sal_uInt32
GetHdlCount() const;
253 virtual SdrHdl
* GetHdl( sal_uInt32 nHdlNum
) const;
256 static bool doConstructOrthogonal(const OUString
& rName
);
258 using SdrTextObj::NbcSetOutlinerParaObject
;
261 #endif //_SVDOASHP_HXX
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */