From 375a86403b7fa8d17d7b142c270e2d8e33bb924f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 11 Jan 2016 11:59:17 -0800 Subject: Merge to XFA: Switch most min/max macros to std::min/max. Fix lint errors along the way. R=tsepez@chromium.org TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1567343002 . (cherry picked from commit 9adfbb0920a258e916003b1ee9515e97879db82a) Review URL: https://codereview.chromium.org/1577503002 . --- core/include/fxcrt/fx_basic.h | 4 +- core/include/fxcrt/fx_system.h | 1 - core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 60 ++++++++++++--------- .../fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 5 +- core/src/fpdfdoc/doc_formcontrol.cpp | 8 +-- core/src/fpdfdoc/doc_utils.cpp | 8 +-- core/src/fpdfdoc/doc_vt.cpp | 44 ++++++++-------- core/src/fpdfdoc/pdf_vt.h | 33 +++++------- core/src/fpdftext/fpdf_text_int.cpp | 36 ++++++------- core/src/fxcodec/codec/fx_codec_png.cpp | 12 +++-- core/src/fxcodec/lbmp/fx_bmp.cpp | 23 ++++++-- core/src/fxcrt/extension.h | 61 ++++++++-------------- core/src/fxcrt/fx_basic_buffer.cpp | 4 +- core/src/fxcrt/fx_basic_wstring.cpp | 8 +-- core/src/fxcrt/fx_extension.cpp | 53 +++++++++++++++++++ core/src/fxcrt/xml_int.h | 9 ++-- core/src/fxge/agg/src/fx_agg_driver.cpp | 34 ++++++------ core/src/fxge/android/fpf_skiafont.cpp | 7 ++- fpdfsdk/include/fxedit/fxet_edit.h | 35 +++---------- fpdfsdk/src/fpdf_flatten.cpp | 6 ++- fpdfsdk/src/fsdk_baseannot.cpp | 8 +-- fpdfsdk/src/fxedit/fxet_edit.cpp | 7 +-- fpdfsdk/src/javascript/PublicMethods.cpp | 6 ++- fpdfsdk/src/pdfwindow/PWL_Utils.cpp | 15 +++--- xfa/src/fdp/src/css/fde_csscache.cpp | 7 ++- xfa/src/fdp/src/fde/fde_gedevice.cpp | 4 +- xfa/src/fdp/src/tto/fde_textout.cpp | 10 ++-- xfa/src/fdp/src/xml/fde_xml.cpp | 6 ++- xfa/src/fee/src/fee/fde_txtedtbuf.cpp | 10 ++-- xfa/src/fee/src/fee/fde_txtedtengine.cpp | 6 ++- xfa/src/fee/src/fee/fde_txtedtpage.cpp | 6 ++- xfa/src/fgas/src/crt/fx_memory.cpp | 6 ++- xfa/src/fgas/src/crt/fx_stream.cpp | 40 +++++++------- xfa/src/fgas/src/crt/fx_stream.h | 2 +- xfa/src/fgas/src/crt/fx_system.cpp | 4 +- xfa/src/fgas/src/crt/fx_utils.cpp | 7 ++- xfa/src/fgas/src/layout/fx_rtfbreak.cpp | 12 +++-- xfa/src/fgas/src/layout/fx_textbreak.cpp | 10 ++-- xfa/src/fgas/src/localization/fx_locale.cpp | 16 +++--- xfa/src/fgas/src/xml/fx_sax_imp.cpp | 13 ++++- xfa/src/fgas/src/xml/fx_sax_imp.h | 2 +- xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp | 6 ++- xfa/src/fwl/src/basewidget/fwl_editimp.cpp | 16 +++--- xfa/src/fwl/src/core/fwl_widgetimp.cpp | 4 +- xfa/src/fwl/src/theme/widgettp.cpp | 4 +- xfa/src/fxbarcode/BC_TwoDimWriter.cpp | 34 ++++++------ xfa/src/fxbarcode/common/BC_CommonByteArray.cpp | 4 +- .../fxbarcode/datamatrix/BC_DataMatrixDetector.cpp | 16 +++--- xfa/src/fxbarcode/oned/BC_OneDReader.cpp | 4 +- xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp | 6 ++- xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp | 4 +- xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp | 8 +-- xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp | 4 +- xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp | 6 ++- xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp | 10 ++-- xfa/src/fxfa/src/app/xfa_ffapp.cpp | 4 +- xfa/src/fxfa/src/app/xfa_ffwidget.cpp | 8 +-- xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp | 24 +++++---- xfa/src/fxfa/src/app/xfa_fontmgr.cpp | 4 +- xfa/src/fxfa/src/app/xfa_textlayout.cpp | 14 ++--- xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp | 6 ++- 61 files changed, 487 insertions(+), 347 deletions(-) diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index 4aa823e06d..4e7c8c84b4 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -7,6 +7,8 @@ #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_ #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ +#include + #include "fx_memory.h" #include "fx_stream.h" #include "fx_string.h" @@ -1096,7 +1098,7 @@ class CFX_SortListArray { return; } while (nCount > 0) { - int32_t temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH); + int32_t temp_count = std::min(nCount, FX_DATALIST_LENGTH); DataList list; list.data = FX_Alloc2D(uint8_t, temp_count, unit); list.start = nStart; diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h index e0412a0349..2fbab98a1d 100644 --- a/core/include/fxcrt/fx_system.h +++ b/core/include/fxcrt/fx_system.h @@ -110,7 +110,6 @@ static_assert(FALSE == false, "false_needs_to_be_false"); #endif #endif -#define FX_MAX(a, b) (((a) > (b)) ? (a) : (b)) #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b)) #define FX_PI 3.1415926535897932384626433832795f diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 168cbf3a61..87b9e025bc 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -8,6 +8,8 @@ #include +#include + #include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_module.h" #include "core/include/fxcodec/fx_codec.h" @@ -41,6 +43,24 @@ int ComponentsForFamily(int family) { return 4; } +void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) { + if (pDestBuf == pSrcBuf) { + for (int i = 0; i < pixels; i++) { + uint8_t temp = pDestBuf[2]; + pDestBuf[2] = pDestBuf[0]; + pDestBuf[0] = temp; + pDestBuf += 3; + } + } else { + for (int i = 0; i < pixels; i++) { + *pDestBuf++ = pSrcBuf[2]; + *pDestBuf++ = pSrcBuf[1]; + *pDestBuf++ = pSrcBuf[0]; + pSrcBuf += 3; + } + } +} + } // namespace CPDF_DeviceCS::CPDF_DeviceCS(CPDF_Document* pDoc, int family) @@ -82,9 +102,9 @@ FX_BOOL CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, AdobeCMYK_to_sRGB(pBuf[0], pBuf[1], pBuf[2], pBuf[3], R, G, B); } else { FX_FLOAT k = pBuf[3]; - R = 1.0f - FX_MIN(1.0f, pBuf[0] + k); - G = 1.0f - FX_MIN(1.0f, pBuf[1] + k); - B = 1.0f - FX_MIN(1.0f, pBuf[2] + k); + R = 1.0f - std::min(1.0f, pBuf[0] + k); + G = 1.0f - std::min(1.0f, pBuf[1] + k); + B = 1.0f - std::min(1.0f, pBuf[2] + k); } } else { ASSERT(m_Family == PDFCS_PATTERN); @@ -148,22 +168,7 @@ FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, } return FALSE; } -static void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) { - if (pDestBuf == pSrcBuf) - for (int i = 0; i < pixels; i++) { - uint8_t temp = pDestBuf[2]; - pDestBuf[2] = pDestBuf[0]; - pDestBuf[0] = temp; - pDestBuf += 3; - } - else - for (int i = 0; i < pixels; i++) { - *pDestBuf++ = pSrcBuf[2]; - *pDestBuf++ = pSrcBuf[1]; - *pDestBuf++ = pSrcBuf[0]; - pSrcBuf += 3; - } -} + void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, @@ -196,9 +201,9 @@ void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, pDestBuf[2], pDestBuf[1], pDestBuf[0]); } else { uint8_t k = pSrcBuf[3]; - pDestBuf[2] = 255 - FX_MIN(255, pSrcBuf[0] + k); - pDestBuf[1] = 255 - FX_MIN(255, pSrcBuf[1] + k); - pDestBuf[0] = 255 - FX_MIN(255, pSrcBuf[2] + k); + pDestBuf[2] = 255 - std::min(255, pSrcBuf[0] + k); + pDestBuf[1] = 255 - std::min(255, pSrcBuf[1] + k); + pDestBuf[0] = 255 - std::min(255, pSrcBuf[2] + k); } pSrcBuf += 4; pDestBuf += 3; @@ -1012,11 +1017,13 @@ CPDF_ColorSpace* CPDF_PatternCS::GetBaseCS() const { } class CPDF_SeparationCS : public CPDF_ColorSpace { public: - CPDF_SeparationCS(CPDF_Document* pDoc) + explicit CPDF_SeparationCS(CPDF_Document* pDoc) : CPDF_ColorSpace(pDoc, PDFCS_SEPARATION, 1), m_pAltCS(nullptr), m_pFunc(nullptr) {} ~CPDF_SeparationCS() override; + + // CPDF_ColorSpace: void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, @@ -1109,11 +1116,13 @@ void CPDF_SeparationCS::EnableStdConversion(FX_BOOL bEnabled) { } class CPDF_DeviceNCS : public CPDF_ColorSpace { public: - CPDF_DeviceNCS(CPDF_Document* pDoc) + explicit CPDF_DeviceNCS(CPDF_Document* pDoc) : CPDF_ColorSpace(pDoc, PDFCS_DEVICEN, 0), m_pAltCS(nullptr), m_pFunc(nullptr) {} ~CPDF_DeviceNCS() override; + + // CPDF_ColorSpace: void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, @@ -1183,10 +1192,11 @@ void CPDF_DeviceNCS::EnableStdConversion(FX_BOOL bEnabled) { m_pAltCS->EnableStdConversion(bEnabled); } } + CPDF_ColorSpace* CPDF_ColorSpace::GetStockCS(int family) { return CPDF_ModuleMgr::Get()->GetPageModule()->GetStockCS(family); - ; } + CPDF_ColorSpace* _CSFromName(const CFX_ByteString& name) { if (name == "DeviceRGB" || name == "RGB") { return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index c74aea9a21..f690c209a0 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -6,6 +6,7 @@ #include "render_int.h" +#include #include #include @@ -573,8 +574,8 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, for (FX_DWORD i = 0; i < m_nComponents; i++) { int min_num = pArray->GetInteger(i * 2); int max_num = pArray->GetInteger(i * 2 + 1); - pCompData[i].m_ColorKeyMin = FX_MAX(min_num, 0); - pCompData[i].m_ColorKeyMax = FX_MIN(max_num, max_data); + pCompData[i].m_ColorKeyMin = std::max(min_num, 0); + pCompData[i].m_ColorKeyMax = std::min(max_num, max_data); } } bColorKey = TRUE; diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp index bd339e375c..6c3d1ec9c4 100644 --- a/core/src/fpdfdoc/doc_formcontrol.cpp +++ b/core/src/fpdfdoc/doc_formcontrol.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fpdfdoc/fpdf_doc.h" CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, @@ -353,9 +355,9 @@ FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, FX_FLOAT m = pEntry->GetNumber(1); FX_FLOAT y = pEntry->GetNumber(2); FX_FLOAT k = pEntry->GetNumber(3); - FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k); - FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k); - FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k); + FX_FLOAT r = 1.0f - std::min(1.0f, c + k); + FX_FLOAT g = 1.0f - std::min(1.0f, m + k); + FX_FLOAT b = 1.0f - std::min(1.0f, y + k); color = ArgbEncode(255, (int)(r * 255), (int)(g * 255), (int)(b * 255)); } return color; diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index 89836739b3..4856cb51e5 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fpdfdoc/fpdf_doc.h" #include "doc_utils.h" @@ -179,9 +181,9 @@ void CPDF_DefaultAppearance::GetColor(FX_ARGB& color, FX_FLOAT m = FX_atof((CFX_ByteString)syntax.GetWord()); FX_FLOAT y = FX_atof((CFX_ByteString)syntax.GetWord()); FX_FLOAT k = FX_atof((CFX_ByteString)syntax.GetWord()); - FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k); - FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k); - FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k); + FX_FLOAT r = 1.0f - std::min(1.0f, c + k); + FX_FLOAT g = 1.0f - std::min(1.0f, m + k); + FX_FLOAT b = 1.0f - std::min(1.0f, y + k); color = ArgbEncode(255, (int)(r * 255 + 0.5f), (int)(g * 255 + 0.5f), (int)(b * 255 + 0.5f)); } diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp index 8df687ed59..e5c9ad8eba 100644 --- a/core/src/fpdfdoc/doc_vt.cpp +++ b/core/src/fpdfdoc/doc_vt.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fpdfdoc/fpdf_doc.h" #include "core/include/fpdfdoc/fpdf_vt.h" #include "pdf_vt.h" @@ -72,7 +74,7 @@ CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place, const CPVT_WordInfo& wordinfo) { CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo); int32_t nWordIndex = - FPDF_MAX(FPDF_MIN(place.nWordIndex, m_WordArray.GetSize()), 0); + std::max(std::min(place.nWordIndex, m_WordArray.GetSize()), 0); if (nWordIndex == m_WordArray.GetSize()) { m_WordArray.Add(pWord); } else { @@ -356,17 +358,17 @@ CPVT_FloatRect CTypeset::CharArray() { if (w == 0) { pLine->m_LineInfo.fLineX = x; } - if (w != m_pSection->m_WordArray.GetSize() - 1) + if (w != m_pSection->m_WordArray.GetSize() - 1) { pWord->fWordTail = (fNodeWidth - (fWordWidth + fNextWidth) * PVT_HALF > 0 ? fNodeWidth - (fWordWidth + fNextWidth) * PVT_HALF : 0); - else { + } else { pWord->fWordTail = 0; } x += fWordWidth; - fLineAscent = FPDF_MAX(fLineAscent, fWordAscent); - fLineDescent = FPDF_MIN(fLineDescent, fWordDescent); + fLineAscent = std::max(fLineAscent, fWordAscent); + fLineDescent = std::min(fLineDescent, fWordDescent); } } pLine->m_LineInfo.nBeginWordIndex = 0; @@ -582,7 +584,7 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { int32_t nCharIndex = 0; CPVT_LineInfo line; FX_FLOAT fWordWidth = 0; - FX_FLOAT fTypesetWidth = FPDF_MAX( + FX_FLOAT fTypesetWidth = std::max( m_pVT->GetPlateWidth() - m_pVT->GetLineIndent(m_pSection->m_SecInfo), 0.0f); int32_t nTotalWords = m_pSection->m_WordArray.GetSize(); @@ -598,15 +600,15 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { if (pWord) { if (bTypeset) { fLineAscent = - FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pWord, TRUE)); + std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, TRUE)); fLineDescent = - FPDF_MIN(fLineDescent, m_pVT->GetWordDescent(*pWord, TRUE)); + std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, TRUE)); fWordWidth = m_pVT->GetWordWidth(*pWord); } else { fLineAscent = - FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pWord, fFontSize)); + std::max(fLineAscent, m_pVT->GetWordAscent(*pWord, fFontSize)); fLineDescent = - FPDF_MIN(fLineDescent, m_pVT->GetWordDescent(*pWord, fFontSize)); + std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, fFontSize)); fWordWidth = m_pVT->GetWordWidth( pWord->nFontIndex, pWord->Word, m_pVT->m_wSubWord, m_pVT->m_fCharSpace, m_pVT->m_nHorzScale, fFontSize, @@ -662,7 +664,7 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { } fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); fMaxY += (-fLineDescent); - fMaxX = FPDF_MAX(fLineWidth, fMaxX); + fMaxX = std::max(fLineWidth, fMaxX); nLineHead = i; fLineWidth = 0.0f; fLineAscent = 0.0f; @@ -688,7 +690,7 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { } fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo)); fMaxY += (-fLineDescent); - fMaxX = FPDF_MAX(fLineWidth, fMaxX); + fMaxX = std::max(fLineWidth, fMaxX); } } else { if (bTypeset) { @@ -720,7 +722,7 @@ void CTypeset::OutputLines() { FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; FX_FLOAT fPosX = 0.0f, fPosY = 0.0f; FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); - FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); + FX_FLOAT fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { default: case 0: @@ -1259,7 +1261,7 @@ CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace& place, return place; } int32_t nSecIndex = - FPDF_MAX(FPDF_MIN(place.nSecIndex, m_SectionArray.GetSize()), 0); + std::max(std::min(place.nSecIndex, m_SectionArray.GetSize()), 0); CSection* pSection = new CSection(this); pSection->m_SecInfo = secinfo; pSection->SecPlace.nSecIndex = nSecIndex; @@ -1287,7 +1289,7 @@ CPVT_WordPlace CPDF_VariableText::AddWord(const CPVT_WordPlace& place, } CPVT_WordPlace newplace = place; newplace.nSecIndex = - FPDF_MAX(FPDF_MIN(newplace.nSecIndex, m_SectionArray.GetSize() - 1), 0); + std::max(std::min(newplace.nSecIndex, m_SectionArray.GetSize() - 1), 0); if (CSection* pSection = m_SectionArray.GetAt(newplace.nSecIndex)) { return pSection->AddWord(newplace, wordinfo); } @@ -1332,7 +1334,7 @@ FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, return FALSE; } CPDF_Rect CPDF_VariableText::GetContentRect() const { - return InToOut(CPDF_EditContainer::GetContentRect()); + return InToOut(CPVT_FloatRect(CPDF_EditContainer::GetContentRect())); } FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo, FX_BOOL bFactFontSize) { @@ -1576,7 +1578,7 @@ FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) { for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { if (CSection* pSection = m_SectionArray.GetAt(s)) { CPVT_Size size = pSection->GetSectionSize(fFontSize); - szTotal.x = FPDF_MAX(size.x, szTotal.x); + szTotal.x = std::max(size.x, szTotal.x); szTotal.y += size.y; if (IsFloatBigger(szTotal.x, GetPlateWidth()) || IsFloatBigger(szTotal.y, GetPlateHeight())) { @@ -1617,10 +1619,10 @@ CPVT_FloatRect CPDF_VariableText::RearrangeSections( if (s == 0) { rcRet = rcSec; } else { - rcRet.left = FPDF_MIN(rcSec.left, rcRet.left); - rcRet.top = FPDF_MIN(rcSec.top, rcRet.top); - rcRet.right = FPDF_MAX(rcSec.right, rcRet.right); - rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom); + rcRet.left = std::min(rcSec.left, rcRet.left); + rcRet.top = std::min(rcSec.top, rcRet.top); + rcRet.right = std::max(rcSec.right, rcRet.right); + rcRet.bottom = std::max(rcSec.bottom, rcRet.bottom); } fPosY += rcSec.Height(); } diff --git a/core/src/fpdfdoc/pdf_vt.h b/core/src/fpdfdoc/pdf_vt.h index 2cd673fbe5..286fad5772 100644 --- a/core/src/fpdfdoc/pdf_vt.h +++ b/core/src/fpdfdoc/pdf_vt.h @@ -22,14 +22,7 @@ class CPDF_VariableText_Iterator; #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) -template -T FPDF_MIN(const T& i, const T& j) { - return ((i < j) ? i : j); -} -template -T FPDF_MAX(const T& i, const T& j) { - return ((i > j) ? i : j); -} + class CPVT_Size { public: CPVT_Size() : x(0.0f), y(0.0f) {} @@ -51,7 +44,7 @@ class CPVT_FloatRect : public CFX_FloatRect { right = other_right; bottom = other_bottom; } - CPVT_FloatRect(const CPDF_Rect& rect) { + explicit CPVT_FloatRect(const CPDF_Rect& rect) { left = rect.left; top = rect.top; right = rect.right; @@ -246,7 +239,7 @@ class CSection { friend class CTypeset; public: - CSection(CPDF_VariableText* pVT); + explicit CSection(CPDF_VariableText* pVT); virtual ~CSection(); void ResetAll(); void ResetLineArray(); @@ -285,7 +278,7 @@ class CSection { }; class CTypeset { public: - CTypeset(CSection* pSection); + explicit CTypeset(CSection* pSection); virtual ~CTypeset(); CPVT_Size GetEditSize(FX_FLOAT fFontSize); CPVT_FloatRect Typeset(); @@ -307,37 +300,37 @@ class CPDF_EditContainer { virtual const CPDF_Rect& GetPlateRect() const { return m_rcPlate; } virtual void SetContentRect(const CPVT_FloatRect& rect) { m_rcContent = rect; - }; + } virtual CPDF_Rect GetContentRect() const { return m_rcContent; } FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } CPVT_Size GetPlateSize() const { return CPVT_Size(GetPlateWidth(), GetPlateHeight()); - }; + } CPDF_Point GetBTPoint() const { return CPDF_Point(m_rcPlate.left, m_rcPlate.top); - }; + } CPDF_Point GetETPoint() const { return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom); - }; + } inline CPDF_Point InToOut(const CPDF_Point& point) const { return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y); - }; + } inline CPDF_Point OutToIn(const CPDF_Point& point) const { return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y); - }; + } inline CPDF_Rect InToOut(const CPVT_FloatRect& rect) const { CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top)); CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom)); return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, ptLeftTop.y); - }; + } inline CPVT_FloatRect OutToIn(const CPDF_Rect& rect) const { CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top)); CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom)); return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, ptRightBottom.y); - }; + } private: CPDF_Rect m_rcPlate; @@ -539,7 +532,7 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator { public: - CPDF_VariableText_Iterator(CPDF_VariableText* pVT); + explicit CPDF_VariableText_Iterator(CPDF_VariableText* pVT); ~CPDF_VariableText_Iterator() override; // IPDF_VariableText_Iterator diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index cf6cde1169..f527f48814 100644 --- a/core/src/fpdftext/fpdf_text_int.cpp +++ b/core/src/fpdftext/fpdf_text_int.cpp @@ -161,9 +161,9 @@ FX_BOOL CPDF_TextPage::ParseTextPage() { PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i); if (charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) { bNormal = TRUE; - } else if (charinfo.m_Unicode == 0 || IsControlChar(charinfo)) + } else if (charinfo.m_Unicode == 0 || IsControlChar(charinfo)) { bNormal = FALSE; - else { + } else { bNormal = TRUE; } if (bNormal) { @@ -1807,10 +1807,10 @@ FX_BOOL CPDF_TextPage::IsHyphen(FX_WCHAR curChar) { } preChar = (PAGECHAR_INFO)m_charList[size - 1]; } - if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag) - if (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode) { - return TRUE; - } + if (FPDFTEXT_CHAR_PIECE == preChar.m_Flag && + (0xAD == preChar.m_Unicode || 0x2D == preChar.m_Unicode)) { + return TRUE; + } } return FALSE; } @@ -1920,17 +1920,14 @@ int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, } } } - if (bNewline) { - if (IsHyphen(curChar)) { - return 3; - } - return 2; - } + if (bNewline) + return IsHyphen(curChar) ? 3 : 2; + int32_t nChars = pObj->CountChars(); - if (nChars == 1 && (0x2D == curChar || 0xAD == curChar)) - if (IsHyphen(curChar)) { - return 3; - } + if (nChars == 1 && (0x2D == curChar || 0xAD == curChar) && + IsHyphen(curChar)) { + return 3; + } CFX_WideString PrevStr = m_pPreTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode); FX_WCHAR preChar = PrevStr.GetAt(PrevStr.GetLength() - 1); @@ -1956,7 +1953,7 @@ int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, threshold *= 1.5; } if (FXSYS_fabs(last_pos + last_width - x) > threshold && curChar != L' ' && - preChar != L' ') + preChar != L' ') { if (curChar != L' ' && preChar != L' ') { if ((x - last_pos - last_width) > threshold || (last_pos - x - last_width) > threshold) { @@ -1970,6 +1967,7 @@ int CPDF_TextPage::ProcessInsertObject(const CPDF_TextObject* pObj, return 1; } } + } return 0; } FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, @@ -2023,8 +2021,8 @@ FX_BOOL CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) * pTextObj2->GetFontSize() / 1000 * 0.9 || FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) > - FX_MAX(FX_MAX(rcPreObj.Height(), rcPreObj.Width()), - pTextObj2->GetFontSize()) / + std::max(std::max(rcPreObj.Height(), rcPreObj.Width()), + pTextObj2->GetFontSize()) / 8) { return FALSE; } diff --git a/core/src/fxcodec/codec/fx_codec_png.cpp b/core/src/fxcodec/codec/fx_codec_png.cpp index 6401081ea3..3acfc19442 100644 --- a/core/src/fxcodec/codec/fx_codec_png.cpp +++ b/core/src/fxcodec/codec/fx_codec_png.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fxcodec/fx_codec.h" #include "core/include/fxge/fx_dib.h" #include "codec_int.h" @@ -62,24 +64,24 @@ static void _png_load_bmp_attribute(png_structp png_ptr, #endif #if defined(PNG_TEXT_SUPPORTED) int i; - FX_DWORD len; + FX_STRSIZE len; const FX_CHAR* buf; int num_text; png_textp text = NULL; png_get_text(png_ptr, info_ptr, &text, &num_text); for (i = 0; i < num_text; i++) { - len = (FX_DWORD)FXSYS_strlen(text[i].key); + len = FXSYS_strlen(text[i].key); buf = "Time"; - if (!FXSYS_memcmp(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)))) { + if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) { if (!bTime) { FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime)); FXSYS_memcpy( pAttribute->m_strTime, text[i].text, - FX_MIN(sizeof(pAttribute->m_strTime) - 1, text[i].text_length)); + std::min(sizeof(pAttribute->m_strTime) - 1, text[i].text_length)); } } else { buf = "Author"; - if (!FXSYS_memcmp(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)))) { + if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) { pAttribute->m_strAuthor.Empty(); pAttribute->m_strAuthor.Load((uint8_t*)text[i].text, (FX_STRSIZE)text[i].text_length); diff --git a/core/src/fxcodec/lbmp/fx_bmp.cpp b/core/src/fxcodec/lbmp/fx_bmp.cpp index 98bcefdaba..00477581a1 100644 --- a/core/src/fxcodec/lbmp/fx_bmp.cpp +++ b/core/src/fxcodec/lbmp/fx_bmp.cpp @@ -5,6 +5,16 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "fx_bmp.h" + +#include + +namespace { + +const size_t kBmpCoreHeaderSize = 12; +const size_t kBmpInfoHeaderSize = 40; + +} // namespace + FX_DWORD _GetDWord_LSBFirst(uint8_t* p) { return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); } @@ -80,10 +90,12 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) { bmp_ptr->img_ifh_size = _GetDWord_LSBFirst(bmp_ptr->next_in + bmp_ptr->skip_size); bmp_ptr->pal_type = 0; - ASSERT(sizeof(BmpCoreHeader) == 12); - ASSERT(sizeof(BmpInfoHeader) == 40); + static_assert(sizeof(BmpCoreHeader) == kBmpCoreHeaderSize, + "BmpCoreHeader has wrong size"); + static_assert(sizeof(BmpInfoHeader) == kBmpInfoHeaderSize, + "BmpInfoHeader has wrong size"); switch (bmp_ptr->img_ifh_size) { - case FX_MIN(12, sizeof(BmpCoreHeader)): { + case kBmpCoreHeaderSize: { bmp_ptr->pal_type = 1; BmpCoreHeaderPtr bmp_core_header_ptr = NULL; if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr, @@ -100,7 +112,7 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) { bmp_ptr->compress_flag = BMP_RGB; bmp_ptr->imgTB_flag = FALSE; } break; - case FX_MIN(40, sizeof(BmpInfoHeader)): { + case kBmpInfoHeaderSize: { BmpInfoHeaderPtr bmp_info_header_ptr = NULL; if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, bmp_ptr->img_ifh_size) == NULL) { @@ -127,7 +139,8 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) { } } break; default: { - if (bmp_ptr->img_ifh_size > FX_MIN(40, sizeof(BmpInfoHeader))) { + if (bmp_ptr->img_ifh_size > + std::min(kBmpInfoHeaderSize, sizeof(BmpInfoHeader))) { BmpInfoHeaderPtr bmp_info_header_ptr = NULL; if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, bmp_ptr->img_ifh_size) == NULL) { diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 638ffef58e..6e799eb3a4 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -7,6 +7,8 @@ #ifndef CORE_SRC_FXCRT_EXTENSION_H_ #define CORE_SRC_FXCRT_EXTENSION_H_ +#include + #include "core/include/fxcrt/fx_basic.h" #include "core/include/fxcrt/fx_safe_types.h" @@ -67,39 +69,21 @@ class CFX_CRTFileAccess : public IFX_FileAccess { class CFX_CRTFileStream final : public IFX_FileStream { public: - CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1) {} - ~CFX_CRTFileStream() override { - if (m_pFile) { - m_pFile->Release(); - } - } - virtual IFX_FileStream* Retain() override { - m_dwCount++; - return this; - } - virtual void Release() override { - FX_DWORD nCount = --m_dwCount; - if (!nCount) { - delete this; - } - } - virtual FX_FILESIZE GetSize() override { return m_pFile->GetSize(); } - virtual FX_BOOL IsEOF() override { return GetPosition() >= GetSize(); } - virtual FX_FILESIZE GetPosition() override { return m_pFile->GetPosition(); } - virtual FX_BOOL ReadBlock(void* buffer, - FX_FILESIZE offset, - size_t size) override { - return (FX_BOOL)m_pFile->ReadPos(buffer, size, offset); - } - virtual size_t ReadBlock(void* buffer, size_t size) override { - return m_pFile->Read(buffer, size); - } - virtual FX_BOOL WriteBlock(const void* buffer, - FX_FILESIZE offset, - size_t size) override { - return (FX_BOOL)m_pFile->WritePos(buffer, size, offset); - } - virtual FX_BOOL Flush() override { return m_pFile->Flush(); } + explicit CFX_CRTFileStream(IFXCRT_FileAccess* pFA); + ~CFX_CRTFileStream() override; + + // IFX_FileStream: + IFX_FileStream* Retain() override; + void Release() override; + FX_FILESIZE GetSize() override; + FX_BOOL IsEOF() override; + FX_FILESIZE GetPosition() override; + FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; + size_t ReadBlock(void* buffer, size_t size) override; + FX_BOOL WriteBlock(const void* buffer, + FX_FILESIZE offset, + size_t size) override; + FX_BOOL Flush() override; protected: IFXCRT_FileAccess* m_pFile; @@ -111,7 +95,7 @@ class CFX_CRTFileStream final : public IFX_FileStream { #define FX_MEMSTREAM_TakeOver 0x02 class CFX_MemoryStream final : public IFX_MemoryStream { public: - CFX_MemoryStream(FX_BOOL bConsecutive) + explicit CFX_MemoryStream(FX_BOOL bConsecutive) : m_dwCount(1), m_nTotalSize(0), m_nCurSize(0), @@ -190,7 +174,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { if (m_nCurPos >= m_nCurSize) { return 0; } - size_t nRead = FX_MIN(size, m_nCurSize - m_nCurPos); + size_t nRead = std::min(size, m_nCurSize - m_nCurPos); if (!ReadBlock(buffer, (int32_t)m_nCurPos, nRead)) { return 0; } @@ -262,12 +246,13 @@ class CFX_MemoryStream final : public IFX_MemoryStream { void EstimateSize(size_t nInitSize, size_t nGrowSize) override { if (m_dwFlags & FX_MEMSTREAM_Consecutive) { if (m_Blocks.GetSize() < 1) { - uint8_t* pBlock = FX_Alloc(uint8_t, FX_MAX(nInitSize, 4096)); + uint8_t* pBlock = + FX_Alloc(uint8_t, std::max(nInitSize, static_cast(4096))); m_Blocks.Add(pBlock); } - m_nGrowSize = FX_MAX(nGrowSize, 4096); + m_nGrowSize = std::max(nGrowSize, static_cast(4096)); } else if (m_Blocks.GetSize() < 1) { - m_nGrowSize = FX_MAX(nGrowSize, 4096); + m_nGrowSize = std::max(nGrowSize, static_cast(4096)); } } uint8_t* GetBuffer() const override { diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp index e5c6c6d4b9..4ef86bbf41 100644 --- a/core/src/fxcrt/fx_basic_buffer.cpp +++ b/core/src/fxcrt/fx_basic_buffer.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fxcrt/fx_basic.h" FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); @@ -401,7 +403,7 @@ int32_t IFX_BufferArchive::AppendBlock(const void* pBuf, size_t size) { uint8_t* buffer = (uint8_t*)pBuf; FX_STRSIZE temp_size = (FX_STRSIZE)size; while (temp_size > 0) { - FX_STRSIZE buf_size = FX_MIN(m_BufSize - m_Length, (FX_STRSIZE)temp_size); + FX_STRSIZE buf_size = std::min(m_BufSize - m_Length, (FX_STRSIZE)temp_size); FXSYS_memcpy(m_pBuffer + m_Length, buffer, buf_size); m_Length += buf_size; if (m_Length == m_BufSize) { diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index dd26f595f2..2370c87cf1 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -5,6 +5,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include // For offsetof(). + +#include #include #include "core/include/fxcrt/fx_basic.h" @@ -639,7 +641,7 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, pOldData->Release(); } lpszStart = m_pData->m_String; - lpszEnd = m_pData->m_String + FX_MAX(m_pData->m_nDataLength, nNewLength); + lpszEnd = m_pData->m_String + std::max(m_pData->m_nDataLength, nNewLength); { while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) != NULL && @@ -758,9 +760,7 @@ void CFX_WideString::FormatV(const FX_WCHAR* lpszFormat, va_list argList) { nMaxLen += 2; } else if (*lpsz == '*') { nWidth = va_arg(argList, int); - } else if (*lpsz == '-' || *lpsz == '+' || *lpsz == '0' || *lpsz == ' ') - ; - else { + } else if (*lpsz != '-' && *lpsz != '+' && *lpsz != '0' && *lpsz != ' ') { break; } } diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp index 4669ac4be4..8a6987b066 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -14,6 +14,59 @@ #include #endif +CFX_CRTFileStream::CFX_CRTFileStream(IFXCRT_FileAccess* pFA) + : m_pFile(pFA), m_dwCount(1) {} + +CFX_CRTFileStream::~CFX_CRTFileStream() { + if (m_pFile) { + m_pFile->Release(); + } +} + +IFX_FileStream* CFX_CRTFileStream::Retain() { + m_dwCount++; + return this; +} + +void CFX_CRTFileStream::Release() { + FX_DWORD nCount = --m_dwCount; + if (!nCount) { + delete this; + } +} + +FX_FILESIZE CFX_CRTFileStream::GetSize() { + return m_pFile->GetSize(); +} + +FX_BOOL CFX_CRTFileStream::IsEOF() { + return GetPosition() >= GetSize(); +} + +FX_FILESIZE CFX_CRTFileStream::GetPosition() { + return m_pFile->GetPosition(); +} + +FX_BOOL CFX_CRTFileStream::ReadBlock(void* buffer, + FX_FILESIZE offset, + size_t size) { + return (FX_BOOL)m_pFile->ReadPos(buffer, size, offset); +} + +size_t CFX_CRTFileStream::ReadBlock(void* buffer, size_t size) { + return m_pFile->Read(buffer, size); +} + +FX_BOOL CFX_CRTFileStream::WriteBlock(const void* buffer, + FX_FILESIZE offset, + size_t size) { + return (FX_BOOL)m_pFile->WritePos(buffer, size, offset); +} + +FX_BOOL CFX_CRTFileStream::Flush() { + return m_pFile->Flush(); +} + #ifdef PDF_ENABLE_XFA IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { if (wsPath.GetLength() == 0) diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h index b11a64b505..a837327445 100644 --- a/core/src/fxcrt/xml_int.h +++ b/core/src/fxcrt/xml_int.h @@ -7,6 +7,8 @@ #ifndef CORE_SRC_FXCRT_XML_INT_H_ #define CORE_SRC_FXCRT_XML_INT_H_ +#include + #include "core/include/fxcrt/fx_stream.h" class CFX_UTF8Decoder; @@ -43,10 +45,9 @@ class CXML_DataBufAcc : public IFX_BufferRead { size_t m_dwCurPos; }; -#define FX_XMLDATASTREAM_BufferSize (32 * 1024) class CXML_DataStmAcc : public IFX_BufferRead { public: - CXML_DataStmAcc(IFX_FileRead* pFileRead) + explicit CXML_DataStmAcc(IFX_FileRead* pFileRead) : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) { FXSYS_assert(m_pFileRead); } @@ -69,7 +70,9 @@ class CXML_DataStmAcc : public IFX_BufferRead { if (m_nStart >= nLength) { return FALSE; } - m_dwSize = (size_t)FX_MIN(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart); + static const FX_FILESIZE FX_XMLDATASTREAM_BufferSize = 32 * 1024; + m_dwSize = static_cast( + std::min(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart)); if (!m_pBuffer) { m_pBuffer = FX_Alloc(uint8_t, m_dwSize); } diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp index ed2e8e41f0..6828531cba 100644 --- a/core/src/fxge/agg/src/fx_agg_driver.cpp +++ b/core/src/fxge/agg/src/fx_agg_driver.cpp @@ -6,6 +6,8 @@ #include "core/src/fxge/agg/include/fx_agg_driver.h" +#include + #include "core/include/fxcodec/fx_codec.h" #include "core/include/fxge/fx_ge.h" #include "core/src/fxge/dib/dib_int.h" @@ -19,20 +21,15 @@ #include "third_party/agg23/agg_renderer_scanline.h" #include "third_party/agg23/agg_scanline_u.h" -void _HardClip(FX_FLOAT& x, FX_FLOAT& y) { - if (x > 50000) { - x = 50000; - } - if (x < -50000) { - x = -50000; - } - if (y > 50000) { - y = 50000; - } - if (y < -50000) { - y = -50000; - } +namespace { + +void HardClip(FX_FLOAT& x, FX_FLOAT& y) { + x = std::max(std::min(x, 50000.0f), -50000.0f); + y = std::max(std::min(y, 50000.0f), -50000.0f); } + +} // namespace + void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device) { int nPoints = pPathData->GetPointCount(); @@ -42,7 +39,7 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, if (pObject2Device) { pObject2Device->Transform(x, y); } - _HardClip(x, y); + HardClip(x, y); int point_type = pPoints[i].m_Flag & FXPT_TYPE; if (point_type == FXPT_MOVETO) { m_PathData.move_to(x, y); @@ -73,6 +70,7 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, } } namespace agg { + template class renderer_scanline_aa_offset { public: @@ -109,7 +107,9 @@ class renderer_scanline_aa_offset { color_type m_color; unsigned m_left, m_top; }; -} + +} // namespace agg + static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, agg::path_storage& path_data, const CFX_Matrix* pObject2Device, @@ -1257,8 +1257,8 @@ FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, } CFX_Matrix matrix1, matrix2; if (pObject2Device) { - matrix1.a = - FX_MAX(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject2Device->b)); + matrix1.a = std::max(FXSYS_fabs(pObject2Device->a), + FXSYS_fabs(pObject2Device->b)); matrix1.d = matrix1.a; matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, diff --git a/core/src/fxge/android/fpf_skiafont.cpp b/core/src/fxge/android/fpf_skiafont.cpp index ba202acc92..222b28ee8f 100644 --- a/core/src/fxge/android/fpf_skiafont.cpp +++ b/core/src/fxge/android/fpf_skiafont.cpp @@ -5,6 +5,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "fx_fpf.h" + +#include + #if _FX_OS_ == _FX_ANDROID_ #include "fpf_skiafont.h" #include "fpf_skiafontmgr.h" @@ -106,8 +109,8 @@ FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) { rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax); rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax); rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin); - rtBBox.top = FX_MIN(rtBBox.top, GetAscent()); - rtBBox.bottom = FX_MAX(rtBBox.bottom, GetDescent()); + rtBBox.top = std::min(rtBBox.top, GetAscent()); + rtBBox.bottom = std::max(rtBBox.bottom, GetDescent()); FXFT_Done_Glyph(glyph); return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0; } diff --git a/fpdfsdk/include/fxedit/fxet_edit.h b/fpdfsdk/include/fxedit/fxet_edit.h index 1ecb70426f..d1df3812fc 100644 --- a/fpdfsdk/include/fxedit/fxet_edit.h +++ b/fpdfsdk/include/fxedit/fxet_edit.h @@ -8,19 +8,10 @@ #define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ #include "core/include/fpdfdoc/fpdf_vt.h" -#include "fx_edit.h" - -class CFX_Edit_Page; -struct CFX_Edit_LineRect; -class CFX_Edit_LineRectArray; -class CFX_Edit_RectArray; -class CFX_Edit_Refresh; -class CFX_Edit_Select; +#include "fpdfsdk/include/fxedit/fx_edit.h" + class CFX_Edit; class CFX_Edit_Iterator; -class CFX_Edit_Refresh; -class CFX_Edit_UndoItem; -class CFX_Edit_Undo; class CFX_Edit_Provider; #define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001) @@ -29,18 +20,6 @@ class CFX_Edit_Provider; #define FX_EDIT_IsFloatSmaller(fa, fb) \ (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb)) -template -T FX_EDIT_MIN(const T& i, const T& j) { - return ((i < j) ? i : j); -} -template -T FX_EDIT_MAX(const T& i, const T& j) { - return ((i > j) ? i : j); -} - -#define FX_EDIT_PI 3.14159265358979f -#define FX_EDIT_ITALIC_ANGEL 10 * FX_EDIT_PI / 180.0f - /* ------------------------- CFX_Edit_Refresh ---------------------------- */ enum REFRESH_PLAN_E { RP_ANALYSE, RP_NOANALYSE, RP_OPTIONAL }; @@ -195,7 +174,7 @@ class CFX_Edit_Select { Set(begin, end); } - CFX_Edit_Select(const CPVT_WordRange& range) { + explicit CFX_Edit_Select(const CPVT_WordRange& range) { Set(range.BeginPos, range.EndPos); } @@ -230,7 +209,7 @@ class CFX_Edit_Select { class CFX_Edit_Undo { public: - CFX_Edit_Undo(int32_t nBufsize = 10000); + explicit CFX_Edit_Undo(int32_t nBufsize); virtual ~CFX_Edit_Undo(); void Undo(); @@ -285,7 +264,7 @@ class CFX_Edit_UndoItem : public IFX_Edit_UndoItem { class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { public: - CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); + explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); ~CFX_Edit_GroupUndoItem() override; void Undo() override; @@ -542,7 +521,7 @@ class CFX_Edit : public IFX_Edit { friend class CFXEU_InsertText; public: - CFX_Edit(IPDF_VariableText* pVT); + explicit CFX_Edit(IPDF_VariableText* pVT); ~CFX_Edit() override; // IFX_Edit @@ -813,7 +792,7 @@ class CFX_Edit_Iterator : public IFX_Edit_Iterator { class CFX_Edit_Provider : public IPDF_VariableText_Provider { public: - CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap); + explicit CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap); ~CFX_Edit_Provider() override; IFX_Edit_FontMap* GetFontMap(); diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp index 2a0c2d947c..50d5036724 100644 --- a/fpdfsdk/src/fpdf_flatten.cpp +++ b/fpdfsdk/src/fpdf_flatten.cpp @@ -6,6 +6,8 @@ #include "public/fpdf_flatten.h" +#include + #include "fpdfsdk/include/fsdk_define.h" typedef CFX_ArrayTemplate CPDF_ObjectArray; @@ -300,8 +302,8 @@ void GetOffset(FX_FLOAT& fa, FX_FLOAT x4 = matrix.a * rcStream.right + matrix.c * rcStream.top + matrix.e; FX_FLOAT y4 = matrix.b * rcStream.right + matrix.d * rcStream.top + matrix.f; - FX_FLOAT left = FX_MIN(FX_MIN(x1, x2), FX_MIN(x3, x4)); - FX_FLOAT bottom = FX_MIN(FX_MIN(y1, y2), FX_MIN(y3, y4)); + FX_FLOAT left = std::min(std::min(x1, x2), std::min(x3, x4)); + FX_FLOAT bottom = std::min(std::min(y1, y2), std::min(y3, y4)); fa = (rcAnnot.right - rcAnnot.left) / fStreamWidth; fd = (rcAnnot.top - rcAnnot.bottom) / fStreamHeight; diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp index 629f35a1d2..30e702241e 100644 --- a/fpdfsdk/src/fsdk_baseannot.cpp +++ b/fpdfsdk/src/fsdk_baseannot.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fxcrt/fx_ext.h" #include "fpdfsdk/include/fsdk_baseannot.h" #include "fpdfsdk/include/fsdk_define.h" @@ -819,9 +821,9 @@ FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const { FX_FLOAT y = pEntry->GetNumber(2); FX_FLOAT k = pEntry->GetNumber(3); - FX_FLOAT r = 1.0f - FX_MIN(1.0f, c + k); - FX_FLOAT g = 1.0f - FX_MIN(1.0f, m + k); - FX_FLOAT b = 1.0f - FX_MIN(1.0f, y + k); + FX_FLOAT r = 1.0f - std::min(1.0f, c + k); + FX_FLOAT g = 1.0f - std::min(1.0f, m + k); + FX_FLOAT b = 1.0f - std::min(1.0f, y + k); color = FXSYS_RGB((int)(r * 255), (int)(g * 255), (int)(b * 255)); diff --git a/fpdfsdk/src/fxedit/fxet_edit.cpp b/fpdfsdk/src/fxedit/fxet_edit.cpp index c7abbf44bb..0e66b0e3b5 100644 --- a/fpdfsdk/src/fxedit/fxet_edit.cpp +++ b/fpdfsdk/src/fxedit/fxet_edit.cpp @@ -6,6 +6,8 @@ #include "fpdfsdk/include/fxedit/fxet_edit.h" +#include + #include "core/include/fpdfapi/fpdf_resource.h" #define FX_EDIT_UNDO_MAXITEM 10000 @@ -176,8 +178,7 @@ void CFX_Edit_Refresh::Analyse(int32_t nAlignment) { CPDF_Rect rcResult; FX_FLOAT fWidthDiff; - int32_t szMax = - FX_EDIT_MAX(m_OldLineRects.GetSize(), m_NewLineRects.GetSize()); + int32_t szMax = std::max(m_OldLineRects.GetSize(), m_NewLineRects.GetSize()); int32_t i = 0; while (i < szMax) { @@ -1726,7 +1727,7 @@ void CFX_Edit::SetContentChanged() { void CFX_Edit::SelectAll() { if (m_pVT->IsValid()) { - m_SelState = GetWholeWordRange(); + m_SelState = CFX_Edit_Select(GetWholeWordRange()); SetCaret(m_SelState.EndPos); ScrollToCaret(); diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp index 6db31de1e7..d2f7fb09ac 100644 --- a/fpdfsdk/src/javascript/PublicMethods.cpp +++ b/fpdfsdk/src/javascript/PublicMethods.cpp @@ -6,6 +6,8 @@ #include "PublicMethods.h" +#include + #include "Field.h" #include "JS_Context.h" #include "JS_Define.h" @@ -142,10 +144,10 @@ double CJS_PublicMethods::AF_Simple(const FX_WCHAR* sFuction, return dValue1 * dValue2; } if (FXSYS_wcsicmp(sFuction, L"MIN") == 0) { - return FX_MIN(dValue1, dValue2); + return std::min(dValue1, dValue2); } if (FXSYS_wcsicmp(sFuction, L"MAX") == 0) { - return FX_MAX(dValue1, dValue2); + return std::max(dValue1, dValue2); } return dValue1; } diff --git a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp index 3b0f3beff9..27ba8bc99f 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp @@ -4,8 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/include/pdfwindow/PWL_Icon.h" #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" + +#include + +#include "fpdfsdk/include/pdfwindow/PWL_Icon.h" #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) @@ -1256,7 +1259,7 @@ void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC, if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 || dK > 1) return; - dGray = 1.0f - FX_MIN(1.0f, 0.3f * dC + 0.59f * dM + 0.11f * dY + dK); + dGray = 1.0f - std::min(1.0f, 0.3f * dC + 0.59f * dM + 0.11f * dY + dK); } void CPWL_Utils::ConvertGRAY2CMYK(FX_FLOAT dGray, @@ -1302,9 +1305,9 @@ void CPWL_Utils::ConvertCMYK2RGB(FX_FLOAT dC, if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 || dK > 1) return; - dR = 1.0f - FX_MIN(1.0f, dC + dK); - dG = 1.0f - FX_MIN(1.0f, dM + dK); - dB = 1.0f - FX_MIN(1.0f, dY + dK); + dR = 1.0f - std::min(1.0f, dC + dK); + dG = 1.0f - std::min(1.0f, dM + dK); + dB = 1.0f - std::min(1.0f, dY + dK); } void CPWL_Utils::ConvertRGB2CMYK(FX_FLOAT dR, @@ -1320,7 +1323,7 @@ void CPWL_Utils::ConvertRGB2CMYK(FX_FLOAT dR, dC = 1.0f - dR; dM = 1.0f - dG; dY = 1.0f - dB; - dK = FX_MIN(dC, FX_MIN(dM, dY)); + dK = std::min(dC, std::min(dM, dY)); } void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color, diff --git a/xfa/src/fdp/src/css/fde_csscache.cpp b/xfa/src/fdp/src/css/fde_csscache.cpp index fd33019e18..3d3b040a87 100644 --- a/xfa/src/fdp/src/css/fde_csscache.cpp +++ b/xfa/src/fdp/src/css/fde_csscache.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "fde_csscache.h" _FDE_CSSCACHEITEM::_FDE_CSSCACHEITEM(IFDE_CSSStyleSheet* p) @@ -34,8 +36,9 @@ void CFDE_CSSStyleSheetCache::AddStyleSheet(const CFX_ByteStringC& szKey, IFDE_CSSStyleSheet* pStyleSheet) { FXSYS_assert(pStyleSheet != NULL); if (m_pFixedStore == NULL) { - m_pFixedStore = FX_CreateAllocator( - FX_ALLOCTYPE_Fixed, FX_MAX(10, m_iMaxItems), sizeof(FDE_CSSCACHEITEM)); + m_pFixedStore = + FX_CreateAllocator(FX_ALLOCTYPE_Fixed, std::max(10, m_iMaxItems), + sizeof(FDE_CSSCACHEITEM)); FXSYS_assert(m_pFixedStore != NULL); } auto it = m_Stylesheets.find(szKey); diff --git a/xfa/src/fdp/src/fde/fde_gedevice.cpp b/xfa/src/fdp/src/fde/fde_gedevice.cpp index 08f05e74bb..f4e46d0d81 100644 --- a/xfa/src/fdp/src/fde/fde_gedevice.cpp +++ b/xfa/src/fdp/src/fde/fde_gedevice.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "fde_gedevice.h" #include "fde_geobject.h" @@ -541,7 +543,7 @@ FX_BOOL CFDE_FxgeDevice::FillLinearGradientPath(IFDE_Brush* pBrush, FX_FLOAT fLength = fDiagonal.Length(); FX_FLOAT fTotalX = fLength / FXSYS_cos(fTheta); FX_FLOAT fTotalY = fLength / FXSYS_cos(FX_PI / 2 - fTheta); - FX_FLOAT fSteps = FX_MAX(fTotalX, fTotalY); + FX_FLOAT fSteps = std::max(fTotalX, fTotalY); FX_FLOAT dx = fTotalX / fSteps; FX_FLOAT dy = fTotalY / fSteps; FX_ARGB cr0, cr1; diff --git a/xfa/src/fdp/src/tto/fde_textout.cpp b/xfa/src/fdp/src/tto/fde_textout.cpp index b9a8e80107..90f21f15bb 100644 --- a/xfa/src/fdp/src/tto/fde_textout.cpp +++ b/xfa/src/fdp/src/tto/fde_textout.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "fde_textout.h" IFDE_TextOut* IFDE_TextOut::Create() { @@ -270,11 +272,11 @@ void CFDE_TextOut::CalcTextSize(const FX_WCHAR* pwsStr, rect.top += fStartPos; rect.left += fInc; rect.width = fHeight; - rect.height = FX_MIN(fWidth, rect.Height()); + rect.height = std::min(fWidth, rect.Height()); } else { rect.left += fStartPos; rect.top += fInc; - rect.width = FX_MIN(fWidth, rect.Width()); + rect.width = std::min(fWidth, rect.Width()); rect.height = fHeight; if (m_dwStyles & FDE_TTOSTYLE_LastLineHeight) { rect.height -= m_fLineSpace - m_fFontSize; @@ -313,7 +315,7 @@ FX_BOOL CFDE_TextOut::RetrieveLineWidth(FX_DWORD dwBreakStatus, for (int32_t i = 0; i < iCount; i++) { const CFX_TxtPiece* pPiece = m_pTxtBreak->GetBreakPiece(i); fLineWidth += (FX_FLOAT)pPiece->m_iWidth / 20000.0f; - fStartPos = FX_MIN(fStartPos, (FX_FLOAT)pPiece->m_iStartPos / 20000.0f); + fStartPos = std::min(fStartPos, (FX_FLOAT)pPiece->m_iStartPos / 20000.0f); } m_pTxtBreak->ClearBreakPieces(); if (dwBreakStatus == FX_TXTBREAK_ParagraphBreak) { @@ -322,7 +324,7 @@ FX_BOOL CFDE_TextOut::RetrieveLineWidth(FX_DWORD dwBreakStatus, if (!bLineWrap && dwBreakStatus == FX_TXTBREAK_LineBreak) { fWidth += fLineWidth; } else { - fWidth = FX_MAX(fWidth, fLineWidth); + fWidth = std::max(fWidth, fLineWidth); fHeight += fLineStep; } m_iTotalLines++; diff --git a/xfa/src/fdp/src/xml/fde_xml.cpp b/xfa/src/fdp/src/xml/fde_xml.cpp index aa217227c4..8725cb7655 100644 --- a/xfa/src/fdp/src/xml/fde_xml.cpp +++ b/xfa/src/fdp/src/xml/fde_xml.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "fde_xml.h" #ifdef __cplusplus @@ -1484,7 +1486,7 @@ void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream, int32_t iStreamLength = pStream->GetLength(); FXSYS_assert(iStreamLength > 0); m_pStream = pStream; - m_iXMLPlaneSize = FX_MIN(iXMLPlaneSize, iStreamLength); + m_iXMLPlaneSize = std::min(iXMLPlaneSize, iStreamLength); uint8_t bom[4]; m_iCurrentPos = m_pStream->GetBOM(bom); FXSYS_assert(m_pBuffer == NULL); @@ -2002,7 +2004,7 @@ void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream, int32_t iStreamLength = pStream->GetLength(); FXSYS_assert(iStreamLength > 0); m_pStream = pStream; - m_iXMLPlaneSize = FX_MIN(iXMLPlaneSize, iStreamLength); + m_iXMLPlaneSize = std::min(iXMLPlaneSize, iStreamLength); m_iTextDataSize = iTextDataSize; uint8_t bom[4]; m_iCurrentPos = m_pStream->GetBOM(bom); diff --git a/xfa/src/fee/src/fee/fde_txtedtbuf.cpp b/xfa/src/fee/src/fee/fde_txtedtbuf.cpp index 0019207212..bdef8d2a9f 100644 --- a/xfa/src/fee/src/fee/fde_txtedtbuf.cpp +++ b/xfa/src/fee/src/fee/fde_txtedtbuf.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fee/include/ifde_txtedtbuf.h" #include "xfa/src/fee/include/ifde_txtedtengine.h" @@ -269,7 +271,7 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos, if (lpChunk->nUsed != m_nChunkSize) { cp.nChunkIndex--; int32_t nFree = m_nChunkSize - lpChunk->nUsed; - int32_t nCopy = FX_MIN(nLengthTemp, nFree); + int32_t nCopy = std::min(nLengthTemp, nFree); FXSYS_memcpy(lpChunk->wChars + lpChunk->nUsed, lpText, nCopy * sizeof(FX_WCHAR)); lpText += nCopy; @@ -282,7 +284,7 @@ void CFDE_TxtEdtBuf::Insert(int32_t nPos, FDE_LPCHUNKHEADER lpChunk = (FDE_LPCHUNKHEADER)m_pAllocator->Alloc( sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR)); FXSYS_assert(lpChunk); - int32_t nCopy = FX_MIN(nLengthTemp, m_nChunkSize); + int32_t nCopy = std::min(nLengthTemp, m_nChunkSize); FXSYS_memcpy(lpChunk->wChars, lpText, nCopy * sizeof(FX_WCHAR)); lpText += nCopy; nLengthTemp -= nCopy; @@ -302,7 +304,7 @@ void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) { int32_t nFirstPart = cpEnd.nCharIndex + 1; int32_t nMovePart = lpChunk->nUsed - nFirstPart; if (nMovePart != 0) { - int32_t nDelete = FX_MIN(nFirstPart, nLength); + int32_t nDelete = std::min(nFirstPart, nLength); FXSYS_memmove(lpChunk->wChars + nFirstPart - nDelete, lpChunk->wChars + nFirstPart, nMovePart * sizeof(FX_WCHAR)); lpChunk->nUsed -= nDelete; @@ -311,7 +313,7 @@ void CFDE_TxtEdtBuf::Delete(int32_t nIndex, int32_t nLength) { } while (nLength > 0) { lpChunk = (FDE_LPCHUNKHEADER)m_Chunks[cpEnd.nChunkIndex]; - int32_t nDeleted = FX_MIN(lpChunk->nUsed, nLength); + int32_t nDeleted = std::min(lpChunk->nUsed, nLength); lpChunk->nUsed -= nDeleted; if (lpChunk->nUsed == 0) { m_pAllocator->Free(lpChunk); diff --git a/xfa/src/fee/src/fee/fde_txtedtengine.cpp b/xfa/src/fee/src/fee/fde_txtedtengine.cpp index 51f41d1273..7d87f2c0e9 100644 --- a/xfa/src/fee/src/fee/fde_txtedtengine.cpp +++ b/xfa/src/fee/src/fee/fde_txtedtengine.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fee/include/ifde_txtedtengine.h" #include "xfa/src/fee/include/ifde_txtedtbuf.h" @@ -122,7 +124,7 @@ void CFDE_TxtEdtEngine::SetTextByStream(IFX_Stream* pStream) { uint8_t bom[4]; int32_t nPos = pStream->GetBOM(bom); pStream->Seek(FX_STREAMSEEK_Begin, nPos); - int32_t nPlateSize = FX_MIN(nStreamLength, m_pTxtBuf->GetChunkSize()); + int32_t nPlateSize = std::min(nStreamLength, m_pTxtBuf->GetChunkSize()); FX_WCHAR* lpwstr = FX_Alloc(FX_WCHAR, nPlateSize); FX_BOOL bEos = false; while (!bEos) { @@ -389,7 +391,7 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, break; } if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) { - AddSelRange(FX_MIN(m_nAnchorPos, m_nCaret), + AddSelRange(std::min(m_nAnchorPos, m_nCaret), FXSYS_abs(m_nAnchorPos - m_nCaret)); m_Param.pEventSink->On_SelChanged(this); } diff --git a/xfa/src/fee/src/fee/fde_txtedtpage.cpp b/xfa/src/fee/src/fee/fde_txtedtpage.cpp index 2c592232f6..fbeccbeba0 100644 --- a/xfa/src/fee/src/fee/fde_txtedtpage.cpp +++ b/xfa/src/fee/src/fee/fde_txtedtpage.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fee/include/ifde_txtedtbuf.h" #include "xfa/src/fee/include/ifde_txtedtengine.h" @@ -395,8 +397,8 @@ int32_t CFDE_TxtEdtPage::LoadPage(FX_LPCRECTF pClipBox, IFX_Pause* pPause) { pBreak->ClearBreakPieces(); int32_t nPageLineCount = m_pEditEngine->GetPageLineCount(); int32_t nStartLine = nPageLineCount * m_nPageIndex; - int32_t nEndLine = FX_MIN((nStartLine + nPageLineCount - 1), - (m_pEditEngine->GetLineCount() - 1)); + int32_t nEndLine = std::min((nStartLine + nPageLineCount - 1), + (m_pEditEngine->GetLineCount() - 1)); int32_t nPageStart, nPageEnd, nTemp, nBgnParag, nStartLineInParag, nEndParag, nEndLineInParag; nBgnParag = m_pEditEngine->Line2Parag(0, 0, nStartLine, nStartLineInParag); diff --git a/xfa/src/fgas/src/crt/fx_memory.cpp b/xfa/src/fgas/src/crt/fx_memory.cpp index a450119caf..0f17dc8a7e 100644 --- a/xfa/src/fgas/src/crt/fx_memory.cpp +++ b/xfa/src/fgas/src/crt/fx_memory.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/fgas/src/fgas_base.h" #include "fx_memory.h" #define FX_4BYTEALIGN(size) (((size) + 3) / 4 * 4) @@ -59,7 +61,7 @@ FX_LPSTATICSTORECHUNK CFX_StaticStore::AllocChunk(size_t size) { FX_LPSTATICSTORECHUNK CFX_StaticStore::FindChunk(size_t size) { FXSYS_assert(size != 0); if (m_pLastChunk == NULL || m_pLastChunk->iFreeSize < size) { - return AllocChunk(FX_MAX(m_iDefChunkSize, size)); + return AllocChunk(std::max(m_iDefChunkSize, size)); } return m_pLastChunk; } @@ -242,7 +244,7 @@ void* CFX_DynamicStore::Alloc(size_t size) { pChunk = pChunk->pNextChunk; } if (pChunk == NULL) { - pChunk = AllocChunk(FX_MAX(m_iDefChunkSize, size)); + pChunk = AllocChunk(std::max(m_iDefChunkSize, size)); pBlock = pChunk->FirstBlock(); } FXSYS_assert(pChunk != NULL && pBlock != NULL); diff --git a/xfa/src/fgas/src/crt/fx_stream.cpp b/xfa/src/fgas/src/crt/fx_stream.cpp index 9bb59782c2..fb8c3c7fba 100644 --- a/xfa/src/fgas/src/crt/fx_stream.cpp +++ b/xfa/src/fgas/src/crt/fx_stream.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/fgas/src/fgas_base.h" #include "fx_stream.h" IFX_Stream* IFX_Stream::CreateStream(IFX_BufferRead* pBufferRead, @@ -204,7 +206,7 @@ int32_t CFX_FileStreamImp::ReadString(FX_WCHAR* pStr, return 0; } int32_t iPosition = FXSYS_ftell(m_hFile); - int32_t iLen = FX_MIN((m_iLength - iPosition) / 2, iMaxLength); + int32_t iLen = std::min((m_iLength - iPosition) / 2, iMaxLength); if (iLen <= 0) { return 0; } @@ -415,7 +417,7 @@ int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer, const uint8_t* pBufferTmp = m_pBufferRead->GetBlockBuffer(); FX_DWORD dwOffsetTmp = m_iPosition - dwBlockOffset; FX_DWORD dwCopySize = - FX_MIN(iBufferSize, (int32_t)(dwBlockSize - dwOffsetTmp)); + std::min(iBufferSize, (int32_t)(dwBlockSize - dwOffsetTmp)); FXSYS_memcpy(pBuffer, pBufferTmp + dwOffsetTmp, dwCopySize); dwOffsetTmp = dwCopySize; iBufferSize -= dwCopySize; @@ -426,7 +428,7 @@ int32_t CFX_BufferReadStreamImp::ReadData(uint8_t* pBuffer, dwBlockOffset = m_pBufferRead->GetBlockOffset(); dwBlockSize = m_pBufferRead->GetBlockSize(); pBufferTmp = m_pBufferRead->GetBlockBuffer(); - dwCopySize = FX_MIN((FX_DWORD)iBufferSize, dwBlockSize); + dwCopySize = std::min((FX_DWORD)iBufferSize, dwBlockSize); FXSYS_memcpy(pBuffer + dwOffsetTmp, pBufferTmp, dwCopySize); dwOffsetTmp += dwCopySize; iBufferSize -= dwCopySize; @@ -562,7 +564,7 @@ FX_BOOL CFX_BufferStreamImp::IsEOF() const { int32_t CFX_BufferStreamImp::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { FXSYS_assert(m_pData != NULL); FXSYS_assert(pBuffer != NULL && iBufferSize > 0); - int32_t iLen = FX_MIN(m_iLength - m_iPosition, iBufferSize); + int32_t iLen = std::min(m_iLength - m_iPosition, iBufferSize); if (iLen <= 0) { return 0; } @@ -575,7 +577,7 @@ int32_t CFX_BufferStreamImp::ReadString(FX_WCHAR* pStr, FX_BOOL& bEOS) { FXSYS_assert(m_pData != NULL); FXSYS_assert(pStr != NULL && iMaxLength > 0); - int32_t iLen = FX_MIN((m_iLength - m_iPosition) / 2, iMaxLength); + int32_t iLen = std::min((m_iLength - m_iPosition) / 2, iMaxLength); if (iLen <= 0) { return 0; } @@ -592,7 +594,7 @@ int32_t CFX_BufferStreamImp::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { FXSYS_assert(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0); FXSYS_assert(pBuffer != NULL && iBufferSize > 0); - int32_t iLen = FX_MIN(m_iTotalSize - m_iPosition, iBufferSize); + int32_t iLen = std::min(m_iTotalSize - m_iPosition, iBufferSize); if (iLen <= 0) { return 0; } @@ -607,7 +609,7 @@ int32_t CFX_BufferStreamImp::WriteString(const FX_WCHAR* pStr, int32_t iLength) { FXSYS_assert(m_pData != NULL && (m_dwAccess & FX_STREAMACCESS_Write) != 0); FXSYS_assert(pStr != NULL && iLength > 0); - int32_t iLen = FX_MIN((m_iTotalSize - m_iPosition) / 2, iLength); + int32_t iLen = std::min((m_iTotalSize - m_iPosition) / 2, iLength); if (iLen <= 0) { return 0; } @@ -688,7 +690,7 @@ void CFX_TextStream::InitStream() { } } #endif - m_pStreamImp->Seek(FX_STREAMSEEK_Begin, FX_MAX(m_wBOMLength, iPosition)); + m_pStreamImp->Seek(FX_STREAMSEEK_Begin, std::max(m_wBOMLength, iPosition)); } void CFX_TextStream::Release() { if (--m_iRefCount < 1) { @@ -747,7 +749,7 @@ int32_t CFX_TextStream::GetBOM(uint8_t bom[4]) const { return 0; } *(FX_DWORD*)bom = m_dwBOM; - return (int32_t)m_wBOMLength; + return m_wBOMLength; } FX_WORD CFX_TextStream::SetCodePage(FX_WORD wCodePage) { if (m_wBOMLength > 0) { @@ -788,7 +790,7 @@ int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, } else { int32_t pos = m_pStreamImp->GetPosition(); int32_t iBytes = pByteSize == NULL ? iMaxLength : *pByteSize; - iBytes = FX_MIN(iBytes, m_pStreamImp->GetLength() - pos); + iBytes = std::min(iBytes, m_pStreamImp->GetLength() - pos); if (iBytes > 0) { if (m_pBuf == NULL) { m_pBuf = FX_Alloc(uint8_t, iBytes); @@ -1024,7 +1026,7 @@ int32_t CFX_Stream::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { if (m_pStreamImp == NULL) { return -1; } - int32_t iLen = FX_MIN(m_iStart + m_iLength - m_iPosition, iBufferSize); + int32_t iLen = std::min(m_iStart + m_iLength - m_iPosition, iBufferSize); if (iLen <= 0) { return 0; } @@ -1048,9 +1050,9 @@ int32_t CFX_Stream::ReadString(FX_WCHAR* pStr, int32_t iEnd = m_iStart + m_iLength; int32_t iLen = iEnd - m_iPosition; if (pByteSize != NULL) { - iLen = FX_MIN(iLen, *pByteSize); + iLen = std::min(iLen, *pByteSize); } - iLen = FX_MIN(iEnd / 2, iMaxLength); + iLen = std::min(iEnd / 2, iMaxLength); if (iLen <= 0) { return 0; } @@ -1076,7 +1078,7 @@ int32_t CFX_Stream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { } int32_t iLen = iBufferSize; if (m_eStreamType == FX_STREAMTYPE_Stream) { - iLen = FX_MIN(m_iStart + m_iTotalSize - m_iPosition, iBufferSize); + iLen = std::min(m_iStart + m_iTotalSize - m_iPosition, iBufferSize); if (iLen <= 0) { return 0; } @@ -1104,7 +1106,7 @@ int32_t CFX_Stream::WriteString(const FX_WCHAR* pStr, int32_t iLength) { } int32_t iLen = iLength; if (m_eStreamType == FX_STREAMTYPE_Stream) { - iLen = FX_MIN((m_iStart + m_iTotalSize - m_iPosition) / 2, iLength); + iLen = std::min((m_iStart + m_iTotalSize - m_iPosition) / 2, iLength); if (iLen <= 0) { return 0; } @@ -1322,7 +1324,7 @@ FX_BOOL CFX_BufferAccImp::ReadBlock(void* buffer, } const uint8_t* pBuffer = m_pBufferRead->GetBlockBuffer(); FX_FILESIZE dwOffset = offset - dwBlockOffset; - size_t dwCopySize = FX_MIN(size, dwBlockSize - dwOffset); + size_t dwCopySize = std::min(size, dwBlockSize - dwOffset); FXSYS_memcpy(buffer, pBuffer + dwOffset, dwCopySize); offset = dwCopySize; size -= dwCopySize; @@ -1333,7 +1335,7 @@ FX_BOOL CFX_BufferAccImp::ReadBlock(void* buffer, dwBlockOffset = m_pBufferRead->GetBlockOffset(); dwBlockSize = m_pBufferRead->GetBlockSize(); pBuffer = m_pBufferRead->GetBlockBuffer(); - dwCopySize = FX_MIN(size, dwBlockSize); + dwCopySize = std::min(size, dwBlockSize); FXSYS_memcpy(((uint8_t*)buffer) + offset, pBuffer, dwCopySize); offset += dwCopySize; size -= dwCopySize; @@ -1415,7 +1417,7 @@ FX_BOOL CFX_BufferAccImp::ReadBlock(void* buffer, } const uint8_t* pBuffer = m_pBufferRead->GetBlockBuffer(); FX_DWORD dwOffset = offset - dwBlockOffset; - FX_DWORD dwCopySize = FX_MIN(size, dwBlockSize - dwOffset); + FX_DWORD dwCopySize = std::min(size, dwBlockSize - dwOffset); FXSYS_memcpy(buffer, pBuffer + dwOffset, dwCopySize); offset = dwCopySize; size -= dwCopySize; @@ -1426,7 +1428,7 @@ FX_BOOL CFX_BufferAccImp::ReadBlock(void* buffer, dwBlockOffset = m_pBufferRead->GetBlockOffset(); dwBlockSize = m_pBufferRead->GetBlockSize(); pBuffer = m_pBufferRead->GetBlockBuffer(); - dwCopySize = FX_MIN(size, dwBlockSize); + dwCopySize = std::min(size, dwBlockSize); FXSYS_memcpy(((uint8_t*)buffer) + offset, pBuffer, dwCopySize); offset += dwCopySize; size -= dwCopySize; diff --git a/xfa/src/fgas/src/crt/fx_stream.h b/xfa/src/fgas/src/crt/fx_stream.h index bb13758f7b..8edd7e2627 100644 --- a/xfa/src/fgas/src/crt/fx_stream.h +++ b/xfa/src/fgas/src/crt/fx_stream.h @@ -252,7 +252,7 @@ class CFX_TextStream : public IFX_Stream, public CFX_ThreadLock { protected: FX_WORD m_wCodePage; - FX_WORD m_wBOMLength; + int32_t m_wBOMLength; FX_DWORD m_dwBOM; uint8_t* m_pBuf; int32_t m_iBufSize; diff --git a/xfa/src/fgas/src/crt/fx_system.cpp b/xfa/src/fgas/src/crt/fx_system.cpp index 0de8e0eb5b..861d1177ad 100644 --- a/xfa/src/fgas/src/crt/fx_system.cpp +++ b/xfa/src/fgas/src/crt/fx_system.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/fgas/src/fgas_base.h" #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ _FX_OS_ == _FX_WIN64_ @@ -155,7 +157,7 @@ FX_BOOL FX_IsRelativePath(const CFX_WideStringC& wsUrl) { if (iUrlLen == 0) { return TRUE; } - for (int32_t i = FX_MIN(5, iUrlLen) - 1; i >= 0; --i) + for (int32_t i = std::min(5, iUrlLen) - 1; i >= 0; --i) if (wsUrl.GetAt(i) == ':') { return FALSE; } diff --git a/xfa/src/fgas/src/crt/fx_utils.cpp b/xfa/src/fgas/src/crt/fx_utils.cpp index 9d89e240f4..7cc4de7022 100644 --- a/xfa/src/fgas/src/crt/fx_utils.cpp +++ b/xfa/src/fgas/src/crt/fx_utils.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/fgas/include/fx_utl.h" #include "xfa/src/fgas/src/fgas_base.h" #include "fx_utils.h" @@ -241,7 +243,8 @@ void CFX_BaseMassArrayImp::Append(int32_t iDstStart, uint8_t* pSrcChunk = (uint8_t*)src.GetAt(iSrcStart); int32_t iDstChunkSize = m_iChunkSize - (iDstStart % m_iChunkSize); int32_t iSrcChunkSize = src.m_iChunkSize - (iSrcStart % src.m_iChunkSize); - int32_t iCopySize = FX_MIN(iSrcCount, FX_MIN(iSrcChunkSize, iDstChunkSize)); + int32_t iCopySize = + std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize)); int32_t iCopyBytes = iCopySize * m_iBlockSize; while (iSrcCount > 0) { FXSYS_assert(pDstChunk != NULL && pSrcChunk != NULL); @@ -263,7 +266,7 @@ void CFX_BaseMassArrayImp::Append(int32_t iDstStart, } else { pDstChunk += iCopyBytes; } - iCopySize = FX_MIN(iSrcCount, FX_MIN(iSrcChunkSize, iDstChunkSize)); + iCopySize = std::min(iSrcCount, std::min(iSrcChunkSize, iDstChunkSize)); iCopyBytes = iCopySize * m_iBlockSize; } } diff --git a/xfa/src/fgas/src/layout/fx_rtfbreak.cpp b/xfa/src/fgas/src/layout/fx_rtfbreak.cpp index 8683bcfdb6..26d27312bc 100644 --- a/xfa/src/fgas/src/layout/fx_rtfbreak.cpp +++ b/xfa/src/fgas/src/layout/fx_rtfbreak.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/fgas/include/fx_lbk.h" #include "xfa/src/fgas/src/fgas_base.h" #include "xfa/src/fgas/src/layout/fx_unicode.h" @@ -389,7 +391,7 @@ FX_DWORD CFX_RTFBreak::AppendChar(FX_WCHAR wch) { (this->*g_FX_RTFBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( pCurChar, iRotation); m_dwCharType = dwType; - return FX_MAX(dwRet1, dwRet2); + return std::max(dwRet1, dwRet2); } FX_DWORD CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL); @@ -1151,7 +1153,7 @@ void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { pBreakPiece = rtfPieces.GetPtrAt(i); int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * pBreakPiece->m_iVerticalScale / 100.0f); - iMax = FX_MAX(pBreakPiece->m_iFontSize, iFontHeight); + iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); if (i == 0) { iLineHeight = iMax; } else if (iLineHeight < iMax) { @@ -1441,7 +1443,7 @@ int32_t CFX_RTFBreak::GetCharRects(FX_LPCRTFTEXTOBJ pText, if (bCharBBox) { bCharBBox = pFont->GetBBox(bbox); } - FX_FLOAT fLeft = FX_MAX(0, bbox.left * fScale); + FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); rtArray.RemoveAll(); rtArray.SetSize(iLength); @@ -1506,13 +1508,13 @@ int32_t CFX_RTFBreak::GetCharRects(FX_LPCRTFTEXTOBJ pText, rtBBoxF.left = rect.top + (rect.height - fHeight) / 2.0f; rtBBoxF.height = fCharWidth; rtBBoxF.width = fHeight; - rtBBoxF.left = FX_MAX(rtBBoxF.left, 0); + rtBBoxF.left = std::max(rtBBoxF.left, 0.0f); } else { rtBBoxF.left = rect.left + fRTLeft; rtBBoxF.top = rect.top + (rect.height - fHeight) / 2.0f; rtBBoxF.width = fCharWidth; rtBBoxF.height = fHeight; - rtBBoxF.top = FX_MAX(rtBBoxF.top, 0); + rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); } rtArray.SetAt(i, rtBBoxF); continue; diff --git a/xfa/src/fgas/src/layout/fx_textbreak.cpp b/xfa/src/fgas/src/layout/fx_textbreak.cpp index 754e10d863..a9ce859623 100644 --- a/xfa/src/fgas/src/layout/fx_textbreak.cpp +++ b/xfa/src/fgas/src/layout/fx_textbreak.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fxcrt/fx_arb.h" #include "xfa/src/fgas/include/fx_lbk.h" #include "xfa/src/fgas/src/fgas_base.h" @@ -605,7 +607,7 @@ FX_DWORD CFX_TxtBreak::AppendChar(FX_WCHAR wch) { FX_DWORD dwRet2 = (this->*g_FX_TxtBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( pCurChar, iRotation); - return FX_MAX(dwRet1, dwRet2); + return std::max(dwRet1, dwRet2); } void CFX_TxtBreak::EndBreak_UpdateArabicShapes() { FXSYS_assert(m_bArabicShapes); @@ -1572,7 +1574,7 @@ int32_t CFX_TxtBreak::GetCharRects(FX_LPCTXTRUN pTxtRun, if (bCharBBox) { bCharBBox = pFont->GetBBox(bbox); } - FX_FLOAT fLeft = FX_MAX(0, bbox.left * fScale); + FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); rtArray.RemoveAll(); rtArray.SetSize(iLength); @@ -1642,13 +1644,13 @@ int32_t CFX_TxtBreak::GetCharRects(FX_LPCTXTRUN pTxtRun, rtBBoxF.left = rect.top + (rect.height - fHeight) / 2.0f; rtBBoxF.height = fCharWidth; rtBBoxF.width = fHeight; - rtBBoxF.left = FX_MAX(rtBBoxF.left, 0); + rtBBoxF.left = std::max(rtBBoxF.left, 0.0f); } else { rtBBoxF.left = rect.left + fRTLeft; rtBBoxF.top = rect.top + (rect.height - fHeight) / 2.0f; rtBBoxF.width = fCharWidth; rtBBoxF.height = fHeight; - rtBBoxF.top = FX_MAX(rtBBoxF.top, 0); + rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); } rtArray.SetAt(i, rtBBoxF); continue; diff --git a/xfa/src/fgas/src/localization/fx_locale.cpp b/xfa/src/fgas/src/localization/fx_locale.cpp index d9424c39fc..49629101c9 100644 --- a/xfa/src/fgas/src/localization/fx_locale.cpp +++ b/xfa/src/fgas/src/localization/fx_locale.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "core/include/fxcrt/fx_xml.h" #include "xfa/src/fgas/src/fgas_base.h" #include "fx_localeimp.h" @@ -4579,7 +4581,7 @@ static inline int8_t fxmath_decimal_helper_raw_compare_any(uint64_t a[], uint64_t b[], uint8_t bl) { int8_t retVal = 0; - for (int i = FX_MAX(al - 1, bl - 1); i >= 0; i--) { + for (int i = std::max(al - 1, bl - 1); i >= 0; i--) { uint64_t l = (i >= al ? 0 : a[i]), r = (i >= bl ? 0 : b[i]); retVal += (l > r ? 1 : (l < r ? -1 : 0)); if (retVal) { @@ -4680,13 +4682,13 @@ static inline void fxmath_decimal_helper_raw_div(uint64_t a[], fxmath_decimal_helper_dec_any(right, al); break; case 0: - for (i = 0; i < FX_MIN(al, cl); i++) { + for (i = 0; i < std::min(al, cl); i++) { c[i] = cur[i]; } return; } } - for (i = 0; i < FX_MIN(al, cl); i++) { + for (i = 0; i < std::min(al, cl); i++) { c[i] = left[i]; } } @@ -4956,8 +4958,8 @@ int8_t CFX_Decimal::Compare(const CFX_Decimal& val) const { int8_t retVal = 0; if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { - uint8_t scale = FX_MIN(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), - FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); + uint8_t scale = std::min(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), + FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); lhs.SetScale(scale); rhs.SetScale(scale); } @@ -4975,8 +4977,8 @@ CFX_Decimal CFX_Decimal::AddOrMinus(const CFX_Decimal& val, CFX_Decimal lhs = *this, rhs = val; if (FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags) != FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)) { - uint8_t scale = FX_MAX(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), - FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); + uint8_t scale = std::max(FXMATH_DECIMAL_FLAGS2SCALE(lhs.m_uFlags), + FXMATH_DECIMAL_FLAGS2SCALE(rhs.m_uFlags)); lhs.SetScale(scale); rhs.SetScale(scale); } diff --git a/xfa/src/fgas/src/xml/fx_sax_imp.cpp b/xfa/src/fgas/src/xml/fx_sax_imp.cpp index dce96470a6..6b3cc778ab 100644 --- a/xfa/src/fgas/src/xml/fx_sax_imp.cpp +++ b/xfa/src/fgas/src/xml/fx_sax_imp.cpp @@ -4,8 +4,17 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/fgas/src/fgas_base.h" #include "fx_sax_imp.h" + +namespace { + +const FX_DWORD kSaxFileBufSize = 32768; + +} // namespace + IFX_SAXReader* FX_SAXReader_Create() { return new CFX_SAXReader; } @@ -31,7 +40,7 @@ FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile, if (dwLen == 0) { return FALSE; } - m_dwBufSize = FX_MIN(dwLen, FX_SAXFILE_BUFSIZE); + m_dwBufSize = std::min(dwLen, kSaxFileBufSize); m_pBuf = FX_Alloc(uint8_t, m_dwBufSize); if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize)) { return FALSE; @@ -49,7 +58,7 @@ FX_BOOL CFX_SAXFile::ReadNextBlock() { if (dwSize == 0) { return FALSE; } - m_dwBufSize = FX_MIN(dwSize, FX_SAXFILE_BUFSIZE); + m_dwBufSize = std::min(dwSize, kSaxFileBufSize); if (!m_pFile->ReadBlock(m_pBuf, m_dwCur, m_dwBufSize)) { return FALSE; } diff --git a/xfa/src/fgas/src/xml/fx_sax_imp.h b/xfa/src/fgas/src/xml/fx_sax_imp.h index 7d04f14698..71be388efd 100644 --- a/xfa/src/fgas/src/xml/fx_sax_imp.h +++ b/xfa/src/fgas/src/xml/fx_sax_imp.h @@ -6,7 +6,7 @@ #ifndef _FX_SAX_IMP_ #define _FX_SAX_IMP_ -#define FX_SAXFILE_BUFSIZE 32768 + class CFX_SAXFile { public: CFX_SAXFile(); diff --git a/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp index 3df1f21391..3fa2119b02 100644 --- a/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fwl/src/core/include/fwl_targetimp.h" #include "xfa/src/fwl/src/core/include/fwl_noteimp.h" @@ -245,8 +247,8 @@ void CFWL_CheckBoxImp::Layout() { CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, m_iTTOAlign, rtFocus); if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) { - FX_FLOAT fWidth = FX_MAX(m_rtCaption.width, rtFocus.width); - FX_FLOAT fHeight = FX_MIN(m_rtCaption.height, rtFocus.height); + FX_FLOAT fWidth = std::max(m_rtCaption.width, rtFocus.width); + FX_FLOAT fHeight = std::min(m_rtCaption.height, rtFocus.height); FX_FLOAT fLeft = m_rtCaption.left; FX_FLOAT fTop = m_rtCaption.top; if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_HLayoutMask) == diff --git a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp index 9b652a79fc..06e185e5a2 100644 --- a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fwl/src/core/include/fwl_threadimp.h" #include "xfa/src/fwl/src/core/include/fwl_appimp.h" @@ -887,11 +889,11 @@ void CFWL_EditImp::On_TextChanged(IFDE_TxtEdtEngine* pEdit, fContentHeight1 = page1->GetContentsBox().height; } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption) { - rtTemp.width = FX_MAX(m_pProperties->m_rtWidget.width, fContentWidth1); + rtTemp.width = std::max(m_pProperties->m_rtWidget.width, fContentWidth1); m_pProperties->m_rtWidget.width = fContentWidth1; } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption) { - rtTemp.height = FX_MAX(m_pProperties->m_rtWidget.height, fContentHeight1); + rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); m_pProperties->m_rtWidget.height = fContentHeight1; } CFWL_EvtEdtTextChanged event; @@ -1062,8 +1064,8 @@ void CFWL_EditImp::DrawContent(CFX_Graphics* pGraphics, if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) { continue; } - int32_t nBgn = FX_MAX(nCharStart, nPageCharStart); - int32_t nEnd = FX_MIN(nCharEnd, nPageCharEnd); + int32_t nBgn = std::max(nCharStart, nPageCharStart); + int32_t nEnd = std::min(nCharEnd, nPageCharEnd); pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, rectArr); } @@ -1926,8 +1928,8 @@ void CFWL_EditImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { } FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; if (bShift && m_pOwner->m_nSelStart != nIndex) { - int32_t iStart = FX_MIN(m_pOwner->m_nSelStart, nIndex); - int32_t iEnd = FX_MAX(m_pOwner->m_nSelStart, nIndex); + int32_t iStart = std::min(m_pOwner->m_nSelStart, nIndex); + int32_t iEnd = std::max(m_pOwner->m_nSelStart, nIndex); m_pOwner->m_pEdtEngine->AddSelRange(iStart, iEnd - iStart); bRepaint = TRUE; } else { @@ -1985,7 +1987,7 @@ void CFWL_EditImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { m_pOwner->m_nSelStart = nLen; } m_pOwner->m_pEdtEngine->AddSelRange( - FX_MIN(m_pOwner->m_nSelStart, nIndex), + std::min(m_pOwner->m_nSelStart, nIndex), FXSYS_abs(nIndex - m_pOwner->m_nSelStart)); } } diff --git a/xfa/src/fwl/src/core/fwl_widgetimp.cpp b/xfa/src/fwl/src/core/fwl_widgetimp.cpp index 88db9b30e2..3872def983 100644 --- a/xfa/src/fwl/src/core/fwl_widgetimp.cpp +++ b/xfa/src/fwl/src/core/fwl_widgetimp.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fwl/src/core/include/fwl_targetimp.h" #include "xfa/src/fwl/src/core/include/fwl_noteimp.h" @@ -769,7 +771,7 @@ FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight, } else if (rtPopup.height < fMinHeight) { fPopHeight = fMinHeight; } - FX_FLOAT fWidth = FX_MAX(rtAnchor.width, rtPopup.width); + FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; TransformTo(NULL, fx, fy); if (fBottom + fy > fScreenHeight) { diff --git a/xfa/src/fwl/src/theme/widgettp.cpp b/xfa/src/fwl/src/theme/widgettp.cpp index 7eaf6e881b..e1351b5a21 100644 --- a/xfa/src/fwl/src/theme/widgettp.cpp +++ b/xfa/src/fwl/src/theme/widgettp.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" static void FWL_SetChildThemeID(IFWL_Widget* pParent, FX_DWORD dwThemeID) { IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); @@ -528,7 +530,7 @@ void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, CFX_Path path; path.Create(); FX_FLOAT fBtn = - FX_MIN(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; + std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; rtArrow.width = fBtn; diff --git a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp index d6d6614449..b270378a87 100644 --- a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp +++ b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp @@ -4,10 +4,14 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + +#include "third_party/base/numerics/safe_math.h" #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/BC_Writer.h" #include "xfa/src/fxbarcode/BC_TwoDimWriter.h" + CBC_TwoDimWriter::CBC_TwoDimWriter() { m_iCorrectLevel = 1; m_bFixedSize = TRUE; @@ -92,18 +96,18 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code, int32_t& e) { int32_t inputWidth = codeWidth; int32_t inputHeight = codeHeight; - int32_t tempWidth = inputWidth + (1 << 1); - int32_t tempHeight = inputHeight + (1 << 1); - FX_FLOAT moduleHSize = (FX_FLOAT)FX_MIN(m_ModuleWidth, m_ModuleHeight); - if (moduleHSize > 8) { - moduleHSize = 8; - } else if (moduleHSize < 1) { - moduleHSize = 1; - } - int32_t outputWidth = (int32_t)FX_MAX(tempWidth * moduleHSize, tempWidth); - int32_t outputHeight = (int32_t)FX_MAX(tempHeight * moduleHSize, tempHeight); - int32_t multiX = 1; - int32_t multiY = 1; + int32_t tempWidth = inputWidth + 2; + int32_t tempHeight = inputHeight + 2; + FX_FLOAT moduleHSize = std::min(m_ModuleWidth, m_ModuleHeight); + moduleHSize = std::min(moduleHSize, 8.0f); + moduleHSize = std::max(moduleHSize, 1.0f); + pdfium::base::CheckedNumeric scaledWidth = tempWidth; + pdfium::base::CheckedNumeric scaledHeight = tempHeight; + scaledWidth *= moduleHSize; + scaledHeight *= moduleHSize; + + int32_t outputWidth = scaledWidth.ValueOrDie(); + int32_t outputHeight = scaledHeight.ValueOrDie(); if (m_bFixedSize) { if (m_Width < outputWidth || m_Height < outputHeight) { e = BCExceptionBitmapSizeError; @@ -117,10 +121,10 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code, outputHeight * ceil((FX_FLOAT)m_Height / (FX_FLOAT)outputHeight)); } } - multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth); - multiY = (int32_t)ceil((FX_FLOAT)outputHeight / (FX_FLOAT)tempHeight); + int32_t multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth); + int32_t multiY = (int32_t)ceil((FX_FLOAT)outputHeight / (FX_FLOAT)tempHeight); if (m_bFixedSize) { - multiX = FX_MIN(multiX, multiY); + multiX = std::min(multiX, multiY); multiY = multiX; } int32_t leftPadding = (outputWidth - (inputWidth * multiX)) / 2; diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp index 967a1849d5..c36ff34a6d 100644 --- a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp +++ b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "BC_CommonByteArray.h" CBC_CommonByteArray::CBC_CommonByteArray() { @@ -61,7 +63,7 @@ FX_BOOL CBC_CommonByteArray::IsEmpty() { } void CBC_CommonByteArray::AppendByte(int32_t value) { if (m_size == 0 || m_index >= m_size) { - int32_t newSize = FX_MAX(32, m_size << 1); + int32_t newSize = std::max(32, m_size << 1); Reserve(newSize); } m_bytes[m_index] = (uint8_t)value; diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp index c930f0e45d..27c29afe77 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" @@ -166,7 +168,7 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { correctedTopRight.get(), dimensionTop, dimensionRight, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } else { - int32_t dimension = FX_MIN(dimensionRight, dimensionTop); + int32_t dimension = std::min(dimensionRight, dimensionTop); correctedTopRight = CBC_AutoPtr( CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); if (correctedTopRight.get() == NULL) { @@ -176,12 +178,12 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { topRight = NULL; } int32_t dimensionCorrected = - FX_MAX(CBC_AutoPtr( - TransitionsBetween(topLeft, correctedTopRight.get())) - ->GetTransitions(), - CBC_AutoPtr( - TransitionsBetween(bottomRight, correctedTopRight.get())) - ->GetTransitions()); + std::max(CBC_AutoPtr( + TransitionsBetween(topLeft, correctedTopRight.get())) + ->GetTransitions(), + CBC_AutoPtr( + TransitionsBetween(bottomRight, correctedTopRight.get())) + ->GetTransitions()); dimensionCorrected++; if ((dimensionCorrected & 0x01) == 1) { dimensionCorrected++; diff --git a/xfa/src/fxbarcode/oned/BC_OneDReader.cpp b/xfa/src/fxbarcode/oned/BC_OneDReader.cpp index 61448d21e7..b89f76423e 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDReader.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/BC_BinaryBitmap.h" @@ -48,7 +50,7 @@ CFX_ByteString CBC_OneDReader::DeDecode(CBC_BinaryBitmap* image, CBC_CommonBitArray* row = NULL; int32_t middle = height >> 1; FX_BOOL tryHarder = FALSE; - int32_t rowStep = FX_MAX(1, height >> (tryHarder ? 8 : 5)); + int32_t rowStep = std::max(1, height >> (tryHarder ? 8 : 5)); int32_t maxLines; if (tryHarder) { maxLines = height; diff --git a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp index 8f4b226e8c..159f27f826 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp @@ -22,6 +22,7 @@ #include "BC_OneDimWriter.h" +#include #include #include "xfa/src/fxbarcode/BC_Writer.h" @@ -391,7 +392,8 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, m_outputHScale = (FX_FLOAT)m_Width / (FX_FLOAT)codeLength; } if (!isDevice) { - m_outputHScale = FX_MAX(m_outputHScale, m_ModuleWidth); + m_outputHScale = + std::max(m_outputHScale, static_cast(m_ModuleWidth)); } FX_FLOAT dataLengthScale = 1.0; if (m_iDataLenth > 0 && contents.GetLength() != 0) { @@ -407,7 +409,7 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents, int32_t outputHeight = 1; if (!isDevice) { if (m_Height == 0) { - outputHeight = FX_MAX(20, m_ModuleHeight); + outputHeight = std::max(20, m_ModuleHeight); } else { outputHeight = m_Height; } diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp index a2177fd699..c75ddd48ee 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" @@ -140,7 +142,7 @@ CFX_Int32Array* CBC_OnedCodaBarReader::FindAsteriskPattern( if (counterPosition == patternLength - 1) { if (ArrayContains(STARTEND_ENCODING, ToNarrowWidePattern(&counters))) { FX_BOOL btemp3 = - row->IsRange(FX_MAX(0, patternStart - (i - patternStart) / 2), + row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), patternStart, FALSE, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); if (btemp3) { diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp index 601baa2a4c..cbc7a5a859 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCode128Reader.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" @@ -115,7 +117,7 @@ CFX_Int32Array* CBC_OnedCode128Reader::FindStartPattern(CBC_CommonBitArray* row, } if (bestMatch >= 0) { FX_BOOL btemp2 = - row->IsRange(FX_MAX(0, patternStart - (i - patternStart) / 2), + row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), patternStart, FALSE, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); if (btemp2) { @@ -338,8 +340,8 @@ CFX_ByteString CBC_OnedCode128Reader::DecodeRow(int32_t rowNumber, nextStart++; } FX_BOOL boolT1 = row->IsRange( - nextStart, FX_MIN(width, nextStart + (nextStart - lastStart) / 2), FALSE, - e); + nextStart, std::min(width, nextStart + (nextStart - lastStart) / 2), + FALSE, e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); if (!boolT1) { e = BCExceptionNotFound; diff --git a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp index a5b77ed13f..18d1e96494 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCode39Reader.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" @@ -144,7 +146,7 @@ CFX_Int32Array* CBC_OnedCode39Reader::FindAsteriskPattern( if (counterPosition == patternLength - 1) { if (ToNarrowWidePattern(&counters) == ASTERISK_ENCODING) { FX_BOOL bT1 = - row->IsRange(FX_MAX(0, patternStart - (i - patternStart) / 2), + row->IsRange(std::max(0, patternStart - (i - patternStart) / 2), patternStart, FALSE, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); if (bT1) { diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index 2610db95dc..2e16c036ca 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" #include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" @@ -876,8 +878,8 @@ void CBC_QRCoderEncoder::InterleaveWithECBytes(CBC_QRCoderBitVector* bits, GenerateECBytes(dataBytes, numEcBytesInBlosk, e); BC_EXCEPTION_CHECK_ReturnVoid(e); blocks.Add(new CBC_QRCoderBlockPair(dataBytes, ecBytes)); - maxNumDataBytes = FX_MAX(maxNumDataBytes, dataBytes->Size()); - maxNumEcBytes = FX_MAX(maxNumEcBytes, ecBytes->Size()); + maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size()); + maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size()); dataBytesOffset += numDataBytesInBlock; } if (numDataBytes != dataBytesOffset) { diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp index 1b799114b4..2280e9a4b8 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp @@ -20,6 +20,8 @@ * limitations under the License. */ +#include + #include "xfa/src/fxbarcode/barcode.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/BC_ResultPoint.h" @@ -255,16 +257,16 @@ CBC_QRAlignmentPattern* CBC_QRDetector::FindAlignmentInRegion( FX_FLOAT allowanceFactor, int32_t& e) { int32_t allowance = (int32_t)(allowanceFactor * overallEstModuleSize); - int32_t alignmentAreaLeftX = FX_MAX(0, estAlignmentX - allowance); + int32_t alignmentAreaLeftX = std::max(0, estAlignmentX - allowance); int32_t alignmentAreaRightX = - FX_MIN(m_image->GetWidth() - 1, estAlignmentX + allowance); + std::min(m_image->GetWidth() - 1, estAlignmentX + allowance); if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) { e = BCExceptionRead; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - int32_t alignmentAreaTopY = FX_MAX(0, estAlignmentY - allowance); + int32_t alignmentAreaTopY = std::max(0, estAlignmentY - allowance); int32_t alignmentAreaBottomY = - FX_MIN(m_image->GetHeight() - 1, estAlignmentY + allowance); + std::min(m_image->GetHeight() - 1, estAlignmentY + allowance); CBC_QRAlignmentPatternFinder alignmentFinder( m_image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, diff --git a/xfa/src/fxfa/src/app/xfa_ffapp.cpp b/xfa/src/fxfa/src/app/xfa_ffapp.cpp index 0ce79e05db..fb37fb7ba3 100644 --- a/xfa/src/fxfa/src/app/xfa_ffapp.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffapp.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fxfa/src/common/xfa_common.h" #include "xfa_ffdochandler.h" @@ -47,7 +49,7 @@ FX_BOOL CXFA_FileRead::ReadBlock(void* buffer, while (index < iCount) { CPDF_StreamAcc& acc = m_Data[index]; FX_DWORD dwSize = acc.GetSize(); - FX_DWORD dwRead = FX_MIN(size, dwSize - offset); + size_t dwRead = std::min(size, static_cast(dwSize - offset)); FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead); size -= dwRead; if (size == 0) { diff --git a/xfa/src/fxfa/src/app/xfa_ffwidget.cpp b/xfa/src/fxfa/src/app/xfa_ffwidget.cpp index 58047302e0..08194bade1 100644 --- a/xfa/src/fxfa/src/app/xfa_ffwidget.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffwidget.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fxfa/src/common/xfa_common.h" #include "xfa_ffapp.h" @@ -776,7 +778,7 @@ void XFA_DrawImage(CFX_Graphics* pGS, case XFA_ATTRIBUTEENUM_Fit: { FX_FLOAT f1 = rtImage.height / rtFit.height; FX_FLOAT f2 = rtImage.width / rtFit.width; - f1 = FX_MIN(f1, f2); + f1 = std::min(f1, f2); rtFit.height = rtFit.height * f1; rtFit.width = rtFit.width * f1; } break; @@ -1116,7 +1118,7 @@ static void XFA_BOX_GetPath_Arc(CXFA_Box box, a = rtDraw.width / 2.0f; b = rtDraw.height / 2.0f; if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { - a = b = FX_MIN(a, b); + a = b = std::min(a, b); } CFX_PointF center = rtDraw.Center(); rtDraw.left = center.x - a; @@ -1655,7 +1657,7 @@ static void XFA_BOX_StrokeArc(CXFA_Box box, a = rtWidget.width / 2.0f; b = rtWidget.height / 2.0f; if (dwFlags & XFA_DRAWBOX_ForceRound) { - a = b = FX_MIN(a, b); + a = b = std::min(a, b); } CFX_PointF center = rtWidget.Center(); rtWidget.left = center.x - a; diff --git a/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp b/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp index 92b6fe920c..717408d7a3 100644 --- a/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fxfa/src/common/xfa_common.h" #include "xfa_ffwidget.h" @@ -825,12 +827,12 @@ FX_BOOL CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { case XFA_ATTRIBUTEENUM_Right: case XFA_ATTRIBUTEENUM_Inline: { size.x += szCap.x; - size.y = FX_MAX(size.y, szCap.y); + size.y = std::max(size.y, szCap.y); } break; case XFA_ATTRIBUTEENUM_Top: case XFA_ATTRIBUTEENUM_Bottom: { size.y += szCap.y; - size.x = FX_MAX(size.x, szCap.x); + size.x = std::max(size.x, szCap.x); } default: break; @@ -859,10 +861,10 @@ FX_BOOL CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { size.x = fVal; } else { if (this->GetMinWidth(fMin)) { - size.x = FX_MAX(size.x, fMin); + size.x = std::max(size.x, fMin); } if (this->GetMaxWidth(fMax) && fMax > 0) { - size.x = FX_MIN(size.x, fMax); + size.x = std::min(size.x, fMax); } } fVal = 0, fMin = 0, fMax = 0; @@ -870,10 +872,10 @@ FX_BOOL CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { size.y = fVal; } else { if (this->GetMinHeight(fMin)) { - size.y = FX_MAX(size.y, fMin); + size.y = std::max(size.y, fMin); } if (this->GetMaxHeight(fMax) && fMax > 0) { - size.y = FX_MIN(size.y, fMax); + size.y = std::min(size.y, fMax); } } return TRUE; @@ -944,7 +946,7 @@ FX_BOOL CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { case XFA_ATTRIBUTEENUM_Left: case XFA_ATTRIBUTEENUM_Right: case XFA_ATTRIBUTEENUM_Inline: { - size.y = FX_MAX(size.y, szCap.y); + size.y = std::max(size.y, szCap.y); } break; case XFA_ATTRIBUTEENUM_Top: case XFA_ATTRIBUTEENUM_Bottom: { @@ -1071,10 +1073,10 @@ FX_FLOAT CXFA_WidgetAcc::CalculateWidgetAutoWidth(FX_FLOAT fWidthCalc) { } FX_FLOAT fMin = 0, fMax = 0; if (this->GetMinWidth(fMin)) { - fWidthCalc = FX_MAX(fWidthCalc, fMin); + fWidthCalc = std::max(fWidthCalc, fMin); } if (this->GetMaxWidth(fMax) && fMax > 0) { - fWidthCalc = FX_MIN(fWidthCalc, fMax); + fWidthCalc = std::min(fWidthCalc, fMax); } return fWidthCalc; } @@ -1098,10 +1100,10 @@ FX_FLOAT CXFA_WidgetAcc::CalculateWidgetAutoHeight(FX_FLOAT fHeightCalc) { } FX_FLOAT fMin = 0, fMax = 0; if (this->GetMinHeight(fMin)) { - fHeightCalc = FX_MAX(fHeightCalc, fMin); + fHeightCalc = std::max(fHeightCalc, fMin); } if (this->GetMaxHeight(fMax) && fMax > 0) { - fHeightCalc = FX_MIN(fHeightCalc, fMax); + fHeightCalc = std::min(fHeightCalc, fMax); } return fHeightCalc; } diff --git a/xfa/src/fxfa/src/app/xfa_fontmgr.cpp b/xfa/src/fxfa/src/app/xfa_fontmgr.cpp index 5be4c8b426..ad5120e493 100644 --- a/xfa/src/fxfa/src/app/xfa_fontmgr.cpp +++ b/xfa/src/fxfa/src/app/xfa_fontmgr.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fxfa/src/common/xfa_common.h" #include "xfa_fontmgr.h" @@ -1983,7 +1985,7 @@ FX_BOOL CXFA_PDFFontMgr::PsNameMatchDRFontName( } if (bBoldFont) { iDifferLength = - FX_MIN(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4); + std::min(iDifferLength - 4, bsDRName.GetLength() - iBoldIndex - 4); } FX_BOOL bItalicFont = TRUE; if (bsDRName.Find("Italic") > 0) { diff --git a/xfa/src/fxfa/src/app/xfa_textlayout.cpp b/xfa/src/fxfa/src/app/xfa_textlayout.cpp index 45eac17884..83fd9ddda5 100644 --- a/xfa/src/fxfa/src/app/xfa_textlayout.cpp +++ b/xfa/src/fxfa/src/app/xfa_textlayout.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fxfa/src/common/xfa_common.h" #include "xfa_textlayout.h" @@ -511,7 +513,7 @@ FX_FLOAT CXFA_TextParser::GetLineHeight(IXFA_TextProvider* pTextProvider, if (fLineHeight < 0.1f) { fLineHeight = fFontSize; } else { - fLineHeight = FX_MIN(fLineHeight, fFontSize); + fLineHeight = std::min(fLineHeight, fFontSize); } } else if (fLineHeight < 0.1f) { fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; @@ -1704,7 +1706,7 @@ void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, } } m_pTabstopContext->m_fLeft = - FX_MIN(fLeft, m_pTabstopContext->m_fTabWidth); + std::min(fLeft, m_pTabstopContext->m_fTabWidth); m_pTabstopContext->m_bTabstops = FALSE; m_pTabstopContext->m_fTabWidth = 0; } @@ -1772,7 +1774,7 @@ void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, } else if (fBaseLine < -fBaseLineTemp) { fBaseLine = -fBaseLineTemp; } - fLineStep = FX_MAX(fLineStep, fLineHeight); + fLineStep = std::max(fLineStep, fLineHeight); if (pUserData != NULL && pUserData->m_pLinkData != NULL) { pUserData->m_pLinkData->AddRef(); pTP->pLinkData = pUserData->m_pLinkData; @@ -1786,7 +1788,7 @@ void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, FX_FLOAT& fTop = pTP->rtPiece.top; FX_FLOAT fBaseLineTemp = fTop; fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; - fTop = FX_MAX(0, fTop); + fTop = std::max(0.0f, fTop); } fLinePos += fLineStep + fBaseLine; } else { @@ -1809,11 +1811,11 @@ void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, fLineHeight = fLineHeightTmp; } } - fLineStep = FX_MAX(fLineStep, fLineHeight); + fLineStep = std::max(fLineStep, fLineHeight); fLineWidth += pPiece->m_iWidth / 20000.0f; } fLinePos += fLineStep; - m_fMaxWidth = FX_MAX(m_fMaxWidth, fLineWidth); + m_fMaxWidth = std::max(m_fMaxWidth, fLineWidth); if (m_pLoader && m_pLoader->m_bSaveLineHeight) { FX_FLOAT fHeight = fLinePos - m_pLoader->m_fLastPos; m_pLoader->m_fLastPos = fLinePos; diff --git a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp index 7d12a289e8..3b991065ad 100644 --- a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp +++ b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp @@ -4,6 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include + #include "xfa/src/foxitlib.h" #include "xfa/src/fxfa/src/common/xfa_utils.h" #include "xfa/src/fxfa/src/common/xfa_object.h" @@ -1277,8 +1279,8 @@ static inline void XFA_ItemLayoutProcessor_RelocateTableRowCells( fColSpanWidth += rgSpecifiedColumnWidths[nCurrentColIdx + i]; } if (nColSpan != nOriginalColSpan) { - fColSpanWidth = - bMetWholeRowCell ? 0 : FX_MAX(fColSpanWidth, pLayoutChild->m_sSize.y); + fColSpanWidth = bMetWholeRowCell ? 0 : std::max(fColSpanWidth, + pLayoutChild->m_sSize.y); } if (nOriginalColSpan == -1) { bMetWholeRowCell = TRUE; -- cgit v1.2.3