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

Side by Side Diff: fpdfsdk/src/fpdfppo.cpp

Issue 1254703002: FX_BOOL considered harmful, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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/src/fpdfformfill.cpp ('k') | fpdfsdk/src/fpdfsave.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_ppo.h" 7 #include "../../public/fpdf_ppo.h"
8 #include "../../third_party/base/nonstd_unique_ptr.h" 8 #include "../../third_party/base/nonstd_unique_ptr.h"
9 #include "../include/fsdk_define.h" 9 #include "../include/fsdk_define.h"
10 10
11 class CPDF_PageOrganizer 11 class CPDF_PageOrganizer
12 { 12 {
13 public: 13 public:
14 using ObjectNumberMap = std::map<FX_DWORD, FX_DWORD>; 14 using ObjectNumberMap = std::map<FX_DWORD, FX_DWORD>;
15 CPDF_PageOrganizer(); 15 CPDF_PageOrganizer();
16 ~CPDF_PageOrganizer(); 16 ~CPDF_PageOrganizer();
17 17
18 FX_BOOL PDFDocInit(CPDF_Document* pDestPDFDoc, CPDF_Document* pSrcPDFDoc); 18 bool PDFDocInit(CPDF_Document* pDestPDFDoc, CPDF_Document* pSrcPDFDoc);
19 FX_BOOL ExportPage(CPDF_Document* pSrcPDFDoc, 19 bool ExportPage(CPDF_Document* pSrcPDFDoc,
20 CFX_WordArray* nPageNum, 20 CFX_WordArray* nPageNum,
21 CPDF_Document* pDestPDFDoc, 21 CPDF_Document* pDestPDFDoc,
22 int nIndex); 22 int nIndex);
23 CPDF_Object* PageDictGetInheritableTag(CPDF_Dictionary* pDict, 23 CPDF_Object* PageDictGetInheritableTag(CPDF_Dictionary* pDict,
24 CFX_ByteString nSrctag); 24 CFX_ByteString nSrctag);
25 FX_BOOL UpdateReference(CPDF_Object* pObj, 25 bool UpdateReference(CPDF_Object* pObj,
26 CPDF_Document* pDoc, 26 CPDF_Document* pDoc,
27 ObjectNumberMap* pObjNumberMap); 27 ObjectNumberMap* pObjNumberMap);
28 FX_DWORD GetNewObjId(CPDF_Document* pDoc, 28 FX_DWORD GetNewObjId(CPDF_Document* pDoc,
29 ObjectNumberMap* pObjNumberMap, 29 ObjectNumberMap* pObjNumberMap,
30 CPDF_Reference* pRef); 30 CPDF_Reference* pRef);
31 }; 31 };
32 32
33 33
34 CPDF_PageOrganizer::CPDF_PageOrganizer() 34 CPDF_PageOrganizer::CPDF_PageOrganizer()
35 { 35 {
36 } 36 }
37 37
38 CPDF_PageOrganizer::~CPDF_PageOrganizer() 38 CPDF_PageOrganizer::~CPDF_PageOrganizer()
39 { 39 {
40 } 40 }
41 41
42 FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc, 42 bool CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc,
43 CPDF_Document* pSrcPDFDoc) 43 CPDF_Document* pSrcPDFDoc)
44 { 44 {
45 if (!pDestPDFDoc || !pSrcPDFDoc) 45 if (!pDestPDFDoc || !pSrcPDFDoc)
46 return FALSE; 46 return false;
47 47
48 CPDF_Dictionary* pNewRoot = pDestPDFDoc->GetRoot(); 48 CPDF_Dictionary* pNewRoot = pDestPDFDoc->GetRoot();
49 if (!pNewRoot) 49 if (!pNewRoot)
50 return FALSE; 50 return false;
51 51
52 //Set the document information//////////////////////////////////////////// 52 //Set the document information////////////////////////////////////////////
53 53
54 CPDF_Dictionary* DInfoDict = pDestPDFDoc->GetInfo(); 54 CPDF_Dictionary* DInfoDict = pDestPDFDoc->GetInfo();
55 if (!DInfoDict) 55 if (!DInfoDict)
56 return FALSE; 56 return false;
57 57
58 CFX_ByteString producerstr; 58 CFX_ByteString producerstr;
59 producerstr.Format("PDFium"); 59 producerstr.Format("PDFium");
60 DInfoDict->SetAt("Producer", new CPDF_String(producerstr)); 60 DInfoDict->SetAt("Producer", new CPDF_String(producerstr));
61 61
62 //Set type//////////////////////////////////////////////////////////////// 62 //Set type////////////////////////////////////////////////////////////////
63 CFX_ByteString cbRootType = pNewRoot->GetString("Type", ""); 63 CFX_ByteString cbRootType = pNewRoot->GetString("Type", "");
64 if (cbRootType.Equal("") ) { 64 if (cbRootType.Equal("") ) {
65 pNewRoot->SetAt("Type", new CPDF_Name("Catalog")); 65 pNewRoot->SetAt("Type", new CPDF_Name("Catalog"));
66 } 66 }
(...skipping 15 matching lines...) Expand all
82 CPDF_Array* pKeysArray = pNewPages->GetArray("Kids"); 82 CPDF_Array* pKeysArray = pNewPages->GetArray("Kids");
83 if (!pKeysArray) { 83 if (!pKeysArray) {
84 CPDF_Array* pNewKids = new CPDF_Array; 84 CPDF_Array* pNewKids = new CPDF_Array;
85 FX_DWORD Kidsobjnum = -1; 85 FX_DWORD Kidsobjnum = -1;
86 Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids); 86 Kidsobjnum = pDestPDFDoc->AddIndirectObject(pNewKids);
87 87
88 pNewPages->SetAt("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum)); 88 pNewPages->SetAt("Kids", new CPDF_Reference(pDestPDFDoc, Kidsobjnum));
89 pNewPages->SetAt("Count", new CPDF_Number(0)); 89 pNewPages->SetAt("Count", new CPDF_Number(0));
90 } 90 }
91 91
92 return TRUE; 92 return true;
93 } 93 }
94 94
95 FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, 95 bool CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc,
96 CFX_WordArray* nPageNum, 96 CFX_WordArray* nPageNum,
97 CPDF_Document* pDestPDFDoc, 97 CPDF_Document* pDestPDFDoc,
98 int nIndex) 98 int nIndex)
99 { 99 {
100 int curpage = nIndex; 100 int curpage = nIndex;
101 101
102 nonstd::unique_ptr<ObjectNumberMap> pObjNumberMap(new ObjectNumberMap); 102 nonstd::unique_ptr<ObjectNumberMap> pObjNumberMap(new ObjectNumberMap);
103 103
104 for (int i = 0; i < nPageNum->GetSize(); ++i) { 104 for (int i = 0; i < nPageNum->GetSize(); ++i) {
105 CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage); 105 CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage);
106 CPDF_Dictionary* pSrcPageDict = 106 CPDF_Dictionary* pSrcPageDict =
107 pSrcPDFDoc->GetPage(nPageNum->GetAt(i) - 1); 107 pSrcPDFDoc->GetPage(nPageNum->GetAt(i) - 1);
108 if (!pSrcPageDict || !pCurPageDict) 108 if (!pSrcPageDict || !pCurPageDict)
109 return FALSE; 109 return false;
110 110
111 // Clone the page dictionary/////////// 111 // Clone the page dictionary///////////
112 FX_POSITION SrcPos = pSrcPageDict->GetStartPos(); 112 FX_POSITION SrcPos = pSrcPageDict->GetStartPos();
113 while (SrcPos) { 113 while (SrcPos) {
114 CFX_ByteString cbSrcKeyStr; 114 CFX_ByteString cbSrcKeyStr;
115 CPDF_Object* pObj = pSrcPageDict->GetNextElement(SrcPos, 115 CPDF_Object* pObj = pSrcPageDict->GetNextElement(SrcPos,
116 cbSrcKeyStr); 116 cbSrcKeyStr);
117 if (cbSrcKeyStr.Compare(("Type")) && 117 if (cbSrcKeyStr.Compare(("Type")) &&
118 cbSrcKeyStr.Compare(("Parent"))) { 118 cbSrcKeyStr.Compare(("Parent"))) {
119 if (pCurPageDict->KeyExist(cbSrcKeyStr)) 119 if (pCurPageDict->KeyExist(cbSrcKeyStr))
(...skipping 24 matching lines...) Expand all
144 pCurPageDict->SetAt("MediaBox", pArray); 144 pCurPageDict->SetAt("MediaBox", pArray);
145 } 145 }
146 } else { 146 } else {
147 pCurPageDict->SetAt("MediaBox", pInheritable->Clone()); 147 pCurPageDict->SetAt("MediaBox", pInheritable->Clone());
148 } 148 }
149 } 149 }
150 //2 Resources //required 150 //2 Resources //required
151 if (!pCurPageDict->KeyExist("Resources")) { 151 if (!pCurPageDict->KeyExist("Resources")) {
152 pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources"); 152 pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources");
153 if (!pInheritable) 153 if (!pInheritable)
154 return FALSE; 154 return false;
155 pCurPageDict->SetAt("Resources", pInheritable->Clone()); 155 pCurPageDict->SetAt("Resources", pInheritable->Clone());
156 } 156 }
157 //3 CropBox //Optional 157 //3 CropBox //Optional
158 if (!pCurPageDict->KeyExist("CropBox")) { 158 if (!pCurPageDict->KeyExist("CropBox")) {
159 pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); 159 pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox");
160 if (pInheritable) 160 if (pInheritable)
161 pCurPageDict->SetAt("CropBox", pInheritable->Clone()); 161 pCurPageDict->SetAt("CropBox", pInheritable->Clone());
162 } 162 }
163 //4 Rotate //Optional 163 //4 Rotate //Optional
164 if (!pCurPageDict->KeyExist("Rotate")) { 164 if (!pCurPageDict->KeyExist("Rotate")) {
165 pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate"); 165 pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate");
166 if (pInheritable) 166 if (pInheritable)
167 pCurPageDict->SetAt("Rotate", pInheritable->Clone()); 167 pCurPageDict->SetAt("Rotate", pInheritable->Clone());
168 } 168 }
169 169
170 ///////////////////////////////////////////// 170 /////////////////////////////////////////////
171 //Update the reference 171 //Update the reference
172 FX_DWORD dwOldPageObj = pSrcPageDict->GetObjNum(); 172 FX_DWORD dwOldPageObj = pSrcPageDict->GetObjNum();
173 FX_DWORD dwNewPageObj = pCurPageDict->GetObjNum(); 173 FX_DWORD dwNewPageObj = pCurPageDict->GetObjNum();
174 174
175 (*pObjNumberMap)[dwOldPageObj] = dwNewPageObj; 175 (*pObjNumberMap)[dwOldPageObj] = dwNewPageObj;
176 176
177 UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get()); 177 UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get());
178 ++curpage; 178 ++curpage;
179 } 179 }
180 180
181 return TRUE; 181 return true;
182 } 182 }
183 183
184 CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag( 184 CPDF_Object* CPDF_PageOrganizer::PageDictGetInheritableTag(
185 CPDF_Dictionary* pDict, 185 CPDF_Dictionary* pDict,
186 CFX_ByteString nSrctag) 186 CFX_ByteString nSrctag)
187 { 187 {
188 if (!pDict || nSrctag.IsEmpty()) 188 if (!pDict || nSrctag.IsEmpty())
189 return nullptr; 189 return nullptr;
190 if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type")) 190 if (!pDict->KeyExist("Parent") || !pDict->KeyExist("Type"))
191 return nullptr; 191 return nullptr;
(...skipping 21 matching lines...) Expand all
213 } 213 }
214 pp = (CPDF_Dictionary*)pp->GetElement("Parent")->GetDirect(); 214 pp = (CPDF_Dictionary*)pp->GetElement("Parent")->GetDirect();
215 if (pp->GetType() == PDFOBJ_NULL) { 215 if (pp->GetType() == PDFOBJ_NULL) {
216 break; 216 break;
217 } 217 }
218 } 218 }
219 219
220 return nullptr; 220 return nullptr;
221 } 221 }
222 222
223 FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, 223 bool CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
224 CPDF_Document* pDoc, 224 CPDF_Document* pDoc,
225 ObjectNumberMap* pObjNumberMap) 225 ObjectNumberMap* pObjNumberMap)
226 { 226 {
227 switch (pObj->GetType()) { 227 switch (pObj->GetType()) {
228 case PDFOBJ_REFERENCE: { 228 case PDFOBJ_REFERENCE: {
229 CPDF_Reference* pReference = (CPDF_Reference*)pObj; 229 CPDF_Reference* pReference = (CPDF_Reference*)pObj;
230 FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference); 230 FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference);
231 if (newobjnum == 0) 231 if (newobjnum == 0)
232 return FALSE; 232 return false;
233 pReference->SetRef(pDoc, newobjnum); 233 pReference->SetRef(pDoc, newobjnum);
234 break; 234 break;
235 } 235 }
236 case PDFOBJ_DICTIONARY: { 236 case PDFOBJ_DICTIONARY: {
237 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj; 237 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
238 238
239 FX_POSITION pos = pDict->GetStartPos(); 239 FX_POSITION pos = pDict->GetStartPos();
240 while (pos) { 240 while (pos) {
241 CFX_ByteString key(""); 241 CFX_ByteString key("");
242 CPDF_Object* pNextObj = pDict->GetNextElement(pos, key); 242 CPDF_Object* pNextObj = pDict->GetNextElement(pos, key);
243 if (!FXSYS_strcmp(key, "Parent") || 243 if (!FXSYS_strcmp(key, "Parent") ||
244 !FXSYS_strcmp(key, "Prev") || 244 !FXSYS_strcmp(key, "Prev") ||
245 !FXSYS_strcmp(key, "First")) { 245 !FXSYS_strcmp(key, "First")) {
246 continue; 246 continue;
247 } 247 }
248 if (pNextObj) { 248 if (pNextObj) {
249 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) 249 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
250 pDict->RemoveAt(key); 250 pDict->RemoveAt(key);
251 } else { 251 } else {
252 return FALSE; 252 return false;
253 } 253 }
254 } 254 }
255 break; 255 break;
256 } 256 }
257 case PDFOBJ_ARRAY: { 257 case PDFOBJ_ARRAY: {
258 CPDF_Array* pArray = (CPDF_Array*)pObj; 258 CPDF_Array* pArray = (CPDF_Array*)pObj;
259 FX_DWORD count = pArray->GetCount(); 259 FX_DWORD count = pArray->GetCount();
260 for (FX_DWORD i = 0; i < count; ++i) { 260 for (FX_DWORD i = 0; i < count; ++i) {
261 CPDF_Object* pNextObj = pArray->GetElement(i); 261 CPDF_Object* pNextObj = pArray->GetElement(i);
262 if (!pNextObj) 262 if (!pNextObj)
263 return FALSE; 263 return false;
264 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) 264 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
265 return FALSE; 265 return false;
266 } 266 }
267 break; 267 break;
268 } 268 }
269 case PDFOBJ_STREAM: { 269 case PDFOBJ_STREAM: {
270 CPDF_Stream* pStream = (CPDF_Stream*)pObj; 270 CPDF_Stream* pStream = (CPDF_Stream*)pObj;
271 CPDF_Dictionary* pDict = pStream->GetDict(); 271 CPDF_Dictionary* pDict = pStream->GetDict();
272 if (pDict) { 272 if (pDict) {
273 if (!UpdateReference(pDict, pDoc, pObjNumberMap)) 273 if (!UpdateReference(pDict, pDoc, pObjNumberMap))
274 return FALSE; 274 return false;
275 } else { 275 } else {
276 return FALSE; 276 return false;
277 } 277 }
278 break; 278 break;
279 } 279 }
280 default: 280 default:
281 break; 281 break;
282 } 282 }
283 283
284 return TRUE; 284 return true;
285 } 285 }
286 286
287 FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc, 287 FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc,
288 ObjectNumberMap* pObjNumberMap, 288 ObjectNumberMap* pObjNumberMap,
289 CPDF_Reference* pRef) 289 CPDF_Reference* pRef)
290 { 290 {
291 if (!pRef) 291 if (!pRef)
292 return 0; 292 return 0;
293 293
294 FX_DWORD dwObjnum = pRef->GetRefObjNum(); 294 FX_DWORD dwObjnum = pRef->GetRefObjNum();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring, 334 FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring,
335 CFX_WordArray* pageArray, 335 CFX_WordArray* pageArray,
336 int nCount) 336 int nCount)
337 { 337 {
338 if (rangstring.GetLength() != 0) { 338 if (rangstring.GetLength() != 0) {
339 rangstring.Remove(' '); 339 rangstring.Remove(' ');
340 int nLength = rangstring.GetLength(); 340 int nLength = rangstring.GetLength();
341 CFX_ByteString cbCompareString("0123456789-,"); 341 CFX_ByteString cbCompareString("0123456789-,");
342 for (int i = 0; i < nLength; ++i) { 342 for (int i = 0; i < nLength; ++i) {
343 if (cbCompareString.Find(rangstring[i]) == -1) 343 if (cbCompareString.Find(rangstring[i]) == -1)
344 return FALSE; 344 return false;
345 } 345 }
346 CFX_ByteString cbMidRange; 346 CFX_ByteString cbMidRange;
347 int nStringFrom = 0; 347 int nStringFrom = 0;
348 int nStringTo = 0; 348 int nStringTo = 0;
349 while (nStringTo < nLength) { 349 while (nStringTo < nLength) {
350 nStringTo = rangstring.Find(',', nStringFrom); 350 nStringTo = rangstring.Find(',', nStringFrom);
351 if (nStringTo == -1) 351 if (nStringTo == -1)
352 nStringTo = nLength; 352 nStringTo = nLength;
353 cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom); 353 cbMidRange = rangstring.Mid(nStringFrom, nStringTo - nStringFrom);
354 int nMid = cbMidRange.Find('-'); 354 int nMid = cbMidRange.Find('-');
355 if (nMid == -1) { 355 if (nMid == -1) {
356 long lPageNum = atol(cbMidRange); 356 long lPageNum = atol(cbMidRange);
357 if (lPageNum <= 0 || lPageNum > nCount) 357 if (lPageNum <= 0 || lPageNum > nCount)
358 return FALSE; 358 return false;
359 pageArray->Add((FX_WORD)lPageNum); 359 pageArray->Add((FX_WORD)lPageNum);
360 } else { 360 } else {
361 int nStartPageNum = atol(cbMidRange.Mid(0, nMid)); 361 int nStartPageNum = atol(cbMidRange.Mid(0, nMid));
362 if (nStartPageNum == 0) 362 if (nStartPageNum == 0)
363 return FALSE; 363 return false;
364 364
365 ++nMid; 365 ++nMid;
366 int nEnd = cbMidRange.GetLength() - nMid; 366 int nEnd = cbMidRange.GetLength() - nMid;
367 if (nEnd == 0) 367 if (nEnd == 0)
368 return FALSE; 368 return false;
369 369
370 int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd)); 370 int nEndPageNum = atol(cbMidRange.Mid(nMid, nEnd));
371 if (nStartPageNum < 0 || 371 if (nStartPageNum < 0 ||
372 nStartPageNum >nEndPageNum || 372 nStartPageNum >nEndPageNum ||
373 nEndPageNum > nCount) { 373 nEndPageNum > nCount) {
374 return FALSE; 374 return false;
375 } 375 }
376 for (int i = nStartPageNum; i <= nEndPageNum; ++i) { 376 for (int i = nStartPageNum; i <= nEndPageNum; ++i) {
377 pageArray->Add(i); 377 pageArray->Add(i);
378 } 378 }
379 } 379 }
380 nStringFrom = nStringTo + 1; 380 nStringFrom = nStringTo + 1;
381 } 381 }
382 } 382 }
383 return TRUE; 383 return true;
384 } 384 }
385 385
386 DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, 386 DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
387 FPDF_DOCUMENT src_doc, 387 FPDF_DOCUMENT src_doc,
388 FPDF_BYTESTRING pagerange, 388 FPDF_BYTESTRING pagerange,
389 int index) 389 int index)
390 { 390 {
391 if (!dest_doc || !src_doc) 391 if (!dest_doc || !src_doc)
392 return FALSE; 392 return false;
393 393
394 CFX_WordArray pageArray; 394 CFX_WordArray pageArray;
395 CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc; 395 CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc;
396 int nCount = pSrcDoc->GetPageCount(); 396 int nCount = pSrcDoc->GetPageCount();
397 if (pagerange) { 397 if (pagerange) {
398 if (!ParserPageRangeString(pagerange,&pageArray,nCount)) 398 if (!ParserPageRangeString(pagerange,&pageArray,nCount))
399 return FALSE; 399 return false;
400 } else { 400 } else {
401 for (int i = 1; i <= nCount; ++i) { 401 for (int i = 1; i <= nCount; ++i) {
402 pageArray.Add(i); 402 pageArray.Add(i);
403 } 403 }
404 } 404 }
405 405
406 CPDF_Document* pDestDoc = (CPDF_Document*)dest_doc; 406 CPDF_Document* pDestDoc = (CPDF_Document*)dest_doc;
407 CPDF_PageOrganizer pageOrg; 407 CPDF_PageOrganizer pageOrg;
408 408
409 pageOrg.PDFDocInit(pDestDoc, pSrcDoc); 409 pageOrg.PDFDocInit(pDestDoc, pSrcDoc);
410 410
411 return pageOrg.ExportPage(pSrcDoc,&pageArray,pDestDoc,index); 411 return pageOrg.ExportPage(pSrcDoc,&pageArray,pDestDoc,index);
412 } 412 }
413 413
414 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, 414 DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc,
415 FPDF_DOCUMENT src_doc) 415 FPDF_DOCUMENT src_doc)
416 { 416 {
417 if (!src_doc || !dest_doc) 417 if (!src_doc || !dest_doc)
418 return false; 418 return false;
419 419
420 CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc; 420 CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc;
421 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot(); 421 CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot();
422 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));; 422 pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));;
423 if (!pSrcDict) 423 if (!pSrcDict)
424 return FALSE; 424 return false;
425 425
426 CPDF_Document* pDstDoc = (CPDF_Document*)dest_doc; 426 CPDF_Document* pDstDoc = (CPDF_Document*)dest_doc;
427 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); 427 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
428 if (!pDstDict) 428 if (!pDstDict)
429 return FALSE; 429 return false;
430 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE)); 430 pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(true));
431 return TRUE; 431 return true;
432 } 432 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfformfill.cpp ('k') | fpdfsdk/src/fpdfsave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698