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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 sAppStream << fLineWidth << " w " << rect.left << " " | 612 sAppStream << fLineWidth << " w " << rect.left << " " |
613 << rect.bottom + fLineWidth << " m " << rect.right << " " | 613 << rect.bottom + fLineWidth << " m " << rect.right << " " |
614 << rect.bottom + fLineWidth << " l S\n"; | 614 << rect.bottom + fLineWidth << " l S\n"; |
615 | 615 |
616 CPDF_Dictionary* pExtGStateDict = | 616 CPDF_Dictionary* pExtGStateDict = |
617 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | 617 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
618 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); | 618 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); |
619 return true; | 619 return true; |
620 } | 620 } |
621 | 621 |
| 622 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, |
| 623 CPDF_Dictionary* pAnnotDict) { |
| 624 // If AP dictionary exists, we use the appearance defined in the |
| 625 // existing AP dictionary. |
| 626 if (pAnnotDict->KeyExist("AP")) |
| 627 return false; |
| 628 |
| 629 CFX_ByteTextBuf sAppStream; |
| 630 CFX_ByteString sExtGSDictName = "GS"; |
| 631 sAppStream << "/" << sExtGSDictName << " gs "; |
| 632 |
| 633 sAppStream << GetColorStringWithDefault(pAnnotDict, |
| 634 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), |
| 635 PaintOperation::STROKE); |
| 636 |
| 637 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); |
| 638 rect.Normalize(); |
| 639 |
| 640 FX_FLOAT fLineWidth = 1.0; |
| 641 sAppStream << fLineWidth << " w "; |
| 642 |
| 643 const FX_FLOAT fDelta = 2.0; |
| 644 const FX_FLOAT fTop = rect.bottom + fDelta; |
| 645 const FX_FLOAT fBottom = rect.bottom; |
| 646 |
| 647 sAppStream << rect.left << " " << fTop << " m "; |
| 648 |
| 649 FX_FLOAT fX = rect.left + fDelta; |
| 650 bool isUpwards = false; |
| 651 |
| 652 while (fX < rect.right) { |
| 653 sAppStream << fX << " " << (isUpwards ? fTop : fBottom) << " l "; |
| 654 |
| 655 fX += fDelta; |
| 656 isUpwards = !isUpwards; |
| 657 } |
| 658 |
| 659 FX_FLOAT fRemainder = rect.right - (fX - fDelta); |
| 660 if (isUpwards) |
| 661 sAppStream << rect.right << " " << fBottom + fRemainder << " l "; |
| 662 else |
| 663 sAppStream << rect.right << " " << fTop - fRemainder << " l "; |
| 664 |
| 665 sAppStream << "S\n"; |
| 666 |
| 667 CPDF_Dictionary* pExtGStateDict = |
| 668 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
| 669 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); |
| 670 return true; |
| 671 } |
| 672 |
622 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, | 673 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, |
623 CPDF_Dictionary* pAnnotDict) { | 674 CPDF_Dictionary* pAnnotDict) { |
624 // If AP dictionary exists, we use the appearance defined in the | 675 // If AP dictionary exists, we use the appearance defined in the |
625 // existing AP dictionary. | 676 // existing AP dictionary. |
626 if (pAnnotDict->KeyExist("AP")) | 677 if (pAnnotDict->KeyExist("AP")) |
627 return false; | 678 return false; |
628 | 679 |
629 CFX_ByteTextBuf sAppStream; | 680 CFX_ByteTextBuf sAppStream; |
630 CFX_ByteString sExtGSDictName = "GS"; | 681 CFX_ByteString sExtGSDictName = "GS"; |
631 sAppStream << "/" << sExtGSDictName << " gs "; | 682 sAppStream << "/" << sExtGSDictName << " gs "; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 int32_t nFontIndex, | 960 int32_t nFontIndex, |
910 FX_FLOAT fFontSize) { | 961 FX_FLOAT fFontSize) { |
911 CFX_ByteTextBuf sRet; | 962 CFX_ByteTextBuf sRet; |
912 if (pFontMap) { | 963 if (pFontMap) { |
913 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 964 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
914 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 965 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
915 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 966 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
916 } | 967 } |
917 return sRet.MakeString(); | 968 return sRet.MakeString(); |
918 } | 969 } |
OLD | NEW |