summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp15
-rw-r--r--fpdfsdk/cpdfsdk_interform.h3
-rw-r--r--fpdfsdk/javascript/Field.cpp53
-rw-r--r--fpdfsdk/javascript/Field.h3
4 files changed, 30 insertions, 44 deletions
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 5229f95528..f8fd3b3db5 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -82,8 +82,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget,
return static_cast<CPDFSDK_Widget*>(pIterator->GetPrevAnnot(pWidget));
}
-CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl,
- bool createIfNeeded) const {
+CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const {
if (!pControl || !m_pInterForm)
return nullptr;
@@ -93,8 +92,6 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl,
pWidget = it->second;
if (pWidget)
return pWidget;
- if (!createIfNeeded)
- return nullptr;
CPDF_Dictionary* pControlDict = pControl->GetWidget();
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
@@ -134,7 +131,7 @@ void CPDFSDK_InterForm::GetWidgets(
for (int i = 0, sz = pField->CountControls(); i < sz; ++i) {
CPDF_FormControl* pFormCtrl = pField->GetControl(i);
ASSERT(pFormCtrl);
- CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, true);
+ CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl);
if (pWidget)
widgets->push_back(pWidget);
}
@@ -213,7 +210,7 @@ void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField,
bool bSynchronizeElse) {
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
- if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false))
+ if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl))
pWidget->Synchronize(bSynchronizeElse);
}
}
@@ -322,7 +319,7 @@ void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField,
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
ASSERT(pFormCtrl);
- if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false))
+ if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl))
pWidget->ResetAppearance(sValue, bValueChanged);
}
}
@@ -332,7 +329,7 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) {
CPDF_FormControl* pFormCtrl = pFormField->GetControl(i);
ASSERT(pFormCtrl);
- if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) {
+ if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) {
UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, false);
FX_RECT rcBBox = m_pFormFillEnv->GetInteractiveFormFiller()->GetViewBBox(
@@ -399,7 +396,7 @@ bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) {
CPDF_FormControl* pControl = pField->GetControl(i);
ASSERT(pControl);
- if (CPDFSDK_Widget* pWidget = GetWidget(pControl, false)) {
+ if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) {
uint32_t nFlags = pWidget->GetFlags();
nFlags &= ~ANNOTFLAG_INVISIBLE;
nFlags &= ~ANNOTFLAG_NOVIEW;
diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h
index f0921a97f4..4c5d10dccf 100644
--- a/fpdfsdk/cpdfsdk_interform.h
+++ b/fpdfsdk/cpdfsdk_interform.h
@@ -39,8 +39,7 @@ class CPDFSDK_InterForm : public IPDF_FormNotify {
bool HighlightWidgets();
CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, bool bNext) const;
- CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl,
- bool createIfNeeded) const;
+ CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl) const;
void GetWidgets(const CFX_WideString& sFieldName,
std::vector<CPDFSDK_Widget*>* widgets) const;
void GetWidgets(CPDF_FormField* pField,
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 4ce1f2e4e8..f8ac479a42 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -316,7 +316,7 @@ void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
ASSERT(pFormControl);
CPDFSDK_InterForm* pForm = pFormFillEnv->GetInterForm();
- CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false);
+ CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl);
if (pWidget) {
if (bResetAP) {
@@ -342,12 +342,10 @@ void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormControl* pFormControl,
- bool createIfNeeded) {
+ CPDF_FormControl* pFormControl) {
CPDFSDK_InterForm* pInterForm =
static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm());
- return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded)
- : nullptr;
+ return pInterForm ? pInterForm->GetWidget(pFormControl) : nullptr;
}
bool Field::ValueIsOccur(CPDF_FormField* pFormField,
@@ -454,8 +452,8 @@ bool Field::borderStyle(IJS_Context* cc,
if (!pFormField)
return false;
- CPDFSDK_Widget* pWidget = GetWidget(
- m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField), false);
+ CPDFSDK_Widget* pWidget =
+ GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField));
if (!pWidget)
return false;
@@ -511,7 +509,7 @@ void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
bool bSet = false;
for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
if (CPDFSDK_Widget* pWidget =
- GetWidget(pFormFillEnv, pFormField->GetControl(i), false)) {
+ GetWidget(pFormFillEnv, pFormField->GetControl(i))) {
if (pWidget->GetBorderStyle() != nBorderStyle) {
pWidget->SetBorderStyle(nBorderStyle);
bSet = true;
@@ -525,8 +523,7 @@ void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
return;
if (CPDF_FormControl* pFormControl =
pFormField->GetControl(nControlIndex)) {
- if (CPDFSDK_Widget* pWidget =
- GetWidget(pFormFillEnv, pFormControl, false)) {
+ if (CPDFSDK_Widget* pWidget = GetWidget(pFormFillEnv, pFormControl)) {
if (pWidget->GetBorderStyle() != nBorderStyle) {
pWidget->SetBorderStyle(nBorderStyle);
UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
@@ -1260,7 +1257,7 @@ bool Field::display(IJS_Context* cc,
ASSERT(pFormField);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
+ pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
return false;
@@ -1298,7 +1295,7 @@ void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormControl* pFormControl = pFormField->GetControl(i);
ASSERT(pFormControl);
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true);
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
if (SetWidgetDisplayStatus(pWidget, number))
bAnySet = true;
}
@@ -1313,7 +1310,7 @@ void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
if (!pFormControl)
return;
- CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true);
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl);
if (SetWidgetDisplayStatus(pWidget, number))
UpdateFormControl(pFormFillEnv, pFormControl, true, false, true);
}
@@ -1522,7 +1519,7 @@ bool Field::hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
ASSERT(pFormField);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(GetSmartFieldControl(pFormField), false);
+ pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
return false;
@@ -1637,8 +1634,7 @@ bool Field::lineWidth(IJS_Context* cc,
if (!pFormField->CountControls())
return false;
- CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormField->GetControl(0), false);
+ CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
if (!pWidget)
return false;
@@ -1662,8 +1658,7 @@ void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormControl* pFormControl = pFormField->GetControl(i);
ASSERT(pFormControl);
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormControl, false)) {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
if (number != pWidget->GetBorderWidth()) {
pWidget->SetBorderWidth(number);
bSet = true;
@@ -1677,8 +1672,7 @@ void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
return;
if (CPDF_FormControl* pFormControl =
pFormField->GetControl(nControlIndex)) {
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormControl, false)) {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
if (number != pWidget->GetBorderWidth()) {
pWidget->SetBorderWidth(number);
UpdateFormControl(pFormFillEnv, pFormControl, true, true, true);
@@ -1904,7 +1898,7 @@ bool Field::print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
bool bSet = false;
for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormField->GetControl(i), false)) {
+ pInterForm->GetWidget(pFormField->GetControl(i))) {
uint32_t dwFlags = pWidget->GetFlags();
if (bVP)
dwFlags |= ANNOTFLAG_PRINT;
@@ -1925,8 +1919,7 @@ bool Field::print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
return false;
if (CPDF_FormControl* pFormControl =
pFormField->GetControl(m_nFormControlIndex)) {
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormControl, true)) {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
uint32_t dwFlags = pWidget->GetFlags();
if (bVP)
dwFlags |= ANNOTFLAG_PRINT;
@@ -1946,7 +1939,7 @@ bool Field::print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
} else {
CPDF_FormField* pFormField = FieldArray[0];
CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
+ pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
return false;
@@ -2053,7 +2046,7 @@ bool Field::rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
CPDF_FormField* pFormField = FieldArray[0];
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
+ pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
return false;
@@ -2087,8 +2080,7 @@ void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormControl* pFormControl = pFormField->GetControl(i);
ASSERT(pFormControl);
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormControl, false)) {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
CFX_FloatRect crRect = rect;
CPDF_Page* pPDFPage = pWidget->GetPDFPage();
@@ -2112,8 +2104,7 @@ void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
return;
if (CPDF_FormControl* pFormControl =
pFormField->GetControl(nControlIndex)) {
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormControl, false)) {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
CFX_FloatRect crRect = rect;
CPDF_Page* pPDFPage = pWidget->GetPDFPage();
@@ -3182,7 +3173,7 @@ bool Field::setFocus(IJS_Context* cc,
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget = nullptr;
if (nCount == 1) {
- pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false);
+ pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
} else {
UnderlyingPageType* pPage =
UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage(
@@ -3193,7 +3184,7 @@ bool Field::setFocus(IJS_Context* cc,
m_pFormFillEnv->GetPageView(pPage, true)) {
for (int32_t i = 0; i < nCount; i++) {
if (CPDFSDK_Widget* pTempWidget =
- pInterForm->GetWidget(pFormField->GetControl(i), false)) {
+ pInterForm->GetWidget(pFormField->GetControl(i))) {
if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) {
pWidget = pTempWidget;
break;
diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h
index d4371ab274..f3948fff5b 100644
--- a/fpdfsdk/javascript/Field.h
+++ b/fpdfsdk/javascript/Field.h
@@ -407,8 +407,7 @@ class Field : public CJS_EmbedObj {
bool bRefresh);
static CPDFSDK_Widget* GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormControl* pFormControl,
- bool createIfNeeded);
+ CPDF_FormControl* pFormControl);
static std::vector<CPDF_FormField*> GetFormFields(
CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& csFieldName);