Split cell result in infinite loop

Using 15.11.0.0

It seems SplitByWidth is broken.

In PowerPoint make a 5x4 table like this:
| H |
|R1 | H2 |
|R2 | H1 A | H1 B |
|R3 | A | B | C | D |

The following code will now never finish:

var presentation = new Presentation(path);
var table = (ITable)presentation.Slides[0].Shapes[0];
var h1a = table[2, 2]; //"H1 A";
h1a.SplitByWidth(h1a.Width / 2);
presentation.Save(somewhere, SaveFormat.Pptx);

The split itself ends up making a cell with colspan 0, and a loop over all cells shows there is no split, rather h1a was updated.

Expected result:
| H |
|R1 | H2 |
|R2 | H1 A | | H1 B |
|R3 | A | B | | | C | D |

Building the original table through the API results in a different error:

var pres = new Presentation();
double[] dblCols = { 120, 120, 120, 120, 120 };
double[] dblRows = { 100, 100, 100, 100 };
var sld = pres.Slides[0];
var tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows);
tbl[0, 0].TextFrame.Text = "H1";
tbl.MergeCells(tbl[0, 0], tbl[1, 0], true);
tbl.MergeCells(tbl[0, 0], tbl[2, 0], true);
tbl.MergeCells(tbl[0, 0], tbl[3, 0], true);
tbl.MergeCells(tbl[0, 0], tbl[4, 0], true);
tbl[0, 1].TextFrame.Text = "R1";
tbl[0, 2].TextFrame.Text = "R2";
tbl[0, 3].TextFrame.Text = "R3";

tbl[1, 1].TextFrame.Text = "H2";
tbl.MergeCells(tbl[1, 1], tbl[2, 1], true);
tbl.MergeCells(tbl[1, 1], tbl[3, 1], true);
tbl.MergeCells(tbl[1, 1], tbl[4, 1], true);

tbl[1, 2].TextFrame.Text = "H1 A";
tbl.MergeCells(tbl[1, 2], tbl[2, 2], true);

tbl[3, 2].TextFrame.Text = "H1 B";
tbl.MergeCells(tbl[3, 2], tbl[4, 2], true);

tbl[1, 3].TextFrame.Text = "A";
tbl[2, 3].TextFrame.Text = "B";
tbl[3, 3].TextFrame.Text = "C";
tbl[4, 3].TextFrame.Text = "D";

tbl[2, 2].SplitByWidth(tbl[2, 2].Width / 2);

Throws exception:

Unhandled Exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Splitting width must be in greater than 0 and less than cell’s width
    at Aspose.Slides.ColumnCollection.☻(Int32 ☻, Double ♥)
    at Aspose.Slides.Cell.SplitByWidth(Double width)

Repro via code only:

var pres = new Presentation();
double[] dblCols = { 60, 60 };
double[] dblRows = { 100, 100};
var sld = pres.Slides[0];
var tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows);
tbl[0, 0].TextFrame.Text = "A";
tbl[0, 1].TextFrame.Text = "B";
tbl[1, 0].TextFrame.Text = "C";
tbl[1, 1].TextFrame.Text = "D";

tbl[1, 1].SplitByWidth(tbl[1, 1].Width / 2);

pres.Save(somewhere, SaveFormat.Pptx);

And another bug for the simpler case:

var pres = new Presentation();
double[] dblCols = { 60 };
double[] dblRows = { 100};
var sld = pres.Slides[0];
var tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows);
tbl[0, 0].TextFrame.Text = "A";

tbl[0, 0].SplitByWidth(tbl[0, 0].Width / 2);

pres.Save(somewhere, SaveFormat.Pptx);

Exception:

Unhandled Exception: System.IndexOutOfRangeException: value of index = 2 is out of range 0…1
at Aspose.Slides.ColumnCollection.get_Item(Int32 index)
at ? .☻(Table ☻, ♠ ♥, ♣)
at ☼ .☻(IShape ☻, ☻?? ♥, ♣, ☼ )
at ☼ .☻(IGroupShape ☻, ☻?? ♥, ♣, ☼ )
at ♥ .☻(IBaseSlide ☻, ♥, ♣)
at ♫ ? .☻(ISlide ☻)
at ♠ .☻ ☻, ISlide ♥, ♣)
at ♠ .☻(IPresentation ☻,? ? ♥, PresentationTypeEx ♣, IPptxOptions)
at Aspose.Slides.Presentation.☻(Stream ☻, PresentationTypeEx ♥, IPptxOptions ♣)
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)

Hi Dennis,

Thank you for your interest in Aspose.Slides.

I have observed your comments and like to share with you that I am unable to reproduce the issue on my end. SplitByWidth method is working fine. I request you to please try using Aspose.Slides for .NET 15.11.0 and below sample code on your side, and then share your kind feedback with us. I have attached the generated output presentation for your kind reference (see Split_15.11.0.pptx). If the issue persists then please share with us the source files to reproduce the issue so that we may proceed further to help you out.

//Create an instance of Presentation class
Presentation Pres = new Presentation();

//Get reference of a slide
ISlide Sld = Pres.Slides[0];

//Add a table on slide
ITable tbl = Sld.Shapes.AddTable(326, 216, new double[] { 50, 50 }, new double[] { 50, 50 });

//Split the cells by splitting function
tbl[0, 0].SplitByWidth(tbl[0,0].Width/2);

//Write the presentation as a PPTX file
Pres.Save(@"D:\Split_15.11.0.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

Please let us know if the issue persists. We will be glad to help you further.

Best Regards,

So of the 4 reported issues (which may or may not be related), you choose to use none of the code mentioned and instead choose to make the absolute most simple test case that actually does work and thus concluded it is working??

Furthermore, you failed to check anything at all. In your example, after the call to SplitByWidth.

foreach (var row in table.Columns)
    foreach (var cell in row)
        Console.WriteLine("Val: { 0} ColSpan: { 1}", cell.TextFrame.Text, cell.ColSpan);

Shows that is there is still only 4 cells AFTER the split, and one of them has a ColSpan of 0.

Furthermore, trying to print .Height of the cells results in the 5th bug found:

Unhandled Exception: System.Exception: Slave cell in first row on the 1 column!
at Aspose.Slides.Table.☻(☼?? ☻, ♣ ♥, Boolean ♣)
at Aspose.Slides.Table.☻()
at Aspose.Slides.Table.☻(♣ ☻)
at Aspose.Slides.Table.wghxc7kq5bpewg3z9kl55dukble7gh7h ♥()
at Aspose.Slides.Cell.get_Height()

Also, if you try to split 1,1 instead of 0,0 in your example you would have encountered the never ending save.

I wrote as the very first thing, that I am already using 15.11.0.0.

And bug 6:

Calling split twice in your example throws exception:

tbl[0, 0].SplitByWidth(tbl[0, 0].Width / 2);
tbl[0, 0].SplitByWidth(tbl[0, 0].Width / 2);
Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at Aspose.Slides.Cell.get_Width()

Hi Dennis,

Please accept my apologies for inconvenience on your end. I have observed the issues reported by you and like to share that we are investigating the reported issues in detail on our end. We will be adding several issues in our issue tracking system in order to rectify them. We really appreciate your keen interest and observation in our API for reporting such issues as it contributes towards betterment of API. We will share further feedback with you shortly after creating tickets in our issue tracking system for reported issues.

Many Thanks,

Hi Dennis,

I have observed your comments and like to share with you that while referring to this post of you, I am getting ArgumentOutOfRangeException while using the attached presentation file (see Split_15.11.0.pptx). I am unable to reproduce the issue as mentioned by you as “The following code will now never finish”. Please refer attached image exception.JPG.

  • About this post, I am able to reproduce the issue which has been logged with ID SLIDESNET-37162 in our issue management system for further investigation and resolution.
  • About this post, the code keeps on executing and the generated file is never saved, for which another issue with ID SLIDESNET-37163 has been logged.
  • About this post, SLIDESNET-37164 has been logged for the issue of IndexOutOfRangeException.
  • About this post, SLIDESNET-37165 has been logged for the issue of zero column span and Height of the cells.
  • About this post, SLIDESNET-37166 has been logged for the issue of ArgumentOutOfRangeException when split is called twice.

This thread has been linked with these tickets so that you may be notified as soon as the issue will be fixed.

We are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESNET-37166;SLIDESNET-37165;SLIDESNET-37164;SLIDESNET-37163;SLIDESNET-37162) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.