diff options
author | Ingrid Halama <iha@openoffice.org> | 2003-11-08 21:52:47 +0000 |
---|---|---|
committer | Ingrid Halama <iha@openoffice.org> | 2003-11-08 21:52:47 +0000 |
commit | 626626140bb7e9ed2c64dba54aa1bc42441d57c9 (patch) | |
tree | de2ae4c301549f3390445ad3c0ca8895c71e7402 | |
parent | f6f0be820f10cba46e8613331b98f7dc0a84ba04 (diff) |
added method getChartTypeOfSeries
-rw-r--r-- | chart2/source/inc/ChartModelHelper.hxx | 15 | ||||
-rw-r--r-- | chart2/source/tools/ChartModelHelper.cxx | 55 |
2 files changed, 66 insertions, 4 deletions
diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx index 81d908b44e74..8883f7f0dd8d 100644 --- a/chart2/source/inc/ChartModelHelper.hxx +++ b/chart2/source/inc/ChartModelHelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModelHelper.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:29 $ + * last change: $Author: iha $ $Date: 2003-11-08 22:52:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,9 @@ #ifndef _CHART2_CONTROLLER_CHARTMODELHELPER_HXX #define _CHART2_CONTROLLER_CHARTMODELHELPER_HXX +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPEGROUP_HPP_ +#include <drafts/com/sun/star/chart2/XChartTypeGroup.hpp> +#endif #ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDATASERIES_HPP_ #include <drafts/com/sun/star/chart2/XDataSeries.hpp> #endif @@ -104,6 +107,14 @@ public: const rtl::OUString& rIdentifier , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel ); + + static ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartType > + getChartTypeOfSeries( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xModel + , const ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XDataSeries >& xGivenDataSeries ); }; //............................................................................. diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index c7a2f971534d..7c4939cd4f6d 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModelHelper.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-09 15:51:53 $ + * last change: $Author: iha $ $Date: 2003-11-08 22:52:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -208,6 +208,57 @@ uno::Reference< XDataSeries > ChartModelHelper::getSeriesByIdentifier( return xRet; } +uno::Reference< XChartType > ChartModelHelper::getChartTypeOfSeries( + const uno::Reference< frame::XModel >& xModel + , const uno::Reference< XDataSeries >& xGivenDataSeries ) +{ + uno::Reference< XChartType > xRet(NULL); + + //iterate through the nmodel to find the given xSeries in the tree + //the found parent indicates the charttype + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); + if(!xDiagram.is()) + return xRet; + uno::Reference< XDataSeriesTreeParent > xTree = xDiagram->getTree(); + if(!xTree.is()) + return xRet; + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aChartTypes( xTree->getChildren() ); + for( sal_Int32 i = 0; i < aChartTypes.getLength(); ++i ) + { + uno::Reference< XChartTypeGroup > xChartTypeGroup( aChartTypes[i], uno::UNO_QUERY ); + DBG_ASSERT(xChartTypeGroup.is(),"First node at the diagram tree needs to be a ChartTypeGroup"); + if( !xChartTypeGroup.is() ) + continue; + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aXSlots( xChartTypeGroup->getChildren() ); + for( sal_Int32 nX = 0; nX < aXSlots.getLength(); ++nX ) + { + uno::Reference< XDataSeriesTreeParent > xXSlot = uno::Reference< XDataSeriesTreeParent >::query( aXSlots[nX] ); + DBG_ASSERT( xXSlot.is(), "a node for the first dimension of a chart tree should always be a parent" ); + if(!xXSlot.is()) + continue; + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aYSlots( xXSlot->getChildren() ); + for( sal_Int32 nY = 0; nY < aYSlots.getLength(); ++nY ) + { + uno::Reference< XDataSeriesTreeParent > xYSlot = uno::Reference< XDataSeriesTreeParent >::query( aYSlots[nY] ); + DBG_ASSERT( xYSlot.is(), "a node for the second dimension of a chart tree should always be a parent" ); + if(!xYSlot.is()) + continue; + uno::Sequence< uno::Reference< XDataSeriesTreeNode > > aSeriesList( xYSlot->getChildren() ); + for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS ) + { + uno::Reference< XDataSeries > xDataSeries( aSeriesList[nS], uno::UNO_QUERY ); + if( xGivenDataSeries==xDataSeries ) + { + xRet = xChartTypeGroup->getChartType(); + return xRet; + } + } + } + } + } + return xRet; +} + //............................................................................. } //namespace chart //............................................................................. |