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>
38 #include <basegfx/point/b2dpoint.hxx>
46 class SdrObjCustomShape
;
48 enum class HandleFlags
55 RANGE_X_MINIMUM
= 0x0020,
56 RANGE_X_MAXIMUM
= 0x0040,
57 RANGE_Y_MINIMUM
= 0x0080,
58 RANGE_Y_MAXIMUM
= 0x0100,
59 RADIUS_RANGE_MINIMUM
= 0x0200,
60 RADIUS_RANGE_MAXIMUM
= 0x0400,
68 template<> struct typed_flags
<HandleFlags
> : is_typed_flags
<HandleFlags
, 0x7fef> {};
71 // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
72 // escher, but we are using it internally in to differentiate
73 // between X_RANGE and Y_RANGE
75 class SVX_DLLPUBLIC EnhancedCustomShape2d
: public SfxItemSet
77 SdrObjCustomShape
& mrSdrObjCustomShape
;
82 sal_Int32 nCoordWidthG
;
83 sal_Int32 nCoordHeightG
;
84 sal_Int32 nCoordWidth
;
85 sal_Int32 nCoordHeight
;
86 tools::Rectangle aLogicRect
;
97 sal_uInt32 nColorData
;
102 struct SAL_DLLPRIVATE EquationResult
{
106 css::uno::Sequence
< OUString
> seqEquations
;
107 std::vector
< std::shared_ptr
< EnhancedCustomShape::ExpressionNode
> > vNodesSharedPtr
;
108 std::vector
< EquationResult
> vEquationResults
;
110 css::uno::Sequence
< css::drawing::EnhancedCustomShapeSegment
> seqSegments
;
111 css::uno::Sequence
< css::drawing::EnhancedCustomShapeParameterPair
> seqCoordinates
;
112 css::uno::Sequence
< css::drawing::EnhancedCustomShapeTextFrame
> seqTextFrames
;
113 css::uno::Sequence
< css::drawing::EnhancedCustomShapeParameterPair
> seqGluePoints
;
114 css::uno::Sequence
< css::drawing::EnhancedCustomShapeAdjustmentValue
> seqAdjustmentValues
;
115 css::uno::Sequence
< css::beans::PropertyValues
> seqHandles
;
116 css::uno::Sequence
< css::awt::Size
> seqSubViewSize
;
118 bool const bFilled
: 1;
119 bool const bStroked
: 1;
123 sal_Int32 nRotateAngle
;
125 SAL_DLLPRIVATE
bool SetAdjustValueAsDouble( const double& rValue
, const sal_Int32 nIndex
);
126 SAL_DLLPRIVATE sal_Int32
GetLuminanceChange( sal_uInt32 nIndex
) const;
127 SAL_DLLPRIVATE Color
GetColorData( const Color
& rFillColor
, sal_uInt32 nIndex
, double dBrightness
) const;
128 SAL_DLLPRIVATE
void AdaptObjColor(
131 const SfxItemSet
& rCustomShapeSet
,
132 sal_uInt32
& nColorIndex
,
133 sal_uInt32 nColorCount
);
134 SAL_DLLPRIVATE Point
GetPoint( const css::drawing::EnhancedCustomShapeParameterPair
&,
135 const bool bScale
= true, const bool bReplaceGeoSize
= false ) const;
136 SAL_DLLPRIVATE
basegfx::B2DPoint
GetPointAsB2DPoint(const css::drawing::EnhancedCustomShapeParameterPair
&,
137 const bool bScale
= true, const bool bReplaceGeoSize
= false ) const;
139 SAL_DLLPRIVATE
void CreateSubPath(
141 sal_Int32
& rSegmentInd
,
142 std::vector
< std::pair
< SdrPathObj
*, double> >& rObjectList
,
143 bool bLineGeometryNeededOnly
,
144 bool bSortFilledObjectsToBack
,
146 SAL_DLLPRIVATE SdrObject
* CreatePathObj( bool bLineGeometryNeededOnly
);
147 SAL_DLLPRIVATE
void ApplyShapeAttributes( const SdrCustomShapeGeometryItem
& rItem
);
149 SAL_DLLPRIVATE
void SetPathSize( sal_Int32 nIndex
= 0 );
153 struct SAL_DLLPRIVATE Handle
157 css::drawing::EnhancedCustomShapeParameterPair aPosition
;
158 css::drawing::EnhancedCustomShapeParameterPair aPolar
;
165 css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum
;
166 css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum
;
167 css::drawing::EnhancedCustomShapeParameter aXRangeMinimum
;
168 css::drawing::EnhancedCustomShapeParameter aXRangeMaximum
;
169 css::drawing::EnhancedCustomShapeParameter aYRangeMinimum
;
170 css::drawing::EnhancedCustomShapeParameter aYRangeMaximum
;
173 : nFlags(HandleFlags::NONE
)
182 SAL_DLLPRIVATE
bool IsFlipVert() { return bFlipV
; };
183 SAL_DLLPRIVATE
bool IsFlipHorz() { return bFlipH
; };
184 SAL_DLLPRIVATE sal_Int32
GetRotateAngle() { return nRotateAngle
; };
186 SdrObject
* CreateLineGeometry();
187 SdrObject
* CreateObject( bool bLineGeometryNeededOnly
);
188 void ApplyGluePoints( SdrObject
* pObj
);
189 tools::Rectangle
GetTextRect() const;
190 const tools::Rectangle
& GetLogicRect() const { return aLogicRect
; }
192 sal_uInt32
GetHdlCount() const;
193 bool GetHandlePosition( const sal_uInt32 nIndex
, Point
& rReturnPosition
) const;
194 bool SetHandleControllerPosition( const sal_uInt32 nIndex
, const css::awt::Point
& rPosition
);
196 EnhancedCustomShape2d(SdrObjCustomShape
& rSdrObjCustomShape
);
197 virtual ~EnhancedCustomShape2d() override
;
199 SAL_DLLPRIVATE
double GetEnumFunc( const EnhancedCustomShape::ExpressionFunct eVal
) const;
201 void GetParameter( double& rParameterReturnValue
, const css::drawing::EnhancedCustomShapeParameter
&,
202 const bool bReplaceGeoWidth
, const bool bReplaceGeoHeight
) const;
203 SAL_DLLPRIVATE
double GetAdjustValueAsDouble( const sal_Int32 nIndex
) const;
204 SAL_DLLPRIVATE
double GetEquationValueAsDouble( const sal_Int32 nIndex
) const;
206 static OUString
GetEquation( const sal_uInt16 nFlags
, sal_Int32 nPara1
, sal_Int32 nPara2
, sal_Int32 nPara3
);
208 SAL_DLLPRIVATE
static void AppendEnhancedCustomShapeEquationParameter( OUString
& rParameter
, const sal_Int32 nPara
, const bool bIsSpecialValue
);
210 static void SetEnhancedCustomShapeParameter( css::drawing::EnhancedCustomShapeParameter
&
211 rParameter
, const sal_Int32 nValue
);
212 static void SetEnhancedCustomShapeHandleParameter( css::drawing::EnhancedCustomShapeParameter
&
213 rParameter
, const sal_Int32 nPara
, const bool bIsSpecialValue
, bool bHorz
);
214 SAL_DLLPRIVATE
static bool ConvertSequenceToEnhancedCustomShape2dHandle( const css::beans::PropertyValues
& rHandleProperties
,
215 EnhancedCustomShape2d::Handle
& rDestinationHandle
);
216 SAL_DLLPRIVATE
static void SwapStartAndEndArrow( SdrObject
* pObj
);
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */