summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/include/fxcrt/fx_basic.h4
-rw-r--r--core/include/fxcrt/fx_system.h1
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp60
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp5
-rw-r--r--core/src/fpdfdoc/doc_formcontrol.cpp8
-rw-r--r--core/src/fpdfdoc/doc_utils.cpp8
-rw-r--r--core/src/fpdfdoc/doc_vt.cpp44
-rw-r--r--core/src/fpdfdoc/pdf_vt.h33
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp36
-rw-r--r--core/src/fxcrt/extension.h61
-rw-r--r--core/src/fxcrt/fx_basic_buffer.cpp4
-rw-r--r--core/src/fxcrt/fx_basic_wstring.cpp8
-rw-r--r--core/src/fxcrt/fx_extension.cpp53
-rw-r--r--core/src/fxcrt/xml_int.h9
-rw-r--r--core/src/fxge/agg/src/fx_agg_driver.cpp34
-rw-r--r--core/src/fxge/android/fpf_skiafont.cpp7
-rw-r--r--fpdfsdk/include/fxedit/fxet_edit.h35
-rw-r--r--fpdfsdk/src/fpdf_flatten.cpp6
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp8
-rw-r--r--fpdfsdk/src/fxedit/fxet_edit.cpp7
-rw-r--r--fpdfsdk/src/javascript/PublicMethods.cpp6
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Utils.cpp15
22 files changed, 248 insertions, 204 deletions
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index fd35de906d..4a3b0ceb2f 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 <algorithm>
+
#include "fx_memory.h"
#include "fx_stream.h"
#include "fx_string.h"
@@ -991,7 +993,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 c9eee8e380..be22344cd9 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 <limits.h>
+#include <algorithm>
+
#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 <algorithm>
#include <memory>
#include <vector>
@@ -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 93e837feaf..29d3211f30 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 <algorithm>
+
#include "core/include/fpdfdoc/fpdf_doc.h"
CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
@@ -358,9 +360,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 01a7470ef0..0f54198c6f 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 <algorithm>
+
#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 <algorithm>
+
#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 <class T>
-T FPDF_MIN(const T& i, const T& j) {
- return ((i < j) ? i : j);
-}
-template <class T>
-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/fxcrt/extension.h b/core/src/fxcrt/extension.h
index 58b0457a7c..fbf040d40d 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 <algorithm>
+
#include "core/include/fxcrt/fx_basic.h"
#include "core/include/fxcrt/fx_safe_types.h"
@@ -33,39 +35,21 @@ IFXCRT_FileAccess* FXCRT_FileAccess_Create();
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;
@@ -77,7 +61,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),
@@ -156,7 +140,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;
}
@@ -228,12 +212,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<size_t>(4096)));
m_Blocks.Add(pBlock);
}
- m_nGrowSize = FX_MAX(nGrowSize, 4096);
+ m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(4096));
} else if (m_Blocks.GetSize() < 1) {
- m_nGrowSize = FX_MAX(nGrowSize, 4096);
+ m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(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 548581c9cb..2a2efd96e8 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 <algorithm>
+
#include "core/include/fxcrt/fx_basic.h"
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
@@ -273,7 +275,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 <stddef.h> // For offsetof().
+
+#include <algorithm>
#include <cctype>
#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 aa06fe5df9..54815465fc 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -14,6 +14,59 @@
#include <ctime>
#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();
+}
+
IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) {
IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
if (!pFA) {
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 <algorithm>
+
#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<size_t>(
+ 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 <algorithm>
+
#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 BaseRenderer>
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 <algorithm>
+
#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 <class T>
-T FX_EDIT_MIN(const T& i, const T& j) {
- return ((i < j) ? i : j);
-}
-template <class T>
-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 76ffec3e26..5c30b662c4 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -6,6 +6,8 @@
#include "public/fpdf_flatten.h"
+#include <algorithm>
+
#include "fpdfsdk/include/fsdk_define.h"
typedef CFX_ArrayTemplate<CPDF_Dictionary*> 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 ef7ab0c03a..9540c5766d 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 <algorithm>
+
#include "core/include/fxcrt/fx_ext.h"
#include "fpdfsdk/include/fsdk_baseannot.h"
#include "fpdfsdk/include/fsdk_define.h"
@@ -815,9 +817,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 <algorithm>
+
#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 <algorithm>
+
#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 <algorithm>
+
+#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,