Generalise ODT build settings
This commit is contained in:
@@ -150,18 +150,21 @@ class Tokenizer(ABC):
|
||||
|
||||
# User Settings
|
||||
self._textFont = QFont("Serif", 11) # Output text font
|
||||
self._lineHeight = 1.15 # Line height in units of em
|
||||
self._blockIndent = 4.00 # Block indent in units of em
|
||||
self._firstIndent = False # Enable first line indent
|
||||
self._firstWidth = 1.40 # First line indent in units of em
|
||||
self._indentFirst = False # Indent first paragraph
|
||||
self._doJustify = False # Justify text
|
||||
self._doBodyText = True # Include body text
|
||||
self._doSynopsis = False # Also process synopsis comments
|
||||
self._doComments = False # Also process comments
|
||||
self._doKeywords = False # Also process keywords like tags and references
|
||||
self._skipKeywords = set() # Keywords to ignore
|
||||
self._keepBreaks = True # Keep line breaks in paragraphs
|
||||
self._lineHeight = 1.15 # Line height in units of em
|
||||
self._colorHeads = True # Colourise headings
|
||||
self._scaleHeads = True # Scale headings to larger font size
|
||||
self._boldHeads = True # Bold headings
|
||||
self._blockIndent = 4.00 # Block indent in units of em
|
||||
self._firstIndent = False # Enable first line indent
|
||||
self._firstWidth = 1.40 # First line indent in units of em
|
||||
self._indentFirst = False # Indent first paragraph
|
||||
self._doJustify = False # Justify text
|
||||
self._doBodyText = True # Include body text
|
||||
self._doSynopsis = False # Also process synopsis comments
|
||||
self._doComments = False # Also process comments
|
||||
self._doKeywords = False # Also process keywords like tags and references
|
||||
self._skipKeywords = set() # Keywords to ignore
|
||||
self._keepBreaks = True # Keep line breaks in paragraphs
|
||||
|
||||
# Margins
|
||||
self._marginTitle = (1.417, 0.500)
|
||||
@@ -346,6 +349,13 @@ class Tokenizer(ABC):
|
||||
self._lineHeight = min(max(float(height), 0.5), 5.0)
|
||||
return
|
||||
|
||||
def setHeadingStyles(self, color: bool, scale: bool, bold: bool) -> None:
|
||||
"""Set text style for headings."""
|
||||
self._colorHeads = color
|
||||
self._scaleHeads = scale
|
||||
self._boldHeads = bold
|
||||
return
|
||||
|
||||
def setBlockIndent(self, indent: float) -> None:
|
||||
"""Set the block indent between 0.0 and 10.0."""
|
||||
self._blockIndent = min(max(float(indent), 0.0), 10.0)
|
||||
|
||||
@@ -161,8 +161,6 @@ class ToOdt(Tokenizer):
|
||||
|
||||
# Properties
|
||||
self._textFont = QFont("Liberation Serif", 12)
|
||||
self._addColours = False
|
||||
self._scaleHeads = True
|
||||
self._headWeight = "bold"
|
||||
self._headerFormat = ""
|
||||
self._pageOffset = 0
|
||||
@@ -226,10 +224,10 @@ class ToOdt(Tokenizer):
|
||||
self._opaHead12 = None
|
||||
self._colHead34 = None
|
||||
self._opaHead34 = None
|
||||
self._colMetaTx = None
|
||||
self._opaMetaTx = None
|
||||
self._colDialogM = None
|
||||
self._colDialogA = None
|
||||
self._colMetaTx = "#813709"
|
||||
self._opaMetaTx = "100%"
|
||||
self._markText = "#ffffa6"
|
||||
|
||||
return
|
||||
@@ -246,17 +244,6 @@ class ToOdt(Tokenizer):
|
||||
self._dCountry = country or self._dCountry
|
||||
return
|
||||
|
||||
def setHeadingStyles(self, scale: bool, bold: bool) -> None:
|
||||
"""Set plain text style for headings."""
|
||||
self._scaleHeads = scale
|
||||
self._headWeight = self._fontBold if bold else None
|
||||
return
|
||||
|
||||
def setColoursEnabled(self, state: bool) -> None:
|
||||
"""Enable/disable coloured headings and comments."""
|
||||
self._addColours = state
|
||||
return
|
||||
|
||||
def setPageLayout(
|
||||
self, width: int | float, height: int | float,
|
||||
top: int | float, bottom: int | float, left: int | float, right: int | float
|
||||
@@ -295,6 +282,7 @@ class ToOdt(Tokenizer):
|
||||
self._fontStyle = FONT_STYLE.get(self._textFont.style(), "normal")
|
||||
self._fontPitch = "fixed" if self._textFont.fixedPitch() else "variable"
|
||||
self._fontBold = FONT_WEIGHT_MAP.get(fontBold, fontBold)
|
||||
self._headWeight = self._fontBold if self._boldHeads else None
|
||||
|
||||
hScale = self._scaleHeads
|
||||
self._fSizeTitle = f"{round((2.50 if hScale else 1.0) * self._fontSize):d}pt"
|
||||
@@ -331,13 +319,11 @@ class ToOdt(Tokenizer):
|
||||
self._mLeftFoot = self._emToCm(self._marginFoot[0])
|
||||
self._mBotFoot = self._emToCm(self._marginFoot[1])
|
||||
|
||||
if self._addColours:
|
||||
if self._colorHeads:
|
||||
self._colHead12 = "#2a6099"
|
||||
self._opaHead12 = "100%"
|
||||
self._colHead34 = "#444444"
|
||||
self._opaHead34 = "100%"
|
||||
self._colMetaTx = "#813709"
|
||||
self._opaMetaTx = "100%"
|
||||
|
||||
if self._showDialog:
|
||||
self._colDialogM = "#2a6099"
|
||||
|
||||
@@ -114,12 +114,13 @@ class ToQTextDocument(Tokenizer):
|
||||
self.T_HEAD4: (mPx * self._marginHead4[0], mPx * self._marginHead4[1]),
|
||||
}
|
||||
|
||||
hScale = self._scaleHeads
|
||||
self._sHead = {
|
||||
self.T_TITLE: nwHeaders.H_SIZES.get(0, 1.0) * fPt,
|
||||
self.T_HEAD1: nwHeaders.H_SIZES.get(1, 1.0) * fPt,
|
||||
self.T_HEAD2: nwHeaders.H_SIZES.get(2, 1.0) * fPt,
|
||||
self.T_HEAD3: nwHeaders.H_SIZES.get(3, 1.0) * fPt,
|
||||
self.T_HEAD4: nwHeaders.H_SIZES.get(4, 1.0) * fPt,
|
||||
self.T_TITLE: (nwHeaders.H_SIZES.get(0, 1.0) * fPt) if hScale else fPt,
|
||||
self.T_HEAD1: (nwHeaders.H_SIZES.get(1, 1.0) * fPt) if hScale else fPt,
|
||||
self.T_HEAD2: (nwHeaders.H_SIZES.get(2, 1.0) * fPt) if hScale else fPt,
|
||||
self.T_HEAD3: (nwHeaders.H_SIZES.get(3, 1.0) * fPt) if hScale else fPt,
|
||||
self.T_HEAD4: (nwHeaders.H_SIZES.get(4, 1.0) * fPt) if hScale else fPt,
|
||||
}
|
||||
|
||||
self._mText = (mPx * self._marginText[0], mPx * self._marginText[1])
|
||||
@@ -148,7 +149,8 @@ class ToQTextDocument(Tokenizer):
|
||||
self._cText.setForeground(self._theme.text)
|
||||
|
||||
self._cHead = QTextCharFormat(self._cText)
|
||||
self._cHead.setForeground(self._theme.head)
|
||||
self._cHead.setForeground(self._theme.head if self._colorHeads else self._theme.text)
|
||||
self._cHead.setFontWeight(self._bold if self._boldHeads else self._normal)
|
||||
|
||||
self._cComment = QTextCharFormat(self._cText)
|
||||
self._cComment.setForeground(self._theme.comment)
|
||||
@@ -410,7 +412,6 @@ class ToQTextDocument(Tokenizer):
|
||||
bFmt.setBottomMargin(mBottom)
|
||||
|
||||
cFmt = QTextCharFormat(self._cText if hType == self.T_TITLE else self._cHead)
|
||||
cFmt.setFontWeight(self._bold)
|
||||
cFmt.setFontPointSize(self._sHead.get(hType, 1.0))
|
||||
if nHead >= 0:
|
||||
cFmt.setAnchorNames([f"{self._handle}:T{nHead:04d}"])
|
||||
|
||||
Reference in New Issue
Block a user