1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX 29 #define OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX 30 31 #include <boost/shared_ptr.hpp> 32 #include <vector> 33 #include <map> 34 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> 35 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp> 36 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> 37 #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp> 38 #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> 39 #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> 40 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> 41 #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp> 42 #include <com/sun/star/beans/PropertyValues.hpp> 43 #include <com/sun/star/drawing/ProjectionMode.hpp> 44 #include <com/sun/star/drawing/XShape.hpp> 45 #include <com/sun/star/graphic/XGraphic.hpp> 46 #include "oox/core/xmlfilterbase.hxx" 47 #include "oox/drawingml/color.hxx" 48 #include "oox/helper/helper.hxx" 49 #include "oox/helper/propertymap.hxx" 50 #include "oox/token/tokens.hxx" 51 52 namespace oox { namespace drawingml { 53 54 class CustomShapeProperties; 55 56 typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr; 57 58 struct CustomShapeGuide 59 { 60 rtl::OUString maName; 61 rtl::OUString maFormula; 62 }; 63 64 struct AdjustHandle 65 { 66 sal_Bool polar; 67 com::sun::star::drawing::EnhancedCustomShapeParameterPair 68 pos; 69 70 // depending to the type (polar or not): 71 OptValue< rtl::OUString > gdRef1; // gdRefX or gdRefR 72 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 73 min1; // minX or minR 74 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 75 max1; // maxX or maxR 76 OptValue< rtl::OUString > gdRef2; // gdRefY or gdRefAng 77 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 78 min2; // minX or minAng 79 OptValue< com::sun::star::drawing::EnhancedCustomShapeParameter > 80 max2; // maxY or maxAng 81 82 AdjustHandle( sal_Bool bPolar ) : polar( bPolar ) {}; 83 }; 84 85 struct ConnectionSite 86 { 87 com::sun::star::drawing::EnhancedCustomShapeParameterPair 88 pos; 89 com::sun::star::drawing::EnhancedCustomShapeParameter 90 ang; 91 }; 92 93 struct GeomRect 94 { 95 com::sun::star::drawing::EnhancedCustomShapeParameter l; 96 com::sun::star::drawing::EnhancedCustomShapeParameter t; 97 com::sun::star::drawing::EnhancedCustomShapeParameter r; 98 com::sun::star::drawing::EnhancedCustomShapeParameter b; 99 }; 100 101 struct Path2D 102 { 103 sal_Int64 w; 104 sal_Int64 h; 105 sal_Int32 fill; 106 sal_Bool stroke; 107 sal_Bool extrusionOk; 108 std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair > parameter; 109 110 Path2D() : w( 0 ), h( 0 ), fill( XML_norm ), stroke( sal_True ), extrusionOk( sal_True ) {}; 111 }; 112 113 class CustomShapeProperties 114 { 115 public: 116 117 CustomShapeProperties(); 118 virtual ~CustomShapeProperties(); 119 120 void apply( const CustomShapePropertiesPtr& ); 121 void pushToPropSet( const ::oox::core::FilterBase& rFilterBase, 122 const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, 123 const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > & xShape) const; 124 125 void setShapePresetType( const rtl::OUString& rShapePresetType ){ maShapePresetType = rShapePresetType; }; 126 127 std::vector< CustomShapeGuide >& getAdjustmentGuideList(){ return maAdjustmentGuideList; }; 128 std::vector< CustomShapeGuide >& getGuideList(){ return maGuideList; }; 129 std::vector< AdjustHandle >& getAdjustHandleList(){ return maAdjustHandleList; }; 130 std::vector< ConnectionSite >& getConnectionSiteList(){ return maConnectionSiteList; }; 131 OptValue< GeomRect >& getTextRect(){ return maTextRect; }; 132 std::vector< Path2D >& getPath2DList(){ return maPath2DList; }; 133 std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >& getSegments(){ return maSegments; }; 134 void setMirroredX( sal_Bool bMirroredX ) { mbMirroredX = bMirroredX; }; 135 void setMirroredY( sal_Bool bMirroredY ) { mbMirroredY = bMirroredY; }; 136 137 double getValue( const std::vector< CustomShapeGuide >&, sal_uInt32 nIndex ) const; 138 static sal_Int32 SetCustomShapeGuideValue( std::vector< CustomShapeGuide >& rGuideList, const CustomShapeGuide& rGuide ); 139 static sal_Int32 GetCustomShapeGuideValue( const std::vector< CustomShapeGuide >& rGuideList, const rtl::OUString& rFormulaName ); 140 141 private: 142 143 rtl::OUString maShapePresetType; 144 std::vector< CustomShapeGuide > maAdjustmentGuideList; 145 std::vector< CustomShapeGuide > maGuideList; 146 std::vector< AdjustHandle > maAdjustHandleList; 147 std::vector< ConnectionSite > maConnectionSiteList; 148 OptValue< GeomRect > maTextRect; 149 std::vector< Path2D > maPath2DList; 150 151 std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment > 152 maSegments; 153 sal_Bool mbMirroredX; 154 sal_Bool mbMirroredY; 155 }; 156 157 } } 158 159 #endif // OOX_DRAWINGML_CUSTOMSHAPEPROPERTIES_HXX 160