OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "core/include/fpdfdoc/fpdf_doc.h" | 9 #include "core/include/fpdfdoc/fpdf_doc.h" |
10 #include "doc_utils.h" | 10 #include "doc_utils.h" |
11 | 11 |
12 static const int FPDFDOC_UTILS_MAXRECURSION = 32; | 12 static const int FPDFDOC_UTILS_MAXRECURSION = 32; |
13 | 13 |
14 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict) { | 14 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict) { |
15 CFX_WideString full_name; | 15 CFX_WideString full_name; |
16 CPDF_Dictionary* pLevel = pFieldDict; | 16 CPDF_Dictionary* pLevel = pFieldDict; |
17 while (pLevel) { | 17 while (pLevel) { |
18 CFX_WideString short_name = pLevel->GetUnicodeText("T"); | 18 CFX_WideString short_name = pLevel->GetUnicodeTextBy("T"); |
19 if (short_name != L"") { | 19 if (short_name != L"") { |
20 if (full_name == L"") { | 20 if (full_name == L"") { |
21 full_name = short_name; | 21 full_name = short_name; |
22 } else { | 22 } else { |
23 full_name = short_name + L"." + full_name; | 23 full_name = short_name + L"." + full_name; |
24 } | 24 } |
25 } | 25 } |
26 pLevel = pLevel->GetDict("Parent"); | 26 pLevel = pLevel->GetDictBy("Parent"); |
27 } | 27 } |
28 return full_name; | 28 return full_name; |
29 } | 29 } |
30 FX_BOOL CPDF_DefaultAppearance::HasFont() { | 30 FX_BOOL CPDF_DefaultAppearance::HasFont() { |
31 if (m_csDA.IsEmpty()) { | 31 if (m_csDA.IsEmpty()) { |
32 return FALSE; | 32 return FALSE; |
33 } | 33 } |
34 CPDF_SimpleParser syntax(m_csDA); | 34 CPDF_SimpleParser syntax(m_csDA); |
35 return syntax.FindTagParam("Tf", 2); | 35 return syntax.FindTagParam("Tf", 2); |
36 } | 36 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 265 } |
266 csDA += "0 g"; | 266 csDA += "0 g"; |
267 if (!pFormDict->KeyExist("DA")) { | 267 if (!pFormDict->KeyExist("DA")) { |
268 pFormDict->SetAtString("DA", csDA); | 268 pFormDict->SetAtString("DA", csDA); |
269 } | 269 } |
270 } | 270 } |
271 FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) { | 271 FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) { |
272 if (!pFormDict) { | 272 if (!pFormDict) { |
273 return 0; | 273 return 0; |
274 } | 274 } |
275 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 275 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
276 if (!pDR) { | 276 if (!pDR) { |
277 return 0; | 277 return 0; |
278 } | 278 } |
279 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 279 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
280 if (!pFonts) { | 280 if (!pFonts) { |
281 return 0; | 281 return 0; |
282 } | 282 } |
283 FX_DWORD dwCount = 0; | 283 FX_DWORD dwCount = 0; |
284 for (const auto& it : *pFonts) { | 284 for (const auto& it : *pFonts) { |
285 CPDF_Object* pObj = it.second; | 285 CPDF_Object* pObj = it.second; |
286 if (!pObj) { | 286 if (!pObj) { |
287 continue; | 287 continue; |
288 } | 288 } |
289 if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) { | 289 if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) { |
290 if (pDirect->GetString("Type") == "Font") { | 290 if (pDirect->GetStringBy("Type") == "Font") { |
291 dwCount++; | 291 dwCount++; |
292 } | 292 } |
293 } | 293 } |
294 } | 294 } |
295 return dwCount; | 295 return dwCount; |
296 } | 296 } |
297 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, | 297 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, |
298 CPDF_Document* pDocument, | 298 CPDF_Document* pDocument, |
299 FX_DWORD index, | 299 FX_DWORD index, |
300 CFX_ByteString& csNameTag) { | 300 CFX_ByteString& csNameTag) { |
301 if (!pFormDict) { | 301 if (!pFormDict) { |
302 return NULL; | 302 return NULL; |
303 } | 303 } |
304 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 304 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
305 if (!pDR) { | 305 if (!pDR) { |
306 return NULL; | 306 return NULL; |
307 } | 307 } |
308 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 308 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
309 if (!pFonts) { | 309 if (!pFonts) { |
310 return NULL; | 310 return NULL; |
311 } | 311 } |
312 FX_DWORD dwCount = 0; | 312 FX_DWORD dwCount = 0; |
313 for (const auto& it : *pFonts) { | 313 for (const auto& it : *pFonts) { |
314 const CFX_ByteString& csKey = it.first; | 314 const CFX_ByteString& csKey = it.first; |
315 CPDF_Object* pObj = it.second; | 315 CPDF_Object* pObj = it.second; |
316 if (!pObj) { | 316 if (!pObj) { |
317 continue; | 317 continue; |
318 } | 318 } |
319 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); | 319 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); |
320 if (!pElement) | 320 if (!pElement) |
321 continue; | 321 continue; |
322 if (pElement->GetString("Type") != "Font") | 322 if (pElement->GetStringBy("Type") != "Font") |
323 continue; | 323 continue; |
324 if (dwCount == index) { | 324 if (dwCount == index) { |
325 csNameTag = csKey; | 325 csNameTag = csKey; |
326 return pDocument->LoadFont(pElement); | 326 return pDocument->LoadFont(pElement); |
327 } | 327 } |
328 dwCount++; | 328 dwCount++; |
329 } | 329 } |
330 return NULL; | 330 return NULL; |
331 } | 331 } |
332 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, | 332 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, |
333 CPDF_Document* pDocument, | 333 CPDF_Document* pDocument, |
334 CFX_ByteString csNameTag) { | 334 CFX_ByteString csNameTag) { |
335 CFX_ByteString csAlias = PDF_NameDecode(csNameTag); | 335 CFX_ByteString csAlias = PDF_NameDecode(csNameTag); |
336 if (!pFormDict || csAlias.IsEmpty()) { | 336 if (!pFormDict || csAlias.IsEmpty()) { |
337 return NULL; | 337 return NULL; |
338 } | 338 } |
339 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 339 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
340 if (!pDR) { | 340 if (!pDR) { |
341 return NULL; | 341 return NULL; |
342 } | 342 } |
343 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 343 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
344 if (!pFonts) { | 344 if (!pFonts) { |
345 return NULL; | 345 return NULL; |
346 } | 346 } |
347 CPDF_Dictionary* pElement = pFonts->GetDict(csAlias); | 347 CPDF_Dictionary* pElement = pFonts->GetDictBy(csAlias); |
348 if (!pElement) { | 348 if (!pElement) { |
349 return NULL; | 349 return NULL; |
350 } | 350 } |
351 if (pElement->GetString("Type") == "Font") { | 351 if (pElement->GetStringBy("Type") == "Font") { |
352 return pDocument->LoadFont(pElement); | 352 return pDocument->LoadFont(pElement); |
353 } | 353 } |
354 return NULL; | 354 return NULL; |
355 } | 355 } |
356 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, | 356 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, |
357 CPDF_Document* pDocument, | 357 CPDF_Document* pDocument, |
358 CFX_ByteString csFontName, | 358 CFX_ByteString csFontName, |
359 CFX_ByteString& csNameTag) { | 359 CFX_ByteString& csNameTag) { |
360 if (!pFormDict || csFontName.IsEmpty()) { | 360 if (!pFormDict || csFontName.IsEmpty()) { |
361 return NULL; | 361 return NULL; |
362 } | 362 } |
363 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 363 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
364 if (!pDR) { | 364 if (!pDR) { |
365 return NULL; | 365 return NULL; |
366 } | 366 } |
367 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 367 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
368 if (!pFonts) { | 368 if (!pFonts) { |
369 return NULL; | 369 return NULL; |
370 } | 370 } |
371 for (const auto& it : *pFonts) { | 371 for (const auto& it : *pFonts) { |
372 const CFX_ByteString& csKey = it.first; | 372 const CFX_ByteString& csKey = it.first; |
373 CPDF_Object* pObj = it.second; | 373 CPDF_Object* pObj = it.second; |
374 if (!pObj) { | 374 if (!pObj) { |
375 continue; | 375 continue; |
376 } | 376 } |
377 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); | 377 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); |
378 if (!pElement) | 378 if (!pElement) |
379 continue; | 379 continue; |
380 if (pElement->GetString("Type") != "Font") | 380 if (pElement->GetStringBy("Type") != "Font") |
381 continue; | 381 continue; |
382 | 382 |
383 CPDF_Font* pFind = pDocument->LoadFont(pElement); | 383 CPDF_Font* pFind = pDocument->LoadFont(pElement); |
384 if (!pFind) | 384 if (!pFind) |
385 continue; | 385 continue; |
386 | 386 |
387 CFX_ByteString csBaseFont; | 387 CFX_ByteString csBaseFont; |
388 csBaseFont = pFind->GetBaseFont(); | 388 csBaseFont = pFind->GetBaseFont(); |
389 csBaseFont.Remove(' '); | 389 csBaseFont.Remove(' '); |
390 if (csBaseFont == csFontName) { | 390 if (csBaseFont == csFontName) { |
391 csNameTag = csKey; | 391 csNameTag = csKey; |
392 return pFind; | 392 return pFind; |
393 } | 393 } |
394 } | 394 } |
395 return NULL; | 395 return NULL; |
396 } | 396 } |
397 CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, | 397 CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, |
398 CPDF_Document* pDocument, | 398 CPDF_Document* pDocument, |
399 uint8_t charSet, | 399 uint8_t charSet, |
400 CFX_ByteString& csNameTag) { | 400 CFX_ByteString& csNameTag) { |
401 if (!pFormDict) { | 401 if (!pFormDict) { |
402 return NULL; | 402 return NULL; |
403 } | 403 } |
404 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 404 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
405 if (!pDR) { | 405 if (!pDR) { |
406 return NULL; | 406 return NULL; |
407 } | 407 } |
408 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 408 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
409 if (!pFonts) { | 409 if (!pFonts) { |
410 return NULL; | 410 return NULL; |
411 } | 411 } |
412 for (const auto& it : *pFonts) { | 412 for (const auto& it : *pFonts) { |
413 const CFX_ByteString& csKey = it.first; | 413 const CFX_ByteString& csKey = it.first; |
414 CPDF_Object* pObj = it.second; | 414 CPDF_Object* pObj = it.second; |
415 if (!pObj) { | 415 if (!pObj) { |
416 continue; | 416 continue; |
417 } | 417 } |
418 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); | 418 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); |
419 if (!pElement) | 419 if (!pElement) |
420 continue; | 420 continue; |
421 if (pElement->GetString("Type") != "Font") | 421 if (pElement->GetStringBy("Type") != "Font") |
422 continue; | 422 continue; |
423 CPDF_Font* pFind = pDocument->LoadFont(pElement); | 423 CPDF_Font* pFind = pDocument->LoadFont(pElement); |
424 if (!pFind) { | 424 if (!pFind) { |
425 continue; | 425 continue; |
426 } | 426 } |
427 CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont(); | 427 CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont(); |
428 if (!pSubst) { | 428 if (!pSubst) { |
429 continue; | 429 continue; |
430 } | 430 } |
431 if (pSubst->m_Charset == (int)charSet) { | 431 if (pSubst->m_Charset == (int)charSet) { |
(...skipping 18 matching lines...) Expand all Loading... |
450 } | 450 } |
451 } | 451 } |
452 return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag); | 452 return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag); |
453 } | 453 } |
454 FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, | 454 FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, |
455 const CPDF_Font* pFont, | 455 const CPDF_Font* pFont, |
456 CFX_ByteString& csNameTag) { | 456 CFX_ByteString& csNameTag) { |
457 if (!pFormDict || !pFont) { | 457 if (!pFormDict || !pFont) { |
458 return FALSE; | 458 return FALSE; |
459 } | 459 } |
460 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 460 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
461 if (!pDR) { | 461 if (!pDR) { |
462 return FALSE; | 462 return FALSE; |
463 } | 463 } |
464 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 464 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
465 if (!pFonts) { | 465 if (!pFonts) { |
466 return FALSE; | 466 return FALSE; |
467 } | 467 } |
468 for (const auto& it : *pFonts) { | 468 for (const auto& it : *pFonts) { |
469 const CFX_ByteString& csKey = it.first; | 469 const CFX_ByteString& csKey = it.first; |
470 CPDF_Object* pObj = it.second; | 470 CPDF_Object* pObj = it.second; |
471 if (!pObj) { | 471 if (!pObj) { |
472 continue; | 472 continue; |
473 } | 473 } |
474 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); | 474 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); |
475 if (!pElement) | 475 if (!pElement) |
476 continue; | 476 continue; |
477 if (pElement->GetString("Type") != "Font") { | 477 if (pElement->GetStringBy("Type") != "Font") { |
478 continue; | 478 continue; |
479 } | 479 } |
480 if (pFont->GetFontDict() == pElement) { | 480 if (pFont->GetFontDict() == pElement) { |
481 csNameTag = csKey; | 481 csNameTag = csKey; |
482 return TRUE; | 482 return TRUE; |
483 } | 483 } |
484 } | 484 } |
485 return FALSE; | 485 return FALSE; |
486 } | 486 } |
487 FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, | 487 FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict, |
488 CPDF_Document* pDocument, | 488 CPDF_Document* pDocument, |
489 CFX_ByteString csFontName, | 489 CFX_ByteString csFontName, |
490 CPDF_Font*& pFont, | 490 CPDF_Font*& pFont, |
491 CFX_ByteString& csNameTag) { | 491 CFX_ByteString& csNameTag) { |
492 if (!pFormDict) { | 492 if (!pFormDict) { |
493 return FALSE; | 493 return FALSE; |
494 } | 494 } |
495 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 495 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
496 if (!pDR) { | 496 if (!pDR) { |
497 return FALSE; | 497 return FALSE; |
498 } | 498 } |
499 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 499 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
500 if (!pFonts) { | 500 if (!pFonts) { |
501 return FALSE; | 501 return FALSE; |
502 } | 502 } |
503 if (csFontName.GetLength() > 0) { | 503 if (csFontName.GetLength() > 0) { |
504 csFontName.Remove(' '); | 504 csFontName.Remove(' '); |
505 } | 505 } |
506 for (const auto& it : *pFonts) { | 506 for (const auto& it : *pFonts) { |
507 const CFX_ByteString& csKey = it.first; | 507 const CFX_ByteString& csKey = it.first; |
508 CPDF_Object* pObj = it.second; | 508 CPDF_Object* pObj = it.second; |
509 if (!pObj) { | 509 if (!pObj) { |
510 continue; | 510 continue; |
511 } | 511 } |
512 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); | 512 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); |
513 if (!pElement) | 513 if (!pElement) |
514 continue; | 514 continue; |
515 if (pElement->GetString("Type") != "Font") { | 515 if (pElement->GetStringBy("Type") != "Font") { |
516 continue; | 516 continue; |
517 } | 517 } |
518 pFont = pDocument->LoadFont(pElement); | 518 pFont = pDocument->LoadFont(pElement); |
519 if (!pFont) { | 519 if (!pFont) { |
520 continue; | 520 continue; |
521 } | 521 } |
522 CFX_ByteString csBaseFont; | 522 CFX_ByteString csBaseFont; |
523 csBaseFont = pFont->GetBaseFont(); | 523 csBaseFont = pFont->GetBaseFont(); |
524 csBaseFont.Remove(' '); | 524 csBaseFont.Remove(' '); |
525 if (csBaseFont == csFontName) { | 525 if (csBaseFont == csFontName) { |
(...skipping 14 matching lines...) Expand all Loading... |
540 InitInterFormDict(pFormDict, pDocument); | 540 InitInterFormDict(pFormDict, pDocument); |
541 } | 541 } |
542 CFX_ByteString csTag; | 542 CFX_ByteString csTag; |
543 if (FindInterFormFont(pFormDict, pFont, csTag)) { | 543 if (FindInterFormFont(pFormDict, pFont, csTag)) { |
544 csNameTag = csTag; | 544 csNameTag = csTag; |
545 return; | 545 return; |
546 } | 546 } |
547 if (!pFormDict) { | 547 if (!pFormDict) { |
548 InitInterFormDict(pFormDict, pDocument); | 548 InitInterFormDict(pFormDict, pDocument); |
549 } | 549 } |
550 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 550 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
551 if (!pDR) { | 551 if (!pDR) { |
552 pDR = new CPDF_Dictionary; | 552 pDR = new CPDF_Dictionary; |
553 pFormDict->SetAt("DR", pDR); | 553 pFormDict->SetAt("DR", pDR); |
554 } | 554 } |
555 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 555 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
556 if (!pFonts) { | 556 if (!pFonts) { |
557 pFonts = new CPDF_Dictionary; | 557 pFonts = new CPDF_Dictionary; |
558 pDR->SetAt("Font", pFonts); | 558 pDR->SetAt("Font", pFonts); |
559 } | 559 } |
560 if (csNameTag.IsEmpty()) { | 560 if (csNameTag.IsEmpty()) { |
561 csNameTag = pFont->GetBaseFont(); | 561 csNameTag = pFont->GetBaseFont(); |
562 } | 562 } |
563 csNameTag.Remove(' '); | 563 csNameTag.Remove(' '); |
564 csNameTag = | 564 csNameTag = |
565 CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag); | 565 CPDF_InterForm::GenerateNewResourceName(pDR, "Font", 4, csNameTag); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 return AddNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag); | 598 return AddNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag); |
599 } | 599 } |
600 void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) { | 600 void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) { |
601 if (!pFormDict || !pFont) { | 601 if (!pFormDict || !pFont) { |
602 return; | 602 return; |
603 } | 603 } |
604 CFX_ByteString csTag; | 604 CFX_ByteString csTag; |
605 if (!FindInterFormFont(pFormDict, pFont, csTag)) { | 605 if (!FindInterFormFont(pFormDict, pFont, csTag)) { |
606 return; | 606 return; |
607 } | 607 } |
608 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 608 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
609 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 609 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
610 pFonts->RemoveAt(csTag); | 610 pFonts->RemoveAt(csTag); |
611 } | 611 } |
612 void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { | 612 void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) { |
613 if (!pFormDict || csNameTag.IsEmpty()) { | 613 if (!pFormDict || csNameTag.IsEmpty()) { |
614 return; | 614 return; |
615 } | 615 } |
616 CPDF_Dictionary* pDR = pFormDict->GetDict("DR"); | 616 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); |
617 if (!pDR) { | 617 if (!pDR) { |
618 return; | 618 return; |
619 } | 619 } |
620 CPDF_Dictionary* pFonts = pDR->GetDict("Font"); | 620 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); |
621 if (!pFonts) { | 621 if (!pFonts) { |
622 return; | 622 return; |
623 } | 623 } |
624 pFonts->RemoveAt(csNameTag); | 624 pFonts->RemoveAt(csNameTag); |
625 } | 625 } |
626 CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, | 626 CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict, |
627 CPDF_Document* pDocument) { | 627 CPDF_Document* pDocument) { |
628 if (!pFormDict) { | 628 if (!pFormDict) { |
629 return NULL; | 629 return NULL; |
630 } | 630 } |
631 CPDF_DefaultAppearance cDA = pFormDict->GetString("DA"); | 631 CPDF_DefaultAppearance cDA = pFormDict->GetStringBy("DA"); |
632 CFX_ByteString csFontNameTag; | 632 CFX_ByteString csFontNameTag; |
633 FX_FLOAT fFontSize; | 633 FX_FLOAT fFontSize; |
634 cDA.GetFont(csFontNameTag, fFontSize); | 634 cDA.GetFont(csFontNameTag, fFontSize); |
635 return GetInterFormFont(pFormDict, pDocument, csFontNameTag); | 635 return GetInterFormFont(pFormDict, pDocument, csFontNameTag); |
636 } | 636 } |
637 CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { | 637 CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { |
638 if (!m_pDict) { | 638 if (!m_pDict) { |
639 return Always; | 639 return Always; |
640 } | 640 } |
641 CFX_ByteString csSW = m_pDict->GetString("SW", "A"); | 641 CFX_ByteString csSW = m_pDict->GetStringBy("SW", "A"); |
642 if (csSW == "B") { | 642 if (csSW == "B") { |
643 return Bigger; | 643 return Bigger; |
644 } | 644 } |
645 if (csSW == "S") { | 645 if (csSW == "S") { |
646 return Smaller; | 646 return Smaller; |
647 } | 647 } |
648 if (csSW == "N") { | 648 if (csSW == "N") { |
649 return Never; | 649 return Never; |
650 } | 650 } |
651 return Always; | 651 return Always; |
652 } | 652 } |
653 FX_BOOL CPDF_IconFit::IsProportionalScale() { | 653 FX_BOOL CPDF_IconFit::IsProportionalScale() { |
654 if (!m_pDict) { | 654 if (!m_pDict) { |
655 return TRUE; | 655 return TRUE; |
656 } | 656 } |
657 return m_pDict->GetString("S", "P") != "A"; | 657 return m_pDict->GetStringBy("S", "P") != "A"; |
658 } | 658 } |
659 void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { | 659 void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { |
660 fLeft = fBottom = 0.5; | 660 fLeft = fBottom = 0.5; |
661 if (!m_pDict) { | 661 if (!m_pDict) { |
662 return; | 662 return; |
663 } | 663 } |
664 CPDF_Array* pA = m_pDict->GetArray("A"); | 664 CPDF_Array* pA = m_pDict->GetArrayBy("A"); |
665 if (pA) { | 665 if (pA) { |
666 FX_DWORD dwCount = pA->GetCount(); | 666 FX_DWORD dwCount = pA->GetCount(); |
667 if (dwCount > 0) { | 667 if (dwCount > 0) { |
668 fLeft = pA->GetNumber(0); | 668 fLeft = pA->GetNumberAt(0); |
669 } | 669 } |
670 if (dwCount > 1) { | 670 if (dwCount > 1) { |
671 fBottom = pA->GetNumber(1); | 671 fBottom = pA->GetNumberAt(1); |
672 } | 672 } |
673 } | 673 } |
674 } | 674 } |
675 FX_BOOL CPDF_IconFit::GetFittingBounds() { | 675 FX_BOOL CPDF_IconFit::GetFittingBounds() { |
676 if (!m_pDict) { | 676 if (!m_pDict) { |
677 return FALSE; | 677 return FALSE; |
678 } | 678 } |
679 return m_pDict->GetBoolean("FB"); | 679 return m_pDict->GetBooleanBy("FB"); |
680 } | 680 } |
681 void SaveCheckedFieldStatus(CPDF_FormField* pField, | 681 void SaveCheckedFieldStatus(CPDF_FormField* pField, |
682 CFX_ByteArray& statusArray) { | 682 CFX_ByteArray& statusArray) { |
683 int iCount = pField->CountControls(); | 683 int iCount = pField->CountControls(); |
684 for (int i = 0; i < iCount; i++) { | 684 for (int i = 0; i < iCount; i++) { |
685 CPDF_FormControl* pControl = pField->GetControl(i); | 685 CPDF_FormControl* pControl = pField->GetControl(i); |
686 if (!pControl) { | 686 if (!pControl) { |
687 continue; | 687 continue; |
688 } | 688 } |
689 statusArray.Add(pControl->IsChecked() ? 1 : 0); | 689 statusArray.Add(pControl->IsChecked() ? 1 : 0); |
690 } | 690 } |
691 } | 691 } |
692 CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, | 692 CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, |
693 const FX_CHAR* name, | 693 const FX_CHAR* name, |
694 int nLevel) { | 694 int nLevel) { |
695 if (nLevel > FPDFDOC_UTILS_MAXRECURSION) { | 695 if (nLevel > FPDFDOC_UTILS_MAXRECURSION) { |
696 return NULL; | 696 return NULL; |
697 } | 697 } |
698 if (!pFieldDict) { | 698 if (!pFieldDict) { |
699 return NULL; | 699 return NULL; |
700 } | 700 } |
701 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); | 701 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); |
702 if (pAttr) { | 702 if (pAttr) { |
703 return pAttr; | 703 return pAttr; |
704 } | 704 } |
705 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); | 705 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); |
706 if (!pParent) { | 706 if (!pParent) { |
707 return NULL; | 707 return NULL; |
708 } | 708 } |
709 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); | 709 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); |
710 } | 710 } |
OLD | NEW |