diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-07-21 16:23:29 +0200 |
---|---|---|
committer | Gabor Kelemen <kelemen.gabor2@nisz.hu> | 2020-09-16 20:24:41 +0200 |
commit | ac66e1319732139bb41f65b9755e70c8bc5ee3a4 (patch) | |
tree | 1373ac7c439a3f5fc3343249b0890acc3d8accaf | |
parent | c5080207a83bef2013d76b1f39c7761c99efa8fc (diff) |
tdf#131288 Chart: fix export of embedded xlsx
To avoid exporting a broken DOCX, we have to seek
the 'embeddingsStream', so we avoid to export an empty
(0 Kb) embedded xlsx.
Co-authored-by: Balázs Regényi
Change-Id: I1723091aab3e2070f3db75ce866897e38021718d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99151
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
(cherry picked from commit b115d4899d827f885f7d35ced4cb64d2385e3422)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99926
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit 2a755d748aecd65d1a3d0c2685678a85472481cd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102766
Tested-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2@nisz.hu>
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 7fed578100d1..7487ba6cb658 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/xml/sax/XSAXSerializable.hpp> #include <com/sun/star/xml/sax/Writer.hpp> #include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/sdb/CommandType.hpp> #include <oox/token/namespaces.hxx> @@ -425,7 +426,7 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID) try { - ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream); + comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream); } catch (uno::Exception const&) { @@ -1445,24 +1446,11 @@ void DocxExport::WriteEmbeddings() contentType); try { - sal_Int32 nBufferSize = 512; - uno::Sequence< sal_Int8 > aDataBuffer(nBufferSize); - sal_Int32 nRead; - do - { - nRead = embeddingsStream->readBytes( aDataBuffer, nBufferSize ); - if( nRead ) - { - if( nRead < nBufferSize ) - { - nBufferSize = nRead; - aDataBuffer.realloc(nRead); - } - xOutStream->writeBytes( aDataBuffer ); - } - } - while( nRead ); - xOutStream->flush(); + // tdf#131288: the stream must be seekable for direct access + uno::Reference< io::XSeekable > xSeekable(embeddingsStream, uno::UNO_QUERY); + if (xSeekable) + xSeekable->seek(0); // tdf#131288: a previous save could position it elsewhere + comphelper::OStorageHelper::CopyInputToOutput(embeddingsStream, xOutStream); } catch(const uno::Exception&) { |