Bug 59724 - FILEOPEN: Inherited currency format not retained through close and open
Summary: FILEOPEN: Inherited currency format not retained through close and open
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.0.0.0.alpha0+ Master
Hardware: All Windows (All)
: medium major
Assignee: Markus Mohrhard
URL:
Whiteboard: target:4.1.0 target:4.0.0
Keywords:
: 58943 (view as bug list)
Depends on:
Blocks: mab4.0
  Show dependency treegraph
 
Reported: 2013-01-22 17:52 UTC by mike.hall
Modified: 2013-01-28 18:03 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample document what reproduced the bug (7.87 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-01-22 18:34 UTC, Rainer Bielefeld Retired
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mike.hall 2013-01-22 17:52:12 UTC
Open a new spreadsheet in 4.0 RC1.

Put numbers into several cells.
Format cells as currency 
Set a formula =one of the cells so that - currency format is inherited
Set a formula to sum the cells - currency format is inherited
Save and close spreadsheet
Reopen
The two cells do not have the inherited format.
Format can be recovered by eg search and replace = for = but the format is lost again on close and reopen - can't be expected to do that every time.

If this is working in alpha0/master as claimed by Rainer this morning, the relevant patch needs to be in LO 4.0 before release.

Have tested on Win7/64 bit and Vista/32 bit, both with 4.0 RC1. Identical behaviour. Also with all other spreadsheets with inherited currency formats. Will test on Win XP in a few mins. If the behaviour is different, will post here.
Comment 1 Rainer Bielefeld Retired 2013-01-22 18:34:22 UTC
Created attachment 73468 [details]
Sample document what reproduced the bug

[Reproducible] with attached Sample document (you see the result) and server installation of  "4.1.0.0.alpha0 (Build ID: 0ff470cff6ecc436e723af6a60986c8eefaba7b) TinderBox: Win-x86@6, Branch:master, Time: 2013-01-19 22:38:36  - ENGLISH UI / German Locale  on German WIN7 Home Premium (64bit) with LO41 Masters User Profile  

The values created by formulas in column B showed Currency format until I had closed the document. After having reopened Currency is missing.

And here also the trick "find & replace all '=' by '='" does the job and reanimates the currency format.

Definitively FILEOPEN problem. 3.5.7.2 opens sample showing Currency format in column B.
Comment 2 Markus Mohrhard 2013-01-22 18:36:33 UTC
Ctrl+Shift+F9 is better than search and replace!

This forces a hard recalculation.
Comment 3 Rainer Bielefeld Retired 2013-01-22 18:39:42 UTC
*** Bug 58943 has been marked as a duplicate of this bug. ***
Comment 4 Rainer Bielefeld Retired 2013-01-22 18:45:55 UTC
Please see <https://bugs.freedesktop.org/show_bug.cgi?id=58943#c3> with hint where problem might have started

Major due to simple workaround
Comment 5 mike.hall 2013-01-22 21:04:56 UTC
Silly question, but is the difference between 3.5.7.2 and 4.0.xxx that the former forces a recalculation on open whereas forced recalculation has been dropped in 4.0?
Comment 6 Markus Mohrhard 2013-01-22 22:54:17 UTC
(In reply to comment #5)
> Silly question, but is the difference between 3.5.7.2 and 4.0.xxx that the
> former forces a recalculation on open whereas forced recalculation has been
> dropped in 4.0?

Yes. Until 4.0 we had to force a full recalculation of all formulas after import. Beginning with 4.0 we import the cached values from ODS and OOXML files and use the stored values to prevent the recalculation. This speeds up the import quite a bit in larger documents. Since this required a major rework of how we handle formulas during import we are still seeing some smaller problems that we have to fix when somebody notices them.
In the long run this change brings us closer to a fast import of all major document formats.
Comment 7 mike.hall 2013-01-22 23:04:39 UTC
So, the problem may not be with FILEOPEN, but rather that inherited formats are not saved with the file at all, just the cached value of the formula. Thus the problem probably applies to all inherited formats. I've just tried with dates, and exactly the same problem occurs.
Comment 8 mike.hall 2013-01-22 23:23:29 UTC
No, percentages and boolean work OK. Percentages can be added or subtracted by formula with inheritance, but inheritance is lost with multiplication or division.

Fractions are the same problem (you can add fractions and get inheritance) but subtraction, multiplication and division just give the number.
Comment 9 Markus Mohrhard 2013-01-22 23:24:52 UTC
(In reply to comment #7)
> So, the problem may not be with FILEOPEN, but rather that inherited formats
> are not saved with the file at all, just the cached value of the formula.
> Thus the problem probably applies to all inherited formats. I've just tried
> with dates, and exactly the same problem occurs.

No. It is an import problems and I finally think I know what is the problem. I need to study the spec a bit more and think a bit about the code and a clean solution.

If I'm right we are incorrectly ignoring the text part of some cell types which results in calling in incorrectly importing the cached value as number.
Comment 10 Not Assigned 2013-01-23 23:49:35 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ae516fabd96a948b62c4d3a522555fc955750c3e

import inherited number formats with cached values, fdo#59724



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 11 mike.hall 2013-01-24 08:22:27 UTC
@Marcus
Many thanks. Will test on Windows. As target is 4.1.0 maybe it would be worth publicising the recalculate workaround Ctrl+Shift F9 in release notes for 4.0?

You didn't mean to put target 4.0.1? (Just hopeful!)
Comment 12 Not Assigned 2013-01-25 18:45:40 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "libreoffice-4-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a2ebd811d4049e2ed03c677cbc7d0e2c8515b797&h=libreoffice-4-0

import inherited number formats with cached values, fdo#59724


It will be available in LibreOffice 4.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Markus Mohrhard 2013-01-25 19:06:26 UTC
(In reply to comment #11)
> @Marcus
> Many thanks. Will test on Windows. As target is 4.1.0 maybe it would be
> worth publicising the recalculate workaround Ctrl+Shift F9 in release notes
> for 4.0?
> 
> You didn't mean to put target 4.0.1? (Just hopeful!)

Still pending review for the 4-0-0 branch.

The original patch was not enough to fix all problems so I needed two more patches to fix the remaining problems. The patch in 4-0 and the one pending review for 4-0-0 are complete.
Comment 14 Kohei Yoshida 2013-01-26 00:38:15 UTC
Assign this to Markus.
Comment 15 Not Assigned 2013-01-28 16:47:38 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "libreoffice-4-0-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=735798ebcf5ce94419bbbca3cd87073225ed396d&h=libreoffice-4-0-0

import inherited number formats with cached values, fdo#59724


It will be available already in LibreOffice 4.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.