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

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

Issue 1513103002: Merge to XFA: Get rid of most uses of CFX_PtrArray. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years 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 <limits.h> 7 #include <limits.h>
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_page.h" 10 #include "core/include/fpdfapi/fpdf_page.h"
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 pFontDesc->SetAtInteger("StemV", nStemV); 1010 pFontDesc->SetAtInteger("StemV", nStemV);
1011 AddIndirectObject(pFontDesc); 1011 AddIndirectObject(pFontDesc);
1012 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); 1012 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
1013 return LoadFont(pBaseDict); 1013 return LoadFont(pBaseDict);
1014 } 1014 }
1015 static int InsertDeletePDFPage(CPDF_Document* pDoc, 1015 static int InsertDeletePDFPage(CPDF_Document* pDoc,
1016 CPDF_Dictionary* pPages, 1016 CPDF_Dictionary* pPages,
1017 int nPagesToGo, 1017 int nPagesToGo,
1018 CPDF_Dictionary* pPage, 1018 CPDF_Dictionary* pPage,
1019 FX_BOOL bInsert, 1019 FX_BOOL bInsert,
1020 CFX_PtrArray& stackList) { 1020 CFX_ArrayTemplate<CPDF_Dictionary*>& stackList) {
1021 CPDF_Array* pKidList = pPages->GetArray("Kids"); 1021 CPDF_Array* pKidList = pPages->GetArray("Kids");
1022 if (!pKidList) { 1022 if (!pKidList) {
1023 return -1; 1023 return -1;
1024 } 1024 }
1025 int nKids = pKidList->GetCount(); 1025 int nKids = pKidList->GetCount();
1026 for (int i = 0; i < nKids; i++) { 1026 for (int i = 0; i < nKids; i++) {
1027 CPDF_Dictionary* pKid = pKidList->GetDict(i); 1027 CPDF_Dictionary* pKid = pKidList->GetDict(i);
1028 if (pKid->GetString("Type") == FX_BSTRC("Page")) { 1028 if (pKid->GetString("Type") == FX_BSTRC("Page")) {
1029 if (nPagesToGo == 0) { 1029 if (nPagesToGo == 0) {
1030 if (bInsert) { 1030 if (bInsert) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 if (iPage == nPages) { 1081 if (iPage == nPages) {
1082 CPDF_Array* pPagesList = pPages->GetArray(FX_BSTRC("Kids")); 1082 CPDF_Array* pPagesList = pPages->GetArray(FX_BSTRC("Kids"));
1083 if (!pPagesList) { 1083 if (!pPagesList) {
1084 pPagesList = new CPDF_Array; 1084 pPagesList = new CPDF_Array;
1085 pPages->SetAt(FX_BSTRC("Kids"), pPagesList); 1085 pPages->SetAt(FX_BSTRC("Kids"), pPagesList);
1086 } 1086 }
1087 pPagesList->Add(pPageDict, pDoc); 1087 pPagesList->Add(pPageDict, pDoc);
1088 pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1); 1088 pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1);
1089 pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum()); 1089 pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum());
1090 } else { 1090 } else {
1091 CFX_PtrArray stack; 1091 CFX_ArrayTemplate<CPDF_Dictionary*> stack;
1092 stack.Add(pPages); 1092 stack.Add(pPages);
1093 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0) { 1093 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0) {
1094 return -1; 1094 return -1;
1095 } 1095 }
1096 } 1096 }
1097 pageList.InsertAt(iPage, pPageDict->GetObjNum()); 1097 pageList.InsertAt(iPage, pPageDict->GetObjNum());
1098 return iPage; 1098 return iPage;
1099 } 1099 }
1100 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) { 1100 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) {
1101 CPDF_Dictionary* pDict = new CPDF_Dictionary; 1101 CPDF_Dictionary* pDict = new CPDF_Dictionary;
(...skipping 20 matching lines...) Expand all
1122 return; 1122 return;
1123 } 1123 }
1124 CPDF_Dictionary* pPages = pRoot->GetDict("Pages"); 1124 CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
1125 if (pPages == NULL) { 1125 if (pPages == NULL) {
1126 return; 1126 return;
1127 } 1127 }
1128 int nPages = pPages->GetInteger("Count"); 1128 int nPages = pPages->GetInteger("Count");
1129 if (iPage < 0 || iPage >= nPages) { 1129 if (iPage < 0 || iPage >= nPages) {
1130 return; 1130 return;
1131 } 1131 }
1132 CFX_PtrArray stack; 1132 CFX_ArrayTemplate<CPDF_Dictionary*> stack;
1133 stack.Add(pPages); 1133 stack.Add(pPages);
1134 if (InsertDeletePDFPage(this, pPages, iPage, NULL, FALSE, stack) < 0) { 1134 if (InsertDeletePDFPage(this, pPages, iPage, NULL, FALSE, stack) < 0) {
1135 return; 1135 return;
1136 } 1136 }
1137 m_PageList.RemoveAt(iPage); 1137 m_PageList.RemoveAt(iPage);
1138 } 1138 }
1139 CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict, 1139 CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict,
1140 const CFX_ByteStringC& name); 1140 const CFX_ByteStringC& name);
1141 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, 1141 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict,
1142 const CFX_ByteStringC& name) { 1142 const CFX_ByteStringC& name) {
1143 if (pPageDict->KeyExist(name)) { 1143 if (pPageDict->KeyExist(name)) {
1144 return; 1144 return;
1145 } 1145 }
1146 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); 1146 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name);
1147 if (pObj) { 1147 if (pObj) {
1148 pPageDict->SetAt(name, pObj->Clone()); 1148 pPageDict->SetAt(name, pObj->Clone());
1149 } 1149 }
1150 } 1150 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698