[ 
https://issues.apache.org/jira/browse/ODFTOOLKIT-334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437713#comment-13437713
 ] 

Kejia Ye commented on ODFTOOLKIT-334:
-------------------------------------

Two new API are added to support load and apply table template.  Please review 
and give your comments.

1. Add API in Document to load load a table template from external table.
/**
         * Construct a  <code>TableTemplate<code> feature by extracting style 
template from an pre-defined table in a foreign document. 
         * The styles loaded by the template will be copied into the document 
as well and can be referenced by table directly.
         *
         * The imported table need to be at least a 5*5 table (e.g. A1E5).  
Each type of style in the template will be set according to the style reference 
in a specific table cell, as following:
         * <br>first column - A2
         * <br>last column - E2
         * <br>first row - A2
         * <br>last row - E2
         * <br>even rows - B3
         * <br>odd rows - B2
         * <br>even columns - C2
         * <br>odd columns - B2
         * <br>body - B2
         * <br>first-row-start-column -A1
         * <br>first-row-end-column -E1
         * <br>last-row-start-column -A5
         * <br>last-row-end-column -E5
         * 
         * @param templateFileInputStream
         *            - the InputStream of the ODF document.
         * @param tableName
         *            - the table name which will be used to load styles as 
template
         * @throws Exception
         *             - if content DOM could not be initialized
         */
        public TableTemplate LoadTableTemplateFromForeignTable(
                        InputStream templateFileInputStream, String tableName) 

2. Add  API in Table.java to apply styles specified in a table template.

/**
         * Apply the formatting specified in the template to corresponding 
table cells.
         * 
         * A table can only be formatted as one type of styles: even-odd-rows or
         * even-odd-columns. The rule is to check the style of odd rows and even
         * rows in the template, only if they have one different properties, 
table:
         * style-name or table:paragraph-style-name, the table template will be
         * treated as a even-odd-columns styled table.
         * 
         * If one style in the template is null, the style of corresponding 
cells
         * will be removed. An empty template can be used to remove all the 
styles
         * in a table.
         * 
         * @param template
         * @throws IllegalArgumentException
         *             if the given template is null
         * @throws Exception
         *             if content DOM could not be initialized
         */
        public void applyStyle(TableTemplate template)

3.  Add class of TableTemplate.java.
/**
 * TableTemplate represents the table template feature in ODF documents.
 * <p>
 * Besides the seven types of style (first row, first column, last row, last
 * column, even/odd rows,even/odd columns and body) defined by
 * <code>table:table-template</code> in ODF 1.2, TableTemplate provide extension
 * mechnism, which allows user to specify style value to additional cells. For
 * example, in ODF 1.2 the four coner cells can only inherit styles from the
 * colum or row they are existing, but through TableTemplate.ExtendedStyleType,
 * they can reference any style defined in the document.
 * <p>
 * TableTemplate provide method to get/set a set of references to table cell
 * styles that specify the formatting to be used on a table.
 * 
 */

 
                
> Add new API to support table autoformat
> ---------------------------------------
>
>                 Key: ODFTOOLKIT-334
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-334
>             Project: ODF Toolkit
>          Issue Type: New Feature
>          Components: simple api
>    Affects Versions: 0.7
>            Reporter: Kejia Ye
>             Fix For: 0.8
>
>         Attachments: patch_tabletemplate.patch, TableTemplate.odt, 
> TestTableTemplate.odt
>
>
> See previous discussion in the mailing list 
> http://markmail.org/thread/edmejexrfv3m6cdn
>  
> I'd like to propose a new Simple API which could provide a similar function 
> in OpenOffice as ' Table > AutoFormat'. This will allow users to define their 
> own table template once and apply them anywhere they need. Since the 
> <table:table template> doesn't have higher-level support yet, API has to 
> define and extract such template from existing table and serialize them into 
> separated elements at current stage.
> Proposed Solution:
> 1. User need to define their own table, as a table template, in a document by 
> ODF editor.
> 2. Add two Simple APIs:
>   * Need new API to import table style from appointed table.
>   * Need new API to apply table style definition to table.
> Since it's difficult to recognize all kinds of style combination, we could 
> use the definition of <table:table template> to define and copy table styles. 
>  It means API can recognize and copy 6 types of cell styles from source table 
> to target table.
>       1. first column
>       2. last column
>       3. first row
>       4. last row
>       5. even rows, odd rows
>      6. even columns, odd rows
> Considering performance and complexity, we'd better restrict the size of 
> imported table, basically a 5*5 table (A1:E5) would be enough. We can get 
> each type of style from an appointed cell.
>       1. first column ( A2)
>       2. last column (E2)
>       3. first row (B2)
>       4. last row (B5)
>       5. even rows (B3),  odd rows (B2)
>       6. even columns: (C2), odd rows (B2)
> For each type of style, API can copy two definitions <table: style-name> and 
> <table: paragraph-style-name>, which displayed as number format, font, 
> alignment, borders and background.
> In ODF specs, there's some restriction on table template definition. If more 
> than one style reference is applied to a cell, it has to follow the order. It 
> means if a table has even/odd row style, it cannot apply even/odd column 
> style at the same time. Besides that, the four corner cell can only inherit 
> the style from the column or the row they exists, and cannot been appointed 
> to other values. Actually, user may need more complicated template than that, 
> like some complicated template pre-defined in OO. Maybe we could consider 
> more extensibility when defining table template in API according to real 
> requirements. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to