Writer/MSInteroperability/PageBorder
Contents
Overall Description
Page border is a very common function for text document applications. Thus, both MS Office Word and Apache OpenOffice gave the similar function on supporting page border. But, as the page border corresponding data model is not the same in the two applications, there exist some MSO word document related interoperability issues on such page border area.
Descriptions of Main Problems
By following below steps, we can reproduce the page border interoperability issue:
- Run Apache OpenOffice Writer and new a text document;
- Right click on the page area;
- Choose the item “Page...” in the context menu;
- In the “Page Style” dialog, switch to tab page “Border”;
- On the top-left corner of the tab page, select icon for setting borders “Set All Four Borders”;
- On the top right corner of the tab page, input some value, such as “2.5 cm”, in any item inside “Spacing to contents”;
- Press button “OK” on the dialog;
- Save the document into a MSO Word Doc 2003 binary format file;
- Reopen the file in Apache OpenOffice or MS Word;
Result: The page border is changed;
Problem Investigation
Before we touch deeper inside of the root cause, we shall have a general overview of the different implementation and design of page border in MSO Word and Apache OpenOffice.
As the coordination unit using in MSO Word and Apache OpenOffice are different, we need to give the conversion formula between Centimeter(CM) and Point(Pt) as below:

Use case In Apache OpenOffice
Inside Apache OpenOffice, such page border corresponding function is separated into 2 related parts.
The first one is the “Page Margin”, which actually defined the distance between the page edge and the page border; We named the distance of “Page Margin” as value APM;
The second one is the “Border Margin”, which actually defined the distance between the page border and the page content area; We named the distance of “Border Margin” as value ABM;
The model Apache OpenOffice is following here is the one specified in the OpenDocument file format standard (ODF) which based here on XSL-FO and CSS - namely the CSS box model.
Following Illustration show us both said values in Apache OpenOffice Writer:

Following Illustration shows us the page margin setting inside Apache OpenOffice Writer:

Following Illustration shows us the border margin setting inside Apache OpenOffice Writer:

More specifications, the value of both ABM and APM must be positive:

Use case in MSO Word
Similarly, MSO Word also involved 2 properties for recording the page border settings. But the exactly definition of said 2 properties are different from Apache OpenOffice Writer.
The first one is the page margin, which actually define the distance between the page edge and the page content area; We named the value as MPM;
The second data is the border margin, which is defined distance between the page border and the page edge or, the page content area, We named the value as MBM. Such value could be alternated via specified UI settings. We named the value of MBM as MBM1, if the MBM indicate the distance between page border and the page edge, or as MBM2, if the MBM indicate the distance between the page border and the page content area;
Following 2 Illustrations describe the definition of all above values:


Following Illustration show us the setting of MPM in MSO word:

The setting of MBM in MSO Word is little more complex. First we need to enable the page border as following Illustration described:

Second, inside the same dialog, we need to click button “Options...” for further customizing. following Illustration show us the setting of MBM1 in MSO Word

As above Illustration shown, the MBM indicates to the distance between the page border and the page edge, which means MBM equals to MBM1;
Following Illustration show us the setting MBM2 in MSO Word:

As the above Illustration shown, the MBM indicates to the distance between the page border and the page content area, which means MBM equals to MBM2;
If assign a value greater than 31 Pt, when setting the value of MBM1 or MBM2 in MSO Word, we will get a warning message like following Illustration:

Which actually means, both MBM1 and MBM2 should be positive, and less than 32 pt, and MPM should be positive:


Design of Mapping
Follow the investigation above, we know that the mapping work between the properties inside Apache OpenOffice and MSO Word on said page border interoperability should like below:
For the page border interoperability of MS Word importing
In the MS Word importing process, the value of MPM and MBM is the known ones. The mapping work should be:


More specifications, in the MSO Word importing process, the first consideration of such set of page border corresponding properties is to keep the distance between page edge and page print area, which actually indicated by the value of MPM, on some other word, the value of APM+ABM will be guaranteed anyway. Here we named such guarantee as “The Importing First Rule”, or “TIFR” in abbreviation.
After the TFR, the importing process also need to consider the available value range of APM and ABM, which should be guaranteed to be greater than 0 anyway. We named this guarantee as “The Importing Second Rule”, or “TISR” in abbreviation.
For the page border interoperability of MS Word exporting
In the MS Word importing process, the value of APM and ABM is the known ones. The mapping work should be:

Similar to the MSO Word document importing process, there are some kind of preferred restrictions inside MSO Word document exporting process. The first one is that, as we need to guarantee the value of MBM is less than 32, we need to set the MBM type depend on that which value is less than 32 Pt,of ABM and APM. We named this rule as “The Exporting First Rule”, or “TEFR” in abbreviation.
Theoretical Limitations of the Design
As there are additional conditions of the TIFR, TISR, TEFR, APM, ABM, MPM and MBM, the mapping design has its owned limitation in theory as below:
Limitation on MS Word importing

Limitation on MS Word Exporting

The Current Support Status of Page Border Interoperability
Following parts indicate the sample cases that Apache already supported, could supported and can not supported:
MSO Word Document Importing
Actually, the most concerning stuff in the MSO Word Document importing process is that, whether the MPM is greater than MBM or not. So the following presented cases will be separated into 2X2 groups:
MBM=MBM1 | MBM=MBM2 | |
MPM > MBM | Importing Case 1 | Importing Case 2 |
MPM < MBM | Importing Case 3 | Importing Case 4 |
Importing case 1:
Key Point of Case | MPM greater than MBM1 |
MPM Value | 3 CM |
MBM Type | MBM1 |
MBM Value | 1 CM |
APM | MBM=1 CM |
ABM | MPM-MBM= 2 CM |
Currently Supportable | YES |
Issue Type | N/A |
Comments | Refer to following Illustration for interoperability result |

Importing case 2:
Key Point of Case | MPM greater than MBM2 |
MPM Value | 3 CM |
MBM Type | MBM2 |
MBM Value | 1 CM |
APM | MPM-MBM= 2 CM |
ABM | MBM=1 CM |
Currently Supportable | YES |
Issue Type | N/A |
Comments | Refer to following Illustration for interoperability result |

Importing case 3:
Key Point of Case | MPM less than MBM1 |
MPM Value | 0.5 CM |
MBM Type | MBM1 |
MBM Value | 1 CM |
APM+ABM | MPM=0.5 CM |
APM | MBM=1 CM(Follow TIFR, changed to 0.5 CM) |
ABM | MPM-MBM= -0.5 CM (Follow TISR, changed to 0 CM) |
Currently Supportable | NO, and can not be supported |
Issue Type | Feature Difference |
Comments | Refer to following Illustration for interoperability result |

Importing case 4:
Key Point of Case | MPM less than MBM2 |
MPM Value | 0.5 CM |
MBM Type | MBM2 |
MBM Value | 1 CM |
APM+ABM | 0.5 CM (Changed to 1 CM incorrectly) |
APM | MPM-MBM= -0.5 CM (Follow the TISR, changed to 0 CM) |
ABM | MBM=1 CM |
Currently Supportable | NO, may partly refined |
Issue Type | Feature Difference/Defect (Disobey TIFR) |
Comments | Refer to following Illustration for interoperability result |

MSO Word Document Exporting
On the other hand, the MSO word Document exporting has others concerning points: the available value range of MBM, whatever its type is. The Illustration 15 show us said available range in a MSO Word:

As we can see, inside the illustration 15, the inner blue zone is the available range for MBM2; The outer blue zone is the available range for MBM1, the dark red zone between said 2 zones, is the totally in-available range for MBM. Based on this situation, we should separate the MSO Word Exporting sample cases into following 2X2 groups:
ABM <= 31 Pt | ABM > 31 Pt | |
APM <= 31 Pt | Exporting Case 1 | Exporting Case 2 |
APM > 31 Pt | Exporting Case 3 | Exporting Case 4 |
Exporting case 1:
Key Point of Case | ABM <= 31 Pt, APM <= 31 Pt |
APM | 1 CM < 31 Pt |
ABM | 1 CM < 31 Pt |
MPM | ABM+APM = 2 CM |
MBM Type | MBM2 |
MBM Value | ABM = 1 CM |
Currently Supportable | YES |
Issue Type | N/A |
Comments | Refer to following Illustration for interoperability result |

Exporting case 2:
Key Point of Case | APM <= 31 Pt, ABM > 31 Pt |
APM | 1 CM < 31 Pt |
ABM | 2 CM > 31 Pt |
MPM | ABM+APM = 3 CM |
MBM Type | MBM1(Using MBM2 incorrectly) |
MBM Value | ABM = 1 CM (Using the available greatest value 31 Pt incorrectly) |
Currently Supportable | NO, and Solvable |
Issue Type | Defect, Disobey TEFR |
Comments | Refer to following Illustration for interoperability result |

Exporting case 3:
Key Point of Case | ABM <= 31 Pt, APM > 31 Pt |
APM | 2 CM > 31 Pt |
ABM | 1 CM < 31 Pt |
MPM | ABM+APM = 3 CM |
MBM Type | MBM2 |
MBM Value | ABM = 1 CM |
Currently Supportable | YES |
Issue Type | N/A |
Comments | Refer to following Illustration for interoperability result |

Exporting case 4:
Key Point of Case | APM > 31 Pt, ABM > 31 Pt |
APM | 2 CM > 31 Pt |
ABM | 2 CM > 31 Pt |
MPM | ABM+APM = 4 CM |
MBM Type | MBM2 (There is no fit-able type for this condition) |
MBM Value | ABM = 2 CM (Using the available greatest value 31 Pt incorrectly) |
Currently Supportable | NO, and can not be supported |
Issue Type | Feature Difference |
Comments | Refer to following Illustration for interoperability result |

Proposal Solution
Issues Statistic
Use Cases | Has Issue | Feature Difference | Defect |
Importing Case 1 | NO | N/A | N/A |
Importing Case 2 | NO | N/A | N/A |
Importing Case 3 | YES | YES | NO |
Importing Case 4 | YES | YES | YES |
Exporting Case 1 | NO | N/A | N/A |
Exporting Case 2 | YES | YES | YES |
Exporting Case 3 | NO | N/A | N/A |
Exporting Case 4 | YES | YES | NO |
The good news is that, more than half of the use cases working correctly, including importing case 1, 2 and exporting case 1, 3, which are marked as green background in the above statistic table.
The “Feature Difference” typed issues, including importing case 3 and exporting case 4, which are marked as gray background in the above statistic table, seems can not be fixed in AOO Writer, or even should not be fixed for some design reason. For inside AOO, the page border stuff is designed as a surrounding rectangle of page content area, and inside the page edge, which means, the size of page border shall contain the page content area, and be contained inside the page edge rectangle. Inside the available size range, AOO has no further limitation on the page border settings. So based the page border design of AOO, it is not reasonable that give the complete comparability of page border properties inside MSO Word 2003 format.
So currently, the issues should and could be fixed, are the ones marked as Defect type, which indicate to importing case 4 and exporting case 2. which was marked as orange background in the above statistic table.
Suggested Solution For Importing Case 4
The most important work on solving the defect issue inside importing case 4 is that, following TISR, which means keeping the distance between the page edge and page content area. Refer the following table for the detailed solution:
Table of Detailed Solution
Check Point | Ideal Value | Current Value | Refined Value |
APM | MPM-MBM = -0.5 CM | 0 CM, Follow TISR | 0 CM, Follow TISR |
ABM | MBM2 = 1 CM | 1 CM | 0.5 CM, Follow TIFR |
APM+ABM | MPM = 0.5 CM | 1 CM | 0.5 CM, Follow TIFR |
TIFR | N/A | Not Followed | Followed |
TISR | N/A | Followed | Followed |
Suggested Solution For Exporting Case 2
The current issue of page border exporting into MSO Word 2003 binary format is that,AOO only supply 1 way for exporting the MBM type: as the MBM2. So the key point on solving the defect issue inside exporting case 2 is that, following TEFR, which actually means giving AOO the capability on exporting MBM, as MBM1, and the corresponding mechanism on verifying which type should be used, based on the value of ABM and APM. Refer the following table for the detailed solution:
Table of Detailed Solution
Check Point | Ideal Value | Current Value | Refined Value |
MPM | ABM+APM = 3 CM | 3 CM | 3 CM |
MBM Type | MBM1 | MBM2 | MBM1 |
MBM Value | APM = 28 Pt = 1 CM | 31 Pt | 28 Pt |
TEFR | N/A | Not Followed | Followed |