summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_mgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/fsdk_mgr.cpp')
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp136
1 files changed, 61 insertions, 75 deletions
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 2e03989d6c..8bcf23147f 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -19,8 +19,8 @@
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_page.h"
#include "../include/fpdfxfa/fpdfxfa_util.h"
+#endif // PDF_ENABLE_XFA
-#endif
#if _FX_OS_ == _FX_ANDROID_
#include "time.h"
#else
@@ -218,7 +218,7 @@ CPDFDoc_Environment::~CPDFDoc_Environment() {
CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
if (pProvider->m_pEnvList.GetSize() == 0)
pProvider->SetJavaScriptInitialized(FALSE);
-#endif
+#endif // PDF_ENABLE_XFA
}
int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg,
@@ -544,7 +544,7 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot;
-#endif
+#endif // PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
if (pPageView && pPageView->IsValid()) {
CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr();
@@ -552,8 +552,7 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
#ifdef PDF_ENABLE_XFA
if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot))
return FALSE;
-
-#endif
+#endif // PDF_ENABLE_XFA
if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag))
return FALSE;
if (!m_pFocusAnnot) {
@@ -570,12 +569,12 @@ FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) {
CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr();
CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
m_pFocusAnnot = nullptr;
-#ifdef PDF_ENABLE_XFA
+#ifdef PDF_ENABLE_XFA
if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot))
return FALSE;
+#endif // PDF_ENABLE_XFA
-#endif
if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) {
if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
@@ -622,25 +621,25 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,
m_bExitWidget(FALSE),
m_bOnWidget(FALSE),
m_bValid(FALSE),
-#ifndef PDF_ENABLE_XFA
+#ifdef PDF_ENABLE_XFA
+ m_bLocked(FALSE) {
+#else // PDF_ENABLE_XFA
m_bLocked(FALSE),
m_bTakeOverPage(FALSE) {
-#else
- m_bLocked(FALSE) {
-#endif
+#endif // PDF_ENABLE_XFA
CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
if (pInterForm) {
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
-#ifndef PDF_ENABLE_XFA
- pPDFInterForm->FixPageFields(page);
-#else
+#ifdef PDF_ENABLE_XFA
if (page->GetPDFPage())
pPDFInterForm->FixPageFields(page->GetPDFPage());
-#endif
+#else // PDF_ENABLE_XFA
+ pPDFInterForm->FixPageFields(page);
+#endif // PDF_ENABLE_XFA
}
#ifndef PDF_ENABLE_XFA
m_page->SetPrivateData((void*)m_page, (void*)this, nullptr);
-#endif
+#endif // PDF_ENABLE_XFA
}
CPDFSDK_PageView::~CPDFSDK_PageView() {
@@ -648,34 +647,33 @@ CPDFSDK_PageView::~CPDFSDK_PageView() {
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray)
pAnnotHandlerMgr->ReleaseAnnot(pAnnot);
- m_fxAnnotArray.clear();
+ m_fxAnnotArray.clear();
m_pAnnotList.reset();
#ifndef PDF_ENABLE_XFA
-
m_page->RemovePrivateData((void*)m_page);
if (m_bTakeOverPage) {
delete m_page;
}
-#endif
+#endif // PDF_ENABLE_XFA
}
void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
-#ifndef PDF_ENABLE_XFA
- CPDF_RenderOptions* pOptions) {
-#else
+#ifdef PDF_ENABLE_XFA
CPDF_RenderOptions* pOptions,
const FX_RECT& pClip) {
-#endif
+#else
+ CPDF_RenderOptions* pOptions) {
+#endif // PDF_ENABLE_XFA
m_curMatrix = *pUser2Device;
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pPage = GetPDFXFAPage();
if (pPage == NULL)
return;
-#ifdef PDF_ENABLE_XFA
if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
CFX_Graphics gs;
gs.Create(pDevice);
@@ -700,7 +698,6 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
#endif // PDF_ENABLE_XFA
// for pdf/static xfa.
-#endif
CPDFSDK_AnnotIterator annotIterator(this, true);
while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
@@ -752,13 +749,11 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX,
CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
CPDFSDK_AnnotIterator annotIterator(this, false);
while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
-#ifndef PDF_ENABLE_XFA
- if (pSDKAnnot->GetType() == "Widget") {
-#else
bool bHitTest = pSDKAnnot->GetType() == "Widget";
+#ifdef PDF_ENABLE_XFA
bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME;
+#endif // PDF_ENABLE_XFA
if (bHitTest) {
-#endif
pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
CPDF_Point point(pageX, pageY);
if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
@@ -817,8 +812,8 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) {
m_fxAnnotArray.push_back(pSDKAnnot);
return pSDKAnnot;
}
+#endif // PDF_ENABLE_XFA
-#endif
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) {
return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr;
}
@@ -829,9 +824,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,
}
FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
-#ifndef PDF_ENABLE_XFA
- return FALSE;
-#else
+#ifdef PDF_ENABLE_XFA
if (!pAnnot)
return FALSE;
CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
@@ -846,26 +839,30 @@ FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
m_CaptureWidget = nullptr;
return TRUE;
-#endif
+#else // PDF_ENABLE_XFA
+ return FALSE;
+#endif // PDF_ENABLE_XFA
}
CPDF_Document* CPDFSDK_PageView::GetPDFDocument() {
if (m_page) {
-#ifndef PDF_ENABLE_XFA
- return m_page->m_pDocument;
-#else
+#ifdef PDF_ENABLE_XFA
return m_page->GetDocument()->GetPDFDoc();
+#else // PDF_ENABLE_XFA
+ return m_page->m_pDocument;
+#endif // PDF_ENABLE_XFA
}
return NULL;
}
+#ifdef PDF_ENABLE_XFA
CPDF_Page* CPDFSDK_PageView::GetPDFPage() {
if (m_page) {
return m_page->GetPDFPage();
-#endif
}
return NULL;
}
+#endif // PDF_ENABLE_XFA
size_t CPDFSDK_PageView::CountAnnots() const {
return m_fxAnnotArray.size();
@@ -882,6 +879,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) {
}
return nullptr;
}
+
#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) {
if (!hWidget)
@@ -893,7 +891,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) {
}
return nullptr;
}
-#endif
+#endif // PDF_ENABLE_XFA
FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point,
FX_UINT nFlag) {
@@ -951,8 +949,8 @@ FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CPDF_Point& point, FX_UINT nFlag) {
}
return TRUE;
}
+#endif // PDF_ENABLE_XFA
-#endif
FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) {
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
ASSERT(pEnv);
@@ -1040,22 +1038,18 @@ void CPDFSDK_PageView::LoadFXAnnots() {
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
#ifdef PDF_ENABLE_XFA
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
-#endif
-
-#ifndef PDF_ENABLE_XFA
+#else
FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
// Disable the default AP construction.
CPDF_InterForm::EnableUpdateAP(FALSE);
m_pAnnotList.reset(new CPDF_AnnotList(m_page));
CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
const size_t nCount = m_pAnnotList->Count();
-#endif
+#endif // PDF_ENABLE_XFA
+
SetLock(TRUE);
-#ifndef PDF_ENABLE_XFA
- for (size_t i = 0; i < nCount; ++i) {
- CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
- CPDF_Document* pDoc = GetPDFDocument();
-#else
+
+#ifdef PDF_ENABLE_XFA
m_page->AddRef();
if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
IXFA_PageView* pageView = NULL;
@@ -1080,24 +1074,10 @@ void CPDFSDK_PageView::LoadFXAnnots() {
m_fxAnnotArray.push_back(pAnnot);
pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
}
-#endif
-
-#ifndef PDF_ENABLE_XFA
- CheckUnSupportAnnot(pDoc, pPDFAnnot);
-#else
pWidgetHander->Release();
} else {
CPDF_Page* pPage = m_page->GetPDFPage();
ASSERT(pPage != NULL);
-#endif
-
-#ifndef PDF_ENABLE_XFA
- CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
- CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
- if (!pAnnot)
- continue;
- m_fxAnnotArray.push_back(pAnnot);
-#else
FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
// Disable the default AP construction.
CPDF_InterForm::EnableUpdateAP(FALSE);
@@ -1113,18 +1093,24 @@ void CPDFSDK_PageView::LoadFXAnnots() {
if (!pAnnot)
continue;
m_fxAnnotArray.push_back(pAnnot);
-#endif
-
-#ifndef PDF_ENABLE_XFA
- pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
-#else
pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
}
-#endif
}
-#ifdef PDF_ENABLE_XFA
m_page->Release();
-#endif
+#else // PDF_ENABLE_XFA
+ for (size_t i = 0; i < nCount; ++i) {
+ CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
+ CPDF_Document* pDoc = GetPDFDocument();
+ CheckUnSupportAnnot(pDoc, pPDFAnnot);
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
+ if (!pAnnot)
+ continue;
+ m_fxAnnotArray.push_back(pAnnot);
+ pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
+ }
+#endif // PDF_ENABLE_XFA
+
SetLock(FALSE);
}
@@ -1145,11 +1131,11 @@ void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) {
int CPDFSDK_PageView::GetPageIndex() {
if (m_page) {
-#ifndef PDF_ENABLE_XFA
- CPDF_Dictionary* pDic = m_page->m_pFormDict;
-#else
+#ifdef PDF_ENABLE_XFA
CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict;
-#endif
+#else // PDF_ENABLE_XFA
+ CPDF_Dictionary* pDic = m_page->m_pFormDict;
+#endif // PDF_ENABLE_XFA
CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
if (pDoc && pDic) {
return pDoc->GetPageIndex(pDic->GetObjNum());