Bug 104816 - Inserting a user field will lose the condition of section
Summary: Inserting a user field will lose the condition of section
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
3.6.7.2 release
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:6.3.0
Keywords: bibisected, regression
: 125658 (view as bug list)
Depends on:
Blocks: Section
  Show dependency treegraph
 
Reported: 2016-12-20 16:44 UTC by Sven
Modified: 2019-06-07 08:59 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
screenshots for every step (205.11 KB, application/pdf)
2016-12-20 16:44 UTC, Sven
Details
File with conditional section (16.76 KB, application/vnd.oasis.opendocument.text)
2017-01-01 19:55 UTC, Buovjaga
Details
hidden_section_crash.odt: solution test document - make sure deleting all visible paragraphs doesn't crash Writer (10.49 KB, application/vnd.oasis.opendocument.text)
2019-01-10 09:11 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven 2016-12-20 16:44:09 UTC
Created attachment 129813 [details]
screenshots for every step

Hi,

our company is going to migrate from OpenOffice to LibreOffice and we have got some problems with conditions for hiding sections. When the section is at the end of the document and the userfield is changing the condition will be lost.

A. Step 1 (picture 1 in attachement)
1. open new writer document
2. insert some paragraphs
3. at the end of the document insert a section and the condition "Test G 0" (after the section there should be nothing, no following paragraph)

B. Step 2 (picture 2 in attachement)
4. add the userfield "Test" to the textfieldmaster with the value 2
5. insert the userfield into the document or only insert it into the textfieldmaster

C. Result (picture 3 in attachement)
The section is still visible and the condition is corrupt. The value of the condition of the section is set to "0"

The problem only appears when the section is at the end of the document and nothing will follow it.

Maybe a duplicate of 101803
Comment 1 Buovjaga 2016-12-31 13:18:11 UTC
Sven: so you have been using Apache OpenOffice and the problem is not present in it? In bug 101803 it is said that the problem is already present in LibreOffice 3.3, which is inherited from OpenOffice.org.
Comment 2 Sven 2017-01-01 15:32:36 UTC
Hello Buovjaga,

thanks for your reply. I wish you a happy new year.

In our company we are using OpenOffice 3.2.1 - OOo320m18 (Build:9502).

I have tested it now with AOO412m3(Build:9782) - Rev. 1709696 (2015-10-21 09:53:29 (Mi, 21 Okt 2015)) and the problem doesn't exist in this version.

The problem only occurs in LibreOffice.

Best regards, 
Sven
Comment 3 Buovjaga 2017-01-01 19:55:45 UTC
Created attachment 130074 [details]
File with conditional section

It works ok in 3.5.0 (good news), broken already in 3.6.7.2.

Steps:
1. Open attached document
2. While in the empty paragraph before the section, Insert - Field - More Fields (or Fields - Other in older versions)
3. Variables tab, User field with Format: Standard, Name: Test, Value: 2. Insert.

Correct result: section disappears
Incorrect result: section does not disappear. Go to Format - Sections and see the changed condition.

Tested with:

Arch Linux 64-bit, KDE Plasma 5
Version: 5.4.0.0.alpha0+
Build ID: fc0d4e6bc43d5f982452df07930f5ecf5927ad22
CPU Threads: 8; OS Version: Linux 4.8; UI Render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on December 31st 2016

Arch Linux 64-bit
Version 3.6.7.2 (Build ID: e183d5b)

Win 10
LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735
Comment 4 Oliver Brinzing 2017-04-16 11:51:17 UTC
confirming with lo 5.3.2.2 and lo 5.4.0.0.alpha0+
(Build ID: c2511f27768341e33b452429b6dac38efa039804)

adding variable "Test" with a value greater "0"
will destory the condition.
Comment 5 Buovjaga 2018-05-23 17:18:45 UTC
Still repro.

Arch Linux 64-bit
Version: 6.1.0.0.alpha1+
Build ID: 5956828c88501ef1366e60010b05053a8e1e642e
CPU threads: 8; OS: Linux 4.16; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on May 23rd 2018
Comment 7 Oliver Brinzing 2018-07-21 12:44:01 UTC
still reproducible in LO 6.0.6.1 and 
6.2.0.0.alpha0+ (x64)
Build ID: cbc992e7370ab006ea7c0f8520896845f79f7749
Comment 8 Justin L 2019-01-10 06:37:21 UTC
confirmed that comment 6 has identified the correct commit. The code is now found in sw/source/core/doc/DocumentFieldsManager.cxx  DocumentFieldsManager::UpdateExpFieldsImpl().

confirmed that without that fix, Writer still crashes if every part of the document belongs to hidden sections. The trick here will be to find out if any of the document is NOT covered by sections (which would be the normal case) and then allow all the sections to be hidden.
Comment 9 Justin L 2019-01-10 09:11:40 UTC
Created attachment 148200 [details]
hidden_section_crash.odt: solution test document - make sure deleting all visible paragraphs doesn't crash Writer

Currently this document does not crash, because it refuses to allow you to delete the paragraph entirely. However, if comment 6's fix is reverted, then deleting all non-section content results in a crash.

That makes this a bit more complicated, because even if the document is currently OK to allow all of the sections to be hidden, the possibility of a crash is again opened up.
Comment 10 Justin L 2019-01-10 18:36:04 UTC
proposed fix at https://gerrit.libreoffice.org/66128

The (In reply to Justin L from comment #9)
> make sure deleting all visible paragraphs doesn't crash Writer
This was from an assert, so it doesn't crash non-debug builds.
Comment 11 Commit Notification 2019-01-18 18:45:11 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/85bd9d81e1dafdef5b868637ebb34f22282befab%5E%21

tdf#104816 sw: if non-section content, let all sections hide.

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.
Comment 12 Justin L 2019-01-18 19:42:15 UTC
A temporary work-around is to ensure that the section is not at the end of the document.  You can insert a space after the section with an alt-enter.
Comment 13 Justin L 2019-06-03 16:24:35 UTC
*** Bug 125658 has been marked as a duplicate of this bug. ***