update emoji autocorrect entries from po-files
[LibreOffice.git] / include / svx / EnhancedCustomShape2d.hxx
blobb9ed6f2b937cf8379e9edf61fd578ffd0cf42144
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 SdrModel;
43 class SdrObject;
44 class SfxItemSet;
45 struct SvxMSDffVertPair;
46 struct SvxMSDffCalculationData;
47 struct SvxMSDffTextRectangles;
49 enum class HandleFlags
51 NONE = 0x0000,
52 MIRRORED_X = 0x0001,
53 MIRRORED_Y = 0x0002,
54 SWITCHED = 0x0004,
55 POLAR = 0x0008,
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,
62 REFX = 0x0800,
63 REFY = 0x1000,
64 REFANGLE = 0x2000,
65 REFR = 0x4000,
67 namespace o3tl
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
76 class SdrPathObj;
78 class SVX_DLLPUBLIC EnhancedCustomShape2d : public SfxItemSet
80 SdrObject* pCustomShapeObj;
81 MSO_SPT eSpType;
83 sal_Int32 nCoordLeft;
84 sal_Int32 nCoordTop;
85 sal_Int32 nCoordWidthG;
86 sal_Int32 nCoordHeightG;
87 sal_Int32 nCoordWidth;
88 sal_Int32 nCoordHeight;
89 Rectangle aLogicRect;
91 double fXScale;
92 double fYScale;
93 double fXRatio;
94 double fYRatio;
96 bool bOOXMLShape;
98 sal_Int32 nXRef;
99 sal_Int32 nYRef;
100 sal_uInt32 nColorData;
105 struct SAL_DLLPRIVATE EquationResult {
106 bool bReady;
107 double fValue;
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;
121 bool bTextFlow : 1;
122 bool bFilled : 1;
123 bool bStroked : 1;
125 bool bFlipH;
126 bool bFlipV;
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,
141 sal_Int32 nIndex );
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 );
147 public :
149 struct SAL_DLLPRIVATE Handle
151 HandleFlags nFlags;
153 bool bMirroredX;
154 bool bMirroredY;
155 bool bSwitched;
157 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
158 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
160 sal_Int32 nRefX;
161 sal_Int32 nRefY;
162 sal_Int32 nRefAngle;
163 sal_Int32 nRefR;
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;
172 Handle()
173 : nFlags(HandleFlags::NONE)
174 , bMirroredX ( false )
175 , bMirroredY ( false )
176 , bSwitched( false )
177 , nRefX( -1 )
178 , nRefY( -1 )
179 , nRefAngle( -1 )
180 , nRefR( -1 )
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
204 ENUM_FUNC_PI,
205 ENUM_FUNC_LEFT,
206 ENUM_FUNC_TOP,
207 ENUM_FUNC_RIGHT,
208 ENUM_FUNC_BOTTOM,
209 ENUM_FUNC_XSTRETCH,
210 ENUM_FUNC_YSTRETCH,
211 ENUM_FUNC_HASSTROKE,
212 ENUM_FUNC_HASFILL,
213 ENUM_FUNC_WIDTH,
214 ENUM_FUNC_HEIGHT,
215 ENUM_FUNC_LOGWIDTH,
216 ENUM_FUNC_LOGHEIGHT
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 );
238 #endif
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */