Skip to content

Commit f9fc72e

Browse files
authored
Merge pull request #451 from cantabular/poppler-update-2026-03
Update Poppler 2026-03
2 parents cd81493 + 672b2bf commit f9fc72e

4 files changed

Lines changed: 19 additions & 40 deletions

File tree

src/DumpAsTextDev.h

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class DumpAsTextDev : public OutputDev {
5353
return OutputDev::needClipToCropBox();
5454
}
5555

56-
void setDefaultCTM(const double *ctm) {
56+
void setDefaultCTM(const std::array<double, 6> &ctm) {
5757
printf("setDefaultCTM\n");
5858
return OutputDev::setDefaultCTM(ctm);
5959
}
@@ -86,26 +86,11 @@ class DumpAsTextDev : public OutputDev {
8686
return OutputDev::dump();
8787
}
8888

89-
void cvtDevToUser(double dx, double dy, double *ux, double *uy) {
90-
printf("cvtDevToUser\n");
91-
return OutputDev::cvtDevToUser(dx, dy, ux, uy);
92-
}
93-
9489
void cvtUserToDev(double ux, double uy, int *dx, int *dy) {
9590
printf("cvtUserToDev\n");
9691
return OutputDev::cvtUserToDev(ux, uy, dx, dy);
9792
}
9893

99-
const double *getDefCTM() {
100-
printf("getDefCTM\n");
101-
return OutputDev::getDefCTM();
102-
}
103-
104-
const double *getDefICTM() {
105-
printf("getDefICTM\n");
106-
return OutputDev::getDefICTM();
107-
}
108-
10994
void saveState(GfxState *A) {
11095
printf("saveState\n");
11196
return OutputDev::saveState(A);
@@ -451,13 +436,13 @@ class DumpAsTextDev : public OutputDev {
451436

452437
void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
453438
int width, int height, bool invert,
454-
bool inlineImg, double *baseMatrix) {
439+
bool inlineImg, std::array<double, 6> &baseMatrix) {
455440
printf("setSoftMaskFromImageMask\n");
456441
return OutputDev::setSoftMaskFromImageMask(state, ref, str, width, height,
457442
invert, inlineImg, baseMatrix);
458443
}
459444

460-
void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) {
445+
void unsetSoftMaskFromImageMask(GfxState *state, std::array<double, 6> &baseMatrix) {
461446
printf("unsetSoftMaskFromImageMask\n");
462447
return OutputDev::unsetSoftMaskFromImageMask(state, baseMatrix);
463448
}
@@ -512,12 +497,12 @@ class DumpAsTextDev : public OutputDev {
512497
return OutputDev::markPoint(name, properties);
513498
}
514499

515-
void opiBegin(GfxState *state, Dict *opiDict) {
500+
void opiBegin(GfxState *state, const Dict &opiDict) {
516501
printf("opiBegin\n");
517502
return OutputDev::opiBegin(state, opiDict);
518503
}
519504

520-
void opiEnd(GfxState *state, Dict *opiDict) {
505+
void opiEnd(GfxState *state, const Dict &opiDict) {
521506
printf("opiEnd\n");
522507
return OutputDev::opiEnd(state, opiDict);
523508
}

src/DumpPathsAsMsgPackDev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const int SET_FILL_COLOR = 15;
2121
typedef struct { double x, y; } Point;
2222

2323
class Mat2x3 {
24-
const double *m;
24+
const std::array<double, 6> &m;
2525

2626
public:
27-
Mat2x3(const double m[6]) : m(m) {}
27+
Mat2x3(const std::array<double, 6> &m) : m(m) {}
2828

2929
inline const Point mul(const double x, const double y) const {
3030
auto xt = x * m[0] + y * m[2] + m[4];

src/main.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,13 @@ static std::string fmt(const Object &o, const UnicodeMap *uMap) {
140140
auto s = o.getString();
141141

142142
char buf[9];
143-
Unicode *ucs4_out;
144143
std::vector<Unicode> ucs4 = TextStringToUCS4(s->toStr());
145-
ucs4_out = (Unicode *)gmallocn(ucs4.size(), sizeof(Unicode));
146-
memcpy(ucs4_out, ucs4.data(), ucs4.size() * sizeof(Unicode));
147-
auto len = ucs4.size();
148144

149145
std::string out;
150-
out.reserve(static_cast<size_t>(len));
146+
out.reserve(ucs4.size());
151147

152-
for (unsigned long int i = 0; i < len; i++) {
153-
auto n = uMap->mapUnicode(ucs4_out[i], buf, sizeof(buf));
148+
for (const auto &uChar : ucs4) {
149+
auto n = uMap->mapUnicode(uChar, buf, sizeof(buf));
154150
out.append(buf, n);
155151
}
156152

@@ -199,7 +195,7 @@ void dump_font_info(PDFDoc *doc) {
199195
void pack_stream_content(Stream *stream) {
200196
GooString content;
201197

202-
stream->reset();
198+
stream->rewind();
203199
stream->fillGooString(&content);
204200
stream->close();
205201

@@ -307,8 +303,6 @@ void dump_document_meta(const std::string filename, PDFDoc *doc,
307303
}
308304
}
309305

310-
void TextPageDecRef(TextPage *text_page) { text_page->decRefCnt(); }
311-
312306
void render_annotations(std::unique_ptr<Gfx> &gfx, Annots *annots) {
313307
gfx->saveState();
314308

@@ -319,7 +313,7 @@ void render_annotations(std::unique_ptr<Gfx> &gfx, Annots *annots) {
319313
gfx->restoreState();
320314
}
321315

322-
typedef std::unique_ptr<TextPage, decltype(&TextPageDecRef)> TextPagePtr;
316+
typedef std::unique_ptr<TextPage> TextPagePtr;
323317

324318
TextPagePtr page_to_text_page(Page *page) {
325319
auto dev = std::make_unique<TextOutputDev>(nullptr, true, 0, false, false);
@@ -343,7 +337,7 @@ TextPagePtr page_to_text_page(Page *page) {
343337

344338
dev->endPage();
345339

346-
return TextPagePtr(dev->takeText(), TextPageDecRef);
340+
return dev->takeText();
347341
}
348342

349343
int count_glyphs(const std::vector<std::vector<std::unique_ptr<TextWordSelection>>>& word_list) {
@@ -439,7 +433,7 @@ void dump_page_bitmap(Page *page) {
439433
// auto mode = splashModeRGB8;
440434
// const auto n_channels = 3;
441435

442-
auto dev = std::make_unique<SplashOutputDev>(mode, 4, false, paperColor,
436+
auto dev = std::make_unique<SplashOutputDev>(mode, 4, paperColor,
443437
true, splashThinLineShape);
444438

445439
dev->setFontAntialias(true);
@@ -502,14 +496,14 @@ void dump_document(PDFDoc *doc, const Options &options) {
502496
}
503497
}
504498

505-
BaseStream *open_file(const std::string filename) {
499+
std::unique_ptr<BaseStream> open_file(const std::string filename) {
506500
std::unique_ptr<GooFile> file = GooFile::open(filename);
507501
if (file == NULL) {
508502
std::cerr << "Failed to open " << filename << std::endl;
509503
exit(5);
510504
}
511-
Object obj;
512-
return new FileStream(file.release(), 0, false, file->size(), Object::null());
505+
auto size = file->size();
506+
return std::make_unique<FileStream>(file.release(), 0, false, size, Object::null());
513507
}
514508

515509
std::string parse_page_range(std::string value, Options *options) {
@@ -618,7 +612,7 @@ int main(int argc, char *argv[]) {
618612
exit(127);
619613
}
620614

621-
std::unique_ptr<PDFDoc> doc(new PDFDoc(file));
615+
std::unique_ptr<PDFDoc> doc(new PDFDoc(std::move(file)));
622616
if (!doc) {
623617
std::cerr << "Problem loading document." << std::endl;
624618
exit(64);
Submodule poppler updated 511 files

0 commit comments

Comments
 (0)