Bug 131527

Summary: FILESAVE DOCX Mail merge field name with starting or ending space saved incorrectly
Product: LibreOffice Reporter: NISZ LibreOffice Team <libreoffice>
Component: WriterAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: dgp-mail, nemeth
Priority: medium Keywords: filter:docx, implementationError
Version: 6.3.0.4 release   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=67207
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 102998    
Attachments: Example file from Writer
The original file saved by Writer to docx
The docx export fixed up by Word 2013
Test data source
Screenshot of the example docx opened in Word – Field with starting space not found
Screenshot of the example docx opened in Word – Field with ending space not found
Example file from Writer - with more characters
The original file saved by Writer to docx
The docx export fixed up by Word 2013
Screenshot of the updated file in Word

Description NISZ LibreOffice Team 2020-03-24 11:27:45 UTC
Created attachment 158919 [details]
Example file from Writer

If a mail merge field name contains a space at the start or end in the data source, inserting in a Writer document results in an incorrect field name that Word can not find in the same data source.
If the field name contains no starting or ending space, Word can find it in the same data source. Upon saving it ignores the starting space and replaces the ending one with an underscore.

Steps to reproduce:
1.	Open attached example document in Writer and save it in DOCX format
2.	Open the document in Word
3.	Choose Mailings – Select Recipients – Use an existing list
4.	Browse the attached data source XLSX
5.	Click Preview Results button in the Mailings ribbon

Actual results:
A dialog pops up that says the Firstname and Lastname fields cannot be found in the data source, asks to choose existing fields.

Expected results:
Data fields are found when Preview Results is selected.

LibreOffice details:
Version: 7.0.0.0.alpha0+ (x64)
Build ID: ec85ed21a960a198a01778cdb89a91fabcb5d0c0
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: GL; VCL: win; 
Locale: en-US (hu_HU); UI-Language: en-US
Calc: CL
Comment 1 NISZ LibreOffice Team 2020-03-24 11:29:48 UTC
Created attachment 158920 [details]
The original file saved by Writer to docx
Comment 2 NISZ LibreOffice Team 2020-03-24 11:30:06 UTC
Created attachment 158921 [details]
The docx export fixed up by Word 2013
Comment 3 NISZ LibreOffice Team 2020-03-24 11:30:43 UTC
Created attachment 158922 [details]
Test data source
Comment 4 NISZ LibreOffice Team 2020-03-24 11:31:03 UTC
Created attachment 158923 [details]
Screenshot of the example docx opened in Word – Field with starting space not found
Comment 5 NISZ LibreOffice Team 2020-03-24 11:31:19 UTC
Created attachment 158924 [details]
Screenshot of the example docx opened in Word – Field with ending space not found
Comment 6 NISZ LibreOffice Team 2020-03-27 12:46:49 UTC
Created attachment 159066 [details]
Example file from Writer - with more characters

Also found that slash and dot are problematic. Replacement field names - if they are the same - are autonumbered.
Comment 7 NISZ LibreOffice Team 2020-03-27 12:47:32 UTC
Created attachment 159067 [details]
The original file saved by Writer to docx
Comment 8 NISZ LibreOffice Team 2020-03-27 12:49:38 UTC
Created attachment 159068 [details]
The docx export fixed up by Word 2013
Comment 9 NISZ LibreOffice Team 2020-03-27 12:52:34 UTC
Created attachment 159069 [details]
Screenshot of the updated file in Word
Comment 10 Dieter 2020-10-18 06:38:34 UTC
I confirm it with

Version: 7.0.2.2 (x64)
Build ID: 8349ace3c3162073abd90d81fd06dcfb6b36b994
CPU threads: 4; OS: Windows 10.0 Build 19041; UI render: Skia/Raster; VCL: win
Locale: he-IL (de_DE); UI: en-GB
Calc: threaded
Comment 11 QA Administrators 2022-10-19 03:33:43 UTC Comment hidden (obsolete)
Comment 12 Dieter 2022-10-21 20:51:23 UTC
Still present in

Version: 7.4.2.3 (x64) / LibreOffice Community
Build ID: 382eef1f22670f7f4118c8c2dd222ec7ad009daf
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL