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_ENHANCEDCUSTOMSHAPE2D_HXX
21 #define INCLUDED_SVX_ENHANCEDCUSTOMSHAPE2D_HXX
23 #include <svx/msdffdef.hxx>
24 #include <svx/sdasitm.hxx>
25 #include <svx/svdotext.hxx>
26 #include <tools/degree.hxx>
27 #include <com/sun/star/awt/Size.hpp>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <com/sun/star/beans/PropertyValues.hpp>
30 #include <svl/itemset.hxx>
31 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
32 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
33 #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
34 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
35 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
37 #include <svx/EnhancedCustomShapeFunctionParser.hxx>
38 #include <tools/gen.hxx>
39 #include <o3tl/typed_flags_set.hxx>
40 #include <basegfx/point/b2dpoint.hxx>
45 namespace com::sun::star::awt
{ struct Point
; }
50 class SdrObjCustomShape
;
52 enum class HandleFlags
59 RANGE_X_MINIMUM
= 0x0020,
60 RANGE_X_MAXIMUM
= 0x0040,
61 RANGE_Y_MINIMUM
= 0x0080,
62 RANGE_Y_MAXIMUM
= 0x0100,
63 RADIUS_RANGE_MINIMUM
= 0x0200,
64 RADIUS_RANGE_MAXIMUM
= 0x0400,
72 template<> struct typed_flags
<HandleFlags
> : is_typed_flags
<HandleFlags
, 0x7fef> {};
75 // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
76 // escher, but we are using it internally in to differentiate
77 // between X_RANGE and Y_RANGE
79 class SVXCORE_DLLPUBLIC EnhancedCustomShape2d final
: public SfxItemSet
81 SdrObjCustomShape
& mrSdrObjCustomShape
;
86 sal_Int32 nCoordWidthG
;
87 sal_Int32 nCoordHeightG
;
88 sal_Int32 nCoordWidth
;
89 sal_Int32 nCoordHeight
;
90 tools::Rectangle aLogicRect
;
101 sal_uInt32 nColorData
;
106 struct SAL_DLLPRIVATE EquationResult
{
110 css::uno::Sequence
< OUString
> seqEquations
;
111 std::vector
< std::shared_ptr
< EnhancedCustomShape::ExpressionNode
> > vNodesSharedPtr
;
112 std::vector
< EquationResult
> vEquationResults
;
114 css::uno::Sequence
< css::drawing::EnhancedCustomShapeSegment
> seqSegments
;
115 css::uno::Sequence
< css::drawing::EnhancedCustomShapeParameterPair
> seqCoordinates
;
116 css::uno::Sequence
< css::drawing::EnhancedCustomShapeTextFrame
> seqTextFrames
;
117 css::uno::Sequence
< css::drawing::EnhancedCustomShapeParameterPair
> seqGluePoints
;
118 css::uno::Sequence
< css::drawing::EnhancedCustomShapeAdjustmentValue
> seqAdjustmentValues
;
119 css::uno::Sequence
< css::beans::PropertyValues
> seqHandles
;
120 css::uno::Sequence
< css::awt::Size
> seqSubViewSize
;
127 Degree100 nRotateAngle
;
129 SAL_DLLPRIVATE
bool SetAdjustValueAsDouble( const double& rValue
, const sal_Int32 nIndex
);
130 SAL_DLLPRIVATE Color
GetColorData( const Color
& rFillColor
, sal_uInt32 nIndex
, double dBrightness
) const;
131 SAL_DLLPRIVATE
void AdaptObjColor(
134 const SfxItemSet
& rCustomShapeSet
,
135 sal_uInt32
& nColorIndex
,
136 sal_uInt32 nColorCount
);
137 SAL_DLLPRIVATE Point
GetPoint( const css::drawing::EnhancedCustomShapeParameterPair
&,
138 const bool bScale
= true, const bool bReplaceGeoSize
= false ) const;
139 SAL_DLLPRIVATE
basegfx::B2DPoint
GetPointAsB2DPoint(const css::drawing::EnhancedCustomShapeParameterPair
&,
140 const bool bScale
= true, const bool bReplaceGeoSize
= false ) const;
142 SAL_DLLPRIVATE
void CreateSubPath(
144 sal_Int32
& rSegmentInd
,
145 std::vector
< std::pair
< rtl::Reference
<SdrPathObj
>, double> >& rObjectList
,
146 bool bLineGeometryNeededOnly
,
147 bool bSortFilledObjectsToBack
,
149 SAL_DLLPRIVATE
rtl::Reference
<SdrObject
> CreatePathObj( bool bLineGeometryNeededOnly
);
150 SAL_DLLPRIVATE
void ApplyShapeAttributes( const SdrCustomShapeGeometryItem
& rItem
);
152 SAL_DLLPRIVATE
void SetPathSize( sal_Int32 nIndex
= 0 );
156 struct SAL_DLLPRIVATE Handle
160 css::drawing::EnhancedCustomShapeParameterPair aPosition
;
161 css::drawing::EnhancedCustomShapeParameterPair aPolar
;
168 css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum
;
169 css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum
;
170 css::drawing::EnhancedCustomShapeParameter aXRangeMinimum
;
171 css::drawing::EnhancedCustomShapeParameter aXRangeMaximum
;
172 css::drawing::EnhancedCustomShapeParameter aYRangeMinimum
;
173 css::drawing::EnhancedCustomShapeParameter aYRangeMaximum
;
176 : nFlags(HandleFlags::NONE
)
185 sal_Int32
GetLuminanceChange( sal_uInt32 nIndex
) const;
186 SAL_DLLPRIVATE
bool IsFlipVert() const { return bFlipV
; };
187 SAL_DLLPRIVATE
bool IsFlipHorz() const { return bFlipH
; };
188 SAL_DLLPRIVATE Degree100
GetRotateAngle() const { return nRotateAngle
; };
190 rtl::Reference
<SdrObject
> CreateLineGeometry();
191 rtl::Reference
<SdrObject
> CreateObject( bool bLineGeometryNeededOnly
);
192 void ApplyGluePoints( SdrObject
* pObj
);
193 tools::Rectangle
GetTextRect() const;
194 const tools::Rectangle
& GetLogicRect() const { return aLogicRect
; }
196 sal_uInt32
GetHdlCount() const;
197 bool GetHandlePosition( const sal_uInt32 nIndex
, Point
& rReturnPosition
) const;
198 bool SetHandleControllerPosition( const sal_uInt32 nIndex
, const css::awt::Point
& rPosition
);
200 EnhancedCustomShape2d(SdrObjCustomShape
& rSdrObjCustomShape
);
201 virtual ~EnhancedCustomShape2d() override
;
203 SAL_DLLPRIVATE
double GetEnumFunc( const EnhancedCustomShape::ExpressionFunct eVal
) const;
205 void GetParameter( double& rParameterReturnValue
, const css::drawing::EnhancedCustomShapeParameter
&,
206 const bool bReplaceGeoWidth
, const bool bReplaceGeoHeight
) const;
207 SAL_DLLPRIVATE
double GetAdjustValueAsDouble( const sal_Int32 nIndex
) const;
208 SAL_DLLPRIVATE
double GetEquationValueAsDouble( const sal_Int32 nIndex
) const;
210 static OUString
GetEquation( const sal_uInt16 nFlags
, sal_Int32 nPara1
, sal_Int32 nPara2
, sal_Int32 nPara3
);
212 SAL_DLLPRIVATE
static void AppendEnhancedCustomShapeEquationParameter( OUString
& rParameter
, const sal_Int32 nPara
, const bool bIsSpecialValue
);
214 static void SetEnhancedCustomShapeParameter( css::drawing::EnhancedCustomShapeParameter
&
215 rParameter
, const sal_Int32 nValue
);
216 static void SetEnhancedCustomShapeHandleParameter( css::drawing::EnhancedCustomShapeParameter
&
217 rParameter
, const sal_Int32 nPara
, const bool bIsSpecialValue
, bool bHorz
);
218 SAL_DLLPRIVATE
static bool ConvertSequenceToEnhancedCustomShape2dHandle( const css::beans::PropertyValues
& rHandleProperties
,
219 EnhancedCustomShape2d::Handle
& rDestinationHandle
);
220 SAL_DLLPRIVATE
static void SwapStartAndEndArrow( SdrObject
* pObj
);
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */