Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: fpdfsdk/javascript/Field.cpp

Issue 2412523002: Cleanup env variable names (Closed)
Patch Set: Cleanup Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/Field.h" 7 #include "fpdfsdk/javascript/Field.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return; 205 return;
206 } 206 }
207 } 207 }
208 strFieldName = strFieldNameParsed.substr(0, iStart); 208 strFieldName = strFieldNameParsed.substr(0, iStart);
209 } 209 }
210 210
211 FX_BOOL Field::AttachField(Document* pDocument, 211 FX_BOOL Field::AttachField(Document* pDocument,
212 const CFX_WideString& csFieldName) { 212 const CFX_WideString& csFieldName) {
213 m_pJSDoc = pDocument; 213 m_pJSDoc = pDocument;
214 m_pFormFillEnv.Reset(pDocument->GetFormFillEnv()); 214 m_pFormFillEnv.Reset(pDocument->GetFormFillEnv());
215 m_bCanSet = 215 m_bCanSet = m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM) ||
216 m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_FILL_FORM) || 216 m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
217 m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_ANNOT_FORM) || 217 m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY);
218 m_pFormFillEnv->GetSDKDocument()->GetPermissions(FPDFPERM_MODIFY);
219 218
220 CPDFSDK_InterForm* pRDInterForm = 219 CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
221 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
222 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); 220 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
223 CFX_WideString swFieldNameTemp = csFieldName; 221 CFX_WideString swFieldNameTemp = csFieldName;
224 swFieldNameTemp.Replace(L"..", L"."); 222 swFieldNameTemp.Replace(L"..", L".");
225 223
226 if (pInterForm->CountFields(swFieldNameTemp) <= 0) { 224 if (pInterForm->CountFields(swFieldNameTemp) <= 0) {
227 std::wstring strFieldName; 225 std::wstring strFieldName;
228 int iControlNo = -1; 226 int iControlNo = -1;
229 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo); 227 ParseFieldName(swFieldNameTemp.c_str(), strFieldName, iControlNo);
230 if (iControlNo == -1) 228 if (iControlNo == -1)
231 return FALSE; 229 return FALSE;
232 230
233 m_FieldName = strFieldName.c_str(); 231 m_FieldName = strFieldName.c_str();
234 m_nFormControlIndex = iControlNo; 232 m_nFormControlIndex = iControlNo;
235 return TRUE; 233 return TRUE;
236 } 234 }
237 235
238 m_FieldName = swFieldNameTemp; 236 m_FieldName = swFieldNameTemp;
239 m_nFormControlIndex = -1; 237 m_nFormControlIndex = -1;
240 238
241 return TRUE; 239 return TRUE;
242 } 240 }
243 241
244 std::vector<CPDF_FormField*> Field::GetFormFields( 242 std::vector<CPDF_FormField*> Field::GetFormFields(
245 CPDFSDK_FormFillEnvironment* pFormFillEnv, 243 CPDFSDK_FormFillEnvironment* pFormFillEnv,
246 const CFX_WideString& csFieldName) { 244 const CFX_WideString& csFieldName) {
247 std::vector<CPDF_FormField*> fields; 245 std::vector<CPDF_FormField*> fields;
248 CPDFSDK_InterForm* pReaderInterForm = 246 CPDFSDK_InterForm* pReaderInterForm = pFormFillEnv->GetInterForm();
249 pFormFillEnv->GetSDKDocument()->GetInterForm();
250 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm(); 247 CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
251 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) { 248 for (int i = 0, sz = pInterForm->CountFields(csFieldName); i < sz; ++i) {
252 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName)) 249 if (CPDF_FormField* pFormField = pInterForm->GetField(i, csFieldName))
253 fields.push_back(pFormField); 250 fields.push_back(pFormField);
254 } 251 }
255 return fields; 252 return fields;
256 } 253 }
257 254
258 std::vector<CPDF_FormField*> Field::GetFormFields( 255 std::vector<CPDF_FormField*> Field::GetFormFields(
259 const CFX_WideString& csFieldName) const { 256 const CFX_WideString& csFieldName) const {
260 return Field::GetFormFields(m_pFormFillEnv.Get(), csFieldName); 257 return Field::GetFormFields(m_pFormFillEnv.Get(), csFieldName);
261 } 258 }
262 259
263 void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv, 260 void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
264 CPDF_FormField* pFormField, 261 CPDF_FormField* pFormField,
265 FX_BOOL bChangeMark, 262 FX_BOOL bChangeMark,
266 FX_BOOL bResetAP, 263 FX_BOOL bResetAP,
267 FX_BOOL bRefresh) { 264 FX_BOOL bRefresh) {
268 CPDFSDK_InterForm* pInterForm = 265 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
269 pFormFillEnv->GetSDKDocument()->GetInterForm();
270 266
271 if (bResetAP) { 267 if (bResetAP) {
272 std::vector<CPDFSDK_Widget*> widgets; 268 std::vector<CPDFSDK_Widget*> widgets;
273 pInterForm->GetWidgets(pFormField, &widgets); 269 pInterForm->GetWidgets(pFormField, &widgets);
274 270
275 int nFieldType = pFormField->GetFieldType(); 271 int nFieldType = pFormField->GetFieldType();
276 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { 272 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) {
277 for (CPDFSDK_Annot* pAnnot : widgets) { 273 for (CPDFSDK_Annot* pAnnot : widgets) {
278 FX_BOOL bFormatted = FALSE; 274 FX_BOOL bFormatted = FALSE;
279 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot); 275 CPDFSDK_Annot::ObservedPtr pObserved(pAnnot);
(...skipping 13 matching lines...) Expand all
293 289
294 if (bRefresh) { 290 if (bRefresh) {
295 // Refresh the widget list. The calls in |bResetAP| may have caused widgets 291 // Refresh the widget list. The calls in |bResetAP| may have caused widgets
296 // to be removed from the list. We need to call |GetWidgets| again to be 292 // to be removed from the list. We need to call |GetWidgets| again to be
297 // sure none of the widgets have been deleted. 293 // sure none of the widgets have been deleted.
298 std::vector<CPDFSDK_Widget*> widgets; 294 std::vector<CPDFSDK_Widget*> widgets;
299 pInterForm->GetWidgets(pFormField, &widgets); 295 pInterForm->GetWidgets(pFormField, &widgets);
300 296
301 // TODO(dsinclair): Determine if all widgets share the same 297 // TODO(dsinclair): Determine if all widgets share the same
302 // CPDFSDK_InterForm. If that's the case, we can move the code to 298 // CPDFSDK_InterForm. If that's the case, we can move the code to
303 // |GetSDKDocument| out of the loop. 299 // |GetFormFillEnv| out of the loop.
304 for (CPDFSDK_Widget* pWidget : widgets) { 300 for (CPDFSDK_Widget* pWidget : widgets) {
305 pWidget->GetInterForm() 301 pWidget->GetInterForm()
306 ->GetFormFillEnv() 302 ->GetFormFillEnv()
307 ->GetSDKDocument()
308 ->UpdateAllViews(nullptr, pWidget); 303 ->UpdateAllViews(nullptr, pWidget);
309 } 304 }
310 } 305 }
311 306
312 if (bChangeMark) 307 if (bChangeMark)
313 pFormFillEnv->GetSDKDocument()->SetChangeMark(); 308 pFormFillEnv->SetChangeMark();
314 } 309 }
315 310
316 void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv, 311 void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
317 CPDF_FormControl* pFormControl, 312 CPDF_FormControl* pFormControl,
318 FX_BOOL bChangeMark, 313 FX_BOOL bChangeMark,
319 FX_BOOL bResetAP, 314 FX_BOOL bResetAP,
320 FX_BOOL bRefresh) { 315 FX_BOOL bRefresh) {
321 ASSERT(pFormControl); 316 ASSERT(pFormControl);
322 317
323 CPDFSDK_InterForm* pForm = pFormFillEnv->GetSDKDocument()->GetInterForm(); 318 CPDFSDK_InterForm* pForm = pFormFillEnv->GetInterForm();
324 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false); 319 CPDFSDK_Widget* pWidget = pForm->GetWidget(pFormControl, false);
325 320
326 if (pWidget) { 321 if (pWidget) {
327 if (bResetAP) { 322 if (bResetAP) {
328 int nFieldType = pWidget->GetFieldType(); 323 int nFieldType = pWidget->GetFieldType();
329 if (nFieldType == FIELDTYPE_COMBOBOX || 324 if (nFieldType == FIELDTYPE_COMBOBOX ||
330 nFieldType == FIELDTYPE_TEXTFIELD) { 325 nFieldType == FIELDTYPE_TEXTFIELD) {
331 FX_BOOL bFormatted = FALSE; 326 FX_BOOL bFormatted = FALSE;
332 CFX_WideString sValue = pWidget->OnFormat(bFormatted); 327 CFX_WideString sValue = pWidget->OnFormat(bFormatted);
333 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE); 328 pWidget->ResetAppearance(bFormatted ? &sValue : nullptr, FALSE);
334 } else { 329 } else {
335 pWidget->ResetAppearance(nullptr, FALSE); 330 pWidget->ResetAppearance(nullptr, FALSE);
336 } 331 }
337 } 332 }
338 333
339 if (bRefresh) { 334 if (bRefresh) {
340 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); 335 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm();
341 pInterForm->GetFormFillEnv()->GetSDKDocument()->UpdateAllViews(nullptr, 336 pInterForm->GetFormFillEnv()->UpdateAllViews(nullptr, pWidget);
342 pWidget);
343 } 337 }
344 } 338 }
345 339
346 if (bChangeMark) 340 if (bChangeMark)
347 pFormFillEnv->GetSDKDocument()->SetChangeMark(); 341 pFormFillEnv->SetChangeMark();
348 } 342 }
349 343
350 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv, 344 CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
351 CPDF_FormControl* pFormControl, 345 CPDF_FormControl* pFormControl,
352 bool createIfNeeded) { 346 bool createIfNeeded) {
353 CPDFSDK_InterForm* pInterForm = static_cast<CPDFSDK_InterForm*>( 347 CPDFSDK_InterForm* pInterForm =
354 pFormFillEnv->GetSDKDocument()->GetInterForm()); 348 static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm());
355 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded) 349 return pInterForm ? pInterForm->GetWidget(pFormControl, createIfNeeded)
356 : nullptr; 350 : nullptr;
357 } 351 }
358 352
359 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField, 353 FX_BOOL Field::ValueIsOccur(CPDF_FormField* pFormField,
360 CFX_WideString csOptLabel) { 354 CFX_WideString csOptLabel) {
361 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) { 355 for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) {
362 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0) 356 if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
363 return TRUE; 357 return TRUE;
364 } 358 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 851 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
858 if (FieldArray.empty()) 852 if (FieldArray.empty())
859 return FALSE; 853 return FALSE;
860 854
861 CPDF_FormField* pFormField = FieldArray[0]; 855 CPDF_FormField* pFormField = FieldArray[0];
862 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && 856 if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
863 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) { 857 pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) {
864 return FALSE; 858 return FALSE;
865 } 859 }
866 860
867 CPDFSDK_InterForm* pRDInterForm = 861 CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
868 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
869 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); 862 CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
870 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField); 863 vp << (int32_t)pInterForm->FindFieldInCalculationOrder(pFormField);
871 } 864 }
872 865
873 return TRUE; 866 return TRUE;
874 } 867 }
875 868
876 void Field::SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv, 869 void Field::SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv,
877 const CFX_WideString& swFieldName, 870 const CFX_WideString& swFieldName,
878 int nControlIndex, 871 int nControlIndex,
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 1255 Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1263 nVP); 1256 nVP);
1264 } 1257 }
1265 } else { 1258 } else {
1266 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1259 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1267 if (FieldArray.empty()) 1260 if (FieldArray.empty())
1268 return FALSE; 1261 return FALSE;
1269 1262
1270 CPDF_FormField* pFormField = FieldArray[0]; 1263 CPDF_FormField* pFormField = FieldArray[0];
1271 ASSERT(pFormField); 1264 ASSERT(pFormField);
1272 CPDFSDK_InterForm* pInterForm = 1265 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1273 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1274 CPDFSDK_Widget* pWidget = 1266 CPDFSDK_Widget* pWidget =
1275 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 1267 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
1276 if (!pWidget) 1268 if (!pWidget)
1277 return FALSE; 1269 return FALSE;
1278 1270
1279 uint32_t dwFlag = pWidget->GetFlags(); 1271 uint32_t dwFlag = pWidget->GetFlags();
1280 1272
1281 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { 1273 if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
1282 vp << (int32_t)1; 1274 vp << (int32_t)1;
1283 } else { 1275 } else {
1284 if (ANNOTFLAG_PRINT & dwFlag) { 1276 if (ANNOTFLAG_PRINT & dwFlag) {
1285 if (ANNOTFLAG_NOVIEW & dwFlag) { 1277 if (ANNOTFLAG_NOVIEW & dwFlag) {
1286 vp << (int32_t)3; 1278 vp << (int32_t)3;
1287 } else { 1279 } else {
1288 vp << (int32_t)0; 1280 vp << (int32_t)0;
1289 } 1281 }
1290 } else { 1282 } else {
1291 vp << (int32_t)2; 1283 vp << (int32_t)2;
1292 } 1284 }
1293 } 1285 }
1294 } 1286 }
1295 1287
1296 return TRUE; 1288 return TRUE;
1297 } 1289 }
1298 1290
1299 void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1291 void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1300 const CFX_WideString& swFieldName, 1292 const CFX_WideString& swFieldName,
1301 int nControlIndex, 1293 int nControlIndex,
1302 int number) { 1294 int number) {
1303 CPDFSDK_InterForm* pInterForm = 1295 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
1304 pFormFillEnv->GetSDKDocument()->GetInterForm();
1305 std::vector<CPDF_FormField*> FieldArray = 1296 std::vector<CPDF_FormField*> FieldArray =
1306 GetFormFields(pFormFillEnv, swFieldName); 1297 GetFormFields(pFormFillEnv, swFieldName);
1307 for (CPDF_FormField* pFormField : FieldArray) { 1298 for (CPDF_FormField* pFormField : FieldArray) {
1308 if (nControlIndex < 0) { 1299 if (nControlIndex < 0) {
1309 bool bAnySet = false; 1300 bool bAnySet = false;
1310 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1301 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1311 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1302 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1312 ASSERT(pFormControl); 1303 ASSERT(pFormControl);
1313 1304
1314 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true); 1305 CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl, true);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 1519 Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
1529 bVP); 1520 bVP);
1530 } 1521 }
1531 } else { 1522 } else {
1532 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1523 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1533 if (FieldArray.empty()) 1524 if (FieldArray.empty())
1534 return FALSE; 1525 return FALSE;
1535 1526
1536 CPDF_FormField* pFormField = FieldArray[0]; 1527 CPDF_FormField* pFormField = FieldArray[0];
1537 ASSERT(pFormField); 1528 ASSERT(pFormField);
1538 CPDFSDK_InterForm* pInterForm = 1529 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1539 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1540 CPDFSDK_Widget* pWidget = 1530 CPDFSDK_Widget* pWidget =
1541 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false); 1531 pInterForm->GetWidget(GetSmartFieldControl(pFormField), false);
1542 if (!pWidget) 1532 if (!pWidget)
1543 return FALSE; 1533 return FALSE;
1544 1534
1545 uint32_t dwFlags = pWidget->GetFlags(); 1535 uint32_t dwFlags = pWidget->GetFlags();
1546 1536
1547 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags) 1537 if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
1548 vp << true; 1538 vp << true;
1549 else 1539 else
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1632 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1643 if (FieldArray.empty()) 1633 if (FieldArray.empty())
1644 return FALSE; 1634 return FALSE;
1645 1635
1646 CPDF_FormField* pFormField = FieldArray[0]; 1636 CPDF_FormField* pFormField = FieldArray[0];
1647 ASSERT(pFormField); 1637 ASSERT(pFormField);
1648 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 1638 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
1649 if (!pFormControl) 1639 if (!pFormControl)
1650 return FALSE; 1640 return FALSE;
1651 1641
1652 CPDFSDK_InterForm* pInterForm = 1642 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1653 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1654 if (!pFormField->CountControls()) 1643 if (!pFormField->CountControls())
1655 return FALSE; 1644 return FALSE;
1656 1645
1657 CPDFSDK_Widget* pWidget = 1646 CPDFSDK_Widget* pWidget =
1658 pInterForm->GetWidget(pFormField->GetControl(0), false); 1647 pInterForm->GetWidget(pFormField->GetControl(0), false);
1659 if (!pWidget) 1648 if (!pWidget)
1660 return FALSE; 1649 return FALSE;
1661 1650
1662 vp << (int32_t)pWidget->GetBorderWidth(); 1651 vp << (int32_t)pWidget->GetBorderWidth();
1663 } 1652 }
1664 1653
1665 return TRUE; 1654 return TRUE;
1666 } 1655 }
1667 1656
1668 void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1657 void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1669 const CFX_WideString& swFieldName, 1658 const CFX_WideString& swFieldName,
1670 int nControlIndex, 1659 int nControlIndex,
1671 int number) { 1660 int number) {
1672 CPDFSDK_InterForm* pInterForm = 1661 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
1673 pFormFillEnv->GetSDKDocument()->GetInterForm();
1674 std::vector<CPDF_FormField*> FieldArray = 1662 std::vector<CPDF_FormField*> FieldArray =
1675 GetFormFields(pFormFillEnv, swFieldName); 1663 GetFormFields(pFormFillEnv, swFieldName);
1676 for (CPDF_FormField* pFormField : FieldArray) { 1664 for (CPDF_FormField* pFormField : FieldArray) {
1677 if (nControlIndex < 0) { 1665 if (nControlIndex < 0) {
1678 FX_BOOL bSet = FALSE; 1666 FX_BOOL bSet = FALSE;
1679 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 1667 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
1680 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 1668 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
1681 ASSERT(pFormControl); 1669 ASSERT(pFormControl);
1682 1670
1683 if (CPDFSDK_Widget* pWidget = 1671 if (CPDFSDK_Widget* pWidget =
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 1824
1837 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1825 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1838 if (FieldArray.empty()) 1826 if (FieldArray.empty())
1839 return FALSE; 1827 return FALSE;
1840 1828
1841 CPDF_FormField* pFormField = FieldArray[0]; 1829 CPDF_FormField* pFormField = FieldArray[0];
1842 if (!pFormField) 1830 if (!pFormField)
1843 return FALSE; 1831 return FALSE;
1844 1832
1845 std::vector<CPDFSDK_Widget*> widgets; 1833 std::vector<CPDFSDK_Widget*> widgets;
1846 m_pFormFillEnv->GetSDKDocument()->GetInterForm()->GetWidgets(pFormField, 1834 m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets);
1847 &widgets);
1848 1835
1849 if (widgets.empty()) { 1836 if (widgets.empty()) {
1850 vp << (int32_t)-1; 1837 vp << (int32_t)-1;
1851 return TRUE; 1838 return TRUE;
1852 } 1839 }
1853 1840
1854 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); 1841 CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
1855 CJS_Array PageArray; 1842 CJS_Array PageArray;
1856 for (size_t i = 0; i < widgets.size(); ++i) { 1843 for (size_t i = 0; i < widgets.size(); ++i) {
1857 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView(); 1844 CPDFSDK_PageView* pPageView = widgets[i]->GetPageView();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 void Field::SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv, 1892 void Field::SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
1906 const CFX_WideString& swFieldName, 1893 const CFX_WideString& swFieldName,
1907 int nControlIndex, 1894 int nControlIndex,
1908 bool b) { 1895 bool b) {
1909 // Not supported. 1896 // Not supported.
1910 } 1897 }
1911 1898
1912 FX_BOOL Field::print(IJS_Context* cc, 1899 FX_BOOL Field::print(IJS_Context* cc,
1913 CJS_PropValue& vp, 1900 CJS_PropValue& vp,
1914 CFX_WideString& sError) { 1901 CFX_WideString& sError) {
1915 CPDFSDK_InterForm* pInterForm = 1902 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
1916 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
1917 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 1903 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
1918 if (FieldArray.empty()) 1904 if (FieldArray.empty())
1919 return FALSE; 1905 return FALSE;
1920 1906
1921 if (vp.IsSetting()) { 1907 if (vp.IsSetting()) {
1922 if (!m_bCanSet) 1908 if (!m_bCanSet)
1923 return FALSE; 1909 return FALSE;
1924 1910
1925 bool bVP; 1911 bool bVP;
1926 vp >> bVP; 1912 vp >> bVP;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 } else { 2058 } else {
2073 Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, 2059 Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
2074 crRect); 2060 crRect);
2075 } 2061 }
2076 } else { 2062 } else {
2077 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 2063 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
2078 if (FieldArray.empty()) 2064 if (FieldArray.empty())
2079 return FALSE; 2065 return FALSE;
2080 2066
2081 CPDF_FormField* pFormField = FieldArray[0]; 2067 CPDF_FormField* pFormField = FieldArray[0];
2082 CPDFSDK_InterForm* pInterForm = 2068 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
2083 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
2084 CPDFSDK_Widget* pWidget = 2069 CPDFSDK_Widget* pWidget =
2085 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true); 2070 pInterForm->GetWidget(GetSmartFieldControl(pFormField), true);
2086 if (!pWidget) 2071 if (!pWidget)
2087 return FALSE; 2072 return FALSE;
2088 2073
2089 CFX_FloatRect crRect = pWidget->GetRect(); 2074 CFX_FloatRect crRect = pWidget->GetRect();
2090 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left)); 2075 Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left));
2091 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top)); 2076 Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top));
2092 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)); 2077 Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right));
2093 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)); 2078 Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom));
2094 2079
2095 CJS_Array rcArray; 2080 CJS_Array rcArray;
2096 rcArray.SetElement(pRuntime, 0, Upper_Leftx); 2081 rcArray.SetElement(pRuntime, 0, Upper_Leftx);
2097 rcArray.SetElement(pRuntime, 1, Upper_Lefty); 2082 rcArray.SetElement(pRuntime, 1, Upper_Lefty);
2098 rcArray.SetElement(pRuntime, 2, Lower_Rightx); 2083 rcArray.SetElement(pRuntime, 2, Lower_Rightx);
2099 rcArray.SetElement(pRuntime, 3, Lower_Righty); 2084 rcArray.SetElement(pRuntime, 3, Lower_Righty);
2100 vp << rcArray; 2085 vp << rcArray;
2101 } 2086 }
2102 return TRUE; 2087 return TRUE;
2103 } 2088 }
2104 2089
2105 void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, 2090 void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
2106 const CFX_WideString& swFieldName, 2091 const CFX_WideString& swFieldName,
2107 int nControlIndex, 2092 int nControlIndex,
2108 const CFX_FloatRect& rect) { 2093 const CFX_FloatRect& rect) {
2109 CPDFSDK_InterForm* pInterForm = 2094 CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
2110 pFormFillEnv->GetSDKDocument()->GetInterForm();
2111 std::vector<CPDF_FormField*> FieldArray = 2095 std::vector<CPDF_FormField*> FieldArray =
2112 GetFormFields(pFormFillEnv, swFieldName); 2096 GetFormFields(pFormFillEnv, swFieldName);
2113 for (CPDF_FormField* pFormField : FieldArray) { 2097 for (CPDF_FormField* pFormField : FieldArray) {
2114 if (nControlIndex < 0) { 2098 if (nControlIndex < 0) {
2115 FX_BOOL bSet = FALSE; 2099 FX_BOOL bSet = FALSE;
2116 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) { 2100 for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
2117 CPDF_FormControl* pFormControl = pFormField->GetControl(i); 2101 CPDF_FormControl* pFormControl = pFormField->GetControl(i);
2118 ASSERT(pFormControl); 2102 ASSERT(pFormControl);
2119 2103
2120 if (CPDFSDK_Widget* pWidget = 2104 if (CPDFSDK_Widget* pWidget =
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
3208 CFX_WideString& sError) { 3192 CFX_WideString& sError) {
3209 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); 3193 std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
3210 if (FieldArray.empty()) 3194 if (FieldArray.empty())
3211 return FALSE; 3195 return FALSE;
3212 3196
3213 CPDF_FormField* pFormField = FieldArray[0]; 3197 CPDF_FormField* pFormField = FieldArray[0];
3214 int32_t nCount = pFormField->CountControls(); 3198 int32_t nCount = pFormField->CountControls();
3215 if (nCount < 1) 3199 if (nCount < 1)
3216 return FALSE; 3200 return FALSE;
3217 3201
3218 CPDFSDK_InterForm* pInterForm = 3202 CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
3219 m_pFormFillEnv->GetSDKDocument()->GetInterForm();
3220 CPDFSDK_Widget* pWidget = nullptr; 3203 CPDFSDK_Widget* pWidget = nullptr;
3221 if (nCount == 1) { 3204 if (nCount == 1) {
3222 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false); 3205 pWidget = pInterForm->GetWidget(pFormField->GetControl(0), false);
3223 } else { 3206 } else {
3224 UnderlyingPageType* pPage = 3207 UnderlyingPageType* pPage =
3225 UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage( 3208 UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage(
3226 m_pFormFillEnv->GetUnderlyingDocument())); 3209 m_pFormFillEnv->GetUnderlyingDocument()));
3227 if (!pPage) 3210 if (!pPage)
3228 return FALSE; 3211 return FALSE;
3229 if (CPDFSDK_PageView* pCurPageView = 3212 if (CPDFSDK_PageView* pCurPageView =
3230 m_pFormFillEnv->GetSDKDocument()->GetPageView(pPage, true)) { 3213 m_pFormFillEnv->GetPageView(pPage, true)) {
3231 for (int32_t i = 0; i < nCount; i++) { 3214 for (int32_t i = 0; i < nCount; i++) {
3232 if (CPDFSDK_Widget* pTempWidget = 3215 if (CPDFSDK_Widget* pTempWidget =
3233 pInterForm->GetWidget(pFormField->GetControl(i), false)) { 3216 pInterForm->GetWidget(pFormField->GetControl(i), false)) {
3234 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) { 3217 if (pTempWidget->GetPDFPage() == pCurPageView->GetPDFPage()) {
3235 pWidget = pTempWidget; 3218 pWidget = pTempWidget;
3236 break; 3219 break;
3237 } 3220 }
3238 } 3221 }
3239 } 3222 }
3240 } 3223 }
3241 } 3224 }
3242 3225
3243 if (pWidget) { 3226 if (pWidget) {
3244 CPDFSDK_Annot::ObservedPtr pObserved(pWidget); 3227 CPDFSDK_Annot::ObservedPtr pObserved(pWidget);
3245 m_pFormFillEnv->GetSDKDocument()->SetFocusAnnot(&pObserved); 3228 m_pFormFillEnv->SetFocusAnnot(&pObserved);
3246 } 3229 }
3247 3230
3248 return TRUE; 3231 return TRUE;
3249 } 3232 }
3250 3233
3251 FX_BOOL Field::setItems(IJS_Context* cc, 3234 FX_BOOL Field::setItems(IJS_Context* cc,
3252 const std::vector<CJS_Value>& params, 3235 const std::vector<CJS_Value>& params,
3253 CJS_Value& vRet, 3236 CJS_Value& vRet,
3254 CFX_WideString& sError) { 3237 CFX_WideString& sError) {
3255 return TRUE; 3238 return TRUE;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 } 3495 }
3513 } 3496 }
3514 3497
3515 void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv, 3498 void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
3516 int nPageIndex, 3499 int nPageIndex,
3517 int nFieldType, 3500 int nFieldType,
3518 const CFX_WideString& sName, 3501 const CFX_WideString& sName,
3519 const CFX_FloatRect& rcCoords) { 3502 const CFX_FloatRect& rcCoords) {
3520 // Not supported. 3503 // Not supported.
3521 } 3504 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698