diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-20 10:05:57 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-20 10:59:15 +0000 |
commit | 711bc66ca34d3b1293a01fa7db16522b87055495 (patch) | |
tree | 2097473f39f104438fe66a25549dc12eb4179cbf /vcl/source | |
parent | f35e6f2504384ad66b475d39849ed10987b2da53 (diff) |
vcl PDF filter: avoid copy&paste
By using a single ifdef block for the disable-pdfium case and by adding
PDFWriterImpl::BitmapEmit::getObject().
Change-Id: Ia21e16d469bc75e9b1a95342ed01caef3e91ccd9
Reviewed-on: https://gerrit.libreoffice.org/34462
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/filter/ipdf/pdfread.cxx | 10 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 13 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 3 |
3 files changed, 20 insertions, 6 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index d998402877fa..d7de71ea37dc 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -37,12 +37,9 @@ double pointToPixel(double fPoint) return fPoint / 72 * 96; } -#endif - /// Does PDF to PNG conversion using pdfium. bool generatePreview(SvStream& rStream, Graphic& rGraphic) { -#if HAVE_FEATURE_PDFIUM FPDF_LIBRARY_CONFIG aConfig; aConfig.version = 2; aConfig.m_pUserFontPaths = nullptr; @@ -109,13 +106,18 @@ bool generatePreview(SvStream& rStream, Graphic& rGraphic) FPDF_ClosePage(pPdfPage); FPDF_CloseDocument(pPdfDocument); FPDF_DestroyLibrary(); + + return true; +} #else +bool generatePreview(SvStream& rStream, Graphic& rGraphic) +{ (void)rStream; (void)rGraphic; -#endif return true; } +#endif // HAVE_FEATURE_PDFIUM } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 8eb3fadad9b4..b18f4fcc3ed1 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -11320,7 +11320,7 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize, aLine.append( ' ' ); m_aPages.back().appendPoint( rDestPoint + Point( 0, rDestSize.Height()-1 ), aLine ); aLine.append( " cm\n/Im" ); - sal_Int32 nObject = rBitmap.m_nFormObject > 0 ? rBitmap.m_nFormObject : rBitmap.m_nObject; + sal_Int32 nObject = rBitmap.getObject(); aLine.append(nObject); aLine.append( " Do Q\n" ); if( nCheckWidth == 0 || nCheckHeight == 0 ) @@ -11378,7 +11378,7 @@ const PDFWriterImpl::BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx OStringBuffer aObjName( 16 ); aObjName.append( "Im" ); - sal_Int32 nObject = it->m_nFormObject > 0 ? it->m_nFormObject : it->m_nObject; + sal_Int32 nObject = it->getObject(); aObjName.append(nObject); pushResource( ResXObject, aObjName.makeStringAndClear(), nObject ); @@ -13236,4 +13236,13 @@ PDFWriterImpl::JPGEmit::JPGEmit(PDFWriterImpl::JPGEmit&& rOther) m_nObject = rOther.m_nObject; m_bTrueColor = rOther.m_bTrueColor; } + +sal_Int32 PDFWriterImpl::BitmapEmit::getObject() const +{ + if (m_nFormObject > 0) + return m_nFormObject; + else + return m_nObject; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 14b41db7ebbf..1e25de4b1c5d 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -221,6 +221,9 @@ public: m_nFormObject(0) { } + + /// Returns the ID one should use when referring to this bitmap. + sal_Int32 getObject() const; }; struct JPGEmit |