summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp12
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_formobject.cpp7
-rw-r--r--core/fpdfapi/page/cpdf_formobject.h4
-rw-r--r--core/fpdfapi/page/cpdf_imageobject.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_imageobject.h2
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_pageobject.h4
-rw-r--r--core/fpdfapi/page/cpdf_pathobject.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_pathobject.h2
-rw-r--r--core/fpdfapi/page/cpdf_shadingobject.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_shadingobject.h4
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp21
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.h6
-rw-r--r--core/fpdfapi/page/cpdf_textobject.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_textobject.h2
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp4
17 files changed, 56 insertions, 33 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index 1244b12331..f1dbffeccf 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -49,7 +49,7 @@ class CPDF_PageContentGeneratorTest : public testing::Test {
};
TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
- auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
+ auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(-1);
pPathObj->m_Path.AppendRect(10, 5, 13, 30);
pPathObj->m_FillType = FXFILL_ALTERNATE;
pPathObj->m_bStroke = true;
@@ -60,7 +60,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
TestProcessPath(&generator, &buf, pPathObj.get());
EXPECT_EQ("q 1 0 0 1 0 0 cm 10 5 3 25 re B* Q\n", ByteString(buf));
- pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
+ pPathObj = pdfium::MakeUnique<CPDF_PathObject>(-1);
pPathObj->m_Path.AppendPoint(CFX_PointF(0, 0), FXPT_TYPE::MoveTo, false);
pPathObj->m_Path.AppendPoint(CFX_PointF(5.2f, 0), FXPT_TYPE::LineTo, false);
pPathObj->m_Path.AppendPoint(CFX_PointF(5.2f, 3.78f), FXPT_TYPE::LineTo,
@@ -75,7 +75,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
}
TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
- auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
+ auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(-1);
pPathObj->m_Path.AppendPoint(CFX_PointF(3.102f, 4.67f), FXPT_TYPE::MoveTo,
false);
pPathObj->m_Path.AppendPoint(CFX_PointF(5.45f, 0.29f), FXPT_TYPE::LineTo,
@@ -110,7 +110,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
}
TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) {
- auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
+ auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(-1);
pPathObj->m_Path.AppendPoint(CFX_PointF(1, 2), FXPT_TYPE::MoveTo, false);
pPathObj->m_Path.AppendPoint(CFX_PointF(3, 4), FXPT_TYPE::LineTo, false);
pPathObj->m_Path.AppendPoint(CFX_PointF(5, 6), FXPT_TYPE::LineTo, true);
@@ -170,7 +170,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) {
CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(0);
auto pTestPage = pdfium::MakeRetain<CPDF_Page>(pDoc.get(), pPageDict, false);
CPDF_PageContentGenerator generator(pTestPage.Get());
- auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>();
+ auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>(-1);
CPDF_Font* pFont = CPDF_Font::GetStockFont(pDoc.get(), "Times-Roman");
pTextObj->m_TextState.SetFont(pFont);
pTextObj->m_TextState.SetFontSize(10.0f);
@@ -237,7 +237,7 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessText) {
std::ostringstream buf;
{
// Set the text object font and text
- auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>();
+ auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>(-1);
CPDF_Dictionary* pDict = pDoc->NewIndirect<CPDF_Dictionary>();
pDict->SetNewFor<CPDF_Name>("Type", "Font");
pDict->SetNewFor<CPDF_Name>("Subtype", "TrueType");
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 9e8f70ef18..c74a889ff6 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -168,7 +168,7 @@ CPDF_ContentParser::Stage CPDF_ContentParser::Parse() {
m_CurrentOffset += m_pParser->Parse(
m_StreamArray[m_CurrentStream]->GetData() + m_CurrentOffset,
m_StreamArray[m_CurrentStream]->GetSize() - m_CurrentOffset,
- PARSE_STEP_LIMIT);
+ PARSE_STEP_LIMIT, m_CurrentStream);
if (m_CurrentOffset >= m_StreamArray[m_CurrentStream]->GetSize()) {
m_CurrentOffset = 0;
diff --git a/core/fpdfapi/page/cpdf_formobject.cpp b/core/fpdfapi/page/cpdf_formobject.cpp
index eca92ca0ff..22ac0d3823 100644
--- a/core/fpdfapi/page/cpdf_formobject.cpp
+++ b/core/fpdfapi/page/cpdf_formobject.cpp
@@ -10,9 +10,12 @@
#include "core/fpdfapi/page/cpdf_form.h"
-CPDF_FormObject::CPDF_FormObject(std::unique_ptr<CPDF_Form> pForm,
+CPDF_FormObject::CPDF_FormObject(int32_t content_stream,
+ std::unique_ptr<CPDF_Form> pForm,
const CFX_Matrix& matrix)
- : m_pForm(std::move(pForm)), m_FormMatrix(matrix) {}
+ : CPDF_PageObject(content_stream),
+ m_pForm(std::move(pForm)),
+ m_FormMatrix(matrix) {}
CPDF_FormObject::~CPDF_FormObject() {}
diff --git a/core/fpdfapi/page/cpdf_formobject.h b/core/fpdfapi/page/cpdf_formobject.h
index c723cc0eaf..b229dce444 100644
--- a/core/fpdfapi/page/cpdf_formobject.h
+++ b/core/fpdfapi/page/cpdf_formobject.h
@@ -16,7 +16,9 @@ class CPDF_Form;
class CPDF_FormObject : public CPDF_PageObject {
public:
- CPDF_FormObject(std::unique_ptr<CPDF_Form> pForm, const CFX_Matrix& matrix);
+ CPDF_FormObject(int32_t content_stream,
+ std::unique_ptr<CPDF_Form> pForm,
+ const CFX_Matrix& matrix);
~CPDF_FormObject() override;
// CPDF_PageObject:
diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp
index 3b5a740155..7826742276 100644
--- a/core/fpdfapi/page/cpdf_imageobject.cpp
+++ b/core/fpdfapi/page/cpdf_imageobject.cpp
@@ -12,7 +12,8 @@
#include "core/fpdfapi/page/cpdf_image.h"
#include "core/fpdfapi/parser/cpdf_document.h"
-CPDF_ImageObject::CPDF_ImageObject() {}
+CPDF_ImageObject::CPDF_ImageObject(int32_t content_stream)
+ : CPDF_PageObject(content_stream) {}
CPDF_ImageObject::~CPDF_ImageObject() {
MaybePurgeCache();
diff --git a/core/fpdfapi/page/cpdf_imageobject.h b/core/fpdfapi/page/cpdf_imageobject.h
index 16a506e537..465b1628ed 100644
--- a/core/fpdfapi/page/cpdf_imageobject.h
+++ b/core/fpdfapi/page/cpdf_imageobject.h
@@ -16,7 +16,7 @@ class CPDF_Image;
class CPDF_ImageObject : public CPDF_PageObject {
public:
- CPDF_ImageObject();
+ explicit CPDF_ImageObject(int32_t content_stream);
~CPDF_ImageObject() override;
// CPDF_PageObject
diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp
index 8bb5bf5978..582b9fff57 100644
--- a/core/fpdfapi/page/cpdf_pageobject.cpp
+++ b/core/fpdfapi/page/cpdf_pageobject.cpp
@@ -6,7 +6,8 @@
#include "core/fpdfapi/page/cpdf_pageobject.h"
-CPDF_PageObject::CPDF_PageObject() : m_bDirty(false) {}
+CPDF_PageObject::CPDF_PageObject(int32_t content_stream)
+ : m_bDirty(false), m_ContentStream(content_stream) {}
CPDF_PageObject::~CPDF_PageObject() {}
diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h
index d23cd971f8..b7cc5996c9 100644
--- a/core/fpdfapi/page/cpdf_pageobject.h
+++ b/core/fpdfapi/page/cpdf_pageobject.h
@@ -28,7 +28,7 @@ class CPDF_PageObject : public CPDF_GraphicStates {
FORM,
};
- CPDF_PageObject();
+ explicit CPDF_PageObject(int32_t content_stream);
~CPDF_PageObject() override;
virtual Type GetType() const = 0;
@@ -58,6 +58,7 @@ class CPDF_PageObject : public CPDF_GraphicStates {
return CFX_FloatRect(m_Left, m_Bottom, m_Right, m_Top);
}
FX_RECT GetBBox(const CFX_Matrix* pMatrix) const;
+ int32_t GetContentStream() const { return m_ContentStream; }
float m_Left;
float m_Right;
@@ -73,6 +74,7 @@ class CPDF_PageObject : public CPDF_GraphicStates {
void operator=(const CPDF_PageObject& src) = delete;
bool m_bDirty;
+ int32_t m_ContentStream;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECT_H_
diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp
index d8c2cb8741..39ab134c92 100644
--- a/core/fpdfapi/page/cpdf_pathobject.cpp
+++ b/core/fpdfapi/page/cpdf_pathobject.cpp
@@ -6,7 +6,8 @@
#include "core/fpdfapi/page/cpdf_pathobject.h"
-CPDF_PathObject::CPDF_PathObject() : m_FillType(0), m_bStroke(false) {}
+CPDF_PathObject::CPDF_PathObject(int32_t content_stream)
+ : CPDF_PageObject(content_stream), m_FillType(0), m_bStroke(false) {}
CPDF_PathObject::~CPDF_PathObject() {}
diff --git a/core/fpdfapi/page/cpdf_pathobject.h b/core/fpdfapi/page/cpdf_pathobject.h
index 58499b5a53..d4843d2fb6 100644
--- a/core/fpdfapi/page/cpdf_pathobject.h
+++ b/core/fpdfapi/page/cpdf_pathobject.h
@@ -14,7 +14,7 @@
class CPDF_PathObject : public CPDF_PageObject {
public:
- CPDF_PathObject();
+ explicit CPDF_PathObject(int32_t content_stream);
~CPDF_PathObject() override;
// CPDF_PageObject
diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp
index 1b16ac4862..725e2e4591 100644
--- a/core/fpdfapi/page/cpdf_shadingobject.cpp
+++ b/core/fpdfapi/page/cpdf_shadingobject.cpp
@@ -9,9 +9,10 @@
#include "core/fpdfapi/page/cpdf_shadingpattern.h"
#include "core/fpdfapi/parser/cpdf_document.h"
-CPDF_ShadingObject::CPDF_ShadingObject(CPDF_ShadingPattern* pattern,
+CPDF_ShadingObject::CPDF_ShadingObject(int32_t content_stream,
+ CPDF_ShadingPattern* pattern,
const CFX_Matrix& matrix)
- : m_pShading(pattern), m_Matrix(matrix) {}
+ : CPDF_PageObject(content_stream), m_pShading(pattern), m_Matrix(matrix) {}
CPDF_ShadingObject::~CPDF_ShadingObject() {}
diff --git a/core/fpdfapi/page/cpdf_shadingobject.h b/core/fpdfapi/page/cpdf_shadingobject.h
index 80e062c729..69b606749d 100644
--- a/core/fpdfapi/page/cpdf_shadingobject.h
+++ b/core/fpdfapi/page/cpdf_shadingobject.h
@@ -15,7 +15,9 @@ class CPDF_ShadingPattern;
class CPDF_ShadingObject : public CPDF_PageObject {
public:
- CPDF_ShadingObject(CPDF_ShadingPattern* pattern, const CFX_Matrix& matrix);
+ CPDF_ShadingObject(int32_t content_stream,
+ CPDF_ShadingPattern* pattern,
+ const CFX_Matrix& matrix);
~CPDF_ShadingObject() override;
// CPDF_PageObject:
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 7e7c337d96..051d79ad1d 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -786,7 +786,8 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
CFX_Matrix matrix = m_pCurStates->m_CTM;
matrix.Concat(m_mtContentToUser);
- auto pFormObj = pdfium::MakeUnique<CPDF_FormObject>(std::move(form), matrix);
+ auto pFormObj = pdfium::MakeUnique<CPDF_FormObject>(m_CurrentContentStream,
+ std::move(form), matrix);
if (!m_pObjectHolder->BackgroundAlphaNeeded() &&
pFormObj->form()->BackgroundAlphaNeeded()) {
m_pObjectHolder->SetBackgroundAlphaNeeded(true);
@@ -801,14 +802,14 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(
if (!pStream)
return nullptr;
- auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>();
+ auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>(m_CurrentContentStream);
pImageObj->SetImage(
pdfium::MakeRetain<CPDF_Image>(m_pDocument.Get(), std::move(pStream)));
return AddImageObject(std::move(pImageObj));
}
CPDF_ImageObject* CPDF_StreamContentParser::AddImage(uint32_t streamObjNum) {
- auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>();
+ auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>(m_CurrentContentStream);
pImageObj->SetImage(m_pDocument->LoadImageFromPageData(streamObjNum));
return AddImageObject(std::move(pImageObj));
}
@@ -818,7 +819,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(
if (!pImage)
return nullptr;
- auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>();
+ auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>(m_CurrentContentStream);
pImageObj->SetImage(
m_pDocument->GetPageData()->GetImage(pImage->GetStream()->GetObjNum()));
@@ -1085,7 +1086,8 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
CFX_Matrix matrix = m_pCurStates->m_CTM;
matrix.Concat(m_mtContentToUser);
- auto pObj = pdfium::MakeUnique<CPDF_ShadingObject>(pShading, matrix);
+ auto pObj = pdfium::MakeUnique<CPDF_ShadingObject>(m_CurrentContentStream,
+ pShading, matrix);
SetGraphicStates(pObj.get(), false, false, false);
CFX_FloatRect bbox =
pObj->m_ClipPath.HasRef() ? pObj->m_ClipPath.GetClipBox() : m_BBox;
@@ -1220,7 +1222,7 @@ void CPDF_StreamContentParser::AddTextObject(ByteString* pStrs,
pFont->IsType3Font() ? TextRenderingMode::MODE_FILL
: m_pCurStates->m_TextState.GetTextMode();
{
- auto pText = pdfium::MakeUnique<CPDF_TextObject>();
+ auto pText = pdfium::MakeUnique<CPDF_TextObject>(m_CurrentContentStream);
m_pLastTextObject = pText.get();
SetGraphicStates(m_pLastTextObject.Get(), true, true, true);
if (TextRenderingModeIsStrokeMode(text_mode)) {
@@ -1457,7 +1459,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) {
CFX_Matrix matrix = m_pCurStates->m_CTM;
matrix.Concat(m_mtContentToUser);
if (bStroke || FillType) {
- auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>();
+ auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(m_CurrentContentStream);
pPathObj->m_bStroke = bStroke;
pPathObj->m_FillType = FillType;
pPathObj->m_Path = Path;
@@ -1477,7 +1479,10 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) {
uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData,
uint32_t dwSize,
- uint32_t max_cost) {
+ uint32_t max_cost,
+ uint32_t content_stream) {
+ m_CurrentContentStream = content_stream;
+
if (m_ParsedSet->size() > kMaxFormLevel ||
pdfium::ContainsKey(*m_ParsedSet, pData))
return dwSize;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 438be024cc..4c593998fd 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -43,7 +43,10 @@ class CPDF_StreamContentParser {
std::set<const uint8_t*>* parsedSet);
~CPDF_StreamContentParser();
- uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost);
+ uint32_t Parse(const uint8_t* pData,
+ uint32_t dwSize,
+ uint32_t max_cost,
+ uint32_t content_stream);
CPDF_PageObjectHolder* GetPageObjectHolder() const {
return m_pObjectHolder.Get();
}
@@ -230,6 +233,7 @@ class CPDF_StreamContentParser {
std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack;
float m_Type3Data[6];
ContentParam m_ParamBuf[kParamBufSize];
+ uint32_t m_CurrentContentStream;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index 36a4722773..68d20b6598 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -18,7 +18,8 @@ CPDF_TextObjectItem::CPDF_TextObjectItem() : m_CharCode(0) {}
CPDF_TextObjectItem::~CPDF_TextObjectItem() = default;
-CPDF_TextObject::CPDF_TextObject() {}
+CPDF_TextObject::CPDF_TextObject(int32_t content_stream)
+ : CPDF_PageObject(content_stream) {}
CPDF_TextObject::~CPDF_TextObject() {
// Move m_CharCodes to a local variable so it will be captured in crash dumps,
@@ -100,7 +101,7 @@ void CPDF_TextObject::GetCharInfo(size_t index,
}
std::unique_ptr<CPDF_TextObject> CPDF_TextObject::Clone() const {
- auto obj = pdfium::MakeUnique<CPDF_TextObject>();
+ auto obj = pdfium::MakeUnique<CPDF_TextObject>(-1);
obj->CopyData(this);
obj->m_CharCodes = m_CharCodes;
obj->m_CharPos = m_CharPos;
diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h
index a6fc62369c..3faccfdfe7 100644
--- a/core/fpdfapi/page/cpdf_textobject.h
+++ b/core/fpdfapi/page/cpdf_textobject.h
@@ -25,7 +25,7 @@ class CPDF_TextObjectItem {
class CPDF_TextObject : public CPDF_PageObject {
public:
- CPDF_TextObject();
+ explicit CPDF_TextObject(int32_t content_stream);
~CPDF_TextObject() override;
// CPDF_PageObject
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index af976903be..9295b0e77f 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1990,7 +1990,7 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
bool bFill,
bool bStroke) {
if (!bStroke) {
- CPDF_PathObject path;
+ CPDF_PathObject path(-1);
std::vector<std::unique_ptr<CPDF_TextObject>> pCopy;
pCopy.push_back(std::unique_ptr<CPDF_TextObject>(textobj->Clone()));
path.m_bStroke = false;
@@ -2019,7 +2019,7 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
if (!pPath)
continue;
- CPDF_PathObject path;
+ CPDF_PathObject path(-1);
path.m_GraphState = textobj->m_GraphState;
path.m_ColorState = textobj->m_ColorState;