summaryrefslogtreecommitdiffstats
path: root/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx')
-rw-r--r--chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx89
1 files changed, 42 insertions, 47 deletions
diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index 4d035c061b6c..653e7bf20e5a 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -21,6 +21,8 @@
#include "SchWhichPairs.hxx"
#include <ChartModelHelper.hxx>
+#include <ChartType.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <DiagramHelper.hxx>
#include <Diagram.hxx>
@@ -29,13 +31,12 @@
#include <ChartModel.hxx>
#include <BaseCoordinateSystem.hxx>
-#include <com/sun/star/chart2/XDataSeries.hpp>
-
#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;
@@ -45,12 +46,12 @@ namespace chart::wrapper
SeriesOptionsItemConverter::SeriesOptionsItemConverter(
const rtl::Reference<::chart::ChartModel>& xChartModel
- , const uno::Reference< uno::XComponentContext > & xContext
- , const uno::Reference< beans::XPropertySet >& xPropertySet
+ , 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)
@@ -69,22 +70,20 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter(
{
try
{
- uno::Reference< XDataSeries > xDataSeries( xPropertySet, uno::UNO_QUERY );
-
m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries );
- rtl::Reference< Diagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) );
- 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];
@@ -128,8 +126,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter(
}
m_aSupportedMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType );
- m_nMissingValueTreatment = DiagramHelper::getCorrectedMissingValueTreatment(
- ChartModelHelper::findDiagram(m_xChartModel), xChartType );
+ m_nMissingValueTreatment = xDiagram->getCorrectedMissingValueTreatment( xChartType );
uno::Reference< beans::XPropertySet > xProp( m_xChartModel->getDataProvider(), uno::UNO_QUERY );
if( xProp.is() )
@@ -147,7 +144,7 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter(
}
}
- m_bHideLegendEntry = !xPropertySet->getPropertyValue("ShowLegendEntry").get<bool>();
+ m_bHideLegendEntry = !xDataSeries->getPropertyValue("ShowLegendEntry").get<bool>();
}
catch( const uno::Exception & )
{
@@ -183,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;
@@ -204,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 );
- rtl::Reference< Diagram > 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 : asNonConstRange(aBarPositionSequence) )
- pos = rBarPosition;
- }
- else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() )
- aBarPositionSequence.getArray()[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;
}
}
}
@@ -241,7 +236,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf
if( m_bSupportingBarConnectors )
{
bool bOldConnectBars = false;
- rtl::Reference< Diagram > 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 )
@@ -260,7 +255,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf
if( m_bSupportingAxisSideBySide )
{
bool bOldGroupBarsPerAxis = true;
- rtl::Reference< Diagram > 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 )
@@ -277,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;
- rtl::Reference< Diagram > 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) );
@@ -293,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() );
@@ -314,7 +309,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf
{
try
{
- rtl::Reference< Diagram > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY );
+ rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() );
if( xDiagramProperties.is() )
{
xDiagramProperties->setPropertyValue( "MissingValueTreatment" , uno::Any( nNew ));
@@ -347,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;
@@ -397,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: