Download it now!
Bug 118113 - MAILMERGE: Conditionally hidden section leads to anchoring to wrong page
Summary: MAILMERGE: Conditionally hidden section leads to anchoring to wrong page
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4 all versions
Hardware: All All
: medium normal
Assignee: Michael Weghorn
URL:
Whiteboard: target:6.2.0 target:6.1.0.1
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-11 14:26 UTC by Michael Weghorn
Modified: 2018-06-12 18:18 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample fle with hidden sections and a text box anchored to the page (20.55 KB, application/vnd.oasis.opendocument.text)
2018-06-11 14:26 UTC, Michael Weghorn
Details
Sample recipient data for the mail merge (7.46 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-06-11 14:27 UTC, Michael Weghorn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weghorn 2018-06-11 14:26:49 UTC
Created attachment 142657 [details]
Sample fle with hidden sections and a text box anchored to the page

Using mail merge on a document that contains objects anchored to the page and sections that are hidden for some of the recipients may result in the objects being anchored to the wrong pages in the resulting merged document.

Steps to reproduce:

1) open attached document "sample_mail_merge_with_hidden_section.odt"
2) run the Mail Merge wizard:
    * select "Tools" -> "Mail Merge Wizard"
    * select "Use the current document" -> "Next"
    * keep "Letter" for the type of document to create -> "Next"
    * select data source:
        * choose "Select Address List"
        * select "Add" and select the attached file "4-recipients.ods"
        * click "OK" to confirm to use this as the address list
        * make sure "This document shall contain an address block" is unselected -> "Next"
    * make sure "This document should contain a salutation" is unselected -> "Finish"
3) select "Save Merged Documents" in the mail merge toolbar
4) select to save as a single large document and click "Save Documents"
5) Once the document has been generated, choose a file name of your choice to save the generated document to.
6) Open the generated odt file

Result:

* The generated document has 13 pages (only 10 pages are actually "visible", the other 3 pages were inserted to make sure the content for each of the 4 data records starts on an odd page number).
* The content for the single data records starts on pages 1, 3, 5, and 9. (This is expected.)
* The text boxes are anchored to pages 1, 5, 9, and 13, which means this does not match the pages on which the content for the single data records starts.
* The 4 last pages are empty except for the last text box that is anchored to page 13.

Expected result:

* The document should contain 9 pages. The 4 last pages from the actual result should not be there at all.
* The content for the single data records starts on pages 1, 3, 5, and 9. (This is already the case.)
* The text boxes should be anchored to pages 1, 3, 5, and 9 (one text box at the start of the content for each of the 4 data records).
Comment 1 Michael Weghorn 2018-06-11 14:27:24 UTC
Created attachment 142658 [details]
Sample recipient data for the mail merge
Comment 2 Michael Weghorn 2018-06-11 14:31:47 UTC
The cause of the problem is that the amount of pages in the merged document differs for the single data records, as there is a text section that is hidden when the value in the column "Hidden" in the recipient data is "True".
There is just a single page of content if the section is hidden, while there is three pages of content when the section is not hidden.

I have analyzed the problem and plan to create a change in Gerrit soon.
Comment 3 Michael Weghorn 2018-06-11 15:43:47 UTC
Gerrit change: https://gerrit.libreoffice.org/55636

Feedback is highly welcome, since most of this is quite new to me...
Comment 4 Xisco Faulí 2018-06-11 16:49:23 UTC
(In reply to Michael Weghorn from comment #3)
> Gerrit change: https://gerrit.libreoffice.org/55636
> 
> Feedback is highly welcome, since most of this is quite new to me...

Thanks for the patch. Setting to ASSIGNED then. Review will take place in gerrit.
Comment 5 Commit Notification 2018-06-12 12:07:45 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=89f896d2cfd84b711583f98a6343e9835a9aed11

tdf#118113 MM: Make sure page count is up to date

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2018-06-12 12:09:07 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ab665e1c939ec231338f9eac256d37cb1c5afcc9

tdf#118113 Add unit test

It will be available in 6.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2018-06-12 18:16:17 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e8a46b0171a49e6b49a2e7b89c8bdfef84ef41ef&h=libreoffice-6-1

tdf#118113 MM: Make sure page count is up to date

It will be available in 6.1.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.