Friday, October 30, 2015

Adding CALS-table related functionality to your custom Oxygen framework

Share to Facebook Share to Twitter Email This Share on Google Plus Share on Tumblr

Oxygen comes with full support for CALS tables in DITA and Docbook documents, meaning that you can easily make selections, resize columns, and invoke special actions like insert or delete rows and columns, join, or split cells. You can also easily customize tables properties such as alignments, separators, and table borders. But what if you are editing documents from other vocabularies, containing tables with CALS structure? What you can do to obtain the same table editing features?

Let's suppose that you already created an Oxygen framework for your documents vocabulary (if you need further information about frameworks, see http://blog.oxygenxml.com/2014/08/the-oxygen-sdk-part-2-frameworks.html). What we want to obtain next is to extract all the CALS tables related support from Docbook framework and add it to your custom framework. Why Docbook and not DITA as reference? Because the DITA customization is based on the "class" attribute checking while the Docbook one is more general (element-name oriented).

  1. Table rendering
    1. copy [oXygen_install_dir]\frameworks\docbook\css\cals_table.css in your framework css directory
    2. in the Document Type edit dialog, Author tab, CSS sub-tab, add the ${framework}/css/cals_table.css entry to the list of the CSSs

    In this way the table will be rendered properly in Author mode and the following features will be available:

    • select cells (CTRL+click), rows (click before the row), columns (click on top of the row), tables (click in the left-up corner of the table)
    • resize table column
  2. Create table actions

    Here are the table-related actions implemented in Docbook that you can implement also in you framework:

    • Expand colspecs
    • Insert/Delete Rows
    • Insert/Delete Columns
    • Table Properties
    • Join cells
    • Split cell
    1. Copy [oXygen_installation_dir]\frameworks\docbook\docbook.jar in your framework directory (this jar contains all the table operations classes needed to create table actions). In Document type edit dialog go to Classpath tab and add the docbook.jar from your framework directory to the list of paths. In this way you have access to all table operations from your framework.
    2. For every table action you have to define a corresponding action in the Document type configuration dialog. Here are the details: https://www.oxygenxml.com/doc/versions/17.1/ug-editor/#topics/the-action-dialog.html. You can look at the corresponding Docbook action to see the properties (id, name, icons, the conditions that enables it, the specific operation for CALS tables).
      Once you created these actions you can add them to the UI.
  3. Add table actions to menu, toolbar and contextual menu
    1. To add an action to the menu go to Document Type configuration dialog, Author tab, Menu sub-tab, select the action from Available actions section and add it to the Current action section.
    2. To add an action to the contextual menu go to Document Type configuration dialog, Author tab, Contextual menu sub-tab, select the action from Available actions section and add it to the Current action section.
    3. To add an action to the toolbar go to Document Type configuration dialog, Author tab, Toolbar sub-tab, select the action from Available actions section and add it to the Current action section.
If all goes well, your custom framework which uses the standard CALS table naming mechanism will properly handle tables, both for display and for table-related operations.

No comments:

Post a Comment