diff options
Diffstat (limited to 'fpdfsdk/fpdfxfa/fpdfxfa_page.cpp')
-rw-r--r-- | fpdfsdk/fpdfxfa/fpdfxfa_page.cpp | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp index 8179db5c11..8c0d6bbf98 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp @@ -16,22 +16,15 @@ #include "xfa/fxfa/include/xfa_ffpageview.h" CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index) - : m_pPDFPage(NULL), - m_pXFAPageView(NULL), - m_iPageIndex(page_index), + : m_pXFAPageView(nullptr), m_pDocument(pDoc), + m_iPageIndex(page_index), m_iRef(1) {} -CPDFXFA_Page::~CPDFXFA_Page() { - if (m_pPDFPage) - delete m_pPDFPage; - m_pPDFPage = NULL; - m_pXFAPageView = NULL; -} +CPDFXFA_Page::~CPDFXFA_Page() {} void CPDFXFA_Page::Release() { - m_iRef--; - if (m_iRef > 0) + if (--m_iRef > 0) return; if (m_pDocument) @@ -43,31 +36,27 @@ void CPDFXFA_Page::Release() { FX_BOOL CPDFXFA_Page::LoadPDFPage() { if (!m_pDocument) return FALSE; + CPDF_Document* pPDFDoc = m_pDocument->GetPDFDoc(); - if (pPDFDoc) { - CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); - if (pDict == NULL) - return FALSE; - if (m_pPDFPage) { - if (m_pPDFPage->m_pFormDict == pDict) - return TRUE; + if (!pPDFDoc) + return FALSE; - delete m_pPDFPage; - m_pPDFPage = NULL; - } + CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); + if (!pDict) + return FALSE; - m_pPDFPage = new CPDF_Page; + if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) { + m_pPDFPage.reset(new CPDF_Page); m_pPDFPage->Load(pPDFDoc, pDict); m_pPDFPage->ParseContent(nullptr); - return TRUE; } - - return FALSE; + return TRUE; } FX_BOOL CPDFXFA_Page::LoadXFAPageView() { if (!m_pDocument) return FALSE; + CXFA_FFDoc* pXFADoc = m_pDocument->GetXFADoc(); if (!pXFADoc) return FALSE; @@ -80,11 +69,7 @@ FX_BOOL CPDFXFA_Page::LoadXFAPageView() { if (!pPageView) return FALSE; - if (m_pXFAPageView == pPageView) - return TRUE; - m_pXFAPageView = pPageView; - (void)m_pXFAPageView->LoadPageView(nullptr); return TRUE; } @@ -110,17 +95,13 @@ FX_BOOL CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { if (!m_pDocument || m_iPageIndex < 0 || !pageDict) return FALSE; - if (m_pPDFPage) - delete m_pPDFPage; - - m_pPDFPage = new CPDF_Page(); + m_pPDFPage.reset(new CPDF_Page()); m_pPDFPage->Load(m_pDocument->GetPDFDoc(), pageDict); m_pPDFPage->ParseContent(nullptr); - return TRUE; } -FX_FLOAT CPDFXFA_Page::GetPageWidth() { +FX_FLOAT CPDFXFA_Page::GetPageWidth() const { if (!m_pPDFPage && !m_pXFAPageView) return 0.0f; @@ -145,7 +126,7 @@ FX_FLOAT CPDFXFA_Page::GetPageWidth() { return 0.0f; } -FX_FLOAT CPDFXFA_Page::GetPageHeight() { +FX_FLOAT CPDFXFA_Page::GetPageHeight() const { if (!m_pPDFPage && !m_pXFAPageView) return 0.0f; |