summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfxfa
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-25 14:14:56 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-25 14:14:56 -0700
commit1f5f2fff688f4075a62c87a032c9a9070bde89fc (patch)
tree45deaa748b75d0eddc521b1ef21fca40db74b495 /fpdfsdk/fpdfxfa
parent084174a3523e0ebdbf2d9d1c9902d2ba4875182e (diff)
downloadpdfium-1f5f2fff688f4075a62c87a032c9a9070bde89fc.tar.xz
Fixup page removal for XFA documents.
Currently when you call DelegePage on a CPDFXFA_Document the page will not be correctly removed. The page is left in the underlying document and, if GetPage was never called for that page index nothing will happen. This CL updates the code to always remove the page_index from the underlying CPDF_Document then, if needed, the original code runs to clear out the XFA page list for that page. BUG=chromium:596373 Review URL: https://codereview.chromium.org/1921033003
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index d55183751e..72f67dd271 100644
--- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -154,6 +154,7 @@ int CPDFXFA_Document::GetPageCount() {
CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) {
if (page_index < 0)
return nullptr;
+
CPDFXFA_Page* pPage = nullptr;
int nCount = m_XFAPageList.GetSize();
if (nCount > 0 && page_index < nCount) {
@@ -166,6 +167,7 @@ CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) {
}
if (pPage)
return pPage;
+
pPage = new CPDFXFA_Page(this, page_index);
if (!pPage->LoadPage()) {
pPage->Release();
@@ -177,13 +179,13 @@ CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) {
CPDFXFA_Page* CPDFXFA_Document::GetPage(CXFA_FFPageView* pPage) {
if (!pPage)
- return NULL;
+ return nullptr;
if (!m_pXFADoc)
- return NULL;
+ return nullptr;
if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
- return NULL;
+ return nullptr;
int nSize = m_XFAPageList.GetSize();
for (int i = 0; i < nSize; i++) {
@@ -194,10 +196,16 @@ CPDFXFA_Page* CPDFXFA_Document::GetPage(CXFA_FFPageView* pPage) {
return pTempPage;
}
- return NULL;
+ return nullptr;
}
void CPDFXFA_Document::DeletePage(int page_index) {
+ // Delete from the document first because, if GetPage was never called for
+ // this |page_index| then |m_XFAPageList| may have size < |page_index| even
+ // if it's a valid page in the document.
+ if (m_pPDFDoc)
+ m_pPDFDoc->DeletePage(page_index);
+
if (page_index < 0 || page_index >= m_XFAPageList.GetSize())
return;