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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 1417823005: Add type cast definitions for CPDF_Name. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 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 "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_module.h" 8 #include "../../../include/fpdfapi/fpdf_module.h"
9 #include "../../../include/fpdfapi/fpdf_serial.h" 9 #include "../../../include/fpdfapi/fpdf_serial.h"
10 #include "pageint.h" 10 #include "pageint.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { 406 void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
407 if (!m_Options.m_bMarkedContent) { 407 if (!m_Options.m_bMarkedContent) {
408 return; 408 return;
409 } 409 }
410 CFX_ByteString tag = GetString(1); 410 CFX_ByteString tag = GetString(1);
411 CPDF_Object* pProperty = GetObject(0); 411 CPDF_Object* pProperty = GetObject(0);
412 if (pProperty == NULL) { 412 if (pProperty == NULL) {
413 return; 413 return;
414 } 414 }
415 FX_BOOL bDirect = TRUE; 415 FX_BOOL bDirect = TRUE;
416 if (pProperty->GetType() == PDFOBJ_NAME) { 416 if (pProperty->IsName()) {
417 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString()); 417 pProperty = FindResourceObj(FX_BSTRC("Properties"), pProperty->GetString());
418 if (pProperty == NULL) { 418 if (!pProperty)
419 return; 419 return;
420 }
421 bDirect = FALSE; 420 bDirect = FALSE;
422 } 421 }
423 if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { 422 if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
424 m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect); 423 m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect);
425 } 424 }
426 } 425 }
427 void CPDF_StreamContentParser::Handle_BeginMarkedContent() { 426 void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
428 if (!m_Options.m_bMarkedContent) { 427 if (!m_Options.m_bMarkedContent) {
429 return; 428 return;
430 } 429 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 while (pos) { 491 while (pos) {
493 CFX_ByteString key; 492 CFX_ByteString key;
494 CPDF_Object* value = pDict->GetNextElement(pos, key); 493 CPDF_Object* value = pDict->GetNextElement(pos, key);
495 CFX_ByteStringC fullname = _PDF_FindFullName( 494 CFX_ByteStringC fullname = _PDF_FindFullName(
496 _PDF_InlineKeyAbbr, sizeof _PDF_InlineKeyAbbr / sizeof(_FX_BSTR), 495 _PDF_InlineKeyAbbr, sizeof _PDF_InlineKeyAbbr / sizeof(_FX_BSTR),
497 key); 496 key);
498 if (!fullname.IsEmpty()) { 497 if (!fullname.IsEmpty()) {
499 pDict->ReplaceKey(key, fullname); 498 pDict->ReplaceKey(key, fullname);
500 key = fullname; 499 key = fullname;
501 } 500 }
502 if (value->GetType() == PDFOBJ_NAME) { 501
502 if (value->IsName()) {
503 CFX_ByteString name = value->GetString(); 503 CFX_ByteString name = value->GetString();
504 fullname = _PDF_FindFullName( 504 fullname = _PDF_FindFullName(
505 _PDF_InlineValueAbbr, 505 _PDF_InlineValueAbbr,
506 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name); 506 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
507 if (!fullname.IsEmpty()) { 507 if (!fullname.IsEmpty()) {
508 pDict->SetAtName(key, fullname); 508 pDict->SetAtName(key, fullname);
509 } 509 }
510 } else { 510 } else {
511 _PDF_ReplaceAbbr(value); 511 _PDF_ReplaceAbbr(value);
512 } 512 }
513 } 513 }
514 break; 514 break;
515 } 515 }
516 case PDFOBJ_ARRAY: { 516 case PDFOBJ_ARRAY: {
517 CPDF_Array* pArray = (CPDF_Array*)pObj; 517 CPDF_Array* pArray = (CPDF_Array*)pObj;
518 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { 518 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
519 CPDF_Object* pElement = pArray->GetElement(i); 519 CPDF_Object* pElement = pArray->GetElement(i);
520 if (pElement->GetType() == PDFOBJ_NAME) { 520 if (pElement->IsName()) {
521 CFX_ByteString name = pElement->GetString(); 521 CFX_ByteString name = pElement->GetString();
522 CFX_ByteStringC fullname = _PDF_FindFullName( 522 CFX_ByteStringC fullname = _PDF_FindFullName(
523 _PDF_InlineValueAbbr, 523 _PDF_InlineValueAbbr,
524 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name); 524 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
525 if (!fullname.IsEmpty()) { 525 if (!fullname.IsEmpty()) {
526 pArray->SetAt(i, CPDF_Name::Create(fullname)); 526 pArray->SetAt(i, CPDF_Name::Create(fullname));
527 } 527 }
528 } else { 528 } else {
529 _PDF_ReplaceAbbr(pElement); 529 _PDF_ReplaceAbbr(pElement);
530 } 530 }
(...skipping 24 matching lines...) Expand all
555 while (pos) { 555 while (pos) {
556 CFX_ByteString key; 556 CFX_ByteString key;
557 CPDF_Object* value = pDict->GetNextElement(pos, key); 557 CPDF_Object* value = pDict->GetNextElement(pos, key);
558 CFX_ByteStringC abbrName = _PDF_FindAbbrName( 558 CFX_ByteStringC abbrName = _PDF_FindAbbrName(
559 _PDF_InlineKeyAbbr, sizeof(_PDF_InlineKeyAbbr) / sizeof(_FX_BSTR), 559 _PDF_InlineKeyAbbr, sizeof(_PDF_InlineKeyAbbr) / sizeof(_FX_BSTR),
560 key); 560 key);
561 if (!abbrName.IsEmpty()) { 561 if (!abbrName.IsEmpty()) {
562 pDict->ReplaceKey(key, abbrName); 562 pDict->ReplaceKey(key, abbrName);
563 key = abbrName; 563 key = abbrName;
564 } 564 }
565 if (value->GetType() == PDFOBJ_NAME) { 565 if (value->IsName()) {
566 CFX_ByteString name = value->GetString(); 566 CFX_ByteString name = value->GetString();
567 abbrName = _PDF_FindAbbrName( 567 abbrName = _PDF_FindAbbrName(
568 _PDF_InlineValueAbbr, 568 _PDF_InlineValueAbbr,
569 sizeof(_PDF_InlineValueAbbr) / sizeof(_FX_BSTR), name); 569 sizeof(_PDF_InlineValueAbbr) / sizeof(_FX_BSTR), name);
570 if (!abbrName.IsEmpty()) { 570 if (!abbrName.IsEmpty()) {
571 pDict->SetAtName(key, abbrName); 571 pDict->SetAtName(key, abbrName);
572 } 572 }
573 } else { 573 } else {
574 _PDF_ReplaceFull(value); 574 _PDF_ReplaceFull(value);
575 } 575 }
576 } 576 }
577 break; 577 break;
578 } 578 }
579 case PDFOBJ_ARRAY: { 579 case PDFOBJ_ARRAY: {
580 CPDF_Array* pArray = (CPDF_Array*)pObj; 580 CPDF_Array* pArray = (CPDF_Array*)pObj;
581 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) { 581 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
582 CPDF_Object* pElement = pArray->GetElement(i); 582 CPDF_Object* pElement = pArray->GetElement(i);
583 if (pElement->GetType() == PDFOBJ_NAME) { 583 if (pElement->IsName()) {
584 CFX_ByteString name = pElement->GetString(); 584 CFX_ByteString name = pElement->GetString();
585 CFX_ByteStringC abbrName = _PDF_FindAbbrName( 585 CFX_ByteStringC abbrName = _PDF_FindAbbrName(
586 _PDF_InlineValueAbbr, 586 _PDF_InlineValueAbbr,
587 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name); 587 sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
588 if (!abbrName.IsEmpty()) { 588 if (!abbrName.IsEmpty()) {
589 pArray->SetAt(i, CPDF_Name::Create(abbrName)); 589 pArray->SetAt(i, CPDF_Name::Create(abbrName));
590 } 590 }
591 } else { 591 } else {
592 _PDF_ReplaceFull(pElement); 592 _PDF_ReplaceFull(pElement);
593 } 593 }
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { 1058 void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
1059 if (m_Options.m_bTextOnly) { 1059 if (m_Options.m_bTextOnly) {
1060 return; 1060 return;
1061 } 1061 }
1062 CPDF_Object* pLastParam = GetObject(0); 1062 CPDF_Object* pLastParam = GetObject(0);
1063 if (pLastParam == NULL) { 1063 if (pLastParam == NULL) {
1064 return; 1064 return;
1065 } 1065 }
1066 int nargs = m_ParamCount; 1066 int nargs = m_ParamCount;
1067 int nvalues = nargs; 1067 int nvalues = nargs;
1068 if (pLastParam->GetType() == PDFOBJ_NAME) { 1068 if (pLastParam->IsName()) {
1069 nvalues--; 1069 nvalues--;
1070 } 1070 }
1071 FX_FLOAT* values = NULL; 1071 FX_FLOAT* values = NULL;
1072 if (nvalues) { 1072 if (nvalues) {
1073 values = FX_Alloc(FX_FLOAT, nvalues); 1073 values = FX_Alloc(FX_FLOAT, nvalues);
1074 for (int i = 0; i < nvalues; i++) { 1074 for (int i = 0; i < nvalues; i++) {
1075 values[i] = GetNumber(nargs - i - 1); 1075 values[i] = GetNumber(nargs - i - 1);
1076 } 1076 }
1077 } 1077 }
1078 if (nvalues != nargs) { 1078 if (nvalues != nargs) {
1079 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); 1079 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
1080 if (pPattern) { 1080 if (pPattern) {
1081 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues); 1081 m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues);
1082 } 1082 }
1083 } else { 1083 } else {
1084 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues); 1084 m_pCurStates->m_ColorState.SetFillColor(NULL, values, nvalues);
1085 } 1085 }
1086 FX_Free(values); 1086 FX_Free(values);
1087 } 1087 }
1088 void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() { 1088 void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
1089 if (m_Options.m_bTextOnly) { 1089 if (m_Options.m_bTextOnly) {
1090 return; 1090 return;
1091 } 1091 }
1092 CPDF_Object* pLastParam = GetObject(0); 1092 CPDF_Object* pLastParam = GetObject(0);
1093 if (pLastParam == NULL) { 1093 if (pLastParam == NULL) {
1094 return; 1094 return;
1095 } 1095 }
1096 int nargs = m_ParamCount; 1096 int nargs = m_ParamCount;
1097 int nvalues = nargs; 1097 int nvalues = nargs;
1098 if (pLastParam->GetType() == PDFOBJ_NAME) { 1098 if (pLastParam->IsName())
1099 nvalues--; 1099 nvalues--;
1100 } 1100
1101 FX_FLOAT* values = NULL; 1101 FX_FLOAT* values = NULL;
1102 if (nvalues) { 1102 if (nvalues) {
1103 values = FX_Alloc(FX_FLOAT, nvalues); 1103 values = FX_Alloc(FX_FLOAT, nvalues);
1104 for (int i = 0; i < nvalues; i++) { 1104 for (int i = 0; i < nvalues; i++) {
1105 values[i] = GetNumber(nargs - i - 1); 1105 values[i] = GetNumber(nargs - i - 1);
1106 } 1106 }
1107 } 1107 }
1108 if (nvalues != nargs) { 1108 if (nvalues != nargs) {
1109 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE); 1109 CPDF_Pattern* pPattern = FindPattern(GetString(0), FALSE);
1110 if (pPattern) { 1110 if (pPattern) {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 if (str.IsEmpty()) { 1350 if (str.IsEmpty()) {
1351 return; 1351 return;
1352 } 1352 }
1353 AddTextObject(&str, 0, NULL, 1); 1353 AddTextObject(&str, 0, NULL, 1);
1354 } 1354 }
1355 void CPDF_StreamContentParser::Handle_ShowText_Positioning() { 1355 void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
1356 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL; 1356 CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
1357 if (pArray == NULL) { 1357 if (pArray == NULL) {
1358 return; 1358 return;
1359 } 1359 }
1360 int n = pArray->GetCount(), nsegs = 0, i; 1360 int n = pArray->GetCount();
1361 for (i = 0; i < n; i++) { 1361 int nsegs = 0;
1362 for (int i = 0; i < n; i++) {
1362 if (pArray->GetElementValue(i)->IsString()) 1363 if (pArray->GetElementValue(i)->IsString())
1363 nsegs++; 1364 nsegs++;
1364 } 1365 }
1365 if (nsegs == 0) { 1366 if (nsegs == 0) {
1366 for (i = 0; i < n; i++) { 1367 for (int i = 0; i < n; i++) {
1367 m_pCurStates->m_TextX -= 1368 m_pCurStates->m_TextX -=
1368 FXSYS_Mul(pArray->GetNumber(i), 1369 FXSYS_Mul(pArray->GetNumber(i),
1369 m_pCurStates->m_TextState.GetFontSize()) / 1370 m_pCurStates->m_TextState.GetFontSize()) /
1370 1000; 1371 1000;
1371 }; 1372 };
1372 return; 1373 return;
1373 } 1374 }
1374 CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; 1375 CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
1375 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); 1376 FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
1376 int iSegment = 0; 1377 int iSegment = 0;
1377 FX_FLOAT fInitKerning = 0; 1378 FX_FLOAT fInitKerning = 0;
1378 for (i = 0; i < n; i++) { 1379 for (int i = 0; i < n; i++) {
1379 CPDF_Object* pObj = pArray->GetElementValue(i); 1380 CPDF_Object* pObj = pArray->GetElementValue(i);
1380 if (pObj->IsString()) { 1381 if (pObj->IsString()) {
1381 CFX_ByteString str = pObj->GetString(); 1382 CFX_ByteString str = pObj->GetString();
1382 if (str.IsEmpty()) { 1383 if (str.IsEmpty()) {
1383 continue; 1384 continue;
1384 } 1385 }
1385 pStrs[iSegment] = str; 1386 pStrs[iSegment] = str;
1386 pKerning[iSegment++] = 0; 1387 pKerning[iSegment++] = 0;
1387 } else { 1388 } else {
1388 FX_FLOAT num = pObj ? pObj->GetNumber() : 0; 1389 FX_FLOAT num = pObj ? pObj->GetNumber() : 0;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 buf.AppendChar((char)code); 1587 buf.AppendChar((char)code);
1587 } 1588 }
1588 bFirst = !bFirst; 1589 bFirst = !bFirst;
1589 } 1590 }
1590 } 1591 }
1591 if (!bFirst) { 1592 if (!bFirst) {
1592 buf.AppendChar((char)code); 1593 buf.AppendChar((char)code);
1593 } 1594 }
1594 return buf.GetByteString(); 1595 return buf.GetByteString();
1595 } 1596 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698