summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp14
-rw-r--r--core/fpdfapi/page/cpdf_page.h1
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.cpp28
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.h6
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectlist.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectlist.h2
6 files changed, 36 insertions, 17 deletions
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index 6518d80aa3..e5d7f381a5 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -186,20 +186,6 @@ int CPDF_Page::GetPageRotation() const {
return (rotate < 0) ? (rotate + 4) : rotate;
}
-bool CPDF_Page::RemoveObject(CPDF_PageObject* pPageObj) {
- pdfium::FakeUniquePtr<CPDF_PageObject> p(pPageObj);
-
- auto* pPageObjectList = GetPageObjectList();
- auto it =
- std::find(std::begin(*pPageObjectList), std::end(*pPageObjectList), p);
- if (it == std::end(*pPageObjectList))
- return false;
-
- it->release();
- pPageObjectList->erase(it);
- return true;
-}
-
bool GraphicsData::operator<(const GraphicsData& other) const {
if (fillAlpha != other.fillAlpha)
return fillAlpha < other.fillAlpha;
diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h
index 995d99cf4e..c7aa12e474 100644
--- a/core/fpdfapi/page/cpdf_page.h
+++ b/core/fpdfapi/page/cpdf_page.h
@@ -54,7 +54,6 @@ class CPDF_Page : public CPDF_PageObjectHolder {
View* GetView() const { return m_pView; }
void SetView(View* pView) { m_pView = pView; }
- bool RemoveObject(CPDF_PageObject* pPageObj);
private:
void StartParse();
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
index 9413ffbfae..67b356fc57 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
#include <algorithm>
+#include <utility>
#include "core/fpdfapi/page/cpdf_allstates.h"
#include "core/fpdfapi/page/cpdf_contentparser.h"
@@ -91,3 +92,30 @@ void CPDF_PageObjectHolder::LoadTransInfo() {
m_iTransparency |= PDFTRANS_KNOCKOUT;
}
}
+
+size_t CPDF_PageObjectHolder::GetPageObjectCount() const {
+ return pdfium::CollectionSize<size_t>(m_PageObjectList);
+}
+
+CPDF_PageObject* CPDF_PageObjectHolder::GetPageObjectByIndex(
+ size_t index) const {
+ return m_PageObjectList.GetPageObjectByIndex(index);
+}
+
+void CPDF_PageObjectHolder::AppendPageObject(
+ std::unique_ptr<CPDF_PageObject> pPageObj) {
+ m_PageObjectList.push_back(std::move(pPageObj));
+}
+
+bool CPDF_PageObjectHolder::RemovePageObject(CPDF_PageObject* pPageObj) {
+ pdfium::FakeUniquePtr<CPDF_PageObject> p(pPageObj);
+
+ auto it =
+ std::find(std::begin(m_PageObjectList), std::end(m_PageObjectList), p);
+ if (it == std::end(m_PageObjectList))
+ return false;
+
+ it->release();
+ m_PageObjectList.erase(it);
+ return true;
+}
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h
index aac907763c..bf6c476186 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.h
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.h
@@ -56,6 +56,12 @@ class CPDF_PageObjectHolder {
const CPDF_PageObjectList* GetPageObjectList() const {
return &m_PageObjectList;
}
+
+ size_t GetPageObjectCount() const;
+ CPDF_PageObject* GetPageObjectByIndex(size_t index) const;
+ void AppendPageObject(std::unique_ptr<CPDF_PageObject> pPageObj);
+ bool RemovePageObject(CPDF_PageObject* pPageObj);
+
const CFX_Matrix& GetLastCTM() const { return m_LastCTM; }
bool BackgroundAlphaNeeded() const { return m_bBackgroundAlphaNeeded; }
diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.cpp b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
index afd2c98536..2c8e061a73 100644
--- a/core/fpdfapi/page/cpdf_pageobjectlist.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
@@ -8,6 +8,6 @@
#include "third_party/base/stl_util.h"
-CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) {
+CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) const {
return pdfium::IndexInBounds(*this, index) ? (*this)[index].get() : nullptr;
}
diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.h b/core/fpdfapi/page/cpdf_pageobjectlist.h
index b4505371f8..77c7d811e1 100644
--- a/core/fpdfapi/page/cpdf_pageobjectlist.h
+++ b/core/fpdfapi/page/cpdf_pageobjectlist.h
@@ -15,7 +15,7 @@ class CPDF_PageObject;
class CPDF_PageObjectList
: public std::deque<std::unique_ptr<CPDF_PageObject>> {
public:
- CPDF_PageObject* GetPageObjectByIndex(int index);
+ CPDF_PageObject* GetPageObjectByIndex(int index) const;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECTLIST_H_