summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-07-01 17:49:28 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-01 18:03:45 +0200
commit63cd667ccb35325a973cf4f98c5e1bf9db92b9b4 (patch)
tree98e1f7f68c78407685b989da7278a83000ff2f4b
parent9263b101c39172cbcf04189c515bca80cb15f3aa (diff)
writerfilter: characters() may be called multiple times for a single token
Change-Id: Icdd3dc7740c5f3d82a45b2553fda65c6010ea4e4
-rw-r--r--writerfilter/source/ooxml/fasttokens.py8
-rw-r--r--writerfilter/source/ooxml/gperffasttokenhandler.py8
2 files changed, 12 insertions, 4 deletions
diff --git a/writerfilter/source/ooxml/fasttokens.py b/writerfilter/source/ooxml/fasttokens.py
index a36425204bb7..bcd0329bfe05 100644
--- a/writerfilter/source/ooxml/fasttokens.py
+++ b/writerfilter/source/ooxml/fasttokens.py
@@ -16,6 +16,7 @@ class ContentHandler(xml.sax.handler.ContentHandler):
def __init__(self):
self.inFasttoken = False
self.counter = 0
+ self.chars = []
def startElement(self, name, attrs):
if name == "fasttoken":
@@ -23,12 +24,15 @@ class ContentHandler(xml.sax.handler.ContentHandler):
def endElement(self, name):
if name == "fasttoken":
+ chars = "".join(self.chars)
+ print("const Token_t OOXML_%s = %s;" % (chars.replace('-', '_'), self.counter))
+ self.chars = []
+ self.counter += 1
self.inFasttoken = False
def characters(self, characters):
if self.inFasttoken:
- print("const Token_t OOXML_%s = %s;" % (characters.replace('-', '_'), self.counter))
- self.counter += 1
+ self.chars.append(characters)
print("""
/*
diff --git a/writerfilter/source/ooxml/gperffasttokenhandler.py b/writerfilter/source/ooxml/gperffasttokenhandler.py
index 103a9444e332..4fa34e796fad 100644
--- a/writerfilter/source/ooxml/gperffasttokenhandler.py
+++ b/writerfilter/source/ooxml/gperffasttokenhandler.py
@@ -15,6 +15,7 @@ import sys
class ContentHandler(xml.sax.handler.ContentHandler):
def __init__(self):
self.inFasttoken = False
+ self.chars = []
def startElement(self, name, attrs):
if name == "fasttoken":
@@ -22,12 +23,15 @@ class ContentHandler(xml.sax.handler.ContentHandler):
def endElement(self, name):
if name == "fasttoken":
+ chars = "".join(self.chars)
+ token = chars.replace('-', '_')
+ print("%s, OOXML_%s" % (token, token))
+ self.chars = []
self.inFasttoken = False
def characters(self, characters):
if self.inFasttoken:
- token = characters.replace('-', '_')
- print("%s, OOXML_%s" % (token, token))
+ self.chars.append(characters)
print("""
%{