The former version does not comply to the best possible coding style.
The variable v comes from the caller and in this case is set to the stringified value attribute, also the caller does not check for the presence of the child element.
The original code tries to access the first child element even if it's not present (resulting in exception)
Even if the problematic ODS is not valid, this patch will improve the code quality and so increase Roo compatibility.
Issue
LibreOffice generates following XML for float cells:
Some other generators (like https://github.com/westonganger/rodf) do not put redundant children elements, so the outcome is as follows:
Attempt to read such ODS throws at
open_office.rb
line 424 (or so)Fix
Replace:
With:
The former version does not comply to the best possible coding style. The variable
v
comes from the caller and in this case is set to the stringifiedvalue
attribute, also the caller does not check for the presence of the child element. The original code tries to access the first child element even if it's not present (resulting in exception)Even if the problematic ODS is not valid, this patch will improve the code quality and so increase Roo compatibility.
System configuration
Roo version: 2.7.1 (still present in 2.8.2) Ruby version:
ruby 2.4.5p335 (2018-10-18 revision 65137) [x64-mingw32]