From 35ddd44a89fe7952bc4780855a1a51a09d804689 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 11 Mar 2012 19:02:12 +0530 Subject: [PATCH] Fix #941134 (LibreOffice 3.5 odt to conversion mobi problem) --- src/odf/odf2xhtml.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/odf/odf2xhtml.py b/src/odf/odf2xhtml.py index df7ce0bc8d..c0537698c4 100644 --- a/src/odf/odf2xhtml.py +++ b/src/odf/odf2xhtml.py @@ -937,8 +937,21 @@ ol, ul { padding-left: 2em; } """ if self.currentstyle is None: # Added by Kovid return + + # Added by Kovid + names = {x[1]:x for x in attrs.iterkeys()} + ignore_keys = set() + if ('margin' in names and 'margin-top' in names and 'margin-left' in + names and 'margin-right' in names and 'margin-bottom' in + names): + # These come from XML and we cannot preserve XML attribute order so + # we assume that margin is to be overriden + # See https://bugs.launchpad.net/calibre/+bug/941134 + ignore_keys.add(names['margin']) + for key,attr in attrs.items(): - self.styledict[self.currentstyle][key] = attr + if key not in ignore_keys: + self.styledict[self.currentstyle][key] = attr familymap = {'frame':'frame', 'paragraph':'p', 'presentation':'presentation',