Kaydet (Commit) a7762b56 authored tarafından Michael Stahl's avatar Michael Stahl

sw: move ProgId parsing to DocxExport::WriteOLEObject

Change-Id: Ieb308d717aa661fa51bd1b9dd3d0a12ca61337c1
üst 88312819
...@@ -4752,7 +4752,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S ...@@ -4752,7 +4752,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
OUString sObjectName = aContainer->GetEmbeddedObjectName( xObj ); OUString sObjectName = aContainer->GetEmbeddedObjectName( xObj );
// set some attributes according to the type of the embedded object // 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 ) for( sal_Int32 i=0; i < aObjectsInteropList.getLength(); ++i )
if ( aObjectsInteropList[i].Name == sObjectName ) if ( aObjectsInteropList[i].Name == sObjectName )
{ {
...@@ -4772,99 +4772,8 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S ...@@ -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 // write embedded file
OString sId = m_rExport.WriteOLEObject( aObject, sMediaType, sRelationType, sFileExtension ); OString sId = m_rExport.WriteOLEObject(aObject, sProgID);
if( sId.isEmpty() ) if( sId.isEmpty() )
{ {
......
...@@ -366,12 +366,113 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_In ...@@ -366,12 +366,113 @@ OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_In
return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); 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() ); uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() );
comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer(); comphelper::EmbeddedObjectContainer* aContainer = rObject.GetObject().GetContainer();
uno::Reference< io::XInputStream > xInStream = aContainer->GetObjectStream( xObj ); 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; OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sFileExtension;
uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer() uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream( OUStringBuffer()
.append( "word/" ) .append( "word/" )
......
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
/// Returns the relationd id /// Returns the relationd id
OString OutputChart( css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr m_pSerializer ); 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 ); static bool lcl_CopyStream( css::uno::Reference< css::io::XInputStream> xIn, css::uno::Reference< css::io::XOutputStream > xOut );
/// Writes the shape using drawingML syntax. /// 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