Compatibility flags in LO allow multiple layout choices to help display documents similar to the way other competing programs do it. I find it hard to wrap my head around everything to consider, so I'm writing it down here to help get a handle on it. (I'm familiar with doing this for DOC/DOCX/RTF.)
See bug 138544 for the additional complication of a switch to "disable loading user settings from the document."
Scenarios to consider
I'm going to use tabOverflow from bug 142404 as my example. In this case, not only was a compatibility flag introduced to handle a Microsoft way of handling tabs that go over the end margin, but it also adjusted the operation of LibreOffice itself. So here are some aspects to consider:
- ODT import: when the compat setting is not specified, make sure it uses the old behaviour. (See sw/source/filter/xml/xmlimp.cxx SwXMLImport::SetConfigurationSettings)
- ODT export: the current settings are always saved - but ONLY in ODT formats - not DOC/DOCX/RTF.
- non-ODT import: the appropriate compat flag needs to be set only if it differs from the default.
- non-ODT export: irrelevant. (Well, it might have its own set of compatibility flags, but that is separate from LO flags.) [Different values may need to be exported for certain objects in order to emulate the intended behaviour.]
So then, there are basically two main reasons for creating a compatibility flag.
- to change the behaviour of LO itself. This is basically irrelevant for non-ODT formats, and is either done to fix a wrong implementation, or to change LibreOffice to conform more to MS Office in order to minimize the pain of switching between formats.
- to add the ability to display a foreign document better. The import filter would set the compat flag. If the document is ever saved into ODT format, then the compat setting is automatically saved as well.
Well, that all seems simple and straight-forward. Why does it always seem more complicated in real life?
- Each foreign format has its own way of handling compatibility. The same logic applies, but it causes compat flags to multiply.
- The user has the ability to change the system default for some flags. (Options - LibreOffice Writer - compatibility, etc.)
- There is a flag to turn off loading the user-settings from a document. (Options - Load/Save - General)
- Although there are fairly standard places to handle compat settings, sometimes new ways are invented and scattered through the code.
Settings to include in a new template
The absence of these properties indicates old behaviour should be used. (See sw/source/filter/xml/xmlimp.cxx SwXMLImport::SetConfigurationSettings)
- PrinterIndependentLayout (high-resolution)
- AddExternalLeading (true)
- UseFormerLineSpacing (false)
- UseFormerObjectPositioning (false)
- UseOldNumbering (false)
- AddParaSpacingToTableCells (true)
- AddParaLineSpacingToTableCells (true)
- UseFormerTextWrapping (false)
- This primarily causes wrapping in the body text around objects that spill out of the header. Rather important.
- ConsiderTextWrapOnObjPos (false) - the default, but it's absence causes other pre-S08 changes.
- UnxForceZeroExtLeading (false)
- SmallCapsPercentage66 (false)
- Small caps are now at 80% size instead of 66%.
- TabOverflow (true)
- PropLineSpacingShrinksFirstLine (true)
- SubtractFlysAnchoredAtFlys (false)
- EmptyDbFieldHidesPara (true)
- CollapseEmptyCellPara (true)