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 if (rAny
.getValueType() == cppu::UnoType
<OUString
>::get())
244 rAny
>>= m_aObjectCID
;
248 rAny
>>= m_xAdditionalShape
;
252 bool ObjectIdentifier::operator==( const ObjectIdentifier
& rOID
) const
254 return areIdenticalObjects( m_aObjectCID
, rOID
.m_aObjectCID
) &&
255 ( m_xAdditionalShape
== rOID
.m_xAdditionalShape
);
258 bool ObjectIdentifier::operator<( const ObjectIdentifier
& rOID
) const
260 bool bReturn
= false;
261 if ( !(m_aObjectCID
.isEmpty() || rOID
.m_aObjectCID
.isEmpty()) )
263 bReturn
= ( m_aObjectCID
.compareTo( rOID
.m_aObjectCID
) < 0 );
265 else if ( !m_aObjectCID
.isEmpty() )
269 else if ( !rOID
.m_aObjectCID
.isEmpty() )
273 else if ( m_xAdditionalShape
.is() && rOID
.m_xAdditionalShape
.is() )
275 bReturn
= ( m_xAdditionalShape
< rOID
.m_xAdditionalShape
);
280 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
281 const rtl::Reference
< ::chart::Title
>& xTitle
282 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
284 TitleHelper::eTitleType aTitleType
;
286 const std::u16string_view aObjectID
;
287 const std::u16string_view aDragMethodServiceName
;
288 const std::u16string_view aDragParameterString
;
289 if( TitleHelper::getTitleType( aTitleType
, xTitle
, xChartModel
) )
291 enum ObjectType eObjectType
= OBJECTTYPE_TITLE
;
292 OUString aParentParticle
= lcl_getTitleParentParticle( aTitleType
);
293 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
294 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
299 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
300 const Reference
< uno::XInterface
>& xObject
301 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
305 enum ObjectType eObjectType
= OBJECTTYPE_UNKNOWN
;
306 const std::u16string_view aObjectID
;
307 OUString aParentParticle
;
308 const std::u16string_view aDragMethodServiceName
;
309 const std::u16string_view aDragParameterString
;
314 if( ::chart::Title
* pTitle
= dynamic_cast<::chart::Title
*>(xObject
.get()) )
315 return createClassifiedIdentifierForObject(rtl::Reference
<Title
>(pTitle
), xChartModel
);
317 uno::Reference
<chart2::XDataTable
> xDataTable(xObject
, uno::UNO_QUERY
);
320 return createClassifiedIdentifierForParticle(createParticleForDataTable(xChartModel
));
324 rtl::Reference
< Axis
> xAxis
= dynamic_cast<Axis
*>( xObject
.get() );
327 rtl::Reference
<Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
328 rtl::Reference
< BaseCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis
, xDiagram
) );
329 OUString
aCooSysParticle( createParticleForCoordinateSystem( xCooSys
, xChartModel
) );
330 sal_Int32 nDimensionIndex
=-1;
331 sal_Int32 nAxisIndex
=-1;
332 AxisHelper::getIndicesForAxis( xAxis
, xCooSys
, nDimensionIndex
, nAxisIndex
);
333 OUString
aAxisParticle( createParticleForAxis( nDimensionIndex
, nAxisIndex
) );
334 return createClassifiedIdentifierForParticles( aCooSysParticle
, aAxisParticle
);
338 Reference
< XLegend
> xLegend( xObject
, uno::UNO_QUERY
);
341 return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel
) );
345 Reference
< XDiagram
> xDiagram( xObject
, uno::UNO_QUERY
);
348 return createClassifiedIdentifierForParticle( createParticleForDiagram() );
358 catch(const uno::Exception
&)
360 DBG_UNHANDLED_EXCEPTION("chart2");
363 if( eObjectType
!= OBJECTTYPE_UNKNOWN
)
365 aRet
= ObjectIdentifier::createClassifiedIdentifierWithParent(
366 eObjectType
, aObjectID
, aParentParticle
, aDragMethodServiceName
, aDragParameterString
);
370 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
376 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
377 const rtl::Reference
< Legend
>& xLegend
378 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
384 return createClassifiedIdentifierForParticle( createParticleForLegend( xChartModel
) );
387 catch(const uno::Exception
&)
389 DBG_UNHANDLED_EXCEPTION("chart2");
392 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
397 OUString
ObjectIdentifier::createClassifiedIdentifierForObject(
398 const rtl::Reference
<::chart::Axis
>& xAxis
399 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
406 rtl::Reference
<Diagram
> xDiagram
= xChartModel
->getFirstChartDiagram();
407 rtl::Reference
< BaseCoordinateSystem
> xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis
, xDiagram
) );
408 OUString
aCooSysParticle( createParticleForCoordinateSystem( xCooSys
, xChartModel
) );
409 sal_Int32 nDimensionIndex
=-1;
410 sal_Int32 nAxisIndex
=-1;
411 AxisHelper::getIndicesForAxis( xAxis
, xCooSys
, nDimensionIndex
, nAxisIndex
);
412 OUString
aAxisParticle( createParticleForAxis( nDimensionIndex
, nAxisIndex
) );
413 return createClassifiedIdentifierForParticles( aCooSysParticle
, aAxisParticle
);
416 catch(const uno::Exception
&)
418 DBG_UNHANDLED_EXCEPTION("chart2");
421 OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
426 OUString
ObjectIdentifier::createClassifiedIdentifierForParticle(
427 std::u16string_view rParticle
)
429 return ObjectIdentifier::createClassifiedIdentifierForParticles( rParticle
, u
"" );
432 OUString
ObjectIdentifier::createClassifiedIdentifierForParticles(
433 std::u16string_view rParentParticle
434 , std::u16string_view rChildParticle
435 , std::u16string_view rDragMethodServiceName
436 , std::u16string_view rDragParameterString
)
438 ObjectType
eObjectType( ObjectIdentifier::getObjectType( rChildParticle
) );
439 if( eObjectType
== OBJECTTYPE_UNKNOWN
)
440 eObjectType
= ObjectIdentifier::getObjectType( rParentParticle
);
442 OUStringBuffer
aRet( m_aProtocol
+
443 lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
444 if(aRet
.getLength() > m_aProtocol
.getLength())
447 if(!rParentParticle
.empty())
449 aRet
.append(rParentParticle
);
450 if( !rChildParticle
.empty() )
453 aRet
.append(rChildParticle
);
455 return aRet
.makeStringAndClear();
458 OUString
ObjectIdentifier::createParticleForDiagram()
460 //TODO: if more than one diagram is implemented, add the correct diagram index here
464 OUString
ObjectIdentifier::createParticleForCoordinateSystem(
465 const rtl::Reference
< BaseCoordinateSystem
>& xCooSys
466 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
470 rtl::Reference
< Diagram
> xDiagram( xChartModel
->getFirstChartDiagram() );
473 std::size_t nCooSysIndex
= 0;
474 const std::vector
< rtl::Reference
< BaseCoordinateSystem
> > aCooSysList( xDiagram
->getBaseCoordinateSystems() );
475 for( ; nCooSysIndex
< aCooSysList
.size(); ++nCooSysIndex
)
477 if( xCooSys
== aCooSysList
[nCooSysIndex
] )
479 aRet
= ObjectIdentifier::createParticleForDiagram() + ":CS=" + OUString::number( nCooSysIndex
);
488 OUString
ObjectIdentifier::createParticleForAxis(
489 sal_Int32 nDimensionIndex
490 , sal_Int32 nAxisIndex
)
493 OUString::number( nDimensionIndex
) +
495 OUString::number( nAxisIndex
);
498 OUString
ObjectIdentifier::createParticleForGrid(
499 sal_Int32 nDimensionIndex
500 , sal_Int32 nAxisIndex
)
502 OUString aRet
= "Axis=" + OUString::number( nDimensionIndex
)
503 + "," + OUString::number( nAxisIndex
) + ":Grid=0";
508 OUString
ObjectIdentifier::createClassifiedIdentifierForGrid(
509 const Reference
< XAxis
>& xAxis
510 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
511 , sal_Int32 nSubGridIndex
)
513 //-1: main grid, 0: first subgrid etc
515 OUString
aAxisCID( createClassifiedIdentifierForObject( xAxis
, xChartModel
) );
516 OUString
aGridCID( addChildParticle( aAxisCID
517 , createChildParticleWithIndex( OBJECTTYPE_GRID
, 0 ) ) );
518 if( nSubGridIndex
>= 0 )
520 aGridCID
= addChildParticle( aGridCID
521 , createChildParticleWithIndex( OBJECTTYPE_SUBGRID
, 0 ) );
526 OUString
ObjectIdentifier::createParticleForSeries(
527 sal_Int32 nDiagramIndex
, sal_Int32 nCooSysIndex
528 , sal_Int32 nChartTypeIndex
, sal_Int32 nSeriesIndex
)
531 "D=" + OUString::number( nDiagramIndex
) +
532 ":CS=" + OUString::number( nCooSysIndex
) +
533 ":CT=" + OUString::number( nChartTypeIndex
) +
534 ":" + getStringForType( OBJECTTYPE_DATA_SERIES
) + "=" +
535 OUString::number( nSeriesIndex
);
539 OUString
ObjectIdentifier::createParticleForLegend(
540 const rtl::Reference
<::chart::ChartModel
>& )
542 //todo: if more than one diagram is implemented, find the correct diagram which is owner of the given legend
544 return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType( OBJECTTYPE_LEGEND
) + "=";
547 OUString
ObjectIdentifier::createParticleForDataTable(const rtl::Reference
<::chart::ChartModel
>& /* xChartModel */)
549 return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType(OBJECTTYPE_DATA_TABLE
) + "=";
552 OUString
ObjectIdentifier::createClassifiedIdentifier(
553 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_SERIES
554 , std::u16string_view rParticleID
)//e.g. SeriesID
556 return createClassifiedIdentifierWithParent(
557 eObjectType
, rParticleID
, u
"" );
560 OUString
ObjectIdentifier::createClassifiedIdentifierWithParent(
561 enum ObjectType eObjectType
//e.g. OBJECTTYPE_DATA_POINT or OBJECTTYPE_GRID
562 , std::u16string_view rParticleID
//e.g. Point Index or SubGrid Index
563 , std::u16string_view rParentPartical
//e.g. "Series=SeriesID" or "Grid=GridId"
564 , std::u16string_view rDragMethodServiceName
565 , std::u16string_view rDragParameterString
567 //, bool bIsMultiClickObject ) //e.g. true
569 //e.g. "MultiClick/Series=2:Point=34"
571 OUStringBuffer
aRet( m_aProtocol
+
572 lcl_createClassificationStringForType( eObjectType
, rDragMethodServiceName
, rDragParameterString
));
573 if(aRet
.getLength() > m_aProtocol
.getLength())
575 aRet
.append(rParentPartical
);
576 if(!rParentPartical
.empty())
579 aRet
.append(getStringForType( eObjectType
) + "=" + rParticleID
);
581 return aRet
.makeStringAndClear();
584 const OUString
& ObjectIdentifier::getPieSegmentDragMethodServiceName()
586 return m_aPieSegmentDragMethodServiceName
;
589 OUString
ObjectIdentifier::createPieSegmentDragParameterString(
590 sal_Int32 nOffsetPercent
591 , const awt::Point
& rMinimumPosition
592 , const awt::Point
& rMaximumPosition
)
594 OUString aRet
= OUString::number( nOffsetPercent
)
595 + "," + OUString::number( rMinimumPosition
.X
)
596 + "," + OUString::number( rMinimumPosition
.Y
)
597 + "," + OUString::number( rMaximumPosition
.X
)
598 + "," + OUString::number( rMaximumPosition
.Y
);
602 bool ObjectIdentifier::parsePieSegmentDragParameterString(
603 std::u16string_view rDragParameterString
604 , sal_Int32
& rOffsetPercent
605 , awt::Point
& rMinimumPosition
606 , awt::Point
& rMaximumPosition
)
608 sal_Int32 nCharacterIndex
= 0;
610 std::u16string_view
aValueString( o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
) );
611 rOffsetPercent
= o3tl::toInt32(aValueString
);
612 if( nCharacterIndex
< 0 )
615 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
616 rMinimumPosition
.X
= o3tl::toInt32(aValueString
);
617 if( nCharacterIndex
< 0 )
620 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
621 rMinimumPosition
.Y
= o3tl::toInt32(aValueString
);
622 if( nCharacterIndex
< 0 )
625 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
626 rMaximumPosition
.X
= o3tl::toInt32(aValueString
);
627 if( nCharacterIndex
< 0 )
630 aValueString
= o3tl::getToken(rDragParameterString
, 0, ',', nCharacterIndex
);
631 rMaximumPosition
.Y
= o3tl::toInt32(aValueString
);
632 return nCharacterIndex
>= 0;
635 std::u16string_view
ObjectIdentifier::getDragMethodServiceName( std::u16string_view rCID
)
637 std::u16string_view aRet
;
639 size_t nIndexStart
= rCID
.find( m_aDragMethodEquals
);
640 if( nIndexStart
!= std::u16string_view::npos
)
642 nIndexStart
= rCID
.find( '=', nIndexStart
);
643 if( nIndexStart
!= std::u16string_view::npos
)
646 size_t nNextSlash
= rCID
.find( '/', nIndexStart
);
647 if( nNextSlash
!= std::u16string_view::npos
)
649 sal_Int32 nIndexEnd
= nNextSlash
;
650 size_t nNextColon
= rCID
.find( ':', nIndexStart
);
651 if( nNextColon
== std::u16string_view::npos
|| nNextColon
< nNextSlash
)
652 nIndexEnd
= nNextColon
;
653 aRet
= rCID
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
660 std::u16string_view
ObjectIdentifier::getDragParameterString( std::u16string_view rCID
)
662 std::u16string_view aRet
;
664 size_t nIndexStart
= rCID
.find( m_aDragParameterEquals
);
665 if( nIndexStart
!= std::u16string_view::npos
)
667 nIndexStart
= rCID
.find( '=', nIndexStart
);
668 if( nIndexStart
!= std::u16string_view::npos
)
671 size_t nNextSlash
= rCID
.find( '/', nIndexStart
);
672 if( nNextSlash
!= std::u16string_view::npos
)
674 sal_Int32 nIndexEnd
= nNextSlash
;
675 size_t nNextColon
= rCID
.find( ':', nIndexStart
);
676 if( nNextColon
== std::u16string_view::npos
|| nNextColon
< nNextSlash
)
677 nIndexEnd
= nNextColon
;
678 aRet
= rCID
.substr(nIndexStart
,nIndexEnd
-nIndexStart
);
685 bool ObjectIdentifier::isDragableObject( std::u16string_view rClassifiedIdentifier
)
687 bool bReturn
= false;
688 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
689 switch( eObjectType
)
691 case OBJECTTYPE_TITLE
:
692 case OBJECTTYPE_LEGEND
:
693 case OBJECTTYPE_DIAGRAM
:
694 case OBJECTTYPE_DATA_LABEL
:
695 case OBJECTTYPE_DATA_CURVE_EQUATION
:
696 //case OBJECTTYPE_DIAGRAM_WALL:
700 std::u16string_view
aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( rClassifiedIdentifier
) );
701 bReturn
= !aDragMethodServiceName
.empty();
707 bool ObjectIdentifier::isDragableObject() const
709 bool bReturn
= false;
710 if ( isAutoGeneratedObject() )
712 bReturn
= isDragableObject( m_aObjectCID
);
714 else if ( isAdditionalShape() )
721 bool ObjectIdentifier::isRotateableObject( std::u16string_view rClassifiedIdentifier
)
723 bool bReturn
= false;
724 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rClassifiedIdentifier
);
725 switch( eObjectType
)
727 case OBJECTTYPE_DIAGRAM
:
728 //case OBJECTTYPE_DIAGRAM_WALL:
738 bool ObjectIdentifier::isMultiClickObject( std::u16string_view rClassifiedIdentifier
)
740 //the name of a shape is it's ClassifiedIdentifier
742 //a MultiClickObject is an object that is selectable by more than one click only ;
743 //before a MultiClickObject can be selected it is necessary that a named parent group object
744 //was selected before;
746 //!!!!! by definition the name of a MultiClickObject starts with "CID/MultiClick:"
747 bool bRet
= o3tl::starts_with(rClassifiedIdentifier
.substr( m_aProtocol
.getLength() ), m_aMultiClick
);
751 bool ObjectIdentifier::areSiblings( std::u16string_view rCID1
, std::u16string_view rCID2
)
754 size_t nLastSign1
= rCID1
.rfind( '=' );
755 size_t nLastSign2
= rCID2
.rfind( '=' );
756 if( nLastSign1
== rCID1
.find( '=' ) )//CID cannot be sibling if only one "=" occurs
758 else if( nLastSign2
== rCID2
.find( '=' ) )//CID cannot be sibling if only one "=" occurs
760 else if( ObjectIdentifier::areIdenticalObjects( rCID1
, rCID2
) )
764 std::u16string_view
aParent1( ObjectIdentifier::getFullParentParticle( rCID1
) );
765 if( !aParent1
.empty() )
767 std::u16string_view
aParent2( ObjectIdentifier::getFullParentParticle( rCID2
) );
768 bRet
=aParent1
== aParent2
;
770 //legend entries are special:
773 if( getObjectType(rCID1
) == OBJECTTYPE_LEGEND_ENTRY
774 && getObjectType(rCID2
) == OBJECTTYPE_LEGEND_ENTRY
)
781 bool ObjectIdentifier::areIdenticalObjects( std::u16string_view rCID1
, std::u16string_view rCID2
)
785 //draggable pie or donut segments need special treatment, as their CIDs do change with offset
787 if( rCID1
.find( m_aPieSegmentDragMethodServiceName
) == std::u16string_view::npos
788 || rCID2
.find( m_aPieSegmentDragMethodServiceName
) == std::u16string_view::npos
)
791 OUString
aID1( ObjectIdentifier::getObjectID( rCID1
) );
792 OUString
aID2( ObjectIdentifier::getObjectID( rCID2
) );
793 if( !aID1
.isEmpty() && aID1
== aID2
)
799 OUString
ObjectIdentifier::getStringForType( ObjectType eObjectType
)
802 switch( eObjectType
)
804 case OBJECTTYPE_PAGE
:
807 case OBJECTTYPE_TITLE
:
810 case OBJECTTYPE_LEGEND
:
813 case OBJECTTYPE_LEGEND_ENTRY
:
816 case OBJECTTYPE_DIAGRAM
:
819 case OBJECTTYPE_DIAGRAM_WALL
:
822 case OBJECTTYPE_DIAGRAM_FLOOR
:
825 case OBJECTTYPE_AXIS
:
828 case OBJECTTYPE_AXIS_UNITLABEL
:
829 aRet
="AxisUnitLabel";
831 case OBJECTTYPE_GRID
:
834 case OBJECTTYPE_SUBGRID
:
837 case OBJECTTYPE_DATA_SERIES
:
840 case OBJECTTYPE_DATA_POINT
:
843 case OBJECTTYPE_DATA_LABELS
:
846 case OBJECTTYPE_DATA_LABEL
:
849 case OBJECTTYPE_DATA_ERRORS_X
:
852 case OBJECTTYPE_DATA_ERRORS_Y
:
855 case OBJECTTYPE_DATA_ERRORS_Z
:
858 case OBJECTTYPE_DATA_CURVE
:
861 case OBJECTTYPE_DATA_CURVE_EQUATION
:
864 case OBJECTTYPE_DATA_AVERAGE_LINE
:
867 case OBJECTTYPE_DATA_STOCK_RANGE
:
870 case OBJECTTYPE_DATA_STOCK_LOSS
:
873 case OBJECTTYPE_DATA_STOCK_GAIN
:
876 case OBJECTTYPE_DATA_TABLE
:
879 default: //OBJECTTYPE_UNKNOWN
885 ObjectType
ObjectIdentifier::getObjectType( std::u16string_view aCID
)
888 size_t nLastSign
= aCID
.rfind( ':' );//last sign before the type string
889 if(nLastSign
== std::u16string_view::npos
)
890 nLastSign
= aCID
.rfind( '/' );
891 if(nLastSign
== std::u16string_view::npos
)
893 size_t nEndIndex
= aCID
.rfind( '=' );
894 if(nEndIndex
== std::u16string_view::npos
)
895 return OBJECTTYPE_UNKNOWN
;
901 aCID
= aCID
.substr(nLastSign
);
902 if( o3tl::starts_with(aCID
, u
"Page") )
903 eRet
= OBJECTTYPE_PAGE
;
904 else if( o3tl::starts_with(aCID
, u
"Title") )
905 eRet
= OBJECTTYPE_TITLE
;
906 else if( o3tl::starts_with(aCID
, u
"LegendEntry") )
907 eRet
= OBJECTTYPE_LEGEND_ENTRY
;
908 else if( o3tl::starts_with(aCID
, u
"Legend") )
909 eRet
= OBJECTTYPE_LEGEND
;
910 else if( o3tl::starts_with(aCID
, u
"DiagramWall") )
911 eRet
= OBJECTTYPE_DIAGRAM_WALL
;
912 else if( o3tl::starts_with(aCID
, u
"DiagramFloor") )
913 eRet
= OBJECTTYPE_DIAGRAM_FLOOR
;
914 else if( o3tl::starts_with(aCID
, u
"D=") )
915 eRet
= OBJECTTYPE_DIAGRAM
;
916 else if( o3tl::starts_with(aCID
, u
"AxisUnitLabel") )
917 eRet
= OBJECTTYPE_AXIS_UNITLABEL
;
918 else if( o3tl::starts_with(aCID
, u
"Axis") )
919 eRet
= OBJECTTYPE_AXIS
;
920 else if( o3tl::starts_with(aCID
, u
"Grid") )
921 eRet
= OBJECTTYPE_GRID
;
922 else if( o3tl::starts_with(aCID
, u
"SubGrid") )
923 eRet
= OBJECTTYPE_SUBGRID
;
924 else if( o3tl::starts_with(aCID
, u
"Series") )
925 eRet
= OBJECTTYPE_DATA_SERIES
;
926 else if( o3tl::starts_with(aCID
, u
"Point") )
927 eRet
= OBJECTTYPE_DATA_POINT
;
928 else if( o3tl::starts_with(aCID
, u
"DataLabels") )
929 eRet
= OBJECTTYPE_DATA_LABELS
;
930 else if( o3tl::starts_with(aCID
, u
"DataLabel") )
931 eRet
= OBJECTTYPE_DATA_LABEL
;
932 else if( o3tl::starts_with(aCID
, u
"ErrorsX") )
933 eRet
= OBJECTTYPE_DATA_ERRORS_X
;
934 else if( o3tl::starts_with(aCID
, u
"ErrorsY") )
935 eRet
= OBJECTTYPE_DATA_ERRORS_Y
;
936 else if( o3tl::starts_with(aCID
, u
"ErrorsZ") )
937 eRet
= OBJECTTYPE_DATA_ERRORS_Z
;
938 else if( o3tl::starts_with(aCID
, u
"Curve") )
939 eRet
= OBJECTTYPE_DATA_CURVE
;
940 else if( o3tl::starts_with(aCID
, u
"Equation") )
941 eRet
= OBJECTTYPE_DATA_CURVE_EQUATION
;
942 else if( o3tl::starts_with(aCID
, u
"Average") )
943 eRet
= OBJECTTYPE_DATA_AVERAGE_LINE
;
944 else if( o3tl::starts_with(aCID
, u
"StockRange") )
945 eRet
= OBJECTTYPE_DATA_STOCK_RANGE
;
946 else if( o3tl::starts_with(aCID
, u
"StockLoss") )
947 eRet
= OBJECTTYPE_DATA_STOCK_LOSS
;
948 else if( o3tl::starts_with(aCID
, u
"StockGain") )
949 eRet
= OBJECTTYPE_DATA_STOCK_GAIN
;
950 else if( o3tl::starts_with(aCID
, u
"DataTable") )
951 eRet
= OBJECTTYPE_DATA_TABLE
;
953 eRet
= OBJECTTYPE_UNKNOWN
;
958 ObjectType
ObjectIdentifier::getObjectType() const
960 ObjectType
eObjectType( OBJECTTYPE_UNKNOWN
);
961 if ( isAutoGeneratedObject() )
963 eObjectType
= getObjectType( m_aObjectCID
);
965 else if ( isAdditionalShape() )
967 eObjectType
= OBJECTTYPE_SHAPE
;
972 OUString
ObjectIdentifier::createDataCurveCID(
973 std::u16string_view rSeriesParticle
974 , sal_Int32 nCurveIndex
975 , bool bAverageLine
)
977 OUString
aParticleID( OUString::number( nCurveIndex
) );
978 ObjectType eType
= bAverageLine
? OBJECTTYPE_DATA_AVERAGE_LINE
: OBJECTTYPE_DATA_CURVE
;
979 return createClassifiedIdentifierWithParent( eType
, aParticleID
, rSeriesParticle
);
982 OUString
ObjectIdentifier::createDataCurveEquationCID(
983 std::u16string_view rSeriesParticle
984 , sal_Int32 nCurveIndex
)
986 OUString
aParticleID( OUString::number( nCurveIndex
) );
987 return createClassifiedIdentifierWithParent( OBJECTTYPE_DATA_CURVE_EQUATION
, aParticleID
, rSeriesParticle
);
990 OUString
ObjectIdentifier::addChildParticle( std::u16string_view rParticle
, std::u16string_view rChildParticle
)
992 OUStringBuffer
aRet(rParticle
);
994 if( !aRet
.isEmpty() && !rChildParticle
.empty() )
996 if( !rChildParticle
.empty() )
997 aRet
.append(rChildParticle
);
999 return aRet
.makeStringAndClear();
1002 OUString
ObjectIdentifier::createChildParticleWithIndex( ObjectType eObjectType
, sal_Int32 nIndex
)
1004 OUStringBuffer
aRet( getStringForType( eObjectType
) );
1005 if( !aRet
.isEmpty() )
1007 aRet
.append("=" + OUString::number(nIndex
));
1009 return aRet
.makeStringAndClear();
1012 sal_Int32
ObjectIdentifier::getIndexFromParticleOrCID( std::u16string_view rParticleOrCID
)
1014 const std::u16string_view aIndexString
= lcl_getIndexStringAfterString( rParticleOrCID
, u
"=" );
1015 return lcl_StringToIndex( o3tl::getToken(aIndexString
, 0, ',' ) );
1018 OUString
ObjectIdentifier::createSeriesSubObjectStub( ObjectType eSubObjectType
1019 , std::u16string_view rSeriesParticle
1020 , std::u16string_view rDragMethodServiceName
1021 , std::u16string_view rDragParameterString
)
1023 OUString aChildParticle
= getStringForType( eSubObjectType
) + "=";
1025 return createClassifiedIdentifierForParticles(
1026 rSeriesParticle
, aChildParticle
1027 , rDragMethodServiceName
, rDragParameterString
);
1030 OUString
ObjectIdentifier::createPointCID( std::u16string_view rPointCID_Stub
, sal_Int32 nIndex
)
1032 return rPointCID_Stub
+ OUString::number( nIndex
);
1035 std::u16string_view
ObjectIdentifier::getParticleID( std::u16string_view rCID
)
1037 std::u16string_view aRet
;
1038 size_t nLast
= rCID
.rfind('=');
1039 if(nLast
!= std::u16string_view::npos
)
1040 aRet
= rCID
.substr(++nLast
);
1044 std::u16string_view
ObjectIdentifier::getFullParentParticle( std::u16string_view rCID
)
1046 std::u16string_view aRet
;
1048 size_t nStartPos
= rCID
.rfind('/');
1049 if( nStartPos
!= std::u16string_view::npos
)
1052 size_t nEndPos
= rCID
.rfind(':');
1053 if( nEndPos
!= std::u16string_view::npos
&& nStartPos
< nEndPos
)
1055 aRet
= rCID
.substr(nStartPos
,nEndPos
-nStartPos
);
1062 OUString
ObjectIdentifier::getObjectID( std::u16string_view rCID
)
1066 size_t nStartPos
= rCID
.rfind('/');
1067 if( nStartPos
!= std::u16string_view::npos
)
1070 size_t nEndPos
= rCID
.size();
1071 aRet
= rCID
.substr(nStartPos
,nEndPos
-nStartPos
);
1077 bool ObjectIdentifier::isCID( std::u16string_view rName
)
1079 return !rName
.empty() && o3tl::starts_with( rName
, m_aProtocol
);
1082 Reference
< beans::XPropertySet
> ObjectIdentifier::getObjectPropertySet(
1083 std::u16string_view rObjectCID
1084 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1086 //return the model object that is indicated by rObjectCID
1087 if(rObjectCID
.empty())
1089 if(!xChartModel
.is())
1092 Reference
< beans::XPropertySet
> xObjectProperties
;
1095 ObjectType eObjectType
= ObjectIdentifier::getObjectType( rObjectCID
);
1096 std::u16string_view aParticleID
= ObjectIdentifier::getParticleID( rObjectCID
);
1098 rtl::Reference
< Diagram
> xDiagram
;
1099 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1100 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1104 case OBJECTTYPE_PAGE
:
1106 xObjectProperties
.set( xChartModel
->getPageBackground() );
1109 case OBJECTTYPE_TITLE
:
1111 TitleHelper::eTitleType aTitleType
= getTitleTypeForCID( rObjectCID
);
1112 rtl::Reference
< Title
> xTitle( TitleHelper::getTitle( aTitleType
, xChartModel
) );
1113 xObjectProperties
= xTitle
;
1116 case OBJECTTYPE_LEGEND
:
1119 xObjectProperties
.set( xDiagram
->getLegend(), uno::UNO_QUERY
);
1122 case OBJECTTYPE_LEGEND_ENTRY
:
1124 case OBJECTTYPE_DIAGRAM
:
1126 xObjectProperties
= xDiagram
;
1129 case OBJECTTYPE_DIAGRAM_WALL
:
1132 xObjectProperties
.set( xDiagram
->getWall() );
1135 case OBJECTTYPE_DIAGRAM_FLOOR
:
1138 xObjectProperties
.set( xDiagram
->getFloor() );
1141 case OBJECTTYPE_AXIS
:
1143 sal_Int32 nDimensionIndex
= -1;
1144 sal_Int32 nAxisIndex
= -1;
1145 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1147 rtl::Reference
< Axis
> xAxis
=
1148 AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
);
1150 xObjectProperties
= xAxis
;
1153 case OBJECTTYPE_AXIS_UNITLABEL
:
1155 case OBJECTTYPE_GRID
:
1156 case OBJECTTYPE_SUBGRID
:
1158 sal_Int32 nDimensionIndex
= -1;
1159 sal_Int32 nAxisIndex
= -1;
1160 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1162 sal_Int32 nSubGridIndex
= -1;
1163 lcl_parseGridIndices( nSubGridIndex
, rObjectCID
);
1165 xObjectProperties
= AxisHelper::getGridProperties( xCooSys
, nDimensionIndex
, nAxisIndex
, nSubGridIndex
);
1168 case OBJECTTYPE_DATA_LABELS
:
1169 case OBJECTTYPE_DATA_SERIES
:
1171 rtl::Reference
< DataSeries
> xSeries( ObjectIdentifier::getDataSeriesForCID(
1172 rObjectCID
, xChartModel
) );
1174 xObjectProperties
= xSeries
;
1178 case OBJECTTYPE_DATA_LABEL
:
1179 case OBJECTTYPE_DATA_POINT
:
1181 rtl::Reference
< DataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID(
1182 rObjectCID
, xChartModel
);
1185 sal_Int32 nIndex
= o3tl::toInt32(aParticleID
);
1186 xObjectProperties
= xSeries
->getDataPointByIndex( nIndex
);
1190 case OBJECTTYPE_DATA_ERRORS_X
:
1191 case OBJECTTYPE_DATA_ERRORS_Y
:
1192 case OBJECTTYPE_DATA_ERRORS_Z
:
1194 rtl::Reference
< DataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID(
1195 rObjectCID
, xChartModel
);
1198 Reference
< beans::XPropertySet
> xErrorBarProp
;
1201 if ( eObjectType
== OBJECTTYPE_DATA_ERRORS_X
)
1202 errorBar
= CHART_UNONAME_ERRORBAR_X
;
1203 else if (eObjectType
== OBJECTTYPE_DATA_ERRORS_Y
)
1204 errorBar
= CHART_UNONAME_ERRORBAR_Y
;
1206 errorBar
= "ErrorBarZ";
1208 xSeries
->getPropertyValue( errorBar
) >>= xErrorBarProp
;
1209 xObjectProperties
= std::move(xErrorBarProp
);
1213 case OBJECTTYPE_DATA_AVERAGE_LINE
:
1214 case OBJECTTYPE_DATA_CURVE
:
1215 case OBJECTTYPE_DATA_CURVE_EQUATION
:
1217 rtl::Reference
< DataSeries
> xRegressionContainer
= ObjectIdentifier::getDataSeriesForCID(
1218 rObjectCID
, xChartModel
);
1219 if(xRegressionContainer
.is())
1221 sal_Int32 nIndex
= o3tl::toInt32(aParticleID
);
1222 const std::vector
< rtl::Reference
< RegressionCurveModel
> > & aCurveList
=
1223 xRegressionContainer
->getRegressionCurves2();
1224 if( nIndex
>= 0 && o3tl::make_unsigned(nIndex
) < aCurveList
.size() )
1226 if( eObjectType
== OBJECTTYPE_DATA_CURVE_EQUATION
)
1227 xObjectProperties
= aCurveList
[nIndex
]->getEquationProperties();
1229 xObjectProperties
= aCurveList
[nIndex
];
1234 case OBJECTTYPE_DATA_STOCK_RANGE
:
1236 case OBJECTTYPE_DATA_STOCK_LOSS
:
1238 rtl::Reference
<ChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1240 xChartType
->getPropertyValue( u
"BlackDay"_ustr
) >>= xObjectProperties
;
1243 case OBJECTTYPE_DATA_STOCK_GAIN
:
1245 rtl::Reference
<ChartType
> xChartType( lcl_getFirstStockChartType( xChartModel
) );
1247 xChartType
->getPropertyValue( u
"WhiteDay"_ustr
) >>= xObjectProperties
;
1250 case OBJECTTYPE_DATA_TABLE
:
1253 xObjectProperties
.set(xDiagram
->getDataTable(), uno::UNO_QUERY
);
1257 default: //OBJECTTYPE_UNKNOWN
1261 catch(const uno::Exception
&)
1263 DBG_UNHANDLED_EXCEPTION("chart2");
1265 return xObjectProperties
;
1268 rtl::Reference
< Axis
> ObjectIdentifier::getAxisForCID(
1269 std::u16string_view rObjectCID
1270 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1272 rtl::Reference
< Diagram
> xDiagram
;
1273 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1274 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1276 sal_Int32 nDimensionIndex
= -1;
1277 sal_Int32 nAxisIndex
= -1;
1278 lcl_parseAxisIndices( nDimensionIndex
, nAxisIndex
, rObjectCID
);
1280 return AxisHelper::getAxis( nDimensionIndex
, nAxisIndex
, xCooSys
);
1283 rtl::Reference
< DataSeries
> ObjectIdentifier::getDataSeriesForCID(
1284 std::u16string_view rObjectCID
1285 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1287 rtl::Reference
< Diagram
> xDiagram
;
1288 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1289 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1291 sal_Int32 nChartTypeIndex
= -1;
1292 sal_Int32 nSeriesIndex
= -1;
1293 sal_Int32 nPointIndex
= -1;
1294 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rObjectCID
);
1296 rtl::Reference
< DataSeries
> xSeries
;
1299 rtl::Reference
< ChartType
> xDataSeriesContainer( xDiagram
->getChartTypeByIndex( nChartTypeIndex
) );
1300 if( xDataSeriesContainer
.is() )
1302 const std::vector
< rtl::Reference
< DataSeries
> > & aDataSeriesSeq( xDataSeriesContainer
->getDataSeries2() );
1303 if( nSeriesIndex
>= 0 && o3tl::make_unsigned(nSeriesIndex
) < aDataSeriesSeq
.size() )
1304 xSeries
= aDataSeriesSeq
[nSeriesIndex
];
1310 rtl::Reference
< Diagram
> ObjectIdentifier::getDiagramForCID(
1311 std::u16string_view rObjectCID
1312 , const rtl::Reference
<::chart::ChartModel
>& xChartModel
)
1314 rtl::Reference
< Diagram
> xDiagram
;
1315 rtl::Reference
< BaseCoordinateSystem
> xCooSys
;
1316 lcl_getDiagramAndCooSys( rObjectCID
, xChartModel
, xDiagram
, xCooSys
);
1321 TitleHelper::eTitleType
ObjectIdentifier::getTitleTypeForCID( std::u16string_view rCID
)
1323 TitleHelper::eTitleType
eRet( TitleHelper::MAIN_TITLE
);
1325 std::u16string_view aParentParticle
= ObjectIdentifier::getFullParentParticle( rCID
);
1326 const tTitleMap
& rMap
= lcl_getTitleMap();
1327 tTitleMap::const_iterator aIt
= std::find_if(rMap
.begin(), rMap
.end(),
1328 [&aParentParticle
](tTitleMap::const_reference rEntry
) { return aParentParticle
== rEntry
.second
; });
1329 if (aIt
!= rMap
.end())
1330 eRet
= (*aIt
).first
;
1335 OUString
ObjectIdentifier::getSeriesParticleFromCID( std::u16string_view rCID
)
1337 sal_Int32 nDiagramIndex
= -1;
1338 sal_Int32 nCooSysIndex
= -1;
1339 lcl_parseCooSysIndices( nDiagramIndex
, nCooSysIndex
, rCID
);
1341 sal_Int32 nChartTypeIndex
= -1;
1342 sal_Int32 nSeriesIndex
= -1;
1343 sal_Int32 nPointIndex
= -1;
1344 lcl_parseSeriesIndices( nChartTypeIndex
, nSeriesIndex
, nPointIndex
, rCID
);
1346 return ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1349 OUString
ObjectIdentifier::getMovedSeriesCID( std::u16string_view rObjectCID
, bool bForward
)
1351 sal_Int32 nDiagramIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CID/D=" ) );
1352 sal_Int32 nCooSysIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CS=" ) );
1353 sal_Int32 nChartTypeIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"CT=" ) );
1354 sal_Int32 nSeriesIndex
= lcl_StringToIndex( lcl_getIndexStringAfterString( rObjectCID
, u
"Series=" ) );
1361 OUString aRet
= ObjectIdentifier::createParticleForSeries( nDiagramIndex
, nCooSysIndex
, nChartTypeIndex
, nSeriesIndex
);
1362 return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet
);
1365 bool ObjectIdentifier::isValid() const
1367 return ( isAutoGeneratedObject() || isAdditionalShape() );
1370 bool ObjectIdentifier::isAutoGeneratedObject() const
1372 return ( !m_aObjectCID
.isEmpty() );
1375 bool ObjectIdentifier::isAdditionalShape() const
1377 return m_xAdditionalShape
.is();
1380 Any
ObjectIdentifier::getAny() const
1383 if ( isAutoGeneratedObject() )
1385 aAny
<<= getObjectCID();
1387 else if ( isAdditionalShape() )
1389 aAny
<<= getAdditionalShape();
1396 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */