summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-03-01 16:29:41 -0800
committerWei Li <weili@chromium.org>2016-03-01 16:29:41 -0800
commit0fc6b25e738c311fd66aa9da8c56de50af5644d5 (patch)
treee148556274b450ae125e2821debebb472f1ba8ee /fpdfsdk
parent738b08ce6b9f80d93b815411b47c2b11c2f090f6 (diff)
downloadpdfium-0fc6b25e738c311fd66aa9da8c56de50af5644d5.tar.xz
Remove implicit conversions and some cleanup
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1751753002 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp18
-rw-r--r--fpdfsdk/src/fpdfdoc.cpp13
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp4
-rw-r--r--fpdfsdk/src/fsdk_actionhandler.cpp6
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp11
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp33
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Icon.cpp2
7 files changed, 44 insertions, 43 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index 21a4bb6ab2..2cad12b4e8 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -128,7 +128,7 @@ void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView,
if (!m_bNotifying) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorEnter)) {
+ if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) {
m_bNotifying = TRUE;
int nValueAge = pWidget->GetValueAge();
@@ -164,7 +164,7 @@ void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
if (!m_bNotifying) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::CursorExit)) {
+ if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) {
m_bNotifying = TRUE;
pWidget->GetAppearanceAge();
int nValueAge = pWidget->GetValueAge();
@@ -202,7 +202,7 @@ FX_BOOL CFFL_IFormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView,
if (!m_bNotifying) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
if (Annot_HitTest(pPageView, pAnnot, point) &&
- pWidget->GetAAction(CPDF_AAction::ButtonDown)) {
+ pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) {
m_bNotifying = TRUE;
pWidget->GetAppearanceAge();
int nValueAge = pWidget->GetValueAge();
@@ -284,7 +284,7 @@ void CFFL_IFormFiller::OnButtonUp(CPDFSDK_Widget* pWidget,
ASSERT(pWidget);
if (!m_bNotifying) {
- if (pWidget->GetAAction(CPDF_AAction::ButtonUp)) {
+ if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) {
m_bNotifying = TRUE;
int nAge = pWidget->GetAppearanceAge();
int nValueAge = pWidget->GetValueAge();
@@ -415,7 +415,7 @@ FX_BOOL CFFL_IFormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
if (!m_bNotifying) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::GetFocus)) {
+ if (pWidget->GetAAction(CPDF_AAction::GetFocus).GetDict()) {
m_bNotifying = TRUE;
pWidget->GetAppearanceAge();
@@ -461,7 +461,7 @@ FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
if (!m_bNotifying) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
- if (pWidget->GetAAction(CPDF_AAction::LoseFocus)) {
+ if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) {
m_bNotifying = TRUE;
pWidget->ClearAppModified();
@@ -642,7 +642,7 @@ void CFFL_IFormFiller::OnKeyStrokeCommit(CPDFSDK_Widget* pWidget,
FX_BOOL& bExit,
FX_DWORD nFlag) {
if (!m_bNotifying) {
- if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) {
+ if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) {
m_bNotifying = TRUE;
pWidget->ClearAppModified();
@@ -674,7 +674,7 @@ void CFFL_IFormFiller::OnValidate(CPDFSDK_Widget* pWidget,
FX_BOOL& bExit,
FX_DWORD nFlag) {
if (!m_bNotifying) {
- if (pWidget->GetAAction(CPDF_AAction::Validate)) {
+ if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) {
m_bNotifying = TRUE;
pWidget->ClearAppModified();
@@ -951,7 +951,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(void* pPrivateData,
#endif // PDF_ENABLE_XFA
if (!m_bNotifying) {
- if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke)) {
+ if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) {
m_bNotifying = TRUE;
int nAge = pData->pWidget->GetAppearanceAge();
int nValueAge = pData->pWidget->GetValueAge();
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index c88dccd86a..50f3e2c904 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -15,16 +15,17 @@ int THISMODULE = 0;
CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
CPDF_Bookmark bookmark,
const CFX_WideString& title) {
- if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
+ if (bookmark.GetDict() &&
+ bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
// First check this item
return bookmark;
}
// go into children items
CPDF_Bookmark child = tree.GetFirstChild(bookmark);
- while (child) {
+ while (child.GetDict()) {
// check if this item
CPDF_Bookmark found = FindBookmark(tree, child, title);
- if (found)
+ if (found.GetDict())
return found;
child = tree.GetNextSibling(child);
}
@@ -112,12 +113,12 @@ DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
return nullptr;
CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
CPDF_Dest dest = bookmark.GetDest(pDoc);
- if (dest)
+ if (dest.GetObject())
return dest.GetObject();
// If this bookmark is not directly associated with a dest, we try to get
// action
CPDF_Action action = bookmark.GetAction();
- if (!action)
+ if (!action.GetDict())
return nullptr;
return action.GetDest(pDoc).GetObject();
}
@@ -244,7 +245,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
return dest;
// If this link is not directly associated with a dest, we try to get action
CPDF_Action action = link.GetAction();
- if (!action)
+ if (!action.GetDict())
return nullptr;
return action.GetDest(pDoc).GetObject();
}
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index c2e75c34d5..874082e277 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -691,7 +691,7 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
if (!pDic)
return;
- CPDF_AAction aa = pDic->GetDictBy("AA");
+ CPDF_AAction aa(pDic->GetDictBy("AA"));
if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) {
CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
CPDFSDK_ActionHandler* pActionHandler =
@@ -715,7 +715,7 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict;
- CPDF_AAction aa = pPageDict->GetDictBy("AA");
+ CPDF_AAction aa(pPageDict->GetDictBy("AA"));
if (FPDFPAGE_AACTION_OPEN == aaType) {
if (aa.ActionExist(CPDF_AAction::OpenPage)) {
CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
diff --git a/fpdfsdk/src/fsdk_actionhandler.cpp b/fpdfsdk/src/fsdk_actionhandler.cpp
index c429373f08..496e1131dc 100644
--- a/fpdfsdk/src/fsdk_actionhandler.cpp
+++ b/fpdfsdk/src/fsdk_actionhandler.cpp
@@ -421,7 +421,7 @@ FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) {
void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
const CPDF_Action& action) {
- ASSERT(action);
+ ASSERT(action.GetDict());
CPDF_Document* pPDFDocument = pDocument->GetPDFDocument();
ASSERT(pPDFDocument);
@@ -454,7 +454,7 @@ void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument,
void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument,
const CPDF_Action& action) {
- ASSERT(action);
+ ASSERT(action.GetDict());
CPDFDoc_Environment* pApp = pDocument->GetEnv();
CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument());
@@ -463,7 +463,7 @@ void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument,
void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument,
const CPDF_Action& action) {
- ASSERT(action);
+ ASSERT(action.GetDict());
CFX_ByteString csName = action.GetNamedAction();
pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 132d30b857..bd73ee3211 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -892,9 +892,8 @@ CPDF_Action CPDFSDK_BAAnnot::GetAction() const {
}
void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
- ASSERT(action);
- if ((CPDF_Action&)action !=
- CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictBy("A"))) {
+ ASSERT(action.GetDict());
+ if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("A")) {
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
CPDF_Dictionary* pDict = action.GetDict();
if (pDict && pDict->GetObjNum() == 0) {
@@ -909,12 +908,12 @@ void CPDFSDK_BAAnnot::RemoveAction() {
}
CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
- return m_pAnnot->GetAnnotDict()->GetDictBy("AA");
+ return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictBy("AA"));
}
void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) {
- if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDictBy("AA"))
- m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
+ if (aa.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("AA"))
+ m_pAnnot->GetAnnotDict()->SetAt("AA", aa.GetDict());
}
void CPDFSDK_BAAnnot::RemoveAAction() {
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 8245980fbb..8d8b95f38e 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -1912,7 +1912,7 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
#endif // PDF_ENABLE_XFA
CPDF_Action action = GetAAction(type);
- if (action && action.GetType() != CPDF_Action::Unknown) {
+ if (action.GetDict() && action.GetType() != CPDF_Action::Unknown) {
CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
return pActionHandler->DoAction_Field(action, type, pDocument,
GetFormField(), data);
@@ -1939,8 +1939,8 @@ CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) {
case CPDF_AAction::Validate:
case CPDF_AAction::Calculate: {
CPDF_FormField* pField = GetFormField();
- if (CPDF_AAction aa = pField->GetAdditionalAction())
- return aa.GetAction(eAAT);
+ if (pField->GetAdditionalAction().GetDict())
+ return pField->GetAdditionalAction().GetAction(eAAT);
return CPDFSDK_BAAnnot::GetAAction(eAAT);
}
default:
@@ -2200,9 +2200,10 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) {
int nType = pField->GetFieldType();
if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
CPDF_AAction aAction = pField->GetAdditionalAction();
- if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) {
+ if (aAction.GetDict() &&
+ aAction.ActionExist(CPDF_AAction::Calculate)) {
CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate);
- if (action) {
+ if (action.GetDict()) {
CFX_WideString csJS = action.GetJavaScript();
if (!csJS.IsEmpty()) {
IJS_Context* pContext = pRuntime->NewContext();
@@ -2256,9 +2257,9 @@ CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField,
bFormated = FALSE;
CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (aAction && aAction.ActionExist(CPDF_AAction::Format)) {
+ if (aAction.GetDict() && aAction.ActionExist(CPDF_AAction::Format)) {
CPDF_Action action = aAction.GetAction(CPDF_AAction::Format);
- if (action) {
+ if (action.GetDict()) {
CFX_WideString script = action.GetJavaScript();
if (!script.IsEmpty()) {
CFX_WideString Value = sValue;
@@ -2313,11 +2314,11 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) {
FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
const CFX_WideString& csValue) {
CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (!aAction || !aAction.ActionExist(CPDF_AAction::KeyStroke))
+ if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke))
return TRUE;
CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke);
- if (!action)
+ if (!action.GetDict())
return TRUE;
CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
@@ -2334,11 +2335,11 @@ FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField,
const CFX_WideString& csValue) {
CPDF_AAction aAction = pFormField->GetAdditionalAction();
- if (!aAction || !aAction.ActionExist(CPDF_AAction::Validate))
+ if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate))
return TRUE;
CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate);
- if (!action)
+ if (!action.GetDict())
return TRUE;
CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
@@ -2353,9 +2354,9 @@ FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField,
}
FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) {
- ASSERT(action);
+ ASSERT(action.GetDict());
- CPDF_ActionFields af = action.GetWidgets();
+ CPDF_ActionFields af(&action);
std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
@@ -2392,7 +2393,7 @@ FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) {
CPDF_Dictionary* pActionDict = action.GetDict();
if (pActionDict->KeyExist("Fields")) {
- CPDF_ActionFields af = action.GetWidgets();
+ CPDF_ActionFields af(&action);
FX_DWORD dwFlags = action.GetFlags();
std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
@@ -2559,13 +2560,13 @@ FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) {
}
FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) {
- ASSERT(action);
+ ASSERT(action.GetDict());
CPDF_Dictionary* pActionDict = action.GetDict();
if (!pActionDict->KeyExist("Fields"))
return m_pInterForm->ResetForm(true);
- CPDF_ActionFields af = action.GetWidgets();
+ CPDF_ActionFields af(&action);
FX_DWORD dwFlags = action.GetFlags();
std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
diff --git a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
index 1bfa1a6d3a..d8e11c2c02 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
@@ -128,7 +128,7 @@ void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
fLeft = 0.0f;
fBottom = 0.0f;
CPDF_Array* pA =
- m_pIconFit->m_pDict ? m_pIconFit->m_pDict->GetArrayBy("A") : NULL;
+ m_pIconFit->GetDict() ? m_pIconFit->GetDict()->GetArrayBy("A") : NULL;
if (pA) {
FX_DWORD dwCount = pA->GetCount();
if (dwCount > 0)