From 97da97662417085774f75c26e535c6fbe70266ae Mon Sep 17 00:00:00 2001 From: Wei Li Date: Fri, 11 Mar 2016 17:00:48 -0800 Subject: Re-enable MSVC warning 4800 for compiling with chromium_code Mainly change the code to avoid the warnings; in a few cases we have to use explicit casts. BUG=pdfium:29 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1783023002 . --- core/include/fpdfapi/cpdf_parser.h | 2 +- core/include/fpdfapi/fpdf_serial.h | 4 +-- core/include/fxcrt/fx_ext.h | 12 +++------ core/include/fxcrt/fx_string.h | 2 +- core/include/fxcrt/fx_system.h | 10 +++++--- core/include/fxge/fx_ge.h | 24 ++++++++--------- core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 8 +++--- core/src/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp | 2 +- core/src/fpdfapi/fpdf_parser/cpdf_parser.cpp | 9 ++++--- .../src/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp | 3 ++- .../fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 11 +++++--- core/src/fpdfdoc/doc_formfield.cpp | 6 ++--- core/src/fxcrt/fx_basic_buffer.cpp | 2 +- core/src/fxcrt/fx_basic_wstring.cpp | 2 +- core/src/fxge/agg/fx_agg_driver.cpp | 30 +++++++++++----------- core/src/fxge/ge/fx_ge_fontmap.cpp | 11 ++++---- fpdfsdk/include/fsdk_baseannot.h | 4 +-- fpdfsdk/include/fsdk_baseform.h | 10 ++++---- fpdfsdk/include/pdfwindow/PWL_SpecialButton.h | 12 ++++----- fpdfsdk/src/formfiller/FFL_CheckBox.cpp | 4 +-- fpdfsdk/src/formfiller/FFL_RadioButton.cpp | 4 +-- fpdfsdk/src/fpdfsave.cpp | 3 +-- fpdfsdk/src/fsdk_baseannot.cpp | 6 ++--- fpdfsdk/src/fsdk_baseform.cpp | 14 +++++----- fpdfsdk/src/javascript/Document.cpp | 4 +-- fpdfsdk/src/javascript/Field.cpp | 8 +++--- fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp | 12 ++++----- pdfium.gyp | 2 +- 28 files changed, 114 insertions(+), 107 deletions(-) diff --git a/core/include/fpdfapi/cpdf_parser.h b/core/include/fpdfapi/cpdf_parser.h index 4ec8d988e0..f2d7343e87 100644 --- a/core/include/fpdfapi/cpdf_parser.h +++ b/core/include/fpdfapi/cpdf_parser.h @@ -130,7 +130,7 @@ class CPDF_Parser { std::map m_ObjectInfo; std::set m_SortedOffset; CFX_ArrayTemplate m_Trailers; - FX_BOOL m_bVersionUpdated; + bool m_bVersionUpdated; CPDF_Object* m_pLinearized; FX_DWORD m_dwFirstPageNo; FX_DWORD m_dwXrefStartObjNum; diff --git a/core/include/fpdfapi/fpdf_serial.h b/core/include/fpdfapi/fpdf_serial.h index 8cf3fb8a1e..cb0c290783 100644 --- a/core/include/fpdfapi/fpdf_serial.h +++ b/core/include/fpdfapi/fpdf_serial.h @@ -26,7 +26,7 @@ class CPDF_Creator { ~CPDF_Creator(); void RemoveSecurity(); - FX_BOOL Create(IFX_StreamWrite* pFile, FX_DWORD flags = 0); + bool Create(IFX_StreamWrite* pFile, FX_DWORD flags = 0); int32_t Continue(IFX_Pause* pPause = NULL); FX_BOOL SetFileVersion(int32_t fileVersion = 17); @@ -57,7 +57,7 @@ class CPDF_Creator { int32_t m_ObjectStreamSize; FX_DWORD m_dwLastObjNum; - FX_BOOL Create(FX_DWORD flags); + bool Create(FX_DWORD flags); void ResetStandardSecurity(); void Clear(); int32_t WriteDoc_Stage1(IFX_Pause* pPause); diff --git a/core/include/fxcrt/fx_ext.h b/core/include/fxcrt/fx_ext.h index 689d8e8fc4..dda6a5c72b 100644 --- a/core/include/fxcrt/fx_ext.h +++ b/core/include/fxcrt/fx_ext.h @@ -60,23 +60,19 @@ inline int FXSYS_toHexDigit(const FX_CHAR c) { } inline bool FXSYS_isDecimalDigit(const FX_CHAR c) { - return std::isdigit(c); + return !!std::isdigit(c); } inline bool FXSYS_isDecimalDigit(const FX_WCHAR c) { - return std::iswdigit(c); + return !!std::iswdigit(c); } inline int FXSYS_toDecimalDigit(const FX_CHAR c) { - if (!std::isdigit(c)) - return 0; - return c - '0'; + return std::isdigit(c) ? c - '0' : 0; } inline int FXSYS_toDecimalDigit(const FX_WCHAR c) { - if (!std::iswdigit(c)) - return 0; - return c - L'0'; + return std::iswdigit(c) ? c - L'0' : 0; } FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h index ca29e1321a..d68fc2cb36 100644 --- a/core/include/fxcrt/fx_string.h +++ b/core/include/fxcrt/fx_string.h @@ -577,7 +577,7 @@ class CFX_WideString { void Empty(); - FX_BOOL IsEmpty() const { return !GetLength(); } + bool IsEmpty() const { return !GetLength(); } FX_STRSIZE GetLength() const { return m_pData ? m_pData->m_nDataLength : 0; } diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h index 76c413e7e3..f62e126fbb 100644 --- a/core/include/fxcrt/fx_system.h +++ b/core/include/fxcrt/fx_system.h @@ -258,10 +258,12 @@ wchar_t* FXSYS_wcsupr(wchar_t* str); #define FXDWORD_FROM_MSBFIRST(i) \ (((uint8_t)(i) << 24) | ((uint8_t)((i) >> 8) << 16) | \ ((uint8_t)((i) >> 16) << 8) | (uint8_t)((i) >> 24)) -#define FXDWORD_GET_LSBFIRST(p) \ - ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0])) -#define FXDWORD_GET_MSBFIRST(p) \ - ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3])) +#define FXDWORD_GET_LSBFIRST(p) \ + ((static_cast(p[3]) << 24) | (static_cast(p[2]) << 16) | \ + (static_cast(p[1]) << 8) | (static_cast(p[0]))) +#define FXDWORD_GET_MSBFIRST(p) \ + ((static_cast(p[0]) << 24) | (static_cast(p[1]) << 16) | \ + (static_cast(p[2]) << 8) | (static_cast(p[3]))) #define FXSYS_HIBYTE(word) ((uint8_t)((word) >> 8)) #define FXSYS_LOBYTE(word) ((uint8_t)(word)) #define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16)) diff --git a/core/include/fxge/fx_ge.h b/core/include/fxge/fx_ge.h index fc9119b123..8a62f13d14 100644 --- a/core/include/fxge/fx_ge.h +++ b/core/include/fxge/fx_ge.h @@ -412,20 +412,20 @@ class CFX_FxgeDevice : public CFX_RenderDevice { CFX_FxgeDevice(); ~CFX_FxgeDevice() override; - FX_BOOL Attach(CFX_DIBitmap* pBitmap, - int dither_bits = 0, - FX_BOOL bRgbByteOrder = FALSE, - CFX_DIBitmap* pOriDevice = NULL, - FX_BOOL bGroupKnockout = FALSE); - - FX_BOOL Create(int width, - int height, - FXDIB_Format format, - int dither_bits = 0, - CFX_DIBitmap* pOriDevice = NULL); + bool Attach(CFX_DIBitmap* pBitmap, + int dither_bits = 0, + bool bRgbByteOrder = false, + CFX_DIBitmap* pOriDevice = NULL, + bool bGroupKnockout = false); + + bool Create(int width, + int height, + FXDIB_Format format, + int dither_bits = 0, + CFX_DIBitmap* pOriDevice = NULL); protected: - FX_BOOL m_bOwnedBitmap; + bool m_bOwnedBitmap; }; class CFX_SkiaDevice : public CFX_RenderDevice { public: diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 9a318eb824..f3797c2532 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -1953,11 +1953,13 @@ void CPDF_Creator::Clear() { m_pIDArray = NULL; } } -FX_BOOL CPDF_Creator::Create(IFX_StreamWrite* pFile, FX_DWORD flags) { + +bool CPDF_Creator::Create(IFX_StreamWrite* pFile, FX_DWORD flags) { m_File.AttachFile(pFile); return Create(flags); } -FX_BOOL CPDF_Creator::Create(FX_DWORD flags) { + +bool CPDF_Creator::Create(FX_DWORD flags) { m_dwFlags = flags; m_iStage = 0; m_Offset = 0; @@ -1966,7 +1968,7 @@ FX_BOOL CPDF_Creator::Create(FX_DWORD flags) { m_NewObjNumArray.RemoveAll(); InitID(); if (flags & FPDFCREATE_PROGRESSIVE) { - return TRUE; + return true; } return Continue(NULL) > -1; } diff --git a/core/src/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/src/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp index 6256f4c526..84464fcff2 100644 --- a/core/src/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp +++ b/core/src/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp @@ -267,7 +267,7 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream, if (!CanReadFromBitStream(hStream, required_bits)) return FALSE; - for (int i = 0; i < dwSharedObjTotal; ++i) { + for (FX_DWORD i = 0; i < dwSharedObjTotal; ++i) { dwPrevObjLen = dwCurObjLen; FX_SAFE_DWORD safeObjLen = hStream->GetBits(dwDeltaGroupLen); safeObjLen += dwGroupLeastLen; diff --git a/core/src/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/src/fpdfapi/fpdf_parser/cpdf_parser.cpp index c9a2d8d496..e9332901c0 100644 --- a/core/src/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -55,6 +55,7 @@ CPDF_Parser::CPDF_Parser() m_FileVersion(0), m_pTrailer(nullptr), m_pEncryptDict(nullptr), + m_bVersionUpdated(false), m_pLinearized(nullptr), m_dwFirstPageNo(0), m_dwXrefStartObjNum(0) { @@ -124,7 +125,7 @@ void CPDF_Parser::ShrinkObjectMap(FX_DWORD objnum) { } void CPDF_Parser::CloseParser() { - m_bVersionUpdated = FALSE; + m_bVersionUpdated = false; delete m_pDocument; m_pDocument = nullptr; @@ -466,7 +467,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos, m_ObjectInfo[objnum].pos = offset; int32_t version = FXSYS_atoi(pEntry + 11); if (version >= 1) - m_bVersionUpdated = TRUE; + m_bVersionUpdated = true; m_ObjectInfo[objnum].gennum = version; if (m_ObjectInfo[objnum].pos < m_pSyntax->m_FileLen) @@ -541,7 +542,7 @@ bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos, m_ObjectInfo[objnum].pos = offset; int32_t version = FXSYS_atoi(pEntry + 11); if (version >= 1) - m_bVersionUpdated = TRUE; + m_bVersionUpdated = true; m_ObjectInfo[objnum].gennum = version; if (m_ObjectInfo[objnum].pos < m_pSyntax->m_FileLen) @@ -775,7 +776,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() { m_ObjectInfo[objnum].pos = obj_pos; m_ObjectInfo[objnum].gennum = gennum; if (oldgen != gennum) - m_bVersionUpdated = TRUE; + m_bVersionUpdated = true; } } else { m_ObjectInfo[objnum].pos = obj_pos; diff --git a/core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp b/core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp index b414827f95..89ad5eec33 100644 --- a/core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.cpp @@ -772,7 +772,8 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, GetNextWordInternal(nullptr); int numMarkers = ReadEOLMarkers(m_Pos); - if (m_WordSize == kEndObjStr.GetLength() && numMarkers != 0 && + if (m_WordSize == static_cast(kEndObjStr.GetLength()) && + numMarkers != 0 && FXSYS_memcmp(m_WordBuffer, kEndObjStr.GetPtr(), kEndObjStr.GetLength()) == 0) { m_Pos = streamStartPos; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 6618a13709..93b867005c 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -628,13 +628,14 @@ int CPDF_DIBSource::CreateDecoder() { pParams ? pParams->GetIntegerBy("ColorTransform", 1) : 1)); if (!m_pDecoder) { FX_BOOL bTransform = FALSE; - int comps, bpc; + int comps; + int bpc; ICodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); if (pJpegModule->LoadInfo(src_data, src_size, m_Width, m_Height, comps, bpc, bTransform)) { - if (m_nComponents != comps) { + if (m_nComponents != static_cast(comps)) { FX_Free(m_pCompData); - m_nComponents = comps; + m_nComponents = static_cast(comps); if (m_Family == PDFCS_LAB && m_nComponents != 3) { m_pCompData = nullptr; return 0; @@ -1440,7 +1441,9 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, FX_BOOL bFlipX, int clip_left, int clip_width) const { - int last_src_x = -1; + // last_src_x used to store the last seen src_x position which should be + // in [0, src_width). Set the initial value to be an invalid src_x value. + FX_DWORD last_src_x = src_width; FX_ARGB last_argb = FXARGB_MAKE(0xFF, 0xFF, 0xFF, 0xFF); FX_FLOAT unit_To8Bpc = 255.0f / ((1 << m_bpc) - 1); for (int i = 0; i < clip_width; i++) { diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index 09393bc30d..4bce85e831 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -110,15 +110,15 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { case CPDF_FormField::RadioButton: { int iCount = CountControls(); if (iCount) { + // TODO(weili): Check whether anything special needs to be done for + // unison field. Otherwise, merge these branches. if (PDF_FormField_IsUnison(this)) { for (int i = 0; i < iCount; i++) { CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE); } } else { for (int i = 0; i < iCount; i++) { - CPDF_FormControl* pControl = GetControl(i); - FX_BOOL bChecked = pControl->IsDefaultChecked(); - CheckControl(i, bChecked, FALSE); + CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE); } } } diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp index f623d995c7..a3039f4188 100644 --- a/core/src/fxcrt/fx_basic_buffer.cpp +++ b/core/src/fxcrt/fx_basic_buffer.cpp @@ -381,7 +381,7 @@ bool CFX_FileBufferArchive::Flush() { return false; if (!m_pBuffer || !nRemaining) return true; - return m_pFile->WriteBlock(m_pBuffer.get(), nRemaining); + return m_pFile->WriteBlock(m_pBuffer.get(), nRemaining) > 0; } int32_t CFX_FileBufferArchive::AppendBlock(const void* pBuf, size_t size) { diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index 11a840a806..95b761bd09 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -205,7 +205,7 @@ bool CFX_WideString::Equal(const wchar_t* ptr) const { if (!ptr) { return m_pData->m_nDataLength == 0; } - return wcslen(ptr) == m_pData->m_nDataLength && + return wcslen(ptr) == static_cast(m_pData->m_nDataLength) && wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; } bool CFX_WideString::Equal(const CFX_WideStringC& str) const { diff --git a/core/src/fxge/agg/fx_agg_driver.cpp b/core/src/fxge/agg/fx_agg_driver.cpp index 16cf705585..2f376b2b19 100644 --- a/core/src/fxge/agg/fx_agg_driver.cpp +++ b/core/src/fxge/agg/fx_agg_driver.cpp @@ -1799,37 +1799,37 @@ CFX_FxgeDevice::CFX_FxgeDevice() { m_bOwnedBitmap = FALSE; } -FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, - int dither_bits, - FX_BOOL bRgbByteOrder, - CFX_DIBitmap* pOriDevice, - FX_BOOL bGroupKnockout) { +bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, + int dither_bits, + bool bRgbByteOrder, + CFX_DIBitmap* pOriDevice, + bool bGroupKnockout) { if (!pBitmap) { - return FALSE; + return false; } SetBitmap(pBitmap); IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver( pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); SetDeviceDriver(pDriver); - return TRUE; + return true; } -FX_BOOL CFX_FxgeDevice::Create(int width, - int height, - FXDIB_Format format, - int dither_bits, - CFX_DIBitmap* pOriDevice) { - m_bOwnedBitmap = TRUE; +bool CFX_FxgeDevice::Create(int width, + int height, + FXDIB_Format format, + int dither_bits, + CFX_DIBitmap* pOriDevice) { + m_bOwnedBitmap = true; CFX_DIBitmap* pBitmap = new CFX_DIBitmap; if (!pBitmap->Create(width, height, format)) { delete pBitmap; - return FALSE; + return false; } SetBitmap(pBitmap); IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE); SetDeviceDriver(pDriver); - return TRUE; + return true; } CFX_FxgeDevice::~CFX_FxgeDevice() { diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp index cd46148b7f..2ad1e5c9de 100644 --- a/core/src/fxge/ge/fx_ge_fontmap.cpp +++ b/core/src/fxge/ge/fx_ge_fontmap.cpp @@ -387,19 +387,20 @@ int32_t GetSimilarValue(int weight, int pitch_family, FX_DWORD style) { int32_t iSimilarValue = 0; - if ((style & FXFONT_BOLD) == (weight > 400)) { + if (!!(style & FXFONT_BOLD) == (weight > 400)) { iSimilarValue += 16; } - if ((style & FXFONT_ITALIC) == bItalic) { + if (!!(style & FXFONT_ITALIC) == bItalic) { iSimilarValue += 16; } - if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) { + if (!!(style & FXFONT_SERIF) == !!(pitch_family & FXFONT_FF_ROMAN)) { iSimilarValue += 16; } - if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) { + if (!!(style & FXFONT_SCRIPT) == !!(pitch_family & FXFONT_FF_SCRIPT)) { iSimilarValue += 8; } - if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) { + if (!!(style & FXFONT_FIXED_PITCH) == + !!(pitch_family & FXFONT_FF_FIXEDPITCH)) { iSimilarValue += 8; } return iSimilarValue; diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h index 8cee331f64..afaa3bc9f9 100644 --- a/fpdfsdk/include/fsdk_baseannot.h +++ b/fpdfsdk/include/fsdk_baseannot.h @@ -148,8 +148,8 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot { void SetModifiedDate(const FX_SYSTEMTIME& st); FX_SYSTEMTIME GetModifiedDate() const; - void SetFlags(int nFlags); - int GetFlags() const; + void SetFlags(FX_DWORD nFlags); + FX_DWORD GetFlags() const; void SetAppState(const CFX_ByteString& str); CFX_ByteString GetAppState() const; diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index e796254adf..c2d09e8d4d 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -127,7 +127,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { int CountOptions() const; FX_BOOL IsOptionSelected(int nIndex) const; int GetTopVisibleIndex() const; - FX_BOOL IsChecked() const; + bool IsChecked() const; /* BF_ALIGN_LEFT BF_ALIGN_MIDDL @@ -141,7 +141,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { CFX_WideString GetAlternateName() const; // Set Properties. - void SetCheck(FX_BOOL bChecked, FX_BOOL bNotify); + void SetCheck(bool bChecked, bool bNotify); void SetValue(const CFX_WideString& sValue, FX_BOOL bNotify); void SetDefaultValue(const CFX_WideString& sValue); void SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify); @@ -298,12 +298,12 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { FX_BOOL IsValidField(CPDF_Dictionary* pFieldDict); FX_BOOL SubmitFields(const CFX_WideString& csDestination, const std::vector& fields, - FX_BOOL bIncludeOrExclude, - FX_BOOL bUrlEncoded); + bool bIncludeOrExclude, + bool bUrlEncoded); FX_BOOL SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded); FX_BOOL ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf); FX_BOOL ExportFieldsToFDFTextBuf(const std::vector& fields, - FX_BOOL bIncludeOrExclude, + bool bIncludeOrExclude, CFX_ByteTextBuf& textBuf); CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); diff --git a/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h b/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h index 6135b87862..8731562726 100644 --- a/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h +++ b/fpdfsdk/include/pdfwindow/PWL_SpecialButton.h @@ -29,11 +29,11 @@ class CPWL_CheckBox : public CPWL_Button { FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) override; FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag) override; - void SetCheck(FX_BOOL bCheck); - FX_BOOL IsChecked() const; + void SetCheck(bool bCheck); + bool IsChecked() const; private: - FX_BOOL m_bChecked; + bool m_bChecked; }; class CPWL_RadioButton : public CPWL_Button { @@ -46,11 +46,11 @@ class CPWL_RadioButton : public CPWL_Button { FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) override; FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag) override; - void SetCheck(FX_BOOL bCheck); - FX_BOOL IsChecked() const; + void SetCheck(bool bCheck); + bool IsChecked() const; private: - FX_BOOL m_bChecked; + bool m_bChecked; }; #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_SPECIALBUTTON_H_ diff --git a/fpdfsdk/src/formfiller/FFL_CheckBox.cpp b/fpdfsdk/src/formfiller/FFL_CheckBox.cpp index 78a689af64..485f86ba75 100644 --- a/fpdfsdk/src/formfiller/FFL_CheckBox.cpp +++ b/fpdfsdk/src/formfiller/FFL_CheckBox.cpp @@ -96,7 +96,7 @@ FX_BOOL CFFL_CheckBox::IsDataChanged(CPDFSDK_PageView* pPageView) { void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) { if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE)) { - FX_BOOL bNewChecked = pWnd->IsChecked(); + bool bNewChecked = pWnd->IsChecked(); if (bNewChecked) { CPDF_FormField* pField = m_pWidget->GetFormField(); @@ -109,7 +109,7 @@ void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) { } } - m_pWidget->SetCheck(bNewChecked, FALSE); + m_pWidget->SetCheck(bNewChecked, false); m_pWidget->UpdateField(); SetChangeMark(); } diff --git a/fpdfsdk/src/formfiller/FFL_RadioButton.cpp b/fpdfsdk/src/formfiller/FFL_RadioButton.cpp index 845df115ca..029bcf1a17 100644 --- a/fpdfsdk/src/formfiller/FFL_RadioButton.cpp +++ b/fpdfsdk/src/formfiller/FFL_RadioButton.cpp @@ -101,7 +101,7 @@ FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) { void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) { if (CPWL_RadioButton* pWnd = (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) { - FX_BOOL bNewChecked = pWnd->IsChecked(); + bool bNewChecked = pWnd->IsChecked(); if (bNewChecked) { CPDF_FormField* pField = m_pWidget->GetFormField(); @@ -114,7 +114,7 @@ void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) { } } - m_pWidget->SetCheck(bNewChecked, FALSE); + m_pWidget->SetCheck(bNewChecked, false); m_pWidget->UpdateField(); SetChangeMark(); } diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp index 1aa1651e47..81defbf0a7 100644 --- a/fpdfsdk/src/fpdfsave.cpp +++ b/fpdfsdk/src/fpdfsave.cpp @@ -302,10 +302,9 @@ bool FPDF_Doc_Save(FPDF_DOCUMENT document, } CFX_IFileWrite* pStreamWrite = NULL; - FX_BOOL bRet; pStreamWrite = new CFX_IFileWrite; pStreamWrite->Init(pFileWrite); - bRet = FileMaker.Create(pStreamWrite, flags); + bool bRet = FileMaker.Create(pStreamWrite, flags); #ifdef PDF_ENABLE_XFA SendPostSaveToXFADoc(pDoc); #endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp index b007e68fa1..276d302bdd 100644 --- a/fpdfsdk/src/fsdk_baseannot.cpp +++ b/fpdfsdk/src/fsdk_baseannot.cpp @@ -623,11 +623,11 @@ FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const { return systime; } -void CPDFSDK_BAAnnot::SetFlags(int nFlags) { +void CPDFSDK_BAAnnot::SetFlags(FX_DWORD nFlags) { m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags); } -int CPDFSDK_BAAnnot::GetFlags() const { +FX_DWORD CPDFSDK_BAAnnot::GetFlags() const { return m_pAnnot->GetAnnotDict()->GetIntegerBy("F"); } @@ -885,7 +885,7 @@ FX_BOOL CPDFSDK_BAAnnot::CreateFormFiller() { return TRUE; } FX_BOOL CPDFSDK_BAAnnot::IsVisible() const { - int nFlags = GetFlags(); + FX_DWORD nFlags = GetFlags(); return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || (nFlags & ANNOTFLAG_NOVIEW)); } diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index 8541193bda..89d27726e8 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -663,7 +663,7 @@ int CPDFSDK_Widget::GetTopVisibleIndex() const { return pFormField->GetTopVisibleIndex(); } -FX_BOOL CPDFSDK_Widget::IsChecked() const { +bool CPDFSDK_Widget::IsChecked() const { #ifdef PDF_ENABLE_XFA if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) { if (IXFA_Widget* hWidget = GetMixXFAWidget()) { @@ -686,7 +686,7 @@ int CPDFSDK_Widget::GetMaxLen() const { return pFormField->GetMaxLen(); } -void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { +void CPDFSDK_Widget::SetCheck(bool bChecked, bool bNotify) { CPDF_FormControl* pFormCtrl = GetFormControl(); CPDF_FormField* pFormField = pFormCtrl->GetField(); pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, @@ -2373,7 +2373,7 @@ FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { ASSERT(pControl); if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { - int nFlags = pWidget->GetFlags(); + FX_DWORD nFlags = pWidget->GetFlags(); nFlags &= ~ANNOTFLAG_INVISIBLE; nFlags &= ~ANNOTFLAG_NOVIEW; if (bHide) @@ -2406,7 +2406,7 @@ FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) return FALSE; - return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE); + return SubmitFields(sDestination, fields, bIncludeOrExclude, false); } } if (m_pInterForm->CheckRequiredFields(nullptr, true)) @@ -2418,8 +2418,8 @@ FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { FX_BOOL CPDFSDK_InterForm::SubmitFields( const CFX_WideString& csDestination, const std::vector& fields, - FX_BOOL bIncludeOrExclude, - FX_BOOL bUrlEncoded) { + bool bIncludeOrExclude, + bool bUrlEncoded) { CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); CFX_ByteTextBuf textBuf; @@ -2483,7 +2483,7 @@ FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( const std::vector& fields, - FX_BOOL bIncludeOrExclude, + bool bIncludeOrExclude, CFX_ByteTextBuf& textBuf) { std::unique_ptr pFDF(m_pInterForm->ExportToFDF( m_pDocument->GetPath(), fields, bIncludeOrExclude)); diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index 1c9c1f31f4..672a3a3874 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -652,7 +652,7 @@ FX_BOOL Document::submitForm(IJS_Context* cc, if (pPDFInterForm->CheckRequiredFields(&fieldObjects, true)) { pRuntime->BeginBlock(); - pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bFDF); + pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF); pRuntime->EndBlock(); } return TRUE; @@ -803,7 +803,7 @@ FX_BOOL Document::info(IJS_Context* cc, (float)pValueObj->GetNumber()); } else if (pValueObj->IsBoolean()) { FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(), - (bool)pValueObj->GetInteger()); + !!pValueObj->GetInteger()); } } vp << pObj; diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp index 35ef8b42da..0c0dfd17bf 100644 --- a/fpdfsdk/src/javascript/Field.cpp +++ b/fpdfsdk/src/javascript/Field.cpp @@ -3022,7 +3022,7 @@ FX_BOOL Field::checkThisBox(IJS_Context* cc, int nWidget = params[0].ToInt(); - FX_BOOL bCheckit = TRUE; + bool bCheckit = true; if (iSize >= 2) bCheckit = params[1].ToBool(); @@ -3036,10 +3036,12 @@ FX_BOOL Field::checkThisBox(IJS_Context* cc, return FALSE; if (nWidget < 0 || nWidget >= pFormField->CountControls()) return FALSE; + // TODO(weili): Check whether anything special needed for radio button, + // otherwise merge these branches. if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) - pFormField->CheckControl(nWidget, bCheckit, TRUE); + pFormField->CheckControl(nWidget, bCheckit, true); else - pFormField->CheckControl(nWidget, bCheckit, TRUE); + pFormField->CheckControl(nWidget, bCheckit, true); UpdateFormField(m_pDocument, pFormField, TRUE, TRUE, TRUE); return TRUE; diff --git a/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp b/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp index 44c3ec8a94..c19a233940 100644 --- a/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp @@ -21,7 +21,7 @@ CFX_FloatRect CPWL_PushButton::GetFocusRect() const { return CPWL_Utils::DeflateRect(GetWindowRect(), (FX_FLOAT)GetBorderWidth()); } -CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE) {} +CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(false) {} CPWL_CheckBox::~CPWL_CheckBox() {} @@ -29,11 +29,11 @@ CFX_ByteString CPWL_CheckBox::GetClassName() const { return "CPWL_CheckBox"; } -void CPWL_CheckBox::SetCheck(FX_BOOL bCheck) { +void CPWL_CheckBox::SetCheck(bool bCheck) { m_bChecked = bCheck; } -FX_BOOL CPWL_CheckBox::IsChecked() const { +bool CPWL_CheckBox::IsChecked() const { return m_bChecked; } @@ -51,7 +51,7 @@ FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) { return TRUE; } -CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(FALSE) {} +CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(false) {} CPWL_RadioButton::~CPWL_RadioButton() {} @@ -68,11 +68,11 @@ FX_BOOL CPWL_RadioButton::OnLButtonUp(const CFX_FloatPoint& point, return TRUE; } -void CPWL_RadioButton::SetCheck(FX_BOOL bCheck) { +void CPWL_RadioButton::SetCheck(bool bCheck) { m_bChecked = bCheck; } -FX_BOOL CPWL_RadioButton::IsChecked() const { +bool CPWL_RadioButton::IsChecked() const { return m_bChecked; } diff --git a/pdfium.gyp b/pdfium.gyp index 982d31ea17..f5743d242e 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -96,7 +96,7 @@ 'msvs_disabled_warnings': [ 4005, 4018, 4146, 4333, 4345, 4267, # TODO(thestig): Fix all instances, remove this, pdfium:29 - 4245, 4310, 4389, 4701, 4702, 4706, 4800, + 4245, 4310, 4389, 4701, 4702, 4706, ], 'variables': { 'clang_warning_flags': [ -- cgit v1.2.3