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_CHART_OBJECTFORMATTER_HXX 25 #define OOX_DRAWINGML_CHART_OBJECTFORMATTER_HXX 26 27 #include "oox/helper/propertyset.hxx" 28 #include "oox/drawingml/drawingmltypes.hxx" 29 #include "oox/drawingml/chart/modelbase.hxx" 30 31 namespace com { namespace sun { namespace star { 32 namespace chart2 { class XChartDocument; } 33 } } } 34 35 namespace oox { namespace core { class XmlFilterBase; } } 36 37 namespace oox { 38 namespace drawingml { 39 namespace chart { 40 41 // ============================================================================ 42 43 /** Enumerates different object types for specific automatic formatting behaviour. */ 44 enum ObjectType 45 { 46 OBJECTTYPE_CHARTSPACE, /// Chart background. 47 OBJECTTYPE_CHARTTITLE, /// Chart title. 48 OBJECTTYPE_LEGEND, /// Legend. 49 OBJECTTYPE_PLOTAREA2D, /// Plot area containing axes and data series in 2D charts. 50 OBJECTTYPE_PLOTAREA3D, /// Plot area containing axes and data series in 3D charts. 51 OBJECTTYPE_WALL, /// Background and side wall in 3D charts. 52 OBJECTTYPE_FLOOR, /// Floor in 3D charts. 53 OBJECTTYPE_AXIS, /// Axis line, labels, tick marks. 54 OBJECTTYPE_AXISTITLE, /// Axis title. 55 OBJECTTYPE_AXISUNIT, /// Axis unit label. 56 OBJECTTYPE_MAJORGRIDLINE, /// Axis major grid line. 57 OBJECTTYPE_MINORGRIDLINE, /// Axis minor grid line. 58 OBJECTTYPE_LINEARSERIES2D, /// Linear series in 2D line/radarline/scatter charts. 59 OBJECTTYPE_FILLEDSERIES2D, /// Filled series in 2D bar/area/radararea/bubble/pie/surface charts. 60 OBJECTTYPE_FILLEDSERIES3D, /// Filled series in 3D charts. 61 OBJECTTYPE_DATALABEL, /// Labels for data points. 62 OBJECTTYPE_TRENDLINE, /// Data series trend line. 63 OBJECTTYPE_TRENDLINELABEL, /// Trend line label. 64 OBJECTTYPE_ERRORBAR, /// Data series error indicator line. 65 OBJECTTYPE_SERLINE, /// Data point connector lines. 66 OBJECTTYPE_LEADERLINE, /// Leader lines between pie slice and data label. 67 OBJECTTYPE_DROPLINE, /// Drop lines between data points and X axis. 68 OBJECTTYPE_HILOLINE, /// High/low lines in line/stock charts. 69 OBJECTTYPE_UPBAR, /// Up-bar in line/stock charts. 70 OBJECTTYPE_DOWNBAR, /// Down-bar in line/stock charts. 71 OBJECTTYPE_DATATABLE /// Data table. 72 }; 73 74 // ============================================================================ 75 76 struct ChartSpaceModel; 77 struct ObjectFormatterData; 78 struct PictureOptionsModel; 79 80 class ObjectFormatter 81 { 82 public: 83 explicit ObjectFormatter( 84 const ::oox::core::XmlFilterBase& rFilter, 85 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& rxChartDoc, 86 const ChartSpaceModel& rChartSpace ); 87 ~ObjectFormatter(); 88 89 /** Sets the maximum series index used for color cycling/fading. */ 90 void setMaxSeriesIndex( sal_Int32 nMaxSeriesIdx ); 91 /** Returns the current maximum series index used for color cycling/fading. */ 92 sal_Int32 getMaxSeriesIndex() const; 93 94 /** Sets frame formatting properties to the passed property set. */ 95 void convertFrameFormatting( 96 PropertySet& rPropSet, 97 const ModelRef< Shape >& rxShapeProp, 98 ObjectType eObjType, 99 sal_Int32 nSeriesIdx = -1 ); 100 101 /** Sets frame formatting properties to the passed property set. */ 102 void convertFrameFormatting( 103 PropertySet& rPropSet, 104 const ModelRef< Shape >& rxShapeProp, 105 const PictureOptionsModel& rPicOptions, 106 ObjectType eObjType, 107 sal_Int32 nSeriesIdx = -1 ); 108 109 /** Sets text formatting properties to the passed property set. */ 110 void convertTextFormatting( 111 PropertySet& rPropSet, 112 const ModelRef< TextBody >& rxTextProp, 113 ObjectType eObjType ); 114 115 /** Sets frame/text formatting properties to the passed property set. */ 116 void convertFormatting( 117 PropertySet& rPropSet, 118 const ModelRef< Shape >& rxShapeProp, 119 const ModelRef< TextBody >& rxTextProp, 120 ObjectType eObjType ); 121 122 /** Sets text formatting properties to the passed property set. */ 123 void convertTextFormatting( 124 PropertySet& rPropSet, 125 const TextCharacterProperties& rTextProps, 126 ObjectType eObjType ); 127 128 /** Sets text rotation properties to the passed property set. */ 129 void convertTextRotation( 130 PropertySet& rPropSet, 131 const ModelRef< TextBody >& rxTextProp, 132 bool bSupportsStacked ); 133 134 /** Sets number format properties to the passed property set. */ 135 void convertNumberFormat( 136 PropertySet& rPropSet, 137 const NumberFormat& rNumberFormat, 138 bool bPercentFormat = false ); 139 140 /** Sets automatic line properties to the passed property set. */ 141 void convertAutomaticLine( 142 PropertySet& rPropSet, 143 ObjectType eObjType, 144 sal_Int32 nSeriesIdx = -1 ); 145 146 /** Sets automatic fill properties to the passed property set. */ 147 void convertAutomaticFill( 148 PropertySet& rPropSet, 149 ObjectType eObjType, 150 sal_Int32 nSeriesIdx = -1 ); 151 152 /** Returns true, if the passed shape properties have automatic line mode. */ 153 static bool isAutomaticLine( const ModelRef< Shape >& rxShapeProp ); 154 /** Returns true, if the passed shape properties have automatic fill mode. */ 155 static bool isAutomaticFill( const ModelRef< Shape >& rxShapeProp ); 156 157 private: 158 ::boost::shared_ptr< ObjectFormatterData > mxData; 159 }; 160 161 // ============================================================================ 162 163 } // namespace chart 164 } // namespace drawingml 165 } // namespace oox 166 167 #endif 168