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 <com/sun/star/uno/Sequence.h>
26 #include <com/sun/star/beans/PropertyValues.hpp>
27 #include <com/sun/star/awt/Point.hpp>
28 #include <com/sun/star/awt/Size.hpp>
29 #include <svl/itemset.hxx>
30 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
31 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
32 #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
33 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
34 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
35 #include <svx/EnhancedCustomShapeFunctionParser.hxx>
36 #include <tools/gen.hxx>
37 #include <o3tl/typed_flags_set.hxx>
45 struct SvxMSDffVertPair
;
46 struct SvxMSDffCalculationData
;
47 struct SvxMSDffTextRectangles
;
49 enum class HandleFlags
56 RANGE_X_MINIMUM
= 0x0020,
57 RANGE_X_MAXIMUM
= 0x0040,
58 RANGE_Y_MINIMUM
= 0x0080,
59 RANGE_Y_MAXIMUM
= 0x0100,
60 RADIUS_RANGE_MINIMUM
= 0x0200,
61 RADIUS_RANGE_MAXIMUM
= 0x0400,
69 template<> struct typed_flags
<HandleFlags
> : is_typed_flags
<HandleFlags
, 0x7fef> {};
72 // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
73 // escher, but we are using it internally in to differentiate
74 // between X_RANGE and Y_RANGE
78 class SVX_DLLPUBLIC EnhancedCustomShape2d
: public SfxItemSet
80 SdrObject
* pCustomShapeObj
;
85 sal_Int32 nCoordWidthG
;
86 sal_Int32 nCoordHeightG
;
87 sal_Int32 nCoordWidth
;
88 sal_Int32 nCoordHeight
;
100 sal_uInt32 nColorData
;
105 struct SAL_DLLPRIVATE EquationResult
{
109 com::sun::star::uno::Sequence
< OUString
> seqEquations
;
110 std::vector
< std::shared_ptr
< EnhancedCustomShape::ExpressionNode
> > vNodesSharedPtr
;
111 std::vector
< EquationResult
> vEquationResults
;
113 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeSegment
> seqSegments
;
114 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> seqCoordinates
;
115 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeTextFrame
> seqTextFrames
;
116 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeParameterPair
> seqGluePoints
;
117 com::sun::star::uno::Sequence
< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue
> seqAdjustmentValues
;
118 com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValues
> seqHandles
;
119 com::sun::star::uno::Sequence
< com::sun::star::awt::Size
> seqSubViewSize
;
127 sal_Int32 nRotateAngle
;
129 SAL_DLLPRIVATE
bool SetAdjustValueAsDouble( const double& rValue
, const sal_Int32 nIndex
);
130 SAL_DLLPRIVATE sal_Int32
GetLuminanceChange( sal_uInt32 nIndex
) const;
131 SAL_DLLPRIVATE Color
GetColorData( const Color
& rFillColor
, sal_uInt32 nIndex
, double dBrightness
) const;
132 SAL_DLLPRIVATE
void AdaptObjColor(SdrPathObj
& rObj
, const SfxItemSet
& rCustomShapeSet
,
133 sal_uInt32
& nColorIndex
, sal_uInt32 nColorCount
);
134 SAL_DLLPRIVATE
bool GetParameter( double& rParameterReturnValue
, const com::sun::star::drawing::EnhancedCustomShapeParameter
&,
135 const bool bReplaceGeoWidth
, const bool bReplaceGeoHeight
) const;
136 SAL_DLLPRIVATE Point
GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair
&,
137 const bool bScale
= true, const bool bReplaceGeoSize
= false ) const;
139 SAL_DLLPRIVATE
void CreateSubPath( sal_uInt16
& rSrcPt
, sal_uInt16
& rSegmentInd
, std::vector
< SdrPathObj
* >& rObjectList
,
140 bool bLineGeometryNeededOnly
, bool bSortFilledObjectsToBack
,
142 SAL_DLLPRIVATE SdrObject
* CreatePathObj( bool bLineGeometryNeededOnly
);
143 SAL_DLLPRIVATE
const sal_Int32
* ApplyShapeAttributes( const SdrCustomShapeGeometryItem
& rItem
);
145 SAL_DLLPRIVATE
void SetPathSize( sal_Int32 nIndex
= 0 );
149 struct SAL_DLLPRIVATE Handle
157 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition
;
158 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar
;
165 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum
;
166 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum
;
167 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum
;
168 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum
;
169 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum
;
170 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum
;
173 : nFlags(HandleFlags::NONE
)
174 , bMirroredX ( false )
175 , bMirroredY ( false )
185 SAL_DLLPRIVATE
bool IsFlipVert() { return bFlipV
; };
186 SAL_DLLPRIVATE
bool IsFlipHorz() { return bFlipH
; };
187 SAL_DLLPRIVATE sal_Int32
GetRotateAngle() { return nRotateAngle
; };
188 bool IsPostRotate() const;
190 SdrObject
* CreateLineGeometry();
191 SdrObject
* CreateObject( bool bLineGeometryNeededOnly
);
192 void ApplyGluePoints( SdrObject
* pObj
);
193 Rectangle
GetTextRect() const;
195 sal_uInt32
GetHdlCount() const;
196 bool GetHandlePosition( const sal_uInt32 nIndex
, Point
& rReturnPosition
) const;
197 bool SetHandleControllerPosition( const sal_uInt32 nIndex
, const com::sun::star::awt::Point
& rPosition
);
199 EnhancedCustomShape2d( SdrObject
* pSdrObjCustomShape
);
200 virtual ~EnhancedCustomShape2d();
202 enum SAL_DLLPRIVATE EnumFunc
218 SAL_DLLPRIVATE
double GetEnumFunc( const EnumFunc eVal
) const;
220 SAL_DLLPRIVATE
double GetAdjustValueAsDouble( const sal_Int32 nIndex
) const;
221 SAL_DLLPRIVATE
double GetEquationValueAsDouble( const sal_Int32 nIndex
) const;
222 SAL_DLLPRIVATE sal_Int32
GetAdjustValueAsInteger( const sal_Int32 nIndex
, const sal_Int32 nDefault
= 0 ) const;
224 static OUString
GetEquation( const sal_uInt16 nFlags
, sal_Int32 nPara1
, sal_Int32 nPara2
, sal_Int32 nPara3
);
226 SAL_DLLPRIVATE
static void AppendEnhancedCustomShapeEquationParameter( OUString
& rParameter
, const sal_Int32 nPara
, const bool bIsSpecialValue
);
228 SAL_DLLPRIVATE
static void SetEnhancedCustomShapeEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter
&
229 rParameter
, const sal_Int16 nPara
, const bool bIsSpecialValue
);
230 static void SetEnhancedCustomShapeParameter( com::sun::star::drawing::EnhancedCustomShapeParameter
&
231 rParameter
, const sal_Int32 nValue
);
232 static void SetEnhancedCustomShapeHandleParameter( com::sun::star::drawing::EnhancedCustomShapeParameter
&
233 rParameter
, const sal_Int32 nPara
, const bool bIsSpecialValue
, bool bHorz
);
234 SAL_DLLPRIVATE
static bool ConvertSequenceToEnhancedCustomShape2dHandle( const com::sun::star::beans::PropertyValues
& rHandleProperties
,
235 EnhancedCustomShape2d::Handle
& rDestinationHandle
);
236 SAL_DLLPRIVATE
static void SwapStartAndEndArrow( SdrObject
* pObj
);
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */