diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake
index 46fbe75..48979c6 100644
a
|
b
|
if(ENABLE_POPPLER)
|
131 | 131 | POPPLER_VERSION VERSION_EQUAL "0.29.0") |
132 | 132 | set(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API ON) |
133 | 133 | endif() |
| 134 | if(POPPLER_VERSION VERSION_GREATER "0.58.0" OR |
| 135 | POPPLER_VERSION VERSION_EQUAL "0.58.0") |
| 136 | set(POPPLER_NEW_OBJECT_API ON) |
| 137 | endif() |
134 | 138 | else() |
135 | 139 | set(ENABLE_POPPLER_CAIRO OFF) |
136 | 140 | endif() |
diff --git a/config.h.cmake b/config.h.cmake
index a7ad4b3..60bea0d 100644
a
|
b
|
|
107 | 107 | /* Use color space API from Poppler >= 0.29.0 */ |
108 | 108 | #cmakedefine POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API 1 |
109 | 109 | |
| 110 | /* Use object API from Poppler >= 0.58.0 */ |
| 111 | #cmakedefine POPPLER_NEW_OBJECT_API 1 |
| 112 | |
110 | 113 | /* Define to 1 if you have the `pow' function. */ |
111 | 114 | #cmakedefine HAVE_POW 1 |
112 | 115 | |
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 844d16c..6e0ee75 100644
a
|
b
|
PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
|
846 | 846 | } |
847 | 847 | |
848 | 848 | // Parse the document structure |
| 849 | #if defined(POPPLER_NEW_OBJECT_API) |
| 850 | Object obj = page->getContents(); |
| 851 | #else |
849 | 852 | Object obj; |
850 | 853 | page->getContents(&obj); |
| 854 | #endif |
851 | 855 | if (!obj.isNull()) { |
852 | 856 | pdf_parser->parse(&obj); |
853 | 857 | } |
854 | 858 | |
855 | 859 | // Cleanup |
| 860 | #if !defined(POPPLER_NEW_OBJECT_API) |
856 | 861 | obj.free(); |
| 862 | #endif |
857 | 863 | delete pdf_parser; |
858 | 864 | delete builder; |
859 | 865 | g_free(docname); |
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index 5ede59b..604b7f8 100644
a
|
b
|
void PdfParser::parse(Object *obj, GBool topLevel) {
|
414 | 414 | |
415 | 415 | if (obj->isArray()) { |
416 | 416 | for (int i = 0; i < obj->arrayGetLength(); ++i) { |
| 417 | #if defined(POPPLER_NEW_OBJECT_API) |
| 418 | obj2 = obj->arrayGet(i); |
| 419 | #else |
417 | 420 | obj->arrayGet(i, &obj2); |
| 421 | #endif |
418 | 422 | if (!obj2.isStream()) { |
419 | 423 | error(errInternal, -1, "Weird page contents"); |
| 424 | #if !defined(POPPLER_NEW_OBJECT_API) |
420 | 425 | obj2.free(); |
| 426 | #endif |
421 | 427 | return; |
422 | 428 | } |
| 429 | #if !defined(POPPLER_NEW_OBJECT_API) |
423 | 430 | obj2.free(); |
| 431 | #endif |
424 | 432 | } |
425 | 433 | } else if (!obj->isStream()) { |
426 | 434 | error(errInternal, -1, "Weird page contents"); |
… |
… |
void PdfParser::go(GBool /*topLevel*/)
|
439 | 447 | |
440 | 448 | // scan a sequence of objects |
441 | 449 | int numArgs = 0; |
| 450 | #if defined(POPPLER_NEW_OBJECT_API) |
| 451 | obj = parser->getObj(); |
| 452 | #else |
442 | 453 | parser->getObj(&obj); |
| 454 | #endif |
443 | 455 | while (!obj.isEOF()) { |
444 | 456 | |
445 | 457 | // got a command - execute it |
… |
… |
void PdfParser::go(GBool /*topLevel*/)
|
457 | 469 | // Run the operation |
458 | 470 | execOp(&obj, args, numArgs); |
459 | 471 | |
| 472 | #if !defined(POPPLER_NEW_OBJECT_API) |
460 | 473 | obj.free(); |
461 | 474 | for (int i = 0; i < numArgs; ++i) |
462 | 475 | args[i].free(); |
| 476 | #endif |
463 | 477 | numArgs = 0; |
464 | 478 | |
465 | 479 | // got an argument - save it |
466 | 480 | } else if (numArgs < maxArgs) { |
| 481 | #if defined(POPPLER_NEW_OBJECT_API) |
| 482 | args[numArgs++] = std::move(obj); |
| 483 | #else |
467 | 484 | args[numArgs++] = obj; |
| 485 | #endif |
468 | 486 | |
469 | 487 | // too many arguments - something is wrong |
470 | 488 | } else { |
… |
… |
void PdfParser::go(GBool /*topLevel*/)
|
475 | 493 | printf("\n"); |
476 | 494 | fflush(stdout); |
477 | 495 | } |
| 496 | #if !defined(POPPLER_NEW_OBJECT_API) |
478 | 497 | obj.free(); |
| 498 | #endif |
479 | 499 | } |
480 | 500 | |
481 | 501 | // grab the next object |
| 502 | #if defined(POPPLER_NEW_OBJECT_API) |
| 503 | obj = parser->getObj(); |
| 504 | #else |
482 | 505 | parser->getObj(&obj); |
| 506 | #endif |
483 | 507 | } |
| 508 | #if !defined(POPPLER_NEW_OBJECT_API) |
484 | 509 | obj.free(); |
| 510 | #endif |
485 | 511 | |
486 | 512 | // args at end with no command |
487 | 513 | if (numArgs > 0) { |
… |
… |
void PdfParser::go(GBool /*topLevel*/)
|
495 | 521 | printf("\n"); |
496 | 522 | fflush(stdout); |
497 | 523 | } |
| 524 | #if !defined(POPPLER_NEW_OBJECT_API) |
498 | 525 | for (int i = 0; i < numArgs; ++i) |
499 | 526 | args[i].free(); |
| 527 | #endif |
500 | 528 | } |
501 | 529 | } |
502 | 530 | |
… |
… |
void PdfParser::opSetDash(Object args[], int /*numArgs*/)
|
692 | 720 | if (length != 0) { |
693 | 721 | dash = (double *)gmallocn(length, sizeof(double)); |
694 | 722 | for (int i = 0; i < length; ++i) { |
| 723 | #if defined(POPPLER_NEW_OBJECT_API) |
| 724 | dash[i] = a->get(i).getNum(); |
| 725 | #else |
695 | 726 | Object obj; |
696 | 727 | dash[i] = a->get(i, &obj)->getNum(); |
697 | 728 | obj.free(); |
| 729 | #endif |
698 | 730 | } |
699 | 731 | } |
700 | 732 | state->setLineDash(dash, length, args[1].getNum()); |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
744 | 776 | GBool haveBackdropColor = gFalse; |
745 | 777 | GBool alpha = gFalse; |
746 | 778 | |
| 779 | #if defined(POPPLER_NEW_OBJECT_API) |
| 780 | if ((obj1 = res->lookupGState(args[0].getName())).isNull()) { |
| 781 | #else |
747 | 782 | if (!res->lookupGState(args[0].getName(), &obj1)) { |
| 783 | #endif |
748 | 784 | return; |
749 | 785 | } |
750 | 786 | if (!obj1.isDict()) { |
751 | 787 | error(errSyntaxError, getPos(), "ExtGState '{0:s}' is wrong type"), args[0].getName(); |
| 788 | #if !defined(POPPLER_NEW_OBJECT_API) |
752 | 789 | obj1.free(); |
| 790 | #endif |
753 | 791 | return; |
754 | 792 | } |
755 | 793 | if (printCommands) { |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
759 | 797 | } |
760 | 798 | |
761 | 799 | // transparency support: blend mode, fill/stroke opacity |
| 800 | #if defined(POPPLER_NEW_OBJECT_API) |
| 801 | if (!((obj2 = obj1.dictLookup(const_cast<char*>("BM"))).isNull())) { |
| 802 | #else |
762 | 803 | if (!obj1.dictLookup(const_cast<char*>("BM"), &obj2)->isNull()) { |
| 804 | #endif |
763 | 805 | GfxBlendMode mode = gfxBlendNormal; |
764 | 806 | if (state->parseBlendMode(&obj2, &mode)) { |
765 | 807 | state->setBlendMode(mode); |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
767 | 809 | error(errSyntaxError, getPos(), "Invalid blend mode in ExtGState"); |
768 | 810 | } |
769 | 811 | } |
| 812 | #if defined(POPPLER_NEW_OBJECT_API) |
| 813 | if ((obj2 = obj1.dictLookup(const_cast<char*>("ca"))).isNum()) { |
| 814 | #else |
770 | 815 | obj2.free(); |
771 | 816 | if (obj1.dictLookup(const_cast<char*>("ca"), &obj2)->isNum()) { |
| 817 | #endif |
772 | 818 | state->setFillOpacity(obj2.getNum()); |
773 | 819 | } |
| 820 | #if defined(POPPLER_NEW_OBJECT_API) |
| 821 | if ((obj2 = obj1.dictLookup(const_cast<char*>("CA"))).isNum()) { |
| 822 | #else |
774 | 823 | obj2.free(); |
775 | 824 | if (obj1.dictLookup(const_cast<char*>("CA"), &obj2)->isNum()) { |
| 825 | #endif |
776 | 826 | state->setStrokeOpacity(obj2.getNum()); |
777 | 827 | } |
| 828 | #if !defined(POPPLER_NEW_OBJECT_API) |
778 | 829 | obj2.free(); |
| 830 | #endif |
779 | 831 | |
780 | 832 | // fill/stroke overprint |
781 | 833 | GBool haveFillOP = gFalse; |
| 834 | #if defined(POPPLER_NEW_OBJECT_API) |
| 835 | if ((haveFillOP = (obj2 = obj1.dictLookup(const_cast<char*>("op"))).isBool())) { |
| 836 | #else |
782 | 837 | if ((haveFillOP = (obj1.dictLookup(const_cast<char*>("op"), &obj2)->isBool()))) { |
| 838 | #endif |
783 | 839 | state->setFillOverprint(obj2.getBool()); |
784 | 840 | } |
| 841 | #if defined(POPPLER_NEW_OBJECT_API) |
| 842 | if ((obj2 = obj1.dictLookup(const_cast<char*>("OP"))).isBool()) { |
| 843 | #else |
785 | 844 | obj2.free(); |
786 | 845 | if (obj1.dictLookup(const_cast<char*>("OP"), &obj2)->isBool()) { |
| 846 | #endif |
787 | 847 | state->setStrokeOverprint(obj2.getBool()); |
788 | 848 | if (!haveFillOP) { |
789 | 849 | state->setFillOverprint(obj2.getBool()); |
790 | 850 | } |
791 | 851 | } |
| 852 | #if !defined(POPPLER_NEW_OBJECT_API) |
792 | 853 | obj2.free(); |
| 854 | #endif |
793 | 855 | |
794 | 856 | // stroke adjust |
| 857 | #if defined(POPPLER_NEW_OBJECT_API) |
| 858 | if ((obj2 = obj1.dictLookup(const_cast<char*>("SA"))).isBool()) { |
| 859 | #else |
795 | 860 | if (obj1.dictLookup(const_cast<char*>("SA"), &obj2)->isBool()) { |
| 861 | #endif |
796 | 862 | state->setStrokeAdjust(obj2.getBool()); |
797 | 863 | } |
| 864 | #if !defined(POPPLER_NEW_OBJECT_API) |
798 | 865 | obj2.free(); |
| 866 | #endif |
799 | 867 | |
800 | 868 | // transfer function |
| 869 | #if defined(POPPLER_NEW_OBJECT_API) |
| 870 | if ((obj2 = obj1.dictLookup(const_cast<char*>("TR2"))).isNull()) { |
| 871 | obj2 = obj1.dictLookup(const_cast<char*>("TR")); |
| 872 | #else |
801 | 873 | if (obj1.dictLookup(const_cast<char*>("TR2"), &obj2)->isNull()) { |
802 | 874 | obj2.free(); |
803 | 875 | obj1.dictLookup(const_cast<char*>("TR"), &obj2); |
| 876 | #endif |
804 | 877 | } |
805 | 878 | if (obj2.isName(const_cast<char*>("Default")) || |
806 | 879 | obj2.isName(const_cast<char*>("Identity"))) { |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
809 | 882 | } else if (obj2.isArray() && obj2.arrayGetLength() == 4) { |
810 | 883 | int pos = 4; |
811 | 884 | for (int i = 0; i < 4; ++i) { |
| 885 | #if defined(POPPLER_NEW_OBJECT_API) |
| 886 | obj3 = obj2.arrayGet(i); |
| 887 | #else |
812 | 888 | obj2.arrayGet(i, &obj3); |
| 889 | #endif |
813 | 890 | funcs[i] = Function::parse(&obj3); |
| 891 | #if !defined(POPPLER_NEW_OBJECT_API) |
814 | 892 | obj3.free(); |
| 893 | #endif |
815 | 894 | if (!funcs[i]) { |
816 | 895 | pos = i; |
817 | 896 | break; |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
828 | 907 | } else if (!obj2.isNull()) { |
829 | 908 | error(errSyntaxError, getPos(), "Invalid transfer function in ExtGState"); |
830 | 909 | } |
| 910 | #if !defined(POPPLER_NEW_OBJECT_API) |
831 | 911 | obj2.free(); |
| 912 | #endif |
832 | 913 | |
833 | 914 | // soft mask |
| 915 | #if defined(POPPLER_NEW_OBJECT_API) |
| 916 | if (!((obj2 = obj1.dictLookup(const_cast<char*>("SMask"))).isNull())) { |
| 917 | #else |
834 | 918 | if (!obj1.dictLookup(const_cast<char*>("SMask"), &obj2)->isNull()) { |
| 919 | #endif |
835 | 920 | if (obj2.isName(const_cast<char*>("None"))) { |
836 | 921 | builder->clearSoftMask(state); |
837 | 922 | } else if (obj2.isDict()) { |
| 923 | #if defined(POPPLER_NEW_OBJECT_API) |
| 924 | if ((obj3 = obj2.dictLookup(const_cast<char*>("S"))).isName(const_cast<char*>("Alpha"))) { |
| 925 | #else |
838 | 926 | if (obj2.dictLookup(const_cast<char*>("S"), &obj3)->isName(const_cast<char*>("Alpha"))) { |
| 927 | #endif |
839 | 928 | alpha = gTrue; |
840 | 929 | } else { // "Luminosity" |
841 | 930 | alpha = gFalse; |
842 | 931 | } |
| 932 | #if !defined(POPPLER_NEW_OBJECT_API) |
843 | 933 | obj3.free(); |
| 934 | #endif |
844 | 935 | funcs[0] = NULL; |
| 936 | #if defined(POPPLER_NEW_OBJECT_API) |
| 937 | if (!((obj3 = obj2.dictLookup(const_cast<char*>("TR"))).isNull())) { |
| 938 | #else |
845 | 939 | if (!obj2.dictLookup(const_cast<char*>("TR"), &obj3)->isNull()) { |
| 940 | #endif |
846 | 941 | funcs[0] = Function::parse(&obj3); |
847 | 942 | if (funcs[0]->getInputSize() != 1 || |
848 | 943 | funcs[0]->getOutputSize() != 1) { |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
851 | 946 | funcs[0] = NULL; |
852 | 947 | } |
853 | 948 | } |
| 949 | #if defined(POPPLER_NEW_OBJECT_API) |
| 950 | if ((haveBackdropColor = (obj3 = obj2.dictLookup(const_cast<char*>("BC"))).isArray())) { |
| 951 | #else |
854 | 952 | obj3.free(); |
855 | 953 | if ((haveBackdropColor = obj2.dictLookup(const_cast<char*>("BC"), &obj3)->isArray())) { |
| 954 | #endif |
856 | 955 | for (int i = 0; i < gfxColorMaxComps; ++i) { |
857 | 956 | backdropColor.c[i] = 0; |
858 | 957 | } |
859 | 958 | for (int i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) { |
| 959 | #if defined(POPPLER_NEW_OBJECT_API) |
| 960 | obj4 = obj3.arrayGet(i); |
| 961 | #else |
860 | 962 | obj3.arrayGet(i, &obj4); |
| 963 | #endif |
861 | 964 | if (obj4.isNum()) { |
862 | 965 | backdropColor.c[i] = dblToCol(obj4.getNum()); |
863 | 966 | } |
| 967 | #if !defined(POPPLER_NEW_OBJECT_API) |
864 | 968 | obj4.free(); |
| 969 | #endif |
865 | 970 | } |
866 | 971 | } |
| 972 | #if defined(POPPLER_NEW_OBJECT_API) |
| 973 | if ((obj3 = obj2.dictLookup(const_cast<char*>("G"))).isStream()) { |
| 974 | if ((obj4 = obj3.streamGetDict()->lookup(const_cast<char*>("Group"))).isDict()) { |
| 975 | #else |
867 | 976 | obj3.free(); |
868 | 977 | if (obj2.dictLookup(const_cast<char*>("G"), &obj3)->isStream()) { |
869 | 978 | if (obj3.streamGetDict()->lookup(const_cast<char*>("Group"), &obj4)->isDict()) { |
| 979 | #endif |
870 | 980 | GfxColorSpace *blendingColorSpace = 0; |
871 | 981 | GBool isolated = gFalse; |
872 | 982 | GBool knockout = gFalse; |
| 983 | #if defined(POPPLER_NEW_OBJECT_API) |
| 984 | if (!((obj5 = obj4.dictLookup(const_cast<char*>("CS"))).isNull())) { |
| 985 | #else |
873 | 986 | if (!obj4.dictLookup(const_cast<char*>("CS"), &obj5)->isNull()) { |
| 987 | #endif |
874 | 988 | #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API) |
875 | 989 | blendingColorSpace = GfxColorSpace::parse(NULL, &obj5, NULL, NULL); |
876 | 990 | #elif defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API) |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
879 | 993 | blendingColorSpace = GfxColorSpace::parse(&obj5, NULL); |
880 | 994 | #endif |
881 | 995 | } |
| 996 | #if defined(POPPLER_NEW_OBJECT_API) |
| 997 | if ((obj5 = obj4.dictLookup(const_cast<char*>("I"))).isBool()) { |
| 998 | #else |
882 | 999 | obj5.free(); |
883 | 1000 | if (obj4.dictLookup(const_cast<char*>("I"), &obj5)->isBool()) { |
| 1001 | #endif |
884 | 1002 | isolated = obj5.getBool(); |
885 | 1003 | } |
| 1004 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1005 | if ((obj5 = obj4.dictLookup(const_cast<char*>("K"))).isBool()) { |
| 1006 | #else |
886 | 1007 | obj5.free(); |
887 | 1008 | if (obj4.dictLookup(const_cast<char*>("K"), &obj5)->isBool()) { |
| 1009 | #endif |
888 | 1010 | knockout = obj5.getBool(); |
889 | 1011 | } |
| 1012 | #if !defined(POPPLER_NEW_OBJECT_API) |
890 | 1013 | obj5.free(); |
| 1014 | #endif |
891 | 1015 | if (!haveBackdropColor) { |
892 | 1016 | if (blendingColorSpace) { |
893 | 1017 | blendingColorSpace->getDefaultColor(&backdropColor); |
… |
… |
void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)
|
906 | 1030 | } else { |
907 | 1031 | error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group"); |
908 | 1032 | } |
| 1033 | #if !defined(POPPLER_NEW_OBJECT_API) |
909 | 1034 | obj4.free(); |
| 1035 | #endif |
910 | 1036 | } else { |
911 | 1037 | error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group"); |
912 | 1038 | } |
| 1039 | #if !defined(POPPLER_NEW_OBJECT_API) |
913 | 1040 | obj3.free(); |
| 1041 | #endif |
914 | 1042 | } else if (!obj2.isNull()) { |
915 | 1043 | error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState"); |
916 | 1044 | } |
917 | 1045 | } |
| 1046 | #if !defined(POPPLER_NEW_OBJECT_API) |
918 | 1047 | obj2.free(); |
919 | 1048 | |
920 | 1049 | obj1.free(); |
| 1050 | #endif |
921 | 1051 | } |
922 | 1052 | |
923 | 1053 | void PdfParser::doSoftMask(Object *str, GBool alpha, |
… |
… |
void PdfParser::doSoftMask(Object *str, GBool alpha,
|
938 | 1068 | dict = str->streamGetDict(); |
939 | 1069 | |
940 | 1070 | // check form type |
| 1071 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1072 | obj1 = dict->lookup(const_cast<char*>("FormType")); |
| 1073 | #else |
941 | 1074 | dict->lookup(const_cast<char*>("FormType"), &obj1); |
| 1075 | #endif |
942 | 1076 | if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { |
943 | 1077 | error(errSyntaxError, getPos(), "Unknown form type"); |
944 | 1078 | } |
| 1079 | #if !defined(POPPLER_NEW_OBJECT_API) |
945 | 1080 | obj1.free(); |
| 1081 | #endif |
946 | 1082 | |
947 | 1083 | // get bounding box |
| 1084 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1085 | obj1 = dict->lookup(const_cast<char*>("BBox")); |
| 1086 | #else |
948 | 1087 | dict->lookup(const_cast<char*>("BBox"), &obj1); |
| 1088 | #endif |
949 | 1089 | if (!obj1.isArray()) { |
| 1090 | #if !defined(POPPLER_NEW_OBJECT_API) |
950 | 1091 | obj1.free(); |
| 1092 | #endif |
951 | 1093 | error(errSyntaxError, getPos(), "Bad form bounding box"); |
952 | 1094 | return; |
953 | 1095 | } |
954 | 1096 | for (i = 0; i < 4; ++i) { |
| 1097 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1098 | obj2 = obj1.arrayGet(i); |
| 1099 | #else |
955 | 1100 | obj1.arrayGet(i, &obj2); |
| 1101 | #endif |
956 | 1102 | bbox[i] = obj2.getNum(); |
| 1103 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1104 | } |
| 1105 | #else |
957 | 1106 | obj2.free(); |
958 | 1107 | } |
959 | 1108 | obj1.free(); |
| 1109 | #endif |
960 | 1110 | |
961 | 1111 | // get matrix |
| 1112 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1113 | obj1 = dict->lookup(const_cast<char*>("Matrix")); |
| 1114 | #else |
962 | 1115 | dict->lookup(const_cast<char*>("Matrix"), &obj1); |
| 1116 | #endif |
963 | 1117 | if (obj1.isArray()) { |
964 | 1118 | for (i = 0; i < 6; ++i) { |
| 1119 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1120 | obj2 = obj1.arrayGet(i); |
| 1121 | #else |
965 | 1122 | obj1.arrayGet(i, &obj2); |
| 1123 | #endif |
966 | 1124 | m[i] = obj2.getNum(); |
| 1125 | #if !defined(POPPLER_NEW_OBJECT_API) |
967 | 1126 | obj2.free(); |
| 1127 | #endif |
968 | 1128 | } |
969 | 1129 | } else { |
970 | 1130 | m[0] = 1; m[1] = 0; |
971 | 1131 | m[2] = 0; m[3] = 1; |
972 | 1132 | m[4] = 0; m[5] = 0; |
973 | 1133 | } |
| 1134 | #if !defined(POPPLER_NEW_OBJECT_API) |
974 | 1135 | obj1.free(); |
| 1136 | #endif |
975 | 1137 | |
976 | 1138 | // get resources |
| 1139 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1140 | obj1 = dict->lookup(const_cast<char*>("Resources")); |
| 1141 | #else |
977 | 1142 | dict->lookup(const_cast<char*>("Resources"), &obj1); |
| 1143 | #endif |
978 | 1144 | resDict = obj1.isDict() ? obj1.getDict() : (Dict *)NULL; |
979 | 1145 | |
980 | 1146 | // draw it |
… |
… |
void PdfParser::doSoftMask(Object *str, GBool alpha,
|
987 | 1153 | if (blendingColorSpace) { |
988 | 1154 | delete blendingColorSpace; |
989 | 1155 | } |
| 1156 | #if !defined(POPPLER_NEW_OBJECT_API) |
990 | 1157 | obj1.free(); |
| 1158 | #endif |
991 | 1159 | } |
992 | 1160 | |
993 | 1161 | void PdfParser::opSetRenderingIntent(Object /*args*/[], int /*numArgs*/) |
… |
… |
void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
|
1084 | 1252 | Object obj; |
1085 | 1253 | |
1086 | 1254 | state->setFillPattern(NULL); |
| 1255 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1256 | obj = res->lookupColorSpace(args[0].getName()); |
| 1257 | #else |
1087 | 1258 | res->lookupColorSpace(args[0].getName(), &obj); |
| 1259 | #endif |
1088 | 1260 | |
1089 | 1261 | GfxColorSpace *colorSpace = 0; |
1090 | 1262 | #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API) |
… |
… |
void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)
|
1106 | 1278 | colorSpace = GfxColorSpace::parse(&obj, NULL); |
1107 | 1279 | } |
1108 | 1280 | #endif |
| 1281 | #if !defined(POPPLER_NEW_OBJECT_API) |
1109 | 1282 | obj.free(); |
| 1283 | #endif |
1110 | 1284 | if (colorSpace) { |
1111 | 1285 | GfxColor color; |
1112 | 1286 | state->setFillColorSpace(colorSpace); |
… |
… |
void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
|
1125 | 1299 | GfxColorSpace *colorSpace = 0; |
1126 | 1300 | |
1127 | 1301 | state->setStrokePattern(NULL); |
| 1302 | #if defined(POPPLER_NEW_OBJECT_API) |
| 1303 | obj = res->lookupColorSpace(args[0].getName()); |
| 1304 | #else |
1128 | 1305 | res->lookupColorSpace(args[0].getName(), &obj); |
| 1306 | #endif |
1129 | 1307 | #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API) |
1130 | 1308 | if (obj.isNull()) { |
1131 | 1309 | colorSpace = GfxColorSpace::parse(NULL, &args[0], NULL, NULL); |
… |
… |
void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)
|
1145 | 1323 | colorSpace = GfxColorSpace::parse(&obj, NULL); |
1146 | 1324 | } |
1147 | 1325 | #endif |
| 1326 | #if !defined(POPPLER_NEW_OBJECT_API) |
1148 | 1327 | obj.free(); |
| 1328 | #endif |
1149 | 1329 | if (colorSpace) { |
1150 | 1330 | GfxColor color; |
1151 | 1331 | state->setStrokeColorSpace(colorSpace); |
… |
… |
void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
|
2375 | 2555 | wMode = state->getFont()->getWMode(); |
2376 | 2556 | a = args[0].getArray(); |
2377 | 2557 | for (int i = 0; i < a->getLength(); ++i) { |
| 2558 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2559 | obj = a->get(i); |
| 2560 | #else |
2378 | 2561 | a->get(i, &obj); |
| 2562 | #endif |
2379 | 2563 | if (obj.isNum()) { |
2380 | 2564 | // this uses the absolute value of the font size to match |
2381 | 2565 | // Acrobat's behavior |
… |
… |
void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)
|
2392 | 2576 | } else { |
2393 | 2577 | error(errSyntaxError, getPos(), "Element of show/space array must be number or string"); |
2394 | 2578 | } |
| 2579 | #if !defined(POPPLER_NEW_OBJECT_API) |
2395 | 2580 | obj.free(); |
| 2581 | #endif |
2396 | 2582 | } |
2397 | 2583 | } |
2398 | 2584 | |
… |
… |
void PdfParser::doShowText(GooString *s) {
|
2465 | 2651 | //out->updateCTM(state, 1, 0, 0, 1, 0, 0); |
2466 | 2652 | if (0){ /*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy, |
2467 | 2653 | code, u, uLen)) {*/ |
| 2654 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2655 | charProc = ((Gfx8BitFont *)font)->getCharProc(code); |
| 2656 | #else |
2468 | 2657 | ((Gfx8BitFont *)font)->getCharProc(code, &charProc); |
| 2658 | #endif |
2469 | 2659 | if ((resDict = ((Gfx8BitFont *)font)->getResources())) { |
2470 | 2660 | pushResources(resDict); |
2471 | 2661 | } |
… |
… |
void PdfParser::doShowText(GooString *s) {
|
2478 | 2668 | if (resDict) { |
2479 | 2669 | popResources(); |
2480 | 2670 | } |
| 2671 | #if !defined(POPPLER_NEW_OBJECT_API) |
2481 | 2672 | charProc.free(); |
| 2673 | #endif |
2482 | 2674 | } |
2483 | 2675 | restoreState(); |
2484 | 2676 | // GfxState::restore() does *not* restore the current position, |
… |
… |
void PdfParser::opXObject(Object args[], int /*numArgs*/)
|
2541 | 2733 | Object obj1, obj2, obj3, refObj; |
2542 | 2734 | |
2543 | 2735 | char *name = args[0].getName(); |
| 2736 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2737 | if ((obj1 = res->lookupXObject(name)).isNull()) { |
| 2738 | #else |
2544 | 2739 | if (!res->lookupXObject(name, &obj1)) { |
| 2740 | #endif |
2545 | 2741 | return; |
2546 | 2742 | } |
2547 | 2743 | if (!obj1.isStream()) { |
2548 | 2744 | error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name); |
| 2745 | #if !defined(POPPLER_NEW_OBJECT_API) |
2549 | 2746 | obj1.free(); |
| 2747 | #endif |
2550 | 2748 | return; |
2551 | 2749 | } |
| 2750 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2751 | obj2 = obj1.streamGetDict()->lookup(const_cast<char*>("Subtype")); |
| 2752 | #else |
2552 | 2753 | obj1.streamGetDict()->lookup(const_cast<char*>("Subtype"), &obj2); |
| 2754 | #endif |
2553 | 2755 | if (obj2.isName(const_cast<char*>("Image"))) { |
| 2756 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2757 | refObj = res->lookupXObjectNF(name); |
| 2758 | #else |
2554 | 2759 | res->lookupXObjectNF(name, &refObj); |
| 2760 | #endif |
2555 | 2761 | doImage(&refObj, obj1.getStream(), gFalse); |
| 2762 | #if !defined(POPPLER_NEW_OBJECT_API) |
2556 | 2763 | refObj.free(); |
| 2764 | #endif |
2557 | 2765 | } else if (obj2.isName(const_cast<char*>("Form"))) { |
2558 | 2766 | doForm(&obj1); |
2559 | 2767 | } else if (obj2.isName(const_cast<char*>("PS"))) { |
| 2768 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2769 | obj3 = obj1.streamGetDict()->lookup(const_cast<char*>("Level1")); |
| 2770 | #else |
2560 | 2771 | obj1.streamGetDict()->lookup(const_cast<char*>("Level1"), &obj3); |
| 2772 | #endif |
2561 | 2773 | /* out->psXObject(obj1.getStream(), |
2562 | 2774 | obj3.isStream() ? obj3.getStream() : (Stream *)NULL);*/ |
2563 | 2775 | } else if (obj2.isName()) { |
… |
… |
void PdfParser::opXObject(Object args[], int /*numArgs*/)
|
2565 | 2777 | } else { |
2566 | 2778 | error(errSyntaxError, getPos(), "XObject subtype is missing or wrong type"); |
2567 | 2779 | } |
| 2780 | #if !defined(POPPLER_NEW_OBJECT_API) |
2568 | 2781 | obj2.free(); |
2569 | 2782 | obj1.free(); |
| 2783 | #endif |
2570 | 2784 | } |
2571 | 2785 | |
2572 | 2786 | void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2593 | 2807 | dict = str->getDict(); |
2594 | 2808 | |
2595 | 2809 | // get size |
| 2810 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2811 | obj1 = dict->lookup(const_cast<char*>("Width")); |
| 2812 | #else |
2596 | 2813 | dict->lookup(const_cast<char*>("Width"), &obj1); |
| 2814 | #endif |
2597 | 2815 | if (obj1.isNull()) { |
| 2816 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2817 | obj1 = dict->lookup(const_cast<char*>("W")); |
| 2818 | #else |
2598 | 2819 | obj1.free(); |
2599 | 2820 | dict->lookup(const_cast<char*>("W"), &obj1); |
| 2821 | #endif |
2600 | 2822 | } |
2601 | 2823 | if (obj1.isInt()){ |
2602 | 2824 | width = obj1.getInt(); |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2607 | 2829 | else { |
2608 | 2830 | goto err2; |
2609 | 2831 | } |
| 2832 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2833 | obj1 = dict->lookup(const_cast<char*>("Height")); |
| 2834 | #else |
2610 | 2835 | obj1.free(); |
2611 | 2836 | dict->lookup(const_cast<char*>("Height"), &obj1); |
| 2837 | #endif |
2612 | 2838 | if (obj1.isNull()) { |
| 2839 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2840 | obj1 = dict->lookup(const_cast<char*>("H")); |
| 2841 | #else |
2613 | 2842 | obj1.free(); |
2614 | 2843 | dict->lookup(const_cast<char*>("H"), &obj1); |
| 2844 | #endif |
2615 | 2845 | } |
2616 | 2846 | if (obj1.isInt()) { |
2617 | 2847 | height = obj1.getInt(); |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2622 | 2852 | else { |
2623 | 2853 | goto err2; |
2624 | 2854 | } |
| 2855 | #if !defined(POPPLER_NEW_OBJECT_API) |
2625 | 2856 | obj1.free(); |
| 2857 | #endif |
2626 | 2858 | |
2627 | 2859 | // image interpolation |
| 2860 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2861 | obj1 = dict->lookup("Interpolate"); |
| 2862 | #else |
2628 | 2863 | dict->lookup("Interpolate", &obj1); |
| 2864 | #endif |
2629 | 2865 | if (obj1.isNull()) { |
| 2866 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2867 | obj1 = dict->lookup("I"); |
| 2868 | #else |
2630 | 2869 | obj1.free(); |
2631 | 2870 | dict->lookup("I", &obj1); |
| 2871 | #endif |
2632 | 2872 | } |
2633 | 2873 | if (obj1.isBool()) |
2634 | 2874 | interpolate = obj1.getBool(); |
2635 | 2875 | else |
2636 | 2876 | interpolate = gFalse; |
| 2877 | #if !defined(POPPLER_NEW_OBJECT_API) |
2637 | 2878 | obj1.free(); |
| 2879 | #endif |
2638 | 2880 | maskInterpolate = gFalse; |
2639 | 2881 | |
2640 | 2882 | // image or mask? |
| 2883 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2884 | obj1 = dict->lookup(const_cast<char*>("ImageMask")); |
| 2885 | #else |
2641 | 2886 | dict->lookup(const_cast<char*>("ImageMask"), &obj1); |
| 2887 | #endif |
2642 | 2888 | if (obj1.isNull()) { |
| 2889 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2890 | obj1 = dict->lookup(const_cast<char*>("IM")); |
| 2891 | #else |
2643 | 2892 | obj1.free(); |
2644 | 2893 | dict->lookup(const_cast<char*>("IM"), &obj1); |
| 2894 | #endif |
2645 | 2895 | } |
2646 | 2896 | mask = gFalse; |
2647 | 2897 | if (obj1.isBool()) { |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2650 | 2900 | else if (!obj1.isNull()) { |
2651 | 2901 | goto err2; |
2652 | 2902 | } |
| 2903 | #if !defined(POPPLER_NEW_OBJECT_API) |
2653 | 2904 | obj1.free(); |
| 2905 | #endif |
2654 | 2906 | |
2655 | 2907 | // bit depth |
2656 | 2908 | if (bits == 0) { |
| 2909 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2910 | obj1 = dict->lookup(const_cast<char*>("BitsPerComponent")); |
| 2911 | #else |
2657 | 2912 | dict->lookup(const_cast<char*>("BitsPerComponent"), &obj1); |
| 2913 | #endif |
2658 | 2914 | if (obj1.isNull()) { |
| 2915 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2916 | obj1 = dict->lookup(const_cast<char*>("BPC")); |
| 2917 | #else |
2659 | 2918 | obj1.free(); |
2660 | 2919 | dict->lookup(const_cast<char*>("BPC"), &obj1); |
| 2920 | #endif |
2661 | 2921 | } |
2662 | 2922 | if (obj1.isInt()) { |
2663 | 2923 | bits = obj1.getInt(); |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2666 | 2926 | } else { |
2667 | 2927 | goto err2; |
2668 | 2928 | } |
| 2929 | #if !defined(POPPLER_NEW_OBJECT_API) |
2669 | 2930 | obj1.free(); |
| 2931 | #endif |
2670 | 2932 | } |
2671 | 2933 | |
2672 | 2934 | // display a mask |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2676 | 2938 | goto err1; |
2677 | 2939 | } |
2678 | 2940 | invert = gFalse; |
| 2941 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2942 | obj1 = dict->lookup(const_cast<char*>("Decode")); |
| 2943 | #else |
2679 | 2944 | dict->lookup(const_cast<char*>("Decode"), &obj1); |
| 2945 | #endif |
2680 | 2946 | if (obj1.isNull()) { |
| 2947 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2948 | obj1 = dict->lookup(const_cast<char*>("D")); |
| 2949 | #else |
2681 | 2950 | obj1.free(); |
2682 | 2951 | dict->lookup(const_cast<char*>("D"), &obj1); |
| 2952 | #endif |
2683 | 2953 | } |
2684 | 2954 | if (obj1.isArray()) { |
| 2955 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2956 | obj2 = obj1.arrayGet(0); |
| 2957 | #else |
2685 | 2958 | obj1.arrayGet(0, &obj2); |
| 2959 | #endif |
2686 | 2960 | if (obj2.isInt() && obj2.getInt() == 1) { |
2687 | 2961 | invert = gTrue; |
2688 | 2962 | } |
| 2963 | #if !defined(POPPLER_NEW_OBJECT_API) |
2689 | 2964 | obj2.free(); |
| 2965 | #endif |
2690 | 2966 | } else if (!obj1.isNull()) { |
2691 | 2967 | goto err2; |
2692 | 2968 | } |
| 2969 | #if !defined(POPPLER_NEW_OBJECT_API) |
2693 | 2970 | obj1.free(); |
| 2971 | #endif |
2694 | 2972 | |
2695 | 2973 | // draw it |
2696 | 2974 | builder->addImageMask(state, str, width, height, invert, interpolate); |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2698 | 2976 | } else { |
2699 | 2977 | // get color space and color map |
2700 | 2978 | GfxColorSpace *colorSpace; |
| 2979 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2980 | obj1 = dict->lookup(const_cast<char*>("ColorSpace")); |
| 2981 | #else |
2701 | 2982 | dict->lookup(const_cast<char*>("ColorSpace"), &obj1); |
| 2983 | #endif |
2702 | 2984 | if (obj1.isNull()) { |
| 2985 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2986 | obj1 = dict->lookup(const_cast<char*>("CS")); |
| 2987 | #else |
2703 | 2988 | obj1.free(); |
2704 | 2989 | dict->lookup(const_cast<char*>("CS"), &obj1); |
| 2990 | #endif |
2705 | 2991 | } |
2706 | 2992 | if (obj1.isName()) { |
| 2993 | #if defined(POPPLER_NEW_OBJECT_API) |
| 2994 | obj2 = res->lookupColorSpace(obj1.getName()); |
| 2995 | #else |
2707 | 2996 | res->lookupColorSpace(obj1.getName(), &obj2); |
| 2997 | #endif |
2708 | 2998 | if (!obj2.isNull()) { |
| 2999 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3000 | obj1 = std::move(obj2); |
| 3001 | #else |
2709 | 3002 | obj1.free(); |
2710 | 3003 | obj1 = obj2; |
| 3004 | #endif |
2711 | 3005 | } else { |
| 3006 | #if !defined(POPPLER_NEW_OBJECT_API) |
2712 | 3007 | obj2.free(); |
| 3008 | #endif |
2713 | 3009 | } |
2714 | 3010 | } |
2715 | 3011 | if (!obj1.isNull()) { |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2729 | 3025 | } else { |
2730 | 3026 | colorSpace = NULL; |
2731 | 3027 | } |
| 3028 | #if !defined(POPPLER_NEW_OBJECT_API) |
2732 | 3029 | obj1.free(); |
| 3030 | #endif |
2733 | 3031 | if (!colorSpace) { |
2734 | 3032 | goto err1; |
2735 | 3033 | } |
| 3034 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3035 | obj1 = dict->lookup(const_cast<char*>("Decode")); |
| 3036 | #else |
2736 | 3037 | dict->lookup(const_cast<char*>("Decode"), &obj1); |
| 3038 | #endif |
2737 | 3039 | if (obj1.isNull()) { |
| 3040 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3041 | obj1 = dict->lookup(const_cast<char*>("D")); |
| 3042 | #else |
2738 | 3043 | obj1.free(); |
2739 | 3044 | dict->lookup(const_cast<char*>("D"), &obj1); |
| 3045 | #endif |
2740 | 3046 | } |
2741 | 3047 | GfxImageColorMap *colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); |
| 3048 | #if !defined(POPPLER_NEW_OBJECT_API) |
2742 | 3049 | obj1.free(); |
| 3050 | #endif |
2743 | 3051 | if (!colorMap->isOk()) { |
2744 | 3052 | delete colorMap; |
2745 | 3053 | goto err1; |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2753 | 3061 | int maskHeight = 0; |
2754 | 3062 | maskInvert = gFalse; |
2755 | 3063 | GfxImageColorMap *maskColorMap = NULL; |
| 3064 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3065 | maskObj = dict->lookup(const_cast<char*>("Mask")); |
| 3066 | smaskObj = dict->lookup(const_cast<char*>("SMask")); |
| 3067 | #else |
2756 | 3068 | dict->lookup(const_cast<char*>("Mask"), &maskObj); |
2757 | 3069 | dict->lookup(const_cast<char*>("SMask"), &smaskObj); |
| 3070 | #endif |
2758 | 3071 | Dict* maskDict; |
2759 | 3072 | if (smaskObj.isStream()) { |
2760 | 3073 | // soft mask |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2763 | 3076 | } |
2764 | 3077 | maskStr = smaskObj.getStream(); |
2765 | 3078 | maskDict = smaskObj.streamGetDict(); |
| 3079 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3080 | obj1 = maskDict->lookup(const_cast<char*>("Width")); |
| 3081 | #else |
2766 | 3082 | maskDict->lookup(const_cast<char*>("Width"), &obj1); |
| 3083 | #endif |
2767 | 3084 | if (obj1.isNull()) { |
| 3085 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3086 | obj1 = maskDict->lookup(const_cast<char*>("W")); |
| 3087 | #else |
2768 | 3088 | obj1.free(); |
2769 | 3089 | maskDict->lookup(const_cast<char*>("W"), &obj1); |
| 3090 | #endif |
2770 | 3091 | } |
2771 | 3092 | if (!obj1.isInt()) { |
2772 | 3093 | goto err2; |
2773 | 3094 | } |
2774 | 3095 | maskWidth = obj1.getInt(); |
| 3096 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3097 | obj1 = maskDict->lookup(const_cast<char*>("Height")); |
| 3098 | #else |
2775 | 3099 | obj1.free(); |
2776 | 3100 | maskDict->lookup(const_cast<char*>("Height"), &obj1); |
| 3101 | #endif |
2777 | 3102 | if (obj1.isNull()) { |
| 3103 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3104 | obj1 = maskDict->lookup(const_cast<char*>("H")); |
| 3105 | #else |
2778 | 3106 | obj1.free(); |
2779 | 3107 | maskDict->lookup(const_cast<char*>("H"), &obj1); |
| 3108 | #endif |
2780 | 3109 | } |
2781 | 3110 | if (!obj1.isInt()) { |
2782 | 3111 | goto err2; |
2783 | 3112 | } |
2784 | 3113 | maskHeight = obj1.getInt(); |
| 3114 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3115 | obj1 = maskDict->lookup(const_cast<char*>("BitsPerComponent")); |
| 3116 | #else |
2785 | 3117 | obj1.free(); |
2786 | 3118 | maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1); |
| 3119 | #endif |
2787 | 3120 | if (obj1.isNull()) { |
| 3121 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3122 | obj1 = maskDict->lookup(const_cast<char*>("BPC")); |
| 3123 | #else |
2788 | 3124 | obj1.free(); |
2789 | 3125 | maskDict->lookup(const_cast<char*>("BPC"), &obj1); |
| 3126 | #endif |
2790 | 3127 | } |
2791 | 3128 | if (!obj1.isInt()) { |
2792 | 3129 | goto err2; |
2793 | 3130 | } |
2794 | 3131 | int maskBits = obj1.getInt(); |
| 3132 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3133 | obj1 = maskDict->lookup(const_cast<char*>("Interpolate")); |
| 3134 | #else |
2795 | 3135 | obj1.free(); |
2796 | 3136 | maskDict->lookup("Interpolate", &obj1); |
| 3137 | #endif |
2797 | 3138 | if (obj1.isNull()) { |
| 3139 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3140 | obj1 = maskDict->lookup(const_cast<char*>("I")); |
| 3141 | #else |
2798 | 3142 | obj1.free(); |
2799 | 3143 | maskDict->lookup("I", &obj1); |
| 3144 | #endif |
2800 | 3145 | } |
2801 | 3146 | if (obj1.isBool()) |
2802 | 3147 | maskInterpolate = obj1.getBool(); |
2803 | 3148 | else |
2804 | 3149 | maskInterpolate = gFalse; |
| 3150 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3151 | obj1 = maskDict->lookup(const_cast<char*>("ColorSpace")); |
| 3152 | #else |
2805 | 3153 | obj1.free(); |
2806 | 3154 | maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1); |
| 3155 | #endif |
2807 | 3156 | if (obj1.isNull()) { |
| 3157 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3158 | obj1 = maskDict->lookup(const_cast<char*>("CS")); |
| 3159 | #else |
2808 | 3160 | obj1.free(); |
2809 | 3161 | maskDict->lookup(const_cast<char*>("CS"), &obj1); |
| 3162 | #endif |
2810 | 3163 | } |
2811 | 3164 | if (obj1.isName()) { |
| 3165 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3166 | obj2 = res->lookupColorSpace(obj1.getName()); |
| 3167 | #else |
2812 | 3168 | res->lookupColorSpace(obj1.getName(), &obj2); |
| 3169 | #endif |
2813 | 3170 | if (!obj2.isNull()) { |
| 3171 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3172 | obj1 = std::move(obj2); |
| 3173 | #else |
2814 | 3174 | obj1.free(); |
2815 | 3175 | obj1 = obj2; |
| 3176 | #endif |
2816 | 3177 | } else { |
| 3178 | #if !defined(POPPLER_NEW_OBJECT_API) |
2817 | 3179 | obj2.free(); |
| 3180 | #endif |
2818 | 3181 | } |
2819 | 3182 | } |
2820 | 3183 | #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API) |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2824 | 3187 | #else |
2825 | 3188 | GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1, NULL); |
2826 | 3189 | #endif |
| 3190 | #if !defined(POPPLER_NEW_OBJECT_API) |
2827 | 3191 | obj1.free(); |
| 3192 | #endif |
2828 | 3193 | if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { |
2829 | 3194 | goto err1; |
2830 | 3195 | } |
| 3196 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3197 | obj1 = maskDict->lookup(const_cast<char*>("Decode")); |
| 3198 | #else |
2831 | 3199 | maskDict->lookup(const_cast<char*>("Decode"), &obj1); |
| 3200 | #endif |
2832 | 3201 | if (obj1.isNull()) { |
| 3202 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3203 | obj1 = maskDict->lookup(const_cast<char*>("D")); |
| 3204 | #else |
2833 | 3205 | obj1.free(); |
2834 | 3206 | maskDict->lookup(const_cast<char*>("D"), &obj1); |
| 3207 | #endif |
2835 | 3208 | } |
2836 | 3209 | maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace); |
| 3210 | #if !defined(POPPLER_NEW_OBJECT_API) |
2837 | 3211 | obj1.free(); |
| 3212 | #endif |
2838 | 3213 | if (!maskColorMap->isOk()) { |
2839 | 3214 | delete maskColorMap; |
2840 | 3215 | goto err1; |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2845 | 3220 | // color key mask |
2846 | 3221 | int i; |
2847 | 3222 | for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) { |
| 3223 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3224 | obj1 = maskObj.arrayGet(i); |
| 3225 | #else |
2848 | 3226 | maskObj.arrayGet(i, &obj1); |
| 3227 | #endif |
2849 | 3228 | maskColors[i] = obj1.getInt(); |
| 3229 | #if !defined(POPPLER_NEW_OBJECT_API) |
2850 | 3230 | obj1.free(); |
| 3231 | #endif |
2851 | 3232 | } |
2852 | 3233 | haveColorKeyMask = gTrue; |
2853 | 3234 | } else if (maskObj.isStream()) { |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2857 | 3238 | } |
2858 | 3239 | maskStr = maskObj.getStream(); |
2859 | 3240 | maskDict = maskObj.streamGetDict(); |
| 3241 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3242 | obj1 = maskDict->lookup(const_cast<char*>("Width")); |
| 3243 | #else |
2860 | 3244 | maskDict->lookup(const_cast<char*>("Width"), &obj1); |
| 3245 | #endif |
2861 | 3246 | if (obj1.isNull()) { |
| 3247 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3248 | obj1 = maskDict->lookup(const_cast<char*>("W")); |
| 3249 | #else |
2862 | 3250 | obj1.free(); |
2863 | 3251 | maskDict->lookup(const_cast<char*>("W"), &obj1); |
| 3252 | #endif |
2864 | 3253 | } |
2865 | 3254 | if (!obj1.isInt()) { |
2866 | 3255 | goto err2; |
2867 | 3256 | } |
2868 | 3257 | maskWidth = obj1.getInt(); |
| 3258 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3259 | obj1 = maskDict->lookup(const_cast<char*>("Height")); |
| 3260 | #else |
2869 | 3261 | obj1.free(); |
2870 | 3262 | maskDict->lookup(const_cast<char*>("Height"), &obj1); |
| 3263 | #endif |
2871 | 3264 | if (obj1.isNull()) { |
| 3265 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3266 | obj1 = maskDict->lookup(const_cast<char*>("H")); |
| 3267 | #else |
2872 | 3268 | obj1.free(); |
2873 | 3269 | maskDict->lookup(const_cast<char*>("H"), &obj1); |
| 3270 | #endif |
2874 | 3271 | } |
2875 | 3272 | if (!obj1.isInt()) { |
2876 | 3273 | goto err2; |
2877 | 3274 | } |
2878 | 3275 | maskHeight = obj1.getInt(); |
| 3276 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3277 | obj1 = maskDict->lookup(const_cast<char*>("ImageMask")); |
| 3278 | #else |
2879 | 3279 | obj1.free(); |
2880 | 3280 | maskDict->lookup(const_cast<char*>("ImageMask"), &obj1); |
| 3281 | #endif |
2881 | 3282 | if (obj1.isNull()) { |
| 3283 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3284 | obj1 = maskDict->lookup(const_cast<char*>("IM")); |
| 3285 | #else |
2882 | 3286 | obj1.free(); |
2883 | 3287 | maskDict->lookup(const_cast<char*>("IM"), &obj1); |
| 3288 | #endif |
2884 | 3289 | } |
2885 | 3290 | if (!obj1.isBool() || !obj1.getBool()) { |
2886 | 3291 | goto err2; |
2887 | 3292 | } |
| 3293 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3294 | obj1 = maskDict->lookup("Interpolate"); |
| 3295 | #else |
2888 | 3296 | obj1.free(); |
2889 | 3297 | maskDict->lookup("Interpolate", &obj1); |
| 3298 | #endif |
2890 | 3299 | if (obj1.isNull()) { |
| 3300 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3301 | obj1 = maskDict->lookup("I"); |
| 3302 | #else |
2891 | 3303 | obj1.free(); |
2892 | 3304 | maskDict->lookup("I", &obj1); |
| 3305 | #endif |
2893 | 3306 | } |
2894 | 3307 | if (obj1.isBool()) |
2895 | 3308 | maskInterpolate = obj1.getBool(); |
2896 | 3309 | else |
2897 | 3310 | maskInterpolate = gFalse; |
| 3311 | #if !defined(POPPLER_NEW_OBJECT_API) |
2898 | 3312 | obj1.free(); |
| 3313 | #endif |
2899 | 3314 | maskInvert = gFalse; |
| 3315 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3316 | obj1 = maskDict->lookup(const_cast<char*>("Decode")); |
| 3317 | #else |
2900 | 3318 | maskDict->lookup(const_cast<char*>("Decode"), &obj1); |
| 3319 | #endif |
2901 | 3320 | if (obj1.isNull()) { |
| 3321 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3322 | obj1 = maskDict->lookup(const_cast<char*>("D")); |
| 3323 | #else |
2902 | 3324 | obj1.free(); |
2903 | 3325 | maskDict->lookup(const_cast<char*>("D"), &obj1); |
| 3326 | #endif |
2904 | 3327 | } |
2905 | 3328 | if (obj1.isArray()) { |
| 3329 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3330 | obj2 = obj1.arrayGet(0); |
| 3331 | #else |
2906 | 3332 | obj1.arrayGet(0, &obj2); |
| 3333 | #endif |
2907 | 3334 | if (obj2.isInt() && obj2.getInt() == 1) { |
2908 | 3335 | maskInvert = gTrue; |
2909 | 3336 | } |
| 3337 | #if !defined(POPPLER_NEW_OBJECT_API) |
2910 | 3338 | obj2.free(); |
| 3339 | #endif |
2911 | 3340 | } else if (!obj1.isNull()) { |
2912 | 3341 | goto err2; |
2913 | 3342 | } |
| 3343 | #if !defined(POPPLER_NEW_OBJECT_API) |
2914 | 3344 | obj1.free(); |
| 3345 | #endif |
2915 | 3346 | haveExplicitMask = gTrue; |
2916 | 3347 | } |
2917 | 3348 | |
… |
… |
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
|
2929 | 3360 | } |
2930 | 3361 | delete colorMap; |
2931 | 3362 | |
| 3363 | #if !defined(POPPLER_NEW_OBJECT_API) |
2932 | 3364 | maskObj.free(); |
2933 | 3365 | smaskObj.free(); |
| 3366 | #endif |
2934 | 3367 | } |
2935 | 3368 | |
2936 | 3369 | return; |
2937 | 3370 | |
2938 | 3371 | err2: |
| 3372 | #if !defined(POPPLER_NEW_OBJECT_API) |
2939 | 3373 | obj1.free(); |
| 3374 | #endif |
2940 | 3375 | err1: |
2941 | 3376 | error(errSyntaxError, getPos(), "Bad image parameters"); |
2942 | 3377 | } |
… |
… |
void PdfParser::doForm(Object *str) {
|
2961 | 3396 | dict = str->streamGetDict(); |
2962 | 3397 | |
2963 | 3398 | // check form type |
| 3399 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3400 | obj1 = dict->lookup(const_cast<char*>("FormType")); |
| 3401 | #else |
2964 | 3402 | dict->lookup(const_cast<char*>("FormType"), &obj1); |
| 3403 | #endif |
2965 | 3404 | if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { |
2966 | 3405 | error(errSyntaxError, getPos(), "Unknown form type"); |
2967 | 3406 | } |
| 3407 | #if !defined(POPPLER_NEW_OBJECT_API) |
2968 | 3408 | obj1.free(); |
| 3409 | #endif |
2969 | 3410 | |
2970 | 3411 | // get bounding box |
| 3412 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3413 | bboxObj = dict->lookup(const_cast<char*>("BBox")); |
| 3414 | #else |
2971 | 3415 | dict->lookup(const_cast<char*>("BBox"), &bboxObj); |
| 3416 | #endif |
2972 | 3417 | if (!bboxObj.isArray()) { |
| 3418 | #if !defined(POPPLER_NEW_OBJECT_API) |
2973 | 3419 | bboxObj.free(); |
| 3420 | #endif |
2974 | 3421 | error(errSyntaxError, getPos(), "Bad form bounding box"); |
2975 | 3422 | return; |
2976 | 3423 | } |
2977 | 3424 | for (i = 0; i < 4; ++i) { |
| 3425 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3426 | obj1 = bboxObj.arrayGet(i); |
| 3427 | #else |
2978 | 3428 | bboxObj.arrayGet(i, &obj1); |
| 3429 | #endif |
2979 | 3430 | bbox[i] = obj1.getNum(); |
| 3431 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3432 | } |
| 3433 | #else |
2980 | 3434 | obj1.free(); |
2981 | 3435 | } |
2982 | 3436 | bboxObj.free(); |
| 3437 | #endif |
2983 | 3438 | |
2984 | 3439 | // get matrix |
| 3440 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3441 | matrixObj = dict->lookup(const_cast<char*>("Matrix")); |
| 3442 | #else |
2985 | 3443 | dict->lookup(const_cast<char*>("Matrix"), &matrixObj); |
| 3444 | #endif |
2986 | 3445 | if (matrixObj.isArray()) { |
2987 | 3446 | for (i = 0; i < 6; ++i) { |
| 3447 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3448 | obj1 = matrixObj.arrayGet(i); |
| 3449 | #else |
2988 | 3450 | matrixObj.arrayGet(i, &obj1); |
| 3451 | #endif |
2989 | 3452 | m[i] = obj1.getNum(); |
| 3453 | #if !defined(POPPLER_NEW_OBJECT_API) |
2990 | 3454 | obj1.free(); |
| 3455 | #endif |
2991 | 3456 | } |
2992 | 3457 | } else { |
2993 | 3458 | m[0] = 1; m[1] = 0; |
2994 | 3459 | m[2] = 0; m[3] = 1; |
2995 | 3460 | m[4] = 0; m[5] = 0; |
2996 | 3461 | } |
| 3462 | #if !defined(POPPLER_NEW_OBJECT_API) |
2997 | 3463 | matrixObj.free(); |
| 3464 | #endif |
2998 | 3465 | |
2999 | 3466 | // get resources |
| 3467 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3468 | resObj = dict->lookup(const_cast<char*>("Resources")); |
| 3469 | #else |
3000 | 3470 | dict->lookup(const_cast<char*>("Resources"), &resObj); |
| 3471 | #endif |
3001 | 3472 | resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; |
3002 | 3473 | |
3003 | 3474 | // check for a transparency group |
3004 | 3475 | transpGroup = isolated = knockout = gFalse; |
3005 | 3476 | blendingColorSpace = NULL; |
| 3477 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3478 | if ((obj1 = dict->lookup(const_cast<char*>("Group"))).isDict()) { |
| 3479 | if ((obj2 = obj1.dictLookup(const_cast<char*>("S"))).isName(const_cast<char*>("Transparency"))) { |
| 3480 | #else |
3006 | 3481 | if (dict->lookup(const_cast<char*>("Group"), &obj1)->isDict()) { |
3007 | 3482 | if (obj1.dictLookup(const_cast<char*>("S"), &obj2)->isName(const_cast<char*>("Transparency"))) { |
| 3483 | #endif |
3008 | 3484 | transpGroup = gTrue; |
| 3485 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3486 | if (!((obj3 = obj1.dictLookup(const_cast<char*>("CS"))).isNull())) { |
| 3487 | #else |
3009 | 3488 | if (!obj1.dictLookup(const_cast<char*>("CS"), &obj3)->isNull()) { |
| 3489 | #endif |
3010 | 3490 | #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API) |
3011 | 3491 | blendingColorSpace = GfxColorSpace::parse(NULL, &obj3, NULL, NULL); |
3012 | 3492 | #elif defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API) |
… |
… |
void PdfParser::doForm(Object *str) {
|
3015 | 3495 | blendingColorSpace = GfxColorSpace::parse(&obj3, NULL); |
3016 | 3496 | #endif |
3017 | 3497 | } |
| 3498 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3499 | if ((obj3 = obj1.dictLookup(const_cast<char*>("I"))).isBool()) { |
| 3500 | #else |
3018 | 3501 | obj3.free(); |
3019 | 3502 | if (obj1.dictLookup(const_cast<char*>("I"), &obj3)->isBool()) { |
| 3503 | #endif |
3020 | 3504 | isolated = obj3.getBool(); |
3021 | 3505 | } |
| 3506 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3507 | if ((obj3 = obj1.dictLookup(const_cast<char*>("K"))).isBool()) { |
| 3508 | #else |
3022 | 3509 | obj3.free(); |
3023 | 3510 | if (obj1.dictLookup(const_cast<char*>("K"), &obj3)->isBool()) { |
| 3511 | #endif |
3024 | 3512 | knockout = obj3.getBool(); |
3025 | 3513 | } |
| 3514 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3515 | } |
| 3516 | } |
| 3517 | #else |
3026 | 3518 | obj3.free(); |
3027 | 3519 | } |
3028 | 3520 | obj2.free(); |
3029 | 3521 | } |
3030 | 3522 | obj1.free(); |
| 3523 | #endif |
3031 | 3524 | |
3032 | 3525 | // draw it |
3033 | 3526 | ++formDepth; |
… |
… |
void PdfParser::doForm(Object *str) {
|
3038 | 3531 | if (blendingColorSpace) { |
3039 | 3532 | delete blendingColorSpace; |
3040 | 3533 | } |
| 3534 | #if !defined(POPPLER_NEW_OBJECT_API) |
3041 | 3535 | resObj.free(); |
| 3536 | #endif |
3042 | 3537 | } |
3043 | 3538 | |
3044 | 3539 | void PdfParser::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox, |
… |
… |
Stream *PdfParser::buildImageStream() {
|
3166 | 3661 | Stream *str; |
3167 | 3662 | |
3168 | 3663 | // build dictionary |
| 3664 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3665 | dict = Object(new Dict(xref)); |
| 3666 | obj = parser->getObj(); |
| 3667 | #else |
3169 | 3668 | dict.initDict(xref); |
3170 | 3669 | parser->getObj(&obj); |
| 3670 | #endif |
3171 | 3671 | while (!obj.isCmd(const_cast<char*>("ID")) && !obj.isEOF()) { |
3172 | 3672 | if (!obj.isName()) { |
3173 | 3673 | error(errSyntaxError, getPos(), "Inline image dictionary key must be a name object"); |
| 3674 | #if !defined(POPPLER_NEW_OBJECT_API) |
3174 | 3675 | obj.free(); |
| 3676 | #endif |
3175 | 3677 | } else { |
3176 | 3678 | key = copyString(obj.getName()); |
| 3679 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3680 | obj = parser->getObj(); |
| 3681 | #else |
3177 | 3682 | obj.free(); |
3178 | 3683 | parser->getObj(&obj); |
| 3684 | #endif |
3179 | 3685 | if (obj.isEOF() || obj.isError()) { |
3180 | 3686 | gfree(key); |
3181 | 3687 | break; |
3182 | 3688 | } |
| 3689 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3690 | dict.dictAdd(key, std::move(obj)); |
| 3691 | } |
| 3692 | obj = parser->getObj(); |
| 3693 | #else |
3183 | 3694 | dict.dictAdd(key, &obj); |
3184 | 3695 | } |
3185 | 3696 | parser->getObj(&obj); |
| 3697 | #endif |
3186 | 3698 | } |
3187 | 3699 | if (obj.isEOF()) { |
3188 | 3700 | error(errSyntaxError, getPos(), "End of file in inline image"); |
| 3701 | #if !defined(POPPLER_NEW_OBJECT_API) |
3189 | 3702 | obj.free(); |
3190 | 3703 | dict.free(); |
| 3704 | #endif |
3191 | 3705 | return NULL; |
3192 | 3706 | } |
| 3707 | #if !defined(POPPLER_NEW_OBJECT_API) |
3193 | 3708 | obj.free(); |
| 3709 | #endif |
3194 | 3710 | |
3195 | 3711 | // make stream |
| 3712 | #if defined(POPPLER_NEW_OBJECT_API) |
| 3713 | str = new EmbedStream(parser->getStream(), dict.copy(), gFalse, 0); |
| 3714 | str = str->addFilters(dict.getDict()); |
| 3715 | #else |
3196 | 3716 | str = new EmbedStream(parser->getStream(), &dict, gFalse, 0); |
3197 | 3717 | str = str->addFilters(&dict); |
| 3718 | #endif |
3198 | 3719 | |
3199 | 3720 | return str; |
3200 | 3721 | } |