summaryrefslogtreecommitdiff
path: root/chart2/source/tools/ObjectIdentifier.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-01-24 15:58:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-01-24 17:43:25 +0100
commit4fbec819fc041cddcd64621acdd29bd35f4dd493 (patch)
tree5919cf487519d55231f5f002d6ec7e5cff583b2e /chart2/source/tools/ObjectIdentifier.cxx
parent54930a004e42f76f310c7ae15f61d07fbb7c7bdb (diff)
use more concrete types in chart2, ChartModel
Change-Id: I86b7fa98a6d4a269637ac042a9bb99b41ab90b0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128870 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/tools/ObjectIdentifier.cxx')
-rw-r--r--chart2/source/tools/ObjectIdentifier.cxx161
1 files changed, 14 insertions, 147 deletions
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index a9bdb598e693..5d17de7ac5aa 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -129,7 +129,7 @@ OUString lcl_getTitleParentParticle( TitleHelper::eTitleType aTitleType )
return aRet;
}
-Reference<XChartType> lcl_getFirstStockChartType( const Reference< frame::XModel >& xChartModel )
+Reference<XChartType> lcl_getFirstStockChartType( const rtl::Reference<::chart::ChartModel>& xChartModel )
{
rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
if(!xDiagram.is())
@@ -212,7 +212,7 @@ void lcl_parseSeriesIndices( sal_Int32& rnChartTypeIndex, sal_Int32& rnSeriesInd
}
void lcl_getDiagramAndCooSys( const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel
+ , const rtl::Reference<::chart::ChartModel>& xChartModel
, rtl::Reference< Diagram >& xDiagram
, rtl::Reference< BaseCoordinateSystem >& xCooSys )
{
@@ -295,7 +295,7 @@ bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const
OUString ObjectIdentifier::createClassifiedIdentifierForObject(
const Reference< uno::XInterface >& xObject
- , ChartModel& rModel)
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
OUString aRet;
@@ -312,91 +312,7 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject(
if( xTitle.is() )
{
TitleHelper::eTitleType aTitleType;
- if( TitleHelper::getTitleType( aTitleType, xTitle, rModel ) )
- {
- eObjectType = OBJECTTYPE_TITLE;
- aParentParticle = lcl_getTitleParentParticle( aTitleType );
- aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
- eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
- }
- return aRet;
-
- }
-
- //axis
- Reference< XAxis > xAxis( xObject, uno::UNO_QUERY );
- if( xAxis.is() )
- {
- rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, rModel.getFirstDiagram() ) );
- OUString aCooSysParticle( createParticleForCoordinateSystem( xCooSys, rModel ) );
- sal_Int32 nDimensionIndex=-1;
- sal_Int32 nAxisIndex=-1;
- AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex );
- OUString aAxisParticle( createParticleForAxis( nDimensionIndex, nAxisIndex ) );
- return createClassifiedIdentifierForParticles( aCooSysParticle, aAxisParticle );
- }
-
- //legend
- Reference< XLegend > xLegend( xObject, uno::UNO_QUERY );
- if( xLegend.is() )
- {
- return createClassifiedIdentifierForParticle( createParticleForLegend( rModel ) );
- }
-
- //diagram
- Reference< XDiagram > xDiagram( xObject, uno::UNO_QUERY );
- if( xDiagram.is() )
- {
- return createClassifiedIdentifierForParticle( createParticleForDiagram() );
- }
-
- //todo
- //XDataSeries
- //CooSys
- //charttype
- //datapoint?
- //Gridproperties
- }
- catch(const uno::Exception&)
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- if( eObjectType != OBJECTTYPE_UNKNOWN )
- {
- aRet = ObjectIdentifier::createClassifiedIdentifierWithParent(
- eObjectType, aObjectID, aParentParticle, aDragMethodServiceName, aDragParameterString );
- }
- else
- {
- OSL_FAIL("give object could not be identified in createClassifiedIdentifierForObject");
- }
-
- return aRet;
-}
-
-OUString ObjectIdentifier::createClassifiedIdentifierForObject(
- const Reference< uno::XInterface >& xObject
- , const Reference< frame::XModel >& xChartModel )
-{
- OUString aRet;
-
- enum ObjectType eObjectType = OBJECTTYPE_UNKNOWN;
- const OUString aObjectID;
- OUString aParentParticle;
- const OUString aDragMethodServiceName;
- const OUString aDragParameterString;
- auto pModel = dynamic_cast<ChartModel*>(xChartModel.get());
- assert(!xChartModel || pModel);
-
- try
- {
- //title
- Reference< XTitle > xTitle( xObject, uno::UNO_QUERY );
- if( xTitle.is() )
- {
- TitleHelper::eTitleType aTitleType;
- if( TitleHelper::getTitleType( aTitleType, xTitle, pModel ) )
+ if( TitleHelper::getTitleType( aTitleType, xTitle, xChartModel ) )
{
eObjectType = OBJECTTYPE_TITLE;
aParentParticle = lcl_getTitleParentParticle( aTitleType );
@@ -499,32 +415,7 @@ OUString ObjectIdentifier::createParticleForDiagram()
OUString ObjectIdentifier::createParticleForCoordinateSystem(
const Reference< XCoordinateSystem >& xCooSys
- , ChartModel& rModel )
-{
- OUString aRet;
-
- rtl::Reference< Diagram > xDiagram( rModel.getFirstChartDiagram() );
- if( xDiagram.is() )
- {
- sal_Int32 nCooSysIndex = 0;
- uno::Sequence< Reference< XCoordinateSystem > > aCooSysList( xDiagram->getCoordinateSystems() );
- for( ; nCooSysIndex < aCooSysList.getLength(); ++nCooSysIndex )
- {
- Reference< XCoordinateSystem > xCurrentCooSys( aCooSysList[nCooSysIndex] );
- if( xCooSys == xCurrentCooSys )
- {
- aRet = ObjectIdentifier::createParticleForDiagram() + ":CS=" + OUString::number( nCooSysIndex );
- break;
- }
- }
- }
-
- return aRet;
-}
-
-OUString ObjectIdentifier::createParticleForCoordinateSystem(
- const Reference< XCoordinateSystem >& xCooSys
- , const Reference< frame::XModel >& xChartModel )
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
OUString aRet;
@@ -569,7 +460,7 @@ OUString ObjectIdentifier::createParticleForGrid(
OUString ObjectIdentifier::createClassifiedIdentifierForGrid(
const Reference< XAxis >& xAxis
- , const Reference< frame::XModel >& xChartModel
+ , const rtl::Reference<::chart::ChartModel>& xChartModel
, sal_Int32 nSubGridIndex )
{
//-1: main grid, 0: first subgrid etc
@@ -597,15 +488,9 @@ OUString ObjectIdentifier::createParticleForSeries(
OUString::number( nSeriesIndex );
}
-OUString ObjectIdentifier::createParticleForLegend( ChartModel& )
-{
- //todo: if more than one diagram is implemented, find the correct diagram which is owner of the given legend
-
- return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType( OBJECTTYPE_LEGEND ) + "=";
-}
OUString ObjectIdentifier::createParticleForLegend(
- const Reference< frame::XModel >& )
+ const rtl::Reference<::chart::ChartModel>& )
{
//todo: if more than one diagram is implemented, find the correct diagram which is owner of the given legend
@@ -1140,32 +1025,14 @@ bool ObjectIdentifier::isCID( const OUString& rName )
}
Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
- const OUString& rObjectCID,
- const Reference< chart2::XChartDocument >& xChartDocument )
-{
- return ObjectIdentifier::getObjectPropertySet(
- rObjectCID, Reference< frame::XModel >( xChartDocument ));
-}
-
-Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
- const OUString& rObjectCID
- , const rtl::Reference< ::chart::ChartModel >& xChartModel )
-{
- return ObjectIdentifier::getObjectPropertySet(
- rObjectCID, Reference< frame::XModel >( xChartModel ));
-}
-
-Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel )
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
//return the model object that is indicated by rObjectCID
if(rObjectCID.isEmpty())
return nullptr;
if(!xChartModel.is())
return nullptr;
- auto pModel = dynamic_cast<ChartModel*>(xChartModel.get());
- assert(pModel);
Reference< beans::XPropertySet > xObjectProperties;
try
@@ -1175,19 +1042,19 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
rtl::Reference< Diagram > xDiagram;
rtl::Reference< BaseCoordinateSystem > xCooSys;
- lcl_getDiagramAndCooSys( rObjectCID, pModel, xDiagram, xCooSys );
+ lcl_getDiagramAndCooSys( rObjectCID, xChartModel, xDiagram, xCooSys );
switch(eObjectType)
{
case OBJECTTYPE_PAGE:
{
- xObjectProperties.set( pModel->getPageBackground() );
+ xObjectProperties.set( xChartModel->getPageBackground() );
}
break;
case OBJECTTYPE_TITLE:
{
TitleHelper::eTitleType aTitleType = getTitleTypeForCID( rObjectCID );
- Reference< XTitle > xTitle( TitleHelper::getTitle( aTitleType, pModel ) );
+ Reference< XTitle > xTitle( TitleHelper::getTitle( aTitleType, xChartModel ) );
xObjectProperties.set( xTitle, uno::UNO_QUERY );
}
break;
@@ -1344,7 +1211,7 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet(
Reference< XAxis > ObjectIdentifier::getAxisForCID(
const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel )
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
rtl::Reference< Diagram > xDiagram;
rtl::Reference< BaseCoordinateSystem > xCooSys;
@@ -1359,7 +1226,7 @@ Reference< XAxis > ObjectIdentifier::getAxisForCID(
Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID(
const OUString& rObjectCID
- , const Reference< frame::XModel >& xChartModel )
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
Reference< XDataSeries > xSeries;
@@ -1385,7 +1252,7 @@ Reference< XDataSeries > ObjectIdentifier::getDataSeriesForCID(
rtl::Reference< Diagram > ObjectIdentifier::getDiagramForCID(
const OUString& rObjectCID
- , const uno::Reference< frame::XModel >& xChartModel )
+ , const rtl::Reference<::chart::ChartModel>& xChartModel )
{
rtl::Reference< Diagram > xDiagram;
rtl::Reference< BaseCoordinateSystem > xCooSys;