Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_contentparser.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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_CONTENTPARSER_H_
8#define CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_
9
10#include <stdint.h>
11
12#include <memory>
13#include <vector>
14
15#include "core/fpdfapi/page/cpdf_form.h"
16#include "core/fpdfapi/page/cpdf_streamcontentparser.h"
17#include "core/fxcrt/fixed_size_data_vector.h"
18#include "core/fxcrt/retain_ptr.h"
19#include "core/fxcrt/unowned_ptr.h"
20#include "third_party/abseil-cpp/absl/types/variant.h"
21
22class CPDF_AllStates;
23class CPDF_Array;
24class CPDF_Page;
26class CPDF_Stream;
27class CPDF_StreamAcc;
28class CPDF_Type3Char;
30
32 public:
33 explicit CPDF_ContentParser(CPDF_Page* pPage);
34 CPDF_ContentParser(RetainPtr<const CPDF_Stream> pStream,
35 CPDF_PageObjectHolder* pPageObjectHolder,
36 const CPDF_AllStates* pGraphicStates,
37 const CFX_Matrix* pParentMatrix,
38 CPDF_Type3Char* pType3Char,
39 CPDF_Form::RecursionState* recursion_state);
41
43 return m_pParser ? m_pParser->GetCurStates() : nullptr;
44 }
45 // Returns whether to continue or not.
46 bool Continue(PauseIndicatorIface* pPause);
47
48 private:
49 enum class Stage : uint8_t {
50 kGetContent = 1,
51 kPrepareContent,
52 kParse,
53 kCheckClip,
54 kComplete,
55 };
56
57 Stage GetContent();
58 Stage PrepareContent();
59 Stage Parse();
60 Stage CheckClip();
61
62 void HandlePageContentStream(const CPDF_Stream* pStream);
63 bool HandlePageContentArray(const CPDF_Array* pArray);
64 void HandlePageContentFailure();
65
66 bool is_owned() const {
67 return absl::holds_alternative<FixedSizeDataVector<uint8_t>>(m_Data);
68 }
69 pdfium::span<const uint8_t> GetData() const;
70
71 Stage m_CurrentStage;
72 UnownedPtr<CPDF_PageObjectHolder> const m_pPageObjectHolder;
73 UnownedPtr<CPDF_Type3Char> m_pType3Char; // Only used when parsing forms.
74 RetainPtr<CPDF_StreamAcc> m_pSingleStream;
75 std::vector<RetainPtr<CPDF_StreamAcc>> m_StreamArray;
76 std::vector<uint32_t> m_StreamSegmentOffsets;
77 absl::variant<pdfium::span<const uint8_t>, FixedSizeDataVector<uint8_t>>
78 m_Data;
79 uint32_t m_nStreams = 0;
80 uint32_t m_CurrentOffset = 0;
81 // Only used when parsing pages.
82 CPDF_Form::RecursionState m_RecursionState;
83
84 // Must not outlive |m_RecursionState|.
85 std::unique_ptr<CPDF_StreamContentParser> m_pParser;
86};
87
88#endif // CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
CFX_FloatRect TransformRect(const CFX_FloatRect &rect) const
void Concat(const CFX_Matrix &right)
const CFX_Matrix & current_transformation_matrix() const
CPDF_ContentParser(CPDF_Page *pPage)
const CPDF_AllStates * GetCurStates() const
bool Continue(PauseIndicatorIface *pPause)
CPDF_ContentParser(RetainPtr< const CPDF_Stream > pStream, CPDF_PageObjectHolder *pPageObjectHolder, const CPDF_AllStates *pGraphicStates, const CFX_Matrix *pParentMatrix, CPDF_Type3Char *pType3Char, CPDF_Form::RecursionState *recursion_state)
void SetBlendType(BlendMode type)
void SetFillAlpha(float alpha)
void SetStrokeAlpha(float alpha)
void SetSoftMask(RetainPtr< CPDF_Dictionary > pDict)
CPDF_Document * GetDocument() const override
Definition cpdf_page.cpp:51
bool HasRef() const
Definition cpdf_path.h:22
void AppendFloatRect(const CFX_FloatRect &rect)
Definition cpdf_path.cpp:49
void Emplace()
Definition cpdf_path.h:21
void Transform(const CFX_Matrix &matrix)
Definition cpdf_path.cpp:41
virtual bool NeedToPauseNow()=0
BlendMode
Definition fx_dib.h:49