[poppler] poppler/GlobalParams.cc poppler/GlobalParams.h poppler/PreScanOutputDev.cc poppler/PreScanOutputDev.h poppler/PSOutputDev.cc poppler/PSOutputDev.h utils/pdftops.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 2 21:27:08 UTC 2020


 poppler/GlobalParams.cc     |   13 -------------
 poppler/GlobalParams.h      |   17 -----------------
 poppler/PSOutputDev.cc      |   22 +++++++++++-----------
 poppler/PSOutputDev.h       |   19 +++++++++++++++----
 poppler/PreScanOutputDev.cc |    6 ++----
 poppler/PreScanOutputDev.h  |    7 +++----
 utils/pdftops.cc            |    8 +++-----
 7 files changed, 34 insertions(+), 58 deletions(-)

New commits:
commit eaa1e07b591b975946f2f3f7262dd94deb9d54b3
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Nov 2 00:03:04 2020 +0100

    Move psLevel to PSOutputDev creation
    
    It's were it makes sense, not as part of GlobalParams that we're
    sloooooooooowly trying to get rid of

diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 630ec4ab..93024cc7 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -391,7 +391,6 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) : popplerDataDir(cu
     sysFonts = new SysFontList();
     psExpandSmaller = false;
     psShrinkLarger = true;
-    psLevel = psLevel2;
     textEncoding = new GooString("UTF-8");
     overprintPreview = false;
     printCommands = false;
@@ -1133,12 +1132,6 @@ bool GlobalParams::getPSShrinkLarger()
     return psShrinkLarger;
 }
 
-PSLevel GlobalParams::getPSLevel()
-{
-    globalParamsLocker();
-    return psLevel;
-}
-
 std::string GlobalParams::getTextEncodingName() const
 {
     globalParamsLocker();
@@ -1247,12 +1240,6 @@ void GlobalParams::setPSShrinkLarger(bool shrink)
     psShrinkLarger = shrink;
 }
 
-void GlobalParams::setPSLevel(PSLevel level)
-{
-    globalParamsLocker();
-    psLevel = level;
-}
-
 void GlobalParams::setTextEncoding(const char *encodingName)
 {
     globalParamsLocker();
diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h
index 4b41ee38..cc3fa117 100644
--- a/poppler/GlobalParams.h
+++ b/poppler/GlobalParams.h
@@ -78,20 +78,6 @@ enum SysFontType
 
 //------------------------------------------------------------------------
 
-enum PSLevel
-{
-    psLevel1,
-    psLevel1Sep,
-    psLevel2,
-    psLevel2Sep,
-    psLevel3,
-    psLevel3Sep
-};
-
-//------------------------------------------------------------------------
-
-//------------------------------------------------------------------------
-
 class GlobalParams
 {
 public:
@@ -126,7 +112,6 @@ public:
     GooString *findSystemFontFile(const GfxFont *font, SysFontType *type, int *fontNum, GooString *substituteFontName = nullptr, const GooString *base14Name = nullptr);
     bool getPSExpandSmaller();
     bool getPSShrinkLarger();
-    PSLevel getPSLevel();
     std::string getTextEncodingName() const;
     bool getOverprintPreview() { return overprintPreview; }
     bool getPrintCommands();
@@ -146,7 +131,6 @@ public:
     void addFontFile(const GooString *fontName, const GooString *path);
     void setPSExpandSmaller(bool expand);
     void setPSShrinkLarger(bool shrink);
-    void setPSLevel(PSLevel level);
     void setTextEncoding(const char *encodingName);
     void setOverprintPreview(bool overprintPreviewA);
     void setPrintCommands(bool printCommandsA);
@@ -196,7 +180,6 @@ private:
     SysFontList *sysFonts; // system fonts
     bool psExpandSmaller; // expand smaller pages to fill paper
     bool psShrinkLarger; // shrink larger pages to fit paper
-    PSLevel psLevel; // PostScript level to generate
     GooString *textEncoding; // encoding (unicodeMap) to use for text
                              //   output
     bool overprintPreview; // enable overprint preview
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 6b99ef2c..2471d56b 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1086,7 +1086,7 @@ static void outputToFile(void *stream, const char *data, int len)
 }
 
 PSOutputDev::PSOutputDev(const char *fileName, PDFDoc *docA, char *psTitleA, const std::vector<int> &pagesA, PSOutMode modeA, int paperWidthA, int paperHeightA, bool noCropA, bool duplexA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
-                         PSForceRasterize forceRasterizeA, bool manualCtrlA, PSOutCustomCodeCbk customCodeCbkA, void *customCodeCbkDataA)
+                         PSForceRasterize forceRasterizeA, bool manualCtrlA, PSOutCustomCodeCbk customCodeCbkA, void *customCodeCbkDataA, PSLevel levelA)
 {
     FILE *f;
     PSFileType fileTypeA;
@@ -1141,11 +1141,11 @@ PSOutputDev::PSOutputDev(const char *fileName, PDFDoc *docA, char *psTitleA, con
         }
     }
 
-    init(outputToFile, f, fileTypeA, psTitleA, docA, pagesA, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, noCropA, duplexA);
+    init(outputToFile, f, fileTypeA, psTitleA, docA, pagesA, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, noCropA, duplexA, levelA);
 }
 
 PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, char *psTitleA, PDFDoc *docA, const std::vector<int> &pagesA, PSOutMode modeA, int paperWidthA, int paperHeightA, bool noCropA, bool duplexA, int imgLLXA, int imgLLYA,
-                         int imgURXA, int imgURYA, PSForceRasterize forceRasterizeA, bool manualCtrlA, PSOutCustomCodeCbk customCodeCbkA, void *customCodeCbkDataA)
+                         int imgURXA, int imgURYA, PSForceRasterize forceRasterizeA, bool manualCtrlA, PSOutCustomCodeCbk customCodeCbkA, void *customCodeCbkDataA, PSLevel levelA)
 {
     underlayCbk = nullptr;
     underlayCbkData = nullptr;
@@ -1168,7 +1168,7 @@ PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, char *ps
     forceRasterize = forceRasterizeA;
     psTitle = nullptr;
 
-    init(outputFuncA, outputStreamA, psGeneric, psTitleA, docA, pagesA, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, noCropA, duplexA);
+    init(outputFuncA, outputStreamA, psGeneric, psTitleA, docA, pagesA, modeA, imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA, paperWidthA, paperHeightA, noCropA, duplexA, levelA);
 }
 
 struct StandardMedia
@@ -1193,7 +1193,7 @@ static bool pageDimensionEqual(int a, int b)
 //   created the PSOutputDev can use the various setters to change defaults.
 
 void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, PSFileType fileTypeA, char *psTitleA, PDFDoc *docA, const std::vector<int> &pagesA, PSOutMode modeA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, bool manualCtrlA,
-                       int paperWidthA, int paperHeightA, bool noCropA, bool duplexA)
+                       int paperWidthA, int paperHeightA, bool noCropA, bool duplexA, PSLevel levelA)
 {
 
     if (pagesA.empty()) {
@@ -1227,7 +1227,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, PSFileType
     fileType = fileTypeA;
     psTitle = (psTitleA ? strdup(psTitleA) : nullptr);
     doc = docA;
-    level = globalParams->getPSLevel();
+    level = levelA;
     pages = pagesA;
     mode = modeA;
     paperWidth = paperWidthA;
@@ -2523,7 +2523,7 @@ void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *fileNam
             }
             if (ffTT->isOpenTypeCFF()) {
                 ffTT->convertToCIDType0(psName->c_str(), codeToGID, codeToGIDLen, outputFunc, outputStream);
-            } else if (globalParams->getPSLevel() >= psLevel3) {
+            } else if (level >= psLevel3) {
                 // Level 3: use a CID font
                 ffTT->convertToCIDType2(psName->c_str(), codeToGID, codeToGIDLen, needVerticalMetrics, outputFunc, outputStream);
             } else {
@@ -2575,7 +2575,7 @@ void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, GooString *p
     // convert it to a Type 0 font
     if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) {
         if ((ffT1C = FoFiType1C::make(fontBuf, fontLen))) {
-            if (globalParams->getPSLevel() >= psLevel3) {
+            if (level >= psLevel3) {
                 // Level 3: use a CID font
                 ffT1C->convertToCIDType0(psName->c_str(), nullptr, 0, outputFunc, outputStream);
             } else {
@@ -2606,7 +2606,7 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, GooString
     // convert it to a Type 0 font
     if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) {
         if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) {
-            if (globalParams->getPSLevel() >= psLevel3) {
+            if (level >= psLevel3) {
                 // Level 3: use a CID font
                 ffTT->convertToCIDType2(psName->c_str(), ((GfxCIDFont *)font)->getCIDToGID(), ((GfxCIDFont *)font)->getCIDToGIDLen(), needVerticalMetrics, outputFunc, outputStream);
             } else {
@@ -2657,7 +2657,7 @@ void PSOutputDev::setupEmbeddedOpenTypeCFFFont(GfxFont *font, Ref *id, GooString
     if ((fontBuf = font->readEmbFontFile(xref, &fontLen))) {
         if ((ffTT = FoFiTrueType::make(fontBuf, fontLen))) {
             if (ffTT->isOpenTypeCFF()) {
-                if (globalParams->getPSLevel() >= psLevel3) {
+                if (level >= psLevel3) {
                     // Level 3: use a CID font
                     ffTT->convertToCIDType0(psName->c_str(), ((GfxCIDFont *)font)->getCIDToGID(), ((GfxCIDFont *)font)->getCIDToGIDLen(), outputFunc, outputStream);
                 } else {
@@ -3152,7 +3152,7 @@ bool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, i
     } else if (forceRasterize == psNeverRasterize) {
         rasterize = false;
     } else {
-        scan = new PreScanOutputDev(doc);
+        scan = new PreScanOutputDev(level);
         page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop, sliceX, sliceY, sliceW, sliceH, printing, abortCheckCbk, abortCheckCbkData, annotDisplayDecideCbk, annotDisplayDecideCbkData);
         rasterize = scan->usesTransparency() || scan->usesPatternImageMask();
         delete scan;
diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h
index b93b9dde..e33125dd 100644
--- a/poppler/PSOutputDev.h
+++ b/poppler/PSOutputDev.h
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2005 Martin Kretzschmar <martink at gnome.org>
 // Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
-// Copyright (C) 2006-2008, 2012, 2013, 2015, 2017-2019 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2008, 2012, 2013, 2015, 2017-2020 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2007 Brad Hards <bradh at kde.org>
 // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 Till Kamppeter <till.kamppeter at gmail.com>
@@ -73,6 +73,16 @@ class PSOutputDev;
 // PSOutputDev
 //------------------------------------------------------------------------
 
+enum PSLevel
+{
+    psLevel1,
+    psLevel1Sep,
+    psLevel2,
+    psLevel2Sep,
+    psLevel3,
+    psLevel3Sep
+};
+
 enum PSOutMode
 {
     psModePS,
@@ -111,13 +121,14 @@ public:
     // Open a PostScript output file, and write the prolog.
     // pages has to be sorted in increasing order
     PSOutputDev(const char *fileName, PDFDoc *docA, char *psTitleA, const std::vector<int> &pages, PSOutMode modeA, int paperWidthA = -1, int paperHeightA = -1, bool noCrop = false, bool duplexA = true, int imgLLXA = 0, int imgLLYA = 0,
-                int imgURXA = 0, int imgURYA = 0, PSForceRasterize forceRasterizeA = psRasterizeWhenNeeded, bool manualCtrlA = false, PSOutCustomCodeCbk customCodeCbkA = nullptr, void *customCodeCbkDataA = nullptr);
+                int imgURXA = 0, int imgURYA = 0, PSForceRasterize forceRasterizeA = psRasterizeWhenNeeded, bool manualCtrlA = false, PSOutCustomCodeCbk customCodeCbkA = nullptr, void *customCodeCbkDataA = nullptr,
+                PSLevel levelA = psLevel2);
 
     // Open a PSOutputDev that will write to a generic stream.
     // pages has to be sorted in increasing order
     PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, char *psTitleA, PDFDoc *docA, const std::vector<int> &pages, PSOutMode modeA, int paperWidthA = -1, int paperHeightA = -1, bool noCrop = false, bool duplexA = true,
                 int imgLLXA = 0, int imgLLYA = 0, int imgURXA = 0, int imgURYA = 0, PSForceRasterize forceRasterizeA = psRasterizeWhenNeeded, bool manualCtrlA = false, PSOutCustomCodeCbk customCodeCbkA = nullptr,
-                void *customCodeCbkDataA = nullptr);
+                void *customCodeCbkDataA = nullptr, PSLevel levelA = psLevel2);
 
     // Destructor -- writes the trailer and closes the file.
     ~PSOutputDev() override;
@@ -348,7 +359,7 @@ public:
 
 private:
     void init(PSOutputFunc outputFuncA, void *outputStreamA, PSFileType fileTypeA, char *psTitleA, PDFDoc *doc, const std::vector<int> &pages, PSOutMode modeA, int imgLLXA, int imgLLYA, int imgURXA, int imgURYA, bool manualCtrlA,
-              int paperWidthA, int paperHeightA, bool noCropA, bool duplexA);
+              int paperWidthA, int paperHeightA, bool noCropA, bool duplexA, PSLevel levelA);
     void postInit();
     void setupResources(Dict *resDict);
     void setupFonts(Dict *resDict);
diff --git a/poppler/PreScanOutputDev.cc b/poppler/PreScanOutputDev.cc
index af1496af..478a7f23 100644
--- a/poppler/PreScanOutputDev.cc
+++ b/poppler/PreScanOutputDev.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
-// Copyright (C) 2010, 2011, 2018, 2019 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2010, 2011, 2018-2020 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2011, 2014 William Bader <williambader at hotmail.com>
 // Copyright (C) 2011, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2011 Adrian Johnson <ajohnson at redneon.com>
@@ -39,10 +39,8 @@
 // PreScanOutputDev
 //------------------------------------------------------------------------
 
-PreScanOutputDev::PreScanOutputDev(PDFDoc *docA)
+PreScanOutputDev::PreScanOutputDev(PSLevel levelA) : level(levelA)
 {
-    level = globalParams->getPSLevel();
-    doc = docA;
     clearStats();
 }
 
diff --git a/poppler/PreScanOutputDev.h b/poppler/PreScanOutputDev.h
index db2c56de..7e089a5d 100644
--- a/poppler/PreScanOutputDev.h
+++ b/poppler/PreScanOutputDev.h
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc at gnome.org>
-// Copyright (C) 2010, 2018, 2019 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2010, 2018-2020 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2011, 2014 William Bader <williambader at hotmail.com>
 // Copyright (C) 2011, 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2011 Adrian Johnson <ajohnson at redneon.com>
@@ -29,8 +29,8 @@
 
 #include "Object.h"
 #include "GfxState.h"
-#include "GlobalParams.h"
 #include "OutputDev.h"
+#include "PSOutputDev.h"
 
 //------------------------------------------------------------------------
 // PreScanOutputDev
@@ -40,7 +40,7 @@ class PreScanOutputDev : public OutputDev
 {
 public:
     // Constructor.
-    PreScanOutputDev(PDFDoc *docA);
+    PreScanOutputDev(PSLevel levelA);
 
     // Destructor.
     ~PreScanOutputDev() override;
@@ -137,7 +137,6 @@ public:
 private:
     void check(GfxColorSpace *colorSpace, const GfxColor *color, double opacity, GfxBlendMode blendMode);
 
-    PDFDoc *doc;
     bool mono;
     bool gray;
     bool transparency;
diff --git a/utils/pdftops.cc b/utils/pdftops.cc
index 072c4d5c..73f00de2 100644
--- a/utils/pdftops.cc
+++ b/utils/pdftops.cc
@@ -16,7 +16,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2006 Kristian Høgsberg <krh at redhat.com>
-// Copyright (C) 2007-2008, 2010, 2015, 2017, 2018 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2007-2008, 2010, 2015, 2017, 2018, 2020 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Till Kamppeter <till.kamppeter at gmail.com>
 // Copyright (C) 2009 Sanjoy Mahajan <sanjoy at mit.edu>
 // Copyright (C) 2009, 2011, 2012, 2014-2016, 2020 William Bader <williambader at hotmail.com>
@@ -269,9 +269,6 @@ int main(int argc, char *argv[])
     if (noShrink) {
         globalParams->setPSShrinkLarger(false);
     }
-    if (level1 || level1Sep || level2 || level2Sep || level3 || level3Sep) {
-        globalParams->setPSLevel(level);
-    }
     if (quiet) {
         globalParams->setErrQuiet(quiet);
     }
@@ -422,7 +419,8 @@ int main(int argc, char *argv[])
     }
 
     // write PostScript file
-    psOut = new PSOutputDev(psFileName->c_str(), doc, nullptr, pages, mode, paperWidth, paperHeight, noCrop, duplex);
+    psOut = new PSOutputDev(psFileName->c_str(), doc, nullptr, pages, mode, paperWidth, paperHeight, noCrop, duplex, /*imgLLXA*/ 0, /*imgLLYA*/ 0,
+                            /*imgURXA*/ 0, /*imgURYA*/ 0, psRasterizeWhenNeeded, /*manualCtrlA*/ false, /*customCodeCbkA*/ nullptr, /*customCodeCbkDataA*/ nullptr, level);
     if (noCenter) {
         psOut->setPSCenter(false);
     }


More information about the poppler mailing list