Bug 132111 - Initial cell's number format in Writer table is reported wrong
Summary: Initial cell's number format in Writer table is reported wrong
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.3.5.2 release
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:25.8.0 target:25.2.0.2
Keywords:
Depends on:
Blocks: Number-Format
  Show dependency treegraph
 
Reported: 2020-04-15 07:02 UTC by Mike Kaganski
Modified: 2024-12-24 11:05 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2020-04-15 07:02:02 UTC
1. In a new text document, add a table.
2. Check number format of a cell of the table (Table->Number Format); then click Cancel.
=> it's "@"; category is "Text"; language is Default.
3. It the same cell, press "="
=> Formula bar appears, as if F2 was pressed
4. Cancel the formula, and put the cursor in another cell
5. Open Format Number dialog (as in step 2), select Number category ("General" format gets selected), click OK.
6. Open Format Number dialog again, select Text category ("@" format gets selected), click OK.
7. Press "="
=> This time, no formula bar appears. "=" is put into the cell as is.

So, changing original cell format (reported as "Text" - "@") to another format, then back to "Text" - "@" (as in steps 5 and 6), changes the cell behaviour. Looks like the original cell format is not shown correctly (at least some indication missing?), or changing the format also modifies some other setting - which?
Comment 1 Dieter 2020-04-19 05:48:55 UTC
I confirm it with

Version: 7.0.0.0.alpha0+ (x64)
Build ID: 1c9ced04189c9d23ffea05d5570960b54b05ef28
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-GB
Calc: CL

and also with

Version: 6.3.5.2 (x64)
Build-ID: dd0751754f11728f69b42ee2af66670068624673
CPU-Threads: 4; BS: Windows 10.0; UI-Render: Standard; VCL: win; 
Gebietsschema: de-DE (de_DE); UI-Sprache: de-DE
Calc: threaded
Comment 2 QA Administrators 2022-04-20 03:37:12 UTC Comment hidden (obsolete)
Comment 3 Mike Kaganski 2022-04-20 06:41:20 UTC
Still repro using Version: 7.3.3.1 (x64) / LibreOffice Community
Build ID: 1688991ca59a3ca1c74bc2176b274fba1b034928
CPU threads: 12; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: en-US
Calc: CL
Comment 4 QA Administrators 2024-04-20 03:15:38 UTC Comment hidden (obsolete)
Comment 5 Mike Kaganski 2024-12-22 16:06:25 UTC
The problem arises from the difference between handling of "default number format" in different places in Writer.

The Number Format dialog is handled in SwTableShell::Execute (case FN_NUM_FORMAT_TABLE_DLG), with the code explicitly taking "NF_TEXT" for "default" case (the result is 100). Even if it would not do that - e.g., in multi-selection case, when eState is INVALID, the pool default is still text (100).

On the other hand, e.g. SwEditShell::IsTableBoxTextFormat (used when pressing "=" in an empty cell) initializes the format with 0 (which is "Standard", i.e., numeric); for any case when it's not explicitly set, it will use that value. That makes it completely inconsistent.
Comment 6 Mike Kaganski 2024-12-22 16:50:53 UTC
SwTableBox::HasNumContent also treats absent RES_BOXATR_FORMAT as format 0.
Comment 7 Mike Kaganski 2024-12-22 18:21:56 UTC
https://gerrit.libreoffice.org/c/core/+/179177
Comment 8 Commit Notification 2024-12-22 19:32:14 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d74738ef156b6c468fd8aa0fb9e0528f04cf5c07

tdf#132111: don't claim a number format for multiselection / no set format

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2024-12-24 11:05:21 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/173d71fe18f4fc5f523291d4b5ac80249ccddd55

tdf#132111: don't claim a number format for multiselection / no set format

It will be available in 25.2.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.