/src/libreoffice/include/svx/EnhancedCustomShape2d.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_SVX_ENHANCEDCUSTOMSHAPE2D_HXX |
21 | | #define INCLUDED_SVX_ENHANCEDCUSTOMSHAPE2D_HXX |
22 | | |
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> |
36 | | |
37 | | #include <svx/EnhancedCustomShapeFunctionParser.hxx> |
38 | | #include <tools/gen.hxx> |
39 | | #include <o3tl/typed_flags_set.hxx> |
40 | | #include <basegfx/point/b2dpoint.hxx> |
41 | | |
42 | | #include <memory> |
43 | | #include <vector> |
44 | | |
45 | | namespace com::sun::star::awt { struct Point; } |
46 | | |
47 | | class Color; |
48 | | class SdrObject; |
49 | | class SdrPathObj; |
50 | | class SdrObjCustomShape; |
51 | | |
52 | | enum class HandleFlags |
53 | | { |
54 | | NONE = 0x0000, |
55 | | MIRRORED_X = 0x0001, |
56 | | MIRRORED_Y = 0x0002, |
57 | | SWITCHED = 0x0004, |
58 | | POLAR = 0x0008, |
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, |
65 | | REFX = 0x0800, |
66 | | REFY = 0x1000, |
67 | | REFANGLE = 0x2000, |
68 | | REFR = 0x4000, |
69 | | }; |
70 | | namespace o3tl |
71 | | { |
72 | | template<> struct typed_flags<HandleFlags> : is_typed_flags<HandleFlags, 0x7fef> {}; |
73 | | } |
74 | | |
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 |
78 | | |
79 | | class SVXCORE_DLLPUBLIC EnhancedCustomShape2d final : public SfxItemSet |
80 | | { |
81 | | SdrObjCustomShape& mrSdrObjCustomShape; |
82 | | MSO_SPT m_eSpType; |
83 | | |
84 | | sal_Int32 m_nCoordLeft; |
85 | | sal_Int32 m_nCoordTop; |
86 | | sal_Int32 m_nCoordWidthG; |
87 | | sal_Int32 m_nCoordHeightG; |
88 | | sal_Int32 m_nCoordWidth; |
89 | | sal_Int32 m_nCoordHeight; |
90 | | tools::Rectangle m_aLogicRect; |
91 | | |
92 | | double m_fXScale; |
93 | | double m_fYScale; |
94 | | double m_fXRatio; |
95 | | double m_fYRatio; |
96 | | |
97 | | bool m_bOOXMLShape; |
98 | | |
99 | | sal_Int32 m_nXRef; |
100 | | sal_Int32 m_nYRef; |
101 | | sal_uInt32 m_nColorData; |
102 | | |
103 | | /* |
104 | | |
105 | | */ |
106 | | struct SAL_DLLPRIVATE EquationResult { |
107 | | mutable bool bParsed = false; |
108 | | bool bReady = false; |
109 | | double fValue = 0; |
110 | | mutable std::shared_ptr< EnhancedCustomShape::ExpressionNode > xNode; |
111 | | }; |
112 | | css::uno::Sequence< OUString > m_seqEquations; |
113 | | std::vector< EquationResult > m_vEquationResults; |
114 | | |
115 | | css::uno::Sequence< css::drawing::EnhancedCustomShapeSegment > m_seqSegments; |
116 | | css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair> m_seqCoordinates; |
117 | | css::uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > m_seqTextFrames; |
118 | | css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair> m_seqGluePoints; |
119 | | css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > m_seqAdjustmentValues; |
120 | | css::uno::Sequence< css::beans::PropertyValues > m_seqHandles; |
121 | | css::uno::Sequence< css::awt::Size > m_seqSubViewSize; |
122 | | css::uno::Sequence< double > m_seqGluePointLeavingDirections; |
123 | | |
124 | | bool m_bFilled : 1; |
125 | | bool m_bStroked : 1; |
126 | | |
127 | | bool m_bFlipH; |
128 | | bool m_bFlipV; |
129 | | Degree100 m_nRotateAngle; |
130 | | |
131 | | SAL_DLLPRIVATE bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex ); |
132 | | SAL_DLLPRIVATE Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const; |
133 | | SAL_DLLPRIVATE void AdaptObjColor( |
134 | | SdrPathObj& rObj, |
135 | | double dBrightness, |
136 | | const SfxItemSet& rCustomShapeSet, |
137 | | sal_uInt32& nColorIndex, |
138 | | sal_uInt32 nColorCount); |
139 | | SAL_DLLPRIVATE Point GetPoint( const css::drawing::EnhancedCustomShapeParameterPair&, |
140 | | const bool bScale = true, const bool bReplaceGeoSize = false ) const; |
141 | | SAL_DLLPRIVATE basegfx::B2DPoint GetPointAsB2DPoint(const css::drawing::EnhancedCustomShapeParameterPair&, |
142 | | const bool bScale = true, const bool bReplaceGeoSize = false ) const; |
143 | | |
144 | | SAL_DLLPRIVATE void CreateSubPath( |
145 | | sal_Int32& rSrcPt, |
146 | | sal_Int32& rSegmentInd, |
147 | | std::vector< std::pair< rtl::Reference<SdrPathObj>, double> >& rObjectList, |
148 | | bool bLineGeometryNeededOnly, |
149 | | bool bSortFilledObjectsToBack, |
150 | | sal_Int32 nIndex); |
151 | | SAL_DLLPRIVATE rtl::Reference<SdrObject> CreatePathObj( bool bLineGeometryNeededOnly ); |
152 | | SAL_DLLPRIVATE void ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem ); |
153 | | |
154 | | SAL_DLLPRIVATE void SetPathSize( sal_Int32 nIndex = 0 ); |
155 | | |
156 | | public: |
157 | | |
158 | | struct SAL_DLLPRIVATE Handle |
159 | | { |
160 | | HandleFlags nFlags; |
161 | | |
162 | | css::drawing::EnhancedCustomShapeParameterPair aPosition; |
163 | | css::drawing::EnhancedCustomShapeParameterPair aPolar; |
164 | | |
165 | | sal_Int32 nRefX; |
166 | | sal_Int32 nRefY; |
167 | | sal_Int32 nRefAngle; |
168 | | sal_Int32 nRefR; |
169 | | |
170 | | css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; |
171 | | css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; |
172 | | css::drawing::EnhancedCustomShapeParameter aXRangeMinimum; |
173 | | css::drawing::EnhancedCustomShapeParameter aXRangeMaximum; |
174 | | css::drawing::EnhancedCustomShapeParameter aYRangeMinimum; |
175 | | css::drawing::EnhancedCustomShapeParameter aYRangeMaximum; |
176 | | |
177 | | Handle() |
178 | 37 | : nFlags(HandleFlags::NONE) |
179 | 37 | , nRefX( -1 ) |
180 | 37 | , nRefY( -1 ) |
181 | 37 | , nRefAngle( -1 ) |
182 | 37 | , nRefR( -1 ) |
183 | 37 | { |
184 | 37 | } |
185 | | }; |
186 | | |
187 | | sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const; |
188 | 85.5k | SAL_DLLPRIVATE bool IsFlipVert() const { return m_bFlipV; }; |
189 | 85.5k | SAL_DLLPRIVATE bool IsFlipHorz() const { return m_bFlipH; }; |
190 | 85.5k | SAL_DLLPRIVATE Degree100 GetRotateAngle() const { return m_nRotateAngle; }; |
191 | | |
192 | | rtl::Reference<SdrObject> CreateLineGeometry(); |
193 | | rtl::Reference<SdrObject> CreateObject( bool bLineGeometryNeededOnly ); |
194 | | rtl::Reference<SdrObject> CreateObject( bool bLineGeometryNeededOnly, SfxStyleSheet* pNewStyleSheet ); |
195 | | void ApplyGluePoints( SdrObject* pObj ); |
196 | | tools::Rectangle GetTextRect() const; |
197 | 0 | const tools::Rectangle& GetLogicRect() const { return m_aLogicRect; } |
198 | | |
199 | | sal_uInt32 GetHdlCount() const; |
200 | | bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const; |
201 | | bool SetHandleControllerPosition( const sal_uInt32 nIndex, const css::awt::Point& rPosition ); |
202 | | |
203 | | EnhancedCustomShape2d(SdrObjCustomShape& rSdrObjCustomShape); |
204 | | virtual ~EnhancedCustomShape2d() override; |
205 | | |
206 | | SAL_DLLPRIVATE double GetEnumFunc( const EnhancedCustomShape::ExpressionFunct eVal ) const; |
207 | | |
208 | | void GetParameter( double& rParameterReturnValue, const css::drawing::EnhancedCustomShapeParameter&, |
209 | | const bool bReplaceGeoWidth, const bool bReplaceGeoHeight ) const; |
210 | | SAL_DLLPRIVATE double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const; |
211 | | SAL_DLLPRIVATE double GetEquationValueAsDouble( const sal_Int32 nIndex ) const; |
212 | | |
213 | | static OUString GetEquation( const sal_uInt16 nFlags, sal_Int32 nPara1, sal_Int32 nPara2, sal_Int32 nPara3 ); |
214 | | |
215 | | SAL_DLLPRIVATE static void AppendEnhancedCustomShapeEquationParameter( OUString& rParameter, const sal_Int32 nPara, const bool bIsSpecialValue ); |
216 | | |
217 | | static void SetEnhancedCustomShapeParameter( css::drawing::EnhancedCustomShapeParameter& |
218 | | rParameter, const sal_Int32 nValue ); |
219 | | static void SetEnhancedCustomShapeHandleParameter( css::drawing::EnhancedCustomShapeParameter& |
220 | | rParameter, const sal_Int32 nPara, const bool bIsSpecialValue, bool bHorz ); |
221 | | SAL_DLLPRIVATE static bool ConvertSequenceToEnhancedCustomShape2dHandle( const css::beans::PropertyValues& rHandleProperties, |
222 | | EnhancedCustomShape2d::Handle& rDestinationHandle ); |
223 | | SAL_DLLPRIVATE static void SwapStartAndEndArrow( SdrObject* pObj ); |
224 | | }; |
225 | | #endif |
226 | | |
227 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |