Collapsing Table Borders

OpenOffice.org 2.0 / StarOffice 8

Document - ID	Specification Owner	Last Change	Status
	Frank Meies	2004-05-24	Final
Conforms to	
Applies to	Writer
Task ID(s)	i29550
Category	Feature

Abstract

MS Word and Writer have different approaches of how to draw table cell borders. Until now Writer uses a border model which is similar to the separated border model known from html, MS Word uses a border model which is similar to the collapsing border model. To enhance interoperability between these products as well as to lower the threshold for users to migrate to Writer Writer now supports certain behavior of the collapsing border model.

i-Team Members (The specification owner is part of the i-Team)

	Name	E-mail Address
User Experience	Falko Tesch (FT)	ft@openoffice.org
Development	Frank Meies (FME)	fme@openoffice.org
Quality Assurance	Michael Rüss (MRU)	mru@openoffice.org
Documentation	Uwe Fischer (UFI)	ufi@openoffice.org

Approved for Implementation

	Approved by	Date
User Experience	Falko Tesch	2004-05-26
Development	Frank Meies	2004-05-26
Quality Assurance	Michael Rüss	2004-06-02
Documentation	Uwe Fischer	2004-05-26
String Review	Elizabeth Matthis	2004-06-10

Document Change History

Rev. Level	Change	Initials	Date
1.0	Initial version	FME	2004-05-24
1.1	Changed abstract	FME	2004-05-26
1.2	Description of Illustration 3 changed	FME	2004-06-02

Contents

Glossary	1

2	Motivation	1

3	User Scenarios	1

4	Goals	2

5	Requirements and Dependencies	2

5.1	Requirements	2

5.2	Technical Dependencies	2

6	Competitive Analyses	2

7	Detailed Specification	3

7.1	Table border calculation	3

7.2	Alignment of borders	3

7.3	Margin calculation	4

7.4	UI changes	4

7.5	Import/export issues	4

7.6	G11n	5

7.7	Error Conditions	5

7.8	Migration	5

8	Future Tasks	5

9	Notes	5

10	References	5

Glossary

Term	Description
Common border segment	The part of the borders of two adjacent table cells, that is common to both of them
Collapsing (table) borders model	Two adjacent table cells have two attributes to define the style of their common border segment. These two attributes are used to determine the style of the common border segment.
Separated (table) borders model	Each table cell has its own borders. Since the cell borders are defined to be inside the cell, they do not interfere with the borders of adjacent table cells.

Motivation

MS Word and Writer have different approaches of how to draw table cell borders. Writer currently uses a border model which is similar to the separated border model known from html, MS Word uses a border model which is similar to the collapsing border model known. To enhance interoperability between these products as well as to lower the threshold for users to migrate to Writer it is mandatory to adapt certain behavior from MS Word and integrate them into Writer.

User Scenarios

The user inserts a 2x2 table in Writer and assigns a solid line with 6pt width to each of the 4 border attributes of the 4 table cells. The result will be a table with double size inner lines, because each table cell has its own borders, which are defined to be inside their cell.

Illustration 1: Writer - All border attributes set to 6pt

The same actions in MS Word will result in a table with the inner lines having the same width like the outer lines, because each adjacent pair of inner lines collapse to one single line:

Illustration 2: MS Word - All border attributes set to 6pt

Goals

Goal of this specification is to enhance the interoperability with MS Word, while documents from previous OpenOffice.org respectively StarOffice version retain their layout.

Requirements and Dependencies

Requirements

An implementation of the collapsing border model in the Writer core, which resembles the border model used in MS Word concerning the table formatting.

The usage of this border model should be individually assignable to each table.

Technical Dependencies

This feature uses the same border painting functions as Calc. These functions paint a line considering the three adjacent lines joining in the start and end point of this line.

The comparison function that determines which of the two adjacent border attributes should be used to define the border style is also common with the one used in Calc.

Competitive Analyses

MS Word uses a table border model, which resembles the collapsing border model concerning the table formatting. In the following example, the first table cell has the lower border attribute set to 6pt green. This gives us a table formatting as if the green line would be at the top of the second row:

Illustration 3: MS Word - Example 1

Note: Only the table formatting considers this 6pt line, it is not painted. Changing the left attribute of cell A1 from 0.5pt black to 3pt black gives the following result:

Illustration 4: MS Word - Example 2

This shows that the formatting of the table cells is done using some kind of collapsing border model, whereas the painting of the table borders follows other rules. With our solution, formatting of table cells and painting their borders will follow the same rules.

Detailed Specification

Table border calculation

Two adjacent table cells can have a common border segment, which in turn has two style attributes, one from each adjacent cell. 'Collapsing' borders means that these two attributes have to be evaluated to determine which of them has to be applied to the common border segment. The main criteria which attribute to use is the line size set in the attribute. In the following example, the red bottom attribute of cell A1 and the blue bottom attribute of B1 both win over the black top attribute of A2. The green top attribute of B2 wins over the blue bottom attribute of B1:

Illustration 5: Writer - Example for border attribute calculation

Changing the cell sizes can give us a different result. The red bottom attribute of A1 wins over the top attributes of A2 and B2. The top attribute of B2 in turn wins over the blue bottom attribute of B1:

Illustration 6: Writer - Example for border attribute calculation

The algorithm to determine which style to use for a common border segment is like follows (see svx/source/dialog/framelink.cxx):

If the two attributes have a different size, we take the attribute with the larger size.

A double line attribute wins over a single line attribute

For two double line attributes, we take the one with the greater distance between the lines

For two single lines, the non-dotted attribute wins.

Alignment of borders

Note that horizontal lines are always aligned top to the lower of the adjacent cells. Vertical lines are centered on the grid lines between the table cells:

Illustration 7: Writer - Alignment of horizontal/vertical borders

Margin calculation

The upper margin of the cells in one row with n cells is given by

Max( Top spacing of cell 1 + Line size at top of cell 1, ..., Top spacing of cell n + Line size at top of cell n )

The lower margin of the cells in one row with n cells is given by

Max( Lower spacing of cell 1, ..., Lower spacing of cell n )

The left/right margin of the cells only depends on their left/right spacing attribute.

UI changes

'Collapsing borders' is a table property and can be set for each table individually.

Import/export issues

The default for new tables will be 'on'. For tables in old documents this setting will be 'off'. For tables in Word/rtf documents this setting will be 'on'.

Illustration 8: UI Mockup

String list

Item	English	German	Comments
FixedLine	Properties	Eigenschaften	
Checkbox	~Merge adjacent line styles	Be~nachbarte Linienstile zusammenführen	

G11n

None

Error Conditions

None

Migration

None

Future Tasks

None

Notes

None

References

Cascading Style Sheets, level 2, CSS2 Specification:
http://www.w3.org/TR/REC-CSS2/tables.html

Collapsing Table Borders

Page 5

http://specs.openoffice.org/writer/compatibility/collapsing_table_borders.sxw

Frank Meies

2004-05-25T08:01:34

Elizabeth Matthis