Bug 132320 - writerfilter/source/ooxml/factoryimpl_ns.py:402: undefined name 'defineNode'
Summary: writerfilter/source/ooxml/factoryimpl_ns.py:402: undefined name 'defineNode'
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.0.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:7.0.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2020-04-22 09:08 UTC by Xisco Faulí
Modified: 2020-05-05 07:19 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2020-04-22 09:08:33 UTC
This is a follow-up of bug 132293 comment 4:

When considering the method:
    398 def charactersActionForValues(nsNode, refNode):
    399     ret = []
    400 
    401     refName = refNode.getAttribute("name")
    402     for defineNode in [i for i in getChildrenByName(getChildByName(nsNode, "grammar"), "define") if defineNode.getAttribute("name") == refName]:
    403         ret.append("    {")
    404         ret.append("    // %s" % defineNode.getAttribute("name"))
    405         for dataNode in getChildrenByName(defineNode, "data"):
    406             if dataNode.getAttribute("type") == "int":
    407                 ret.append("    OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(sText));")
    408                 ret.append("    pValueHandler->setValue(pValue);")
    409         ret.append("    }")
    410 
    411     return ret
(see https://opengrok.libreoffice.org/xref/core/writerfilter/source/ooxml/factoryimpl_ns.py?r=c4fa6efa#398)

since line 402 is wrong, it's quite possible we never enter the loop so the expected code to generate may never be generated.
It might be a source of bugs. I insist to tell "it might" since I must recognize I don't really know if it's the case or not.
Remark: I'm not sure too that generating C++ code from Python, Perl whatever is a good thing since it's less easy to debug/maintain. IMHO, this part should be converted in C++ but that's another story.
Comment 1 Xisco Faulí 2020-04-22 09:12:30 UTC
Introduced by:

author	Miklos Vajna <vmiklos@collabora.co.uk>	2014-07-27 17:46:42 +0200
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2014-07-27 17:46:42 +0200
commit 821ab16a1fb0353397914131ab559685d12b92b7 (patch)
tree dd2ad806bc996322e515366f5bd2e8b0a46546d7
parent 21977778168af134e7f72afcc07ff5062324a19d (diff)
writerfilter: convert factoryimpl_ns to Python

Adding Cc: to Miklos Vajna
Comment 2 Miklos Vajna 2020-04-22 09:39:43 UTC
I'll take a look.
Comment 3 Julien Nabet 2020-04-22 09:42:35 UTC
I think this patch should make it:
diff --git a/writerfilter/source/ooxml/factoryimpl_ns.py b/writerfilter/source/ooxml/factoryimpl_ns.py
index 35fdadfd3a9d..db06cf1c9218 100644
--- a/writerfilter/source/ooxml/factoryimpl_ns.py
+++ b/writerfilter/source/ooxml/factoryimpl_ns.py
@@ -399,7 +399,7 @@ def charactersActionForValues(nsNode, refNode):
     ret = []
 
     refName = refNode.getAttribute("name")
-    for defineNode in [i for i in getChildrenByName(getChildByName(nsNode, "grammar"), "define") if defineNode.getAttribute("name") == refName]:
+    for defineNode in [i for i in getChildrenByName(getChildByName(nsNode, "grammar"), "define") if i.getAttribute("name") == refName]:
         ret.append("    {")
         ret.append("    // %s" % defineNode.getAttribute("name"))
         for dataNode in getChildrenByName(defineNode, "data"):

but I let you check.
Comment 4 Commit Notification 2020-05-05 07:07:27 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/62ba3248f654febe55fdf422163fff76552e9c32

tdf#132320 writerfilter: fix typo in factoryimpl_ns.py

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Miklos Vajna 2020-05-05 07:13:07 UTC
(In reply to Julien Nabet from comment #3)
> I think this patch should make it:

Oh sorry, I didn't notice this before pushing my patch. The upside is that you suggested the same. :-) Thanks.
Comment 6 Julien Nabet 2020-05-05 07:19:37 UTC
(In reply to Miklos Vajna from comment #5)
> (In reply to Julien Nabet from comment #3)
> > I think this patch should make it:
> 
> Oh sorry, I didn't notice this before pushing my patch. The upside is that
> you suggested the same. :-) Thanks.

No pb, the most important is the bug is now fixed! :-)