1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "ObjectIdentifier.hxx"
23 #include "TitleHelper.hxx"
24 #include "ChartModelHelper.hxx"
25 #include "AxisHelper.hxx"
26 #include "servicenames_charttypes.hxx"
27 #include "DiagramHelper.hxx"
28 #include "AxisIndexDefines.hxx"
29 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
30 #include <com/sun/star/chart2/XChartDocument.hpp>
31 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
32 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
33 #include <com/sun/star/chart2/XAxis.hpp>
34 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
36 // header for define DBG_ASSERT
37 #include <tools/debug.hxx>
38 #include <comphelper/InlineContainer.hxx>
40 #include <rtl/ustrbuf.hxx>
42 //.............................................................................
45 //.............................................................................
46 using namespace ::com::sun::star
;
47 using namespace ::com::sun::star::chart2
;
49 using ::com::sun::star::uno::Reference
;
50 using ::com::sun::star::uno::Any
;
52 static OUString
m_aMultiClick( "MultiClick" );
53 static OUString
m_aDragMethodEquals( "DragMethod=" );
54 static OUString
m_aDragParameterEquals( "DragParameter=" );
55 static OUString
m_aProtocol( "CID/" );
56 static OUString m_aEmptyString
;
57 static OUString
m_aPieSegmentDragMethodServiceName( "PieSegmentDraging" );
62 OUString
lcl_createClassificationStringForType( ObjectType eObjectType
63 , const OUString
& rDragMethodServiceName
64 , const OUString
& rDragParameterString
70 //these object types are all selected only after their parents was selected before
71 case OBJECTTYPE_LEGEND_ENTRY
: //parent is intended to be OBJECTTYPE_LEGEND
72 case OBJECTTYPE_DATA_POINT
: //parent is intended to be OBJECTTYPE_DATA_SERIES
73 case OBJECTTYPE_DATA_LABEL
: //parent is intended to be OBJECTTYPE_DATA_LABELS
74 case OBJECTTYPE_DATA_ERRORS_X
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
75 case OBJECTTYPE_DATA_ERRORS_Y
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
76 case OBJECTTYPE_DATA_ERRORS_Z
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
81 if( !rDragMethodServiceName
.isEmpty() )
84 aRet
.appendAscii(":");
85 aRet
.append( m_aDragMethodEquals
);
86 aRet
.append( rDragMethodServiceName
);
88 if( !rDragParameterString
.isEmpty() )
91 aRet
.appendAscii(":");
92 aRet
.append( m_aDragParameterEquals
);
93 aRet
.append( rDragParameterString
);
96 return aRet
.makeStringAndClear();
99 typedef ::comphelper::MakeMap
< TitleHelper::eTitleType
, OUString
> tTitleMap
;
100 const tTitleMap
& lcl_getTitleMap()
102 //maps the title type to the ParentParticle for that title
103 static tTitleMap m_aTitleMap
= tTitleMap
104 ( TitleHelper::MAIN_TITLE
, "" )
105 ( TitleHelper::SUB_TITLE
, "D=0" )
106 ( TitleHelper::X_AXIS_TITLE
, "D=0:CS=0:Axis=0,0" )
107 ( TitleHelper::Y_AXIS_TITLE
, "D=0:CS=0:Axis=1,0" )
108 ( TitleHelper::Z_AXIS_TITLE
, "D=0:CS=0:Axis=2,0" )
109 ( TitleHelper::SECONDARY_X_AXIS_TITLE
, "D=0:CS=0:Axis=0,1" )
110 ( TitleHelper::SECONDARY_Y_AXIS_TITLE
, "D=0:CS=0:Axis=1,1" )
115 OUString
lcl_getTitleParentParticle( TitleHelper::eTitleType aTitleType
)
119 const tTitleMap
& rMap
= lcl_getTitleMap();
120 tTitleMap::const_iterator
aIt( rMap
.find( aTitleType
) );
121 if( aIt
!= rMap
.end())
122 aRet
= (*aIt
).second
;
127 Reference
<XChartType
> lcl_getFirstStockChartType( const Reference
< frame::XModel
>& xChartModel
)
129 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
133 //iterate through all coordinate systems
134 Reference
< XCoordinateSystemContainer
> xCooSysContainer( xDiagram
, uno::UNO_QUERY
);
135 if( !xCooSysContainer
.is())
138 uno::Sequence
< Reference
< XCoordinateSystem
> > aCooSysList( xCooSysContainer
->getCoordinateSystems() );
139 for( sal_Int32 nCS
= 0; nCS
< aCooSysList
.getLength(); ++nCS
)
141 //iterate through all chart types in the current coordinate system
142 Reference
< XChartTypeContainer
> xChartTypeContainer( aCooSysList
[nCS
], uno::UNO_QUERY
);
143 if( !xChartTypeContainer
.is() )
146 uno::Sequence
< Reference
< XChartType
> > aChartTypeList( xChartTypeContainer
->getChartTypes() );
147 for( sal_Int32 nT
= 0; nT
< aChartTypeList
.getLength(); ++nT
)
149 Reference
< XChartType
> xChartType( aChartTypeList
[nT
] );
152 OUString aChartType
= xChartType
->getChartType();
153 if( aChartType
.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK
) )
160 OUString
lcl_getIndexStringAfterString( const OUString
& rString
, const OUString
& rSearchString
)
164 sal_Int32 nIndexStart
= rString
.lastIndexOf( rSearchString
);
165 if( nIndexStart
!= -1 )
167 nIndexStart
+= rSearchString
.getLength();
168 sal_Int32 nIndexEnd
= rString
.getLength();
169 sal_Int32 nNextColon
= rString
.indexOf( ':', nIndexStart
);
170 if( nNextColon
!= -1 )
171 nIndexEnd
= nNextColon
;
172 aRet
= rString
.copy(nIndexStart
,nIndexEnd
-nIndexStart
);
175 return aRet
.makeStringAndClear();
178 sal_Int32
lcl_StringToIndex( const OUString
& rIndexString
)
181 if( !rIndexString
.isEmpty() )
183 nRet
= rIndexString
.toInt32();
190 void lcl_parseCooSysIndices( sal_Int32
& rnDiagram
, sal_Int32
& rnCooSys
, const OUString
& rString
)
192 rnDiagram
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, "D=" ) );
193 rnCooSys
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, "CS=" ) );
196 void lcl_parseAxisIndices( sal_Int32
& rnDimensionIndex
, sal_Int32
& rnAxisIndex
, const OUString
& rString
)
198 OUString aAxisIndexString
= lcl_getIndexStringAfterString( rString
, ":Axis=" );
199 sal_Int32 nCharacterIndex
=0;
200 rnDimensionIndex
= lcl_StringToIndex( aAxisIndexString
.getToken( 0, ',', nCharacterIndex
) );
201 rnAxisIndex
= lcl_StringToIndex( aAxisIndexString
.getToken( 0, ',', nCharacterIndex
) );
204 void lcl_parseGridIndices( sal_Int32
& rnSubGridIndex
, const OUString
& rString
)
207 rnSubGridIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, ":SubGrid=" ) );
210 void lcl_parseSeriesIndices( sal_Int32
& rnChartTypeIndex
, sal_Int32
& rnSeriesIndex
, sal_Int32
& rnPointIndex
, const OUString
& rString
)
212 rnChartTypeIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, "CT=" ) );
213 rnSeriesIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, "Series=" ) );
214 rnPointIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, "Point=" ) );
217 void lcl_getDiagramAndCooSys( const OUString
& rObjectCID
218 , const Reference
< frame::XModel
>& xChartModel
219 , Reference
< XDiagram
>& xDiagram
220 , Reference
< XCoordinateSystem
>& xCooSys
)
222 sal_Int32 nDiagramIndex
= -1;
223 sal_Int32 nCooSysIndex
= -1;
224 lcl_parseCooSysIndices( nDiagramIndex
, nCooSysIndex
, rObjectCID
);
225 xDiagram
= ChartModelHelper::findDiagram( xChartModel
);//todo use nDiagramIndex when more than one diagram is possible in future
229 if( nCooSysIndex
> -1 )
231 Reference
< XCoordinateSystemContainer
> xCooSysContainer( xDiagram
, uno::UNO_QUERY
);
232 if( xCooSysContainer
.is() )
234 uno::Sequence
< Reference
< XCoordinateSystem
> > aCooSysList( xCooSysContainer
->getCoordinateSystems() );
235 if( nCooSysIndex
< aCooSysList
.getLength() )
236 xCooSys
= aCooSysList
[nCooSysIndex
];
241 } //anonymous namespace
243 ObjectIdentifier::ObjectIdentifier()
244 :m_aObjectCID( OUString() )
245 ,m_xAdditionalShape( 0 )
249 ObjectIdentifier::ObjectIdentifier( const OUString
& rObjectCID
)
250 :m_aObjectCID( rObjectCID
)
251 ,m_xAdditionalShape( 0 )
255 ObjectIdentifier::ObjectIdentifier( const Reference
< drawing::XShape
>& rxShape
)
256 :m_aObjectCID( OUString() )
257 ,m_xAdditionalShape( rxShape
)
261 ObjectIdentifier::ObjectIdentifier( const Any
& rAny
)
262 :m_aObjectCID( OUString() )
263 ,m_xAdditionalShape( 0 )
265 const uno::Type
& rType
= rAny
.getValueType();
266 if ( rType
== ::getCppuType( static_cast< const OUString
* >( 0 ) ) )
268 rAny
>>= m_aObjectCID
;
270 else if ( rType
== ::getCppuType( static_cast< const Reference
< drawing::XShape
>* >( 0 ) ) )
272 rAny
>>= m_xAdditionalShape
;
276 ObjectIdentifier::~ObjectIdentifier()
280 ObjectIdentifier::ObjectIdentifier( const ObjectIdentifier
& rOID
)
281 :m_aObjectCID( rOID
.m_aObjectCID
)
282 ,m_xAdditionalShape( rOID
.m_xAdditionalShape
)
287 ObjectIdentifier
& ObjectIdentifier::operator=( const ObjectIdentifier
& rOID
)
289 m_aObjectCID
= rOID
.m_aObjectCID
;
290 m_xAdditionalShape
= rOID
.m_xAdditionalShape
;
294 bool ObjectIdentifier::operator==( const ObjectIdentifier
& rOID
) const
296 if ( areIdenticalObjects( m_aObjectCID
, rOID
.m_aObjectCID
) &&
297 ( m_xAdditionalShape
== rOID
.m_xAdditionalShape
) )
304 bool ObjectIdentifier::operator!=( const ObjectIdentifier
& rOID
) const
306 return !operator==( rOID
);
309 bool ObjectIdentifier::operator<( const ObjectIdentifier
& rOID
) const
311 bool bReturn
= false;
312 if ( !(m_aObjectCID
.isEmpty() || rOID
.m_aObjectCID
.isEmpty()) )
314 bReturn
= ( m_aObjectCID
.compareTo( rOID
.m_aObjectCID
) < 0 );
316 else if ( !m_aObjectCID
.isEmpty() )
320 else if ( !rOID
.m_aObjectCID
.isEmpty() )
324 else if ( m_xAdditionalShape
.is() && rOID
.m_xAdditionalShape
.is() )
326 bReturn
= ( m_xAdditionalShape
< rOID
.m_xAdditionalShape
);
331 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
332 const Reference
< uno::XInterface
>& xObject
333 , const Reference
< frame::XModel
>& xChartModel
)
337 enum ObjectType eObjectType
= OBJECTTYPE_UNKNOWN
;
339 OUString aParentParticle
;
340 OUString aDragMethodServiceName
;
341 OUString aDragParameterString
;
347 Reference
< XTitle
> xTitle( xObject
, uno::UNO_QUERY
);
350 TitleHelper::eTitleType aTitleType
;
351 if( TitleHelper::getTitleType( aTitleType
, xTitle
, xChartModel
) )
353 eObjectType
= OBJECTTYPE_TITLE
;
354 aParentParticle
= lcl_getTitleParentParticle( aTitleType
);
355 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
356 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
363 Reference
< XAxis
> xAxis( xObject
, uno::UNO_QUERY
);
366 Reference
< XCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis
, ChartModelHelper::findDiagram( xChartModel
) ) );
367 OUString
aCooSysParticle( createParticleForCoordinateSystem( xCooSys
, xChartModel
) );
368 sal_Int32 nDimensionIndex
=-1;
369 sal_Int32 nAxisIndex
=-1;
370 AxisHelper::getIndicesForAxis( xAxis
, xCooSys
, nDimensionIndex
, nAxisIndex
);
371 OUString
aAxisParticle( createParticleForAxis( nDimensionIndex
, nAxisIndex
) );
372 return createClassifiedIdentifierForParticles( aCooSysParticle
, aAxisParticle
);
376 Reference
< XLegend
> xLegend( xObject
, uno::UNO_QUERY
);
379 return createClassifiedIdentifierForParticle( createParticleForLegend( xLegend
, xChartModel
) );
383 Reference
< XDiagram
> xDiagram( xObject
, uno::UNO_QUERY
);
386 return createClassifiedIdentifierForParticle( createParticleForDiagram( xDiagram
, xChartModel
) );
396 catch(const uno::Exception
& ex
)
398 ASSERT_EXCEPTION( ex
);
401 if( eObjectType
!= OBJECTTYPE_UNKNOWN
)
403 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
404 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
408 OSL_FAIL("give object could not be identifed in createClassifiedIdentifierForObject");
414 OUString
ObjectIdentifier::createClassifiedIdentifierForParticle(
415 const OUString
& rParticle
)
417 return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle
, OUString() );
420 OUString
ObjectIdentifier::createClassifiedIdentifierForParticles(
421 const OUString
& rParentParticle
422 , const OUString
& rChildParticle
423 , const OUString
& rDragMethodServiceName
424 , const OUString
& rDragParameterString
)
426 ObjectType
eObjectType( ObjectIdentifier::getObjectType( rChildParticle
) );
427 if( eObjectType
== OBJECTTYPE_UNKNOWN
)
428 eObjectType
= ObjectIdentifier::getObjectType( rParentParticle
);
430 OUStringBuffer
aRet( m_aProtocol
);
431 aRet
.append( lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
432 if(aRet
.getLength()>m_aProtocol
.getLength())
433 aRet
.appendAscii("/");
435 if(!rParentParticle
.isEmpty())
437 aRet
.append(rParentParticle
);
438 if( !rChildParticle
.isEmpty() )
439 aRet
.appendAscii(":");
441 aRet
.append(rChildParticle
);
443 return aRet
.makeStringAndClear();
446 OUString
ObjectIdentifier::createParticleForDiagram(
447 const Reference
< XDiagram
>& /*xDiagram*/
448 , const Reference
< frame::XModel
>& /*xChartModel*/ )
450 static OUString
aRet("D=0");
451 //todo: if more than one diagram is implemeted, add the correct diagram index here
455 OUString
ObjectIdentifier::createParticleForCoordinateSystem(
456 const Reference
< XCoordinateSystem
>& xCooSys
457 , const Reference
< frame::XModel
>& xChartModel
)
461 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
462 Reference
< XCoordinateSystemContainer
> xCooSysContainer( xDiagram
, uno::UNO_QUERY
);
463 if( xCooSysContainer
.is() )
465 sal_Int32 nCooSysIndex
= 0;
466 uno::Sequence
< Reference
< XCoordinateSystem
> > aCooSysList( xCooSysContainer
->getCoordinateSystems() );
467 for( ; nCooSysIndex
< aCooSysList
.getLength(); ++nCooSysIndex
)
469 Reference
< XCoordinateSystem
> xCurrentCooSys( aCooSysList
[nCooSysIndex
] );
470 if( xCooSys
== xCurrentCooSys
)
472 aRet
= ObjectIdentifier::createParticleForDiagram( xDiagram
, xChartModel
);
473 aRet
.appendAscii(":CS=");
474 aRet
.append( OUString::valueOf( nCooSysIndex
) );
480 return aRet
.makeStringAndClear();
483 OUString
ObjectIdentifier::createParticleForAxis(
484 sal_Int32 nDimensionIndex
485 , sal_Int32 nAxisIndex
)
487 OUStringBuffer
aRet("Axis=");
489 aRet
.append( OUString::valueOf( nDimensionIndex
) );
490 aRet
.appendAscii(",");
491 aRet
.append( OUString::valueOf( nAxisIndex
) );
493 return aRet
.makeStringAndClear();
496 OUString
ObjectIdentifier::createParticleForGrid(
497 sal_Int32 nDimensionIndex
498 , sal_Int32 nAxisIndex
)
500 OUStringBuffer
aRet("Axis=");
501 aRet
.append( OUString::valueOf( nDimensionIndex
) );
502 aRet
.appendAscii(",");
503 aRet
.append( OUString::valueOf( nAxisIndex
) );
504 aRet
.append( ":Grid=0" );
506 return aRet
.makeStringAndClear();
509 OUString
ObjectIdentifier::createClassifiedIdentifierForGrid(
510 const Reference
< XAxis
>& xAxis
511 , const Reference
< frame::XModel
>& xChartModel
512 , sal_Int32 nSubGridIndex
)
514 //-1: main grid, 0: first subgrid etc
516 OUString
aAxisCID( createClassifiedIdentifierForObject( xAxis
, xChartModel
) );
517 OUString
aGridCID( addChildParticle( aAxisCID
518 , createChildParticleWithIndex( OBJECTTYPE_GRID
, 0 ) ) );
519 if( nSubGridIndex
>= 0 )
521 aGridCID
= addChildParticle( aGridCID
522 , createChildParticleWithIndex( OBJECTTYPE_SUBGRID
, 0 ) );
527 OUString
ObjectIdentifier::createParticleForSeries(
528 sal_Int32 nDiagramIndex
, sal_Int32 nCooSysIndex
529 , sal_Int32 nChartTypeIndex
, sal_Int32 nSeriesIndex
)
533 aRet
.appendAscii("D=");
534 aRet
.append( OUString::valueOf( nDiagramIndex
) );
535 aRet
.appendAscii(":CS=");
536 aRet
.append( OUString::valueOf( nCooSysIndex
) );
537 aRet
.appendAscii(":CT=");
538 aRet
.append( OUString::valueOf( nChartTypeIndex
) );
539 aRet
.appendAscii(":");
540 aRet
.append(getStringForType( OBJECTTYPE_DATA_SERIES
));
541 aRet
.appendAscii("=");
542 aRet
.append( OUString::valueOf( nSeriesIndex
) );
544 return aRet
.makeStringAndClear();
547 OUString
ObjectIdentifier::createParticleForLegend(
548 const Reference
< XLegend
>& /*xLegend*/
549 , const Reference
< frame::XModel
>& xChartModel
)
553 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
554 //todo: if more than one diagram is implemeted, find the correct diagram which is owner of the given legend
556 aRet
.append( ObjectIdentifier::createParticleForDiagram( xDiagram
, xChartModel
) );
557 aRet
.appendAscii(":");
558 aRet
.append(getStringForType( OBJECTTYPE_LEGEND
));
559 aRet
.appendAscii("=");
561 return aRet
.makeStringAndClear();
564 OUString
ObjectIdentifier::createClassifiedIdentifier(
565 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_SERIES
566 , const OUString
& rParticleID
)//e.g. SeriesID
568 return createClassifiedIdentifierWithParent(
569 eObjectType
, rParticleID
, m_aEmptyString
);
572 OUString
ObjectIdentifier::createClassifiedIdentifierWithParent(
573 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
574 , const OUString
& rParticleID
//e.g. Point Index or SubGrid Index
575 , const OUString
& rParentPartical
//e.g. "Series=SeriesID" or "Grid=GridId"
576 , const OUString
& rDragMethodServiceName
577 , const OUString
& rDragParameterString
579 //, bool bIsMultiClickObject ) //e.g. true
581 //e.g. "MultiClick/Series=2:Point=34"
583 OUStringBuffer
aRet( m_aProtocol
);
584 aRet
.append( lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
585 if(aRet
.getLength()>m_aProtocol
.getLength())
586 aRet
.appendAscii("/");
587 aRet
.append(rParentPartical
);
588 if(!rParentPartical
.isEmpty())
589 aRet
.appendAscii(":");
591 aRet
.append(getStringForType( eObjectType
));
592 aRet
.appendAscii("=");
593 aRet
.append(rParticleID
);
595 return aRet
.makeStringAndClear();
598 const OUString
& ObjectIdentifier::getPieSegmentDragMethodServiceName()
600 return m_aPieSegmentDragMethodServiceName
;
603 OUString
ObjectIdentifier::createPieSegmentDragParameterString(
604 sal_Int32 nOffsetPercent
605 , const awt::Point
& rMinimumPosition
606 , const awt::Point
& rMaximumPosition
)
608 OUStringBuffer
aRet( OUString::valueOf( nOffsetPercent
) );
609 aRet
.append( sal_Unicode( ',' ));
610 aRet
.append( OUString::valueOf( rMinimumPosition
.X
) );
611 aRet
.append( sal_Unicode( ',' ));
612 aRet
.append( OUString::valueOf( rMinimumPosition
.Y
) );
613 aRet
.append( sal_Unicode( ',' ));
614 aRet
.append( OUString::valueOf( rMaximumPosition
.X
) );
615 aRet
.append( sal_Unicode( ',' ));
616 aRet
.append( OUString::valueOf( rMaximumPosition
.Y
) );
617 return aRet
.makeStringAndClear();
620 bool ObjectIdentifier::parsePieSegmentDragParameterString(
621 const OUString
& rDragParameterString
622 , sal_Int32
& rOffsetPercent
623 , awt::Point
& rMinimumPosition
624 , awt::Point
& rMaximumPosition
)
626 sal_Int32 nCharacterIndex
= 0;
628 OUString
aValueString( rDragParameterString
.getToken( 0, ',', nCharacterIndex
) );
629 rOffsetPercent
= aValueString
.toInt32();
630 if( nCharacterIndex
< 0 )
633 aValueString
= rDragParameterString
.getToken( 0, ',', nCharacterIndex
);
634 rMinimumPosition
.X
= aValueString
.toInt32();
635 if( nCharacterIndex
< 0 )
638 aValueString
= rDragParameterString
.getToken( 0, ',', nCharacterIndex
);
639 rMinimumPosition
.Y
= aValueString
.toInt32();
640 if( nCharacterIndex
< 0 )
643 aValueString
= rDragParameterString
.getToken( 0, ',', nCharacterIndex
);
644 rMaximumPosition
.X
= aValueString
.toInt32();
645 if( nCharacterIndex
< 0 )
648 aValueString
= rDragParameterString
.getToken( 0, ',', nCharacterIndex
);
649 rMaximumPosition
.Y
= aValueString
.toInt32();
650 if( nCharacterIndex
< 0 )
656 OUString
ObjectIdentifier::getDragMethodServiceName( const OUString
& rCID
)
660 sal_Int32 nIndexStart
= rCID
.indexOf( m_aDragMethodEquals
);
661 if( nIndexStart
!= -1 )
663 nIndexStart
= rCID
.indexOf( '=', nIndexStart
);
664 if( nIndexStart
!= -1 )
667 sal_Int32 nNextSlash
= rCID
.indexOf( '/', nIndexStart
);
668 if( nNextSlash
!= -1 )
670 sal_Int32 nIndexEnd
= nNextSlash
;
671 sal_Int32 nNextColon
= rCID
.indexOf( ':', nIndexStart
);
672 if( nNextColon
< nNextSlash
)
673 nIndexEnd
= nNextColon
;
674 aRet
= rCID
.copy(nIndexStart
,nIndexEnd
-nIndexStart
);
681 OUString
ObjectIdentifier::getDragParameterString( const OUString
& rCID
)
685 sal_Int32 nIndexStart
= rCID
.indexOf( m_aDragParameterEquals
);
686 if( nIndexStart
!= -1 )
688 nIndexStart
= rCID
.indexOf( '=', nIndexStart
);
689 if( nIndexStart
!= -1 )
692 sal_Int32 nNextSlash
= rCID
.indexOf( '/', nIndexStart
);
693 if( nNextSlash
!= -1 )
695 sal_Int32 nIndexEnd
= nNextSlash
;
696 sal_Int32 nNextColon
= rCID
.indexOf( ':', nIndexStart
);
697 if( nNextColon
< nNextSlash
)
698 nIndexEnd
= nNextColon
;
699 aRet
= rCID
.copy(nIndexStart
,nIndexEnd
-nIndexStart
);
706 bool ObjectIdentifier::isDragableObject( const OUString
& rClassifiedIdentifier
)
708 bool bReturn
= false;
709 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
710 switch( eObjectType
)
712 case OBJECTTYPE_TITLE
:
713 case OBJECTTYPE_LEGEND
:
714 case OBJECTTYPE_DIAGRAM
:
715 case OBJECTTYPE_DATA_CURVE_EQUATION
:
716 //case OBJECTTYPE_DIAGRAM_WALL:
720 OUString
aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier
) );
721 bReturn
= !aDragMethodServiceName
.isEmpty();
727 bool ObjectIdentifier::isDragableObject()
729 bool bReturn
= false;
730 if ( isAutoGeneratedObject() )
732 bReturn
= isDragableObject( m_aObjectCID
);
734 else if ( isAdditionalShape() )
741 bool ObjectIdentifier::isRotateableObject( const OUString
& rClassifiedIdentifier
)
743 bool bReturn
= false;
744 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
745 switch( eObjectType
)
747 case OBJECTTYPE_DIAGRAM
:
748 //case OBJECTTYPE_DIAGRAM_WALL:
758 bool ObjectIdentifier::isMultiClickObject( const OUString
& rClassifiedIdentifier
)
760 //the name of a shape is it's ClassifiedIdentifier
762 //a MultiClickObject is an object that is selectable by more than one click only ;
763 //before a MultiClickObject can be selected it is necessary that a named parent group object
764 //was selected before;
766 //!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:"
767 bool bRet
= rClassifiedIdentifier
.match( m_aMultiClick
, m_aProtocol
.getLength() );
771 bool ObjectIdentifier::areSiblings( const OUString
& rCID1
, const OUString
& rCID2
)
774 sal_Int32 nLastSign1
= rCID1
.lastIndexOf( '=' );
775 sal_Int32 nLastSign2
= rCID2
.lastIndexOf( '=' );
776 if( nLastSign1
== rCID1
.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
778 else if( nLastSign2
== rCID2
.indexOf( '=' ) )//CID cannot be sibling if only one "=" occurs
780 else if( ObjectIdentifier::areIdenticalObjects( rCID1
, rCID2
) )
784 OUString
aParent1( ObjectIdentifier::getFullParentParticle( rCID1
) );
785 if( !aParent1
.isEmpty() )
787 OUString
aParent2( ObjectIdentifier::getFullParentParticle( rCID2
) );
788 bRet
=aParent1
.equals(aParent2
);
790 //legend entries are special:
793 if( OBJECTTYPE_LEGEND_ENTRY
== getObjectType(rCID1
)
794 && OBJECTTYPE_LEGEND_ENTRY
== getObjectType(rCID2
) )
801 bool ObjectIdentifier::areIdenticalObjects( const OUString
& rCID1
, const OUString
& rCID2
)
803 if( rCID1
.equals( rCID2
) )
805 //draggable pie or donut segments need special treatment, as their CIDs do change with offset
807 if( rCID1
.indexOf( m_aPieSegmentDragMethodServiceName
) < 0
808 || rCID2
.indexOf( m_aPieSegmentDragMethodServiceName
) < 0 )
811 OUString
aID1( ObjectIdentifier::getObjectID( rCID1
) );
812 OUString
aID2( ObjectIdentifier::getObjectID( rCID2
) );
813 if( !aID1
.isEmpty() && aID1
.equals( aID2
) )
819 OUString
ObjectIdentifier::getStringForType( ObjectType eObjectType
)
822 switch( eObjectType
)
824 case OBJECTTYPE_PAGE
:
827 case OBJECTTYPE_TITLE
:
830 case OBJECTTYPE_LEGEND
:
833 case OBJECTTYPE_LEGEND_ENTRY
:
836 case OBJECTTYPE_DIAGRAM
:
839 case OBJECTTYPE_DIAGRAM_WALL
:
842 case OBJECTTYPE_DIAGRAM_FLOOR
:
845 case OBJECTTYPE_AXIS
:
848 case OBJECTTYPE_AXIS_UNITLABEL
:
849 aRet
="AxisUnitLabel";
851 case OBJECTTYPE_GRID
:
854 case OBJECTTYPE_SUBGRID
:
857 case OBJECTTYPE_DATA_SERIES
:
860 case OBJECTTYPE_DATA_POINT
:
863 case OBJECTTYPE_DATA_LABELS
:
866 case OBJECTTYPE_DATA_LABEL
:
869 case OBJECTTYPE_DATA_ERRORS_X
:
872 case OBJECTTYPE_DATA_ERRORS_Y
:
875 case OBJECTTYPE_DATA_ERRORS_Z
:
878 case OBJECTTYPE_DATA_CURVE
:
881 case OBJECTTYPE_DATA_CURVE_EQUATION
:
884 case OBJECTTYPE_DATA_AVERAGE_LINE
:
887 case OBJECTTYPE_DATA_STOCK_RANGE
:
890 case OBJECTTYPE_DATA_STOCK_LOSS
:
893 case OBJECTTYPE_DATA_STOCK_GAIN
:
896 default: //OBJECTTYPE_UNKNOWN
902 ObjectType
ObjectIdentifier::getObjectType( const OUString
& rCID
)
905 sal_Int32 nLastSign
= rCID
.lastIndexOf( ':' );//last sign before the type string
907 nLastSign
= rCID
.lastIndexOf( '/' );
910 sal_Int32 nEndIndex
= rCID
.lastIndexOf( '=' );
912 return OBJECTTYPE_UNKNOWN
;
918 if( rCID
.match("Page",nLastSign
) )
919 eRet
= OBJECTTYPE_PAGE
;
920 else if( rCID
.match("Title",nLastSign
) )
921 eRet
= OBJECTTYPE_TITLE
;
922 else if( rCID
.match("LegendEntry",nLastSign
) )
923 eRet
= OBJECTTYPE_LEGEND_ENTRY
;
924 else if( rCID
.match("Legend",nLastSign
) )
925 eRet
= OBJECTTYPE_LEGEND
;
926 else if( rCID
.match("DiagramWall",nLastSign
) )
927 eRet
= OBJECTTYPE_DIAGRAM_WALL
;
928 else if( rCID
.match("DiagramFloor",nLastSign
) )
929 eRet
= OBJECTTYPE_DIAGRAM_FLOOR
;
930 else if( rCID
.match("D=",nLastSign
) )
931 eRet
= OBJECTTYPE_DIAGRAM
;
932 else if( rCID
.match("AxisUnitLabel",nLastSign
) )
933 eRet
= OBJECTTYPE_AXIS_UNITLABEL
;
934 else if( rCID
.match("Axis",nLastSign
) )
935 eRet
= OBJECTTYPE_AXIS
;
936 else if( rCID
.match("Grid",nLastSign
) )
937 eRet
= OBJECTTYPE_GRID
;
938 else if( rCID
.match("SubGrid",nLastSign
) )
939 eRet
= OBJECTTYPE_SUBGRID
;
940 else if( rCID
.match("Series",nLastSign
) )
941 eRet
= OBJECTTYPE_DATA_SERIES
;
942 else if( rCID
.match("Point",nLastSign
) )
943 eRet
= OBJECTTYPE_DATA_POINT
;
944 else if( rCID
.match("DataLabels",nLastSign
) )
945 eRet
= OBJECTTYPE_DATA_LABELS
;
946 else if( rCID
.match("DataLabel",nLastSign
) )
947 eRet
= OBJECTTYPE_DATA_LABEL
;
948 else if( rCID
.match("ErrorsX",nLastSign
) )
949 eRet
= OBJECTTYPE_DATA_ERRORS_X
;
950 else if( rCID
.match("ErrorsY",nLastSign
) )
951 eRet
= OBJECTTYPE_DATA_ERRORS_Y
;
952 else if( rCID
.match("ErrorsZ",nLastSign
) )
953 eRet
= OBJECTTYPE_DATA_ERRORS_Z
;
954 else if( rCID
.match("Curve",nLastSign
) )
955 eRet
= OBJECTTYPE_DATA_CURVE
;
956 else if( rCID
.match("Equation",nLastSign
) )
957 eRet
= OBJECTTYPE_DATA_CURVE_EQUATION
;
958 else if( rCID
.match("Average",nLastSign
) )
959 eRet
= OBJECTTYPE_DATA_AVERAGE_LINE
;
960 else if( rCID
.match("StockRange",nLastSign
) )
961 eRet
= OBJECTTYPE_DATA_STOCK_RANGE
;
962 else if( rCID
.match("StockLoss",nLastSign
) )
963 eRet
= OBJECTTYPE_DATA_STOCK_LOSS
;
964 else if( rCID
.match("StockGain",nLastSign
) )
965 eRet
= OBJECTTYPE_DATA_STOCK_GAIN
;
967 eRet
= OBJECTTYPE_UNKNOWN
;
972 ObjectType
ObjectIdentifier::getObjectType()
974 ObjectType
eObjectType( OBJECTTYPE_UNKNOWN
);
975 if ( isAutoGeneratedObject() )
977 eObjectType
= getObjectType( m_aObjectCID
);
979 else if ( isAdditionalShape() )
981 eObjectType
= OBJECTTYPE_SHAPE
;
986 OUString
ObjectIdentifier::createDataCurveCID(
987 const OUString
& rSeriesParticle
988 , sal_Int32 nCurveIndex
989 , bool bAverageLine
)
991 OUString
aParticleID( OUString::valueOf( nCurveIndex
) );
992 ObjectType eType
= bAverageLine
? OBJECTTYPE_DATA_AVERAGE_LINE
: OBJECTTYPE_DATA_CURVE
;
993 return createClassifiedIdentifierWithParent( eType
, aParticleID
, rSeriesParticle
);
996 OUString
ObjectIdentifier::createDataCurveEquationCID(
997 const OUString
& rSeriesParticle
998 , sal_Int32 nCurveIndex
)
1000 OUString
aParticleID( OUString::valueOf( nCurveIndex
) );
1001 return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION
, aParticleID
, rSeriesParticle
);
1004 OUString
ObjectIdentifier::addChildParticle( const OUString
& rParticle
, const OUString
& rChildParticle
)
1006 OUStringBuffer
aRet(rParticle
);
1008 if( aRet
.getLength() && !rChildParticle
.isEmpty() )
1009 aRet
.appendAscii(":");
1010 if( !rChildParticle
.isEmpty() )
1011 aRet
.append(rChildParticle
);
1013 return aRet
.makeStringAndClear();
1016 OUString
ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType
, sal_Int32 nIndex
)
1018 OUStringBuffer
aRet( getStringForType( eObjectType
) );
1019 if( aRet
.getLength() )
1021 aRet
.appendAscii("=");
1022 aRet
.append(OUString::valueOf(nIndex
));
1024 return aRet
.makeStringAndClear();
1027 sal_Int32
ObjectIdentifier::getIndexFromParticleOrCID( const OUString
& rParticleOrCID
)
1029 OUString aIndexString
= lcl_getIndexStringAfterString( rParticleOrCID
, "=" );
1030 sal_Int32 nCharacterIndex
=0;
1031 sal_Int32 nRet
= lcl_StringToIndex( aIndexString
.getToken( 0, ',', nCharacterIndex
) );
1036 OUString
ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
1037 , const OUString
& rSeriesParticle
1038 , const OUString
& rDragMethodServiceName
1039 , const OUString
& rDragParameterString
)
1041 OUString
aChildParticle( getStringForType( eSubObjectType
) );
1042 aChildParticle
+=("=");
1044 return createClassifiedIdentifierForParticles(
1045 rSeriesParticle
, aChildParticle
1046 , rDragMethodServiceName
, rDragParameterString
);
1049 OUString
ObjectIdentifier::createPointCID( const OUString
& rPointCID_Stub
, sal_Int32 nIndex
)
1051 OUString
aRet(rPointCID_Stub
);
1052 return aRet
+=OUString::valueOf( nIndex
);
1055 OUString
ObjectIdentifier::getParticleID( const OUString
& rCID
)
1058 sal_Int32 nLast
= rCID
.lastIndexOf('=');
1060 aRet
= rCID
.copy(++nLast
);
1064 OUString
ObjectIdentifier::getFullParentParticle( const OUString
& rCID
)
1068 sal_Int32 nStartPos
= rCID
.lastIndexOf('/');
1072 sal_Int32 nEndPos
= rCID
.lastIndexOf(':');
1073 if( nEndPos
>=0 && nStartPos
< nEndPos
)
1075 aRet
= rCID
.copy(nStartPos
,nEndPos
-nStartPos
);
1082 OUString
ObjectIdentifier::getObjectID( const OUString
& rCID
)
1086 sal_Int32 nStartPos
= rCID
.lastIndexOf('/');
1090 sal_Int32 nEndPos
= rCID
.getLength();
1091 aRet
= rCID
.copy(nStartPos
,nEndPos
-nStartPos
);
1097 bool ObjectIdentifier::isCID( const OUString
& rName
)
1099 return !rName
.isEmpty() && rName
.match( m_aProtocol
);
1102 Reference
< beans::XPropertySet
> ObjectIdentifier::getObjectPropertySet(
1103 const OUString
& rObjectCID
,
1104 const Reference
< chart2::XChartDocument
>& xChartDocument
)
1106 return ObjectIdentifier::getObjectPropertySet(
1107 rObjectCID
, Reference
< frame::XModel
>( xChartDocument
, uno::UNO_QUERY
));
1110 Reference
< beans::XPropertySet
> ObjectIdentifier::getObjectPropertySet(
1111 const OUString
& rObjectCID
1112 , const Reference
< frame::XModel
>& xChartModel
)
1114 //return the model object that is indicated by rObjectCID
1115 if(rObjectCID
.isEmpty())
1117 if(!xChartModel
.is())
1120 Reference
< beans::XPropertySet
> xObjectProperties
= NULL
;
1123 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rObjectCID
);
1124 OUString aParticleID
= ObjectIdentifier::getParticleID( rObjectCID
);
1126 Reference
< XDiagram
> xDiagram
;
1127 Reference
< XCoordinateSystem
> xCooSys
;
1128 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1132 case OBJECTTYPE_PAGE
:
1134 Reference
< XChartDocument
> xChartDocument( xChartModel
, uno::UNO_QUERY
);
1135 if( xChartDocument
.is())
1136 xObjectProperties
.set( xChartDocument
->getPageBackground() );
1139 case OBJECTTYPE_TITLE
:
1141 TitleHelper::eTitleType aTitleType
= getTitleTypeForCID( rObjectCID
);
1142 Reference
< XTitle
> xTitle( TitleHelper::getTitle( aTitleType
, xChartModel
) );
1143 xObjectProperties
.set( xTitle
, uno::UNO_QUERY
);
1146 case OBJECTTYPE_LEGEND
:
1149 xObjectProperties
.set( xDiagram
->getLegend(), uno::UNO_QUERY
);
1152 case OBJECTTYPE_LEGEND_ENTRY
:
1154 case OBJECTTYPE_DIAGRAM
:
1156 xObjectProperties
.set( xDiagram
, uno::UNO_QUERY
);
1159 case OBJECTTYPE_DIAGRAM_WALL
:
1162 xObjectProperties
.set( xDiagram
->getWall() );
1165 case OBJECTTYPE_DIAGRAM_FLOOR
:
1168 xObjectProperties
.set( xDiagram
->getFloor() );
1171 case OBJECTTYPE_AXIS
:
1173 sal_Int32 nDimensionIndex
= -1;
1174 sal_Int32 nAxisIndex
= -1;
1175 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1177 Reference
< chart2::XAxis
> xAxis(
1178 AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
) );
1180 xObjectProperties
.set( xAxis
, uno::UNO_QUERY
);
1183 case OBJECTTYPE_AXIS_UNITLABEL
:
1185 case OBJECTTYPE_GRID
:
1186 case OBJECTTYPE_SUBGRID
:
1188 sal_Int32 nDimensionIndex
= -1;
1189 sal_Int32 nAxisIndex
= -1;
1190 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1192 sal_Int32 nSubGridIndex
= -1;
1193 lcl_parseGridIndices( nSubGridIndex
, rObjectCID
);
1195 xObjectProperties
.set( AxisHelper::getGridProperties( xCooSys
, nDimensionIndex
, nAxisIndex
, nSubGridIndex
) );
1198 case OBJECTTYPE_DATA_LABELS
:
1199 case OBJECTTYPE_DATA_SERIES
:
1201 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID(
1202 rObjectCID
, xChartModel
) );
1204 xObjectProperties
= Reference
< beans::XPropertySet
>( xSeries
, uno::UNO_QUERY
);
1208 case OBJECTTYPE_DATA_LABEL
:
1209 case OBJECTTYPE_DATA_POINT
:
1211 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID(
1212 rObjectCID
, xChartModel
) );
1215 sal_Int32 nIndex
= aParticleID
.toInt32();
1216 xObjectProperties
= xSeries
->getDataPointByIndex( nIndex
);
1220 case OBJECTTYPE_DATA_ERRORS_X
:
1221 case OBJECTTYPE_DATA_ERRORS_Y
:
1222 case OBJECTTYPE_DATA_ERRORS_Z
:
1224 Reference
< XDataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID(
1225 rObjectCID
, xChartModel
) );
1228 Reference
< beans::XPropertySet
> xSeriesProp( xSeries
, uno::UNO_QUERY
);
1229 Reference
< beans::XPropertySet
> xErrorBarProp
;
1230 if( xSeriesProp
.is() )
1234 if ( eObjectType
== OBJECTTYPE_DATA_ERRORS_X
)
1235 errorBar
= "ErrorBarX";
1236 else if (eObjectType
== OBJECTTYPE_DATA_ERRORS_Y
)
1237 errorBar
= "ErrorBarY";
1239 errorBar
= "ErrorBarZ";
1241 xSeriesProp
->getPropertyValue( errorBar
) >>= xErrorBarProp
;
1242 xObjectProperties
= Reference
< beans::XPropertySet
>( xErrorBarProp
, uno::UNO_QUERY
);
1247 case OBJECTTYPE_DATA_AVERAGE_LINE
:
1248 case OBJECTTYPE_DATA_CURVE
:
1249 case OBJECTTYPE_DATA_CURVE_EQUATION
:
1251 Reference
< XRegressionCurveContainer
> xRegressionContainer( ObjectIdentifier::getDataSeriesForCID(
1252 rObjectCID
, xChartModel
), uno::UNO_QUERY
);
1253 if(xRegressionContainer
.is())
1255 sal_Int32 nIndex
= aParticleID
.toInt32();
1256 uno::Sequence
< Reference
< XRegressionCurve
> > aCurveList
=
1257 xRegressionContainer
->getRegressionCurves();
1258 if( nIndex
>= 0 && nIndex
<aCurveList
.getLength() )
1260 if( eObjectType
== OBJECTTYPE_DATA_CURVE_EQUATION
)
1261 xObjectProperties
.set( aCurveList
[nIndex
]->getEquationProperties());
1263 xObjectProperties
.set( aCurveList
[nIndex
], uno::UNO_QUERY
);
1268 case OBJECTTYPE_DATA_STOCK_RANGE
:
1270 case OBJECTTYPE_DATA_STOCK_LOSS
:
1272 Reference
<XChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1273 Reference
< beans::XPropertySet
> xChartTypeProps( xChartType
, uno::UNO_QUERY
);
1274 if(xChartTypeProps
.is())
1275 xChartTypeProps
->getPropertyValue( "BlackDay" ) >>= xObjectProperties
;
1278 case OBJECTTYPE_DATA_STOCK_GAIN
:
1280 Reference
<XChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1281 Reference
< beans::XPropertySet
> xChartTypeProps( xChartType
, uno::UNO_QUERY
);
1282 if(xChartTypeProps
.is())
1283 xChartTypeProps
->getPropertyValue( "WhiteDay" ) >>= xObjectProperties
;
1286 default: //OBJECTTYPE_UNKNOWN
1290 catch(const uno::Exception
& ex
)
1292 ASSERT_EXCEPTION( ex
);
1294 return xObjectProperties
;
1297 Reference
< XAxis
> ObjectIdentifier::getAxisForCID(
1298 const OUString
& rObjectCID
1299 , const Reference
< frame::XModel
>& xChartModel
)
1301 Reference
< XDiagram
> xDiagram
;
1302 Reference
< XCoordinateSystem
> xCooSys
;
1303 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1305 sal_Int32 nDimensionIndex
= -1;
1306 sal_Int32 nAxisIndex
= -1;
1307 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1309 return AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
);
1312 Reference
< XDataSeries
> ObjectIdentifier::getDataSeriesForCID(
1313 const OUString
& rObjectCID
1314 , const Reference
< frame::XModel
>& xChartModel
)
1316 Reference
< XDataSeries
> xSeries(NULL
);
1318 Reference
< XDiagram
> xDiagram
;
1319 Reference
< XCoordinateSystem
> xCooSys
;
1320 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1322 sal_Int32 nChartTypeIndex
= -1;
1323 sal_Int32 nSeriesIndex
= -1;
1324 sal_Int32 nPointIndex
= -1;
1325 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rObjectCID
);
1327 Reference
< XDataSeriesContainer
> xDataSeriesContainer( DiagramHelper::getChartTypeByIndex( xDiagram
, nChartTypeIndex
), uno::UNO_QUERY
);
1328 if( xDataSeriesContainer
.is() )
1330 uno::Sequence
< uno::Reference
< XDataSeries
> > aDataSeriesSeq( xDataSeriesContainer
->getDataSeries() );
1331 if( nSeriesIndex
>= 0 && nSeriesIndex
< aDataSeriesSeq
.getLength() )
1332 xSeries
.set( aDataSeriesSeq
[nSeriesIndex
] );
1338 Reference
< XDiagram
> ObjectIdentifier::getDiagramForCID(
1339 const OUString
& rObjectCID
1340 , const uno::Reference
< frame::XModel
>& xChartModel
)
1342 Reference
< XDiagram
> xDiagram
;
1344 Reference
< XCoordinateSystem
> xCooSys
;
1345 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1350 TitleHelper::eTitleType
ObjectIdentifier::getTitleTypeForCID( const OUString
& rCID
)
1352 TitleHelper::eTitleType
eRet( TitleHelper::MAIN_TITLE
);
1354 OUString aParentParticle
= ObjectIdentifier::getFullParentParticle( rCID
);
1355 const tTitleMap
& rMap
= lcl_getTitleMap();
1356 tTitleMap::const_iterator
aIt( rMap
.begin() );
1357 for( ;aIt
!= rMap
.end(); ++aIt
)
1359 if( aParentParticle
.equals( (*aIt
).second
) )
1361 eRet
= (*aIt
).first
;
1369 OUString
ObjectIdentifier::getSeriesParticleFromCID( const OUString
& rCID
)
1371 sal_Int32 nDiagramIndex
= -1;
1372 sal_Int32 nCooSysIndex
= -1;
1373 lcl_parseCooSysIndices( nDiagramIndex
, nCooSysIndex
, rCID
);
1375 sal_Int32 nChartTypeIndex
= -1;
1376 sal_Int32 nSeriesIndex
= -1;
1377 sal_Int32 nPointIndex
= -1;
1378 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rCID
);
1380 return ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1383 OUString
ObjectIdentifier::getMovedSeriesCID( const OUString
& rObjectCID
, sal_Bool bForward
)
1385 sal_Int32 nDiagramIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, "CID/D=" ) );
1386 sal_Int32 nCooSysIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, "CS=" ) );
1387 sal_Int32 nChartTypeIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, "CT=" ) );
1388 sal_Int32 nSeriesIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, "Series=" ) );
1395 OUString aRet
= ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1396 return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet
);
1399 bool ObjectIdentifier::isValid() const
1401 return ( isAutoGeneratedObject() || isAdditionalShape() );
1404 bool ObjectIdentifier::isAutoGeneratedObject() const
1406 return ( !m_aObjectCID
.isEmpty() );
1409 bool ObjectIdentifier::isAdditionalShape() const
1411 return m_xAdditionalShape
.is();
1414 OUString
ObjectIdentifier::getObjectCID() const
1416 return m_aObjectCID
;
1419 Reference
< drawing::XShape
> ObjectIdentifier::getAdditionalShape() const
1421 return m_xAdditionalShape
;
1424 Any
ObjectIdentifier::getAny() const
1427 if ( isAutoGeneratedObject() )
1429 aAny
= uno::makeAny( getObjectCID() );
1431 else if ( isAdditionalShape() )
1433 aAny
= uno::makeAny( getAdditionalShape() );
1438 //.............................................................................
1440 //.............................................................................
1442 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */