Move colour theme to Tokenizer class

This commit is contained in:
Veronica Berglyd Olsen
2024-10-22 17:07:57 +02:00
parent 2d8664b3ce
commit e759aa8d1b
16 changed files with 132 additions and 119 deletions
@@ -50,7 +50,7 @@
</w:pPr>
<w:rPr>
<w:b />
<w:color w:val="2a6099" />
<w:color w:val="4271ae" />
<w:sz w:val="48" />
<w:szCs w:val="48" />
</w:rPr>
@@ -65,7 +65,7 @@
</w:pPr>
<w:rPr>
<w:b />
<w:color w:val="2a6099" />
<w:color w:val="4271ae" />
<w:sz w:val="42" />
<w:szCs w:val="42" />
</w:rPr>
@@ -80,7 +80,7 @@
</w:pPr>
<w:rPr>
<w:b />
<w:color w:val="444444" />
<w:color w:val="4271ae" />
<w:sz w:val="36" />
<w:szCs w:val="36" />
</w:rPr>
@@ -95,7 +95,7 @@
</w:pPr>
<w:rPr>
<w:b />
<w:color w:val="444444" />
<w:color w:val="4271ae" />
<w:sz w:val="30" />
<w:szCs w:val="30" />
</w:rPr>
@@ -1,13 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<office:document xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
<office:meta>
<meta:creation-date>2024-10-17T22:22:08</meta:creation-date>
<meta:creation-date>2024-10-22T11:39:53</meta:creation-date>
<meta:generator>novelWriter/2.6a1</meta:generator>
<meta:initial-creator>Jane Smith</meta:initial-creator>
<meta:editing-cycles>1234</meta:editing-cycles>
<meta:editing-duration>P42DT12H34M56S</meta:editing-duration>
<dc:title>Test Project</dc:title>
<dc:date>2024-10-17T22:22:08</dc:date>
<dc:date>2024-10-22T11:39:53</dc:date>
<dc:creator>Jane Smith</dc:creator>
</office:meta>
<office:font-face-decls>
@@ -47,19 +47,19 @@
</style:style>
<style:style style:name="Heading_20_1" style:family="paragraph" style:display-name="Heading 1" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="1" style:class="text">
<style:paragraph-properties fo:margin-top="0.601cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="24pt" fo:font-weight="bold" fo:color="#2a6099" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="24pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_2" style:family="paragraph" style:display-name="Heading 2" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="2" style:class="text">
<style:paragraph-properties fo:margin-top="0.707cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="21pt" fo:font-weight="bold" fo:color="#2a6099" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="21pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_3" style:family="paragraph" style:display-name="Heading 3" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="3" style:class="text">
<style:paragraph-properties fo:margin-top="0.495cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="18pt" fo:font-weight="bold" fo:color="#444444" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="18pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_4" style:family="paragraph" style:display-name="Heading 4" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="4" style:class="text">
<style:paragraph-properties fo:margin-top="0.495cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="15pt" fo:font-weight="bold" fo:color="#444444" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="15pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Header" style:family="paragraph" style:display-name="Header" style:parent-style-name="Header_20_and_20_Footer">
<style:paragraph-properties fo:text-align="right" />
+4 -4
View File
@@ -37,19 +37,19 @@
</style:style>
<style:style style:name="Heading_20_1" style:family="paragraph" style:display-name="Heading 1" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="1" style:class="text">
<style:paragraph-properties fo:margin-top="0.601cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="24pt" fo:font-weight="bold" fo:color="#2a6099" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="24pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_2" style:family="paragraph" style:display-name="Heading 2" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="2" style:class="text">
<style:paragraph-properties fo:margin-top="0.707cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="21pt" fo:font-weight="bold" fo:color="#2a6099" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="21pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_3" style:family="paragraph" style:display-name="Heading 3" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="3" style:class="text">
<style:paragraph-properties fo:margin-top="0.495cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="18pt" fo:font-weight="bold" fo:color="#444444" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="18pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_4" style:family="paragraph" style:display-name="Heading 4" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="4" style:class="text">
<style:paragraph-properties fo:margin-top="0.495cm" fo:margin-bottom="0.212cm" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="15pt" fo:font-weight="bold" fo:color="#444444" loext:opacity="100%" />
<style:text-properties style:font-name="Liberation Serif" fo:font-family="Liberation Serif" fo:font-size="15pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Header" style:family="paragraph" style:display-name="Header" style:parent-style-name="Header_20_and_20_Footer">
<style:paragraph-properties fo:text-align="right" />
@@ -5,12 +5,12 @@
<title>Lorem Ipsum</title>
</head>
<style>
body {font-family: 'Arial'; font-size: 12pt; font-weight: 400; font-style: normal;}
body {color: #000000; font-family: 'Arial'; font-size: 12pt; font-weight: 400; font-style: normal;}
p {text-align: left; line-height: 150%; margin-top: 0.00em; margin-bottom: 0.76em;}
h1 {color: rgb(66, 113, 174); page-break-after: avoid; margin-top: 1.85em; margin-bottom: 0.65em;}
h2 {color: rgb(66, 113, 174); page-break-after: avoid; margin-top: 2.18em; margin-bottom: 0.65em;}
h3 {color: rgb(50, 50, 50); page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}
h4 {color: rgb(50, 50, 50); page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}
h1 {color: #4271ae; page-break-after: avoid; margin-top: 1.85em; margin-bottom: 0.65em;}
h2 {color: #4271ae; page-break-after: avoid; margin-top: 2.18em; margin-bottom: 0.65em;}
h3 {color: #4271ae; page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}
h4 {color: #4271ae; page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}
.title {font-size: 2.5em; margin-top: 1.85em; margin-bottom: 0.65em;}
.sep, .skip {text-align: center; margin-top: 1.30em; margin-bottom: 1.30em;}
a {color: rgb(66, 113, 174);}
@@ -2,17 +2,17 @@
"meta": {
"projectName": "Lorem Ipsum",
"novelAuthor": "lipsum.com",
"buildTime": 1729529369,
"buildTimeStr": "2024-10-21 18:49:29"
"buildTime": 1729590078,
"buildTimeStr": "2024-10-22 11:41:18"
},
"text": {
"css": [
"body {font-family: 'Arial'; font-size: 12pt; font-weight: 400; font-style: normal;}",
"body {color: #000000; font-family: 'Arial'; font-size: 12pt; font-weight: 400; font-style: normal;}",
"p {text-align: left; line-height: 150%; margin-top: 0.00em; margin-bottom: 0.76em;}",
"h1 {color: rgb(66, 113, 174); page-break-after: avoid; margin-top: 1.85em; margin-bottom: 0.65em;}",
"h2 {color: rgb(66, 113, 174); page-break-after: avoid; margin-top: 2.18em; margin-bottom: 0.65em;}",
"h3 {color: rgb(50, 50, 50); page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}",
"h4 {color: rgb(50, 50, 50); page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}",
"h1 {color: #4271ae; page-break-after: avoid; margin-top: 1.85em; margin-bottom: 0.65em;}",
"h2 {color: #4271ae; page-break-after: avoid; margin-top: 2.18em; margin-bottom: 0.65em;}",
"h3 {color: #4271ae; page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}",
"h4 {color: #4271ae; page-break-after: avoid; margin-top: 1.53em; margin-bottom: 0.65em;}",
".title {font-size: 2.5em; margin-top: 1.85em; margin-bottom: 0.65em;}",
".sep, .skip {text-align: center; margin-top: 1.30em; margin-bottom: 1.30em;}",
"a {color: rgb(66, 113, 174);}",
@@ -1,13 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<office:document xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
<office:meta>
<meta:creation-date>2024-10-21T18:49:29</meta:creation-date>
<meta:creation-date>2024-10-22T11:39:52</meta:creation-date>
<meta:generator>novelWriter/2.6a1</meta:generator>
<meta:initial-creator>lipsum.com</meta:initial-creator>
<meta:editing-cycles>45</meta:editing-cycles>
<meta:editing-duration>P0DT0H36M8S</meta:editing-duration>
<dc:title>Lorem Ipsum</dc:title>
<dc:date>2024-10-21T18:49:29</dc:date>
<dc:date>2024-10-22T11:39:52</dc:date>
<dc:creator>lipsum.com</dc:creator>
</office:meta>
<office:font-face-decls>
@@ -47,19 +47,19 @@
</style:style>
<style:style style:name="Heading_20_1" style:family="paragraph" style:display-name="Heading 1" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="1" style:class="text">
<style:paragraph-properties fo:margin-top="0.784cm" fo:margin-bottom="0.276cm" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="24pt" fo:font-weight="bold" fo:color="#2a6099" loext:opacity="100%" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="24pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_2" style:family="paragraph" style:display-name="Heading 2" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="2" style:class="text">
<style:paragraph-properties fo:margin-top="0.922cm" fo:margin-bottom="0.276cm" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="21pt" fo:font-weight="bold" fo:color="#2a6099" loext:opacity="100%" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="21pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_3" style:family="paragraph" style:display-name="Heading 3" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="3" style:class="text">
<style:paragraph-properties fo:margin-top="0.646cm" fo:margin-bottom="0.276cm" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="18pt" fo:font-weight="bold" fo:color="#444444" loext:opacity="100%" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="18pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Heading_20_4" style:family="paragraph" style:display-name="Heading 4" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="4" style:class="text">
<style:paragraph-properties fo:margin-top="0.646cm" fo:margin-bottom="0.276cm" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="15pt" fo:font-weight="bold" fo:color="#444444" loext:opacity="100%" />
<style:text-properties style:font-name="Arial" fo:font-family="Arial" fo:font-size="15pt" fo:font-weight="bold" fo:color="#4271ae" loext:opacity="100%" />
</style:style>
<style:style style:name="Header" style:family="paragraph" style:display-name="Header" style:parent-style-name="Header_20_and_20_Footer">
<style:paragraph-properties fo:text-align="right" />
+12 -6
View File
@@ -27,6 +27,8 @@ from shutil import copyfile
import pytest
from PyQt5.QtGui import QColor
from novelwriter.common import xmlIndent
from novelwriter.constants import nwHeadFmt
from novelwriter.core.project import NWProject
@@ -1106,11 +1108,15 @@ def testFmtToOdt_ODTParagraphStyle():
assert parStyle._tAttr["color"] == ["fo", None]
assert parStyle._tAttr["opacity"] == ["loext", None]
parStyle.setColour("#000000")
parStyle.setOpacity("1.00")
parStyle.setColour(QColor(0, 0, 0, 128))
assert parStyle._tAttr["color"] == ["fo", "#000000"]
assert parStyle._tAttr["opacity"] == ["loext", "1.00"]
assert parStyle._tAttr["opacity"] == ["loext", "50%"]
parStyle.setColour(None)
assert parStyle._tAttr["color"] == ["fo", None]
assert parStyle._tAttr["opacity"] == ["loext", None]
# Pack XML
# ========
@@ -1124,7 +1130,7 @@ def testFmtToOdt_ODTParagraphStyle():
'fo:margin-left="0.000cm" fo:margin-right="0.000cm" fo:text-indent="0.000cm" '
'fo:line-height="1.15" />'
'<style:text-properties style:font-name="Verdana" fo:font-family="Verdana" '
'fo:font-size="12pt" fo:color="#000000" loext:opacity="1.00" />'
'fo:font-size="12pt" />'
'</style:style>'
'</test>'
)
@@ -1151,8 +1157,8 @@ def testFmtToOdt_ODTParagraphStyle():
aStyle = ODTParagraphStyle("test")
oStyle = ODTParagraphStyle("test")
aStyle.setColour("#000000")
oStyle.setColour("#111111")
aStyle.setColour(QColor(0, 0, 0))
oStyle.setColour(QColor(42, 42, 42))
assert aStyle.checkNew(oStyle) is True
assert aStyle.getID() != oStyle.getID()
+2 -2
View File
@@ -27,8 +27,8 @@ from PyQt5.QtGui import QTextBlock, QTextCharFormat, QTextCursor
from novelwriter import CONFIG
from novelwriter.constants import nwUnicode
from novelwriter.core.project import NWProject
from novelwriter.formats.shared import BlockFmt, BlockTyp
from novelwriter.formats.toqdoc import TextDocumentTheme, ToQTextDocument
from novelwriter.formats.shared import BlockFmt, BlockTyp, TextDocumentTheme
from novelwriter.formats.toqdoc import ToQTextDocument
from novelwriter.types import (
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
QtPageBreakAfter, QtTransparent, QtVAlignNormal, QtVAlignSub, QtVAlignSuper