Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / EnhancedCustomShape2d.hxx
blobe086cede26b88ddd2c274c5b0e5a23c315cabc8b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
39 #include <memory>
40 #include <vector>
42 class Color;
43 class SdrObject;
44 class SdrPathObj;
46 enum class HandleFlags
48 NONE = 0x0000,
49 MIRRORED_X = 0x0001,
50 MIRRORED_Y = 0x0002,
51 SWITCHED = 0x0004,
52 POLAR = 0x0008,
53 RANGE_X_MINIMUM = 0x0020,
54 RANGE_X_MAXIMUM = 0x0040,
55 RANGE_Y_MINIMUM = 0x0080,
56 RANGE_Y_MAXIMUM = 0x0100,
57 RADIUS_RANGE_MINIMUM = 0x0200,
58 RADIUS_RANGE_MAXIMUM = 0x0400,
59 REFX = 0x0800,
60 REFY = 0x1000,
61 REFANGLE = 0x2000,
62 REFR = 0x4000,
64 namespace o3tl
66 template<> struct typed_flags<HandleFlags> : is_typed_flags<HandleFlags, 0x7fef> {};
69 // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
70 // escher, but we are using it internally in to differentiate
71 // between X_RANGE and Y_RANGE
73 class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet
75 SdrObject* pCustomShapeObj;
76 MSO_SPT eSpType;
78 sal_Int32 nCoordLeft;
79 sal_Int32 nCoordTop;
80 sal_Int32 nCoordWidthG;
81 sal_Int32 nCoordHeightG;
82 sal_Int32 nCoordWidth;
83 sal_Int32 nCoordHeight;
84 tools::Rectangle aLogicRect;
86 double fXScale;
87 double fYScale;
88 double fXRatio;
89 double fYRatio;
91 bool bOOXMLShape;
93 sal_Int32 nXRef;
94 sal_Int32 nYRef;
95 sal_uInt32 nColorData;
100 struct SAL_DLLPRIVATE EquationResult {
101 bool bReady;
102 double fValue;
104 css::uno::Sequence< OUString > seqEquations;
105 std::vector< std::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr;
106 std::vector< EquationResult > vEquationResults;
108 css::uno::Sequence< css::drawing::EnhancedCustomShapeSegment > seqSegments;
109 css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
110 css::uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
111 css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
112 css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
113 css::uno::Sequence< css::beans::PropertyValues > seqHandles;
114 css::uno::Sequence< css::awt::Size > seqSubViewSize;
116 bool bTextFlow : 1;
117 bool bFilled : 1;
118 bool bStroked : 1;
120 bool bFlipH;
121 bool bFlipV;
122 sal_Int32 nRotateAngle;
124 SAL_DLLPRIVATE bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
125 SAL_DLLPRIVATE sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
126 SAL_DLLPRIVATE Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const;
127 SAL_DLLPRIVATE void AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
128 sal_uInt32& nColorIndex, sal_uInt32 nColorCount);
129 SAL_DLLPRIVATE Point GetPoint( const css::drawing::EnhancedCustomShapeParameterPair&,
130 const bool bScale = true, const bool bReplaceGeoSize = false ) const;
132 SAL_DLLPRIVATE void CreateSubPath( sal_Int32& rSrcPt, sal_Int32& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
133 bool bLineGeometryNeededOnly, bool bSortFilledObjectsToBack,
134 sal_Int32 nIndex );
135 SAL_DLLPRIVATE SdrObject* CreatePathObj( bool bLineGeometryNeededOnly );
136 SAL_DLLPRIVATE void ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
138 SAL_DLLPRIVATE void SetPathSize( sal_Int32 nIndex = 0 );
140 public:
142 struct SAL_DLLPRIVATE Handle
144 HandleFlags nFlags;
146 css::drawing::EnhancedCustomShapeParameterPair aPosition;
147 css::drawing::EnhancedCustomShapeParameterPair aPolar;
149 sal_Int32 nRefX;
150 sal_Int32 nRefY;
151 sal_Int32 nRefAngle;
152 sal_Int32 nRefR;
154 css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
155 css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
156 css::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
157 css::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
158 css::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
159 css::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
161 Handle()
162 : nFlags(HandleFlags::NONE)
163 , nRefX( -1 )
164 , nRefY( -1 )
165 , nRefAngle( -1 )
166 , nRefR( -1 )
171 SAL_DLLPRIVATE bool IsFlipVert() { return bFlipV; };
172 SAL_DLLPRIVATE bool IsFlipHorz() { return bFlipH; };
173 SAL_DLLPRIVATE sal_Int32 GetRotateAngle() { return nRotateAngle; };
174 bool IsPostRotate() const;
176 SdrObject* CreateLineGeometry();
177 SdrObject* CreateObject( bool bLineGeometryNeededOnly );
178 void ApplyGluePoints( SdrObject* pObj );
179 tools::Rectangle GetTextRect() const;
180 const tools::Rectangle& GetLogicRect() const { return aLogicRect; }
182 sal_uInt32 GetHdlCount() const;
183 bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const;
184 bool SetHandleControllerPosition( const sal_uInt32 nIndex, const css::awt::Point& rPosition );
186 EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape );
187 virtual ~EnhancedCustomShape2d() override;
189 SAL_DLLPRIVATE double GetEnumFunc( const EnhancedCustomShape::ExpressionFunct eVal ) const;
191 void GetParameter( double& rParameterReturnValue, const css::drawing::EnhancedCustomShapeParameter&,
192 const bool bReplaceGeoWidth, const bool bReplaceGeoHeight ) const;
193 SAL_DLLPRIVATE double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
194 SAL_DLLPRIVATE double GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
196 static OUString GetEquation( const sal_uInt16 nFlags, sal_Int32 nPara1, sal_Int32 nPara2, sal_Int32 nPara3 );
198 SAL_DLLPRIVATE static void AppendEnhancedCustomShapeEquationParameter( OUString& rParameter, const sal_Int32 nPara, const bool bIsSpecialValue );
200 static void SetEnhancedCustomShapeParameter( css::drawing::EnhancedCustomShapeParameter&
201 rParameter, const sal_Int32 nValue );
202 static void SetEnhancedCustomShapeHandleParameter( css::drawing::EnhancedCustomShapeParameter&
203 rParameter, const sal_Int32 nPara, const bool bIsSpecialValue, bool bHorz );
204 SAL_DLLPRIVATE static bool ConvertSequenceToEnhancedCustomShape2dHandle( const css::beans::PropertyValues& rHandleProperties,
205 EnhancedCustomShape2d::Handle& rDestinationHandle );
206 SAL_DLLPRIVATE static void SwapStartAndEndArrow( SdrObject* pObj );
208 #endif
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */