From 3e1f86c9289660bf83781a31260ec079b21fd21e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20Br=C3=BCns?= Date: Fri, 28 Dec 2018 19:42:32 +0100 Subject: [PATCH] Support GooString::c_str() introduced by poppler 0.72 --- filter/pdftoopvp/OPVPOutputDev.cxx | 48 +++++++++++++++--------------- filter/pdftoopvp/pdftoopvp.cxx | 19 ++++++++++++ 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/filter/pdftoopvp/OPVPOutputDev.cxx b/filter/pdftoopvp/OPVPOutputDev.cxx index a85bfc314..252671486 100644 --- a/filter/pdftoopvp/OPVPOutputDev.cxx +++ b/filter/pdftoopvp/OPVPOutputDev.cxx @@ -499,6 +499,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { SplashOutFontFileID *id; SplashFontFile *fontFile; SplashFontSrc *fontsrc = NULL; + const char *fontName = "(unnamed)"; FoFiTrueType *ff; Ref embRef; Object refObj, strObj; @@ -530,6 +531,13 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { delete id; } else { + if (gfxFont->getName()) { +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR <= 71 + fontName = gfxFont->getName()->getCString(); +#else + fontName = gfxFont->getName()->c_str(); +#endif + } // if there is an embedded font, write it to disk if (gfxFont->getEmbeddedFontID(&embRef)) { @@ -542,9 +550,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { fileName = globalParams->findSystemFontFile(gfxFont,&sftype, &faceIndex, NULL); if (fileName == 0) { - opvpError(-1, "Couldn't find a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't find a font for '%s'", fontName); goto err2; } switch (sftype) { @@ -573,9 +579,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { fontsrc, (const char **) ((Gfx8BitFont *)gfxFont)->getEncoding()))) { - opvpError(-1, "Couldn't create a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't create a font for '%s'", fontName); goto err2; } break; @@ -585,9 +589,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { fontsrc, (const char **) ((Gfx8BitFont *)gfxFont)->getEncoding()))) { - opvpError(-1, "Couldn't create a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't create a font for '%s'", fontName); goto err2; } break; @@ -597,16 +599,18 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { fontsrc, (const char **) ((Gfx8BitFont *)gfxFont)->getEncoding()))) { - opvpError(-1, "Couldn't create a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't create a font for '%s'", fontName); goto err2; } break; case fontTrueTypeOT: case fontTrueType: if (fileName) +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR <= 71 ff = FoFiTrueType::load(fileName->getCString()); +#else + ff = FoFiTrueType::load(fileName->c_str()); +#endif else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); if (ff) { @@ -621,9 +625,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { id, fontsrc, codeToGID, n))) { - opvpError(-1, "Couldn't create a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't create a font for '%s'", fontName); goto err2; } break; @@ -632,9 +634,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { if (!(fontFile = fontEngine->loadCIDFont( id, fontsrc))) { - opvpError(-1, "Couldn't create a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't create a font for '%s'", fontName); goto err2; } break; @@ -650,9 +650,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { if (!(fontFile = fontEngine->loadOpenTypeCFFFont( id, fontsrc,codeToGID,n))) { - opvpError(-1, "Couldn't create a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't create a font for '%s'", fontName); goto err2; } break; @@ -669,7 +667,11 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { } } else { if (fileName) +#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR <= 71 ff = FoFiTrueType::load(fileName->getCString()); +#else + ff = FoFiTrueType::load(fileName->c_str()); +#endif else ff = FoFiTrueType::make(tmpBuf, tmpBufLen); if (! ff) @@ -681,9 +683,7 @@ void OPVPOutputDev::doUpdateFont(GfxState *state) { id, fontsrc, codeToGID, n, faceIndex))) { - opvpError(-1, "Couldn't create a font for '%s'", - gfxFont->getName() ? gfxFont->getName()->getCString() - : "(unnamed)"); + opvpError(-1, "Couldn't create a font for '%s'", fontName); goto err2; } break; diff --git a/filter/pdftoopvp/pdftoopvp.cxx b/filter/pdftoopvp/pdftoopvp.cxx index 65aca4d86..dfff692ee 100644 --- a/filter/pdftoopvp/pdftoopvp.cxx +++ b/filter/pdftoopvp/pdftoopvp.cxx @@ -464,12 +464,21 @@ int main(int argc, char *argv[]) { if (choices != 0) free(choices); } +#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR <= 71 strncpy(jobInfo,jobInfoStr.getCString(),sizeof(jobInfo)-1); jobInfo[sizeof(jobInfo)-1] = '\0'; strncpy(docInfo,docInfoStr.getCString(),sizeof(docInfo)-1); docInfo[sizeof(docInfo)-1] = '\0'; strncpy(pageInfo,pageInfoStr.getCString(),sizeof(pageInfo)-1); pageInfo[sizeof(pageInfo)-1] = '\0'; +#else + strncpy(jobInfo,jobInfoStr.c_str(),sizeof(jobInfo)-1); + jobInfo[sizeof(jobInfo)-1] = '\0'; + strncpy(docInfo,docInfoStr.c_str(),sizeof(docInfo)-1); + docInfo[sizeof(docInfo)-1] = '\0'; + strncpy(pageInfo,pageInfoStr.c_str(),sizeof(pageInfo)-1); + pageInfo[sizeof(pageInfo)-1] = '\0'; +#endif colorProfile = getColorProfilePath(ppd,&colorProfilePath); @@ -629,7 +638,13 @@ exit(0); name.append("/tmp"); } name.append("/XXXXXX"); +#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR <= 71 fd = mkstemp(name.getCString()); +#else + std::string t = name.toStr(); + fd = mkstemp(&t[0]); + name = GooString(std::move(t)); +#endif if (fd < 0) { opvpError(-1,"Can't create temporary file"); exitCode = 2; @@ -673,7 +688,11 @@ exit(0); close(fd); doc = new PDFDoc(&name); /* remove name */ +#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR <= 71 unlink(name.getCString()); +#else + unlink(name.c_str()); +#endif } else { /* no jcl check */ doc = new PDFDoc(fileName.copy()); -- 2.47.2