]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Support GooString::c_str() introduced by poppler 0.72 83/head
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Fri, 28 Dec 2018 18:42:32 +0000 (19:42 +0100)
committerStefan Brüns <stefan.bruens@rwth-aachen.de>
Sat, 29 Dec 2018 03:01:51 +0000 (04:01 +0100)
filter/pdftoopvp/OPVPOutputDev.cxx
filter/pdftoopvp/pdftoopvp.cxx

index a85bfc314bd8278bccae28e435752a1810d301ef..2526714868eb25bbb8a2912cb821331aaf8b87df 100644 (file)
@@ -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;
index 65aca4d86677bcb09710de104f958e0ed0d6c358..dfff692ee49196ac29dd4716ca3b57798674cb89 100644 (file)
@@ -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());