summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-11-02 21:14:48 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-02 21:14:48 +0000
commitc130381fd038893c1ee62a34648764d39d138b2c (patch)
treebd302874eba914154a58ed29b3753ff04205d193 /core/fpdfapi/page
parent638c764a3312f8387bdb5b2b2f2fabefbfcbc57f (diff)
downloadpdfium-c130381fd038893c1ee62a34648764d39d138b2c.tar.xz
Encapsulate CPDF_FormObject members.
Also remove a conditional in the CPDF_Form ctor that cannot be true. Change-Id: Icd00233969cea33e9c63d0d6a9d07226c2b173f2 Reviewed-on: https://pdfium-review.googlesource.com/17070 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_form.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_formobject.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_formobject.h6
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.h2
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp17
6 files changed, 24 insertions, 15 deletions
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index e4334016b4..ae06cb2f7e 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -17,8 +17,7 @@ CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
CPDF_Dictionary* pPageResources,
CPDF_Stream* pFormStream,
CPDF_Dictionary* pParentResources)
- : CPDF_PageObjectHolder(pDoc,
- pFormStream ? pFormStream->GetDict() : nullptr) {
+ : CPDF_PageObjectHolder(pDoc, pFormStream->GetDict()) {
m_pFormStream = pFormStream;
m_pResources = m_pFormDict->GetDictFor("Resources");
m_pPageResources = pPageResources;
diff --git a/core/fpdfapi/page/cpdf_formobject.cpp b/core/fpdfapi/page/cpdf_formobject.cpp
index c0cdd3e950..eca92ca0ff 100644
--- a/core/fpdfapi/page/cpdf_formobject.cpp
+++ b/core/fpdfapi/page/cpdf_formobject.cpp
@@ -6,9 +6,13 @@
#include "core/fpdfapi/page/cpdf_formobject.h"
+#include <utility>
+
#include "core/fpdfapi/page/cpdf_form.h"
-CPDF_FormObject::CPDF_FormObject() {}
+CPDF_FormObject::CPDF_FormObject(std::unique_ptr<CPDF_Form> pForm,
+ const CFX_Matrix& matrix)
+ : 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 b13cb5fbe4..c723cc0eaf 100644
--- a/core/fpdfapi/page/cpdf_formobject.h
+++ b/core/fpdfapi/page/cpdf_formobject.h
@@ -16,7 +16,7 @@ class CPDF_Form;
class CPDF_FormObject : public CPDF_PageObject {
public:
- CPDF_FormObject();
+ CPDF_FormObject(std::unique_ptr<CPDF_Form> pForm, const CFX_Matrix& matrix);
~CPDF_FormObject() override;
// CPDF_PageObject:
@@ -28,8 +28,10 @@ class CPDF_FormObject : public CPDF_PageObject {
void CalcBoundingBox();
const CPDF_Form* form() const { return m_pForm.get(); }
+ const CFX_Matrix& form_matrix() const { return m_FormMatrix; }
- std::unique_ptr<CPDF_Form> m_pForm;
+ private:
+ const std::unique_ptr<CPDF_Form> m_pForm;
CFX_Matrix m_FormMatrix;
};
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
index 5de911513f..4e9da63dea 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -22,7 +22,10 @@ CPDF_PageObjectHolder::CPDF_PageObjectHolder(CPDF_Document* pDoc,
m_pResources(nullptr),
m_iTransparency(0),
m_bBackgroundAlphaNeeded(false),
- m_ParseState(CONTENT_NOT_PARSED) {}
+ m_ParseState(CONTENT_NOT_PARSED) {
+ // TODO(thestig): Check if |m_pFormDict| is never a nullptr and simplify
+ // callers that checks for that.
+}
CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {}
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h
index 1a8b1aae38..f649ef7b62 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.h
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.h
@@ -71,7 +71,7 @@ class CPDF_PageObjectHolder {
void Transform(const CFX_Matrix& matrix);
CFX_FloatRect CalcBoundingBox() const;
- UnownedPtr<CPDF_Dictionary> m_pFormDict;
+ const UnownedPtr<CPDF_Dictionary> m_pFormDict;
UnownedPtr<CPDF_Stream> m_pFormStream;
UnownedPtr<CPDF_Document> m_pDocument;
UnownedPtr<CPDF_Dictionary> m_pPageResources;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 4ba1d2a44e..9e9c450c7d 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -767,20 +767,21 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
}
void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
- auto pFormObj = pdfium::MakeUnique<CPDF_FormObject>();
- pFormObj->m_pForm = pdfium::MakeUnique<CPDF_Form>(
- m_pDocument.Get(), m_pPageResources.Get(), pStream, m_pResources.Get());
- pFormObj->m_FormMatrix = m_pCurStates->m_CTM;
- pFormObj->m_FormMatrix.Concat(m_mtContentToUser);
CPDF_AllStates status;
status.m_GeneralState = m_pCurStates->m_GeneralState;
status.m_GraphState = m_pCurStates->m_GraphState;
status.m_ColorState = m_pCurStates->m_ColorState;
status.m_TextState = m_pCurStates->m_TextState;
- pFormObj->m_pForm->ParseContentWithParams(&status, nullptr, nullptr,
- m_ParsedSet.Get());
+ auto form = pdfium::MakeUnique<CPDF_Form>(
+ m_pDocument.Get(), m_pPageResources.Get(), pStream, m_pResources.Get());
+ form->ParseContentWithParams(&status, nullptr, nullptr, m_ParsedSet.Get());
+
+ CFX_Matrix matrix = m_pCurStates->m_CTM;
+ matrix.Concat(m_mtContentToUser);
+
+ auto pFormObj = pdfium::MakeUnique<CPDF_FormObject>(std::move(form), matrix);
if (!m_pObjectHolder->BackgroundAlphaNeeded() &&
- pFormObj->m_pForm->BackgroundAlphaNeeded()) {
+ pFormObj->form()->BackgroundAlphaNeeded()) {
m_pObjectHolder->SetBackgroundAlphaNeeded(true);
}
pFormObj->CalcBoundingBox();