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 #ifndef _CHART2_OBJECTIDENTIFIER_HXX 24 #define _CHART2_OBJECTIDENTIFIER_HXX 25 26 #include <com/sun/star/chart2/XChartType.hpp> 27 #include <com/sun/star/chart2/XDiagram.hpp> 28 #include <com/sun/star/chart2/XCoordinateSystem.hpp> 29 #include <com/sun/star/chart2/XDataSeries.hpp> 30 #include <com/sun/star/chart2/XChartDocument.hpp> 31 #include "TitleHelper.hxx" 32 #include "charttoolsdllapi.hxx" 33 34 // header for class OUString 35 #include <rtl/ustring.hxx> 36 #include <com/sun/star/frame/XModel.hpp> 37 #include <com/sun/star/beans/XPropertySet.hpp> 38 #include <com/sun/star/awt/Point.hpp> 39 #include <com/sun/star/drawing/XShape.hpp> 40 41 //............................................................................. 42 namespace chart 43 { 44 //............................................................................. 45 46 //----------------------------------------------------------------------------- 47 /** 48 */ 49 enum ObjectType 50 { 51 OBJECTTYPE_PAGE, 52 OBJECTTYPE_TITLE, 53 OBJECTTYPE_LEGEND, 54 OBJECTTYPE_LEGEND_ENTRY, 55 OBJECTTYPE_DIAGRAM, 56 OBJECTTYPE_DIAGRAM_WALL, 57 OBJECTTYPE_DIAGRAM_FLOOR, 58 OBJECTTYPE_AXIS, 59 OBJECTTYPE_AXIS_UNITLABEL, 60 OBJECTTYPE_GRID, 61 OBJECTTYPE_SUBGRID, 62 OBJECTTYPE_DATA_SERIES, 63 OBJECTTYPE_DATA_POINT, 64 OBJECTTYPE_DATA_LABELS, 65 OBJECTTYPE_DATA_LABEL, 66 OBJECTTYPE_DATA_ERRORS, 67 OBJECTTYPE_DATA_ERRORS_X, 68 OBJECTTYPE_DATA_ERRORS_Y, 69 OBJECTTYPE_DATA_ERRORS_Z, 70 OBJECTTYPE_DATA_CURVE,//e.g. a statistical method printed as line 71 OBJECTTYPE_DATA_AVERAGE_LINE, 72 OBJECTTYPE_DATA_CURVE_EQUATION, 73 OBJECTTYPE_DATA_STOCK_RANGE, 74 OBJECTTYPE_DATA_STOCK_LOSS, 75 OBJECTTYPE_DATA_STOCK_GAIN, 76 OBJECTTYPE_SHAPE, 77 OBJECTTYPE_UNKNOWN 78 }; 79 80 class OOO_DLLPUBLIC_CHARTTOOLS ObjectIdentifier 81 { 82 //CID == ClassifiedIdentifier <--> name of shape 83 //semicolon, colon, equal sign and slash have special meanings in a CID 84 //and are therefore not allowed in its components 85 86 //syntax of a CID: CID:/classification/ObjectID 87 88 //where classification: nothing or "MultiClick" or "DragMethod=DragMethodServiceName" and "DragParameter=DragParameterString" 89 // or a combination of these seperated with a colon 90 //where DragMethodServiceName can be a selfdefined servicename for special actions //todo define standard service for this purpose 91 //where DragParameterString is any string you like to transport information to your special drag service 92 // only semicolon, colon, equal sign and slash are not allowed characters 93 // also the keywors used in the ObjectIdentifiers are not allowed 94 95 //where ObjectID: Parent-Particle:Particle //e.g. Series=2:Point=22 96 //where Particle: Type=ParticleID //e.g. Point=22 97 //where Type: getStringForType( ObjectType eType ) or other string 98 99 public: 100 ObjectIdentifier(); 101 ObjectIdentifier( const ::rtl::OUString& rObjectCID ); 102 ObjectIdentifier( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape ); 103 ObjectIdentifier( const ::com::sun::star::uno::Any& rAny ); 104 virtual ~ObjectIdentifier(); 105 106 ObjectIdentifier( const ObjectIdentifier& rOID ); 107 ObjectIdentifier& operator=( const ObjectIdentifier& rOID ); 108 bool operator==( const ObjectIdentifier& rOID ) const; 109 bool operator!=( const ObjectIdentifier& rOID ) const; 110 bool operator<( const ObjectIdentifier& rOID ) const; 111 112 static rtl::OUString createClassifiedIdentifierForObject( 113 const ::com::sun::star::uno::Reference< 114 ::com::sun::star::uno::XInterface >& xObject 115 , const ::com::sun::star::uno::Reference< 116 ::com::sun::star::frame::XModel >& xChartModel ); 117 118 static rtl::OUString createClassifiedIdentifierForParticle( 119 const rtl::OUString& rParticle ); 120 121 static rtl::OUString createClassifiedIdentifierForParticles( 122 const rtl::OUString& rParentParticle 123 , const rtl::OUString& rChildParticle 124 , const rtl::OUString& rDragMethodServiceName = rtl::OUString() 125 , const rtl::OUString& rDragParameterString = rtl::OUString() ); 126 127 static rtl::OUString createClassifiedIdentifierForGrid( 128 const ::com::sun::star::uno::Reference< 129 ::com::sun::star::chart2::XAxis >& xAxis 130 , const ::com::sun::star::uno::Reference< 131 ::com::sun::star::frame::XModel >& xChartModel 132 , sal_Int32 nSubIndex = -1 );//-1: main grid, 0: first subgrid etc 133 134 SAL_DLLPRIVATE static rtl::OUString createParticleForDiagram( 135 const ::com::sun::star::uno::Reference< 136 ::com::sun::star::chart2::XDiagram >& xDiagram 137 , const ::com::sun::star::uno::Reference< 138 ::com::sun::star::frame::XModel >& xChartModel ); 139 140 141 static rtl::OUString createParticleForCoordinateSystem( 142 const ::com::sun::star::uno::Reference< 143 ::com::sun::star::chart2::XCoordinateSystem >& xCooSys 144 , const ::com::sun::star::uno::Reference< 145 ::com::sun::star::frame::XModel >& xChartModel ); 146 147 static rtl::OUString createParticleForAxis( 148 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); 149 150 static rtl::OUString createParticleForGrid( 151 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); 152 153 static rtl::OUString createParticleForSeries( sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex 154 , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex ); 155 156 static rtl::OUString createParticleForLegend( 157 const ::com::sun::star::uno::Reference< 158 ::com::sun::star::chart2::XLegend >& xLegend 159 , const ::com::sun::star::uno::Reference< 160 ::com::sun::star::frame::XModel >& xChartModel ); 161 162 static rtl::OUString addChildParticle( const rtl::OUString& rParticle, const rtl::OUString& rChildParticle ); 163 static rtl::OUString createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex ); 164 static sal_Int32 getIndexFromParticleOrCID( const rtl::OUString& rParticleOrCID ); 165 166 static rtl::OUString createClassifiedIdentifier( 167 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES 168 , const rtl::OUString& rParticleID );//e.g. SeriesID 169 170 static rtl::OUString createClassifiedIdentifierWithParent( 171 enum ObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID 172 , const rtl::OUString& rParticleID //for points or subgrids this is an Index or otherwise an identifier from the model object 173 , const rtl::OUString& rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId" 174 , const rtl::OUString& rDragMethodServiceName = rtl::OUString() 175 , const rtl::OUString& rDragParameterString = rtl::OUString() 176 ); 177 178 static bool isCID( const rtl::OUString& rName ); 179 static rtl::OUString getDragMethodServiceName( const rtl::OUString& rClassifiedIdentifier ); 180 static rtl::OUString getDragParameterString( const rtl::OUString& rCID ); 181 static bool isDragableObject( const rtl::OUString& rClassifiedIdentifier ); 182 bool isDragableObject(); 183 static bool isRotateableObject( const rtl::OUString& rClassifiedIdentifier ); 184 static bool isMultiClickObject( const rtl::OUString& rClassifiedIdentifier ); 185 static bool areSiblings( const rtl::OUString& rCID1, const rtl::OUString& rCID2 );//identical object is no sibling 186 static bool areIdenticalObjects( const ::rtl::OUString& rCID1, const ::rtl::OUString& rCID2 ); 187 188 static rtl::OUString getStringForType( ObjectType eObjectType ); 189 static ObjectType getObjectType( const rtl::OUString& rCID ); 190 ObjectType getObjectType(); 191 192 static rtl::OUString createSeriesSubObjectStub( ObjectType eSubObjectType 193 , const rtl::OUString& rSeriesParticle 194 , const rtl::OUString& rDragMethodServiceName = rtl::OUString() 195 , const rtl::OUString& rDragParameterString = rtl::OUString() ); 196 static rtl::OUString createPointCID( const rtl::OUString& rPointCID_Stub, sal_Int32 nIndex ); 197 198 static rtl::OUString createDataCurveCID( const rtl::OUString& rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine ); 199 static rtl::OUString createDataCurveEquationCID( const rtl::OUString& rSeriesParticle, sal_Int32 nCurveIndex ); 200 201 SAL_DLLPRIVATE static rtl::OUString getObjectID( const rtl::OUString& rCID ); 202 static rtl::OUString getParticleID( const rtl::OUString& rCID ); 203 static rtl::OUString getFullParentParticle( const rtl::OUString& rCID ); 204 205 //returns the series particle of a CID when the CID is a child of the series 206 static rtl::OUString getSeriesParticleFromCID( const rtl::OUString& rCID ); 207 208 //return the model object that is indicated by rObjectCID 209 static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 210 getObjectPropertySet( 211 const rtl::OUString& rObjectCID 212 , const ::com::sun::star::uno::Reference< 213 ::com::sun::star::frame::XModel >& xChartModel ); 214 static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 215 getObjectPropertySet( 216 const rtl::OUString& rObjectCID 217 , const ::com::sun::star::uno::Reference< 218 ::com::sun::star::chart2::XChartDocument >& xChartDocument ); 219 220 //return the axis object that belongs to rObjectCID if any 221 static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > 222 getAxisForCID( 223 const rtl::OUString& rObjectCID 224 , const ::com::sun::star::uno::Reference< 225 ::com::sun::star::frame::XModel >& xChartModel ); 226 227 //return the series object that belongs to rObjectCID if any 228 static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > 229 getDataSeriesForCID( 230 const rtl::OUString& rObjectCID 231 , const ::com::sun::star::uno::Reference< 232 ::com::sun::star::frame::XModel >& xChartModel ); 233 234 static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram > 235 getDiagramForCID( 236 const rtl::OUString& rObjectCID 237 , const ::com::sun::star::uno::Reference< 238 ::com::sun::star::frame::XModel >& xChartModel ); 239 240 static const ::rtl::OUString& getPieSegmentDragMethodServiceName(); 241 static ::rtl::OUString createPieSegmentDragParameterString( 242 sal_Int32 nOffsetPercent 243 , const ::com::sun::star::awt::Point& rMinimumPosition 244 , const ::com::sun::star::awt::Point& rMaximumPosition ); 245 static bool parsePieSegmentDragParameterString( const rtl::OUString& rDragParameterString 246 , sal_Int32& rOffsetPercent 247 , ::com::sun::star::awt::Point& rMinimumPosition 248 , ::com::sun::star::awt::Point& rMaximumPosition ); 249 250 static TitleHelper::eTitleType getTitleTypeForCID( const ::rtl::OUString& rCID ); 251 252 static ::rtl::OUString getMovedSeriesCID( const ::rtl::OUString& rObjectCID, sal_Bool bForward ); 253 254 bool isValid() const; 255 bool isAutoGeneratedObject() const; 256 bool isAdditionalShape() const; 257 ::rtl::OUString getObjectCID() const; 258 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > getAdditionalShape() const; 259 ::com::sun::star::uno::Any getAny() const; 260 261 private: 262 // #i12587# support for shapes in chart 263 // For autogenerated chart objects a CID is specified in m_aObjectCID, 264 // for all other objects m_xAdditionalShape is set. 265 // Note, that if m_aObjectCID is set, m_xAdditionalShape must be empty 266 // and vice versa. 267 ::rtl::OUString m_aObjectCID; 268 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > m_xAdditionalShape; 269 }; 270 271 //............................................................................. 272 } //namespace chart 273 //............................................................................. 274 #endif 275