| 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 "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 Loading... |
| 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 CFX_FloatRect rcAnnot = pAnnotDict->GetRectBy("Rect"); | 330 CPDF_Rect 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 CFX_FloatRect rcBBox; | 335 CPDF_Rect 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 = CFX_FloatRect(0, 0, rcAnnot.right - rcAnnot.left, | 339 rcBBox = CPDF_Rect(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 = CFX_FloatRect(0, 0, rcAnnot.top - rcAnnot.bottom, | 344 rcBBox = CPDF_Rect(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 = CFX_FloatRect(0, 0, rcAnnot.right - rcAnnot.left, | 350 rcBBox = CPDF_Rect(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 = CFX_FloatRect(0, 0, rcAnnot.top - rcAnnot.bottom, | 355 rcBBox = CPDF_Rect(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 Loading... |
| 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 CFX_FloatRect rcBody = | 417 CPDF_Rect rcBody = |
| 418 CFX_FloatRect(rcBBox.left + fBorderWidth, rcBBox.bottom + fBorderWidth, | 418 CPDF_Rect(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 Loading... |
| 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 CFX_FloatRect rcContent = vt.GetContentRect(); | 499 CPDF_Rect rcContent = vt.GetContentRect(); |
| 500 CFX_FloatPoint ptOffset(0.0f, 0.0f); | 500 CPDF_Point ptOffset(0.0f, 0.0f); |
| 501 if (!bMultiLine) { | 501 if (!bMultiLine) { |
| 502 ptOffset = | 502 ptOffset = |
| 503 CFX_FloatPoint(0.0f, (rcContent.Height() - rcBody.Height()) / 2.0f); | 503 CPDF_Point(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 CFX_FloatRect rcButton = rcBody; | 532 CPDF_Rect rcButton = rcBody; |
| 533 rcButton.left = rcButton.right - 13; | 533 rcButton.left = rcButton.right - 13; |
| 534 rcButton.Normalize(); | 534 rcButton.Normalize(); |
| 535 CFX_FloatRect rcEdit = rcBody; | 535 CPDF_Rect 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 CFX_FloatRect rcContent = vt.GetContentRect(); | 547 CPDF_Rect rcContent = vt.GetContentRect(); |
| 548 CFX_FloatPoint ptOffset = | 548 CPDF_Point ptOffset = |
| 549 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); | 549 CPDF_Point(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 CFX_FloatPoint ptCenter = | 578 CPDF_Point ptCenter = CPDF_Point((rcButton.left + rcButton.right) / 2, |
| 579 CFX_FloatPoint((rcButton.left + rcButton.right) / 2, | 579 (rcButton.top + rcButton.bottom) / 2); |
| 580 (rcButton.top + rcButton.bottom) / 2); | |
| 581 if (IsFloatBigger(rcButton.Width(), 6) && | 580 if (IsFloatBigger(rcButton.Width(), 6) && |
| 582 IsFloatBigger(rcButton.Height(), 6)) { | 581 IsFloatBigger(rcButton.Height(), 6)) { |
| 583 sAppStream << "q\n" | 582 sAppStream << "q\n" |
| 584 << " 0 g\n"; | 583 << " 0 g\n"; |
| 585 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"; | 584 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n"; |
| 586 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"; | 585 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n"; |
| 587 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"; | 586 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n"; |
| 588 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; | 587 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n"; |
| 589 sAppStream << sButton << "Q\n"; | 588 sAppStream << sButton << "Q\n"; |
| 590 } | 589 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 if (pSels) { | 621 if (pSels) { |
| 623 for (FX_DWORD s = 0, ssz = pSels->GetCount(); s < ssz; s++) { | 622 for (FX_DWORD s = 0, ssz = pSels->GetCount(); s < ssz; s++) { |
| 624 if (i == pSels->GetIntegerAt(s)) { | 623 if (i == pSels->GetIntegerAt(s)) { |
| 625 bSelected = TRUE; | 624 bSelected = TRUE; |
| 626 break; | 625 break; |
| 627 } | 626 } |
| 628 } | 627 } |
| 629 } | 628 } |
| 630 CPDF_VariableText vt; | 629 CPDF_VariableText vt; |
| 631 vt.SetProvider(&prd); | 630 vt.SetProvider(&prd); |
| 632 vt.SetPlateRect( | 631 vt.SetPlateRect(CPDF_Rect(rcBody.left, 0.0f, rcBody.right, 0.0f)); |
| 633 CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f)); | |
| 634 if (IsFloatZero(fFontSize)) { | 632 if (IsFloatZero(fFontSize)) { |
| 635 vt.SetFontSize(12.0f); | 633 vt.SetFontSize(12.0f); |
| 636 } else { | 634 } else { |
| 637 vt.SetFontSize(fFontSize); | 635 vt.SetFontSize(fFontSize); |
| 638 } | 636 } |
| 639 vt.Initialize(); | 637 vt.Initialize(); |
| 640 vt.SetText(swItem.c_str()); | 638 vt.SetText(swItem.c_str()); |
| 641 vt.RearrangeAll(); | 639 vt.RearrangeAll(); |
| 642 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); | 640 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); |
| 643 if (bSelected) { | 641 if (bSelected) { |
| 644 CFX_FloatRect rcItem = CFX_FloatRect( | 642 CPDF_Rect rcItem = |
| 645 rcBody.left, fy - fItemHeight, rcBody.right, fy); | 643 CPDF_Rect(rcBody.left, fy - fItemHeight, rcBody.right, fy); |
| 646 sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP( | 644 sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP( |
| 647 CPVT_Color(CPVT_Color::kRGB, 0, | 645 CPVT_Color(CPVT_Color::kRGB, 0, |
| 648 51.0f / 255.0f, 113.0f / 255.0f), | 646 51.0f / 255.0f, 113.0f / 255.0f), |
| 649 TRUE) | 647 TRUE) |
| 650 << rcItem.left << " " << rcItem.bottom << " " | 648 << rcItem.left << " " << rcItem.bottom << " " |
| 651 << rcItem.Width() << " " << rcItem.Height() << " re f\n" | 649 << rcItem.Width() << " " << rcItem.Height() << " re f\n" |
| 652 << "Q\n"; | 650 << "Q\n"; |
| 653 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP( | 651 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP( |
| 654 CPVT_Color(CPVT_Color::kGray, 1), TRUE) | 652 CPVT_Color(CPVT_Color::kGray, 1), TRUE) |
| 655 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), | 653 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), |
| 656 CFX_FloatPoint(0.0f, fy), | 654 CPDF_Point(0.0f, fy), |
| 657 TRUE, 0) | 655 TRUE, 0) |
| 658 << "ET\n"; | 656 << "ET\n"; |
| 659 } else { | 657 } else { |
| 660 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) | 658 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) |
| 661 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), | 659 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), |
| 662 CFX_FloatPoint(0.0f, fy), | 660 CPDF_Point(0.0f, fy), |
| 663 TRUE, 0) | 661 TRUE, 0) |
| 664 << "ET\n"; | 662 << "ET\n"; |
| 665 } | 663 } |
| 666 fy -= fItemHeight; | 664 fy -= fItemHeight; |
| 667 } | 665 } |
| 668 } | 666 } |
| 669 } | 667 } |
| 670 if (sBody.GetSize() > 0) { | 668 if (sBody.GetSize() > 0) { |
| 671 sAppStream << "/Tx BMC\n" | 669 sAppStream << "/Tx BMC\n" |
| 672 << "q\n"; | 670 << "q\n"; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 CPDF_Dictionary* pAnnotDict) { | 707 CPDF_Dictionary* pAnnotDict) { |
| 710 return GenerateWidgetAP(pDoc, pAnnotDict, 1); | 708 return GenerateWidgetAP(pDoc, pAnnotDict, 1); |
| 711 } | 709 } |
| 712 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, | 710 FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, |
| 713 CPDF_Dictionary* pAnnotDict) { | 711 CPDF_Dictionary* pAnnotDict) { |
| 714 return GenerateWidgetAP(pDoc, pAnnotDict, 2); | 712 return GenerateWidgetAP(pDoc, pAnnotDict, 2); |
| 715 } | 713 } |
| 716 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( | 714 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( |
| 717 IPVT_FontMap* pFontMap, | 715 IPVT_FontMap* pFontMap, |
| 718 IPDF_VariableText_Iterator* pIterator, | 716 IPDF_VariableText_Iterator* pIterator, |
| 719 const CFX_FloatPoint& ptOffset, | 717 const CPDF_Point& ptOffset, |
| 720 FX_BOOL bContinuous, | 718 FX_BOOL bContinuous, |
| 721 FX_WORD SubWord, | 719 FX_WORD SubWord, |
| 722 const CPVT_WordRange* pVisible) { | 720 const CPVT_WordRange* pVisible) { |
| 723 CFX_ByteTextBuf sEditStream, sLineStream, sWords; | 721 CFX_ByteTextBuf sEditStream, sLineStream, sWords; |
| 724 CFX_FloatPoint ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); | 722 CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f); |
| 725 int32_t nCurFontIndex = -1; | 723 int32_t nCurFontIndex = -1; |
| 726 if (pIterator) { | 724 if (pIterator) { |
| 727 if (pVisible) { | 725 if (pVisible) { |
| 728 pIterator->SetAt(pVisible->BeginPos); | 726 pIterator->SetAt(pVisible->BeginPos); |
| 729 } else { | 727 } else { |
| 730 pIterator->SetAt(0); | 728 pIterator->SetAt(0); |
| 731 } | 729 } |
| 732 CPVT_WordPlace oldplace; | 730 CPVT_WordPlace oldplace; |
| 733 while (pIterator->NextWord()) { | 731 while (pIterator->NextWord()) { |
| 734 CPVT_WordPlace place = pIterator->GetAt(); | 732 CPVT_WordPlace place = pIterator->GetAt(); |
| 735 if (pVisible && place.WordCmp(pVisible->EndPos) > 0) { | 733 if (pVisible && place.WordCmp(pVisible->EndPos) > 0) { |
| 736 break; | 734 break; |
| 737 } | 735 } |
| 738 if (bContinuous) { | 736 if (bContinuous) { |
| 739 if (place.LineCmp(oldplace) != 0) { | 737 if (place.LineCmp(oldplace) != 0) { |
| 740 if (sWords.GetSize() > 0) { | 738 if (sWords.GetSize() > 0) { |
| 741 sLineStream << GetWordRenderString(sWords.GetByteString()); | 739 sLineStream << GetWordRenderString(sWords.GetByteString()); |
| 742 sEditStream << sLineStream; | 740 sEditStream << sLineStream; |
| 743 sLineStream.Clear(); | 741 sLineStream.Clear(); |
| 744 sWords.Clear(); | 742 sWords.Clear(); |
| 745 } | 743 } |
| 746 CPVT_Word word; | 744 CPVT_Word word; |
| 747 if (pIterator->GetWord(word)) { | 745 if (pIterator->GetWord(word)) { |
| 748 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, | 746 ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, |
| 749 word.ptWord.y + ptOffset.y); | 747 word.ptWord.y + ptOffset.y); |
| 750 } else { | 748 } else { |
| 751 CPVT_Line line; | 749 CPVT_Line line; |
| 752 pIterator->GetLine(line); | 750 pIterator->GetLine(line); |
| 753 ptNew = CFX_FloatPoint(line.ptLine.x + ptOffset.x, | 751 ptNew = CPDF_Point(line.ptLine.x + ptOffset.x, |
| 754 line.ptLine.y + ptOffset.y); | 752 line.ptLine.y + ptOffset.y); |
| 755 } | 753 } |
| 756 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { | 754 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { |
| 757 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y | 755 sLineStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y |
| 758 << " Td\n"; | 756 << " Td\n"; |
| 759 ptOld = ptNew; | 757 ptOld = ptNew; |
| 760 } | 758 } |
| 761 } | 759 } |
| 762 CPVT_Word word; | 760 CPVT_Word word; |
| 763 if (pIterator->GetWord(word)) { | 761 if (pIterator->GetWord(word)) { |
| 764 if (word.nFontIndex != nCurFontIndex) { | 762 if (word.nFontIndex != nCurFontIndex) { |
| 765 if (sWords.GetSize() > 0) { | 763 if (sWords.GetSize() > 0) { |
| 766 sLineStream << GetWordRenderString(sWords.GetByteString()); | 764 sLineStream << GetWordRenderString(sWords.GetByteString()); |
| 767 sWords.Clear(); | 765 sWords.Clear(); |
| 768 } | 766 } |
| 769 sLineStream << GetFontSetString(pFontMap, word.nFontIndex, | 767 sLineStream << GetFontSetString(pFontMap, word.nFontIndex, |
| 770 word.fFontSize); | 768 word.fFontSize); |
| 771 nCurFontIndex = word.nFontIndex; | 769 nCurFontIndex = word.nFontIndex; |
| 772 } | 770 } |
| 773 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word, | 771 sWords << GetPDFWordString(pFontMap, nCurFontIndex, word.Word, |
| 774 SubWord); | 772 SubWord); |
| 775 } | 773 } |
| 776 oldplace = place; | 774 oldplace = place; |
| 777 } else { | 775 } else { |
| 778 CPVT_Word word; | 776 CPVT_Word word; |
| 779 if (pIterator->GetWord(word)) { | 777 if (pIterator->GetWord(word)) { |
| 780 ptNew = CFX_FloatPoint(word.ptWord.x + ptOffset.x, | 778 ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, |
| 781 word.ptWord.y + ptOffset.y); | 779 word.ptWord.y + ptOffset.y); |
| 782 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { | 780 if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) { |
| 783 sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y | 781 sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y |
| 784 << " Td\n"; | 782 << " Td\n"; |
| 785 ptOld = ptNew; | 783 ptOld = ptNew; |
| 786 } | 784 } |
| 787 if (word.nFontIndex != nCurFontIndex) { | 785 if (word.nFontIndex != nCurFontIndex) { |
| 788 sEditStream << GetFontSetString(pFontMap, word.nFontIndex, | 786 sEditStream << GetFontSetString(pFontMap, word.nFontIndex, |
| 789 word.fFontSize); | 787 word.fFontSize); |
| 790 nCurFontIndex = word.nFontIndex; | 788 nCurFontIndex = word.nFontIndex; |
| 791 } | 789 } |
| 792 sEditStream << GetWordRenderString( | 790 sEditStream << GetWordRenderString( |
| 793 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord)); | 791 GetPDFWordString(pFontMap, nCurFontIndex, word.Word, SubWord)); |
| 794 } | 792 } |
| 795 } | 793 } |
| 796 } | 794 } |
| 797 if (sWords.GetSize() > 0) { | 795 if (sWords.GetSize() > 0) { |
| 798 sLineStream << GetWordRenderString(sWords.GetByteString()); | 796 sLineStream << GetWordRenderString(sWords.GetByteString()); |
| 799 sEditStream << sLineStream; | 797 sEditStream << sLineStream; |
| 800 sWords.Clear(); | 798 sWords.Clear(); |
| 801 } | 799 } |
| 802 } | 800 } |
| 803 return sEditStream.GetByteString(); | 801 return sEditStream.GetByteString(); |
| 804 } | 802 } |
| 805 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( | 803 CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( |
| 806 const CFX_FloatRect& rect, | 804 const CPDF_Rect& rect, |
| 807 FX_FLOAT fWidth, | 805 FX_FLOAT fWidth, |
| 808 const CPVT_Color& color, | 806 const CPVT_Color& color, |
| 809 const CPVT_Color& crLeftTop, | 807 const CPVT_Color& crLeftTop, |
| 810 const CPVT_Color& crRightBottom, | 808 const CPVT_Color& crRightBottom, |
| 811 int32_t nStyle, | 809 int32_t nStyle, |
| 812 const CPVT_Dash& dash) { | 810 const CPVT_Dash& dash) { |
| 813 CFX_ByteTextBuf sAppStream; | 811 CFX_ByteTextBuf sAppStream; |
| 814 CFX_ByteString sColor; | 812 CFX_ByteString sColor; |
| 815 FX_FLOAT fLeft = rect.left; | 813 FX_FLOAT fLeft = rect.left; |
| 816 FX_FLOAT fRight = rect.right; | 814 FX_FLOAT fRight = rect.right; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 case CPVT_Color::kCMYK: | 922 case CPVT_Color::kCMYK: |
| 925 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 923 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 926 << color.fColor3 << " " << color.fColor4 << " " | 924 << color.fColor3 << " " << color.fColor4 << " " |
| 927 << (bFillOrStroke ? "k" : "K") << "\n"; | 925 << (bFillOrStroke ? "k" : "K") << "\n"; |
| 928 break; | 926 break; |
| 929 case CPVT_Color::kTransparent: | 927 case CPVT_Color::kTransparent: |
| 930 break; | 928 break; |
| 931 } | 929 } |
| 932 return sColorStream.GetByteString(); | 930 return sColorStream.GetByteString(); |
| 933 } | 931 } |
| OLD | NEW |