CALS Table functions

Having trouble installing Oxygen? Got a bug to report? Post it all here.
shilpa
Posts: 66
Joined: Mon Jul 04, 2022 8:42 am

CALS Table functions

Post by shilpa »

Hi Team,

I working on table functionality in web author.
Need your help to understand and use the proper existing class of table operations for the below functionalities.
Using CALS table.

Insert column to existing table
Insert row to existing table
Delete row from existing table
Delete column from existing table.

Thanks & Regards
Shilpa.P
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: CALS Table functions

Post by mihaela »

Hi Shilpa,

We recently created a sample plugin that offers the following CALS Table support for any XML document in Web Author:
- table rendering
- specific actions are added before each table to insert or delete rows and columns and to join or split cells
- multiple rows and columns can be selected (by mouse drag or click on column header markers) to easily copy or move table data by using copy/paste

Here is the web-author-CALS-table-plugin:
https://github.com/oxygenxml/web-author ... ble-plugin

You can use it for your customization and tell us if there is some functionality that is missing for you and you do not know how it can be implemented.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shilpa
Posts: 66
Joined: Mon Jul 04, 2022 8:42 am

Re: CALS Table functions

Post by shilpa »

Hi Mihaela,

I have added code [image 1] which you mentioned in previous post in my plugin and getting exception [image 2].
image.png
image.png (45.67 KiB) Viewed 1122 times
image.png
image.png (31.54 KiB) Viewed 1122 times
Please do the needfull.

Thanks & Regards
Shilpa.P
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: CALS Table functions

Post by mihaela »

Hello,

Can you please provide a sample XML for which you can reproduce this exception?
Also please specify where is the caret when you invoke the Insert Column operation.
Thank you!

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shilpa
Posts: 66
Joined: Mon Jul 04, 2022 8:42 am

Re: CALS Table functions

Post by shilpa »

Hi Miheala,

Please find below table structure.

<tbl ID="tbl5" maxsize="default">
<table colsep="0" rowsep="0"><?ctbl ampex.cols='2'?>
<tgroup cols="2"><?ctbl ampex.table.align='center'?><?ctbl ampex.colwidth='100'?>
<colspec align="left" colname="col1" colnum="1"/><?ctbl ampex.vert.just='top'?><?ctbl ampex.colwidth='100'?>
<colspec align="center" colname="col2" colnum="2"/><?ctbl ampex.vert.just='top'?>
<tbody>
<row>
<entry colname="col1" valign="top">
<para>
<paratext ID="p69">
<leader source="dtbl">
<leaderchar>1</leaderchar>
</leader>
</paratext>
</para>
</entry>
<entry colname="col2" valign="top">
<para>
<paratext ID="p70"/>
</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</tbl>

my cursor position is inside entry tag
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: CALS Table functions

Post by mihaela »

Hello,

Thank you for the sample and the details, we managed to reproduce the problem.
We analyzed this and the error appears when there are processing instructions inside the table, between the colspecs.
If I remove the processing instructions from your sample, the action works well.

We added an issue in our internal issues tracking system for this and we will update this thread when a fix will be available (the fix must be included in a Web Author release, it is not something that can be fixed in the CALS tables sample plugin).

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: CALS Table functions

Post by mihaela »

Hello,

It is ok for you that this problem to be fixed in the next Web Author version (25.1)? The release is planned in two months.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
shilpa
Posts: 66
Joined: Mon Jul 04, 2022 8:42 am

Re: CALS Table functions

Post by shilpa »

Thank you Mihaela for the update.

Actually Next month we have prod release so we need to provide this item end of this month itself.
Now using insertXMLFragmentSchemaAware am able to insert new column.
For updating new column name and number to colspec using below code.
Below code giving CALSColSpec object as null.. Could you please tell me am i missing anything.

Code: Select all

int caretOffset = authorAccess.getEditorAccess().getCaretOffset();
			AuthorNode nodeAtCaret = docCtrl.getNodeAtOffset(caretOffset);
			cellElement = getElementAncestor(nodeAtCaret, AuthorTableHelper.TYPE_CELL);
			if(null!=cellElement) {
				AuthorElement tgroupElement = getElementAncestor(nodeAtCaret, AuthorTableHelper.TYPE_TABLE);
				List<AuthorNode> childNodes = tgroupElement.getContentNodes();
				AuthorElement tableElement = (AuthorElement) tgroupElement.getParentElement();
				AuthorTableCellSpanProvider provider = tableHelper.getTableCellSpanProvider(tableElement);
				CALSTableCellInfoProvider cellInfoProvider = new CALSTableCellInfoProvider(true);
				cellInfoProvider.init(tableElement);
				for(AuthorNode childNode : tgroupElement.getContentNodes()) {
					if(childNode.getType() == AuthorNode.NODE_TYPE_ELEMENT && tableHelper.isColspec(childNode)){
						AuthorElement childElement = (AuthorElement) childNode;
						String colSpecName = childElement.getAttribute("colname").getValue();
						CALSColSpec calsColSpec = cellInfoProvider.getColSpec(colSpecName);
					}
				}
			}
Thanks & Regards
Shilpa.P
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: CALS Table functions

Post by Bogdan Dumitru »

Hello Shilpa,

The "calsColSpec" variable might be null if the AuthorTableCellSpanProvider is created on the wrong element (tableHelper.getTableCellSpanProvider(tableElement)). The "getTableCellSpanProvider" method should be called with the parameter that has the "display: table" CSS property specified. Notice that for the CALS tables, the "display: table" CSS property is set on the "tgroup" element, not on the "table" element. Try replacing "getTableCellSpanProvider(tableElement)" with "getTableCellSpanProvider(tgroupElement)".
Bogdan Dumitru
http://www.oxygenxml.com
shilpa
Posts: 66
Joined: Mon Jul 04, 2022 8:42 am

Re: CALS Table functions

Post by shilpa »

Thanks Dumitru..
Now i am able to get CALSColSpec object.
Below is my table structure
image.png
image.png (56.36 KiB) Viewed 989 times
My requirement is to add new column to each rows of existing table.
Below is the code to add a new column.
docCtrl.insertXMLFragmentSchemaAware(cellFragment. offsetToInsert);

//Below code for getting existing colspec
AuthorTableCellSpanProvider tableCellsSpanprovider = tableHelper.getTableCellSpanProvider(tgroupElement);
CALSTableCellInfoProvider cellInfoProvider = new CALSTableCellInfoProvider(true);
cellInfoProvider.init(tgroupElement);
CALSColSpec calsColSpec= cellInfoProvider.getColSpec(cellColSpecName);
int colIndex = calsColSpec.getIndexInDocument();
//count is number of colspec already present in table

after column insertion i am adding below code to update colspec
updateColumnCellsSpan(authorAccess, tableCellsSpanprovider, tgroupElement, colIndex,
new TableColumnSpecificationInformation(WidthRepresentation.DEFAULT_WIDTH_REPRESENTATION),
"http://www.thomsonreuters.com/legal/judicialdocs", count);
Getting below exception
ro.sync.ecss.extensions.api.AuthorOperationException: Could not compute the index of the column to be inserted.
Please let me know if anything wrong i am doing for updating the colspec.
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: CALS Table functions

Post by mihaela »

Hello,

From what I understand you are trying to implement the Insert Column operation because the built-in operation fails with "Could not compute the index of the column to be inserted" error when there are processing instructions in the colspecs.

We analyzed the code to find the source of the error and here is what you can do: you can copy the code from the built-in operation (ro.sync.ecss.extensions.commons.table.operations.cals.InsertColumnOperation) and apply the next fix: move the incrementation of i from line 189 inside the preceding if.

So, the code is:
image.png
image.png (39.83 KiB) Viewed 944 times
and you must correct it like this:
image.png
image.png (53.21 KiB) Viewed 944 times
This code tries to determine the index of a colspec and the problem is that the index is incremented even when the processing instruction is encountered.

Please let us know if this fix works for you.
We will also include the fix in the next release of Web Author and we will update this thread when it will be available so that you can use the built-in operation instead of this temporary solution.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply