[seam-commits] Seam SVN: r8930 - in trunk:
examples/excel/src/org/jboss/seam/excel and 11 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Sep 10 16:41:18 EDT 2008
Author: nickarls
Date: 2008-09-10 16:41:17 -0400 (Wed, 10 Sep 2008)
New Revision: 8930
Added:
trunk/src/excel/org/jboss/seam/excel/css/
trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java
trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java
trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java
trunk/src/excel/org/jboss/seam/excel/css/Parser.java
trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java
trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java
trunk/src/excel/org/jboss/seam/excel/css/StyleMap.java
trunk/src/excel/org/jboss/seam/excel/jxl/CellInfo.java
trunk/src/excel/org/jboss/seam/excel/jxl/CellInfoCache.java
trunk/src/excel/org/jboss/seam/excel/jxl/JXLFactory.java
trunk/src/excel/org/jboss/seam/excel/jxl/JXLHelper.java
trunk/src/excel/org/jboss/seam/excel/ui/UICellBase.java
trunk/src/excel/org/jboss/seam/excel/ui/UILink.java
trunk/src/excel/org/jboss/seam/excel/ui/command/
trunk/src/excel/org/jboss/seam/excel/ui/command/Command.java
trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupColumns.java
trunk/src/excel/org/jboss/seam/excel/ui/command/UIGroupRows.java
trunk/src/excel/org/jboss/seam/excel/ui/command/UIMergeCells.java
trunk/src/excel/org/jboss/seam/excel/ui/command/UIRowPageBreak.java
trunk/src/excel/org/jboss/seam/excel/ui/validation/
trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidation.java
trunk/src/excel/org/jboss/seam/excel/ui/validation/UIListValidationItem.java
trunk/src/excel/org/jboss/seam/excel/ui/validation/UINumericValidation.java
trunk/src/excel/org/jboss/seam/excel/ui/validation/UIRangeValidation.java
trunk/src/excel/org/jboss/seam/excel/ui/validation/Validation.java
Removed:
trunk/src/excel/org/jboss/seam/excel/Command.java
trunk/src/excel/org/jboss/seam/excel/Template.java
trunk/src/excel/org/jboss/seam/excel/Validation.java
trunk/src/excel/org/jboss/seam/excel/exporter/StyleParser.java
trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelFactory.java
trunk/src/excel/org/jboss/seam/excel/jxl/JXLTemplates.java
trunk/src/excel/org/jboss/seam/excel/ui/UIBackground.java
trunk/src/excel/org/jboss/seam/excel/ui/UIBorder.java
trunk/src/excel/org/jboss/seam/excel/ui/UICellFormat.java
trunk/src/excel/org/jboss/seam/excel/ui/UICellTemplate.java
trunk/src/excel/org/jboss/seam/excel/ui/UIExcelExport.java
trunk/src/excel/org/jboss/seam/excel/ui/UIFont.java
trunk/src/excel/org/jboss/seam/excel/ui/UIGroupColumns.java
trunk/src/excel/org/jboss/seam/excel/ui/UIGroupRows.java
trunk/src/excel/org/jboss/seam/excel/ui/UIListValidation.java
trunk/src/excel/org/jboss/seam/excel/ui/UIListValidationItem.java
trunk/src/excel/org/jboss/seam/excel/ui/UIMergeCells.java
trunk/src/excel/org/jboss/seam/excel/ui/UINumericValidation.java
trunk/src/excel/org/jboss/seam/excel/ui/UIRangeValidation.java
trunk/src/excel/org/jboss/seam/excel/ui/UIRowPageBreak.java
trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetSettings.java
trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheetTemplate.java
trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelCellFactoryTest.java
trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/JXLExcelWorkbookTest.java
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Excel.xml
trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java
trunk/examples/excel/view/home.xhtml
trunk/src/excel/META-INF/faces-config.xml
trunk/src/excel/META-INF/seam-excel.taglib.xml
trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java
trunk/src/excel/org/jboss/seam/excel/csv/CsvExcelWorkbook.java
trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
trunk/src/excel/org/jboss/seam/excel/jxl/JXLExcelWorkbook.java
trunk/src/excel/org/jboss/seam/excel/ui/ExcelComponent.java
trunk/src/excel/org/jboss/seam/excel/ui/UICell.java
trunk/src/excel/org/jboss/seam/excel/ui/UIColumn.java
trunk/src/excel/org/jboss/seam/excel/ui/UIHyperlink.java
trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
trunk/src/excel/org/jboss/seam/excel/ui/UIWorksheet.java
trunk/src/test/excel/unit/org/jboss/seam/test/excel/unit/testng.xml
Log:
JBSEAM-3231. Major rewrite of the templating system for Excel
* Dropped worksheet templates (merged into worksheet)
* Dropped Cell templates, UIFont, UIBorder, UIBackground in favor of CSS
* Added CSS with shorthand to xhtml and datatable exporter
* Added e:link for xhtml stylesheet reference
* UI tag subpackages for commands and validations
* Updated docs
* Dropped concept UIExport tag (not used)
* Dropped unit tests. Will be rewritten.
* Minor code cleanups/refactoring
NOTE! Examples still broken. Daaaanieeeelll....
Modified: trunk/doc/Seam_Reference_Guide/en-US/Excel.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Excel.xml 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/doc/Seam_Reference_Guide/en-US/Excel.xml 2008-09-10 20:41:17 UTC (rev 8930)
@@ -126,8 +126,7 @@
<section id="excel.workbook">
<title>Workbooks</title>
<para>
- Workbooks are the top-level parents of worksheets, cell templates and
- worksheet templates.
+ Workbooks are the top-level parents of worksheets and stylesheet links.
</para>
<informaltable>
<tgroup cols="2">
@@ -340,22 +339,14 @@
<itemizedlist>
<listitem>
<para>
- <literal><e:cellTemplate/></literal>
- —Zero or more cell templates (see
- <xref linkend="excel.templates.cell" />
+ <literal><e:link/></literal>
+ —Zero or more stylesheet links (see
+ <xref linkend="excel.fontsandlayout.link" />
).
</para>
</listitem>
<listitem>
<para>
- <literal><e:worksheetTemplate/></literal>
- —Zero or more worksheet templates (see
- <xref linkend="excel.templates.worksheetsettings" />
- ).
- </para>
- </listitem>
- <listitem>
- <para>
<literal><e:worksheet/></literal>
—Zero or more worksheets (see
<xref linkend="excel.worksheet" />
@@ -465,16 +456,6 @@
</listitem>
<listitem>
<para>
- <literal>templates</literal>
- —The comma-separated list of
- <literal>worksheetTemplates</literal>
- to cascade on. The value is a string (see
- <xref linkend="excel.templates.cell" />
- ).
- </para>
- </listitem>
- <listitem>
- <para>
<literal>automaticFormulaCalculation</literal>
—Should formulas be automatically
calculated? The value is a boolean.
@@ -825,7 +806,8 @@
<para>
Columns are the children of worksheets and the parents of cells,
images, formulas and hyperlinks. They are the structure that control
- the iteration of the worksheet data.
+ the iteration of the worksheet data. See <xref linkend="excel.fontsandlayout.columnsettings"/>
+ for formatting.
</para>
<informaltable>
<tgroup cols="2">
@@ -845,25 +827,9 @@
<itemizedlist>
<listitem>
<para>
- <literal>autoSize</literal>
- —Should the column be autosized? The value
- is a boolean.
+ <literal>none</literal>
</para>
</listitem>
- <listitem>
- <para>
- <literal>hidden</literal>
- —Should the column be hidden? The value is a
- boolean.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>width</literal>
- —The width of the column. The valus ia
- number (characters multiplied by 256)
- </para>
- </listitem>
</itemizedlist>
<para>
<emphasis>Child elemenents</emphasis>
@@ -964,8 +930,8 @@
(for direct placement using the <literal>column</literal> and
<literal>row</literal> attributes) and are responsible for outputting
the value (usually though en EL-expression involving the
- <literal>var</literal>-attribute of the datatable. They can contain
- fonts and other formattings and can also use pre-defined templates.
+ <literal>var</literal>-attribute of the datatable. See
+ <xref linkend="excel.fontsandlayout.cells"/>
</para>
<informaltable>
<tgroup cols="2">
@@ -1009,16 +975,6 @@
</listitem>
<listitem>
<para>
- <literal>templates</literal>
- —A comma-separated list of cascading,
- predefined templates to apply before the own
- formattings (see
- <xref linkend="excel.templates.cell" />
- ).
- </para>
- </listitem>
- <listitem>
- <para>
<literal>forceType</literal>
—The forced type of the cell data. The value
is a string that can be one of "general",
@@ -1029,14 +985,6 @@
</listitem>
<listitem>
<para>
- <literal>alignment</literal>
- —The alignment of the cell data. The value
- is a string that can be one of "centre", "fill",
- "general", "justify", "left" or "right".
- </para>
- </listitem>
- <listitem>
- <para>
<literal>comment</literal>
—A comment to add to the cell. The value is
a string.
@@ -1056,62 +1004,6 @@
number (in pixels).
</para>
</listitem>
- <listitem>
- <para>
- <literal>indentation</literal>
- —The indentation of the cell. The value is a
- number (in pixels)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>locked</literal>
- —Should the cell be locked? For this to have
- any effect, the sheet containing cells with this
- format must also be locked. The value is a
- boolean.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>mask</literal>
- —A format mask (see
- <xref linkend="excel.cells.formatmasks" />
- ).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>orientation</literal>
- —The orientation of the cell data. The value
- is a string that can be one of "horizontal",
- "minus_45", "minus_90", "plus_45", "plus_90",
- "stacked" or "vertical".
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>shrinkToFit</literal>
- —Should the cell data be shrunk to fit? The
- value is a boolean.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>verticalAlignment</literal>
- —The vertical aligment of the cell data. The
- value is a string that can be one of "bottom",
- "centre", "justify" or "top").
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>wrap</literal>
- —Should the data be wrapped so that it fits
- within the cell boundaries? The value is a
- boolean.
- </para>
- </listitem>
</itemizedlist>
<para>
@@ -1181,323 +1073,6 @@
]]>
</programlisting>
<para>defines a column with a header and an iterated output</para>
- <section id="excel.cells.fonts">
- <title>Fonts</title>
- <para>
- Fonts are nested inside cells, formulas, hyperlinks or cell
- templates. They determine the typeface of the cell data
- </para>
- <informaltable>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="1*" />
- <colspec colnum="2" colwidth="3*" />
- <tbody>
- <row>
- <entry valign="top">
- <para>
- <literal><e:font></literal>
- </para>
- </entry>
- <entry valign="top">
- <para>
- <emphasis>Attributes</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>fontName</literal>
- —The font name. The value is a string.
- Should be used with care, since the used font
- must be recognized by the
- <trademark class="registered">
- Microsoft
- </trademark>
- <trademark class="registered">Excel</trademark>
- spreadsheet application
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>color</literal>
- —The color of the background. The value
- is a string that can be one of "blue", "red"
- etc (see
- <ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
- </ulink>
- ).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>pointSize</literal>
- —The point size of the font. The value is
- a number.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>bold</literal>
- —Should the font be bold? The value is a
- boolean.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>italic</literal>
- —Should the font be italic? The value is
- a boolean.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>struckOut</literal>
- —Should the font be struck out? The value
- is a boolean.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>scriptStyle</literal>
- —The script style of the font. The value
- is a string that can be one of "normal_script",
- "subscript" or "superscript".
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>underlineStyle</literal>
- —The underline style of the font. The
- value is a string that can be one of "double",
- "double_accounting", "no_underline", "single"
- or "single_accounting".
- </para>
- </listitem>
- </itemizedlist>
- <para>
- <emphasis>Child elemenents</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>none</literal>
- </para>
- </listitem>
- </itemizedlist>
- <para>
- <emphasis>Facets</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>none</literal>
- </para>
- </listitem>
- </itemizedlist>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:worksheet>
- <e:column value="#{personList}" var="person">
- <e:cell value="#{person.age">
- <e:font fontName="Times New Roman" color="red" bold="true"/>
- </e:cell>
- </e:column>
- </e:worksheet>
- </e:workbook>
- ]]>
- </programlisting>
- <para>defines a cell with a red, bold, Times New Roman font.</para>
- </section>
- <section id="excel.cells.backgrounds">
- <title>Backgrounds</title>
- <para>
- Backgrounds are nested inside cells, formulas, hyperlinks or cell
- templates. They determine the color and pattern of the cell.
- </para>
- <informaltable>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="1*" />
- <colspec colnum="2" colwidth="3*" />
- <tbody>
- <row>
- <entry valign="top">
- <para>
- <literal><e:background></literal>
- </para>
- </entry>
- <entry valign="top">
- <para>
- <emphasis>Attributes</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>pattern</literal>
- —The pattern of the background. The value
- is a string that can be one of "solid",
- "gray_25" etc (see
- <ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Pattern.html">
- jxl.format.Pattern
- </ulink>
- ). The default is "solid".
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>color</literal>
- —The color of the background. The value
- is a string that can be one of "blue", "red"
- etc
- </para>
- </listitem>
- </itemizedlist>
- <para>
- <emphasis>Child elemenents</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>none</literal>
- </para>
- </listitem>
- </itemizedlist>
- <para>
- <emphasis>Facets</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>none</literal>
- </para>
- </listitem>
- </itemizedlist>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:worksheet>
- <e:column value="#{personList}" var="person">
- <e:cell value="#{person.age">
- <e:background color="green" pattern="gray_25"/>
- </e:cell>
- </e:column>
- </e:worksheet>
- </e:workbook>
- ]]>
- </programlisting>
- <para>defined a green cell background with a 25% gray mask.</para>
- </section>
- <section id="excel.cells.borders">
- <title>Borders</title>
- <para>
- Borders are nested inside cells, formulas, hyperlinks and cell
- templates. They determine the color and line style of the cell
- borders.
- </para>
- <informaltable>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="1*" />
- <colspec colnum="2" colwidth="3*" />
- <tbody>
- <row>
- <entry valign="top">
- <para>
- <literal><e:border></literal>
- </para>
- </entry>
- <entry valign="top">
- <para>
- <emphasis>Attributes</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>border</literal>
- —The border to apply the settings to. The
- value is a string that can be one of "all",
- "bottom", "left", "none", "right" or "top". The
- default is "all".
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>lineStyle</literal>
- —The border line style. The value is a
- string that can be one of "medium", "thin" etc
- (see
- <ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/BorderLineStyler.html">
- jxl.format.BorderLineStyle
- </ulink>
- ).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>color</literal>
- —The color of the border. The value is a
- string that can be one of "blue", "red" etc
- (see
- <ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
- </ulink>
- ).
- </para>
- </listitem>
- </itemizedlist>
- <para>
- <emphasis>Child elemenents</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>none</literal>
- </para>
- </listitem>
- </itemizedlist>
- <para>
- <emphasis>Facets</emphasis>
- </para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>none</literal>
- </para>
- </listitem>
- </itemizedlist>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:worksheet>
- <e:column value="#{personList}" var="person">
- <e:cell value="#{person.age">
- <e:border border="left" color="green" lineStyle="thin"/>
- </e:cell>
- </e:column>
- </e:worksheet>
- </e:workbook>
- ]]>
- </programlisting>
- <para>defined a thin green border on the left edge of the cell.</para>
- </section>
<section id="excel.cells.validation">
<title>Validation</title>
<para>
@@ -2816,113 +2391,6 @@
<para>merges the cells in the range A1:J10</para>
</section>
</section>
- <section id="excel.templates">
- <title>Templates</title>
- <para>
- Templates are a way of grouping common formatting under a name to be
- used later. They come in two flavors, cell level and worksheet settings
- level and they can be cascaded so that the end result is a union of the
- applied templates (overriden where applicable)
- </para>
- <section id="excel.templates.cell">
- <title>Cell templates</title>
- <para>
- Cell templates are defined on workbook level using the following
- notation
- </para>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:cellTemplate name="foo">
- <font color="red"/>
- </e:cellTemplate>
- </e:workbook>
- ]]>
- </programlisting>
- <para>
- and are later used by referencing them in the templates attribute of
- a cell
- </para>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:worksheet>
- <e:cell templates="foo" column="0" row="0" value="ping"/>
- </e:worksheet>
- </e:workbook>
- ]]>
- </programlisting>
- <para>
- Cell templates have the same attributes as cells (see
- <xref linkend="excel.cells" />
- ). Note that the cellTemplate can also contain tags for font, border
- and background definitions and they are merged with the definitions
- of the cell using the templates so a more complex definition could
- look like
- </para>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:cellTemplate name="foo" alignment="right">
- <e:font name="Times New Roman"/>
- <e:background color="blue"/>
- </e:cellTemplate>
-
- <e:cellTemplate name="bar" wrap="true">
- <e:font color="red"/>
- <e:border color="yellow" lineStyle="thick"/>
- </e:cellTemplate>
- </e:workbook>
- ]]>
- </programlisting>
- <para>so that a cell that later on applies the templates</para>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:worksheet>
- <e:cell templates="foo,bar" column="0" row="0" value="ping">
- <e:border border="left" color="green" lineStyle="thin"/>
- </e:cell>
- </e:worksheet>
- </e:workbook>
- ]]>
- </programlisting>
- <para>
- end up with a red Times New Roman font in a right-aligned, wrapping
- cell that has a solid blue background and thick yellow borders, with
- exception of the left border, which is thin and green.
- </para>
- </section>
- <section id="excel.templates.worksheetsettings">
- <title>Worksheet setting templates</title>
- <para>
- Worksheet settings are defined and used in the same way as cell
- templates. On workbook level, you can place a
- </para>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:worksheetTemplate name="foo" horizontalFreeze="5"/>
- </e:workbook>
- ]]>
- </programlisting>
- <para>and when you later use it like</para>
- <programlisting role="XML">
- <![CDATA[
- <e:workbook>
- <e:worksheet templates="foo" verticalFreeze="5"/>
- </e:workbook>
- ]]>
- </programlisting>
- <para>
- you end up with a worksheet that is frozen at column 5 and row 5.
- Note that a worksheetTemplate is essentially a named worksheet (see
- <xref linkend="excel.worksheet" />
- ).
- </para>
-
- </section>
- </section>
<section id="excel.datatableexporter">
<title>Datatable exporter</title>
<para>
@@ -2962,32 +2430,93 @@
for a dedicated export tag that can be placed inside the datatable tag
so you won't have to refer to the datatable by ID.
</para>
- <section id="excel.datatableexporter.css">
- <title>CSS</title>
+ <para>
+ See <xref linkend="excel.fontsandlayout"/> for formatting.
+ </para>
+ </section>
+ <section id="excel.fontsandlayout">
+ <title>Fonts and layout</title>
+ <para>
+ Controlling how the output look is done with a combination of CSSish
+ style attributes and tag attributes. The most common ones (fonts, borders,
+ backgrounds etc) are CSS and some more general settings are in tag attributes.
+ </para>
+ <para>
+ The CSS attributes cascade down from parent to children and within one tag
+ cascades over the CSS classes referenced in the <literal>styleClass</literal>
+ attributes and finally over the CSS attributes defined in the
+ <literal>style</literal>attribute. You can place them pretty much anywhere but
+ e.g. placing a column width setting in a cell nested within that column makes
+ little sense.
+ </para>
+ <section id="excel.fontsandlayout.link">
+ <title>Stylesheet links</title>
<para>
- In order to provide formatting for the spreadsheet, you can utilize
- a number of xls-prefixed CSS:ish attributes that are placed in the
- style-attribute of the datatable to be exported:
+ External stylesheets are references with the e:link tag. They are placed as
+ children of the workbook.
</para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="3*" />
+ <tbody>
+ <row>
+ <entry valign="top">
+ <para>
+ <literal><e:link></literal>
+ </para>
+ </entry>
+ <entry valign="top">
+ <para>
+ <emphasis>Attributes</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>URL</literal>
+ —The URL to the stylesheet
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis>Child elemenents</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>none</literal>
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ <emphasis>Facets</emphasis>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>none</literal>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
<programlisting role="XML">
<![CDATA[
- <h:form id="theForm">
- <h:dataTable
- id="theDataTable"
- value="#{personList.personList}"
- var="person"
- style="xlsFontName : Times New Roman; xlsBackgroundColor : red">
- ...
- </h:dataTable>
- </h:form>
+ <e:workbook>
+ <e:link URL="/css/excel.css"/>
+ </e:workbook>
]]>
</programlisting>
+ <para>References a stylesheet that can be found at /css/excel.css</para>
+ </section>
+
+ <section id="excel.fontsandlayout.fonts">
+ <title>Fonts</title>
<para>
- which sets Times New Roman as the font and red as the cell
- background. Just as in CSS, separate name and value with a
- <literal>:</literal> and multiple attributes with a
- <literal>;</literal>. Below is a list of the supported
- style-attributes:
+ This group of XLS-CSS attributes define a font and its attributes
</para>
<informaltable>
<tgroup cols="2">
@@ -2996,23 +2525,26 @@
<tbody>
<row>
<entry valign="top">
- <para>xlsFontName</para>
+ <para>xls-font-family</para>
</entry>
<entry valign="top">
- <para>The name of the font</para>
+ <para>
+ The name of the font. Make sure that it's one that is
+ supported by your system.
+ </para>
</entry>
</row>
<row>
<entry valign="top">
- <para>xlsFontSize</para>
+ <para>xls-font-size</para>
</entry>
<entry valign="top">
- <para>The font size</para>
+ <para>The font size. Use a plain number</para>
</entry>
</row>
<row>
<entry valign="top">
- <para>xlsFontColor</para>
+ <para>xls-font-color</para>
</entry>
<entry valign="top">
<para>
@@ -3027,7 +2559,7 @@
</row>
<row>
<entry valign="top">
- <para>xlsFontBold</para>
+ <para>xls-font-bold</para>
</entry>
<entry valign="top">
<para>
@@ -3038,7 +2570,7 @@
</row>
<row>
<entry valign="top">
- <para>xlsFontItalic</para>
+ <para>xls-font-italic</para>
</entry>
<entry valign="top">
<para>
@@ -3049,7 +2581,7 @@
</row>
<row>
<entry valign="top">
- <para>xlsFontScriptStyle</para>
+ <para>xls-font-script-style</para>
</entry>
<entry valign="top">
<para>
@@ -3064,10 +2596,25 @@
</row>
<row>
<entry valign="top">
- <para>xlsFontStruckOut</para>
+ <para>xls-font-underline-style</para>
</entry>
<entry valign="top">
<para>
+ The underline style of the font (see
+ <ulink
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/UnderlineStyle.html">
+ jxl.format.UnderlineStyle
+ </ulink>
+ ).
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-font-struck-out</para>
+ </entry>
+ <entry valign="top">
+ <para>
Should the font be struck out? Valid values are
"true" and "false"
</para>
@@ -3075,26 +2622,42 @@
</row>
<row>
<entry valign="top">
- <para>xlsFontUnderlineStyle</para>
+ <para>xls-font</para>
</entry>
<entry valign="top">
<para>
- The underline style of the font (see
- <ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/UnderlineStyle.html">
- jxl.format.UnderlineStyle
- </ulink>
- ).
+ A shorthand notation for setting all the values. Place
+ the font name last and use tick marks for fonts with
+ spaces in them, e.g. 'Times New Roman'. Use "italic", "bold"
+ and "struckout".
</para>
+ <para>
+ Example style="xls-font: red bold italic 22 Verdana"
+ </para>
</entry>
</row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section id="excel.fontsandlayout.borders">
+ <title>Borders</title>
+ <para>
+ This group of XLS-CSS attributes define the borders of the cell
+ </para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="3*" />
+ <tbody>
<row>
<entry valign="top">
- <para>xlsBackgroundColor</para>
+ <para>xls-border-left-color</para>
</entry>
<entry valign="top">
<para>
- The background color of the cell (see
+ The border color of the left edge of the cell
+ (see
<ulink
url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
jxl.format.Colour
@@ -3105,14 +2668,14 @@
</row>
<row>
<entry valign="top">
- <para>xlsBackgroundPattern</para>
+ <para>xls-border-left-line-style</para>
</entry>
<entry valign="top">
<para>
- The background pattern of the cell (see
+ The border line style of the left edge of the cell (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Pattern.html">
- jxl.format.Pattern
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+ jxl.format.LineStyle
</ulink>
).
</para>
@@ -3120,14 +2683,26 @@
</row>
<row>
<entry valign="top">
- <para>xlsAlignment</para>
+ <para>xls-border-left</para>
</entry>
<entry valign="top">
<para>
- The alignment of the cell value (see
+ A shorthand for setting color and line style of the left edge
+ of the cell, e.g style="xls-border-left: red thick"
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-border-top-color</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ The border color of the top edge of the cell
+ (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Alignment.html">
- jxl.format.Alignment
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
+ jxl.format.Colour
</ulink>
).
</para>
@@ -3135,36 +2710,38 @@
</row>
<row>
<entry valign="top">
- <para>xlsColumnWidths</para>
+ <para>xls-border-top-line-style</para>
</entry>
<entry valign="top">
<para>
- The column widths. Note that the unit is internal to
- &excel;, be prepared to use largeish numbers.
- Separate columns with a <literal>,</literal>
- and use <literal>*</literal> for not setting a value.
+ The border line style of the top edge of the cell (see
+ <ulink
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+ jxl.format.LineStyle
+ </ulink>
+ ).
</para>
- <programlisting role="XML">
- <![CDATA[
- <h:dataTable style="xlsColumnWidths : *,800">
- ...
- </h:dataTable>
- ]]>
- </programlisting>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-border-top</para>
+ </entry>
+ <entry valign="top">
<para>
- leaves the width on column 1 as default, sets the
- width of column 2 to 800 and leaves the rest of the
- columns (if any) as default.
+ A shorthand for setting color and line style of the top edge
+ of the cell, e.g style="xls-border-left: red thick"
</para>
</entry>
</row>
<row>
<entry valign="top">
- <para>xlsBorderColor</para>
+ <para>xls-border-right-color</para>
</entry>
<entry valign="top">
<para>
- The the border color of the entire cell (see
+ The border color of the right edge of the cell
+ (see
<ulink
url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
jxl.format.Colour
@@ -3175,15 +2752,14 @@
</row>
<row>
<entry valign="top">
- <para>xlsBorderColorLeft</para>
+ <para>xls-border-right-line-style</para>
</entry>
<entry valign="top">
<para>
- The the border color of the left edge of the cell
- (see
+ The border line style of the right edge of the cell (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+ jxl.format.LineStyle
</ulink>
).
</para>
@@ -3191,26 +2767,22 @@
</row>
<row>
<entry valign="top">
- <para>xlsBorderColorTop</para>
+ <para>xls-border-right</para>
</entry>
<entry valign="top">
<para>
- The the border color of the top edge of the cell (see
- <ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
- </ulink>
- ).
+ A shorthand for setting color and line style of the right edge
+ of the cell, e.g style="xls-border-right: red thick"
</para>
</entry>
</row>
<row>
<entry valign="top">
- <para>xlsBorderColorRight</para>
+ <para>xls-border-bottom-color</para>
</entry>
<entry valign="top">
<para>
- The the border color of the right edge of the cell
+ The border color of the bottom edge of the cell
(see
<ulink
url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
@@ -3222,15 +2794,14 @@
</row>
<row>
<entry valign="top">
- <para>xlsBorderColorBottom</para>
+ <para>xls-border-bottom-line-style</para>
</entry>
<entry valign="top">
<para>
- The the border color of the bottom edge of the cell
- (see
+ The border line style of the bottom edge of the cell (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+ jxl.format.LineStyle
</ulink>
).
</para>
@@ -3238,14 +2809,50 @@
</row>
<row>
<entry valign="top">
- <para>xlsBorderLineStyle</para>
+ <para>xls-border-bottom</para>
</entry>
<entry valign="top">
<para>
- The the border line style of the entire cell (see
+ A shorthand for setting color and line style of the bottom edge
+ of the cell, e.g style="xls-border-bottom: red thick"
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-border</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ A shorthand for setting color and line style all edges
+ of the cell, e.g style="xls-border: red thick"
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section id="excel.fontsandlayout.background">
+ <title>Background</title>
+ <para>
+ This group of XLS-CSS attributes define the background of the cell
+ </para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="3*" />
+ <tbody>
+ <row>
+ <entry valign="top">
+ <para>xls-background-color</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ The color of the background (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/LineStyle.html">
+ jxl.format.LineStyle
</ulink>
).
</para>
@@ -3253,15 +2860,14 @@
</row>
<row>
<entry valign="top">
- <para>xlsBorderLineStyleLeft</para>
+ <para>xls-background-pattern</para>
</entry>
<entry valign="top">
<para>
- The the border line style of the left edge of the
- cell (see
+ The pattern of the background (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Pattern.html">
+ jxl.format.Pattern
</ulink>
).
</para>
@@ -3269,15 +2875,99 @@
</row>
<row>
<entry valign="top">
- <para>xlsBorderLineStyleTop</para>
+ <para>xls-background</para>
</entry>
<entry valign="top">
<para>
- The the border line style of the top edge of the cell
- (see
+ A shorthand for setting the background color and pattern. See above for rules.
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section id="excel.fontsandlayout.columnsettings">
+ <title>Column settings</title>
+ <para>
+ This group of XLS-CSS attributes define the column widths etc.
+ </para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="3*" />
+ <tbody>
+ <row>
+ <entry valign="top">
+ <para>xls-column-width</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ The width of the column. Use largeish values (~5000) to start with.
+ Used by the e:column in xhtml mode.
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-column-widths</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ The width of the column. Use largeish values (~5000) to start with.
+ Used by the excel exporter, placed in the datatable style attribute.
+ Use numerical values or * to bypass a column.
+ </para>
+ <para>
+ Example style="xls-column-widths: 5000, 5000, *, 10000"
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-column-autosize</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ Should an attempt be made to autosize the column? Valid values
+ are "true" and "false".
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-column-hidden</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ Should the column be hidden? Valid values are "true" and "false".
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </section>
+ <section id="excel.fontsandlayout.cellsettings">
+ <title>Cell settings</title>
+ <para>
+ This group of XLS-CSS attributes define the cell properties
+ </para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colnum="1" colwidth="1*" />
+ <colspec colnum="2" colwidth="3*" />
+ <tbody>
+ <row>
+ <entry valign="top">
+ <para>xls-alignment</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ The alignment of the cell value (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Alignment.html">
+ jxl.format.Alignment
</ulink>
).
</para>
@@ -3285,73 +2975,136 @@
</row>
<row>
<entry valign="top">
- <para>xlsBorderLineStyleRight</para>
+ <para>xls-format-mask</para>
</entry>
<entry valign="top">
<para>
- The the border line style of the right edge of the
- cell (see
+ The format mask of the cell, see <xref linkend="excel.cells.formatmasks" />
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-indentation</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ The indentation of the cell value. The value is numeric.
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-locked</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ Should the cell be locked. Use with workbook level locked.
+ Valid values are "true" and "false".
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-orientation</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ The orientation of the cell value (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Orientation.html">
+ jxl.format.Orientation
</ulink>
- ). styles
+ ).
</para>
</entry>
</row>
<row>
<entry valign="top">
- <para>xlsBorderLineStyleBottom</para>
+ <para>xls-vertical-alignment</para>
</entry>
<entry valign="top">
<para>
- The the border line style of the bottom edge of the
- cell (see
+ The vertical alignment of the cell value (see
<ulink
- url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/Colour.html">
- jxl.format.Colour
+ url="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/format/VerticalAlignment.html">
+ jxl.format.VerticalAlignment
</ulink>
- ). styles
+ ).
</para>
</entry>
</row>
+ <row>
+ <entry valign="top">
+ <para>xls-shrink-to-fit</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ Should the cell values shrink to fit?
+ Valid values are "true" and "false".
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top">
+ <para>xls-wrap</para>
+ </entry>
+ <entry valign="top">
+ <para>
+ Should the cell wrap with newlines?
+ Valid values are "true" and "false".
+ </para>
+ </entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
</section>
- <section id="excel.datatableexporter.templates">
- <title>Templates</title>
+ <section id="excel.fontsandlayout.datatableexporter">
+ <title>The datatable exporter</title>
<para>
- In order to provide different formatting for different kind of cells
- you can use templates. Templates are defined in the datatable style
- attribute as seen in the examples in the previous section by using a
- dot-notation on the xls-attribute names. Attributes without template
- names are considered global and are applied to all cells.
+ The datatable exporter uses the same xls-css attributes as the xhtml
+ document with the exception that column widths are defined with the
+ <literal>xls-column-widths</literal> attribute on the datatable (since
+ the UIColumn doesn't support the style or styleClass attributes).
</para>
+ </section>
+ <section id="excel.fontsandlayout.examples">
+ <title>Layout examples</title>
<para>
- Templates are used by referring to them in the style attribute of
- the UIOutput using the xlsTemplates attribute. If you wish to
- cascade several templates, separate them with a
- <literal>,</literal>
- .
+ TODO
</para>
- <programlisting role="XML">
- <![CDATA[
- <h:dataTable style="xlsFontName : Times New Roman; xlsFontColor.foo : blue;
- xlsFontColor.bar : red; xlsFontBold.tar : true">
- <h:column>
- <h:outputText style="xlsTemplates : foo"/>
- </h:column>
- <h:column>
- <h:outputText style="xlsTemplates : bar,tar"/>
- </h:column>
- </h:dataTable>
- ]]>
- </programlisting>
+ </section>
+ <section id="excel.fontsandlayout.limitations">
+ <title>Limitations</title>
<para>
- results in the first column being Times New Roman, blue and the
- second column being Times New Roman red bold.
+ In the current version there are some known limitations regarding
+ CSS support
</para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ When using .xhtml documents, stylesheets must be referenced
+ through the <literal><e:link> tag</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ When using external stylesheets they must be formatted in
+ one line per entry like
+ </para>
+ <programlisting role="XML">
+ .header { xls-font: bold 14 Verdana }
+ .data { xls-font: 12 'Times New Roman' }
+ </programlisting>
+ </listitem>
+ <listitem>
+ <para>
+ When using the datatable exporter, CSS must be entered through
+ style-attributes, external stylesheets are not supported
+ </para>
+ </listitem>
+ </itemizedlist>
</section>
</section>
<section id="excel.links">
Modified: trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java
===================================================================
--- trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/examples/excel/src/org/jboss/seam/excel/ExcelTest.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -24,8 +24,8 @@
@Create
public void create()
{
- people.add(new Person("Gavin King", "Red Hat Inc.", "Project Lead"));
- people.add(new Person("Pete Muir", "Red Hat Inc.", "Seam Core"));
+ people.add(new Person("Pete Muir", "Red Hat Inc.", "Project Lead"));
+ people.add(new Person("Gavin King", "Red Hat Inc.", "Project Founder"));
people.add(new Person("Norman Richards", "Red Hat Inc.", "Seam Core"));
people.add(new Person("Shane Bryzak", "Red Hat Inc.", "Seam Security, Seam Remoting"));
people.add(new Person("Michael Yuan", "Individual", ""));
@@ -42,7 +42,6 @@
people.add(new Person("Max Rydahl Andersen", "Red Hat Inc.", "Lead developer JBoss Tools, Hibernate Tools, Seam Tools"));
people.add(new Person("Emmanuel Bernard", "Red Hat Inc.", "Lead developer Hibernate Annotations, EntityManager, Validator, Search"));
repeat.add(people.subList(0, 5));
-
}
public List<List<Person>> getRepeat()
Modified: trunk/examples/excel/view/home.xhtml
===================================================================
--- trunk/examples/excel/view/home.xhtml 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/examples/excel/view/home.xhtml 2008-09-10 20:41:17 UTC (rev 8930)
@@ -34,10 +34,11 @@
<a4j:outputPanel id="searchResults">
<rich:dataTable value="#{excelTest.result}" var="person"
rendered="#{!empty excelTest.result}" id="excelTable"
+ style="xls-font: red bold 22 Verdana; xls-column-widths: 8000 9000 10000"
columnClasses="left, right" width="500px">
<rich:column>
<f:facet name="header">
- <h:outputText value="Name" />
+ <h:outputText value="Name" style="xls-font: italic"/>
</f:facet>
<h:outputText value="#{person.name}" />
</rich:column>
Modified: trunk/src/excel/META-INF/faces-config.xml
===================================================================
--- trunk/src/excel/META-INF/faces-config.xml 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/META-INF/faces-config.xml 2008-09-10 20:41:17 UTC (rev 8930)
@@ -9,18 +9,6 @@
<component-class>org.jboss.seam.excel.ui.UIWorkbook</component-class>
</component>
<component>
- <component-type>org.jboss.seam.excel.ui.UIWorksheetSettings</component-type>
- <component-class>org.jboss.seam.excel.ui.UIWorksheetSettings</component-class>
- </component>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIBackground</component-type>
- <component-class>org.jboss.seam.excel.ui.UIBackground</component-class>
- </component>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIBorder</component-type>
- <component-class>org.jboss.seam.excel.ui.UIBorder</component-class>
- </component>
- <component>
<component-type>org.jboss.seam.excel.ui.UICell</component-type>
<component-class>org.jboss.seam.excel.ui.UICell</component-class>
</component>
@@ -29,10 +17,6 @@
<component-class>org.jboss.seam.excel.ui.UIColumn</component-class>
</component>
<component>
- <component-type>org.jboss.seam.excel.ui.UIFont</component-type>
- <component-class>org.jboss.seam.excel.ui.UIFont</component-class>
- </component>
- <component>
<component-type>org.jboss.seam.excel.ui.UIWorksheet</component-type>
<component-class>org.jboss.seam.excel.ui.UIWorksheet</component-class>
</component>
@@ -73,14 +57,6 @@
<component-class>org.jboss.seam.excel.ui.UIFormula</component-class>
</component>
<component>
- <component-type>org.jboss.seam.excel.ui.UICellTemplate</component-type>
- <component-class>org.jboss.seam.excel.ui.UICellTemplate</component-class>
- </component>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIWorksheetTemplate</component-type>
- <component-class>org.jboss.seam.excel.ui.UIWorksheetTemplate</component-class>
- </component>
- <component>
<component-type>org.jboss.seam.excel.ui.UIGroupColumns</component-type>
<component-class>org.jboss.seam.excel.ui.UIGroupColumns</component-class>
</component>
@@ -89,24 +65,24 @@
<component-class>org.jboss.seam.excel.ui.UIGroupRows</component-class>
</component>
<component>
- <component-type>org.jboss.seam.excel.ui.UIListValidation</component-type>
- <component-class>org.jboss.seam.excel.ui.UIListValidation</component-class>
+ <component-type>org.jboss.seam.excel.ui.validation.UIListValidation</component-type>
+ <component-class>org.jboss.seam.excel.ui.validation.UIListValidation</component-class>
</component>
<component>
- <component-type>org.jboss.seam.excel.ui.UIListValidationItem</component-type>
- <component-class>org.jboss.seam.excel.ui.UIListValidationItem</component-class>
+ <component-type>org.jboss.seam.excel.ui.validation.UIListValidationItem</component-type>
+ <component-class>org.jboss.seam.excel.ui.validation.UIListValidationItem</component-class>
</component>
<component>
<component-type>org.jboss.seam.excel.ui.UIMergeCells</component-type>
<component-class>org.jboss.seam.excel.ui.UIMergeCells</component-class>
</component>
<component>
- <component-type>org.jboss.seam.excel.ui.UINumericValidation</component-type>
- <component-class>org.jboss.seam.excel.ui.UINumericValidation</component-class>
+ <component-type>org.jboss.seam.excel.ui.validation.UINumericValidation</component-type>
+ <component-class>org.jboss.seam.excel.ui.validation.UINumericValidation</component-class>
</component>
<component>
- <component-type>org.jboss.seam.excel.ui.UIRangeValidation</component-type>
- <component-class>org.jboss.seam.excel.ui.UIRangeValidation</component-class>
+ <component-type>org.jboss.seam.excel.ui.validation.UIRangeValidation</component-type>
+ <component-class>org.jboss.seam.excel.ui.validation.UIRangeValidation</component-class>
</component>
<component>
<component-type>org.jboss.seam.excel.ui.UIRowPageBreak</component-type>
@@ -116,4 +92,8 @@
<component-type>org.jboss.seam.excel.ui.UIExcelExport</component-type>
<component-class>org.jboss.seam.excel.ui.UIExcelExport</component-class>
</component>
+ <component>
+ <component-type>org.jboss.seam.excel.ui.UILink</component-type>
+ <component-class>org.jboss.seam.excel.ui.UILink</component-class>
+ </component>
</faces-config>
Modified: trunk/src/excel/META-INF/seam-excel.taglib.xml
===================================================================
--- trunk/src/excel/META-INF/seam-excel.taglib.xml 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/META-INF/seam-excel.taglib.xml 2008-09-10 20:41:17 UTC (rev 8930)
@@ -21,27 +21,6 @@
</tag>
<tag>
- <tag-name>worksheetSettings</tag-name>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIWorksheetSettings</component-type>
- </component>
- </tag>
-
- <tag>
- <tag-name>background</tag-name>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIBackground</component-type>
- </component>
- </tag>
-
- <tag>
- <tag-name>border</tag-name>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIBorder</component-type>
- </component>
- </tag>
-
- <tag>
<tag-name>cell</tag-name>
<component>
<component-type>org.jboss.seam.excel.ui.UICell</component-type>
@@ -56,13 +35,6 @@
</tag>
<tag>
- <tag-name>font</tag-name>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIFont</component-type>
- </component>
- </tag>
-
- <tag>
<tag-name>headerFooter</tag-name>
<component>
<component-type>org.jboss.seam.excel.ui.UIHeaderFooter</component-type>
@@ -112,79 +84,72 @@
</tag>
<tag>
- <tag-name>formula</tag-name>
+ <tag-name>link</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIFormula</component-type>
+ <component-type>org.jboss.seam.excel.ui.UILink</component-type>
</component>
</tag>
<tag>
- <tag-name>cellTemplate</tag-name>
+ <tag-name>formula</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UICellTemplate</component-type>
+ <component-type>org.jboss.seam.excel.ui.UIFormula</component-type>
</component>
</tag>
<tag>
- <tag-name>worksheetTemplate</tag-name>
- <component>
- <component-type>org.jboss.seam.excel.ui.UIWorksheetTemplate</component-type>
- </component>
- </tag>
-
- <tag>
<tag-name>groupColumns</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIGroupColumns</component-type>
+ <component-type>org.jboss.seam.excel.ui.command.UIGroupColumns</component-type>
</component>
</tag>
<tag>
<tag-name>groupRows</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIGroupRows</component-type>
+ <component-type>org.jboss.seam.excel.ui.command.UIGroupRows</component-type>
</component>
</tag>
<tag>
<tag-name>listValidation</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIListValidation</component-type>
+ <component-type>org.jboss.seam.excel.ui.validation.UIListValidation</component-type>
</component>
</tag>
<tag>
<tag-name>listValidationItem</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIListValidationItem</component-type>
+ <component-type>org.jboss.seam.excel.ui.validation.UIListValidationItem</component-type>
</component>
</tag>
<tag>
<tag-name>mergeCells</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIMergeCells</component-type>
+ <component-type>org.jboss.seam.excel.ui.command.UIMergeCells</component-type>
</component>
</tag>
<tag>
<tag-name>numericValidation</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UINumericValidation</component-type>
+ <component-type>org.jboss.seam.excel.ui.validation.UINumericValidation</component-type>
</component>
</tag>
<tag>
<tag-name>rangeValidation</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIRangeValidation</component-type>
+ <component-type>org.jboss.seam.excel.ui.validation.UIRangeValidation</component-type>
</component>
</tag>
<tag>
<tag-name>rowPageBreak</tag-name>
<component>
- <component-type>org.jboss.seam.excel.ui.UIRowPageBreak</component-type>
+ <component-type>org.jboss.seam.excel.ui.command.UIRowPageBreak</component-type>
</component>
</tag>
Deleted: trunk/src/excel/org/jboss/seam/excel/Command.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/Command.java 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/Command.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,11 +0,0 @@
-package org.jboss.seam.excel;
-
-public interface Command
-{
- public enum CommandType
- {
- merge_cells, add_row_pagebreak, group_rows, group_columns
- }
-
- public abstract CommandType getCommandType();
-}
Modified: trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/ExcelWorkbook.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,9 +1,13 @@
package org.jboss.seam.excel;
+import java.util.List;
+
import org.jboss.seam.document.DocumentData.DocumentType;
import org.jboss.seam.excel.ui.UIColumn;
+import org.jboss.seam.excel.ui.UILink;
import org.jboss.seam.excel.ui.UIWorkbook;
import org.jboss.seam.excel.ui.UIWorksheet;
+import org.jboss.seam.excel.ui.command.Command;
/**
* General interface interacting with an Excel Workbook abstraction
@@ -67,13 +71,6 @@
public abstract void addItem(WorksheetItem item);
/**
- * Adds a template to the template stack
- *
- * @param template The template to add
- */
- public abstract void addTemplate(Template template);
-
- /**
* Executes a command for a worksheet
*
* @param command The command to execute
@@ -95,4 +92,6 @@
* @param colspan The number of columns to span
*/
public abstract void addWorksheetFooter(WorksheetItem item, int colspan);
+
+ public abstract void setStylesheets(List<UILink> stylesheets);
}
\ No newline at end of file
Deleted: trunk/src/excel/org/jboss/seam/excel/Template.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/Template.java 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/Template.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,14 +0,0 @@
-package org.jboss.seam.excel;
-
-public interface Template
-{
- public enum TemplateType
- {
- cell, worksheet
- }
-
- public abstract TemplateType getType();
-
- public abstract String getName();
-
-}
Deleted: trunk/src/excel/org/jboss/seam/excel/Validation.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/Validation.java 2008-09-08 13:50:06 UTC (rev 8929)
+++ trunk/src/excel/org/jboss/seam/excel/Validation.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -1,11 +0,0 @@
-package org.jboss.seam.excel;
-
-public interface Validation
-{
- public enum ValidationType
- {
- numeric, range, list
- }
-
- public abstract ValidationType getType();
-}
Added: trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/CSSNames.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,51 @@
+package org.jboss.seam.excel.css;
+
+public class CSSNames
+{
+ public static final String FONT_FAMILY = "xls-font-family";
+ public static final String FONT_SIZE = "xls-font-size";
+ public static final String FONT_COLOR = "xls-font-color";
+ public static final String FONT_ITALIC = "xls-font-italic";
+ public static final String FONT_SCRIPT_STYLE = "xls-font-script-style";
+ public static final String FONT_STRUCK_OUT = "xls-font-struck-out";
+ public static final String FONT_UNDERLINE_STYLE = "xls-font-underline-style";
+ public static final String FONT_BOLD = "xls-font-bold";
+ public static final String FONT = "xls-font";
+
+ public static final String BACKGROUND_PATTERN = "xls-background-pattern";
+ public static final String BACKGROUND_COLOR = "xls-background-color";
+ public static final String BACKGROUND = "xls-background";
+
+ public static final String BORDER_LEFT_COLOR = "xls-border-left-color";
+ public static final String BORDER_LEFT_LINE_STYLE = "xls-border-left-line-style";
+ public static final String BORDER_LEFT = "xls-border-left";
+
+ public static final String BORDER_TOP_COLOR = "xls-border-top-color";
+ public static final String BORDER_TOP_LINE_STYLE = "xls-border-top-line-style";
+ public static final String BORDER_TOP = "xls-border-top";
+
+ public static final String BORDER_RIGHT_COLOR = "xls-border-right-color";
+ public static final String BORDER_RIGHT_LINE_STYLE = "xls-border-right-line-style";
+ public static final String BORDER_RIGHT = "xls-border-right";
+
+ public static final String BORDER_BOTTOM_COLOR = "xls-border-bottom-color";
+ public static final String BORDER_BOTTOM_LINE_STYLE = "xls-border-bottom-line-style";
+ public static final String BORDER_BOTTOM = "xls-border-bottom";
+
+ public static final String BORDER = "xls-border";
+
+ public static final String ALIGNMENT = "xls-alignment";
+ public static final String FORMAT_MASK = "xls-format-mask";
+ public static final String INDENTATION = "xls-indentation";
+ public static final String LOCKED = "xls-locked";
+ public static final String ORIENTATION = "xls-orientation";
+ public static final String SHRINK_TO_FIT = "xls-shrink-to-fit";
+ public static final String VERICAL_ALIGNMENT = "xls-vertical-alignment";
+ public static final String WRAP = "xls-wrap";
+
+ public static final String COLUMN_WIDTH = "xls-column-width";
+ public static final String COLUMN_WIDTHS = "xls-column-widths";
+ public static final String COLUMN_AUTO_SIZE = "xls-column-autosize";
+ public static final String COLUMN_HIDDEN = "xls-column-hidden";
+
+}
Added: trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/CellStyle.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,94 @@
+package org.jboss.seam.excel.css;
+
+import java.util.Map;
+
+public class CellStyle
+{
+
+ public class Font
+ {
+ public String family;
+ public Integer pointSize;
+ public String color;
+ public Boolean bold;
+ public Boolean italic;
+ public String scriptStyle;
+ public String underlineStyle;
+ public Boolean struckOut;
+
+ public boolean isUsed()
+ {
+ return family != null || pointSize != null || color != null || bold != null || italic != null ||
+ scriptStyle != null || underlineStyle != null || struckOut != null;
+ }
+ }
+
+ public class Background
+ {
+ public String color;
+ public String pattern;
+
+ public boolean isUsed()
+ {
+ return color != null || pattern != null;
+ }
+ }
+
+ public class Border
+ {
+ public String color;
+ public String lineStyle;
+
+ public boolean isUsed()
+ {
+ return color != null || lineStyle != null;
+ }
+
+ }
+
+ public Font font = new Font();
+ public Background background = new Background();
+ public Border leftBorder = new Border();
+ public Border topBorder = new Border();
+ public Border bottomBorder = new Border();
+ public Border rightBorder = new Border();
+ public String alignment;
+ public Integer indentation;
+ public Boolean locked;
+ public String orientation;
+ public Boolean shrinkToFit;
+ public Boolean wrap;
+ public String verticalAlignment;
+ public String formatMask;
+
+ public CellStyle(Map<String, Object> styleMap)
+ {
+ font.family = (String) styleMap.get(CSSNames.FONT_FAMILY);
+ font.color = (String) styleMap.get(CSSNames.FONT_COLOR);
+ font.pointSize = (Integer) styleMap.get(CSSNames.FONT_SIZE);
+ font.italic = (Boolean) styleMap.get(CSSNames.FONT_ITALIC);
+ font.scriptStyle = (String) styleMap.get(CSSNames.FONT_SCRIPT_STYLE);
+ font.struckOut = (Boolean) styleMap.get(CSSNames.FONT_STRUCK_OUT);
+ font.underlineStyle = (String) styleMap.get(CSSNames.FONT_UNDERLINE_STYLE);
+ font.bold = (Boolean) styleMap.get(CSSNames.FONT_BOLD);
+ background.color = (String) styleMap.get(CSSNames.BACKGROUND_PATTERN);
+ background.pattern = (String) styleMap.get(CSSNames.BACKGROUND_COLOR);
+ leftBorder.color = (String) styleMap.get(CSSNames.BORDER_LEFT_COLOR);
+ leftBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_LEFT_LINE_STYLE);
+ topBorder.color = (String) styleMap.get(CSSNames.BORDER_TOP_COLOR);
+ topBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_TOP_LINE_STYLE);
+ rightBorder.color = (String) styleMap.get(CSSNames.BORDER_RIGHT_COLOR);
+ rightBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_RIGHT_LINE_STYLE);
+ bottomBorder.color = (String) styleMap.get(CSSNames.BORDER_BOTTOM_COLOR);
+ bottomBorder.lineStyle = (String) styleMap.get(CSSNames.BORDER_BOTTOM_LINE_STYLE);
+ alignment = (String) styleMap.get(CSSNames.ALIGNMENT);
+ indentation = (Integer) styleMap.get(CSSNames.INDENTATION);
+ locked = (Boolean) styleMap.get(CSSNames.LOCKED);
+ orientation = (String) styleMap.get(CSSNames.ORIENTATION);
+ shrinkToFit = (Boolean) styleMap.get(CSSNames.SHRINK_TO_FIT);
+ wrap = (Boolean) styleMap.get(CSSNames.WRAP);
+ verticalAlignment = (String) styleMap.get(CSSNames.VERICAL_ALIGNMENT);
+ formatMask = (String) styleMap.get(CSSNames.FORMAT_MASK);
+ }
+
+}
Added: trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/ColumnStyle.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,16 @@
+package org.jboss.seam.excel.css;
+
+import java.util.Map;
+
+public class ColumnStyle
+{
+ public Boolean autoSize;
+ public Boolean hidden;
+ public Integer width;
+
+ public ColumnStyle(Map<String, Object> styleMap) {
+ autoSize = (Boolean) styleMap.get(CSSNames.COLUMN_AUTO_SIZE);
+ hidden = (Boolean) styleMap.get(CSSNames.COLUMN_HIDDEN);
+ width = (Integer) styleMap.get(CSSNames.COLUMN_WIDTH);
+ }
+}
Added: trunk/src/excel/org/jboss/seam/excel/css/Parser.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/Parser.java (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/Parser.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,248 @@
+package org.jboss.seam.excel.css;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.excel.ExcelWorkbookException;
+import org.jboss.seam.excel.ui.UILink;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.log.Logging;
+
+public class Parser
+{
+ private static final String STYLE_ATTRIBUTE = "style";
+ private static final String STYLE_CLASS_ATTRIBUTE = "styleClass";
+ private static final String STYLES_SEPARATOR = ";";
+ private static final String STYLE_NAME_VALUE_SEPARATOR = ":";
+ private static final String STYLE_SHORTHAND_SEPARATOR = " ";
+
+ private Map<String, StyleMap> definedStyleClasses = new HashMap<String, StyleMap>();
+ private Map<String, PropertyBuilder> propertyBuilders = new HashMap<String, PropertyBuilder>();
+ private Map<UIComponent, StyleMap> cellStyleCache = new HashMap<UIComponent, StyleMap>();
+
+ private Log log = Logging.getLog(Parser.class);
+
+ public Parser()
+ {
+ initPropertyBuilders();
+ }
+
+ public Parser(List<UILink> stylesheets) throws MalformedURLException, IOException
+ {
+ initPropertyBuilders();
+ loadStylesheets(stylesheets);
+ }
+
+ private void loadStylesheets(List<UILink> stylesheets) throws MalformedURLException, IOException
+ {
+ for (UILink stylesheet : stylesheets)
+ {
+ definedStyleClasses.putAll(parseStylesheet(stylesheet.getURL()));
+ }
+ }
+
+ private void initPropertyBuilders()
+ {
+ propertyBuilders.put(CSSNames.FONT_FAMILY, new PropertyBuilders.FontFamily());
+ propertyBuilders.put(CSSNames.FONT_SIZE, new PropertyBuilders.FontSize());
+ propertyBuilders.put(CSSNames.FONT_COLOR, new PropertyBuilders.FontColor());
+ propertyBuilders.put(CSSNames.FONT_ITALIC, new PropertyBuilders.FontItalic());
+ propertyBuilders.put(CSSNames.FONT_SCRIPT_STYLE, new PropertyBuilders.FontScriptStyle());
+ propertyBuilders.put(CSSNames.FONT_STRUCK_OUT, new PropertyBuilders.FontStruckOut());
+ propertyBuilders.put(CSSNames.FONT_UNDERLINE_STYLE, new PropertyBuilders.FontUnderlineStyle());
+ propertyBuilders.put(CSSNames.FONT_BOLD, new PropertyBuilders.FontBold());
+ propertyBuilders.put(CSSNames.FONT, new PropertyBuilders.FontShorthand());
+ propertyBuilders.put(CSSNames.BACKGROUND_PATTERN, new PropertyBuilders.BackgroundPattern());
+ propertyBuilders.put(CSSNames.BACKGROUND_COLOR, new PropertyBuilders.BackgroundColor());
+ propertyBuilders.put(CSSNames.BACKGROUND, new PropertyBuilders.BackgroundShorthand());
+ propertyBuilders.put(CSSNames.BORDER_LEFT_COLOR, new PropertyBuilders.BorderLeftColor());
+ propertyBuilders.put(CSSNames.BORDER_LEFT_LINE_STYLE, new PropertyBuilders.BorderLeftLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_LEFT, new PropertyBuilders.BorderLeftShorthand());
+ propertyBuilders.put(CSSNames.BORDER_TOP_COLOR, new PropertyBuilders.BorderTopColor());
+ propertyBuilders.put(CSSNames.BORDER_TOP_LINE_STYLE, new PropertyBuilders.BorderTopLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_TOP, new PropertyBuilders.BorderTopShorthand());
+ propertyBuilders.put(CSSNames.BORDER_RIGHT_COLOR, new PropertyBuilders.BorderRightColor());
+ propertyBuilders.put(CSSNames.BORDER_RIGHT_LINE_STYLE, new PropertyBuilders.BorderRightLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_RIGHT, new PropertyBuilders.BorderRightShorthand());
+ propertyBuilders.put(CSSNames.BORDER_BOTTOM_COLOR, new PropertyBuilders.BorderBottomColor());
+ propertyBuilders.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, new PropertyBuilders.BorderBottomLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_BOTTOM, new PropertyBuilders.BorderBottomShorthand());
+ propertyBuilders.put(CSSNames.BORDER, new PropertyBuilders.BorderShorthand());
+ propertyBuilders.put(CSSNames.FORMAT_MASK, new PropertyBuilders.FormatMask());
+ propertyBuilders.put(CSSNames.ALIGNMENT, new PropertyBuilders.Alignment());
+ propertyBuilders.put(CSSNames.INDENTATION, new PropertyBuilders.Indentation());
+ propertyBuilders.put(CSSNames.ORIENTATION, new PropertyBuilders.Orientation());
+ propertyBuilders.put(CSSNames.LOCKED, new PropertyBuilders.Locked());
+ propertyBuilders.put(CSSNames.SHRINK_TO_FIT, new PropertyBuilders.ShrinkToFit());
+ propertyBuilders.put(CSSNames.WRAP, new PropertyBuilders.Wrap());
+ propertyBuilders.put(CSSNames.VERICAL_ALIGNMENT, new PropertyBuilders.VericalAlignment());
+ propertyBuilders.put(CSSNames.COLUMN_WIDTH, new PropertyBuilders.ColumnWidth());
+ propertyBuilders.put(CSSNames.COLUMN_AUTO_SIZE, new PropertyBuilders.ColumnAutoSize());
+ propertyBuilders.put(CSSNames.COLUMN_HIDDEN, new PropertyBuilders.ColumnHidden());
+ propertyBuilders.put(CSSNames.COLUMN_WIDTHS, new PropertyBuilders.ColumnWidths());
+ }
+
+ private Map<String, StyleMap> parseStylesheet(String URL) throws MalformedURLException, IOException
+ {
+ Map<String, StyleMap> styleClasses = new HashMap<String, StyleMap>();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(URL).openStream()));
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ String[] spaceParts = line.split(" ");
+ String name = spaceParts[0];
+ if (name.startsWith("."))
+ {
+ name = name.substring(1);
+ }
+ int startbrace = line.indexOf("{");
+ int stopbrace = line.indexOf("}");
+ if (startbrace < 0 || stopbrace < 0)
+ {
+ String message = Interpolator.instance().interpolate("Could not find braces in #0", line);
+ throw new ExcelWorkbookException(message);
+ }
+ String styleData = line.substring(startbrace + 1, stopbrace).trim();
+ StyleMap styleMap = parseStyleString(styleData);
+ styleClasses.put(name, styleMap);
+ }
+ reader.close();
+ return styleClasses;
+ }
+
+ public static String getStyle(UIComponent component) {
+ return getStyleProperty(component, STYLE_ATTRIBUTE);
+ }
+
+ public static String getStyleClass(UIComponent component) {
+ return getStyleProperty(component, STYLE_CLASS_ATTRIBUTE);
+ }
+
+ private static String getStyleProperty(UIComponent component, String field)
+ {
+ try
+ {
+ return (String) PropertyUtils.getProperty(component, field);
+ }
+ catch (NoSuchMethodException e)
+ {
+ // No panic, no property
+ return null;
+ }
+ catch (Exception e)
+ {
+ String message = Interpolator.instance().interpolate("Could not read field #0 of bean #1", field, component.getId());
+ throw new ExcelWorkbookException(message, e);
+ }
+ }
+
+ private List<StyleMap> cascadeStyleMap(UIComponent component, List<StyleMap> styleMaps) {
+ styleMaps.add(getStyleMap(component));
+ if (component.getParent() != null) {
+ cascadeStyleMap(component.getParent(), styleMaps);
+ }
+ return styleMaps;
+ }
+
+ public StyleMap getCascadedStyleMap(UIComponent component) {
+ List<StyleMap> styleMaps = cascadeStyleMap(component, new ArrayList<StyleMap>());
+ Collections.reverse(styleMaps);
+ StyleMap cascadedStyleMap = new StyleMap();
+ for (StyleMap styleMap : styleMaps) {
+ cascadedStyleMap.putAll(styleMap);
+ }
+ return cascadedStyleMap;
+ }
+
+ private StyleMap getStyleMap(UIComponent component)
+ {
+ if (cellStyleCache.containsKey(component))
+ {
+ return cellStyleCache.get(component);
+ }
+
+ StyleMap styleMap = new StyleMap();
+
+ String componentStyleClass = getStyleProperty(component, STYLE_CLASS_ATTRIBUTE);
+ if (componentStyleClass != null)
+ {
+ String[] styleClasses = trimArray(componentStyleClass.split(STYLE_SHORTHAND_SEPARATOR));
+ for (String styleClass : styleClasses)
+ {
+ if (!definedStyleClasses.containsKey(styleClass))
+ {
+ log.warn("Uknown style class #0", styleClass);
+ continue;
+ }
+ styleMap.putAll(definedStyleClasses.get(styleClass));
+ }
+ }
+
+ String componentStyle = getStyleProperty(component, STYLE_ATTRIBUTE);
+ if (componentStyle != null)
+ {
+ styleMap.putAll(parseStyleString(componentStyle));
+ }
+
+ cellStyleCache.put(component, styleMap);
+ return styleMap;
+ }
+
+ private StyleMap parseStyleString(String styleString)
+ {
+ StyleMap styleMap = new StyleMap();
+
+ String[] styles = trimArray(styleString.split(STYLES_SEPARATOR));
+ for (String style : styles)
+ {
+ String[] styleParts = style.split(STYLE_NAME_VALUE_SEPARATOR);
+ if (styleParts.length != 2)
+ {
+ log.warn("Style component #0 should be of form <key>#1<value>", style, STYLE_NAME_VALUE_SEPARATOR);
+ continue;
+ }
+ String styleName = styleParts[0].toLowerCase().trim();
+ if (!propertyBuilders.containsKey(styleName))
+ {
+ log.warn("No property builder (unknown style) for property #0", styleName);
+ continue;
+ }
+ PropertyBuilder propertyBuilder = propertyBuilders.get(styleName);
+ String styleValue = styleParts[1];
+ String[] styleValues = trimArray(styleValue.trim().split(STYLE_SHORTHAND_SEPARATOR));
+ styleMap.putAll(propertyBuilder.parseProperty(styleName, styleValues));
+ }
+
+ return styleMap;
+ }
+
+ private String[] trimArray(String[] array)
+ {
+ List<String> validValues = new ArrayList<String>();
+ for (int i = 0; i < array.length; i++)
+ {
+ if (!"".equals(array[i]) && !" ".equals(array[i]))
+ {
+ validValues.add(array[i].toLowerCase().trim());
+ }
+ }
+ return validValues.toArray(new String[validValues.size()]);
+ }
+
+ public void setStylesheets(List<UILink> stylesheets) throws MalformedURLException, IOException
+ {
+ loadStylesheets(stylesheets);
+ }
+}
Added: trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilder.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,6 @@
+package org.jboss.seam.excel.css;
+
+public interface PropertyBuilder
+{
+ public StyleMap parseProperty(String key, String[] values);
+}
\ No newline at end of file
Added: trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java (rev 0)
+++ trunk/src/excel/org/jboss/seam/excel/css/PropertyBuilders.java 2008-09-10 20:41:17 UTC (rev 8930)
@@ -0,0 +1,442 @@
+package org.jboss.seam.excel.css;
+
+import org.jboss.seam.core.Interpolator;
+import org.jboss.seam.excel.ExcelWorkbookException;
+import org.jboss.seam.excel.jxl.JXLFactory;
+
+public class PropertyBuilders
+{
+ private static final String COLUMN_WIDTH_WILDCARD = "*";
+
+ // "xls-column-widths: 100 200 * 300"
+ public static class ColumnWidths implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ String indexedKey = CSSNames.COLUMN_WIDTHS + i;
+ if (COLUMN_WIDTH_WILDCARD.equals(value)) {
+ // Skip it, just moving along
+ } else if (isNumeric(value)) {
+ styleMap.put(indexedKey, Integer.parseInt(value));
+ } else {
+ String message = Interpolator.instance().interpolate("Column widths must be numerical or *, not #0", value);
+ throw new ExcelWorkbookException(message);
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class ColumnWidth extends IntegerPropertyBuilder
+ {
+ }
+
+ public static class ColumnAutoSize extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class ColumnHidden extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class BorderBottomLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderBottomColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderBottomShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (JXLFactory.isColor(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_BOTTOM_COLOR, value);
+ }
+ else if (JXLFactory.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new ExcelWorkbookException("Border bottom shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderRightLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderRightColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderRightShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (JXLFactory.isColor(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_RIGHT_COLOR, value);
+ }
+ else if (JXLFactory.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_RIGHT_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new ExcelWorkbookException("Border right shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderTopLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderTopColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderTopShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (JXLFactory.isColor(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_TOP_COLOR, value);
+ }
+ else if (JXLFactory.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_TOP_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new ExcelWorkbookException("Border top shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderLeftLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderLeftColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderLeftShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (JXLFactory.isColor(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_COLOR, value);
+ }
+ else if (JXLFactory.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new ExcelWorkbookException("Border left shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (JXLFactory.isColor(value))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_COLOR, values[1]);
+ styleMap.put(CSSNames.BORDER_RIGHT_COLOR, values[1]);
+ styleMap.put(CSSNames.BORDER_TOP_COLOR, values[1]);
+ styleMap.put(CSSNames.BORDER_BOTTOM_COLOR, values[1]);
+ }
+ else if (JXLFactory.isBorderLineStyle(value))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_LINE_STYLE, values[0]);
+ styleMap.put(CSSNames.BORDER_RIGHT_LINE_STYLE, values[0]);
+ styleMap.put(CSSNames.BORDER_TOP_LINE_STYLE, values[0]);
+ styleMap.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, values[0]);
+ }
+ else
+ {
+ throw new ExcelWorkbookException("Border shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BackgroundColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BackgroundPattern extends StringPropertyBuilder
+ {
+ }
+
+ public static class BackgroundShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (JXLFactory.isPattern(values[i]))
+ {
+ styleMap.put(CSSNames.BACKGROUND_PATTERN, value);
+ }
+ else if (JXLFactory.isColor(values[i]))
+ {
+ styleMap.put(CSSNames.BACKGROUND_COLOR, value);
+ }
+ else
+ {
+ throw new ExcelWorkbookException("Background shorthand can only handle color and pattern");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class FontFamily extends MergingStringPropertyBuilder
+ {
+ }
+
+ private static String collectString(String[] values, String delimiter) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < values.length; i++) {
+ if (i > 0) {
+ buffer.append(delimiter);
+ }
+ buffer.append(values[i]);
+ }
+ return buffer.toString();
+ }
+
+ private static class MergingStringPropertyBuilder extends StringPropertyBuilder {
+ @Override
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ String concatValues = collectString(values, " ");
+ return super.parseProperty(key, new String[] {concatValues});
+ }
+ }
+
+ public static class FontSize extends IntegerPropertyBuilder
+ {
+ }
+
+ public static class FontColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class FontItalic extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class FontScriptStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class FontUnderlineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class FontBold extends BooleanPropertyBuilder
+