summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-06-02 10:57:23 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-06-02 14:53:29 +0200
commit97fa7024ce608b7908aca369e8c643a5de9ebf78 (patch)
tree72e7cff11d04d90b3b4a6a4f756d1e18e22018e7 /sw
parentf883a6b420efa7ed099448f7e6e5cadaa3bb275b (diff)
Related: tdf#108269 oox: allow recovering broken DOCM files
The content type inside an OOXML file differs for DOCX and DOCM. These must be in sync with the file extension, otherwise MSO refuses to open the file. We used to always write the DOCX content-type even for files which had the DOCM extension. Allow users to recover those broken files by detecting a "has docm extension but docx content-type" file as docm, so re-saving it will produce output that's accepted by MSO as well. Change-Id: I7d60c6f6c1d0421e95b3dc9e8fff617f101919f5 Reviewed-on: https://gerrit.libreoffice.org/38342 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/bad.docmbin0 -> 9672 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx11
2 files changed, 11 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/bad.docm b/sw/qa/extras/ooxmlexport/data/bad.docm
new file mode 100644
index 000000000000..b1e83220aa83
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/bad.docm
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 9d1a5e161fcc..0191b8a38023 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -24,6 +24,9 @@
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+
class Test : public SwModelTestBase
{
public:
@@ -82,6 +85,14 @@ DECLARE_SW_ROUNDTRIP_TEST(testDocmSave, "hello.docm", nullptr, DocmTest)
"application/vnd.ms-word.document.macroEnabled.main+xml");
}
+DECLARE_SW_ROUNDTRIP_TEST(testBadDocm, "bad.docm", nullptr, DocmTest)
+{
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ // This was 'MS Word 2007 XML', broken docm files were not recognized.
+ CPPUNIT_ASSERT_EQUAL(OUString("MS Word 2007 XML VBA"), pTextDoc->GetDocShell()->GetMedium()->GetFilter()->GetName());
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx")
{
// This was true, <w:effect w:val="none"/> resulted in setting the blinking font effect.