[Libreoffice-commits] core.git: vcl/qa vcl/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Apr 11 18:35:11 UTC 2017
vcl/qa/cppunit/pdfexport/pdfexport.cxx | 12 +++++++++---
vcl/source/gdi/pdfwriter_impl.cxx | 17 ++++++++---------
2 files changed, 17 insertions(+), 12 deletions(-)
New commits:
commit 54a4121f2040bd11f3d6056767f2d7ad6c7745ac
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Apr 11 17:39:10 2017 +0200
PDF export of PDF images: compress page stream if requested
compressStream() automatically takes care of
VCL_DEBUG_DISABLE_PDFCOMPRESSION, so this also simplifies code.
Change-Id: I7661123e6ba73f8f064ec0543a03e2ec15fd2468
Reviewed-on: https://gerrit.libreoffice.org/36415
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 76cad0f2a9af..36b5134bdaf3 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -481,10 +481,16 @@ void PdfExportTest::testTdf107089()
// Make sure 'Hello' is part of the form object's stream.
vcl::filter::PDFStreamElement* pStream = pForm->GetStream();
CPPUNIT_ASSERT(pStream);
- SvMemoryStream& rObjectStream = pStream->GetMemory();
+ SvMemoryStream aObjectStream;
+ ZCodec aZCodec;
+ aZCodec.BeginCompression();
+ pStream->GetMemory().Seek(0);
+ aZCodec.Decompress(pStream->GetMemory(), aObjectStream);
+ CPPUNIT_ASSERT(aZCodec.EndCompression());
+ aObjectStream.Seek(0);
OString aHello("Hello");
- auto pStart = static_cast<const char*>(rObjectStream.GetData());
- const char* pEnd = pStart + rObjectStream.GetSize();
+ auto pStart = static_cast<const char*>(aObjectStream.GetData());
+ const char* pEnd = pStart + aObjectStream.GetSize();
auto it = std::search(pStart, pEnd, aHello.getStr(), aHello.getStr() + aHello.getLength());
// This failed, 'Hello' was part only a mixed compressed/uncompressed stream, i.e. garbage.
CPPUNIT_ASSERT(it != pEnd);
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 4c7542de2bfa..23706483e3f3 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -11164,10 +11164,11 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
aLine.append(aSize.Height());
aLine.append(" ]");
+ if (!g_bDebugDisableCompression)
+ aLine.append(" /Filter/FlateDecode");
aLine.append(" /Length ");
- sal_Int32 nLength = 0;
- OStringBuffer aStream;
+ SvMemoryStream aStream;
for (auto pContent : aContentStreams)
{
filter::PDFStreamElement* pPageStream = pContent->GetStream();
@@ -11196,21 +11197,19 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
continue;
}
- nLength += aMemoryStream.GetSize();
- aStream.append(static_cast<const sal_Char*>(aMemoryStream.GetData()), aMemoryStream.GetSize());
+ aStream.WriteBytes(aMemoryStream.GetData(), aMemoryStream.GetSize());
}
else
- {
- nLength += rPageStream.GetSize();
- aStream.append(static_cast<const sal_Char*>(rPageStream.GetData()), rPageStream.GetSize());
- }
+ aStream.WriteBytes(rPageStream.GetData(), rPageStream.GetSize());
}
+ compressStream(&aStream);
+ sal_Int32 nLength = aStream.Tell();
aLine.append(nLength);
aLine.append(">>\nstream\n");
// Copy the original page streams to the form XObject stream.
- aLine.append(aStream.makeStringAndClear());
+ aLine.append(static_cast<const sal_Char*>(aStream.GetData()), aStream.GetSize());
aLine.append("\nendstream\nendobj\n\n");
if (!updateObject(nWrappedFormObject))
return;
More information about the Libreoffice-commits
mailing list