Chromium Code Reviews| 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 = CPVT_GenerateAP::GenerateColorAP(crBG, false); |
| 157 if (sBG.GetLength() > 0) { | 157 if (sBG.GetLength() > 0) { |
| 158 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " " | 158 sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " " |
| 159 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" | 159 << rcBBox.Width() << " " << rcBBox.Height() << " re f\n" |
| 160 << "Q\n"; | 160 << "Q\n"; |
| 161 } | 161 } |
| 162 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( | 162 CFX_ByteString sBorderStream = CPVT_GenerateAP::GenerateBorderAP( |
| 163 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, | 163 rcBBox, fBorderWidth, crBorder, crLeftTop, crRightBottom, nBorderStyle, |
| 164 dsBorder); | 164 dsBorder); |
| 165 if (sBorderStream.GetLength() > 0) | 165 if (sBorderStream.GetLength() > 0) |
| 166 sAppStream << "q\n" << sBorderStream << "Q\n"; | 166 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); | 256 &map, vt.GetIterator(), ptOffset, !bCharArray, subWord); |
| 257 if (sBody.GetLength() > 0) { | 257 if (sBody.GetLength() > 0) { |
| 258 sAppStream << "/Tx BMC\n" | 258 sAppStream << "/Tx BMC\n" |
| 259 << "q\n"; | 259 << "q\n"; |
| 260 if (rcContent.Width() > rcBody.Width() || | 260 if (rcContent.Width() > rcBody.Width() || |
| 261 rcContent.Height() > rcBody.Height()) { | 261 rcContent.Height() > rcBody.Height()) { |
| 262 sAppStream << rcBody.left << " " << rcBody.bottom << " " | 262 sAppStream << rcBody.left << " " << rcBody.bottom << " " |
| 263 << rcBody.Width() << " " << rcBody.Height() | 263 << rcBody.Width() << " " << rcBody.Height() |
| 264 << " re\nW\nn\n"; | 264 << " re\nW\nn\n"; |
| 265 } | 265 } |
| 266 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) | 266 sAppStream << "BT\n" |
| 267 << sBody << "ET\n" | 267 << CPVT_GenerateAP::GenerateColorAP(crText, false) << sBody |
| 268 << "ET\n" | |
| 268 << "Q\nEMC\n"; | 269 << "Q\nEMC\n"; |
| 269 } | 270 } |
| 270 } break; | 271 } break; |
| 271 case 1: { | 272 case 1: { |
| 272 CFX_WideString swValue = | 273 CFX_WideString swValue = |
| 273 FPDF_GetFieldAttr(pAnnotDict, "V") | 274 FPDF_GetFieldAttr(pAnnotDict, "V") |
| 274 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() | 275 ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() |
| 275 : CFX_WideString(); | 276 : CFX_WideString(); |
| 276 CPVT_FontMap map( | 277 CPVT_FontMap map( |
| 277 pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr, | 278 pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 297 CFX_FloatRect rcContent = vt.GetContentRect(); | 298 CFX_FloatRect rcContent = vt.GetContentRect(); |
| 298 CFX_FloatPoint ptOffset = | 299 CFX_FloatPoint ptOffset = |
| 299 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); | 300 CFX_FloatPoint(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f); |
| 300 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( | 301 CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP( |
| 301 &map, vt.GetIterator(), ptOffset, TRUE, 0); | 302 &map, vt.GetIterator(), ptOffset, TRUE, 0); |
| 302 if (sEdit.GetLength() > 0) { | 303 if (sEdit.GetLength() > 0) { |
| 303 sAppStream << "/Tx BMC\n" | 304 sAppStream << "/Tx BMC\n" |
| 304 << "q\n"; | 305 << "q\n"; |
| 305 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " | 306 sAppStream << rcEdit.left << " " << rcEdit.bottom << " " |
| 306 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n"; | 307 << rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n"; |
| 307 sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) | 308 sAppStream << "BT\n" |
| 308 << sEdit << "ET\n" | 309 << CPVT_GenerateAP::GenerateColorAP(crText, false) << sEdit |
| 310 << "ET\n" | |
| 309 << "Q\nEMC\n"; | 311 << "Q\nEMC\n"; |
| 310 } | 312 } |
| 311 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP( | 313 CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP( |
| 312 CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f, | 314 CPVT_Color(CPVT_Color::kRGB, 220.0f / 255.0f, 220.0f / 255.0f, |
| 313 220.0f / 255.0f), | 315 220.0f / 255.0f), |
| 314 TRUE); | 316 false); |
| 315 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) { | 317 if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) { |
| 316 sAppStream << "q\n" << sButton; | 318 sAppStream << "q\n" << sButton; |
| 317 sAppStream << rcButton.left << " " << rcButton.bottom << " " | 319 sAppStream << rcButton.left << " " << rcButton.bottom << " " |
| 318 << rcButton.Width() << " " << rcButton.Height() << " re f\n"; | 320 << rcButton.Width() << " " << rcButton.Height() << " re f\n"; |
| 319 sAppStream << "Q\n"; | 321 sAppStream << "Q\n"; |
| 320 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( | 322 CFX_ByteString sButtonBorder = CPVT_GenerateAP::GenerateBorderAP( |
| 321 rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), | 323 rcButton, 2, CPVT_Color(CPVT_Color::kGray, 0), |
| 322 CPVT_Color(CPVT_Color::kGray, 1), | 324 CPVT_Color(CPVT_Color::kGray, 1), |
| 323 CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED, | 325 CPVT_Color(CPVT_Color::kGray, 0.5), BorderStyle::BEVELED, |
| 324 CPVT_Dash(3, 0, 0)); | 326 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)); | 381 CFX_FloatRect(rcBody.left, 0.0f, rcBody.right, 0.0f)); |
| 380 vt.SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); | 382 vt.SetFontSize(IsFloatZero(fFontSize) ? 12.0f : fFontSize); |
| 381 | 383 |
| 382 vt.Initialize(); | 384 vt.Initialize(); |
| 383 vt.SetText(swItem.c_str()); | 385 vt.SetText(swItem.c_str()); |
| 384 vt.RearrangeAll(); | 386 vt.RearrangeAll(); |
| 385 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); | 387 FX_FLOAT fItemHeight = vt.GetContentRect().Height(); |
| 386 if (bSelected) { | 388 if (bSelected) { |
| 387 CFX_FloatRect rcItem = CFX_FloatRect( | 389 CFX_FloatRect rcItem = CFX_FloatRect( |
| 388 rcBody.left, fy - fItemHeight, rcBody.right, fy); | 390 rcBody.left, fy - fItemHeight, rcBody.right, fy); |
| 389 sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP( | 391 sBody << "q\n" |
| 390 CPVT_Color(CPVT_Color::kRGB, 0, | 392 << CPVT_GenerateAP::GenerateColorAP( |
| 391 51.0f / 255.0f, 113.0f / 255.0f), | 393 CPVT_Color(CPVT_Color::kRGB, 0, 51.0f / 255.0f, |
| 392 TRUE) | 394 113.0f / 255.0f), |
| 395 false) | |
| 393 << rcItem.left << " " << rcItem.bottom << " " | 396 << rcItem.left << " " << rcItem.bottom << " " |
| 394 << rcItem.Width() << " " << rcItem.Height() << " re f\n" | 397 << rcItem.Width() << " " << rcItem.Height() << " re f\n" |
| 395 << "Q\n"; | 398 << "Q\n"; |
| 396 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP( | 399 sBody << "BT\n" |
| 397 CPVT_Color(CPVT_Color::kGray, 1), TRUE) | 400 << CPVT_GenerateAP::GenerateColorAP( |
| 401 CPVT_Color(CPVT_Color::kGray, 1), false) | |
| 398 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), | 402 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), |
| 399 CFX_FloatPoint(0.0f, fy), | 403 CFX_FloatPoint(0.0f, fy), |
| 400 TRUE, 0) | 404 TRUE, 0) |
| 401 << "ET\n"; | 405 << "ET\n"; |
| 402 } else { | 406 } else { |
| 403 sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) | 407 sBody << "BT\n" |
| 408 << CPVT_GenerateAP::GenerateColorAP(crText, false) | |
| 404 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), | 409 << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), |
| 405 CFX_FloatPoint(0.0f, fy), | 410 CFX_FloatPoint(0.0f, fy), |
| 406 TRUE, 0) | 411 TRUE, 0) |
| 407 << "ET\n"; | 412 << "ET\n"; |
| 408 } | 413 } |
| 409 fy -= fItemHeight; | 414 fy -= fItemHeight; |
| 410 } | 415 } |
| 411 } | 416 } |
| 412 } | 417 } |
| 413 if (sBody.GetSize() > 0) { | 418 if (sBody.GetSize() > 0) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 // existing AP dictionary. | 504 // existing AP dictionary. |
| 500 if (pAnnotDict->KeyExist("AP")) | 505 if (pAnnotDict->KeyExist("AP")) |
| 501 return false; | 506 return false; |
| 502 | 507 |
| 503 CFX_ByteTextBuf sAppStream; | 508 CFX_ByteTextBuf sAppStream; |
| 504 sAppStream << "/GS gs "; | 509 sAppStream << "/GS gs "; |
| 505 | 510 |
| 506 if (pAnnotDict->KeyExist("C")) { | 511 if (pAnnotDict->KeyExist("C")) { |
| 507 CPDF_Array* pColor = pAnnotDict->GetArrayBy("C"); | 512 CPDF_Array* pColor = pAnnotDict->GetArrayBy("C"); |
| 508 CPVT_Color color = CPVT_Color::ParseColor(*pColor); | 513 CPVT_Color color = CPVT_Color::ParseColor(*pColor); |
| 509 sAppStream << CPVT_GenerateAP::GenerateColorAP(color, TRUE); | 514 sAppStream << CPVT_GenerateAP::GenerateColorAP(color, false); |
| 510 } else { | 515 } else { |
| 511 // Defaults to 0xFFFF00 color for highlight. | 516 // Defaults to 0xFFFF00 color for highlight. |
| 512 sAppStream << "1 1 0 rg \n"; | 517 sAppStream << "1 1 0 rg \n"; |
| 513 } | 518 } |
| 514 | 519 |
| 515 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); | 520 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| 516 rect.Normalize(); | 521 rect.Normalize(); |
| 517 | 522 |
| 518 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " | 523 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " |
| 519 << rect.top << " l " << rect.right << " " << rect.bottom << " l " | 524 << rect.top << " l " << rect.right << " " << rect.bottom << " l " |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 CFX_ByteString sColor; | 656 CFX_ByteString sColor; |
| 652 FX_FLOAT fLeft = rect.left; | 657 FX_FLOAT fLeft = rect.left; |
| 653 FX_FLOAT fRight = rect.right; | 658 FX_FLOAT fRight = rect.right; |
| 654 FX_FLOAT fTop = rect.top; | 659 FX_FLOAT fTop = rect.top; |
| 655 FX_FLOAT fBottom = rect.bottom; | 660 FX_FLOAT fBottom = rect.bottom; |
| 656 if (fWidth > 0.0f) { | 661 if (fWidth > 0.0f) { |
| 657 FX_FLOAT fHalfWidth = fWidth / 2.0f; | 662 FX_FLOAT fHalfWidth = fWidth / 2.0f; |
| 658 switch (nStyle) { | 663 switch (nStyle) { |
| 659 default: | 664 default: |
| 660 case BorderStyle::SOLID: | 665 case BorderStyle::SOLID: |
| 661 sColor = GenerateColorAP(color, TRUE); | 666 sColor = GenerateColorAP(color, false); |
| 662 if (sColor.GetLength() > 0) { | 667 if (sColor.GetLength() > 0) { |
| 663 sAppStream << sColor; | 668 sAppStream << sColor; |
| 664 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " | 669 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " |
| 665 << fTop - fBottom << " re\n"; | 670 << fTop - fBottom << " re\n"; |
| 666 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " | 671 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " " |
| 667 << fRight - fLeft - fWidth * 2 << " " | 672 << fRight - fLeft - fWidth * 2 << " " |
| 668 << fTop - fBottom - fWidth * 2 << " re\n"; | 673 << fTop - fBottom - fWidth * 2 << " re\n"; |
| 669 sAppStream << "f*\n"; | 674 sAppStream << "f*\n"; |
| 670 } | 675 } |
| 671 break; | 676 break; |
| 672 case BorderStyle::DASH: | 677 case BorderStyle::DASH: |
| 673 sColor = GenerateColorAP(color, FALSE); | 678 sColor = GenerateColorAP(color, true); |
| 674 if (sColor.GetLength() > 0) { | 679 if (sColor.GetLength() > 0) { |
| 675 sAppStream << sColor; | 680 sAppStream << sColor; |
| 676 sAppStream << fWidth << " w" | 681 sAppStream << fWidth << " w" |
| 677 << " [" << dash.nDash << " " << dash.nGap << "] " | 682 << " [" << dash.nDash << " " << dash.nGap << "] " |
| 678 << dash.nPhase << " d\n"; | 683 << dash.nPhase << " d\n"; |
| 679 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 | 684 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 |
| 680 << " m\n"; | 685 << " m\n"; |
| 681 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 | 686 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 |
| 682 << " l\n"; | 687 << " l\n"; |
| 683 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 | 688 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 |
| 684 << " l\n"; | 689 << " l\n"; |
| 685 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 | 690 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 |
| 686 << " l\n"; | 691 << " l\n"; |
| 687 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 | 692 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 |
| 688 << " l S\n"; | 693 << " l S\n"; |
| 689 } | 694 } |
| 690 break; | 695 break; |
| 691 case BorderStyle::BEVELED: | 696 case BorderStyle::BEVELED: |
| 692 case BorderStyle::INSET: | 697 case BorderStyle::INSET: |
| 693 sColor = GenerateColorAP(crLeftTop, TRUE); | 698 sColor = GenerateColorAP(crLeftTop, false); |
| 694 if (sColor.GetLength() > 0) { | 699 if (sColor.GetLength() > 0) { |
| 695 sAppStream << sColor; | 700 sAppStream << sColor; |
| 696 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth | 701 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth |
| 697 << " m\n"; | 702 << " m\n"; |
| 698 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth | 703 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth |
| 699 << " l\n"; | 704 << " l\n"; |
| 700 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth | 705 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth |
| 701 << " l\n"; | 706 << " l\n"; |
| 702 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 707 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
| 703 << " l\n"; | 708 << " l\n"; |
| 704 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 709 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
| 705 << " l\n"; | 710 << " l\n"; |
| 706 sAppStream << fLeft + fHalfWidth * 2 << " " | 711 sAppStream << fLeft + fHalfWidth * 2 << " " |
| 707 << fBottom + fHalfWidth * 2 << " l f\n"; | 712 << fBottom + fHalfWidth * 2 << " l f\n"; |
| 708 } | 713 } |
| 709 sColor = GenerateColorAP(crRightBottom, TRUE); | 714 sColor = GenerateColorAP(crRightBottom, false); |
| 710 if (sColor.GetLength() > 0) { | 715 if (sColor.GetLength() > 0) { |
| 711 sAppStream << sColor; | 716 sAppStream << sColor; |
| 712 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth | 717 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth |
| 713 << " m\n"; | 718 << " m\n"; |
| 714 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth | 719 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth |
| 715 << " l\n"; | 720 << " l\n"; |
| 716 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth | 721 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth |
| 717 << " l\n"; | 722 << " l\n"; |
| 718 sAppStream << fLeft + fHalfWidth * 2 << " " | 723 sAppStream << fLeft + fHalfWidth * 2 << " " |
| 719 << fBottom + fHalfWidth * 2 << " l\n"; | 724 << fBottom + fHalfWidth * 2 << " l\n"; |
| 720 sAppStream << fRight - fHalfWidth * 2 << " " | 725 sAppStream << fRight - fHalfWidth * 2 << " " |
| 721 << fBottom + fHalfWidth * 2 << " l\n"; | 726 << fBottom + fHalfWidth * 2 << " l\n"; |
| 722 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 | 727 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 |
| 723 << " l f\n"; | 728 << " l f\n"; |
| 724 } | 729 } |
| 725 sColor = GenerateColorAP(color, TRUE); | 730 sColor = GenerateColorAP(color, false); |
| 726 if (sColor.GetLength() > 0) { | 731 if (sColor.GetLength() > 0) { |
| 727 sAppStream << sColor; | 732 sAppStream << sColor; |
| 728 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " | 733 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " |
| 729 << fTop - fBottom << " re\n"; | 734 << fTop - fBottom << " re\n"; |
| 730 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " " | 735 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " " |
| 731 << fRight - fLeft - fHalfWidth * 2 << " " | 736 << fRight - fLeft - fHalfWidth * 2 << " " |
| 732 << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; | 737 << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; |
| 733 } | 738 } |
| 734 break; | 739 break; |
| 735 case BorderStyle::UNDERLINE: | 740 case BorderStyle::UNDERLINE: |
| 736 sColor = GenerateColorAP(color, FALSE); | 741 sColor = GenerateColorAP(color, true); |
| 737 if (sColor.GetLength() > 0) { | 742 if (sColor.GetLength() > 0) { |
| 738 sAppStream << sColor; | 743 sAppStream << sColor; |
| 739 sAppStream << fWidth << " w\n"; | 744 sAppStream << fWidth << " w\n"; |
| 740 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; | 745 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n"; |
| 741 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; | 746 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n"; |
| 742 } | 747 } |
| 743 break; | 748 break; |
| 744 } | 749 } |
| 745 } | 750 } |
| 746 return sAppStream.MakeString(); | 751 return sAppStream.MakeString(); |
| 747 } | 752 } |
| 748 | 753 |
| 749 // Static. | 754 // Static. |
| 750 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, | 755 CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color& color, |
| 751 const FX_BOOL& bFillOrStroke) { | 756 bool bIsStroke) { |
|
Lei Zhang
2016/08/01 19:33:48
Consider making this an enum, then you can write:
jaepark
2016/08/02 18:15:47
Done.
| |
| 752 CFX_ByteTextBuf sColorStream; | 757 CFX_ByteTextBuf sColorStream; |
| 753 switch (color.nColorType) { | 758 switch (color.nColorType) { |
| 754 case CPVT_Color::kRGB: | 759 case CPVT_Color::kRGB: |
| 755 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 760 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 756 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG") | 761 << color.fColor3 << " " << (bIsStroke ? "RG" : "rg") << "\n"; |
| 757 << "\n"; | |
| 758 break; | 762 break; |
| 759 case CPVT_Color::kGray: | 763 case CPVT_Color::kGray: |
| 760 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") | 764 sColorStream << color.fColor1 << " " << (bIsStroke ? "G" : "g") << "\n"; |
| 761 << "\n"; | |
| 762 break; | 765 break; |
| 763 case CPVT_Color::kCMYK: | 766 case CPVT_Color::kCMYK: |
| 764 sColorStream << color.fColor1 << " " << color.fColor2 << " " | 767 sColorStream << color.fColor1 << " " << color.fColor2 << " " |
| 765 << color.fColor3 << " " << color.fColor4 << " " | 768 << color.fColor3 << " " << color.fColor4 << " " |
| 766 << (bFillOrStroke ? "k" : "K") << "\n"; | 769 << (bIsStroke ? "K" : "k") << "\n"; |
| 767 break; | 770 break; |
| 768 case CPVT_Color::kTransparent: | 771 case CPVT_Color::kTransparent: |
| 769 break; | 772 break; |
| 770 } | 773 } |
| 771 return sColorStream.MakeString(); | 774 return sColorStream.MakeString(); |
| 772 } | 775 } |
| 773 | 776 |
| 774 // Static. | 777 // Static. |
| 775 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, | 778 CFX_ByteString CPVT_GenerateAP::GetPDFWordString(IPVT_FontMap* pFontMap, |
| 776 int32_t nFontIndex, | 779 int32_t nFontIndex, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 int32_t nFontIndex, | 814 int32_t nFontIndex, |
| 812 FX_FLOAT fFontSize) { | 815 FX_FLOAT fFontSize) { |
| 813 CFX_ByteTextBuf sRet; | 816 CFX_ByteTextBuf sRet; |
| 814 if (pFontMap) { | 817 if (pFontMap) { |
| 815 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 818 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
| 816 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 819 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
| 817 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 820 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
| 818 } | 821 } |
| 819 return sRet.MakeString(); | 822 return sRet.MakeString(); |
| 820 } | 823 } |
| OLD | NEW |