Bug 154212 - A Frame with a Heading disrupts the "Move Chapter Up/Down" in Navigator
Summary: A Frame with a Heading disrupts the "Move Chapter Up/Down" in Navigator
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Jim Raykowski
URL:
Whiteboard: target:7.6.0
Keywords:
Depends on:
Blocks: Navigator
  Show dependency treegraph
 
Reported: 2023-03-15 18:53 UTC by sdc.blanco
Modified: 2023-11-04 17:07 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Document for demonstrating the effect of a frame on moving a chapter up (44.28 KB, application/vnd.oasis.opendocument.text)
2023-03-15 18:53 UTC, sdc.blanco
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sdc.blanco 2023-03-15 18:53:38 UTC
Created attachment 185989 [details]
Document for demonstrating the effect of a frame on moving a chapter up

The issue is easier to explain by demonstration.

1. Open the attached document.
2. In Navigator notice "MOVE THIS Heading Level 2"
3. Use context menu or "Move Chapter Down" icon in Navigator Panel
to move this heading down.
4. Then use "Move Chapter Up" (or icon in panel)

Actual: Heading moved to top in Navigator (and document) (above Level 1 Heading)
Expected: Moved back to its original place.

Additional information:
1. Example is a simplified version of an actual document where some headings appear in frames. 
2. Have also encountered cases where "Move Chapter Down" gives unexpected effects with frames.

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: ee5dbd193fa24b46fb980ddd8a6c39ca349d0d01
CPU threads: 8; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: da-DK (da_DK); UI: en-US
Calc: CL threaded
Comment 1 Dieter 2023-03-31 18:24:13 UTC
I confirm it with

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: b5c3a7502f7ff6ccf0f829c1f3a2ba50b8584c41
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (de_DE); UI: en-GB
Calc: CL threaded

Adding Jim Raykowski as expert for navigator
Comment 2 Jim Raykowski 2023-03-31 20:14:02 UTC
The bug has to do with where frame nodes are stored in the document model (before regular document content). Patches for Bug 143569 made headings that are in frames show in document order.

This bug can also be reproduced with a second level Heading appended to the end of the document and then doing "Move Chapter Up".

Navigator outline move commands are handled here:

sw/source/uibase/utlui/content.cxx
void SwContentTree::ExecCommand(std::string_view rCmd, bool bOutlineWithChildren)
Comment 3 Jim Raykowski 2023-04-01 00:16:55 UTC
For me, holding the Ctrl key and clicking the "Move Chapter Up" button in the Navigator tool box gives the expected result of moving the chapter back to the position it was before the "Move Chapter Down". Holding the Ctrl key and clicking the chapter move buttons in the tool box moves the chapter with out moving sub-chapters. In this case the moved chapter doesn't have sub-chapters so the expected result is seen.
Comment 4 sdc.blanco 2023-04-01 09:58:54 UTC
Repro that holding Ctrl and clicking Move Chapter Up/Down works as expected.

Also noticed: with Move Chapter Up/Down and frame is anchored to the heading/subheadings being moved, then the frame is moved with the text, and text goes where expected.  (i.e., all as expected, no disruption in final location).
Comment 5 Jim Raykowski 2023-04-01 23:25:07 UTC
Worse yet is the crash that occurs with Ctrl + "Move Chapter Down" for the "A level 2 heading for a change" heading :(

I've come up with a patch to fix the bug reported here and the mentioned crash. The problem is, multiple selection moves don't work as the patch stands now. Multiple selection moves are tricky. I did some hacking on this a few years ago. Round two challenge accepted!
Comment 6 Jim Raykowski 2023-04-02 22:33:39 UTC
Here is a link to a patch that fixes the reported bug and mentioned crash:
https://gerrit.libreoffice.org/c/core/+/149944
Comment 7 Commit Notification 2023-04-06 18:02:12 UTC
Jim Raykowski committed a patch related to this issue.
It has been pushed to "master":

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

tdf#154212 SwNavigator: Fix outline up/down handling

It will be available in 7.6.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 8 sdc.blanco 2023-04-07 08:06:16 UTC
Thanks Jim.  Can move headings and text up and down now without the "frame" causing the heading/text to jump to the top.  (seems hard to test systematically, because there can be many different outline structures, but definitely an improvement!)
Comment 9 Jim Raykowski 2023-08-26 04:28:55 UTC
I think this is fixed and I forgot to set it as such, so doing it now.
Comment 10 Dieter 2023-11-04 17:07:25 UTC
VERIFIED with

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: c0c8cffd3541e3cd616c96791b04e7ebf2b2ed03
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL threaded