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

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

Issue 1832113003: Replace CFX_DWordArray with CFX_ArrayTemplate<FX_DWORD>. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Re-upload Created 4 years, 9 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 | « core/fpdfapi/fpdf_edit/editint.h ('k') | core/fpdfapi/fpdf_edit/include/cpdf_creator.h » ('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 <limits.h> 7 #include <limits.h>
8 8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString& dest) { 493 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString& dest) {
494 SInt32 len = CFStringGetLength(src); 494 SInt32 len = CFStringGetLength(src);
495 CFRange range = CFRangeMake(0, len); 495 CFRange range = CFRangeMake(0, len);
496 CFIndex used = 0; 496 CFIndex used = 0;
497 UInt8* pBuffer = (UInt8*)calloc(len + 1, sizeof(UInt8)); 497 UInt8* pBuffer = (UInt8*)calloc(len + 1, sizeof(UInt8));
498 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len, 498 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
499 &used); 499 &used);
500 dest = (FX_CHAR*)pBuffer; 500 dest = (FX_CHAR*)pBuffer;
501 free(pBuffer); 501 free(pBuffer);
502 } 502 }
503 FX_BOOL IsHasCharSet(CFArrayRef languages, const CFX_DWordArray& charSets) { 503 FX_BOOL IsHasCharSet(CFArrayRef languages,
504 const CFX_ArrayTemplate<FX_DWORD>& charSets) {
504 int iCount = charSets.GetSize(); 505 int iCount = charSets.GetSize();
505 for (int i = 0; i < CFArrayGetCount(languages); ++i) { 506 for (int i = 0; i < CFArrayGetCount(languages); ++i) {
506 CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i); 507 CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i);
507 FX_DWORD CharSet = FX_GetCharsetFromLang( 508 FX_DWORD CharSet = FX_GetCharsetFromLang(
508 CFStringGetCStringPtr(language, kCFStringEncodingMacRoman), -1); 509 CFStringGetCStringPtr(language, kCFStringEncodingMacRoman), -1);
509 for (int j = 0; j < iCount; ++j) { 510 for (int j = 0; j < iCount; ++j) {
510 if (CharSet == charSets[j]) { 511 if (CharSet == charSets[j]) {
511 return TRUE; 512 return TRUE;
512 } 513 }
513 } 514 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 FX_BOOL bCJK = FALSE; 565 FX_BOOL bCJK = FALSE;
565 int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0, 566 int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0,
566 bbox[4]; 567 bbox[4];
567 FXSYS_memset(bbox, 0, sizeof(int) * 4); 568 FXSYS_memset(bbox, 0, sizeof(int) * 4);
568 CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute( 569 CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(
569 descriptor, kCTFontLanguagesAttribute); 570 descriptor, kCTFontLanguagesAttribute);
570 if (!languages) { 571 if (!languages) {
571 CFRelease(descriptor); 572 CFRelease(descriptor);
572 return NULL; 573 return NULL;
573 } 574 }
574 CFX_DWordArray charSets; 575 CFX_ArrayTemplate<FX_DWORD> charSets;
575 charSets.Add(FXFONT_CHINESEBIG5_CHARSET); 576 charSets.Add(FXFONT_CHINESEBIG5_CHARSET);
576 charSets.Add(FXFONT_GB2312_CHARSET); 577 charSets.Add(FXFONT_GB2312_CHARSET);
577 charSets.Add(FXFONT_HANGEUL_CHARSET); 578 charSets.Add(FXFONT_HANGEUL_CHARSET);
578 charSets.Add(FXFONT_SHIFTJIS_CHARSET); 579 charSets.Add(FXFONT_SHIFTJIS_CHARSET);
579 if (IsHasCharSet(languages, charSets)) { 580 if (IsHasCharSet(languages, charSets)) {
580 bCJK = TRUE; 581 bCJK = TRUE;
581 } 582 }
582 CFRelease(descriptor); 583 CFRelease(descriptor);
583 CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font); 584 CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font);
584 if (!traits) { 585 if (!traits) {
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 return 1; 1069 return 1;
1069 } 1070 }
1070 nPagesToGo -= nPages; 1071 nPagesToGo -= nPages;
1071 } 1072 }
1072 } 1073 }
1073 return 0; 1074 return 0;
1074 } 1075 }
1075 static int InsertNewPage(CPDF_Document* pDoc, 1076 static int InsertNewPage(CPDF_Document* pDoc,
1076 int iPage, 1077 int iPage,
1077 CPDF_Dictionary* pPageDict, 1078 CPDF_Dictionary* pPageDict,
1078 CFX_DWordArray& pageList) { 1079 CFX_ArrayTemplate<FX_DWORD>& pageList) {
1079 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 1080 CPDF_Dictionary* pRoot = pDoc->GetRoot();
1080 if (!pRoot) { 1081 if (!pRoot) {
1081 return -1; 1082 return -1;
1082 } 1083 }
1083 CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages"); 1084 CPDF_Dictionary* pPages = pRoot->GetDictBy("Pages");
1084 if (!pPages) { 1085 if (!pPages) {
1085 return -1; 1086 return -1;
1086 } 1087 }
1087 int nPages = pDoc->GetPageCount(); 1088 int nPages = pDoc->GetPageCount();
1088 if (iPage < 0 || iPage > nPages) { 1089 if (iPage < 0 || iPage > nPages) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, 1151 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict,
1151 const CFX_ByteStringC& name) { 1152 const CFX_ByteStringC& name) {
1152 if (pPageDict->KeyExist(name)) { 1153 if (pPageDict->KeyExist(name)) {
1153 return; 1154 return;
1154 } 1155 }
1155 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); 1156 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name);
1156 if (pObj) { 1157 if (pObj) {
1157 pPageDict->SetAt(name, pObj->Clone()); 1158 pPageDict->SetAt(name, pObj->Clone());
1158 } 1159 }
1159 } 1160 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_edit/editint.h ('k') | core/fpdfapi/fpdf_edit/include/cpdf_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698