Skip to content

Commit

Permalink
Fixed bug in fodt-xml-sax-filter-meta script
Browse files Browse the repository at this point in the history
The filter meta script should not add the xml header to the meta
files.
  • Loading branch information
hakonhagland committed May 20, 2024
1 parent 0309807 commit c7991af
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion parts/meta/sections/automatic-styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:automatic-styles>
<style:style style:name="Table108" style:family="table">
<style:table-properties style:width="16.976cm" fo:margin-left="-0.053cm" table:align="left" style:writing-mode="lr-tb" table:border-model="separating"/>
Expand Down
1 change: 0 additions & 1 deletion parts/meta/sections/font-face-decls.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:font-face-decls>
<style:font-face style:name="StarSymbol" svg:font-family="StarSymbol" style:font-charset="x-symbol"/>
<style:font-face style:name="BernhardMod BT Roman" svg:font-family="&apos;BernhardMod BT Roman&apos;"/>
Expand Down
1 change: 0 additions & 1 deletion parts/meta/sections/master-styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:master-styles>
<style:master-page style:name="Standard" style:page-layout-name="pm1"/>
<style:master-page style:name="First_20_Page" style:display-name="First Page" style:page-layout-name="pm2" draw:style-name="dp1" style:next-style-name="Standard"/>
Expand Down
1 change: 0 additions & 1 deletion parts/meta/sections/meta.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:meta><meta:creation-date>2023-05-18T17:05:55.227000000</meta:creation-date><meta:editing-duration>PT5H27M43S</meta:editing-duration><meta:editing-cycles>23</meta:editing-cycles><meta:generator>LibreOffice/7.0.4.2$Linux_X86_64 LibreOffice_project/00$Build-2</meta:generator><dc:subject>OPM Flow Reference Manual</dc:subject><dc:title>OPEN POROUS MEDIA</dc:title><dc:description>To insert equations with numbing and correct Table layout type
1) eq
2) F3
Expand Down
1 change: 0 additions & 1 deletion parts/meta/sections/scripts.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:scripts>
<office:script script:language="ooo:Basic">
<ooo:libraries xmlns:ooo="http://openoffice.org/2004/office" xmlns:xlink="http://www.w3.org/1999/xlink"/>
Expand Down
1 change: 0 additions & 1 deletion parts/meta/sections/settings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:settings>
<config:config-item-set config:name="ooo:view-settings">
<config:config-item config:name="ViewAreaTop" config:type="long">0</config:config-item>
Expand Down
1 change: 0 additions & 1 deletion parts/meta/sections/styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<office:styles>
<draw:gradient draw:name="Gradient_20_1" draw:display-name="Gradient 1" draw:style="linear" draw:start-color="#000000" draw:end-color="#ffffff" draw:start-intensity="100%" draw:end-intensity="100%" draw:angle="0deg" draw:border="0%"/>
<draw:gradient draw:name="Gradient_20_2" draw:display-name="Gradient 2" draw:style="linear" draw:start-color="#000000" draw:end-color="#ffffff" draw:start-intensity="100%" draw:end-intensity="100%" draw:angle="0deg" draw:border="0%"/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/python/src/fodt/xml_filter_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run_filter(self) -> None:

def filter_file(self, filename: Path) -> None:
parser = xml.sax.make_parser()
handler = PassThroughFilterHandler()
handler = PassThroughFilterHandler(add_header=False)
parser.setContentHandler(handler)
parser.parse(filename)
with open(filename, "w", encoding='utf8') as f:
Expand Down
6 changes: 4 additions & 2 deletions scripts/python/src/fodt/xml_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from fodt.xml_helpers import XMLHelper

class PassThroughFilterHandler(xml.sax.handler.ContentHandler):
def __init__(self) -> None:
def __init__(self, add_header=True) -> None:
self.add_header = add_header
self.content = io.StringIO()
self.start_tag_open = False # For empty tags, do not close with />

Expand All @@ -31,7 +32,8 @@ def get_content(self) -> str:
return self.content.getvalue()

def startDocument(self):
self.content.write(XMLHelper.header)
if self.add_header:
self.content.write(XMLHelper.header)

def startElement(self, name:str, attrs: xml.sax.xmlreader.AttributesImpl):
if self.start_tag_open:
Expand Down

0 comments on commit c7991af

Please sign in to comment.