summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-12-09 17:01:19 +0100
committerMichael Stahl <mstahl@redhat.com>2015-12-15 17:44:35 +0100
commita7762b56c0f0605d090ed95069db16c6641f769e (patch)
treefcce507d13cc75e30a60ef1b4d125332ae309990 /sw
parent8831281942b0ffe3dbdcea6febcda97a2ab665b3 (diff)
sw: move ProgId parsing to DocxExport::WriteOLEObject
Change-Id: Ieb308d717aa661fa51bd1b9dd3d0a12ca61337c1
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx95
-rw-r--r--sw/source/filter/ww8/docxexport.cxx103
-rw-r--r--sw/source/filter/ww8/docxexport.hxx2
3 files changed, 105 insertions, 95 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d9b45e8939f5..d65d9dbd6f83 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4752,7 +4752,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 )
{
@@ -4772,99 +4772,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 if (sProgID == "AcroExch.Document.11")
- {
- sMediaType = "application/pdf";
- sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
- sFileExtension = "pdf";
- }
- 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() )
{
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 109b36d3f7f3..3e77d9ae4c68 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -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 );
+ 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()
.append( "word/" )
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index a4315d702c5e..169759d67aa2 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -170,7 +170,7 @@ public:
/// Returns the relationd id
OString OutputChart( css::uno::Reference< css::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.