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

Side by Side Diff: core/fpdfdoc/include/fpdf_doc.h

Issue 2183313004: Split fpdfdoc/include/fpdf_doc.h into individual classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: review feedback Created 4 years, 4 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 | « core/fpdfdoc/include/cpdf_viewerpreferences.h ('k') | core/fpdfdoc/include/ipdf_formnotify.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_
8 #define CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_
9
10 #include <map>
11 #include <memory>
12 #include <unordered_map>
13 #include <vector>
14
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
16 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
17 #include "core/fpdfdoc/cpdf_annot.h"
18 #include "core/fpdfdoc/cpdf_annotlist.h"
19 #include "core/fxge/include/fx_dib.h"
20
21 class CFDF_Document;
22 class CFieldTree;
23 class CFX_RenderDevice;
24 class CPDF_AAction;
25 class CPDF_Action;
26 class CPDF_ActionFields;
27 class CPDF_ApSettings;
28 class CPDF_Bookmark;
29 class CPDF_BookmarkTree;
30 class CPDF_DefaultAppearance;
31 class CPDF_Dest;
32 class CPDF_DocJSActions;
33 class CPDF_Document;
34 class CPDF_FileSpec;
35 class CPDF_Font;
36 class CPDF_Form;
37 class CPDF_FormControl;
38 class CPDF_FormField;
39 class CPDF_IconFit;
40 class CPDF_Link;
41 class CPDF_Metadata;
42 class CPDF_OCContext;
43 class CPDF_Page;
44 class CPDF_PageObject;
45 class CPDF_RenderContext;
46 class CPDF_RenderOptions;
47 class CXML_Element;
48 class IPDF_FormNotify;
49
50 enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE };
51
52 class CPDF_NameTree {
53 public:
54 explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
55 CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category);
56
57 CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const;
58 CPDF_Object* LookupValue(const CFX_ByteString& csName) const;
59 CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName);
60 int GetIndex(const CFX_ByteString& csName) const;
61 size_t GetCount() const;
62 CPDF_Dictionary* GetRoot() const { return m_pRoot; }
63
64 protected:
65 CPDF_Dictionary* m_pRoot;
66 };
67
68 class CPDF_BookmarkTree {
69 public:
70 explicit CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {}
71
72 CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const;
73 CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const;
74 CPDF_Document* GetDocument() const { return m_pDocument; }
75
76 protected:
77 CPDF_Document* const m_pDocument;
78 };
79
80 #define PDFBOOKMARK_ITALIC 1
81 #define PDFBOOKMARK_BOLD 2
82 class CPDF_Bookmark {
83 public:
84 CPDF_Bookmark() : m_pDict(nullptr) {}
85 explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
86
87 CPDF_Dictionary* GetDict() const { return m_pDict; }
88 uint32_t GetColorRef() const;
89 uint32_t GetFontStyle() const;
90 CFX_WideString GetTitle() const;
91 CPDF_Dest GetDest(CPDF_Document* pDocument) const;
92 CPDF_Action GetAction() const;
93
94 protected:
95 CPDF_Dictionary* m_pDict;
96 };
97
98 #define PDFZOOM_XYZ 1
99 #define PDFZOOM_FITPAGE 2
100 #define PDFZOOM_FITHORZ 3
101 #define PDFZOOM_FITVERT 4
102 #define PDFZOOM_FITRECT 5
103 #define PDFZOOM_FITBBOX 6
104 #define PDFZOOM_FITBHORZ 7
105 #define PDFZOOM_FITBVERT 8
106 class CPDF_Dest {
107 public:
108 CPDF_Dest() : m_pObj(nullptr) {}
109 explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) {}
110
111 CPDF_Object* GetObject() const { return m_pObj; }
112 CFX_ByteString GetRemoteName();
113 int GetPageIndex(CPDF_Document* pDoc);
114 uint32_t GetPageObjNum();
115 int GetZoomMode();
116 FX_FLOAT GetParam(int index);
117
118 protected:
119 CPDF_Object* m_pObj;
120 };
121
122 class CPDF_OCContext {
123 public:
124 enum UsageType { View = 0, Design, Print, Export };
125
126 CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType);
127 ~CPDF_OCContext();
128
129 bool CheckOCGVisible(const CPDF_Dictionary* pOCGDict);
130 bool CheckObjectVisible(const CPDF_PageObject* pObj);
131
132 protected:
133 bool LoadOCGStateFromConfig(const CFX_ByteString& csConfig,
134 const CPDF_Dictionary* pOCGDict) const;
135 bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const;
136 bool GetOCGVisible(const CPDF_Dictionary* pOCGDict);
137 bool GetOCGVE(CPDF_Array* pExpression, int nLevel);
138 bool LoadOCMDState(const CPDF_Dictionary* pOCMDDict);
139
140 CPDF_Document* const m_pDocument;
141 const UsageType m_eUsageType;
142 std::unordered_map<const CPDF_Dictionary*, bool> m_OCGStates;
143 };
144
145 class CPDF_ActionFields {
146 public:
147 explicit CPDF_ActionFields(const CPDF_Action* pAction) : m_pAction(pAction) {}
148
149 size_t GetFieldsCount() const;
150 std::vector<CPDF_Object*> GetAllFields() const;
151 CPDF_Object* GetField(size_t iIndex) const;
152
153 protected:
154 const CPDF_Action* const m_pAction;
155 };
156
157 #define PDFNAMED_NEXTPAGE 1
158 #define PDFNAMED_PREVPAGE 2
159 #define PDFNAMED_FIRSTPAGE 3
160 #define PDFNAMED_LASTPAGE 4
161 #define PDFJS_MAXLENGTH 64
162 class CPDF_Action {
163 public:
164 enum ActionType {
165 Unknown = 0,
166 GoTo,
167 GoToR,
168 GoToE,
169 Launch,
170 Thread,
171 URI,
172 Sound,
173 Movie,
174 Hide,
175 Named,
176 SubmitForm,
177 ResetForm,
178 ImportData,
179 JavaScript,
180 SetOCGState,
181 Rendition,
182 Trans,
183 GoTo3DView
184 };
185
186 CPDF_Action() : m_pDict(nullptr) {}
187 explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
188
189 CPDF_Dictionary* GetDict() const { return m_pDict; }
190 ActionType GetType() const;
191 CPDF_Dest GetDest(CPDF_Document* pDoc) const;
192 CFX_WideString GetFilePath() const;
193 CFX_ByteString GetURI(CPDF_Document* pDoc) const;
194 bool GetHideStatus() const { return m_pDict->GetBooleanBy("H", true); }
195 CFX_ByteString GetNamedAction() const { return m_pDict->GetStringBy("N"); }
196 uint32_t GetFlags() const { return m_pDict->GetIntegerBy("Flags"); }
197 CFX_WideString GetJavaScript() const;
198 size_t GetSubActionsCount() const;
199 CPDF_Action GetSubAction(size_t iIndex) const;
200
201 protected:
202 CPDF_Dictionary* const m_pDict;
203 };
204
205 class CPDF_AAction {
206 public:
207 enum AActionType {
208 CursorEnter = 0,
209 CursorExit,
210 ButtonDown,
211 ButtonUp,
212 GetFocus,
213 LoseFocus,
214 PageOpen,
215 PageClose,
216 PageVisible,
217 PageInvisible,
218 OpenPage,
219 ClosePage,
220 KeyStroke,
221 Format,
222 Validate,
223 Calculate,
224 CloseDocument,
225 SaveDocument,
226 DocumentSaved,
227 PrintDocument,
228 DocumentPrinted
229 };
230
231 CPDF_AAction() : m_pDict(nullptr) {}
232 explicit CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
233
234 FX_BOOL ActionExist(AActionType eType) const;
235 CPDF_Action GetAction(AActionType eType) const;
236 CPDF_Dictionary* GetDict() const { return m_pDict; }
237
238 protected:
239 CPDF_Dictionary* const m_pDict;
240 };
241
242 class CPDF_DocJSActions {
243 public:
244 explicit CPDF_DocJSActions(CPDF_Document* pDoc);
245
246 int CountJSActions() const;
247 CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const;
248 CPDF_Action GetJSAction(const CFX_ByteString& csName) const;
249 int FindJSAction(const CFX_ByteString& csName) const;
250 CPDF_Document* GetDocument() const { return m_pDocument; }
251
252 protected:
253 CPDF_Document* const m_pDocument;
254 };
255
256 class CPDF_FileSpec {
257 public:
258 CPDF_FileSpec();
259 explicit CPDF_FileSpec(CPDF_Object* pObj) : m_pObj(pObj) {}
260
261 // Convert a platform dependent file name into pdf format.
262 static CFX_WideString EncodeFileName(const CFX_WideStringC& filepath);
263
264 // Convert a pdf file name into platform dependent format.
265 static CFX_WideString DecodeFileName(const CFX_WideStringC& filepath);
266
267 CPDF_Object* GetObj() const { return m_pObj; }
268 bool GetFileName(CFX_WideString* wsFileName) const;
269
270 // Set this file spec to refer to a file name (not a url).
271 void SetFileName(const CFX_WideStringC& wsFileName);
272
273 protected:
274 CPDF_Object* m_pObj;
275 };
276
277 class CPDF_LinkList {
278 public:
279 CPDF_LinkList();
280 ~CPDF_LinkList();
281
282 CPDF_Link GetLinkAtPoint(CPDF_Page* pPage,
283 FX_FLOAT pdf_x,
284 FX_FLOAT pdf_y,
285 int* z_order);
286
287 private:
288 const std::vector<CPDF_Dictionary*>* GetPageLinks(CPDF_Page* pPage);
289 void LoadPageLinks(CPDF_Page* pPage, std::vector<CPDF_Dictionary*>* pList);
290
291 std::map<uint32_t, std::vector<CPDF_Dictionary*>> m_PageMap;
292 };
293
294 class CPDF_Link {
295 public:
296 CPDF_Link() : m_pDict(nullptr) {}
297 explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
298
299 CPDF_Dictionary* GetDict() const { return m_pDict; }
300
301 CFX_FloatRect GetRect();
302 CPDF_Dest GetDest(CPDF_Document* pDoc);
303 CPDF_Action GetAction();
304
305 protected:
306 CPDF_Dictionary* m_pDict;
307 };
308
309 #define COLORTYPE_TRANSPARENT 0
310 #define COLORTYPE_GRAY 1
311 #define COLORTYPE_RGB 2
312 #define COLORTYPE_CMYK 3
313 class CPDF_DefaultAppearance {
314 public:
315 CPDF_DefaultAppearance() {}
316 explicit CPDF_DefaultAppearance(const CFX_ByteString& csDA) : m_csDA(csDA) {}
317
318 CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) {
319 m_csDA = cDA.GetStr();
320 }
321
322 CFX_ByteString GetStr() const { return m_csDA; }
323 FX_BOOL HasFont();
324 CFX_ByteString GetFontString();
325 void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize);
326 FX_BOOL HasColor(FX_BOOL bStrokingOperation = FALSE);
327 CFX_ByteString GetColorString(FX_BOOL bStrokingOperation = FALSE);
328 void GetColor(int& iColorType,
329 FX_FLOAT fc[4],
330 FX_BOOL bStrokingOperation = FALSE);
331 void GetColor(FX_ARGB& color,
332 int& iColorType,
333 FX_BOOL bStrokingOperation = FALSE);
334 FX_BOOL HasTextMatrix();
335 CFX_ByteString GetTextMatrixString();
336 CFX_Matrix GetTextMatrix();
337
338 protected:
339 CFX_ByteString m_csDA;
340 };
341
342 #define FIELDTYPE_UNKNOWN 0
343 #define FIELDTYPE_PUSHBUTTON 1
344 #define FIELDTYPE_CHECKBOX 2
345 #define FIELDTYPE_RADIOBUTTON 3
346 #define FIELDTYPE_COMBOBOX 4
347 #define FIELDTYPE_LISTBOX 5
348 #define FIELDTYPE_TEXTFIELD 6
349 #define FIELDTYPE_SIGNATURE 7
350
351 class CPDF_InterForm {
352 public:
353 explicit CPDF_InterForm(CPDF_Document* pDocument);
354 ~CPDF_InterForm();
355
356 static void SetUpdateAP(FX_BOOL bUpdateAP);
357 static FX_BOOL IsUpdateAPEnabled();
358 static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict,
359 const FX_CHAR* csType,
360 int iMinLen = 2,
361 const FX_CHAR* csPrefix = "");
362 static CPDF_Font* AddStandardFont(CPDF_Document* pDocument,
363 CFX_ByteString csFontName);
364 static CFX_ByteString GetNativeFont(uint8_t iCharSet,
365 void* pLogFont = nullptr);
366 static CFX_ByteString GetNativeFont(void* pLogFont = nullptr);
367 static uint8_t GetNativeCharSet();
368 static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument);
369 static CPDF_Font* AddNativeFont(CPDF_Document* pDocument);
370
371 FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType);
372 FX_BOOL ValidateFieldName(const CPDF_FormField* pField,
373 CFX_WideString& csNewFieldName);
374 FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl,
375 CFX_WideString& csNewFieldName);
376
377 uint32_t CountFields(const CFX_WideString& csFieldName = L"");
378 CPDF_FormField* GetField(uint32_t index,
379 const CFX_WideString& csFieldName = L"");
380 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
381
382 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage,
383 FX_FLOAT pdf_x,
384 FX_FLOAT pdf_y,
385 int* z_order) const;
386 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const;
387
388 CPDF_Document* GetDocument() const { return m_pDocument; }
389 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; }
390 FX_BOOL NeedConstructAP() const;
391 int CountFieldsInCalculationOrder();
392 CPDF_FormField* GetFieldInCalculationOrder(int index);
393 int FindFieldInCalculationOrder(const CPDF_FormField* pField);
394
395 uint32_t CountFormFonts();
396 CPDF_Font* GetFormFont(uint32_t index, CFX_ByteString& csNameTag);
397 CPDF_Font* GetFormFont(CFX_ByteString csNameTag);
398 CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag);
399 CPDF_Font* GetNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag);
400 CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag);
401 FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
402 FX_BOOL FindFormFont(CFX_ByteString csFontName,
403 CPDF_Font*& pFont,
404 CFX_ByteString& csNameTag);
405
406 FX_BOOL FindFormFont(CFX_WideString csFontName,
407 CPDF_Font*& pFont,
408 CFX_ByteString& csNameTag) {
409 return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag);
410 }
411
412 void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag);
413 CPDF_Font* AddNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag);
414 CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag);
415
416 void RemoveFormFont(const CPDF_Font* pFont);
417 void RemoveFormFont(CFX_ByteString csNameTag);
418
419 CPDF_DefaultAppearance GetDefaultAppearance();
420 CPDF_Font* GetDefaultFormFont();
421 int GetFormAlignment();
422
423 CPDF_FormField* CheckRequiredFields(
424 const std::vector<CPDF_FormField*>* fields,
425 bool bIncludeOrExclude) const;
426
427 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path,
428 bool bSimpleFileSpec = false) const;
429 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path,
430 const std::vector<CPDF_FormField*>& fields,
431 bool bIncludeOrExclude = true,
432 bool bSimpleFileSpec = false) const;
433 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE);
434
435 bool ResetForm(const std::vector<CPDF_FormField*>& fields,
436 bool bIncludeOrExclude = true,
437 bool bNotify = false);
438 bool ResetForm(bool bNotify = false);
439
440 void SetFormNotify(IPDF_FormNotify* pNotify);
441 FX_BOOL HasXFAForm() const;
442 void FixPageFields(const CPDF_Page* pPage);
443
444 protected:
445 static FX_BOOL s_bUpdateAP;
446
447 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0);
448 CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name);
449 CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict);
450 CPDF_FormControl* AddControl(CPDF_FormField* pField,
451 CPDF_Dictionary* pWidgetDict);
452 void FDF_ImportField(CPDF_Dictionary* pField,
453 const CFX_WideString& parent_name,
454 FX_BOOL bNotify = FALSE,
455 int nLevel = 0);
456 FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName,
457 int iType,
458 const CPDF_FormField* pExcludedField,
459 const CPDF_FormControl* pExcludedControl);
460 int CompareFieldName(const CFX_WideString& name1,
461 const CFX_WideString& name2);
462 int CompareFieldName(const CFX_ByteString& name1,
463 const CFX_ByteString& name2);
464
465 CPDF_Document* const m_pDocument;
466 CPDF_Dictionary* m_pFormDict;
467 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap;
468 std::unique_ptr<CFieldTree> m_pFieldTree;
469 CFX_ByteString m_bsEncoding;
470 IPDF_FormNotify* m_pFormNotify;
471
472 friend class CPDF_FormControl;
473 friend class CPDF_FormField;
474 };
475
476 #define FORMFIELD_READONLY 0x01
477 #define FORMFIELD_REQUIRED 0x02
478 #define FORMFIELD_NOEXPORT 0x04
479 #define FORMRADIO_NOTOGGLEOFF 0x100
480 #define FORMRADIO_UNISON 0x200
481 #define FORMTEXT_MULTILINE 0x100
482 #define FORMTEXT_PASSWORD 0x200
483 #define FORMTEXT_NOSCROLL 0x400
484 #define FORMTEXT_COMB 0x800
485 #define FORMCOMBO_EDIT 0x100
486 #define FORMLIST_MULTISELECT 0x100
487
488 class CPDF_FormField {
489 public:
490 enum Type {
491 Unknown,
492 PushButton,
493 RadioButton,
494 CheckBox,
495 Text,
496 RichText,
497 File,
498 ListBox,
499 ComboBox,
500 Sign
501 };
502
503 CFX_WideString GetFullName() const;
504
505 Type GetType() const { return m_Type; }
506 uint32_t GetFlags() const { return m_Flags; }
507
508 CPDF_Dictionary* GetFieldDict() const { return m_pDict; }
509 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; }
510
511 FX_BOOL ResetField(FX_BOOL bNotify = FALSE);
512
513 int CountControls() const { return m_ControlList.GetSize(); }
514
515 CPDF_FormControl* GetControl(int index) const {
516 return m_ControlList.GetAt(index);
517 }
518
519 int GetControlIndex(const CPDF_FormControl* pControl) const;
520 int GetFieldType() const;
521
522 CPDF_AAction GetAdditionalAction() const;
523 CFX_WideString GetAlternateName() const;
524 CFX_WideString GetMappingName() const;
525
526 uint32_t GetFieldFlags() const;
527 CFX_ByteString GetDefaultStyle() const;
528 CFX_WideString GetRichTextString() const;
529
530 CFX_WideString GetValue() const;
531 CFX_WideString GetDefaultValue() const;
532 FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE);
533
534 int GetMaxLen() const;
535 int CountSelectedItems() const;
536 int GetSelectedIndex(int index) const;
537
538 FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE);
539 FX_BOOL IsItemSelected(int index) const;
540 FX_BOOL SetItemSelection(int index,
541 FX_BOOL bSelected,
542 FX_BOOL bNotify = FALSE);
543
544 FX_BOOL IsItemDefaultSelected(int index) const;
545
546 int GetDefaultSelectedItem() const;
547 int CountOptions() const;
548
549 CFX_WideString GetOptionLabel(int index) const;
550 CFX_WideString GetOptionValue(int index) const;
551
552 int FindOption(CFX_WideString csOptLabel) const;
553 int FindOptionValue(const CFX_WideString& csOptValue) const;
554
555 FX_BOOL CheckControl(int iControlIndex, bool bChecked, bool bNotify = false);
556
557 int GetTopVisibleIndex() const;
558 int CountSelectedOptions() const;
559
560 int GetSelectedOptionIndex(int index) const;
561 FX_BOOL IsOptionSelected(int iOptIndex) const;
562
563 FX_BOOL SelectOption(int iOptIndex,
564 FX_BOOL bSelected,
565 FX_BOOL bNotify = FALSE);
566
567 FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE);
568
569 #ifdef PDF_ENABLE_XFA
570 FX_BOOL ClearOptions(FX_BOOL bNotify = FALSE);
571
572 int InsertOption(CFX_WideString csOptLabel,
573 int index = -1,
574 FX_BOOL bNotify = FALSE);
575 #endif // PDF_ENABLE_XFA
576
577 FX_FLOAT GetFontSize() const { return m_FontSize; }
578 CPDF_Font* GetFont() const { return m_pFont; }
579
580 protected:
581 CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict);
582 ~CPDF_FormField();
583
584 CFX_WideString GetValue(FX_BOOL bDefault) const;
585 FX_BOOL SetValue(const CFX_WideString& value,
586 FX_BOOL bDefault,
587 FX_BOOL bNotify);
588
589 void SyncFieldFlags();
590 int FindListSel(CPDF_String* str);
591 CFX_WideString GetOptionText(int index, int sub_index) const;
592
593 void LoadDA();
594 CFX_WideString GetCheckValue(FX_BOOL bDefault) const;
595 FX_BOOL SetCheckValue(const CFX_WideString& value,
596 FX_BOOL bDefault,
597 FX_BOOL bNotify);
598
599 bool NotifyBeforeSelectionChange(const CFX_WideString& value);
600 void NotifyAfterSelectionChange();
601
602 bool NotifyBeforeValueChange(const CFX_WideString& value);
603 void NotifyAfterValueChange();
604
605 bool NotifyListOrComboBoxBeforeChange(const CFX_WideString& value);
606 void NotifyListOrComboBoxAfterChange();
607
608 CPDF_FormField::Type m_Type;
609 uint32_t m_Flags;
610 CPDF_InterForm* m_pForm;
611 CPDF_Dictionary* m_pDict;
612 CFX_ArrayTemplate<CPDF_FormControl*> m_ControlList;
613 FX_FLOAT m_FontSize;
614 CPDF_Font* m_pFont;
615
616 friend class CPDF_InterForm;
617 friend class CPDF_FormControl;
618 };
619
620 CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict,
621 const FX_CHAR* name,
622 int nLevel = 0);
623 class CPDF_IconFit {
624 public:
625 enum ScaleMethod { Always = 0, Bigger, Smaller, Never };
626
627 explicit CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
628
629 ScaleMethod GetScaleMethod();
630 FX_BOOL IsProportionalScale();
631 void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom);
632 bool GetFittingBounds();
633 const CPDF_Dictionary* GetDict() const { return m_pDict; }
634
635 protected:
636 const CPDF_Dictionary* const m_pDict;
637 };
638
639 #define TEXTPOS_CAPTION 0
640 #define TEXTPOS_ICON 1
641 #define TEXTPOS_BELOW 2
642 #define TEXTPOS_ABOVE 3
643 #define TEXTPOS_RIGHT 4
644 #define TEXTPOS_LEFT 5
645 #define TEXTPOS_OVERLAID 6
646
647 class CPDF_FormControl {
648 public:
649 enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle };
650
651 CPDF_FormField::Type GetType() const { return m_pField->GetType(); }
652 CPDF_InterForm* GetInterForm() const { return m_pForm; }
653 CPDF_FormField* GetField() const { return m_pField; }
654 CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; }
655 CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectBy("Rect"); }
656
657 void DrawControl(CFX_RenderDevice* pDevice,
658 CFX_Matrix* pMatrix,
659 CPDF_Page* pPage,
660 CPDF_Annot::AppearanceMode mode,
661 const CPDF_RenderOptions* pOptions = nullptr);
662
663 CFX_ByteString GetCheckedAPState();
664 CFX_WideString GetExportValue() const;
665
666 bool IsChecked() const;
667 bool IsDefaultChecked() const;
668
669 HighlightingMode GetHighlightingMode();
670 bool HasMKEntry(const CFX_ByteString& csEntry) const;
671 int GetRotation();
672
673 FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); }
674
675 FX_FLOAT GetOriginalBorderColor(int index) {
676 return GetOriginalColor(index, "BC");
677 }
678
679 void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) {
680 GetOriginalColor(iColorType, fc, "BC");
681 }
682
683 FX_ARGB GetBackgroundColor(int& iColorType) {
684 return GetColor(iColorType, "BG");
685 }
686
687 FX_FLOAT GetOriginalBackgroundColor(int index) {
688 return GetOriginalColor(index, "BG");
689 }
690
691 void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) {
692 GetOriginalColor(iColorType, fc, "BG");
693 }
694
695 CFX_WideString GetNormalCaption() { return GetCaption("CA"); }
696 CFX_WideString GetRolloverCaption() { return GetCaption("RC"); }
697 CFX_WideString GetDownCaption() { return GetCaption("AC"); }
698
699 CPDF_Stream* GetNormalIcon() { return GetIcon("I"); }
700 CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); }
701 CPDF_Stream* GetDownIcon() { return GetIcon("IX"); }
702 CPDF_IconFit GetIconFit();
703
704 int GetTextPosition();
705 CPDF_Action GetAction();
706 CPDF_AAction GetAdditionalAction();
707 CPDF_DefaultAppearance GetDefaultAppearance();
708
709 CPDF_Font* GetDefaultControlFont();
710 int GetControlAlignment();
711
712 protected:
713 CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict);
714
715 CFX_ByteString GetOnStateName() const;
716 void SetOnStateName(const CFX_ByteString& csOn);
717 void CheckControl(FX_BOOL bChecked);
718 FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry);
719 FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry);
720 void GetOriginalColor(int& iColorType,
721 FX_FLOAT fc[4],
722 const CFX_ByteString& csEntry);
723
724 CFX_WideString GetCaption(const CFX_ByteString& csEntry);
725 CPDF_Stream* GetIcon(const CFX_ByteString& csEntry);
726 CPDF_ApSettings GetMK() const;
727
728 CPDF_FormField* const m_pField;
729 CPDF_Dictionary* const m_pWidgetDict;
730 CPDF_InterForm* const m_pForm;
731
732 friend class CPDF_InterForm;
733 friend class CPDF_FormField;
734 };
735
736 class IPDF_FormNotify {
737 public:
738 virtual ~IPDF_FormNotify();
739
740 virtual int BeforeValueChange(CPDF_FormField* pField,
741 const CFX_WideString& csValue);
742 virtual void AfterValueChange(CPDF_FormField* pField);
743 virtual int BeforeSelectionChange(CPDF_FormField* pField,
744 const CFX_WideString& csValue);
745 virtual void AfterSelectionChange(CPDF_FormField* pField);
746 virtual void AfterCheckedStatusChange(CPDF_FormField* pField);
747 virtual int BeforeFormReset(CPDF_InterForm* pForm);
748 virtual void AfterFormReset(CPDF_InterForm* pForm);
749 virtual int BeforeFormImportData(CPDF_InterForm* pForm);
750 virtual void AfterFormImportData(CPDF_InterForm* pForm);
751 };
752
753 class CPDF_PageLabel {
754 public:
755 explicit CPDF_PageLabel(CPDF_Document* pDocument);
756
757 CFX_WideString GetLabel(int nPage) const;
758 int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const;
759 int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const;
760
761 protected:
762 CPDF_Document* const m_pDocument;
763 };
764
765 class CPDF_Metadata {
766 public:
767 explicit CPDF_Metadata(CPDF_Document* pDoc);
768 ~CPDF_Metadata();
769
770 const CXML_Element* GetRoot() const;
771
772 private:
773 std::unique_ptr<CXML_Element> m_pXmlElement;
774 };
775
776 class CPDF_ViewerPreferences {
777 public:
778 explicit CPDF_ViewerPreferences(CPDF_Document* pDoc);
779 ~CPDF_ViewerPreferences();
780
781 FX_BOOL IsDirectionR2L() const;
782 FX_BOOL PrintScaling() const;
783 int32_t NumCopies() const;
784 CPDF_Array* PrintPageRange() const;
785 CFX_ByteString Duplex() const;
786
787 protected:
788 CPDF_Dictionary* GetViewerPreferences() const;
789
790 CPDF_Document* const m_pDoc;
791 };
792
793 class CPDF_ApSettings {
794 public:
795 explicit CPDF_ApSettings(CPDF_Dictionary* pDict);
796
797 bool HasMKEntry(const CFX_ByteString& csEntry) const;
798 int GetRotation() const;
799
800 FX_ARGB GetBorderColor(int& iColorType) const {
801 return GetColor(iColorType, "BC");
802 }
803
804 FX_FLOAT GetOriginalBorderColor(int index) const {
805 return GetOriginalColor(index, "BC");
806 }
807
808 void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) const {
809 GetOriginalColor(iColorType, fc, "BC");
810 }
811
812 FX_ARGB GetBackgroundColor(int& iColorType) const {
813 return GetColor(iColorType, "BG");
814 }
815
816 FX_FLOAT GetOriginalBackgroundColor(int index) const {
817 return GetOriginalColor(index, "BG");
818 }
819
820 void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) const {
821 GetOriginalColor(iColorType, fc, "BG");
822 }
823
824 CFX_WideString GetNormalCaption() const { return GetCaption("CA"); }
825 CFX_WideString GetRolloverCaption() const { return GetCaption("RC"); }
826 CFX_WideString GetDownCaption() const { return GetCaption("AC"); }
827 CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); }
828 CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); }
829 CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); }
830 CPDF_IconFit GetIconFit() const;
831 int GetTextPosition() const;
832
833 protected:
834 friend class CPDF_FormControl;
835
836 FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const;
837 FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry) const;
838 void GetOriginalColor(int& iColorType,
839 FX_FLOAT fc[4],
840 const CFX_ByteString& csEntry) const;
841
842 CFX_WideString GetCaption(const CFX_ByteString& csEntry) const;
843 CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const;
844
845 CPDF_Dictionary* const m_pDict;
846 };
847
848 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
849 CPDF_Annot::AppearanceMode mode);
850
851 #endif // CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_
OLDNEW
« no previous file with comments | « core/fpdfdoc/include/cpdf_viewerpreferences.h ('k') | core/fpdfdoc/include/ipdf_formnotify.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698