1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _ENHANCEDCUSTOMSHAPE2D_HXX 25 #define _ENHANCEDCUSTOMSHAPE2D_HXX 26 27 #include <svx/msdffdef.hxx> 28 #include <svx/sdasitm.hxx> 29 #include <com/sun/star/uno/Sequence.h> 30 #include <com/sun/star/beans/PropertyValues.hpp> 31 #include <com/sun/star/awt/Point.hpp> 32 #include <svl/itemset.hxx> 33 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> 34 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> 35 #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp> 36 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> 37 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> 38 #include <svx/EnhancedCustomShapeFunctionParser.hxx> 39 40 #include <boost/shared_ptr.hpp> 41 #include <vector> 42 43 #define DFF_CUSTOMSHAPE_FLIP_V 1 44 #define DFF_CUSTOMSHAPE_FLIP_H 2 45 #define DFF_CUSTOMSHAPE_EXCH 4 46 47 class SdrModel; 48 class SdrObject; 49 class SfxItemSet; 50 struct SvxMSDffVertPair; 51 struct SvxMSDffCalculationData; 52 struct SvxMSDffTextRectangles; 53 class SvxMSDffAdjustmentHandle; 54 55 #define HANDLE_FLAGS_MIRRORED_X 0x0001 56 #define HANDLE_FLAGS_MIRRORED_Y 0x0002 57 #define HANDLE_FLAGS_SWITCHED 0x0004 58 #define HANDLE_FLAGS_POLAR 0x0008 59 #define HANDLE_FLAGS_MAP 0x0010 60 #define HANDLE_FLAGS_RANGE_X_MINIMUM 0x0020 61 #define HANDLE_FLAGS_RANGE_X_MAXIMUM 0x0040 62 #define HANDLE_FLAGS_RANGE_Y_MINIMUM 0x0080 63 #define HANDLE_FLAGS_RANGE_Y_MAXIMUM 0x0100 64 #define HANDLE_FLAGS_RADIUS_RANGE_MINIMUM 0x0200 65 #define HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM 0x0400 66 #define HANDLE_FLAGS_REFX 0x0800 67 #define HANDLE_FLAGS_REFY 0x1000 68 #define HANDLE_FLAGS_REFANGLE 0x2000 69 #define HANDLE_FLAGS_REFR 0x4000 70 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 74 75 class SdrPathObj; 76 77 class EnhancedCustomShape2d : public SfxItemSet 78 { 79 SdrObject* pCustomShapeObj; 80 MSO_SPT eSpType; 81 82 sal_Int32 nCoordLeft; 83 sal_Int32 nCoordTop; 84 sal_Int32 nCoordWidth; 85 sal_Int32 nCoordHeight; 86 Rectangle aLogicRect; 87 88 double fXScale; 89 double fYScale; 90 double fXRatio; 91 double fYRatio; 92 93 sal_Int32 nXRef; 94 sal_Int32 nYRef; 95 sal_uInt32 nFlags; 96 sal_uInt32 nColorData; 97 98 /* 99 100 */ 101 com::sun::star::uno::Sequence< rtl::OUString > seqEquations; 102 std::vector< ::boost::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr; 103 104 105 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments; 106 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates; 107 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames; 108 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints; 109 com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues; 110 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles; 111 112 sal_Bool bTextFlow : 1; 113 sal_Bool bFilled : 1; 114 sal_Bool bStroked : 1; 115 116 sal_Bool bFlipH; 117 sal_Bool bFlipV; 118 sal_Int32 nRotateAngle; 119 120 sal_Bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex ); 121 sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const; 122 Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex ) const; 123 void AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet, 124 sal_uInt32& nColorIndex, sal_uInt32 nColorCount); 125 sal_Bool GetParameter( double& rParameterReturnValue, const com::sun::star::drawing::EnhancedCustomShapeParameter&, 126 const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const; 127 Point GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair&, 128 const sal_Bool bScale = sal_True, const sal_Bool bReplaceGeoSize = sal_False ) const; 129 130 void CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList, 131 sal_Bool bLineGeometryNeededOnly, sal_Bool bSortFilledObjectsToBack ); 132 SdrObject* CreatePathObj( sal_Bool bLineGeometryNeededOnly ); 133 const sal_Int32* ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem ); 134 135 public : 136 137 struct Handle 138 { 139 sal_uInt32 nFlags; 140 141 sal_Bool bMirroredX; 142 sal_Bool bMirroredY; 143 sal_Bool bSwitched; 144 145 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition; 146 com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar; 147 148 sal_Int32 nRefX; 149 sal_Int32 nRefY; 150 sal_Int32 nRefAngle; 151 sal_Int32 nRefR; 152 153 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; 154 com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; 155 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum; 156 com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum; 157 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum; 158 com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum; 159 HandleEnhancedCustomShape2d::Handle160 Handle() : bMirroredX ( sal_False ), bMirroredY ( sal_False ), bSwitched( sal_False ), 161 nRefX( -1 ), nRefY( -1 ), nRefAngle( -1 ), nRefR( -1 ) {}; 162 }; 163 IsFlipVert()164 sal_Bool IsFlipVert() { return bFlipV; }; IsFlipHorz()165 sal_Bool IsFlipHorz() { return bFlipH; }; GetRotateAngle()166 sal_Int32 GetRotateAngle() { return nRotateAngle; }; 167 168 SVX_DLLPUBLIC SdrObject* CreateLineGeometry(); 169 SVX_DLLPUBLIC SdrObject* CreateObject( sal_Bool bLineGeometryNeededOnly ); 170 SVX_DLLPUBLIC void ApplyGluePoints( SdrObject* pObj ); 171 SVX_DLLPUBLIC Rectangle GetTextRect() const; 172 173 SVX_DLLPUBLIC sal_uInt32 GetHdlCount() const; 174 SVX_DLLPUBLIC sal_Bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const; 175 SVX_DLLPUBLIC sal_Bool SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition ); 176 177 SVX_DLLPUBLIC EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape ); 178 SVX_DLLPUBLIC ~EnhancedCustomShape2d(); 179 180 enum EnumFunc 181 { 182 ENUM_FUNC_PI, 183 ENUM_FUNC_LEFT, 184 ENUM_FUNC_TOP, 185 ENUM_FUNC_RIGHT, 186 ENUM_FUNC_BOTTOM, 187 ENUM_FUNC_XSTRETCH, 188 ENUM_FUNC_YSTRETCH, 189 ENUM_FUNC_HASSTROKE, 190 ENUM_FUNC_HASFILL, 191 ENUM_FUNC_WIDTH, 192 ENUM_FUNC_HEIGHT, 193 ENUM_FUNC_LOGWIDTH, 194 ENUM_FUNC_LOGHEIGHT 195 }; 196 double GetEnumFunc( const EnumFunc eVal ) const; 197 198 double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const; 199 double GetEquationValueAsDouble( const sal_Int32 nIndex ) const; 200 sal_Int32 GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault = 0 ) const; 201 202 SVX_DLLPUBLIC static rtl::OUString GetEquation( const sal_uInt16 nFlags, sal_Int32 nPara1, sal_Int32 nPara2, sal_Int32 nPara3 ); 203 204 static void AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue ); 205 206 static void SetEnhancedCustomShapeEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter& 207 rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue ); 208 SVX_DLLPUBLIC static void SetEnhancedCustomShapeParameter( com::sun::star::drawing::EnhancedCustomShapeParameter& 209 rParameter, const sal_Int32 nValue ); 210 SVX_DLLPUBLIC static void SetEnhancedCustomShapeHandleParameter( com::sun::star::drawing::EnhancedCustomShapeParameter& 211 rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz ); 212 static sal_Bool ConvertSequenceToEnhancedCustomShape2dHandle( const com::sun::star::beans::PropertyValues& rHandleProperties, 213 EnhancedCustomShape2d::Handle& rDestinationHandle ); 214 static void SwapStartAndEndArrow( SdrObject* pObj ); 215 }; 216 #endif 217 218