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 .
20 #include <sal/config.h>
25 #include <ObjectIdentifier.hxx>
26 #include <TitleHelper.hxx>
27 #include <ChartModel.hxx>
28 #include <ChartModelHelper.hxx>
29 #include <ChartType.hxx>
30 #include <GridProperties.hxx>
32 #include <AxisHelper.hxx>
33 #include <servicenames_charttypes.hxx>
34 #include <DiagramHelper.hxx>
35 #include <Diagram.hxx>
36 #include <unonames.hxx>
37 #include <BaseCoordinateSystem.hxx>
38 #include <DataSeries.hxx>
39 #include <RegressionCurveModel.hxx>
41 #include <com/sun/star/chart2/XAxis.hpp>
42 #include <com/sun/star/awt/Point.hpp>
43 #include <com/sun/star/drawing/XShape.hpp>
45 #include <rtl/ustrbuf.hxx>
46 #include <comphelper/diagnose_ex.hxx>
47 #include <o3tl/safeint.hxx>
48 #include <o3tl/string_view.hxx>
51 namespace com::sun::star::drawing
{ class XShape
; }
55 using namespace ::com::sun::star
;
56 using namespace ::com::sun::star::chart2
;
58 using ::com::sun::star::uno::Reference
;
59 using ::com::sun::star::uno::Any
;
61 constexpr OUString m_aMultiClick
= u
"MultiClick"_ustr
;
62 constexpr OUString m_aDragMethodEquals
= u
"DragMethod="_ustr
;
63 constexpr OUString m_aDragParameterEquals
= u
"DragParameter="_ustr
;
64 constexpr OUString m_aProtocol
= u
"CID/"_ustr
;
65 constexpr OUString
m_aPieSegmentDragMethodServiceName(u
"PieSegmentDragging"_ustr
);
70 OUString
lcl_createClassificationStringForType( ObjectType eObjectType
71 , std::u16string_view rDragMethodServiceName
72 , std::u16string_view rDragParameterString
78 //these object types are all selected only after their parents was selected before
79 case OBJECTTYPE_LEGEND_ENTRY
: //parent is intended to be OBJECTTYPE_LEGEND
80 case OBJECTTYPE_DATA_POINT
: //parent is intended to be OBJECTTYPE_DATA_SERIES
81 case OBJECTTYPE_DATA_LABEL
: //parent is intended to be OBJECTTYPE_DATA_LABELS
82 case OBJECTTYPE_DATA_ERRORS_X
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
83 case OBJECTTYPE_DATA_ERRORS_Y
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
84 case OBJECTTYPE_DATA_ERRORS_Z
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
90 if( !rDragMethodServiceName
.empty() )
94 aRet
.append( OUString::Concat(m_aDragMethodEquals
) + rDragMethodServiceName
);
96 if( !rDragParameterString
.empty() )
100 aRet
.append( OUString::Concat(m_aDragParameterEquals
) + rDragParameterString
);
103 return aRet
.makeStringAndClear();
106 typedef std::map
< TitleHelper::eTitleType
, OUString
> tTitleMap
;
107 const tTitleMap
& lcl_getTitleMap()
109 //maps the title type to the ParentParticle for that title
110 static tTitleMap s_aTitleMap
{
111 {TitleHelper::MAIN_TITLE
, ""},
112 {TitleHelper::SUB_TITLE
, "D=0"},
113 {TitleHelper::X_AXIS_TITLE
, "D=0:CS=0:Axis=0,0"},
114 {TitleHelper::Y_AXIS_TITLE
, "D=0:CS=0:Axis=1,0"},
115 {TitleHelper::Z_AXIS_TITLE
, "D=0:CS=0:Axis=2,0"},
116 {TitleHelper::SECONDARY_X_AXIS_TITLE
, "D=0:CS=0:Axis=0,1"},
117 {TitleHelper::SECONDARY_Y_AXIS_TITLE
, "D=0:CS=0:Axis=1,1"}};
121 OUString
lcl_getTitleParentParticle( TitleHelper::eTitleType aTitleType
)
125 const tTitleMap
& rMap
= lcl_getTitleMap();
126 tTitleMap::const_iterator
aIt( rMap
.find( aTitleType
) );
127 if( aIt
!= rMap
.end())
128 aRet
= (*aIt
).second
;
133 rtl::Reference
<ChartType
> lcl_getFirstStockChartType( const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
135 rtl::Reference
< Diagram
> xDiagram( xChartModel
->getFirstChartDiagram() );
139 //iterate through all coordinate systems
141 const std::vector
< rtl::Reference
< BaseCoordinateSystem
> > & aCooSysList( xDiagram
->getBaseCoordinateSystems() );
142 for( rtl::Reference
< BaseCoordinateSystem
> const & coords
: aCooSysList
)
144 //iterate through all chart types in the current coordinate system
145 for( rtl::Reference
< ChartType
> const & xChartType
: coords
->getChartTypes2() )
147 OUString aChartType
= xChartType
->getChartType();
148 if( aChartType
.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK
) )
155 std::u16string_view
lcl_getIndexStringAfterString( std::u16string_view rString
, std::u16string_view rSearchString
)
157 size_t nIndexStart
= rString
.rfind( rSearchString
);
158 if( nIndexStart
== std::u16string_view::npos
)
159 return std::u16string_view();
160 nIndexStart
+= rSearchString
.size();
161 size_t nIndexEnd
= rString
.size();
162 size_t nNextColon
= rString
.find( ':', nIndexStart
);
163 if( nNextColon
!= std::u16string_view::npos
)
164 nIndexEnd
= nNextColon
;
165 return rString
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
168 sal_Int32
lcl_StringToIndex( std::u16string_view rIndexString
)
171 if( !rIndexString
.empty() )
173 nRet
= o3tl::toInt32(rIndexString
);
180 void lcl_parseCooSysIndices( sal_Int32
& rnDiagram
, sal_Int32
& rnCooSys
, std::u16string_view rString
)
182 rnDiagram
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"D=" ) );
183 rnCooSys
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"CS=" ) );
186 void lcl_parseAxisIndices( sal_Int32
& rnDimensionIndex
, sal_Int32
& rnAxisIndex
, std::u16string_view rString
)
188 std::u16string_view aAxisIndexString
= lcl_getIndexStringAfterString( rString
, u
":Axis=" );
189 sal_Int32 nCharacterIndex
=0;
190 rnDimensionIndex
= lcl_StringToIndex( o3tl::getToken(aAxisIndexString
, 0, ',', nCharacterIndex
) );
191 rnAxisIndex
= lcl_StringToIndex( o3tl::getToken(aAxisIndexString
, 0, ',', nCharacterIndex
) );
194 void lcl_parseGridIndices( sal_Int32
& rnSubGridIndex
, std::u16string_view rString
)
197 rnSubGridIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
":SubGrid=" ) );
200 void lcl_parseSeriesIndices( sal_Int32
& rnChartTypeIndex
, sal_Int32
& rnSeriesIndex
, sal_Int32
& rnPointIndex
, std::u16string_view rString
)
202 rnChartTypeIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"CT=" ) );
203 rnSeriesIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"Series=" ) );
204 rnPointIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"Point=" ) );
207 void lcl_getDiagramAndCooSys( std::u16string_view rObjectCID
208 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
209 , rtl::Reference
< Diagram
>& xDiagram
210 , rtl::Reference
< BaseCoordinateSystem
>& xCooSys
)
212 sal_Int32 nDiagramIndex
= -1;
213 sal_Int32 nCooSysIndex
= -1;
214 lcl_parseCooSysIndices( nDiagramIndex
, nCooSysIndex
, rObjectCID
);
215 xDiagram
= xChartModel
->getFirstChartDiagram();//todo use nDiagramIndex when more than one diagram is possible in future
219 if( nCooSysIndex
> -1 )
221 const std::vector
< rtl::Reference
< BaseCoordinateSystem
> > aCooSysList( xDiagram
->getBaseCoordinateSystems() );
222 if( o3tl::make_unsigned(nCooSysIndex
) < aCooSysList
.size() )
223 xCooSys
= aCooSysList
[nCooSysIndex
];
227 } //anonymous namespace
229 ObjectIdentifier::ObjectIdentifier()
233 ObjectIdentifier::ObjectIdentifier( OUString aObjectCID
)
234 :m_aObjectCID(std::move( aObjectCID
))
238 ObjectIdentifier::ObjectIdentifier( const Reference
< drawing::XShape
>& rxShape
)
239 : m_xAdditionalShape( rxShape
)
243 ObjectIdentifier::ObjectIdentifier( const Any
& rAny
)
245 const uno::Type
& rType
= rAny
.getValueType();
246 if ( rType
== cppu::UnoType
<OUString
>::get() )
248 rAny
>>= m_aObjectCID
;
250 else if ( rType
== cppu::UnoType
< drawing::XShape
>::get() )
252 rAny
>>= m_xAdditionalShape
;
256 bool ObjectIdentifier::operator==( const ObjectIdentifier
& rOID
) const
258 return areIdenticalObjects( m_aObjectCID
, rOID
.m_aObjectCID
) &&
259 ( m_xAdditionalShape
== rOID
.m_xAdditionalShape
);
262 bool ObjectIdentifier::operator!=( const ObjectIdentifier
& rOID
) const
264 return !operator==( rOID
);
267 bool ObjectIdentifier::operator<( const ObjectIdentifier
& rOID
) const
269 bool bReturn
= false;
270 if ( !(m_aObjectCID
.isEmpty() || rOID
.m_aObjectCID
.isEmpty()) )
272 bReturn
= ( m_aObjectCID
.compareTo( rOID
.m_aObjectCID
) < 0 );
274 else if ( !m_aObjectCID
.isEmpty() )
278 else if ( !rOID
.m_aObjectCID
.isEmpty() )
282 else if ( m_xAdditionalShape
.is() && rOID
.m_xAdditionalShape
.is() )
284 bReturn
= ( m_xAdditionalShape
< rOID
.m_xAdditionalShape
);
289 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
290 const rtl::Reference
< ::chart::Title
>& xTitle
291 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
293 TitleHelper::eTitleType aTitleType
;
295 const std::u16string_view aObjectID
;
296 const std::u16string_view aDragMethodServiceName
;
297 const std::u16string_view aDragParameterString
;
298 if( TitleHelper::getTitleType( aTitleType
, xTitle
, xChartModel
) )
300 enum ObjectType eObjectType
= OBJECTTYPE_TITLE
;
301 OUString aParentParticle
= lcl_getTitleParentParticle( aTitleType
);
302 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
303 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
308 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
309 const Reference
< uno::XInterface
>& xObject
310 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
314 enum ObjectType eObjectType
= OBJECTTYPE_UNKNOWN
;
315 const std::u16string_view aObjectID
;
316 OUString aParentParticle
;
317 const std::u16string_view aDragMethodServiceName
;
318 const std::u16string_view aDragParameterString
;
323 if( ::chart::Title
* pTitle
= dynamic_cast<::chart::Title
*>(xObject
.get()) )
324 return createClassifiedIdentifierForObject(rtl::Reference
<Title
>(pTitle
), xChartModel
);
326 uno::Reference
<chart2::XDataTable
> xDataTable(xObject
, uno::UNO_QUERY
);
329 return createClassifiedIdentifierForParticle(createParticleForDataTable(xChartModel
));
333 rtl::Reference
< Axis
> xAxis
= dynamic_cast<Axis
*>( xObject
.get() );
336 rtl::Reference
<Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
337 rtl::Reference
< BaseCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis
, xDiagram
) );
338 OUString
aCooSysParticle( createParticleForCoordinateSystem( xCooSys
, xChartModel
) );
339 sal_Int32 nDimensionIndex
=-1;
340 sal_Int32 nAxisIndex
=-1;
341 AxisHelper::getIndicesForAxis( xAxis
, xCooSys
, nDimensionIndex
, nAxisIndex
);
342 OUString
aAxisParticle( createParticleForAxis( nDimensionIndex
, nAxisIndex
) );
343 return createClassifiedIdentifierForParticles( aCooSysParticle
, aAxisParticle
);
347 Reference
< XLegend
> xLegend( xObject
, uno::UNO_QUERY
);
350 return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel
) );
354 Reference
< XDiagram
> xDiagram( xObject
, uno::UNO_QUERY
);
357 return createClassifiedIdentifierForParticle( createParticleForDiagram() );
367 catch(const uno::Exception
&)
369 DBG_UNHANDLED_EXCEPTION("chart2");
372 if( eObjectType
!= OBJECTTYPE_UNKNOWN
)
374 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
375 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
379 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
385 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
386 const rtl::Reference
< Legend
>& xLegend
387 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
393 return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel
) );
396 catch(const uno::Exception
&)
398 DBG_UNHANDLED_EXCEPTION("chart2");
401 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
406 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
407 const rtl::Reference
<::chart::Axis
>& xAxis
408 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
415 rtl::Reference
<Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
416 rtl::Reference
< BaseCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis
, xDiagram
) );
417 OUString
aCooSysParticle( createParticleForCoordinateSystem( xCooSys
, xChartModel
) );
418 sal_Int32 nDimensionIndex
=-1;
419 sal_Int32 nAxisIndex
=-1;
420 AxisHelper::getIndicesForAxis( xAxis
, xCooSys
, nDimensionIndex
, nAxisIndex
);
421 OUString
aAxisParticle( createParticleForAxis( nDimensionIndex
, nAxisIndex
) );
422 return createClassifiedIdentifierForParticles( aCooSysParticle
, aAxisParticle
);
425 catch(const uno::Exception
&)
427 DBG_UNHANDLED_EXCEPTION("chart2");
430 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
435 OUString
ObjectIdentifier::createClassifiedIdentifierForParticle(
436 std::u16string_view rParticle
)
438 return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle
, u
"" );
441 OUString
ObjectIdentifier::createClassifiedIdentifierForParticles(
442 std::u16string_view rParentParticle
443 , std::u16string_view rChildParticle
444 , std::u16string_view rDragMethodServiceName
445 , std::u16string_view rDragParameterString
)
447 ObjectType
eObjectType( ObjectIdentifier::getObjectType( rChildParticle
) );
448 if( eObjectType
== OBJECTTYPE_UNKNOWN
)
449 eObjectType
= ObjectIdentifier::getObjectType( rParentParticle
);
451 OUStringBuffer
aRet( m_aProtocol
+
452 lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
453 if(aRet
.getLength() > m_aProtocol
.getLength())
456 if(!rParentParticle
.empty())
458 aRet
.append(rParentParticle
);
459 if( !rChildParticle
.empty() )
462 aRet
.append(rChildParticle
);
464 return aRet
.makeStringAndClear();
467 OUString
ObjectIdentifier::createParticleForDiagram()
469 //TODO: if more than one diagram is implemented, add the correct diagram index here
473 OUString
ObjectIdentifier::createParticleForCoordinateSystem(
474 const rtl::Reference
< BaseCoordinateSystem
>& xCooSys
475 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
479 rtl::Reference
< Diagram
> xDiagram( xChartModel
->getFirstChartDiagram() );
482 std::size_t nCooSysIndex
= 0;
483 const std::vector
< rtl::Reference
< BaseCoordinateSystem
> > & aCooSysList( xDiagram
->getBaseCoordinateSystems() );
484 for( ; nCooSysIndex
< aCooSysList
.size(); ++nCooSysIndex
)
486 if( xCooSys
== aCooSysList
[nCooSysIndex
] )
488 aRet
= ObjectIdentifier::createParticleForDiagram() + ":CS=" + OUString::number( nCooSysIndex
);
497 OUString
ObjectIdentifier::createParticleForAxis(
498 sal_Int32 nDimensionIndex
499 , sal_Int32 nAxisIndex
)
502 OUString::number( nDimensionIndex
) +
504 OUString::number( nAxisIndex
);
507 OUString
ObjectIdentifier::createParticleForGrid(
508 sal_Int32 nDimensionIndex
509 , sal_Int32 nAxisIndex
)
511 OUString aRet
= "Axis=" + OUString::number( nDimensionIndex
)
512 + "," + OUString::number( nAxisIndex
) + ":Grid=0";
517 OUString
ObjectIdentifier::createClassifiedIdentifierForGrid(
518 const Reference
< XAxis
>& xAxis
519 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
520 , sal_Int32 nSubGridIndex
)
522 //-1: main grid, 0: first subgrid etc
524 OUString
aAxisCID( createClassifiedIdentifierForObject( xAxis
, xChartModel
) );
525 OUString
aGridCID( addChildParticle( aAxisCID
526 , createChildParticleWithIndex( OBJECTTYPE_GRID
, 0 ) ) );
527 if( nSubGridIndex
>= 0 )
529 aGridCID
= addChildParticle( aGridCID
530 , createChildParticleWithIndex( OBJECTTYPE_SUBGRID
, 0 ) );
535 OUString
ObjectIdentifier::createParticleForSeries(
536 sal_Int32 nDiagramIndex
, sal_Int32 nCooSysIndex
537 , sal_Int32 nChartTypeIndex
, sal_Int32 nSeriesIndex
)
540 "D=" + OUString::number( nDiagramIndex
) +
541 ":CS=" + OUString::number( nCooSysIndex
) +
542 ":CT=" + OUString::number( nChartTypeIndex
) +
543 ":" + getStringForType( OBJECTTYPE_DATA_SERIES
) + "=" +
544 OUString::number( nSeriesIndex
);
548 OUString
ObjectIdentifier::createParticleForLegend(
549 const rtl::Reference
<::chart::ChartModel
>& )
551 //todo: if more than one diagram is implemented, find the correct diagram which is owner of the given legend
553 return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType( OBJECTTYPE_LEGEND
) + "=";
556 OUString
ObjectIdentifier::createParticleForDataTable(const rtl::Reference
<::chart::ChartModel
>& /* xChartModel */)
558 return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType(OBJECTTYPE_DATA_TABLE
) + "=";
561 OUString
ObjectIdentifier::createClassifiedIdentifier(
562 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_SERIES
563 , std::u16string_view rParticleID
)//e.g. SeriesID
565 return createClassifiedIdentifierWithParent(
566 eObjectType
, rParticleID
, u
"" );
569 OUString
ObjectIdentifier::createClassifiedIdentifierWithParent(
570 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
571 , std::u16string_view rParticleID
//e.g. Point Index or SubGrid Index
572 , std::u16string_view rParentPartical
//e.g. "Series=SeriesID" or "Grid=GridId"
573 , std::u16string_view rDragMethodServiceName
574 , std::u16string_view rDragParameterString
576 //, bool bIsMultiClickObject ) //e.g. true
578 //e.g. "MultiClick/Series=2:Point=34"
580 OUStringBuffer
aRet( m_aProtocol
+
581 lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
582 if(aRet
.getLength() > m_aProtocol
.getLength())
584 aRet
.append(rParentPartical
);
585 if(!rParentPartical
.empty())
588 aRet
.append(getStringForType( eObjectType
) + "=" + rParticleID
);
590 return aRet
.makeStringAndClear();
593 const OUString
& ObjectIdentifier::getPieSegmentDragMethodServiceName()
595 return m_aPieSegmentDragMethodServiceName
;
598 OUString
ObjectIdentifier::createPieSegmentDragParameterString(
599 sal_Int32 nOffsetPercent
600 , const awt::Point
& rMinimumPosition
601 , const awt::Point
& rMaximumPosition
)
603 OUString aRet
= OUString::number( nOffsetPercent
)
604 + "," + OUString::number( rMinimumPosition
.X
)
605 + "," + OUString::number( rMinimumPosition
.Y
)
606 + "," + OUString::number( rMaximumPosition
.X
)
607 + "," + OUString::number( rMaximumPosition
.Y
);
611 bool ObjectIdentifier::parsePieSegmentDragParameterString(
612 std::u16string_view rDragParameterString
613 , sal_Int32
& rOffsetPercent
614 , awt::Point
& rMinimumPosition
615 , awt::Point
& rMaximumPosition
)
617 sal_Int32 nCharacterIndex
= 0;
619 std::u16string_view
aValueString( o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
) );
620 rOffsetPercent
= o3tl::toInt32(aValueString
);
621 if( nCharacterIndex
< 0 )
624 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
625 rMinimumPosition
.X
= o3tl::toInt32(aValueString
);
626 if( nCharacterIndex
< 0 )
629 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
630 rMinimumPosition
.Y
= o3tl::toInt32(aValueString
);
631 if( nCharacterIndex
< 0 )
634 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
635 rMaximumPosition
.X
= o3tl::toInt32(aValueString
);
636 if( nCharacterIndex
< 0 )
639 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
640 rMaximumPosition
.Y
= o3tl::toInt32(aValueString
);
641 return nCharacterIndex
>= 0;
644 std::u16string_view
ObjectIdentifier::getDragMethodServiceName( std::u16string_view rCID
)
646 std::u16string_view aRet
;
648 size_t nIndexStart
= rCID
.find( m_aDragMethodEquals
);
649 if( nIndexStart
!= std::u16string_view::npos
)
651 nIndexStart
= rCID
.find( '=', nIndexStart
);
652 if( nIndexStart
!= std::u16string_view::npos
)
655 size_t nNextSlash
= rCID
.find( '/', nIndexStart
);
656 if( nNextSlash
!= std::u16string_view::npos
)
658 sal_Int32 nIndexEnd
= nNextSlash
;
659 size_t nNextColon
= rCID
.find( ':', nIndexStart
);
660 if( nNextColon
== std::u16string_view::npos
|| nNextColon
< nNextSlash
)
661 nIndexEnd
= nNextColon
;
662 aRet
= rCID
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
669 std::u16string_view
ObjectIdentifier::getDragParameterString( std::u16string_view rCID
)
671 std::u16string_view aRet
;
673 size_t nIndexStart
= rCID
.find( m_aDragParameterEquals
);
674 if( nIndexStart
!= std::u16string_view::npos
)
676 nIndexStart
= rCID
.find( '=', nIndexStart
);
677 if( nIndexStart
!= std::u16string_view::npos
)
680 size_t nNextSlash
= rCID
.find( '/', nIndexStart
);
681 if( nNextSlash
!= std::u16string_view::npos
)
683 sal_Int32 nIndexEnd
= nNextSlash
;
684 size_t nNextColon
= rCID
.find( ':', nIndexStart
);
685 if( nNextColon
== std::u16string_view::npos
|| nNextColon
< nNextSlash
)
686 nIndexEnd
= nNextColon
;
687 aRet
= rCID
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
694 bool ObjectIdentifier::isDragableObject( std::u16string_view rClassifiedIdentifier
)
696 bool bReturn
= false;
697 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
698 switch( eObjectType
)
700 case OBJECTTYPE_TITLE
:
701 case OBJECTTYPE_LEGEND
:
702 case OBJECTTYPE_DIAGRAM
:
703 case OBJECTTYPE_DATA_LABEL
:
704 case OBJECTTYPE_DATA_CURVE_EQUATION
:
705 //case OBJECTTYPE_DIAGRAM_WALL:
709 std::u16string_view
aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier
) );
710 bReturn
= !aDragMethodServiceName
.empty();
716 bool ObjectIdentifier::isDragableObject() const
718 bool bReturn
= false;
719 if ( isAutoGeneratedObject() )
721 bReturn
= isDragableObject( m_aObjectCID
);
723 else if ( isAdditionalShape() )
730 bool ObjectIdentifier::isRotateableObject( std::u16string_view rClassifiedIdentifier
)
732 bool bReturn
= false;
733 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
734 switch( eObjectType
)
736 case OBJECTTYPE_DIAGRAM
:
737 //case OBJECTTYPE_DIAGRAM_WALL:
747 bool ObjectIdentifier::isMultiClickObject( std::u16string_view rClassifiedIdentifier
)
749 //the name of a shape is it's ClassifiedIdentifier
751 //a MultiClickObject is an object that is selectable by more than one click only ;
752 //before a MultiClickObject can be selected it is necessary that a named parent group object
753 //was selected before;
755 //!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:"
756 bool bRet
= o3tl::starts_with(rClassifiedIdentifier
.substr( m_aProtocol
.getLength() ), m_aMultiClick
);
760 bool ObjectIdentifier::areSiblings( std::u16string_view rCID1
, std::u16string_view rCID2
)
763 size_t nLastSign1
= rCID1
.rfind( '=' );
764 size_t nLastSign2
= rCID2
.rfind( '=' );
765 if( nLastSign1
== rCID1
.find( '=' ) )//CID cannot be sibling if only one "=" occurs
767 else if( nLastSign2
== rCID2
.find( '=' ) )//CID cannot be sibling if only one "=" occurs
769 else if( ObjectIdentifier::areIdenticalObjects( rCID1
, rCID2
) )
773 std::u16string_view
aParent1( ObjectIdentifier::getFullParentParticle( rCID1
) );
774 if( !aParent1
.empty() )
776 std::u16string_view
aParent2( ObjectIdentifier::getFullParentParticle( rCID2
) );
777 bRet
=aParent1
== aParent2
;
779 //legend entries are special:
782 if( getObjectType(rCID1
) == OBJECTTYPE_LEGEND_ENTRY
783 && getObjectType(rCID2
) == OBJECTTYPE_LEGEND_ENTRY
)
790 bool ObjectIdentifier::areIdenticalObjects( std::u16string_view rCID1
, std::u16string_view rCID2
)
794 //draggable pie or donut segments need special treatment, as their CIDs do change with offset
796 if( rCID1
.find( m_aPieSegmentDragMethodServiceName
) == std::u16string_view::npos
797 || rCID2
.find( m_aPieSegmentDragMethodServiceName
) == std::u16string_view::npos
)
800 OUString
aID1( ObjectIdentifier::getObjectID( rCID1
) );
801 OUString
aID2( ObjectIdentifier::getObjectID( rCID2
) );
802 if( !aID1
.isEmpty() && aID1
== aID2
)
808 OUString
ObjectIdentifier::getStringForType( ObjectType eObjectType
)
811 switch( eObjectType
)
813 case OBJECTTYPE_PAGE
:
816 case OBJECTTYPE_TITLE
:
819 case OBJECTTYPE_LEGEND
:
822 case OBJECTTYPE_LEGEND_ENTRY
:
825 case OBJECTTYPE_DIAGRAM
:
828 case OBJECTTYPE_DIAGRAM_WALL
:
831 case OBJECTTYPE_DIAGRAM_FLOOR
:
834 case OBJECTTYPE_AXIS
:
837 case OBJECTTYPE_AXIS_UNITLABEL
:
838 aRet
="AxisUnitLabel";
840 case OBJECTTYPE_GRID
:
843 case OBJECTTYPE_SUBGRID
:
846 case OBJECTTYPE_DATA_SERIES
:
849 case OBJECTTYPE_DATA_POINT
:
852 case OBJECTTYPE_DATA_LABELS
:
855 case OBJECTTYPE_DATA_LABEL
:
858 case OBJECTTYPE_DATA_ERRORS_X
:
861 case OBJECTTYPE_DATA_ERRORS_Y
:
864 case OBJECTTYPE_DATA_ERRORS_Z
:
867 case OBJECTTYPE_DATA_CURVE
:
870 case OBJECTTYPE_DATA_CURVE_EQUATION
:
873 case OBJECTTYPE_DATA_AVERAGE_LINE
:
876 case OBJECTTYPE_DATA_STOCK_RANGE
:
879 case OBJECTTYPE_DATA_STOCK_LOSS
:
882 case OBJECTTYPE_DATA_STOCK_GAIN
:
885 case OBJECTTYPE_DATA_TABLE
:
888 default: //OBJECTTYPE_UNKNOWN
894 ObjectType
ObjectIdentifier::getObjectType( std::u16string_view aCID
)
897 size_t nLastSign
= aCID
.rfind( ':' );//last sign before the type string
898 if(nLastSign
== std::u16string_view::npos
)
899 nLastSign
= aCID
.rfind( '/' );
900 if(nLastSign
== std::u16string_view::npos
)
902 size_t nEndIndex
= aCID
.rfind( '=' );
903 if(nEndIndex
== std::u16string_view::npos
)
904 return OBJECTTYPE_UNKNOWN
;
910 aCID
= aCID
.substr(nLastSign
);
911 if( o3tl::starts_with(aCID
, u
"Page") )
912 eRet
= OBJECTTYPE_PAGE
;
913 else if( o3tl::starts_with(aCID
, u
"Title") )
914 eRet
= OBJECTTYPE_TITLE
;
915 else if( o3tl::starts_with(aCID
, u
"LegendEntry") )
916 eRet
= OBJECTTYPE_LEGEND_ENTRY
;
917 else if( o3tl::starts_with(aCID
, u
"Legend") )
918 eRet
= OBJECTTYPE_LEGEND
;
919 else if( o3tl::starts_with(aCID
, u
"DiagramWall") )
920 eRet
= OBJECTTYPE_DIAGRAM_WALL
;
921 else if( o3tl::starts_with(aCID
, u
"DiagramFloor") )
922 eRet
= OBJECTTYPE_DIAGRAM_FLOOR
;
923 else if( o3tl::starts_with(aCID
, u
"D=") )
924 eRet
= OBJECTTYPE_DIAGRAM
;
925 else if( o3tl::starts_with(aCID
, u
"AxisUnitLabel") )
926 eRet
= OBJECTTYPE_AXIS_UNITLABEL
;
927 else if( o3tl::starts_with(aCID
, u
"Axis") )
928 eRet
= OBJECTTYPE_AXIS
;
929 else if( o3tl::starts_with(aCID
, u
"Grid") )
930 eRet
= OBJECTTYPE_GRID
;
931 else if( o3tl::starts_with(aCID
, u
"SubGrid") )
932 eRet
= OBJECTTYPE_SUBGRID
;
933 else if( o3tl::starts_with(aCID
, u
"Series") )
934 eRet
= OBJECTTYPE_DATA_SERIES
;
935 else if( o3tl::starts_with(aCID
, u
"Point") )
936 eRet
= OBJECTTYPE_DATA_POINT
;
937 else if( o3tl::starts_with(aCID
, u
"DataLabels") )
938 eRet
= OBJECTTYPE_DATA_LABELS
;
939 else if( o3tl::starts_with(aCID
, u
"DataLabel") )
940 eRet
= OBJECTTYPE_DATA_LABEL
;
941 else if( o3tl::starts_with(aCID
, u
"ErrorsX") )
942 eRet
= OBJECTTYPE_DATA_ERRORS_X
;
943 else if( o3tl::starts_with(aCID
, u
"ErrorsY") )
944 eRet
= OBJECTTYPE_DATA_ERRORS_Y
;
945 else if( o3tl::starts_with(aCID
, u
"ErrorsZ") )
946 eRet
= OBJECTTYPE_DATA_ERRORS_Z
;
947 else if( o3tl::starts_with(aCID
, u
"Curve") )
948 eRet
= OBJECTTYPE_DATA_CURVE
;
949 else if( o3tl::starts_with(aCID
, u
"Equation") )
950 eRet
= OBJECTTYPE_DATA_CURVE_EQUATION
;
951 else if( o3tl::starts_with(aCID
, u
"Average") )
952 eRet
= OBJECTTYPE_DATA_AVERAGE_LINE
;
953 else if( o3tl::starts_with(aCID
, u
"StockRange") )
954 eRet
= OBJECTTYPE_DATA_STOCK_RANGE
;
955 else if( o3tl::starts_with(aCID
, u
"StockLoss") )
956 eRet
= OBJECTTYPE_DATA_STOCK_LOSS
;
957 else if( o3tl::starts_with(aCID
, u
"StockGain") )
958 eRet
= OBJECTTYPE_DATA_STOCK_GAIN
;
959 else if( o3tl::starts_with(aCID
, u
"DataTable") )
960 eRet
= OBJECTTYPE_DATA_TABLE
;
962 eRet
= OBJECTTYPE_UNKNOWN
;
967 ObjectType
ObjectIdentifier::getObjectType() const
969 ObjectType
eObjectType( OBJECTTYPE_UNKNOWN
);
970 if ( isAutoGeneratedObject() )
972 eObjectType
= getObjectType( m_aObjectCID
);
974 else if ( isAdditionalShape() )
976 eObjectType
= OBJECTTYPE_SHAPE
;
981 OUString
ObjectIdentifier::createDataCurveCID(
982 std::u16string_view rSeriesParticle
983 , sal_Int32 nCurveIndex
984 , bool bAverageLine
)
986 OUString
aParticleID( OUString::number( nCurveIndex
) );
987 ObjectType eType
= bAverageLine
? OBJECTTYPE_DATA_AVERAGE_LINE
: OBJECTTYPE_DATA_CURVE
;
988 return createClassifiedIdentifierWithParent( eType
, aParticleID
, rSeriesParticle
);
991 OUString
ObjectIdentifier::createDataCurveEquationCID(
992 std::u16string_view rSeriesParticle
993 , sal_Int32 nCurveIndex
)
995 OUString
aParticleID( OUString::number( nCurveIndex
) );
996 return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION
, aParticleID
, rSeriesParticle
);
999 OUString
ObjectIdentifier::addChildParticle( std::u16string_view rParticle
, std::u16string_view rChildParticle
)
1001 OUStringBuffer
aRet(rParticle
);
1003 if( !aRet
.isEmpty() && !rChildParticle
.empty() )
1005 if( !rChildParticle
.empty() )
1006 aRet
.append(rChildParticle
);
1008 return aRet
.makeStringAndClear();
1011 OUString
ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType
, sal_Int32 nIndex
)
1013 OUStringBuffer
aRet( getStringForType( eObjectType
) );
1014 if( !aRet
.isEmpty() )
1016 aRet
.append("=" + OUString::number(nIndex
));
1018 return aRet
.makeStringAndClear();
1021 sal_Int32
ObjectIdentifier::getIndexFromParticleOrCID( std::u16string_view rParticleOrCID
)
1023 const std::u16string_view aIndexString
= lcl_getIndexStringAfterString( rParticleOrCID
, u
"=" );
1024 return lcl_StringToIndex( o3tl::getToken(aIndexString
, 0, ',' ) );
1027 OUString
ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
1028 , std::u16string_view rSeriesParticle
1029 , std::u16string_view rDragMethodServiceName
1030 , std::u16string_view rDragParameterString
)
1032 OUString aChildParticle
= getStringForType( eSubObjectType
) + "=";
1034 return createClassifiedIdentifierForParticles(
1035 rSeriesParticle
, aChildParticle
1036 , rDragMethodServiceName
, rDragParameterString
);
1039 OUString
ObjectIdentifier::createPointCID( std::u16string_view rPointCID_Stub
, sal_Int32 nIndex
)
1041 return rPointCID_Stub
+ OUString::number( nIndex
);
1044 std::u16string_view
ObjectIdentifier::getParticleID( std::u16string_view rCID
)
1046 std::u16string_view aRet
;
1047 size_t nLast
= rCID
.rfind('=');
1048 if(nLast
!= std::u16string_view::npos
)
1049 aRet
= rCID
.substr(++nLast
);
1053 std::u16string_view
ObjectIdentifier::getFullParentParticle( std::u16string_view rCID
)
1055 std::u16string_view aRet
;
1057 size_t nStartPos
= rCID
.rfind('/');
1058 if( nStartPos
!= std::u16string_view::npos
)
1061 size_t nEndPos
= rCID
.rfind(':');
1062 if( nEndPos
!= std::u16string_view::npos
&& nStartPos
< nEndPos
)
1064 aRet
= rCID
.substr(nStartPos
,nEndPos
-nStartPos
);
1071 OUString
ObjectIdentifier::getObjectID( std::u16string_view rCID
)
1075 size_t nStartPos
= rCID
.rfind('/');
1076 if( nStartPos
!= std::u16string_view::npos
)
1079 size_t nEndPos
= rCID
.size();
1080 aRet
= rCID
.substr(nStartPos
,nEndPos
-nStartPos
);
1086 bool ObjectIdentifier::isCID( std::u16string_view rName
)
1088 return !rName
.empty() && o3tl::starts_with( rName
, m_aProtocol
);
1091 Reference
< beans::XPropertySet
> ObjectIdentifier::getObjectPropertySet(
1092 std::u16string_view rObjectCID
1093 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1095 //return the model object that is indicated by rObjectCID
1096 if(rObjectCID
.empty())
1098 if(!xChartModel
.is())
1101 Reference
< beans::XPropertySet
> xObjectProperties
;
1104 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rObjectCID
);
1105 std::u16string_view aParticleID
= ObjectIdentifier::getParticleID( rObjectCID
);
1107 rtl::Reference
< Diagram
> xDiagram
;
1108 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1109 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1113 case OBJECTTYPE_PAGE
:
1115 xObjectProperties
.set( xChartModel
->getPageBackground() );
1118 case OBJECTTYPE_TITLE
:
1120 TitleHelper::eTitleType aTitleType
= getTitleTypeForCID( rObjectCID
);
1121 rtl::Reference
< Title
> xTitle( TitleHelper::getTitle( aTitleType
, xChartModel
) );
1122 xObjectProperties
= xTitle
;
1125 case OBJECTTYPE_LEGEND
:
1128 xObjectProperties
.set( xDiagram
->getLegend(), uno::UNO_QUERY
);
1131 case OBJECTTYPE_LEGEND_ENTRY
:
1133 case OBJECTTYPE_DIAGRAM
:
1135 xObjectProperties
= xDiagram
;
1138 case OBJECTTYPE_DIAGRAM_WALL
:
1141 xObjectProperties
.set( xDiagram
->getWall() );
1144 case OBJECTTYPE_DIAGRAM_FLOOR
:
1147 xObjectProperties
.set( xDiagram
->getFloor() );
1150 case OBJECTTYPE_AXIS
:
1152 sal_Int32 nDimensionIndex
= -1;
1153 sal_Int32 nAxisIndex
= -1;
1154 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1156 rtl::Reference
< Axis
> xAxis
=
1157 AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
);
1159 xObjectProperties
= xAxis
;
1162 case OBJECTTYPE_AXIS_UNITLABEL
:
1164 case OBJECTTYPE_GRID
:
1165 case OBJECTTYPE_SUBGRID
:
1167 sal_Int32 nDimensionIndex
= -1;
1168 sal_Int32 nAxisIndex
= -1;
1169 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1171 sal_Int32 nSubGridIndex
= -1;
1172 lcl_parseGridIndices( nSubGridIndex
, rObjectCID
);
1174 xObjectProperties
= AxisHelper::getGridProperties( xCooSys
, nDimensionIndex
, nAxisIndex
, nSubGridIndex
);
1177 case OBJECTTYPE_DATA_LABELS
:
1178 case OBJECTTYPE_DATA_SERIES
:
1180 rtl::Reference
< DataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID(
1181 rObjectCID
, xChartModel
) );
1183 xObjectProperties
= xSeries
;
1187 case OBJECTTYPE_DATA_LABEL
:
1188 case OBJECTTYPE_DATA_POINT
:
1190 rtl::Reference
< DataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID(
1191 rObjectCID
, xChartModel
);
1194 sal_Int32 nIndex
= o3tl::toInt32(aParticleID
);
1195 xObjectProperties
= xSeries
->getDataPointByIndex( nIndex
);
1199 case OBJECTTYPE_DATA_ERRORS_X
:
1200 case OBJECTTYPE_DATA_ERRORS_Y
:
1201 case OBJECTTYPE_DATA_ERRORS_Z
:
1203 rtl::Reference
< DataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID(
1204 rObjectCID
, xChartModel
);
1207 Reference
< beans::XPropertySet
> xErrorBarProp
;
1210 if ( eObjectType
== OBJECTTYPE_DATA_ERRORS_X
)
1211 errorBar
= CHART_UNONAME_ERRORBAR_X
;
1212 else if (eObjectType
== OBJECTTYPE_DATA_ERRORS_Y
)
1213 errorBar
= CHART_UNONAME_ERRORBAR_Y
;
1215 errorBar
= "ErrorBarZ";
1217 xSeries
->getPropertyValue( errorBar
) >>= xErrorBarProp
;
1218 xObjectProperties
= xErrorBarProp
;
1222 case OBJECTTYPE_DATA_AVERAGE_LINE
:
1223 case OBJECTTYPE_DATA_CURVE
:
1224 case OBJECTTYPE_DATA_CURVE_EQUATION
:
1226 rtl::Reference
< DataSeries
> xRegressionContainer
= ObjectIdentifier::getDataSeriesForCID(
1227 rObjectCID
, xChartModel
);
1228 if(xRegressionContainer
.is())
1230 sal_Int32 nIndex
= o3tl::toInt32(aParticleID
);
1231 const std::vector
< rtl::Reference
< RegressionCurveModel
> > & aCurveList
=
1232 xRegressionContainer
->getRegressionCurves2();
1233 if( nIndex
>= 0 && o3tl::make_unsigned(nIndex
) < aCurveList
.size() )
1235 if( eObjectType
== OBJECTTYPE_DATA_CURVE_EQUATION
)
1236 xObjectProperties
= aCurveList
[nIndex
]->getEquationProperties();
1238 xObjectProperties
= aCurveList
[nIndex
];
1243 case OBJECTTYPE_DATA_STOCK_RANGE
:
1245 case OBJECTTYPE_DATA_STOCK_LOSS
:
1247 rtl::Reference
<ChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1249 xChartType
->getPropertyValue( "BlackDay" ) >>= xObjectProperties
;
1252 case OBJECTTYPE_DATA_STOCK_GAIN
:
1254 rtl::Reference
<ChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1256 xChartType
->getPropertyValue( "WhiteDay" ) >>= xObjectProperties
;
1259 case OBJECTTYPE_DATA_TABLE
:
1262 xObjectProperties
.set(xDiagram
->getDataTable(), uno::UNO_QUERY
);
1266 default: //OBJECTTYPE_UNKNOWN
1270 catch(const uno::Exception
&)
1272 DBG_UNHANDLED_EXCEPTION("chart2");
1274 return xObjectProperties
;
1277 rtl::Reference
< Axis
> ObjectIdentifier::getAxisForCID(
1278 std::u16string_view rObjectCID
1279 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1281 rtl::Reference
< Diagram
> xDiagram
;
1282 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1283 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1285 sal_Int32 nDimensionIndex
= -1;
1286 sal_Int32 nAxisIndex
= -1;
1287 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1289 return AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
);
1292 rtl::Reference
< DataSeries
> ObjectIdentifier::getDataSeriesForCID(
1293 std::u16string_view rObjectCID
1294 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1296 rtl::Reference
< Diagram
> xDiagram
;
1297 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1298 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1300 sal_Int32 nChartTypeIndex
= -1;
1301 sal_Int32 nSeriesIndex
= -1;
1302 sal_Int32 nPointIndex
= -1;
1303 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rObjectCID
);
1305 rtl::Reference
< DataSeries
> xSeries
;
1308 rtl::Reference
< ChartType
> xDataSeriesContainer( xDiagram
->getChartTypeByIndex( nChartTypeIndex
) );
1309 if( xDataSeriesContainer
.is() )
1311 const std::vector
< rtl::Reference
< DataSeries
> > & aDataSeriesSeq( xDataSeriesContainer
->getDataSeries2() );
1312 if( nSeriesIndex
>= 0 && o3tl::make_unsigned(nSeriesIndex
) < aDataSeriesSeq
.size() )
1313 xSeries
= aDataSeriesSeq
[nSeriesIndex
];
1319 rtl::Reference
< Diagram
> ObjectIdentifier::getDiagramForCID(
1320 std::u16string_view rObjectCID
1321 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1323 rtl::Reference
< Diagram
> xDiagram
;
1324 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1325 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1330 TitleHelper::eTitleType
ObjectIdentifier::getTitleTypeForCID( std::u16string_view rCID
)
1332 TitleHelper::eTitleType
eRet( TitleHelper::MAIN_TITLE
);
1334 std::u16string_view aParentParticle
= ObjectIdentifier::getFullParentParticle( rCID
);
1335 const tTitleMap
& rMap
= lcl_getTitleMap();
1336 tTitleMap::const_iterator aIt
= std::find_if(rMap
.begin(), rMap
.end(),
1337 [&aParentParticle
](tTitleMap::const_reference rEntry
) { return aParentParticle
== rEntry
.second
; });
1338 if (aIt
!= rMap
.end())
1339 eRet
= (*aIt
).first
;
1344 OUString
ObjectIdentifier::getSeriesParticleFromCID( std::u16string_view rCID
)
1346 sal_Int32 nDiagramIndex
= -1;
1347 sal_Int32 nCooSysIndex
= -1;
1348 lcl_parseCooSysIndices( nDiagramIndex
, nCooSysIndex
, rCID
);
1350 sal_Int32 nChartTypeIndex
= -1;
1351 sal_Int32 nSeriesIndex
= -1;
1352 sal_Int32 nPointIndex
= -1;
1353 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rCID
);
1355 return ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1358 OUString
ObjectIdentifier::getMovedSeriesCID( std::u16string_view rObjectCID
, bool bForward
)
1360 sal_Int32 nDiagramIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CID/D=" ) );
1361 sal_Int32 nCooSysIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CS=" ) );
1362 sal_Int32 nChartTypeIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CT=" ) );
1363 sal_Int32 nSeriesIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"Series=" ) );
1370 OUString aRet
= ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1371 return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet
);
1374 bool ObjectIdentifier::isValid() const
1376 return ( isAutoGeneratedObject() || isAdditionalShape() );
1379 bool ObjectIdentifier::isAutoGeneratedObject() const
1381 return ( !m_aObjectCID
.isEmpty() );
1384 bool ObjectIdentifier::isAdditionalShape() const
1386 return m_xAdditionalShape
.is();
1389 Any
ObjectIdentifier::getAny() const
1392 if ( isAutoGeneratedObject() )
1394 aAny
<<= getObjectCID();
1396 else if ( isAdditionalShape() )
1398 aAny
<<= getAdditionalShape();
1405 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */