| @@ -1,22 +1,23 @@ | | | @@ -1,22 +1,23 @@ |
1 | $NetBSD: patch-src_extension_internal_pdfinput_pdf-parser.cpp,v 1.6 2017/09/09 21:48:56 prlw1 Exp $ | | 1 | $NetBSD: patch-src_extension_internal_pdfinput_pdf-parser.cpp,v 1.7 2018/05/01 06:17:11 wiz Exp $ |
2 | | | 2 | |
3 | - Object.h is included in pdf-parser.h -- see patch for pdf-parser.h. | | 3 | - Object.h is included in pdf-parser.h -- see patch for pdf-parser.h. |
4 | - Support poppler 0.58 | | 4 | - Support poppler 0.58 |
5 | https://gitlab.com/inkscape/inkscape/commit/9418824967eb4c53371ef8588243fed4cab496e0 | | 5 | https://gitlab.com/inkscape/inkscape/commit/9418824967eb4c53371ef8588243fed4cab496e0 |
| | | 6 | - Support poppler 0.64 |
6 | | | 7 | |
7 | --- src/extension/internal/pdfinput/pdf-parser.cpp.orig 2014-06-09 13:24:41.000000000 +0000 | | 8 | --- src/extension/internal/pdfinput/pdf-parser.cpp.orig 2017-08-06 20:44:00.000000000 +0000 |
8 | +++ src/extension/internal/pdfinput/pdf-parser.cpp | | 9 | +++ src/extension/internal/pdfinput/pdf-parser.cpp |
9 | @@ -38,7 +38,7 @@ extern "C" { | | 10 | @@ -41,7 +41,7 @@ extern "C" { |
10 | #include "goo/GooHash.h" | | 11 | #include "goo/GooHash.h" |
11 | #include "GlobalParams.h" | | 12 | #include "GlobalParams.h" |
12 | #include "CharTypes.h" | | 13 | #include "CharTypes.h" |
13 | -#include "Object.h" | | 14 | -#include "Object.h" |
14 | +#define POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API 1 | | 15 | +#define POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API 1 |
15 | #include "Array.h" | | 16 | #include "Array.h" |
16 | #include "Dict.h" | | 17 | #include "Dict.h" |
17 | #include "Stream.h" | | 18 | #include "Stream.h" |
18 | @@ -414,13 +414,21 @@ void PdfParser::parse(Object *obj, GBool | | 19 | @@ -414,13 +414,21 @@ void PdfParser::parse(Object *obj, GBool |
19 | | | 20 | |
20 | if (obj->isArray()) { | | 21 | if (obj->isArray()) { |
21 | for (int i = 0; i < obj->arrayGetLength(); ++i) { | | 22 | for (int i = 0; i < obj->arrayGetLength(); ++i) { |
22 | +#if defined(POPPLER_NEW_OBJECT_API) | | 23 | +#if defined(POPPLER_NEW_OBJECT_API) |
| @@ -495,39 +496,71 @@ $NetBSD: patch-src_extension_internal_pd | | | @@ -495,39 +496,71 @@ $NetBSD: patch-src_extension_internal_pd |
495 | #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API) | | 496 | #if defined(POPPLER_EVEN_NEWER_NEW_COLOR_SPACE_API) |
496 | if (obj.isNull()) { | | 497 | if (obj.isNull()) { |
497 | colorSpace = GfxColorSpace::parse(NULL, &args[0], NULL, NULL); | | 498 | colorSpace = GfxColorSpace::parse(NULL, &args[0], NULL, NULL); |
498 | @@ -1145,7 +1323,9 @@ void PdfParser::opSetStrokeColorSpace(Ob | | 499 | @@ -1145,7 +1323,9 @@ void PdfParser::opSetStrokeColorSpace(Ob |
499 | colorSpace = GfxColorSpace::parse(&obj, NULL); | | 500 | colorSpace = GfxColorSpace::parse(&obj, NULL); |
500 | } | | 501 | } |
501 | #endif | | 502 | #endif |
502 | +#if !defined(POPPLER_NEW_OBJECT_API) | | 503 | +#if !defined(POPPLER_NEW_OBJECT_API) |
503 | obj.free(); | | 504 | obj.free(); |
504 | +#endif | | 505 | +#endif |
505 | if (colorSpace) { | | 506 | if (colorSpace) { |
506 | GfxColor color; | | 507 | GfxColor color; |
507 | state->setStrokeColorSpace(colorSpace); | | 508 | state->setStrokeColorSpace(colorSpace); |
| | | 509 | @@ -2310,7 +2490,7 @@ void PdfParser::opShowText(Object args[] |
| | | 510 | builder->updateFont(state); |
| | | 511 | fontChanged = gFalse; |
| | | 512 | } |
| | | 513 | - doShowText(args[0].getString()); |
| | | 514 | + doShowText((GooString *)args[0].getString()); |
| | | 515 | } |
| | | 516 | |
| | | 517 | // TODO not good that numArgs is ignored but args[] is used: |
| | | 518 | @@ -2331,7 +2511,7 @@ void PdfParser::opMoveShowText(Object ar |
| | | 519 | ty = state->getLineY() - state->getLeading(); |
| | | 520 | state->textMoveTo(tx, ty); |
| | | 521 | builder->updateTextPosition(tx, ty); |
| | | 522 | - doShowText(args[0].getString()); |
| | | 523 | + doShowText((GooString *)args[0].getString()); |
| | | 524 | } |
| | | 525 | |
| | | 526 | // TODO not good that numArgs is ignored but args[] is used: |
| | | 527 | @@ -2354,7 +2534,7 @@ void PdfParser::opMoveSetShowText(Object |
| | | 528 | ty = state->getLineY() - state->getLeading(); |
| | | 529 | state->textMoveTo(tx, ty); |
| | | 530 | builder->updateTextPosition(tx, ty); |
| | | 531 | - doShowText(args[2].getString()); |
| | | 532 | + doShowText((GooString *)args[2].getString()); |
| | | 533 | } |
| | | 534 | |
| | | 535 | // TODO not good that numArgs is ignored but args[] is used: |
508 | @@ -2375,7 +2555,11 @@ void PdfParser::opShowSpaceText(Object a | | 536 | @@ -2375,7 +2555,11 @@ void PdfParser::opShowSpaceText(Object a |
509 | wMode = state->getFont()->getWMode(); | | 537 | wMode = state->getFont()->getWMode(); |
510 | a = args[0].getArray(); | | 538 | a = args[0].getArray(); |
511 | for (int i = 0; i < a->getLength(); ++i) { | | 539 | for (int i = 0; i < a->getLength(); ++i) { |
512 | +#if defined(POPPLER_NEW_OBJECT_API) | | 540 | +#if defined(POPPLER_NEW_OBJECT_API) |
513 | + obj = a->get(i); | | 541 | + obj = a->get(i); |
514 | +#else | | 542 | +#else |
515 | a->get(i, &obj); | | 543 | a->get(i, &obj); |
516 | +#endif | | 544 | +#endif |
517 | if (obj.isNum()) { | | 545 | if (obj.isNum()) { |
518 | // this uses the absolute value of the font size to match | | 546 | // this uses the absolute value of the font size to match |
519 | // Acrobat's behavior | | 547 | // Acrobat's behavior |
520 | @@ -2392,7 +2576,9 @@ void PdfParser::opShowSpaceText(Object a | | 548 | @@ -2388,11 +2572,13 @@ void PdfParser::opShowSpaceText(Object a |
| | | 549 | } |
| | | 550 | builder->updateTextShift(state, obj.getNum()); |
| | | 551 | } else if (obj.isString()) { |
| | | 552 | - doShowText(obj.getString()); |
| | | 553 | + doShowText((GooString *)obj.getString()); |
521 | } else { | | 554 | } else { |
522 | error(errSyntaxError, getPos(), "Element of show/space array must be number or string"); | | 555 | error(errSyntaxError, getPos(), "Element of show/space array must be number or string"); |
523 | } | | 556 | } |
524 | +#if !defined(POPPLER_NEW_OBJECT_API) | | 557 | +#if !defined(POPPLER_NEW_OBJECT_API) |
525 | obj.free(); | | 558 | obj.free(); |
526 | +#endif | | 559 | +#endif |
527 | } | | 560 | } |
528 | } | | 561 | } |
529 | | | 562 | |
530 | @@ -2465,7 +2651,11 @@ void PdfParser::doShowText(GooString *s) | | 563 | @@ -2465,7 +2651,11 @@ void PdfParser::doShowText(GooString *s) |
531 | //out->updateCTM(state, 1, 0, 0, 1, 0, 0); | | 564 | //out->updateCTM(state, 1, 0, 0, 1, 0, 0); |
532 | if (0){ /*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy, | | 565 | if (0){ /*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy, |
533 | code, u, uLen)) {*/ | | 566 | code, u, uLen)) {*/ |
| @@ -539,30 +572,32 @@ $NetBSD: patch-src_extension_internal_pd | | | @@ -539,30 +572,32 @@ $NetBSD: patch-src_extension_internal_pd |
539 | if ((resDict = ((Gfx8BitFont *)font)->getResources())) { | | 572 | if ((resDict = ((Gfx8BitFont *)font)->getResources())) { |
540 | pushResources(resDict); | | 573 | pushResources(resDict); |
541 | } | | 574 | } |
542 | @@ -2478,7 +2668,9 @@ void PdfParser::doShowText(GooString *s) | | 575 | @@ -2478,7 +2668,9 @@ void PdfParser::doShowText(GooString *s) |
543 | if (resDict) { | | 576 | if (resDict) { |
544 | popResources(); | | 577 | popResources(); |
545 | } | | 578 | } |
546 | +#if !defined(POPPLER_NEW_OBJECT_API) | | 579 | +#if !defined(POPPLER_NEW_OBJECT_API) |
547 | charProc.free(); | | 580 | charProc.free(); |
548 | +#endif | | 581 | +#endif |
549 | } | | 582 | } |
550 | restoreState(); | | 583 | restoreState(); |
551 | // GfxState::restore() does *not* restore the current position, | | 584 | // GfxState::restore() does *not* restore the current position, |
552 | @@ -2541,23 +2733,43 @@ void PdfParser::opXObject(Object args[], | | 585 | @@ -2540,24 +2732,44 @@ void PdfParser::opXObject(Object args[], |
| | | 586 | { |
553 | Object obj1, obj2, obj3, refObj; | | 587 | Object obj1, obj2, obj3, refObj; |
554 | | | 588 | |
555 | char *name = args[0].getName(); | | 589 | - char *name = args[0].getName(); |
| | | 590 | + char *name = (char *)args[0].getName(); |
556 | +#if defined(POPPLER_NEW_OBJECT_API) | | 591 | +#if defined(POPPLER_NEW_OBJECT_API) |
557 | + if ((obj1 = res->lookupXObject(name)).isNull()) { | | 592 | + if ((obj1 = res->lookupXObject(name)).isNull()) { |
558 | +#else | | 593 | +#else |
559 | if (!res->lookupXObject(name, &obj1)) { | | 594 | if (!res->lookupXObject(name, &obj1)) { |
560 | +#endif | | 595 | +#endif |
561 | return; | | 596 | return; |
562 | } | | 597 | } |
563 | if (!obj1.isStream()) { | | 598 | if (!obj1.isStream()) { |
564 | error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name); | | 599 | error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name); |
565 | +#if !defined(POPPLER_NEW_OBJECT_API) | | 600 | +#if !defined(POPPLER_NEW_OBJECT_API) |
566 | obj1.free(); | | 601 | obj1.free(); |
567 | +#endif | | 602 | +#endif |
568 | return; | | 603 | return; |