[Libreoffice-bugs] [Bug 131025] Writer document with tables lost data in cells (apparently) replacing with 0

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Tue Feb 16 10:12:16 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=131025

--- Comment #34 from Mike Kaganski <mikekaganski at hotmail.com> ---
When a cell has a numeric format, and one types there something that does not
convert to a number, the cell format is automatically converted to text (@).
This makes sure that cell content (text) matches cell value type.

When a format is applied onto a cell with existing value, the format is
applied, but (since the fix to tdf#106322) the value is retained in this
session (and gets saved to ODF), so the problem arises (as mentioned in comment
7, it somehow does not affect "General" number format). It seems bad that the
cell value type (and thus cell value) might differ from cell content type.

The standard says [1] that only for textual value type, the value is defined by
cell content:

> If the value type is not string or if the <table:table-cell> element content
> differs from the value of the element, the corresponding Value Attribute(s)
> (Table 14 - Value attributes) shall contain the value(s) of the element.
> ...
> If the value type is string and the office:string-value attribute is not
> present, the element content defines the value.

So LO behaves correctly when opening the file: the 'office:value' attribute is
authoritative in this case, and is rightfully overrides the text contained in
the cell.

It seems that the change is needed when a format is *applied* to a cell: it
should try to convert the existing data, and if failed, keep the previous
number format along with previous data. So if one applies a numeric format
string, and there's "123" text, it successfully converts to number, and the
format is accepted (and office:value becomes 123); if there were "abc", then
the conversion fails, and the format stays '@'. This way, the value type,
value, and content will always be in sync. The drawback is that when user
applies a number format string to a range of cells, some of the cells might
refuse that format, and keep older format (unexpectedly to user). Possibly that
is acceptable inconvenience (which would need a documentation) compared to data
loss.

[1]
http://docs.oasis-open.org/office/OpenDocument/v1.3/OpenDocument-v1.3-part3-schema.html#attribute-office_value-type

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210216/76183f80/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list