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 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 if (isUpwards) | |
|
Lei Zhang
2016/08/03 19:36:04
Since it fits on 1 line:
sAppStream << fX << " "
jaepark
2016/08/03 21:16:29
Done.
| |
| 654 sAppStream << fX << " " << fTop << " l "; | |
| 655 else | |
| 656 sAppStream << fX << " " << fBottom << " l "; | |
| 657 | |
| 658 fX += fDelta; | |
| 659 isUpwards = !isUpwards; | |
| 660 } | |
| 661 | |
| 662 FX_FLOAT fRemainder = rect.right - (fX - fDelta); | |
| 663 if (isUpwards) | |
| 664 sAppStream << rect.right << " " << fBottom + fRemainder << " l "; | |
| 665 else | |
| 666 sAppStream << rect.right << " " << fTop - fRemainder << " l "; | |
| 667 | |
| 668 sAppStream << "S\n"; | |
| 669 | |
| 670 CPDF_Dictionary* pExtGStateDict = | |
| 671 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); | |
| 672 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); | |
| 673 return true; | |
| 674 } | |
| 675 | |
| 622 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, | 676 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, |
| 623 CPDF_Dictionary* pAnnotDict) { | 677 CPDF_Dictionary* pAnnotDict) { |
| 624 // If AP dictionary exists, we use the appearance defined in the | 678 // If AP dictionary exists, we use the appearance defined in the |
| 625 // existing AP dictionary. | 679 // existing AP dictionary. |
| 626 if (pAnnotDict->KeyExist("AP")) | 680 if (pAnnotDict->KeyExist("AP")) |
| 627 return false; | 681 return false; |
| 628 | 682 |
| 629 CFX_ByteTextBuf sAppStream; | 683 CFX_ByteTextBuf sAppStream; |
| 630 CFX_ByteString sExtGSDictName = "GS"; | 684 CFX_ByteString sExtGSDictName = "GS"; |
| 631 sAppStream << "/" << sExtGSDictName << " gs "; | 685 sAppStream << "/" << sExtGSDictName << " gs "; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 909 int32_t nFontIndex, | 963 int32_t nFontIndex, |
| 910 FX_FLOAT fFontSize) { | 964 FX_FLOAT fFontSize) { |
| 911 CFX_ByteTextBuf sRet; | 965 CFX_ByteTextBuf sRet; |
| 912 if (pFontMap) { | 966 if (pFontMap) { |
| 913 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 967 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
| 914 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 968 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
| 915 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 969 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
| 916 } | 970 } |
| 917 return sRet.MakeString(); | 971 return sRet.MakeString(); |
| 918 } | 972 } |
| OLD | NEW |