kogmbh/WebODF — pull request #25 by kossebau (2013-09-26 23:17:55+00:00)
Title: Properly load and save font-face declarations, to some degree at least

While seeing to fix #16 the TODOs for proper merging and splitting up of the font-face declarations on loading and saving came into my way. Because I found that using fonts in automatic styles (e.g. by direct styling of the used font) was lost when opening the file in LO.

This is a first innocent approach to solve it. The documents I tested from other ODF producers like LO usually had equal font-faces declared in their styles.xml and content.xml, so other than with the automatic styles it made sense to try to merge them, instead of prefixing the name=identifier. Some fallback code was added for the case of conflicts with the same name but different properties, but that was just for safety, I had no such sample in my test documents where that was needed.

Grepping for the font-face declaration referrers in the style elements surely can be improved (xpath perhaps?), but should be better than nothing for now.

Any unused font-face declarations will be dropped on saving, there is no need to keep them, especially if the document will be opened on another system with a different of system fonts. This still needs some check if that does conflict with unused but embedded fonts, did not investigate in that direction yet.

Possibly there is some issue with the way how new font-face declarations are generated if a so far unused system font is selected for use in a style. But that is topic different from this.