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::GenerateStrikeOutAP(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 FX_FLOAT fY = (rect.top + rect.bottom) / 2; |
| 642 sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m " |
| 643 << rect.right << " " << fY << " l S\n"; |
| 644 |
| 645 CPDF_Dictionary* pExtGStateDict = |
| 646 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); |
| 647 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); |
| 648 return true; |
| 649 } |
| 650 |
622 // Static. | 651 // Static. |
623 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( | 652 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( |
624 IPVT_FontMap* pFontMap, | 653 IPVT_FontMap* pFontMap, |
625 CPDF_VariableText::Iterator* pIterator, | 654 CPDF_VariableText::Iterator* pIterator, |
626 const CFX_FloatPoint& ptOffset, | 655 const CFX_FloatPoint& ptOffset, |
627 FX_BOOL bContinuous, | 656 FX_BOOL bContinuous, |
628 uint16_t SubWord) { | 657 uint16_t SubWord) { |
629 CFX_ByteTextBuf sEditStream; | 658 CFX_ByteTextBuf sEditStream; |
630 CFX_ByteTextBuf sLineStream; | 659 CFX_ByteTextBuf sLineStream; |
631 CFX_ByteTextBuf sWords; | 660 CFX_ByteTextBuf sWords; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 int32_t nFontIndex, | 909 int32_t nFontIndex, |
881 FX_FLOAT fFontSize) { | 910 FX_FLOAT fFontSize) { |
882 CFX_ByteTextBuf sRet; | 911 CFX_ByteTextBuf sRet; |
883 if (pFontMap) { | 912 if (pFontMap) { |
884 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); | 913 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); |
885 if (sFontAlias.GetLength() > 0 && fFontSize > 0) | 914 if (sFontAlias.GetLength() > 0 && fFontSize > 0) |
886 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; | 915 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; |
887 } | 916 } |
888 return sRet.MakeString(); | 917 return sRet.MakeString(); |
889 } | 918 } |
OLD | NEW |