From a3c00ee3c7b3b0fbcde32baeb7023c7e8526b908 Mon Sep 17 00:00:00 2001 From: Ravindra Vidhate Date: Tue, 22 Apr 2014 15:28:46 +0530 Subject: fdo#77759 : Embedded excel getting renamed to binary object. The embedded excel (xlsx) when inserted on its own (unlike with chart) is getting converted to ".bin". Note that only extension differs otherwise its an excel file only. There is no loss of user experience in editing the file in MS Word. The similar case is also exists when power point is inserted on it's own. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/9126 Change-Id: Ie13c098a794179c3b27100a7b9e30884fb47f656 --- sw/qa/extras/ooxmlexport/data/fdo77759.docx | Bin 0 -> 23880 bytes sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 +++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 7 +++++-- sw/source/filter/ww8/docxexport.cxx | 4 ++-- sw/source/filter/ww8/docxexport.hxx | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/fdo77759.docx (limited to 'sw') diff --git a/sw/qa/extras/ooxmlexport/data/fdo77759.docx b/sw/qa/extras/ooxmlexport/data/fdo77759.docx new file mode 100644 index 000000000000..6558690690a8 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo77759.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 31fd36badc1e..18f91a8ce92a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3225,6 +3225,19 @@ DECLARE_OOXMLEXPORT_TEST(testFDO75431, "fdo75431.docx") assertXPath(pXmlDoc, "//w:p/w:pPr/w:sectPr/w:type", "val", "nextPage"); } +DECLARE_OOXMLEXPORT_TEST(testContentTypeOLE, "fdo77759.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']", + "PartName", + "/word/embeddings/oleObject1.xlsx"); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a4679f7e9fd4..27835b308780 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4011,7 +4011,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S OUString sObjectName = aContainer->GetEmbeddedObjectName( xObj ); // set some attributes according to the type of the embedded object - OUString sProgID, sMediaType, sRelationType; + OUString sProgID, sMediaType, sRelationType, sFileExtension; for( sal_Int32 i=0; i < aObjectsInteropList.getLength(); ++i ) if ( aObjectsInteropList[i].Name == sObjectName ) { @@ -4022,20 +4022,23 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S { sMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + sFileExtension = "xlsx"; } else if( sProgID.startsWith("PowerPoint.Show") ) { sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; + sFileExtension = "pptx"; } else { sMediaType = "application/vnd.openxmlformats-officedocument.oleObject"; sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + sFileExtension = "bin"; } // write embedded file - OString sId = m_rExport.WriteOLEObject( aObject, sMediaType, sRelationType ); + OString sId = m_rExport.WriteOLEObject( aObject, sMediaType, sRelationType, sFileExtension ); if( sId.isEmpty() ) { diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index ff74f3a4800a..c3a6ddf93678 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -358,13 +358,13 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_In return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); } -OString DocxExport::WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType ) +OString DocxExport::WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType, const OUString& sFileExtension ) { uno::Reference xObj( rObject.GetOleRef() ); comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer(); uno::Reference< io::XInputStream > xInStream = aContainer->GetObjectStream( xObj, NULL ); - OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + ".bin"; + OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sFileExtension; uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer() .appendAscii( "word/" ) .append( sFileName ) diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 2c55b2b3e0e7..cd5450ed7cc4 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -168,7 +168,7 @@ public: /// Returns the relationd id OString OutputChart( com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr m_pSerializer ); - OString WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType ); + OString WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType, const OUString& sFileExtension ); bool lcl_CopyStream( css::uno::Reference< css::io::XInputStream> xIn, css::uno::Reference< css::io::XOutputStream > xOut ); /// Writes the shape using drawingML syntax. -- cgit