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::FILL); |
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::FILL) |
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::FILL) |
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::FILL); |
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::FILL) |
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::FILL) |
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::FILL) |
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, PaintOperation::FILL); |
510 } else { | 520 } else { |
511 // Defaults to 0xFFFF00 color for highlight. | 521 // Defaults to 0xFFFF00 color for highlight. |
512 sAppStream << "1 1 0 rg \n"; | 522 sAppStream << "1 1 0 rg \n"; |
513 } | 523 } |
514 | 524 |
515 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 525 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
516 rect.Normalize(); | 526 rect.Normalize(); |
517 | 527 |
518 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " | 528 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " |
519 << rect.top << " l " << rect.right << " " << rect.bottom << " l " | 529 << 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; | 664 CFX_ByteString sColor; |
655 FX_FLOAT fLeft = rect.left; | 665 FX_FLOAT fLeft = rect.left; |
656 FX_FLOAT fRight = rect.right; | 666 FX_FLOAT fRight = rect.right; |
657 FX_FLOAT fTop = rect.top; | 667 FX_FLOAT fTop = rect.top; |
658 FX_FLOAT fBottom = rect.bottom; | 668 FX_FLOAT fBottom = rect.bottom; |
659 if (fWidth > 0.0f) { | 669 if (fWidth > 0.0f) { |
660 FX_FLOAT fHalfWidth = fWidth / 2.0f; | 670 FX_FLOAT fHalfWidth = fWidth / 2.0f; |
661 switch (nStyle) { | 671 switch (nStyle) { |
662 default: | 672 default: |
663 case BorderStyle::SOLID: | 673 case BorderStyle::SOLID: |
664 sColor = GenerateColorAP(color, TRUE); | 674 sColor = GenerateColorAP(color, PaintOperation::FILL); |
665 if (sColor.GetLength() > 0) { | 675 if (sColor.GetLength() > 0) { |
666 sAppStream << sColor; | 676 sAppStream << sColor; |
667 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " | 677 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " |
668 << fTop - fBottom << " re\n"; | 678 << fTop - fBottom << " re\n"; |
669 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " | 679 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " |
670 << fRight - fLeft - fWidth * 2 << " " | 680 << fRight - fLeft - fWidth * 2 << " " |
671 << fTop - fBottom - fWidth * 2 << " re\n"; | 681 << fTop - fBottom - fWidth * 2 << " re\n"; |
672 sAppStream << "f*\n"; | 682 sAppStream << "f*\n"; |
673 } | 683 } |
674 break; | 684 break; |
675 case BorderStyle::DASH: | 685 case BorderStyle::DASH: |
676 sColor = GenerateColorAP(color, FALSE); | 686 sColor = GenerateColorAP(color, PaintOperation::STROKE); |
677 if (sColor.GetLength() > 0) { | 687 if (sColor.GetLength() > 0) { |
678 sAppStream << sColor; | 688 sAppStream << sColor; |
679 sAppStream << fWidth << " w" | 689 sAppStream << fWidth << " w" |
680 << " [" << dash.nDash << " " << dash.nGap << "] " | 690 << " [" << dash.nDash << " " << dash.nGap << "] " |
681 << dash.nPhase << " d\n"; | 691 << dash.nPhase << " d\n"; |
682 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 | 692 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 |
683 << " m\n"; | 693 << " m\n"; |
684 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 | 694 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 |
685 << " l\n"; | 695 << " l\n"; |
686 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 | 696 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 |
687 << " l\n"; | 697 << " l\n"; |
688 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 | 698 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 |
689 << " l\n"; | 699 << " l\n"; |
690 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 | 700 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 |
691 << " l S\n"; | 701 << " l S\n"; |
692 } | 702 } |
693 break; | 703 break; |
694 case BorderStyle::BEVELED: | 704 case BorderStyle::BEVELED: |
695 case BorderStyle::INSET: | 705 case BorderStyle::INSET: |
696 sColor = GenerateColorAP(crLeftTop, TRUE); | 706 sColor = GenerateColorAP(crLeftTop, PaintOperation::FILL); |
697 if (sColor.GetLength() > 0) { | 707 if (sColor.GetLength() > 0) { |
698 sAppStream << sColor; | 708 sAppStream << sColor; |
699 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth | 709 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth |
700 << " m\n"; | 710 << " m\n"; |
701 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth | 711 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth |
702 << " l\n"; | 712 << " l\n"; |
703 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth | 713 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth |
704 << " l\n"; | 714 << " l\n"; |
705 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 715 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
706 << " l\n"; | 716 << " l\n"; |
707 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 717 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
708 << " l\n"; | 718 << " l\n"; |
709 sAppStream << fLeft + fHalfWidth * 2 << " " | 719 sAppStream << fLeft + fHalfWidth * 2 << " " |
710 << fBottom + fHalfWidth * 2 << " l f\n"; | 720 << fBottom + fHalfWidth * 2 << " l f\n"; |
711 } | 721 } |
712 sColor = GenerateColorAP(crRightBottom, TRUE); | 722 sColor = GenerateColorAP(crRightBottom, PaintOperation::FILL); |
713 if (sColor.GetLength() > 0) { | 723 if (sColor.GetLength() > 0) { |
714 sAppStream << sColor; | 724 sAppStream << sColor; |
715 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth | 725 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth |
716 << " m\n"; | 726 << " m\n"; |
717 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth | 727 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth |
718 << " l\n"; | 728 << " l\n"; |
719 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth | 729 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth |
720 << " l\n"; | 730 << " l\n"; |
721 sAppStream << fLeft + fHalfWidth * 2 << " " | 731 sAppStream << fLeft + fHalfWidth * 2 << " " |
722 << fBottom + fHalfWidth * 2 << " l\n"; | 732 << fBottom + fHalfWidth * 2 << " l\n"; |
723 sAppStream << fRight - fHalfWidth * 2 << " " | 733 sAppStream << fRight - fHalfWidth * 2 << " " |
724 << fBottom + fHalfWidth * 2 << " l\n"; | 734 << fBottom + fHalfWidth * 2 << " l\n"; |
725 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 735 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
726 << " l f\n"; | 736 << " l f\n"; |
727 } | 737 } |
728 sColor = GenerateColorAP(color, TRUE); | 738 sColor = GenerateColorAP(color, PaintOperation::FILL); |
729 if (sColor.GetLength() > 0) { | 739 if (sColor.GetLength() > 0) { |
730 sAppStream << sColor; | 740 sAppStream << sColor; |
731 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " | 741 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " |
732 << fTop - fBottom << " re\n"; | 742 << fTop - fBottom << " re\n"; |
733 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " " | 743 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " " |
734 << fRight - fLeft - fHalfWidth * 2 << " " | 744 << fRight - fLeft - fHalfWidth * 2 << " " |
735 << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; | 745 << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; |
736 } | 746 } |
737 break; | 747 break; |
738 case BorderStyle::UNDERLINE: | 748 case BorderStyle::UNDERLINE: |
739 sColor = GenerateColorAP(color, FALSE); | 749 sColor = GenerateColorAP(color, PaintOperation::STROKE); |
740 if (sColor.GetLength() > 0) { | 750 if (sColor.GetLength() > 0) { |
741 sAppStream << sColor; | 751 sAppStream << sColor; |
742 sAppStream << fWidth << " w\n"; | 752 sAppStream << fWidth << " w\n"; |
743 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; | 753 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; |
744 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; | 754 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; |
745 } | 755 } |
746 break; | 756 break; |
747 } | 757 } |
748 } | 758 } |
749 return sAppStream.MakeString(); | 759 return sAppStream.MakeString(); |
750 } | 760 } |
751 | 761 |
752 // Static. | 762 // Static. |
753 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, | 763 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, |
754 const FX_BOOL& bFillOrStroke) { | 764 PaintOperation nOperation) { |
755 CFX_ByteTextBuf sColorStream; | 765 CFX_ByteTextBuf sColorStream; |
756 switch (color.nColorType) { | 766 switch (color.nColorType) { |
757 case CPVT_Color::kRGB: | 767 case CPVT_Color::kRGB: |
758 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 768 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
759 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") | 769 << color.fColor3 << " " |
| 770 << (nOperation == PaintOperation::STROKE ? "RG" : "rg") |
760 << "\n"; | 771 << "\n"; |
761 break; | 772 break; |
762 case CPVT_Color::kGray: | 773 case CPVT_Color::kGray: |
763 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") | 774 sColorStream << color.fColor1 << " " |
| 775 << (nOperation == PaintOperation::STROKE ? "G" : "g") |
764 << "\n"; | 776 << "\n"; |
765 break; | 777 break; |
766 case CPVT_Color::kCMYK: | 778 case CPVT_Color::kCMYK: |
767 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 779 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
768 << color.fColor3 << " " << color.fColor4 << " " | 780 << color.fColor3 << " " << color.fColor4 << " " |
769 << (bFillOrStroke ? "k" : "K") << "\n"; | 781 << (nOperation == PaintOperation::STROKE ? "K" : "k") |
| 782 << "\n"; |
770 break; | 783 break; |
771 case CPVT_Color::kTransparent: | 784 case CPVT_Color::kTransparent: |
772 break; | 785 break; |
773 } | 786 } |
774 return sColorStream.MakeString(); | 787 return sColorStream.MakeString(); |
775 } | 788 } |
776 | 789 |
777 // Static. | 790 // Static. |
778 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, | 791 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, |
779 int32_t nFontIndex, | 792 int32_t nFontIndex, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 int32_t nFontIndex, | 827 int32_t nFontIndex, |
815 FX_FLOAT fFontSize) { | 828 FX_FLOAT fFontSize) { |
816 CFX_ByteTextBuf sRet; | 829 CFX_ByteTextBuf sRet; |
817 if (pFontMap) { | 830 if (pFontMap) { |
818 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 831 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
819 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 832 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
820 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 833 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
821 } | 834 } |
822 return sRet.MakeString(); | 835 return sRet.MakeString(); |
823 } | 836 } |
OLD | NEW |