summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_baseannot.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-03-05 16:30:09 -0800
committerTom Sepez <tsepez@chromium.org>2015-03-05 16:30:09 -0800
commit624b6c1e0fc6a5b0467061ef37b6db6856681afb (patch)
tree8b1083b0b3f167da7fa7747ab530a9b37dab44b7 /fpdfsdk/src/fsdk_baseannot.cpp
parent61c25eebf5a0fcf44dd1a434c88f502a34073eac (diff)
downloadpdfium-624b6c1e0fc6a5b0467061ef37b6db6856681afb.tar.xz
Make conversion between CPDF_Action and its dictionary explicit.
Precursor to taking a second shot at cleaning up the FPDF_* APIs. A FPDF_Action is a CPDF_Dictionary, and a CPDF_Action is a structure holding a FPDF_Action. This goes against the convention that FPDF_ types get cast to CPDF_* types, so we want to make it clear where objects are getting constructed, etc. Also tidy fpdf_actionhandler.cpp because it bugs me. R=thestig@chromium.org Review URL: https://codereview.chromium.org/984773002
Diffstat (limited to 'fpdfsdk/src/fsdk_baseannot.cpp')
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp42
1 files changed, 13 insertions, 29 deletions
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 2b8cee9035..8265662be3 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -1090,43 +1090,30 @@ FX_BOOL CPDFSDK_Annot::IsVisible() const
CPDF_Action CPDFSDK_Annot::GetAction() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- return m_pAnnot->m_pAnnotDict->GetDict("A");
+ return CPDF_Action(m_pAnnot->m_pAnnotDict->GetDict("A"));
}
void CPDFSDK_Annot::SetAction(const CPDF_Action& action)
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
- ASSERT(action != NULL);
-
- if ((CPDF_Action&)action != m_pAnnot->m_pAnnotDict->GetDict("A"))
+ ASSERT(action);
+ if ((CPDF_Action&)action != CPDF_Action(m_pAnnot->m_pAnnotDict->GetDict("A")))
{
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
- ASSERT(pDoc != NULL);
-
- if (action.m_pDict && (action.m_pDict->GetObjNum() == 0))
- pDoc->AddIndirectObject(action.m_pDict);
- m_pAnnot->m_pAnnotDict->SetAtReference("A", pDoc, action.m_pDict->GetObjNum());
+ CPDF_Dictionary* pDict = action.GetDict();
+ if (pDict && pDict->GetObjNum() == 0) {
+ pDoc->AddIndirectObject(pDict);
+ }
+ m_pAnnot->m_pAnnotDict->SetAtReference("A", pDoc, pDict->GetObjNum());
}
}
void CPDFSDK_Annot::RemoveAction()
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
m_pAnnot->m_pAnnotDict->RemoveAt("A");
}
CPDF_AAction CPDFSDK_Annot::GetAAction() const
{
- ASSERT(m_pAnnot != NULL);
- ASSERT(m_pAnnot->m_pAnnotDict != NULL);
-
return m_pAnnot->m_pAnnotDict->GetDict("AA");
}
@@ -1151,17 +1138,14 @@ void CPDFSDK_Annot::RemoveAAction()
CPDF_Action CPDFSDK_Annot::GetAAction(CPDF_AAction::AActionType eAAT)
{
CPDF_AAction AAction = GetAAction();
-
+
if (AAction.ActionExist(eAAT))
- {
return AAction.GetAction(eAAT);
- }
- else if (eAAT == CPDF_AAction::ButtonUp)
- {
+
+ if (eAAT == CPDF_AAction::ButtonUp)
return GetAction();
- }
-
- return NULL;
+
+ return CPDF_Action();
}
void CPDFSDK_Annot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, CPDF_RenderOptions* pOptions)