1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 #pragma once 20 21 #include <sal/config.h> 22 23 #include <string_view> 24 25 #include "TitleHelper.hxx" 26 #include "charttoolsdllapi.hxx" 27 28 #include <rtl/ustring.hxx> 29 30 namespace chart { class ChartModel; } 31 namespace com::sun::star::awt { struct Point; } 32 namespace com::sun::star::beans { class XPropertySet; } 33 namespace com::sun::star::chart2 { class XAxis; } 34 namespace com::sun::star::chart2 { class XChartDocument; } 35 namespace com::sun::star::chart2 { class XCoordinateSystem; } 36 namespace com::sun::star::chart2 { class XDataSeries; } 37 namespace com::sun::star::chart2 { class XDiagram; } 38 namespace com::sun::star::drawing { class XShape; } 39 namespace com::sun::star::frame { class XModel; } 40 namespace com::sun::star::uno { class XInterface; } 41 42 namespace chart 43 { 44 45 enum ObjectType 46 { 47 OBJECTTYPE_PAGE, 48 OBJECTTYPE_TITLE, 49 OBJECTTYPE_LEGEND, 50 OBJECTTYPE_LEGEND_ENTRY, 51 OBJECTTYPE_DIAGRAM, 52 OBJECTTYPE_DIAGRAM_WALL, 53 OBJECTTYPE_DIAGRAM_FLOOR, 54 OBJECTTYPE_AXIS, 55 OBJECTTYPE_AXIS_UNITLABEL, 56 OBJECTTYPE_GRID, 57 OBJECTTYPE_SUBGRID, 58 OBJECTTYPE_DATA_SERIES, 59 OBJECTTYPE_DATA_POINT, 60 OBJECTTYPE_DATA_LABELS, 61 OBJECTTYPE_DATA_LABEL, 62 OBJECTTYPE_DATA_ERRORS_X, 63 OBJECTTYPE_DATA_ERRORS_Y, 64 OBJECTTYPE_DATA_ERRORS_Z, 65 OBJECTTYPE_DATA_CURVE,//e.g. a statistical method printed as line 66 OBJECTTYPE_DATA_AVERAGE_LINE, 67 OBJECTTYPE_DATA_CURVE_EQUATION, 68 OBJECTTYPE_DATA_STOCK_RANGE, 69 OBJECTTYPE_DATA_STOCK_LOSS, 70 OBJECTTYPE_DATA_STOCK_GAIN, 71 OBJECTTYPE_SHAPE, 72 OBJECTTYPE_UNKNOWN 73 }; 74 75 class OOO_DLLPUBLIC_CHARTTOOLS ObjectIdentifier 76 { 77 //CID == ClassifiedIdentifier <--> name of shape 78 //semicolon, colon, equal sign and slash have special meanings in a CID 79 //and are therefore not allowed in its components 80 81 //syntax of a CID: CID:/classification/ObjectID 82 83 //where classification: nothing or "MultiClick" or "DragMethod=DragMethodServiceName" and "DragParameter=DragParameterString" 84 // or a combination of these separated with a colon 85 //where DragMethodServiceName can be a selfdefined servicename for special actions //todo define standard service for this purpose 86 //where DragParameterString is any string you like to transport information to your special drag service 87 // only semicolon, colon, equal sign and slash are not allowed characters 88 // also the keywords used in the ObjectIdentifiers are not allowed 89 90 //where ObjectID: Parent-Particle:Particle //e.g. Series=2:Point=22 91 //where Particle: Type=ParticleID //e.g. Point=22 92 //where Type: getStringForType( ObjectType eType ) or other string 93 94 public: 95 ObjectIdentifier(); 96 ObjectIdentifier( const OUString& rObjectCID ); 97 ObjectIdentifier( const css::uno::Reference< css::drawing::XShape >& rxShape ); 98 ObjectIdentifier( const css::uno::Any& rAny ); 99 100 bool operator==( const ObjectIdentifier& rOID ) const; 101 bool operator!=( const ObjectIdentifier& rOID ) const; 102 bool operator<( const ObjectIdentifier& rOID ) const; 103 104 static OUString createClassifiedIdentifierForObject( 105 const css::uno::Reference< css::uno::XInterface >& xObject 106 , ChartModel& rModel); 107 108 static OUString createClassifiedIdentifierForObject( 109 const css::uno::Reference< css::uno::XInterface >& xObject 110 , const css::uno::Reference< css::frame::XModel >& xChartModel ); 111 112 static OUString createClassifiedIdentifierForParticle( 113 const OUString& rParticle ); 114 115 static OUString createClassifiedIdentifierForParticles( 116 const OUString& rParentParticle 117 , const OUString& rChildParticle 118 , std::u16string_view rDragMethodServiceName = std::u16string_view() 119 , std::u16string_view rDragParameterString = std::u16string_view() ); 120 121 static OUString createClassifiedIdentifierForGrid( 122 const css::uno::Reference< css::chart2::XAxis >& xAxis 123 , const css::uno::Reference< css::frame::XModel >& xChartModel 124 , sal_Int32 nSubIndex = -1 );//-1: main grid, 0: first subgrid etc 125 126 SAL_DLLPRIVATE static OUString createParticleForDiagram(); 127 128 static OUString createParticleForCoordinateSystem( 129 const css::uno::Reference< css::chart2::XCoordinateSystem >& xCooSys 130 , ChartModel& rModel ); 131 132 static OUString createParticleForCoordinateSystem( 133 const css::uno::Reference< css::chart2::XCoordinateSystem >& xCooSys 134 , const css::uno::Reference< css::frame::XModel >& xChartModel ); 135 136 static OUString createParticleForAxis( 137 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); 138 139 static OUString createParticleForGrid( 140 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); 141 142 static OUString createParticleForSeries( sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex 143 , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex ); 144 145 static OUString createParticleForLegend( ChartModel& rModel ); 146 147 static OUString createParticleForLegend( 148 const css::uno::Reference< css::frame::XModel >& xChartModel ); 149 150 static OUString addChildParticle( const OUString& rParticle, std::u16string_view rChildParticle ); 151 static OUString createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex ); 152 static sal_Int32 getIndexFromParticleOrCID( const OUString& rParticleOrCID ); 153 154 static OUString createClassifiedIdentifier( 155 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES 156 , std::u16string_view rParticleID );//e.g. SeriesID 157 158 static OUString createClassifiedIdentifierWithParent( 159 enum ObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID 160 , std::u16string_view rParticleID //for points or subgrids this is an Index or otherwise an identifier from the model object 161 , std::u16string_view rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId" 162 , std::u16string_view rDragMethodServiceName = std::u16string_view() 163 , std::u16string_view rDragParameterString = std::u16string_view() 164 ); 165 166 static bool isCID( const OUString& rName ); 167 static OUString getDragMethodServiceName( const OUString& rClassifiedIdentifier ); 168 static OUString getDragParameterString( const OUString& rCID ); 169 static bool isDragableObject( const OUString& rClassifiedIdentifier ); 170 bool isDragableObject() const; 171 static bool isRotateableObject( const OUString& rClassifiedIdentifier ); 172 static bool isMultiClickObject( const OUString& rClassifiedIdentifier ); 173 static bool areSiblings( const OUString& rCID1, const OUString& rCID2 );//identical object is no sibling 174 static bool areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 ); 175 176 static OUString getStringForType( ObjectType eObjectType ); 177 static ObjectType getObjectType( const OUString& rCID ); 178 ObjectType getObjectType() const; 179 180 static OUString createSeriesSubObjectStub( ObjectType eSubObjectType 181 , const OUString& rSeriesParticle 182 , std::u16string_view rDragMethodServiceName = std::u16string_view() 183 , std::u16string_view rDragParameterString = std::u16string_view() ); 184 static OUString createPointCID( std::u16string_view rPointCID_Stub, sal_Int32 nIndex ); 185 186 static OUString createDataCurveCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine ); 187 static OUString createDataCurveEquationCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex ); 188 189 SAL_DLLPRIVATE static OUString getObjectID( const OUString& rCID ); 190 static OUString getParticleID( const OUString& rCID ); 191 static OUString getFullParentParticle( const OUString& rCID ); 192 193 //returns the series particle of a CID when the CID is a child of the series 194 static OUString getSeriesParticleFromCID( const OUString& rCID ); 195 196 //return the model object that is indicated by rObjectCID 197 static css::uno::Reference< css::beans::XPropertySet > 198 getObjectPropertySet( 199 const OUString& rObjectCID 200 , const css::uno::Reference< css::frame::XModel >& xChartModel ); 201 static css::uno::Reference< css::beans::XPropertySet > 202 getObjectPropertySet( 203 const OUString& rObjectCID 204 , const css::uno::Reference< css::chart2::XChartDocument >& xChartDocument ); 205 206 //return the axis object that belongs to rObjectCID if any 207 static css::uno::Reference< css::chart2::XAxis > 208 getAxisForCID( 209 const OUString& rObjectCID 210 , const css::uno::Reference< css::frame::XModel >& xChartModel ); 211 212 //return the series object that belongs to rObjectCID if any 213 static css::uno::Reference< css::chart2::XDataSeries > 214 getDataSeriesForCID( 215 const OUString& rObjectCID 216 , const css::uno::Reference< css::frame::XModel >& xChartModel ); 217 218 static css::uno::Reference< css::chart2::XDiagram > 219 getDiagramForCID( 220 const OUString& rObjectCID 221 , const css::uno::Reference< css::frame::XModel >& xChartModel ); 222 223 static const OUString& getPieSegmentDragMethodServiceName(); 224 static OUString createPieSegmentDragParameterString( 225 sal_Int32 nOffsetPercent 226 , const css::awt::Point& rMinimumPosition 227 , const css::awt::Point& rMaximumPosition ); 228 static bool parsePieSegmentDragParameterString( const OUString& rDragParameterString 229 , sal_Int32& rOffsetPercent 230 , css::awt::Point& rMinimumPosition 231 , css::awt::Point& rMaximumPosition ); 232 233 static TitleHelper::eTitleType getTitleTypeForCID( const OUString& rCID ); 234 235 static OUString getMovedSeriesCID( const OUString& rObjectCID, bool bForward ); 236 237 bool isValid() const; 238 bool isAutoGeneratedObject() const; 239 bool isAdditionalShape() const; getObjectCID() const240 const OUString& getObjectCID() const { return m_aObjectCID;} getAdditionalShape() const241 const css::uno::Reference< css::drawing::XShape >& getAdditionalShape() const { return m_xAdditionalShape;} 242 css::uno::Any getAny() const; 243 244 private: 245 // #i12587# support for shapes in chart 246 // For autogenerated chart objects a CID is specified in m_aObjectCID, 247 // for all other objects m_xAdditionalShape is set. 248 // Note, that if m_aObjectCID is set, m_xAdditionalShape must be empty 249 // and vice versa. 250 OUString m_aObjectCID; 251 css::uno::Reference< css::drawing::XShape > m_xAdditionalShape; 252 }; 253 254 } //namespace chart 255 256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 257