mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DOCX Input: Fix handling of toggle properties such as bold/italic/strikethrough/etc. when specified as document defaults. Fixes #1548187 [docx conversion to epub and mobi has strikethrough on converted document](https://bugs.launchpad.net/calibre/+bug/1548187)
This commit is contained in:
parent
a1fb9149f0
commit
447d1c547c
@ -189,12 +189,15 @@ class Styles(object):
|
|||||||
if val is not inherit:
|
if val is not inherit:
|
||||||
return val
|
return val
|
||||||
if attr in direct_formatting.toggle_properties:
|
if attr in direct_formatting.toggle_properties:
|
||||||
val = False
|
# The spec (section 17.7.3) does not make sense, so we follow the behavior
|
||||||
for rs in parent_styles:
|
# of Word, which seems to only consider the document default if the
|
||||||
pval = getattr(rs, attr)
|
# property has not been defined in any styles.
|
||||||
if pval is True:
|
vals = [int(getattr(rs, attr)) for rs in parent_styles if rs is not self.default_character_style and getattr(rs, attr) is not inherit]
|
||||||
val ^= True
|
if vals:
|
||||||
return val
|
return sum(vals) % 2 == 1
|
||||||
|
if self.default_character_style is not None:
|
||||||
|
return getattr(self.default_character_style, attr) is True
|
||||||
|
return False
|
||||||
for rs in reversed(parent_styles):
|
for rs in reversed(parent_styles):
|
||||||
rval = getattr(rs, attr)
|
rval = getattr(rs, attr)
|
||||||
if rval is not inherit:
|
if rval is not inherit:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user