incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Weir <>
Subject Re: [PROPOSAL]Add new Simple API to apply user customized styles to table.
Date Thu, 02 Aug 2012 20:58:52 GMT
On Thu, Aug 2, 2012 at 9:30 AM, Kejia Ye <> wrote:
> Hi All,
> I'd like to propose a new Simple API which could apply user customized
> styles to table. The similar function can be found in OpenOffice as ' Table
>> AutoFormat', which refers to 5 cell properties, number format, font,
> alignment, borders and background. Customers usually have their own
> customized table styles to process specified kind of data. So it would be
> nice to let them define the styles once and apply them everywhere they need.
> As for the input of the style, an easy way is to let customers create their
> own styles in a document and the API can import the document and find the
> specific table by its name, like Table.applyStyle(TemplateFile, TableName).
> This would be easy for customers, they don't need to know more about the
> style definition and can create their styles by any word processor, like
> OpenOffice. But this would leave complex details to the API implementation,
> since not all the word processors support the <table:table-template> by
> now, the styles applied on a table may not be easy to extract.

OK.  Hopefully you have looked at the markup that is generated when
you use table AutoFormat in OpenOffice.  If you do you will see that
it is not really the same thing as a style definition on ODF.
AutoFormat is more like a template, a collection of multiple table,
column and cell styles that look good together.  But the ODF that
OpenOffice generates is just separate style definitions.  There is no
high-level support for <table:table-template>.

Two other things that make this more complicated:

1) If the user wants to later edit the document in their editor, and
manually create a new table, it will be hard for them to make it look
like the same styles as the one created by the Toolkit.    Compare
this to creating normal named styles for text or paragraphs or lists.
These style names would show up in the styles lists in the OpenOffice
UI so the user can pick them.  But new AutoFormat templates are not
put in the OpenOffice UI.  Maybe this is OK for your use?

2) Need to be careful about interaction with the table size.

A) You probably can't apply the AutoFormat to an empty table, since
there are no cells to apply the styles to,

B) If you add rows or columns to a table after the AutoFormat is
applied, then you need logic to determine how the new table elements
"inherit" styles from neighboring rows and columns of the table.

Easiest case would be to apply AutoFormat after the table is at its
final size.  But it is hard to predict what order a user will do

C) If you "import" a table AutoFormat from another table, it is easy
if both tables are the exact same size.  But if they are different,
then you will need some logic to figure out what the pattern is.  For
example, is it a shaded row header and column header with alternating
row colors?  or something else.  If there are just a handful of common
patterns that we recognize then this is easy.

Or maybe the cleanest thing is to just borrow the tabe:table-template
definition, and use that in the API, but serialize it as separate
styles.  And then if OpenOffice supports table-template in the future,
we can change the serialization logic, but user code would remain the
same.  In other words, we could use table:table-template as a good
abstraction in the toolkit.

Does anyone else have ideas?


> Meanwhile, I saw there were some similar topics around customized default
> styles( on JIRA, but
> I'm not sure whether they're overlapped to some extent. And there've been
> no updates about that topic for some time, so if someone is still working
> on that issue please let me know and any comments are welcome.
> Regards,
> Kejia Ye

View raw message