From a5203eb648a09cc89324669fe359ae06ee6fe35b Mon Sep 17 00:00:00 2001 From: DraviaVemal Date: Wed, 17 Apr 2024 13:09:53 +0000 Subject: [PATCH] Presentation Slide Remove Fix --- Directory.Build.props | 2 +- Global/Components/Charts/2007/PieChart.cs | 14 +++++++------- Presentation/Internal/Presentation.cs | 13 ++++++++++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index df090ff1..85c001ef 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,7 +15,7 @@ 5.0 ..\bin\ DraviaVemal - 2.6.15 + 2.6.16 DraviaVemal Copyright (c) 2023 DraviaVemal Permission is hereby granted, free of charge, to any person obtaining a copy of this diff --git a/Global/Components/Charts/2007/PieChart.cs b/Global/Components/Charts/2007/PieChart.cs index 2237a902..228182ea 100644 --- a/Global/Components/Charts/2007/PieChart.cs +++ b/Global/Components/Charts/2007/PieChart.cs @@ -116,19 +116,19 @@ private SolidFillModel GetDataPointBorder(uint index, int seriesIndex) } private C.PieChartSeries CreateChartSeries(int seriesIndex, ChartDataGrouping chartDataGrouping) { - C.DataLabels dataLabels = null; - if (seriesIndex < pieChartSetting.pieChartSeriesSettings.Count) - { - PieChartDataLabel pieChartDataLabel1 = pieChartSetting.pieChartSeriesSettings.ElementAtOrDefault(seriesIndex) != null ? pieChartSetting.pieChartSeriesSettings.ElementAtOrDefault(seriesIndex).pieChartDataLabel : null; - int dataLabelCellsLength = chartDataGrouping.dataLabelCells != null ? chartDataGrouping.dataLabelCells.Length : 0; - dataLabels = CreatePieDataLabels(pieChartDataLabel1 ?? new PieChartDataLabel(), dataLabelCellsLength); - } C.PieChartSeries series = new C.PieChartSeries( new C.Index { Val = new UInt32Value((uint)chartDataGrouping.id) }, new C.Order { Val = new UInt32Value((uint)chartDataGrouping.id) }, CreateSeriesText(chartDataGrouping.seriesHeaderFormula, new[] { chartDataGrouping.seriesHeaderCells })); for (uint index = 0; index < chartDataGrouping.xAxisCells.Length; index++) { + C.DataLabels dataLabels = null; + if (seriesIndex < pieChartSetting.pieChartSeriesSettings.Count) + { + PieChartDataLabel pieChartDataLabel1 = pieChartSetting.pieChartSeriesSettings.ElementAtOrDefault(seriesIndex) != null ? pieChartSetting.pieChartSeriesSettings.ElementAtOrDefault(seriesIndex).pieChartDataLabel : null; + int dataLabelCellsLength = chartDataGrouping.dataLabelCells != null ? chartDataGrouping.dataLabelCells.Length : 0; + dataLabels = CreatePieDataLabels(pieChartDataLabel1 ?? new PieChartDataLabel(), dataLabelCellsLength); + } C.DataPoint dataPoint = new C.DataPoint(new C.Index { Val = index }, new C.Bubble3D { Val = false }); ShapePropertiesModel shapePropertiesModel = new ShapePropertiesModel() { diff --git a/Presentation/Internal/Presentation.cs b/Presentation/Internal/Presentation.cs index 8f394548..04d69833 100644 --- a/Presentation/Internal/Presentation.cs +++ b/Presentation/Internal/Presentation.cs @@ -65,7 +65,18 @@ internal void RemoveSlideByIndex(int SlideIndex) P.SlideId SlideId = (P.SlideId)GetSlideIdList().ElementAt(SlideIndex); SlidePart SlidePart = (SlidePart)GetPresentationPart().GetPartById(SlideId.RelationshipId.Value); GetSlideIdList().RemoveChild(SlideId); - GetPresentationPart().DeleteReferenceRelationship(SlideId.RelationshipId.Value); + try + { + GetPresentationPart().DeleteReferenceRelationship(SlideId.RelationshipId.Value); + } + catch (ArgumentNullException) + { + //ignore + } + catch (Exception ex) + { + throw ex; + } GetPresentationPart().DeletePart(SlidePart); } else