tdf#106693 vcl PDF export: initial UseReferenceXObject option

It's still on, but in experimental mode start work towards the ability
to not use that markup.

Change-Id: Idf11c0e0a3c61ad93af331346ec7107304f6dc0f
Reviewed-on: https://gerrit.libreoffice.org/35538
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna
2017-03-22 16:30:35 +01:00
parent 4c88eddef0
commit 5f4826d89b
3 changed files with 24 additions and 11 deletions

View File

@@ -47,6 +47,7 @@
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
#include <officecfg/Office/Common.hxx>
#include "pdfexport.hxx"
#include "impdialog.hxx"
@@ -776,6 +777,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
aContext.SignPassword = msSignPassword;
aContext.SignCertificate = maSignCertificate;
aContext.SignTSA = msSignTSA;
// Not using reference XObjects is experimental for now.
aContext.UseReferenceXObject = !officecfg::Office::Common::Misc::ExperimentalMode::get();
// all context data set, time to create the printing device
std::unique_ptr<vcl::PDFWriter> pPDFWriter(new vcl::PDFWriter( aContext, xEnc ));

View File

@@ -632,6 +632,8 @@ The following structure describes the permissions used in PDF security
PDFWriter::ColorMode ColorMode;
css::uno::Reference< css::security::XCertificate> SignCertificate;
OUString SignTSA;
/// Use reference XObject markup for PDF images.
bool UseReferenceXObject;
PDFWriterContext() :
RelFsys( false ), //i56629, i49415?, i64585?
@@ -661,7 +663,8 @@ The following structure describes the permissions used in PDF security
DPIx( 0 ),
DPIy( 0 ),
ColorMode( PDFWriter::DrawColor ),
SignCertificate( nullptr )
SignCertificate( nullptr ),
UseReferenceXObject( false )
{}
};

View File

@@ -10859,7 +10859,7 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject )
void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
{
if (rEmit.m_nFormObject <= 0 || rEmit.m_nEmbeddedObject <= 0)
if (rEmit.m_nFormObject <= 0)
return;
OStringBuffer aLine;
@@ -10899,10 +10899,13 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
aLine.append(aSize.Height());
aLine.append(" ]\n");
// Write the reference dictionary.
aLine.append("/Ref<< /F << /Type /Filespec /F (<embedded file>) /EF << /F ");
aLine.append(rEmit.m_nEmbeddedObject);
aLine.append(" 0 R >> >> /Page 0 >>\n");
if (m_aContext.UseReferenceXObject && rEmit.m_nEmbeddedObject > 0)
{
// Write the reference dictionary.
aLine.append("/Ref<< /F << /Type /Filespec /F (<embedded file>) /EF << /F ");
aLine.append(rEmit.m_nEmbeddedObject);
aLine.append(" 0 R >> >> /Page 0 >>\n");
}
aLine.append("/Length ");
@@ -11251,13 +11254,17 @@ void PDFWriterImpl::createEmbeddedFile(const Graphic& rGraphic, ReferenceXObject
if (!rGraphic.getPdfData().hasElements())
return;
// Store the original PDF data as an embedded file.
m_aEmbeddedFiles.push_back(PDFEmbeddedFile());
m_aEmbeddedFiles.back().m_nObject = createObject();
m_aEmbeddedFiles.back().m_aData = rGraphic.getPdfData();
if (m_aContext.UseReferenceXObject)
{
// Store the original PDF data as an embedded file.
m_aEmbeddedFiles.push_back(PDFEmbeddedFile());
m_aEmbeddedFiles.back().m_nObject = createObject();
m_aEmbeddedFiles.back().m_aData = rGraphic.getPdfData();
rEmit.m_nEmbeddedObject = m_aEmbeddedFiles.back().m_nObject;
}
rEmit.m_nFormObject = createObject();
rEmit.m_nEmbeddedObject = m_aEmbeddedFiles.back().m_nObject;
rEmit.m_aPixelSize = rGraphic.GetBitmap().GetPrefSize();
}