summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-10-05 13:43:25 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-05 13:43:25 -0700
commite883afcab15b17769bda0a1aac0f540568df3368 (patch)
tree6b86eded90bc816a985a9de87f7429e0f19ff38e
parentb69a98cf50537130f88ce3a799117f2ca8353ac5 (diff)
downloadpdfium-e883afcab15b17769bda0a1aac0f540568df3368.tar.xz
Removed unused stuff, some FX_BOOL, and cleanup pageint.h a bit
- Remove some unused stuff from pageint.h. - Replace some FX_BOOL with bool in pageint.h, and related. - Replace some "protected" with "private" in pageint.h. - Move 2 methods into namespace in fpdf_page_parser_old.cpp. Review-Url: https://codereview.chromium.org/2399573002
-rw-r--r--core/fpdfapi/page/cpdf_color.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.h6
-rw-r--r--core/fpdfapi/page/cpdf_textstate.cpp3
-rw-r--r--core/fpdfapi/page/fpdf_page_doc.cpp21
-rw-r--r--core/fpdfapi/page/fpdf_page_parser.cpp71
-rw-r--r--core/fpdfapi/page/fpdf_page_parser_old.cpp88
-rw-r--r--core/fpdfapi/page/pageint.h54
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp4
-rw-r--r--core/fpdfapi/parser/cpdf_document.h2
-rw-r--r--core/fpdfapi/render/fpdf_render_text.cpp2
11 files changed, 114 insertions, 141 deletions
diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp
index 2ba843ca69..d06d445adf 100644
--- a/core/fpdfapi/page/cpdf_color.cpp
+++ b/core/fpdfapi/page/cpdf_color.cpp
@@ -127,7 +127,7 @@ void CPDF_Color::Copy(const CPDF_Color* pSrc) {
CPDF_Pattern* pPattern = pValue->m_pPattern;
if (pPattern && pPattern->document()) {
pValue->m_pPattern = pPattern->document()->GetPageData()->GetPattern(
- pPattern->pattern_obj(), FALSE, pPattern->parent_matrix());
+ pPattern->pattern_obj(), false, pPattern->parent_matrix());
}
}
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp
index eb8dc975c2..e1472c95a7 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp
@@ -25,7 +25,7 @@ ShadingType ToShadingType(int type) {
CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
- FX_BOOL bShading,
+ bool bShading,
const CFX_Matrix& parentMatrix)
: CPDF_Pattern(SHADING,
pDoc,
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h
index 6f5978f8a5..136153d4a0 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.h
+++ b/core/fpdfapi/page/cpdf_shadingpattern.h
@@ -36,7 +36,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
public:
CPDF_ShadingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
- FX_BOOL bShading,
+ bool bShading,
const CFX_Matrix& parentMatrix);
~CPDF_ShadingPattern() override;
@@ -52,7 +52,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
bool Load();
ShadingType GetShadingType() const { return m_ShadingType; }
- FX_BOOL IsShadingObject() const { return m_bShadingObj; }
+ bool IsShadingObject() const { return m_bShadingObj; }
CPDF_Object* GetShadingObject() const { return m_pShadingObj; }
CPDF_ColorSpace* GetCS() const { return m_pCS; }
const std::vector<std::unique_ptr<CPDF_Function>>& GetFuncs() const {
@@ -61,7 +61,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
private:
ShadingType m_ShadingType;
- FX_BOOL m_bShadingObj;
+ bool m_bShadingObj;
CPDF_Object* m_pShadingObj;
// Still keep |m_pCS| as some CPDF_ColorSpace (name object) are not managed
diff --git a/core/fpdfapi/page/cpdf_textstate.cpp b/core/fpdfapi/page/cpdf_textstate.cpp
index 85ca9e21ec..6fc8ed29cc 100644
--- a/core/fpdfapi/page/cpdf_textstate.cpp
+++ b/core/fpdfapi/page/cpdf_textstate.cpp
@@ -116,8 +116,7 @@ CPDF_TextState::TextData::TextData(const TextData& that)
m_CTM[i] = that.m_CTM[i];
if (m_pDocument && m_pFont) {
- m_pFont =
- m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict(), FALSE);
+ m_pFont = m_pDocument->GetPageData()->GetFont(m_pFont->GetFontDict());
}
}
diff --git a/core/fpdfapi/page/fpdf_page_doc.cpp b/core/fpdfapi/page/fpdf_page_doc.cpp
index 798983fadc..6fa64cfa8e 100644
--- a/core/fpdfapi/page/fpdf_page_doc.cpp
+++ b/core/fpdfapi/page/fpdf_page_doc.cpp
@@ -29,11 +29,11 @@ void CPDF_ModuleMgr::InitPageModule() {
}
CPDF_DocPageData::CPDF_DocPageData(CPDF_Document* pPDFDoc)
- : m_pPDFDoc(pPDFDoc), m_bForceClear(FALSE) {}
+ : m_pPDFDoc(pPDFDoc), m_bForceClear(false) {}
CPDF_DocPageData::~CPDF_DocPageData() {
- Clear(FALSE);
- Clear(TRUE);
+ Clear(false);
+ Clear(true);
for (auto& it : m_PatternMap)
delete it.second;
@@ -48,7 +48,7 @@ CPDF_DocPageData::~CPDF_DocPageData() {
m_ColorSpaceMap.clear();
}
-void CPDF_DocPageData::Clear(FX_BOOL bForceRelease) {
+void CPDF_DocPageData::Clear(bool bForceRelease) {
m_bForceClear = bForceRelease;
for (auto& it : m_PatternMap) {
@@ -128,8 +128,7 @@ void CPDF_DocPageData::Clear(FX_BOOL bForceRelease) {
}
}
-CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict,
- FX_BOOL findOnly) {
+CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict) {
if (!pFontDict)
return nullptr;
@@ -141,10 +140,6 @@ CPDF_Font* CPDF_DocPageData::GetFont(CPDF_Dictionary* pFontDict,
return pFontData->AddRef();
}
}
-
- if (findOnly)
- return nullptr;
-
std::unique_ptr<CPDF_Font> pFont = CPDF_Font::Create(m_pPDFDoc, pFontDict);
if (!pFont)
return nullptr;
@@ -342,7 +337,7 @@ void CPDF_DocPageData::ReleaseColorSpace(const CPDF_Object* pColorSpace) {
}
CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj,
- FX_BOOL bShading,
+ bool bShading,
const CFX_Matrix& matrix) {
if (!pPatternObj)
return nullptr;
@@ -357,7 +352,7 @@ CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj,
}
CPDF_Pattern* pPattern = nullptr;
if (bShading) {
- pPattern = new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, TRUE, matrix);
+ pPattern = new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, true, matrix);
} else {
CPDF_Dictionary* pDict = pPatternObj ? pPatternObj->GetDict() : nullptr;
if (pDict) {
@@ -366,7 +361,7 @@ CPDF_Pattern* CPDF_DocPageData::GetPattern(CPDF_Object* pPatternObj,
pPattern = new CPDF_TilingPattern(m_pPDFDoc, pPatternObj, matrix);
} else if (type == CPDF_Pattern::SHADING) {
pPattern =
- new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, FALSE, matrix);
+ new CPDF_ShadingPattern(m_pPDFDoc, pPatternObj, false, matrix);
}
}
}
diff --git a/core/fpdfapi/page/fpdf_page_parser.cpp b/core/fpdfapi/page/fpdf_page_parser.cpp
index 23d087304f..124bf71189 100644
--- a/core/fpdfapi/page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/page/fpdf_page_parser.cpp
@@ -178,20 +178,6 @@ CFX_ByteStringC PDF_FindValueAbbreviationForTesting(
FX_ArraySize(PDF_InlineValueAbbr), abbr);
}
-bool IsPathOperator(const uint8_t* buf, size_t len) {
- if (len == 1) {
- uint8_t op = buf[0];
- return op == kPathOperatorSubpath || op == kPathOperatorLine ||
- op == kPathOperatorCubicBezier1 || op == kPathOperatorCubicBezier2 ||
- op == kPathOperatorCubicBezier3;
- }
- if (len == 2) {
- return buf[0] == kPathOperatorRectangle[0] &&
- buf[1] == kPathOperatorRectangle[1];
- }
- return false;
-}
-
CPDF_StreamContentParser::CPDF_StreamContentParser(
CPDF_Document* pDocument,
CPDF_Dictionary* pPageResources,
@@ -222,9 +208,8 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
m_pLastImage(nullptr),
m_pLastImageDict(nullptr),
m_pLastCloneImageDict(nullptr),
- m_bReleaseLastDict(TRUE),
m_bColored(false),
- m_bResourceMissing(FALSE) {
+ m_bResourceMissing(false) {
if (pmtContentToUser)
m_mtContentToUser = *pmtContentToUser;
if (!m_pResources)
@@ -396,9 +381,9 @@ FX_FLOAT CPDF_StreamContentParser::GetNumber(uint32_t index) {
}
void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj,
- FX_BOOL bColor,
- FX_BOOL bText,
- FX_BOOL bGraph) {
+ bool bColor,
+ bool bText,
+ bool bGraph) {
pObj->m_GeneralState = m_pCurStates->m_GeneralState;
pObj->m_ClipPath = m_pCurStates->m_ClipPath;
pObj->m_ContentMark = m_CurContentMark;
@@ -555,20 +540,20 @@ void CPDF_StreamContentParser::OnOperator(const FX_CHAR* op) {
void CPDF_StreamContentParser::Handle_CloseFillStrokePath() {
Handle_ClosePath();
- AddPathObject(FXFILL_WINDING, TRUE);
+ AddPathObject(FXFILL_WINDING, true);
}
void CPDF_StreamContentParser::Handle_FillStrokePath() {
- AddPathObject(FXFILL_WINDING, TRUE);
+ AddPathObject(FXFILL_WINDING, true);
}
void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() {
AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE);
- AddPathObject(FXFILL_ALTERNATE, TRUE);
+ AddPathObject(FXFILL_ALTERNATE, true);
}
void CPDF_StreamContentParser::Handle_EOFillStrokePath() {
- AddPathObject(FXFILL_ALTERNATE, TRUE);
+ AddPathObject(FXFILL_ALTERNATE, true);
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
@@ -577,12 +562,12 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
if (!pProperty) {
return;
}
- FX_BOOL bDirect = TRUE;
+ bool bDirect = true;
if (pProperty->IsName()) {
pProperty = FindResourceObj("Properties", pProperty->GetString());
if (!pProperty)
return;
- bDirect = FALSE;
+ bDirect = false;
}
if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
m_CurContentMark.AddMark(tag, pDict, bDirect);
@@ -734,7 +719,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name));
if (!pXObject) {
- m_bResourceMissing = TRUE;
+ m_bResourceMissing = true;
return;
}
@@ -770,7 +755,7 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
m_pObjectHolder->SetBackgroundAlphaNeeded(TRUE);
}
pFormObj->CalcBoundingBox();
- SetGraphicStates(pFormObj.get(), TRUE, TRUE, TRUE);
+ SetGraphicStates(pFormObj.get(), true, true, true);
m_pObjectHolder->GetPageObjectList()->push_back(std::move(pFormObj));
}
@@ -793,8 +778,8 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream,
pImageObj->SetOwnedImage(
pdfium::MakeUnique<CPDF_Image>(m_pDocument, pStream, bInline));
}
- SetGraphicStates(pImageObj.get(), pImageObj->GetImage()->IsMask(), FALSE,
- FALSE);
+ SetGraphicStates(pImageObj.get(), pImageObj->GetImage()->IsMask(), false,
+ false);
pImageObj->m_Matrix = ImageMatrix;
pImageObj->CalcBoundingBox();
CPDF_ImageObject* pRet = pImageObj.get();
@@ -822,15 +807,15 @@ void CPDF_StreamContentParser::Handle_EndText() {
}
void CPDF_StreamContentParser::Handle_FillPath() {
- AddPathObject(FXFILL_WINDING, FALSE);
+ AddPathObject(FXFILL_WINDING, false);
}
void CPDF_StreamContentParser::Handle_FillPathOld() {
- AddPathObject(FXFILL_WINDING, FALSE);
+ AddPathObject(FXFILL_WINDING, false);
}
void CPDF_StreamContentParser::Handle_EOFillPath() {
- AddPathObject(FXFILL_ALTERNATE, FALSE);
+ AddPathObject(FXFILL_ALTERNATE, false);
}
void CPDF_StreamContentParser::Handle_SetGray_Fill() {
@@ -849,7 +834,7 @@ void CPDF_StreamContentParser::Handle_SetExtendGraphState() {
CFX_ByteString name = GetString(0);
CPDF_Dictionary* pGS = ToDictionary(FindResourceObj("ExtGState", name));
if (!pGS) {
- m_bResourceMissing = TRUE;
+ m_bResourceMissing = true;
return;
}
m_pCurStates->ProcessExtGS(pGS, this);
@@ -928,7 +913,7 @@ void CPDF_StreamContentParser::Handle_SetMiterLimit() {
void CPDF_StreamContentParser::Handle_MarkPlace() {}
void CPDF_StreamContentParser::Handle_EndPath() {
- AddPathObject(0, FALSE);
+ AddPathObject(0, false);
}
void CPDF_StreamContentParser::Handle_SaveGraphState() {
@@ -990,11 +975,11 @@ void CPDF_StreamContentParser::Handle_SetRenderIntent() {}
void CPDF_StreamContentParser::Handle_CloseStrokePath() {
Handle_ClosePath();
- AddPathObject(0, TRUE);
+ AddPathObject(0, true);
}
void CPDF_StreamContentParser::Handle_StrokePath() {
- AddPathObject(0, TRUE);
+ AddPathObject(0, true);
}
void CPDF_StreamContentParser::Handle_SetColor_Fill() {
@@ -1090,7 +1075,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
std::unique_ptr<CPDF_ShadingObject> pObj(new CPDF_ShadingObject);
pObj->m_pShading = pShading;
- SetGraphicStates(pObj.get(), FALSE, FALSE, FALSE);
+ SetGraphicStates(pObj.get(), false, false, false);
pObj->m_Matrix = m_pCurStates->m_CTM;
pObj->m_Matrix.Concat(m_mtContentToUser);
CFX_FloatRect bbox =
@@ -1150,7 +1135,7 @@ CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
if (!pFontDict) {
- m_bResourceMissing = TRUE;
+ m_bResourceMissing = true;
return CPDF_Font::GetStockFont(m_pDocument, "Helvetica");
}
@@ -1184,7 +1169,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
}
CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name);
if (!pCSObj) {
- m_bResourceMissing = TRUE;
+ m_bResourceMissing = true;
return nullptr;
}
return m_pDocument->LoadColorSpace(pCSObj);
@@ -1195,7 +1180,7 @@ CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name,
CPDF_Object* pPattern =
FindResourceObj(bShading ? "Shading" : "Pattern", name);
if (!pPattern || (!pPattern->IsDictionary() && !pPattern->IsStream())) {
- m_bResourceMissing = TRUE;
+ m_bResourceMissing = true;
return nullptr;
}
return m_pDocument->LoadPattern(pPattern, bShading,
@@ -1238,7 +1223,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
{
std::unique_ptr<CPDF_TextObject> pText(new CPDF_TextObject);
m_pLastTextObject = pText.get();
- SetGraphicStates(m_pLastTextObject, TRUE, TRUE, TRUE);
+ SetGraphicStates(m_pLastTextObject, true, true, true);
if (TextRenderingModeIsStrokeMode(text_mode)) {
FX_FLOAT* pCTM = pText->m_TextState.GetMutableCTM();
pCTM[0] = m_pCurStates->m_CTM.a;
@@ -1453,7 +1438,7 @@ void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag) {
m_pPathPoints[m_PathPointCount - 1].m_PointY = y;
}
-void CPDF_StreamContentParser::AddPathObject(int FillType, FX_BOOL bStroke) {
+void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) {
int PathPointCount = m_PathPointCount;
uint8_t PathClipType = m_PathClipType;
m_PathPointCount = 0;
@@ -1482,7 +1467,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, FX_BOOL bStroke) {
pPathObj->m_FillType = FillType;
pPathObj->m_Path = Path;
pPathObj->m_Matrix = matrix;
- SetGraphicStates(pPathObj.get(), TRUE, FALSE, TRUE);
+ SetGraphicStates(pPathObj.get(), true, false, true);
pPathObj->CalcBoundingBox();
m_pObjectHolder->GetPageObjectList()->push_back(std::move(pPathObj));
}
diff --git a/core/fpdfapi/page/fpdf_page_parser_old.cpp b/core/fpdfapi/page/fpdf_page_parser_old.cpp
index 7dc8d3e1d6..f073b51b27 100644
--- a/core/fpdfapi/page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/page/fpdf_page_parser_old.cpp
@@ -33,37 +33,19 @@
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_renderdevice.h"
+CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
+ const uint8_t* src_buf,
+ uint32_t src_size,
+ int width,
+ int height,
+ const CPDF_Dictionary* pParams);
+
namespace {
const uint32_t kMaxNestedArrayLevel = 512;
const uint32_t kMaxWordBuffer = 256;
const FX_STRSIZE kMaxStringLength = 32767;
-} // namespace
-
-CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize)
- : m_pBuf(pData),
- m_Size(dwSize),
- m_Pos(0),
- m_pLastObj(nullptr),
- m_pPool(nullptr) {}
-
-CPDF_StreamParser::CPDF_StreamParser(
- const uint8_t* pData,
- uint32_t dwSize,
- const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
- : m_pBuf(pData),
- m_Size(dwSize),
- m_Pos(0),
- m_pLastObj(nullptr),
- m_pPool(pPool) {}
-
-CPDF_StreamParser::~CPDF_StreamParser() {
- if (m_pLastObj) {
- m_pLastObj->Release();
- }
-}
-
uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder,
uint8_t*& dest_buf,
uint32_t& dest_size) {
@@ -93,13 +75,6 @@ uint32_t DecodeAllScanlines(CCodec_ScanlineDecoder* pDecoder,
return srcoff;
}
-CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder(
- const uint8_t* src_buf,
- uint32_t src_size,
- int width,
- int height,
- const CPDF_Dictionary* pParams);
-
uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf,
uint32_t limit,
int width,
@@ -142,6 +117,31 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf,
return (uint32_t)-1;
}
+} // namespace
+
+CPDF_StreamParser::CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize)
+ : m_pBuf(pData),
+ m_Size(dwSize),
+ m_Pos(0),
+ m_pLastObj(nullptr),
+ m_pPool(nullptr) {}
+
+CPDF_StreamParser::CPDF_StreamParser(
+ const uint8_t* pData,
+ uint32_t dwSize,
+ const CFX_WeakPtr<CFX_ByteStringPool>& pPool)
+ : m_pBuf(pData),
+ m_Size(dwSize),
+ m_Pos(0),
+ m_pLastObj(nullptr),
+ m_pPool(pPool) {}
+
+CPDF_StreamParser::~CPDF_StreamParser() {
+ if (m_pLastObj) {
+ m_pLastObj->Release();
+ }
+}
+
CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
CPDF_Dictionary* pDict,
CPDF_Object* pCSObj) {
@@ -257,7 +257,7 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
}
m_WordSize = 0;
- FX_BOOL bIsNumber = TRUE;
+ bool bIsNumber = true;
if (!PositionIsInBounds())
return EndOfData;
@@ -294,7 +294,7 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
m_WordBuffer[m_WordSize++] = ch;
if (!PDFCharIsNumeric(ch))
- bIsNumber = FALSE;
+ bIsNumber = false;
if (!PositionIsInBounds())
break;
@@ -332,9 +332,15 @@ CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
return Keyword;
}
+CPDF_Object* CPDF_StreamParser::GetObject() {
+ CPDF_Object* pObj = m_pLastObj;
+ m_pLastObj = nullptr;
+ return pObj;
+}
+
CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray,
uint32_t dwInArrayLevel) {
- FX_BOOL bIsNumber;
+ bool bIsNumber;
GetNextWord(bIsNumber);
if (!m_WordSize)
return nullptr;
@@ -421,9 +427,9 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray,
return nullptr;
}
-void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) {
+void CPDF_StreamParser::GetNextWord(bool& bIsNumber) {
m_WordSize = 0;
- bIsNumber = TRUE;
+ bIsNumber = true;
if (!PositionIsInBounds())
return;
@@ -449,7 +455,7 @@ void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) {
}
if (PDFCharIsDelimiter(ch)) {
- bIsNumber = FALSE;
+ bIsNumber = false;
m_WordBuffer[m_WordSize++] = ch;
if (ch == '/') {
while (1) {
@@ -488,7 +494,7 @@ void CPDF_StreamParser::GetNextWord(FX_BOOL& bIsNumber) {
if (m_WordSize < kMaxWordBuffer)
m_WordBuffer[m_WordSize++] = ch;
if (!PDFCharIsNumeric(ch))
- bIsNumber = FALSE;
+ bIsNumber = false;
if (!PositionIsInBounds())
return;
@@ -659,7 +665,7 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage) {
return;
}
m_pObjectHolder = pPage;
- m_bForm = FALSE;
+ m_bForm = false;
m_Status = ToBeContinued;
m_InternalStage = STAGE_GETCONTENT;
m_CurrentOffset = 0;
@@ -691,7 +697,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
int level) {
m_pType3Char = pType3Char;
m_pObjectHolder = pForm;
- m_bForm = TRUE;
+ m_bForm = true;
CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixFor("Matrix");
if (pGraphicStates) {
form_matrix.Concat(pGraphicStates->m_CTM);
diff --git a/core/fpdfapi/page/pageint.h b/core/fpdfapi/page/pageint.h
index 8bbadf0cf0..79cd46b819 100644
--- a/core/fpdfapi/page/pageint.h
+++ b/core/fpdfapi/page/pageint.h
@@ -56,21 +56,18 @@ class CPDF_StreamParser {
SyntaxType ParseNextElement();
uint8_t* GetWordBuf() { return m_WordBuffer; }
uint32_t GetWordSize() const { return m_WordSize; }
- CPDF_Object* GetObject() {
- CPDF_Object* pObj = m_pLastObj;
- m_pLastObj = nullptr;
- return pObj;
- }
+ CPDF_Object* GetObject();
uint32_t GetPos() const { return m_Pos; }
void SetPos(uint32_t pos) { m_Pos = pos; }
CPDF_Object* ReadNextObject(bool bAllowNestedArray, uint32_t dwInArrayLevel);
- protected:
+ private:
friend class fpdf_page_parser_old_ReadHexString_Test;
- void GetNextWord(FX_BOOL& bIsNumber);
+ void GetNextWord(bool& bIsNumber);
CFX_ByteString ReadString();
CFX_ByteString ReadHexString();
+ bool PositionIsInBounds() const;
const uint8_t* m_pBuf;
uint32_t m_Size; // Length in bytes of m_pBuf.
@@ -79,12 +76,10 @@ class CPDF_StreamParser {
uint32_t m_WordSize;
CPDF_Object* m_pLastObj;
CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
-
- private:
- bool PositionIsInBounds() const;
};
#define PARAM_BUF_SIZE 16
+
struct ContentParam {
enum Type { OBJECT = 0, NUMBER, NAME };
Type m_Type;
@@ -103,8 +98,10 @@ struct ContentParam {
} m_Name;
};
};
+
#define _FPDF_MAX_FORM_LEVEL_ 30
#define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4
+
class CPDF_StreamContentParser {
public:
CPDF_StreamContentParser(CPDF_Document* pDoc,
@@ -133,8 +130,6 @@ class CPDF_StreamContentParser {
FX_FLOAT GetNumber(uint32_t index);
int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); }
void OnOperator(const FX_CHAR* op);
- void BigCaseCaller(int index);
- uint32_t GetParsePos() { return m_pSyntax->GetPos(); }
void AddTextObject(CFX_ByteString* pText,
FX_FLOAT fInitKerning,
FX_FLOAT* pKerning,
@@ -147,25 +142,22 @@ class CPDF_StreamContentParser {
void ParsePathObject();
void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag);
void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h);
- void AddPathObject(int FillType, FX_BOOL bStroke);
+ void AddPathObject(int FillType, bool bStroke);
CPDF_ImageObject* AddImage(CPDF_Stream* pStream,
CPDF_Image* pImage,
bool bInline);
- void AddDuplicateImage();
void AddForm(CPDF_Stream* pStream);
void SetGraphicStates(CPDF_PageObject* pObj,
- FX_BOOL bColor,
- FX_BOOL bText,
- FX_BOOL bGraph);
- void SaveStates(CPDF_AllStates* pState);
- void RestoreStates(CPDF_AllStates* pState);
+ bool bColor,
+ bool bText,
+ bool bGraph);
CPDF_Font* FindFont(const CFX_ByteString& name);
CPDF_ColorSpace* FindColorSpace(const CFX_ByteString& name);
CPDF_Pattern* FindPattern(const CFX_ByteString& name, bool bShading);
CPDF_Object* FindResourceObj(const CFX_ByteString& type,
const CFX_ByteString& name);
- protected:
+ private:
using OpCodes =
std::unordered_map<uint32_t, void (CPDF_StreamContentParser::*)()>;
static OpCodes InitializeOpCodes();
@@ -270,17 +262,14 @@ class CPDF_StreamContentParser {
uint8_t m_PathClipType;
CFX_ByteString m_LastImageName;
CPDF_Image* m_pLastImage;
- CFX_BinaryBuf m_LastImageDict;
- CFX_BinaryBuf m_LastImageData;
CPDF_Dictionary* m_pLastImageDict;
CPDF_Dictionary* m_pLastCloneImageDict;
- FX_BOOL m_bReleaseLastDict;
- FX_BOOL m_bSameLastDict;
bool m_bColored;
FX_FLOAT m_Type3Data[6];
- FX_BOOL m_bResourceMissing;
+ bool m_bResourceMissing;
std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack;
};
+
class CPDF_ContentParser {
public:
enum ParseStatus { Ready, ToBeContinued, Done };
@@ -307,7 +296,7 @@ class CPDF_ContentParser {
ParseStatus m_Status;
InternalStage m_InternalStage;
CPDF_PageObjectHolder* m_pObjectHolder;
- FX_BOOL m_bForm;
+ bool m_bForm;
CPDF_Type3Char* m_pType3Char;
uint32_t m_nStreams;
std::unique_ptr<CPDF_StreamAcc> m_pSingleStream;
@@ -323,8 +312,8 @@ class CPDF_DocPageData {
explicit CPDF_DocPageData(CPDF_Document* pPDFDoc);
~CPDF_DocPageData();
- void Clear(FX_BOOL bRelease = FALSE);
- CPDF_Font* GetFont(CPDF_Dictionary* pFontDict, FX_BOOL findOnly);
+ void Clear(bool bRelease = FALSE);
+ CPDF_Font* GetFont(CPDF_Dictionary* pFontDict);
CPDF_Font* GetStandardFont(const CFX_ByteString& fontName,
CPDF_FontEncoding* pEncoding);
void ReleaseFont(const CPDF_Dictionary* pFontDict);
@@ -333,7 +322,7 @@ class CPDF_DocPageData {
CPDF_ColorSpace* GetCopiedColorSpace(CPDF_Object* pCSObj);
void ReleaseColorSpace(const CPDF_Object* pColorSpace);
CPDF_Pattern* GetPattern(CPDF_Object* pPatternObj,
- FX_BOOL bShading,
+ bool bShading,
const CFX_Matrix& matrix);
void ReleasePattern(const CPDF_Object* pPatternObj);
CPDF_Image* GetImage(CPDF_Object* pImageStream);
@@ -342,7 +331,7 @@ class CPDF_DocPageData {
void ReleaseIccProfile(const CPDF_IccProfile* pIccProfile);
CPDF_StreamAcc* GetFontFileStreamAcc(CPDF_Stream* pFontStream);
void ReleaseFontFileStreamAcc(const CPDF_Stream* pFontStream);
- FX_BOOL IsForceClear() const { return m_bForceClear; }
+ bool IsForceClear() const { return m_bForceClear; }
CPDF_CountedColorSpace* FindColorSpacePtr(CPDF_Object* pCSObj) const;
CPDF_CountedPattern* FindPatternPtr(CPDF_Object* pPatternObj) const;
@@ -366,7 +355,7 @@ class CPDF_DocPageData {
std::set<CPDF_Object*>* pVisited);
CPDF_Document* const m_pPDFDoc;
- FX_BOOL m_bForceClear;
+ bool m_bForceClear;
std::map<CFX_ByteString, CPDF_Stream*> m_HashProfileMap;
CPDF_ColorSpaceMap m_ColorSpaceMap;
CPDF_FontFileMap m_FontFileMap;
@@ -495,7 +484,7 @@ class CPDF_IccProfile {
CPDF_IccProfile(const uint8_t* pData, uint32_t dwSize);
~CPDF_IccProfile();
uint32_t GetComponents() const { return m_nSrcComponents; }
- FX_BOOL m_bsRGB;
+ bool m_bsRGB;
void* m_pTransform;
private:
@@ -561,6 +550,5 @@ CFX_ByteStringC PDF_FindValueAbbreviationForTesting(
const CFX_ByteStringC& abbr);
void PDF_ReplaceAbbr(CPDF_Object* pObj);
-bool IsPathOperator(const uint8_t* buf, size_t len);
#endif // CORE_FPDFAPI_PAGE_PAGEINT_H_
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 435f180454..0e688c685b 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -659,7 +659,7 @@ uint32_t CPDF_Document::GetUserPermissions() const {
CPDF_Font* CPDF_Document::LoadFont(CPDF_Dictionary* pFontDict) {
ASSERT(pFontDict);
- return m_pDocPage->GetFont(pFontDict, FALSE);
+ return m_pDocPage->GetFont(pFontDict);
}
CPDF_StreamAcc* CPDF_Document::LoadFontFile(CPDF_Stream* pStream) {
@@ -672,7 +672,7 @@ CPDF_ColorSpace* CPDF_Document::LoadColorSpace(CPDF_Object* pCSObj,
}
CPDF_Pattern* CPDF_Document::LoadPattern(CPDF_Object* pPatternObj,
- FX_BOOL bShading,
+ bool bShading,
const CFX_Matrix& matrix) {
return m_pDocPage->GetPattern(pPatternObj, bShading, matrix);
}
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index 83ceb77b08..c557a56013 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -77,7 +77,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_Dictionary* pResources = nullptr);
CPDF_Pattern* LoadPattern(CPDF_Object* pObj,
- FX_BOOL bShading,
+ bool bShading,
const CFX_Matrix& matrix);
CPDF_Image* LoadImageF(CPDF_Object* pObj);
diff --git a/core/fpdfapi/render/fpdf_render_text.cpp b/core/fpdfapi/render/fpdf_render_text.cpp
index 67bb2376b1..26edc1b0f4 100644
--- a/core/fpdfapi/render/fpdf_render_text.cpp
+++ b/core/fpdfapi/render/fpdf_render_text.cpp
@@ -146,7 +146,7 @@ CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) {
if (!pFont->m_pDocument) {
return nullptr;
}
- pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), FALSE);
+ pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict());
return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont);
}
static void ReleaseCachedType3(CPDF_Type3Font* pFont) {