summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_ext.cpp16
-rw-r--r--fpdfsdk/fpdfformfill.cpp4
-rw-r--r--fpdfsdk/fsdk_baseform.cpp6
-rw-r--r--fpdfsdk/include/fsdk_baseform.h10
4 files changed, 16 insertions, 20 deletions
diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp
index 9bb54da594..350945e328 100644
--- a/fpdfsdk/fpdf_ext.cpp
+++ b/fpdfsdk/fpdf_ext.cpp
@@ -6,6 +6,8 @@
#include "public/fpdf_ext.h"
+#include <memory>
+
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "core/fpdfapi/include/cpdf_modulemgr.h"
@@ -20,13 +22,13 @@
class CFSDK_UnsupportInfo_Adapter {
public:
- CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info) {
- m_unsp_info = unsp_info;
- }
+ explicit CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info)
+ : m_unsp_info(unsp_info) {}
+
void ReportError(int nErrorType);
private:
- UNSUPPORT_INFO* m_unsp_info;
+ UNSUPPORT_INFO* const m_unsp_info;
};
void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) {
@@ -183,11 +185,9 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) {
#ifndef PDF_ENABLE_XFA
// XFA Forms
- CPDF_InterForm* pInterForm = new CPDF_InterForm(pDoc, FALSE);
- if (pInterForm->HasXFAForm()) {
+ CPDF_InterForm interform(pDoc);
+ if (interform.HasXFAForm())
FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM);
- }
- delete pInterForm;
#endif // PDF_ENABLE_XFA
}
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 438150974d..81c5dd7a12 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -64,7 +64,7 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
return -1;
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (pPage) {
- CPDF_InterForm interform(pPage->m_pDocument, FALSE);
+ CPDF_InterForm interform(pPage->m_pDocument);
CPDF_FormControl* pFormCtrl =
interform.GetControlAtPoint(pPage, static_cast<FX_FLOAT>(page_x),
static_cast<FX_FLOAT>(page_y), nullptr);
@@ -134,7 +134,7 @@ DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return -1;
- CPDF_InterForm interform(pPage->m_pDocument, FALSE);
+ CPDF_InterForm interform(pPage->m_pDocument);
int z_order = -1;
(void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y,
&z_order);
diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp
index 4e5c9f0065..dbef4a9b67 100644
--- a/fpdfsdk/fsdk_baseform.cpp
+++ b/fpdfsdk/fsdk_baseform.cpp
@@ -1967,24 +1967,20 @@ CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const {
CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
: m_pDocument(pDocument),
- m_pInterForm(NULL),
+ m_pInterForm(new CPDF_InterForm(m_pDocument->GetPDFDocument())),
#ifdef PDF_ENABLE_XFA
m_bXfaCalculate(TRUE),
m_bXfaValidationsEnabled(TRUE),
#endif // PDF_ENABLE_XFA
m_bCalculate(TRUE),
m_bBusy(FALSE) {
- m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE);
m_pInterForm->SetFormNotify(this);
-
for (int i = 0; i < kNumFieldTypes; ++i)
m_bNeedHightlight[i] = FALSE;
m_iHighlightAlpha = 0;
}
CPDFSDK_InterForm::~CPDFSDK_InterForm() {
- delete m_pInterForm;
- m_pInterForm = nullptr;
m_Map.clear();
#ifdef PDF_ENABLE_XFA
m_XFAMap.clear();
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index fa19c75a6b..5e00e16402 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -212,7 +212,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY);
private:
- CPDFSDK_InterForm* m_pInterForm;
+ CPDFSDK_InterForm* const m_pInterForm;
FX_BOOL m_bAppModified;
int32_t m_nAppAge;
int32_t m_nValueAge;
@@ -245,12 +245,12 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot {
};
#endif // PDF_ENABLE_XFA
-class CPDFSDK_InterForm : public CPDF_FormNotify {
+class CPDFSDK_InterForm : public IPDF_FormNotify {
public:
explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument);
~CPDFSDK_InterForm() override;
- CPDF_InterForm* GetInterForm() const { return m_pInterForm; }
+ CPDF_InterForm* GetInterForm() const { return m_pInterForm.get(); }
CPDFSDK_Document* GetDocument() const { return m_pDocument; }
FX_BOOL HighlightWidgets();
@@ -313,7 +313,7 @@ class CPDFSDK_InterForm : public CPDF_FormNotify {
#endif // PDF_ENABLE_XFA
private:
- // CPDF_FormNotify:
+ // IPDF_FormNotify:
int BeforeValueChange(CPDF_FormField* pField,
const CFX_WideString& csValue) override;
void AfterValueChange(CPDF_FormField* pField) override;
@@ -335,7 +335,7 @@ class CPDFSDK_InterForm : public CPDF_FormNotify {
using CPDFSDK_WidgetMap = std::map<CPDF_FormControl*, CPDFSDK_Widget*>;
CPDFSDK_Document* m_pDocument;
- CPDF_InterForm* m_pInterForm;
+ std::unique_ptr<CPDF_InterForm> m_pInterForm;
CPDFSDK_WidgetMap m_Map;
#ifdef PDF_ENABLE_XFA
std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap;