diff options
-rw-r--r-- | fpdfsdk/fpdfeditpage.cpp | 7 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp index e10f3825af..493329c360 100644 --- a/fpdfsdk/fpdfeditpage.cpp +++ b/fpdfsdk/fpdfeditpage.cpp @@ -57,11 +57,8 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() { } DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) { - CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); - if (!pDoc || page_index < 0 || page_index >= pDoc->GetPageCount()) - return; - - pDoc->DeletePage(page_index); + if (UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document)) + pDoc->DeletePage(page_index); } DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index 144e5dc811..6e0edf646e 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -182,6 +182,14 @@ CPDFXFA_Page* CPDFXFA_Document::GetPage(IXFA_PageView* pPage) { return NULL; } +void CPDFXFA_Document::DeletePage(int page_index) { + if (page_index < 0 || page_index >= m_XFAPageList.GetSize()) + return; + + if (CPDFXFA_Page* pPage = m_XFAPageList.GetAt(page_index)) + pPage->Release(); +} + void CPDFXFA_Document::RemovePage(CPDFXFA_Page* page) { m_XFAPageList.SetAt(page->GetPageIndex(), NULL); } diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h index 2bc579c1da..55310e5615 100644 --- a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h +++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h @@ -35,6 +35,8 @@ class CPDFXFA_Document : public IXFA_DocProvider { int GetPageCount(); CPDFXFA_Page* GetPage(int page_index); CPDFXFA_Page* GetPage(IXFA_PageView* pPage); + + void DeletePage(int page_index); void RemovePage(CPDFXFA_Page* page); int GetDocType() { return m_iDocType; } |