Bug 108269 - DOCM files can't be opened in Word after a roundtrip in Writer (until renaming)
Summary: DOCM files can't be opened in Word after a roundtrip in Writer (until renaming)
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: All All
: medium normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:5.4.0.1 target:5.5.0
Keywords: filter:docx
Depends on:
Blocks: DOCX-Corrupted
  Show dependency treegraph
 
Reported: 2017-05-31 16:22 UTC by Aron Budea
Modified: 2017-06-08 06:04 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
DOCM with macro (19.71 KB, application/vnd.ms-word.document.macroEnabled.12)
2017-05-31 16:23 UTC, Aron Budea
Details
DOCM with no macro (15.59 KB, application/vnd.ms-word.document.macroEnabled.12)
2017-05-31 16:24 UTC, Aron Budea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2017-05-31 16:22:47 UTC
Known limitations (not a concern of this bug report):
- Writer doesn't handle VBA macros.
- It doesn't even preserve macros (seems like section "You can choose to preserve or delete VBA macros" in [1] is not valid for newer, OOXML formats, at least in Writer).

Open and save the attached files in Writer. Both are DOCMs created in Word 2013, one has macro, the other doesn't.
Open the roundtripped file in Word.

=> Word gives an error: "We're sorry. We can't open <file name> because we found a problem with its contents."
The file can only be opened after renaming it to have .DOCX extension.

One particular difference is that in the original archive /word/document.xml has ContentType "application/vnd.ms-word.document.macroEnabled.main+xml", while in the roundtripped file it's "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml".

Observed with 5.4beta1 and 4.0.0.3 / Windows 7.

[1] https://help.libreoffice.org/Common/Using_Microsoft_Office_and
Comment 1 Aron Budea 2017-05-31 16:23:40 UTC
Created attachment 133753 [details]
DOCM with macro
Comment 2 Aron Budea 2017-05-31 16:24:24 UTC
Created attachment 133754 [details]
DOCM with no macro
Comment 3 Michael Meeks 2017-05-31 17:55:36 UTC
Interestingly, just changing the ContentType in [Content_Types].xml is sufficient for Word to import this for me without problems, even with the docm suffix. Presumably this is reasonably easy to do - I'll take a look.
Comment 4 Michael Meeks 2017-06-01 02:48:43 UTC
Hi Miklos,
   Any chance you can take a look ? the quick / horrible hack is to add to:

        DocxExportFilter::exportDocument

   a quick check for .docm at the end of getFileUrl() - but that, while functional would be pretty nasty I think.

   I imagine the best way is to add a 'Macro' variant of OOXML - complete with filter fragments, etc. and to update the oox/source/core/filterdetect.cxx to detect that, and so on (?) - that should let us manually save in that format as well. Clearly this also needs doing for XLSM / PPTM as well - albeit at a lower urgency for C'bra.

   Thanks !

       Michael.
Comment 5 Miklos Vajna 2017-06-01 10:25:33 UTC
<https://gerrit.libreoffice.org/#/c/38298/> adds a docm filter, then it's easy to act accordingly in the export code.

I checked that the oox filter detection already differentiates for xlsx/xlsm. For pptx/pptm I would suggest to use a follow-up bug.
Comment 6 Miklos Vajna 2017-06-01 12:09:10 UTC
https://gerrit.libreoffice.org/gitweb?p=core.git;a=commitdiff;h=697173f6fdfae581022cfdb5ec5171c5a3be58f0 fixes this on master, just forgot to mention the bug number in the commit message.
Comment 7 Commit Notification 2017-06-01 13:42:47 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0e6ecd59ec0767fc74cec37512bacaabc3cd1f9d&h=libreoffice-5-4

tdf#108269 sw: add separate DOCM filter

It will be available in 5.4.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.
Comment 8 Commit Notification 2017-06-02 12:54:40 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

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

Related: tdf#108269 oox: allow recovering broken DOCM files

It will be available in 5.5.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 9 Commit Notification 2017-06-02 19:31:43 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

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

Related: tdf#108269 DOCM filter: preserve VBA stream

It will be available in 5.5.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 10 Commit Notification 2017-06-06 09:31:56 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=32f45f1bca454659d17dea80499b635a43ae4490&h=libreoffice-5-4

Related: tdf#108269 oox: allow recovering broken DOCM files

It will be available in 5.4.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.
Comment 11 Commit Notification 2017-06-06 12:10:03 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

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

Related: tdf#108269 oox: ignore case when checking .docm extension

It will be available in 5.5.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 12 Commit Notification 2017-06-07 02:42:17 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=81451bb88855e575fc9a2f5c1e91254c15f07cb9&h=libreoffice-5-4

Related: tdf#108269 oox: ignore case when checking .docm extension

It will be available in 5.4.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.
Comment 13 Commit Notification 2017-06-07 02:49:48 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=35c3dfddf9933809525540d02484c2754510f6d9&h=libreoffice-5-4

Related: tdf#108269 DOCM filter: preserve VBA stream

It will be available in 5.4.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.
Comment 14 Commit Notification 2017-06-07 12:49:48 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

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

Related: tdf#108269 DOCM filter: reuse oox code for VBA preservation

It will be available in 5.5.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 15 Commit Notification 2017-06-07 17:08:32 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

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

Related: tdf#108269 DOCM filter: reuse oox code for VBA data preservation

It will be available in 5.5.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 16 Commit Notification 2017-06-08 06:04:47 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9af01c56237b716c7f3bfe4664fd1ca1cd87edde&h=libreoffice-5-4

Related: tdf#108269 DOCM filter: reuse oox code for VBA preservation

It will be available in 5.4.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.
Comment 17 Commit Notification 2017-06-08 06:04:53 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=538186004a1201f4881a64cdf5d905a24f86bfb1&h=libreoffice-5-4

Related: tdf#108269 DOCM filter: reuse oox code for VBA data preservation

It will be available in 5.4.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.