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 OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX 25 #define OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX 26 27 #include <boost/shared_ptr.hpp> 28 #include <vector> 29 #include <map> 30 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> 31 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp> 32 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> 33 #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp> 34 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> 35 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> 36 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> 37 #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp> 38 #include <com/sun/star/beans/PropertyValues.hpp> 39 #include <com/sun/star/drawing/ProjectionMode.hpp> 40 #include <com/sun/star/drawing/XShape.hpp> 41 #include <com/sun/star/graphic/XGraphic.hpp> 42 #include "oox/core/xmlfilterbase.hxx" 43 #include "oox/drawingml/color.hxx" 44 #include "oox/helper/helper.hxx" 45 #include "oox/helper/propertymap.hxx" 46 #include "oox/token/tokens.hxx" 47 48 namespace oox { namespace drawingml { 49 50 class CustomShapeProperties; 51 52 typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; 53 54 struct CustomShapeGuide 55 { 56 rtl::OUString maName; 57 rtl::OUString maFormula; 58 }; 59 60 struct AdjustHandle 61 { 62 sal_Bool polar; 63 com::sun::star::drawing::EnhancedCustomShapeParameterPair 64 pos; 65 66 // depending to the type (polar or not): 67 OptValue< rtl::OUString > gdRef1; // gdRefX or gdRefR 68 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 69 min1; // minX or minR 70 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 71 max1; // maxX or maxR 72 OptValue< rtl::OUString > gdRef2; // gdRefY or gdRefAng 73 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 74 min2; // minX or minAng 75 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 76 max2; // maxY or maxAng 77 AdjustHandleoox::drawingml::AdjustHandle78 AdjustHandle( sal_Bool bPolar ) : polar( bPolar ) {}; 79 }; 80 81 struct ConnectionSite 82 { 83 com::sun::star::drawing::EnhancedCustomShapeParameterPair 84 pos; 85 com::sun::star::drawing::EnhancedCustomShapeParameter 86 ang; 87 }; 88 89 struct GeomRect 90 { 91 com::sun::star::drawing::EnhancedCustomShapeParameter l; 92 com::sun::star::drawing::EnhancedCustomShapeParameter t; 93 com::sun::star::drawing::EnhancedCustomShapeParameter r; 94 com::sun::star::drawing::EnhancedCustomShapeParameter b; 95 }; 96 97 struct Path2D 98 { 99 sal_Int64 w; 100 sal_Int64 h; 101 sal_Int32 fill; 102 sal_Bool stroke; 103 sal_Bool extrusionOk; 104 std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair > parameter; 105 Path2Doox::drawingml::Path2D106 Path2D() : w( 0 ), h( 0 ), fill( XML_norm ), stroke( sal_True ), extrusionOk( sal_True ) {}; 107 }; 108 109 class CustomShapeProperties 110 { 111 public: 112 113 CustomShapeProperties(); 114 virtual ~CustomShapeProperties(); 115 116 void apply( const CustomShapePropertiesPtr& ); 117 void pushToPropSet( const ::oox::core::FilterBase& rFilterBase, 118 const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, 119 const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > & xShape) const; 120 setShapePresetType(const rtl::OUString & rShapePresetType)121 void setShapePresetType( const rtl::OUString& rShapePresetType ){ maShapePresetType = rShapePresetType; }; 122 getAdjustmentGuideList()123 std::vector< CustomShapeGuide >& getAdjustmentGuideList(){ return maAdjustmentGuideList; }; getGuideList()124 std::vector< CustomShapeGuide >& getGuideList(){ return maGuideList; }; getAdjustHandleList()125 std::vector< AdjustHandle >& getAdjustHandleList(){ return maAdjustHandleList; }; getConnectionSiteList()126 std::vector< ConnectionSite >& getConnectionSiteList(){ return maConnectionSiteList; }; getTextRect()127 OptValue< GeomRect >& getTextRect(){ return maTextRect; }; getPath2DList()128 std::vector< Path2D >& getPath2DList(){ return maPath2DList; }; getSegments()129 std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& getSegments(){ return maSegments; }; setMirroredX(sal_Bool bMirroredX)130 void setMirroredX( sal_Bool bMirroredX ) { mbMirroredX = bMirroredX; }; setMirroredY(sal_Bool bMirroredY)131 void setMirroredY( sal_Bool bMirroredY ) { mbMirroredY = bMirroredY; }; 132 133 // #119920# Add missing extra text rotation setTextRotation(sal_Int32 nTextRotation)134 void setTextRotation(sal_Int32 nTextRotation) { mnTextRotation = nTextRotation; } 135 136 double getValue( const std::vector< CustomShapeGuide >&, sal_uInt32 nIndex ) const; 137 static sal_Int32 SetCustomShapeGuideValue( std::vector< CustomShapeGuide >& rGuideList, const CustomShapeGuide& rGuide ); 138 static sal_Int32 GetCustomShapeGuideValue( const std::vector< CustomShapeGuide >& rGuideList, const rtl::OUString& rFormulaName ); 139 140 private: 141 142 rtl::OUString maShapePresetType; 143 std::vector< CustomShapeGuide > maAdjustmentGuideList; 144 std::vector< CustomShapeGuide > maGuideList; 145 std::vector< AdjustHandle > maAdjustHandleList; 146 std::vector< ConnectionSite > maConnectionSiteList; 147 OptValue< GeomRect > maTextRect; 148 std::vector< Path2D > maPath2DList; 149 150 std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment > 151 maSegments; 152 sal_Bool mbMirroredX; 153 sal_Bool mbMirroredY; 154 155 // #119920# Add missing extra text rotation 156 sal_Int32 mnTextRotation; 157 }; 158 159 } } 160 161 #endif // OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX 162