|
|
a1bd173 |
From c8c52960f1a23e6871504f890ca33ea0d19557b2 Mon Sep 17 00:00:00 2001
|
|
|
a1bd173 |
From: Michael Stahl <mstahl@redhat.com>
|
|
|
a1bd173 |
Date: Wed, 2 Dec 2015 16:00:58 +0100
|
|
|
a1bd173 |
Subject: [PATCH 3/6] sw: move ProgId parsing to DocxExport::WriteOLEObject
|
|
|
a1bd173 |
|
|
|
a1bd173 |
(cherry picked from commit a7762b56c0f0605d090ed95069db16c6641f769e)
|
|
|
a1bd173 |
(cherry picked from commit 6768b669bafa62fe94a81971285e12823c3716e6)
|
|
|
a1bd173 |
|
|
|
a1bd173 |
sw: docx export: write something more specific for embedded PDF
|
|
|
a1bd173 |
|
|
|
a1bd173 |
Doesn't really change anything, but looks nicer.
|
|
|
a1bd173 |
|
|
|
a1bd173 |
(cherry picked from commit 6c569a2ed797aa7ad52f8a7dc6be3bfb3b4b452a)
|
|
|
a1bd173 |
(cherry picked from commit f8e628ab3993024e5e5885f99b5e9ebb2c30d467)
|
|
|
a1bd173 |
|
|
|
a1bd173 |
Change-Id: Ieb308d717aa661fa51bd1b9dd3d0a12ca61337c1
|
|
|
a1bd173 |
Reviewed-on: https://gerrit.libreoffice.org/20758
|
|
|
a1bd173 |
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
|
|
|
a1bd173 |
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
|
|
|
a1bd173 |
---
|
|
|
a1bd173 |
sw/source/filter/ww8/docxattributeoutput.cxx | 89 +----------------------
|
|
|
a1bd173 |
sw/source/filter/ww8/docxexport.cxx | 103 ++++++++++++++++++++++++++-
|
|
|
a1bd173 |
sw/source/filter/ww8/docxexport.hxx | 2 +-
|
|
|
a1bd173 |
3 files changed, 105 insertions(+), 89 deletions(-)
|
|
|
a1bd173 |
|
|
|
a1bd173 |
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
|
|
|
a1bd173 |
index 049d280..19eb879 100644
|
|
|
a1bd173 |
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
|
|
|
a1bd173 |
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
|
|
|
a1bd173 |
@@ -4670,7 +4670,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
|
|
|
a1bd173 |
OUString sObjectName = aContainer->GetEmbeddedObjectName( xObj );
|
|
|
a1bd173 |
|
|
|
a1bd173 |
// set some attributes according to the type of the embedded object
|
|
|
a1bd173 |
- OUString sProgID, sMediaType, sRelationType, sFileExtension, sDrawAspect="Content";
|
|
|
a1bd173 |
+ OUString sProgID, sDrawAspect = "Content";
|
|
|
a1bd173 |
for( sal_Int32 i=0; i < aObjectsInteropList.getLength(); ++i )
|
|
|
a1bd173 |
if ( aObjectsInteropList[i].Name == sObjectName )
|
|
|
a1bd173 |
{
|
|
|
a1bd173 |
@@ -4690,93 +4690,8 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
|
|
|
a1bd173 |
}
|
|
|
a1bd173 |
}
|
|
|
a1bd173 |
|
|
|
a1bd173 |
- if( sProgID == "Excel.Sheet.12" )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "xlsx";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if(sProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "xlsb";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID.startsWith("Excel.SheetMacroEnabled.12") )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "xlsm";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID.startsWith("Excel.Sheet") )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-excel";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
- sFileExtension = "xls";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID == "PowerPoint.Show.12" )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "pptx";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if(sProgID == "PowerPoint.ShowMacroEnabled.12")
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "pptm";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID.startsWith("PowerPoint.Show") )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-powerpoint";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
- sFileExtension = "ppt";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if (sProgID.startsWith("PowerPoint.Slide.12"))
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.slide";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "sldx";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID == "PowerPoint.SlideMacroEnabled.12" )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "sldm";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID == "Word.DocumentMacroEnabled.12" )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-word.document.macroEnabled.12";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "docm";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if (sProgID == "Word.Document.12")
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
- sFileExtension = "docx";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID == "Word.Document.8" )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/msword";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
- sFileExtension = "doc";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else if( sProgID == "Excel.Chart.8" )
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.ms-excel";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
- sFileExtension = "xls";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
- else
|
|
|
a1bd173 |
- {
|
|
|
a1bd173 |
- sMediaType = "application/vnd.openxmlformats-officedocument.oleObject";
|
|
|
a1bd173 |
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
- sFileExtension = "bin";
|
|
|
a1bd173 |
- }
|
|
|
a1bd173 |
-
|
|
|
a1bd173 |
// write embedded file
|
|
|
a1bd173 |
- OString sId = m_rExport.WriteOLEObject( aObject, sMediaType, sRelationType, sFileExtension );
|
|
|
a1bd173 |
+ OString sId = m_rExport.WriteOLEObject(aObject, sProgID);
|
|
|
a1bd173 |
|
|
|
a1bd173 |
if( sId.isEmpty() )
|
|
|
a1bd173 |
{
|
|
|
a1bd173 |
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
|
|
|
a1bd173 |
index 1525eaa..df8401d 100644
|
|
|
a1bd173 |
--- a/sw/source/filter/ww8/docxexport.cxx
|
|
|
a1bd173 |
+++ b/sw/source/filter/ww8/docxexport.cxx
|
|
|
a1bd173 |
@@ -366,12 +366,113 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_In
|
|
|
a1bd173 |
return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
|
|
|
a1bd173 |
}
|
|
|
a1bd173 |
|
|
|
a1bd173 |
-OString DocxExport::WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType, const OUString& sFileExtension )
|
|
|
a1bd173 |
+
|
|
|
a1bd173 |
+static void lcl_ConvertProgID(OUString const& rProgID,
|
|
|
a1bd173 |
+ OUString & o_rMediaType, OUString & o_rRelationType, OUString & o_rFileExtension)
|
|
|
a1bd173 |
+{
|
|
|
a1bd173 |
+ if (rProgID == "Excel.Sheet.12")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "xlsx";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") )
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "xlsb";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID.startsWith("Excel.SheetMacroEnabled.12"))
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "xlsm";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID.startsWith("Excel.Sheet"))
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-excel";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
+ o_rFileExtension = "xls";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "PowerPoint.Show.12")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "pptx";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "PowerPoint.ShowMacroEnabled.12")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "pptm";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID.startsWith("PowerPoint.Show"))
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-powerpoint";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
+ o_rFileExtension = "ppt";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID.startsWith("PowerPoint.Slide.12"))
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.openxmlformats-officedocument.presentationml.slide";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "sldx";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "PowerPoint.SlideMacroEnabled.12")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "sldm";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "Word.DocumentMacroEnabled.12")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-word.document.macroEnabled.12";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "docm";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "Word.Document.12")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
|
|
|
a1bd173 |
+ o_rFileExtension = "docx";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "Word.Document.8")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/msword";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
+ o_rFileExtension = "doc";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "Excel.Chart.8")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.ms-excel";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
+ o_rFileExtension = "xls";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else if (rProgID == "AcroExch.Document.11")
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/pdf";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
+ o_rFileExtension = "pdf";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+ else
|
|
|
a1bd173 |
+ {
|
|
|
a1bd173 |
+ o_rMediaType = "application/vnd.openxmlformats-officedocument.oleObject";
|
|
|
a1bd173 |
+ o_rRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
|
|
|
a1bd173 |
+ o_rFileExtension = "bin";
|
|
|
a1bd173 |
+ }
|
|
|
a1bd173 |
+}
|
|
|
a1bd173 |
+
|
|
|
a1bd173 |
+OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID)
|
|
|
a1bd173 |
{
|
|
|
a1bd173 |
uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() );
|
|
|
a1bd173 |
comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer();
|
|
|
a1bd173 |
uno::Reference< io::XInputStream > xInStream = aContainer->GetObjectStream( xObj, NULL );
|
|
|
a1bd173 |
|
|
|
a1bd173 |
+ OUString sMediaType;
|
|
|
a1bd173 |
+ OUString sRelationType;
|
|
|
a1bd173 |
+ OUString sFileExtension;
|
|
|
a1bd173 |
+ lcl_ConvertProgID(rProgID, sMediaType, sRelationType, sFileExtension);
|
|
|
a1bd173 |
+
|
|
|
a1bd173 |
OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sFileExtension;
|
|
|
a1bd173 |
uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer()
|
|
|
a1bd173 |
.appendAscii( "word/" )
|
|
|
a1bd173 |
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
|
|
|
a1bd173 |
index ef8ba4c..8705358 100644
|
|
|
a1bd173 |
--- a/sw/source/filter/ww8/docxexport.hxx
|
|
|
a1bd173 |
+++ b/sw/source/filter/ww8/docxexport.hxx
|
|
|
a1bd173 |
@@ -173,7 +173,7 @@ public:
|
|
|
a1bd173 |
|
|
|
a1bd173 |
/// Returns the relationd id
|
|
|
a1bd173 |
OString OutputChart( com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr m_pSerializer );
|
|
|
a1bd173 |
- OString WriteOLEObject( SwOLEObj& rObject, const OUString& sMediaType, const OUString& sRelationType, const OUString& sFileExtension );
|
|
|
a1bd173 |
+ OString WriteOLEObject(SwOLEObj& rObject, OUString const& rProgID);
|
|
|
a1bd173 |
static bool lcl_CopyStream( css::uno::Reference< css::io::XInputStream> xIn, css::uno::Reference< css::io::XOutputStream > xOut );
|
|
|
a1bd173 |
|
|
|
a1bd173 |
/// Writes the shape using drawingML syntax.
|
|
|
a1bd173 |
--
|
|
|
a1bd173 |
2.5.0
|
|
|
a1bd173 |
|