Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / inc / ObjectIdentifier.hxx
blob87fb5723e3fcdf76c4513eb16a0f2f25eb4329cc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CHART2_SOURCE_INC_OBJECTIDENTIFIER_HXX
20 #define INCLUDED_CHART2_SOURCE_INC_OBJECTIDENTIFIER_HXX
22 #include "TitleHelper.hxx"
23 #include "charttoolsdllapi.hxx"
25 #include <rtl/ustring.hxx>
27 namespace chart { class ChartModel; }
28 namespace com { namespace sun { namespace star { namespace awt { struct Point; } } } }
29 namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
30 namespace com { namespace sun { namespace star { namespace chart2 { class XAxis; } } } }
31 namespace com { namespace sun { namespace star { namespace chart2 { class XChartDocument; } } } }
32 namespace com { namespace sun { namespace star { namespace chart2 { class XCoordinateSystem; } } } }
33 namespace com { namespace sun { namespace star { namespace chart2 { class XDataSeries; } } } }
34 namespace com { namespace sun { namespace star { namespace chart2 { class XDiagram; } } } }
35 namespace com { namespace sun { namespace star { namespace drawing { class XShape; } } } }
36 namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } }
37 namespace com { namespace sun { namespace star { namespace uno { class XInterface; } } } }
39 namespace chart
42 enum ObjectType
44 OBJECTTYPE_PAGE,
45 OBJECTTYPE_TITLE,
46 OBJECTTYPE_LEGEND,
47 OBJECTTYPE_LEGEND_ENTRY,
48 OBJECTTYPE_DIAGRAM,
49 OBJECTTYPE_DIAGRAM_WALL,
50 OBJECTTYPE_DIAGRAM_FLOOR,
51 OBJECTTYPE_AXIS,
52 OBJECTTYPE_AXIS_UNITLABEL,
53 OBJECTTYPE_GRID,
54 OBJECTTYPE_SUBGRID,
55 OBJECTTYPE_DATA_SERIES,
56 OBJECTTYPE_DATA_POINT,
57 OBJECTTYPE_DATA_LABELS,
58 OBJECTTYPE_DATA_LABEL,
59 OBJECTTYPE_DATA_ERRORS_X,
60 OBJECTTYPE_DATA_ERRORS_Y,
61 OBJECTTYPE_DATA_ERRORS_Z,
62 OBJECTTYPE_DATA_CURVE,//e.g. a statistical method printed as line
63 OBJECTTYPE_DATA_AVERAGE_LINE,
64 OBJECTTYPE_DATA_CURVE_EQUATION,
65 OBJECTTYPE_DATA_STOCK_RANGE,
66 OBJECTTYPE_DATA_STOCK_LOSS,
67 OBJECTTYPE_DATA_STOCK_GAIN,
68 OBJECTTYPE_SHAPE,
69 OBJECTTYPE_UNKNOWN
72 class OOO_DLLPUBLIC_CHARTTOOLS ObjectIdentifier
74 //CID == ClassifiedIdentifier <--> name of shape
75 //semicolon, colon, equal sign and slash have special meanings in a CID
76 //and are therefore not allowed in its components
78 //syntax of a CID: CID:/classification/ObjectID
80 //where classification: nothing or "MultiClick" or "DragMethod=DragMethodServiceName" and "DragParameter=DragParameterString"
81 // or a combination of these separated with a colon
82 //where DragMethodServiceName can be a selfdefined servicename for special actions //todo define standard service for this purpose
83 //where DragParameterString is any string you like to transport information to your special drag service
84 // only semicolon, colon, equal sign and slash are not allowed characters
85 // also the keywords used in the ObjectIdentifiers are not allowed
87 //where ObjectID: Parent-Particle:Particle //e.g. Series=2:Point=22
88 //where Particle: Type=ParticleID //e.g. Point=22
89 //where Type: getStringForType( ObjectType eType ) or other string
91 public:
92 ObjectIdentifier();
93 ObjectIdentifier( const OUString& rObjectCID );
94 ObjectIdentifier( const css::uno::Reference< css::drawing::XShape >& rxShape );
95 ObjectIdentifier( const css::uno::Any& rAny );
97 bool operator==( const ObjectIdentifier& rOID ) const;
98 bool operator!=( const ObjectIdentifier& rOID ) const;
99 bool operator<( const ObjectIdentifier& rOID ) const;
101 static OUString createClassifiedIdentifierForObject(
102 const css::uno::Reference< css::uno::XInterface >& xObject
103 , ChartModel& rModel);
105 static OUString createClassifiedIdentifierForObject(
106 const css::uno::Reference< css::uno::XInterface >& xObject
107 , const css::uno::Reference< css::frame::XModel >& xChartModel );
109 static OUString createClassifiedIdentifierForParticle(
110 const OUString& rParticle );
112 static OUString createClassifiedIdentifierForParticles(
113 const OUString& rParentParticle
114 , const OUString& rChildParticle
115 , const OUString& rDragMethodServiceName = OUString()
116 , const OUString& rDragParameterString = OUString() );
118 static OUString createClassifiedIdentifierForGrid(
119 const css::uno::Reference< css::chart2::XAxis >& xAxis
120 , const css::uno::Reference< css::frame::XModel >& xChartModel
121 , sal_Int32 nSubIndex = -1 );//-1: main grid, 0: first subgrid etc
123 SAL_DLLPRIVATE static OUString createParticleForDiagram();
125 static OUString createParticleForCoordinateSystem(
126 const css::uno::Reference< css::chart2::XCoordinateSystem >& xCooSys
127 , ChartModel& rModel );
129 static OUString createParticleForCoordinateSystem(
130 const css::uno::Reference< css::chart2::XCoordinateSystem >& xCooSys
131 , const css::uno::Reference< css::frame::XModel >& xChartModel );
133 static OUString createParticleForAxis(
134 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
136 static OUString createParticleForGrid(
137 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
139 static OUString createParticleForSeries( sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex
140 , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex );
142 static OUString createParticleForLegend( ChartModel& rModel );
144 static OUString createParticleForLegend(
145 const css::uno::Reference< css::frame::XModel >& xChartModel );
147 static OUString addChildParticle( const OUString& rParticle, const OUString& rChildParticle );
148 static OUString createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex );
149 static sal_Int32 getIndexFromParticleOrCID( const OUString& rParticleOrCID );
151 static OUString createClassifiedIdentifier(
152 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES
153 , const OUString& rParticleID );//e.g. SeriesID
155 static OUString createClassifiedIdentifierWithParent(
156 enum ObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
157 , const OUString& rParticleID //for points or subgrids this is an Index or otherwise an identifier from the model object
158 , const OUString& rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId"
159 , const OUString& rDragMethodServiceName = OUString()
160 , const OUString& rDragParameterString = OUString()
163 static bool isCID( const OUString& rName );
164 static OUString getDragMethodServiceName( const OUString& rClassifiedIdentifier );
165 static OUString getDragParameterString( const OUString& rCID );
166 static bool isDragableObject( const OUString& rClassifiedIdentifier );
167 bool isDragableObject() const;
168 static bool isRotateableObject( const OUString& rClassifiedIdentifier );
169 static bool isMultiClickObject( const OUString& rClassifiedIdentifier );
170 static bool areSiblings( const OUString& rCID1, const OUString& rCID2 );//identical object is no sibling
171 static bool areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 );
173 static OUString getStringForType( ObjectType eObjectType );
174 static ObjectType getObjectType( const OUString& rCID );
175 ObjectType getObjectType() const;
177 static OUString createSeriesSubObjectStub( ObjectType eSubObjectType
178 , const OUString& rSeriesParticle
179 , const OUString& rDragMethodServiceName = OUString()
180 , const OUString& rDragParameterString = OUString() );
181 static OUString createPointCID( const OUString& rPointCID_Stub, sal_Int32 nIndex );
183 static OUString createDataCurveCID( const OUString& rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine );
184 static OUString createDataCurveEquationCID( const OUString& rSeriesParticle, sal_Int32 nCurveIndex );
186 SAL_DLLPRIVATE static OUString getObjectID( const OUString& rCID );
187 static OUString getParticleID( const OUString& rCID );
188 static OUString getFullParentParticle( const OUString& rCID );
190 //returns the series particle of a CID when the CID is a child of the series
191 static OUString getSeriesParticleFromCID( const OUString& rCID );
193 //return the model object that is indicated by rObjectCID
194 static css::uno::Reference< css::beans::XPropertySet >
195 getObjectPropertySet(
196 const OUString& rObjectCID
197 , const css::uno::Reference< css::frame::XModel >& xChartModel );
198 static css::uno::Reference< css::beans::XPropertySet >
199 getObjectPropertySet(
200 const OUString& rObjectCID
201 , const css::uno::Reference< css::chart2::XChartDocument >& xChartDocument );
203 //return the axis object that belongs to rObjectCID if any
204 static css::uno::Reference< css::chart2::XAxis >
205 getAxisForCID(
206 const OUString& rObjectCID
207 , const css::uno::Reference< css::frame::XModel >& xChartModel );
209 //return the series object that belongs to rObjectCID if any
210 static css::uno::Reference< css::chart2::XDataSeries >
211 getDataSeriesForCID(
212 const OUString& rObjectCID
213 , const css::uno::Reference< css::frame::XModel >& xChartModel );
215 static css::uno::Reference< css::chart2::XDiagram >
216 getDiagramForCID(
217 const OUString& rObjectCID
218 , const css::uno::Reference< css::frame::XModel >& xChartModel );
220 static const OUString& getPieSegmentDragMethodServiceName();
221 static OUString createPieSegmentDragParameterString(
222 sal_Int32 nOffsetPercent
223 , const css::awt::Point& rMinimumPosition
224 , const css::awt::Point& rMaximumPosition );
225 static bool parsePieSegmentDragParameterString( const OUString& rDragParameterString
226 , sal_Int32& rOffsetPercent
227 , css::awt::Point& rMinimumPosition
228 , css::awt::Point& rMaximumPosition );
230 static TitleHelper::eTitleType getTitleTypeForCID( const OUString& rCID );
232 static OUString getMovedSeriesCID( const OUString& rObjectCID, bool bForward );
234 bool isValid() const;
235 bool isAutoGeneratedObject() const;
236 bool isAdditionalShape() const;
237 const OUString& getObjectCID() const { return m_aObjectCID;}
238 const css::uno::Reference< css::drawing::XShape >& getAdditionalShape() const { return m_xAdditionalShape;}
239 css::uno::Any getAny() const;
241 private:
242 // #i12587# support for shapes in chart
243 // For autogenerated chart objects a CID is specified in m_aObjectCID,
244 // for all other objects m_xAdditionalShape is set.
245 // Note, that if m_aObjectCID is set, m_xAdditionalShape must be empty
246 // and vice versa.
247 OUString m_aObjectCID;
248 css::uno::Reference< css::drawing::XShape > m_xAdditionalShape;
251 } //namespace chart
252 #endif
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */