Difference between revisions of "Table Style in Writerfilter"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 31: Line 31:
 
       < /w:tblStylePr>
 
       < /w:tblStylePr>
 
   < /w:style>
 
   < /w:style>
 +
 +
  
 
== Background Color ==  
 
== Background Color ==  
Line 37: Line 39:
 
=== wholeTable ===
 
=== wholeTable ===
  
The '''w:tcPr''' under '''w:style''' is applied for whole table.  
+
The '''w:tcPr''' under '''w:style''' is applied on the whole table.  
 
So, the background color of whole table should be applied with fill color "C0504D" and its theme should be "accent2" from '''theme.xml'''.
 
So, the background color of whole table should be applied with fill color "C0504D" and its theme should be "accent2" from '''theme.xml'''.
  
Line 49: Line 51:
  
 
For first row of table, below '''firstRow tblStylePr''' will be applied with fill color "4BACC6" and its theme should be "accent5".
 
For first row of table, below '''firstRow tblStylePr''' will be applied with fill color "4BACC6" and its theme should be "accent5".
It will overwrite related color and theme from whole table mentioned above.
+
It will overwrite related color and theme from '''wholeTable''' mentioned above.
  
 
       < w:tblStylePr w:type="firstRow">
 
       < w:tblStylePr w:type="firstRow">
Line 58: Line 60:
  
 
There can be also up to 12 types of tblStyle here. They are:
 
There can be also up to 12 types of tblStyle here. They are:
* firstRow #first row
+
* '''firstRow '''        #first row
* lastRow #last row
+
* '''lastRow '''        #last row
* firstCol #first column
+
* '''firstCol '''        #first column
* lastCol #last column
+
* '''lastCol '''        #last column
* band1Vert #odd column
+
* '''band1Vert'''        #odd column
* band2Vert #even column
+
* '''band2Vert'''        #even column
* band1Horz #odd row
+
* '''band1Horz'''        #odd row
* band2Horz #even row
+
* '''band2Horz'''        #even row
* neCell #last cell in first row
+
* '''neCell   '''        #last cell in first row
* nwCell #first cell in first row
+
* '''nwCell   '''        #first cell in first row
* seCell #last cell in last row
+
* '''seCell   '''        #last cell in last row
* swCell #first cell in last row
+
* '''swCell   '''        #first cell in last row
  
 
=== tblLook and cnfStyle ===
 
=== tblLook and cnfStyle ===
Line 76: Line 78:
 
For example, for the first cell in first row, which tblStyle should take effect, firstRow, firstCol, nwCell?
 
For example, for the first cell in first row, which tblStyle should take effect, firstRow, firstCol, nwCell?
 
Which one has highest priority?
 
Which one has highest priority?
The answer is it depends on the '''tblLook''' of whole table, '''cnfStyle''' of the row and the cell.
+
It depends on the '''tblLook''' in '''tblPr''' for whole table, '''cnfStyle''' in '''trPr''' for row and '''tcPr''' for cell.
  
 
Take below cell in a table from document.xml for example:
 
Take below cell in a table from document.xml for example:
Line 96: Line 98:
 
       < /w:tr>
 
       < /w:tr>
 
   < /w:tbl>
 
   < /w:tbl>
 +
 +
==== tblLook ====
  
 
Based on description from [[Office Open XML]], tblLook decides whether following tblStyle can be applied on table or not:
 
Based on description from [[Office Open XML]], tblLook decides whether following tblStyle can be applied on table or not:
Line 107: Line 111:
 
* band2Horz
 
* band2Horz
  
That means, even there is firstRow tblStyle exisiting in styles.xml, if tblLook forbids using firstRow, you should not expect to apply it on the row.
+
That means, it won't be applied, if tblLook forbids using firstRow, even though there is firstRow tblStyle exisiting in styles.xml.
  
 +
==== cnfStyle ====
 +
 +
Assume tblLook allows all types of tblStyle.
 
Then, let's turn to cnfStyle. It specifies which kind of tblStyle can be applied for current row and cell.
 
Then, let's turn to cnfStyle. It specifies which kind of tblStyle can be applied for current row and cell.
 
Not all first row can be applied with firstRow tblStyle, unless its cnfStyle tells this.
 
Not all first row can be applied with firstRow tblStyle, unless its cnfStyle tells this.
Line 127: Line 134:
  
 
== Font Properties ==  
 
== Font Properties ==  
 +
 
Including font size, bold, italic, color, strike-through, underline, and so on.
 
Including font size, bold, italic, color, strike-through, underline, and so on.
  
 
== Border Styles ==
 
== Border Styles ==
 +
 
Including border's style, color, and so on.
 
Including border's style, color, and so on.
  

Revision as of 02:33, 15 August 2012

Table style refers to table's border styles, text's font properties, background color. It is mainly decided by styles.xml from Office Open XML.


Assume there is styles.xml from docx as below:

  < w:style w:type="table" w:styleId="DarkList-Accent2">
     < w:tcPr>
        < w:shd w:val="clear" w:color="auto" w:fill="C0504D" w:themeFill="accent2"/>
     < /w:tcPr>
     < w:tblStylePr w:type="firstRow">
        < w:pPr>
           < w:spacing w:before="0" w:after="0" w:line="240" w:lineRule="auto"/>
        < /w:pPr>
        < w:rPr>
           < w:b/>
           < w:bCs/>
           < w:color w:val="FFFFFF" w:themeColor="background1"/>
        < /w:rPr>
        < w:tblPr/>
        < w:tcPr>
           < w:tcBorders>
              < w:top w:val="single" w:sz="18" w:space="0" w:color="auto"/>
              < w:left w:val="nil"/>
              < w:bottom w:val="single" w:sz="18" w:space="0" w:color="auto"/>
              < w:right w:val="nil"/>
              < w:insideH w:val="nil"/>
              < w:insideV w:val="nil"/>
           < /w:tcBorders>
           < w:shd w:val="clear" w:color="auto" w:fill="4BACC6" w:themeFill="accent5"/>
        < /w:tcPr>
     < /w:tblStylePr>
  < /w:style>


Background Color

Include cell/row/table's background color.

wholeTable

The w:tcPr under w:style is applied on the whole table. So, the background color of whole table should be applied with fill color "C0504D" and its theme should be "accent2" from theme.xml.

  < w:style w:type="table" w:styleId="DarkList-Accent2">
     < w:tcPr>
        < w:shd w:val="clear" w:color="auto" w:fill="C0504D" w:themeFill="accent2"/>
     < /w:tcPr>
  < /w:style>

firstRow and others

For first row of table, below firstRow tblStylePr will be applied with fill color "4BACC6" and its theme should be "accent5". It will overwrite related color and theme from wholeTable mentioned above.

     < w:tblStylePr w:type="firstRow">
        < w:tcPr>
           < w:shd w:val="clear" w:color="auto" w:fill="4BACC6" w:themeFill="accent5"/>
        < /w:tcPr>
     < /w:tblStylePr>

There can be also up to 12 types of tblStyle here. They are:

  • firstRow #first row
  • lastRow #last row
  • firstCol #first column
  • lastCol #last column
  • band1Vert #odd column
  • band2Vert #even column
  • band1Horz #odd row
  • band2Horz #even row
  • neCell #last cell in first row
  • nwCell #first cell in first row
  • seCell #last cell in last row
  • swCell #first cell in last row

tblLook and cnfStyle

With above basic knowledge, we now can get further. For example, for the first cell in first row, which tblStyle should take effect, firstRow, firstCol, nwCell? Which one has highest priority? It depends on the tblLook in tblPr for whole table, cnfStyle in trPr for row and tcPr for cell.

Take below cell in a table from document.xml for example:

  < w:tbl>
     < w:tblPr>
        < w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
     < /w:tblPr>
     < w:tr w:rsidR="001662F7" w:rsidTr="00C76FCB">
        < w:trPr>
           < w:cnfStyle w:val="100000000000" w:firstRow="1" w:lastRow="0" w:firstColumn="0" w:lastColumn="0" w:oddVBand="0" w:evenVBand="0" w:oddHBand="0" w:evenHBand="0" w:firstRowFirstColumn="0" w:firstRowLastColumn="0" w:lastRowFirstColumn="0" w:lastRowLastColumn="0"/>
        < /w:trPr>
        < w:tc>
           < w:tcPr>
              < w:cnfStyle w:val="001000000100" w:firstRow="0" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:oddVBand="0" w:evenVBand="0" w:oddHBand="0" w:evenHBand="0" w:firstRowFirstColumn="1" w:firstRowLastColumn="0" w:lastRowFirstColumn="0" w:lastRowLastColumn="0"/>
              < w:tcW w:w="4261" w:type="dxa"/>
           < /w:tcPr>
        < /w:tc>
     < /w:tr>
  < /w:tbl>

tblLook

Based on description from Office Open XML, tblLook decides whether following tblStyle can be applied on table or not:

  • firstRow
  • lastRow
  • firstCol
  • lastCol
  • band1Vert
  • band2Vert
  • band1Horz
  • band2Horz

That means, it won't be applied, if tblLook forbids using firstRow, even though there is firstRow tblStyle exisiting in styles.xml.

cnfStyle

Assume tblLook allows all types of tblStyle. Then, let's turn to cnfStyle. It specifies which kind of tblStyle can be applied for current row and cell. Not all first row can be applied with firstRow tblStyle, unless its cnfStyle tells this. It's similar case for cell, check its cnfStyle.

Sometimes, the cnfStyle for cell will specify more than that from row. How to decide it? There is a rule from Office Open XML:

  • wholeTable
  • band1Horz band2Horz
  • band1Vert band2Vert
  • firstCol lastCol
  • firstRow lastRow
  • neCell nwCell seCell swCell

That means neCell has higher priority than firstRow. The firstRow and lastRow tblStyle have higher priority than firstCol and lastCol. And so on.


Font Properties

Including font size, bold, italic, color, strike-through, underline, and so on.

Border Styles

Including border's style, color, and so on.

Personal tools