summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fsdk_baseannot.h73
-rw-r--r--fpdfsdk/include/fsdk_baseform.h6
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp14
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp141
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp15
5 files changed, 133 insertions, 116 deletions
diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h
index bfeebeb9f3..063ffa078e 100644
--- a/fpdfsdk/include/fsdk_baseannot.h
+++ b/fpdfsdk/include/fsdk_baseannot.h
@@ -68,21 +68,30 @@ class CPDFSDK_DateTime {
class CPDFSDK_Annot {
public:
- CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
- virtual ~CPDFSDK_Annot();
+ CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
+ virtual ~CPDFSDK_Annot(){};
- public:
virtual FX_FLOAT GetMinWidth() const;
virtual FX_FLOAT GetMinHeight() const;
// define layout order to 5.
virtual int GetLayoutOrder() const { return 5; }
- public:
- CPDF_Annot* GetPDFAnnot();
+ virtual CPDF_Annot* GetPDFAnnot() const { return nullptr; }
+
+ virtual CFX_ByteString GetType() const { return ""; }
+ virtual CFX_ByteString GetSubType() const { return ""; }
+
+ virtual void SetRect(const CPDF_Rect& rect) {}
+ virtual CPDF_Rect GetRect() const { return CPDF_Rect(); }
+
+ virtual void Annot_OnDraw(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device,
+ CPDF_RenderOptions* pOptions) {}
+
+ CPDF_Page* GetPDFPage();
- void SetPage(CPDFSDK_PageView* pPageView);
- CPDFSDK_PageView* GetPageView();
- FX_DWORD GetFlags();
+ void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; }
+ CPDFSDK_PageView* GetPageView() const { return m_pPageView; }
// Tab Order
int GetTabOrder();
@@ -92,17 +101,34 @@ class CPDFSDK_Annot {
FX_BOOL IsSelected();
void SetSelected(FX_BOOL bSelected);
- CFX_ByteString GetType() const;
+ protected:
+ CPDF_Annot* m_pAnnot;
+ CPDFSDK_PageView* m_pPageView;
+ FX_BOOL m_bSelected;
+ int m_nTabOrder;
+};
+
+class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
+ public:
+ CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
+ virtual ~CPDFSDK_BAAnnot();
+
+ public:
+ virtual CFX_ByteString GetType() const;
virtual CFX_ByteString GetSubType() const;
- CPDF_Page* GetPDFPage();
+ virtual void SetRect(const CPDF_Rect& rect);
+ virtual CPDF_Rect GetRect() const;
+
+ virtual CPDF_Annot* GetPDFAnnot() const;
+
+ virtual void Annot_OnDraw(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device,
+ CPDF_RenderOptions* pOptions);
public:
CPDF_Dictionary* GetAnnotDict() const;
- void SetRect(const CPDF_Rect& rect);
- CPDF_Rect GetRect() const;
-
void SetContents(const CFX_WideString& sContents);
CFX_WideString GetContents() const;
@@ -159,12 +185,12 @@ class CPDFSDK_Annot {
virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
public:
- FX_BOOL IsAppearanceValid();
- FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
- void DrawAppearance(CFX_RenderDevice* pDevice,
- const CPDF_Matrix* pUser2Device,
- CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions);
+ virtual FX_BOOL IsAppearanceValid();
+ virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
+ virtual void DrawAppearance(CFX_RenderDevice* pDevice,
+ const CPDF_Matrix* pUser2Device,
+ CPDF_Annot::AppearanceMode mode,
+ const CPDF_RenderOptions* pOptions);
void DrawBorder(CFX_RenderDevice* pDevice,
const CPDF_Matrix* pUser2Device,
const CPDF_RenderOptions* pOptions);
@@ -177,20 +203,11 @@ class CPDFSDK_Annot {
const CFX_ByteString& sContents,
const CFX_ByteString& sAPState = "");
- public:
- virtual void Annot_OnDraw(CFX_RenderDevice* pDevice,
- CPDF_Matrix* pUser2Device,
- CPDF_RenderOptions* pOptions);
-
- public:
private:
FX_BOOL CreateFormFiller();
protected:
CPDF_Annot* m_pAnnot;
- CPDFSDK_PageView* m_pPageView;
- FX_BOOL m_bSelected;
- int m_nTabOrder;
};
#endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index f402aae76f..b356d255fe 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -57,7 +57,7 @@ typedef struct _PDFSDK_FieldAction {
FX_BOOL bRC; // in[out]
} PDFSDK_FieldAction;
-class CPDFSDK_Widget : public CPDFSDK_Annot {
+class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
public:
CPDFSDK_Widget(CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPageView,
@@ -67,6 +67,7 @@ class CPDFSDK_Widget : public CPDFSDK_Annot {
// CPDFSDK_Annot
CFX_ByteString GetSubType() const override;
CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override;
+ FX_BOOL IsAppearanceValid() override;
int GetLayoutOrder() const override { return 2; }
@@ -161,9 +162,8 @@ class CPDFSDK_Widget : public CPDFSDK_Annot {
void DrawAppearance(CFX_RenderDevice* pDevice,
const CPDF_Matrix* pUser2Device,
CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions);
+ const CPDF_RenderOptions* pOptions) override;
- public:
FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY);
private:
diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
index b1b2e2cc76..d6a2c00bd6 100644
--- a/fpdfsdk/src/fsdk_annothandler.cpp
+++ b/fpdfsdk/src/fsdk_annothandler.cpp
@@ -57,7 +57,7 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot,
return pAnnotHandler->NewAnnot(pAnnot, pPageView);
}
- return new CPDFSDK_Annot(pAnnot, pPageView);
+ return new CPDFSDK_BAAnnot(pAnnot, pPageView);
}
void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
@@ -100,9 +100,9 @@ IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
ASSERT(pAnnot != NULL);
CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
- ASSERT(pPDFAnnot != NULL);
-
- return GetAnnotHandler(pPDFAnnot->GetSubType());
+ if (pPDFAnnot)
+ return GetAnnotHandler(pPDFAnnot->GetSubType());
+ return nullptr;
}
IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
@@ -121,7 +121,8 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
} else {
- pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ ((CPDFSDK_BAAnnot*)pAnnot)
+ ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
}
}
@@ -384,7 +385,8 @@ void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
CFX_ByteString sSubType = pAnnot->GetSubType();
if (sSubType == BFFT_SIGNATURE) {
- pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
+ ((CPDFSDK_BAAnnot*)pAnnot)
+ ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
} 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 c6731e6f56..e9ef0fb2b6 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -505,33 +505,22 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::AddSeconds(int seconds) {
//---------------------------------------------------------------------------
// CPDFSDK_Annot
//---------------------------------------------------------------------------
-CPDFSDK_Annot::CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView)
- : m_pAnnot(pAnnot),
- m_pPageView(pPageView),
- m_bSelected(FALSE),
- m_nTabOrder(-1) {}
-
-CPDFSDK_Annot::~CPDFSDK_Annot() {
- m_pAnnot = NULL;
- m_pPageView = NULL;
+CPDFSDK_Annot::CPDFSDK_Annot(CPDFSDK_PageView* pPageView)
+ : m_pPageView(pPageView), m_bSelected(FALSE), m_nTabOrder(-1) {
}
-CPDF_Annot* CPDFSDK_Annot::GetPDFAnnot() {
- return m_pAnnot;
+// CPDFSDK_BAAnnot
+CPDFSDK_BAAnnot::CPDFSDK_BAAnnot(CPDF_Annot* pAnnot,
+ CPDFSDK_PageView* pPageView)
+ : CPDFSDK_Annot(pPageView), m_pAnnot(pAnnot) {
}
-FX_DWORD CPDFSDK_Annot::GetFlags() {
- ASSERT(m_pAnnot != NULL);
-
- return m_pAnnot->GetFlags();
-}
-
-void CPDFSDK_Annot::SetPage(CPDFSDK_PageView* pPageView) {
- m_pPageView = pPageView;
+CPDFSDK_BAAnnot::~CPDFSDK_BAAnnot() {
+ m_pAnnot = NULL;
}
-CPDFSDK_PageView* CPDFSDK_Annot::GetPageView() {
- return m_pPageView;
+CPDF_Annot* CPDFSDK_BAAnnot::GetPDFAnnot() const {
+ return m_pAnnot;
}
FX_BOOL CPDFSDK_Annot::IsSelected() {
@@ -551,20 +540,20 @@ void CPDFSDK_Annot::SetTabOrder(int iTabOrder) {
m_nTabOrder = iTabOrder;
}
-CPDF_Dictionary* CPDFSDK_Annot::GetAnnotDict() const {
+CPDF_Dictionary* CPDFSDK_BAAnnot::GetAnnotDict() const {
ASSERT(m_pAnnot != NULL);
return m_pAnnot->GetAnnotDict();
}
-void CPDFSDK_Annot::SetRect(const CPDF_Rect& rect) {
+void CPDFSDK_BAAnnot::SetRect(const CPDF_Rect& rect) {
ASSERT(rect.right - rect.left >= GetMinWidth());
ASSERT(rect.top - rect.bottom >= GetMinHeight());
m_pAnnot->GetAnnotDict()->SetAtRect("Rect", rect);
}
-CPDF_Rect CPDFSDK_Annot::GetRect() const {
+CPDF_Rect CPDFSDK_BAAnnot::GetRect() const {
ASSERT(m_pAnnot != NULL);
CPDF_Rect rect;
@@ -573,20 +562,20 @@ CPDF_Rect CPDFSDK_Annot::GetRect() const {
return rect;
}
-CFX_ByteString CPDFSDK_Annot::GetType() const {
+CFX_ByteString CPDFSDK_BAAnnot::GetType() const {
ASSERT(m_pAnnot != NULL);
return m_pAnnot->GetSubType();
}
-CFX_ByteString CPDFSDK_Annot::GetSubType() const {
+CFX_ByteString CPDFSDK_BAAnnot::GetSubType() const {
return "";
}
-void CPDFSDK_Annot::DrawAppearance(CFX_RenderDevice* pDevice,
- const CPDF_Matrix* pUser2Device,
- CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions) {
+void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice,
+ const CPDF_Matrix* pUser2Device,
+ CPDF_Annot::AppearanceMode mode,
+ const CPDF_RenderOptions* pOptions) {
ASSERT(m_pPageView != NULL);
ASSERT(m_pAnnot != NULL);
@@ -594,11 +583,11 @@ void CPDFSDK_Annot::DrawAppearance(CFX_RenderDevice* pDevice,
mode, pOptions);
}
-FX_BOOL CPDFSDK_Annot::IsAppearanceValid() {
+FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid() {
return m_pAnnot->GetAnnotDict()->GetDict("AP") != NULL;
}
-FX_BOOL CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) {
+FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) {
CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
if (pAP == NULL)
return FALSE;
@@ -620,19 +609,19 @@ FX_BOOL CPDFSDK_Annot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) {
return TRUE;
}
-void CPDFSDK_Annot::DrawBorder(CFX_RenderDevice* pDevice,
- const CPDF_Matrix* pUser2Device,
- const CPDF_RenderOptions* pOptions) {
+void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice,
+ const CPDF_Matrix* pUser2Device,
+ const CPDF_RenderOptions* pOptions) {
ASSERT(m_pAnnot != NULL);
m_pAnnot->DrawBorder(pDevice, pUser2Device, pOptions);
}
-void CPDFSDK_Annot::ClearCachedAP() {
+void CPDFSDK_BAAnnot::ClearCachedAP() {
ASSERT(m_pAnnot != NULL);
m_pAnnot->ClearCachedAP();
}
-void CPDFSDK_Annot::SetContents(const CFX_WideString& sContents) {
+void CPDFSDK_BAAnnot::SetContents(const CFX_WideString& sContents) {
if (sContents.IsEmpty())
m_pAnnot->GetAnnotDict()->RemoveAt("Contents");
else
@@ -640,22 +629,22 @@ void CPDFSDK_Annot::SetContents(const CFX_WideString& sContents) {
PDF_EncodeText(sContents));
}
-CFX_WideString CPDFSDK_Annot::GetContents() const {
+CFX_WideString CPDFSDK_BAAnnot::GetContents() const {
return m_pAnnot->GetAnnotDict()->GetUnicodeText("Contents");
}
-void CPDFSDK_Annot::SetAnnotName(const CFX_WideString& sName) {
+void CPDFSDK_BAAnnot::SetAnnotName(const CFX_WideString& sName) {
if (sName.IsEmpty())
m_pAnnot->GetAnnotDict()->RemoveAt("NM");
else
m_pAnnot->GetAnnotDict()->SetAtString("NM", PDF_EncodeText(sName));
}
-CFX_WideString CPDFSDK_Annot::GetAnnotName() const {
+CFX_WideString CPDFSDK_BAAnnot::GetAnnotName() const {
return m_pAnnot->GetAnnotDict()->GetUnicodeText("NM");
}
-void CPDFSDK_Annot::SetModifiedDate(const FX_SYSTEMTIME& st) {
+void CPDFSDK_BAAnnot::SetModifiedDate(const FX_SYSTEMTIME& st) {
CPDFSDK_DateTime dt(st);
CFX_ByteString str = dt.ToPDFDateTimeString();
@@ -665,7 +654,7 @@ void CPDFSDK_Annot::SetModifiedDate(const FX_SYSTEMTIME& st) {
m_pAnnot->GetAnnotDict()->SetAtString("M", str);
}
-FX_SYSTEMTIME CPDFSDK_Annot::GetModifiedDate() const {
+FX_SYSTEMTIME CPDFSDK_BAAnnot::GetModifiedDate() const {
FX_SYSTEMTIME systime;
CFX_ByteString str = m_pAnnot->GetAnnotDict()->GetString("M");
@@ -675,35 +664,35 @@ FX_SYSTEMTIME CPDFSDK_Annot::GetModifiedDate() const {
return systime;
}
-void CPDFSDK_Annot::SetFlags(int nFlags) {
+void CPDFSDK_BAAnnot::SetFlags(int nFlags) {
m_pAnnot->GetAnnotDict()->SetAtInteger("F", nFlags);
}
-int CPDFSDK_Annot::GetFlags() const {
+int CPDFSDK_BAAnnot::GetFlags() const {
return m_pAnnot->GetAnnotDict()->GetInteger("F");
}
-void CPDFSDK_Annot::SetAppState(const CFX_ByteString& str) {
+void CPDFSDK_BAAnnot::SetAppState(const CFX_ByteString& str) {
if (str.IsEmpty())
m_pAnnot->GetAnnotDict()->RemoveAt("AS");
else
m_pAnnot->GetAnnotDict()->SetAtString("AS", str);
}
-CFX_ByteString CPDFSDK_Annot::GetAppState() const {
+CFX_ByteString CPDFSDK_BAAnnot::GetAppState() const {
return m_pAnnot->GetAnnotDict()->GetString("AS");
}
-void CPDFSDK_Annot::SetStructParent(int key) {
+void CPDFSDK_BAAnnot::SetStructParent(int key) {
m_pAnnot->GetAnnotDict()->SetAtInteger("StructParent", key);
}
-int CPDFSDK_Annot::GetStructParent() const {
+int CPDFSDK_BAAnnot::GetStructParent() const {
return m_pAnnot->GetAnnotDict()->GetInteger("StructParent");
}
// border
-void CPDFSDK_Annot::SetBorderWidth(int nWidth) {
+void CPDFSDK_BAAnnot::SetBorderWidth(int nWidth) {
CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
if (pBorder) {
@@ -720,7 +709,7 @@ void CPDFSDK_Annot::SetBorderWidth(int nWidth) {
}
}
-int CPDFSDK_Annot::GetBorderWidth() const {
+int CPDFSDK_BAAnnot::GetBorderWidth() const {
if (CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border")) {
return pBorder->GetInteger(2);
}
@@ -730,7 +719,7 @@ int CPDFSDK_Annot::GetBorderWidth() const {
return 1;
}
-void CPDFSDK_Annot::SetBorderStyle(int nStyle) {
+void CPDFSDK_BAAnnot::SetBorderStyle(int nStyle) {
CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (!pBSDict) {
pBSDict = new CPDF_Dictionary;
@@ -756,7 +745,7 @@ void CPDFSDK_Annot::SetBorderStyle(int nStyle) {
}
}
-int CPDFSDK_Annot::GetBorderStyle() const {
+int CPDFSDK_BAAnnot::GetBorderStyle() const {
CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (pBSDict) {
CFX_ByteString sBorderStyle = pBSDict->GetString("S", "S");
@@ -784,7 +773,7 @@ int CPDFSDK_Annot::GetBorderStyle() const {
return BBS_SOLID;
}
-void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array) {
+void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array) {
CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDict("BS");
if (!pBSDict) {
pBSDict = new CPDF_Dictionary;
@@ -799,7 +788,7 @@ void CPDFSDK_Annot::SetBorderDash(const CFX_IntArray& array) {
pBSDict->SetAt("D", pArray);
}
-void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const {
+void CPDFSDK_BAAnnot::GetBorderDash(CFX_IntArray& array) const {
CPDF_Array* pDash = NULL;
CPDF_Array* pBorder = m_pAnnot->GetAnnotDict()->GetArray("Border");
@@ -819,7 +808,7 @@ void CPDFSDK_Annot::GetBorderDash(CFX_IntArray& array) const {
}
}
-void CPDFSDK_Annot::SetColor(FX_COLORREF color) {
+void CPDFSDK_BAAnnot::SetColor(FX_COLORREF color) {
CPDF_Array* pArray = new CPDF_Array;
pArray->AddNumber((FX_FLOAT)FXSYS_GetRValue(color) / 255.0f);
pArray->AddNumber((FX_FLOAT)FXSYS_GetGValue(color) / 255.0f);
@@ -827,11 +816,11 @@ void CPDFSDK_Annot::SetColor(FX_COLORREF color) {
m_pAnnot->GetAnnotDict()->SetAt("C", pArray);
}
-void CPDFSDK_Annot::RemoveColor() {
+void CPDFSDK_BAAnnot::RemoveColor() {
m_pAnnot->GetAnnotDict()->RemoveAt("C");
}
-FX_BOOL CPDFSDK_Annot::GetColor(FX_COLORREF& color) const {
+FX_BOOL CPDFSDK_BAAnnot::GetColor(FX_COLORREF& color) const {
if (CPDF_Array* pEntry = m_pAnnot->GetAnnotDict()->GetArray("C")) {
int nCount = pEntry->GetCount();
if (nCount == 1) {
@@ -867,11 +856,11 @@ FX_BOOL CPDFSDK_Annot::GetColor(FX_COLORREF& color) const {
return FALSE;
}
-void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType,
- const CPDF_Rect& rcBBox,
- const CPDF_Matrix& matrix,
- const CFX_ByteString& sContents,
- const CFX_ByteString& sAPState) {
+void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
+ const CPDF_Rect& rcBBox,
+ const CPDF_Matrix& matrix,
+ const CFX_ByteString& sContents,
+ const CFX_ByteString& sAPState) {
CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDict("AP");
if (!pAPDict) {
@@ -897,13 +886,17 @@ void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType,
}
if (!pStream) {
+ ASSERT(m_pPageView != NULL);
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
+ ASSERT(pDoc != NULL);
+
pStream = new CPDF_Stream(NULL, 0, NULL);
int32_t objnum = pDoc->AddIndirectObject(pStream);
pParentDict->SetAtReference(sAPType, pDoc, objnum);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
+
if (!pStreamDict) {
pStreamDict = new CPDF_Dictionary;
pStreamDict->SetAtName("Type", "XObject");
@@ -932,20 +925,20 @@ FX_FLOAT CPDFSDK_Annot::GetMinHeight() const {
return BA_ANNOT_MINHEIGHT;
}
-FX_BOOL CPDFSDK_Annot::CreateFormFiller() {
+FX_BOOL CPDFSDK_BAAnnot::CreateFormFiller() {
return TRUE;
}
-FX_BOOL CPDFSDK_Annot::IsVisible() const {
+FX_BOOL CPDFSDK_BAAnnot::IsVisible() const {
int nFlags = GetFlags();
return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) ||
(nFlags & ANNOTFLAG_NOVIEW));
}
-CPDF_Action CPDFSDK_Annot::GetAction() const {
+CPDF_Action CPDFSDK_BAAnnot::GetAction() const {
return CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A"));
}
-void CPDFSDK_Annot::SetAction(const CPDF_Action& action) {
+void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
ASSERT(action);
if ((CPDF_Action&)action !=
CPDF_Action(m_pAnnot->GetAnnotDict()->GetDict("A"))) {
@@ -958,26 +951,26 @@ void CPDFSDK_Annot::SetAction(const CPDF_Action& action) {
}
}
-void CPDFSDK_Annot::RemoveAction() {
+void CPDFSDK_BAAnnot::RemoveAction() {
m_pAnnot->GetAnnotDict()->RemoveAt("A");
}
-CPDF_AAction CPDFSDK_Annot::GetAAction() const {
+CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
return m_pAnnot->GetAnnotDict()->GetDict("AA");
}
-void CPDFSDK_Annot::SetAAction(const CPDF_AAction& aa) {
+void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) {
ASSERT(aa != NULL);
if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDict("AA"))
m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
}
-void CPDFSDK_Annot::RemoveAAction() {
+void CPDFSDK_BAAnnot::RemoveAAction() {
m_pAnnot->GetAnnotDict()->RemoveAt("AA");
}
-CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT) {
+CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) {
CPDF_AAction AAction = GetAAction();
if (AAction.ActionExist(eAAT))
@@ -989,9 +982,9 @@ CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT) {
return CPDF_Action();
}
-void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice,
- CPDF_Matrix* pUser2Device,
- CPDF_RenderOptions* pOptions) {
+void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device,
+ CPDF_RenderOptions* pOptions) {
m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal);
m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device,
CPDF_Annot::Normal, NULL);
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index e3536e0a19..9a20e48e84 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -26,7 +26,7 @@
CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPageView,
CPDFSDK_InterForm* pInterForm)
- : CPDFSDK_Annot(pAnnot, pPageView),
+ : CPDFSDK_BAAnnot(pAnnot, pPageView),
m_pInterForm(pInterForm),
m_nAppAge(0),
m_nValueAge(0) {
@@ -80,6 +80,12 @@ int CPDFSDK_Widget::GetFieldType() const {
return pField->GetFieldType();
}
+FX_BOOL CPDFSDK_Widget::IsAppearanceValid() {
+ ASSERT(m_pPageView != NULL);
+
+ return CPDFSDK_BAAnnot::IsAppearanceValid();
+}
+
int CPDFSDK_Widget::GetFieldFlags() const {
CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm();
ASSERT(pPDFInterForm != NULL);
@@ -356,7 +362,7 @@ void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice,
pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA,
FXFILL_ALTERNATE);
} else {
- CPDFSDK_Annot::DrawAppearance(pDevice, pUser2Device, mode, pOptions);
+ CPDFSDK_BAAnnot::DrawAppearance(pDevice, pUser2Device, mode, pOptions);
}
}
@@ -1462,7 +1468,7 @@ CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) {
case CPDF_AAction::PageClose:
case CPDF_AAction::PageVisible:
case CPDF_AAction::PageInvisible:
- return CPDFSDK_Annot::GetAAction(eAAT);
+ return CPDFSDK_BAAnnot::GetAAction(eAAT);
case CPDF_AAction::KeyStroke:
case CPDF_AAction::Format:
@@ -1471,8 +1477,7 @@ CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) {
CPDF_FormField* pField = GetFormField();
if (CPDF_AAction aa = pField->GetAdditionalAction())
return aa.GetAction(eAAT);
-
- return CPDFSDK_Annot::GetAAction(eAAT);
+ return CPDFSDK_BAAnnot::GetAAction(eAAT);
}
default:
break;