Kaydet (Commit) d68ac7a2 authored tarafından Michael Stahl's avatar Michael Stahl Kaydeden (comit) Andras Timar

sw: move ProgId parsing to DocxExport::WriteOLEObject

(cherry picked from commit a7762b56)
(cherry picked from commit 6768b669)

sw: docx export: write something more specific for embedded PDF

Doesn't really change anything, but looks nicer.

(cherry picked from commit 6c569a2e)
(cherry picked from commit f8e628ab)

Change-Id: Ieb308d717aa661fa51bd1b9dd3d0a12ca61337c1
Reviewed-on: https://gerrit.libreoffice.org/20758Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit c8c52960)
üst 3ce2b3ed
......@@ -4670,7 +4670,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, sFileExtension, sDrawAspect="Content";
OUString sProgID, sDrawAspect = "Content";
for( sal_Int32 i=0; i < aObjectsInteropList.getLength(); ++i )
if ( aObjectsInteropList[i].Name == sObjectName )
{
......@@ -4690,93 +4690,8 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
}
}
if( sProgID == "Excel.Sheet.12" )
{
sMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "xlsx";
}
else if(sProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") )
{
sMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "xlsb";
}
else if( sProgID.startsWith("Excel.SheetMacroEnabled.12") )
{
sMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "xlsm";
}
else if( sProgID.startsWith("Excel.Sheet") )
{
sMediaType = "application/vnd.ms-excel";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
sFileExtension = "xls";
}
else if( sProgID == "PowerPoint.Show.12" )
{
sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "pptx";
}
else if(sProgID == "PowerPoint.ShowMacroEnabled.12")
{
sMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "pptm";
}
else if( sProgID.startsWith("PowerPoint.Show") )
{
sMediaType = "application/vnd.ms-powerpoint";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
sFileExtension = "ppt";
}
else if (sProgID.startsWith("PowerPoint.Slide.12"))
{
sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.slide";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "sldx";
}
else if( sProgID == "PowerPoint.SlideMacroEnabled.12" )
{
sMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "sldm";
}
else if( sProgID == "Word.DocumentMacroEnabled.12" )
{
sMediaType = "application/vnd.ms-word.document.macroEnabled.12";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "docm";
}
else if (sProgID == "Word.Document.12")
{
sMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
sFileExtension = "docx";
}
else if( sProgID == "Word.Document.8" )
{
sMediaType = "application/msword";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
sFileExtension = "doc";
}
else if( sProgID == "Excel.Chart.8" )
{
sMediaType = "application/vnd.ms-excel";
sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
sFileExtension = "xls";
}
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, sFileExtension );
OString sId = m_rExport.WriteOLEObject(aObject, sProgID);
if( sId.isEmpty() )
{
......
......@@ -366,12 +366,113 @@ 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, const OUString& sFileExtension )
static void lcl_ConvertProgID(OUString const& rProgID,
OUString & o_rMediaType, OUString & o_rRelationType, OUString & o_rFileExtension)
{
if (rProgID == "Excel.Sheet.12")
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "xlsx";
}
else if (rProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") )
{
o_rMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "xlsb";
}
else if (rProgID.startsWith("Excel.SheetMacroEnabled.12"))
{
o_rMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "xlsm";
}
else if (rProgID.startsWith("Excel.Sheet"))
{
o_rMediaType = "application/vnd.ms-excel";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
o_rFileExtension = "xls";
}
else if (rProgID == "PowerPoint.Show.12")
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "pptx";
}
else if (rProgID == "PowerPoint.ShowMacroEnabled.12")
{
o_rMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "pptm";
}
else if (rProgID.startsWith("PowerPoint.Show"))
{
o_rMediaType = "application/vnd.ms-powerpoint";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
o_rFileExtension = "ppt";
}
else if (rProgID.startsWith("PowerPoint.Slide.12"))
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.slide";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "sldx";
}
else if (rProgID == "PowerPoint.SlideMacroEnabled.12")
{
o_rMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "sldm";
}
else if (rProgID == "Word.DocumentMacroEnabled.12")
{
o_rMediaType = "application/vnd.ms-word.document.macroEnabled.12";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "docm";
}
else if (rProgID == "Word.Document.12")
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
o_rFileExtension = "docx";
}
else if (rProgID == "Word.Document.8")
{
o_rMediaType = "application/msword";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
o_rFileExtension = "doc";
}
else if (rProgID == "Excel.Chart.8")
{
o_rMediaType = "application/vnd.ms-excel";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
o_rFileExtension = "xls";
}
else if (rProgID == "AcroExch.Document.11")
{
o_rMediaType = "application/pdf";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
o_rFileExtension = "pdf";
}
else
{
o_rMediaType = "application/vnd.openxmlformats-officedocument.oleObject";
o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
o_rFileExtension = "bin";
}
}
OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID)
{
uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() );
comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer();
uno::Reference< io::XInputStream > xInStream = aContainer->GetObjectStream( xObj, NULL );
OUString sMediaType;
OUString sRelationType;
OUString sFileExtension;
lcl_ConvertProgID(rProgID, sMediaType, sRelationType, sFileExtension);
OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sFileExtension;
uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer()
.appendAscii( "word/" )
......
......@@ -173,7 +173,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, const OUString& sFileExtension );
OString WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID);
static bool lcl_CopyStream( css::uno::Reference< css::io::XInputStream> xIn, css::uno::Reference< css::io::XOutputStream > xOut );
/// Writes the shape using drawingML syntax.
......
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