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

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

Issue 1834203002: use std::vector in more places in JavaScript bindings code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@util_printx
Patch Set: Nits. Created 4 years, 8 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
« no previous file with comments | « no previous file | fpdfsdk/javascript/Field.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef FPDFSDK_JAVASCRIPT_FIELD_H_ 7 #ifndef FPDFSDK_JAVASCRIPT_FIELD_H_
8 #define FPDFSDK_JAVASCRIPT_FIELD_H_ 8 #define FPDFSDK_JAVASCRIPT_FIELD_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 FP_ROTATION, 46 FP_ROTATION,
47 FP_STROKECOLOR, 47 FP_STROKECOLOR,
48 FP_STYLE, 48 FP_STYLE,
49 FP_TEXTCOLOR, 49 FP_TEXTCOLOR,
50 FP_TEXTFONT, 50 FP_TEXTFONT,
51 FP_TEXTSIZE, 51 FP_TEXTSIZE,
52 FP_USERNAME, 52 FP_USERNAME,
53 FP_VALUE 53 FP_VALUE
54 }; 54 };
55 55
56 class CJS_WideStringArray { 56 struct CJS_DelayData {
57 public: 57 CJS_DelayData(FIELD_PROP prop, int idx, const CFX_WideString& name)
58 CJS_WideStringArray() {} 58 : eProp(prop), nControlIndex(idx), sFieldName(name) {}
59 virtual ~CJS_WideStringArray() {
60 for (int i = 0, sz = m_Data.GetSize(); i < sz; i++)
61 delete m_Data.GetAt(i);
62 m_Data.RemoveAll();
63 }
64 59
65 void Add(const CFX_WideString& string) { 60 FIELD_PROP eProp;
66 m_Data.Add(new CFX_WideString(string)); 61 int nControlIndex;
67 }
68
69 int GetSize() const { return m_Data.GetSize(); }
70
71 CFX_WideString GetAt(int i) const { return *m_Data.GetAt(i); }
72
73 private:
74 CFX_ArrayTemplate<CFX_WideString*> m_Data;
75 };
76
77 struct CJS_DelayData {
78 CFX_WideString sFieldName; 62 CFX_WideString sFieldName;
79 int nControlIndex;
80 enum FIELD_PROP eProp;
81 int32_t num; 63 int32_t num;
82 bool b; 64 bool b;
83 CFX_ByteString string; 65 CFX_ByteString string;
84 CFX_WideString widestring; 66 CFX_WideString widestring;
85 CFX_FloatRect rect; 67 CFX_FloatRect rect;
86 CPWL_Color color; 68 CPWL_Color color;
87 CFX_ArrayTemplate<uint32_t> wordarray; 69 std::vector<uint32_t> wordarray;
88 CJS_WideStringArray widestringarray; 70 std::vector<CFX_WideString> widestringarray;
89 }; 71 };
90 72
91 class Field : public CJS_EmbedObj { 73 class Field : public CJS_EmbedObj {
92 public: 74 public:
93 explicit Field(CJS_Object* pJSObject); 75 explicit Field(CJS_Object* pJSObject);
94 ~Field() override; 76 ~Field() override;
95 77
96 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError); 78 FX_BOOL alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
97 FX_BOOL borderStyle(IJS_Context* cc, 79 FX_BOOL borderStyle(IJS_Context* cc,
98 CJS_PropValue& vp, 80 CJS_PropValue& vp,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 const CFX_WideString& swFieldName, 319 const CFX_WideString& swFieldName,
338 int nControlIndex, 320 int nControlIndex,
339 bool b); 321 bool b);
340 static void SetCommitOnSelChange(CPDFSDK_Document* pDocument, 322 static void SetCommitOnSelChange(CPDFSDK_Document* pDocument,
341 const CFX_WideString& swFieldName, 323 const CFX_WideString& swFieldName,
342 int nControlIndex, 324 int nControlIndex,
343 bool b); 325 bool b);
344 static void SetCurrentValueIndices(CPDFSDK_Document* pDocument, 326 static void SetCurrentValueIndices(CPDFSDK_Document* pDocument,
345 const CFX_WideString& swFieldName, 327 const CFX_WideString& swFieldName,
346 int nControlIndex, 328 int nControlIndex,
347 const CFX_ArrayTemplate<uint32_t>& array); 329 const std::vector<uint32_t>& array);
348 static void SetDefaultStyle(CPDFSDK_Document* pDocument, 330 static void SetDefaultStyle(CPDFSDK_Document* pDocument,
349 const CFX_WideString& swFieldName, 331 const CFX_WideString& swFieldName,
350 int nControlIndex); 332 int nControlIndex);
351 static void SetDefaultValue(CPDFSDK_Document* pDocument, 333 static void SetDefaultValue(CPDFSDK_Document* pDocument,
352 const CFX_WideString& swFieldName, 334 const CFX_WideString& swFieldName,
353 int nControlIndex, 335 int nControlIndex,
354 const CFX_WideString& string); 336 const CFX_WideString& string);
355 static void SetDoNotScroll(CPDFSDK_Document* pDocument, 337 static void SetDoNotScroll(CPDFSDK_Document* pDocument,
356 const CFX_WideString& swFieldName, 338 const CFX_WideString& swFieldName,
357 int nControlIndex, 339 int nControlIndex,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 const CFX_WideString& swFieldName, 405 const CFX_WideString& swFieldName,
424 int nControlIndex, 406 int nControlIndex,
425 int number); 407 int number);
426 static void SetUserName(CPDFSDK_Document* pDocument, 408 static void SetUserName(CPDFSDK_Document* pDocument,
427 const CFX_WideString& swFieldName, 409 const CFX_WideString& swFieldName,
428 int nControlIndex, 410 int nControlIndex,
429 const CFX_WideString& string); 411 const CFX_WideString& string);
430 static void SetValue(CPDFSDK_Document* pDocument, 412 static void SetValue(CPDFSDK_Document* pDocument,
431 const CFX_WideString& swFieldName, 413 const CFX_WideString& swFieldName,
432 int nControlIndex, 414 int nControlIndex,
433 const CJS_WideStringArray& strArray); 415 const std::vector<CFX_WideString>& strArray);
434 416
435 static void AddField(CPDFSDK_Document* pDocument, 417 static void AddField(CPDFSDK_Document* pDocument,
436 int nPageIndex, 418 int nPageIndex,
437 int nFieldType, 419 int nFieldType,
438 const CFX_WideString& sName, 420 const CFX_WideString& sName,
439 const CFX_FloatRect& rcCoords); 421 const CFX_FloatRect& rcCoords);
440 422
441 static void UpdateFormField(CPDFSDK_Document* pDocument, 423 static void UpdateFormField(CPDFSDK_Document* pDocument,
442 CPDF_FormField* pFormField, 424 CPDF_FormField* pFormField,
443 FX_BOOL bChangeMark, 425 FX_BOOL bChangeMark,
(...skipping 19 matching lines...) Expand all
463 445
464 protected: 446 protected:
465 void ParseFieldName(const std::wstring& strFieldNameParsed, 447 void ParseFieldName(const std::wstring& strFieldNameParsed,
466 std::wstring& strFieldName, 448 std::wstring& strFieldName,
467 int& iControlNo); 449 int& iControlNo);
468 std::vector<CPDF_FormField*> GetFormFields( 450 std::vector<CPDF_FormField*> GetFormFields(
469 const CFX_WideString& csFieldName) const; 451 const CFX_WideString& csFieldName) const;
470 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField); 452 CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField);
471 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel); 453 FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel);
472 454
473 void AddDelay_Int(enum FIELD_PROP prop, int32_t n); 455 void AddDelay_Int(FIELD_PROP prop, int32_t n);
474 void AddDelay_Bool(enum FIELD_PROP prop, bool b); 456 void AddDelay_Bool(FIELD_PROP prop, bool b);
475 void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string); 457 void AddDelay_String(FIELD_PROP prop, const CFX_ByteString& string);
476 void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string); 458 void AddDelay_WideString(FIELD_PROP prop, const CFX_WideString& string);
477 void AddDelay_Rect(enum FIELD_PROP prop, const CFX_FloatRect& rect); 459 void AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect);
478 void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color); 460 void AddDelay_Color(FIELD_PROP prop, const CPWL_Color& color);
479 void AddDelay_WordArray(enum FIELD_PROP prop, 461 void AddDelay_WordArray(FIELD_PROP prop, const std::vector<uint32_t>& array);
480 const CFX_ArrayTemplate<uint32_t>& array); 462 void AddDelay_WideStringArray(FIELD_PROP prop,
481 void AddDelay_WideStringArray(enum FIELD_PROP prop, 463 const std::vector<CFX_WideString>& array);
482 const CJS_WideStringArray& array);
483 464
484 void DoDelay(); 465 void DoDelay();
485 466
486 public: 467 public:
487 Document* m_pJSDoc; 468 Document* m_pJSDoc;
488 CPDFSDK_Document* m_pDocument; 469 CPDFSDK_Document* m_pDocument;
489 CFX_WideString m_FieldName; 470 CFX_WideString m_FieldName;
490 int m_nFormControlIndex; 471 int m_nFormControlIndex;
491 FX_BOOL m_bCanSet; 472 FX_BOOL m_bCanSet;
492 473
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 JS_STATIC_METHOD(setLock, Field); 558 JS_STATIC_METHOD(setLock, Field);
578 JS_STATIC_METHOD(signatureGetModifications, Field); 559 JS_STATIC_METHOD(signatureGetModifications, Field);
579 JS_STATIC_METHOD(signatureGetSeedValue, Field); 560 JS_STATIC_METHOD(signatureGetSeedValue, Field);
580 JS_STATIC_METHOD(signatureInfo, Field); 561 JS_STATIC_METHOD(signatureInfo, Field);
581 JS_STATIC_METHOD(signatureSetSeedValue, Field); 562 JS_STATIC_METHOD(signatureSetSeedValue, Field);
582 JS_STATIC_METHOD(signatureSign, Field); 563 JS_STATIC_METHOD(signatureSign, Field);
583 JS_STATIC_METHOD(signatureValidate, Field); 564 JS_STATIC_METHOD(signatureValidate, Field);
584 }; 565 };
585 566
586 #endif // FPDFSDK_JAVASCRIPT_FIELD_H_ 567 #endif // FPDFSDK_JAVASCRIPT_FIELD_H_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/javascript/Field.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698