Kaydet (Commit) e1b5e32a authored tarafından Ravindra Vidhate's avatar Ravindra Vidhate Kaydeden (comit) Miklos Vajna

fdo#76098 ContentType for .xlsm external data file is wrong

1. Open a File which has Pie Chart in LO.
2. The content type of Pie Chart should Macro Enabled.
3. using LO, SAVE this file.
4. Opened the Save file in MS-Office.
5. The file gets corrupted due to the ContentType gets changed.

Conflicts:
	sw/qa/extras/inc/swmodeltestbase.hxx
Reviewed on:
	https://gerrit.libreoffice.org/8572

Change-Id: I20f92f52cc79df4fc5e10c4e4867e2e704ba3c86
üst 6415f3e7
...@@ -552,6 +552,7 @@ protected: ...@@ -552,6 +552,7 @@ protected:
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rels"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rels"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships"));
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordml")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordml"));
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math"));
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ContentType"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/content-types"));
xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx); xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
return pXmlXpathObj->nodesetval; return pXmlXpathObj->nodesetval;
} }
......
...@@ -2813,6 +2813,18 @@ DECLARE_OOXMLEXPORT_TEST(testNestedAlternateContent, "nestedAlternateContent.doc ...@@ -2813,6 +2813,18 @@ DECLARE_OOXMLEXPORT_TEST(testNestedAlternateContent, "nestedAlternateContent.doc
assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wpg:wgp[1]/wps:wsp[2]/wps:txbx[1]/w:txbxContent[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]",0); assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wpg:wgp[1]/wps:wsp[2]/wps:txbx[1]/w:txbxContent[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]",0);
} }
DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx")
{
xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[2]", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12");
}
#endif #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -1213,10 +1213,15 @@ void DocxExport::WriteEmbeddings() ...@@ -1213,10 +1213,15 @@ void DocxExport::WriteEmbeddings()
OUString embeddingPath = embeddingsList[j].Name; OUString embeddingPath = embeddingsList[j].Name;
uno::Reference<io::XInputStream> embeddingsStream; uno::Reference<io::XInputStream> embeddingsStream;
embeddingsList[j].Value >>= embeddingsStream; embeddingsList[j].Value >>= embeddingsStream;
OUString contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
if (embeddingPath.endsWith(OUString(".xlsm")))
contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";
if ( embeddingsStream.is() ) if ( embeddingsStream.is() )
{ {
uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream(embeddingPath, uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream(embeddingPath,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); contentType);
try try
{ {
sal_Int32 nBufferSize = 512; sal_Int32 nBufferSize = 512;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment