Bug 124895 - Multiple selected chapter promote/demote produce incorrect results
Summary: Multiple selected chapter promote/demote produce incorrect results
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.3.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Jim Raykowski
URL:
Whiteboard: target:6.3.0
Keywords:
Depends on:
Blocks: Navigator
  Show dependency treegraph
 
Reported: 2019-04-23 07:31 UTC by Jim Raykowski
Modified: 2019-05-26 00:24 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
test headings (23.12 KB, application/vnd.oasis.opendocument.text)
2019-04-23 07:31 UTC, Jim Raykowski
Details
Result after patch (26.82 KB, image/png)
2019-05-03 12:20 UTC, Buovjaga
Details
outline heading test file (10.60 KB, application/vnd.oasis.opendocument.text)
2019-05-20 23:31 UTC, Jim Raykowski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Raykowski 2019-04-23 07:31:01 UTC
Created attachment 150931 [details]
test headings

Steps to show incorrect chapter promote results:

1) Open the attached Headings file
2) Open Navigator (F5 or Ctrl+F5 to open sidebar then select Navigator deck)
3) Select Headings
4) Switch to content navigation root mode by using the Content Navigation View button in the tool box
5) Select Uberscrift 10, 20, and 30 (Ctrl key + mouse click items to multi select)
6) Click on Promote Chapter button in the tool box

Results look correct:

Uberscrift 10
Uberscrift 20
Uberscrift 30
Uberscrift 1
Uberscrift 40
Uberscrift 50
Uberscrift 60

7) Expand Uberscrift 10 by clicking on the + or > expand button
Sub chapters 11 - 18 are shown. Where is sub chapter 19?

8) Expand Uberscrift 30
Sub chapter 19 now follows sub chapter 39.

Expected results:
Uberscrift 10 contains sub chapters 11-19
Uberscrift 20 contains sub chapters 21-29
Uberscrift 30 contains sub chapters 31-39


Steps to show incorrect chapter demote results:

1) Follow above steps 1-4
2) Select Uberscrift 30, 40 and 50
2) Click on Demote Chapter button in the tool box

Results are:

Uberscrift 1
Uberscrift 10
Uberscrift 20
Uberscrift 60
Uberscrift 50 sub chapters 51-52
Uberscrift 30 sub chapters 31-39
Uberscrift 40 sub chapters 41-49 followed by 53-59

Expected Results:

Uberscrift 1
Uberscrift 10
Uberscrift 20
Uberscrift 60
Uberscrift 30 sub chapters 31-39
Uberscrift 40 sub chapters 41-49
Uberscrift 50 sub chapters 51-59
Comment 1 Buovjaga 2019-05-03 12:20:22 UTC
Created attachment 151156 [details]
Result after patch

I first applied https://gerrit.libreoffice.org/#/c/69602/ and then https://gerrit.libreoffice.org/#/c/71270/

I also tried with the attachment in bug 124305 and it does not solve the collapsing.
Comment 2 Jim Raykowski 2019-05-04 00:57:18 UTC
(In reply to Buovjaga from comment #1)
> Created attachment 151156 [details]
> Result after patch
> 
> I first applied https://gerrit.libreoffice.org/#/c/69602/ and then
> https://gerrit.libreoffice.org/#/c/71270/
> 
> I also tried with the attachment in bug 124305 and it does not solve the
> collapsing.

Hi Buovjaga,
From attachment 151156 [details] it looks like you have used the 'Demote Level' tool box item to accomplish what is shown. I believe this is correct behavior for level demotion because this shows that the level demoted selected headings are now sub headings under the expanded heading. The patch for the bug in the initial comment is for incorrect *Chapter* promote/demote behavior. For me 'Promote Chapter' and 'Demote Chapter' buttons are shown on the first row last two items of the Navigator tool box as Up and Down arrow buttons.
Comment 3 Buovjaga 2019-05-04 06:45:00 UTC
Yes, I had never tried the chapter promotion/demotion.

(In reply to Jim Raykowski from comment #0)
> Steps to show incorrect chapter demote results:
> 
> 1) Follow above steps 1-4
> 2) Select Uberscrift 30, 40 and 50
> 2) Click on Demote Chapter button in the tool box

My results are

Uberscrift 1
Uberscrift 40 sub chapters 41-49
Uberscrift 10
Uberscrift 20
Uberscrift 30 sub chapters 31-39
Uberscrift 50 sub chapters 51-59
Uberscrift 60
Comment 4 Brian Fraser 2019-05-05 08:11:02 UTC
Tried the steps on LO 6.0.7.3 (Linux) and verified the behaviour listed in the original post.

I cherry picked the two patches into a Linux build and it correctly demonstrates the "expected" behaviour, as listed in the top post.

Testing the cherry picked patches found a few other seemingly related unexpected behaviours which may (or may not) be of interest to fix as part of this, which are listed in a comment on the patch here:
https://gerrit.libreoffice.org/#/c/71270/1
Comment 5 Jim Raykowski 2019-05-08 05:33:20 UTC
Hi all, 

Thanks for the comments.

My first stab at this was a fail :(

A second stab is ready :) The patch to keep multi selection after a move won't work with this second stab so shouldn't be applied if testing.

https://gerrit.libreoffice.org/#/c/71270/
Comment 6 Jim Raykowski 2019-05-20 23:31:33 UTC
Created attachment 151542 [details]
outline heading test file

Attached is a document with a skeleton outline I have been using for testing this patch. The patch to make the selections remain selected after moving is also ready[1]. IMO it makes testing this patch easier. A test I use to prove correct move behavior is noting selected headings positions and doing opposite chapter moves (i.e promote followed by demote or demote followed by promote). After opposite moves the content headings tree should be as it was before the moves. Multi selected move results should match that of moving selected headings individually in selection order from top of content list to bottom when promoting (moving up) and in selection order from bottom to top when demoting (moving down).

[1] https://gerrit.libreoffice.org/#/c/69602/
Comment 7 Buovjaga 2019-05-23 16:08:47 UTC
I tested with both patches applied:
https://gerrit.libreoffice.org/#/c/71270/
https://gerrit.libreoffice.org/#/c/69602/

The result of chapter promotion is now as expected!
Comment 8 Commit Notification 2019-05-24 10:52:37 UTC
Jim Raykowski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/23fc425ff9b16371a6f83e054d63ef9d253b6236%5E%21

tdf#124895 Fix multi selected chapter promote demote

It will be available in 6.3.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.