Functions related to table

Having trouble installing Oxygen? Got a bug to report? Post it all here.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Functions related to table

Post by SmitaPatil »

Hi Team,
Can you please tell if there is any methods available in oxygen web author to get data from table eg. if we need data from last column of selected table.
which will help to do some more functionalities(span cells, unspan cells, selecting column content) related to table.
Can you please let me know if there is any?

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

Re: Functions related to table

Post by mihaela »

Hello,

We need more details from you in order to better understand your use case and to help you with solutions proposals.

If you try to implement table-related operations in your custom framework, like Insert Table, Dleete Column or Split, Join, you can use as an example the implementation that we alreay provide for the built-in frameworks like DITA, Docbook or HTML. There is also a blog post that can be helpful if you try to add CALS-table related functionality to your custom Oxygen framework.

So please let us know what type of documents you are editing, what type of tables do you use (CALS, HTML like) and what type of operations you are trying to implement?

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: Functions related to table

Post by SmitaPatil »

Hi Mihaela,

We are working on content which in form of XML and in oxygen web author it is displayed using HTML.
as shown in below screenshot.
image.png
image.png (65.07 KiB) Viewed 1226 times
We are trying to do span selected row or unspan cell where cursor is placed.
Please let me know if any more information is needed

Thanks,
Smita
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Functions related to table

Post by mihaela »

Hi,
Thank you for the details. So I understand that you want to include Join and Split actions to your custom framework.
For this you can folow the "Create table actions" section from the tutorial that I mentioned in my previous message.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: Functions related to table

Post by SmitaPatil »

Hi Mihaela,
I have tried adding docbook.jar file and tried to add that in classpath tab in oxygen xml editor-option-preferences-document type association but whenever I am adding classpath it is creating another extended framework file as shown in below screenshot.
image.png
image.png (5.44 KiB) Viewed 1185 times
Then I tried to add it directly in .framework file as shown in below screenshot.
image.png
image.png (9.7 KiB) Viewed 1185 times

but when I am trying to use the method from docbook.jar, I got following error :Error For security reasons, the execution of ro.sync.ecss.extensions.commons.table.operations.xhtml.JoinRowCellsOperation with user-provided parameters is blocked. If the operation is safe, consider annotating it with ro.sync.ecss.extensions.api.webapp.WebappRestSafe.
docbook.jar is present inside content-framework/judicialArtifact folder in the same hierarchy level where .framework file is present.
Can you please guide me through it to add that classpath in the present framework file.
Please let me know if you need more information.

Thanks,
Smita
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Functions related to table

Post by mihaela »

Hi,

In this case you can try to create your own join operation that extends the default JoinRowCellsOperation, just for adding the @WebappRestSafe annotation.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: Functions related to table

Post by SmitaPatil »

Hi Mihaela,
I tried to use below method to span selected cells
@WebappRestSafe
public class SpanCells extends AuthorOperationWithResult {

private static Logger logger = Logger.getLogger(SpanCells.class.getName());

@Override
public String doOperation(AuthorDocumentModel model, ArgumentsMap args) throws AuthorOperationException {

AuthorAccess authorAccess = model.getAuthorAccess();

AuthorDocumentController docCtrl = authorAccess.getDocumentController();

CALSDocumentTypeHelper calsDocumentTypeHelper=new CALSDocumentTypeHelper();
JoinRowCellsOperation joinRowCellsOperation=new JoinRowCellsOperation(calsDocumentTypeHelper);
joinRowCellsOperation.doOperation(authorAccess, args);
}
}
and I have following table content :
<tbl ID="tbl2" maxsize="default">
<table colsep="0" rowsep="0"><?ctbl ampex.cols="3"?>
<tgroup cols="3"><?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"?><?ctbl ampex.colwidth="100"?>
<colspec align="right" colname="col3" colnum="3"/><?ctbl ampex.vert.just="top"?>
<tbody>
<row>
<entry colname="col1" valign="top">
<para>
<paratext ID="p73">
<leader source="dtbl">
<leaderchar>z</leaderchar>
</leader>
</paratext>
</para>
</entry>
<entry colname="col2" valign="top">
<para>
<paratext ID="p74">
<leader source="dtbl">
<leaderchar>x</leaderchar>
</leader>
</paratext>
</para>
</entry>
<entry colname="col3" valign="top">
<para>
<paratext ID="p75"/>
</para>
</entry>
</row>
<row>
<entry colname="col1" valign="top">
<para>
<paratext ID="p76">
<leader source="dtbl">
<leaderchar>z</leaderchar>
</leader>
</paratext>
</para>
</entry>
<entry colname="col2" valign="top">
<para>
<paratext ID="p77">
<leader source="dtbl">
<leaderchar>x</leaderchar>
</leader>
</paratext>
</para>
</entry>
<entry colname="col3" valign="top">
<para>
<paratext ID="p78"/>
</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</tbl>

but I am getting null pointer error as follows:
java.lang.NullPointerException
java.lang.NullPointerException: null
at ro.sync.ecss.extensions.commons.table.operations.JoinRowCellsOperationBase.updateColSpanForMergedCell(Unknown Source)
at ro.sync.ecss.extensions.commons.table.operations.JoinRowCellsOperationBase.doOperationInternal(Unknown Source)
at ro.sync.ecss.extensions.commons.table.operations.AbstractTableOperation.doOperation(Unknown Source)

just want to check with you if I am missing something while using this method. Can you please have a look at it once.
Please let me know if you need any more information

Thanks,
Smita
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Functions related to table

Post by mihaela »

Hello,

I inserted the CALS table from your message in a Docbook document and the Join operation works as expected, the exception is not thrown.
I also created a custom operation, similar to the one you created (please note that you can just create an operation that extends JoinRowCellsOperation and add the @WebappRestSafe annotation on it) and the join worked as expected (I tried different selection combinations).

What you can do further if you want to investigate this issue is to get the code from the default join operation, and use it directly in your operation so that you can log the problems (exceptions) that occur when you invoke the operation.
The code of the table operations is available to be downloaded from the "Oxygen XML SDK - Download" page, "Default Framework Operations Source Code" section :
https://www.oxygenxml.com/oxygen_sdk/download.html


Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: Functions related to table

Post by SmitaPatil »

Hi Mihaela,

I have checked by putting logger in code and actually
I am getting null value from getTableColSpanIndices(destCellElement) method
and in description of this method its written as Can be null if the element does not correspond to a cell in a table.
but cells are correspond to the selected table.
and that's why I am getting null pointer exception.

int[] destCellColSpanIndices = authorAccess.getTableAccess().getTableColSpanIndices(destCellElement);

logger.debug("sourceCells size-1 "+(sourceCells.size() - 1));
AuthorElement lastElem = (AuthorElement) sourceCells.get(sourceCells.size() - 1);
logger.debug("lastElem :"+lastElem);
int[] endCellColSpanIndices = tableAccess.getTableColSpanIndices(lastElem);

sourceCells :[<entry colname="col2" , valign="top" ,> (1156, 1166)]
destCellElement :<entry colname="col1" , valign="top" ,> (1145, 1155)
sourceCells size-1 : 0
lastElem :<entry colname="col2" , valign="top" ,> (1156, 1166)
destCellColSpanIndices : null

I did selection as below:
image.png
image.png (34.2 KiB) Viewed 1117 times
As you said for you it worked for you, I am not sure why this issue is coming for me. is there any selection problem or anything else is missing ?

Thanks,
Smita
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Functions related to table

Post by Bogdan Dumitru »

Hello Smita,

The AuthorTableAccess.getTableColSpanIndices(AuthorElement) API method indeed says that returns null if the given element does not correspond to a cell and the important detail here is that it checks if the given element is a table cell by inspecting its styles, more specifically the "display" CSS property.

So, no matter that you use elements whose names coincide with the ones from a CALS table specification if there is no CSS in your framework that specifies the "display: table", "display: table-row", "display: table-cell", etc, the AuthorTableAccess won't see them as table elements.

Considering the above, please check that you set the proper "display" CSS property on the table elements.
Bogdan Dumitru
http://www.oxygenxml.com
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

Re: Functions related to table

Post by SmitaPatil »

Hi Bogdan,

is it possible to have call with you. I have some doubt regarding table insert and some other functionalities?

Thanks,
Smita
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Functions related to table

Post by Bogdan Dumitru »

Hello Smita,

Yes, we can schedule a meeting.
Please contact us at support@oxygenxml.com in order to schedule the meeting at a time that suits both of us.
Bogdan Dumitru
http://www.oxygenxml.com
Post Reply