cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / chart2 / source / inc / ObjectIdentifier.hxx
blob5cfd6a1671b123c9067fe196313c6911406dcc56
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 #pragma once
21 #include <sal/config.h>
23 #include <string_view>
25 #include "TitleHelper.hxx"
26 #include "charttoolsdllapi.hxx"
28 #include <rtl/ustring.hxx>
29 #include <rtl/ref.hxx>
31 namespace chart { class ChartModel; }
32 namespace com::sun::star::awt { struct Point; }
33 namespace com::sun::star::beans { class XPropertySet; }
34 namespace com::sun::star::chart2 { class XAxis; }
35 namespace com::sun::star::chart2 { class XChartDocument; }
36 namespace com::sun::star::chart2 { class XCoordinateSystem; }
37 namespace com::sun::star::chart2 { class XDataSeries; }
38 namespace com::sun::star::chart2 { class XDiagram; }
39 namespace com::sun::star::drawing { class XShape; }
40 namespace com::sun::star::frame { class XModel; }
41 namespace com::sun::star::uno { class XInterface; }
43 namespace chart
45 class Axis;
46 class BaseCoordinateSystem;
47 class DataSeries;
48 class Diagram;
49 class Legend;
51 enum ObjectType
53 OBJECTTYPE_PAGE,
54 OBJECTTYPE_TITLE,
55 OBJECTTYPE_LEGEND,
56 OBJECTTYPE_LEGEND_ENTRY,
57 OBJECTTYPE_DIAGRAM,
58 OBJECTTYPE_DIAGRAM_WALL,
59 OBJECTTYPE_DIAGRAM_FLOOR,
60 OBJECTTYPE_AXIS,
61 OBJECTTYPE_AXIS_UNITLABEL,
62 OBJECTTYPE_GRID,
63 OBJECTTYPE_SUBGRID,
64 OBJECTTYPE_DATA_SERIES,
65 OBJECTTYPE_DATA_POINT,
66 OBJECTTYPE_DATA_LABELS,
67 OBJECTTYPE_DATA_LABEL,
68 OBJECTTYPE_DATA_ERRORS_X,
69 OBJECTTYPE_DATA_ERRORS_Y,
70 OBJECTTYPE_DATA_ERRORS_Z,
71 OBJECTTYPE_DATA_CURVE,//e.g. a statistical method printed as line
72 OBJECTTYPE_DATA_AVERAGE_LINE,
73 OBJECTTYPE_DATA_CURVE_EQUATION,
74 OBJECTTYPE_DATA_STOCK_RANGE,
75 OBJECTTYPE_DATA_STOCK_LOSS,
76 OBJECTTYPE_DATA_STOCK_GAIN,
77 OBJECTTYPE_DATA_TABLE,
78 OBJECTTYPE_SHAPE,
79 OBJECTTYPE_UNKNOWN
82 class UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS) ObjectIdentifier
84 //CID == ClassifiedIdentifier <--> name of shape
85 //semicolon, colon, equal sign and slash have special meanings in a CID
86 //and are therefore not allowed in its components
88 //syntax of a CID: CID:/classification/ObjectID
90 //where classification: nothing or "MultiClick" or "DragMethod=DragMethodServiceName" and "DragParameter=DragParameterString"
91 // or a combination of these separated with a colon
92 //where DragMethodServiceName can be a selfdefined servicename for special actions //todo define standard service for this purpose
93 //where DragParameterString is any string you like to transport information to your special drag service
94 // only semicolon, colon, equal sign and slash are not allowed characters
95 // also the keywords used in the ObjectIdentifiers are not allowed
97 //where ObjectID: Parent-Particle:Particle //e.g. Series=2:Point=22
98 //where Particle: Type=ParticleID //e.g. Point=22
99 //where Type: getStringForType( ObjectType eType ) or other string
101 public:
102 ObjectIdentifier();
103 ObjectIdentifier( OUString aObjectCID );
104 ObjectIdentifier( const css::uno::Reference< css::drawing::XShape >& rxShape );
105 ObjectIdentifier( const css::uno::Any& rAny );
107 bool operator==( const ObjectIdentifier& rOID ) const;
108 bool operator<( const ObjectIdentifier& rOID ) const;
110 static OUString createClassifiedIdentifierForObject(
111 const css::uno::Reference< css::uno::XInterface >& xObject
112 , const rtl::Reference<::chart::ChartModel>& xChartModel );
113 static OUString createClassifiedIdentifierForObject(
114 const rtl::Reference< ::chart::Title >& xObject
115 , const rtl::Reference<::chart::ChartModel>& xChartModel );
116 static OUString createClassifiedIdentifierForObject(
117 const rtl::Reference< ::chart::Legend >& xObject
118 , const rtl::Reference<::chart::ChartModel>& xChartModel );
119 static OUString createClassifiedIdentifierForObject(
120 const rtl::Reference< ::chart::Axis >& xObject
121 , const rtl::Reference<::chart::ChartModel>& xChartModel );
123 static OUString createClassifiedIdentifierForParticle(
124 std::u16string_view rParticle );
126 static OUString createClassifiedIdentifierForParticles(
127 std::u16string_view rParentParticle
128 , std::u16string_view rChildParticle
129 , std::u16string_view rDragMethodServiceName = std::u16string_view()
130 , std::u16string_view rDragParameterString = std::u16string_view() );
132 static OUString createClassifiedIdentifierForGrid(
133 const css::uno::Reference< css::chart2::XAxis >& xAxis
134 , const rtl::Reference<::chart::ChartModel>& xChartModel
135 , sal_Int32 nSubIndex = -1 );//-1: main grid, 0: first subgrid etc
137 SAL_DLLPRIVATE static OUString createParticleForDiagram();
139 static OUString createParticleForCoordinateSystem(
140 const rtl::Reference< ::chart::BaseCoordinateSystem >& xCooSys
141 , const rtl::Reference<::chart::ChartModel>& xChartModel );
143 static OUString createParticleForAxis(
144 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
146 static OUString createParticleForGrid(
147 sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
149 static OUString createParticleForSeries( sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex
150 , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex );
152 static OUString createParticleForLegend(
153 const rtl::Reference<::chart::ChartModel>& xChartModel );
155 /** Creates an identifier for the data table */
156 static OUString createParticleForDataTable(
157 const rtl::Reference<::chart::ChartModel>& xChartModel );
159 static OUString addChildParticle( std::u16string_view rParticle, std::u16string_view rChildParticle );
160 static OUString createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex );
161 static sal_Int32 getIndexFromParticleOrCID( std::u16string_view rParticleOrCID );
163 static OUString createClassifiedIdentifier(
164 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES
165 , std::u16string_view rParticleID );//e.g. SeriesID
167 static OUString createClassifiedIdentifierWithParent(
168 enum ObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
169 , std::u16string_view rParticleID //for points or subgrids this is an Index or otherwise an identifier from the model object
170 , std::u16string_view rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId"
171 , std::u16string_view rDragMethodServiceName = std::u16string_view()
172 , std::u16string_view rDragParameterString = std::u16string_view()
175 static bool isCID( std::u16string_view rName );
176 static std::u16string_view getDragMethodServiceName( std::u16string_view rClassifiedIdentifier );
177 static std::u16string_view getDragParameterString( std::u16string_view rCID );
178 static bool isDragableObject( std::u16string_view rClassifiedIdentifier );
179 bool isDragableObject() const;
180 static bool isRotateableObject( std::u16string_view rClassifiedIdentifier );
181 static bool isMultiClickObject( std::u16string_view rClassifiedIdentifier );
182 static bool areSiblings( std::u16string_view rCID1, std::u16string_view rCID2 );//identical object is no sibling
183 static bool areIdenticalObjects( std::u16string_view rCID1, std::u16string_view rCID2 );
185 static OUString getStringForType( ObjectType eObjectType );
186 static ObjectType getObjectType( std::u16string_view rCID );
187 ObjectType getObjectType() const;
189 static OUString createSeriesSubObjectStub( ObjectType eSubObjectType
190 , std::u16string_view rSeriesParticle
191 , std::u16string_view rDragMethodServiceName = std::u16string_view()
192 , std::u16string_view rDragParameterString = std::u16string_view() );
193 static OUString createPointCID( std::u16string_view rPointCID_Stub, sal_Int32 nIndex );
195 static OUString createDataCurveCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex, bool bAverageLine );
196 static OUString createDataCurveEquationCID( std::u16string_view rSeriesParticle, sal_Int32 nCurveIndex );
198 SAL_DLLPRIVATE static OUString getObjectID( std::u16string_view rCID );
199 static std::u16string_view getParticleID( std::u16string_view rCID );
200 static std::u16string_view getFullParentParticle( std::u16string_view rCID );
202 //returns the series particle of a CID when the CID is a child of the series
203 static OUString getSeriesParticleFromCID( std::u16string_view rCID );
205 //return the model object that is indicated by rObjectCID
206 static css::uno::Reference< css::beans::XPropertySet >
207 getObjectPropertySet(
208 std::u16string_view rObjectCID
209 , const rtl::Reference< ::chart::ChartModel >& xChartDocument );
211 //return the axis object that belongs to rObjectCID if any
212 static rtl::Reference< ::chart::Axis >
213 getAxisForCID(
214 std::u16string_view rObjectCID
215 , const rtl::Reference<::chart::ChartModel>& xChartModel );
217 //return the series object that belongs to rObjectCID if any
218 static rtl::Reference< ::chart::DataSeries >
219 getDataSeriesForCID(
220 std::u16string_view rObjectCID
221 , const rtl::Reference<::chart::ChartModel>& xChartModel );
223 static rtl::Reference< ::chart::Diagram >
224 getDiagramForCID(
225 std::u16string_view rObjectCID
226 , const rtl::Reference<::chart::ChartModel>& xChartModel );
228 static const OUString& getPieSegmentDragMethodServiceName();
229 static OUString createPieSegmentDragParameterString(
230 sal_Int32 nOffsetPercent
231 , const css::awt::Point& rMinimumPosition
232 , const css::awt::Point& rMaximumPosition );
233 static bool parsePieSegmentDragParameterString( std::u16string_view rDragParameterString
234 , sal_Int32& rOffsetPercent
235 , css::awt::Point& rMinimumPosition
236 , css::awt::Point& rMaximumPosition );
238 static TitleHelper::eTitleType getTitleTypeForCID( std::u16string_view rCID );
240 static OUString getMovedSeriesCID( std::u16string_view rObjectCID, bool bForward );
242 bool isValid() const;
243 bool isAutoGeneratedObject() const;
244 bool isAdditionalShape() const;
245 const OUString& getObjectCID() const { return m_aObjectCID;}
246 const css::uno::Reference< css::drawing::XShape >& getAdditionalShape() const { return m_xAdditionalShape;}
247 css::uno::Any getAny() const;
249 private:
250 // #i12587# support for shapes in chart
251 // For autogenerated chart objects a CID is specified in m_aObjectCID,
252 // for all other objects m_xAdditionalShape is set.
253 // Note, that if m_aObjectCID is set, m_xAdditionalShape must be empty
254 // and vice versa.
255 OUString m_aObjectCID;
256 css::uno::Reference< css::drawing::XShape > m_xAdditionalShape;
259 } //namespace chart
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */