Collections and references


#1

Hello,

I am evaluating your product for use, and I have found a couple steps that are used very often and are quite annoying.

Here’s an example block of code:

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
section.Paragraphs = new Paragraphs();
section.Paragraphs.Add(table1);

Row row1 = new Row();
row1.Table = table1;
table1.Rows = new Rows();
table1.Rows.Add(row1);

Cell cell1 = new Cell();
cell1.Table = table1;
row1.Cells = new Cells();
row1.Cells.Add(cell1);
cell1.FitWidth = 100;


These are the two parts in question:
1. Whenever creating a new object (e.g. a Row), instead of being forced to set the Table property afterwards, could the Table be passed into the constructor instead? This would save quite a few lines of code especially since it could be done for the Cell, too.
2. When creating a new (e.g. a Row again), it is very annoying having to set the child collection to a new collection. The annoyance factor grows since it has to be done every time. To eliminate this the child collection could be set to a new collection in the constructor of the class. This will eliminate a lot of code (e.g. “row1.Cells = new Cells()” would never need to be done by the developer because it will be in the “Row” constructor).

Let me know if there would be any problems with implementing these ideas, or if there are any particular reasons for having the code written the way it is.

Thanks,


#2

In the following code:

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
section.Paragraphs = new Paragraphs();
section.Paragraphs.Add(table1);

Row row1 = new Row();
row1.Table = table1;
table1.Rows = new Rows();
table1.Rows.Add(row1);

Cell cell1 = new Cell();
cell1.Table = table1;
row1.Cells = new Cells();
row1.Cells.Add(cell1);
cell1.FitWidth = 100;

Text text1 = new Text(section);
cell1.Paragraphs = new Paragraphs();
cell1.Paragraphs.Add(text1);
Segment segment1 = new Segment(text1);
text1.Segments = new Segments();
text1.Segments.Add(segment1);
segment1.Content = “cell1”;


Why does “text1” require the section to be passed into the constructor, and when it is not passed in I get an “Invalid ColorSpaceType type” error? “text1” is a child of cell1, so a reference to the section seems strange. Also receiving the type of error that I did is even stranger.

This code was taken from the example under the Cell class in the help file.


#3

Dear Marksman,

Thanks for your consideration.

1. Whenever creating a new object (e.g. a Row), instead of being forced to set the Table property afterwards, could the Table be passed into the constructor instead? This would save quite a few lines of code especially since it could be done for the Cell, too.

We will change our code to pass the “Table” object through to the constructor. And we will check and fix all similar issues.

2. When creating a new (e.g. a Row again), it is very annoying having to set the child collection to a new collection. The annoyance factor grows since it has to be done every time. To eliminate this the child collection could be set to a new collection in the constructor of the class. This will eliminate a lot of code (e.g. “row1.Cells = new Cells()” would never need to be done by the developer because it will be in the “Row” constructor).

We will change our code to set the child collection to new collection in the constructor. And we will check and fix all similar issues.

Why does “text1” require the section to be passed into the constructor, and when it is not passed in I get an “Invalid ColorSpaceType type” error? “text1” is a child of cell1, so a reference to the section seems strange. Also receiving the type of error that I did is even stranger.

Text paragraph inherits many properties from Section, such as font and color. If a series of paragraphs share some of these properties, you can set them in the “Section” object and need not set them in every paragraph. That’s why passing the “Section” object to the Text object is needed. However, you should be able to use the default constructor of “Text”. We will fix this problem by using the default color and font when no “Section” object is passed to the “Text” object. Again, we will check and fix all similar issues.


#4

Dear Marksman,

I greatly appreciate your suggestion and believe it is very reasonable.

The to-be-announced release will reflect that and, hopefully, will be available within the next week.

Thanks for your tolerance.


#5

Thanks for your prompt response and consideration of my ideas.