7#include "core/fpdfapi/edit/cpdf_pageorganizer.h"
12#include "constants/page_object.h"
13#include "core/fpdfapi/parser/cpdf_array.h"
14#include "core/fpdfapi/parser/cpdf_dictionary.h"
15#include "core/fpdfapi/parser/cpdf_document.h"
16#include "core/fpdfapi/parser/cpdf_name.h"
17#include "core/fpdfapi/parser/cpdf_number.h"
18#include "core/fpdfapi/parser/cpdf_object.h"
19#include "core/fpdfapi/parser/cpdf_reference.h"
20#include "core/fpdfapi/parser/cpdf_stream.h"
21#include "core/fpdfapi/parser/cpdf_string.h"
22#include "core/fxcrt/bytestring.h"
23#include "core/fxcrt/check.h"
46 info->SetNewFor<CPDF_String>(
"Producer",
"PDFium");
49 if (root->GetByteStringFor(
"Type",
ByteString()).IsEmpty()) {
50 root->SetNewFor<CPDF_Name>(
"Type",
"Catalog");
56 pages = ToDictionary(current_pages->GetMutableDirect());
60 root->SetNewFor<CPDF_Reference>(
"Pages",
dest(), pages->GetObjNum());
62 if (pages->GetByteStringFor(
"Type",
ByteString()).IsEmpty()) {
63 pages->SetNewFor<CPDF_Name>(
"Type",
"Pages");
66 if (!pages->GetArrayFor(
"Kids")) {
68 pages->SetNewFor<CPDF_Number>(
"Count", 0);
69 pages->SetNewFor<CPDF_Reference>(
"Kids",
dest(), kids_array->GetObjNum());
75 switch (obj->GetType()) {
77 CPDF_Reference* reference = obj->AsMutableReference();
78 uint32_t newobjnum = GetNewObjId(reference);
87 std::vector<ByteString> bad_keys;
90 for (
const auto& it : locker) {
91 const ByteString& key = it.first;
92 if (key ==
"Parent" || key ==
"Prev" || key ==
"First") {
95 RetainPtr<CPDF_Object> next_obj = it.second;
96 if (!UpdateReference(next_obj)) {
97 bad_keys.push_back(key);
101 for (
const auto& key : bad_keys) {
102 dict->RemoveFor(key.AsStringView());
108 for (size_t i = 0; i < array->size(); ++i) {
129 uint32_t new_obj_num = 0;
130 const auto it = object_number_map_.find(obj_num);
131 if (it != object_number_map_.end()) {
132 new_obj_num = it->second;
169 if (dest_page_dict->KeyExist(key)) {
174 PageDictGetInheritableTag(std::move(src_page_dict), key);
179 dest_page_dict->SetFor(key, inheritable->Clone());
187 if (!dict || src_tag.IsEmpty()) {
196 ToName(dict->GetObjectFor(pdfium::page_object::kType)->GetDirect());
197 if (!name || name->GetString() !=
"Page") {
202 dict->GetObjectFor(pdfium::page_object::kParent)->GetDirect());
207 if (dict->KeyExist(src_tag)) {
208 return dict->GetObjectFor(src_tag);
212 if (pp->KeyExist(src_tag)) {
213 return pp->GetObjectFor(src_tag);
fxcrt::ByteString ByteString
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
CPDF_DictionaryLocker(const CPDF_Dictionary *pDictionary)
bool KeyExist(const ByteString &key) const
ByteString GetByteStringFor(const ByteString &key) const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
uint32_t AddIndirectObject(RetainPtr< CPDF_Object > pObj)
static bool CopyInheritable(RetainPtr< CPDF_Dictionary > dest_page_dict, RetainPtr< const CPDF_Dictionary > src_page_dict, const ByteString &key)
static RetainPtr< const CPDF_Object > PageDictGetInheritableTag(RetainPtr< const CPDF_Dictionary > dict, const ByteString &src_tag)
CPDF_PageOrganizer(CPDF_Document *dest_doc, CPDF_Document *src_doc)
bool UpdateReference(RetainPtr< CPDF_Object > obj)
void AddObjectMapping(uint32_t old_page_obj_num, uint32_t new_page_obj_num)
void SetRef(CPDF_IndirectObjectHolder *pDoc, uint32_t objnum)
uint32_t GetRefObjNum() const
bool EqualNoCase(ByteStringView str) const