diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-12-19 00:11:28 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-12-20 00:56:07 +0100 |
commit | e564f58b789139c7609facd0bea88f0b651b5153 (patch) | |
tree | dbd882924d71dffbc6a1893f46a6c54cc195c609 /sw | |
parent | 89e85e5d2ec337aaccfa74bd7017898df42529b4 (diff) |
sw: remove that silly lcl_CopyStream
Change-Id: I0a357d5c4a2ff46e5203ba045b9550285e33943e
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 42 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.hxx | 1 |
2 files changed, 14 insertions, 29 deletions
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 <oox/token/properties.hxx> +#include <comphelper/storagehelper.hxx> #include <comphelper/string.hxx> #include <rtl/ustrbuf.hxx> #include <vcl/font.hxx> @@ -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<io::XInputStream> xIn, uno::Reference<io::XOutputStream> 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<drawing::XShape>& xShape) { uno::Reference<lang::XServiceInfo> 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 ); |