From 95061379c9453b941783398826acff674d2bbfd7 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Thu, 10 May 2018 16:38:15 +0000 Subject: Do not build BMP when codec is disabled Currently all of the BMP related code is being built when support for the codec is disabled, it just isn't being utilized. Depending on the settings being used, this unneeded code may or may not get stripped during linking. This CL explicitly turns off building the BMP codec code if support for BMP is turned off. BUG=pdfium:1080 Change-Id: I56d40639a5a3631f9c601a1eef3f98873feac94f Reviewed-on: https://pdfium-review.googlesource.com/32370 Commit-Queue: Ryan Harrison Reviewed-by: dsinclair --- BUILD.gn | 20 +++--- core/fxcodec/codec/ccodec_progressivedecoder.h | 34 +++++++--- core/fxcodec/codec/fx_codec.cpp | 13 ++-- core/fxcodec/codec/fx_codec_progress.cpp | 92 +++++++++++++++----------- core/fxcodec/fx_codec.h | 20 ++++-- core/fxcodec/fx_codec_def.h | 2 + testing/libfuzzer/BUILD.gn | 16 +++-- testing/libfuzzer/xfa_codec_fuzzer.h | 7 +- xfa/fxfa/cxfa_ffwidget.cpp | 2 + xfa/fxfa/parser/cxfa_node.cpp | 20 ++++-- 10 files changed, 146 insertions(+), 80 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 60ff4983e6..8be7f1658d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -780,17 +780,21 @@ jumbo_static_library("fxcodec") { if (pdf_enable_xfa) { sources += [ - "core/fxcodec/bmp/cfx_bmpcontext.cpp", - "core/fxcodec/bmp/cfx_bmpcontext.h", - "core/fxcodec/bmp/cfx_bmpdecompressor.cpp", - "core/fxcodec/bmp/cfx_bmpdecompressor.h", - "core/fxcodec/bmp/fx_bmp.cpp", - "core/fxcodec/bmp/fx_bmp.h", - "core/fxcodec/codec/ccodec_bmpmodule.cpp", - "core/fxcodec/codec/ccodec_bmpmodule.h", "core/fxcodec/codec/ccodec_progressivedecoder.h", "core/fxcodec/codec/fx_codec_progress.cpp", ] + if (pdf_enable_xfa_bmp) { + sources += [ + "core/fxcodec/bmp/cfx_bmpcontext.cpp", + "core/fxcodec/bmp/cfx_bmpcontext.h", + "core/fxcodec/bmp/cfx_bmpdecompressor.cpp", + "core/fxcodec/bmp/cfx_bmpdecompressor.h", + "core/fxcodec/bmp/fx_bmp.cpp", + "core/fxcodec/bmp/fx_bmp.h", + "core/fxcodec/codec/ccodec_bmpmodule.cpp", + "core/fxcodec/codec/ccodec_bmpmodule.h", + ] + } if (pdf_enable_xfa_gif) { sources += [ "core/fxcodec/codec/ccodec_gifmodule.cpp", diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index 07716a80ae..4eeb59d559 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -11,7 +11,6 @@ #include #include -#include "core/fxcodec/codec/ccodec_bmpmodule.h" #include "core/fxcodec/codec/ccodec_jpegmodule.h" #include "core/fxcodec/fx_codec_def.h" #include "core/fxcrt/fx_system.h" @@ -20,9 +19,13 @@ #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_dib.h" +#ifdef PDF_ENABLE_XFA_BMP +#include "core/fxcodec/codec/ccodec_bmpmodule.h" +#endif // PDF_ENABLE_XFA_BMP + #ifdef PDF_ENABLE_XFA_GIF #include "core/fxcodec/codec/ccodec_gifmodule.h" -#endif // PDF_ENABLE_XFA_gif +#endif // PDF_ENABLE_XFA_GIF #ifdef PDF_ENABLE_XFA_PNG #include "core/fxcodec/codec/ccodec_pngmodule.h" @@ -38,14 +41,17 @@ class IFX_SeekableReadStream; class CCodec_Dummy {}; // Placeholder to work around C++ syntax issues -class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, +class CCodec_ProgressiveDecoder : +#ifdef PDF_ENABLE_XFA_BMP + public CCodec_BmpModule::Delegate, +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF - public CCodec_GifModule::Delegate, + public CCodec_GifModule::Delegate, #endif // PDF_ENABLE_XFA_GIF #ifdef PDF_ENABLE_XFA_PNG - public CCodec_PngModule::Delegate, + public CCodec_PngModule::Delegate, #endif // PDF_ENABLE_XFA_PNG - public CCodec_Dummy { + public CCodec_Dummy { public: enum FXCodec_Format { FXCodec_Invalid = 0, @@ -166,17 +172,21 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, void GifReadScanline(int32_t row_num, uint8_t* row_buf) override; #endif // PDF_ENABLE_XFA_GIF +#ifdef PDF_ENABLE_XFA_BMP // CCodec_BmpModule::Delegate bool BmpInputImagePositionBuf(uint32_t rcd_pos) override; void BmpReadScanline(uint32_t row_num, const std::vector& row_buf) override; +#endif // PDF_ENABLE_XFA_BMP private: +#ifdef PDF_ENABLE_XFA_BMP bool BmpReadMoreData(CCodec_BmpModule* pBmpModule, FXCODEC_STATUS& err_status); bool BmpDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size); FXCODEC_STATUS BmpStartDecode(const RetainPtr& pDIBitmap); FXCODEC_STATUS BmpContinueDecode(); +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF bool GifReadMoreData(CCodec_GifModule* pGifModule, @@ -234,14 +244,16 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, RetainPtr m_pFile; RetainPtr m_pDeviceBitmap; UnownedPtr m_pCodecMgr; +#ifdef PDF_ENABLE_XFA_BMP + std::unique_ptr m_pBmpContext; +#endif // PDF_ENABLE_XFA_BMP +#ifdef PDF_ENABLE_XFA_GIF + std::unique_ptr m_pGifContext; +#endif // PDF_ENABLE_XFA_GIF std::unique_ptr m_pJpegContext; #ifdef PDF_ENABLE_XFA_PNG std::unique_ptr m_pPngContext; #endif // PDF_ENABLE_XFA_PNG -#ifdef PDF_ENABLE_XFA_GIF - std::unique_ptr m_pGifContext; -#endif // PDF_ENABLE_XFA_GIF - std::unique_ptr m_pBmpContext; #ifdef PDF_ENABLE_XFA_TIFF std::unique_ptr m_pTiffContext; #endif // PDF_ENABLE_XFA_TIFF @@ -279,7 +291,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, FX_RECT m_GifFrameRect; bool m_InvalidateGifBuffer; #endif // PDF_ENABLE_XFA_GIF +#ifdef PDF_ENABLE_XFA_BMP bool m_BmpIsTopBottom; +#endif // PDF_ENABLE_XFA_BMP FXCODEC_STATUS m_status; }; diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp index e58da052aa..d81e8f756c 100644 --- a/core/fxcodec/codec/fx_codec.cpp +++ b/core/fxcodec/codec/fx_codec.cpp @@ -1510,17 +1510,20 @@ bool CCodec_BasicModule::A85Encode(const uint8_t* src_buf, #ifdef PDF_ENABLE_XFA CFX_DIBAttribute::CFX_DIBAttribute() - : m_nXDPI(-1), - m_nYDPI(-1), - m_fAspectRatio(-1.0f), - m_wDPIUnit(0), + : +#ifdef PDF_ENABLE_XFA_BMP + m_nBmpCompressType(0), +#endif // PDF_ENABLE_BMP #ifdef PDF_ENABLE_XFA_GIF m_nGifLeft(0), m_nGifTop(0), m_pGifLocalPalette(nullptr), m_nGifLocalPalNum(0), #endif // PDF_ENABLE_XFA_GIF - m_nBmpCompressType(0) { + m_nXDPI(-1), + m_nYDPI(-1), + m_fAspectRatio(-1.0f), + m_wDPIUnit(0) { } CFX_DIBAttribute::~CFX_DIBAttribute() { diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 1d6bc708db..e45dff6682 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -283,7 +283,9 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( m_GifFrameRect = FX_RECT(0, 0, 0, 0); m_InvalidateGifBuffer = true; #endif // PDF_ENABLE_XFA_GIF +#ifdef PDF_ENABLE_XFA_BMP m_BmpIsTopBottom = false; +#endif // PDF_ENABLE_XFA_BMP } CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { @@ -613,6 +615,7 @@ void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num, } #endif // PDF_ENABLE_XFA_GIF +#ifdef PDF_ENABLE_XFA_BMP bool CCodec_ProgressiveDecoder::BmpInputImagePositionBuf(uint32_t rcd_pos) { m_offSet = rcd_pos; FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; @@ -926,6 +929,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::BmpContinueDecode() { return m_status; } } +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, @@ -1733,18 +1737,20 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, memset(m_pSrcBuf, 0, size); m_SrcSize = size; switch (imageType) { +#ifdef PDF_ENABLE_XFA_BMP case FXCODEC_IMAGE_BMP: return BmpDetectImageType(pAttribute, size); +#endif // PDF_ENABLE_XFA_BMP +#ifdef PDF_ENABLE_XFA_GIF + case FXCODEC_IMAGE_GIF: + return GifDetectImageType(pAttribute, size); +#endif // PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_JPG: return JpegDetectImageType(pAttribute, size); #ifdef PDF_ENABLE_XFA_PNG case FXCODEC_IMAGE_PNG: return PngDetectImageType(pAttribute, size); #endif // PDF_ENABLE_XFA_PNG -#ifdef PDF_ENABLE_XFA_GIF - case FXCODEC_IMAGE_GIF: - return GifDetectImageType(pAttribute, size); -#endif // PDF_ENABLE_XFA_GIF #ifdef PDF_ENABLE_XFA_TIFF case FXCODEC_IMAGE_TIFF: return TiffDetectImageType(pAttribute, size); @@ -1794,9 +1800,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( if (bSkipImageTypeCheck) return m_status; - for (int type = FXCODEC_IMAGE_BMP; type < FXCODEC_IMAGE_MAX; type++) { - if (DetectImageType((FXCODEC_IMAGE_TYPE)type, pAttribute)) { - m_imagType = (FXCODEC_IMAGE_TYPE)type; + for (int type = FXCODEC_IMAGE_UNKNOWN + 1; type < FXCODEC_IMAGE_MAX; type++) { + if (DetectImageType(static_cast(type), pAttribute)) { + m_imagType = static_cast(type); m_status = FXCODEC_STATUS_FRAME_READY; return m_status; } @@ -2065,6 +2071,7 @@ void CCodec_ProgressiveDecoder::ReSampleScanline( dest_scan += dest_bytes_per_pixel - 3; } break; case 12: { +#ifdef PDF_ENABLE_XFA_BMP if (m_pBmpContext) { int dest_r = 0; int dest_g = 0; @@ -2082,26 +2089,27 @@ void CCodec_ProgressiveDecoder::ReSampleScanline( *dest_scan++ = (uint8_t)((dest_g) >> 16); *dest_scan++ = (uint8_t)((dest_r) >> 16); *dest_scan++ = 0xFF; - } else { - int dest_a = 0; - int dest_r = 0; - int dest_g = 0; - int dest_b = 0; - for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd; - j++) { - int pixel_weight = - pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart]; - unsigned long argb = m_pSrcPalette[src_scan[j]]; - dest_a += pixel_weight * (uint8_t)(argb >> 24); - dest_r += pixel_weight * (uint8_t)(argb >> 16); - dest_g += pixel_weight * (uint8_t)(argb >> 8); - dest_b += pixel_weight * (uint8_t)argb; - } - *dest_scan++ = (uint8_t)((dest_b) >> 16); - *dest_scan++ = (uint8_t)((dest_g) >> 16); - *dest_scan++ = (uint8_t)((dest_r) >> 16); - *dest_scan++ = (uint8_t)((dest_a) >> 16); + break; + } +#endif // PDF_ENABLE_XFA_BMP + int dest_a = 0; + int dest_r = 0; + int dest_g = 0; + int dest_b = 0; + for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd; + j++) { + int pixel_weight = + pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart]; + unsigned long argb = m_pSrcPalette[src_scan[j]]; + dest_a += pixel_weight * (uint8_t)(argb >> 24); + dest_r += pixel_weight * (uint8_t)(argb >> 16); + dest_g += pixel_weight * (uint8_t)(argb >> 8); + dest_b += pixel_weight * (uint8_t)argb; } + *dest_scan++ = (uint8_t)((dest_b) >> 16); + *dest_scan++ = (uint8_t)((dest_g) >> 16); + *dest_scan++ = (uint8_t)((dest_r) >> 16); + *dest_scan++ = (uint8_t)((dest_a) >> 16); } break; case 9: { uint32_t dest_b = 0; @@ -2306,8 +2314,10 @@ std::pair CCodec_ProgressiveDecoder::GetFrames() { } switch (m_imagType) { - case FXCODEC_IMAGE_JPG: +#ifdef PDF_ENABLE_XFA_BMP case FXCODEC_IMAGE_BMP: +#endif // PDF_ENABLE_XFA_BMP + case FXCODEC_IMAGE_JPG: #ifdef PDF_ENABLE_XFA_PNG case FXCODEC_IMAGE_PNG: #endif // PDF_ENABLE_XFA_PNG @@ -2405,18 +2415,20 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( return FXCODEC_STATUS_ERR_PARAMS; } switch (m_imagType) { +#ifdef PDF_ENABLE_XFA_BMP + case FXCODEC_IMAGE_BMP: + return BmpStartDecode(pDIBitmap); +#endif // PDF_ENABLE_XFA_BMP +#ifdef PDF_ENABLE_XFA_GIF + case FXCODEC_IMAGE_GIF: + return GifStartDecode(pDIBitmap); +#endif // PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_JPG: return JpegStartDecode(pDIBitmap); #ifdef PDF_ENABLE_XFA_PNG case FXCODEC_IMAGE_PNG: return PngStartDecode(pDIBitmap); #endif // PDF_ENABLE_XFA_PNG -#ifdef PDF_ENABLE_XFA_GIF - case FXCODEC_IMAGE_GIF: - return GifStartDecode(pDIBitmap); -#endif // PDF_ENABLE_XFA_GIF - case FXCODEC_IMAGE_BMP: - return BmpStartDecode(pDIBitmap); #ifdef PDF_ENABLE_XFA_TIFF case FXCODEC_IMAGE_TIFF: m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; @@ -2432,18 +2444,20 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() { return FXCODEC_STATUS_ERROR; switch (m_imagType) { +#ifdef PDF_ENABLE_XFA_BMP + case FXCODEC_IMAGE_BMP: + return BmpContinueDecode(); +#endif // PDF_ENABLE_XFA_BMP +#ifdef PDF_ENABLE_XFA_GIF + case FXCODEC_IMAGE_GIF: + return GifContinueDecode(); +#endif // PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_JPG: return JpegContinueDecode(); #ifdef PDF_ENABLE_XFA_PNG case FXCODEC_IMAGE_PNG: return PngContinueDecode(); #endif // PDF_ENABLE_XFA_PNG -#ifdef PDF_ENABLE_XFA_GIF - case FXCODEC_IMAGE_GIF: - return GifContinueDecode(); -#endif // PDF_ENABLE_XFA_GIF - case FXCODEC_IMAGE_BMP: - return BmpContinueDecode(); #ifdef PDF_ENABLE_XFA_TIFF case FXCODEC_IMAGE_TIFF: return TiffContinueDecode(); diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h index b5e8d8ad39..91d9f2fb32 100644 --- a/core/fxcodec/fx_codec.h +++ b/core/fxcodec/fx_codec.h @@ -19,7 +19,9 @@ #include "core/fxcrt/fx_string.h" #ifdef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA_BMP #include "core/fxcodec/codec/ccodec_bmpmodule.h" +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF #include "core/fxcodec/codec/ccodec_gifmodule.h" @@ -54,17 +56,20 @@ class CFX_DIBAttribute { CFX_DIBAttribute(); ~CFX_DIBAttribute(); - int32_t m_nXDPI; - int32_t m_nYDPI; - float m_fAspectRatio; - uint16_t m_wDPIUnit; +#ifdef PDF_ENABLE_XFA_BMP + int32_t m_nBmpCompressType; +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF int32_t m_nGifLeft; int32_t m_nGifTop; uint32_t* m_pGifLocalPalette; uint32_t m_nGifLocalPalNum; #endif // PDF_ENABLE_XFA_GIF - int32_t m_nBmpCompressType; + + int32_t m_nXDPI; + int32_t m_nYDPI; + float m_fAspectRatio; + uint16_t m_wDPIUnit; std::map m_Exif; }; #endif // PDF_ENABLE_XFA @@ -84,10 +89,13 @@ class CCodec_ModuleMgr { #ifdef PDF_ENABLE_XFA std::unique_ptr CreateProgressiveDecoder(); + +#ifdef PDF_ENABLE_XFA_BMP CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } void SetBmpModule(std::unique_ptr module) { m_pBmpModule = std::move(module); } +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } @@ -120,7 +128,9 @@ class CCodec_ModuleMgr { std::unique_ptr m_pIccModule; #ifdef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA_BMP std::unique_ptr m_pBmpModule; +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF std::unique_ptr m_pGifModule; diff --git a/core/fxcodec/fx_codec_def.h b/core/fxcodec/fx_codec_def.h index f7d6916aa5..154fe967ee 100644 --- a/core/fxcodec/fx_codec_def.h +++ b/core/fxcodec/fx_codec_def.h @@ -26,7 +26,9 @@ enum FXCODEC_STATUS { #ifdef PDF_ENABLE_XFA enum FXCODEC_IMAGE_TYPE { FXCODEC_IMAGE_UNKNOWN = 0, +#ifdef PDF_ENABLE_XFA_BMP FXCODEC_IMAGE_BMP, +#endif // PDF_ENABLE_XFA_BMP FXCODEC_IMAGE_JPG, #ifdef PDF_ENABLE_XFA_PNG FXCODEC_IMAGE_PNG, diff --git a/testing/libfuzzer/BUILD.gn b/testing/libfuzzer/BUILD.gn index 1d17d3d4e7..2b2c19389b 100644 --- a/testing/libfuzzer/BUILD.gn +++ b/testing/libfuzzer/BUILD.gn @@ -39,12 +39,14 @@ group("libfuzzer") { if (pdf_enable_xfa) { deps += [ ":pdf_cfx_barcode_fuzzer", - ":pdf_codec_bmp_fuzzer", ":pdf_codec_jpeg_fuzzer", ":pdf_css_fuzzer", ":pdf_fm2js_fuzzer", ":pdf_formcalc_fuzzer", ] + if (pdf_enable_xfa_bmp) { + deps += [ ":pdf_codec_bmp_fuzzer" ] + } if (pdf_enable_xfa_gif) { deps += [ ":pdf_codec_gif_fuzzer", @@ -85,11 +87,13 @@ if (pdf_enable_xfa) { ] } - pdfium_fuzzer("pdf_codec_bmp_fuzzer") { - sources = [ - "pdf_codec_bmp_fuzzer.cc", - "xfa_codec_fuzzer.h", - ] + if (pdf_enable_xfa_bmp) { + pdfium_fuzzer("pdf_codec_bmp_fuzzer") { + sources = [ + "pdf_codec_bmp_fuzzer.cc", + "xfa_codec_fuzzer.h", + ] + } } if (pdf_enable_xfa_gif) { diff --git a/testing/libfuzzer/xfa_codec_fuzzer.h b/testing/libfuzzer/xfa_codec_fuzzer.h index 483177e232..bcc3a5c7fe 100644 --- a/testing/libfuzzer/xfa_codec_fuzzer.h +++ b/testing/libfuzzer/xfa_codec_fuzzer.h @@ -7,13 +7,16 @@ #include -#include "core/fxcodec/codec/ccodec_bmpmodule.h" #include "core/fxcodec/codec/ccodec_progressivedecoder.h" #include "core/fxcodec/fx_codec.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "testing/fx_string_testhelpers.h" #include "third_party/base/ptr_util.h" +#ifdef PDF_ENABLE_XFA_BMP +#include "core/fxcodec/codec/ccodec_bmpmodule.h" +#endif // PDF_ENABLE_XFA_BMP + #ifdef PDF_ENABLE_XFA_GIF #include "core/fxcodec/codec/ccodec_gifmodule.h" #endif // PDF_ENABLE_XFA_GIF @@ -34,7 +37,9 @@ class XFACodecFuzzer { public: static int Fuzz(const uint8_t* data, size_t size, FXCODEC_IMAGE_TYPE type) { auto mgr = pdfium::MakeUnique(); +#ifdef PDF_ENABLE_XFA_BMP mgr->SetBmpModule(pdfium::MakeUnique()); +#endif // PDF_ENABLE_XFA_BMP #ifdef PDF_ENABLE_XFA_GIF mgr->SetGifModule(pdfium::MakeUnique()); #endif // PDF_ENABLE_XFA_GIF diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 3c5a3411a7..c9bb072cb9 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -40,7 +40,9 @@ FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, int32_t iBitsPerComponent) { FXDIB_Format dibFormat = FXDIB_Argb; switch (type) { +#ifdef PDF_ENABLE_XFA_BMP case FXCODEC_IMAGE_BMP: +#endif // PDF_ENABLE_XFA_BMP case FXCODEC_IMAGE_JPG: #ifdef PDF_ENABLE_XFA_TIFF case FXCODEC_IMAGE_TIFF: diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index f178bd92a9..af3ad63f72 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -163,22 +163,30 @@ int32_t XFA_Base64Decode(const char* pStr, uint8_t* pOutBuffer) { FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) { WideString wsContentType(wsType); wsContentType.MakeLower(); + +#ifdef PDF_ENABLE_XFA_BMP + if (wsContentType == L"image/bmp") + return FXCODEC_IMAGE_BMP; +#endif // PDF_ENABLE_XFA_BMP + +#ifdef PDF_ENABLE_XFA_GIF + if (wsContentType == L"image/gif") + return FXCODEC_IMAGE_GIF; +#endif // PDF_ENABLE_XFA_GIF + if (wsContentType == L"image/jpg") return FXCODEC_IMAGE_JPG; + #ifdef PDF_ENABLE_XFA_PNG if (wsContentType == L"image/png") return FXCODEC_IMAGE_PNG; #endif // PDF_ENABLE_XFA_PNG -#ifdef PDF_ENABLE_XFA_GIF - if (wsContentType == L"image/gif") - return FXCODEC_IMAGE_GIF; -#endif // PDF_ENABLE_XFA_GIF - if (wsContentType == L"image/bmp") - return FXCODEC_IMAGE_BMP; + #ifdef PDF_ENABLE_XFA_TIFF if (wsContentType == L"image/tif") return FXCODEC_IMAGE_TIFF; #endif // PDF_ENABLE_XFA_TIFF + return FXCODEC_IMAGE_UNKNOWN; } -- cgit v1.2.3