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 <ChartType.hxx>
30 #include <AxisHelper.hxx>
31 #include <servicenames_charttypes.hxx>
32 #include <Diagram.hxx>
33 #include <unonames.hxx>
34 #include <BaseCoordinateSystem.hxx>
35 #include <DataSeries.hxx>
36 #include <RegressionCurveModel.hxx>
38 #include <com/sun/star/chart2/XAxis.hpp>
39 #include <com/sun/star/awt/Point.hpp>
40 #include <com/sun/star/drawing/XShape.hpp>
42 #include <rtl/ustrbuf.hxx>
43 #include <comphelper/diagnose_ex.hxx>
44 #include <o3tl/safeint.hxx>
45 #include <o3tl/string_view.hxx>
48 namespace com::sun::star::drawing
{ class XShape
; }
52 using namespace ::com::sun::star
;
53 using namespace ::com::sun::star::chart2
;
55 using ::com::sun::star::uno::Reference
;
56 using ::com::sun::star::uno::Any
;
58 constexpr OUString m_aMultiClick
= u
"MultiClick"_ustr
;
59 constexpr OUString m_aDragMethodEquals
= u
"DragMethod="_ustr
;
60 constexpr OUString m_aDragParameterEquals
= u
"DragParameter="_ustr
;
61 constexpr OUString m_aProtocol
= u
"CID/"_ustr
;
62 constexpr OUString
m_aPieSegmentDragMethodServiceName(u
"PieSegmentDragging"_ustr
);
67 OUString
lcl_createClassificationStringForType( ObjectType eObjectType
68 , std::u16string_view rDragMethodServiceName
69 , std::u16string_view rDragParameterString
75 //these object types are all selected only after their parents was selected before
76 case OBJECTTYPE_LEGEND_ENTRY
: //parent is intended to be OBJECTTYPE_LEGEND
77 case OBJECTTYPE_DATA_POINT
: //parent is intended to be OBJECTTYPE_DATA_SERIES
78 case OBJECTTYPE_DATA_LABEL
: //parent is intended to be OBJECTTYPE_DATA_LABELS
79 case OBJECTTYPE_DATA_ERRORS_X
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
80 case OBJECTTYPE_DATA_ERRORS_Y
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
81 case OBJECTTYPE_DATA_ERRORS_Z
: //parent is intended to be OBJECTTYPE_DATA_ERRORS
87 if( !rDragMethodServiceName
.empty() )
91 aRet
.append( OUString::Concat(m_aDragMethodEquals
) + rDragMethodServiceName
);
93 if( !rDragParameterString
.empty() )
97 aRet
.append( OUString::Concat(m_aDragParameterEquals
) + rDragParameterString
);
100 return aRet
.makeStringAndClear();
103 typedef std::map
< TitleHelper::eTitleType
, OUString
> tTitleMap
;
104 const tTitleMap
& lcl_getTitleMap()
106 //maps the title type to the ParentParticle for that title
107 static tTitleMap s_aTitleMap
{
108 {TitleHelper::MAIN_TITLE
, ""},
109 {TitleHelper::SUB_TITLE
, "D=0"},
110 {TitleHelper::X_AXIS_TITLE
, "D=0:CS=0:Axis=0,0"},
111 {TitleHelper::Y_AXIS_TITLE
, "D=0:CS=0:Axis=1,0"},
112 {TitleHelper::Z_AXIS_TITLE
, "D=0:CS=0:Axis=2,0"},
113 {TitleHelper::SECONDARY_X_AXIS_TITLE
, "D=0:CS=0:Axis=0,1"},
114 {TitleHelper::SECONDARY_Y_AXIS_TITLE
, "D=0:CS=0:Axis=1,1"}};
118 OUString
lcl_getTitleParentParticle( TitleHelper::eTitleType aTitleType
)
122 const tTitleMap
& rMap
= lcl_getTitleMap();
123 tTitleMap::const_iterator
aIt( rMap
.find( aTitleType
) );
124 if( aIt
!= rMap
.end())
125 aRet
= (*aIt
).second
;
130 rtl::Reference
<ChartType
> lcl_getFirstStockChartType( const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
132 rtl::Reference
< Diagram
> xDiagram( xChartModel
->getFirstChartDiagram() );
136 //iterate through all coordinate systems
138 const std::vector
< rtl::Reference
< BaseCoordinateSystem
> > & aCooSysList( xDiagram
->getBaseCoordinateSystems() );
139 for( rtl::Reference
< BaseCoordinateSystem
> const & coords
: aCooSysList
)
141 //iterate through all chart types in the current coordinate system
142 for( rtl::Reference
< ChartType
> const & xChartType
: coords
->getChartTypes2() )
144 OUString aChartType
= xChartType
->getChartType();
145 if( aChartType
.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK
) )
152 std::u16string_view
lcl_getIndexStringAfterString( std::u16string_view rString
, std::u16string_view rSearchString
)
154 size_t nIndexStart
= rString
.rfind( rSearchString
);
155 if( nIndexStart
== std::u16string_view::npos
)
156 return std::u16string_view();
157 nIndexStart
+= rSearchString
.size();
158 size_t nIndexEnd
= rString
.size();
159 size_t nNextColon
= rString
.find( ':', nIndexStart
);
160 if( nNextColon
!= std::u16string_view::npos
)
161 nIndexEnd
= nNextColon
;
162 return rString
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
165 sal_Int32
lcl_StringToIndex( std::u16string_view rIndexString
)
168 if( !rIndexString
.empty() )
170 nRet
= o3tl::toInt32(rIndexString
);
177 void lcl_parseCooSysIndices( sal_Int32
& rnDiagram
, sal_Int32
& rnCooSys
, std::u16string_view rString
)
179 rnDiagram
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"D=" ) );
180 rnCooSys
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"CS=" ) );
183 void lcl_parseAxisIndices( sal_Int32
& rnDimensionIndex
, sal_Int32
& rnAxisIndex
, std::u16string_view rString
)
185 std::u16string_view aAxisIndexString
= lcl_getIndexStringAfterString( rString
, u
":Axis=" );
186 sal_Int32 nCharacterIndex
=0;
187 rnDimensionIndex
= lcl_StringToIndex( o3tl::getToken(aAxisIndexString
, 0, ',', nCharacterIndex
) );
188 rnAxisIndex
= lcl_StringToIndex( o3tl::getToken(aAxisIndexString
, 0, ',', nCharacterIndex
) );
191 void lcl_parseGridIndices( sal_Int32
& rnSubGridIndex
, std::u16string_view rString
)
194 rnSubGridIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
":SubGrid=" ) );
197 void lcl_parseSeriesIndices( sal_Int32
& rnChartTypeIndex
, sal_Int32
& rnSeriesIndex
, sal_Int32
& rnPointIndex
, std::u16string_view rString
)
199 rnChartTypeIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"CT=" ) );
200 rnSeriesIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"Series=" ) );
201 rnPointIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rString
, u
"Point=" ) );
204 void lcl_getDiagramAndCooSys( std::u16string_view rObjectCID
205 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
206 , rtl::Reference
< Diagram
>& xDiagram
207 , rtl::Reference
< BaseCoordinateSystem
>& xCooSys
)
209 sal_Int32 nDiagramIndex
= -1;
210 sal_Int32 nCooSysIndex
= -1;
211 lcl_parseCooSysIndices( nDiagramIndex
, nCooSysIndex
, rObjectCID
);
212 xDiagram
= xChartModel
->getFirstChartDiagram();//todo use nDiagramIndex when more than one diagram is possible in future
216 if( nCooSysIndex
> -1 )
218 const std::vector
< rtl::Reference
< BaseCoordinateSystem
> > aCooSysList( xDiagram
->getBaseCoordinateSystems() );
219 if( o3tl::make_unsigned(nCooSysIndex
) < aCooSysList
.size() )
220 xCooSys
= aCooSysList
[nCooSysIndex
];
224 } //anonymous namespace
226 ObjectIdentifier::ObjectIdentifier()
230 ObjectIdentifier::ObjectIdentifier( OUString aObjectCID
)
231 :m_aObjectCID(std::move( aObjectCID
))
235 ObjectIdentifier::ObjectIdentifier( const Reference
< drawing::XShape
>& rxShape
)
236 : m_xAdditionalShape( rxShape
)
240 ObjectIdentifier::ObjectIdentifier( const Any
& rAny
)
242 const uno::Type
& rType
= rAny
.getValueType();
243 if ( rType
== cppu::UnoType
<OUString
>::get() )
245 rAny
>>= m_aObjectCID
;
247 else if ( rType
== cppu::UnoType
< drawing::XShape
>::get() )
249 rAny
>>= m_xAdditionalShape
;
253 bool ObjectIdentifier::operator==( const ObjectIdentifier
& rOID
) const
255 return areIdenticalObjects( m_aObjectCID
, rOID
.m_aObjectCID
) &&
256 ( m_xAdditionalShape
== rOID
.m_xAdditionalShape
);
259 bool ObjectIdentifier::operator<( const ObjectIdentifier
& rOID
) const
261 bool bReturn
= false;
262 if ( !(m_aObjectCID
.isEmpty() || rOID
.m_aObjectCID
.isEmpty()) )
264 bReturn
= ( m_aObjectCID
.compareTo( rOID
.m_aObjectCID
) < 0 );
266 else if ( !m_aObjectCID
.isEmpty() )
270 else if ( !rOID
.m_aObjectCID
.isEmpty() )
274 else if ( m_xAdditionalShape
.is() && rOID
.m_xAdditionalShape
.is() )
276 bReturn
= ( m_xAdditionalShape
< rOID
.m_xAdditionalShape
);
281 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
282 const rtl::Reference
< ::chart::Title
>& xTitle
283 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
285 TitleHelper::eTitleType aTitleType
;
287 const std::u16string_view aObjectID
;
288 const std::u16string_view aDragMethodServiceName
;
289 const std::u16string_view aDragParameterString
;
290 if( TitleHelper::getTitleType( aTitleType
, xTitle
, xChartModel
) )
292 enum ObjectType eObjectType
= OBJECTTYPE_TITLE
;
293 OUString aParentParticle
= lcl_getTitleParentParticle( aTitleType
);
294 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
295 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
300 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
301 const Reference
< uno::XInterface
>& xObject
302 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
306 enum ObjectType eObjectType
= OBJECTTYPE_UNKNOWN
;
307 const std::u16string_view aObjectID
;
308 OUString aParentParticle
;
309 const std::u16string_view aDragMethodServiceName
;
310 const std::u16string_view aDragParameterString
;
315 if( ::chart::Title
* pTitle
= dynamic_cast<::chart::Title
*>(xObject
.get()) )
316 return createClassifiedIdentifierForObject(rtl::Reference
<Title
>(pTitle
), xChartModel
);
318 uno::Reference
<chart2::XDataTable
> xDataTable(xObject
, uno::UNO_QUERY
);
321 return createClassifiedIdentifierForParticle(createParticleForDataTable(xChartModel
));
325 rtl::Reference
< Axis
> xAxis
= dynamic_cast<Axis
*>( xObject
.get() );
328 rtl::Reference
<Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
329 rtl::Reference
< BaseCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis
, xDiagram
) );
330 OUString
aCooSysParticle( createParticleForCoordinateSystem( xCooSys
, xChartModel
) );
331 sal_Int32 nDimensionIndex
=-1;
332 sal_Int32 nAxisIndex
=-1;
333 AxisHelper::getIndicesForAxis( xAxis
, xCooSys
, nDimensionIndex
, nAxisIndex
);
334 OUString
aAxisParticle( createParticleForAxis( nDimensionIndex
, nAxisIndex
) );
335 return createClassifiedIdentifierForParticles( aCooSysParticle
, aAxisParticle
);
339 Reference
< XLegend
> xLegend( xObject
, uno::UNO_QUERY
);
342 return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel
) );
346 Reference
< XDiagram
> xDiagram( xObject
, uno::UNO_QUERY
);
349 return createClassifiedIdentifierForParticle( createParticleForDiagram() );
359 catch(const uno::Exception
&)
361 DBG_UNHANDLED_EXCEPTION("chart2");
364 if( eObjectType
!= OBJECTTYPE_UNKNOWN
)
366 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
367 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
371 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
377 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
378 const rtl::Reference
< Legend
>& xLegend
379 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
385 return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel
) );
388 catch(const uno::Exception
&)
390 DBG_UNHANDLED_EXCEPTION("chart2");
393 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
398 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
399 const rtl::Reference
<::chart::Axis
>& xAxis
400 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
407 rtl::Reference
<Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
408 rtl::Reference
< BaseCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis
, xDiagram
) );
409 OUString
aCooSysParticle( createParticleForCoordinateSystem( xCooSys
, xChartModel
) );
410 sal_Int32 nDimensionIndex
=-1;
411 sal_Int32 nAxisIndex
=-1;
412 AxisHelper::getIndicesForAxis( xAxis
, xCooSys
, nDimensionIndex
, nAxisIndex
);
413 OUString
aAxisParticle( createParticleForAxis( nDimensionIndex
, nAxisIndex
) );
414 return createClassifiedIdentifierForParticles( aCooSysParticle
, aAxisParticle
);
417 catch(const uno::Exception
&)
419 DBG_UNHANDLED_EXCEPTION("chart2");
422 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
427 OUString
ObjectIdentifier::createClassifiedIdentifierForParticle(
428 std::u16string_view rParticle
)
430 return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle
, u
"" );
433 OUString
ObjectIdentifier::createClassifiedIdentifierForParticles(
434 std::u16string_view rParentParticle
435 , std::u16string_view rChildParticle
436 , std::u16string_view rDragMethodServiceName
437 , std::u16string_view rDragParameterString
)
439 ObjectType
eObjectType( ObjectIdentifier::getObjectType( rChildParticle
) );
440 if( eObjectType
== OBJECTTYPE_UNKNOWN
)
441 eObjectType
= ObjectIdentifier::getObjectType( rParentParticle
);
443 OUStringBuffer
aRet( m_aProtocol
+
444 lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
445 if(aRet
.getLength() > m_aProtocol
.getLength())
448 if(!rParentParticle
.empty())
450 aRet
.append(rParentParticle
);
451 if( !rChildParticle
.empty() )
454 aRet
.append(rChildParticle
);
456 return aRet
.makeStringAndClear();
459 OUString
ObjectIdentifier::createParticleForDiagram()
461 //TODO: if more than one diagram is implemented, add the correct diagram index here
465 OUString
ObjectIdentifier::createParticleForCoordinateSystem(
466 const rtl::Reference
< BaseCoordinateSystem
>& xCooSys
467 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
471 rtl::Reference
< Diagram
> xDiagram( xChartModel
->getFirstChartDiagram() );
474 std::size_t nCooSysIndex
= 0;
475 const std::vector
< rtl::Reference
< BaseCoordinateSystem
> > & aCooSysList( xDiagram
->getBaseCoordinateSystems() );
476 for( ; nCooSysIndex
< aCooSysList
.size(); ++nCooSysIndex
)
478 if( xCooSys
== aCooSysList
[nCooSysIndex
] )
480 aRet
= ObjectIdentifier::createParticleForDiagram() + ":CS=" + OUString::number( nCooSysIndex
);
489 OUString
ObjectIdentifier::createParticleForAxis(
490 sal_Int32 nDimensionIndex
491 , sal_Int32 nAxisIndex
)
494 OUString::number( nDimensionIndex
) +
496 OUString::number( nAxisIndex
);
499 OUString
ObjectIdentifier::createParticleForGrid(
500 sal_Int32 nDimensionIndex
501 , sal_Int32 nAxisIndex
)
503 OUString aRet
= "Axis=" + OUString::number( nDimensionIndex
)
504 + "," + OUString::number( nAxisIndex
) + ":Grid=0";
509 OUString
ObjectIdentifier::createClassifiedIdentifierForGrid(
510 const Reference
< XAxis
>& xAxis
511 , const rtl::Reference
<::chart::ChartModel
>& 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
)
532 "D=" + OUString::number( nDiagramIndex
) +
533 ":CS=" + OUString::number( nCooSysIndex
) +
534 ":CT=" + OUString::number( nChartTypeIndex
) +
535 ":" + getStringForType( OBJECTTYPE_DATA_SERIES
) + "=" +
536 OUString::number( nSeriesIndex
);
540 OUString
ObjectIdentifier::createParticleForLegend(
541 const rtl::Reference
<::chart::ChartModel
>& )
543 //todo: if more than one diagram is implemented, find the correct diagram which is owner of the given legend
545 return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType( OBJECTTYPE_LEGEND
) + "=";
548 OUString
ObjectIdentifier::createParticleForDataTable(const rtl::Reference
<::chart::ChartModel
>& /* xChartModel */)
550 return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType(OBJECTTYPE_DATA_TABLE
) + "=";
553 OUString
ObjectIdentifier::createClassifiedIdentifier(
554 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_SERIES
555 , std::u16string_view rParticleID
)//e.g. SeriesID
557 return createClassifiedIdentifierWithParent(
558 eObjectType
, rParticleID
, u
"" );
561 OUString
ObjectIdentifier::createClassifiedIdentifierWithParent(
562 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
563 , std::u16string_view rParticleID
//e.g. Point Index or SubGrid Index
564 , std::u16string_view rParentPartical
//e.g. "Series=SeriesID" or "Grid=GridId"
565 , std::u16string_view rDragMethodServiceName
566 , std::u16string_view rDragParameterString
568 //, bool bIsMultiClickObject ) //e.g. true
570 //e.g. "MultiClick/Series=2:Point=34"
572 OUStringBuffer
aRet( m_aProtocol
+
573 lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
574 if(aRet
.getLength() > m_aProtocol
.getLength())
576 aRet
.append(rParentPartical
);
577 if(!rParentPartical
.empty())
580 aRet
.append(getStringForType( eObjectType
) + "=" + rParticleID
);
582 return aRet
.makeStringAndClear();
585 const OUString
& ObjectIdentifier::getPieSegmentDragMethodServiceName()
587 return m_aPieSegmentDragMethodServiceName
;
590 OUString
ObjectIdentifier::createPieSegmentDragParameterString(
591 sal_Int32 nOffsetPercent
592 , const awt::Point
& rMinimumPosition
593 , const awt::Point
& rMaximumPosition
)
595 OUString aRet
= OUString::number( nOffsetPercent
)
596 + "," + OUString::number( rMinimumPosition
.X
)
597 + "," + OUString::number( rMinimumPosition
.Y
)
598 + "," + OUString::number( rMaximumPosition
.X
)
599 + "," + OUString::number( rMaximumPosition
.Y
);
603 bool ObjectIdentifier::parsePieSegmentDragParameterString(
604 std::u16string_view rDragParameterString
605 , sal_Int32
& rOffsetPercent
606 , awt::Point
& rMinimumPosition
607 , awt::Point
& rMaximumPosition
)
609 sal_Int32 nCharacterIndex
= 0;
611 std::u16string_view
aValueString( o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
) );
612 rOffsetPercent
= o3tl::toInt32(aValueString
);
613 if( nCharacterIndex
< 0 )
616 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
617 rMinimumPosition
.X
= o3tl::toInt32(aValueString
);
618 if( nCharacterIndex
< 0 )
621 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
622 rMinimumPosition
.Y
= o3tl::toInt32(aValueString
);
623 if( nCharacterIndex
< 0 )
626 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
627 rMaximumPosition
.X
= o3tl::toInt32(aValueString
);
628 if( nCharacterIndex
< 0 )
631 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
632 rMaximumPosition
.Y
= o3tl::toInt32(aValueString
);
633 return nCharacterIndex
>= 0;
636 std::u16string_view
ObjectIdentifier::getDragMethodServiceName( std::u16string_view rCID
)
638 std::u16string_view aRet
;
640 size_t nIndexStart
= rCID
.find( m_aDragMethodEquals
);
641 if( nIndexStart
!= std::u16string_view::npos
)
643 nIndexStart
= rCID
.find( '=', nIndexStart
);
644 if( nIndexStart
!= std::u16string_view::npos
)
647 size_t nNextSlash
= rCID
.find( '/', nIndexStart
);
648 if( nNextSlash
!= std::u16string_view::npos
)
650 sal_Int32 nIndexEnd
= nNextSlash
;
651 size_t nNextColon
= rCID
.find( ':', nIndexStart
);
652 if( nNextColon
== std::u16string_view::npos
|| nNextColon
< nNextSlash
)
653 nIndexEnd
= nNextColon
;
654 aRet
= rCID
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
661 std::u16string_view
ObjectIdentifier::getDragParameterString( std::u16string_view rCID
)
663 std::u16string_view aRet
;
665 size_t nIndexStart
= rCID
.find( m_aDragParameterEquals
);
666 if( nIndexStart
!= std::u16string_view::npos
)
668 nIndexStart
= rCID
.find( '=', nIndexStart
);
669 if( nIndexStart
!= std::u16string_view::npos
)
672 size_t nNextSlash
= rCID
.find( '/', nIndexStart
);
673 if( nNextSlash
!= std::u16string_view::npos
)
675 sal_Int32 nIndexEnd
= nNextSlash
;
676 size_t nNextColon
= rCID
.find( ':', nIndexStart
);
677 if( nNextColon
== std::u16string_view::npos
|| nNextColon
< nNextSlash
)
678 nIndexEnd
= nNextColon
;
679 aRet
= rCID
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
686 bool ObjectIdentifier::isDragableObject( std::u16string_view rClassifiedIdentifier
)
688 bool bReturn
= false;
689 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
690 switch( eObjectType
)
692 case OBJECTTYPE_TITLE
:
693 case OBJECTTYPE_LEGEND
:
694 case OBJECTTYPE_DIAGRAM
:
695 case OBJECTTYPE_DATA_LABEL
:
696 case OBJECTTYPE_DATA_CURVE_EQUATION
:
697 //case OBJECTTYPE_DIAGRAM_WALL:
701 std::u16string_view
aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier
) );
702 bReturn
= !aDragMethodServiceName
.empty();
708 bool ObjectIdentifier::isDragableObject() const
710 bool bReturn
= false;
711 if ( isAutoGeneratedObject() )
713 bReturn
= isDragableObject( m_aObjectCID
);
715 else if ( isAdditionalShape() )
722 bool ObjectIdentifier::isRotateableObject( std::u16string_view rClassifiedIdentifier
)
724 bool bReturn
= false;
725 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
726 switch( eObjectType
)
728 case OBJECTTYPE_DIAGRAM
:
729 //case OBJECTTYPE_DIAGRAM_WALL:
739 bool ObjectIdentifier::isMultiClickObject( std::u16string_view rClassifiedIdentifier
)
741 //the name of a shape is it's ClassifiedIdentifier
743 //a MultiClickObject is an object that is selectable by more than one click only ;
744 //before a MultiClickObject can be selected it is necessary that a named parent group object
745 //was selected before;
747 //!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:"
748 bool bRet
= o3tl::starts_with(rClassifiedIdentifier
.substr( m_aProtocol
.getLength() ), m_aMultiClick
);
752 bool ObjectIdentifier::areSiblings( std::u16string_view rCID1
, std::u16string_view rCID2
)
755 size_t nLastSign1
= rCID1
.rfind( '=' );
756 size_t nLastSign2
= rCID2
.rfind( '=' );
757 if( nLastSign1
== rCID1
.find( '=' ) )//CID cannot be sibling if only one "=" occurs
759 else if( nLastSign2
== rCID2
.find( '=' ) )//CID cannot be sibling if only one "=" occurs
761 else if( ObjectIdentifier::areIdenticalObjects( rCID1
, rCID2
) )
765 std::u16string_view
aParent1( ObjectIdentifier::getFullParentParticle( rCID1
) );
766 if( !aParent1
.empty() )
768 std::u16string_view
aParent2( ObjectIdentifier::getFullParentParticle( rCID2
) );
769 bRet
=aParent1
== aParent2
;
771 //legend entries are special:
774 if( getObjectType(rCID1
) == OBJECTTYPE_LEGEND_ENTRY
775 && getObjectType(rCID2
) == OBJECTTYPE_LEGEND_ENTRY
)
782 bool ObjectIdentifier::areIdenticalObjects( std::u16string_view rCID1
, std::u16string_view rCID2
)
786 //draggable pie or donut segments need special treatment, as their CIDs do change with offset
788 if( rCID1
.find( m_aPieSegmentDragMethodServiceName
) == std::u16string_view::npos
789 || rCID2
.find( m_aPieSegmentDragMethodServiceName
) == std::u16string_view::npos
)
792 OUString
aID1( ObjectIdentifier::getObjectID( rCID1
) );
793 OUString
aID2( ObjectIdentifier::getObjectID( rCID2
) );
794 if( !aID1
.isEmpty() && aID1
== aID2
)
800 OUString
ObjectIdentifier::getStringForType( ObjectType eObjectType
)
803 switch( eObjectType
)
805 case OBJECTTYPE_PAGE
:
808 case OBJECTTYPE_TITLE
:
811 case OBJECTTYPE_LEGEND
:
814 case OBJECTTYPE_LEGEND_ENTRY
:
817 case OBJECTTYPE_DIAGRAM
:
820 case OBJECTTYPE_DIAGRAM_WALL
:
823 case OBJECTTYPE_DIAGRAM_FLOOR
:
826 case OBJECTTYPE_AXIS
:
829 case OBJECTTYPE_AXIS_UNITLABEL
:
830 aRet
="AxisUnitLabel";
832 case OBJECTTYPE_GRID
:
835 case OBJECTTYPE_SUBGRID
:
838 case OBJECTTYPE_DATA_SERIES
:
841 case OBJECTTYPE_DATA_POINT
:
844 case OBJECTTYPE_DATA_LABELS
:
847 case OBJECTTYPE_DATA_LABEL
:
850 case OBJECTTYPE_DATA_ERRORS_X
:
853 case OBJECTTYPE_DATA_ERRORS_Y
:
856 case OBJECTTYPE_DATA_ERRORS_Z
:
859 case OBJECTTYPE_DATA_CURVE
:
862 case OBJECTTYPE_DATA_CURVE_EQUATION
:
865 case OBJECTTYPE_DATA_AVERAGE_LINE
:
868 case OBJECTTYPE_DATA_STOCK_RANGE
:
871 case OBJECTTYPE_DATA_STOCK_LOSS
:
874 case OBJECTTYPE_DATA_STOCK_GAIN
:
877 case OBJECTTYPE_DATA_TABLE
:
880 default: //OBJECTTYPE_UNKNOWN
886 ObjectType
ObjectIdentifier::getObjectType( std::u16string_view aCID
)
889 size_t nLastSign
= aCID
.rfind( ':' );//last sign before the type string
890 if(nLastSign
== std::u16string_view::npos
)
891 nLastSign
= aCID
.rfind( '/' );
892 if(nLastSign
== std::u16string_view::npos
)
894 size_t nEndIndex
= aCID
.rfind( '=' );
895 if(nEndIndex
== std::u16string_view::npos
)
896 return OBJECTTYPE_UNKNOWN
;
902 aCID
= aCID
.substr(nLastSign
);
903 if( o3tl::starts_with(aCID
, u
"Page") )
904 eRet
= OBJECTTYPE_PAGE
;
905 else if( o3tl::starts_with(aCID
, u
"Title") )
906 eRet
= OBJECTTYPE_TITLE
;
907 else if( o3tl::starts_with(aCID
, u
"LegendEntry") )
908 eRet
= OBJECTTYPE_LEGEND_ENTRY
;
909 else if( o3tl::starts_with(aCID
, u
"Legend") )
910 eRet
= OBJECTTYPE_LEGEND
;
911 else if( o3tl::starts_with(aCID
, u
"DiagramWall") )
912 eRet
= OBJECTTYPE_DIAGRAM_WALL
;
913 else if( o3tl::starts_with(aCID
, u
"DiagramFloor") )
914 eRet
= OBJECTTYPE_DIAGRAM_FLOOR
;
915 else if( o3tl::starts_with(aCID
, u
"D=") )
916 eRet
= OBJECTTYPE_DIAGRAM
;
917 else if( o3tl::starts_with(aCID
, u
"AxisUnitLabel") )
918 eRet
= OBJECTTYPE_AXIS_UNITLABEL
;
919 else if( o3tl::starts_with(aCID
, u
"Axis") )
920 eRet
= OBJECTTYPE_AXIS
;
921 else if( o3tl::starts_with(aCID
, u
"Grid") )
922 eRet
= OBJECTTYPE_GRID
;
923 else if( o3tl::starts_with(aCID
, u
"SubGrid") )
924 eRet
= OBJECTTYPE_SUBGRID
;
925 else if( o3tl::starts_with(aCID
, u
"Series") )
926 eRet
= OBJECTTYPE_DATA_SERIES
;
927 else if( o3tl::starts_with(aCID
, u
"Point") )
928 eRet
= OBJECTTYPE_DATA_POINT
;
929 else if( o3tl::starts_with(aCID
, u
"DataLabels") )
930 eRet
= OBJECTTYPE_DATA_LABELS
;
931 else if( o3tl::starts_with(aCID
, u
"DataLabel") )
932 eRet
= OBJECTTYPE_DATA_LABEL
;
933 else if( o3tl::starts_with(aCID
, u
"ErrorsX") )
934 eRet
= OBJECTTYPE_DATA_ERRORS_X
;
935 else if( o3tl::starts_with(aCID
, u
"ErrorsY") )
936 eRet
= OBJECTTYPE_DATA_ERRORS_Y
;
937 else if( o3tl::starts_with(aCID
, u
"ErrorsZ") )
938 eRet
= OBJECTTYPE_DATA_ERRORS_Z
;
939 else if( o3tl::starts_with(aCID
, u
"Curve") )
940 eRet
= OBJECTTYPE_DATA_CURVE
;
941 else if( o3tl::starts_with(aCID
, u
"Equation") )
942 eRet
= OBJECTTYPE_DATA_CURVE_EQUATION
;
943 else if( o3tl::starts_with(aCID
, u
"Average") )
944 eRet
= OBJECTTYPE_DATA_AVERAGE_LINE
;
945 else if( o3tl::starts_with(aCID
, u
"StockRange") )
946 eRet
= OBJECTTYPE_DATA_STOCK_RANGE
;
947 else if( o3tl::starts_with(aCID
, u
"StockLoss") )
948 eRet
= OBJECTTYPE_DATA_STOCK_LOSS
;
949 else if( o3tl::starts_with(aCID
, u
"StockGain") )
950 eRet
= OBJECTTYPE_DATA_STOCK_GAIN
;
951 else if( o3tl::starts_with(aCID
, u
"DataTable") )
952 eRet
= OBJECTTYPE_DATA_TABLE
;
954 eRet
= OBJECTTYPE_UNKNOWN
;
959 ObjectType
ObjectIdentifier::getObjectType() const
961 ObjectType
eObjectType( OBJECTTYPE_UNKNOWN
);
962 if ( isAutoGeneratedObject() )
964 eObjectType
= getObjectType( m_aObjectCID
);
966 else if ( isAdditionalShape() )
968 eObjectType
= OBJECTTYPE_SHAPE
;
973 OUString
ObjectIdentifier::createDataCurveCID(
974 std::u16string_view rSeriesParticle
975 , sal_Int32 nCurveIndex
976 , bool bAverageLine
)
978 OUString
aParticleID( OUString::number( nCurveIndex
) );
979 ObjectType eType
= bAverageLine
? OBJECTTYPE_DATA_AVERAGE_LINE
: OBJECTTYPE_DATA_CURVE
;
980 return createClassifiedIdentifierWithParent( eType
, aParticleID
, rSeriesParticle
);
983 OUString
ObjectIdentifier::createDataCurveEquationCID(
984 std::u16string_view rSeriesParticle
985 , sal_Int32 nCurveIndex
)
987 OUString
aParticleID( OUString::number( nCurveIndex
) );
988 return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION
, aParticleID
, rSeriesParticle
);
991 OUString
ObjectIdentifier::addChildParticle( std::u16string_view rParticle
, std::u16string_view rChildParticle
)
993 OUStringBuffer
aRet(rParticle
);
995 if( !aRet
.isEmpty() && !rChildParticle
.empty() )
997 if( !rChildParticle
.empty() )
998 aRet
.append(rChildParticle
);
1000 return aRet
.makeStringAndClear();
1003 OUString
ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType
, sal_Int32 nIndex
)
1005 OUStringBuffer
aRet( getStringForType( eObjectType
) );
1006 if( !aRet
.isEmpty() )
1008 aRet
.append("=" + OUString::number(nIndex
));
1010 return aRet
.makeStringAndClear();
1013 sal_Int32
ObjectIdentifier::getIndexFromParticleOrCID( std::u16string_view rParticleOrCID
)
1015 const std::u16string_view aIndexString
= lcl_getIndexStringAfterString( rParticleOrCID
, u
"=" );
1016 return lcl_StringToIndex( o3tl::getToken(aIndexString
, 0, ',' ) );
1019 OUString
ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
1020 , std::u16string_view rSeriesParticle
1021 , std::u16string_view rDragMethodServiceName
1022 , std::u16string_view rDragParameterString
)
1024 OUString aChildParticle
= getStringForType( eSubObjectType
) + "=";
1026 return createClassifiedIdentifierForParticles(
1027 rSeriesParticle
, aChildParticle
1028 , rDragMethodServiceName
, rDragParameterString
);
1031 OUString
ObjectIdentifier::createPointCID( std::u16string_view rPointCID_Stub
, sal_Int32 nIndex
)
1033 return rPointCID_Stub
+ OUString::number( nIndex
);
1036 std::u16string_view
ObjectIdentifier::getParticleID( std::u16string_view rCID
)
1038 std::u16string_view aRet
;
1039 size_t nLast
= rCID
.rfind('=');
1040 if(nLast
!= std::u16string_view::npos
)
1041 aRet
= rCID
.substr(++nLast
);
1045 std::u16string_view
ObjectIdentifier::getFullParentParticle( std::u16string_view rCID
)
1047 std::u16string_view aRet
;
1049 size_t nStartPos
= rCID
.rfind('/');
1050 if( nStartPos
!= std::u16string_view::npos
)
1053 size_t nEndPos
= rCID
.rfind(':');
1054 if( nEndPos
!= std::u16string_view::npos
&& nStartPos
< nEndPos
)
1056 aRet
= rCID
.substr(nStartPos
,nEndPos
-nStartPos
);
1063 OUString
ObjectIdentifier::getObjectID( std::u16string_view rCID
)
1067 size_t nStartPos
= rCID
.rfind('/');
1068 if( nStartPos
!= std::u16string_view::npos
)
1071 size_t nEndPos
= rCID
.size();
1072 aRet
= rCID
.substr(nStartPos
,nEndPos
-nStartPos
);
1078 bool ObjectIdentifier::isCID( std::u16string_view rName
)
1080 return !rName
.empty() && o3tl::starts_with( rName
, m_aProtocol
);
1083 Reference
< beans::XPropertySet
> ObjectIdentifier::getObjectPropertySet(
1084 std::u16string_view rObjectCID
1085 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1087 //return the model object that is indicated by rObjectCID
1088 if(rObjectCID
.empty())
1090 if(!xChartModel
.is())
1093 Reference
< beans::XPropertySet
> xObjectProperties
;
1096 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rObjectCID
);
1097 std::u16string_view aParticleID
= ObjectIdentifier::getParticleID( rObjectCID
);
1099 rtl::Reference
< Diagram
> xDiagram
;
1100 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1101 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1105 case OBJECTTYPE_PAGE
:
1107 xObjectProperties
.set( xChartModel
->getPageBackground() );
1110 case OBJECTTYPE_TITLE
:
1112 TitleHelper::eTitleType aTitleType
= getTitleTypeForCID( rObjectCID
);
1113 rtl::Reference
< Title
> xTitle( TitleHelper::getTitle( aTitleType
, xChartModel
) );
1114 xObjectProperties
= xTitle
;
1117 case OBJECTTYPE_LEGEND
:
1120 xObjectProperties
.set( xDiagram
->getLegend(), uno::UNO_QUERY
);
1123 case OBJECTTYPE_LEGEND_ENTRY
:
1125 case OBJECTTYPE_DIAGRAM
:
1127 xObjectProperties
= xDiagram
;
1130 case OBJECTTYPE_DIAGRAM_WALL
:
1133 xObjectProperties
.set( xDiagram
->getWall() );
1136 case OBJECTTYPE_DIAGRAM_FLOOR
:
1139 xObjectProperties
.set( xDiagram
->getFloor() );
1142 case OBJECTTYPE_AXIS
:
1144 sal_Int32 nDimensionIndex
= -1;
1145 sal_Int32 nAxisIndex
= -1;
1146 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1148 rtl::Reference
< Axis
> xAxis
=
1149 AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
);
1151 xObjectProperties
= xAxis
;
1154 case OBJECTTYPE_AXIS_UNITLABEL
:
1156 case OBJECTTYPE_GRID
:
1157 case OBJECTTYPE_SUBGRID
:
1159 sal_Int32 nDimensionIndex
= -1;
1160 sal_Int32 nAxisIndex
= -1;
1161 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1163 sal_Int32 nSubGridIndex
= -1;
1164 lcl_parseGridIndices( nSubGridIndex
, rObjectCID
);
1166 xObjectProperties
= AxisHelper::getGridProperties( xCooSys
, nDimensionIndex
, nAxisIndex
, nSubGridIndex
);
1169 case OBJECTTYPE_DATA_LABELS
:
1170 case OBJECTTYPE_DATA_SERIES
:
1172 rtl::Reference
< DataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID(
1173 rObjectCID
, xChartModel
) );
1175 xObjectProperties
= xSeries
;
1179 case OBJECTTYPE_DATA_LABEL
:
1180 case OBJECTTYPE_DATA_POINT
:
1182 rtl::Reference
< DataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID(
1183 rObjectCID
, xChartModel
);
1186 sal_Int32 nIndex
= o3tl::toInt32(aParticleID
);
1187 xObjectProperties
= xSeries
->getDataPointByIndex( nIndex
);
1191 case OBJECTTYPE_DATA_ERRORS_X
:
1192 case OBJECTTYPE_DATA_ERRORS_Y
:
1193 case OBJECTTYPE_DATA_ERRORS_Z
:
1195 rtl::Reference
< DataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID(
1196 rObjectCID
, xChartModel
);
1199 Reference
< beans::XPropertySet
> xErrorBarProp
;
1202 if ( eObjectType
== OBJECTTYPE_DATA_ERRORS_X
)
1203 errorBar
= CHART_UNONAME_ERRORBAR_X
;
1204 else if (eObjectType
== OBJECTTYPE_DATA_ERRORS_Y
)
1205 errorBar
= CHART_UNONAME_ERRORBAR_Y
;
1207 errorBar
= "ErrorBarZ";
1209 xSeries
->getPropertyValue( errorBar
) >>= xErrorBarProp
;
1210 xObjectProperties
= xErrorBarProp
;
1214 case OBJECTTYPE_DATA_AVERAGE_LINE
:
1215 case OBJECTTYPE_DATA_CURVE
:
1216 case OBJECTTYPE_DATA_CURVE_EQUATION
:
1218 rtl::Reference
< DataSeries
> xRegressionContainer
= ObjectIdentifier::getDataSeriesForCID(
1219 rObjectCID
, xChartModel
);
1220 if(xRegressionContainer
.is())
1222 sal_Int32 nIndex
= o3tl::toInt32(aParticleID
);
1223 const std::vector
< rtl::Reference
< RegressionCurveModel
> > & aCurveList
=
1224 xRegressionContainer
->getRegressionCurves2();
1225 if( nIndex
>= 0 && o3tl::make_unsigned(nIndex
) < aCurveList
.size() )
1227 if( eObjectType
== OBJECTTYPE_DATA_CURVE_EQUATION
)
1228 xObjectProperties
= aCurveList
[nIndex
]->getEquationProperties();
1230 xObjectProperties
= aCurveList
[nIndex
];
1235 case OBJECTTYPE_DATA_STOCK_RANGE
:
1237 case OBJECTTYPE_DATA_STOCK_LOSS
:
1239 rtl::Reference
<ChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1241 xChartType
->getPropertyValue( u
"BlackDay"_ustr
) >>= xObjectProperties
;
1244 case OBJECTTYPE_DATA_STOCK_GAIN
:
1246 rtl::Reference
<ChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1248 xChartType
->getPropertyValue( u
"WhiteDay"_ustr
) >>= xObjectProperties
;
1251 case OBJECTTYPE_DATA_TABLE
:
1254 xObjectProperties
.set(xDiagram
->getDataTable(), uno::UNO_QUERY
);
1258 default: //OBJECTTYPE_UNKNOWN
1262 catch(const uno::Exception
&)
1264 DBG_UNHANDLED_EXCEPTION("chart2");
1266 return xObjectProperties
;
1269 rtl::Reference
< Axis
> ObjectIdentifier::getAxisForCID(
1270 std::u16string_view rObjectCID
1271 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1273 rtl::Reference
< Diagram
> xDiagram
;
1274 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1275 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1277 sal_Int32 nDimensionIndex
= -1;
1278 sal_Int32 nAxisIndex
= -1;
1279 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1281 return AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
);
1284 rtl::Reference
< DataSeries
> ObjectIdentifier::getDataSeriesForCID(
1285 std::u16string_view rObjectCID
1286 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1288 rtl::Reference
< Diagram
> xDiagram
;
1289 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1290 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1292 sal_Int32 nChartTypeIndex
= -1;
1293 sal_Int32 nSeriesIndex
= -1;
1294 sal_Int32 nPointIndex
= -1;
1295 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rObjectCID
);
1297 rtl::Reference
< DataSeries
> xSeries
;
1300 rtl::Reference
< ChartType
> xDataSeriesContainer( xDiagram
->getChartTypeByIndex( nChartTypeIndex
) );
1301 if( xDataSeriesContainer
.is() )
1303 const std::vector
< rtl::Reference
< DataSeries
> > & aDataSeriesSeq( xDataSeriesContainer
->getDataSeries2() );
1304 if( nSeriesIndex
>= 0 && o3tl::make_unsigned(nSeriesIndex
) < aDataSeriesSeq
.size() )
1305 xSeries
= aDataSeriesSeq
[nSeriesIndex
];
1311 rtl::Reference
< Diagram
> ObjectIdentifier::getDiagramForCID(
1312 std::u16string_view rObjectCID
1313 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1315 rtl::Reference
< Diagram
> xDiagram
;
1316 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1317 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1322 TitleHelper::eTitleType
ObjectIdentifier::getTitleTypeForCID( std::u16string_view rCID
)
1324 TitleHelper::eTitleType
eRet( TitleHelper::MAIN_TITLE
);
1326 std::u16string_view aParentParticle
= ObjectIdentifier::getFullParentParticle( rCID
);
1327 const tTitleMap
& rMap
= lcl_getTitleMap();
1328 tTitleMap::const_iterator aIt
= std::find_if(rMap
.begin(), rMap
.end(),
1329 [&aParentParticle
](tTitleMap::const_reference rEntry
) { return aParentParticle
== rEntry
.second
; });
1330 if (aIt
!= rMap
.end())
1331 eRet
= (*aIt
).first
;
1336 OUString
ObjectIdentifier::getSeriesParticleFromCID( std::u16string_view rCID
)
1338 sal_Int32 nDiagramIndex
= -1;
1339 sal_Int32 nCooSysIndex
= -1;
1340 lcl_parseCooSysIndices( nDiagramIndex
, nCooSysIndex
, rCID
);
1342 sal_Int32 nChartTypeIndex
= -1;
1343 sal_Int32 nSeriesIndex
= -1;
1344 sal_Int32 nPointIndex
= -1;
1345 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rCID
);
1347 return ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1350 OUString
ObjectIdentifier::getMovedSeriesCID( std::u16string_view rObjectCID
, bool bForward
)
1352 sal_Int32 nDiagramIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CID/D=" ) );
1353 sal_Int32 nCooSysIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CS=" ) );
1354 sal_Int32 nChartTypeIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CT=" ) );
1355 sal_Int32 nSeriesIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"Series=" ) );
1362 OUString aRet
= ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1363 return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet
);
1366 bool ObjectIdentifier::isValid() const
1368 return ( isAutoGeneratedObject() || isAdditionalShape() );
1371 bool ObjectIdentifier::isAutoGeneratedObject() const
1373 return ( !m_aObjectCID
.isEmpty() );
1376 bool ObjectIdentifier::isAdditionalShape() const
1378 return m_xAdditionalShape
.is();
1381 Any
ObjectIdentifier::getAny() const
1384 if ( isAutoGeneratedObject() )
1386 aAny
<<= getObjectCID();
1388 else if ( isAdditionalShape() )
1390 aAny
<<= getAdditionalShape();
1397 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */