From e564f58b789139c7609facd0bea88f0b651b5153 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Sat, 19 Dec 2015 00:11:28 +0100 Subject: sw: remove that silly lcl_CopyStream Change-Id: I0a357d5c4a2ff46e5203ba045b9550285e33943e --- sw/source/filter/ww8/docxexport.cxx | 42 +++++++++++++------------------------ sw/source/filter/ww8/docxexport.hxx | 1 - 2 files changed, 14 insertions(+), 29 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index f0a931ca0678..2c04e3f82062 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -70,6 +70,7 @@ #include "ww8par.hxx" #include "ww8scan.hxx" #include +#include #include #include #include @@ -393,41 +394,26 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID) GetFilter().openFragmentStream("word/" + sFileName, sMediaType); assert(xOutStream.is()); // no reason why that could fail - bool const isExported = lcl_CopyStream(xInStream, xOutStream); - - OUString sId; - if (isExported) + try + { + ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream); + } + catch (uno::Exception const& e) { - sId = m_pFilter->addRelation( GetFS()->getOutputStream(), + SAL_WARN("sw.ww8", "DocxExport::WriteOLEObject: exception: " << e.Message); + return OString(); + } + + OUString const sId = m_pFilter->addRelation( GetFS()->getOutputStream(), sRelationType, sFileName ); - if (pProgID) - { - io_rProgID = OUString::createFromAscii(pProgID); - } + if (pProgID) + { + io_rProgID = OUString::createFromAscii(pProgID); } return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); } -// function copied from embeddedobj/source/msole/oleembed.cxx -bool DocxExport::lcl_CopyStream( uno::Reference xIn, uno::Reference xOut ) -{ - if( !xIn.is() || !xOut.is() ) - return false; - - const sal_Int32 nChunkSize = 4096; - uno::Sequence< sal_Int8 > aData(nChunkSize); - sal_Int32 nTotalRead = 0; - sal_Int32 nRead = 0; - do - { - nRead = xIn->readBytes(aData, nChunkSize); - nTotalRead += nRead; - xOut->writeBytes(aData); - } while (nRead == nChunkSize); - return nTotalRead != 0; -} - void DocxExport::OutputDML(uno::Reference& xShape) { uno::Reference xServiceInfo(xShape, uno::UNO_QUERY_THROW); diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index cc1854de9e7b..124b62614179 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -171,7 +171,6 @@ 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, OUString & io_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. void OutputDML( css::uno::Reference< css::drawing::XShape >& xShape ); -- cgit v1.2.3