[poppler] glib/poppler-action.cc poppler/GfxState.cc poppler/GfxState.h poppler/GlobalParams.cc poppler/GlobalParamsWin.cc splash/SplashBitmap.cc utils/pdffonts.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 3 16:35:06 UTC 2019


 glib/poppler-action.cc     |    4 +-
 poppler/GfxState.cc        |   62 +++++++++++++++++++++----------------------
 poppler/GfxState.h         |   64 ++++++++++++++++++++++-----------------------
 poppler/GlobalParams.cc    |   44 ++++++++++++++++--------------
 poppler/GlobalParamsWin.cc |    2 -
 splash/SplashBitmap.cc     |    2 -
 utils/pdffonts.cc          |    4 +-
 7 files changed, 92 insertions(+), 90 deletions(-)

New commits:
commit 4163bccb07191da0e6e6fe2aaa78e01007261fe2
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Dec 3 16:02:22 2019 +0100

    Add some more const

diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc
index 097c00df..f6fed6ba 100644
--- a/glib/poppler-action.cc
+++ b/glib/poppler-action.cc
@@ -544,7 +544,7 @@ build_rendition (PopplerAction *action,
 static PopplerLayer *
 get_layer_for_ref (PopplerDocument *document,
 		   GList           *layers,
-		   Ref             *ref,
+		   const Ref       *ref,
 		   gboolean         preserve_rb)
 {
 	GList *l;
@@ -603,7 +603,7 @@ build_ocg_state (PopplerDocument *document,
 			break;
 		}
 
-		for (Ref *ref : (*list->list)) {
+		for (const Ref *ref : (*list->list)) {
 			PopplerLayer *layer = get_layer_for_ref (document, document->layers, ref, preserve_rb);
 
 			action_layer->layers = g_list_prepend (action_layer->layers, layer);
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 2889d1e7..9aca67b3 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -663,7 +663,7 @@ GfxDeviceGrayColorSpace::GfxDeviceGrayColorSpace() {
 GfxDeviceGrayColorSpace::~GfxDeviceGrayColorSpace() {
 }
 
-GfxColorSpace *GfxDeviceGrayColorSpace::copy() {
+GfxColorSpace *GfxDeviceGrayColorSpace::copy() const {
   return new GfxDeviceGrayColorSpace();
 }
 
@@ -754,7 +754,7 @@ GfxCalGrayColorSpace::~GfxCalGrayColorSpace() {
 #endif
 }
 
-GfxColorSpace *GfxCalGrayColorSpace::copy() {
+GfxColorSpace *GfxCalGrayColorSpace::copy() const {
   GfxCalGrayColorSpace *cs;
 
   cs = new GfxCalGrayColorSpace();
@@ -955,7 +955,7 @@ GfxDeviceRGBColorSpace::GfxDeviceRGBColorSpace() {
 GfxDeviceRGBColorSpace::~GfxDeviceRGBColorSpace() {
 }
 
-GfxColorSpace *GfxDeviceRGBColorSpace::copy() {
+GfxColorSpace *GfxDeviceRGBColorSpace::copy() const {
   return new GfxDeviceRGBColorSpace();
 }
 
@@ -1109,7 +1109,7 @@ GfxCalRGBColorSpace::~GfxCalRGBColorSpace() {
 #endif
 }
 
-GfxColorSpace *GfxCalRGBColorSpace::copy() {
+GfxColorSpace *GfxCalRGBColorSpace::copy() const {
   GfxCalRGBColorSpace *cs;
   int i;
 
@@ -1322,7 +1322,7 @@ GfxDeviceCMYKColorSpace::GfxDeviceCMYKColorSpace() {
 GfxDeviceCMYKColorSpace::~GfxDeviceCMYKColorSpace() {
 }
 
-GfxColorSpace *GfxDeviceCMYKColorSpace::copy() {
+GfxColorSpace *GfxDeviceCMYKColorSpace::copy() const {
   return new GfxDeviceCMYKColorSpace();
 }
 
@@ -1463,7 +1463,7 @@ GfxLabColorSpace::~GfxLabColorSpace() {
 #endif
 }
 
-GfxColorSpace *GfxLabColorSpace::copy() {
+GfxColorSpace *GfxLabColorSpace::copy() const {
   GfxLabColorSpace *cs;
 
   cs = new GfxLabColorSpace();
@@ -1747,7 +1747,7 @@ GfxICCBasedColorSpace::~GfxICCBasedColorSpace() {
 #endif
 }
 
-GfxColorSpace *GfxICCBasedColorSpace::copy() {
+GfxColorSpace *GfxICCBasedColorSpace::copy() const {
   GfxICCBasedColorSpace *cs;
   int i;
 
@@ -2384,7 +2384,7 @@ GfxIndexedColorSpace::~GfxIndexedColorSpace() {
   gfree(lookup);
 }
 
-GfxColorSpace *GfxIndexedColorSpace::copy() {
+GfxColorSpace *GfxIndexedColorSpace::copy() const {
   GfxIndexedColorSpace *cs;
 
   cs = new GfxIndexedColorSpace(base->copy(), indexHigh);
@@ -2641,7 +2641,7 @@ GfxSeparationColorSpace::~GfxSeparationColorSpace() {
     gfree(mapping);
 }
 
-GfxColorSpace *GfxSeparationColorSpace::copy() {
+GfxColorSpace *GfxSeparationColorSpace::copy() const {
   int *mappingA = nullptr;
   if (mapping != nullptr) {
     mappingA = (int *) gmalloc(sizeof(int));
@@ -2911,12 +2911,12 @@ GfxDeviceNColorSpace::~GfxDeviceNColorSpace() {
     gfree(mapping);
 }
 
-GfxColorSpace *GfxDeviceNColorSpace::copy() {
+GfxColorSpace *GfxDeviceNColorSpace::copy() const {
   int *mappingA = nullptr;
 
   auto sepsCSA = new std::vector<GfxSeparationColorSpace*>();
   sepsCSA->reserve(sepsCS->size());
-  for (GfxSeparationColorSpace *scs : *sepsCS) {
+  for (const GfxSeparationColorSpace *scs : *sepsCS) {
     if (likely(scs != nullptr)) {
       sepsCSA->push_back((GfxSeparationColorSpace*)scs->copy());
     }
@@ -3104,7 +3104,7 @@ void GfxDeviceNColorSpace::createMapping(std::vector<GfxSeparationColorSpace*> *
       if (nComps == 1)
         sepFunc = func;
       else {
-        for (GfxSeparationColorSpace *sepCS : *sepsCS) {
+        for (const GfxSeparationColorSpace *sepCS : *sepsCS) {
           if (!sepCS->getName()->cmp(names[i])) {
             sepFunc = sepCS->getFunc();
             break;
@@ -3143,7 +3143,7 @@ void GfxDeviceNColorSpace::createMapping(std::vector<GfxSeparationColorSpace*> *
         if (nComps == 1)
 	  separationList->push_back(new GfxSeparationColorSpace(new GooString(names[i]),alt->copy(), func->copy()));
         else {
-          for (GfxSeparationColorSpace *sepCS : *sepsCS) {
+          for (const GfxSeparationColorSpace *sepCS : *sepsCS) {
             if (!sepCS->getName()->cmp(names[i])) {
               found = true;
 	      separationList->push_back((GfxSeparationColorSpace*)sepCS->copy());
@@ -3178,7 +3178,7 @@ GfxPatternColorSpace::~GfxPatternColorSpace() {
   }
 }
 
-GfxColorSpace *GfxPatternColorSpace::copy() {
+GfxColorSpace *GfxPatternColorSpace::copy() const {
   return new GfxPatternColorSpace(under ? under->copy() :
 				          nullptr);
 }
@@ -3342,8 +3342,8 @@ GfxTilingPattern *GfxTilingPattern::parse(Object *patObj, int patternRefNum) {
 
 GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA,
 				   const double *bboxA, double xStepA, double yStepA,
-				   Object *resDictA, const double *matrixA,
-				   Object *contentStreamA, int patternRefNumA) :
+				   const Object *resDictA, const double *matrixA,
+				   const Object *contentStreamA, int patternRefNumA) :
   GfxPattern(1, patternRefNumA)
 {
   int i;
@@ -3365,7 +3365,7 @@ GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA,
 GfxTilingPattern::~GfxTilingPattern() {
 }
 
-GfxPattern *GfxTilingPattern::copy() {
+GfxPattern *GfxTilingPattern::copy() const {
   return new GfxTilingPattern(paintType, tilingType, bbox, xStep, yStep,
 			      &resDict, matrix, &contentStream, getPatternRefNum());
 }
@@ -3423,7 +3423,7 @@ GfxShadingPattern::~GfxShadingPattern() {
   delete shading;
 }
 
-GfxPattern *GfxShadingPattern::copy() {
+GfxPattern *GfxShadingPattern::copy() const {
   return new GfxShadingPattern(shading->copy(), matrix, getPatternRefNum());
 }
 
@@ -3436,7 +3436,7 @@ GfxShading::GfxShading(int typeA) {
   colorSpace = nullptr;
 }
 
-GfxShading::GfxShading(GfxShading *shading) {
+GfxShading::GfxShading(const GfxShading *shading) {
   int i;
 
   type = shading->type;
@@ -3605,7 +3605,7 @@ GfxFunctionShading::GfxFunctionShading(double x0A, double y0A,
   }
 }
 
-GfxFunctionShading::GfxFunctionShading(GfxFunctionShading *shading):
+GfxFunctionShading::GfxFunctionShading(const GfxFunctionShading *shading):
   GfxShading(shading)
 {
   int i;
@@ -3707,7 +3707,7 @@ GfxFunctionShading *GfxFunctionShading::parse(GfxResources *res, Dict *dict, Out
   return shading;
 }
 
-GfxShading *GfxFunctionShading::copy() {
+GfxShading *GfxFunctionShading::copy() const {
   return new GfxFunctionShading(this);
 }
 
@@ -3758,7 +3758,7 @@ GfxUnivariateShading::GfxUnivariateShading(int typeA,
   cacheValues = nullptr;
 }
 
-GfxUnivariateShading::GfxUnivariateShading(GfxUnivariateShading *shading):
+GfxUnivariateShading::GfxUnivariateShading(const GfxUnivariateShading *shading):
   GfxShading(shading)
 {
   int i;
@@ -3946,7 +3946,7 @@ GfxAxialShading::GfxAxialShading(double x0A, double y0A,
   y1 = y1A;
 }
 
-GfxAxialShading::GfxAxialShading(GfxAxialShading *shading):
+GfxAxialShading::GfxAxialShading(const GfxAxialShading *shading):
   GfxUnivariateShading(shading)
 {
   x0 = shading->x0;
@@ -4035,7 +4035,7 @@ GfxAxialShading *GfxAxialShading::parse(GfxResources *res, Dict *dict, OutputDev
   return shading;
 }
 
-GfxShading *GfxAxialShading::copy() {
+GfxShading *GfxAxialShading::copy() const {
   return new GfxAxialShading(this);
 }
 
@@ -4128,7 +4128,7 @@ GfxRadialShading::GfxRadialShading(double x0A, double y0A, double r0A,
   r1 = r1A;
 }
 
-GfxRadialShading::GfxRadialShading(GfxRadialShading *shading):
+GfxRadialShading::GfxRadialShading(const GfxRadialShading *shading):
   GfxUnivariateShading(shading)
 {
   x0 = shading->x0;
@@ -4214,7 +4214,7 @@ GfxRadialShading *GfxRadialShading::parse(GfxResources *res, Dict *dict, OutputD
   return shading;
 }
 
-GfxShading *GfxRadialShading::copy() {
+GfxShading *GfxRadialShading::copy() const {
   return new GfxRadialShading(this);
 }
 
@@ -4620,7 +4620,7 @@ GfxGouraudTriangleShading::GfxGouraudTriangleShading(
 }
 
 GfxGouraudTriangleShading::GfxGouraudTriangleShading(
-			       GfxGouraudTriangleShading *shading):
+			       const GfxGouraudTriangleShading *shading):
   GfxShading(shading)
 {
   int i;
@@ -4869,7 +4869,7 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(GfxResources *res, i
   return shading;
 }
 
-GfxShading *GfxGouraudTriangleShading::copy() {
+GfxShading *GfxGouraudTriangleShading::copy() const {
   return new GfxGouraudTriangleShading(this);
 }
 
@@ -4986,7 +4986,7 @@ GfxPatchMeshShading::GfxPatchMeshShading(int typeA,
   }
 }
 
-GfxPatchMeshShading::GfxPatchMeshShading(GfxPatchMeshShading *shading):
+GfxPatchMeshShading::GfxPatchMeshShading(const GfxPatchMeshShading *shading):
   GfxShading(shading)
 {
   int i;
@@ -5569,7 +5569,7 @@ void GfxPatchMeshShading::getParameterizedColor(double t, GfxColor *color) const
   }
 }
 
-GfxShading *GfxPatchMeshShading::copy() {
+GfxShading *GfxPatchMeshShading::copy() const {
   return new GfxPatchMeshShading(this);
 }
 
@@ -5747,7 +5747,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode,
   ok = false;
 }
 
-GfxImageColorMap::GfxImageColorMap(GfxImageColorMap *colorMap) {
+GfxImageColorMap::GfxImageColorMap(const GfxImageColorMap *colorMap) {
   int n, i, k;
 
   colorSpace = colorMap->colorSpace->copy();
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 0e054632..15c4c70f 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -220,7 +220,7 @@ public:
   GfxColorSpace(const GfxColorSpace &) = delete;
   GfxColorSpace& operator=(const GfxColorSpace &other) = delete;
 
-  virtual GfxColorSpace *copy() = 0;
+  virtual GfxColorSpace *copy() const = 0;
   virtual GfxColorSpaceMode getMode() const = 0;
 
   // Construct a color space.  Returns nullptr if unsuccessful.
@@ -299,7 +299,7 @@ public:
 
   GfxDeviceGrayColorSpace();
   ~GfxDeviceGrayColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csDeviceGray; }
 
   void getGray(const GfxColor *color, GfxGray *gray) const override;
@@ -333,7 +333,7 @@ public:
 
   GfxCalGrayColorSpace();
   ~GfxCalGrayColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csCalGray; }
 
   // Construct a CalGray color space.  Returns nullptr if unsuccessful.
@@ -377,7 +377,7 @@ public:
 
   GfxDeviceRGBColorSpace();
   ~GfxDeviceRGBColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csDeviceRGB; }
 
   void getGray(const GfxColor *color, GfxGray *gray) const override;
@@ -411,7 +411,7 @@ public:
 
   GfxCalRGBColorSpace();
   ~GfxCalRGBColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csCalRGB; }
 
   // Construct a CalRGB color space.  Returns nullptr if unsuccessful.
@@ -459,7 +459,7 @@ public:
 
   GfxDeviceCMYKColorSpace();
   ~GfxDeviceCMYKColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csDeviceCMYK; }
 
   void getGray(const GfxColor *color, GfxGray *gray) const override;
@@ -490,7 +490,7 @@ public:
 
   GfxLabColorSpace();
   ~GfxLabColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csLab; }
 
   // Construct a Lab color space.  Returns nullptr if unsuccessful.
@@ -540,7 +540,7 @@ public:
 
   GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA);
   ~GfxICCBasedColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csICCBased; }
 
   // Construct an ICCBased color space.  Returns nullptr if unsuccessful.
@@ -591,7 +591,7 @@ public:
 
   GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA);
   ~GfxIndexedColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csIndexed; }
 
   // Construct an Indexed color space.  Returns nullptr if unsuccessful.
@@ -644,7 +644,7 @@ public:
   GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA,
 			  Function *funcA);
   ~GfxSeparationColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csSeparation; }
 
   // Construct a Separation color space.  Returns nullptr if unsuccessful.
@@ -689,7 +689,7 @@ public:
   GfxDeviceNColorSpace(int nCompsA, std::vector<std::string> &&namesA,
 		       GfxColorSpace *alt, Function *func, std::vector<GfxSeparationColorSpace*> *sepsCS);
   ~GfxDeviceNColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csDeviceN; }
 
   // Construct a DeviceN color space.  Returns nullptr if unsuccessful.
@@ -735,7 +735,7 @@ public:
 
   GfxPatternColorSpace(GfxColorSpace *underA);
   ~GfxPatternColorSpace() override;
-  GfxColorSpace *copy() override;
+  GfxColorSpace *copy() const override;
   GfxColorSpaceMode getMode() const override { return csPattern; }
 
   // Construct a Pattern color space.  Returns nullptr if unsuccessful.
@@ -773,7 +773,7 @@ public:
 
   static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum);
 
-  virtual GfxPattern *copy() = 0;
+  virtual GfxPattern *copy() const = 0;
 
   int getType() const { return type; }
 
@@ -795,7 +795,7 @@ public:
   static GfxTilingPattern *parse(Object *patObj, int patternRefNum);
   ~GfxTilingPattern() override;
 
-  GfxPattern *copy() override;
+  GfxPattern *copy() const override;
 
   int getPaintType() const { return paintType; }
   int getTilingType() const { return tilingType; }
@@ -811,8 +811,8 @@ private:
 
   GfxTilingPattern(int paintTypeA, int tilingTypeA,
 		   const double *bboxA, double xStepA, double yStepA,
-		   Object *resDictA, const double *matrixA,
-		   Object *contentStreamA, int patternRefNumA);
+		   const Object *resDictA, const double *matrixA,
+		   const Object *contentStreamA, int patternRefNumA);
 
   int paintType;
   int tilingType;
@@ -833,7 +833,7 @@ public:
   static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum);
   ~GfxShadingPattern() override;
 
-  GfxPattern *copy() override;
+  GfxPattern *copy() const override;
 
   GfxShading *getShading() { return shading; }
   const double *getMatrix() const { return matrix; }
@@ -854,7 +854,7 @@ class GfxShading {
 public:
 
   GfxShading(int typeA);
-  GfxShading(GfxShading *shading);
+  GfxShading(const GfxShading *shading);
   virtual ~GfxShading();
 
   GfxShading(const GfxShading &) = delete;
@@ -862,7 +862,7 @@ public:
 
   static GfxShading *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state);
 
-  virtual GfxShading *copy() = 0;
+  virtual GfxShading *copy() const = 0;
 
   int getType() const { return type; }
   GfxColorSpace *getColorSpace() { return colorSpace; }
@@ -902,7 +902,7 @@ public:
 		       double t0A, double t1A,
 		       Function **funcsA, int nFuncsA,
 		       bool extend0A, bool extend1A);
-  GfxUnivariateShading(GfxUnivariateShading *shading);
+  GfxUnivariateShading(const GfxUnivariateShading *shading);
   ~GfxUnivariateShading() override;
 
   double getDomain0() const { return t0; }
@@ -949,12 +949,12 @@ public:
 		     double x1A, double y1A,
 		     const double *matrixA,
 		     Function **funcsA, int nFuncsA);
-  GfxFunctionShading(GfxFunctionShading *shading);
+  GfxFunctionShading(const GfxFunctionShading *shading);
   ~GfxFunctionShading() override;
 
   static GfxFunctionShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
 
-  GfxShading *copy() override;
+  GfxShading *copy() const override;
 
   void getDomain(double *x0A, double *y0A, double *x1A, double *y1A) const
     { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
@@ -983,12 +983,12 @@ public:
 		  double t0A, double t1A,
 		  Function **funcsA, int nFuncsA,
 		  bool extend0A, bool extend1A);
-  GfxAxialShading(GfxAxialShading *shading);
+  GfxAxialShading(const GfxAxialShading *shading);
   ~GfxAxialShading() override;
 
   static GfxAxialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
 
-  GfxShading *copy() override;
+  GfxShading *copy() const override;
 
   void getCoords(double *x0A, double *y0A, double *x1A, double *y1A) const
     { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }
@@ -1016,12 +1016,12 @@ public:
 		   double t0A, double t1A,
 		   Function **funcsA, int nFuncsA,
 		   bool extend0A, bool extend1A);
-  GfxRadialShading(GfxRadialShading *shading);
+  GfxRadialShading(const GfxRadialShading *shading);
   ~GfxRadialShading() override;
 
   static GfxRadialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state);
 
-  GfxShading *copy() override;
+  GfxShading *copy() const override;
 
   void getCoords(double *x0A, double *y0A, double *r0A,
 		 double *x1A, double *y1A, double *r1A) const
@@ -1054,12 +1054,12 @@ public:
 			    GfxGouraudVertex *verticesA, int nVerticesA,
 			    int (*trianglesA)[3], int nTrianglesA,
 			    Function **funcsA, int nFuncsA);
-  GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading);
+  GfxGouraudTriangleShading(const GfxGouraudTriangleShading *shading);
   ~GfxGouraudTriangleShading() override;
 
   static GfxGouraudTriangleShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
 
-  GfxShading *copy() override;
+  GfxShading *copy() const override;
 
   int getNTriangles() const { return nTriangles; }
 
@@ -1140,12 +1140,12 @@ public:
 
   GfxPatchMeshShading(int typeA, GfxPatch *patchesA, int nPatchesA,
 		      Function **funcsA, int nFuncsA);
-  GfxPatchMeshShading(GfxPatchMeshShading *shading);
+  GfxPatchMeshShading(const GfxPatchMeshShading *shading);
   ~GfxPatchMeshShading() override;
 
   static GfxPatchMeshShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state);
 
-  GfxShading *copy() override;
+  GfxShading *copy() const override;
 
   int getNPatches() const { return nPatches; }
   const GfxPatch *getPatch(int i) const { return &patches[i]; }
@@ -1189,7 +1189,7 @@ public:
   GfxImageColorMap& operator=(const GfxImageColorMap &) = delete;
 
   // Return a copy of this color map.
-  GfxImageColorMap *copy() { return new GfxImageColorMap(this); }
+  GfxImageColorMap *copy() const { return new GfxImageColorMap(this); }
 
   // Is color map valid?
   bool isOk() const { return ok; }
@@ -1227,7 +1227,7 @@ public:
   const GfxColor *getMatteColor() const { return (useMatte) ? &matteColor : nullptr; }
 private:
 
-  GfxImageColorMap(GfxImageColorMap *colorMap);
+  GfxImageColorMap(const GfxImageColorMap *colorMap);
 
   GfxColorSpace *colorSpace;	// the image color space
   int bits;			// bits per component
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 9a2b92a9..58364cb5 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -181,9 +181,9 @@ public:
   ~SysFontInfo();
   SysFontInfo(const SysFontInfo &) = delete;
   SysFontInfo& operator=(const SysFontInfo&) = delete;
-  bool match(SysFontInfo *fi);
-  bool match(GooString *nameA, bool boldA, bool italicA, bool obliqueA, bool fixedWidthA);
-  bool match(GooString *nameA, bool boldA, bool italicA);
+  bool match(const SysFontInfo *fi) const;
+  bool match(const GooString *nameA, bool boldA, bool italicA, bool obliqueA, bool fixedWidthA) const;
+  bool match(const GooString *nameA, bool boldA, bool italicA) const;
 };
 
 SysFontInfo::SysFontInfo(GooString *nameA, bool boldA, bool italicA, bool obliqueA, bool fixedWidthA,
@@ -205,17 +205,17 @@ SysFontInfo::~SysFontInfo() {
   delete substituteName;
 }
 
-bool SysFontInfo::match(SysFontInfo *fi) {
+bool SysFontInfo::match(const SysFontInfo *fi) const {
   return !strcasecmp(name->c_str(), fi->name->c_str()) &&
          bold == fi->bold && italic == fi->italic && oblique == fi->oblique && fixedWidth == fi->fixedWidth;
 }
 
-bool SysFontInfo::match(GooString *nameA, bool boldA, bool italicA, bool obliqueA, bool fixedWidthA) {
+bool SysFontInfo::match(const GooString *nameA, bool boldA, bool italicA, bool obliqueA, bool fixedWidthA) const {
   return !strcasecmp(name->c_str(), nameA->c_str()) &&
          bold == boldA && italic == italicA && oblique == obliqueA && fixedWidth == fixedWidthA;
 }
 
-bool SysFontInfo::match(GooString *nameA, bool boldA, bool italicA) {
+bool SysFontInfo::match(const GooString *nameA, bool boldA, bool italicA) const {
   return !strcasecmp(name->c_str(), nameA->c_str()) &&
          bold == boldA && italic == italicA;
 }
@@ -231,7 +231,7 @@ public:
   ~SysFontList();
   SysFontList(const SysFontList &) = delete;
   SysFontList& operator=(const SysFontList &) = delete;
-  SysFontInfo *find(const GooString *name, bool isFixedWidth, bool exact);
+  const SysFontInfo *find(const GooString *name, bool isFixedWidth, bool exact);
 
 #ifdef _WIN32
   void scanWindowsFonts(GooString *winFontDir);
@@ -260,7 +260,7 @@ SysFontList::~SysFontList() {
   delete fonts;
 }
 
-SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exact) {
+const SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exact) {
   GooString *name2;
   bool bold, italic, oblique;
   int n;
@@ -339,8 +339,8 @@ SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exac
   }
 
   // search for the font
-  SysFontInfo *fi = nullptr;
-  for (SysFontInfo *f : *fonts) {
+  const SysFontInfo *fi = nullptr;
+  for (const SysFontInfo *f : *fonts) {
     fi = f;
     if (fi->match(name2, bold, italic, oblique, fixedWidth)) {
       break;
@@ -349,7 +349,7 @@ SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exac
   }
   if (!fi && !exact && bold) {
     // try ignoring the bold flag
-    for (SysFontInfo *f : *fonts) {
+    for (const SysFontInfo *f : *fonts) {
       fi = f;
       if (fi->match(name2, false, italic)) {
 	break;
@@ -359,7 +359,7 @@ SysFontInfo *SysFontList::find(const GooString *name, bool fixedWidth, bool exac
   }
   if (!fi && !exact && (bold || italic)) {
     // try ignoring the bold and italic flags
-    for (SysFontInfo *f : *fonts) {
+    for (const SysFontInfo *f : *fonts) {
       fi = f;
       if (fi->match(name2, false, false)) {
 	break;
@@ -638,7 +638,7 @@ FILE *GlobalParams::findToUnicodeFile(const GooString *name) {
   FILE *f;
 
   globalParamsLocker();
-  for (GooString *dir : *toUnicodeDirs) {
+  for (const GooString *dir : *toUnicodeDirs) {
     fileName = appendToPath(dir->copy(), name->c_str());
     f = openFile(fileName->c_str(), "r");
     delete fileName;
@@ -850,7 +850,7 @@ GooString *GlobalParams::findBase14FontFile(const GooString *base14Name, const G
 GooString *GlobalParams::findSystemFontFile(const GfxFont *font,
 					  SysFontType *type,
 					  int *fontNum, GooString *substituteFontName, const GooString *base14Name) {
-  SysFontInfo *fi = nullptr;
+  const SysFontInfo *fi = nullptr;
   FcPattern *p=nullptr;
   GooString *path = nullptr;
   const GooString *fontName = font->getName();
@@ -951,9 +951,10 @@ GooString *GlobalParams::findSystemFontFile(const GfxFont *font,
 	  *fontNum = 0;
 	  *type = (!strncasecmp(ext,".ttc",4)) ? sysFontTTC : sysFontTTF;
 	  FcPatternGetInteger(set->fonts[i], FC_INDEX, 0, fontNum);
-	  fi = new SysFontInfo(fontName->copy(), bold, italic, oblique, font->isFixedWidth(),
-			       new GooString((char*)s), *type, *fontNum, substituteName.copy());
-	  sysFonts->addFcFont(fi);
+	  SysFontInfo *sfi = new SysFontInfo(fontName->copy(), bold, italic, oblique, font->isFixedWidth(),
+					      new GooString((char*)s), *type, *fontNum, substituteName.copy());
+	  sysFonts->addFcFont(sfi);
+	  fi = sfi;
 	  path = new GooString((char*)s);
 	}
 	else if (!strncasecmp(ext,".pfa",4) || !strncasecmp(ext,".pfb",4)) 
@@ -976,9 +977,10 @@ GooString *GlobalParams::findSystemFontFile(const GfxFont *font,
 	  *fontNum = 0;
 	  *type = (!strncasecmp(ext,".pfa",4)) ? sysFontPFA : sysFontPFB;
 	  FcPatternGetInteger(set->fonts[i], FC_INDEX, 0, fontNum);
-	  fi = new SysFontInfo(fontName->copy(), bold, italic, oblique, font->isFixedWidth(),
-			       new GooString((char*)s), *type, *fontNum, substituteName.copy());
-	  sysFonts->addFcFont(fi);
+	  SysFontInfo *sfi = new SysFontInfo(fontName->copy(), bold, italic, oblique, font->isFixedWidth(),
+					      new GooString((char*)s), *type, *fontNum, substituteName.copy());
+	  sysFonts->addFcFont(sfi);
+	  fi = sfi;
 	  path = new GooString((char*)s);
 	}
 	else
@@ -1098,7 +1100,7 @@ GooString *GlobalParams::findSystemFontFile(const GfxFont *font,
 					  SysFontType *type,
 					  int *fontNum, GooString * /*substituteFontName*/,
 					  const GooString * /*base14Name*/) {
-  SysFontInfo *fi;
+  const SysFontInfo *fi;
   GooString *path;
 
   const GooString *fontName = font->getName();
diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
index 8f265514..7d02ad95 100644
--- a/poppler/GlobalParamsWin.cc
+++ b/poppler/GlobalParamsWin.cc
@@ -532,7 +532,7 @@ GooString *GlobalParams::findSystemFontFile(const GfxFont *font,
 					  SysFontType *type,
 					  int *fontNum, GooString *substituteFontName,
                                           const GooString *base14Name) {
-  SysFontInfo *fi;
+  const SysFontInfo *fi;
   GooString *path = nullptr;
   const GooString *fontName = font->getName();
   if (!fontName) return nullptr;
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index e4522f62..b2661206 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -124,7 +124,7 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPadA,
   }
   separationList = new std::vector<GfxSeparationColorSpace*>();
   if (separationListA != nullptr)
-    for (GfxSeparationColorSpace *separation : *separationListA)
+    for (const GfxSeparationColorSpace *separation : *separationListA)
       separationList->push_back((GfxSeparationColorSpace*)separation->copy());
 }
 
diff --git a/utils/pdffonts.cc b/utils/pdffonts.cc
index e4e90959..598a4913 100644
--- a/utils/pdffonts.cc
+++ b/utils/pdffonts.cc
@@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
       // print the font substitutions
       printf("name                                 object ID substitute font                      substitute font file\n");
       printf("------------------------------------ --------- ------------------------------------ ------------------------------------\n");
-        for (FontInfo* font : fonts) {
+        for (const FontInfo* font : fonts) {
           if (font->getFile()) {
             printf("%-36s",
                    font->getName() ? font->getName()->c_str() : "[none]");
@@ -176,7 +176,7 @@ int main(int argc, char *argv[]) {
       // print the font info
       printf("name                                 type              encoding         emb sub uni object ID\n");
       printf("------------------------------------ ----------------- ---------------- --- --- --- ---------\n");
-        for (FontInfo* font : fonts) {
+        for (const FontInfo* font : fonts) {
           printf("%-36s %-17s %-16s %-3s %-3s %-3s",
                  font->getName() ? font->getName()->c_str() : "[none]",
                  fontTypeNames[font->getType()],


More information about the poppler mailing list