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>
37 class CustomShapeProperties
;
41 class SdrAShapeObjGeoData
: public SdrTextObjGeoData
46 double fObjectRotation
;
48 css::uno::Sequence
< css::drawing::EnhancedCustomShapeAdjustmentValue
> aAdjustmentSeq
;
51 enum class CustomShapeHandleModes
56 RESIZE_ABSOLUTE_X
= 4,
57 RESIZE_ABSOLUTE_Y
= 8,
64 template<> struct typed_flags
<CustomShapeHandleModes
> : is_typed_flags
<CustomShapeHandleModes
, 63> {};
67 struct SdrCustomShapeInteraction
69 css::uno::Reference
< css::drawing::XCustomShapeHandle
> xInteraction
;
70 css::awt::Point aPosition
;
71 CustomShapeHandleModes nMode
;
74 class SVX_DLLPUBLIC SdrObjCustomShape
: public SdrTextObj
77 // fObjectRotation is containing the object rotation in degrees.
78 double fObjectRotation
;
79 bool mbAdjustingTextFrameWidthAndHeight
;
82 virtual sdr::contact::ViewContact
* CreateObjectSpecificViewContact() override
;
83 virtual void impl_setUnoShape(const css::uno::Reference
<css::uno::XInterface
>& rxUnoShape
) override
;
86 virtual sdr::properties::BaseProperties
* CreateObjectSpecificProperties() override
;
88 // to allow sdr::properties::CustomShapeProperties access
89 friend class sdr::properties::CustomShapeProperties
;
91 css::uno::Reference
< css::drawing::XShape
> mXRenderedCustomShape
;
93 mutable css::uno::Reference
< css::drawing::XCustomShapeEngine
> mxCustomShapeEngine
;
95 // #i37011# render geometry shadow
96 SdrObject
* mpLastShadowGeometry
;
98 css::uno::Reference
< css::drawing::XCustomShapeEngine
> const & GetCustomShapeEngine() const;
100 // SVX_DLLPRIVATE css::uno::Sequence< css::uno::Reference< css::drawing::XCustomShapeHandle > >
101 // SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const;
103 // SVX_DLLPRIVATE std::vector< css::uno::Reference< css::drawing::XCustomShapeHandle > > GetFixedInteractionHandle() const;
105 SVX_DLLPRIVATE
std::vector
< SdrCustomShapeInteraction
> GetInteractionHandles() const;
107 SVX_DLLPRIVATE
void DragCreateObject( SdrDragStat
& rDrag
);
109 SVX_DLLPRIVATE
void DragResizeCustomShape( const tools::Rectangle
& rNewRect
);
110 SVX_DLLPRIVATE
void DragMoveCustomShapeHdl( const Point
& rDestination
,
111 const sal_uInt16 nCustomShapeHdlNum
, bool bMoveCalloutRectangle
);
113 // #i37011# centralize throw-away of render geometry
114 void InvalidateRenderGeometry();
117 void ImpCheckCustomGluePointsAreAdded();
119 // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed.
120 tools::Rectangle
ImpCalculateTextFrame( const bool bHgt
, const bool bWdt
);
124 const SdrObject
* GetSdrObjectFromCustomShape() const;
125 const SdrObject
* GetSdrObjectShadowFromCustomShape() const;
126 bool GetTextBounds( tools::Rectangle
& rTextBound
) const;
127 bool IsTextPath() const;
128 basegfx::B2DPolyPolygon
GetLineGeometry( const bool bBezierAllowed
) const;
131 // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set
132 // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities
134 virtual void AdaptTextMinSize() override
;
136 Size m_aSuggestedTextFrameSize
;
139 bool UseNoFillStyle() const;
141 bool IsMirroredX() const;
142 bool IsMirroredY() const;
143 bool IsPostRotate() const;
144 void SetMirroredX( const bool bMirroredX
);
145 void SetMirroredY( const bool bMirroredY
);
147 double GetObjectRotation() const { return fObjectRotation
;}
148 double GetExtraTextRotation( const bool bPreRotation
= false ) const;
151 virtual ~SdrObjCustomShape() override
;
153 /* is merging default attributes from type-shape 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
= nullptr );
158 /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
159 enum class DefaultType
170 bool IsDefaultGeometry( const DefaultType eDefaultType
) const;
172 virtual sal_uInt16
GetObjIdentifier() const override
;
173 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const override
;
175 virtual void SetModel(SdrModel
* pNewModel
) override
;
177 virtual void Move(const Size
& rSiz
) override
;
178 virtual void Shear(const Point
& rRef
, long nAngle
, double tn
, bool bVShear
) override
;
179 virtual void SetSnapRect(const tools::Rectangle
& rRect
) override
;
180 virtual void SetLogicRect(const tools::Rectangle
& rRect
) override
;
182 virtual void NbcMove(const Size
& rSiz
) override
;
183 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
184 virtual void NbcRotate(const Point
& rRef
, long nAngle
, double sn
, double cs
) override
;
185 virtual void NbcMirror(const Point
& rRef1
, const Point
& rRef2
) override
;
186 virtual void NbcShear(const Point
& rRef
, long nAngle
, double tn
, bool bVShear
) override
;
187 virtual void NbcSetSnapRect(const tools::Rectangle
& rRect
) override
;
188 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
190 virtual SdrGluePoint
GetVertexGluePoint(sal_uInt16 nNum
) const override
;
192 virtual void NbcSetStyleSheet( SfxStyleSheet
* pNewStyleSheet
, bool bDontRemoveHardAttr
) override
;
194 // special drag methods
195 virtual bool hasSpecialDrag() const override
;
196 virtual bool beginSpecialDrag(SdrDragStat
& rDrag
) const override
;
197 virtual bool applySpecialDrag(SdrDragStat
& rDrag
) override
;
199 virtual bool MovCreate(SdrDragStat
& rStat
) override
; // #i37448#
200 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
203 * Allows suggesting the text frame size: in case the application has its
204 * own text associated to the shape, instead of using the shape's editeng
207 void SuggestTextFrameSize(Size aSuggestedTextFrameSize
);
208 virtual bool AdjustTextFrameWidthAndHeight(tools::Rectangle
& rR
, bool bHgt
= true, bool bWdt
= true) const override
;
209 virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt
= true, bool bWdt
= true) override
;
210 virtual bool AdjustTextFrameWidthAndHeight() override
;
211 virtual bool IsAutoGrowHeight() const override
;
212 virtual bool IsAutoGrowWidth() const override
;
213 virtual void SetVerticalWriting(bool bVertical
) override
;
214 virtual void TakeTextEditArea(Size
* pPaperMin
, Size
* pPaperMax
, tools::Rectangle
* pViewInit
, tools::Rectangle
* pViewMin
) const override
;
215 virtual void EndTextEdit( SdrOutliner
& rOutl
) override
;
216 virtual void TakeTextAnchorRect( tools::Rectangle
& rAnchorRect
) const override
;
217 virtual void TakeTextRect( SdrOutliner
& rOutliner
, tools::Rectangle
& rTextRect
, bool bNoEditText
,
218 tools::Rectangle
* pAnchorRect
, bool bLineWidth
= true ) const override
;
219 virtual SdrObjCustomShape
* Clone() const override
;
220 SdrObjCustomShape
& operator=(const SdrObjCustomShape
& rObj
);
222 virtual OUString
TakeObjNameSingul() const override
;
223 virtual OUString
TakeObjNamePlural() const override
;
225 virtual basegfx::B2DPolyPolygon
TakeCreatePoly( const SdrDragStat
& rDrag
) const override
;
227 virtual basegfx::B2DPolyPolygon
TakeXorPoly() const override
;
228 virtual basegfx::B2DPolyPolygon
TakeContour() const override
;
230 virtual void NbcSetOutlinerParaObject(OutlinerParaObject
* pTextObject
) override
;
232 virtual SdrObject
* DoConvertToPolyObj(bool bBezier
, bool bAddText
) const override
;
234 virtual void SetPage( SdrPage
* pNewPage
) override
;
236 virtual SdrObjGeoData
*NewGeoData() const override
;
237 virtual void SaveGeoData(SdrObjGeoData
&rGeo
) const override
;
238 virtual void RestGeoData(const SdrObjGeoData
&rGeo
) override
;
240 // need to take fObjectRotation instead of aGeo.nAngle, replace it temporary
241 virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix
& rMatrix
, basegfx::B2DPolyPolygon
& rPolyPolygon
) const override
;
242 virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix
& rMatrix
, const basegfx::B2DPolyPolygon
& rPolyPolygon
) override
;
244 virtual const SdrGluePointList
* GetGluePointList() const override
;
245 //virtual SdrGluePointList* GetGluePointList();
246 virtual SdrGluePointList
* ForceGluePointList() override
;
248 virtual sal_uInt32
GetHdlCount() const override
;
249 virtual SdrHdl
* GetHdl( sal_uInt32 nHdlNum
) const override
;
252 static bool doConstructOrthogonal(const OUString
& rName
);
254 using SdrTextObj::NbcSetOutlinerParaObject
;
256 OUString
GetCustomShapeName();
259 #endif // INCLUDED_SVX_SVDOASHP_HXX
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */