• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_FPDFAPI_PAGE_CPDF_FORM_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_FORM_H_
9 
10 #include <memory>
11 #include <set>
12 #include <utility>
13 
14 #include "core/fpdfapi/font/cpdf_font.h"
15 #include "core/fpdfapi/page/cpdf_pageobjectholder.h"
16 
17 class CFX_Matrix;
18 class CPDF_AllStates;
19 class CPDF_Dictionary;
20 class CPDF_Document;
21 class CPDF_ImageObject;
22 class CPDF_Stream;
23 class CPDF_Type3Char;
24 
25 class CPDF_Form final : public CPDF_PageObjectHolder,
26                         public CPDF_Font::FormIface {
27  public:
28   // Helper method to choose the first non-null resources dictionary.
29   static CPDF_Dictionary* ChooseResourcesDict(CPDF_Dictionary* pResources,
30                                               CPDF_Dictionary* pParentResources,
31                                               CPDF_Dictionary* pPageResources);
32 
33   CPDF_Form(CPDF_Document* pDocument,
34             CPDF_Dictionary* pPageResources,
35             CPDF_Stream* pFormStream);
36   CPDF_Form(CPDF_Document* pDocument,
37             CPDF_Dictionary* pPageResources,
38             CPDF_Stream* pFormStream,
39             CPDF_Dictionary* pParentResources);
40   ~CPDF_Form() override;
41 
42   // CPDF_Font::FormIface:
43   void ParseContentForType3Char(CPDF_Type3Char* pType3Char) override;
44   bool HasPageObjects() const override;
45   CFX_FloatRect CalcBoundingBox() const override;
46   Optional<std::pair<RetainPtr<CFX_DIBitmap>, CFX_Matrix>>
47   GetBitmapAndMatrixFromSoleImageOfForm() const override;
48 
49   void ParseContent();
50   void ParseContent(const CPDF_AllStates* pGraphicStates,
51                     const CFX_Matrix* pParentMatrix,
52                     std::set<const uint8_t*>* pParsedSet);
53 
54   const CPDF_Stream* GetStream() const;
55 
56  private:
57   void ParseContentInternal(const CPDF_AllStates* pGraphicStates,
58                             const CFX_Matrix* pParentMatrix,
59                             CPDF_Type3Char* pType3Char,
60                             std::set<const uint8_t*>* pParsedSet);
61 
62   std::unique_ptr<std::set<const uint8_t*>> m_ParsedSet;
63   RetainPtr<CPDF_Stream> const m_pFormStream;
64 };
65 
66 #endif  // CORE_FPDFAPI_PAGE_CPDF_FORM_H_
67