Kaydet (Commit) 711bc66c authored tarafından Miklos Vajna's avatar Miklos Vajna

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/34462Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst f35e6f25
...@@ -37,12 +37,9 @@ double pointToPixel(double fPoint) ...@@ -37,12 +37,9 @@ double pointToPixel(double fPoint)
return fPoint / 72 * 96; return fPoint / 72 * 96;
} }
#endif
/// Does PDF to PNG conversion using pdfium. /// Does PDF to PNG conversion using pdfium.
bool generatePreview(SvStream& rStream, Graphic& rGraphic) bool generatePreview(SvStream& rStream, Graphic& rGraphic)
{ {
#if HAVE_FEATURE_PDFIUM
FPDF_LIBRARY_CONFIG aConfig; FPDF_LIBRARY_CONFIG aConfig;
aConfig.version = 2; aConfig.version = 2;
aConfig.m_pUserFontPaths = nullptr; aConfig.m_pUserFontPaths = nullptr;
...@@ -109,13 +106,18 @@ bool generatePreview(SvStream& rStream, Graphic& rGraphic) ...@@ -109,13 +106,18 @@ bool generatePreview(SvStream& rStream, Graphic& rGraphic)
FPDF_ClosePage(pPdfPage); FPDF_ClosePage(pPdfPage);
FPDF_CloseDocument(pPdfDocument); FPDF_CloseDocument(pPdfDocument);
FPDF_DestroyLibrary(); FPDF_DestroyLibrary();
return true;
}
#else #else
bool generatePreview(SvStream& rStream, Graphic& rGraphic)
{
(void)rStream; (void)rStream;
(void)rGraphic; (void)rGraphic;
#endif
return true; return true;
} }
#endif // HAVE_FEATURE_PDFIUM
} }
......
...@@ -11320,7 +11320,7 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize, ...@@ -11320,7 +11320,7 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize,
aLine.append( ' ' ); aLine.append( ' ' );
m_aPages.back().appendPoint( rDestPoint + Point( 0, rDestSize.Height()-1 ), aLine ); m_aPages.back().appendPoint( rDestPoint + Point( 0, rDestSize.Height()-1 ), aLine );
aLine.append( " cm\n/Im" ); 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(nObject);
aLine.append( " Do Q\n" ); aLine.append( " Do Q\n" );
if( nCheckWidth == 0 || nCheckHeight == 0 ) if( nCheckWidth == 0 || nCheckHeight == 0 )
...@@ -11378,7 +11378,7 @@ const PDFWriterImpl::BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx ...@@ -11378,7 +11378,7 @@ const PDFWriterImpl::BitmapEmit& PDFWriterImpl::createBitmapEmit( const BitmapEx
OStringBuffer aObjName( 16 ); OStringBuffer aObjName( 16 );
aObjName.append( "Im" ); aObjName.append( "Im" );
sal_Int32 nObject = it->m_nFormObject > 0 ? it->m_nFormObject : it->m_nObject; sal_Int32 nObject = it->getObject();
aObjName.append(nObject); aObjName.append(nObject);
pushResource( ResXObject, aObjName.makeStringAndClear(), nObject ); pushResource( ResXObject, aObjName.makeStringAndClear(), nObject );
...@@ -13236,4 +13236,13 @@ PDFWriterImpl::JPGEmit::JPGEmit(PDFWriterImpl::JPGEmit&& rOther) ...@@ -13236,4 +13236,13 @@ PDFWriterImpl::JPGEmit::JPGEmit(PDFWriterImpl::JPGEmit&& rOther)
m_nObject = rOther.m_nObject; m_nObject = rOther.m_nObject;
m_bTrueColor = rOther.m_bTrueColor; 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -221,6 +221,9 @@ public: ...@@ -221,6 +221,9 @@ public:
m_nFormObject(0) m_nFormObject(0)
{ {
} }
/// Returns the ID one should use when referring to this bitmap.
sal_Int32 getObject() const;
}; };
struct JPGEmit struct JPGEmit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment