diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-08-03 20:43:51 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-08-03 20:46:52 +0200 |
commit | e9c7159baf6f09b769e39b4d377d0f115edbf556 (patch) | |
tree | 38946c204ea269af754e3897e6f8ce154c33898e | |
parent | writerfilter: Kill ListValueMap(s) & their construction. (diff) | |
download | core-e9c7159baf6f09b769e39b4d377d0f115edbf556.tar.gz core-e9c7159baf6f09b769e39b4d377d0f115edbf556.zip |
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
-rw-r--r-- | writerfilter/source/ooxml/factoryimpl_ns.py | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py index 6fc955077d91..bf3a8d91580c 100644 --- a/writerfilter/source/ooxml/factoryimpl_ns.py +++ b/writerfilter/source/ooxml/factoryimpl_ns.py @@ -188,10 +188,38 @@ def idToLabel(idName): else: return idName +def appendValueData(values, name, value): + first = name[0:1] -def valueToLabel(value): - return value.replace('-', 'm').replace('+', 'p').replace(' ', '_').replace(',', '_') + if not (first in values): + 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): print("""bool OOXMLFactory_%s::getListValue(Id nId, const OUString& rValue, sal_uInt32& rOutValue) @@ -204,15 +232,14 @@ def factoryGetListValue(nsNode): for resourceNode in [i for i in getChildrenByName(nsNode, "resource") if i.getAttribute("resource") == "List"]: print(" case %s:" % idForDefine(nsNode, resourceNode)) - output_else = "" + values = {} for valueNode in getChildrenByName(resourceNode, "value"): valueData = "" if len(valueNode.childNodes): valueData = valueNode.childNodes[0].data - print(" %sif (rValue == \"%s\") { rOutValue = %s; }" % (output_else, valueData, idToLabel(valueNode.getAttribute("tokenid")))) - output_else = "else " - print(" %s{ return false; }" % (output_else)) - print(" return true;") + appendValueData(values, valueData, idToLabel(valueNode.getAttribute("tokenid"))) + printValueData(values) + print(" return false;") print(" break;") print(""" default: |