diff options
Diffstat (limited to 'core')
45 files changed, 1257 insertions, 892 deletions
diff --git a/core/fpdfapi/cpdf_pagerendercontext.cpp b/core/fpdfapi/cpdf_pagerendercontext.cpp index 04ae3a8e33..a82a460835 100644 --- a/core/fpdfapi/cpdf_pagerendercontext.cpp +++ b/core/fpdfapi/cpdf_pagerendercontext.cpp @@ -9,8 +9,8 @@ #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" -#include "core/fpdfdoc/cpdf_annotlist.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_annotlist.h" +#include "core/fpdfdoc/include/cpdf_occontext.h" #include "core/fxge/include/fx_ge.h" CPDF_PageRenderContext::CPDF_PageRenderContext() {} diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h index 63141bf297..3cece1c0a8 100644 --- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h +++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h @@ -11,7 +11,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_indirect_object_holder.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_linklist.h" #include "core/fxcrt/include/fx_basic.h" class CFX_Font; diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp index 66beb5b04c..ef208b54fd 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp @@ -27,7 +27,7 @@ #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" #include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_occontext.h" #include "core/fxge/include/fx_ge.h" CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index de9d1099cf..fc0321b46b 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -22,7 +22,7 @@ #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_occontext.h" #include "core/fxcodec/include/fx_codec.h" #include "core/fxcrt/include/fx_safe_types.h" #include "core/fxge/include/fx_ge.h" diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 57e7bc0bbb..18b1e9d946 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fpdfdoc/cpdf_annot.h" +#include "core/fpdfdoc/include/cpdf_annot.h" #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 8b8c0e98bb..1e0e99b476 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -4,14 +4,16 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fpdfdoc/cpdf_annotlist.h" +#include "core/fpdfdoc/include/cpdf_annotlist.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" -#include "core/fpdfdoc/cpdf_annot.h" #include "core/fpdfdoc/cpvt_generateap.h" +#include "core/fpdfdoc/include/cpdf_annot.h" +#include "core/fpdfdoc/include/cpdf_interform.h" +#include "core/fpdfdoc/include/cpdf_occontext.h" CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) : m_pDocument(pPage->m_pDocument) { diff --git a/core/fpdfdoc/cpdf_apsettings.h b/core/fpdfdoc/cpdf_apsettings.h new file mode 100644 index 0000000000..d2bca5c5ee --- /dev/null +++ b/core/fpdfdoc/cpdf_apsettings.h @@ -0,0 +1,74 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_CPDF_APSETTINGS_H_ +#define CORE_FPDFDOC_CPDF_APSETTINGS_H_ + +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" +#include "core/fxge/include/fx_dib.h" +#include "core/fpdfdoc/include/cpdf_iconfit.h" + +class CPDF_Dictionary; +class CPDF_FormControl; +class CPDF_Stream; + +class CPDF_ApSettings { + public: + explicit CPDF_ApSettings(CPDF_Dictionary* pDict); + + bool HasMKEntry(const CFX_ByteString& csEntry) const; + int GetRotation() const; + + FX_ARGB GetBorderColor(int& iColorType) const { + return GetColor(iColorType, "BC"); + } + + FX_FLOAT GetOriginalBorderColor(int index) const { + return GetOriginalColor(index, "BC"); + } + + void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) const { + GetOriginalColor(iColorType, fc, "BC"); + } + + FX_ARGB GetBackgroundColor(int& iColorType) const { + return GetColor(iColorType, "BG"); + } + + FX_FLOAT GetOriginalBackgroundColor(int index) const { + return GetOriginalColor(index, "BG"); + } + + void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) const { + GetOriginalColor(iColorType, fc, "BG"); + } + + CFX_WideString GetNormalCaption() const { return GetCaption("CA"); } + CFX_WideString GetRolloverCaption() const { return GetCaption("RC"); } + CFX_WideString GetDownCaption() const { return GetCaption("AC"); } + CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); } + CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); } + CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); } + CPDF_IconFit GetIconFit() const; + int GetTextPosition() const; + + private: + friend class CPDF_FormControl; + + FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const; + FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry) const; + void GetOriginalColor(int& iColorType, + FX_FLOAT fc[4], + const CFX_ByteString& csEntry) const; + + CFX_WideString GetCaption(const CFX_ByteString& csEntry) const; + CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const; + + CPDF_Dictionary* const m_pDict; +}; + +#endif // CORE_FPDFDOC_CPDF_APSETTINGS_H_ diff --git a/core/fpdfdoc/cpdf_pagelabel.h b/core/fpdfdoc/cpdf_pagelabel.h new file mode 100644 index 0000000000..16acf3b701 --- /dev/null +++ b/core/fpdfdoc/cpdf_pagelabel.h @@ -0,0 +1,26 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_CPDF_PAGELABEL_H_ +#define CORE_FPDFDOC_CPDF_PAGELABEL_H_ + +#include "core/fxcrt/include/fx_string.h" + +class CPDF_Document; + +class CPDF_PageLabel { + public: + explicit CPDF_PageLabel(CPDF_Document* pDocument); + + CFX_WideString GetLabel(int nPage) const; + int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const; + int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const; + + private: + CPDF_Document* const m_pDocument; +}; + +#endif // CORE_FPDFDOC_CPDF_PAGELABEL_H_ diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index db2ee6c01d..7eb6188c94 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -11,10 +11,11 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfdoc/cpvt_color.h" #include "core/fpdfdoc/cpvt_fontmap.h" +#include "core/fpdfdoc/include/cpdf_formfield.h" #include "core/fpdfdoc/include/cpvt_word.h" -#include "core/fpdfdoc/include/fpdf_doc.h" #include "core/fpdfdoc/pdf_vt.h" namespace { diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h index 1258643d3e..fe120909da 100644 --- a/core/fpdfdoc/cpvt_generateap.h +++ b/core/fpdfdoc/cpvt_generateap.h @@ -9,8 +9,8 @@ #include "core/fpdfdoc/cpvt_color.h" #include "core/fpdfdoc/cpvt_dash.h" +#include "core/fpdfdoc/include/cpdf_defaultappearance.h" #include "core/fpdfdoc/include/cpdf_variabletext.h" -#include "core/fpdfdoc/include/fpdf_doc.h" #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" diff --git a/core/fpdfdoc/doc_action.cpp b/core/fpdfdoc/doc_action.cpp index c512d1afa9..30d4006b54 100644 --- a/core/fpdfdoc/doc_action.cpp +++ b/core/fpdfdoc/doc_action.cpp @@ -4,11 +4,17 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfdoc/include/cpdf_action.h" + #include <vector> #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_aaction.h" +#include "core/fpdfdoc/include/cpdf_actionfields.h" +#include "core/fpdfdoc/include/cpdf_docjsactions.h" +#include "core/fpdfdoc/include/cpdf_filespec.h" +#include "core/fpdfdoc/include/cpdf_nametree.h" namespace { diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp index 3fe182ae78..97acf2384f 100644 --- a/core/fpdfdoc/doc_basic.cpp +++ b/core/fpdfdoc/doc_basic.cpp @@ -6,8 +6,12 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfdoc/doc_utils.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/cpdf_pagelabel.h" +#include "core/fpdfdoc/include/cpdf_filespec.h" +#include "core/fpdfdoc/include/cpdf_nametree.h" +#include "core/fpdfdoc/include/ipdf_formnotify.h" namespace { diff --git a/core/fpdfdoc/doc_basic_unittest.cpp b/core/fpdfdoc/doc_basic_unittest.cpp index 5713a6debb..23e88385d1 100644 --- a/core/fpdfdoc/doc_basic_unittest.cpp +++ b/core/fpdfdoc/doc_basic_unittest.cpp @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "core/fpdfdoc/include/fpdf_doc.h" - #include <memory> #include <vector> +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" +#include "core/fpdfdoc/include/cpdf_filespec.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" diff --git a/core/fpdfdoc/doc_bookmark.cpp b/core/fpdfdoc/doc_bookmark.cpp index 2c6f0dddef..8a0054e98c 100644 --- a/core/fpdfdoc/doc_bookmark.cpp +++ b/core/fpdfdoc/doc_bookmark.cpp @@ -4,13 +4,17 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfdoc/include/cpdf_bookmark.h" + #include <memory> #include <vector> #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_bookmarktree.h" +#include "core/fpdfdoc/include/cpdf_nametree.h" +#include "core/fxge/include/fx_dib.h" CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( const CPDF_Bookmark& parent) const { diff --git a/core/fpdfdoc/doc_form.cpp b/core/fpdfdoc/doc_form.cpp index bad051ffb9..3dde448a24 100644 --- a/core/fpdfdoc/doc_form.cpp +++ b/core/fpdfdoc/doc_form.cpp @@ -12,8 +12,10 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" +#include "core/fpdfdoc/include/cpdf_filespec.h" +#include "core/fpdfdoc/include/cpdf_formcontrol.h" +#include "core/fpdfdoc/include/cpdf_interform.h" #include "core/fpdfdoc/doc_utils.h" -#include "core/fpdfdoc/include/fpdf_doc.h" #include "third_party/base/stl_util.h" namespace { diff --git a/core/fpdfdoc/doc_formcontrol.cpp b/core/fpdfdoc/doc_formcontrol.cpp index 7e058ae310..932a006be5 100644 --- a/core/fpdfdoc/doc_formcontrol.cpp +++ b/core/fpdfdoc/doc_formcontrol.cpp @@ -4,14 +4,17 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfdoc/include/cpdf_formcontrol.h" + #include <algorithm> #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_interform.h" namespace { diff --git a/core/fpdfdoc/doc_formfield.cpp b/core/fpdfdoc/doc_formfield.cpp index 14497ef045..cb1b0a4566 100644 --- a/core/fpdfdoc/doc_formfield.cpp +++ b/core/fpdfdoc/doc_formfield.cpp @@ -4,18 +4,38 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfdoc/include/cpdf_formfield.h" + #include "core/fpdfapi/fpdf_parser/include/cfdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h" +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfdoc/cpvt_generateap.h" #include "core/fpdfdoc/doc_utils.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_formcontrol.h" +#include "core/fpdfdoc/include/cpdf_interform.h" namespace { +const int kFormListMultiSelect = 0x100; + +const int kFormComboEdit = 0x100; + +const int kFormFieldReadOnly = 0x01; +const int kFormFieldRequired = 0x02; +const int kFormFieldNoExport = 0x04; + +const int kFormRadioNoToggleOff = 0x100; +const int kFormRadioUnison = 0x200; + +const int kFormTextMultiLine = 0x100; +const int kFormTextPassword = 0x200; +const int kFormTextNoScroll = 0x400; +const int kFormTextComb = 0x800; + bool PDF_FormField_IsUnison(CPDF_FormField* pField) { if (pField->GetType() == CPDF_FormField::CheckBox) return true; @@ -45,22 +65,22 @@ void CPDF_FormField::SyncFieldFlags() { : 0; m_Flags = 0; if (flags & 1) { - m_Flags |= FORMFIELD_READONLY; + m_Flags |= kFormFieldReadOnly; } if (flags & 2) { - m_Flags |= FORMFIELD_REQUIRED; + m_Flags |= kFormFieldRequired; } if (flags & 4) { - m_Flags |= FORMFIELD_NOEXPORT; + m_Flags |= kFormFieldNoExport; } if (type_name == "Btn") { if (flags & 0x8000) { m_Type = RadioButton; if (flags & 0x4000) { - m_Flags |= FORMRADIO_NOTOGGLEOFF; + m_Flags |= kFormRadioNoToggleOff; } if (flags & 0x2000000) { - m_Flags |= FORMRADIO_UNISON; + m_Flags |= kFormRadioUnison; } } else if (flags & 0x10000) { m_Type = PushButton; @@ -75,16 +95,16 @@ void CPDF_FormField::SyncFieldFlags() { } else { m_Type = Text; if (flags & 0x1000) { - m_Flags |= FORMTEXT_MULTILINE; + m_Flags |= kFormTextMultiLine; } if (flags & 0x2000) { - m_Flags |= FORMTEXT_PASSWORD; + m_Flags |= kFormTextPassword; } if (flags & 0x800000) { - m_Flags |= FORMTEXT_NOSCROLL; + m_Flags |= kFormTextNoScroll; } if (flags & 0x100000) { - m_Flags |= FORMTEXT_COMB; + m_Flags |= kFormTextComb; } } LoadDA(); @@ -92,12 +112,12 @@ void CPDF_FormField::SyncFieldFlags() { if (flags & 0x20000) { m_Type = ComboBox; if (flags & 0x40000) { - m_Flags |= FORMCOMBO_EDIT; + m_Flags |= kFormComboEdit; } } else { m_Type = ListBox; if (flags & 0x200000) { - m_Flags |= FORMLIST_MULTISELECT; + m_Flags |= kFormListMultiSelect; } } LoadDA(); @@ -511,7 +531,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, if (bSelected) { if (GetType() == ListBox) { SelectOption(index, TRUE); - if (!(m_Flags & FORMLIST_MULTISELECT)) { + if (!(m_Flags & kFormListMultiSelect)) { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; diff --git a/core/fpdfdoc/doc_link.cpp b/core/fpdfdoc/doc_link.cpp index 5d21e1d9aa..aa4e761f6d 100644 --- a/core/fpdfdoc/doc_link.cpp +++ b/core/fpdfdoc/doc_link.cpp @@ -4,12 +4,14 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_link.h" #include <vector> #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" +#include "core/fpdfdoc/include/cpdf_linklist.h" +#include "core/fpdfdoc/include/cpdf_nametree.h" CPDF_LinkList::CPDF_LinkList() {} diff --git a/core/fpdfdoc/doc_metadata.cpp b/core/fpdfdoc/doc_metadata.cpp index f36250ab7a..6273a62bef 100644 --- a/core/fpdfdoc/doc_metadata.cpp +++ b/core/fpdfdoc/doc_metadata.cpp @@ -4,10 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfdoc/include/cpdf_metadata.h" + #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" -#include "core/fpdfdoc/include/fpdf_doc.h" #include "core/fxcrt/include/fx_xml.h" CPDF_Metadata::CPDF_Metadata(CPDF_Document* pDoc) { diff --git a/core/fpdfdoc/doc_ocg.cpp b/core/fpdfdoc/doc_ocg.cpp index 1251cb20e3..50bae65800 100644 --- a/core/fpdfdoc/doc_ocg.cpp +++ b/core/fpdfdoc/doc_ocg.cpp @@ -4,11 +4,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfdoc/include/cpdf_occontext.h" + #include "core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h" #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" -#include "core/fpdfdoc/include/fpdf_doc.h" namespace { diff --git a/core/fpdfdoc/doc_utils.cpp b/core/fpdfdoc/doc_utils.cpp index 7f79a34245..284520d150 100644 --- a/core/fpdfdoc/doc_utils.cpp +++ b/core/fpdfdoc/doc_utils.cpp @@ -11,8 +11,11 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" #include "core/fpdfdoc/doc_utils.h" -#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fpdfdoc/include/cpdf_defaultappearance.h" +#include "core/fpdfdoc/include/cpdf_formcontrol.h" +#include "core/fpdfdoc/include/cpdf_interform.h" #include "core/fxge/include/fx_font.h" namespace { diff --git a/core/fpdfdoc/doc_viewerPreferences.cpp b/core/fpdfdoc/doc_viewerPreferences.cpp index 1de8c92614..3fe638d4f5 100644 --- a/core/fpdfdoc/doc_viewerPreferences.cpp +++ b/core/fpdfdoc/doc_viewerPreferences.cpp @@ -4,8 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include "core/fpdfdoc/include/cpdf_viewerpreferences.h" + #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" -#include "core/fpdfdoc/include/fpdf_doc.h" CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc) : m_pDoc(pDoc) {} diff --git a/core/fpdfdoc/include/cpdf_aaction.h b/core/fpdfdoc/include/cpdf_aaction.h new file mode 100644 index 0000000000..b3a55da23e --- /dev/null +++ b/core/fpdfdoc/include/cpdf_aaction.h @@ -0,0 +1,51 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_AACTION_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_AACTION_H_ + +#include "core/fpdfdoc/include/cpdf_action.h" + +class CPDF_Dictionary; + +class CPDF_AAction { + public: + enum AActionType { + CursorEnter = 0, + CursorExit, + ButtonDown, + ButtonUp, + GetFocus, + LoseFocus, + PageOpen, + PageClose, + PageVisible, + PageInvisible, + OpenPage, + ClosePage, + KeyStroke, + Format, + Validate, + Calculate, + CloseDocument, + SaveDocument, + DocumentSaved, + PrintDocument, + DocumentPrinted + }; + + CPDF_AAction() : m_pDict(nullptr) {} + explicit CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + + FX_BOOL ActionExist(AActionType eType) const; + CPDF_Action GetAction(AActionType eType) const; + CPDF_Dictionary* GetDict() const { return m_pDict; } + + private: + CPDF_Dictionary* const m_pDict; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_AACTION_H_ diff --git a/core/fpdfdoc/include/cpdf_action.h b/core/fpdfdoc/include/cpdf_action.h new file mode 100644 index 0000000000..90e33015e7 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_action.h @@ -0,0 +1,59 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_ACTION_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_ACTION_H_ + +#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" +#include "core/fpdfdoc/include/cpdf_dest.h" +#include "core/fxcrt/include/fx_string.h" + +class CPDF_Document; + +class CPDF_Action { + public: + enum ActionType { + Unknown = 0, + GoTo, + GoToR, + GoToE, + Launch, + Thread, + URI, + Sound, + Movie, + Hide, + Named, + SubmitForm, + ResetForm, + ImportData, + JavaScript, + SetOCGState, + Rendition, + Trans, + GoTo3DView + }; + + CPDF_Action() : m_pDict(nullptr) {} + explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + + CPDF_Dictionary* GetDict() const { return m_pDict; } + ActionType GetType() const; + CPDF_Dest GetDest(CPDF_Document* pDoc) const; + CFX_WideString GetFilePath() const; + CFX_ByteString GetURI(CPDF_Document* pDoc) const; + bool GetHideStatus() const { return m_pDict->GetBooleanBy("H", true); } + CFX_ByteString GetNamedAction() const { return m_pDict->GetStringBy("N"); } + uint32_t GetFlags() const { return m_pDict->GetIntegerBy("Flags"); } + CFX_WideString GetJavaScript() const; + size_t GetSubActionsCount() const; + CPDF_Action GetSubAction(size_t iIndex) const; + + private: + CPDF_Dictionary* const m_pDict; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_ACTION_H_ diff --git a/core/fpdfdoc/include/cpdf_actionfields.h b/core/fpdfdoc/include/cpdf_actionfields.h new file mode 100644 index 0000000000..ad7962b761 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_actionfields.h @@ -0,0 +1,27 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_ACTIONFIELDS_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_ACTIONFIELDS_H_ + +#include <vector> + +class CPDF_Action; +class CPDF_Object; + +class CPDF_ActionFields { + public: + explicit CPDF_ActionFields(const CPDF_Action* pAction) : m_pAction(pAction) {} + + size_t GetFieldsCount() const; + std::vector<CPDF_Object*> GetAllFields() const; + CPDF_Object* GetField(size_t iIndex) const; + + private: + const CPDF_Action* const m_pAction; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_ACTIONFIELDS_H_ diff --git a/core/fpdfdoc/cpdf_annot.h b/core/fpdfdoc/include/cpdf_annot.h index eab76a6376..99efd98886 100644 --- a/core/fpdfdoc/cpdf_annot.h +++ b/core/fpdfdoc/include/cpdf_annot.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef CORE_FPDFDOC_CPDF_ANNOT_H_ -#define CORE_FPDFDOC_CPDF_ANNOT_H_ +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ #include <map> #include <memory> @@ -67,4 +67,7 @@ class CPDF_Annot { std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap; }; -#endif // CORE_FPDFDOC_CPDF_ANNOT_H_ +CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, + CPDF_Annot::AppearanceMode mode); + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ diff --git a/core/fpdfdoc/cpdf_annotlist.h b/core/fpdfdoc/include/cpdf_annotlist.h index afe85f33af..f76ec64cd9 100644 --- a/core/fpdfdoc/cpdf_annotlist.h +++ b/core/fpdfdoc/include/cpdf_annotlist.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef CORE_FPDFDOC_CPDF_ANNOTLIST_H_ -#define CORE_FPDFDOC_CPDF_ANNOTLIST_H_ +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_ANNOTLIST_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_ANNOTLIST_H_ #include <memory> #include <vector> @@ -61,4 +61,4 @@ class CPDF_AnnotList { std::vector<std::unique_ptr<CPDF_Annot>> m_AnnotList; }; -#endif // CORE_FPDFDOC_CPDF_ANNOTLIST_H_ +#endif // CORE_FPDFDOC_INCLUDE_CPDF_ANNOTLIST_H_ diff --git a/core/fpdfdoc/include/cpdf_bookmark.h b/core/fpdfdoc/include/cpdf_bookmark.h new file mode 100644 index 0000000000..ba0b059572 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_bookmark.h @@ -0,0 +1,33 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_BOOKMARK_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_BOOKMARK_H_ + +#include "core/fpdfdoc/include/cpdf_action.h" +#include "core/fpdfdoc/include/cpdf_dest.h" +#include "core/fxcrt/include/fx_string.h" + +class CPDF_Dictionary; +class CPDF_Document; + +class CPDF_Bookmark { + public: + CPDF_Bookmark() : m_pDict(nullptr) {} + explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + + CPDF_Dictionary* GetDict() const { return m_pDict; } + uint32_t GetColorRef() const; + uint32_t GetFontStyle() const; + CFX_WideString GetTitle() const; + CPDF_Dest GetDest(CPDF_Document* pDocument) const; + CPDF_Action GetAction() const; + + private: + CPDF_Dictionary* m_pDict; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_BOOKMARK_H_ diff --git a/core/fpdfdoc/include/cpdf_bookmarktree.h b/core/fpdfdoc/include/cpdf_bookmarktree.h new file mode 100644 index 0000000000..f496053383 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_bookmarktree.h @@ -0,0 +1,26 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_BOOKMARKTREE_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_BOOKMARKTREE_H_ + +#include "core/fpdfdoc/include/cpdf_bookmark.h" + +class CPDF_Document; + +class CPDF_BookmarkTree { + public: + explicit CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} + + CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const; + CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const; + CPDF_Document* GetDocument() const { return m_pDocument; } + + private: + CPDF_Document* const m_pDocument; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_BOOKMARKTREE_H_ diff --git a/core/fpdfdoc/include/cpdf_defaultappearance.h b/core/fpdfdoc/include/cpdf_defaultappearance.h new file mode 100644 index 0000000000..c45d4eeffc --- /dev/null +++ b/core/fpdfdoc/include/cpdf_defaultappearance.h @@ -0,0 +1,50 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_DEFAULTAPPEARANCE_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_DEFAULTAPPEARANCE_H_ + +#include "core/fpdfdoc/include/cpdf_defaultappearance.h" +#include "core/fxcrt/include/fx_coordinates.h" +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" +#include "core/fxge/include/fx_dib.h" + +enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE }; + +class CPDF_DefaultAppearance { + public: + CPDF_DefaultAppearance() {} + explicit CPDF_DefaultAppearance(const CFX_ByteString& csDA) : m_csDA(csDA) {} + + CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) { + m_csDA = cDA.GetStr(); + } + + CFX_ByteString GetStr() const { return m_csDA; } + + FX_BOOL HasFont(); + CFX_ByteString GetFontString(); + void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize); + + FX_BOOL HasColor(FX_BOOL bStrokingOperation = FALSE); + CFX_ByteString GetColorString(FX_BOOL bStrokingOperation = FALSE); + void GetColor(int& iColorType, + FX_FLOAT fc[4], + FX_BOOL bStrokingOperation = FALSE); + void GetColor(FX_ARGB& color, + int& iColorType, + FX_BOOL bStrokingOperation = FALSE); + + FX_BOOL HasTextMatrix(); + CFX_ByteString GetTextMatrixString(); + CFX_Matrix GetTextMatrix(); + + private: + CFX_ByteString m_csDA; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_DEFAULTAPPEARANCE_H_ diff --git a/core/fpdfdoc/include/cpdf_dest.h b/core/fpdfdoc/include/cpdf_dest.h new file mode 100644 index 0000000000..82d8a2b5cf --- /dev/null +++ b/core/fpdfdoc/include/cpdf_dest.h @@ -0,0 +1,32 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_DEST_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_DEST_H_ + +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" + +class CPDF_Document; +class CPDF_Object; + +class CPDF_Dest { + public: + CPDF_Dest() : m_pObj(nullptr) {} + explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) {} + + CPDF_Object* GetObject() const { return m_pObj; } + CFX_ByteString GetRemoteName(); + int GetPageIndex(CPDF_Document* pDoc); + uint32_t GetPageObjNum(); + int GetZoomMode(); + FX_FLOAT GetParam(int index); + + private: + CPDF_Object* m_pObj; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_DEST_H_ diff --git a/core/fpdfdoc/include/cpdf_docjsactions.h b/core/fpdfdoc/include/cpdf_docjsactions.h new file mode 100644 index 0000000000..137b6afd53 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_docjsactions.h @@ -0,0 +1,29 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_DOCJSACTIONS_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_DOCJSACTIONS_H_ + +#include "core/fpdfdoc/include/cpdf_action.h" +#include "core/fxcrt/include/fx_string.h" + +class CPDF_Document; + +class CPDF_DocJSActions { + public: + explicit CPDF_DocJSActions(CPDF_Document* pDoc); + + int CountJSActions() const; + CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const; + CPDF_Action GetJSAction(const CFX_ByteString& csName) const; + int FindJSAction(const CFX_ByteString& csName) const; + CPDF_Document* GetDocument() const { return m_pDocument; } + + private: + CPDF_Document* const m_pDocument; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_DOCJSACTIONS_H_ diff --git a/core/fpdfdoc/include/cpdf_filespec.h b/core/fpdfdoc/include/cpdf_filespec.h new file mode 100644 index 0000000000..06badbaa5e --- /dev/null +++ b/core/fpdfdoc/include/cpdf_filespec.h @@ -0,0 +1,35 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_FILESPEC_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_FILESPEC_H_ + +#include "core/fxcrt/include/fx_string.h" + +class CPDF_Object; + +class CPDF_FileSpec { + public: + CPDF_FileSpec(); + explicit CPDF_FileSpec(CPDF_Object* pObj) : m_pObj(pObj) {} + + // Convert a platform dependent file name into pdf format. + static CFX_WideString EncodeFileName(const CFX_WideStringC& filepath); + + // Convert a pdf file name into platform dependent format. + static CFX_WideString DecodeFileName(const CFX_WideStringC& filepath); + + CPDF_Object* GetObj() const { return m_pObj; } + bool GetFileName(CFX_WideString* wsFileName) const; + + // Set this file spec to refer to a file name (not a url). + void SetFileName(const CFX_WideStringC& wsFileName); + + private: + CPDF_Object* m_pObj; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_FILESPEC_H_ diff --git a/core/fpdfdoc/include/cpdf_formcontrol.h b/core/fpdfdoc/include/cpdf_formcontrol.h new file mode 100644 index 0000000000..cf246bd878 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_formcontrol.h @@ -0,0 +1,134 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_FORMCONTROL_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_FORMCONTROL_H_ + +#include "core/fpdfdoc/cpdf_apsettings.h" +#include "core/fpdfdoc/include/cpdf_aaction.h" +#include "core/fpdfdoc/include/cpdf_action.h" +#include "core/fpdfdoc/include/cpdf_annot.h" +#include "core/fpdfdoc/include/cpdf_annotlist.h" +#include "core/fpdfdoc/include/cpdf_defaultappearance.h" +#include "core/fpdfdoc/include/cpdf_formfield.h" +#include "core/fpdfdoc/include/cpdf_iconfit.h" +#include "core/fpdfdoc/include/ipdf_formnotify.h" +#include "core/fxcrt/include/fx_coordinates.h" +#include "core/fxcrt/include/fx_string.h" +#include "core/fxge/include/fx_dib.h" + +#define TEXTPOS_CAPTION 0 +#define TEXTPOS_ICON 1 +#define TEXTPOS_BELOW 2 +#define TEXTPOS_ABOVE 3 +#define TEXTPOS_RIGHT 4 +#define TEXTPOS_LEFT 5 +#define TEXTPOS_OVERLAID 6 + +#define COLORTYPE_TRANSPARENT 0 +#define COLORTYPE_GRAY 1 +#define COLORTYPE_RGB 2 +#define COLORTYPE_CMYK 3 + +class CFX_RenderDevice; +class CPDF_Dictionary; +class CPDF_Font; +class CPDF_FormField; +class CPDF_InterForm; +class CPDF_OCContext; +class CPDF_RenderOptions; +class CPDF_Stream; + +class CPDF_FormControl { + public: + enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle }; + + CPDF_FormField::Type GetType() const { return m_pField->GetType(); } + CPDF_InterForm* GetInterForm() const { return m_pForm; } + CPDF_FormField* GetField() const { return m_pField; } + CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } + CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectBy("Rect"); } + + void DrawControl(CFX_RenderDevice* pDevice, + CFX_Matrix* pMatrix, + CPDF_Page* pPage, + CPDF_Annot::AppearanceMode mode, + const CPDF_RenderOptions* pOptions = nullptr); + + CFX_ByteString GetCheckedAPState(); + CFX_WideString GetExportValue() const; + + bool IsChecked() const; + bool IsDefaultChecked() const; + + HighlightingMode GetHighlightingMode(); + bool HasMKEntry(const CFX_ByteString& csEntry) const; + int GetRotation(); + + FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); } + + FX_FLOAT GetOriginalBorderColor(int index) { + return GetOriginalColor(index, "BC"); + } + + void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) { + GetOriginalColor(iColorType, fc, "BC"); + } + + FX_ARGB GetBackgroundColor(int& iColorType) { + return GetColor(iColorType, "BG"); + } + + FX_FLOAT GetOriginalBackgroundColor(int index) { + return GetOriginalColor(index, "BG"); + } + + void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) { + GetOriginalColor(iColorType, fc, "BG"); + } + + CFX_WideString GetNormalCaption() { return GetCaption("CA"); } + CFX_WideString GetRolloverCaption() { return GetCaption("RC"); } + CFX_WideString GetDownCaption() { return GetCaption("AC"); } + + CPDF_Stream* GetNormalIcon() { return GetIcon("I"); } + CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); } + CPDF_Stream* GetDownIcon() { return GetIcon("IX"); } + CPDF_IconFit GetIconFit(); + + int GetTextPosition(); + CPDF_Action GetAction(); + CPDF_AAction GetAdditionalAction(); + CPDF_DefaultAppearance GetDefaultAppearance(); + + CPDF_Font* GetDefaultControlFont(); + int GetControlAlignment(); + + private: + friend class CPDF_InterForm; + friend class CPDF_FormField; + + CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict); + + CFX_ByteString GetOnStateName() const; + void SetOnStateName(const CFX_ByteString& csOn); + void CheckControl(FX_BOOL bChecked); + FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry); + FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry); + void GetOriginalColor(int& iColorType, + FX_FLOAT fc[4], + const CFX_ByteString& csEntry); + + CFX_WideString GetCaption(const CFX_ByteString& csEntry); + CPDF_Stream* GetIcon(const CFX_ByteString& csEntry); + CPDF_ApSettings GetMK() const; + + CPDF_FormField* const m_pField; + CPDF_Dictionary* const m_pWidgetDict; + CPDF_InterForm* const m_pForm; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_FORMCONTROL_H_ diff --git a/core/fpdfdoc/include/cpdf_formfield.h b/core/fpdfdoc/include/cpdf_formfield.h new file mode 100644 index 0000000000..3d9d88fb6b --- /dev/null +++ b/core/fpdfdoc/include/cpdf_formfield.h @@ -0,0 +1,167 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_FORMFIELD_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_FORMFIELD_H_ + +#include "core/fpdfdoc/include/cpdf_aaction.h" +#include "core/fpdfdoc/include/cpdf_formfield.h" +#include "core/fxcrt/include/fx_basic.h" +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" + +#define FIELDTYPE_UNKNOWN 0 +#define FIELDTYPE_PUSHBUTTON 1 +#define FIELDTYPE_CHECKBOX 2 +#define FIELDTYPE_RADIOBUTTON 3 +#define FIELDTYPE_COMBOBOX 4 +#define FIELDTYPE_LISTBOX 5 +#define FIELDTYPE_TEXTFIELD 6 +#define FIELDTYPE_SIGNATURE 7 + +class CPDF_Dictionary; +class CPDF_Font; +class CPDF_FormControl; +class CPDF_InterForm; +class CPDF_String; + +CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, + const FX_CHAR* name, + int nLevel = 0); + +class CPDF_FormField { + public: + enum Type { + Unknown, + PushButton, + RadioButton, + CheckBox, + Text, + RichText, + File, + ListBox, + ComboBox, + Sign + }; + + CFX_WideString GetFullName() const; + + Type GetType() const { return m_Type; } + uint32_t GetFlags() const { return m_Flags; } + + CPDF_Dictionary* GetFieldDict() const { return m_pDict; } + void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } + + FX_BOOL ResetField(FX_BOOL bNotify = FALSE); + + int CountControls() const { return m_ControlList.GetSize(); } + + CPDF_FormControl* GetControl(int index) const { + return m_ControlList.GetAt(index); + } + + int GetControlIndex(const CPDF_FormControl* pControl) const; + int GetFieldType() const; + + CPDF_AAction GetAdditionalAction() const; + CFX_WideString GetAlternateName() const; + CFX_WideString GetMappingName() const; + + uint32_t GetFieldFlags() const; + CFX_ByteString GetDefaultStyle() const; + CFX_WideString GetRichTextString() const; + + CFX_WideString GetValue() const; + CFX_WideString GetDefaultValue() const; + FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE); + + int GetMaxLen() const; + int CountSelectedItems() const; + int GetSelectedIndex(int index) const; + + FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE); + FX_BOOL IsItemSelected(int index) const; + FX_BOOL SetItemSelection(int index, + FX_BOOL bSelected, + FX_BOOL bNotify = FALSE); + + FX_BOOL IsItemDefaultSelected(int index) const; + + int GetDefaultSelectedItem() const; + int CountOptions() const; + + CFX_WideString GetOptionLabel(int index) const; + CFX_WideString GetOptionValue(int index) const; + + int FindOption(CFX_WideString csOptLabel) const; + int FindOptionValue(const CFX_WideString& csOptValue) const; + + FX_BOOL CheckControl(int iControlIndex, bool bChecked, bool bNotify = false); + + int GetTopVisibleIndex() const; + int CountSelectedOptions() const; + + int GetSelectedOptionIndex(int index) const; + FX_BOOL IsOptionSelected(int iOptIndex) const; + + FX_BOOL SelectOption(int iOptIndex, + FX_BOOL bSelected, + FX_BOOL bNotify = FALSE); + + FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE); + +#ifdef PDF_ENABLE_XFA + FX_BOOL ClearOptions(FX_BOOL bNotify = FALSE); + + int InsertOption(CFX_WideString csOptLabel, + int index = -1, + FX_BOOL bNotify = FALSE); +#endif // PDF_ENABLE_XFA + + FX_FLOAT GetFontSize() const { return m_FontSize; } + CPDF_Font* GetFont() const { return m_pFont; } + + private: + friend class CPDF_InterForm; + friend class CPDF_FormControl; + + CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict); + ~CPDF_FormField(); + + CFX_WideString GetValue(FX_BOOL bDefault) const; + FX_BOOL SetValue(const CFX_WideString& value, + FX_BOOL bDefault, + FX_BOOL bNotify); + + void SyncFieldFlags(); + int FindListSel(CPDF_String* str); + CFX_WideString GetOptionText(int index, int sub_index) const; + + void LoadDA(); + CFX_WideString GetCheckValue(FX_BOOL bDefault) const; + FX_BOOL SetCheckValue(const CFX_WideString& value, + FX_BOOL bDefault, + FX_BOOL bNotify); + + bool NotifyBeforeSelectionChange(const CFX_WideString& value); + void NotifyAfterSelectionChange(); + + bool NotifyBeforeValueChange(const CFX_WideString& value); + void NotifyAfterValueChange(); + + bool NotifyListOrComboBoxBeforeChange(const CFX_WideString& value); + void NotifyListOrComboBoxAfterChange(); + + CPDF_FormField::Type m_Type; + uint32_t m_Flags; + CPDF_InterForm* m_pForm; + CPDF_Dictionary* m_pDict; + CFX_ArrayTemplate<CPDF_FormControl*> m_ControlList; + FX_FLOAT m_FontSize; + CPDF_Font* m_pFont; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_FORMFIELD_H_ diff --git a/core/fpdfdoc/include/cpdf_iconfit.h b/core/fpdfdoc/include/cpdf_iconfit.h new file mode 100644 index 0000000000..a13730d8ce --- /dev/null +++ b/core/fpdfdoc/include/cpdf_iconfit.h @@ -0,0 +1,30 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_ICONFIT_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_ICONFIT_H_ + +#include "core/fxcrt/include/fx_system.h" + +class CPDF_Dictionary; + +class CPDF_IconFit { + public: + enum ScaleMethod { Always = 0, Bigger, Smaller, Never }; + + explicit CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {} + + ScaleMethod GetScaleMethod(); + FX_BOOL IsProportionalScale(); + void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); + bool GetFittingBounds(); + const CPDF_Dictionary* GetDict() const { return m_pDict; } + + private: + const CPDF_Dictionary* const m_pDict; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_ICONFIT_H_ diff --git a/core/fpdfdoc/include/cpdf_interform.h b/core/fpdfdoc/include/cpdf_interform.h new file mode 100644 index 0000000000..f07172c42b --- /dev/null +++ b/core/fpdfdoc/include/cpdf_interform.h @@ -0,0 +1,155 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ + +#include <map> +#include <memory> +#include <vector> + +#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" +#include "core/fpdfdoc/include/cpdf_defaultappearance.h" +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" + +class CFieldTree; +class CFDF_Document; +class CPDF_Document; +class CPDF_Dictionary; +class CPDF_Font; +class CPDF_FormControl; +class CPDF_FormField; +class CPDF_Object; +class CPDF_Page; +class IPDF_FormNotify; + +class CPDF_InterForm { + public: + explicit CPDF_InterForm(CPDF_Document* pDocument); + ~CPDF_InterForm(); + + static void SetUpdateAP(FX_BOOL bUpdateAP); + static FX_BOOL IsUpdateAPEnabled(); + static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, + const FX_CHAR* csType, + int iMinLen = 2, + const FX_CHAR* csPrefix = ""); + static CPDF_Font* AddStandardFont(CPDF_Document* pDocument, + CFX_ByteString csFontName); + static CFX_ByteString GetNativeFont(uint8_t iCharSet, + void* pLogFont = nullptr); + static CFX_ByteString GetNativeFont(void* pLogFont = nullptr); + static uint8_t GetNativeCharSet(); + static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument); + static CPDF_Font* AddNativeFont(CPDF_Document* pDocument); + + FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType); + FX_BOOL ValidateFieldName(const CPDF_FormField* pField, + CFX_WideString& csNewFieldName); + FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl, + CFX_WideString& csNewFieldName); + + uint32_t CountFields(const CFX_WideString& csFieldName = L""); + CPDF_FormField* GetField(uint32_t index, + const CFX_WideString& csFieldName = L""); + CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; + + CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, + FX_FLOAT pdf_x, + FX_FLOAT pdf_y, + int* z_order) const; + CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; + + CPDF_Document* GetDocument() const { return m_pDocument; } + CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } + FX_BOOL NeedConstructAP() const; + int CountFieldsInCalculationOrder(); + CPDF_FormField* GetFieldInCalculationOrder(int index); + int FindFieldInCalculationOrder(const CPDF_FormField* pField); + + uint32_t CountFormFonts(); + CPDF_Font* GetFormFont(uint32_t index, CFX_ByteString& csNameTag); + CPDF_Font* GetFormFont(CFX_ByteString csNameTag); + CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag); + CPDF_Font* GetNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); + CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag); + FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); + FX_BOOL FindFormFont(CFX_ByteString csFontName, + CPDF_Font*& pFont, + CFX_ByteString& csNameTag); + + FX_BOOL FindFormFont(CFX_WideString csFontName, + CPDF_Font*& pFont, + CFX_ByteString& csNameTag) { + return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag); + } + + void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); + CPDF_Font* AddNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); + CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag); + + void RemoveFormFont(const CPDF_Font* pFont); + void RemoveFormFont(CFX_ByteString csNameTag); + + CPDF_DefaultAppearance GetDefaultAppearance(); + CPDF_Font* GetDefaultFormFont(); + int GetFormAlignment(); + + CPDF_FormField* CheckRequiredFields( + const std::vector<CPDF_FormField*>* fields, + bool bIncludeOrExclude) const; + + CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, + bool bSimpleFileSpec = false) const; + CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, + const std::vector<CPDF_FormField*>& fields, + bool bIncludeOrExclude = true, + bool bSimpleFileSpec = false) const; + FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); + + bool ResetForm(const std::vector<CPDF_FormField*>& fields, + bool bIncludeOrExclude = true, + bool bNotify = false); + bool ResetForm(bool bNotify = false); + + void SetFormNotify(IPDF_FormNotify* pNotify); + FX_BOOL HasXFAForm() const; + void FixPageFields(const CPDF_Page* pPage); + + private: + friend class CPDF_FormControl; + friend class CPDF_FormField; + + void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); + CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name); + CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict); + CPDF_FormControl* AddControl(CPDF_FormField* pField, + CPDF_Dictionary* pWidgetDict); + void FDF_ImportField(CPDF_Dictionary* pField, + const CFX_WideString& parent_name, + FX_BOOL bNotify = FALSE, + int nLevel = 0); + FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, + int iType, + const CPDF_FormField* pExcludedField, + const CPDF_FormControl* pExcludedControl); + int CompareFieldName(const CFX_WideString& name1, + const CFX_WideString& name2); + int CompareFieldName(const CFX_ByteString& name1, + const CFX_ByteString& name2); + + static FX_BOOL s_bUpdateAP; + + CPDF_Document* const m_pDocument; + CPDF_Dictionary* m_pFormDict; + std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; + std::unique_ptr<CFieldTree> m_pFieldTree; + CFX_ByteString m_bsEncoding; + IPDF_FormNotify* m_pFormNotify; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ diff --git a/core/fpdfdoc/include/cpdf_link.h b/core/fpdfdoc/include/cpdf_link.h new file mode 100644 index 0000000000..a3be3ccc90 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_link.h @@ -0,0 +1,31 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_LINK_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_LINK_H_ + +#include "core/fpdfdoc/include/cpdf_action.h" +#include "core/fpdfdoc/include/cpdf_dest.h" +#include "core/fxcrt/include/fx_coordinates.h" + +class CPDF_Dictionary; + +class CPDF_Link { + public: + CPDF_Link() : m_pDict(nullptr) {} + explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + + CPDF_Dictionary* GetDict() const { return m_pDict; } + + CFX_FloatRect GetRect(); + CPDF_Dest GetDest(CPDF_Document* pDoc); + CPDF_Action GetAction(); + + private: + CPDF_Dictionary* m_pDict; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_LINK_H_ diff --git a/core/fpdfdoc/include/cpdf_linklist.h b/core/fpdfdoc/include/cpdf_linklist.h new file mode 100644 index 0000000000..dd9f5517d4 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_linklist.h @@ -0,0 +1,36 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_LINKLIST_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_LINKLIST_H_ + +#include <map> +#include <vector> + +#include "core/fpdfdoc/include/cpdf_link.h" +#include "core/fxcrt/include/fx_system.h" + +class CPDF_Page; +class CPDF_Dictionary; + +class CPDF_LinkList { + public: + CPDF_LinkList(); + ~CPDF_LinkList(); + + CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, + FX_FLOAT pdf_x, + FX_FLOAT pdf_y, + int* z_order); + + private: + const std::vector<CPDF_Dictionary*>* GetPageLinks(CPDF_Page* pPage); + void LoadPageLinks(CPDF_Page* pPage, std::vector<CPDF_Dictionary*>* pList); + + std::map<uint32_t, std::vector<CPDF_Dictionary*>> m_PageMap; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_LINKLIST_H_ diff --git a/core/fpdfdoc/include/cpdf_metadata.h b/core/fpdfdoc/include/cpdf_metadata.h new file mode 100644 index 0000000000..31497dd33c --- /dev/null +++ b/core/fpdfdoc/include/cpdf_metadata.h @@ -0,0 +1,26 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_METADATA_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_METADATA_H_ + +#include <memory> + +class CPDF_Document; +class CXML_Element; + +class CPDF_Metadata { + public: + explicit CPDF_Metadata(CPDF_Document* pDoc); + ~CPDF_Metadata(); + + const CXML_Element* GetRoot() const; + + private: + std::unique_ptr<CXML_Element> m_pXmlElement; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_METADATA_H_ diff --git a/core/fpdfdoc/include/cpdf_nametree.h b/core/fpdfdoc/include/cpdf_nametree.h new file mode 100644 index 0000000000..39a520ddfa --- /dev/null +++ b/core/fpdfdoc/include/cpdf_nametree.h @@ -0,0 +1,34 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_NAMETREE_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_NAMETREE_H_ + +#include "core/fxcrt/include/fx_string.h" + +class CPDF_Array; +class CPDF_Dictionary; +class CPDF_Document; +class CPDF_Object; + +class CPDF_NameTree { + public: + explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} + CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category); + + CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; + CPDF_Object* LookupValue(const CFX_ByteString& csName) const; + CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName); + + int GetIndex(const CFX_ByteString& csName) const; + size_t GetCount() const; + CPDF_Dictionary* GetRoot() const { return m_pRoot; } + + private: + CPDF_Dictionary* m_pRoot; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_NAMETREE_H_ diff --git a/core/fpdfdoc/include/cpdf_occontext.h b/core/fpdfdoc/include/cpdf_occontext.h new file mode 100644 index 0000000000..38e81705e5 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_occontext.h @@ -0,0 +1,42 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_OCCONTEXT_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_OCCONTEXT_H_ + +#include <unordered_map> + +#include "core/fxcrt/include/fx_string.h" + +class CPDF_Array; +class CPDF_Dictionary; +class CPDF_Document; +class CPDF_PageObject; + +class CPDF_OCContext { + public: + enum UsageType { View = 0, Design, Print, Export }; + + CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType); + ~CPDF_OCContext(); + + bool CheckOCGVisible(const CPDF_Dictionary* pOCGDict); + bool CheckObjectVisible(const CPDF_PageObject* pObj); + + private: + bool LoadOCGStateFromConfig(const CFX_ByteString& csConfig, + const CPDF_Dictionary* pOCGDict) const; + bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const; + bool GetOCGVisible(const CPDF_Dictionary* pOCGDict); + bool GetOCGVE(CPDF_Array* pExpression, int nLevel); + bool LoadOCMDState(const CPDF_Dictionary* pOCMDDict); + + CPDF_Document* const m_pDocument; + const UsageType m_eUsageType; + std::unordered_map<const CPDF_Dictionary*, bool> m_OCGStates; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_OCCONTEXT_H_ diff --git a/core/fpdfdoc/include/cpdf_viewerpreferences.h b/core/fpdfdoc/include/cpdf_viewerpreferences.h new file mode 100644 index 0000000000..d93c261183 --- /dev/null +++ b/core/fpdfdoc/include/cpdf_viewerpreferences.h @@ -0,0 +1,34 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_CPDF_VIEWERPREFERENCES_H_ +#define CORE_FPDFDOC_INCLUDE_CPDF_VIEWERPREFERENCES_H_ + +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" + +class CPDF_Array; +class CPDF_Dictionary; +class CPDF_Document; + +class CPDF_ViewerPreferences { + public: + explicit CPDF_ViewerPreferences(CPDF_Document* pDoc); + ~CPDF_ViewerPreferences(); + + FX_BOOL IsDirectionR2L() const; + FX_BOOL PrintScaling() const; + int32_t NumCopies() const; + CPDF_Array* PrintPageRange() const; + CFX_ByteString Duplex() const; + + private: + CPDF_Dictionary* GetViewerPreferences() const; + + CPDF_Document* const m_pDoc; +}; + +#endif // CORE_FPDFDOC_INCLUDE_CPDF_VIEWERPREFERENCES_H_ diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h deleted file mode 100644 index edcec239f6..0000000000 --- a/core/fpdfdoc/include/fpdf_doc.h +++ /dev/null @@ -1,851 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ -#define CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ - -#include <map> -#include <memory> -#include <unordered_map> -#include <vector> - -#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" -#include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" -#include "core/fpdfdoc/cpdf_annot.h" -#include "core/fpdfdoc/cpdf_annotlist.h" -#include "core/fxge/include/fx_dib.h" - -class CFDF_Document; -class CFieldTree; -class CFX_RenderDevice; -class CPDF_AAction; -class CPDF_Action; -class CPDF_ActionFields; -class CPDF_ApSettings; -class CPDF_Bookmark; -class CPDF_BookmarkTree; -class CPDF_DefaultAppearance; -class CPDF_Dest; -class CPDF_DocJSActions; -class CPDF_Document; -class CPDF_FileSpec; -class CPDF_Font; -class CPDF_Form; -class CPDF_FormControl; -class CPDF_FormField; -class CPDF_IconFit; -class CPDF_Link; -class CPDF_Metadata; -class CPDF_OCContext; -class CPDF_Page; -class CPDF_PageObject; -class CPDF_RenderContext; -class CPDF_RenderOptions; -class CXML_Element; -class IPDF_FormNotify; - -enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE }; - -class CPDF_NameTree { - public: - explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} - CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category); - - CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; - CPDF_Object* LookupValue(const CFX_ByteString& csName) const; - CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteString& sName); - int GetIndex(const CFX_ByteString& csName) const; - size_t GetCount() const; - CPDF_Dictionary* GetRoot() const { return m_pRoot; } - - protected: - CPDF_Dictionary* m_pRoot; -}; - -class CPDF_BookmarkTree { - public: - explicit CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} - - CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const; - CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const; - CPDF_Document* GetDocument() const { return m_pDocument; } - - protected: - CPDF_Document* const m_pDocument; -}; - -#define PDFBOOKMARK_ITALIC 1 -#define PDFBOOKMARK_BOLD 2 -class CPDF_Bookmark { - public: - CPDF_Bookmark() : m_pDict(nullptr) {} - explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {} - - CPDF_Dictionary* GetDict() const { return m_pDict; } - uint32_t GetColorRef() const; - uint32_t GetFontStyle() const; - CFX_WideString GetTitle() const; - CPDF_Dest GetDest(CPDF_Document* pDocument) const; - CPDF_Action GetAction() const; - - protected: - CPDF_Dictionary* m_pDict; -}; - -#define PDFZOOM_XYZ 1 -#define PDFZOOM_FITPAGE 2 -#define PDFZOOM_FITHORZ 3 -#define PDFZOOM_FITVERT 4 -#define PDFZOOM_FITRECT 5 -#define PDFZOOM_FITBBOX 6 -#define PDFZOOM_FITBHORZ 7 -#define PDFZOOM_FITBVERT 8 -class CPDF_Dest { - public: - CPDF_Dest() : m_pObj(nullptr) {} - explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) {} - - CPDF_Object* GetObject() const { return m_pObj; } - CFX_ByteString GetRemoteName(); - int GetPageIndex(CPDF_Document* pDoc); - uint32_t GetPageObjNum(); - int GetZoomMode(); - FX_FLOAT GetParam(int index); - - protected: - CPDF_Object* m_pObj; -}; - -class CPDF_OCContext { - public: - enum UsageType { View = 0, Design, Print, Export }; - - CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType); - ~CPDF_OCContext(); - - bool CheckOCGVisible(const CPDF_Dictionary* pOCGDict); - bool CheckObjectVisible(const CPDF_PageObject* pObj); - - protected: - bool LoadOCGStateFromConfig(const CFX_ByteString& csConfig, - const CPDF_Dictionary* pOCGDict) const; - bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const; - bool GetOCGVisible(const CPDF_Dictionary* pOCGDict); - bool GetOCGVE(CPDF_Array* pExpression, int nLevel); - bool LoadOCMDState(const CPDF_Dictionary* pOCMDDict); - - CPDF_Document* const m_pDocument; - const UsageType m_eUsageType; - std::unordered_map<const CPDF_Dictionary*, bool> m_OCGStates; -}; - -class CPDF_ActionFields { - public: - explicit CPDF_ActionFields(const CPDF_Action* pAction) : m_pAction(pAction) {} - - size_t GetFieldsCount() const; - std::vector<CPDF_Object*> GetAllFields() const; - CPDF_Object* GetField(size_t iIndex) const; - - protected: - const CPDF_Action* const m_pAction; -}; - -#define PDFNAMED_NEXTPAGE 1 -#define PDFNAMED_PREVPAGE 2 -#define PDFNAMED_FIRSTPAGE 3 -#define PDFNAMED_LASTPAGE 4 -#define PDFJS_MAXLENGTH 64 -class CPDF_Action { - public: - enum ActionType { - Unknown = 0, - GoTo, - GoToR, - GoToE, - Launch, - Thread, - URI, - Sound, - Movie, - Hide, - Named, - SubmitForm, - ResetForm, - ImportData, - JavaScript, - SetOCGState, - Rendition, - Trans, - GoTo3DView - }; - - CPDF_Action() : m_pDict(nullptr) {} - explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {} - - CPDF_Dictionary* GetDict() const { return m_pDict; } - ActionType GetType() const; - CPDF_Dest GetDest(CPDF_Document* pDoc) const; - CFX_WideString GetFilePath() const; - CFX_ByteString GetURI(CPDF_Document* pDoc) const; - bool GetHideStatus() const { return m_pDict->GetBooleanBy("H", true); } - CFX_ByteString GetNamedAction() const { return m_pDict->GetStringBy("N"); } - uint32_t GetFlags() const { return m_pDict->GetIntegerBy("Flags"); } - CFX_WideString GetJavaScript() const; - size_t GetSubActionsCount() const; - CPDF_Action GetSubAction(size_t iIndex) const; - - protected: - CPDF_Dictionary* const m_pDict; -}; - -class CPDF_AAction { - public: - enum AActionType { - CursorEnter = 0, - CursorExit, - ButtonDown, - ButtonUp, - GetFocus, - LoseFocus, - PageOpen, - PageClose, - PageVisible, - PageInvisible, - OpenPage, - ClosePage, - KeyStroke, - Format, - Validate, - Calculate, - CloseDocument, - SaveDocument, - DocumentSaved, - PrintDocument, - DocumentPrinted - }; - - CPDF_AAction() : m_pDict(nullptr) {} - explicit CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {} - - FX_BOOL ActionExist(AActionType eType) const; - CPDF_Action GetAction(AActionType eType) const; - CPDF_Dictionary* GetDict() const { return m_pDict; } - - protected: - CPDF_Dictionary* const m_pDict; -}; - -class CPDF_DocJSActions { - public: - explicit CPDF_DocJSActions(CPDF_Document* pDoc); - - int CountJSActions() const; - CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const; - CPDF_Action GetJSAction(const CFX_ByteString& csName) const; - int FindJSAction(const CFX_ByteString& csName) const; - CPDF_Document* GetDocument() const { return m_pDocument; } - - protected: - CPDF_Document* const m_pDocument; -}; - -class CPDF_FileSpec { - public: - CPDF_FileSpec(); - explicit CPDF_FileSpec(CPDF_Object* pObj) : m_pObj(pObj) {} - - // Convert a platform dependent file name into pdf format. - static CFX_WideString EncodeFileName(const CFX_WideStringC& filepath); - - // Convert a pdf file name into platform dependent format. - static CFX_WideString DecodeFileName(const CFX_WideStringC& filepath); - - CPDF_Object* GetObj() const { return m_pObj; } - bool GetFileName(CFX_WideString* wsFileName) const; - - // Set this file spec to refer to a file name (not a url). - void SetFileName(const CFX_WideStringC& wsFileName); - - protected: - CPDF_Object* m_pObj; -}; - -class CPDF_LinkList { - public: - CPDF_LinkList(); - ~CPDF_LinkList(); - - CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, - FX_FLOAT pdf_x, - FX_FLOAT pdf_y, - int* z_order); - - private: - const std::vector<CPDF_Dictionary*>* GetPageLinks(CPDF_Page* pPage); - void LoadPageLinks(CPDF_Page* pPage, std::vector<CPDF_Dictionary*>* pList); - - std::map<uint32_t, std::vector<CPDF_Dictionary*>> m_PageMap; -}; - -class CPDF_Link { - public: - CPDF_Link() : m_pDict(nullptr) {} - explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {} - - CPDF_Dictionary* GetDict() const { return m_pDict; } - - CFX_FloatRect GetRect(); - CPDF_Dest GetDest(CPDF_Document* pDoc); - CPDF_Action GetAction(); - - protected: - CPDF_Dictionary* m_pDict; -}; - -#define COLORTYPE_TRANSPARENT 0 -#define COLORTYPE_GRAY 1 -#define COLORTYPE_RGB 2 -#define COLORTYPE_CMYK 3 -class CPDF_DefaultAppearance { - public: - CPDF_DefaultAppearance() {} - explicit CPDF_DefaultAppearance(const CFX_ByteString& csDA) : m_csDA(csDA) {} - - CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) { - m_csDA = cDA.GetStr(); - } - - CFX_ByteString GetStr() const { return m_csDA; } - FX_BOOL HasFont(); - CFX_ByteString GetFontString(); - void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize); - FX_BOOL HasColor(FX_BOOL bStrokingOperation = FALSE); - CFX_ByteString GetColorString(FX_BOOL bStrokingOperation = FALSE); - void GetColor(int& iColorType, - FX_FLOAT fc[4], - FX_BOOL bStrokingOperation = FALSE); - void GetColor(FX_ARGB& color, - int& iColorType, - FX_BOOL bStrokingOperation = FALSE); - FX_BOOL HasTextMatrix(); - CFX_ByteString GetTextMatrixString(); - CFX_Matrix GetTextMatrix(); - - protected: - CFX_ByteString m_csDA; -}; - -#define FIELDTYPE_UNKNOWN 0 -#define FIELDTYPE_PUSHBUTTON 1 -#define FIELDTYPE_CHECKBOX 2 -#define FIELDTYPE_RADIOBUTTON 3 -#define FIELDTYPE_COMBOBOX 4 -#define FIELDTYPE_LISTBOX 5 -#define FIELDTYPE_TEXTFIELD 6 -#define FIELDTYPE_SIGNATURE 7 - -class CPDF_InterForm { - public: - explicit CPDF_InterForm(CPDF_Document* pDocument); - ~CPDF_InterForm(); - - static void SetUpdateAP(FX_BOOL bUpdateAP); - static FX_BOOL IsUpdateAPEnabled(); - static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, - const FX_CHAR* csType, - int iMinLen = 2, - const FX_CHAR* csPrefix = ""); - static CPDF_Font* AddStandardFont(CPDF_Document* pDocument, - CFX_ByteString csFontName); - static CFX_ByteString GetNativeFont(uint8_t iCharSet, - void* pLogFont = nullptr); - static CFX_ByteString GetNativeFont(void* pLogFont = nullptr); - static uint8_t GetNativeCharSet(); - static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument); - static CPDF_Font* AddNativeFont(CPDF_Document* pDocument); - - FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType); - FX_BOOL ValidateFieldName(const CPDF_FormField* pField, - CFX_WideString& csNewFieldName); - FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl, - CFX_WideString& csNewFieldName); - - uint32_t CountFields(const CFX_WideString& csFieldName = L""); - CPDF_FormField* GetField(uint32_t index, - const CFX_WideString& csFieldName = L""); - CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; - - CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, - FX_FLOAT pdf_x, - FX_FLOAT pdf_y, - int* z_order) const; - CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; - - CPDF_Document* GetDocument() const { return m_pDocument; } - CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } - FX_BOOL NeedConstructAP() const; - int CountFieldsInCalculationOrder(); - CPDF_FormField* GetFieldInCalculationOrder(int index); - int FindFieldInCalculationOrder(const CPDF_FormField* pField); - - uint32_t CountFormFonts(); - CPDF_Font* GetFormFont(uint32_t index, CFX_ByteString& csNameTag); - CPDF_Font* GetFormFont(CFX_ByteString csNameTag); - CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag); - CPDF_Font* GetNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); - CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag); - FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); - FX_BOOL FindFormFont(CFX_ByteString csFontName, - CPDF_Font*& pFont, - CFX_ByteString& csNameTag); - - FX_BOOL FindFormFont(CFX_WideString csFontName, - CPDF_Font*& pFont, - CFX_ByteString& csNameTag) { - return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag); - } - - void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); - CPDF_Font* AddNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); - CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag); - - void RemoveFormFont(const CPDF_Font* pFont); - void RemoveFormFont(CFX_ByteString csNameTag); - - CPDF_DefaultAppearance GetDefaultAppearance(); - CPDF_Font* GetDefaultFormFont(); - int GetFormAlignment(); - - CPDF_FormField* CheckRequiredFields( - const std::vector<CPDF_FormField*>* fields, - bool bIncludeOrExclude) const; - - CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, - bool bSimpleFileSpec = false) const; - CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, - const std::vector<CPDF_FormField*>& fields, - bool bIncludeOrExclude = true, - bool bSimpleFileSpec = false) const; - FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); - - bool ResetForm(const std::vector<CPDF_FormField*>& fields, - bool bIncludeOrExclude = true, - bool bNotify = false); - bool ResetForm(bool bNotify = false); - - void SetFormNotify(IPDF_FormNotify* pNotify); - FX_BOOL HasXFAForm() const; - void FixPageFields(const CPDF_Page* pPage); - - protected: - static FX_BOOL s_bUpdateAP; - - void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); - CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name); - CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict); - CPDF_FormControl* AddControl(CPDF_FormField* pField, - CPDF_Dictionary* pWidgetDict); - void FDF_ImportField(CPDF_Dictionary* pField, - const CFX_WideString& parent_name, - FX_BOOL bNotify = FALSE, - int nLevel = 0); - FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, - int iType, - const CPDF_FormField* pExcludedField, - const CPDF_FormControl* pExcludedControl); - int CompareFieldName(const CFX_WideString& name1, - const CFX_WideString& name2); - int CompareFieldName(const CFX_ByteString& name1, - const CFX_ByteString& name2); - - CPDF_Document* const m_pDocument; - CPDF_Dictionary* m_pFormDict; - std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; - std::unique_ptr<CFieldTree> m_pFieldTree; - CFX_ByteString m_bsEncoding; - IPDF_FormNotify* m_pFormNotify; - - friend class CPDF_FormControl; - friend class CPDF_FormField; -}; - -#define FORMFIELD_READONLY 0x01 -#define FORMFIELD_REQUIRED 0x02 -#define FORMFIELD_NOEXPORT 0x04 -#define FORMRADIO_NOTOGGLEOFF 0x100 -#define FORMRADIO_UNISON 0x200 -#define FORMTEXT_MULTILINE 0x100 -#define FORMTEXT_PASSWORD 0x200 -#define FORMTEXT_NOSCROLL 0x400 -#define FORMTEXT_COMB 0x800 -#define FORMCOMBO_EDIT 0x100 -#define FORMLIST_MULTISELECT 0x100 - -class CPDF_FormField { - public: - enum Type { - Unknown, - PushButton, - RadioButton, - CheckBox, - Text, - RichText, - File, - ListBox, - ComboBox, - Sign - }; - - CFX_WideString GetFullName() const; - - Type GetType() const { return m_Type; } - uint32_t GetFlags() const { return m_Flags; } - - CPDF_Dictionary* GetFieldDict() const { return m_pDict; } - void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } - - FX_BOOL ResetField(FX_BOOL bNotify = FALSE); - - int CountControls() const { return m_ControlList.GetSize(); } - - CPDF_FormControl* GetControl(int index) const { - return m_ControlList.GetAt(index); - } - - int GetControlIndex(const CPDF_FormControl* pControl) const; - int GetFieldType() const; - - CPDF_AAction GetAdditionalAction() const; - CFX_WideString GetAlternateName() const; - CFX_WideString GetMappingName() const; - - uint32_t GetFieldFlags() const; - CFX_ByteString GetDefaultStyle() const; - CFX_WideString GetRichTextString() const; - - CFX_WideString GetValue() const; - CFX_WideString GetDefaultValue() const; - FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE); - - int GetMaxLen() const; - int CountSelectedItems() const; - int GetSelectedIndex(int index) const; - - FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE); - FX_BOOL IsItemSelected(int index) const; - FX_BOOL SetItemSelection(int index, - FX_BOOL bSelected, - FX_BOOL bNotify = FALSE); - - FX_BOOL IsItemDefaultSelected(int index) const; - - int GetDefaultSelectedItem() const; - int CountOptions() const; - - CFX_WideString GetOptionLabel(int index) const; - CFX_WideString GetOptionValue(int index) const; - - int FindOption(CFX_WideString csOptLabel) const; - int FindOptionValue(const CFX_WideString& csOptValue) const; - - FX_BOOL CheckControl(int iControlIndex, bool bChecked, bool bNotify = false); - - int GetTopVisibleIndex() const; - int CountSelectedOptions() const; - - int GetSelectedOptionIndex(int index) const; - FX_BOOL IsOptionSelected(int iOptIndex) const; - - FX_BOOL SelectOption(int iOptIndex, - FX_BOOL bSelected, - FX_BOOL bNotify = FALSE); - - FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE); - -#ifdef PDF_ENABLE_XFA - FX_BOOL ClearOptions(FX_BOOL bNotify = FALSE); - - int InsertOption(CFX_WideString csOptLabel, - int index = -1, - FX_BOOL bNotify = FALSE); -#endif // PDF_ENABLE_XFA - - FX_FLOAT GetFontSize() const { return m_FontSize; } - CPDF_Font* GetFont() const { return m_pFont; } - - protected: - CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict); - ~CPDF_FormField(); - - CFX_WideString GetValue(FX_BOOL bDefault) const; - FX_BOOL SetValue(const CFX_WideString& value, - FX_BOOL bDefault, - FX_BOOL bNotify); - - void SyncFieldFlags(); - int FindListSel(CPDF_String* str); - CFX_WideString GetOptionText(int index, int sub_index) const; - - void LoadDA(); - CFX_WideString GetCheckValue(FX_BOOL bDefault) const; - FX_BOOL SetCheckValue(const CFX_WideString& value, - FX_BOOL bDefault, - FX_BOOL bNotify); - - bool NotifyBeforeSelectionChange(const CFX_WideString& value); - void NotifyAfterSelectionChange(); - - bool NotifyBeforeValueChange(const CFX_WideString& value); - void NotifyAfterValueChange(); - - bool NotifyListOrComboBoxBeforeChange(const CFX_WideString& value); - void NotifyListOrComboBoxAfterChange(); - - CPDF_FormField::Type m_Type; - uint32_t m_Flags; - CPDF_InterForm* m_pForm; - CPDF_Dictionary* m_pDict; - CFX_ArrayTemplate<CPDF_FormControl*> m_ControlList; - FX_FLOAT m_FontSize; - CPDF_Font* m_pFont; - - friend class CPDF_InterForm; - friend class CPDF_FormControl; -}; - -CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, - const FX_CHAR* name, - int nLevel = 0); -class CPDF_IconFit { - public: - enum ScaleMethod { Always = 0, Bigger, Smaller, Never }; - - explicit CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {} - - ScaleMethod GetScaleMethod(); - FX_BOOL IsProportionalScale(); - void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); - bool GetFittingBounds(); - const CPDF_Dictionary* GetDict() const { return m_pDict; } - - protected: - const CPDF_Dictionary* const m_pDict; -}; - -#define TEXTPOS_CAPTION 0 -#define TEXTPOS_ICON 1 -#define TEXTPOS_BELOW 2 -#define TEXTPOS_ABOVE 3 -#define TEXTPOS_RIGHT 4 -#define TEXTPOS_LEFT 5 -#define TEXTPOS_OVERLAID 6 - -class CPDF_FormControl { - public: - enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle }; - - CPDF_FormField::Type GetType() const { return m_pField->GetType(); } - CPDF_InterForm* GetInterForm() const { return m_pForm; } - CPDF_FormField* GetField() const { return m_pField; } - CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } - CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectBy("Rect"); } - - void DrawControl(CFX_RenderDevice* pDevice, - CFX_Matrix* pMatrix, - CPDF_Page* pPage, - CPDF_Annot::AppearanceMode mode, - const CPDF_RenderOptions* pOptions = nullptr); - - CFX_ByteString GetCheckedAPState(); - CFX_WideString GetExportValue() const; - - bool IsChecked() const; - bool IsDefaultChecked() const; - - HighlightingMode GetHighlightingMode(); - bool HasMKEntry(const CFX_ByteString& csEntry) const; - int GetRotation(); - - FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); } - - FX_FLOAT GetOriginalBorderColor(int index) { - return GetOriginalColor(index, "BC"); - } - - void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) { - GetOriginalColor(iColorType, fc, "BC"); - } - - FX_ARGB GetBackgroundColor(int& iColorType) { - return GetColor(iColorType, "BG"); - } - - FX_FLOAT GetOriginalBackgroundColor(int index) { - return GetOriginalColor(index, "BG"); - } - - void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) { - GetOriginalColor(iColorType, fc, "BG"); - } - - CFX_WideString GetNormalCaption() { return GetCaption("CA"); } - CFX_WideString GetRolloverCaption() { return GetCaption("RC"); } - CFX_WideString GetDownCaption() { return GetCaption("AC"); } - - CPDF_Stream* GetNormalIcon() { return GetIcon("I"); } - CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); } - CPDF_Stream* GetDownIcon() { return GetIcon("IX"); } - CPDF_IconFit GetIconFit(); - - int GetTextPosition(); - CPDF_Action GetAction(); - CPDF_AAction GetAdditionalAction(); - CPDF_DefaultAppearance GetDefaultAppearance(); - - CPDF_Font* GetDefaultControlFont(); - int GetControlAlignment(); - - protected: - CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict); - - CFX_ByteString GetOnStateName() const; - void SetOnStateName(const CFX_ByteString& csOn); - void CheckControl(FX_BOOL bChecked); - FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry); - FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry); - void GetOriginalColor(int& iColorType, - FX_FLOAT fc[4], - const CFX_ByteString& csEntry); - - CFX_WideString GetCaption(const CFX_ByteString& csEntry); - CPDF_Stream* GetIcon(const CFX_ByteString& csEntry); - CPDF_ApSettings GetMK() const; - - CPDF_FormField* const m_pField; - CPDF_Dictionary* const m_pWidgetDict; - CPDF_InterForm* const m_pForm; - - friend class CPDF_InterForm; - friend class CPDF_FormField; -}; - -class IPDF_FormNotify { - public: - virtual ~IPDF_FormNotify(); - - virtual int BeforeValueChange(CPDF_FormField* pField, - const CFX_WideString& csValue); - virtual void AfterValueChange(CPDF_FormField* pField); - virtual int BeforeSelectionChange(CPDF_FormField* pField, - const CFX_WideString& csValue); - virtual void AfterSelectionChange(CPDF_FormField* pField); - virtual void AfterCheckedStatusChange(CPDF_FormField* pField); - virtual int BeforeFormReset(CPDF_InterForm* pForm); - virtual void AfterFormReset(CPDF_InterForm* pForm); - virtual int BeforeFormImportData(CPDF_InterForm* pForm); - virtual void AfterFormImportData(CPDF_InterForm* pForm); -}; - -class CPDF_PageLabel { - public: - explicit CPDF_PageLabel(CPDF_Document* pDocument); - - CFX_WideString GetLabel(int nPage) const; - int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const; - int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const; - - protected: - CPDF_Document* const m_pDocument; -}; - -class CPDF_Metadata { - public: - explicit CPDF_Metadata(CPDF_Document* pDoc); - ~CPDF_Metadata(); - - const CXML_Element* GetRoot() const; - - private: - std::unique_ptr<CXML_Element> m_pXmlElement; -}; - -class CPDF_ViewerPreferences { - public: - explicit CPDF_ViewerPreferences(CPDF_Document* pDoc); - ~CPDF_ViewerPreferences(); - - FX_BOOL IsDirectionR2L() const; - FX_BOOL PrintScaling() const; - int32_t NumCopies() const; - CPDF_Array* PrintPageRange() const; - CFX_ByteString Duplex() const; - - protected: - CPDF_Dictionary* GetViewerPreferences() const; - - CPDF_Document* const m_pDoc; -}; - -class CPDF_ApSettings { - public: - explicit CPDF_ApSettings(CPDF_Dictionary* pDict); - - bool HasMKEntry(const CFX_ByteString& csEntry) const; - int GetRotation() const; - - FX_ARGB GetBorderColor(int& iColorType) const { - return GetColor(iColorType, "BC"); - } - - FX_FLOAT GetOriginalBorderColor(int index) const { - return GetOriginalColor(index, "BC"); - } - - void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) const { - GetOriginalColor(iColorType, fc, "BC"); - } - - FX_ARGB GetBackgroundColor(int& iColorType) const { - return GetColor(iColorType, "BG"); - } - - FX_FLOAT GetOriginalBackgroundColor(int index) const { - return GetOriginalColor(index, "BG"); - } - - void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) const { - GetOriginalColor(iColorType, fc, "BG"); - } - - CFX_WideString GetNormalCaption() const { return GetCaption("CA"); } - CFX_WideString GetRolloverCaption() const { return GetCaption("RC"); } - CFX_WideString GetDownCaption() const { return GetCaption("AC"); } - CPDF_Stream* GetNormalIcon() const { return GetIcon("I"); } - CPDF_Stream* GetRolloverIcon() const { return GetIcon("RI"); } - CPDF_Stream* GetDownIcon() const { return GetIcon("IX"); } - CPDF_IconFit GetIconFit() const; - int GetTextPosition() const; - - protected: - friend class CPDF_FormControl; - - FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const; - FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry) const; - void GetOriginalColor(int& iColorType, - FX_FLOAT fc[4], - const CFX_ByteString& csEntry) const; - - CFX_WideString GetCaption(const CFX_ByteString& csEntry) const; - CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const; - - CPDF_Dictionary* const m_pDict; -}; - -CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, - CPDF_Annot::AppearanceMode mode); - -#endif // CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ diff --git a/core/fpdfdoc/include/ipdf_formnotify.h b/core/fpdfdoc/include/ipdf_formnotify.h new file mode 100644 index 0000000000..65be2df3d7 --- /dev/null +++ b/core/fpdfdoc/include/ipdf_formnotify.h @@ -0,0 +1,32 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFDOC_INCLUDE_IPDF_FORMNOTIFY_H_ +#define CORE_FPDFDOC_INCLUDE_IPDF_FORMNOTIFY_H_ + +#include "core/fxcrt/include/fx_string.h" + +class CPDF_FormField; +class CPDF_InterForm; + +class IPDF_FormNotify { + public: + virtual ~IPDF_FormNotify(); + + virtual int BeforeValueChange(CPDF_FormField* pField, + const CFX_WideString& csValue); + virtual void AfterValueChange(CPDF_FormField* pField); + virtual int BeforeSelectionChange(CPDF_FormField* pField, + const CFX_WideString& csValue); + virtual void AfterSelectionChange(CPDF_FormField* pField); + virtual void AfterCheckedStatusChange(CPDF_FormField* pField); + virtual int BeforeFormReset(CPDF_InterForm* pForm); + virtual void AfterFormReset(CPDF_InterForm* pForm); + virtual int BeforeFormImportData(CPDF_InterForm* pForm); + virtual void AfterFormImportData(CPDF_InterForm* pForm); +}; + +#endif // CORE_FPDFDOC_INCLUDE_IPDF_FORMNOTIFY_H_ |