10.3.2 Discussion and exercise

In the example above, we have only one type of Document and a single StandardTemplate. We may of course have defined several subclasses of Document and Template. Most publishers, professional societies, etc., have their own document and template formats. For MS Word and LaTex there are numerous possibilities depending on the use of the document.

As mentioned, the above text formatter is very simple. If you consider at system like MS Word, it contains a large number of options for formating a given document. This includes fonts and font families – class Style may be extended to include a font, a font size, etc. A Paragraph may include how it is to be adjusted. A Document may have a size (A4, US Letter, …) and it may have a page orientation (landscape or portrait). 

In MS Word it is possible to change the template of a given document. This implies that there must be a procedure/algorithm for converting the style of each paragraph to a similar style in the new tempalte. In MS Word this is mainly done by selecting a style of the same name.

It is a major task to develop a text system that resembles MS Word. The above classes may be extended to some extent, but it is unlikely that the structure of these classes may expand into something like MS Word.

Exercise

Add methods that generate a HTML-document from the content of a Document object.