Issue 117825 - Variable field imported incorrectly from 3.2.1 to 3.3.0
Summary: Variable field imported incorrectly from 3.2.1 to 3.3.0
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOo 3.3
Hardware: All All
: P3 Normal (vote)
Target Milestone: ---
Assignee: mst.ooo
QA Contact: issues@sw
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2011-04-13 04:42 UTC by richard
Modified: 2012-06-21 03:13 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Writer document that works on 3.2.1 but fails on 3.3.0 (10.81 KB, application/vnd.oasis.opendocument.text)
2011-04-13 04:42 UTC, richard
no flags Details
restrict hack a bit (1.96 KB, patch)
2011-04-29 17:38 UTC, mst.ooo
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description richard 2011-04-13 04:42:08 UTC
Created attachment 76368 [details]
Writer document that works on 3.2.1 but fails on 3.3.0

Until quite recently, I was using OpenOffice.org 3.2.1 (OOO320m18 (Build:9502)) on Linux.  I then tried using OpenOffice.org 3.3.0 (OOO330m20 (Build:9567)) on Linux.

I have Writer documents that were behaving as I expected with OpenOffice.org 3.2.1 that now fail with OpenOffice.org 3.3.0.

I have stripped down my document to something fairly minimal that continues to demonstrate the problem.  (This particular document was saved from OpenOffice.org 3.2.1 (OOO320m18 (build:9502)) on Windows.)

If I load the document in OpenOffice.org 3.2.1, the second line of the table shows:

NZ$   15.00

based on the field being set as:

GST = SubTotal*3/20

If I load the document in OpenOffice.org 3.3.0, the second line of the table shows:

** Expression is faulty **

based on the cell being set as:

= round SubTotal*0.125

This actually seems to be something being resurrected from a previous version of the document.
Comment 1 eric.savary 2011-04-14 10:58:39 UTC
@OS: regression compared to 3.2.1. Reproducible in 3.4 beta.
Comment 2 mst.ooo 2011-04-29 10:34:32 UTC
the offending table cell looks like this:

  <table:table-cell table:style-name="Table3.A2" table:formula="ooow:round SubTotal*0.125" office:value-type="float" office:value="1.79769313486232E+308">
     <text:p text:style-name="P1">
       NZ$<text:tab/>
       <text:variable-set text:name="GST" text:formula="ooow:SubTotal*3/20"
             office:value-type="float" office:value="15"
             style:data-style-name="N4">15.00</text:variable-set>
     </text:p>
  </table:table-cell>

so it has both a formula and some text content.
the problem is that the formula seems to be invalid.

in OOo 3.2.1 the text content was displayed in the cell,
while in OOo 3.4beta the cell content is replaced with an error message.

i've tracked down the changeset that caused the change:
it is revision 041ccff4197b, which fixes issue 104949.
reverting the change causes the text content to be displayed again.

haven't thought about what is desirable here yet...
Comment 3 mst.ooo 2011-04-29 17:28:43 UTC
this is a most interesting critter.

what actually happens in issue 104949 is not at all obvious:
the problem is that the report builder does very weird
things with variables.
for formulas used in header/footer, a variable will be declared,
the header/footer will contain a <text:variable-get> element,
and every result in the report body will have in its first cell
a hidden <text:variable-set> field that sets the variable to
its current value.

 <text:p>
  <text:variable-set text:name="auto_report_1" text:display="none" text:formula="ooow:Date(2011;04;29)" office:date-value="2011-04-29T00:00:00.0Z" office:value-type="date"/>
  here is the formula result of the cell as text
 </text:p>

in the case of the bugdoc at issue 104949 this is always the
same value, but perhaps this is not always so; if the value
were different in different results, then the
<text:variable-get> in the header/footer would display
a value set on the current page.

now the problem in issue 104949 is that these hidden
<text:variable-set> fields prevent the table cells that
contain them from displaying their formula result; the fields
cause them to be treated as text cells instead.
so a horribly ugly hack was introduced in swtable.cxx to treat
cells that contain a single paragraph with no special content
_except_ <text:variable-set> fields not as text cells, so
their content will be replaced with the formula result.
this is what causes the regression described in this issue.

now, ripping out the hideous hack would of course re-introduce
issue 104949, which would be a regression to OOo 3.3.

perhaps it would be possible to put the variable-set fields
into a dummy hidden table cell, but that seems like a lot of
effort, and i'm not sure it is possible.

for OOo 3.4 it would perhaps be appropriate to restrict the
ugly hack a bit so it causes less collateral damage.
Comment 4 mst.ooo 2011-04-29 17:38:22 UTC
Created attachment 76466 [details]
restrict hack a bit

patch to restrict the collateral damage a bit:
<text:variable-set> fields are ignored only if they are
at the start of the paragraph and hidden.

the bugdoc here and the report from bugdoc at issue 104949
look ok for me with this.

please review.
Comment 5 Mathias_Bauer 2011-05-04 12:06:09 UTC
Excellent hack! :-)
Please proceed with it.
Comment 6 mst.ooo 2011-05-04 12:29:48 UTC
fixed in CWS sw34bf06
http://hg.services.openoffice.org/hg/cws/sw34bf06/rev/3b8bef840a50
Comment 7 Oliver-Rainer Wittmann 2012-06-13 12:27:18 UTC
getting rid of value "enhancement" for field "severity".
For enhancement the field "issue type" shall be used.
Comment 8 binguo 2012-06-21 03:13:26 UTC
It repros on OO3.3(I verified it on OOO330m20 build:9567), Verified it on Aoo_Trunk_20120616.1800.1350879 and it does not reproduce, but so close it as fixed.