summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fsdk_baseannot.h16
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp14
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp28
3 files changed, 21 insertions, 37 deletions
diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h
index 58abfff49e..1cd29b1f87 100644
--- a/fpdfsdk/include/fsdk_baseannot.h
+++ b/fpdfsdk/include/fsdk_baseannot.h
@@ -68,8 +68,8 @@ class CPDFSDK_DateTime {
class CPDFSDK_Annot {
public:
- CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
- virtual ~CPDFSDK_Annot(){};
+ explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
+ virtual ~CPDFSDK_Annot() {}
virtual FX_BOOL IsXFAField() { return FALSE; }
@@ -106,7 +106,6 @@ class CPDFSDK_Annot {
void SetSelected(FX_BOOL bSelected);
protected:
- CPDF_Annot* m_pAnnot;
CPDFSDK_PageView* m_pPageView;
FX_BOOL m_bSelected;
int m_nTabOrder;
@@ -115,9 +114,8 @@ class CPDFSDK_Annot {
class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
public:
CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
- virtual ~CPDFSDK_BAAnnot();
+ virtual ~CPDFSDK_BAAnnot() {}
- public:
virtual FX_BOOL IsXFAField();
virtual CFX_ByteString GetType() const;
@@ -132,7 +130,6 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
CPDF_Matrix* pUser2Device,
CPDF_RenderOptions* pOptions);
- public:
CPDF_Dictionary* GetAnnotDict() const;
void SetContents(const CFX_WideString& sContents);
@@ -190,7 +187,6 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
- public:
virtual FX_BOOL IsAppearanceValid();
virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
virtual void DrawAppearance(CFX_RenderDevice* pDevice,
@@ -209,11 +205,11 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
const CFX_ByteString& sContents,
const CFX_ByteString& sAPState = "");
- private:
- FX_BOOL CreateFormFiller();
-
protected:
CPDF_Annot* m_pAnnot;
+
+ private:
+ FX_BOOL CreateFormFiller();
};
#endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_
diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
index e0c49411a9..bdfda15453 100644
--- a/fpdfsdk/src/fsdk_annothandler.cpp
+++ b/fpdfsdk/src/fsdk_annothandler.cpp
@@ -137,14 +137,15 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
FX_DWORD dwFlags) {
- ASSERT(pAnnot != NULL);
+ ASSERT(pAnnot);
if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
} else {
- if (!pAnnot->IsXFAField())
- ((CPDFSDK_BAAnnot*)pAnnot)
- ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ if (!pAnnot->IsXFAField()) {
+ static_cast<CPDFSDK_BAAnnot*>(pAnnot)
+ ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
+ }
}
}
@@ -449,12 +450,11 @@ void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
FX_DWORD dwFlags) {
- ASSERT(pAnnot != NULL);
CFX_ByteString sSubType = pAnnot->GetSubType();
if (sSubType == BFFT_SIGNATURE) {
- ((CPDFSDK_BAAnnot*)pAnnot)
- ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ static_cast<CPDFSDK_BAAnnot*>(pAnnot)
+ ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
} else {
if (m_pFormFiller) {
m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 1c96936f03..45f359a9d2 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -9,9 +9,6 @@
#include "../include/fsdk_mgr.h"
#include "../include/fsdk_baseannot.h"
-//---------------------------------------------------------------------------
-// CPDFSDK_DateTime
-//---------------------------------------------------------------------------
int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) {
return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60);
}
@@ -503,19 +500,13 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds) {
return *this;
}
-//---------------------------------------------------------------------------
-// CPDFSDK_Annot
-//---------------------------------------------------------------------------
CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView)
- : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {}
+ : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {
+}
-// CPDFSDK_BAAnnot
CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPageView)
- : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) {}
-
-CPDFSDK_BAAnnot::~CPDFSDK_BAAnnot() {
- m_pAnnot = NULL;
+ : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) {
}
CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const {
@@ -867,8 +858,8 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
}
- CPDF_Stream* pStream = NULL;
- CPDF_Dictionary* pParentDict = NULL;
+ CPDF_Stream* pStream = nullptr;
+ CPDF_Dictionary* pParentDict = nullptr;
if (sAPState.IsEmpty()) {
pParentDict = pAPDict;
@@ -885,11 +876,9 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
}
if (!pStream) {
- ASSERT(m_pPageView != NULL);
- CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- ASSERT(pDoc != NULL);
+ pStream = new CPDF_Stream(nullptr, 0, nullptr);
- pStream = new CPDF_Stream(NULL, 0, NULL);
+ CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
int32_t objnum = pDoc->AddIndirectObject(pStream);
// pAPDict->SetAtReference(sAPType, pDoc, objnum);
ASSERT(pParentDict != NULL);
@@ -897,13 +886,12 @@ void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
-
if (!pStreamDict) {
pStreamDict = new CPDF_Dictionary;
pStreamDict->SetAtName("Type", "XObject");
pStreamDict->SetAtName("Subtype", "Form");
pStreamDict->SetAtInteger("FormType", 1);
- pStream->InitStream(NULL, 0, pStreamDict);
+ pStream->InitStream(nullptr, 0, pStreamDict);
}
if (pStreamDict) {