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

Side by Side Diff: core/fpdfdoc/doc_annot.cpp

Issue 1867183002: Use std::vector as internal storage for CPDF_Array (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
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 "core/fpdfapi/fpdf_page/include/cpdf_form.h" 7 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
8 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 8 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 11 matching lines...) Expand all
22 return; 22 return;
23 23
24 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots"); 24 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots");
25 if (!pAnnots) 25 if (!pAnnots)
26 return; 26 return;
27 27
28 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); 28 CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
29 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); 29 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
30 FX_BOOL bRegenerateAP = 30 FX_BOOL bRegenerateAP =
31 pAcroForm && pAcroForm->GetBooleanBy("NeedAppearances"); 31 pAcroForm && pAcroForm->GetBooleanBy("NeedAppearances");
32 for (uint32_t i = 0; i < pAnnots->GetCount(); ++i) { 32 for (size_t i = 0; i < pAnnots->GetCount(); ++i) {
33 CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i)); 33 CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i));
34 if (!pDict) 34 if (!pDict)
35 continue; 35 continue;
36 36
37 uint32_t dwObjNum = pDict->GetObjNum(); 37 uint32_t dwObjNum = pDict->GetObjNum();
38 if (dwObjNum == 0) { 38 if (dwObjNum == 0) {
39 dwObjNum = m_pDocument->AddIndirectObject(pDict); 39 dwObjNum = m_pDocument->AddIndirectObject(pDict);
40 CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum); 40 CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum);
41 pAnnots->InsertAt(i, pAction); 41 pAnnots->InsertAt(i, pAction);
42 pAnnots->RemoveAt(i + 1); 42 pAnnots->RemoveAt(i + 1);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (!pBS) { 279 if (!pBS) {
280 CPDF_Array* pBorderArray = m_pAnnotDict->GetArrayBy("Border"); 280 CPDF_Array* pBorderArray = m_pAnnotDict->GetArrayBy("Border");
281 style_char = 'S'; 281 style_char = 'S';
282 if (pBorderArray) { 282 if (pBorderArray) {
283 width = pBorderArray->GetNumberAt(2); 283 width = pBorderArray->GetNumberAt(2);
284 if (pBorderArray->GetCount() == 4) { 284 if (pBorderArray->GetCount() == 4) {
285 pDashArray = pBorderArray->GetArrayAt(3); 285 pDashArray = pBorderArray->GetArrayAt(3);
286 if (!pDashArray) { 286 if (!pDashArray) {
287 return; 287 return;
288 } 288 }
289 int nLen = pDashArray->GetCount(); 289 size_t nLen = pDashArray->GetCount();
290 int i = 0; 290 size_t i = 0;
291 for (; i < nLen; ++i) { 291 for (; i < nLen; ++i) {
292 CPDF_Object* pObj = pDashArray->GetDirectObjectAt(i); 292 CPDF_Object* pObj = pDashArray->GetDirectObjectAt(i);
293 if (pObj && pObj->GetInteger()) { 293 if (pObj && pObj->GetInteger()) {
294 break; 294 break;
295 } 295 }
296 } 296 }
297 if (i == nLen) { 297 if (i == nLen) {
298 return; 298 return;
299 } 299 }
300 style_char = 'D'; 300 style_char = 'D';
(...skipping 15 matching lines...) Expand all
316 if (pColor) { 316 if (pColor) {
317 int R = (int32_t)(pColor->GetNumberAt(0) * 255); 317 int R = (int32_t)(pColor->GetNumberAt(0) * 255);
318 int G = (int32_t)(pColor->GetNumberAt(1) * 255); 318 int G = (int32_t)(pColor->GetNumberAt(1) * 255);
319 int B = (int32_t)(pColor->GetNumberAt(2) * 255); 319 int B = (int32_t)(pColor->GetNumberAt(2) * 255);
320 argb = ArgbEncode(0xff, R, G, B); 320 argb = ArgbEncode(0xff, R, G, B);
321 } 321 }
322 CFX_GraphStateData graph_state; 322 CFX_GraphStateData graph_state;
323 graph_state.m_LineWidth = width; 323 graph_state.m_LineWidth = width;
324 if (style_char == 'D') { 324 if (style_char == 'D') {
325 if (pDashArray) { 325 if (pDashArray) {
326 uint32_t dash_count = pDashArray->GetCount(); 326 size_t dash_count = pDashArray->GetCount();
327 if (dash_count % 2) { 327 if (dash_count % 2) {
328 dash_count++; 328 dash_count++;
329 } 329 }
330 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); 330 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
331 graph_state.m_DashCount = dash_count; 331 graph_state.m_DashCount = dash_count;
332 uint32_t i; 332 size_t i;
333 for (i = 0; i < pDashArray->GetCount(); ++i) { 333 for (i = 0; i < pDashArray->GetCount(); ++i) {
334 graph_state.m_DashArray[i] = pDashArray->GetNumberAt(i); 334 graph_state.m_DashArray[i] = pDashArray->GetNumberAt(i);
335 } 335 }
336 if (i < dash_count) { 336 if (i < dash_count) {
337 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; 337 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1];
338 } 338 }
339 } else { 339 } else {
340 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); 340 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2);
341 graph_state.m_DashCount = 2; 341 graph_state.m_DashCount = 2;
342 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; 342 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f;
343 } 343 }
344 } 344 }
345 CFX_FloatRect rect; 345 CFX_FloatRect rect;
346 GetRect(rect); 346 GetRect(rect);
347 CFX_PathData path; 347 CFX_PathData path;
348 width /= 2; 348 width /= 2;
349 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, 349 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
350 rect.top - width); 350 rect.top - width);
351 int fill_type = 0; 351 int fill_type = 0;
352 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { 352 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
353 fill_type |= FXFILL_NOPATHSMOOTH; 353 fill_type |= FXFILL_NOPATHSMOOTH;
354 } 354 }
355 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); 355 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
356 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698