Bug 156061 - Paragraph that contains mergeFields with white space disappears
Summary: Paragraph that contains mergeFields with white space disappears
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.2.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:26.2.0 target:25.8.0.0.beta2
Keywords: bibisected, bisected
: 161264 (view as bug list)
Depends on:
Blocks: Paragraph
  Show dependency treegraph
 
Reported: 2023-06-26 13:42 UTC by Hector
Modified: 2025-06-30 13:32 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
File with the problem (30.29 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-06-26 13:43 UTC, Hector
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hector 2023-06-26 13:42:54 UTC
Description:
I have a problem with mergeFields.
If the value is white space, the text disappears.
In LibreOffice the entire paragraph that contains it disappears.
In WordPad works perfectly.

Steps to Reproduce:
1. Open a file with mergeFields the contains white space


Actual Results:
Only 3 paragraphs appear in the document

Expected Results:
4 paragraphs should appear in the document


Reproducible: Always


User Profile Reset: No

Additional Info:
4 paragraphs should appear in the document
Comment 1 Hector 2023-06-26 13:43:45 UTC
Created attachment 188094 [details]
File with the problem
Comment 2 Hector 2023-06-26 13:45:05 UTC
I Have a problem with mergeFields.
If the value is white space, the text disappears.
In LibreOffice the entire paragraph that contains it disappears.
In WordPad works perfectly.

I add file here.
Comment 3 Julien Nabet 2023-06-26 13:46:25 UTC Comment hidden (obsolete)
Comment 4 Mike Kaganski 2023-06-26 14:03:08 UTC
Likely related to commit db04be037b611e296ef9f2542322c52ed82d7a2b.
However, the function that checks if the paragraph should be hidden only checks that field text is empty - i.e., no characters. Some whitespace is not empty, so should not make it hidden. Thus, it is likely an import issue, turning whitespace into nothing.

Interesting, if it worked between 6.1 (where the feature was implemented) and 7.5?
Comment 5 Hector 2023-06-26 15:21:10 UTC
I have only tested it in version 7.5
Comment 6 Stéphane Guillou (stragu) 2023-06-26 19:03:12 UTC
(In reply to Mike Kaganski from comment #4)
> Likely related to commit db04be037b611e296ef9f2542322c52ed82d7a2b.
> However, the function that checks if the paragraph should be hidden only
> checks that field text is empty - i.e., no characters. Some whitespace is
> not empty, so should not make it hidden. Thus, it is likely an import issue,
> turning whitespace into nothing.
> 
> Interesting, if it worked between 6.1 (where the feature was implemented)
> and 7.5?

Testing with "Tools > Options > Writer > Compatibility > Hide paragraphs of database fields" on:

- 6.1 build at db04be037b611e296ef9f2542322c52ed82d7a2b shows the paragraph.
- starts being hidden in 7.2

I had to bisect in --safe-mode.
Bibisected with linux-64-7.2 repo to first bad commit 426308e0d943e62cfe25211ced21fa90c02a97ac which points to core commit:

commit ac14ed9f26582701032a28cb424f2b6bf35ca7fd
author	Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>	Wed Dec 09 09:11:24 2020 +0100
committer	Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>	Thu Dec 10 16:50:42 2020 +0100
Don't show HiddenParagraphs by default
Showing them means that the layout is different from what is printed.
This probably shouldn't be the default.
The similiar HiddenCharacter is also false by default.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107385

I don't understand the feature(s) enough to judge if that was by design.

Samuel and Mike?
Comment 7 Mike Kaganski 2023-06-27 05:50:28 UTC
(In reply to Stéphane Guillou (stragu) from comment #6)

Thank you; the setting changed in that commit is about showing *on screen*.
The file, when opened in Word, has that paragraph shown even on print preview.

In Writer 6.1, it hides the paragraph on print preview, so no need to bisect further.
Comment 8 Mike Kaganski 2023-07-09 09:32:51 UTC
It looks like the feature implemented in bug 35798 Needs fixing. Empty mail merge fields should not hide anything in the source document; only the merge itself should perform the hide.

FTR: Word seems to only hide when the paragraph after the merge only contains whitespace. So paragraphs with labels in plain text (not as Word's merge field's \b argument) would not hide; and fields containing space (not exactly empty) would hide. I am unsure if this exact processing should be implemented; anyway, even if, it's separate.
Comment 9 Mike Kaganski 2025-06-29 07:41:40 UTC
*** Bug 161264 has been marked as a duplicate of this bug. ***
Comment 10 Mike Kaganski 2025-06-29 12:33:07 UTC
https://gerrit.libreoffice.org/c/core/+/187150
Comment 11 Commit Notification 2025-06-29 16:23:26 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

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

tdf#156061: don't hide DB fields when not in mail merge

It will be available in 26.2.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 Commit Notification 2025-06-30 10:44:19 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

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

tdf#156061: fix UI strings for EmptyDbFieldHidesPara compat option

It will be available in 26.2.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 13 Commit Notification 2025-06-30 11:33:33 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/0c0496b2902a00639e37ed57dd753a8445f9ef97

tdf#156061: don't hide DB fields when not in mail merge

It will be available in 25.8.0.0.beta2.

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 14 Commit Notification 2025-06-30 13:32:03 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

https://git.libreoffice.org/core/commit/1d7f160f9a0f01ce74bf306a86bd9e8a9f291a7e

tdf#156061: fix UI strings for EmptyDbFieldHidesPara compat option

It will be available in 25.8.0.0.beta2.

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.