sw/source/filter/ww8/docxexport.cxx |   26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

New commits:
commit 2a755d748aecd65d1a3d0c2685678a85472481cd
Author:     Balazs Varga <balazs.varga...@gmail.com>
AuthorDate: Tue Jul 21 16:23:29 2020 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Aug 4 09:25:06 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.kagan...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit b115d4899d827f885f7d35ced4cb64d2385e3422)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99926
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index 5e9dcc6718e3..849c987845cc 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>
@@ -426,7 +427,7 @@ OString DocxExport::WriteOLEObject(SwOLEObj& rObject, 
OUString & io_rProgID)
 
     try
     {
-        ::comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
+        comphelper::OStorageHelper::CopyInputToOutput(xInStream, xOutStream);
     }
     catch (uno::Exception const&)
     {
@@ -1596,24 +1597,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&)
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to