Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(901)

Side by Side Diff: core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp

Issue 1841173002: Rename GetElementValue() to GetDirectObject{By,At}(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix test name Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h" 7 #include "core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h"
8 8
9 #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" 9 #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h"
10 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" 10 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h"
(...skipping 29 matching lines...) Expand all
40 CFX_ByteTextBuf buf; 40 CFX_ByteTextBuf buf;
41 CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict; 41 CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict;
42 for (int i = 0; i < m_pageObjects.GetSize(); ++i) { 42 for (int i = 0; i < m_pageObjects.GetSize(); ++i) {
43 CPDF_PageObject* pPageObj = m_pageObjects[i]; 43 CPDF_PageObject* pPageObj = m_pageObjects[i];
44 if (!pPageObj || !pPageObj->IsImage()) { 44 if (!pPageObj || !pPageObj->IsImage()) {
45 continue; 45 continue;
46 } 46 }
47 ProcessImage(buf, pPageObj->AsImage()); 47 ProcessImage(buf, pPageObj->AsImage());
48 } 48 }
49 CPDF_Object* pContent = 49 CPDF_Object* pContent =
50 pPageDict ? pPageDict->GetElementValue("Contents") : NULL; 50 pPageDict ? pPageDict->GetDirectObjectBy("Contents") : NULL;
51 if (pContent) { 51 if (pContent) {
52 pPageDict->RemoveAt("Contents"); 52 pPageDict->RemoveAt("Contents");
53 } 53 }
54 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); 54 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL);
55 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); 55 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE);
56 m_pDocument->AddIndirectObject(pStream); 56 m_pDocument->AddIndirectObject(pStream);
57 pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum()); 57 pPageDict->SetAtReference("Contents", m_pDocument, pStream->GetObjNum());
58 } 58 }
59 CFX_ByteString CPDF_PageContentGenerator::RealizeResource( 59 CFX_ByteString CPDF_PageContentGenerator::RealizeResource(
60 CPDF_Object* pResourceObj, 60 CPDF_Object* pResourceObj,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 CFX_FloatRect bbox = m_pPage->GetPageBBox(); 115 CFX_FloatRect bbox = m_pPage->GetPageBBox();
116 matrix.TransformRect(bbox); 116 matrix.TransformRect(bbox);
117 pFormDict->SetAtRect("BBox", bbox); 117 pFormDict->SetAtRect("BBox", bbox);
118 pStream->InitStream((uint8_t*)data, size, pFormDict); 118 pStream->InitStream((uint8_t*)data, size, pFormDict);
119 buf << "q " << matrix << " cm "; 119 buf << "q " << matrix << " cm ";
120 CFX_ByteString name = RealizeResource(pStream, "XObject"); 120 CFX_ByteString name = RealizeResource(pStream, "XObject");
121 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; 121 buf << "/" << PDF_NameEncode(name) << " Do Q\n";
122 } 122 }
123 void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { 123 void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) {
124 CPDF_Dictionary* pDict = m_pPage->m_pFormDict; 124 CPDF_Dictionary* pDict = m_pPage->m_pFormDict;
125 CPDF_Object* pContent = pDict ? pDict->GetElementValue("Contents") : NULL; 125 CPDF_Object* pContent = pDict ? pDict->GetDirectObjectBy("Contents") : NULL;
126 if (!pContent) 126 if (!pContent)
127 return; 127 return;
128 128
129 CFX_ByteTextBuf buf; 129 CFX_ByteTextBuf buf;
130 if (CPDF_Array* pArray = pContent->AsArray()) { 130 if (CPDF_Array* pArray = pContent->AsArray()) {
131 int iCount = pArray->GetCount(); 131 int iCount = pArray->GetCount();
132 CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount); 132 CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount);
133 int size = 0; 133 int size = 0;
134 int i = 0; 134 int i = 0;
135 for (i = 0; i < iCount; ++i) { 135 for (i = 0; i < iCount; ++i) {
136 pContent = pArray->GetElement(i); 136 pContent = pArray->GetObjectAt(i);
137 CPDF_Stream* pStream = ToStream(pContent); 137 CPDF_Stream* pStream = ToStream(pContent);
138 if (!pStream) 138 if (!pStream)
139 continue; 139 continue;
140 140
141 CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc(); 141 CPDF_StreamAcc* pStreamAcc = new CPDF_StreamAcc();
142 pStreamAcc->LoadAllData(pStream); 142 pStreamAcc->LoadAllData(pStream);
143 pContentArray[i] = pStreamAcc; 143 pContentArray[i] = pStreamAcc;
144 size += pContentArray[i]->GetSize() + 1; 144 size += pContentArray[i]->GetSize() + 1;
145 } 145 }
146 int pos = 0; 146 int pos = 0;
(...skipping 12 matching lines...) Expand all
159 CPDF_StreamAcc contentStream; 159 CPDF_StreamAcc contentStream;
160 contentStream.LoadAllData(pStream); 160 contentStream.LoadAllData(pStream);
161 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); 161 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix);
162 } 162 }
163 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); 163 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL);
164 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); 164 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE);
165 m_pDocument->AddIndirectObject(pStream); 165 m_pDocument->AddIndirectObject(pStream);
166 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, 166 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument,
167 pStream->GetObjNum()); 167 pStream->GetObjNum());
168 } 168 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698