[Libreoffice-commits] core.git: 2 commits - writerfilter/source
Jan Holesovsky
kendy at collabora.com
Tue Aug 5 05:02:09 PDT 2014
writerfilter/source/ooxml/factoryimpl_ns.py | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
New commits:
commit 9b64eed1e58e57d08b5f02fdbd2a69b55a8132af
Author: Jan Holesovsky <kendy at collabora.com>
Date: Tue Aug 5 12:51:18 2014 +0200
writerfilter: Use if's in ::attributeAction's instead of switches.
This only improves readability, otherwise the code size is exactly the same.
[And there is only one place where we are checking for 2 values - case
NN_wml|DEFINE_CT_FtnEdn: in OOXMLFactory_wml.cxx.]
Change-Id: Id6dc6b0cdd0e42f2215e978e1d4d91472969bbb8
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index 467bbfc..cfcd30f 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -602,12 +602,13 @@ def factoryAttributeActionDefineInner(nsNode, defineNode):
defineName = defineNode.getAttribute("name")
block = []
+ output_else = ""
for resourceNode in [i for i in getChildrenByName(nsNode, "resource") if i.getAttribute("name") == defineName]:
for attributeNode in getChildrenByName(resourceNode, "attribute"):
if attributeNode.hasAttribute("action"):
- block.append(" case %s:" % fastToken(attributeNode))
+ block.append(" %sif (nToken == static_cast<Token_t>(%s))" % (output_else, fastToken(attributeNode)))
block.append(" pHandler->%s(pValue);" % attributeNode.getAttribute("action"))
- block.append(" break;")
+ output_else = "else "
if len(block):
resource = ""
for resourceNode in [i for i in getChildrenByName(nsNode, "resource") if i.getAttribute("name") == defineName]:
@@ -615,13 +616,7 @@ def factoryAttributeActionDefineInner(nsNode, defineNode):
break
ret.append(" {")
ret.append(" OOXMLFastContextHandler%s* pHandler = dynamic_cast<OOXMLFastContextHandler%s*>(_pHandler);" % (resource, resource))
- ret.append("")
- ret.append(" switch (nToken)")
- ret.append(" {")
ret.extend(block)
- ret.append(" default:")
- ret.append(" break;")
- ret.append(" }")
ret.append(" }")
return ret
commit d9ce700a817c7b7c7d5515b34dadf0d0bcd61bd2
Author: Jan Holesovsky <kendy at collabora.com>
Date: Tue Aug 5 12:29:00 2014 +0200
writerfilter: Make the generated ::attributeAction's readable.
Change-Id: I8461c374841ebd98d5767469ab2d931a2854921e
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index bf3a8d9..467bbfc 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -605,24 +605,24 @@ def factoryAttributeActionDefineInner(nsNode, defineNode):
for resourceNode in [i for i in getChildrenByName(nsNode, "resource") if i.getAttribute("name") == defineName]:
for attributeNode in getChildrenByName(resourceNode, "attribute"):
if attributeNode.hasAttribute("action"):
- block.append("case %s:" % fastToken(attributeNode))
- block.append(" pHandler->%s(pValue);" % attributeNode.getAttribute("action"))
- block.append(" break;")
+ block.append(" case %s:" % fastToken(attributeNode))
+ block.append(" pHandler->%s(pValue);" % attributeNode.getAttribute("action"))
+ block.append(" break;")
if len(block):
resource = ""
for resourceNode in [i for i in getChildrenByName(nsNode, "resource") if i.getAttribute("name") == defineName]:
resource = resourceNode.getAttribute("resource")
break
- ret.append("{")
- ret.append(" OOXMLFastContextHandler%s* pHandler = dynamic_cast<OOXMLFastContextHandler%s*>(_pHandler);" % (resource, resource))
+ ret.append(" {")
+ ret.append(" OOXMLFastContextHandler%s* pHandler = dynamic_cast<OOXMLFastContextHandler%s*>(_pHandler);" % (resource, resource))
ret.append("")
- ret.append(" switch (nToken)")
- ret.append(" {")
+ ret.append(" switch (nToken)")
+ ret.append(" {")
ret.extend(block)
- ret.append(" default:")
- ret.append(" break;")
- ret.append(" }")
- ret.append("}")
+ ret.append(" default:")
+ ret.append(" break;")
+ ret.append(" }")
+ ret.append(" }")
return ret
More information about the Libreoffice-commits
mailing list