From c01c8b20230ba656a47a81315aea64900c15e712 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:10:07 +0200 Subject: [PATCH] Use iterable for checking difference between Odt paragraph styles --- novelwriter/core/toodt.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/novelwriter/core/toodt.py b/novelwriter/core/toodt.py index 8381c540..8a5b8193 100644 --- a/novelwriter/core/toodt.py +++ b/novelwriter/core/toodt.py @@ -1240,18 +1240,16 @@ class ODTParagraphStyle: ## def checkNew(self, style: ODTParagraphStyle) -> bool: - """Check if there are new settings in refStyle that differ from - those in the current object. + """Check if there are new settings in style that differ from + those in this object. Unset styles are ignored as they can be + inherited from the parent style. """ - for name, (_, aVal) in style._mAttr.items(): - if aVal is not None and aVal != self._mAttr[name][1]: - return True - for name, (_, aVal) in style._pAttr.items(): - if aVal is not None and aVal != self._pAttr[name][1]: - return True - for name, (_, aVal) in style._tAttr.items(): - if aVal is not None and aVal != self._tAttr[name][1]: - return True + if any(v and v != self._mAttr[m][1] for m, (_, v) in style._mAttr.items()): + return True + if any(v and v != self._pAttr[m][1] for m, (_, v) in style._pAttr.items()): + return True + if any(v and v != self._tAttr[m][1] for m, (_, v) in style._tAttr.items()): + return True return False def getID(self) -> str: