summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp20
-rw-r--r--core/fpdfapi/page/cpdf_page.h20
-rw-r--r--core/fpdfapi/parser/cpdf_document.h3
3 files changed, 21 insertions, 22 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index d97e8abf0b..1244b12331 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -54,8 +54,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) {
pPathObj->m_FillType = FXFILL_ALTERNATE;
pPathObj->m_bStroke = true;
- auto pTestPage = pdfium::MakeUnique<CPDF_Page>(nullptr, nullptr, false);
- CPDF_PageContentGenerator generator(pTestPage.get());
+ auto pTestPage = pdfium::MakeRetain<CPDF_Page>(nullptr, nullptr, false);
+ CPDF_PageContentGenerator generator(pTestPage.Get());
std::ostringstream buf;
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));
@@ -98,8 +98,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
pPathObj->m_FillType = FXFILL_WINDING;
pPathObj->m_bStroke = false;
- auto pTestPage = pdfium::MakeUnique<CPDF_Page>(nullptr, nullptr, false);
- CPDF_PageContentGenerator generator(pTestPage.get());
+ auto pTestPage = pdfium::MakeRetain<CPDF_Page>(nullptr, nullptr, false);
+ CPDF_PageContentGenerator generator(pTestPage.Get());
std::ostringstream buf;
TestProcessPath(&generator, &buf, pPathObj.get());
EXPECT_EQ(
@@ -129,8 +129,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) {
auto pDoc = pdfium::MakeUnique<CPDF_Document>(nullptr);
pDoc->CreateNewDoc();
CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(0);
- auto pTestPage = pdfium::MakeUnique<CPDF_Page>(pDoc.get(), pPageDict, false);
- CPDF_PageContentGenerator generator(pTestPage.get());
+ auto pTestPage = pdfium::MakeRetain<CPDF_Page>(pDoc.get(), pPageDict, false);
+ CPDF_PageContentGenerator generator(pTestPage.Get());
std::ostringstream buf;
TestProcessPath(&generator, &buf, pPathObj.get());
ByteString pathString(buf);
@@ -168,8 +168,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) {
auto pDoc = pdfium::MakeUnique<CPDF_Document>(nullptr);
pDoc->CreateNewDoc();
CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(0);
- auto pTestPage = pdfium::MakeUnique<CPDF_Page>(pDoc.get(), pPageDict, false);
- CPDF_PageContentGenerator generator(pTestPage.get());
+ auto pTestPage = pdfium::MakeRetain<CPDF_Page>(pDoc.get(), pPageDict, false);
+ CPDF_PageContentGenerator generator(pTestPage.Get());
auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>();
CPDF_Font* pFont = CPDF_Font::GetStockFont(pDoc.get(), "Times-Roman");
pTextObj->m_TextState.SetFont(pFont);
@@ -231,8 +231,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessText) {
auto pDoc = pdfium::MakeUnique<CPDF_Document>(nullptr);
pDoc->CreateNewDoc();
CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(0);
- auto pTestPage = pdfium::MakeUnique<CPDF_Page>(pDoc.get(), pPageDict, false);
- CPDF_PageContentGenerator generator(pTestPage.get());
+ auto pTestPage = pdfium::MakeRetain<CPDF_Page>(pDoc.get(), pPageDict, false);
+ CPDF_PageContentGenerator generator(pTestPage.Get());
std::ostringstream buf;
{
diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h
index 28a12f45b5..0bb99b73f1 100644
--- a/core/fpdfapi/page/cpdf_page.h
+++ b/core/fpdfapi/page/cpdf_page.h
@@ -10,7 +10,6 @@
#include <memory>
#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
-#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
@@ -23,19 +22,13 @@ class CPDF_Object;
class CPDF_PageRenderCache;
class CPDF_PageRenderContext;
-class CPDF_Page : public CPDF_PageObjectHolder {
+class CPDF_Page : public Retainable, public CPDF_PageObjectHolder {
public:
class View {}; // Caller implements as desired, empty here due to layering.
+ class Extension : public Retainable {}; // XFA page parent class, layering.
- // XFA page parent class, layering.
- class Extension : public Retainable {
- virtual CPDF_Document::Extension* GetDocumentExtension() const = 0;
- };
-
- CPDF_Page(CPDF_Document* pDocument,
- CPDF_Dictionary* pPageDict,
- bool bPageCache);
- ~CPDF_Page() override;
+ template <typename T, typename... Args>
+ friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
// CPDF_PageObjectHolder:
bool IsPage() const override;
@@ -71,6 +64,11 @@ class CPDF_Page : public CPDF_PageObjectHolder {
void SetPageExtension(Extension* pExt) { m_pPageExtension = pExt; }
private:
+ CPDF_Page(CPDF_Document* pDocument,
+ CPDF_Dictionary* pPageDict,
+ bool bPageCache);
+ ~CPDF_Page() override;
+
void StartParse();
CPDF_Object* GetPageAttr(const ByteString& name) const;
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index 356d341302..013eded765 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -14,6 +14,7 @@
#include <vector>
#include "core/fpdfapi/page/cpdf_image.h"
+#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfdoc/cpdf_linklist.h"
@@ -165,7 +166,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
std::unique_ptr<CPDF_DocRenderData> m_pDocRender;
std::unique_ptr<JBig2_DocumentContext> m_pCodecContext;
std::unique_ptr<CPDF_LinkList> m_pLinksContext;
- std::vector<uint32_t> m_PageList;
+ std::vector<uint32_t> m_PageList; // Page number to page's dict objnum.
UnownedPtr<Extension> m_pExtension;
};