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