Bug 128148 - Mail merge: Fields in headers not correctly replaced if header only from page 2 on
Summary: Mail merge: Fields in headers not correctly replaced if header only from page...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: Michael Weghorn
URL:
Whiteboard: target:6.4.0 target:6.3.4
Keywords:
Depends on:
Blocks: Mail-Merge
  Show dependency treegraph
 
Reported: 2019-10-15 07:24 UTC by Michael Weghorn
Modified: 2021-04-12 09:03 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample file wither header on page 2 (9.07 KB, application/vnd.oasis.opendocument.text)
2019-10-15 07:24 UTC, Michael Weghorn
Details
Sample data for mail merge (18.41 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-10-15 07:26 UTC, Michael Weghorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weghorn 2019-10-15 07:24:56 UTC
Created attachment 155010 [details]
Sample file wither header on page 2

Mail merge to a single document doesn't correctly replace fields in headers/footers if the first page doesn't have a header/footer, but following ones do.

Steps to reproduce:

1) open attached sample document "header_from_page2_on.odt"
2) start mail merge wizard ("Tools" -> "Mail Merge Wizard")
3) click through the wizard and select to print a letter using any data source, e.g. the attached ODS sheet
4) Click "Save Merged Documents" item in the mail merge toolbar
5) select "Save as a single large document" and "Save Document"
6) save and open the resulting file

Result: The header on the second page for every data set contains the text "Page 2 of 8" (with fields being used).

Expected result: The header on the second page for every data should contain the text "Page 2 of **2**" (since the printout for every recipient has only 2 pages)


Note: The sample document doesn't have a header in the page style for the first page, but does have one for the pages style of the second page. It works as expected if the first page also has a header (e.g. it is assigned the "Default Style" as well).
Comment 1 Michael Weghorn 2019-10-15 07:26:19 UTC
Created attachment 155011 [details]
Sample data for mail merge
Comment 2 Michael Weghorn 2019-10-15 07:26:43 UTC
Self-confirming since the issue has originally been reported by somebody else in our internal issue tracker. I've already analyzed this and will submit a patch to Gerrit soon.
Comment 3 Michael Weghorn 2019-10-15 08:44:26 UTC
Pending fix: https://gerrit.libreoffice.org/80814
Unit test: https://gerrit.libreoffice.org/80815
Comment 4 Commit Notification 2019-10-15 20:36:05 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9271152c5fb64a698de167861e39f6b073a60ad6

tdf#128148 SwDoc::Append: Copy page descs if any has header/footer

It will be available in 6.4.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 5 Commit Notification 2019-10-15 20:36:11 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/758516295e5f69393bd78bb4af6e7214d48ece0b

tdf#128148 Add unit test

It will be available in 6.4.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 6 Michael Weghorn 2019-10-15 20:37:29 UTC
Fixed in master, backport for 6.3 pending at: https://gerrit.libreoffice.org/#/c/80859
Comment 7 Commit Notification 2019-10-16 11:13:11 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "libreoffice-6-3":

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

tdf#128148 SwDoc::Append: Copy page descs if any has header/footer

It will be available in 6.3.4.

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 Timur 2021-03-08 14:45:02 UTC
Hello Michael. 
Please see Bug 137510, looks similar. 
I wanted to verify this one but attached odt is not mail merge document. 
Otoh, bug 124550 seems duplicate by version.
Comment 9 Michael Weghorn 2021-03-08 15:48:04 UTC
(In reply to Timur from comment #8)
> Hello Michael. 
> Please see Bug 137510, looks similar. 

That actually sounds similar, will keep it in mind but don't really have time to look deeper into it at the moment.

> I wanted to verify this one but attached odt is not mail merge document. 
> Otoh, bug 124550 seems duplicate by version.

The attached doc just uses the "page count" statistics field, which was already enough to reproduce the issue. It wasn't even necessary to insert any data from an actual data source, i.e. you could choose anyone you like to reproduce, the actual data in it don't matter.