summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-02-22 15:31:28 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-14 12:36:45 +0100
commit8147a907a4082f9041821b0119dd86dbf175534f (patch)
tree657e109bc90bc1cbdf4410f7198a2568a81a9fe5 /vcl
parent1219584dfcdabf7f005557967717c3839e894243 (diff)
tdf#106059 PDF export: create a reference XObject for PDF images
If a reader is capable of showing reference XObjects, then it can show the original/vector PDF image instead of the bitmap fallback. Change-Id: Iac8a460c43ff7467e3a5fd8ee4cbf2179084335b (cherry picked from commit 6db0f1feb1d9931d2726dd11a889c58815710ce0)
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx20
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx5
-rw-r--r--vcl/source/gdi/pdfwriter_impl2.cxx7
3 files changed, 21 insertions, 11 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index ff1966419e25..bd65b6c52422 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -12011,7 +12011,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
}
// Write the form XObject proxy for the image.
- if (rObject.m_nFormObject > 0)
+ if (rObject.m_nFormObject > 0 && rObject.m_nEmbeddedObject > 0)
{
aLine.setLength(0);
if (!updateObject(rObject.m_nFormObject))
@@ -12048,8 +12048,14 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
aLine.append(aSize.Width());
aLine.append(" ");
aLine.append(aSize.Height());
- aLine.append(" ]");
- aLine.append(" /Length ");
+ aLine.append(" ]\n");
+
+ // Write the reference dictionary.
+ aLine.append("/Ref<< /F << /Type /Filespec /F (<embedded file>) /EF << /F ");
+ aLine.append(rObject.m_nEmbeddedObject);
+ aLine.append(" 0 R >> >> /Page 0 >>\n");
+
+ aLine.append("/Length ");
OStringBuffer aStream;
aStream.append("q ");
@@ -12233,7 +12239,15 @@ const PDFWriterImpl::BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx
m_aBitmaps.front().m_aBitmap = aBitmap;
m_aBitmaps.front().m_nObject = createObject();
if (rGraphic.getPdfData().hasElements())
+ {
+ // 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();
+
m_aBitmaps.front().m_nFormObject = createObject();
+ m_aBitmaps.front().m_nEmbeddedObject = m_aEmbeddedFiles.back().m_nObject;
+ }
it = m_aBitmaps.begin();
}
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index df6b3dd82a5d..3c3eec8bc654 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -197,10 +197,13 @@ public:
sal_Int32 m_nObject;
/// ID of the Form XObject, if any.
sal_Int32 m_nFormObject;
+ /// ID of the embedded object, if m_nFormObject is used.
+ sal_Int32 m_nEmbeddedObject;
BitmapEmit()
: m_nObject(0),
- m_nFormObject(0)
+ m_nFormObject(0),
+ m_nEmbeddedObject(0)
{
}
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index 92914883fecf..7302a94bec9b 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -248,13 +248,6 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx );
else
m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap(), i_Graphic );
-
- if (i_Graphic.getPdfData().hasElements())
- {
- m_aEmbeddedFiles.push_back(PDFEmbeddedFile());
- m_aEmbeddedFiles.back().m_nObject = createObject();
- m_aEmbeddedFiles.back().m_aData = i_Graphic.getPdfData();
- }
}
}
}