| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fpdfdoc/cpvt_generateap.h" | 7 #include "core/fpdfdoc/cpvt_generateap.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 CPVT_Color crBorder, crBG; | 148 CPVT_Color crBorder, crBG; |
| 149 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) { | 149 if (CPDF_Dictionary* pMKDict = pAnnotDict->GetDictBy("MK")) { |
| 150 if (CPDF_Array* pArray = pMKDict->GetArrayBy("BC")) | 150 if (CPDF_Array* pArray = pMKDict->GetArrayBy("BC")) |
| 151 crBorder = CPVT_Color::ParseColor(*pArray); | 151 crBorder = CPVT_Color::ParseColor(*pArray); |
| 152 if (CPDF_Array* pArray = pMKDict->GetArrayBy("BG")) | 152 if (CPDF_Array* pArray = pMKDict->GetArrayBy("BG")) |
| 153 crBG = CPVT_Color::ParseColor(*pArray); | 153 crBG = CPVT_Color::ParseColor(*pArray); |
| 154 } | 154 } |
| 155 CFX_ByteTextBuf sAppStream; | 155 CFX_ByteTextBuf sAppStream; |
| 156 CFX_ByteString sBG = CPVT_GenerateAP::GenerateColorAP(crBG, TRUE); | 156 CFX_ByteString sBG = |
| 157 CPVT_GenerateAP::GenerateColorAP(crBG, PaintOperation::kFill); |
| 157 if (sBG.GetLength() > 0) { | 158 if (sBG.GetLength() > 0) { |
| 158 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " " | 159 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " " |
| 159 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" | 160 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" |
| 160 << "Q\n"; | 161 << "Q\n"; |
| 161 } | 162 } |
| 162 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( | 163 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( |
| 163 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, | 164 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, |
| 164 dsBorder); | 165 dsBorder); |
| 165 if (sBorderStream.GetLength() > 0) | 166 if (sBorderStream.GetLength() > 0) |
| 166 sAppStream << "q\n" << sBorderStream << "Q\n"; | 167 sAppStream << "q\n" << sBorderStream << "Q\n"; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); | 257 &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); |
| 257 if (sBody.GetLength() > 0) { | 258 if (sBody.GetLength() > 0) { |
| 258 sAppStream << "/Tx BMC\n" | 259 sAppStream << "/Tx BMC\n" |
| 259 << "q\n"; | 260 << "q\n"; |
| 260 if (rcContent.Width() > rcBody.Width() || | 261 if (rcContent.Width() > rcBody.Width() || |
| 261 rcContent.Height() > rcBody.Height()) { | 262 rcContent.Height() > rcBody.Height()) { |
| 262 sAppStream << rcBody.left << " " << rcBody.bottom << " " | 263 sAppStream << rcBody.left << " " << rcBody.bottom << " " |
| 263 << rcBody.Width() << " " << rcBody.Height() | 264 << rcBody.Width() << " " << rcBody.Height() |
| 264 << " re\nW\nn\n"; | 265 << " re\nW\nn\n"; |
| 265 } | 266 } |
| 266 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) | 267 sAppStream << "BT\n" |
| 268 << CPVT_GenerateAP::GenerateColorAP(crText, |
| 269 PaintOperation::kFill) |
| 267 << sBody << "ET\n" | 270 << sBody << "ET\n" |
| 268 << "Q\nEMC\n"; | 271 << "Q\nEMC\n"; |
| 269 } | 272 } |
| 270 } break; | 273 } break; |
| 271 case 1: { | 274 case 1: { |
| 272 CFX_WideString swValue = | 275 CFX_WideString swValue = |
| 273 FPDF_GetFieldAttr(pAnnotDict, "V") | 276 FPDF_GetFieldAttr(pAnnotDict, "V") |
| 274 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() | 277 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() |
| 275 : CFX_WideString(); | 278 : CFX_WideString(); |
| 276 CPVT_FontMap map( | 279 CPVT_FontMap map( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 297 CFX_FloatRect rcContent = vt.GetContentRect(); | 300 CFX_FloatRect rcContent = vt.GetContentRect(); |
| 298 CFX_FloatPoint ptOffset = | 301 CFX_FloatPoint ptOffset = |
| 299 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); | 302 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); |
| 300 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( | 303 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( |
| 301 &map, vt.GetIterator(), ptOffset, TRUE, 0); | 304 &map, vt.GetIterator(), ptOffset, TRUE, 0); |
| 302 if (sEdit.GetLength() > 0) { | 305 if (sEdit.GetLength() > 0) { |
| 303 sAppStream << "/Tx BMC\n" | 306 sAppStream << "/Tx BMC\n" |
| 304 << "q\n"; | 307 << "q\n"; |
| 305 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " | 308 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " |
| 306 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n"; | 309 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n"; |
| 307 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) | 310 sAppStream << "BT\n" |
| 311 << CPVT_GenerateAP::GenerateColorAP(crText, |
| 312 PaintOperation::kFill) |
| 308 << sEdit << "ET\n" | 313 << sEdit << "ET\n" |
| 309 << "Q\nEMC\n"; | 314 << "Q\nEMC\n"; |
| 310 } | 315 } |
| 311 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP( | 316 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP( |
| 312 CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f, | 317 CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f, |
| 313 220.0f / 255.0f), | 318 220.0f / 255.0f), |
| 314 TRUE); | 319 PaintOperation::kFill); |
| 315 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) { | 320 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) { |
| 316 sAppStream << "q\n" << sButton; | 321 sAppStream << "q\n" << sButton; |
| 317 sAppStream << rcButton.left << " " << rcButton.bottom << " " | 322 sAppStream << rcButton.left << " " << rcButton.bottom << " " |
| 318 << rcButton.Width() << " " << rcButton.Height() << " re f\n"; | 323 << rcButton.Width() << " " << rcButton.Height() << " re f\n"; |
| 319 sAppStream << "Q\n"; | 324 sAppStream << "Q\n"; |
| 320 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( | 325 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( |
| 321 rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), | 326 rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), |
| 322 CPVT_Color(CPVT_Color::kGray, 1), | 327 CPVT_Color(CPVT_Color::kGray, 1), |
| 323 CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED, | 328 CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED, |
| 324 CPVT_Dash(3, 0, 0)); | 329 CPVT_Dash(3, 0, 0)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f)); | 384 CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f)); |
| 380 vt.SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); | 385 vt.SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); |
| 381 | 386 |
| 382 vt.Initialize(); | 387 vt.Initialize(); |
| 383 vt.SetText(swItem.c_str()); | 388 vt.SetText(swItem.c_str()); |
| 384 vt.RearrangeAll(); | 389 vt.RearrangeAll(); |
| 385 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); | 390 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); |
| 386 if (bSelected) { | 391 if (bSelected) { |
| 387 CFX_FloatRect rcItem = CFX_FloatRect( | 392 CFX_FloatRect rcItem = CFX_FloatRect( |
| 388 rcBody.left, fy - fItemHeight, rcBody.right, fy); | 393 rcBody.left, fy - fItemHeight, rcBody.right, fy); |
| 389 sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP( | 394 sBody << "q\n" |
| 390 CPVT_Color(CPVT_Color::kRGB, 0, | 395 << CPVT_GenerateAP::GenerateColorAP( |
| 391 51.0f / 255.0f, 113.0f / 255.0f), | 396 CPVT_Color(CPVT_Color::kRGB, 0, 51.0f / 255.0f, |
| 392 TRUE) | 397 113.0f / 255.0f), |
| 398 PaintOperation::kFill) |
| 393 << rcItem.left << " " << rcItem.bottom << " " | 399 << rcItem.left << " " << rcItem.bottom << " " |
| 394 << rcItem.Width() << " " << rcItem.Height() << " re f\n" | 400 << rcItem.Width() << " " << rcItem.Height() << " re f\n" |
| 395 << "Q\n"; | 401 << "Q\n"; |
| 396 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP( | 402 sBody << "BT\n" |
| 397 CPVT_Color(CPVT_Color::kGray, 1), TRUE) | 403 << CPVT_GenerateAP::GenerateColorAP( |
| 404 CPVT_Color(CPVT_Color::kGray, 1), |
| 405 PaintOperation::kFill) |
| 398 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), | 406 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), |
| 399 CFX_FloatPoint(0.0f, fy), | 407 CFX_FloatPoint(0.0f, fy), |
| 400 TRUE, 0) | 408 TRUE, 0) |
| 401 << "ET\n"; | 409 << "ET\n"; |
| 402 } else { | 410 } else { |
| 403 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) | 411 sBody << "BT\n" |
| 412 << CPVT_GenerateAP::GenerateColorAP(crText, |
| 413 PaintOperation::kFill) |
| 404 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), | 414 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), |
| 405 CFX_FloatPoint(0.0f, fy), | 415 CFX_FloatPoint(0.0f, fy), |
| 406 TRUE, 0) | 416 TRUE, 0) |
| 407 << "ET\n"; | 417 << "ET\n"; |
| 408 } | 418 } |
| 409 fy -= fItemHeight; | 419 fy -= fItemHeight; |
| 410 } | 420 } |
| 411 } | 421 } |
| 412 } | 422 } |
| 413 if (sBody.GetSize() > 0) { | 423 if (sBody.GetSize() > 0) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // existing AP dictionary. | 509 // existing AP dictionary. |
| 500 if (pAnnotDict->KeyExist("AP")) | 510 if (pAnnotDict->KeyExist("AP")) |
| 501 return false; | 511 return false; |
| 502 | 512 |
| 503 CFX_ByteTextBuf sAppStream; | 513 CFX_ByteTextBuf sAppStream; |
| 504 sAppStream << "/GS gs "; | 514 sAppStream << "/GS gs "; |
| 505 | 515 |
| 506 if (pAnnotDict->KeyExist("C")) { | 516 if (pAnnotDict->KeyExist("C")) { |
| 507 CPDF_Array* pColor = pAnnotDict->GetArrayBy("C"); | 517 CPDF_Array* pColor = pAnnotDict->GetArrayBy("C"); |
| 508 CPVT_Color color = CPVT_Color::ParseColor(*pColor); | 518 CPVT_Color color = CPVT_Color::ParseColor(*pColor); |
| 509 sAppStream << CPVT_GenerateAP::GenerateColorAP(color, TRUE); | 519 sAppStream << CPVT_GenerateAP::GenerateColorAP(color, |
| 520 PaintOperation::kFill); |
| 510 } else { | 521 } else { |
| 511 // Defaults to 0xFFFF00 color for highlight. | 522 // Defaults to 0xFFFF00 color for highlight. |
| 512 sAppStream << "1 1 0 rg \n"; | 523 sAppStream << "1 1 0 rg \n"; |
| 513 } | 524 } |
| 514 | 525 |
| 515 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 526 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| 516 rect.Normalize(); | 527 rect.Normalize(); |
| 517 | 528 |
| 518 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " | 529 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " |
| 519 << rect.top << " l " << rect.right << " " << rect.bottom << " l " | 530 << rect.top << " l " << rect.right << " " << rect.bottom << " l " |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 CFX_ByteString sColor; | 665 CFX_ByteString sColor; |
| 655 FX_FLOAT fLeft = rect.left; | 666 FX_FLOAT fLeft = rect.left; |
| 656 FX_FLOAT fRight = rect.right; | 667 FX_FLOAT fRight = rect.right; |
| 657 FX_FLOAT fTop = rect.top; | 668 FX_FLOAT fTop = rect.top; |
| 658 FX_FLOAT fBottom = rect.bottom; | 669 FX_FLOAT fBottom = rect.bottom; |
| 659 if (fWidth > 0.0f) { | 670 if (fWidth > 0.0f) { |
| 660 FX_FLOAT fHalfWidth = fWidth / 2.0f; | 671 FX_FLOAT fHalfWidth = fWidth / 2.0f; |
| 661 switch (nStyle) { | 672 switch (nStyle) { |
| 662 default: | 673 default: |
| 663 case BorderStyle::SOLID: | 674 case BorderStyle::SOLID: |
| 664 sColor = GenerateColorAP(color, TRUE); | 675 sColor = GenerateColorAP(color, PaintOperation::kFill); |
| 665 if (sColor.GetLength() > 0) { | 676 if (sColor.GetLength() > 0) { |
| 666 sAppStream << sColor; | 677 sAppStream << sColor; |
| 667 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " | 678 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " |
| 668 << fTop - fBottom << " re\n"; | 679 << fTop - fBottom << " re\n"; |
| 669 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " | 680 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " |
| 670 << fRight - fLeft - fWidth * 2 << " " | 681 << fRight - fLeft - fWidth * 2 << " " |
| 671 << fTop - fBottom - fWidth * 2 << " re\n"; | 682 << fTop - fBottom - fWidth * 2 << " re\n"; |
| 672 sAppStream << "f*\n"; | 683 sAppStream << "f*\n"; |
| 673 } | 684 } |
| 674 break; | 685 break; |
| 675 case BorderStyle::DASH: | 686 case BorderStyle::DASH: |
| 676 sColor = GenerateColorAP(color, FALSE); | 687 sColor = GenerateColorAP(color, PaintOperation::kStroke); |
| 677 if (sColor.GetLength() > 0) { | 688 if (sColor.GetLength() > 0) { |
| 678 sAppStream << sColor; | 689 sAppStream << sColor; |
| 679 sAppStream << fWidth << " w" | 690 sAppStream << fWidth << " w" |
| 680 << " [" << dash.nDash << " " << dash.nGap << "] " | 691 << " [" << dash.nDash << " " << dash.nGap << "] " |
| 681 << dash.nPhase << " d\n"; | 692 << dash.nPhase << " d\n"; |
| 682 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 | 693 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 |
| 683 << " m\n"; | 694 << " m\n"; |
| 684 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 | 695 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 |
| 685 << " l\n"; | 696 << " l\n"; |
| 686 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 | 697 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 |
| 687 << " l\n"; | 698 << " l\n"; |
| 688 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 | 699 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 |
| 689 << " l\n"; | 700 << " l\n"; |
| 690 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 | 701 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 |
| 691 << " l S\n"; | 702 << " l S\n"; |
| 692 } | 703 } |
| 693 break; | 704 break; |
| 694 case BorderStyle::BEVELED: | 705 case BorderStyle::BEVELED: |
| 695 case BorderStyle::INSET: | 706 case BorderStyle::INSET: |
| 696 sColor = GenerateColorAP(crLeftTop, TRUE); | 707 sColor = GenerateColorAP(crLeftTop, PaintOperation::kFill); |
| 697 if (sColor.GetLength() > 0) { | 708 if (sColor.GetLength() > 0) { |
| 698 sAppStream << sColor; | 709 sAppStream << sColor; |
| 699 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth | 710 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth |
| 700 << " m\n"; | 711 << " m\n"; |
| 701 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth | 712 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth |
| 702 << " l\n"; | 713 << " l\n"; |
| 703 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth | 714 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth |
| 704 << " l\n"; | 715 << " l\n"; |
| 705 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 716 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
| 706 << " l\n"; | 717 << " l\n"; |
| 707 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 718 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
| 708 << " l\n"; | 719 << " l\n"; |
| 709 sAppStream << fLeft + fHalfWidth * 2 << " " | 720 sAppStream << fLeft + fHalfWidth * 2 << " " |
| 710 << fBottom + fHalfWidth * 2 << " l f\n"; | 721 << fBottom + fHalfWidth * 2 << " l f\n"; |
| 711 } | 722 } |
| 712 sColor = GenerateColorAP(crRightBottom, TRUE); | 723 sColor = GenerateColorAP(crRightBottom, PaintOperation::kFill); |
| 713 if (sColor.GetLength() > 0) { | 724 if (sColor.GetLength() > 0) { |
| 714 sAppStream << sColor; | 725 sAppStream << sColor; |
| 715 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth | 726 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth |
| 716 << " m\n"; | 727 << " m\n"; |
| 717 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth | 728 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth |
| 718 << " l\n"; | 729 << " l\n"; |
| 719 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth | 730 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth |
| 720 << " l\n"; | 731 << " l\n"; |
| 721 sAppStream << fLeft + fHalfWidth * 2 << " " | 732 sAppStream << fLeft + fHalfWidth * 2 << " " |
| 722 << fBottom + fHalfWidth * 2 << " l\n"; | 733 << fBottom + fHalfWidth * 2 << " l\n"; |
| 723 sAppStream << fRight - fHalfWidth * 2 << " " | 734 sAppStream << fRight - fHalfWidth * 2 << " " |
| 724 << fBottom + fHalfWidth * 2 << " l\n"; | 735 << fBottom + fHalfWidth * 2 << " l\n"; |
| 725 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 736 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
| 726 << " l f\n"; | 737 << " l f\n"; |
| 727 } | 738 } |
| 728 sColor = GenerateColorAP(color, TRUE); | 739 sColor = GenerateColorAP(color, PaintOperation::kFill); |
| 729 if (sColor.GetLength() > 0) { | 740 if (sColor.GetLength() > 0) { |
| 730 sAppStream << sColor; | 741 sAppStream << sColor; |
| 731 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " | 742 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " |
| 732 << fTop - fBottom << " re\n"; | 743 << fTop - fBottom << " re\n"; |
| 733 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " " | 744 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " " |
| 734 << fRight - fLeft - fHalfWidth * 2 << " " | 745 << fRight - fLeft - fHalfWidth * 2 << " " |
| 735 << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; | 746 << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; |
| 736 } | 747 } |
| 737 break; | 748 break; |
| 738 case BorderStyle::UNDERLINE: | 749 case BorderStyle::UNDERLINE: |
| 739 sColor = GenerateColorAP(color, FALSE); | 750 sColor = GenerateColorAP(color, PaintOperation::kStroke); |
| 740 if (sColor.GetLength() > 0) { | 751 if (sColor.GetLength() > 0) { |
| 741 sAppStream << sColor; | 752 sAppStream << sColor; |
| 742 sAppStream << fWidth << " w\n"; | 753 sAppStream << fWidth << " w\n"; |
| 743 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; | 754 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; |
| 744 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; | 755 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; |
| 745 } | 756 } |
| 746 break; | 757 break; |
| 747 } | 758 } |
| 748 } | 759 } |
| 749 return sAppStream.MakeString(); | 760 return sAppStream.MakeString(); |
| 750 } | 761 } |
| 751 | 762 |
| 752 // Static. | 763 // Static. |
| 753 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, | 764 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, |
| 754 const FX_BOOL& bFillOrStroke) { | 765 PaintOperation nOperation) { |
| 755 CFX_ByteTextBuf sColorStream; | 766 CFX_ByteTextBuf sColorStream; |
| 756 switch (color.nColorType) { | 767 switch (color.nColorType) { |
| 757 case CPVT_Color::kRGB: | 768 case CPVT_Color::kRGB: |
| 758 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 769 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 759 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") | 770 << color.fColor3 << " " |
| 771 << (nOperation == PaintOperation::kStroke ? "RG" : "rg") |
| 760 << "\n"; | 772 << "\n"; |
| 761 break; | 773 break; |
| 762 case CPVT_Color::kGray: | 774 case CPVT_Color::kGray: |
| 763 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") | 775 sColorStream << color.fColor1 << " " |
| 776 << (nOperation == PaintOperation::kStroke ? "G" : "g") |
| 764 << "\n"; | 777 << "\n"; |
| 765 break; | 778 break; |
| 766 case CPVT_Color::kCMYK: | 779 case CPVT_Color::kCMYK: |
| 767 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 780 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 768 << color.fColor3 << " " << color.fColor4 << " " | 781 << color.fColor3 << " " << color.fColor4 << " " |
| 769 << (bFillOrStroke ? "k" : "K") << "\n"; | 782 << (nOperation == PaintOperation::kStroke ? "K" : "k") |
| 783 << "\n"; |
| 770 break; | 784 break; |
| 771 case CPVT_Color::kTransparent: | 785 case CPVT_Color::kTransparent: |
| 772 break; | 786 break; |
| 773 } | 787 } |
| 774 return sColorStream.MakeString(); | 788 return sColorStream.MakeString(); |
| 775 } | 789 } |
| 776 | 790 |
| 777 // Static. | 791 // Static. |
| 778 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, | 792 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, |
| 779 int32_t nFontIndex, | 793 int32_t nFontIndex, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 int32_t nFontIndex, | 828 int32_t nFontIndex, |
| 815 FX_FLOAT fFontSize) { | 829 FX_FLOAT fFontSize) { |
| 816 CFX_ByteTextBuf sRet; | 830 CFX_ByteTextBuf sRet; |
| 817 if (pFontMap) { | 831 if (pFontMap) { |
| 818 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 832 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
| 819 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 833 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
| 820 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 834 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
| 821 } | 835 } |
| 822 return sRet.MakeString(); | 836 return sRet.MakeString(); |
| 823 } | 837 } |
| OLD | NEW |