diff options
Diffstat (limited to 'chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx')
-rw-r--r-- | chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx | 117 |
1 files changed, 55 insertions, 62 deletions
diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index fc25407d1a58..653e7bf20e5a 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -21,19 +21,22 @@ #include "SchWhichPairs.hxx" #include <ChartModelHelper.hxx> +#include <ChartType.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <ChartTypeHelper.hxx> #include <DataSeriesHelper.hxx> #include <ChartModel.hxx> - -#include <com/sun/star/chart2/XDataSeries.hpp> +#include <BaseCoordinateSystem.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> #include <svl/ilstitem.hxx> #include <svx/sdangitm.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -42,13 +45,13 @@ namespace chart::wrapper { SeriesOptionsItemConverter::SeriesOptionsItemConverter( - const uno::Reference< frame::XModel >& xChartModel - , const uno::Reference< uno::XComponentContext > & xContext - , const uno::Reference< beans::XPropertySet >& xPropertySet + const rtl::Reference<::chart::ChartModel>& xChartModel + , uno::Reference< uno::XComponentContext > xContext + , const rtl::Reference< ::chart::DataSeries >& xDataSeries , SfxItemPool& rItemPool ) - : ItemConverter( xPropertySet, rItemPool ) + : ItemConverter( xDataSeries, rItemPool ) , m_xChartModel(xChartModel) - , m_xCC(xContext) + , m_xCC(std::move(xContext)) , m_bAttachToMainAxis(true) , m_bSupportingOverlapAndGapWidthProperties(false) , m_bSupportingBarConnectors(false) @@ -60,7 +63,6 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( , m_bSupportingStartingAngle(false) , m_nStartingAngle(90) , m_bClockwise(false) - , m_aSupportedMissingValueTreatments() , m_nMissingValueTreatment(0) , m_bSupportingPlottingOfHiddenCells(false) , m_bIncludeHiddenCells(true) @@ -68,23 +70,20 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( { try { - uno::Reference< XDataSeries > xDataSeries( xPropertySet, uno::UNO_QUERY ); - m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); - uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); - uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) ); + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xDataSeries ) ); m_xCooSys = DataSeriesHelper::getCoordinateSystemOfSeries( xDataSeries, xDiagram ); if( m_xCooSys.is() ) { - uno::Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1, 0, m_xCooSys ) ); + rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, 0, m_xCooSys ); chart2::ScaleData aScale( xAxis->getScaleData() ); m_bClockwise = (aScale.Orientation == chart2::AxisOrientation_REVERSE); } - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + sal_Int32 nDimensionCount = xDiagram->getDimension(); m_bSupportingOverlapAndGapWidthProperties = ChartTypeHelper::isSupportingOverlapAndGapWidthProperties( xChartType, nDimensionCount ); if( m_bSupportingOverlapAndGapWidthProperties ) @@ -93,15 +92,14 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); uno::Sequence< sal_Int32 > aBarPositionSequence; - uno::Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY ); - if( xChartTypeProps.is() ) + if( xChartType.is() ) { - if( xChartTypeProps->getPropertyValue( "OverlapSequence" ) >>= aBarPositionSequence ) + if( xChartType->getPropertyValue( "OverlapSequence" ) >>= aBarPositionSequence ) { if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) m_nBarOverlap = aBarPositionSequence[nAxisIndex]; } - if( xChartTypeProps->getPropertyValue( "GapwidthSequence" ) >>= aBarPositionSequence ) + if( xChartType->getPropertyValue( "GapwidthSequence" ) >>= aBarPositionSequence ) { if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) m_nGapWidth = aBarPositionSequence[nAxisIndex]; @@ -110,29 +108,27 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( } m_bSupportingBarConnectors = ChartTypeHelper::isSupportingBarConnectors( xChartType, nDimensionCount ); - if( m_bSupportingBarConnectors && xDiagramProperties.is() ) + if( m_bSupportingBarConnectors && xDiagram.is() ) { - xDiagramProperties->getPropertyValue( "ConnectBars" ) >>= m_bConnectBars; + xDiagram->getPropertyValue( "ConnectBars" ) >>= m_bConnectBars; } m_bSupportingAxisSideBySide = ChartTypeHelper::isSupportingAxisSideBySide( xChartType, nDimensionCount ); - if( m_bSupportingAxisSideBySide && xDiagramProperties.is() ) + if( m_bSupportingAxisSideBySide && xDiagram.is() ) { - xDiagramProperties->getPropertyValue( "GroupBarsPerAxis" ) >>= m_bGroupBarsPerAxis; + xDiagram->getPropertyValue( "GroupBarsPerAxis" ) >>= m_bGroupBarsPerAxis; } m_bSupportingStartingAngle = ChartTypeHelper::isSupportingStartingAngle( xChartType ); if( m_bSupportingStartingAngle ) { - xDiagramProperties->getPropertyValue( "StartingAngle" ) >>= m_nStartingAngle; + xDiagram->getPropertyValue( "StartingAngle" ) >>= m_nStartingAngle; } m_aSupportedMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ); - m_nMissingValueTreatment = DiagramHelper::getCorrectedMissingValueTreatment( - ChartModelHelper::findDiagram(m_xChartModel), xChartType ); + m_nMissingValueTreatment = xDiagram->getCorrectedMissingValueTreatment( xChartType ); - uno::Reference< XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xProp( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProp( m_xChartModel->getDataProvider(), uno::UNO_QUERY ); if( xProp.is() ) { try @@ -141,14 +137,14 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( xProp->getPropertyValue( "IncludeHiddenCells" ); //if not exception is thrown the property is offered m_bSupportingPlottingOfHiddenCells = true; - xDiagramProperties->getPropertyValue( "IncludeHiddenCells" ) >>= m_bIncludeHiddenCells; + xDiagram->getPropertyValue( "IncludeHiddenCells" ) >>= m_bIncludeHiddenCells; } catch( const beans::UnknownPropertyException& ) { } } - m_bHideLegendEntry = !xPropertySet->getPropertyValue("ShowLegendEntry").get<bool>(); + m_bHideLegendEntry = !xDataSeries->getPropertyValue("ShowLegendEntry").get<bool>(); } catch( const uno::Exception & ) { @@ -160,7 +156,7 @@ SeriesOptionsItemConverter::~SeriesOptionsItemConverter() { } -const sal_uInt16 * SeriesOptionsItemConverter::GetWhichPairs() const +const WhichRangesContainer& SeriesOptionsItemConverter::GetWhichPairs() const { // must span all used items! return nSeriesOptionsWhichPairs; @@ -184,8 +180,9 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( bAttachToMainAxis != m_bAttachToMainAxis ) { //change model: - bChanged = DiagramHelper::attachSeriesToAxis( bAttachToMainAxis, uno::Reference< XDataSeries >::query( GetPropertySet() ) - , ChartModelHelper::findDiagram(m_xChartModel), m_xCC ); + rtl::Reference<DataSeries> xDataSeries = dynamic_cast<DataSeries*>( GetPropertySet().get() ); + bChanged = m_xChartModel->getFirstChartDiagram()->attachSeriesToAxis( bAttachToMainAxis, xDataSeries + , m_xCC ); if( bChanged ) m_bAttachToMainAxis = bAttachToMainAxis; @@ -205,30 +202,27 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( nWhichId == SCHATTR_BAR_OVERLAP ) aPropName = "OverlapSequence"; - uno::Reference< XDataSeries > xDataSeries( GetPropertySet(), uno::UNO_QUERY ); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(m_xChartModel) ); - uno::Reference< beans::XPropertySet > xChartTypeProps( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ), uno::UNO_QUERY ); - if( xChartTypeProps.is() ) + rtl::Reference< DataSeries > xDataSeries( dynamic_cast<DataSeries*>(GetPropertySet().get()) ); + rtl::Reference< Diagram > xDiagram( m_xChartModel->getFirstChartDiagram() ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xDataSeries ) ); + if( xChartType.is() ) { sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); uno::Sequence< sal_Int32 > aBarPositionSequence; - if( xChartTypeProps.is() ) + if( xChartType->getPropertyValue( aPropName ) >>= aBarPositionSequence ) { - if( xChartTypeProps->getPropertyValue( aPropName ) >>= aBarPositionSequence ) + bool bGroupBarsPerAxis = rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS ).GetValue(); + if(!bGroupBarsPerAxis) { - bool bGroupBarsPerAxis = rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS ).GetValue(); - if(!bGroupBarsPerAxis) - { - //set the same value for all axes - for( auto & pos : aBarPositionSequence ) - pos = rBarPosition; - } - else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) - aBarPositionSequence[nAxisIndex] = rBarPosition; - - xChartTypeProps->setPropertyValue( aPropName, uno::Any(aBarPositionSequence) ); - bChanged = true; + //set the same value for all axes + for( auto & pos : asNonConstRange(aBarPositionSequence) ) + pos = rBarPosition; } + else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) + aBarPositionSequence.getArray()[nAxisIndex] = rBarPosition; + + xChartType->setPropertyValue( aPropName, uno::Any(aBarPositionSequence) ); + bChanged = true; } } } @@ -242,7 +236,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( m_bSupportingBarConnectors ) { bool bOldConnectBars = false; - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() && (xDiagramProperties->getPropertyValue( "ConnectBars" ) >>= bOldConnectBars) && bOldConnectBars != m_bConnectBars ) @@ -261,7 +255,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( m_bSupportingAxisSideBySide ) { bool bOldGroupBarsPerAxis = true; - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() && (xDiagramProperties->getPropertyValue( "GroupBarsPerAxis" ) >>= bOldGroupBarsPerAxis) && bOldGroupBarsPerAxis != m_bGroupBarsPerAxis ) @@ -278,7 +272,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( m_bSupportingStartingAngle ) { m_nStartingAngle = static_cast< const SdrAngleItem & >( rItemSet.Get( nWhichId )).GetValue().get() / 100; - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() ) { xDiagramProperties->setPropertyValue( "StartingAngle" , uno::Any(m_nStartingAngle) ); @@ -294,7 +288,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf rItemSet.Get( nWhichId )).GetValue(); if( m_xCooSys.is() ) { - uno::Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1, 0, m_xCooSys ) ); + rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, 0, m_xCooSys ); if( xAxis.is() ) { chart2::ScaleData aScaleData( xAxis->getScaleData() ); @@ -315,7 +309,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf { try { - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() ) { xDiagramProperties->setPropertyValue( "MissingValueTreatment" , uno::Any( nNew )); @@ -337,9 +331,8 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf bool bIncludeHiddenCells = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue(); if (bIncludeHiddenCells != m_bIncludeHiddenCells) { - ChartModel* pModel = dynamic_cast<ChartModel*>(m_xChartModel.get()); - if (pModel) - bChanged = ChartModelHelper::setIncludeHiddenCells( bIncludeHiddenCells, *pModel ); + if (m_xChartModel) + bChanged = ChartModelHelper::setIncludeHiddenCells( bIncludeHiddenCells, *m_xChartModel ); } } } @@ -349,7 +342,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf bool bHideLegendEntry = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue(); if (bHideLegendEntry != m_bHideLegendEntry) { - GetPropertySet()->setPropertyValue("ShowLegendEntry", css::uno::makeAny(!bHideLegendEntry)); + GetPropertySet()->setPropertyValue("ShowLegendEntry", css::uno::Any(!bHideLegendEntry)); } } break; @@ -399,7 +392,7 @@ void SeriesOptionsItemConverter::FillSpecialItem( case SCHATTR_STARTING_ANGLE: { if( m_bSupportingStartingAngle ) - rOutItemSet.Put( SdrAngleItem(nWhichId, Degree100(m_nStartingAngle*100)) ); + rOutItemSet.Put( SdrAngleItem(SCHATTR_STARTING_ANGLE, Degree100(m_nStartingAngle*100)) ); break; } case SCHATTR_CLOCKWISE: |