merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / tools / ObjectIdentifier.cxx
blob0599f9317aedfc1d569235b95638c3c1d7cc04f7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "ObjectIdentifier.hxx"
32 #include "macros.hxx"
33 #include "TitleHelper.hxx"
34 #include "ChartModelHelper.hxx"
35 #include "AxisHelper.hxx"
36 #include "servicenames_charttypes.hxx"
37 #include "DiagramHelper.hxx"
38 #include "AxisIndexDefines.hxx"
39 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
40 #include <com/sun/star/chart2/XChartDocument.hpp>
41 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
42 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
43 #include <com/sun/star/chart2/XAxis.hpp>
44 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
46 // header for define DBG_ASSERT
47 #include <tools/debug.hxx>
48 #include <comphelper/InlineContainer.hxx>
50 #include <rtl/ustrbuf.hxx>
52 //.............................................................................
53 namespace chart
55 //.............................................................................
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::chart2;
59 using rtl::OUString;
60 using rtl::OUStringBuffer;
61 using ::com::sun::star::uno::Reference;
62 using ::com::sun::star::uno::Any;
64 static OUString m_aMultiClick( C2U("MultiClick") );
65 static OUString m_aDragMethodEquals( C2U("DragMethod=") );
66 static OUString m_aDragParameterEquals( C2U("DragParameter=") );
67 static OUString m_aProtocol( C2U("CID/") );
68 static OUString m_aEmptyString;
69 static OUString m_aPieSegmentDragMethodServiceName( C2U("PieSegmentDraging") );
71 namespace
74 OUString lcl_createClassificationStringForType( ObjectType eObjectType
75 , const OUString& rDragMethodServiceName
76 , const OUString& rDragParameterString
79 OUStringBuffer aRet;
80 switch( eObjectType )
82 //these object types are all selected only after their parents was selected before
83 case OBJECTTYPE_LEGEND_ENTRY: //parent is intended to be OBJECTTYPE_LEGEND
84 case OBJECTTYPE_DATA_POINT: //parent is intended to be OBJECTTYPE_DATA_SERIES
85 case OBJECTTYPE_DATA_LABEL: //parent is intended to be OBJECTTYPE_DATA_LABELS
86 case OBJECTTYPE_DATA_ERRORS_X: //parent is intended to be OBJECTTYPE_DATA_ERRORS
87 case OBJECTTYPE_DATA_ERRORS_Y: //parent is intended to be OBJECTTYPE_DATA_ERRORS
88 case OBJECTTYPE_DATA_ERRORS_Z: //parent is intended to be OBJECTTYPE_DATA_ERRORS
89 aRet=m_aMultiClick;
90 default:
91 ;//empty string
93 if( rDragMethodServiceName.getLength() )
95 if( aRet.getLength() )
96 aRet.appendAscii(":");
97 aRet.append( m_aDragMethodEquals );
98 aRet.append( rDragMethodServiceName );
100 if( rDragParameterString.getLength() )
102 if( aRet.getLength() )
103 aRet.appendAscii(":");
104 aRet.append( m_aDragParameterEquals );
105 aRet.append( rDragParameterString );
108 return aRet.makeStringAndClear();
111 typedef ::comphelper::MakeMap< TitleHelper::eTitleType, OUString > tTitleMap;
112 const tTitleMap& lcl_getTitleMap()
114 //maps the title type to the ParentParticle for that title
115 static tTitleMap m_aTitleMap = tTitleMap
116 ( TitleHelper::MAIN_TITLE, C2U("") )
117 ( TitleHelper::SUB_TITLE, C2U("D=0") )
118 ( TitleHelper::X_AXIS_TITLE, C2U("D=0:CS=0:Axis=0,0") )
119 ( TitleHelper::Y_AXIS_TITLE, C2U("D=0:CS=0:Axis=1,0") )
120 ( TitleHelper::Z_AXIS_TITLE, C2U("D=0:CS=0:Axis=2,0") )
121 ( TitleHelper::SECONDARY_X_AXIS_TITLE, C2U("D=0:CS=0:Axis=0,1") )
122 ( TitleHelper::SECONDARY_Y_AXIS_TITLE, C2U("D=0:CS=0:Axis=1,1") )
124 return m_aTitleMap;
127 OUString lcl_getTitleParentParticle( TitleHelper::eTitleType aTitleType )
129 OUString aRet;
131 const tTitleMap& rMap = lcl_getTitleMap();
132 tTitleMap::const_iterator aIt( rMap.find( aTitleType ) );
133 if( aIt != rMap.end())
134 aRet = (*aIt).second;
136 return aRet;
139 Reference<XChartType> lcl_getFirstStockChartType( const Reference< frame::XModel >& xChartModel )
141 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
142 if(!xDiagram.is())
143 return 0;
145 //iterate through all coordinate systems
146 Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
147 if( !xCooSysContainer.is())
148 return 0;
150 uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
151 for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
153 //iterate through all chart types in the current coordinate system
154 Reference< XChartTypeContainer > xChartTypeContainer( aCooSysList[nCS], uno::UNO_QUERY );
155 if( !xChartTypeContainer.is() )
156 continue;
158 uno::Sequence< Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
159 for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
161 Reference< XChartType > xChartType( aChartTypeList[nT] );
162 if(!xChartType.is())
163 continue;
164 OUString aChartType = xChartType->getChartType();
165 if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
166 return xChartType;
169 return 0;
172 OUString lcl_getIndexStringAfterString( const OUString& rString, const OUString& rSearchString )
174 OUStringBuffer aRet;
176 sal_Int32 nIndexStart = rString.lastIndexOf( rSearchString );
177 if( nIndexStart != -1 )
179 nIndexStart += rSearchString.getLength();
180 sal_Int32 nIndexEnd = rString.getLength();
181 sal_Int32 nNextColon = rString.indexOf( ':', nIndexStart );
182 if( nNextColon != -1 )
183 nIndexEnd = nNextColon;
184 aRet = rString.copy(nIndexStart,nIndexEnd-nIndexStart);
187 return aRet.makeStringAndClear();
190 sal_Int32 lcl_StringToIndex( const OUString& rIndexString )
192 sal_Int32 nRet = -1;
193 if( rIndexString.getLength() )
195 nRet = rIndexString.toInt32();
196 if( nRet < -1 )
197 nRet = -1;
199 return nRet;
202 void lcl_parseCooSysIndices( sal_Int32& rnDiagram, sal_Int32& rnCooSys, const OUString& rString )
204 rnDiagram = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("D=") ) );
205 rnCooSys = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("CS=") ) );
208 void lcl_parseAxisIndices( sal_Int32& rnDimensionIndex, sal_Int32& rnAxisIndex, const OUString& rString )
210 OUString aAxisIndexString = lcl_getIndexStringAfterString( rString, C2U(":Axis=") );
211 sal_Int32 nCharacterIndex=0;
212 rnDimensionIndex = lcl_StringToIndex( aAxisIndexString.getToken( 0, ',', nCharacterIndex ) );
213 rnAxisIndex = lcl_StringToIndex( aAxisIndexString.getToken( 0, ',', nCharacterIndex ) );
216 void lcl_parseGridIndices( sal_Int32& rnSubGridIndex, const OUString& rString )
218 rnSubGridIndex = -1;
219 rnSubGridIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U(":SubGrid=") ) );
222 void lcl_parseSeriesIndices( sal_Int32& rnChartTypeIndex, sal_Int32& rnSeriesIndex, sal_Int32& rnPointIndex, const OUString& rString )
224 rnChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("CT=") ) );
225 rnSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("Series=") ) );
226 rnPointIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rString, C2U("Point=") ) );
229 void lcl_getDiagramAndCooSys( const OUString& rObjectCID
230 , const Reference< frame::XModel >& xChartModel
231 , Reference< XDiagram >& xDiagram
232 , Reference< XCoordinateSystem >& xCooSys )
234 sal_Int32 nDiagramIndex = -1;
235 sal_Int32 nCooSysIndex = -1;
236 lcl_parseCooSysIndices( nDiagramIndex, nCooSysIndex, rObjectCID );
237 xDiagram = ChartModelHelper::findDiagram( xChartModel );//todo use nDiagramIndex when more than one diagram is possible in future
238 if( !xDiagram.is() )
239 return;
241 if( nCooSysIndex > -1 )
243 Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
244 if( xCooSysContainer.is() )
246 uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
247 if( nCooSysIndex < aCooSysList.getLength() )
248 xCooSys = aCooSysList[nCooSysIndex];
253 } //anonymous namespace
255 ObjectIdentifier::ObjectIdentifier()
256 :m_aObjectCID( OUString() )
257 ,m_xAdditionalShape( 0 )
261 ObjectIdentifier::ObjectIdentifier( const OUString& rObjectCID )
262 :m_aObjectCID( rObjectCID )
263 ,m_xAdditionalShape( 0 )
267 ObjectIdentifier::ObjectIdentifier( const Reference< drawing::XShape >& rxShape )
268 :m_aObjectCID( OUString() )
269 ,m_xAdditionalShape( rxShape )
273 ObjectIdentifier::ObjectIdentifier( const Any& rAny )
274 :m_aObjectCID( OUString() )
275 ,m_xAdditionalShape( 0 )
277 const uno::Type& rType = rAny.getValueType();
278 if ( rType == ::getCppuType( static_cast< const OUString* >( 0 ) ) )
280 rAny >>= m_aObjectCID;
282 else if ( rType == ::getCppuType( static_cast< const Reference< drawing::XShape >* >( 0 ) ) )
284 rAny >>= m_xAdditionalShape;
288 ObjectIdentifier::~ObjectIdentifier()
292 ObjectIdentifier::ObjectIdentifier( const ObjectIdentifier& rOID )
293 :m_aObjectCID( rOID.m_aObjectCID )
294 ,m_xAdditionalShape( rOID.m_xAdditionalShape )
299 ObjectIdentifier& ObjectIdentifier::operator=( const ObjectIdentifier& rOID )
301 m_aObjectCID = rOID.m_aObjectCID;
302 m_xAdditionalShape = rOID.m_xAdditionalShape;
303 return *this;
306 bool ObjectIdentifier::operator==( const ObjectIdentifier& rOID ) const
308 if ( areIdenticalObjects( m_aObjectCID, rOID.m_aObjectCID ) &&
309 ( m_xAdditionalShape == rOID.m_xAdditionalShape ) )
311 return true;
313 return false;
316 bool ObjectIdentifier::operator!=( const ObjectIdentifier& rOID ) const
318 return !operator==( rOID );
321 bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const
323 bool bReturn = false;
324 if ( m_aObjectCID.getLength() && rOID.m_aObjectCID.getLength() )
326 bReturn = ( m_aObjectCID.compareTo( rOID.m_aObjectCID ) < 0 );
328 else if ( m_aObjectCID.getLength() )
330 bReturn = true;
332 else if ( rOID.m_aObjectCID.getLength() )
334 bReturn = false;
336 else if ( m_xAdditionalShape.is() && rOID.m_xAdditionalShape.is() )
338 bReturn = ( m_xAdditionalShape < rOID.m_xAdditionalShape );
340 return bReturn;
343 //static
344 OUString ObjectIdentifier::createClassifiedIdentifierForObject(
345 const Reference< uno::XInterface >& xObject
346 , const Reference< frame::XModel >& xChartModel )
348 OUString aRet;
350 enum ObjectType eObjectType = OBJECTTYPE_UNKNOWN;
351 OUString aObjectID;
352 OUString aParentParticle;
353 OUString aDragMethodServiceName;
354 OUString aDragParameterString;
359 //title
360 Reference< XTitle > xTitle( xObject, uno::UNO_QUERY );
361 if( xTitle.is() )
363 TitleHelper::eTitleType aTitleType;
364 if( TitleHelper::getTitleType( aTitleType, xTitle, xChartModel ) )
366 eObjectType = OBJECTTYPE_TITLE;
367 aParentParticle = lcl_getTitleParentParticle( aTitleType );
368 aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
369 eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
371 return aRet;
375 //axis
376 Reference< XAxis > xAxis( xObject, uno::UNO_QUERY );
377 if( xAxis.is() )
379 Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ) ) );
380 rtl::OUString aCooSysParticle( createParticleForCoordinateSystem( xCooSys, xChartModel ) );
381 sal_Int32 nDimensionIndex=-1;
382 sal_Int32 nAxisIndex=-1;
383 AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex );
384 rtl::OUString aAxisParticle( createParticleForAxis( nDimensionIndex, nAxisIndex ) );
385 return createClassifiedIdentifierForParticles( aCooSysParticle, aAxisParticle );
388 //legend
389 Reference< XLegend > xLegend( xObject, uno::UNO_QUERY );
390 if( xLegend.is() )
392 return createClassifiedIdentifierForParticle( createParticleForLegend( xLegend, xChartModel ) );
395 //diagram
396 Reference< XDiagram > xDiagram( xObject, uno::UNO_QUERY );
397 if( xDiagram.is() )
399 return createClassifiedIdentifierForParticle( createParticleForDiagram( xDiagram, xChartModel ) );
402 //todo
403 //XDataSeries
404 //CooSys
405 //charttype
406 //datapoint?
407 //Gridproperties
409 catch( uno::Exception& ex)
411 ASSERT_EXCEPTION( ex );
414 if( eObjectType != OBJECTTYPE_UNKNOWN )
416 aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
417 eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
419 else
421 DBG_ASSERT(false,"give object could not be identifed in createClassifiedIdentifierForObject");
424 return aRet;
427 //static
428 OUString ObjectIdentifier::createClassifiedIdentifierForParticle(
429 const OUString& rParticle )
431 return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle, OUString() );
434 //static
435 OUString ObjectIdentifier::createClassifiedIdentifierForParticles(
436 const OUString& rParentParticle
437 , const OUString& rChildParticle
438 , const OUString& rDragMethodServiceName
439 , const OUString& rDragParameterString )
441 ObjectType eObjectType( ObjectIdentifier::getObjectType( rChildParticle ) );
442 if( eObjectType == OBJECTTYPE_UNKNOWN )
443 eObjectType = ObjectIdentifier::getObjectType( rParentParticle );
445 OUStringBuffer aRet( m_aProtocol );
446 aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
447 if(aRet.getLength()>m_aProtocol.getLength())
448 aRet.appendAscii("/");
450 if(rParentParticle.getLength())
452 aRet.append(rParentParticle);
453 if( rChildParticle.getLength() )
454 aRet.appendAscii(":");
456 aRet.append(rChildParticle);
458 return aRet.makeStringAndClear();
461 //static
462 OUString ObjectIdentifier::createParticleForDiagram(
463 const Reference< XDiagram >& /*xDiagram*/
464 , const Reference< frame::XModel >& /*xChartModel*/ )
466 static OUString aRet(C2U("D=0"));
467 //todo: if more than one diagram is implemeted, add the correct diagram index here
468 return aRet;
471 //static
472 OUString ObjectIdentifier::createParticleForCoordinateSystem(
473 const Reference< XCoordinateSystem >& xCooSys
474 , const Reference< frame::XModel >& xChartModel )
476 OUStringBuffer aRet;
478 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
479 Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
480 if( xCooSysContainer.is() )
482 sal_Int32 nCooSysIndex = 0;
483 uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
484 for( ; nCooSysIndex < aCooSysList.getLength(); ++nCooSysIndex )
486 Reference< XCoordinateSystem > xCurrentCooSys( aCooSysList[nCooSysIndex] );
487 if( xCooSys == xCurrentCooSys )
489 aRet = ObjectIdentifier::createParticleForDiagram( xDiagram, xChartModel );
490 aRet.appendAscii(":CS=");
491 aRet.append( OUString::valueOf( nCooSysIndex ) );
492 break;
497 return aRet.makeStringAndClear();
500 //static
501 OUString ObjectIdentifier::createParticleForAxis(
502 sal_Int32 nDimensionIndex
503 , sal_Int32 nAxisIndex )
505 OUStringBuffer aRet(C2U("Axis="));
507 aRet.append( OUString::valueOf( nDimensionIndex ) );
508 aRet.appendAscii(",");
509 aRet.append( OUString::valueOf( nAxisIndex ) );
511 return aRet.makeStringAndClear();
514 //static
515 OUString ObjectIdentifier::createParticleForGrid(
516 sal_Int32 nDimensionIndex
517 , sal_Int32 nAxisIndex )
519 OUStringBuffer aRet(C2U("Axis="));
520 aRet.append( OUString::valueOf( nDimensionIndex ) );
521 aRet.appendAscii(",");
522 aRet.append( OUString::valueOf( nAxisIndex ) );
523 aRet.append( C2U(":Grid=0") );
525 return aRet.makeStringAndClear();
528 //static
529 OUString ObjectIdentifier::createClassifiedIdentifierForGrid(
530 const Reference< XAxis >& xAxis
531 , const Reference< frame::XModel >& xChartModel
532 , sal_Int32 nSubGridIndex )
534 //-1: main grid, 0: first subgrid etc
536 rtl::OUString aAxisCID( createClassifiedIdentifierForObject( xAxis, xChartModel ) );
537 rtl::OUString aGridCID( addChildParticle( aAxisCID
538 , createChildParticleWithIndex( OBJECTTYPE_GRID, 0 ) ) );
539 if( nSubGridIndex >= 0 )
541 aGridCID = addChildParticle( aGridCID
542 , createChildParticleWithIndex( OBJECTTYPE_SUBGRID, 0 ) );
544 return aGridCID;
547 //static
548 OUString ObjectIdentifier::createParticleForSeries(
549 sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex
550 , sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex )
552 OUStringBuffer aRet;
554 aRet.appendAscii("D=");
555 aRet.append( OUString::valueOf( nDiagramIndex ) );
556 aRet.appendAscii(":CS=");
557 aRet.append( OUString::valueOf( nCooSysIndex ) );
558 aRet.appendAscii(":CT=");
559 aRet.append( OUString::valueOf( nChartTypeIndex ) );
560 aRet.appendAscii(":");
561 aRet.append(getStringForType( OBJECTTYPE_DATA_SERIES ));
562 aRet.appendAscii("=");
563 aRet.append( OUString::valueOf( nSeriesIndex ) );
565 return aRet.makeStringAndClear();
568 //static
569 OUString ObjectIdentifier::createParticleForLegend(
570 const Reference< XLegend >& /*xLegend*/
571 , const Reference< frame::XModel >& xChartModel )
573 OUStringBuffer aRet;
575 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
576 //todo: if more than one diagram is implemeted, find the correct diagram wich is owner of the given legend
578 aRet.append( ObjectIdentifier::createParticleForDiagram( xDiagram, xChartModel ) );
579 aRet.appendAscii(":");
580 aRet.append(getStringForType( OBJECTTYPE_LEGEND ));
581 aRet.appendAscii("=");
583 return aRet.makeStringAndClear();
586 //static
587 OUString ObjectIdentifier::createClassifiedIdentifier(
588 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES
589 , const OUString& rParticleID )//e.g. SeriesID
591 return createClassifiedIdentifierWithParent(
592 eObjectType, rParticleID, m_aEmptyString );
595 //static
596 OUString ObjectIdentifier::createClassifiedIdentifierWithParent(
597 enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
598 , const OUString& rParticleID //e.g. Point Index or SubGrid Index
599 , const OUString& rParentPartical //e.g. "Series=SeriesID" or "Grid=GridId"
600 , const OUString& rDragMethodServiceName
601 , const OUString& rDragParameterString
603 //, bool bIsMultiClickObject ) //e.g. true
605 //e.g. "MultiClick/Series=2:Point=34"
607 OUStringBuffer aRet( m_aProtocol );
608 aRet.append( lcl_createClassificationStringForType( eObjectType, rDragMethodServiceName, rDragParameterString ));
609 if(aRet.getLength()>m_aProtocol.getLength())
610 aRet.appendAscii("/");
611 aRet.append(rParentPartical);
612 if(rParentPartical.getLength())
613 aRet.appendAscii(":");
615 aRet.append(getStringForType( eObjectType ));
616 aRet.appendAscii("=");
617 aRet.append(rParticleID);
619 return aRet.makeStringAndClear();
622 //static
623 const OUString& ObjectIdentifier::getPieSegmentDragMethodServiceName()
625 return m_aPieSegmentDragMethodServiceName;
628 //static
629 OUString ObjectIdentifier::createPieSegmentDragParameterString(
630 sal_Int32 nOffsetPercent
631 , const awt::Point& rMinimumPosition
632 , const awt::Point& rMaximumPosition )
634 OUStringBuffer aRet( OUString::valueOf( nOffsetPercent ) );
635 aRet.append( sal_Unicode( ',' ));
636 aRet.append( OUString::valueOf( rMinimumPosition.X ) );
637 aRet.append( sal_Unicode( ',' ));
638 aRet.append( OUString::valueOf( rMinimumPosition.Y ) );
639 aRet.append( sal_Unicode( ',' ));
640 aRet.append( OUString::valueOf( rMaximumPosition.X ) );
641 aRet.append( sal_Unicode( ',' ));
642 aRet.append( OUString::valueOf( rMaximumPosition.Y ) );
643 return aRet.makeStringAndClear();
646 //static
647 bool ObjectIdentifier::parsePieSegmentDragParameterString(
648 const OUString& rDragParameterString
649 , sal_Int32& rOffsetPercent
650 , awt::Point& rMinimumPosition
651 , awt::Point& rMaximumPosition )
653 OUString aValue;
654 sal_Int32 nCharacterIndex = 0;
656 OUString aValueString( rDragParameterString.getToken( 0, ',', nCharacterIndex ) );
657 rOffsetPercent = aValueString.toInt32();
658 if( nCharacterIndex < 0 )
659 return false;
661 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
662 rMinimumPosition.X = aValueString.toInt32();
663 if( nCharacterIndex < 0 )
664 return false;
666 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
667 rMinimumPosition.Y = aValueString.toInt32();
668 if( nCharacterIndex < 0 )
669 return false;
671 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
672 rMaximumPosition.X = aValueString.toInt32();
673 if( nCharacterIndex < 0 )
674 return false;
676 aValueString = rDragParameterString.getToken( 0, ',', nCharacterIndex );
677 rMaximumPosition.Y = aValueString.toInt32();
678 if( nCharacterIndex < 0 )
679 return false;
681 return true;
684 //static
685 OUString ObjectIdentifier::getDragMethodServiceName( const OUString& rCID )
687 OUString aRet;
689 sal_Int32 nIndexStart = rCID.indexOf( m_aDragMethodEquals );
690 if( nIndexStart != -1 )
692 nIndexStart = rCID.indexOf( '=', nIndexStart );
693 if( nIndexStart != -1 )
695 nIndexStart++;
696 sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
697 if( nNextSlash != -1 )
699 sal_Int32 nIndexEnd = nNextSlash;
700 sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
701 if( nNextColon < nNextSlash )
702 nIndexEnd = nNextColon;
703 aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
707 return aRet;
710 //static
711 OUString ObjectIdentifier::getDragParameterString( const OUString& rCID )
713 OUString aRet;
715 sal_Int32 nIndexStart = rCID.indexOf( m_aDragParameterEquals );
716 if( nIndexStart != -1 )
718 nIndexStart = rCID.indexOf( '=', nIndexStart );
719 if( nIndexStart != -1 )
721 nIndexStart++;
722 sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
723 if( nNextSlash != -1 )
725 sal_Int32 nIndexEnd = nNextSlash;
726 sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
727 if( nNextColon < nNextSlash )
728 nIndexEnd = nNextColon;
729 aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
733 return aRet;
736 //static
737 bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier )
739 ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier );
740 switch( eObjectType )
742 case OBJECTTYPE_TITLE:
743 case OBJECTTYPE_LEGEND:
744 case OBJECTTYPE_DIAGRAM:
745 case OBJECTTYPE_DATA_CURVE_EQUATION:
746 //case OBJECTTYPE_DIAGRAM_WALL:
747 return true;
748 default:
749 OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier ) );
750 if( aDragMethodServiceName.getLength() )
751 return true;
752 return false;
754 return false;
757 bool ObjectIdentifier::isDragableObject()
759 bool bReturn = false;
760 if ( isAutoGeneratedObject() )
762 bReturn = isDragableObject( m_aObjectCID );
764 else if ( isAdditionalShape() )
766 bReturn = true;
768 return bReturn;
771 //static
772 bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier )
774 ObjectType eObjectType = ObjectIdentifier::getObjectType( rClassifiedIdentifier );
775 switch( eObjectType )
777 case OBJECTTYPE_DIAGRAM:
778 //case OBJECTTYPE_DIAGRAM_WALL:
779 return true;
780 default:
781 return false;
783 return false;
786 //static
787 bool ObjectIdentifier::isMultiClickObject( const OUString& rClassifiedIdentifier )
789 //the name of a shape is it's ClassifiedIdentifier
791 //a MultiClickObject is an object that is selectable by more than one click only ;
792 //before a MultiClickObject can be selected it is necessary that a named parent group object
793 //was selected before;
795 //!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:"
796 bool bRet = false;
797 bRet = rClassifiedIdentifier.match( m_aMultiClick, m_aProtocol.getLength() );
798 return bRet;
801 bool ObjectIdentifier::areSiblings( const OUString& rCID1, const OUString& rCID2 )
803 bool bRet=false;
804 sal_Int32 nLastSign1 = rCID1.lastIndexOf( '=' );
805 sal_Int32 nLastSign2 = rCID2.lastIndexOf( '=' );
806 if( nLastSign1 == rCID1.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
807 bRet=false;
808 else if( nLastSign2 == rCID2.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
809 bRet=false;
810 else if( ObjectIdentifier::areIdenticalObjects( rCID1, rCID2 ) )
811 bRet=false;
812 else
814 OUString aParent1( ObjectIdentifier::getFullParentParticle( rCID1 ) );
815 if( aParent1.getLength() )
817 OUString aParent2( ObjectIdentifier::getFullParentParticle( rCID2 ) );
818 bRet=aParent1.equals(aParent2);
820 //legend entries are special:
821 if(!bRet)
823 if( OBJECTTYPE_LEGEND_ENTRY == getObjectType(rCID1)
824 && OBJECTTYPE_LEGEND_ENTRY == getObjectType(rCID2) )
825 bRet = true;
828 return bRet;
831 bool ObjectIdentifier::areIdenticalObjects( const OUString& rCID1, const OUString& rCID2 )
833 if( rCID1.equals( rCID2 ) )
834 return true;
835 //draggable pie or donut segments need special treatment, as their CIDs do change with offset
837 if( rCID1.indexOf( m_aPieSegmentDragMethodServiceName ) < 0
838 || rCID2.indexOf( m_aPieSegmentDragMethodServiceName ) < 0 )
839 return false;
841 OUString aID1( ObjectIdentifier::getObjectID( rCID1 ) );
842 OUString aID2( ObjectIdentifier::getObjectID( rCID2 ) );
843 if( aID1.getLength() && aID1.equals( aID2 ) )
844 return true;
846 return false;
849 //static
850 OUString ObjectIdentifier::getStringForType( ObjectType eObjectType )
852 OUString aRet;
853 switch( eObjectType )
855 case OBJECTTYPE_PAGE:
856 aRet=C2U("Page");
857 break;
858 case OBJECTTYPE_TITLE:
859 aRet=C2U("Title");
860 break;
861 case OBJECTTYPE_LEGEND:
862 aRet=C2U("Legend");
863 break;
864 case OBJECTTYPE_LEGEND_ENTRY:
865 aRet=C2U("LegendEntry");
866 break;
867 case OBJECTTYPE_DIAGRAM:
868 aRet=C2U("D");
869 break;
870 case OBJECTTYPE_DIAGRAM_WALL:
871 aRet=C2U("DiagramWall");
872 break;
873 case OBJECTTYPE_DIAGRAM_FLOOR:
874 aRet=C2U("DiagramFloor");
875 break;
876 case OBJECTTYPE_AXIS:
877 aRet=C2U("Axis");
878 break;
879 case OBJECTTYPE_AXIS_UNITLABEL:
880 aRet=C2U("AxisUnitLabel");
881 break;
882 case OBJECTTYPE_GRID:
883 aRet=C2U("Grid");
884 break;
885 case OBJECTTYPE_SUBGRID:
886 aRet=C2U("SubGrid");
887 break;
888 case OBJECTTYPE_DATA_SERIES:
889 aRet=C2U("Series");
890 break;
891 case OBJECTTYPE_DATA_POINT:
892 aRet=C2U("Point");
893 break;
894 case OBJECTTYPE_DATA_LABELS:
895 aRet=C2U("DataLabels");
896 break;
897 case OBJECTTYPE_DATA_LABEL:
898 aRet=C2U("DataLabel");
899 break;
900 case OBJECTTYPE_DATA_ERRORS:
901 aRet=C2U("Errors");
902 break;
903 case OBJECTTYPE_DATA_ERRORS_X:
904 aRet=C2U("ErrorsX");
905 break;
906 case OBJECTTYPE_DATA_ERRORS_Y:
907 aRet=C2U("ErrorsY");
908 break;
909 case OBJECTTYPE_DATA_ERRORS_Z:
910 aRet=C2U("ErrorsZ");
911 break;
912 case OBJECTTYPE_DATA_CURVE:
913 aRet=C2U("Curve");
914 break;
915 case OBJECTTYPE_DATA_CURVE_EQUATION:
916 aRet=C2U("Equation");
917 break;
918 case OBJECTTYPE_DATA_AVERAGE_LINE:
919 aRet=C2U("Average");
920 break;
921 case OBJECTTYPE_DATA_STOCK_RANGE:
922 aRet=C2U("StockRange");
923 break;
924 case OBJECTTYPE_DATA_STOCK_LOSS:
925 aRet=C2U("StockLoss");
926 break;
927 case OBJECTTYPE_DATA_STOCK_GAIN:
928 aRet=C2U("StockGain");
929 break;
930 default: //OBJECTTYPE_UNKNOWN
933 return aRet;
936 //static
937 ObjectType ObjectIdentifier::getObjectType( const OUString& rCID )
939 ObjectType eRet;
940 sal_Int32 nLastSign = rCID.lastIndexOf( ':' );//last sign before the type string
941 if(nLastSign==-1)
942 nLastSign = rCID.lastIndexOf( '/' );
943 if(nLastSign==-1)
945 sal_Int32 nEndIndex = rCID.lastIndexOf( '=' );
946 if(nEndIndex==-1)
947 return OBJECTTYPE_UNKNOWN;
948 nLastSign = 0;
950 if( nLastSign>0 )
951 nLastSign++;
953 if( rCID.match(C2U("Page"),nLastSign) )
954 eRet = OBJECTTYPE_PAGE;
955 else if( rCID.match(C2U("Title"),nLastSign) )
956 eRet = OBJECTTYPE_TITLE;
957 else if( rCID.match(C2U("LegendEntry"),nLastSign) )
958 eRet = OBJECTTYPE_LEGEND_ENTRY;
959 else if( rCID.match(C2U("Legend"),nLastSign) )
960 eRet = OBJECTTYPE_LEGEND;
961 else if( rCID.match(C2U("DiagramWall"),nLastSign) )
962 eRet = OBJECTTYPE_DIAGRAM_WALL;
963 else if( rCID.match(C2U("DiagramFloor"),nLastSign) )
964 eRet = OBJECTTYPE_DIAGRAM_FLOOR;
965 else if( rCID.match(C2U("D="),nLastSign) )
966 eRet = OBJECTTYPE_DIAGRAM;
967 else if( rCID.match(C2U("AxisUnitLabel"),nLastSign) )
968 eRet = OBJECTTYPE_AXIS_UNITLABEL;
969 else if( rCID.match(C2U("Axis"),nLastSign) )
970 eRet = OBJECTTYPE_AXIS;
971 else if( rCID.match(C2U("Grid"),nLastSign) )
972 eRet = OBJECTTYPE_GRID;
973 else if( rCID.match(C2U("SubGrid"),nLastSign) )
974 eRet = OBJECTTYPE_SUBGRID;
975 else if( rCID.match(C2U("Series"),nLastSign) )
976 eRet = OBJECTTYPE_DATA_SERIES;
977 else if( rCID.match(C2U("Point"),nLastSign) )
978 eRet = OBJECTTYPE_DATA_POINT;
979 else if( rCID.match(C2U("DataLabels"),nLastSign) )
980 eRet = OBJECTTYPE_DATA_LABELS;
981 else if( rCID.match(C2U("DataLabel"),nLastSign) )
982 eRet = OBJECTTYPE_DATA_LABEL;
983 else if( rCID.match(C2U("ErrorsX"),nLastSign) )
984 eRet = OBJECTTYPE_DATA_ERRORS_X;
985 else if( rCID.match(C2U("ErrorsY"),nLastSign) )
986 eRet = OBJECTTYPE_DATA_ERRORS_Y;
987 else if( rCID.match(C2U("ErrorsZ"),nLastSign) )
988 eRet = OBJECTTYPE_DATA_ERRORS_Z;
989 else if( rCID.match(C2U("Errors"),nLastSign) )
990 eRet = OBJECTTYPE_DATA_ERRORS;
991 else if( rCID.match(C2U("Curve"),nLastSign) )
992 eRet = OBJECTTYPE_DATA_CURVE;
993 else if( rCID.match(C2U("Equation"),nLastSign) )
994 eRet = OBJECTTYPE_DATA_CURVE_EQUATION;
995 else if( rCID.match(C2U("Average"),nLastSign) )
996 eRet = OBJECTTYPE_DATA_AVERAGE_LINE;
997 else if( rCID.match(C2U("StockRange"),nLastSign) )
998 eRet = OBJECTTYPE_DATA_STOCK_RANGE;
999 else if( rCID.match(C2U("StockLoss"),nLastSign) )
1000 eRet = OBJECTTYPE_DATA_STOCK_LOSS;
1001 else if( rCID.match(C2U("StockGain"),nLastSign) )
1002 eRet = OBJECTTYPE_DATA_STOCK_GAIN;
1003 else
1004 eRet = OBJECTTYPE_UNKNOWN;
1006 return eRet;
1009 ObjectType ObjectIdentifier::getObjectType()
1011 ObjectType eObjectType( OBJECTTYPE_UNKNOWN );
1012 if ( isAutoGeneratedObject() )
1014 eObjectType = getObjectType( m_aObjectCID );
1016 else if ( isAdditionalShape() )
1018 eObjectType = OBJECTTYPE_SHAPE;
1020 return eObjectType;
1023 //static
1024 OUString ObjectIdentifier::createDataCurveCID(
1025 const OUString& rSeriesParticle
1026 , sal_Int32 nCurveIndex
1027 , bool bAverageLine )
1029 OUString aParticleID( OUString::valueOf( nCurveIndex ) );
1030 ObjectType eType = bAverageLine ? OBJECTTYPE_DATA_AVERAGE_LINE : OBJECTTYPE_DATA_CURVE;
1031 return createClassifiedIdentifierWithParent( eType, aParticleID, rSeriesParticle );
1034 //static
1035 OUString ObjectIdentifier::createDataCurveEquationCID(
1036 const OUString& rSeriesParticle
1037 , sal_Int32 nCurveIndex )
1039 OUString aParticleID( OUString::valueOf( nCurveIndex ) );
1040 return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION, aParticleID, rSeriesParticle );
1043 //static
1044 OUString ObjectIdentifier::addChildParticle( const rtl::OUString& rParticle, const rtl::OUString& rChildParticle )
1046 OUStringBuffer aRet(rParticle);
1048 if( aRet.getLength() && rChildParticle.getLength() )
1049 aRet.appendAscii(":");
1050 if( rChildParticle.getLength() )
1051 aRet.append(rChildParticle);
1053 return aRet.makeStringAndClear();
1056 //static
1057 rtl::OUString ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex )
1059 OUStringBuffer aRet( getStringForType( eObjectType ) );
1060 if( aRet.getLength() )
1062 aRet.appendAscii("=");
1063 aRet.append(OUString::valueOf(nIndex));
1065 return aRet.makeStringAndClear();
1068 //static
1069 sal_Int32 ObjectIdentifier::getIndexFromParticleOrCID( const rtl::OUString& rParticleOrCID )
1071 sal_Int32 nRet = -1;
1073 OUString aIndexString = lcl_getIndexStringAfterString( rParticleOrCID, C2U("=") );
1074 sal_Int32 nCharacterIndex=0;
1075 nRet = lcl_StringToIndex( aIndexString.getToken( 0, ',', nCharacterIndex ) );
1077 return nRet;
1080 //static
1081 OUString ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
1082 , const rtl::OUString& rSeriesParticle
1083 , const rtl::OUString& rDragMethodServiceName
1084 , const rtl::OUString& rDragParameterString )
1086 OUString aChildParticle( getStringForType( eSubObjectType ) );
1087 aChildParticle+=(C2U("="));
1089 return createClassifiedIdentifierForParticles(
1090 rSeriesParticle, aChildParticle
1091 , rDragMethodServiceName, rDragParameterString );
1094 //static
1095 OUString ObjectIdentifier::createPointCID( const OUString& rPointCID_Stub, sal_Int32 nIndex )
1097 OUString aRet(rPointCID_Stub);
1098 return aRet+=OUString::valueOf( nIndex );
1101 //static
1102 OUString ObjectIdentifier::getParticleID( const OUString& rCID )
1104 OUString aRet;
1105 sal_Int32 nLast = rCID.lastIndexOf('=');
1106 if(nLast>=0)
1107 aRet = rCID.copy(++nLast);
1108 return aRet;
1111 //static
1112 OUString ObjectIdentifier::getFullParentParticle( const OUString& rCID )
1114 OUString aRet;
1116 sal_Int32 nStartPos = rCID.lastIndexOf('/');
1117 if( nStartPos>=0 )
1119 nStartPos++;
1120 sal_Int32 nEndPos = rCID.lastIndexOf(':');
1121 if( nEndPos>=0 && nStartPos < nEndPos )
1123 aRet = rCID.copy(nStartPos,nEndPos-nStartPos);
1127 return aRet;
1130 //static
1131 OUString ObjectIdentifier::getObjectID( const rtl::OUString& rCID )
1133 OUString aRet;
1135 sal_Int32 nStartPos = rCID.lastIndexOf('/');
1136 if( nStartPos>=0 )
1138 nStartPos++;
1139 sal_Int32 nEndPos = rCID.getLength();
1140 aRet = rCID.copy(nStartPos,nEndPos-nStartPos);
1143 return aRet;
1146 //static
1147 bool ObjectIdentifier::isCID( const OUString& rName )
1149 return rName.getLength() && rName.match( m_aProtocol );
1152 Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
1153 const OUString& rObjectCID,
1154 const Reference< chart2::XChartDocument >& xChartDocument )
1156 return ObjectIdentifier::getObjectPropertySet(
1157 rObjectCID, Reference< frame::XModel >( xChartDocument, uno::UNO_QUERY ));
1160 //static
1161 Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
1162 const OUString& rObjectCID
1163 , const Reference< frame::XModel >& xChartModel )
1165 //return the model object that is indicated by rObjectCID
1166 if(!rObjectCID.getLength())
1167 return NULL;
1168 if(!xChartModel.is())
1169 return NULL;
1171 Reference< beans::XPropertySet > xObjectProperties = NULL;
1174 ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID );
1175 OUString aParticleID = ObjectIdentifier::getParticleID( rObjectCID );
1177 Reference< XDiagram > xDiagram;
1178 Reference< XCoordinateSystem > xCooSys;
1179 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1181 switch(eObjectType)
1183 case OBJECTTYPE_PAGE:
1185 Reference< XChartDocument > xChartDocument( xChartModel, uno::UNO_QUERY );
1186 if( xChartDocument.is())
1187 xObjectProperties.set( xChartDocument->getPageBackground() );
1189 break;
1190 case OBJECTTYPE_TITLE:
1192 TitleHelper::eTitleType aTitleType = getTitleTypeForCID( rObjectCID );
1193 Reference< XTitle > xTitle( TitleHelper::getTitle( aTitleType, xChartModel ) );
1194 xObjectProperties.set( xTitle, uno::UNO_QUERY );
1196 break;
1197 case OBJECTTYPE_LEGEND:
1199 if( xDiagram.is() )
1200 xObjectProperties.set( xDiagram->getLegend(), uno::UNO_QUERY );
1202 break;
1203 case OBJECTTYPE_LEGEND_ENTRY:
1204 break;
1205 case OBJECTTYPE_DIAGRAM:
1207 xObjectProperties.set( xDiagram, uno::UNO_QUERY );
1209 break;
1210 case OBJECTTYPE_DIAGRAM_WALL:
1212 if( xDiagram.is() )
1213 xObjectProperties.set( xDiagram->getWall() );
1215 break;
1216 case OBJECTTYPE_DIAGRAM_FLOOR:
1218 if( xDiagram.is() )
1219 xObjectProperties.set( xDiagram->getFloor() );
1221 break;
1222 case OBJECTTYPE_AXIS:
1224 sal_Int32 nDimensionIndex = -1;
1225 sal_Int32 nAxisIndex = -1;
1226 lcl_parseAxisIndices( nDimensionIndex, nAxisIndex, rObjectCID );
1228 Reference< chart2::XAxis > xAxis(
1229 AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys ) );
1230 if( xAxis.is() )
1231 xObjectProperties.set( xAxis, uno::UNO_QUERY );
1233 break;
1234 case OBJECTTYPE_AXIS_UNITLABEL:
1235 break;
1236 case OBJECTTYPE_GRID:
1237 case OBJECTTYPE_SUBGRID:
1239 sal_Int32 nDimensionIndex = -1;
1240 sal_Int32 nAxisIndex = -1;
1241 lcl_parseAxisIndices( nDimensionIndex, nAxisIndex, rObjectCID );
1243 sal_Int32 nSubGridIndex = -1;
1244 lcl_parseGridIndices( nSubGridIndex, rObjectCID );
1246 xObjectProperties.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, nAxisIndex, nSubGridIndex ) );
1248 break;
1249 case OBJECTTYPE_DATA_LABELS:
1250 case OBJECTTYPE_DATA_SERIES:
1252 Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
1253 rObjectCID, xChartModel ) );
1254 if( xSeries.is() )
1255 xObjectProperties = Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY );
1257 break;
1259 case OBJECTTYPE_DATA_LABEL:
1260 case OBJECTTYPE_DATA_POINT:
1262 Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
1263 rObjectCID, xChartModel ) );
1264 if(xSeries.is())
1266 sal_Int32 nIndex = aParticleID.toInt32();
1267 xObjectProperties = xSeries->getDataPointByIndex( nIndex );
1269 break;
1271 case OBJECTTYPE_DATA_ERRORS:
1273 Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(
1274 rObjectCID, xChartModel ) );
1275 if(xSeries.is())
1277 Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
1278 Reference< beans::XPropertySet > xErrorBarProp;
1279 if( xSeriesProp.is() )
1281 xSeriesProp->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProp;
1282 xObjectProperties = Reference< beans::XPropertySet >( xErrorBarProp, uno::UNO_QUERY );
1285 break;
1287 case OBJECTTYPE_DATA_ERRORS_X:
1288 break;
1289 case OBJECTTYPE_DATA_ERRORS_Y:
1290 break;
1291 case OBJECTTYPE_DATA_ERRORS_Z:
1292 break;
1293 case OBJECTTYPE_DATA_AVERAGE_LINE:
1294 case OBJECTTYPE_DATA_CURVE:
1295 case OBJECTTYPE_DATA_CURVE_EQUATION:
1297 Reference< XRegressionCurveContainer > xRegressionContainer( ObjectIdentifier::getDataSeriesForCID(
1298 rObjectCID, xChartModel ), uno::UNO_QUERY );
1299 if(xRegressionContainer.is())
1301 sal_Int32 nIndex = aParticleID.toInt32();
1302 uno::Sequence< Reference< XRegressionCurve > > aCurveList =
1303 xRegressionContainer->getRegressionCurves();
1304 if( nIndex >= 0 && nIndex <aCurveList.getLength() )
1306 if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION )
1307 xObjectProperties.set( aCurveList[nIndex]->getEquationProperties());
1308 else
1309 xObjectProperties.set( aCurveList[nIndex], uno::UNO_QUERY );
1312 break;
1314 case OBJECTTYPE_DATA_STOCK_RANGE:
1315 break;
1316 case OBJECTTYPE_DATA_STOCK_LOSS:
1318 Reference<XChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
1319 Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY );
1320 if(xChartTypeProps.is())
1321 xChartTypeProps->getPropertyValue( C2U( "BlackDay" ) ) >>= xObjectProperties;
1323 break;
1324 case OBJECTTYPE_DATA_STOCK_GAIN:
1326 Reference<XChartType> xChartType( lcl_getFirstStockChartType( xChartModel ) );
1327 Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY );
1328 if(xChartTypeProps.is())
1329 xChartTypeProps->getPropertyValue( C2U( "WhiteDay" ) ) >>= xObjectProperties;
1331 break;
1332 default: //OBJECTTYPE_UNKNOWN
1333 break;
1336 catch( uno::Exception& ex)
1338 ASSERT_EXCEPTION( ex );
1340 return xObjectProperties;
1343 //static
1344 Reference< XAxis > ObjectIdentifier::getAxisForCID(
1345 const OUString& rObjectCID
1346 , const Reference< frame::XModel >& xChartModel )
1348 Reference< XDiagram > xDiagram;
1349 Reference< XCoordinateSystem > xCooSys;
1350 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1352 sal_Int32 nDimensionIndex = -1;
1353 sal_Int32 nAxisIndex = -1;
1354 lcl_parseAxisIndices( nDimensionIndex, nAxisIndex, rObjectCID );
1356 return AxisHelper::getAxis( nDimensionIndex, nAxisIndex, xCooSys );
1359 //static
1360 Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID(
1361 const OUString& rObjectCID
1362 , const Reference< frame::XModel >& xChartModel )
1364 Reference< XDataSeries > xSeries(NULL);
1366 Reference< XDiagram > xDiagram;
1367 Reference< XCoordinateSystem > xCooSys;
1368 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1370 sal_Int32 nChartTypeIndex = -1;
1371 sal_Int32 nSeriesIndex = -1;
1372 sal_Int32 nPointIndex = -1;
1373 lcl_parseSeriesIndices( nChartTypeIndex, nSeriesIndex, nPointIndex, rObjectCID );
1375 Reference< XDataSeriesContainer > xDataSeriesContainer( DiagramHelper::getChartTypeByIndex( xDiagram, nChartTypeIndex ), uno::UNO_QUERY );
1376 if( xDataSeriesContainer.is() )
1378 uno::Sequence< uno::Reference< XDataSeries > > aDataSeriesSeq( xDataSeriesContainer->getDataSeries() );
1379 if( nSeriesIndex >= 0 && nSeriesIndex < aDataSeriesSeq.getLength() )
1380 xSeries.set( aDataSeriesSeq[nSeriesIndex] );
1383 return xSeries;
1386 //static
1387 Reference< XDiagram > ObjectIdentifier::getDiagramForCID(
1388 const rtl::OUString& rObjectCID
1389 , const uno::Reference< frame::XModel >& xChartModel )
1391 Reference< XDiagram > xDiagram;
1393 Reference< XCoordinateSystem > xCooSys;
1394 lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
1396 return xDiagram;
1399 TitleHelper::eTitleType ObjectIdentifier::getTitleTypeForCID( const OUString& rCID )
1401 TitleHelper::eTitleType eRet( TitleHelper::MAIN_TITLE );
1403 OUString aParentParticle = ObjectIdentifier::getFullParentParticle( rCID );
1404 const tTitleMap& rMap = lcl_getTitleMap();
1405 tTitleMap::const_iterator aIt( rMap.begin() );
1406 for( ;aIt != rMap.end(); ++aIt )
1408 if( aParentParticle.equals( (*aIt).second ) )
1410 eRet = (*aIt).first;
1411 break;
1415 return eRet;
1418 // static
1419 OUString ObjectIdentifier::getSeriesParticleFromCID( const OUString& rCID )
1421 sal_Int32 nDiagramIndex = -1;
1422 sal_Int32 nCooSysIndex = -1;
1423 lcl_parseCooSysIndices( nDiagramIndex, nCooSysIndex, rCID );
1425 sal_Int32 nChartTypeIndex = -1;
1426 sal_Int32 nSeriesIndex = -1;
1427 sal_Int32 nPointIndex = -1;
1428 lcl_parseSeriesIndices( nChartTypeIndex, nSeriesIndex, nPointIndex, rCID );
1430 return ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex );
1433 //static
1434 OUString ObjectIdentifier::getMovedSeriesCID( const ::rtl::OUString& rObjectCID, sal_Bool bForward )
1436 sal_Int32 nDiagramIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("CID/D=") ) );
1437 sal_Int32 nCooSysIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("CS=") ) );
1438 sal_Int32 nChartTypeIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("CT=") ) );
1439 sal_Int32 nSeriesIndex = lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID, C2U("Series=") ) );
1441 if( bForward )
1442 nSeriesIndex--;
1443 else
1444 nSeriesIndex++;
1446 OUString aRet = ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex );
1447 return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet );
1450 bool ObjectIdentifier::isValid() const
1452 return ( isAutoGeneratedObject() || isAdditionalShape() );
1455 bool ObjectIdentifier::isAutoGeneratedObject() const
1457 return ( m_aObjectCID.getLength() > 0 );
1460 bool ObjectIdentifier::isAdditionalShape() const
1462 return m_xAdditionalShape.is();
1465 OUString ObjectIdentifier::getObjectCID() const
1467 return m_aObjectCID;
1470 Reference< drawing::XShape > ObjectIdentifier::getAdditionalShape() const
1472 return m_xAdditionalShape;
1475 Any ObjectIdentifier::getAny() const
1477 Any aAny;
1478 if ( isAutoGeneratedObject() )
1480 aAny = uno::makeAny( getObjectCID() );
1482 else if ( isAdditionalShape() )
1484 aAny = uno::makeAny( getAdditionalShape() );
1486 return aAny;
1489 //.............................................................................
1490 } //namespace chart
1491 //.............................................................................