Bug 95687 - Average in Writer is not average
Summary: Average in Writer is not average
Status: RESOLVED DUPLICATE of bug 61228
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-09 07:00 UTC by Ondřej
Modified: 2015-11-22 14:08 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Third column = averge calculated by Writer, Fourth column = expected values (11.13 KB, application/vnd.oasis.opendocument.text)
2015-11-09 07:00 UTC, Ondřej
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ondřej 2015-11-09 07:00:02 UTC
Created attachment 120401 [details]
Third column = averge calculated by Writer, Fourth column = expected values

Hello,

I have found, that when the table is crated in Writer and some volues need to be aveged, than Writer makes addition instead of making average.

Probably is is not critical, but it present in multiple versions (also on Ubuntu 14.04 ... guess, tha it is 4.2.3.x).

Have a nice day ;)
Comment 1 raal 2015-11-09 20:36:08 UTC
I can confirm with Version: 5.1.0.0.alpha1+
Build ID: c5fefe46fc9dca3942b2fc33ffd1f7e041d450e6
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2015-11-04_07:04:49
Locale: cs-CZ (cs_CZ.UTF-8) and LibreOffice 3.5.0 
Build ID: d6cde02
Comment 2 Julien Nabet 2015-11-11 15:34:24 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this

In fact, any name which doesn't correspond to an existing function returns a sum as a range without function.

I mean these are equivalent:
- =xxxxx<A1:B1>
- =<A1:B1>
- =SUM<A1:B1>

If you want average, you should use "MEAN" function.

So the problem is Writer should popup an error message in case of incorrect function.
Comment 3 Julien Nabet 2015-11-11 16:17:31 UTC
I tried to understand why it doesn't popup an error msg but failed to do it.
Here is some pointer:
http://opengrok.libreoffice.org/xref/core/sw/source/core/bastyp/calc.cxx#676
Comment 4 Ondřej 2015-11-11 18:52:16 UTC
OK, thanks for all reactions. So if I understand correctly, the problem is in that Writer does not have included "average" function, but "mean" function works fine (already tried). And there is no warning to user, when undefined function is used. 
I am not good in reading in code, but I guess that usable functions are these: http://opengrok.libreoffice.org/xref/core/sw/source/core/bastyp/calc.cxx#55 ?
Comment 5 Julien Nabet 2015-11-11 21:01:22 UTC
Let's give a try with this patch:
https://gerrit.libreoffice.org/#/c/19919/

With it, LO displays an error for unknown function but perhaps it's not that simple and I miss some cases.
Let's wait for the review of this one.
Comment 6 Ondřej 2015-11-11 22:02:35 UTC
Thank you a lot! :) As soon as possible I will try to apply the patch somehow, now I can´t quickly find the way how to do it. In fact I am just a little advanced user, not a programmer.
Comment 7 Julien Nabet 2015-11-11 22:08:08 UTC
If interested + have some time you can first build the sources by following this link https://wiki.documentfoundation.org/Development/BuildingOnLinux
then apply the patch.

You may also wait for the review, if it's ok, you'll find a daily master containing the fix 24 to 48 hours afterwards there:
http://dev-builds.libreoffice.org/daily/master/
Comment 8 Ondřej 2015-11-11 22:14:55 UTC
OK, thank you for advice, now I am busy at school, so maybe I will try it on weekend.
Comment 9 Commit Notification 2015-11-21 14:37:13 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

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

tdf#95687: Wrong function names in Formula Writer are considered as SUM

It will be available in 5.1.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.
Comment 10 Julien Nabet 2015-11-21 14:38:32 UTC
Review for 5.0 branch, see https://gerrit.libreoffice.org/#/c/20106/
Comment 11 Ondřej 2015-11-21 18:12:06 UTC
Great work! :-) I will test it ASAP after release.
Have a nice day.
Comment 12 Commit Notification 2015-11-21 23:28:15 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

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

Revert "tdf#95687: Wrong function names in Formula Writer are considered as SUM"

It will be available in 5.1.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.
Comment 13 Julien Nabet 2015-11-21 23:31:28 UTC
Sorry the fix was wrong, see http://cgit.freedesktop.org/libreoffice/core/commit/?id=0acf23044bdf003bee2df1e8a3066ed157343401 for details.
Comment 14 Julien Nabet 2015-11-22 08:57:23 UTC
I submitted a new patch here:
https://gerrit.libreoffice.org/#/c/20113/

Hope it'll be fine.
Indeed, when using non existent functions ("foo" included), there's an error but now PythonTest_sw_python with set_expression test (which was ko) is ok.
Comment 15 Commit Notification 2015-11-22 09:25:41 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

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

tdf#95687: Wrong function names in Formula Writer are considered as SUM

It will be available in 5.1.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.
Comment 16 Commit Notification 2015-11-22 14:05:35 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

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

Revert "tdf#95687: Wrong function names in Formula Writer are considered as SUM"

It will be available in 5.1.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.
Comment 17 Julien Nabet 2015-11-22 14:06:00 UTC
The last patch was wrong because variables aren't dealt anymore with this.
What a mess to fix this! :-(
Comment 18 Julien Nabet 2015-11-22 14:08:41 UTC
Thank you to Mike for having noticed it was related to tdf#61228, in fact, it's even a dup of it.

*** This bug has been marked as a duplicate of bug 61228 ***