LibreOffice Module svx (master)  1
EnhancedCustomShape2d.hxx
Go to the documentation of this file.
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 <tools/degree.hxx>
26 #include <com/sun/star/awt/Size.hpp>
27 #include <com/sun/star/uno/Sequence.h>
28 #include <com/sun/star/beans/PropertyValues.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 
37 #include <tools/gen.hxx>
38 #include <o3tl/typed_flags_set.hxx>
40 
41 #include <memory>
42 #include <vector>
43 
44 namespace com::sun::star::awt { struct Point; }
45 
46 class Color;
47 class SdrObject;
48 class SdrPathObj;
49 class SdrObjCustomShape;
50 
51 enum class HandleFlags
52 {
53  NONE = 0x0000,
54  MIRRORED_X = 0x0001,
55  MIRRORED_Y = 0x0002,
56  SWITCHED = 0x0004,
57  POLAR = 0x0008,
58  RANGE_X_MINIMUM = 0x0020,
59  RANGE_X_MAXIMUM = 0x0040,
60  RANGE_Y_MINIMUM = 0x0080,
61  RANGE_Y_MAXIMUM = 0x0100,
62  RADIUS_RANGE_MINIMUM = 0x0200,
63  RADIUS_RANGE_MAXIMUM = 0x0400,
64  REFX = 0x0800,
65  REFY = 0x1000,
66  REFANGLE = 0x2000,
67  REFR = 0x4000,
68 };
69 namespace o3tl
70 {
71  template<> struct typed_flags<HandleFlags> : is_typed_flags<HandleFlags, 0x7fef> {};
72 }
73 
74 // MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
75 // escher, but we are using it internally in to differentiate
76 // between X_RANGE and Y_RANGE
77 
79 {
82 
83  sal_Int32 nCoordLeft;
84  sal_Int32 nCoordTop;
85  sal_Int32 nCoordWidthG;
86  sal_Int32 nCoordHeightG;
87  sal_Int32 nCoordWidth;
88  sal_Int32 nCoordHeight;
90 
91  double fXScale;
92  double fYScale;
93  double fXRatio;
94  double fYRatio;
95 
97 
98  sal_Int32 nXRef;
99  sal_Int32 nYRef;
100  sal_uInt32 nColorData;
101 
102  /*
103 
104  */
105  struct SAL_DLLPRIVATE EquationResult {
106  bool bReady;
107  double fValue;
108  };
109  css::uno::Sequence< OUString > seqEquations;
110  std::vector< std::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr;
111  std::vector< EquationResult > vEquationResults;
112 
113  css::uno::Sequence< css::drawing::EnhancedCustomShapeSegment > seqSegments;
114  css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
115  css::uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
116  css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
117  css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
118  css::uno::Sequence< css::beans::PropertyValues > seqHandles;
119  css::uno::Sequence< css::awt::Size > seqSubViewSize;
120 
121  bool bFilled : 1;
122  bool bStroked : 1;
123 
124  bool bFlipH;
125  bool bFlipV;
127 
128  SAL_DLLPRIVATE bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
129  SAL_DLLPRIVATE sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
130  SAL_DLLPRIVATE Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex, double dBrightness ) const;
131  SAL_DLLPRIVATE void AdaptObjColor(
132  SdrPathObj& rObj,
133  double dBrightness,
134  const SfxItemSet& rCustomShapeSet,
135  sal_uInt32& nColorIndex,
136  sal_uInt32 nColorCount);
137  SAL_DLLPRIVATE Point GetPoint( const css::drawing::EnhancedCustomShapeParameterPair&,
138  const bool bScale = true, const bool bReplaceGeoSize = false ) const;
139  SAL_DLLPRIVATE basegfx::B2DPoint GetPointAsB2DPoint(const css::drawing::EnhancedCustomShapeParameterPair&,
140  const bool bScale = true, const bool bReplaceGeoSize = false ) const;
141 
142  SAL_DLLPRIVATE void CreateSubPath(
143  sal_Int32& rSrcPt,
144  sal_Int32& rSegmentInd,
145  std::vector< std::pair< SdrPathObj*, double> >& rObjectList,
146  bool bLineGeometryNeededOnly,
147  bool bSortFilledObjectsToBack,
148  sal_Int32 nIndex);
149  SAL_DLLPRIVATE SdrObject* CreatePathObj( bool bLineGeometryNeededOnly );
150  SAL_DLLPRIVATE void ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
151 
152  SAL_DLLPRIVATE void SetPathSize( sal_Int32 nIndex = 0 );
153 
154  public:
155 
156  struct SAL_DLLPRIVATE Handle
157  {
159 
160  css::drawing::EnhancedCustomShapeParameterPair aPosition;
161  css::drawing::EnhancedCustomShapeParameterPair aPolar;
162 
163  sal_Int32 nRefX;
164  sal_Int32 nRefY;
165  sal_Int32 nRefAngle;
166  sal_Int32 nRefR;
167 
168  css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
169  css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
170  css::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
171  css::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
172  css::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
173  css::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
174 
176  : nFlags(HandleFlags::NONE)
177  , nRefX( -1 )
178  , nRefY( -1 )
179  , nRefAngle( -1 )
180  , nRefR( -1 )
181  {
182  }
183  };
184 
185  SAL_DLLPRIVATE bool IsFlipVert() const { return bFlipV; };
186  SAL_DLLPRIVATE bool IsFlipHorz() const { return bFlipH; };
187  SAL_DLLPRIVATE Degree100 GetRotateAngle() const { return nRotateAngle; };
188 
189  SdrObject* CreateLineGeometry();
190  SdrObject* CreateObject( bool bLineGeometryNeededOnly );
191  void ApplyGluePoints( SdrObject* pObj );
192  tools::Rectangle GetTextRect() const;
193  const tools::Rectangle& GetLogicRect() const { return aLogicRect; }
194 
195  sal_uInt32 GetHdlCount() const;
196  bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const;
197  bool SetHandleControllerPosition( const sal_uInt32 nIndex, const css::awt::Point& rPosition );
198 
199  EnhancedCustomShape2d(SdrObjCustomShape& rSdrObjCustomShape);
200  virtual ~EnhancedCustomShape2d() override;
201 
202  SAL_DLLPRIVATE double GetEnumFunc( const EnhancedCustomShape::ExpressionFunct eVal ) const;
203 
204  void GetParameter( double& rParameterReturnValue, const css::drawing::EnhancedCustomShapeParameter&,
205  const bool bReplaceGeoWidth, const bool bReplaceGeoHeight ) const;
206  SAL_DLLPRIVATE double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
207  SAL_DLLPRIVATE double GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
208 
209  static OUString GetEquation( const sal_uInt16 nFlags, sal_Int32 nPara1, sal_Int32 nPara2, sal_Int32 nPara3 );
210 
211  SAL_DLLPRIVATE static void AppendEnhancedCustomShapeEquationParameter( OUString& rParameter, const sal_Int32 nPara, const bool bIsSpecialValue );
212 
213  static void SetEnhancedCustomShapeParameter( css::drawing::EnhancedCustomShapeParameter&
214  rParameter, const sal_Int32 nValue );
215  static void SetEnhancedCustomShapeHandleParameter( css::drawing::EnhancedCustomShapeParameter&
216  rParameter, const sal_Int32 nPara, const bool bIsSpecialValue, bool bHorz );
217  SAL_DLLPRIVATE static bool ConvertSequenceToEnhancedCustomShape2dHandle( const css::beans::PropertyValues& rHandleProperties,
218  EnhancedCustomShape2d::Handle& rDestinationHandle );
219  SAL_DLLPRIVATE static void SwapStartAndEndArrow( SdrObject* pObj );
220 };
221 #endif
222 
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::drawing::EnhancedCustomShapeParameter aYRangeMinimum
SdrObjCustomShape & mrSdrObjCustomShape
SAL_DLLPRIVATE bool IsFlipHorz() const
SAL_DLLPRIVATE Degree100 GetRotateAngle() const
std::vector< EquationResult > vEquationResults
NONE
css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum
MSO_SPT
Definition: msdffdef.hxx:274
css::drawing::EnhancedCustomShapeParameter aXRangeMaximum
css::uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > seqTextFrames
static void GetPoint(const tools::Polygon &rPoly, const std::vector< double > &rDistances, const double &fX, double &fx1, double &fy1)
css::uno::Sequence< css::awt::Size > seqSubViewSize
css::drawing::EnhancedCustomShapeParameterPair aPolar
css::uno::Sequence< OUString > seqEquations
css::drawing::EnhancedCustomShapeParameterPair aPosition
css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum
SAL_DLLPRIVATE bool IsFlipVert() const
std::vector< std::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr
css::uno::Sequence< css::beans::PropertyValues > seqHandles
css::drawing::EnhancedCustomShapeParameter aXRangeMinimum
Abstract DrawObject.
Definition: svdobj.hxx:261
css::uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair > seqGluePoints
css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair > seqCoordinates
css::uno::Sequence< css::drawing::EnhancedCustomShapeSegment > seqSegments
const tools::Rectangle & GetLogicRect() const
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
css::drawing::EnhancedCustomShapeParameter aYRangeMaximum