merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / tools / ObjectIdentifier.cxx
blob3c32e42a0e7b38353e985c0cd768af231b7bbdbf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ObjectIdentifier.cxx,v $
10 * $Revision: 1.8.24.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "ObjectIdentifier.hxx"
35 #include "macros.hxx"
36 #include "TitleHelper.hxx"
37 #include "ChartModelHelper.hxx"
38 #include "AxisHelper.hxx"
39 #include "servicenames_charttypes.hxx"
40 #include "DiagramHelper.hxx"
41 #include "AxisIndexDefines.hxx"
42 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
43 #include <com/sun/star/chart2/XChartDocument.hpp>
44 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
45 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
46 #include <com/sun/star/chart2/XAxis.hpp>
47 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
49 // header for define DBG_ASSERT
50 #include <tools/debug.hxx>
51 #include <comphelper/InlineContainer.hxx>
53 #include <rtl/ustrbuf.hxx>
55 //.............................................................................
56 namespace chart
58 //.............................................................................
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::chart2;
62 using rtl::OUString;
63 using rtl::OUStringBuffer;
64 using ::com::sun::star::uno::Reference;
66 static OUString m_aMultiClick( C2U("MultiClick") );
67 static OUString m_aDragMethodEquals( C2U("DragMethod=") );
68 static OUString m_aDragParameterEquals( C2U("DragParameter=") );
69 static OUString m_aProtocol( C2U("CID/") );
70 static OUString m_aEmptyString;
71 static OUString m_aPieSegmentDragMethodServiceName( C2U("PieSegmentDraging") );
73 namespace
76 OUString lcl_createClassificationStringForType( ObjectType eObjectType
77 , const OUString& rDragMethodServiceName
78 , const OUString& rDragParameterString
81 OUStringBuffer aRet;
82 switch( eObjectType )
84 //these object types are all selected only after their parents was selected before
85 case OBJECTTYPE_LEGEND_ENTRY: //parent is intended to be OBJECTTYPE_LEGEND
86 case OBJECTTYPE_DATA_POINT: //parent is intended to be OBJECTTYPE_DATA_SERIES
87 case OBJECTTYPE_DATA_LABEL: //parent is intended to be OBJECTTYPE_DATA_LABELS
88 case OBJECTTYPE_DATA_ERRORS_X: //parent is intended to be OBJECTTYPE_DATA_ERRORS
89 case OBJECTTYPE_DATA_ERRORS_Y: //parent is intended to be OBJECTTYPE_DATA_ERRORS
90 case OBJECTTYPE_DATA_ERRORS_Z: //parent is intended to be OBJECTTYPE_DATA_ERRORS
91 aRet=m_aMultiClick;
92 default:
93 ;//empty string
95 if( rDragMethodServiceName.getLength() )
97 if( aRet.getLength() )
98 aRet.appendAscii(":");
99 aRet.append( m_aDragMethodEquals );
100 aRet.append( rDragMethodServiceName );
102 if( rDragParameterString.getLength() )
104 if( aRet.getLength() )
105 aRet.appendAscii(":");
106 aRet.append( m_aDragParameterEquals );
107 aRet.append( rDragParameterString );
110 return aRet.makeStringAndClear();
113 typedef ::comphelper::MakeMap< TitleHelper::eTitleType, OUString > tTitleMap;
114 const tTitleMap& lcl_getTitleMap()
116 //maps the title type to the ParentParticle for that title
117 static tTitleMap m_aTitleMap = tTitleMap
118 ( TitleHelper::MAIN_TITLE, C2U("") )
119 ( TitleHelper::SUB_TITLE, C2U("D=0") )
120 ( TitleHelper::X_AXIS_TITLE, C2U("D=0:CS=0:Axis=0,0") )
121 ( TitleHelper::Y_AXIS_TITLE, C2U("D=0:CS=0:Axis=1,0") )
122 ( TitleHelper::Z_AXIS_TITLE, C2U("D=0:CS=0:Axis=2,0") )
123 ( TitleHelper::SECONDARY_X_AXIS_TITLE, C2U("D=0:CS=0:Axis=0,1") )
124 ( TitleHelper::SECONDARY_Y_AXIS_TITLE, C2U("D=0:CS=0:Axis=1,1") )
126 return m_aTitleMap;
129 OUString lcl_getTitleParentParticle( TitleHelper::eTitleType aTitleType )
131 OUString aRet;
133 const tTitleMap& rMap = lcl_getTitleMap();
134 tTitleMap::const_iterator aIt( rMap.find( aTitleType ) );
135 if( aIt != rMap.end())
136 aRet = (*aIt).second;
138 return aRet;
141 Reference<XChartType> lcl_getFirstStockChartType( const Reference< frame::XModel >& xChartModel )
143 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
144 if(!xDiagram.is())
145 return 0;
147 //iterate through all coordinate systems
148 Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
149 if( !xCooSysContainer.is())
150 return 0;
152 uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
153 for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
155 //iterate through all chart types in the current coordinate system
156 Reference< XChartTypeContainer > xChartTypeContainer( aCooSysList[nCS], uno::UNO_QUERY );
157 if( !xChartTypeContainer.is() )
158 continue;
160 uno::Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
161 for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
163 Reference< XChartType > xChartType( aChartTypeList[nT] );
164 if(!xChartType.is())
165 continue;
166 OUString aChartType = xChartType->getChartType();
167 if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
168 return xChartType;
171 return 0;
174 OUString lcl_getIndexStringAfterString( const OUString& rString, const OUString& rSearchString )
176 OUStringBuffer aRet;
178 sal_Int32 nIndexStart = rString.lastIndexOf( rSearchString );
179 if( nIndexStart != -1 )
181 nIndexStart += rSearchString.getLength();
182 sal_Int32 nIndexEnd = rString.getLength();
183 sal_Int32 nNextColon = rString.indexOf( ':', nIndexStart );
184 if( nNextColon != -1 )
185 nIndexEnd = nNextColon;
186 aRet = rString.copy(nIndexStart,nIndexEnd-nIndexStart);
189 return aRet.makeStringAndClear();
192 sal_Int32 lcl_StringToIndex( const OUString& rIndexString )
194 sal_Int32 nRet = -1;
195 if( rIndexString.getLength() )
197 nRet = rIndexString.toInt32();
198 if( nRet < -1 )
199 nRet = -1;
201 return nRet;
204 void lcl_parseCooSysIndices( sal_Int32& rnDiagram, sal_Int32& rnCooSys, const OUString& rString )
206 rnDiagram = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("D=") ) );
207 rnCooSys = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("CS=") ) );
210 void lcl_parseAxisIndices( sal_Int32& rnDimensionIndex, sal_Int32& rnAxisIndex, const OUString& rString )
212 OUString aAxisIndexString = lcl_getIndexStringAfterString( rString, C2U(":Axis=") );
213 sal_Int32 nCharacterIndex=0;
214 rnDimensionIndex = lcl_StringToIndex( aAxisIndexString.getToken( 0, ',', nCharacterIndex ) );
215 rnAxisIndex = lcl_StringToIndex( aAxisIndexString.getToken( 0, ',', nCharacterIndex ) );
218 void lcl_parseGridIndices( sal_Int32& rnSubGridIndex, const OUString& rString )
220 rnSubGridIndex = -1;
221 rnSubGridIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U(":SubGrid=") ) );
224 void lcl_parseSeriesIndices( sal_Int32& rnChartTypeIndex, sal_Int32& rnSeriesIndex, sal_Int32& rnPointIndex, const OUString& rString )
226 rnChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("CT=") ) );
227 rnSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("Series=") ) );
228 rnPointIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("Point=") ) );
231 void lcl_getDiagramAndCooSys( const OUString& rObjectCID
232 , const Reference< frame::XModel >& xChartModel
233 , Reference< XDiagram >& xDiagram
234 , Reference< XCoordinateSystem >& xCooSys )
236 sal_Int32 nDiagramIndex = -1;
237 sal_Int32 nCooSysIndex = -1;
238 lcl_parseCooSysIndices( nDiagramIndex, nCooSysIndex, rObjectCID );
239 xDiagram = ChartModelHelper::findDiagram( xChartModel );//todo use nDiagramIndex when more than one diagram is possible in future
240 if( !xDiagram.is() )
241 return;
243 if( nCooSysIndex > -1 )
245 Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
246 if( xCooSysContainer.is() )
248 uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
249 if( nCooSysIndex < aCooSysList.getLength() )
250 xCooSys = aCooSysList[nCooSysIndex];
255 } //anonymous namespace
257 //static
258 OUString ObjectIdentifier::createClassifiedIdentifierForObject(
259 const Reference< uno::XInterface >& xObject
260 , const Reference< frame::XModel >& xChartModel )
262 OUString aRet;
264 enum ObjectType eObjectType = OBJECTTYPE_UNKNOWN;
265 OUString aObjectID;
266 OUString aParentParticle;
267 OUString aDragMethodServiceName;
268 OUString aDragParameterString;
273 //title
274 Reference< XTitle > xTitle( xObject, uno::UNO_QUERY );
275 if( xTitle.is() )
277 TitleHelper::eTitleType aTitleType;
278 if( TitleHelper::getTitleType( aTitleType, xTitle, xChartModel ) )
280 eObjectType = OBJECTTYPE_TITLE;
281 aParentParticle = lcl_getTitleParentParticle( aTitleType );
282 aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
283 eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
285 return aRet;
289 //axis
290 Reference< XAxis > xAxis( xObject, uno::UNO_QUERY );
291 if( xAxis.is() )
293 Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ) ) );
294 rtl::OUString aCooSysParticle( createParticleForCoordinateSystem( xCooSys, xChartModel ) );
295 sal_Int32 nDimensionIndex=-1;
296 sal_Int32 nAxisIndex=-1;
297 AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex );
298 rtl::OUString aAxisParticle( createParticleForAxis( nDimensionIndex, nAxisIndex ) );
299 return createClassifiedIdentifierForParticles( aCooSysParticle, aAxisParticle );
302 //legend
303 Reference< XLegend > xLegend( xObject, uno::UNO_QUERY );
304 if( xLegend.is() )
306 return createClassifiedIdentifierForParticle( createParticleForLegend( xLegend, xChartModel ) );
309 //diagram
310 Reference< XDiagram > xDiagram( xObject, uno::UNO_QUERY );
311 if( xDiagram.is() )
313 return createClassifiedIdentifierForParticle( createParticleForDiagram( xDiagram, xChartModel ) );
316 //todo
317 //XDataSeries
318 //CooSys
319 //charttype
320 //datapoint?
321 //Gridproperties
323 catch( uno::Exception& ex)
325 ASSERT_EXCEPTION( ex );
328 if( eObjectType != OBJECTTYPE_UNKNOWN )
330 aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
331 eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
333 else
335 DBG_ASSERT(false,"give object could not be identifed in createClassifiedIdentifierForObject");
338 return aRet;
341 //static
342 OUString ObjectIdentifier::createClassifiedIdentifierForParticle(
343 const OUString& rParticle )
345 return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle, OUString() );
348 //static
349 OUString ObjectIdentifier::createClassifiedIdentifierForParticles(
350 const OUString& rParentParticle
351 , const OUString& rChildParticle
352 , const OUString& rDragMethodServiceName
353 , const OUString& rDragParameterString )
355 ObjectType eObjectType( ObjectIdentifier::getObjectType( rChildParticle ) );
356 if( eObjectType == OBJECTTYPE_UNKNOWN )
357 eObjectType = ObjectIdentifier::getObjectType( rParentParticle );
359 OUStringBuffer aRet( m_aProtocol );
360 aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
361 if(aRet.getLength()>m_aProtocol.getLength())
362 aRet.appendAscii("/");
364 if(rParentParticle.getLength())
366 aRet.append(rParentParticle);
367 if( rChildParticle.getLength() )
368 aRet.appendAscii(":");
370 aRet.append(rChildParticle);
372 return aRet.makeStringAndClear();
375 //static
376 OUString ObjectIdentifier::createParticleForDiagram(
377 const Reference< XDiagram >& /*xDiagram*/
378 , const Reference< frame::XModel >& /*xChartModel*/ )
380 static OUString aRet(C2U("D=0"));
381 //todo: if more than one diagram is implemeted, add the correct diagram index here
382 return aRet;
385 //static
386 OUString ObjectIdentifier::createParticleForCoordinateSystem(
387 const Reference< XCoordinateSystem >& xCooSys
388 , const Reference< frame::XModel >& xChartModel )
390 OUStringBuffer aRet;
392 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
393 Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
394 if( xCooSysContainer.is() )
396 sal_Int32 nCooSysIndex = 0;
397 uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
398 for( ; nCooSysIndex < aCooSysList.getLength(); ++nCooSysIndex )
400 Reference< XCoordinateSystem > xCurrentCooSys( aCooSysList[nCooSysIndex] );
401 if( xCooSys == xCurrentCooSys )
403 aRet = ObjectIdentifier::createParticleForDiagram( xDiagram, xChartModel );
404 aRet.appendAscii(":CS=");
405 aRet.append( OUString::valueOf( nCooSysIndex ) );
406 break;
411 return aRet.makeStringAndClear();
414 //static
415 OUString ObjectIdentifier::createParticleForAxis(
416 sal_Int32 nDimensionIndex
417 , sal_Int32 nAxisIndex )
419 OUStringBuffer aRet(C2U("Axis="));
421 aRet.append( OUString::valueOf( nDimensionIndex ) );
422 aRet.appendAscii(",");
423 aRet.append( OUString::valueOf( nAxisIndex ) );
425 return aRet.makeStringAndClear();
428 //static
429 OUString ObjectIdentifier::createParticleForGrid(
430 sal_Int32 nDimensionIndex
431 , sal_Int32 nAxisIndex )
433 OUStringBuffer aRet(C2U("Axis="));
434 aRet.append( OUString::valueOf( nDimensionIndex ) );
435 aRet.appendAscii(",");
436 aRet.append( OUString::valueOf( nAxisIndex ) );
437 aRet.append( C2U(":Grid=0") );
439 return aRet.makeStringAndClear();
442 //static
443 OUString ObjectIdentifier::createClassifiedIdentifierForGrid(
444 const Reference< XAxis >& xAxis
445 , const Reference< frame::XModel >& xChartModel
446 , sal_Int32 nSubGridIndex )
448 //-1: main grid, 0: first subgrid etc
450 rtl::OUString aAxisCID( createClassifiedIdentifierForObject( xAxis, xChartModel ) );
451 rtl::OUString aGridCID( addChildParticle( aAxisCID
452 , createChildParticleWithIndex( OBJECTTYPE_GRID, 0 ) ) );
453 if( nSubGridIndex >= 0 )
455 aGridCID = addChildParticle( aGridCID
456 , createChildParticleWithIndex( OBJECTTYPE_SUBGRID, 0 ) );
458 return aGridCID;
461 //static
462 OUString ObjectIdentifier::createParticleForSeries(
463 sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex
464 , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex )
466 OUStringBuffer aRet;
468 aRet.appendAscii("D=");
469 aRet.append( OUString::valueOf( nDiagramIndex ) );
470 aRet.appendAscii(":CS=");
471 aRet.append( OUString::valueOf( nCooSysIndex ) );
472 aRet.appendAscii(":CT=");
473 aRet.append( OUString::valueOf( nChartTypeIndex ) );
474 aRet.appendAscii(":");
475 aRet.append(getStringForType( OBJECTTYPE_DATA_SERIES ));
476 aRet.appendAscii("=");
477 aRet.append( OUString::valueOf( nSeriesIndex ) );
479 return aRet.makeStringAndClear();
482 //static
483 OUString ObjectIdentifier::createParticleForLegend(
484 const Reference< XLegend >& /*xLegend*/
485 , const Reference< frame::XModel >& xChartModel )
487 OUStringBuffer aRet;
489 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
490 //todo: if more than one diagram is implemeted, find the correct diagram wich is owner of the given legend
492 aRet.append( ObjectIdentifier::createParticleForDiagram( xDiagram, xChartModel ) );
493 aRet.appendAscii(":");
494 aRet.append(getStringForType( OBJECTTYPE_LEGEND ));
495 aRet.appendAscii("=");
497 return aRet.makeStringAndClear();
500 //static
501 OUString ObjectIdentifier::createClassifiedIdentifier(
502 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES
503 , const OUString& rParticleID )//e.g. SeriesID
505 return createClassifiedIdentifierWithParent(
506 eObjectType, rParticleID, m_aEmptyString );
509 //static
510 OUString ObjectIdentifier::createClassifiedIdentifierWithParent(
511 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
512 , const OUString& rParticleID //e.g. Point Index or SubGrid Index
513 , const OUString& rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId"
514 , const OUString& rDragMethodServiceName
515 , const OUString& rDragParameterString
517 //, bool bIsMultiClickObject ) //e.g. true
519 //e.g. "MultiClick/Series=2:Point=34"
521 OUStringBuffer aRet( m_aProtocol );
522 aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
523 if(aRet.getLength()>m_aProtocol.getLength())
524 aRet.appendAscii("/");
525 aRet.append(rParentPartical);
526 if(rParentPartical.getLength())
527 aRet.appendAscii(":");
529 aRet.append(getStringForType( eObjectType ));
530 aRet.appendAscii("=");
531 aRet.append(rParticleID);
533 return aRet.makeStringAndClear();
536 //static
537 const OUString& ObjectIdentifier::getPieSegmentDragMethodServiceName()
539 return m_aPieSegmentDragMethodServiceName;
542 //static
543 OUString ObjectIdentifier::createPieSegmentDragParameterString(
544 sal_Int32 nOffsetPercent
545 , const awt::Point& rMinimumPosition
546 , const awt::Point& rMaximumPosition )
548 OUStringBuffer aRet( OUString::valueOf( nOffsetPercent ) );
549 aRet.append( sal_Unicode( ',' ));
550 aRet.append( OUString::valueOf( rMinimumPosition.X ) );
551 aRet.append( sal_Unicode( ',' ));
552 aRet.append( OUString::valueOf( rMinimumPosition.Y ) );
553 aRet.append( sal_Unicode( ',' ));
554 aRet.append( OUString::valueOf( rMaximumPosition.X ) );
555 aRet.append( sal_Unicode( ',' ));
556 aRet.append( OUString::valueOf( rMaximumPosition.Y ) );
557 return aRet.makeStringAndClear();
560 //static
561 bool ObjectIdentifier::parsePieSegmentDragParameterString(
562 const OUString& rDragParameterString
563 , sal_Int32& rOffsetPercent
564 , awt::Point& rMinimumPosition
565 , awt::Point& rMaximumPosition )
567 OUString aValue;
568 sal_Int32 nCharacterIndex = 0;
570 OUString aValueString( rDragParameterString.getToken( 0, ',', nCharacterIndex ) );
571 rOffsetPercent = aValueString.toInt32();
572 if( nCharacterIndex < 0 )
573 return false;
575 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
576 rMinimumPosition.X = aValueString.toInt32();
577 if( nCharacterIndex < 0 )
578 return false;
580 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
581 rMinimumPosition.Y = aValueString.toInt32();
582 if( nCharacterIndex < 0 )
583 return false;
585 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
586 rMaximumPosition.X = aValueString.toInt32();
587 if( nCharacterIndex < 0 )
588 return false;
590 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
591 rMaximumPosition.Y = aValueString.toInt32();
592 if( nCharacterIndex < 0 )
593 return false;
595 return true;
598 //static
599 OUString ObjectIdentifier::getDragMethodServiceName( const OUString& rCID )
601 OUString aRet;
603 sal_Int32 nIndexStart = rCID.indexOf( m_aDragMethodEquals );
604 if( nIndexStart != -1 )
606 nIndexStart = rCID.indexOf( '=', nIndexStart );
607 if( nIndexStart != -1 )
609 nIndexStart++;
610 sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
611 if( nNextSlash != -1 )
613 sal_Int32 nIndexEnd = nNextSlash;
614 sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
615 if( nNextColon < nNextSlash )
616 nIndexEnd = nNextColon;
617 aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
621 return aRet;
624 //static
625 OUString ObjectIdentifier::getDragParameterString( const OUString& rCID )
627 OUString aRet;
629 sal_Int32 nIndexStart = rCID.indexOf( m_aDragParameterEquals );
630 if( nIndexStart != -1 )
632 nIndexStart = rCID.indexOf( '=', nIndexStart );
633 if( nIndexStart != -1 )
635 nIndexStart++;
636 sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
637 if( nNextSlash != -1 )
639 sal_Int32 nIndexEnd = nNextSlash;
640 sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
641 if( nNextColon < nNextSlash )
642 nIndexEnd = nNextColon;
643 aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
647 return aRet;
650 //static
651 bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier )
653 ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier );
654 switch( eObjectType )
656 case OBJECTTYPE_TITLE:
657 case OBJECTTYPE_LEGEND:
658 case OBJECTTYPE_DIAGRAM:
659 case OBJECTTYPE_DATA_CURVE_EQUATION:
660 //case OBJECTTYPE_DIAGRAM_WALL:
661 return true;
662 default:
663 OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier ) );
664 if( aDragMethodServiceName.getLength() )
665 return true;
666 return false;
668 return false;
671 //static
672 bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier )
674 ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier );
675 switch( eObjectType )
677 case OBJECTTYPE_DIAGRAM:
678 //case OBJECTTYPE_DIAGRAM_WALL:
679 return true;
680 default:
681 return false;
683 return false;
686 //static
687 bool ObjectIdentifier::isMultiClickObject( const OUString& rClassifiedIdentifier )
689 //the name of a shape is it's ClassifiedIdentifier
691 //a MultiClickObject is an object that is selectable by more than one click only ;
692 //before a MultiClickObject can be selected it is necessary that a named parent group object
693 //was selected before;
695 //!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:"
696 bool bRet = false;
697 bRet = rClassifiedIdentifier.match( m_aMultiClick, m_aProtocol.getLength() );
698 return bRet;
701 bool ObjectIdentifier::areSiblings( const OUString& rCID1, const OUString& rCID2 )
703 bool bRet=false;
704 sal_Int32 nLastSign1 = rCID1.lastIndexOf( '=' );
705 sal_Int32 nLastSign2 = rCID2.lastIndexOf( '=' );
706 if( nLastSign1 == rCID1.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
707 bRet=false;
708 else if( nLastSign2 == rCID2.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
709 bRet=false;
710 else if( ObjectIdentifier::areIdenticalObjects( rCID1, rCID2 ) )
711 bRet=false;
712 else
714 OUString aParent1( ObjectIdentifier::getFullParentParticle( rCID1 ) );
715 if( aParent1.getLength() )
717 OUString aParent2( ObjectIdentifier::getFullParentParticle( rCID2 ) );
718 bRet=aParent1.equals(aParent2);
720 //legend entries are special:
721 if(!bRet)
723 if( OBJECTTYPE_LEGEND_ENTRY == getObjectType(rCID1)
724 && OBJECTTYPE_LEGEND_ENTRY == getObjectType(rCID2) )
725 bRet = true;
728 return bRet;
731 bool ObjectIdentifier::areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 )
733 if( rCID1.equals( rCID2 ) )
734 return true;
735 //draggable pie or donut segments need special treatment, as their CIDs do change with offset
737 if( rCID1.indexOf( m_aPieSegmentDragMethodServiceName ) < 0
738 || rCID2.indexOf( m_aPieSegmentDragMethodServiceName ) < 0 )
739 return false;
741 OUString aID1( ObjectIdentifier::getObjectID( rCID1 ) );
742 OUString aID2( ObjectIdentifier::getObjectID( rCID2 ) );
743 if( aID1.getLength() && aID1.equals( aID2 ) )
744 return true;
746 return false;
749 //static
750 OUString ObjectIdentifier::getStringForType( ObjectType eObjectType )
752 OUString aRet;
753 switch( eObjectType )
755 case OBJECTTYPE_PAGE:
756 aRet=C2U("Page");
757 break;
758 case OBJECTTYPE_TITLE:
759 aRet=C2U("Title");
760 break;
761 case OBJECTTYPE_LEGEND:
762 aRet=C2U("Legend");
763 break;
764 case OBJECTTYPE_LEGEND_ENTRY:
765 aRet=C2U("LegendEntry");
766 break;
767 case OBJECTTYPE_DIAGRAM:
768 aRet=C2U("D");
769 break;
770 case OBJECTTYPE_DIAGRAM_WALL:
771 aRet=C2U("DiagramWall");
772 break;
773 case OBJECTTYPE_DIAGRAM_FLOOR:
774 aRet=C2U("DiagramFloor");
775 break;
776 case OBJECTTYPE_AXIS:
777 aRet=C2U("Axis");
778 break;
779 case OBJECTTYPE_AXIS_UNITLABEL:
780 aRet=C2U("AxisUnitLabel");
781 break;
782 case OBJECTTYPE_GRID:
783 aRet=C2U("Grid");
784 break;
785 case OBJECTTYPE_SUBGRID:
786 aRet=C2U("SubGrid");
787 break;
788 case OBJECTTYPE_DATA_SERIES:
789 aRet=C2U("Series");
790 break;
791 case OBJECTTYPE_DATA_POINT:
792 aRet=C2U("Point");
793 break;
794 case OBJECTTYPE_DATA_LABELS:
795 aRet=C2U("DataLabels");
796 break;
797 case OBJECTTYPE_DATA_LABEL:
798 aRet=C2U("DataLabel");
799 break;
800 case OBJECTTYPE_DATA_ERRORS:
801 aRet=C2U("Errors");
802 break;
803 case OBJECTTYPE_DATA_ERRORS_X:
804 aRet=C2U("ErrorsX");
805 break;
806 case OBJECTTYPE_DATA_ERRORS_Y:
807 aRet=C2U("ErrorsY");
808 break;
809 case OBJECTTYPE_DATA_ERRORS_Z:
810 aRet=C2U("ErrorsZ");
811 break;
812 case OBJECTTYPE_DATA_CURVE:
813 aRet=C2U("Curve");
814 break;
815 case OBJECTTYPE_DATA_CURVE_EQUATION:
816 aRet=C2U("Equation");
817 break;
818 case OBJECTTYPE_DATA_AVERAGE_LINE:
819 aRet=C2U("Average");
820 break;
821 case OBJECTTYPE_DATA_STOCK_RANGE:
822 aRet=C2U("StockRange");
823 break;
824 case OBJECTTYPE_DATA_STOCK_LOSS:
825 aRet=C2U("StockLoss");
826 break;
827 case OBJECTTYPE_DATA_STOCK_GAIN:
828 aRet=C2U("StockGain");
829 break;
830 default: //OBJECTTYPE_UNKNOWN
833 return aRet;
836 //static
837 ObjectType ObjectIdentifier::getObjectType( const OUString& rCID )
839 ObjectType eRet;
840 sal_Int32 nLastSign = rCID.lastIndexOf( ':' );//last sign before the type string
841 if(nLastSign==-1)
842 nLastSign = rCID.lastIndexOf( '/' );
843 if(nLastSign==-1)
845 sal_Int32 nEndIndex = rCID.lastIndexOf( '=' );
846 if(nEndIndex==-1)
847 return OBJECTTYPE_UNKNOWN;
848 nLastSign = 0;
850 if( nLastSign>0 )
851 nLastSign++;
853 if( rCID.match(C2U("Page"),nLastSign) )
854 eRet = OBJECTTYPE_PAGE;
855 else if( rCID.match(C2U("Title"),nLastSign) )
856 eRet = OBJECTTYPE_TITLE;
857 else if( rCID.match(C2U("LegendEntry"),nLastSign) )
858 eRet = OBJECTTYPE_LEGEND_ENTRY;
859 else if( rCID.match(C2U("Legend"),nLastSign) )
860 eRet = OBJECTTYPE_LEGEND;
861 else if( rCID.match(C2U("DiagramWall"),nLastSign) )
862 eRet = OBJECTTYPE_DIAGRAM_WALL;
863 else if( rCID.match(C2U("DiagramFloor"),nLastSign) )
864 eRet = OBJECTTYPE_DIAGRAM_FLOOR;
865 else if( rCID.match(C2U("D="),nLastSign) )
866 eRet = OBJECTTYPE_DIAGRAM;
867 else if( rCID.match(C2U("AxisUnitLabel"),nLastSign) )
868 eRet = OBJECTTYPE_AXIS_UNITLABEL;
869 else if( rCID.match(C2U("Axis"),nLastSign) )
870 eRet = OBJECTTYPE_AXIS;
871 else if( rCID.match(C2U("Grid"),nLastSign) )
872 eRet = OBJECTTYPE_GRID;
873 else if( rCID.match(C2U("SubGrid"),nLastSign) )
874 eRet = OBJECTTYPE_SUBGRID;
875 else if( rCID.match(C2U("Series"),nLastSign) )
876 eRet = OBJECTTYPE_DATA_SERIES;
877 else if( rCID.match(C2U("Point"),nLastSign) )
878 eRet = OBJECTTYPE_DATA_POINT;
879 else if( rCID.match(C2U("DataLabels"),nLastSign) )
880 eRet = OBJECTTYPE_DATA_LABELS;
881 else if( rCID.match(C2U("DataLabel"),nLastSign) )
882 eRet = OBJECTTYPE_DATA_LABEL;
883 else if( rCID.match(C2U("ErrorsX"),nLastSign) )
884 eRet = OBJECTTYPE_DATA_ERRORS_X;
885 else if( rCID.match(C2U("ErrorsY"),nLastSign) )
886 eRet = OBJECTTYPE_DATA_ERRORS_Y;
887 else if( rCID.match(C2U("ErrorsZ"),nLastSign) )
888 eRet = OBJECTTYPE_DATA_ERRORS_Z;
889 else if( rCID.match(C2U("Errors"),nLastSign) )
890 eRet = OBJECTTYPE_DATA_ERRORS;
891 else if( rCID.match(C2U("Curve"),nLastSign) )
892 eRet = OBJECTTYPE_DATA_CURVE;
893 else if( rCID.match(C2U("Equation"),nLastSign) )
894 eRet = OBJECTTYPE_DATA_CURVE_EQUATION;
895 else if( rCID.match(C2U("Average"),nLastSign) )
896 eRet = OBJECTTYPE_DATA_AVERAGE_LINE;
897 else if( rCID.match(C2U("StockRange"),nLastSign) )
898 eRet = OBJECTTYPE_DATA_STOCK_RANGE;
899 else if( rCID.match(C2U("StockLoss"),nLastSign) )
900 eRet = OBJECTTYPE_DATA_STOCK_LOSS;
901 else if( rCID.match(C2U("StockGain"),nLastSign) )
902 eRet = OBJECTTYPE_DATA_STOCK_GAIN;
903 else
904 eRet = OBJECTTYPE_UNKNOWN;
906 return eRet;
909 //static
910 OUString ObjectIdentifier::createDataCurveCID(
911 const OUString& rSeriesParticle
912 , sal_Int32 nCurveIndex
913 , bool bAverageLine )
915 OUString aParticleID( OUString::valueOf( nCurveIndex ) );
916 ObjectType eType = bAverageLine ? OBJECTTYPE_DATA_AVERAGE_LINE : OBJECTTYPE_DATA_CURVE;
917 return createClassifiedIdentifierWithParent( eType, aParticleID, rSeriesParticle );
920 //static
921 OUString ObjectIdentifier::createDataCurveEquationCID(
922 const OUString& rSeriesParticle
923 , sal_Int32 nCurveIndex )
925 OUString aParticleID( OUString::valueOf( nCurveIndex ) );
926 return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION, aParticleID, rSeriesParticle );
929 //static
930 OUString ObjectIdentifier::addChildParticle( const rtl::OUString& rParticle, const rtl::OUString& rChildParticle )
932 OUStringBuffer aRet(rParticle);
934 if( aRet.getLength() && rChildParticle.getLength() )
935 aRet.appendAscii(":");
936 if( rChildParticle.getLength() )
937 aRet.append(rChildParticle);
939 return aRet.makeStringAndClear();
942 //static
943 rtl::OUString ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex )
945 OUStringBuffer aRet( getStringForType( eObjectType ) );
946 if( aRet.getLength() )
948 aRet.appendAscii("=");
949 aRet.append(OUString::valueOf(nIndex));
951 return aRet.makeStringAndClear();
954 //static
955 sal_Int32 ObjectIdentifier::getIndexFromParticleOrCID( const rtl::OUString& rParticleOrCID )
957 sal_Int32 nRet = -1;
959 OUString aIndexString = lcl_getIndexStringAfterString( rParticleOrCID, C2U("=") );
960 sal_Int32 nCharacterIndex=0;
961 nRet = lcl_StringToIndex( aIndexString.getToken( 0, ',', nCharacterIndex ) );
963 return nRet;
966 //static
967 OUString ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
968 , const rtl::OUString& rSeriesParticle
969 , const rtl::OUString& rDragMethodServiceName
970 , const rtl::OUString& rDragParameterString )
972 OUString aChildParticle( getStringForType( eSubObjectType ) );
973 aChildParticle+=(C2U("="));
975 return createClassifiedIdentifierForParticles(
976 rSeriesParticle, aChildParticle
977 , rDragMethodServiceName, rDragParameterString );
980 //static
981 OUString ObjectIdentifier::createPointCID( const OUString& rPointCID_Stub, sal_Int32 nIndex )
983 OUString aRet(rPointCID_Stub);
984 return aRet+=OUString::valueOf( nIndex );
987 //static
988 OUString ObjectIdentifier::getParticleID( const OUString& rCID )
990 OUString aRet;
991 sal_Int32 nLast = rCID.lastIndexOf('=');
992 if(nLast>=0)
993 aRet = rCID.copy(++nLast);
994 return aRet;
997 //static
998 OUString ObjectIdentifier::getFullParentParticle( const OUString& rCID )
1000 OUString aRet;
1002 sal_Int32 nStartPos = rCID.lastIndexOf('/');
1003 if( nStartPos>=0 )
1005 nStartPos++;
1006 sal_Int32 nEndPos = rCID.lastIndexOf(':');
1007 if( nEndPos>=0 && nStartPos < nEndPos )
1009 aRet = rCID.copy(nStartPos,nEndPos-nStartPos);
1013 return aRet;
1016 //static
1017 OUString ObjectIdentifier::getObjectID( const rtl::OUString& rCID )
1019 OUString aRet;
1021 sal_Int32 nStartPos = rCID.lastIndexOf('/');
1022 if( nStartPos>=0 )
1024 nStartPos++;
1025 sal_Int32 nEndPos = rCID.getLength();
1026 aRet = rCID.copy(nStartPos,nEndPos-nStartPos);
1029 return aRet;
1032 //static
1033 bool ObjectIdentifier::isCID( const OUString& rName )
1035 return rName.getLength() && rName.match( m_aProtocol );
1038 Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
1039 const OUString& rObjectCID,
1040 const Reference< chart2::XChartDocument >& xChartDocument )
1042 return ObjectIdentifier::getObjectPropertySet(
1043 rObjectCID, Reference< frame::XModel >( xChartDocument, uno::UNO_QUERY ));
1046 //static
1047 Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
1048 const OUString& rObjectCID
1049 , const Reference< frame::XModel >& xChartModel )
1051 //return the model object that is indicated by rObjectCID
1052 if(!rObjectCID.getLength())
1053 return NULL;
1054 if(!xChartModel.is())
1055 return NULL;
1057 Reference< beans::XPropertySet > xObjectProperties = NULL;
1060 ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID );
1061 OUString aParticleID = ObjectIdentifier::getParticleID( rObjectCID );
1063 Reference< XDiagram > xDiagram;
1064 Reference< XCoordinateSystem > xCooSys;
1065 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1067 switch(eObjectType)
1069 case OBJECTTYPE_PAGE:
1071 Reference< XChartDocument > xChartDocument( xChartModel, uno::UNO_QUERY );
1072 if( xChartDocument.is())
1073 xObjectProperties.set( xChartDocument->getPageBackground() );
1075 break;
1076 case OBJECTTYPE_TITLE:
1078 TitleHelper::eTitleType aTitleType = getTitleTypeForCID( rObjectCID );
1079 Reference< XTitle > xTitle( TitleHelper::getTitle( aTitleType, xChartModel ) );
1080 xObjectProperties.set( xTitle, uno::UNO_QUERY );
1082 break;
1083 case OBJECTTYPE_LEGEND:
1085 if( xDiagram.is() )
1086 xObjectProperties.set( xDiagram->getLegend(), uno::UNO_QUERY );
1088 break;
1089 case OBJECTTYPE_LEGEND_ENTRY:
1090 break;
1091 case OBJECTTYPE_DIAGRAM:
1093 xObjectProperties.set( xDiagram, uno::UNO_QUERY );
1095 break;
1096 case OBJECTTYPE_DIAGRAM_WALL:
1098 if( xDiagram.is() )
1099 xObjectProperties.set( xDiagram->getWall() );
1101 break;
1102 case OBJECTTYPE_DIAGRAM_FLOOR:
1104 if( xDiagram.is() )
1105 xObjectProperties.set( xDiagram->getFloor() );
1107 break;
1108 case OBJECTTYPE_AXIS:
1110 sal_Int32 nDimensionIndex = -1;
1111 sal_Int32 nAxisIndex = -1;
1112 lcl_parseAxisIndices( nDimensionIndex, nAxisIndex, rObjectCID );
1114 Reference< chart2::XAxis > xAxis(
1115 AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys ) );
1116 if( xAxis.is() )
1117 xObjectProperties.set( xAxis, uno::UNO_QUERY );
1119 break;
1120 case OBJECTTYPE_AXIS_UNITLABEL:
1121 break;
1122 case OBJECTTYPE_GRID:
1123 case OBJECTTYPE_SUBGRID:
1125 sal_Int32 nDimensionIndex = -1;
1126 sal_Int32 nAxisIndex = -1;
1127 lcl_parseAxisIndices( nDimensionIndex, nAxisIndex, rObjectCID );
1129 sal_Int32 nSubGridIndex = -1;
1130 lcl_parseGridIndices( nSubGridIndex, rObjectCID );
1132 xObjectProperties.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, nAxisIndex, nSubGridIndex ) );
1134 break;
1135 case OBJECTTYPE_DATA_LABELS:
1136 case OBJECTTYPE_DATA_SERIES:
1138 Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
1139 rObjectCID, xChartModel ) );
1140 if( xSeries.is() )
1141 xObjectProperties = Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY );
1143 break;
1145 case OBJECTTYPE_DATA_LABEL:
1146 case OBJECTTYPE_DATA_POINT:
1148 Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
1149 rObjectCID, xChartModel ) );
1150 if(xSeries.is())
1152 sal_Int32 nIndex = aParticleID.toInt32();
1153 xObjectProperties = xSeries->getDataPointByIndex( nIndex );
1155 break;
1157 case OBJECTTYPE_DATA_ERRORS:
1159 Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
1160 rObjectCID, xChartModel ) );
1161 if(xSeries.is())
1163 Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
1164 Reference< beans::XPropertySet > xErrorBarProp;
1165 if( xSeriesProp.is() )
1167 xSeriesProp->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProp;
1168 xObjectProperties = Reference< beans::XPropertySet >( xErrorBarProp, uno::UNO_QUERY );
1171 break;
1173 case OBJECTTYPE_DATA_ERRORS_X:
1174 break;
1175 case OBJECTTYPE_DATA_ERRORS_Y:
1176 break;
1177 case OBJECTTYPE_DATA_ERRORS_Z:
1178 break;
1179 case OBJECTTYPE_DATA_AVERAGE_LINE:
1180 case OBJECTTYPE_DATA_CURVE:
1181 case OBJECTTYPE_DATA_CURVE_EQUATION:
1183 Reference< XRegressionCurveContainer > xRegressionContainer( ObjectIdentifier::getDataSeriesForCID(
1184 rObjectCID, xChartModel ), uno::UNO_QUERY );
1185 if(xRegressionContainer.is())
1187 sal_Int32 nIndex = aParticleID.toInt32();
1188 uno::Sequence< Reference< XRegressionCurve > > aCurveList =
1189 xRegressionContainer->getRegressionCurves();
1190 if( nIndex >= 0 && nIndex <aCurveList.getLength() )
1192 if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION )
1193 xObjectProperties.set( aCurveList[nIndex]->getEquationProperties());
1194 else
1195 xObjectProperties.set( aCurveList[nIndex], uno::UNO_QUERY );
1198 break;
1200 case OBJECTTYPE_DATA_STOCK_RANGE:
1201 break;
1202 case OBJECTTYPE_DATA_STOCK_LOSS:
1204 Reference<XChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
1205 Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY );
1206 if(xChartTypeProps.is())
1207 xChartTypeProps->getPropertyValue( C2U( "BlackDay" ) ) >>= xObjectProperties;
1209 break;
1210 case OBJECTTYPE_DATA_STOCK_GAIN:
1212 Reference<XChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
1213 Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY );
1214 if(xChartTypeProps.is())
1215 xChartTypeProps->getPropertyValue( C2U( "WhiteDay" ) ) >>= xObjectProperties;
1217 break;
1218 default: //OBJECTTYPE_UNKNOWN
1219 break;
1222 catch( uno::Exception& ex)
1224 ASSERT_EXCEPTION( ex );
1226 return xObjectProperties;
1229 //static
1230 Reference< XAxis > ObjectIdentifier::getAxisForCID(
1231 const OUString& rObjectCID
1232 , const Reference< frame::XModel >& xChartModel )
1234 Reference< XDiagram > xDiagram;
1235 Reference< XCoordinateSystem > xCooSys;
1236 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1238 sal_Int32 nDimensionIndex = -1;
1239 sal_Int32 nAxisIndex = -1;
1240 lcl_parseAxisIndices( nDimensionIndex, nAxisIndex, rObjectCID );
1242 return AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys );
1245 //static
1246 Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID(
1247 const OUString& rObjectCID
1248 , const Reference< frame::XModel >& xChartModel )
1250 Reference< XDataSeries > xSeries(NULL);
1252 Reference< XDiagram > xDiagram;
1253 Reference< XCoordinateSystem > xCooSys;
1254 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1256 sal_Int32 nChartTypeIndex = -1;
1257 sal_Int32 nSeriesIndex = -1;
1258 sal_Int32 nPointIndex = -1;
1259 lcl_parseSeriesIndices( nChartTypeIndex, nSeriesIndex, nPointIndex, rObjectCID );
1261 Reference< XDataSeriesContainer > xDataSeriesContainer( DiagramHelper::getChartTypeByIndex( xDiagram, nChartTypeIndex ), uno::UNO_QUERY );
1262 if( xDataSeriesContainer.is() )
1264 uno::Sequence< uno::Reference< XDataSeries > > aDataSeriesSeq( xDataSeriesContainer->getDataSeries() );
1265 if( nSeriesIndex >= 0 && nSeriesIndex < aDataSeriesSeq.getLength() )
1266 xSeries.set( aDataSeriesSeq[nSeriesIndex] );
1269 return xSeries;
1272 //static
1273 Reference< XDiagram > ObjectIdentifier::getDiagramForCID(
1274 const rtl::OUString& rObjectCID
1275 , const uno::Reference< frame::XModel >& xChartModel )
1277 Reference< XDiagram > xDiagram;
1279 Reference< XCoordinateSystem > xCooSys;
1280 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1282 return xDiagram;
1285 TitleHelper::eTitleType ObjectIdentifier::getTitleTypeForCID( const OUString& rCID )
1287 TitleHelper::eTitleType eRet( TitleHelper::MAIN_TITLE );
1289 OUString aParentParticle = ObjectIdentifier::getFullParentParticle( rCID );
1290 const tTitleMap& rMap = lcl_getTitleMap();
1291 tTitleMap::const_iterator aIt( rMap.begin() );
1292 for( ;aIt != rMap.end(); ++aIt )
1294 if( aParentParticle.equals( (*aIt).second ) )
1296 eRet = (*aIt).first;
1297 break;
1301 return eRet;
1304 // static
1305 OUString ObjectIdentifier::getSeriesParticleFromCID( const OUString& rCID )
1307 sal_Int32 nDiagramIndex = -1;
1308 sal_Int32 nCooSysIndex = -1;
1309 lcl_parseCooSysIndices( nDiagramIndex, nCooSysIndex, rCID );
1311 sal_Int32 nChartTypeIndex = -1;
1312 sal_Int32 nSeriesIndex = -1;
1313 sal_Int32 nPointIndex = -1;
1314 lcl_parseSeriesIndices( nChartTypeIndex, nSeriesIndex, nPointIndex, rCID );
1316 return ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex );
1319 //static
1320 OUString ObjectIdentifier::getMovedSeriesCID( const ::rtl::OUString& rObjectCID, sal_Bool bForward )
1322 sal_Int32 nDiagramIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("CID/D=") ) );
1323 sal_Int32 nCooSysIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("CS=") ) );
1324 sal_Int32 nChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("CT=") ) );
1325 sal_Int32 nSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("Series=") ) );
1327 if( bForward )
1328 nSeriesIndex--;
1329 else
1330 nSeriesIndex++;
1332 OUString aRet = ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex );
1333 return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet );
1335 //static
1336 //.............................................................................
1337 } //namespace chart
1338 //.............................................................................