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

Side by Side Diff: fpdfsdk/fpdf_transformpage.cpp

Issue 2334323005: Rename dictionary set and get methods (Closed)
Patch Set: Created 4 years, 3 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 | « fpdfsdk/fpdf_flatten.cpp ('k') | fpdfsdk/fpdfdoc.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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 "public/fpdf_transformpage.h" 7 #include "public/fpdf_transformpage.h"
8 8
9 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" 9 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h"
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
(...skipping 13 matching lines...) Expand all
24 const CFX_ByteString& key, 24 const CFX_ByteString& key,
25 float left, 25 float left,
26 float bottom, 26 float bottom,
27 float right, 27 float right,
28 float top) { 28 float top) {
29 CPDF_Array* pBoundingBoxArray = new CPDF_Array; 29 CPDF_Array* pBoundingBoxArray = new CPDF_Array;
30 pBoundingBoxArray->Add(new CPDF_Number(left)); 30 pBoundingBoxArray->Add(new CPDF_Number(left));
31 pBoundingBoxArray->Add(new CPDF_Number(bottom)); 31 pBoundingBoxArray->Add(new CPDF_Number(bottom));
32 pBoundingBoxArray->Add(new CPDF_Number(right)); 32 pBoundingBoxArray->Add(new CPDF_Number(right));
33 pBoundingBoxArray->Add(new CPDF_Number(top)); 33 pBoundingBoxArray->Add(new CPDF_Number(top));
34 page->m_pFormDict->SetAt(key, pBoundingBoxArray); 34 page->m_pFormDict->SetFor(key, pBoundingBoxArray);
35 } 35 }
36 36
37 bool GetBoundingBox(CPDF_Page* page, 37 bool GetBoundingBox(CPDF_Page* page,
38 const CFX_ByteString& key, 38 const CFX_ByteString& key,
39 float* left, 39 float* left,
40 float* bottom, 40 float* bottom,
41 float* right, 41 float* right,
42 float* top) { 42 float* top) {
43 CPDF_Array* pArray = page->m_pFormDict->GetArrayBy(key); 43 CPDF_Array* pArray = page->m_pFormDict->GetArrayFor(key);
44 if (!pArray) 44 if (!pArray)
45 return false; 45 return false;
46 46
47 *left = pArray->GetFloatAt(0); 47 *left = pArray->GetFloatAt(0);
48 *bottom = pArray->GetFloatAt(1); 48 *bottom = pArray->GetFloatAt(1);
49 *right = pArray->GetFloatAt(2); 49 *right = pArray->GetFloatAt(2);
50 *top = pArray->GetFloatAt(3); 50 *top = pArray->GetFloatAt(3);
51 return true; 51 return true;
52 } 52 }
53 53
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 rect.Width(), rect.Height()); 112 rect.Width(), rect.Height());
113 textBuf << bsClipping; 113 textBuf << bsClipping;
114 114
115 CFX_ByteString bsMatix; 115 CFX_ByteString bsMatix;
116 bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c, 116 bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c,
117 matrix->d, matrix->e, matrix->f); 117 matrix->d, matrix->e, matrix->f);
118 textBuf << bsMatix; 118 textBuf << bsMatix;
119 119
120 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; 120 CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
121 CPDF_Object* pContentObj = 121 CPDF_Object* pContentObj =
122 pPageDic ? pPageDic->GetObjectBy("Contents") : nullptr; 122 pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr;
123 if (!pContentObj) 123 if (!pContentObj)
124 pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; 124 pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr;
125 if (!pContentObj) 125 if (!pContentObj)
126 return FALSE; 126 return FALSE;
127 127
128 CPDF_Dictionary* pDic = new CPDF_Dictionary; 128 CPDF_Dictionary* pDic = new CPDF_Dictionary;
129 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); 129 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
130 pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE); 130 pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
131 CPDF_Document* pDoc = pPage->m_pDocument; 131 CPDF_Document* pDoc = pPage->m_pDocument;
132 if (!pDoc) 132 if (!pDoc)
133 return FALSE; 133 return FALSE;
134 pDoc->AddIndirectObject(pStream); 134 pDoc->AddIndirectObject(pStream);
(...skipping 17 matching lines...) Expand all
152 if (pObjArray) { 152 if (pObjArray) {
153 pContentArray = pObjArray; 153 pContentArray = pObjArray;
154 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 154 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
155 pContentArray->InsertAt(0, pRef); 155 pContentArray->InsertAt(0, pRef);
156 pContentArray->AddReference(pDoc, pEndStream); 156 pContentArray->AddReference(pDoc, pEndStream);
157 } else if (pDirectObj->IsStream()) { 157 } else if (pDirectObj->IsStream()) {
158 pContentArray = new CPDF_Array(); 158 pContentArray = new CPDF_Array();
159 pContentArray->AddReference(pDoc, pStream->GetObjNum()); 159 pContentArray->AddReference(pDoc, pStream->GetObjNum());
160 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); 160 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
161 pContentArray->AddReference(pDoc, pEndStream); 161 pContentArray->AddReference(pDoc, pEndStream);
162 pPageDic->SetAtReference("Contents", pDoc, 162 pPageDic->SetReferenceFor("Contents", pDoc,
163 pDoc->AddIndirectObject(pContentArray)); 163 pDoc->AddIndirectObject(pContentArray));
164 } 164 }
165 } 165 }
166 } 166 }
167 167
168 // Need to transform the patterns as well. 168 // Need to transform the patterns as well.
169 CPDF_Dictionary* pRes = pPageDic->GetDictBy("Resources"); 169 CPDF_Dictionary* pRes = pPageDic->GetDictFor("Resources");
170 if (pRes) { 170 if (pRes) {
171 CPDF_Dictionary* pPattenDict = pRes->GetDictBy("Pattern"); 171 CPDF_Dictionary* pPattenDict = pRes->GetDictFor("Pattern");
172 if (pPattenDict) { 172 if (pPattenDict) {
173 for (const auto& it : *pPattenDict) { 173 for (const auto& it : *pPattenDict) {
174 CPDF_Object* pObj = it.second; 174 CPDF_Object* pObj = it.second;
175 if (pObj->IsReference()) 175 if (pObj->IsReference())
176 pObj = pObj->GetDirect(); 176 pObj = pObj->GetDirect();
177 177
178 CPDF_Dictionary* pDict = nullptr; 178 CPDF_Dictionary* pDict = nullptr;
179 if (pObj->IsDictionary()) 179 if (pObj->IsDictionary())
180 pDict = pObj->AsDictionary(); 180 pDict = pObj->AsDictionary();
181 else if (CPDF_Stream* pObjStream = pObj->AsStream()) 181 else if (CPDF_Stream* pObjStream = pObj->AsStream())
182 pDict = pObjStream->GetDict(); 182 pDict = pObjStream->GetDict();
183 else 183 else
184 continue; 184 continue;
185 185
186 CFX_Matrix m = pDict->GetMatrixBy("Matrix"); 186 CFX_Matrix m = pDict->GetMatrixFor("Matrix");
187 CFX_Matrix t = *(CFX_Matrix*)matrix; 187 CFX_Matrix t = *(CFX_Matrix*)matrix;
188 m.Concat(t); 188 m.Concat(t);
189 pDict->SetAtMatrix("Matrix", m); 189 pDict->SetMatrixFor("Matrix", m);
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 return TRUE; 194 return TRUE;
195 } 195 }
196 196
197 DLLEXPORT void STDCALL 197 DLLEXPORT void STDCALL
198 FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, 198 FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,
199 double a, 199 double a,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 271
272 DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, 272 DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
273 FPDF_CLIPPATH clipPath) { 273 FPDF_CLIPPATH clipPath) {
274 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 274 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
275 if (!pPage) 275 if (!pPage)
276 return; 276 return;
277 277
278 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; 278 CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
279 CPDF_Object* pContentObj = 279 CPDF_Object* pContentObj =
280 pPageDic ? pPageDic->GetObjectBy("Contents") : nullptr; 280 pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr;
281 if (!pContentObj) 281 if (!pContentObj)
282 pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; 282 pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr;
283 if (!pContentObj) 283 if (!pContentObj)
284 return; 284 return;
285 285
286 CFX_ByteTextBuf strClip; 286 CFX_ByteTextBuf strClip;
287 CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; 287 CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
288 uint32_t i; 288 uint32_t i;
289 for (i = 0; i < pClipPath->GetPathCount(); i++) { 289 for (i = 0; i < pClipPath->GetPathCount(); i++) {
290 CPDF_Path path = pClipPath->GetPath(i); 290 CPDF_Path path = pClipPath->GetPath(i);
291 int iClipType = pClipPath->GetClipType(i); 291 int iClipType = pClipPath->GetClipType(i);
292 if (path.GetPointCount() == 0) { 292 if (path.GetPointCount() == 0) {
(...skipping 26 matching lines...) Expand all
319 if (pDirectObj) { 319 if (pDirectObj) {
320 CPDF_Array* pObjArray = pDirectObj->AsArray(); 320 CPDF_Array* pObjArray = pDirectObj->AsArray();
321 if (pObjArray) { 321 if (pObjArray) {
322 pContentArray = pObjArray; 322 pContentArray = pObjArray;
323 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); 323 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
324 pContentArray->InsertAt(0, pRef); 324 pContentArray->InsertAt(0, pRef);
325 } else if (pDirectObj->IsStream()) { 325 } else if (pDirectObj->IsStream()) {
326 pContentArray = new CPDF_Array(); 326 pContentArray = new CPDF_Array();
327 pContentArray->AddReference(pDoc, pStream->GetObjNum()); 327 pContentArray->AddReference(pDoc, pStream->GetObjNum());
328 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); 328 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
329 pPageDic->SetAtReference("Contents", pDoc, 329 pPageDic->SetReferenceFor("Contents", pDoc,
330 pDoc->AddIndirectObject(pContentArray)); 330 pDoc->AddIndirectObject(pContentArray));
331 } 331 }
332 } 332 }
333 } 333 }
334 } 334 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdf_flatten.cpp ('k') | fpdfsdk/fpdfdoc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698