Bug 127706 - Clearing direct formatting breaks undo
Summary: Clearing direct formatting breaks undo
Status: NEW
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: preBibisect, regression
: 127694 132910 (view as bug list)
Depends on:
Blocks: Undo-Redo Clear-Formatting Formatting-Text-Diverse
  Show dependency treegraph
 
Reported: 2019-09-23 05:46 UTC by Mike Kaganski
Modified: 2023-05-30 20:08 UTC (History)
8 users (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 2019-09-23 05:46:37 UTC
1. In a new text document, add a lorem ipsum text.
2. Select all (Ctrl+A), and set font size to 18.
3. Select a single word (e.g., double-click it), and apply italic direct formatting (Ctrl+I).
4. Select another word in the same paragraph (double-click it) and clear direct formatting (Ctrl+M).
5. Undo (Ctrl+Z), undo again (Ctrl+Z).

Expected: all text has font size 18, not italic (since the effects of both Ctrl+M and Ctrl+I were undone, but not setting font size 18).

Actual: the word that was made italic at step 3 has now font size 12.

Undoing once after step 4 gives expected result, so it is likely step 5 that breaks the undo.

Reproducible with current master (toward 6.4), and with LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735.

Not reproducible with LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735.
Comment 1 Xisco Faulí 2019-09-23 11:34:42 UTC
Reproduced in

Version: 6.4.0.0.alpha0+
Build ID: ea4f3099d6e0cf30d80caa8b2121c7a358f80fdd
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded

@Jim, I thought you might be interested in this issue...
Comment 2 Mike Kaganski 2019-09-23 11:43:40 UTC Comment hidden (obsolete)
Comment 3 Xisco Faulí 2019-09-23 11:49:24 UTC
(In reply to Mike Kaganski from comment #2)
> (In reply to Mike Kaganski from comment #0)
> > Not reproducible with LibreOffice 3.5.0rc3 
> > Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735.
> 
> Oh, sorry: not reproducible with LibreOffice 3.4.0 
> OOO340m1 (Build:11)
> 
> Is that possible to bisect in range 3.4-3.5?

oldest bisection build is

LibreOffice 3.5.0 
Build ID: d6cde02

and it's already reproducible, so not possible to bisect this particular issue
Comment 4 Jim Raykowski 2019-09-29 06:17:26 UTC
Hi all,

Here is a stab at this made by observing expected undo results after selecting all but the first or last character in a paragraph. 

https://gerrit.libreoffice.org/#/c/79808/

Review required and very much appreciated.
Comment 5 Mike Kaganski 2019-09-29 20:44:12 UTC
Made some test with the steps from comment 0 (in a version without patch from comment 4). Specifically, I have saved a new copy of the document after each of the steps starting after 2. For creating lorem ipsum text, I typed "lorem" then F3, so I had 4 paragraphs in the document (the last empty).

After step 2, the resulting ODF contained all paragraphs having direct formatting applied at *paragraph* level; the size 18 was defined in styles under "office:automatic-styles" element, which had style:family="paragraph"; no styles there having style:family="text".

After step 3, the paragraph with the modification still had size defined at paragraph level, but the italic formatting was, naturally, defined at character level (i.e., using a test:span referring to a style which family was "text").

After step 4, the edited paragraph no more had direct formatting at the paragraph level: instead, all formatting was now using several text:span elements, which referred to two character autostyles. The portion that was cleared from direct formatting was outside of the spans, i.e. having the paragraph formatting.

After step 5, the modified paragraph was also free of direct formatting, and everything manual was still applied using text spans.

So I believe that the problem here is that when we clear direct formatting in a span inside a paragraph having direct formatting at paragraph level, its formatting is modified in such a way that is isn't a paragraph-level formatting anymore, but a character-level formatting; and *this step is not undone* in undo, which is the reason of the bug.
Comment 6 Jim Raykowski 2019-12-16 04:36:51 UTC
I observed that undo, redo, undo results in expected results for this problem. Maybe this will help to find a real fix. Here is a patch that does undo, redo, undo for SwUndoAttr undos.

https://gerrit.libreoffice.org/#/c/85195/
Comment 7 Timur 2020-03-24 09:45:25 UTC
*** Bug 127694 has been marked as a duplicate of this bug. ***
Comment 8 Telesto 2020-05-10 10:04:16 UTC
*** Bug 132910 has been marked as a duplicate of this bug. ***
Comment 9 BogdanB 2023-05-30 20:08:57 UTC
Also in
Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 0ceb131e964206efbb1c76a03f19d1992e2f89c7
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded