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_pageobjectholder.cpp
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#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
8
9#include <algorithm>
10#include <utility>
11
12#include "constants/transparency.h"
13#include "core/fpdfapi/page/cpdf_allstates.h"
14#include "core/fpdfapi/page/cpdf_contentparser.h"
15#include "core/fpdfapi/page/cpdf_pageobject.h"
16#include "core/fpdfapi/parser/cpdf_dictionary.h"
17#include "core/fpdfapi/parser/cpdf_document.h"
18#include "core/fxcrt/fx_extension.h"
19#include "core/fxcrt/stl_util.h"
20#include "third_party/base/check.h"
21#include "third_party/base/check_op.h"
22
23bool GraphicsData::operator<(const GraphicsData& other) const {
24 if (!FXSYS_SafeEQ(fillAlpha, other.fillAlpha))
25 return FXSYS_SafeLT(fillAlpha, other.fillAlpha);
26 if (!FXSYS_SafeEQ(strokeAlpha, other.strokeAlpha))
27 return FXSYS_SafeLT(strokeAlpha, other.strokeAlpha);
28 return blendType < other.blendType;
29}
30
31bool FontData::operator<(const FontData& other) const {
32 if (baseFont != other.baseFont)
33 return baseFont < other.baseFont;
34 return type < other.type;
35}
36
38 CPDF_Document* pDoc,
39 RetainPtr<CPDF_Dictionary> pDict,
40 RetainPtr<CPDF_Dictionary> pPageResources,
41 RetainPtr<CPDF_Dictionary> pResources)
46 DCHECK(m_pDict);
47}
48
50
52 return false;
53}
54
56 std::unique_ptr<CPDF_ContentParser> pParser) {
57 DCHECK_EQ(m_ParseState, ParseState::kNotParsed);
58 m_pParser = std::move(pParser);
59 m_ParseState = ParseState::kParsing;
60}
61
63 if (m_ParseState == ParseState::kParsed)
64 return;
65
66 DCHECK_EQ(m_ParseState, ParseState::kParsing);
67 if (m_pParser->Continue(pPause))
68 return;
69
70 m_ParseState = ParseState::kParsed;
71 m_pDocument->IncrementParsedPageCount();
72 if (m_pParser->GetCurStates()) {
73 m_LastCTM = m_pParser->GetCurStates()->current_transformation_matrix();
74 }
75
76 m_pParser.reset();
77}
78
80 m_MaskBoundingBoxes.push_back(box);
81}
82
84 auto dirty_streams = std::move(m_DirtyStreams);
85 m_DirtyStreams.clear();
86 return dirty_streams;
87}
88
90 const GraphicsData& gd) {
91 auto it = m_GraphicsMap.find(gd);
92 if (it == m_GraphicsMap.end())
93 return absl::nullopt;
94
95 return it->second;
96}
97
99 const ByteString& str) {
100 m_GraphicsMap[gd] = str;
101}
102
104 const FontData& fd) {
105 auto it = m_FontsMap.find(fd);
106 if (it == m_FontsMap.end())
107 return absl::nullopt;
108
109 return it->second;
110}
111
113 const ByteString& str) {
114 m_FontsMap[fd] = str;
115}
116
118 RetainPtr<const CPDF_Dictionary> pGroup = m_pDict->GetDictFor("Group");
119 if (!pGroup)
120 return;
121
122 if (pGroup->GetByteStringFor(pdfium::transparency::kGroupSubType) !=
124 return;
125 }
127 if (pGroup->GetIntegerFor(pdfium::transparency::kI))
129}
130
132 size_t index) const {
133 return fxcrt::IndexInBounds(m_PageObjectList, index)
134 ? m_PageObjectList[index].get()
135 : nullptr;
136}
137
139 std::unique_ptr<CPDF_PageObject> pPageObj) {
140 m_PageObjectList.push_back(std::move(pPageObj));
141}
142
144 CPDF_PageObject* pPageObj) {
145 auto it = std::find(std::begin(m_PageObjectList), std::end(m_PageObjectList),
146 fxcrt::MakeFakeUniquePtr(pPageObj));
147 if (it == std::end(m_PageObjectList))
148 return nullptr;
149
150 std::unique_ptr<CPDF_PageObject> result = std::move(*it);
151 m_PageObjectList.erase(it);
152
153 int32_t content_stream = pPageObj->GetContentStream();
154 if (content_stream >= 0)
155 m_DirtyStreams.insert(content_stream);
156
157 return result;
158}
159
161 if (index >= m_PageObjectList.size())
162 return false;
163
164 m_PageObjectList.erase(m_PageObjectList.begin() + index);
165 return true;
166}
absl::optional< ByteString > GraphicsMapSearch(const GraphicsData &gd)
void StartParse(std::unique_ptr< CPDF_ContentParser > pParser)
virtual bool IsPage() const
virtual ~CPDF_PageObjectHolder()
void GraphicsMapInsert(const GraphicsData &gd, const ByteString &str)
void AddImageMaskBoundingBox(const CFX_FloatRect &box)
void AppendPageObject(std::unique_ptr< CPDF_PageObject > pPageObj)
void FontsMapInsert(const FontData &fd, const ByteString &str)
absl::optional< ByteString > FontsMapSearch(const FontData &fd)
bool ErasePageObjectAtIndex(size_t index)
CPDF_PageObjectHolder(CPDF_Document *pDoc, RetainPtr< CPDF_Dictionary > pDict, RetainPtr< CPDF_Dictionary > pPageResources, RetainPtr< CPDF_Dictionary > pResources)
void ContinueParse(PauseIndicatorIface *pPause)
CPDF_PageObject * GetPageObjectByIndex(size_t index) const
std::unique_ptr< CPDF_PageObject > RemovePageObject(CPDF_PageObject *pPageObj)
CPDF_Transparency m_Transparency
std::set< int32_t > TakeDirtyStreams()
int32_t GetContentStream() const
const char kTransparency[]
const char kGroupSubType[]
bool operator<(const FontData &other) const
bool operator<(const GraphicsData &other) const