Index: core/src/fpdfdoc/doc_vt.cpp |
diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp |
index 8df687ed5937c52fe3b6d996ea625f69024cd5b7..e5c9ad8ebacd56c1d707e5a343000f88911c3d7b 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(); |
} |