summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fpdfdoc')
-rw-r--r--core/src/fpdfdoc/doc_annot.cpp5
-rw-r--r--core/src/fpdfdoc/doc_ap.cpp30
-rw-r--r--core/src/fpdfdoc/doc_basic.cpp5
-rw-r--r--core/src/fpdfdoc/doc_formfield.cpp17
4 files changed, 33 insertions, 24 deletions
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 227578a974..8952845570 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -165,7 +165,7 @@ void CPDF_Annot::ClearCachedAP()
}
CFX_ByteString CPDF_Annot::GetSubType() const
{
- return m_pAnnotDict->GetConstString(FX_BSTRC("Subtype"));
+ return m_pAnnotDict ? m_pAnnotDict->GetConstString(FX_BSTRC("Subtype")) : CFX_ByteStringC();
}
void CPDF_Annot::GetRect(CPDF_Rect& rect) const
{
@@ -202,7 +202,8 @@ CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::Appeara
if (as.IsEmpty()) {
CFX_ByteString value = pAnnotDict->GetString(FX_BSTRC("V"));
if (value.IsEmpty()) {
- value = pAnnotDict->GetDict(FX_BSTRC("Parent"))->GetString(FX_BSTRC("V"));
+ CPDF_Dictionary* pDict = pAnnotDict->GetDict(FX_BSTRC("Parent"));
+ value = pDict ? pDict->GetString(FX_BSTRC("V")) : CFX_ByteString();
}
if (value.IsEmpty() || !((CPDF_Dictionary*)psub)->KeyExist(value)) {
as = FX_BSTRC("Off");
diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp
index 784d89daed..6a8ab374d2 100644
--- a/core/src/fpdfdoc/doc_ap.cpp
+++ b/core/src/fpdfdoc/doc_ap.cpp
@@ -10,11 +10,11 @@
#include "../../include/fpdfdoc/fpdf_ap.h"
FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
{
- if (pAnnotDict->GetConstString("Subtype") != FX_BSTRC("Widget")) {
+ if (!pAnnotDict || pAnnotDict->GetConstString("Subtype") != FX_BSTRC("Widget")) {
return FALSE;
}
CFX_ByteString field_type = FPDF_GetFieldAttr(pAnnotDict, "FT")->GetString();
- FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger();
+ FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0;
if (field_type == "Tx") {
return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict);
} else if (field_type == "Ch") {
@@ -253,7 +253,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
if (!pFormDict) {
return FALSE;
}
- CFX_ByteString DA = FPDF_GetFieldAttr(pAnnotDict, "DA")->GetString();
+ CFX_ByteString DA = FPDF_GetFieldAttr(pAnnotDict, "DA") ? FPDF_GetFieldAttr(pAnnotDict, "DA")->GetString() : CFX_ByteString();
if (DA.IsEmpty()) {
DA = pFormDict->GetString("DA");
}
@@ -277,7 +277,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
bUseFormRes = TRUE;
}
CPDF_Dictionary * pDRFontDict = NULL;
- if ((pDRFontDict = pDRDict->GetDict("Font"))) {
+ if (pDRDict && (pDRFontDict = pDRDict->GetDict("Font"))) {
pFontDict = pDRFontDict->GetDict(sFontName.Mid(1));
if (!pFontDict && !bUseFormRes) {
pDRDict = pFormDict->GetDict(FX_BSTRC("DR"));
@@ -430,11 +430,11 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
}
switch (nWidgetType) {
case 0: {
- CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText();
- FX_INT32 nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")->GetInteger();
- FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger();
- FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger();
- CPVT_FontMap map(pDoc, pStreamDict->GetDict("Resources"), pDefFont, sFontName.Right(sFontName.GetLength() - 1));
+ CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString();
+ FX_INT32 nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")? FPDF_GetFieldAttr(pAnnotDict, "Q")->GetInteger() : 0;
+ FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0;
+ FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen") ? FPDF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger() : 0;
+ CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resources") : NULL , pDefFont, sFontName.Right(sFontName.GetLength() - 1));
CPVT_Provider prd(&map);
CPDF_VariableText vt;
vt.SetProvider(&prd);
@@ -482,8 +482,8 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
}
break;
case 1: {
- CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText();
- CPVT_FontMap map(pDoc, pStreamDict->GetDict("Resources"), pDefFont, sFontName.Right(sFontName.GetLength() - 1));
+ CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V") ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString();
+ CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resources"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1));
CPVT_Provider prd(&map);
CPDF_VariableText vt;
vt.SetProvider(&prd);
@@ -534,11 +534,11 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
}
break;
case 2: {
- CPVT_FontMap map(pDoc, pStreamDict->GetDict("Resources"), pDefFont, sFontName.Right(sFontName.GetLength() - 1));
+ CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resources"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1));
CPVT_Provider prd(&map);
- CPDF_Array * pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt")->GetArray();
- CPDF_Array * pSels = FPDF_GetFieldAttr(pAnnotDict, "I")->GetArray();
- FX_INT32 nTop = FPDF_GetFieldAttr(pAnnotDict, "TI")->GetInteger();
+ CPDF_Array * pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt") ? FPDF_GetFieldAttr(pAnnotDict, "Opt")->GetArray() : NULL;
+ CPDF_Array * pSels = FPDF_GetFieldAttr(pAnnotDict, "I") ? FPDF_GetFieldAttr(pAnnotDict, "I")->GetArray() : NULL;
+ FX_INT32 nTop = FPDF_GetFieldAttr(pAnnotDict, "TI") ? FPDF_GetFieldAttr(pAnnotDict, "TI")->GetInteger() : 0;
CFX_ByteTextBuf sBody;
if (pOpts) {
FX_FLOAT fy = rcBody.top;
diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp
index 199a9a6dec..25f641c52e 100644
--- a/core/src/fpdfdoc/doc_basic.cpp
+++ b/core/src/fpdfdoc/doc_basic.cpp
@@ -72,7 +72,10 @@ CFX_ByteString CPDF_Dest::GetRemoteName()
}
CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc, FX_BSTR category)
{
- m_pRoot = pDoc->GetRoot()->GetDict(FX_BSTRC("Names"))->GetDict(category);
+ if (pDoc->GetRoot() && pDoc->GetRoot()->GetDict(FX_BSTRC("Names")))
+ m_pRoot = pDoc->GetRoot()->GetDict(FX_BSTRC("Names"))->GetDict(category);
+ else
+ m_pRoot = NULL;
}
static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, const CFX_ByteString& csName,
int& nIndex, CPDF_Array** ppFind, int nLevel = 0)
diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp
index 548448696d..e51acf94a1 100644
--- a/core/src/fpdfdoc/doc_formfield.cpp
+++ b/core/src/fpdfdoc/doc_formfield.cpp
@@ -32,8 +32,8 @@ CPDF_FormField::~CPDF_FormField()
}
void CPDF_FormField::SyncFieldFlags()
{
- CFX_ByteString type_name = FPDF_GetFieldAttr(m_pDict, "FT")->GetString();
- FX_DWORD flags = FPDF_GetFieldAttr(m_pDict, "Ff")->GetInteger();
+ CFX_ByteString type_name = FPDF_GetFieldAttr(m_pDict, "FT") ? FPDF_GetFieldAttr(m_pDict, "FT")->GetString() : CFX_ByteString();
+ FX_DWORD flags = FPDF_GetFieldAttr(m_pDict, "Ff")? FPDF_GetFieldAttr(m_pDict, "Ff")->GetInteger() : 0;
m_Flags = 0;
if (flags & 1) {
m_Flags |= FORMFIELD_READONLY;
@@ -485,7 +485,8 @@ int CPDF_FormField::GetSelectedIndex(int index)
if (index < 0) {
return -1;
}
- sel_value = ((CPDF_Array*)pValue)->GetElementValue(index)->GetUnicodeText();
+ CPDF_Object* elementValue = ((CPDF_Array*)pValue)->GetElementValue(index);
+ sel_value = elementValue ? elementValue->GetUnicodeText() : CFX_WideString();
}
if (index < CountSelectedOptions()) {
int iOptIndex = GetSelectedOptionIndex(index);
@@ -1076,9 +1077,9 @@ FX_BOOL CPDF_FormField::ClearSelectedOptions(FX_BOOL bNotify)
}
void CPDF_FormField::LoadDA()
{
- CFX_ByteString DA = FPDF_GetFieldAttr(m_pDict, "DA")->GetString();
+ CFX_ByteString DA = FPDF_GetFieldAttr(m_pDict, "DA") ? FPDF_GetFieldAttr(m_pDict, "DA")->GetString() : CFX_ByteString();
if (DA.IsEmpty()) {
- DA = m_pForm->m_pFormDict->GetString("DA");
+ DA = m_pForm->m_pFormDict ? m_pForm->m_pFormDict->GetString("DA") : CFX_ByteString();
}
if (DA.IsEmpty()) {
return;
@@ -1086,7 +1087,11 @@ void CPDF_FormField::LoadDA()
CPDF_SimpleParser syntax(DA);
syntax.FindTagParam("Tf", 2);
CFX_ByteString font_name = syntax.GetWord();
- CPDF_Dictionary* pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict(font_name);
+ CPDF_Dictionary* pFontDict = NULL;
+ if (m_pForm->m_pFormDict && m_pForm->m_pFormDict->GetDict("DR") &&
+ m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font") )
+ pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict(font_name);
+
if (pFontDict == NULL) {
return;
}