diff --git a/novelwriter/formats/todocx.py b/novelwriter/formats/todocx.py index 16772d7a..26336800 100644 --- a/novelwriter/formats/todocx.py +++ b/novelwriter/formats/todocx.py @@ -471,7 +471,7 @@ class ToDocX(Tokenizer): def _generateFootnote(self, key: str) -> ET.Element | None: """Generate a footnote XML object.""" - if self._footnotes.get(key): + if key in self._footnotes: idx = len(self._usedNotes) + 1 run = ET.Element(_wTag("r")) rPr = xmlSubElem(run, _wTag("rPr")) diff --git a/novelwriter/formats/toodt.py b/novelwriter/formats/toodt.py index a6d7f000..45f9074e 100644 --- a/novelwriter/formats/toodt.py +++ b/novelwriter/formats/toodt.py @@ -152,10 +152,8 @@ class ToOdt(Tokenizer): self._autoPara: dict[str, ODTParagraphStyle] = {} # Auto-generated paragraph styles self._autoText: dict[str, ODTTextStyle] = {} # Auto-generated text styles - # Footnotes + # Storage self._nNote = 0 - self._etNotes: dict[str, ET.Element] = {} # Generated note elements - self._errData = [] # List of errors encountered # Properties @@ -405,8 +403,6 @@ class ToOdt(Tokenizer): def doConvert(self) -> None: """Convert the list of text tokens into XML elements.""" - self._result = "" # Not used, but cleared just in case - xText = self._xText for tType, _, tText, tFormat, tStyle in self._blocks: @@ -678,7 +674,6 @@ class ToOdt(Tokenizer): tKey = str(hFmt) if fClass and (color := self._classes.get(fClass)): tKey = f"{tKey}:{fClass}" - if tKey in self._autoText: return self._autoText[tKey].name @@ -1089,16 +1084,6 @@ class ODTParagraphStyle: def name(self) -> str: return self._name - ## - # Checkers - ## - - def isUnaligned(self) -> bool: - """Check if paragraph has any sort of alignment or margins.""" - return all( - self._pAttr[n][1] is None for n in ["text-align", "margin-left", "margin-right"] - ) - ## # Setters ## diff --git a/novelwriter/formats/toqdoc.py b/novelwriter/formats/toqdoc.py index 30ee9337..c65e7a3e 100644 --- a/novelwriter/formats/toqdoc.py +++ b/novelwriter/formats/toqdoc.py @@ -69,7 +69,6 @@ class ToQTextDocument(Tokenizer): self._document.setUndoRedoEnabled(False) self._document.setDocumentMargin(0) - self._styles: dict[int, T_TextStyle] = {} self._usedNotes: dict[str, int] = {} self._init = False @@ -149,13 +148,13 @@ class ToQTextDocument(Tokenizer): # Text Formats # ============ + QtPropLineHeight = QTextBlockFormat.LineHeightTypes.ProportionalHeight + self._blockFmt = QTextBlockFormat() self._blockFmt.setTopMargin(self._mText[0]) self._blockFmt.setBottomMargin(self._mText[1]) self._blockFmt.setAlignment(QtAlignAbsolute) - self._blockFmt.setLineHeight( - 100*self._lineHeight, QTextBlockFormat.LineHeightTypes.ProportionalHeight - ) + self._blockFmt.setLineHeight(100.0*self._lineHeight, QtPropLineHeight) self._charFmt = QTextCharFormat() self._charFmt.setBackground(QtTransparent) @@ -176,7 +175,6 @@ class ToQTextDocument(Tokenizer): for tType, nHead, tText, tFormat, tStyle in self._blocks: - # Styles bFmt = QTextBlockFormat(self._blockFmt) if tType in (BlockTyp.COMMENT, BlockTyp.KEYWORD): bFmt.setTopMargin(self._mMeta[0]) @@ -234,7 +232,7 @@ class ToQTextDocument(Tokenizer): return def saveDocument(self, path: Path) -> None: - """Save the document to a PDF file.""" + """Save the document as a PDF file.""" m = self._pageMargins printer = QPrinter(QPrinter.PrinterMode.PrinterResolution) @@ -366,9 +364,6 @@ class ToQTextDocument(Tokenizer): bFmt.setTopMargin(mTop) bFmt.setBottomMargin(mBottom) - self._cTitle = QTextCharFormat(self._charFmt) - self._cTitle.setFontWeight(self._bold if self._boldHeads else self._normal) - hCol = self._colorHeads and hType != BlockTyp.TITLE cFmt = QTextCharFormat(self._charFmt) cFmt.setForeground(self._theme.head if hCol else self._theme.text) diff --git a/tests/test_formats/test_fmt_toodt.py b/tests/test_formats/test_fmt_toodt.py index ba7946b6..d87d62e9 100644 --- a/tests/test_formats/test_fmt_toodt.py +++ b/tests/test_formats/test_fmt_toodt.py @@ -951,8 +951,6 @@ def testFmtToOdt_ODTParagraphStyle(): assert parStyle._pAttr["text-indent"] == ["fo", None] assert parStyle._pAttr["line-height"] == ["fo", None] - assert parStyle.isUnaligned() is True - parStyle.setMarginTop("0.000cm") parStyle.setMarginBottom("0.000cm") parStyle.setMarginLeft("0.000cm") @@ -967,8 +965,6 @@ def testFmtToOdt_ODTParagraphStyle(): assert parStyle._pAttr["text-indent"] == ["fo", "0.000cm"] assert parStyle._pAttr["line-height"] == ["fo", "1.15"] - assert parStyle.isUnaligned() is False - # Text Alignment assert parStyle._pAttr["text-align"] == ["fo", None] parStyle.setTextAlign("stuff")