Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: core/fpdfdoc/cpvt_generateap.cpp

Issue 2273893002: Display content of the annotation when mouse hover. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Display content of the annotation when mouse hover. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/cpvt_generateap.h ('k') | core/fpdfdoc/include/cpdf_annot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 CFX_ByteTextBuf sDashStream; 502 CFX_ByteTextBuf sDashStream;
503 503
504 sDashStream << "["; 504 sDashStream << "[";
505 for (size_t i = 0; i < pDashArrayCount; ++i) 505 for (size_t i = 0; i < pDashArrayCount; ++i)
506 sDashStream << pDashArray->GetNumberAt(i) << " "; 506 sDashStream << pDashArray->GetNumberAt(i) << " ";
507 sDashStream << "] 0 d\n"; 507 sDashStream << "] 0 d\n";
508 508
509 return sDashStream.MakeString(); 509 return sDashStream.MakeString();
510 } 510 }
511 511
512 CFX_ByteString GetPopupContentsString(CPDF_Document* pDoc,
513 const CPDF_Dictionary& pAnnotDict,
514 CPDF_Font* pDefFont,
515 const CFX_ByteString& sFontName) {
516 CFX_WideString swValue(pAnnotDict.GetUnicodeTextBy("T"));
517 swValue += L'\n';
518 swValue += pAnnotDict.GetUnicodeTextBy("Contents");
519 CPVT_FontMap map(pDoc, nullptr, pDefFont, sFontName);
520
521 CPDF_VariableText::Provider prd(&map);
522 CPDF_VariableText vt;
523 vt.SetProvider(&prd);
524 vt.SetPlateRect(pAnnotDict.GetRectBy("Rect"));
525 vt.SetFontSize(12);
526 vt.SetAutoReturn(TRUE);
527 vt.SetMultiLine(TRUE);
528
529 vt.Initialize();
530 vt.SetText(swValue.c_str());
531 vt.RearrangeAll();
532 CFX_FloatPoint ptOffset(3.0f, -3.0f);
533 CFX_ByteString sContent = CPVT_GenerateAP::GenerateEditAP(
534 &map, vt.GetIterator(), ptOffset, FALSE, 0);
535
536 if (sContent.IsEmpty())
537 return CFX_ByteString();
538
539 CFX_ByteTextBuf sAppStream;
540 sAppStream << "BT\n"
541 << CPVT_GenerateAP::GenerateColorAP(
542 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::FILL)
543 << sContent << "ET\n"
544 << "Q\n";
545 return sAppStream.MakeString();
546 }
547
512 CPDF_Dictionary* GenerateExtGStateDict(const CPDF_Dictionary& pAnnotDict, 548 CPDF_Dictionary* GenerateExtGStateDict(const CPDF_Dictionary& pAnnotDict,
513 const CFX_ByteString& sExtGSDictName, 549 const CFX_ByteString& sExtGSDictName,
514 const CFX_ByteString& sBlendMode) { 550 const CFX_ByteString& sBlendMode) {
515 CPDF_Dictionary* pGSDict = new CPDF_Dictionary; 551 CPDF_Dictionary* pGSDict = new CPDF_Dictionary;
516 pGSDict->SetAtString("Type", "ExtGState"); 552 pGSDict->SetAtString("Type", "ExtGState");
517 553
518 FX_FLOAT fOpacity = 554 FX_FLOAT fOpacity =
519 pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberBy("CA") : 1; 555 pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberBy("CA") : 1;
520 pGSDict->SetAtNumber("CA", fOpacity); 556 pGSDict->SetAtNumber("CA", fOpacity);
521 pGSDict->SetAtNumber("ca", fOpacity); 557 pGSDict->SetAtNumber("ca", fOpacity);
522 pGSDict->SetAtBoolean("AIS", false); 558 pGSDict->SetAtBoolean("AIS", false);
523 pGSDict->SetAtString("BM", sBlendMode); 559 pGSDict->SetAtString("BM", sBlendMode);
524 560
525 CPDF_Dictionary* pExtGStateDict = new CPDF_Dictionary; 561 CPDF_Dictionary* pExtGStateDict = new CPDF_Dictionary;
526 pExtGStateDict->SetAt(sExtGSDictName, pGSDict); 562 pExtGStateDict->SetAt(sExtGSDictName, pGSDict);
527 563
528 return pExtGStateDict; 564 return pExtGStateDict;
529 } 565 }
530 566
531 // Takes ownership of |pExtGStateDict|. 567 CPDF_Dictionary* GenerateResourceFontDict(CPDF_Document* pDoc,
568 const CFX_ByteString& sFontDictName) {
569 CPDF_Dictionary* pFontDict = new CPDF_Dictionary;
570 pFontDict->SetAtName("Type", "Font");
571 pFontDict->SetAtName("Subtype", "Type1");
572 pFontDict->SetAtName("BaseFont", "Helvetica");
573 pFontDict->SetAtName("Encoding", "WinAnsiEncoding");
574 pDoc->AddIndirectObject(pFontDict);
575
576 CPDF_Dictionary* pResourceFontDict = new CPDF_Dictionary;
577 pResourceFontDict->SetAtReference(sFontDictName, pDoc, pFontDict);
578
579 return pResourceFontDict;
580 }
581
582 // Takes ownership of |pExtGStateDict| and |pResourceFontDict|.
583 CPDF_Dictionary* GenerateResourceDict(CPDF_Dictionary* pExtGStateDict,
584 CPDF_Dictionary* pResourceFontDict) {
585 CPDF_Dictionary* pResourceDict = new CPDF_Dictionary;
586 if (pExtGStateDict)
587 pResourceDict->SetAt("ExtGState", pExtGStateDict);
588
589 if (pResourceFontDict)
590 pResourceDict->SetAt("Font", pResourceFontDict);
591
592 return pResourceDict;
593 }
594
595 // Takes ownership of |pResourceDict|.
532 void GenerateAndSetAPDict(CPDF_Document* pDoc, 596 void GenerateAndSetAPDict(CPDF_Document* pDoc,
533 CPDF_Dictionary* pAnnotDict, 597 CPDF_Dictionary* pAnnotDict,
534 const CFX_ByteTextBuf& sAppStream, 598 const CFX_ByteTextBuf& sAppStream,
535 CPDF_Dictionary* pExtGStateDict) { 599 CPDF_Dictionary* pResourceDict) {
536 CPDF_Dictionary* pAPDict = new CPDF_Dictionary; 600 CPDF_Dictionary* pAPDict = new CPDF_Dictionary;
537 pAnnotDict->SetAt("AP", pAPDict); 601 pAnnotDict->SetAt("AP", pAPDict);
538 602
539 CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr); 603 CPDF_Stream* pNormalStream = new CPDF_Stream(nullptr, 0, nullptr);
540 int32_t objnum = pDoc->AddIndirectObject(pNormalStream); 604 int32_t objnum = pDoc->AddIndirectObject(pNormalStream);
541 pAnnotDict->GetDictBy("AP")->SetAtReference("N", pDoc, objnum); 605 pAnnotDict->GetDictBy("AP")->SetAtReference("N", pDoc, objnum);
542 606
543 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE, 607 pNormalStream->SetData(sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE,
544 FALSE); 608 FALSE);
545 609
546 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); 610 CPDF_Dictionary* pStreamDict = pNormalStream->GetDict();
547 pStreamDict->SetAtInteger("FormType", 1); 611 pStreamDict->SetAtInteger("FormType", 1);
548 pStreamDict->SetAtString("Subtype", "Form"); 612 pStreamDict->SetAtString("Subtype", "Form");
549 pStreamDict->SetAtMatrix("Matrix", CFX_Matrix()); 613 pStreamDict->SetAtMatrix("Matrix", CFX_Matrix());
550 614
551 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 615 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
552 pStreamDict->SetAtRect("BBox", rect); 616 pStreamDict->SetAtRect("BBox", rect);
553 617
554 CPDF_Dictionary* pResourceDict = new CPDF_Dictionary;
555 pResourceDict->SetAt("ExtGState", pExtGStateDict);
556
557 pStreamDict->SetAt("Resources", pResourceDict); 618 pStreamDict->SetAt("Resources", pResourceDict);
558 } 619 }
559 620
560 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) { 621 CFX_ByteString GetPaintOperatorString(bool bIsStrokeRect, bool bIsFillRect) {
561 if (bIsStrokeRect) 622 if (bIsStrokeRect)
562 return bIsFillRect ? "b" : "s"; 623 return bIsFillRect ? "b" : "s";
563 return bIsFillRect ? "f" : "n"; 624 return bIsFillRect ? "f" : "n";
564 } 625 }
565 626
566 CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { 627 CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // Fourth Bezier Curve 796 // Fourth Bezier Curve
736 sAppStream << rect.left << " " << fMiddleY + fDeltaY << " " 797 sAppStream << rect.left << " " << fMiddleY + fDeltaY << " "
737 << fMiddleX - fDeltaX << " " << rect.top << " " << fMiddleX << " " 798 << fMiddleX - fDeltaX << " " << rect.top << " " << fMiddleX << " "
738 << rect.top << " c\n"; 799 << rect.top << " c\n";
739 800
740 bool bIsFillRect = pInteriorColor && !pInteriorColor->IsEmpty(); 801 bool bIsFillRect = pInteriorColor && !pInteriorColor->IsEmpty();
741 sAppStream << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; 802 sAppStream << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n";
742 803
743 CPDF_Dictionary* pExtGStateDict = 804 CPDF_Dictionary* pExtGStateDict =
744 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 805 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
745 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 806 CPDF_Dictionary* pResourceDict =
807 GenerateResourceDict(pExtGStateDict, nullptr);
808 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
746 return true; 809 return true;
747 } 810 }
748 811
749 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, 812 bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc,
750 CPDF_Dictionary* pAnnotDict) { 813 CPDF_Dictionary* pAnnotDict) {
751 if (!ShouldGenerateAPForAnnotation(pAnnotDict)) 814 if (!ShouldGenerateAPForAnnotation(pAnnotDict))
752 return false; 815 return false;
753 816
754 CFX_ByteTextBuf sAppStream; 817 CFX_ByteTextBuf sAppStream;
755 CFX_ByteString sExtGSDictName = "GS"; 818 CFX_ByteString sExtGSDictName = "GS";
756 sAppStream << "/" << sExtGSDictName << " gs "; 819 sAppStream << "/" << sExtGSDictName << " gs ";
757 820
758 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 821 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
759 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0), 822 CPVT_Color(CPVT_Color::kRGB, 1, 1, 0),
760 PaintOperation::FILL); 823 PaintOperation::FILL);
761 824
762 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 825 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
763 rect.Normalize(); 826 rect.Normalize();
764 827
765 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " " 828 sAppStream << rect.left << " " << rect.top << " m " << rect.right << " "
766 << rect.top << " l " << rect.right << " " << rect.bottom << " l " 829 << rect.top << " l " << rect.right << " " << rect.bottom << " l "
767 << rect.left << " " << rect.bottom << " l " 830 << rect.left << " " << rect.bottom << " l "
768 << "h f\n"; 831 << "h f\n";
769 832
770 CPDF_Dictionary* pExtGStateDict = 833 CPDF_Dictionary* pExtGStateDict =
771 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Multiply"); 834 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Multiply");
772 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 835 CPDF_Dictionary* pResourceDict =
836 GenerateResourceDict(pExtGStateDict, nullptr);
837 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
773 838
774 return true; 839 return true;
775 } 840 }
776 841
777 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, 842 bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc,
778 CPDF_Dictionary* pAnnotDict) { 843 CPDF_Dictionary* pAnnotDict) {
779 if (!ShouldGenerateAPForAnnotation(pAnnotDict)) 844 if (!ShouldGenerateAPForAnnotation(pAnnotDict))
780 return false; 845 return false;
781 846
782 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); 847 FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 for (size_t j = 0; j < pInkCoordList->GetCount() - 1; j += 2) { 882 for (size_t j = 0; j < pInkCoordList->GetCount() - 1; j += 2) {
818 sAppStream << pInkCoordList->GetNumberAt(j) << " " 883 sAppStream << pInkCoordList->GetNumberAt(j) << " "
819 << pInkCoordList->GetNumberAt(j + 1) << " l "; 884 << pInkCoordList->GetNumberAt(j + 1) << " l ";
820 } 885 }
821 886
822 sAppStream << "S\n"; 887 sAppStream << "S\n";
823 } 888 }
824 889
825 CPDF_Dictionary* pExtGStateDict = 890 CPDF_Dictionary* pExtGStateDict =
826 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 891 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
827 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 892 CPDF_Dictionary* pResourceDict =
893 GenerateResourceDict(pExtGStateDict, nullptr);
894 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
828 return true; 895 return true;
829 } 896 }
830 897
831 bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, 898 bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc,
832 CPDF_Dictionary* pAnnotDict) { 899 CPDF_Dictionary* pAnnotDict) {
833 if (!ShouldGenerateAPForAnnotation(pAnnotDict)) 900 if (!ShouldGenerateAPForAnnotation(pAnnotDict))
834 return false; 901 return false;
835 902
836 CFX_ByteTextBuf sAppStream; 903 CFX_ByteTextBuf sAppStream;
837 CFX_ByteString sExtGSDictName = "GS"; 904 CFX_ByteString sExtGSDictName = "GS";
838 sAppStream << "/" << sExtGSDictName << " gs "; 905 sAppStream << "/" << sExtGSDictName << " gs ";
839 906
840 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 907 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
841 const FX_FLOAT fNoteLength = 20; 908 const FX_FLOAT fNoteLength = 20;
842 CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength, 909 CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength,
843 rect.bottom + fNoteLength); 910 rect.bottom + fNoteLength);
844 pAnnotDict->SetAtRect("Rect", noteRect); 911 pAnnotDict->SetAtRect("Rect", noteRect);
845 912
846 sAppStream << GenerateTextSymbolAP(noteRect); 913 sAppStream << GenerateTextSymbolAP(noteRect);
847 914
848 CPDF_Dictionary* pExtGStateDict = 915 CPDF_Dictionary* pExtGStateDict =
849 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 916 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
850 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 917 CPDF_Dictionary* pResourceDict =
851 918 GenerateResourceDict(pExtGStateDict, nullptr);
919 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
852 return true; 920 return true;
853 } 921 }
854 922
855 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, 923 bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc,
856 CPDF_Dictionary* pAnnotDict) { 924 CPDF_Dictionary* pAnnotDict) {
857 if (!ShouldGenerateAPForAnnotation(pAnnotDict)) 925 if (!ShouldGenerateAPForAnnotation(pAnnotDict))
858 return false; 926 return false;
859 927
860 CFX_ByteTextBuf sAppStream; 928 CFX_ByteTextBuf sAppStream;
861 CFX_ByteString sExtGSDictName = "GS"; 929 CFX_ByteString sExtGSDictName = "GS";
862 sAppStream << "/" << sExtGSDictName << " gs "; 930 sAppStream << "/" << sExtGSDictName << " gs ";
863 931
864 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 932 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
865 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 933 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
866 PaintOperation::STROKE); 934 PaintOperation::STROKE);
867 935
868 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 936 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
869 rect.Normalize(); 937 rect.Normalize();
870 938
871 FX_FLOAT fLineWidth = 1.0; 939 FX_FLOAT fLineWidth = 1.0;
872 sAppStream << fLineWidth << " w " << rect.left << " " 940 sAppStream << fLineWidth << " w " << rect.left << " "
873 << rect.bottom + fLineWidth << " m " << rect.right << " " 941 << rect.bottom + fLineWidth << " m " << rect.right << " "
874 << rect.bottom + fLineWidth << " l S\n"; 942 << rect.bottom + fLineWidth << " l S\n";
875 943
876 CPDF_Dictionary* pExtGStateDict = 944 CPDF_Dictionary* pExtGStateDict =
877 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 945 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
878 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 946 CPDF_Dictionary* pResourceDict =
947 GenerateResourceDict(pExtGStateDict, nullptr);
948 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
879 return true; 949 return true;
880 } 950 }
881 951
952 bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc,
953 CPDF_Dictionary* pAnnotDict) {
954 CFX_ByteTextBuf sAppStream;
955 CFX_ByteString sExtGSDictName = "GS";
956 sAppStream << "/" << sExtGSDictName << " gs\n";
957
958 sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 1, 1, 0),
959 PaintOperation::FILL);
960 sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
961 PaintOperation::STROKE);
962
963 FX_FLOAT fBorderWidth = 1;
Lei Zhang 2016/08/29 22:41:28 const?
jaepark 2016/08/29 23:59:37 Done.
964 sAppStream << fBorderWidth << " w\n";
965
966 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
967 rect.Normalize();
968 rect.Deflate(fBorderWidth / 2, fBorderWidth / 2);
969
970 sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " "
971 << rect.Height() << " re b\n";
972
973 CFX_ByteString sFontName = "FONT";
974 CPDF_Dictionary* pExtGStateDict =
975 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
976 CPDF_Dictionary* pResourceFontDict =
977 GenerateResourceFontDict(pDoc, sFontName);
978 CPDF_Dictionary* pResourceDict =
979 GenerateResourceDict(pResourceFontDict, pExtGStateDict);
980
981 CPDF_Font* pDefFont = pDoc->LoadFont(pResourceFontDict);
982 if (!pDefFont)
983 return false;
984
985 sAppStream << GetPopupContentsString(pDoc, *pAnnotDict, pDefFont, sFontName);
986 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
987 return true;
988 }
989
882 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, 990 bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc,
883 CPDF_Dictionary* pAnnotDict) { 991 CPDF_Dictionary* pAnnotDict) {
884 if (!ShouldGenerateAPForAnnotation(pAnnotDict)) 992 if (!ShouldGenerateAPForAnnotation(pAnnotDict))
885 return false; 993 return false;
886 994
887 CFX_ByteTextBuf sAppStream; 995 CFX_ByteTextBuf sAppStream;
888 CFX_ByteString sExtGSDictName = "GS"; 996 CFX_ByteString sExtGSDictName = "GS";
889 sAppStream << "/" << sExtGSDictName << " gs "; 997 sAppStream << "/" << sExtGSDictName << " gs ";
890 998
891 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC"); 999 CPDF_Array* pInteriorColor = pAnnotDict->GetArrayBy("IC");
(...skipping 24 matching lines...) Expand all
916 } 1024 }
917 1025
918 bool bIsFillRect = pInteriorColor && (pInteriorColor->GetCount() > 0); 1026 bool bIsFillRect = pInteriorColor && (pInteriorColor->GetCount() > 0);
919 1027
920 sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " " 1028 sAppStream << rect.left << " " << rect.bottom << " " << rect.Width() << " "
921 << rect.Height() << " re " 1029 << rect.Height() << " re "
922 << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n"; 1030 << GetPaintOperatorString(bIsStrokeRect, bIsFillRect) << "\n";
923 1031
924 CPDF_Dictionary* pExtGStateDict = 1032 CPDF_Dictionary* pExtGStateDict =
925 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 1033 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
926 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 1034 CPDF_Dictionary* pResourceDict =
1035 GenerateResourceDict(pExtGStateDict, nullptr);
1036 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
927 return true; 1037 return true;
928 } 1038 }
929 1039
930 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, 1040 bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc,
931 CPDF_Dictionary* pAnnotDict) { 1041 CPDF_Dictionary* pAnnotDict) {
932 if (!ShouldGenerateAPForAnnotation(pAnnotDict)) 1042 if (!ShouldGenerateAPForAnnotation(pAnnotDict))
933 return false; 1043 return false;
934 1044
935 CFX_ByteTextBuf sAppStream; 1045 CFX_ByteTextBuf sAppStream;
936 CFX_ByteString sExtGSDictName = "GS"; 1046 CFX_ByteString sExtGSDictName = "GS";
(...skipping 28 matching lines...) Expand all
965 FX_FLOAT fRemainder = rect.right - (fX - fDelta); 1075 FX_FLOAT fRemainder = rect.right - (fX - fDelta);
966 if (isUpwards) 1076 if (isUpwards)
967 sAppStream << rect.right << " " << fBottom + fRemainder << " l "; 1077 sAppStream << rect.right << " " << fBottom + fRemainder << " l ";
968 else 1078 else
969 sAppStream << rect.right << " " << fTop - fRemainder << " l "; 1079 sAppStream << rect.right << " " << fTop - fRemainder << " l ";
970 1080
971 sAppStream << "S\n"; 1081 sAppStream << "S\n";
972 1082
973 CPDF_Dictionary* pExtGStateDict = 1083 CPDF_Dictionary* pExtGStateDict =
974 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 1084 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
975 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 1085 CPDF_Dictionary* pResourceDict =
1086 GenerateResourceDict(pExtGStateDict, nullptr);
1087 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
976 return true; 1088 return true;
977 } 1089 }
978 1090
979 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, 1091 bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc,
980 CPDF_Dictionary* pAnnotDict) { 1092 CPDF_Dictionary* pAnnotDict) {
981 if (!ShouldGenerateAPForAnnotation(pAnnotDict)) 1093 if (!ShouldGenerateAPForAnnotation(pAnnotDict))
982 return false; 1094 return false;
983 1095
984 CFX_ByteTextBuf sAppStream; 1096 CFX_ByteTextBuf sAppStream;
985 CFX_ByteString sExtGSDictName = "GS"; 1097 CFX_ByteString sExtGSDictName = "GS";
986 sAppStream << "/" << sExtGSDictName << " gs "; 1098 sAppStream << "/" << sExtGSDictName << " gs ";
987 1099
988 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"), 1100 sAppStream << GetColorStringWithDefault(pAnnotDict->GetArrayBy("C"),
989 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), 1101 CPVT_Color(CPVT_Color::kRGB, 0, 0, 0),
990 PaintOperation::STROKE); 1102 PaintOperation::STROKE);
991 1103
992 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect"); 1104 CFX_FloatRect rect = pAnnotDict->GetRectBy("Rect");
993 rect.Normalize(); 1105 rect.Normalize();
994 1106
995 FX_FLOAT fLineWidth = 1.0; 1107 FX_FLOAT fLineWidth = 1.0;
996 FX_FLOAT fY = (rect.top + rect.bottom) / 2; 1108 FX_FLOAT fY = (rect.top + rect.bottom) / 2;
997 sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m " 1109 sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m "
998 << rect.right << " " << fY << " l S\n"; 1110 << rect.right << " " << fY << " l S\n";
999 1111
1000 CPDF_Dictionary* pExtGStateDict = 1112 CPDF_Dictionary* pExtGStateDict =
1001 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal"); 1113 GenerateExtGStateDict(*pAnnotDict, sExtGSDictName, "Normal");
1002 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pExtGStateDict); 1114 CPDF_Dictionary* pResourceDict =
1115 GenerateResourceDict(pExtGStateDict, nullptr);
1116 GenerateAndSetAPDict(pDoc, pAnnotDict, sAppStream, pResourceDict);
1003 return true; 1117 return true;
1004 } 1118 }
1005 1119
1006 // Static. 1120 // Static.
1007 CFX_ByteString CPVT_GenerateAP::GenerateEditAP( 1121 CFX_ByteString CPVT_GenerateAP::GenerateEditAP(
1008 IPVT_FontMap* pFontMap, 1122 IPVT_FontMap* pFontMap,
1009 CPDF_VariableText::Iterator* pIterator, 1123 CPDF_VariableText::Iterator* pIterator,
1010 const CFX_FloatPoint& ptOffset, 1124 const CFX_FloatPoint& ptOffset,
1011 FX_BOOL bContinuous, 1125 FX_BOOL bContinuous,
1012 uint16_t SubWord) { 1126 uint16_t SubWord) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 int32_t nFontIndex, 1378 int32_t nFontIndex,
1265 FX_FLOAT fFontSize) { 1379 FX_FLOAT fFontSize) {
1266 CFX_ByteTextBuf sRet; 1380 CFX_ByteTextBuf sRet;
1267 if (pFontMap) { 1381 if (pFontMap) {
1268 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); 1382 CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
1269 if (sFontAlias.GetLength() > 0 && fFontSize > 0) 1383 if (sFontAlias.GetLength() > 0 && fFontSize > 0)
1270 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n"; 1384 sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
1271 } 1385 }
1272 return sRet.MakeString(); 1386 return sRet.MakeString();
1273 } 1387 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpvt_generateap.h ('k') | core/fpdfdoc/include/cpdf_annot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698