summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/hello.docmbin0 -> 12709 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx33
-rw-r--r--sw/source/filter/ww8/docxexport.cxx12
-rw-r--r--sw/source/filter/ww8/docxexport.hxx5
-rw-r--r--sw/source/filter/ww8/docxexportfilter.cxx7
5 files changed, 51 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/hello.docm b/sw/qa/extras/ooxmlexport/data/hello.docm
new file mode 100644
index 000000000000..a00aa58e7ba5
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/hello.docm
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 8e263e2c9f3d..9d1a5e161fcc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -39,6 +39,15 @@ protected:
}
};
+class DocmTest : public SwModelTestBase
+{
+public:
+ DocmTest()
+ : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "MS Word 2007 XML VBA")
+ {
+ }
+};
+
DECLARE_OOXMLEXPORT_TEST(testFdo55381, "fdo55381.docx")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
@@ -49,6 +58,30 @@ DECLARE_OOXMLEXPORT_TEST(testFdo55381, "fdo55381.docx")
//TODO: frames not located on the correct pages
}
+DECLARE_OOXMLEXPORT_TEST(testDocm, "hello.docm")
+{
+ // Make sure that we check the name of the export filter.
+ // This was application/vnd.ms-word.document.macroEnabled.main+xml when the
+ // name of the import filter was checked.
+ if (xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"))
+ assertXPath(pXmlDoc,
+ "/ContentType:Types/ContentType:Override[@PartName='/word/document.xml']",
+ "ContentType",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml");
+}
+
+DECLARE_SW_ROUNDTRIP_TEST(testDocmSave, "hello.docm", nullptr, DocmTest)
+{
+ // This was
+ // application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml,
+ // we used the wrong content type for .docm files.
+ if (xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"))
+ assertXPath(pXmlDoc,
+ "/ContentType:Types/ContentType:Override[@PartName='/word/document.xml']",
+ "ContentType",
+ "application/vnd.ms-word.document.macroEnabled.main+xml");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx")
{
// This was true, <w:effect w:val="none"/> resulted in setting the blinking font effect.
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index e06585d4ee5a..57432c9add87 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1447,7 +1447,7 @@ void DocxExport::SetFS( ::sax_fastparser::FSHelperPtr const & pFS )
mpFS = pFS;
}
-DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam )
+DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, bool bDocm )
: MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ),
m_pFilter( pFilter ),
m_pAttrOutput( nullptr ),
@@ -1457,7 +1457,8 @@ DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCur
m_nOLEObjects( 0 ),
m_nHeadersFootersInSection(0),
m_pVMLExport( nullptr ),
- m_pSdrExport( nullptr )
+ m_pSdrExport( nullptr ),
+ m_bDocm(bDocm)
{
// Write the document properies
WriteProperties( );
@@ -1466,9 +1467,12 @@ DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCur
m_pFilter->addRelation( oox::getRelationship(Relationship::OFFICEDOCUMENT),
"word/document.xml" );
+ // DOCM needs a different media type for the document.xml stream.
+ OUString aMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
+ if (m_bDocm)
+ aMediaType = "application/vnd.ms-word.document.macroEnabled.main+xml";
// the actual document
- m_pDocumentFS = m_pFilter->openFragmentStreamWithSerializer( "word/document.xml",
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" );
+ m_pDocumentFS = m_pFilter->openFragmentStreamWithSerializer( "word/document.xml", aMediaType );
SetFS(m_pDocumentFS);
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index 99d1368c553f..454e0742cee1 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -100,6 +100,9 @@ class DocxExport : public MSWordExportBase
/// Exporter of drawings.
DocxSdrExport* m_pSdrExport;
+ /// If the result will be a .docm file or not.
+ bool m_bDocm;
+
DocxSettingsData m_aSettings;
public:
@@ -254,7 +257,7 @@ public:
/// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument,
- SwPaM *pCurrentPam, SwPaM *pOriginalPam );
+ SwPaM *pCurrentPam, SwPaM *pOriginalPam, bool bDocm );
/// Destructor.
virtual ~DocxExport() override;
diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx
index 31b58968b591..e0c2522e29e3 100644
--- a/sw/source/filter/ww8/docxexportfilter.cxx
+++ b/sw/source/filter/ww8/docxexportfilter.cxx
@@ -30,6 +30,7 @@
#include <IDocumentLayoutAccess.hxx>
#include <cppuhelper/implementationentry.hxx>
+#include <unotools/mediadescriptor.hxx>
using namespace ::comphelper;
using namespace ::com::sun::star;
@@ -74,10 +75,14 @@ bool DocxExportFilter::exportDocument()
std::unique_ptr<SwPaM> pCurPam( new SwPaM( *aPam.End(), *aPam.Start() ) );
+ OUString aFilterName;
+ getMediaDescriptor()[utl::MediaDescriptor::PROP_FILTERNAME()] >>= aFilterName;
+ bool bDocm = aFilterName.endsWith("VBA");
+
// export the document
// (in a separate block so that it's destructed before the commit)
{
- DocxExport aExport( this, pDoc, pCurPam.get(), &aPam );
+ DocxExport aExport( this, pDoc, pCurPam.get(), &aPam, bDocm );
aExport.ExportDocument( true ); // FIXME support exporting selection only
}