[Libreoffice-commits] core.git: sw/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 22 15:46:24 UTC 2020
sw/source/filter/ww8/docxexport.cxx | 26 +++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)
New commits:
commit b115d4899d827f885f7d35ced4cb64d2385e3422
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Tue Jul 21 16:23:29 2020 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Jul 22 17:45:39 2020 +0200
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 at collabora.com>
Tested-by: Jenkins
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index caaacf7a0024..74f7ad317cb4 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 <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/util/XModifiable.hpp>
@@ -424,7 +425,7 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID)
try
{
- ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
+ comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
}
catch (uno::Exception const&)
{
@@ -1594,24 +1595,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&)
{
More information about the Libreoffice-commits
mailing list