Bug 106959 - MAILMERGE: if output saved as individual documents the second document is identical to the first one if document starts with table
Summary: MAILMERGE: if output saved as individual documents the second document is ide...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected) release
Hardware: All All
: medium normal
Assignee: Not Assigned
Keywords: bibisected, regression
: 139072 (view as bug list)
Depends on:
Blocks: Mail-Merge
  Show dependency treegraph
Reported: 2017-04-04 21:27 UTC by Braciolo
Modified: 2021-10-07 10:09 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:
Regression By:

Example of db to test the bug (8.08 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-04-20 17:40 UTC, Braciolo
Example of mail merge odt (with table) to test the bug (8.31 KB, application/vnd.oasis.opendocument.text)
2017-04-20 17:45 UTC, Braciolo

Note You need to log in before you can comment on or make changes to this bug.
Description Braciolo 2017-04-04 21:27:41 UTC
In mail merge with a simple document, even with only a merge field, if the document contains a table in the top of the page (before the fields) when you "Save merged documents" as individual documents, you obtain the exact number of output files, but the first and the second files are identical (in the content) and related to the first record of data. The last obtained file contains the merged content of the 2 last records of data. The behavior returns normal when the table is removed from the mail merge master document.
The same "tabled" document merged with Openoffice does not present this  behavior. 

Steps to Reproduce:
1. create a new empty writer document (odt);
2. with Tools -> "Mail Merge Wizard" select an  "Address List" (a simple ods file with a field of data);
3. insert a table on the top of the page;
4. open "Data Sources" (CTRL+SHIFT+F4);
5. insert the field in the document with drag and drop after the table position;
6. on the "Mail Merge toolbar" select "Save merged documents" -> "Save as individual document" -> Save Documents;
7. select a name for merged individual files; 

Actual Results:  
The number of the files obtained is correct (the same of the rows of data).
The first and the second file (name_0, name_1) have the same content, if the rows of data contains [1,2,3,..,n] the first and the second file refer to the same value of data "1". The last file name_n-1 contains 2 pages with value of n-1 and n rows data.

Expected Results:
The first file contains the first data row.
The second file contains the second data row.
The last file contains the last data row.

Reproducible: Always

User Profile Reset: No

Additional Info:
If the table (on the top of the page) is deleted the behavior of mail merge becomes normal.

User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Braciolo 2017-04-20 17:40:26 UTC
Created attachment 132720 [details]
Example of db to test the bug

Simple db to test writer bug
Comment 2 Braciolo 2017-04-20 17:45:22 UTC
Created attachment 132721 [details]
Example of mail merge odt (with table) to test the bug

Use this odt file with the db (other attachment) to test the behavior of writer
Comment 3 Timur 2017-07-13 17:01:00 UTC Comment hidden (obsolete)
Comment 4 Timur 2017-07-13 17:19:29 UTC Comment hidden (obsolete)
Comment 5 Timur 2017-07-14 09:21:56 UTC
Whatever the cause of this bug is, it still exists with 6.0+. 
Looks like the cause is table before field, and even that only if document starts with the table. If there's line before, not reproduced. 
I reproduced on yours and on the other example, like my data source. Repro with 4.4.0 so bibisect hopefully possible.
I change the generic title to point to table issue.
Comment 6 Braciolo 2017-07-17 13:21:17 UTC
Thanks for the attention, now the bug's title is clearer. The bug is especially dangerous if you use the automatic sending of emails with custom attachments, a person's attachment might be sent to others with privacy issues.
Comment 7 Buovjaga 2018-05-24 12:21:25 UTC
Bibisected on Windows to range https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=1964870db4ad1e4334e8fc5050795469dc1fb05e...64f186cfda29d3d92c0ebd9c4ee7992898a00134

of which https://cgit.freedesktop.org/libreoffice/core/commit/?id=c808802e94eba48dc23d7fca133ed35c17feb163 seems to be the cause

commit c808802e94eba48dc23d7fca133ed35c17feb163 (patch)
tree 8faaf4dfaec9a046137d57eb084d0d74f9afca66
parent 8e174eab91acec0f1578af4dac23be76dce700af (diff)
MM: introduce SwDoc::Append helper function
This drops all the specialized, workaround code from MM, introduced
to use the SwFEShell::Paste function and additionally merges
and renames SwDoc::Paste into SwDoc::Append.

There is still a little common codepath, therefore this adds
comments to always update both functions.

Change-Id: I704b3ef3257dd977dac95e16e25049ff8ade97ed
Reviewed-on: https://gerrit.libreoffice.org/10967

Adding Jan-Marek to CC
Comment 8 QA Administrators 2019-05-25 02:56:54 UTC Comment hidden (obsolete)
Comment 9 NISZ LibreOffice Team 2020-05-04 15:04:09 UTC
Still happens in

Version: (x64)
Build ID: a40455528c4ec2c079444f320a02d1946e1d8ac9
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: GL; VCL: win; 
Locale: hu-HU (hu_HU); UI-Language: en-US
Calc: CL
Comment 10 NISZ LibreOffice Team 2021-09-13 14:50:26 UTC
*** Bug 139072 has been marked as a duplicate of this bug. ***
Comment 11 Oleg Shchelykalnov 2021-10-07 10:09:55 UTC
Got similar issue when use MailMerge and XMailMergeListener to fill text fields. When I use individual document text field stores Content and Value property from previous row. If I use merged document issue doesn't occur.