Bug 104819 - Formatting: Corrupt Document/Format After Save When Starting With Empty .docx Document
Summary: Formatting: Corrupt Document/Format After Save When Starting With Empty .docx...
Status: RESOLVED DUPLICATE of bug 123476
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.2.3.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
Depends on:
Blocks: DOCX-Corrupted
  Show dependency treegraph
 
Reported: 2016-12-20 19:20 UTC by junk_2010
Modified: 2021-04-27 06:01 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Corrupted Microsoft .docx After Edits and Save (546 bytes, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-12-20 19:24 UTC, junk_2010
Details
Fine no problem Microsoft .doc file after edits and save (11.00 KB, application/msword)
2016-12-20 19:25 UTC, junk_2010
Details
Fine no problem LibreOffice .odt file after edits and save (11.95 KB, application/vnd.oasis.opendocument.text)
2016-12-20 19:26 UTC, junk_2010
Details
Fine no problem Microsoft .docx file after save from previously edited, saved and closed LibreOffice .odt file (5.47 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-12-20 19:28 UTC, junk_2010
Details
zipped New Microsoft Word Document .docx Created In Folder By Right Mouse Button Click And Menu Item Selection (162 bytes, application/zip)
2016-12-20 20:05 UTC, junk_2010
Details
This DOCX opens fine in MSO 2013 (5.94 KB, application/msword)
2017-01-05 10:28 UTC, Buovjaga
Details
New Microsoft Excel Document .xlsx Created In Folder By Right Mouse Button Click And Menu Item Selection (6.03 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2017-01-08 15:35 UTC, junk_2010
Details
empty New Microsoft Word Document corrupted by writer save (2 bytes, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-01-12 18:50 UTC, junk_2010
Details
Screenshots of options and dialogue box (107.30 KB, application/pdf)
2017-01-21 12:26 UTC, junk_2010
Details

Note You need to log in before you can comment on or make changes to this bug.
Description junk_2010 2016-12-20 19:20:49 UTC
I have been seeing some "strange" behaviour with the text in headers and footers for a few versions. In trying to produce a repeatable example I created the "corruption" below. This example was created using 5.2.3.3 on Windows 10.

The behaviour I was trying to create, which I have seen in both 5.0 and 5.1 was the tab positions in the headers and footers not being saved correctly.

In the example below the "strange" behaviour is more general for the headers and footers and main body text with a new .docx document edited in LibreOffice Writer.

The steps followed:
Create a new Microsoft Word Doc in a folder (using the right mouse button option) on Windows 10 with Microsoft Word from Microsoft Office Professional Plus 2013 (15.0.4875.1001)
Open the document with LibreOffice Writer
Insert -> Header and Footer -> Header -> Default Style
Insert -> Header and Footer -> Footer -> Default Style

In both the header and footer place text:
left justified 0 tab - “Left”
centre justified tab 8.5 - “Middle”
right justified tab 17 - “Right”

Add some text in the main body (ie not the header and footer).
Addng the "->" characters seems to be especially troublesome.

Save document (just a save operation), so re-saves as in original as "Microsoft Word (.docx)" format
Save as document as "Microsoft Word 97-2003 (.doc)" (save as operation)
Save as document "ODF Text Document (.odt)" (save as operation)

Close the existing file and re-open the three saved files in LibreOffice Writer.
The .docx will have no header or footer text and will have other "strange" text formatting corruption. Note that if I try to open this document using Microsoft Word I get the message "We're sorry. We can't open header_footer_tab_bug because we found a problem with its contents."
Details: "The file is corrupt and cannot be opened".

The .doc and .odt files look as expected in LibreOffice Writer.

I also tried from the open .odt file in LibreOffice Writer a save as "Microsoft Word 2007-2013 XML (.docx)". This document opened "fine" and had the expected content in both LibreOffice Writer and Microsoft Word.

Attached files:
1) New Microsoft Word Document.docx - Original blank docx file created in folder in Windows 10.
2) header_footer_tab_bug.docx - "Corrupted" .docx file
3) header_footer_tab_bug.doc - "Fine" .doc file
4) header_footer_tab_bug.odt - "Fine" .odt file
5) header_footer_tab_bug_saved_from_odt_document.docx - "Fine" .docx file saved from re-opened .odt file
Comment 1 junk_2010 2016-12-20 19:24:03 UTC
Created attachment 129819 [details]
Corrupted Microsoft .docx After Edits and Save
Comment 2 junk_2010 2016-12-20 19:25:21 UTC
Created attachment 129820 [details]
Fine no problem Microsoft .doc file after edits and save
Comment 3 junk_2010 2016-12-20 19:26:41 UTC
Created attachment 129821 [details]
Fine no problem LibreOffice .odt file after edits and save
Comment 4 junk_2010 2016-12-20 19:28:10 UTC
Created attachment 129822 [details]
Fine no problem Microsoft .docx file after save from previously edited, saved and closed LibreOffice .odt file
Comment 5 junk_2010 2016-12-20 20:05:46 UTC
Created attachment 129824 [details]
zipped New Microsoft Word Document .docx Created In Folder By Right Mouse Button Click And Menu Item Selection

The system would not allow me to upload the "New Microsoft Word Document.docx" file created in a windows folder by a right mouse button click and menu item selection. This has hightlighted what is probably the cause of the problem described in this ticket, the file is zero size. I have zipped up the file to enable it to be uploaded.

I have checked that if I open a "new" blank word document using Microsoft 2013, make the same edits described in this ticket, then just press the "save" button and close the document, that the document then opens and displays correctly in both Word 2013 and LibreOffice.
Comment 6 Buovjaga 2016-12-31 15:09:03 UTC
(In reply to junk_2010 from comment #5)
> Created attachment 129824 [details]
> zipped New Microsoft Word Document .docx Created In Folder By Right Mouse
> Button Click And Menu Item Selection

For me, it offers to save as Text format. If I save as .DOCX, my created header and footer are intact.
Maybe I could try opening my own produced file in MSO2013 later.

Win 10
Version: 5.2.4.1 (x64)
Build ID: 9b50003582f07ac674d6451e411e9b77cccd2b22
CPU Threads: 4; OS Version: Windows 6.19; UI Render: default; 
Locale: fi-FI (fi_FI); Calc: group

Arch Linux 64-bit, KDE Plasma 5
Version: 5.2.4.2.0+
Build ID: 5.2.4-1
CPU Threads: 8; OS Version: Linux 4.8; UI Render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Comment 7 Buovjaga 2017-01-05 10:28:11 UTC
Created attachment 130167 [details]
This DOCX opens fine in MSO 2013

Yep, my file works in MSO 2013 just fine.
Comment 8 junk_2010 2017-01-08 15:35:19 UTC
Created attachment 130258 [details]
New Microsoft Excel Document .xlsx Created In Folder By Right Mouse Button Click And Menu Item Selection

Note that unlike the "New Microsoft Word" .docx document created in the same way the "New Microsoft Excel Worksheet" .xlsx file is not zero size. It is 7kB. When the "New Microsoft Excel Worksheet" .xlsx file is opened, edited and saved in LibreOffice Calc the resultant document can then be re-opened without any issues in both LibreOffice Calc and Microsoft Excel.

I do not know why the "New Microsoft Word" .docx document was zero size when created, but the situation remains that if I open, edit and save the "New Microsoft Word" .docx document using LibreOffice Writer I end up with an "incorrect/corrupt" document.
However, if instead I use Microsoft Word I end up with a "correct/valid" document.
Comment 9 junk_2010 2017-01-12 18:47:45 UTC
I have checked on another computer running Windows 10 Enterprise Edition, and Microsoft Office Professional Plus 2013, that when a blank Microsoft Word document is created in a folder using the Right Mouse Button form option, it is zero size.

I have also checked that if I open a blank document created in this way in Microsoft Word, and just save it, without making any edits, it is still zero size.

However, if I open it in LibreOffice writer, and just save it, without making any edits, it is 1KB in size. If I then quit LibreOffice and open the saved "empty" document using Microsoft Word 2013, Microsoft Word thinks that the document is corrupt.

Note that when I saved the document in LibreOffice writer I just pressed the "save" icon. It saved with no user prompts.

I will attach this "blank" Microsoft Word document that saving in LibreOffice writer has "corrupted".
Comment 10 junk_2010 2017-01-12 18:50:47 UTC
Created attachment 130367 [details]
empty New Microsoft Word Document corrupted by writer save

"Empty" Microsoft Word Document "corrupted" by undertaking a "save" operation in LibreOffice Writer.
Comment 11 Buovjaga 2017-01-15 15:06:10 UTC
(In reply to junk_2010 from comment #9)
> However, if I open it in LibreOffice writer, and just save it, without
> making any edits, it is 1KB in size. If I then quit LibreOffice and open the
> saved "empty" document using Microsoft Word 2013, Microsoft Word thinks that
> the document is corrupt.
> 
> Note that when I saved the document in LibreOffice writer I just pressed the
> "save" icon. It saved with no user prompts.

Well, it's strange as this is definitely not the case for me.

I created an empty DOCX with the MSO Explorer action. If I open it in LibO and try to simply save, it prompts, if I want to save it as text or ODF.
Comment 12 junk_2010 2017-01-21 12:24:53 UTC
I believe I now understand why I am getting a corrupt document and user Buovjaga is not.

I believe it is dependent on the setting of the option:
"Warn when not saving in ODF or default format"

If the option is unselected, I have the behaviour I reported and end up with a corrupt document.
If the option is selected, I get the behaviour reported by user Buovjaga, with a dialogue box prompting me to save using either "Use Text Format" or "Use ODF Format" format.

I do not believe that the behaviour with the option selected (Dialogue box pop-up) is correct. As I was editing a blank Microsoft Word (.docx) document I would expect to at least have an option to save in the Microsoft Word (.docx) format as well.

This pop-up dialogue box also gives the user the option of unchecking a box:
"Ask when not saving in ODF or default format".
If I uncheck this it unsets the option:
"Warn when not saving in ODF or default format"

I will attached a document showing screenshots of the option and dialogue box.
Comment 13 junk_2010 2017-01-21 12:26:33 UTC
Created attachment 130596 [details]
Screenshots of options and dialogue box
Comment 14 Buovjaga 2017-01-27 14:03:34 UTC
(In reply to junk_2010 from comment #12)
> I believe I now understand why I am getting a corrupt document and user
> Buovjaga is not.
> 
> I believe it is dependent on the setting of the option:
> "Warn when not saving in ODF or default format"

Confirmed.

Tools - options - load/save

Win 8.1 32-bit
MSO 2013
LibO Version: 5.4.0.0.alpha0+
Build ID: b41186a2fc49e440890b8c86e5367352ffaf9cd6
CPU Threads: 4; OS Version: Windows 6.29; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-01-26_01:50:40
Locale: fi-FI (fi_FI); Calc: group
Comment 15 Buovjaga 2017-02-20 10:45:56 UTC
I found an older report.

*** This bug has been marked as a duplicate of bug 90613 ***
Comment 16 Mike Kaganski 2021-04-27 06:01:25 UTC

*** This bug has been marked as a duplicate of bug 123476 ***