Ticket #9733: inkscape-0.92.2-poppler-1.patch

File inkscape-0.92.2-poppler-1.patch, 40.6 KB (added by Tim Tassonis, 7 years ago)
  • CMakeScripts/DefineDependsandFlags.cmake

    diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake
    index 46fbe75..48979c6 100644
    a b if(ENABLE_POPPLER)  
    131131                POPPLER_VERSION VERSION_EQUAL   "0.29.0")
    132132            set(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API ON)
    133133        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()
    134138    else()
    135139        set(ENABLE_POPPLER_CAIRO OFF)
    136140    endif()
  • config.h.cmake

    diff --git a/config.h.cmake b/config.h.cmake
    index a7ad4b3..60bea0d 100644
    a b  
    107107/* Use color space API from Poppler >= 0.29.0 */
    108108#cmakedefine POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API 1
    109109
     110/* Use object API from Poppler >= 0.58.0 */
     111#cmakedefine POPPLER_NEW_OBJECT_API 1
     112
    110113/* Define to 1 if you have the `pow' function. */
    111114#cmakedefine HAVE_POW 1
    112115
  • src/extension/internal/pdfinput/pdf-input.cpp

    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) {  
    846846        }
    847847
    848848        // Parse the document structure
     849#if defined(POPPLER_NEW_OBJECT_API)
     850        Object obj = page->getContents();
     851#else
    849852        Object obj;
    850853        page->getContents(&obj);
     854#endif
    851855        if (!obj.isNull()) {
    852856            pdf_parser->parse(&obj);
    853857        }
    854858
    855859        // Cleanup
     860#if !defined(POPPLER_NEW_OBJECT_API)
    856861        obj.free();
     862#endif
    857863        delete pdf_parser;
    858864        delete builder;
    859865        g_free(docname);
  • src/extension/internal/pdfinput/pdf-parser.cpp

    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) {  
    414414
    415415  if (obj->isArray()) {
    416416    for (int i = 0; i < obj->arrayGetLength(); ++i) {
     417#if defined(POPPLER_NEW_OBJECT_API)
     418      obj2 = obj->arrayGet(i);
     419#else
    417420      obj->arrayGet(i, &obj2);
     421#endif
    418422      if (!obj2.isStream()) {
    419423        error(errInternal, -1, "Weird page contents");
     424#if !defined(POPPLER_NEW_OBJECT_API)
    420425        obj2.free();
     426#endif
    421427        return;
    422428      }
     429#if !defined(POPPLER_NEW_OBJECT_API)
    423430      obj2.free();
     431#endif
    424432    }
    425433  } else if (!obj->isStream()) {
    426434        error(errInternal, -1, "Weird page contents");
    void PdfParser::go(GBool /*topLevel*/)  
    439447
    440448  // scan a sequence of objects
    441449  int numArgs = 0;
     450#if defined(POPPLER_NEW_OBJECT_API)
     451  obj = parser->getObj();
     452#else
    442453  parser->getObj(&obj);
     454#endif
    443455  while (!obj.isEOF()) {
    444456
    445457    // got a command - execute it
    void PdfParser::go(GBool /*topLevel*/)  
    457469      // Run the operation
    458470      execOp(&obj, args, numArgs);
    459471
     472#if !defined(POPPLER_NEW_OBJECT_API)
    460473      obj.free();
    461474      for (int i = 0; i < numArgs; ++i)
    462475        args[i].free();
     476#endif
    463477      numArgs = 0;
    464478
    465479    // got an argument - save it
    466480    } else if (numArgs < maxArgs) {
     481#if defined(POPPLER_NEW_OBJECT_API)
     482      args[numArgs++] = std::move(obj);
     483#else
    467484      args[numArgs++] = obj;
     485#endif
    468486
    469487    // too many arguments - something is wrong
    470488    } else {
    void PdfParser::go(GBool /*topLevel*/)  
    475493        printf("\n");
    476494        fflush(stdout);
    477495      }
     496#if !defined(POPPLER_NEW_OBJECT_API)
    478497      obj.free();
     498#endif
    479499    }
    480500
    481501    // grab the next object
     502#if defined(POPPLER_NEW_OBJECT_API)
     503    obj = parser->getObj();
     504#else
    482505    parser->getObj(&obj);
     506#endif
    483507  }
     508#if !defined(POPPLER_NEW_OBJECT_API)
    484509  obj.free();
     510#endif
    485511
    486512  // args at end with no command
    487513  if (numArgs > 0) {
    void PdfParser::go(GBool /*topLevel*/)  
    495521      printf("\n");
    496522      fflush(stdout);
    497523    }
     524#if !defined(POPPLER_NEW_OBJECT_API)
    498525    for (int i = 0; i < numArgs; ++i)
    499526      args[i].free();
     527#endif
    500528  }
    501529}
    502530
    void PdfParser::opSetDash(Object args[], int /*numArgs*/)  
    692720  if (length != 0) {
    693721    dash = (double *)gmallocn(length, sizeof(double));
    694722    for (int i = 0; i < length; ++i) {
     723#if defined(POPPLER_NEW_OBJECT_API)
     724      dash[i] = a->get(i).getNum();
     725#else
    695726      Object obj;
    696727      dash[i] = a->get(i, &obj)->getNum();
    697728      obj.free();
     729#endif
    698730    }
    699731  }
    700732  state->setLineDash(dash, length, args[1].getNum());
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    744776  GBool haveBackdropColor = gFalse;
    745777  GBool alpha = gFalse;
    746778
     779#if defined(POPPLER_NEW_OBJECT_API)
     780  if ((obj1 = res->lookupGState(args[0].getName())).isNull()) {
     781#else
    747782  if (!res->lookupGState(args[0].getName(), &obj1)) {
     783#endif
    748784    return;
    749785  }
    750786  if (!obj1.isDict()) {
    751787    error(errSyntaxError, getPos(), "ExtGState '{0:s}' is wrong type"), args[0].getName();
     788#if !defined(POPPLER_NEW_OBJECT_API)
    752789    obj1.free();
     790#endif
    753791    return;
    754792  }
    755793  if (printCommands) {
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    759797  }
    760798
    761799  // 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
    762803  if (!obj1.dictLookup(const_cast<char*>("BM"), &obj2)->isNull()) {
     804#endif
    763805    GfxBlendMode mode = gfxBlendNormal;
    764806    if (state->parseBlendMode(&obj2, &mode)) {
    765807      state->setBlendMode(mode);
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    767809      error(errSyntaxError, getPos(), "Invalid blend mode in ExtGState");
    768810    }
    769811  }
     812#if defined(POPPLER_NEW_OBJECT_API)
     813  if ((obj2 = obj1.dictLookup(const_cast<char*>("ca"))).isNum()) {
     814#else
    770815  obj2.free();
    771816  if (obj1.dictLookup(const_cast<char*>("ca"), &obj2)->isNum()) {
     817#endif
    772818    state->setFillOpacity(obj2.getNum());
    773819  }
     820#if defined(POPPLER_NEW_OBJECT_API)
     821  if ((obj2 = obj1.dictLookup(const_cast<char*>("CA"))).isNum()) {
     822#else
    774823  obj2.free();
    775824  if (obj1.dictLookup(const_cast<char*>("CA"), &obj2)->isNum()) {
     825#endif
    776826    state->setStrokeOpacity(obj2.getNum());
    777827  }
     828#if !defined(POPPLER_NEW_OBJECT_API)
    778829  obj2.free();
     830#endif
    779831
    780832  // fill/stroke overprint
    781833  GBool haveFillOP = gFalse;
     834#if defined(POPPLER_NEW_OBJECT_API)
     835  if ((haveFillOP = (obj2 = obj1.dictLookup(const_cast<char*>("op"))).isBool())) {
     836#else
    782837  if ((haveFillOP = (obj1.dictLookup(const_cast<char*>("op"), &obj2)->isBool()))) {
     838#endif
    783839    state->setFillOverprint(obj2.getBool());
    784840  }
     841#if defined(POPPLER_NEW_OBJECT_API)
     842  if ((obj2 = obj1.dictLookup(const_cast<char*>("OP"))).isBool()) {
     843#else
    785844  obj2.free();
    786845  if (obj1.dictLookup(const_cast<char*>("OP"), &obj2)->isBool()) {
     846#endif
    787847    state->setStrokeOverprint(obj2.getBool());
    788848    if (!haveFillOP) {
    789849      state->setFillOverprint(obj2.getBool());
    790850    }
    791851  }
     852#if !defined(POPPLER_NEW_OBJECT_API)
    792853  obj2.free();
     854#endif
    793855
    794856  // stroke adjust
     857#if defined(POPPLER_NEW_OBJECT_API)
     858  if ((obj2 = obj1.dictLookup(const_cast<char*>("SA"))).isBool()) {
     859#else
    795860  if (obj1.dictLookup(const_cast<char*>("SA"), &obj2)->isBool()) {
     861#endif
    796862    state->setStrokeAdjust(obj2.getBool());
    797863  }
     864#if !defined(POPPLER_NEW_OBJECT_API)
    798865  obj2.free();
     866#endif
    799867
    800868  // 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
    801873  if (obj1.dictLookup(const_cast<char*>("TR2"), &obj2)->isNull()) {
    802874    obj2.free();
    803875    obj1.dictLookup(const_cast<char*>("TR"), &obj2);
     876#endif
    804877  }
    805878  if (obj2.isName(const_cast<char*>("Default")) ||
    806879      obj2.isName(const_cast<char*>("Identity"))) {
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    809882  } else if (obj2.isArray() && obj2.arrayGetLength() == 4) {
    810883    int pos = 4;
    811884    for (int i = 0; i < 4; ++i) {
     885#if defined(POPPLER_NEW_OBJECT_API)
     886      obj3 = obj2.arrayGet(i);
     887#else
    812888      obj2.arrayGet(i, &obj3);
     889#endif
    813890      funcs[i] = Function::parse(&obj3);
     891#if !defined(POPPLER_NEW_OBJECT_API)
    814892      obj3.free();
     893#endif
    815894      if (!funcs[i]) {
    816895        pos = i;
    817896        break;
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    828907  } else if (!obj2.isNull()) {
    829908    error(errSyntaxError, getPos(), "Invalid transfer function in ExtGState");
    830909  }
     910#if !defined(POPPLER_NEW_OBJECT_API)
    831911  obj2.free();
     912#endif
    832913
    833914  // soft mask
     915#if defined(POPPLER_NEW_OBJECT_API)
     916  if (!((obj2 = obj1.dictLookup(const_cast<char*>("SMask"))).isNull())) {
     917#else
    834918  if (!obj1.dictLookup(const_cast<char*>("SMask"), &obj2)->isNull()) {
     919#endif
    835920    if (obj2.isName(const_cast<char*>("None"))) {
    836921      builder->clearSoftMask(state);
    837922    } 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
    838926      if (obj2.dictLookup(const_cast<char*>("S"), &obj3)->isName(const_cast<char*>("Alpha"))) {
     927#endif
    839928        alpha = gTrue;
    840929      } else { // "Luminosity"
    841930        alpha = gFalse;
    842931      }
     932#if !defined(POPPLER_NEW_OBJECT_API)
    843933      obj3.free();
     934#endif
    844935      funcs[0] = NULL;
     936#if defined(POPPLER_NEW_OBJECT_API)
     937      if (!((obj3 = obj2.dictLookup(const_cast<char*>("TR"))).isNull())) {
     938#else
    845939      if (!obj2.dictLookup(const_cast<char*>("TR"), &obj3)->isNull()) {
     940#endif
    846941        funcs[0] = Function::parse(&obj3);
    847942        if (funcs[0]->getInputSize() != 1 ||
    848943            funcs[0]->getOutputSize() != 1) {
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    851946          funcs[0] = NULL;
    852947        }
    853948      }
     949#if defined(POPPLER_NEW_OBJECT_API)
     950      if ((haveBackdropColor = (obj3 = obj2.dictLookup(const_cast<char*>("BC"))).isArray())) {
     951#else
    854952      obj3.free();
    855953      if ((haveBackdropColor = obj2.dictLookup(const_cast<char*>("BC"), &obj3)->isArray())) {
     954#endif
    856955        for (int i = 0; i < gfxColorMaxComps; ++i) {
    857956          backdropColor.c[i] = 0;
    858957        }
    859958        for (int i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) {
     959#if defined(POPPLER_NEW_OBJECT_API)
     960          obj4 = obj3.arrayGet(i);
     961#else
    860962          obj3.arrayGet(i, &obj4);
     963#endif
    861964          if (obj4.isNum()) {
    862965            backdropColor.c[i] = dblToCol(obj4.getNum());
    863966          }
     967#if !defined(POPPLER_NEW_OBJECT_API)
    864968          obj4.free();
     969#endif
    865970        }
    866971      }
     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
    867976      obj3.free();
    868977      if (obj2.dictLookup(const_cast<char*>("G"), &obj3)->isStream()) {
    869978        if (obj3.streamGetDict()->lookup(const_cast<char*>("Group"), &obj4)->isDict()) {
     979#endif
    870980          GfxColorSpace *blendingColorSpace = 0;
    871981          GBool isolated = gFalse;
    872982          GBool knockout = gFalse;
     983#if defined(POPPLER_NEW_OBJECT_API)
     984          if (!((obj5 = obj4.dictLookup(const_cast<char*>("CS"))).isNull())) {
     985#else
    873986          if (!obj4.dictLookup(const_cast<char*>("CS"), &obj5)->isNull()) {
     987#endif
    874988#if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
    875989            blendingColorSpace = GfxColorSpace::parse(NULL, &obj5, NULL, NULL);
    876990#elif defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    879993            blendingColorSpace = GfxColorSpace::parse(&obj5, NULL);
    880994#endif
    881995          }
     996#if defined(POPPLER_NEW_OBJECT_API)
     997          if ((obj5 = obj4.dictLookup(const_cast<char*>("I"))).isBool()) {
     998#else
    882999          obj5.free();
    8831000          if (obj4.dictLookup(const_cast<char*>("I"), &obj5)->isBool()) {
     1001#endif
    8841002            isolated = obj5.getBool();
    8851003          }
     1004#if defined(POPPLER_NEW_OBJECT_API)
     1005          if ((obj5 = obj4.dictLookup(const_cast<char*>("K"))).isBool()) {
     1006#else
    8861007          obj5.free();
    8871008          if (obj4.dictLookup(const_cast<char*>("K"), &obj5)->isBool()) {
     1009#endif
    8881010            knockout = obj5.getBool();
    8891011          }
     1012#if !defined(POPPLER_NEW_OBJECT_API)
    8901013          obj5.free();
     1014#endif
    8911015          if (!haveBackdropColor) {
    8921016            if (blendingColorSpace) {
    8931017              blendingColorSpace->getDefaultColor(&backdropColor);
    void PdfParser::opSetExtGState(Object args[], int /*numArgs*/)  
    9061030        } else {
    9071031          error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group");
    9081032        }
     1033#if !defined(POPPLER_NEW_OBJECT_API)
    9091034        obj4.free();
     1035#endif
    9101036      } else {
    9111037        error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group");
    9121038      }
     1039#if !defined(POPPLER_NEW_OBJECT_API)
    9131040      obj3.free();
     1041#endif
    9141042    } else if (!obj2.isNull()) {
    9151043      error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState");
    9161044    }
    9171045  }
     1046#if !defined(POPPLER_NEW_OBJECT_API)
    9181047  obj2.free();
    9191048
    9201049  obj1.free();
     1050#endif
    9211051}
    9221052
    9231053void PdfParser::doSoftMask(Object *str, GBool alpha,
    void PdfParser::doSoftMask(Object *str, GBool alpha,  
    9381068  dict = str->streamGetDict();
    9391069
    9401070  // check form type
     1071#if defined(POPPLER_NEW_OBJECT_API)
     1072  obj1 = dict->lookup(const_cast<char*>("FormType"));
     1073#else
    9411074  dict->lookup(const_cast<char*>("FormType"), &obj1);
     1075#endif
    9421076  if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) {
    9431077    error(errSyntaxError, getPos(), "Unknown form type");
    9441078  }
     1079#if !defined(POPPLER_NEW_OBJECT_API)
    9451080  obj1.free();
     1081#endif
    9461082
    9471083  // get bounding box
     1084#if defined(POPPLER_NEW_OBJECT_API)
     1085  obj1 = dict->lookup(const_cast<char*>("BBox"));
     1086#else
    9481087  dict->lookup(const_cast<char*>("BBox"), &obj1);
     1088#endif
    9491089  if (!obj1.isArray()) {
     1090#if !defined(POPPLER_NEW_OBJECT_API)
    9501091    obj1.free();
     1092#endif
    9511093    error(errSyntaxError, getPos(), "Bad form bounding box");
    9521094    return;
    9531095  }
    9541096  for (i = 0; i < 4; ++i) {
     1097#if defined(POPPLER_NEW_OBJECT_API)
     1098    obj2 = obj1.arrayGet(i);
     1099#else
    9551100    obj1.arrayGet(i, &obj2);
     1101#endif
    9561102    bbox[i] = obj2.getNum();
     1103#if defined(POPPLER_NEW_OBJECT_API)
     1104  }
     1105#else
    9571106    obj2.free();
    9581107  }
    9591108  obj1.free();
     1109#endif
    9601110
    9611111  // get matrix
     1112#if defined(POPPLER_NEW_OBJECT_API)
     1113  obj1 = dict->lookup(const_cast<char*>("Matrix"));
     1114#else
    9621115  dict->lookup(const_cast<char*>("Matrix"), &obj1);
     1116#endif
    9631117  if (obj1.isArray()) {
    9641118    for (i = 0; i < 6; ++i) {
     1119#if defined(POPPLER_NEW_OBJECT_API)
     1120      obj2 = obj1.arrayGet(i);
     1121#else
    9651122      obj1.arrayGet(i, &obj2);
     1123#endif
    9661124      m[i] = obj2.getNum();
     1125#if !defined(POPPLER_NEW_OBJECT_API)
    9671126      obj2.free();
     1127#endif
    9681128    }
    9691129  } else {
    9701130    m[0] = 1; m[1] = 0;
    9711131    m[2] = 0; m[3] = 1;
    9721132    m[4] = 0; m[5] = 0;
    9731133  }
     1134#if !defined(POPPLER_NEW_OBJECT_API)
    9741135  obj1.free();
     1136#endif
    9751137
    9761138  // get resources
     1139#if defined(POPPLER_NEW_OBJECT_API)
     1140  obj1 = dict->lookup(const_cast<char*>("Resources"));
     1141#else
    9771142  dict->lookup(const_cast<char*>("Resources"), &obj1);
     1143#endif
    9781144  resDict = obj1.isDict() ? obj1.getDict() : (Dict *)NULL;
    9791145
    9801146  // draw it
    void PdfParser::doSoftMask(Object *str, GBool alpha,  
    9871153  if (blendingColorSpace) {
    9881154    delete blendingColorSpace;
    9891155  }
     1156#if !defined(POPPLER_NEW_OBJECT_API)
    9901157  obj1.free();
     1158#endif
    9911159}
    9921160
    9931161void PdfParser::opSetRenderingIntent(Object /*args*/[], int /*numArgs*/)
    void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)  
    10841252  Object obj;
    10851253
    10861254  state->setFillPattern(NULL);
     1255#if defined(POPPLER_NEW_OBJECT_API)
     1256  obj = res->lookupColorSpace(args[0].getName());
     1257#else
    10871258  res->lookupColorSpace(args[0].getName(), &obj);
     1259#endif
    10881260
    10891261  GfxColorSpace *colorSpace = 0;
    10901262#if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
    void PdfParser::opSetFillColorSpace(Object args[], int /*numArgs*/)  
    11061278    colorSpace = GfxColorSpace::parse(&obj, NULL);
    11071279  }
    11081280#endif
     1281#if !defined(POPPLER_NEW_OBJECT_API)
    11091282  obj.free();
     1283#endif
    11101284  if (colorSpace) {
    11111285  GfxColor color;
    11121286    state->setFillColorSpace(colorSpace);
    void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)  
    11251299  GfxColorSpace *colorSpace = 0;
    11261300
    11271301  state->setStrokePattern(NULL);
     1302#if defined(POPPLER_NEW_OBJECT_API)
     1303  obj = res->lookupColorSpace(args[0].getName());
     1304#else
    11281305  res->lookupColorSpace(args[0].getName(), &obj);
     1306#endif
    11291307#if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
    11301308  if (obj.isNull()) {
    11311309    colorSpace = GfxColorSpace::parse(NULL, &args[0], NULL, NULL);
    void PdfParser::opSetStrokeColorSpace(Object args[], int /*numArgs*/)  
    11451323    colorSpace = GfxColorSpace::parse(&obj, NULL);
    11461324  }
    11471325#endif
     1326#if !defined(POPPLER_NEW_OBJECT_API)
    11481327  obj.free();
     1328#endif
    11491329  if (colorSpace) {
    11501330    GfxColor color;
    11511331    state->setStrokeColorSpace(colorSpace);
    void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)  
    23752555  wMode = state->getFont()->getWMode();
    23762556  a = args[0].getArray();
    23772557  for (int i = 0; i < a->getLength(); ++i) {
     2558#if defined(POPPLER_NEW_OBJECT_API)
     2559    obj = a->get(i);
     2560#else
    23782561    a->get(i, &obj);
     2562#endif
    23792563    if (obj.isNum()) {
    23802564      // this uses the absolute value of the font size to match
    23812565      // Acrobat's behavior
    void PdfParser::opShowSpaceText(Object args[], int /*numArgs*/)  
    23922576    } else {
    23932577      error(errSyntaxError, getPos(), "Element of show/space array must be number or string");
    23942578    }
     2579#if !defined(POPPLER_NEW_OBJECT_API)
    23952580    obj.free();
     2581#endif
    23962582  }
    23972583}
    23982584
    void PdfParser::doShowText(GooString *s) {  
    24652651      //out->updateCTM(state, 1, 0, 0, 1, 0, 0);
    24662652      if (0){ /*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy,
    24672653                               code, u, uLen)) {*/
     2654#if defined(POPPLER_NEW_OBJECT_API)
     2655        charProc = ((Gfx8BitFont *)font)->getCharProc(code);
     2656#else
    24682657        ((Gfx8BitFont *)font)->getCharProc(code, &charProc);
     2658#endif
    24692659        if ((resDict = ((Gfx8BitFont *)font)->getResources())) {
    24702660          pushResources(resDict);
    24712661        }
    void PdfParser::doShowText(GooString *s) {  
    24782668        if (resDict) {
    24792669          popResources();
    24802670        }
     2671#if !defined(POPPLER_NEW_OBJECT_API)
    24812672        charProc.free();
     2673#endif
    24822674      }
    24832675      restoreState();
    24842676      // GfxState::restore() does *not* restore the current position,
    void PdfParser::opXObject(Object args[], int /*numArgs*/)  
    25412733  Object obj1, obj2, obj3, refObj;
    25422734
    25432735  char *name = args[0].getName();
     2736#if defined(POPPLER_NEW_OBJECT_API)
     2737  if ((obj1 = res->lookupXObject(name)).isNull()) {
     2738#else
    25442739  if (!res->lookupXObject(name, &obj1)) {
     2740#endif
    25452741    return;
    25462742  }
    25472743  if (!obj1.isStream()) {
    25482744    error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name);
     2745#if !defined(POPPLER_NEW_OBJECT_API)
    25492746    obj1.free();
     2747#endif
    25502748    return;
    25512749  }
     2750#if defined(POPPLER_NEW_OBJECT_API)
     2751  obj2 = obj1.streamGetDict()->lookup(const_cast<char*>("Subtype"));
     2752#else
    25522753  obj1.streamGetDict()->lookup(const_cast<char*>("Subtype"), &obj2);
     2754#endif
    25532755  if (obj2.isName(const_cast<char*>("Image"))) {
     2756#if defined(POPPLER_NEW_OBJECT_API)
     2757    refObj = res->lookupXObjectNF(name);
     2758#else
    25542759    res->lookupXObjectNF(name, &refObj);
     2760#endif
    25552761    doImage(&refObj, obj1.getStream(), gFalse);
     2762#if !defined(POPPLER_NEW_OBJECT_API)
    25562763    refObj.free();
     2764#endif
    25572765  } else if (obj2.isName(const_cast<char*>("Form"))) {
    25582766    doForm(&obj1);
    25592767  } 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
    25602771    obj1.streamGetDict()->lookup(const_cast<char*>("Level1"), &obj3);
     2772#endif
    25612773/*    out->psXObject(obj1.getStream(),
    25622774                   obj3.isStream() ? obj3.getStream() : (Stream *)NULL);*/
    25632775  } else if (obj2.isName()) {
    void PdfParser::opXObject(Object args[], int /*numArgs*/)  
    25652777  } else {
    25662778    error(errSyntaxError, getPos(), "XObject subtype is missing or wrong type");
    25672779  }
     2780#if !defined(POPPLER_NEW_OBJECT_API)
    25682781  obj2.free();
    25692782  obj1.free();
     2783#endif
    25702784}
    25712785
    25722786void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    25932807    dict = str->getDict();
    25942808   
    25952809    // get size
     2810#if defined(POPPLER_NEW_OBJECT_API)
     2811    obj1 = dict->lookup(const_cast<char*>("Width"));
     2812#else
    25962813    dict->lookup(const_cast<char*>("Width"), &obj1);
     2814#endif
    25972815    if (obj1.isNull()) {
     2816#if defined(POPPLER_NEW_OBJECT_API)
     2817        obj1 = dict->lookup(const_cast<char*>("W"));
     2818#else
    25982819        obj1.free();
    25992820        dict->lookup(const_cast<char*>("W"), &obj1);
     2821#endif
    26002822    }
    26012823    if (obj1.isInt()){
    26022824        width = obj1.getInt();
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    26072829    else {
    26082830        goto err2;
    26092831    }
     2832#if defined(POPPLER_NEW_OBJECT_API)
     2833    obj1 = dict->lookup(const_cast<char*>("Height"));
     2834#else
    26102835    obj1.free();
    26112836    dict->lookup(const_cast<char*>("Height"), &obj1);
     2837#endif
    26122838    if (obj1.isNull()) {
     2839#if defined(POPPLER_NEW_OBJECT_API)
     2840        obj1 = dict->lookup(const_cast<char*>("H"));
     2841#else
    26132842        obj1.free();
    26142843        dict->lookup(const_cast<char*>("H"), &obj1);
     2844#endif
    26152845    }
    26162846    if (obj1.isInt()) {
    26172847        height = obj1.getInt();
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    26222852    else {
    26232853        goto err2;
    26242854    }
     2855#if !defined(POPPLER_NEW_OBJECT_API)
    26252856    obj1.free();
     2857#endif
    26262858   
    26272859    // image interpolation
     2860#if defined(POPPLER_NEW_OBJECT_API)
     2861    obj1 = dict->lookup("Interpolate");
     2862#else
    26282863    dict->lookup("Interpolate", &obj1);
     2864#endif
    26292865    if (obj1.isNull()) {
     2866#if defined(POPPLER_NEW_OBJECT_API)
     2867      obj1 = dict->lookup("I");
     2868#else
    26302869      obj1.free();
    26312870      dict->lookup("I", &obj1);
     2871#endif
    26322872    }
    26332873    if (obj1.isBool())
    26342874      interpolate = obj1.getBool();
    26352875    else
    26362876      interpolate = gFalse;
     2877#if !defined(POPPLER_NEW_OBJECT_API)
    26372878    obj1.free();
     2879#endif
    26382880    maskInterpolate = gFalse;
    26392881
    26402882    // image or mask?
     2883#if defined(POPPLER_NEW_OBJECT_API)
     2884    obj1 = dict->lookup(const_cast<char*>("ImageMask"));
     2885#else
    26412886    dict->lookup(const_cast<char*>("ImageMask"), &obj1);
     2887#endif
    26422888    if (obj1.isNull()) {
     2889#if defined(POPPLER_NEW_OBJECT_API)
     2890        obj1 = dict->lookup(const_cast<char*>("IM"));
     2891#else
    26432892        obj1.free();
    26442893        dict->lookup(const_cast<char*>("IM"), &obj1);
     2894#endif
    26452895    }
    26462896    mask = gFalse;
    26472897    if (obj1.isBool()) {
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    26502900    else if (!obj1.isNull()) {
    26512901        goto err2;
    26522902    }
     2903#if !defined(POPPLER_NEW_OBJECT_API)
    26532904    obj1.free();
     2905#endif
    26542906   
    26552907    // bit depth
    26562908    if (bits == 0) {
     2909#if defined(POPPLER_NEW_OBJECT_API)
     2910        obj1 = dict->lookup(const_cast<char*>("BitsPerComponent"));
     2911#else
    26572912        dict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
     2913#endif
    26582914        if (obj1.isNull()) {
     2915#if defined(POPPLER_NEW_OBJECT_API)
     2916            obj1 = dict->lookup(const_cast<char*>("BPC"));
     2917#else
    26592918            obj1.free();
    26602919            dict->lookup(const_cast<char*>("BPC"), &obj1);
     2920#endif
    26612921        }
    26622922        if (obj1.isInt()) {
    26632923            bits = obj1.getInt();
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    26662926        } else {
    26672927            goto err2;
    26682928        }
     2929#if !defined(POPPLER_NEW_OBJECT_API)
    26692930        obj1.free();
     2931#endif
    26702932    }
    26712933   
    26722934    // display a mask
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    26762938            goto err1;
    26772939        }
    26782940        invert = gFalse;
     2941#if defined(POPPLER_NEW_OBJECT_API)
     2942        obj1 = dict->lookup(const_cast<char*>("Decode"));
     2943#else
    26792944        dict->lookup(const_cast<char*>("Decode"), &obj1);
     2945#endif
    26802946        if (obj1.isNull()) {
     2947#if defined(POPPLER_NEW_OBJECT_API)
     2948            obj1 = dict->lookup(const_cast<char*>("D"));
     2949#else
    26812950            obj1.free();
    26822951            dict->lookup(const_cast<char*>("D"), &obj1);
     2952#endif
    26832953        }
    26842954        if (obj1.isArray()) {
     2955#if defined(POPPLER_NEW_OBJECT_API)
     2956            obj2 = obj1.arrayGet(0);
     2957#else
    26852958            obj1.arrayGet(0, &obj2);
     2959#endif
    26862960            if (obj2.isInt() && obj2.getInt() == 1) {
    26872961                invert = gTrue;
    26882962            }
     2963#if !defined(POPPLER_NEW_OBJECT_API)
    26892964            obj2.free();
     2965#endif
    26902966        } else if (!obj1.isNull()) {
    26912967            goto err2;
    26922968        }
     2969#if !defined(POPPLER_NEW_OBJECT_API)
    26932970        obj1.free();
     2971#endif
    26942972       
    26952973        // draw it
    26962974        builder->addImageMask(state, str, width, height, invert, interpolate);
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    26982976    } else {
    26992977        // get color space and color map
    27002978        GfxColorSpace *colorSpace;
     2979#if defined(POPPLER_NEW_OBJECT_API)
     2980        obj1 = dict->lookup(const_cast<char*>("ColorSpace"));
     2981#else
    27012982        dict->lookup(const_cast<char*>("ColorSpace"), &obj1);
     2983#endif
    27022984        if (obj1.isNull()) {
     2985#if defined(POPPLER_NEW_OBJECT_API)
     2986            obj1 = dict->lookup(const_cast<char*>("CS"));
     2987#else
    27032988            obj1.free();
    27042989            dict->lookup(const_cast<char*>("CS"), &obj1);
     2990#endif
    27052991        }
    27062992        if (obj1.isName()) {
     2993#if defined(POPPLER_NEW_OBJECT_API)
     2994            obj2 = res->lookupColorSpace(obj1.getName());
     2995#else
    27072996            res->lookupColorSpace(obj1.getName(), &obj2);
     2997#endif
    27082998            if (!obj2.isNull()) {
     2999#if defined(POPPLER_NEW_OBJECT_API)
     3000                    obj1 = std::move(obj2);
     3001#else
    27093002                    obj1.free();
    27103003                    obj1 = obj2;
     3004#endif
    27113005            } else {
     3006#if !defined(POPPLER_NEW_OBJECT_API)
    27123007                    obj2.free();
     3008#endif
    27133009            }
    27143010        }
    27153011        if (!obj1.isNull()) {
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    27293025        } else {
    27303026            colorSpace = NULL;
    27313027        }
     3028#if !defined(POPPLER_NEW_OBJECT_API)
    27323029        obj1.free();
     3030#endif
    27333031        if (!colorSpace) {
    27343032            goto err1;
    27353033        }
     3034#if defined(POPPLER_NEW_OBJECT_API)
     3035        obj1 = dict->lookup(const_cast<char*>("Decode"));
     3036#else
    27363037        dict->lookup(const_cast<char*>("Decode"), &obj1);
     3038#endif
    27373039        if (obj1.isNull()) {
     3040#if defined(POPPLER_NEW_OBJECT_API)
     3041            obj1 = dict->lookup(const_cast<char*>("D"));
     3042#else
    27383043            obj1.free();
    27393044            dict->lookup(const_cast<char*>("D"), &obj1);
     3045#endif
    27403046        }
    27413047        GfxImageColorMap *colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
     3048#if !defined(POPPLER_NEW_OBJECT_API)
    27423049        obj1.free();
     3050#endif
    27433051        if (!colorMap->isOk()) {
    27443052            delete colorMap;
    27453053            goto err1;
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    27533061        int maskHeight = 0;
    27543062        maskInvert = gFalse;
    27553063        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
    27563068        dict->lookup(const_cast<char*>("Mask"), &maskObj);
    27573069        dict->lookup(const_cast<char*>("SMask"), &smaskObj);
     3070#endif
    27583071        Dict* maskDict;
    27593072        if (smaskObj.isStream()) {
    27603073            // soft mask
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    27633076            }
    27643077            maskStr = smaskObj.getStream();
    27653078            maskDict = smaskObj.streamGetDict();
     3079#if defined(POPPLER_NEW_OBJECT_API)
     3080            obj1 = maskDict->lookup(const_cast<char*>("Width"));
     3081#else
    27663082            maskDict->lookup(const_cast<char*>("Width"), &obj1);
     3083#endif
    27673084            if (obj1.isNull()) {
     3085#if defined(POPPLER_NEW_OBJECT_API)
     3086                    obj1 = maskDict->lookup(const_cast<char*>("W"));
     3087#else
    27683088                    obj1.free();
    27693089                    maskDict->lookup(const_cast<char*>("W"), &obj1);
     3090#endif
    27703091            }
    27713092            if (!obj1.isInt()) {
    27723093                    goto err2;
    27733094            }
    27743095            maskWidth = obj1.getInt();
     3096#if defined(POPPLER_NEW_OBJECT_API)
     3097            obj1 = maskDict->lookup(const_cast<char*>("Height"));
     3098#else
    27753099            obj1.free();
    27763100            maskDict->lookup(const_cast<char*>("Height"), &obj1);
     3101#endif
    27773102            if (obj1.isNull()) {
     3103#if defined(POPPLER_NEW_OBJECT_API)
     3104                    obj1 = maskDict->lookup(const_cast<char*>("H"));
     3105#else
    27783106                    obj1.free();
    27793107                    maskDict->lookup(const_cast<char*>("H"), &obj1);
     3108#endif
    27803109            }
    27813110            if (!obj1.isInt()) {
    27823111                    goto err2;
    27833112            }
    27843113            maskHeight = obj1.getInt();
     3114#if defined(POPPLER_NEW_OBJECT_API)
     3115            obj1 = maskDict->lookup(const_cast<char*>("BitsPerComponent"));
     3116#else
    27853117            obj1.free();
    27863118            maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
     3119#endif
    27873120            if (obj1.isNull()) {
     3121#if defined(POPPLER_NEW_OBJECT_API)
     3122                    obj1 = maskDict->lookup(const_cast<char*>("BPC"));
     3123#else
    27883124                    obj1.free();
    27893125                    maskDict->lookup(const_cast<char*>("BPC"), &obj1);
     3126#endif
    27903127            }
    27913128            if (!obj1.isInt()) {
    27923129                    goto err2;
    27933130            }
    27943131            int maskBits = obj1.getInt();
     3132#if defined(POPPLER_NEW_OBJECT_API)
     3133            obj1 = maskDict->lookup(const_cast<char*>("Interpolate"));
     3134#else
    27953135            obj1.free();
    27963136            maskDict->lookup("Interpolate", &obj1);
     3137#endif
    27973138            if (obj1.isNull()) {
     3139#if defined(POPPLER_NEW_OBJECT_API)
     3140              obj1 = maskDict->lookup(const_cast<char*>("I"));
     3141#else
    27983142              obj1.free();
    27993143              maskDict->lookup("I", &obj1);
     3144#endif
    28003145            }
    28013146            if (obj1.isBool())
    28023147              maskInterpolate = obj1.getBool();
    28033148            else
    28043149              maskInterpolate = gFalse;
     3150#if defined(POPPLER_NEW_OBJECT_API)
     3151            obj1 = maskDict->lookup(const_cast<char*>("ColorSpace"));
     3152#else
    28053153            obj1.free();
    28063154            maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1);
     3155#endif
    28073156            if (obj1.isNull()) {
     3157#if defined(POPPLER_NEW_OBJECT_API)
     3158                    obj1 = maskDict->lookup(const_cast<char*>("CS"));
     3159#else
    28083160                    obj1.free();
    28093161                    maskDict->lookup(const_cast<char*>("CS"), &obj1);
     3162#endif
    28103163            }
    28113164            if (obj1.isName()) {
     3165#if defined(POPPLER_NEW_OBJECT_API)
     3166                    obj2 = res->lookupColorSpace(obj1.getName());
     3167#else
    28123168                    res->lookupColorSpace(obj1.getName(), &obj2);
     3169#endif
    28133170                    if (!obj2.isNull()) {
     3171#if defined(POPPLER_NEW_OBJECT_API)
     3172                        obj1 = std::move(obj2);
     3173#else
    28143174                        obj1.free();
    28153175                    obj1 = obj2;
     3176#endif
    28163177                    } else {
     3178#if !defined(POPPLER_NEW_OBJECT_API)
    28173179                        obj2.free();
     3180#endif
    28183181                    }
    28193182            }
    28203183#if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    28243187#else
    28253188            GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
    28263189#endif
     3190#if !defined(POPPLER_NEW_OBJECT_API)
    28273191            obj1.free();
     3192#endif
    28283193            if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
    28293194                goto err1;
    28303195            }
     3196#if defined(POPPLER_NEW_OBJECT_API)
     3197            obj1 = maskDict->lookup(const_cast<char*>("Decode"));
     3198#else
    28313199            maskDict->lookup(const_cast<char*>("Decode"), &obj1);
     3200#endif
    28323201            if (obj1.isNull()) {
     3202#if defined(POPPLER_NEW_OBJECT_API)
     3203                obj1 = maskDict->lookup(const_cast<char*>("D"));
     3204#else
    28333205                    obj1.free();
    28343206                maskDict->lookup(const_cast<char*>("D"), &obj1);
     3207#endif
    28353208            }
    28363209            maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace);
     3210#if !defined(POPPLER_NEW_OBJECT_API)
    28373211            obj1.free();
     3212#endif
    28383213            if (!maskColorMap->isOk()) {
    28393214                delete maskColorMap;
    28403215                goto err1;
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    28453220            // color key mask
    28463221            int i;
    28473222            for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) {
     3223#if defined(POPPLER_NEW_OBJECT_API)
     3224                obj1 = maskObj.arrayGet(i);
     3225#else
    28483226                maskObj.arrayGet(i, &obj1);
     3227#endif
    28493228                maskColors[i] = obj1.getInt();
     3229#if !defined(POPPLER_NEW_OBJECT_API)
    28503230                obj1.free();
     3231#endif
    28513232            }
    28523233              haveColorKeyMask = gTrue;
    28533234        } else if (maskObj.isStream()) {
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    28573238            }
    28583239            maskStr = maskObj.getStream();
    28593240            maskDict = maskObj.streamGetDict();
     3241#if defined(POPPLER_NEW_OBJECT_API)
     3242            obj1 = maskDict->lookup(const_cast<char*>("Width"));
     3243#else
    28603244            maskDict->lookup(const_cast<char*>("Width"), &obj1);
     3245#endif
    28613246            if (obj1.isNull()) {
     3247#if defined(POPPLER_NEW_OBJECT_API)
     3248                obj1 = maskDict->lookup(const_cast<char*>("W"));
     3249#else
    28623250                obj1.free();
    28633251                maskDict->lookup(const_cast<char*>("W"), &obj1);
     3252#endif
    28643253            }
    28653254            if (!obj1.isInt()) {
    28663255                goto err2;
    28673256            }
    28683257            maskWidth = obj1.getInt();
     3258#if defined(POPPLER_NEW_OBJECT_API)
     3259            obj1 = maskDict->lookup(const_cast<char*>("Height"));
     3260#else
    28693261            obj1.free();
    28703262            maskDict->lookup(const_cast<char*>("Height"), &obj1);
     3263#endif
    28713264            if (obj1.isNull()) {
     3265#if defined(POPPLER_NEW_OBJECT_API)
     3266                obj1 = maskDict->lookup(const_cast<char*>("H"));
     3267#else
    28723268                obj1.free();
    28733269                maskDict->lookup(const_cast<char*>("H"), &obj1);
     3270#endif
    28743271            }
    28753272            if (!obj1.isInt()) {
    28763273                goto err2;
    28773274            }
    28783275            maskHeight = obj1.getInt();
     3276#if defined(POPPLER_NEW_OBJECT_API)
     3277            obj1 = maskDict->lookup(const_cast<char*>("ImageMask"));
     3278#else
    28793279            obj1.free();
    28803280            maskDict->lookup(const_cast<char*>("ImageMask"), &obj1);
     3281#endif
    28813282            if (obj1.isNull()) {
     3283#if defined(POPPLER_NEW_OBJECT_API)
     3284                obj1 = maskDict->lookup(const_cast<char*>("IM"));
     3285#else
    28823286                obj1.free();
    28833287                maskDict->lookup(const_cast<char*>("IM"), &obj1);
     3288#endif
    28843289            }
    28853290            if (!obj1.isBool() || !obj1.getBool()) {
    28863291                goto err2;
    28873292            }
     3293#if defined(POPPLER_NEW_OBJECT_API)
     3294            obj1 = maskDict->lookup("Interpolate");
     3295#else
    28883296            obj1.free();
    28893297            maskDict->lookup("Interpolate", &obj1);
     3298#endif
    28903299            if (obj1.isNull()) {
     3300#if defined(POPPLER_NEW_OBJECT_API)
     3301              obj1 = maskDict->lookup("I");
     3302#else
    28913303              obj1.free();
    28923304              maskDict->lookup("I", &obj1);
     3305#endif
    28933306            }
    28943307            if (obj1.isBool())
    28953308              maskInterpolate = obj1.getBool();
    28963309            else
    28973310              maskInterpolate = gFalse;
     3311#if !defined(POPPLER_NEW_OBJECT_API)
    28983312            obj1.free();
     3313#endif
    28993314            maskInvert = gFalse;
     3315#if defined(POPPLER_NEW_OBJECT_API)
     3316            obj1 = maskDict->lookup(const_cast<char*>("Decode"));
     3317#else
    29003318            maskDict->lookup(const_cast<char*>("Decode"), &obj1);
     3319#endif
    29013320            if (obj1.isNull()) {
     3321#if defined(POPPLER_NEW_OBJECT_API)
     3322                obj1 = maskDict->lookup(const_cast<char*>("D"));
     3323#else
    29023324                obj1.free();
    29033325                maskDict->lookup(const_cast<char*>("D"), &obj1);
     3326#endif
    29043327            }
    29053328            if (obj1.isArray()) {
     3329#if defined(POPPLER_NEW_OBJECT_API)
     3330                obj2 = obj1.arrayGet(0);
     3331#else
    29063332                obj1.arrayGet(0, &obj2);
     3333#endif
    29073334                if (obj2.isInt() && obj2.getInt() == 1) {
    29083335                    maskInvert = gTrue;
    29093336                }
     3337#if !defined(POPPLER_NEW_OBJECT_API)
    29103338                obj2.free();
     3339#endif
    29113340            } else if (!obj1.isNull()) {
    29123341                goto err2;
    29133342            }
     3343#if !defined(POPPLER_NEW_OBJECT_API)
    29143344            obj1.free();
     3345#endif
    29153346            haveExplicitMask = gTrue;
    29163347        }
    29173348       
    void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)  
    29293360        }
    29303361        delete colorMap;
    29313362       
     3363#if !defined(POPPLER_NEW_OBJECT_API)
    29323364        maskObj.free();
    29333365        smaskObj.free();
     3366#endif
    29343367    }
    29353368
    29363369    return;
    29373370
    29383371 err2:
     3372#if !defined(POPPLER_NEW_OBJECT_API)
    29393373    obj1.free();
     3374#endif
    29403375 err1:
    29413376    error(errSyntaxError, getPos(), "Bad image parameters");
    29423377}
    void PdfParser::doForm(Object *str) {  
    29613396  dict = str->streamGetDict();
    29623397
    29633398  // check form type
     3399#if defined(POPPLER_NEW_OBJECT_API)
     3400  obj1 = dict->lookup(const_cast<char*>("FormType"));
     3401#else
    29643402  dict->lookup(const_cast<char*>("FormType"), &obj1);
     3403#endif
    29653404  if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) {
    29663405    error(errSyntaxError, getPos(), "Unknown form type");
    29673406  }
     3407#if !defined(POPPLER_NEW_OBJECT_API)
    29683408  obj1.free();
     3409#endif
    29693410
    29703411  // get bounding box
     3412#if defined(POPPLER_NEW_OBJECT_API)
     3413  bboxObj = dict->lookup(const_cast<char*>("BBox"));
     3414#else
    29713415  dict->lookup(const_cast<char*>("BBox"), &bboxObj);
     3416#endif
    29723417  if (!bboxObj.isArray()) {
     3418#if !defined(POPPLER_NEW_OBJECT_API)
    29733419    bboxObj.free();
     3420#endif
    29743421    error(errSyntaxError, getPos(), "Bad form bounding box");
    29753422    return;
    29763423  }
    29773424  for (i = 0; i < 4; ++i) {
     3425#if defined(POPPLER_NEW_OBJECT_API)
     3426    obj1 = bboxObj.arrayGet(i);
     3427#else
    29783428    bboxObj.arrayGet(i, &obj1);
     3429#endif
    29793430    bbox[i] = obj1.getNum();
     3431#if defined(POPPLER_NEW_OBJECT_API)
     3432  }
     3433#else
    29803434    obj1.free();
    29813435  }
    29823436  bboxObj.free();
     3437#endif
    29833438
    29843439  // get matrix
     3440#if defined(POPPLER_NEW_OBJECT_API)
     3441  matrixObj = dict->lookup(const_cast<char*>("Matrix"));
     3442#else
    29853443  dict->lookup(const_cast<char*>("Matrix"), &matrixObj);
     3444#endif
    29863445  if (matrixObj.isArray()) {
    29873446    for (i = 0; i < 6; ++i) {
     3447#if defined(POPPLER_NEW_OBJECT_API)
     3448      obj1 = matrixObj.arrayGet(i);
     3449#else
    29883450      matrixObj.arrayGet(i, &obj1);
     3451#endif
    29893452      m[i] = obj1.getNum();
     3453#if !defined(POPPLER_NEW_OBJECT_API)
    29903454      obj1.free();
     3455#endif
    29913456    }
    29923457  } else {
    29933458    m[0] = 1; m[1] = 0;
    29943459    m[2] = 0; m[3] = 1;
    29953460    m[4] = 0; m[5] = 0;
    29963461  }
     3462#if !defined(POPPLER_NEW_OBJECT_API)
    29973463  matrixObj.free();
     3464#endif
    29983465
    29993466  // get resources
     3467#if defined(POPPLER_NEW_OBJECT_API)
     3468  resObj = dict->lookup(const_cast<char*>("Resources"));
     3469#else
    30003470  dict->lookup(const_cast<char*>("Resources"), &resObj);
     3471#endif
    30013472  resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL;
    30023473
    30033474  // check for a transparency group
    30043475  transpGroup = isolated = knockout = gFalse;
    30053476  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
    30063481  if (dict->lookup(const_cast<char*>("Group"), &obj1)->isDict()) {
    30073482    if (obj1.dictLookup(const_cast<char*>("S"), &obj2)->isName(const_cast<char*>("Transparency"))) {
     3483#endif
    30083484      transpGroup = gTrue;
     3485#if defined(POPPLER_NEW_OBJECT_API)
     3486      if (!((obj3 = obj1.dictLookup(const_cast<char*>("CS"))).isNull())) {
     3487#else
    30093488      if (!obj1.dictLookup(const_cast<char*>("CS"), &obj3)->isNull()) {
     3489#endif
    30103490#if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API)
    30113491        blendingColorSpace = GfxColorSpace::parse(NULL, &obj3, NULL, NULL);
    30123492#elif defined(POPPLER_EVEN_NEWER_COLOR_SPACE_API)
    void PdfParser::doForm(Object *str) {  
    30153495        blendingColorSpace = GfxColorSpace::parse(&obj3, NULL);
    30163496#endif
    30173497      }
     3498#if defined(POPPLER_NEW_OBJECT_API)
     3499      if ((obj3 = obj1.dictLookup(const_cast<char*>("I"))).isBool()) {
     3500#else
    30183501      obj3.free();
    30193502      if (obj1.dictLookup(const_cast<char*>("I"), &obj3)->isBool()) {
     3503#endif
    30203504        isolated = obj3.getBool();
    30213505      }
     3506#if defined(POPPLER_NEW_OBJECT_API)
     3507      if ((obj3 = obj1.dictLookup(const_cast<char*>("K"))).isBool()) {
     3508#else
    30223509      obj3.free();
    30233510      if (obj1.dictLookup(const_cast<char*>("K"), &obj3)->isBool()) {
     3511#endif
    30243512        knockout = obj3.getBool();
    30253513      }
     3514#if defined(POPPLER_NEW_OBJECT_API)
     3515    }
     3516  }
     3517#else
    30263518      obj3.free();
    30273519    }
    30283520    obj2.free();
    30293521  }
    30303522  obj1.free();
     3523#endif
    30313524
    30323525  // draw it
    30333526  ++formDepth;
    void PdfParser::doForm(Object *str) {  
    30383531  if (blendingColorSpace) {
    30393532    delete blendingColorSpace;
    30403533  }
     3534#if !defined(POPPLER_NEW_OBJECT_API)
    30413535  resObj.free();
     3536#endif
    30423537}
    30433538
    30443539void PdfParser::doForm1(Object *str, Dict *resDict, double *matrix, double *bbox,
    Stream *PdfParser::buildImageStream() {  
    31663661  Stream *str;
    31673662
    31683663  // build dictionary
     3664#if defined(POPPLER_NEW_OBJECT_API)
     3665  dict = Object(new Dict(xref));
     3666  obj = parser->getObj();
     3667#else
    31693668  dict.initDict(xref);
    31703669  parser->getObj(&obj);
     3670#endif
    31713671  while (!obj.isCmd(const_cast<char*>("ID")) && !obj.isEOF()) {
    31723672    if (!obj.isName()) {
    31733673      error(errSyntaxError, getPos(), "Inline image dictionary key must be a name object");
     3674#if !defined(POPPLER_NEW_OBJECT_API)
    31743675      obj.free();
     3676#endif
    31753677    } else {
    31763678      key = copyString(obj.getName());
     3679#if defined(POPPLER_NEW_OBJECT_API)
     3680      obj = parser->getObj();
     3681#else
    31773682      obj.free();
    31783683      parser->getObj(&obj);
     3684#endif
    31793685      if (obj.isEOF() || obj.isError()) {
    31803686        gfree(key);
    31813687        break;
    31823688      }
     3689#if defined(POPPLER_NEW_OBJECT_API)
     3690      dict.dictAdd(key, std::move(obj));
     3691    }
     3692    obj = parser->getObj();
     3693#else
    31833694      dict.dictAdd(key, &obj);
    31843695    }
    31853696    parser->getObj(&obj);
     3697#endif
    31863698  }
    31873699  if (obj.isEOF()) {
    31883700    error(errSyntaxError, getPos(), "End of file in inline image");
     3701#if !defined(POPPLER_NEW_OBJECT_API)
    31893702    obj.free();
    31903703    dict.free();
     3704#endif
    31913705    return NULL;
    31923706  }
     3707#if !defined(POPPLER_NEW_OBJECT_API)
    31933708  obj.free();
     3709#endif
    31943710
    31953711  // 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
    31963716  str = new EmbedStream(parser->getStream(), &dict, gFalse, 0);
    31973717  str = str->addFilters(&dict);
     3718#endif
    31983719
    31993720  return str;
    32003721}