Kaydet (Commit) e9c7159b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

writerfilter: Switch according to first letter in getListValue().

This hopefully makes it more bearable for MSVC, and also breaks down the large
data nicely.

Change-Id: Ic3028eb78a5dcca4393738d428b6cf03a3ddbaeb
üst 1ae698ad
...@@ -188,10 +188,38 @@ def idToLabel(idName): ...@@ -188,10 +188,38 @@ def idToLabel(idName):
else: else:
return idName return idName
def appendValueData(values, name, value):
first = name[0:1]
def valueToLabel(value): if not (first in values):
return value.replace('-', 'm').replace('+', 'p').replace(' ', '_').replace(',', '_') values[first] = []
values[first].append([name, value])
def printValueData(values):
if "" in values:
output_else = ""
for i in values[""]:
print(" %sif (rValue == \"%s\") { rOutValue = %s; return true; }" % (output_else, i[0], i[1]))
output_else = "else "
print(" else switch (rValue[0])")
else:
print(" if (rValue.isEmpty())")
print(" return false;")
print(" switch (rValue[0])")
print(" {")
for k in sorted(values.keys()):
if k != "":
print(" case '%s':" % k)
output_else = ""
for i in values[k]:
print(" %sif (rValue == \"%s\") { rOutValue = %s; }" % (output_else, i[0], i[1]))
output_else = "else "
print(" else { return false; }")
print(" return true;")
print(" break;")
print(" }")
def factoryGetListValue(nsNode): def factoryGetListValue(nsNode):
print("""bool OOXMLFactory_%s::getListValue(Id nId, const OUString& rValue, sal_uInt32& rOutValue) print("""bool OOXMLFactory_%s::getListValue(Id nId, const OUString& rValue, sal_uInt32& rOutValue)
...@@ -204,15 +232,14 @@ def factoryGetListValue(nsNode): ...@@ -204,15 +232,14 @@ def factoryGetListValue(nsNode):
for resourceNode in [i for i in getChildrenByName(nsNode, "resource") if i.getAttribute("resource") == "List"]: for resourceNode in [i for i in getChildrenByName(nsNode, "resource") if i.getAttribute("resource") == "List"]:
print(" case %s:" % idForDefine(nsNode, resourceNode)) print(" case %s:" % idForDefine(nsNode, resourceNode))
output_else = "" values = {}
for valueNode in getChildrenByName(resourceNode, "value"): for valueNode in getChildrenByName(resourceNode, "value"):
valueData = "" valueData = ""
if len(valueNode.childNodes): if len(valueNode.childNodes):
valueData = valueNode.childNodes[0].data valueData = valueNode.childNodes[0].data
print(" %sif (rValue == \"%s\") { rOutValue = %s; }" % (output_else, valueData, idToLabel(valueNode.getAttribute("tokenid")))) appendValueData(values, valueData, idToLabel(valueNode.getAttribute("tokenid")))
output_else = "else " printValueData(values)
print(" %s{ return false; }" % (output_else)) print(" return false;")
print(" return true;")
print(" break;") print(" break;")
print(""" default: print(""" default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment