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

Side by Side Diff: core/src/fpdfdoc/doc_ap.cpp

Issue 1737593006: Re-land "Replace CPDF_Rect and CPDF_Point with CFX types." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Ooops. Created 4 years, 10 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/src/fpdfdoc/doc_annot.cpp ('k') | core/src/fpdfdoc/doc_link.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 "core/include/fpdfdoc/fpdf_ap.h" 7 #include "core/include/fpdfdoc/fpdf_ap.h"
8 #include "core/include/fpdfdoc/fpdf_doc.h" 8 #include "core/include/fpdfdoc/fpdf_doc.h"
9 #include "core/include/fpdfdoc/fpdf_vt.h" 9 #include "core/include/fpdfdoc/fpdf_vt.h"
10 #include "core/src/fpdfdoc/doc_utils.h" 10 #include "core/src/fpdfdoc/doc_utils.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 pFontDict->SetAtName("Subtype", "Type1"); 320 pFontDict->SetAtName("Subtype", "Type1");
321 pFontDict->SetAtName("BaseFont", "Helvetica"); 321 pFontDict->SetAtName("BaseFont", "Helvetica");
322 pFontDict->SetAtName("Encoding", "WinAnsiEncoding"); 322 pFontDict->SetAtName("Encoding", "WinAnsiEncoding");
323 pDoc->AddIndirectObject(pFontDict); 323 pDoc->AddIndirectObject(pFontDict);
324 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict); 324 pDRFontDict->SetAtReference(sFontName.Mid(1), pDoc, pFontDict);
325 } 325 }
326 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict); 326 CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
327 if (!pDefFont) { 327 if (!pDefFont) {
328 return FALSE; 328 return FALSE;
329 } 329 }
330 CPDF_Rect rcAnnot = pAnnotDict->GetRectBy("Rect"); 330 CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect");
331 int32_t nRotate = 0; 331 int32_t nRotate = 0;
332 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) { 332 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) {
333 nRotate = pMKDict->GetIntegerBy("R"); 333 nRotate = pMKDict->GetIntegerBy("R");
334 } 334 }
335 CPDF_Rect rcBBox; 335 CFX_FloatRect rcBBox;
336 CFX_Matrix matrix; 336 CFX_Matrix matrix;
337 switch (nRotate % 360) { 337 switch (nRotate % 360) {
338 case 0: 338 case 0:
339 rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, 339 rcBBox = CFX_FloatRect(0, 0, rcAnnot.right - rcAnnot.left,
340 rcAnnot.top - rcAnnot.bottom); 340 rcAnnot.top - rcAnnot.bottom);
341 break; 341 break;
342 case 90: 342 case 90:
343 matrix = CFX_Matrix(0, 1, -1, 0, rcAnnot.right - rcAnnot.left, 0); 343 matrix = CFX_Matrix(0, 1, -1, 0, rcAnnot.right - rcAnnot.left, 0);
344 rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, 344 rcBBox = CFX_FloatRect(0, 0, rcAnnot.top - rcAnnot.bottom,
345 rcAnnot.right - rcAnnot.left); 345 rcAnnot.right - rcAnnot.left);
346 break; 346 break;
347 case 180: 347 case 180:
348 matrix = CFX_Matrix(-1, 0, 0, -1, rcAnnot.right - rcAnnot.left, 348 matrix = CFX_Matrix(-1, 0, 0, -1, rcAnnot.right - rcAnnot.left,
349 rcAnnot.top - rcAnnot.bottom); 349 rcAnnot.top - rcAnnot.bottom);
350 rcBBox = CPDF_Rect(0, 0, rcAnnot.right - rcAnnot.left, 350 rcBBox = CFX_FloatRect(0, 0, rcAnnot.right - rcAnnot.left,
351 rcAnnot.top - rcAnnot.bottom); 351 rcAnnot.top - rcAnnot.bottom);
352 break; 352 break;
353 case 270: 353 case 270:
354 matrix = CFX_Matrix(0, -1, 1, 0, 0, rcAnnot.top - rcAnnot.bottom); 354 matrix = CFX_Matrix(0, -1, 1, 0, 0, rcAnnot.top - rcAnnot.bottom);
355 rcBBox = CPDF_Rect(0, 0, rcAnnot.top - rcAnnot.bottom, 355 rcBBox = CFX_FloatRect(0, 0, rcAnnot.top - rcAnnot.bottom,
356 rcAnnot.right - rcAnnot.left); 356 rcAnnot.right - rcAnnot.left);
357 break; 357 break;
358 } 358 }
359 int32_t nBorderStyle = PBS_SOLID; 359 int32_t nBorderStyle = PBS_SOLID;
360 FX_FLOAT fBorderWidth = 1; 360 FX_FLOAT fBorderWidth = 1;
361 CPVT_Dash dsBorder(3, 0, 0); 361 CPVT_Dash dsBorder(3, 0, 0);
362 CPVT_Color crLeftTop, crRightBottom; 362 CPVT_Color crLeftTop, crRightBottom;
363 if (CPDF_Dictionary* pBSDict = pAnnotDict->GetDictBy("BS")) { 363 if (CPDF_Dictionary* pBSDict = pAnnotDict->GetDictBy("BS")) {
364 if (pBSDict->KeyExist("W")) { 364 if (pBSDict->KeyExist("W")) {
365 fBorderWidth = pBSDict->GetNumberBy("W"); 365 fBorderWidth = pBSDict->GetNumberBy("W");
366 } 366 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " " 407 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " "
408 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" 408 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n"
409 << "Q\n"; 409 << "Q\n";
410 } 410 }
411 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( 411 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP(
412 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, 412 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle,
413 dsBorder); 413 dsBorder);
414 if (sBorderStream.GetLength() > 0) { 414 if (sBorderStream.GetLength() > 0) {
415 sAppStream << "q\n" << sBorderStream << "Q\n"; 415 sAppStream << "q\n" << sBorderStream << "Q\n";
416 } 416 }
417 CPDF_Rect rcBody = 417 CFX_FloatRect rcBody =
418 CPDF_Rect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, 418 CFX_FloatRect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth,
419 rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth); 419 rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth);
420 rcBody.Normalize(); 420 rcBody.Normalize();
421 CPDF_Dictionary* pAPDict = pAnnotDict->GetDictBy("AP"); 421 CPDF_Dictionary* pAPDict = pAnnotDict->GetDictBy("AP");
422 if (!pAPDict) { 422 if (!pAPDict) {
423 pAPDict = new CPDF_Dictionary; 423 pAPDict = new CPDF_Dictionary;
424 pAnnotDict->SetAt("AP", pAPDict); 424 pAnnotDict->SetAt("AP", pAPDict);
425 } 425 }
426 CPDF_Stream* pNormalStream = pAPDict->GetStreamBy("N"); 426 CPDF_Stream* pNormalStream = pAPDict->GetStreamBy("N");
427 if (!pNormalStream) { 427 if (!pNormalStream) {
428 pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); 428 pNormalStream = new CPDF_Stream(nullptr, 0, nullptr);
429 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); 429 int32_t objnum = pDoc->AddIndirectObject(pNormalStream);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 489 }
490 FX_BOOL bCharArray = (dwFlags >> 24) & 1; 490 FX_BOOL bCharArray = (dwFlags >> 24) & 1;
491 if (bCharArray) { 491 if (bCharArray) {
492 vt.SetCharArray(dwMaxLen); 492 vt.SetCharArray(dwMaxLen);
493 } else { 493 } else {
494 vt.SetLimitChar(dwMaxLen); 494 vt.SetLimitChar(dwMaxLen);
495 } 495 }
496 vt.Initialize(); 496 vt.Initialize();
497 vt.SetText(swValue.c_str()); 497 vt.SetText(swValue.c_str());
498 vt.RearrangeAll(); 498 vt.RearrangeAll();
499 CPDF_Rect rcContent = vt.GetContentRect(); 499 CFX_FloatRect rcContent = vt.GetContentRect();
500 CPDF_Point ptOffset(0.0f, 0.0f); 500 CFX_FloatPoint ptOffset(0.0f, 0.0f);
501 if (!bMultiLine) { 501 if (!bMultiLine) {
502 ptOffset = 502 ptOffset =
503 CPDF_Point(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); 503 CFX_FloatPoint(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f);
504 } 504 }
505 CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP( 505 CFX_ByteString sBody = CPVT_GenerateAP::GenerateEditAP(
506 &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); 506 &map, vt.GetIterator(), ptOffset, !bCharArray, subWord);
507 if (sBody.GetLength() > 0) { 507 if (sBody.GetLength() > 0) {
508 sAppStream << "/Tx BMC\n" 508 sAppStream << "/Tx BMC\n"
509 << "q\n"; 509 << "q\n";
510 if (rcContent.Width() > rcBody.Width() || 510 if (rcContent.Width() > rcBody.Width() ||
511 rcContent.Height() > rcBody.Height()) { 511 rcContent.Height() > rcBody.Height()) {
512 sAppStream << rcBody.left << " " << rcBody.bottom << " " 512 sAppStream << rcBody.left << " " << rcBody.bottom << " "
513 << rcBody.Width() << " " << rcBody.Height() 513 << rcBody.Width() << " " << rcBody.Height()
514 << " re\nW\nn\n"; 514 << " re\nW\nn\n";
515 } 515 }
516 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) 516 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE)
517 << sBody << "ET\n" 517 << sBody << "ET\n"
518 << "Q\nEMC\n"; 518 << "Q\nEMC\n";
519 } 519 }
520 } break; 520 } break;
521 case 1: { 521 case 1: {
522 CFX_WideString swValue = 522 CFX_WideString swValue =
523 FPDF_GetFieldAttr(pAnnotDict, "V") 523 FPDF_GetFieldAttr(pAnnotDict, "V")
524 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() 524 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText()
525 : CFX_WideString(); 525 : CFX_WideString();
526 CPVT_FontMap map(pDoc, 526 CPVT_FontMap map(pDoc,
527 pStreamDict ? pStreamDict->GetDictBy("Resources") : NULL, 527 pStreamDict ? pStreamDict->GetDictBy("Resources") : NULL,
528 pDefFont, sFontName.Right(sFontName.GetLength() - 1)); 528 pDefFont, sFontName.Right(sFontName.GetLength() - 1));
529 CPVT_Provider prd(&map); 529 CPVT_Provider prd(&map);
530 CPDF_VariableText vt; 530 CPDF_VariableText vt;
531 vt.SetProvider(&prd); 531 vt.SetProvider(&prd);
532 CPDF_Rect rcButton = rcBody; 532 CFX_FloatRect rcButton = rcBody;
533 rcButton.left = rcButton.right - 13; 533 rcButton.left = rcButton.right - 13;
534 rcButton.Normalize(); 534 rcButton.Normalize();
535 CPDF_Rect rcEdit = rcBody; 535 CFX_FloatRect rcEdit = rcBody;
536 rcEdit.right = rcButton.left; 536 rcEdit.right = rcButton.left;
537 rcEdit.Normalize(); 537 rcEdit.Normalize();
538 vt.SetPlateRect(rcEdit); 538 vt.SetPlateRect(rcEdit);
539 if (IsFloatZero(fFontSize)) { 539 if (IsFloatZero(fFontSize)) {
540 vt.SetAutoFontSize(TRUE); 540 vt.SetAutoFontSize(TRUE);
541 } else { 541 } else {
542 vt.SetFontSize(fFontSize); 542 vt.SetFontSize(fFontSize);
543 } 543 }
544 vt.Initialize(); 544 vt.Initialize();
545 vt.SetText(swValue.c_str()); 545 vt.SetText(swValue.c_str());
546 vt.RearrangeAll(); 546 vt.RearrangeAll();
547 CPDF_Rect rcContent = vt.GetContentRect(); 547 CFX_FloatRect rcContent = vt.GetContentRect();
548 CPDF_Point ptOffset = 548 CFX_FloatPoint ptOffset =
549 CPDF_Point(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); 549 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f);
550 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( 550 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(
551 &map, vt.GetIterator(), ptOffset, TRUE, 0); 551 &map, vt.GetIterator(), ptOffset, TRUE, 0);
552 if (sEdit.GetLength() > 0) { 552 if (sEdit.GetLength() > 0) {
553 sAppStream << "/Tx BMC\n" 553 sAppStream << "/Tx BMC\n"
554 << "q\n"; 554 << "q\n";
555 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " 555 sAppStream << rcEdit.left << " " << rcEdit.bottom << " "
556 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n"; 556 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n";
557 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) 557 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE)
558 << sEdit << "ET\n" 558 << sEdit << "ET\n"
559 << "Q\nEMC\n"; 559 << "Q\nEMC\n";
560 } 560 }
561 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP( 561 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP(
562 CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f, 562 CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f,
563 220.0f / 255.0f), 563 220.0f / 255.0f),
564 TRUE); 564 TRUE);
565 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) { 565 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) {
566 sAppStream << "q\n" << sButton; 566 sAppStream << "q\n" << sButton;
567 sAppStream << rcButton.left << " " << rcButton.bottom << " " 567 sAppStream << rcButton.left << " " << rcButton.bottom << " "
568 << rcButton.Width() << " " << rcButton.Height() << " re f\n"; 568 << rcButton.Width() << " " << rcButton.Height() << " re f\n";
569 sAppStream << "Q\n"; 569 sAppStream << "Q\n";
570 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( 570 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP(
571 rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), 571 rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0),
572 CPVT_Color(CPVT_Color::kGray, 1), 572 CPVT_Color(CPVT_Color::kGray, 1),
573 CPVT_Color(CPVT_Color::kGray, 0.5), PBS_BEVELED, 573 CPVT_Color(CPVT_Color::kGray, 0.5), PBS_BEVELED,
574 CPVT_Dash(3, 0, 0)); 574 CPVT_Dash(3, 0, 0));
575 if (sButtonBorder.GetLength() > 0) { 575 if (sButtonBorder.GetLength() > 0) {
576 sAppStream << "q\n" << sButtonBorder << "Q\n"; 576 sAppStream << "q\n" << sButtonBorder << "Q\n";
577 } 577 }
578 CPDF_Point ptCenter = CPDF_Point((rcButton.left + rcButton.right) / 2, 578 CFX_FloatPoint ptCenter =
579 (rcButton.top + rcButton.bottom) / 2); 579 CFX_FloatPoint((rcButton.left + rcButton.right) / 2,
580 (rcButton.top + rcButton.bottom) / 2);
580 if (IsFloatBigger(rcButton.Width(), 6) && 581 if (IsFloatBigger(rcButton.Width(), 6) &&
581 IsFloatBigger(rcButton.Height(), 6)) { 582 IsFloatBigger(rcButton.Height(), 6)) {
582 sAppStream << "q\n" 583 sAppStream << "q\n"
583 << " 0 g\n"; 584 << " 0 g\n";
584 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"; 585 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n";
585 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"; 586 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n";
586 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"; 587 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n";
587 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; 588 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n";
588 sAppStream << sButton << "Q\n"; 589 sAppStream << sButton << "Q\n";
589 } 590 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if (pSels) { 622 if (pSels) {
622 for (FX_DWORD s = 0, ssz = pSels->GetCount(); s < ssz; s++) { 623 for (FX_DWORD s = 0, ssz = pSels->GetCount(); s < ssz; s++) {
623 if (i == pSels->GetIntegerAt(s)) { 624 if (i == pSels->GetIntegerAt(s)) {
624 bSelected = TRUE; 625 bSelected = TRUE;
625 break; 626 break;
626 } 627 }
627 } 628 }
628 } 629 }
629 CPDF_VariableText vt; 630 CPDF_VariableText vt;
630 vt.SetProvider(&prd); 631 vt.SetProvider(&prd);
631 vt.SetPlateRect(CPDF_Rect(rcBody.left, 0.0f, rcBody.right, 0.0f)); 632 vt.SetPlateRect(
633 CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f));
632 if (IsFloatZero(fFontSize)) { 634 if (IsFloatZero(fFontSize)) {
633 vt.SetFontSize(12.0f); 635 vt.SetFontSize(12.0f);
634 } else { 636 } else {
635 vt.SetFontSize(fFontSize); 637 vt.SetFontSize(fFontSize);
636 } 638 }
637 vt.Initialize(); 639 vt.Initialize();
638 vt.SetText(swItem.c_str()); 640 vt.SetText(swItem.c_str());
639 vt.RearrangeAll(); 641 vt.RearrangeAll();
640 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); 642 FX_FLOAT fItemHeight = vt.GetContentRect().Height();
641 if (bSelected) { 643 if (bSelected) {
642 CPDF_Rect rcItem = 644 CFX_FloatRect rcItem = CFX_FloatRect(
643 CPDF_Rect(rcBody.left, fy - fItemHeight, rcBody.right, fy); 645 rcBody.left, fy - fItemHeight, rcBody.right, fy);
644 sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP( 646 sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP(
645 CPVT_Color(CPVT_Color::kRGB, 0, 647 CPVT_Color(CPVT_Color::kRGB, 0,
646 51.0f / 255.0f, 113.0f / 255.0f), 648 51.0f / 255.0f, 113.0f / 255.0f),
647 TRUE) 649 TRUE)
648 << rcItem.left << " " << rcItem.bottom << " " 650 << rcItem.left << " " << rcItem.bottom << " "
649 << rcItem.Width() << " " << rcItem.Height() << " re f\n" 651 << rcItem.Width() << " " << rcItem.Height() << " re f\n"
650 << "Q\n"; 652 << "Q\n";
651 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP( 653 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(
652 CPVT_Color(CPVT_Color::kGray, 1), TRUE) 654 CPVT_Color(CPVT_Color::kGray, 1), TRUE)
653 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), 655 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(),
654 CPDF_Point(0.0f, fy), 656 CFX_FloatPoint(0.0f, fy),
655 TRUE, 0) 657 TRUE, 0)
656 << "ET\n"; 658 << "ET\n";
657 } else { 659 } else {
658 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) 660 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE)
659 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), 661 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(),
660 CPDF_Point(0.0f, fy), 662 CFX_FloatPoint(0.0f, fy),
661 TRUE, 0) 663 TRUE, 0)
662 << "ET\n"; 664 << "ET\n";
663 } 665 }
664 fy -= fItemHeight; 666 fy -= fItemHeight;
665 } 667 }
666 } 668 }
667 } 669 }
668 if (sBody.GetSize() > 0) { 670 if (sBody.GetSize() > 0) {
669 sAppStream << "/Tx BMC\n" 671 sAppStream << "/Tx BMC\n"
670 << "q\n"; 672 << "q\n";
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 CPDF_Dictionary* pAnnotDict) { 709 CPDF_Dictionary* pAnnotDict) {
708 return GenerateWidgetAP(pDoc, pAnnotDict, 1); 710 return GenerateWidgetAP(pDoc, pAnnotDict, 1);
709 } 711 }
710 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, 712 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc,
711 CPDF_Dictionary* pAnnotDict) { 713 CPDF_Dictionary* pAnnotDict) {
712 return GenerateWidgetAP(pDoc, pAnnotDict, 2); 714 return GenerateWidgetAP(pDoc, pAnnotDict, 2);
713 } 715 }
714 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( 716 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
715 IPVT_FontMap* pFontMap, 717 IPVT_FontMap* pFontMap,
716 IPDF_VariableText_Iterator* pIterator, 718 IPDF_VariableText_Iterator* pIterator,
717 const CPDF_Point& ptOffset, 719 const CFX_FloatPoint& ptOffset,
718 FX_BOOL bContinuous, 720 FX_BOOL bContinuous,
719 FX_WORD SubWord, 721 FX_WORD SubWord,
720 const CPVT_WordRange* pVisible) { 722 const CPVT_WordRange* pVisible) {
721 CFX_ByteTextBuf sEditStream, sLineStream, sWords; 723 CFX_ByteTextBuf sEditStream, sLineStream, sWords;
722 CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); 724 CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
723 int32_t nCurFontIndex = -1; 725 int32_t nCurFontIndex = -1;
724 if (pIterator) { 726 if (pIterator) {
725 if (pVisible) { 727 if (pVisible) {
726 pIterator->SetAt(pVisible->BeginPos); 728 pIterator->SetAt(pVisible->BeginPos);
727 } else { 729 } else {
728 pIterator->SetAt(0); 730 pIterator->SetAt(0);
729 } 731 }
730 CPVT_WordPlace oldplace; 732 CPVT_WordPlace oldplace;
731 while (pIterator->NextWord()) { 733 while (pIterator->NextWord()) {
732 CPVT_WordPlace place = pIterator->GetAt(); 734 CPVT_WordPlace place = pIterator->GetAt();
733 if (pVisible && place.WordCmp(pVisible->EndPos) > 0) { 735 if (pVisible && place.WordCmp(pVisible->EndPos) > 0) {
734 break; 736 break;
735 } 737 }
736 if (bContinuous) { 738 if (bContinuous) {
737 if (place.LineCmp(oldplace) != 0) { 739 if (place.LineCmp(oldplace) != 0) {
738 if (sWords.GetSize() > 0) { 740 if (sWords.GetSize() > 0) {
739 sLineStream << GetWordRenderString(sWords.GetByteString()); 741 sLineStream << GetWordRenderString(sWords.GetByteString());
740 sEditStream << sLineStream; 742 sEditStream << sLineStream;
741 sLineStream.Clear(); 743 sLineStream.Clear();
742 sWords.Clear(); 744 sWords.Clear();
743 } 745 }
744 CPVT_Word word; 746 CPVT_Word word;
745 if (pIterator->GetWord(word)) { 747 if (pIterator->GetWord(word)) {
746 ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, 748 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
747 word.ptWord.y + ptOffset.y); 749 word.ptWord.y + ptOffset.y);
748 } else { 750 } else {
749 CPVT_Line line; 751 CPVT_Line line;
750 pIterator->GetLine(line); 752 pIterator->GetLine(line);
751 ptNew = CPDF_Point(line.ptLine.x + ptOffset.x, 753 ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x,
752 line.ptLine.y + ptOffset.y); 754 line.ptLine.y + ptOffset.y);
753 } 755 }
754 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { 756 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
755 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y 757 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
756 << " Td\n"; 758 << " Td\n";
757 ptOld = ptNew; 759 ptOld = ptNew;
758 } 760 }
759 } 761 }
760 CPVT_Word word; 762 CPVT_Word word;
761 if (pIterator->GetWord(word)) { 763 if (pIterator->GetWord(word)) {
762 if (word.nFontIndex != nCurFontIndex) { 764 if (word.nFontIndex != nCurFontIndex) {
763 if (sWords.GetSize() > 0) { 765 if (sWords.GetSize() > 0) {
764 sLineStream << GetWordRenderString(sWords.GetByteString()); 766 sLineStream << GetWordRenderString(sWords.GetByteString());
765 sWords.Clear(); 767 sWords.Clear();
766 } 768 }
767 sLineStream << GetFontSetString(pFontMap, word.nFontIndex, 769 sLineStream << GetFontSetString(pFontMap, word.nFontIndex,
768 word.fFontSize); 770 word.fFontSize);
769 nCurFontIndex = word.nFontIndex; 771 nCurFontIndex = word.nFontIndex;
770 } 772 }
771 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word, 773 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word,
772 SubWord); 774 SubWord);
773 } 775 }
774 oldplace = place; 776 oldplace = place;
775 } else { 777 } else {
776 CPVT_Word word; 778 CPVT_Word word;
777 if (pIterator->GetWord(word)) { 779 if (pIterator->GetWord(word)) {
778 ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, 780 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x,
779 word.ptWord.y + ptOffset.y); 781 word.ptWord.y + ptOffset.y);
780 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { 782 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
781 sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y 783 sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
782 << " Td\n"; 784 << " Td\n";
783 ptOld = ptNew; 785 ptOld = ptNew;
784 } 786 }
785 if (word.nFontIndex != nCurFontIndex) { 787 if (word.nFontIndex != nCurFontIndex) {
786 sEditStream << GetFontSetString(pFontMap, word.nFontIndex, 788 sEditStream << GetFontSetString(pFontMap, word.nFontIndex,
787 word.fFontSize); 789 word.fFontSize);
788 nCurFontIndex = word.nFontIndex; 790 nCurFontIndex = word.nFontIndex;
789 } 791 }
790 sEditStream << GetWordRenderString( 792 sEditStream << GetWordRenderString(
791 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord)); 793 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord));
792 } 794 }
793 } 795 }
794 } 796 }
795 if (sWords.GetSize() > 0) { 797 if (sWords.GetSize() > 0) {
796 sLineStream << GetWordRenderString(sWords.GetByteString()); 798 sLineStream << GetWordRenderString(sWords.GetByteString());
797 sEditStream << sLineStream; 799 sEditStream << sLineStream;
798 sWords.Clear(); 800 sWords.Clear();
799 } 801 }
800 } 802 }
801 return sEditStream.GetByteString(); 803 return sEditStream.GetByteString();
802 } 804 }
803 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( 805 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(
804 const CPDF_Rect& rect, 806 const CFX_FloatRect& rect,
805 FX_FLOAT fWidth, 807 FX_FLOAT fWidth,
806 const CPVT_Color& color, 808 const CPVT_Color& color,
807 const CPVT_Color& crLeftTop, 809 const CPVT_Color& crLeftTop,
808 const CPVT_Color& crRightBottom, 810 const CPVT_Color& crRightBottom,
809 int32_t nStyle, 811 int32_t nStyle,
810 const CPVT_Dash& dash) { 812 const CPVT_Dash& dash) {
811 CFX_ByteTextBuf sAppStream; 813 CFX_ByteTextBuf sAppStream;
812 CFX_ByteString sColor; 814 CFX_ByteString sColor;
813 FX_FLOAT fLeft = rect.left; 815 FX_FLOAT fLeft = rect.left;
814 FX_FLOAT fRight = rect.right; 816 FX_FLOAT fRight = rect.right;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 case CPVT_Color::kCMYK: 924 case CPVT_Color::kCMYK:
923 sColorStream << color.fColor1 << " " << color.fColor2 << " " 925 sColorStream << color.fColor1 << " " << color.fColor2 << " "
924 << color.fColor3 << " " << color.fColor4 << " " 926 << color.fColor3 << " " << color.fColor4 << " "
925 << (bFillOrStroke ? "k" : "K") << "\n"; 927 << (bFillOrStroke ? "k" : "K") << "\n";
926 break; 928 break;
927 case CPVT_Color::kTransparent: 929 case CPVT_Color::kTransparent:
928 break; 930 break;
929 } 931 }
930 return sColorStream.GetByteString(); 932 return sColorStream.GetByteString();
931 } 933 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_annot.cpp ('k') | core/src/fpdfdoc/doc_link.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698