• 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_FPDFDOC_CPDF_OCCONTEXT_H_
8 #define CORE_FPDFDOC_CPDF_OCCONTEXT_H_
9 
10 #include <map>
11 
12 #include "core/fxcrt/fx_string.h"
13 #include "core/fxcrt/retain_ptr.h"
14 
15 class CPDF_Array;
16 class CPDF_Dictionary;
17 class CPDF_Document;
18 class CPDF_PageObject;
19 
20 class CPDF_OCContext : public Retainable {
21  public:
22   template <typename T, typename... Args>
23   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
24 
25   enum UsageType { View = 0, Design, Print, Export };
26 
27   bool CheckOCGVisible(const CPDF_Dictionary* pOCGDict);
28   bool CheckObjectVisible(const CPDF_PageObject* pObj);
29 
30  private:
31   CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType);
32   ~CPDF_OCContext() override;
33 
34   bool LoadOCGStateFromConfig(const ByteString& csConfig,
35                               const CPDF_Dictionary* pOCGDict) const;
36   bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const;
37   bool GetOCGVisible(const CPDF_Dictionary* pOCGDict);
38   bool GetOCGVE(CPDF_Array* pExpression, int nLevel);
39   bool LoadOCMDState(const CPDF_Dictionary* pOCMDDict);
40 
41   UnownedPtr<CPDF_Document> const m_pDocument;
42   const UsageType m_eUsageType;
43   std::map<const CPDF_Dictionary*, bool> m_OCGStates;
44 };
45 
46 #endif  // CORE_FPDFDOC_CPDF_OCCONTEXT_H_
47