Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 630482 | Differences between
and this patch

Collapse All | Expand All

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

Return to bug 630482