[poppler] CMakeLists.txt cpp/poppler-image.cpp cpp/poppler-page.cpp poppler/GfxState.cc qt5/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 31 18:09:24 UTC 2018


 CMakeLists.txt             |    2 -
 cpp/poppler-image.cpp      |    2 -
 cpp/poppler-page.cpp       |   14 ++++++-------
 poppler/GfxState.cc        |    2 -
 qt5/src/ArthurOutputDev.cc |   46 ++++++++++++++++++++++++++-------------------
 5 files changed, 37 insertions(+), 29 deletions(-)

New commits:
commit 9bfc10eecb57354270806aa1d9278eebb1db2287
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Fri Aug 31 18:47:52 2018 +0200

    Bump required C++ standard version to C++14 and convert a few hopefully obvious call sites where types are repeated to using std::make_unique.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35bdf1b6..b3dfa6eb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ set(POPPLER_MINOR_VERSION "68")
 set(POPPLER_MICRO_VERSION "0")
 set(POPPLER_VERSION "${POPPLER_MAJOR_VERSION}.${POPPLER_MINOR_VERSION}.${POPPLER_MICRO_VERSION}")
 
-set (CMAKE_CXX_STANDARD 11)
+set (CMAKE_CXX_STANDARD 14)
 set (CMAKE_CXX_EXTENSIONS OFF)
 
 # command line switches
diff --git a/cpp/poppler-image.cpp b/cpp/poppler-image.cpp
index 6bd43f7d..7c9bdad7 100644
--- a/cpp/poppler-image.cpp
+++ b/cpp/poppler-image.cpp
@@ -125,7 +125,7 @@ image_private *image_private::create_data(int width, int height, image::format_e
         return nullptr;
     }
 
-    std::unique_ptr<image_private> d(new image_private(width, height, format));
+    auto d = std::make_unique<image_private>(width, height, format);
     d->bytes_num = bpr * height;
     d->data = reinterpret_cast<char *>(std::malloc(d->bytes_num));
     if (!d->data) {
diff --git a/cpp/poppler-page.cpp b/cpp/poppler-page.cpp
index c3862cef..8280c14f 100644
--- a/cpp/poppler-page.cpp
+++ b/cpp/poppler-page.cpp
@@ -336,13 +336,13 @@ std::vector<text_box> page::text_list() const
     std::vector<text_box>  output_list;
 
     /* config values are same with Qt5 Page::TextList() */
-    std::unique_ptr<TextOutputDev> output_dev{
-        new TextOutputDev(nullptr,    /* char* fileName */
-                          gFalse,  /* GBool physLayoutA */
-                          0,       /* double fixedPitchA */
-                          gFalse,  /* GBool rawOrderA */
-                          gFalse)  /* GBool append */
-    };
+    auto output_dev = std::make_unique<TextOutputDev>(
+	nullptr,    /* char* fileName */
+	gFalse,  /* GBool physLayoutA */
+	0,       /* double fixedPitchA */
+	gFalse,  /* GBool rawOrderA */
+	gFalse  /* GBool append */
+    );
 
     /*
      * config values are same with Qt5 Page::TextList(),
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index a41a56bb..90e0d6a0 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -5225,7 +5225,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di
   nPatchesA = 0;
   patchesA = nullptr;
   patchesSize = 0;
-  std::unique_ptr<GfxShadingBitBuf> bitBuf(new GfxShadingBitBuf(str));
+  auto bitBuf = std::make_unique<GfxShadingBitBuf>(str);
   while (1) {
     if (!bitBuf->getBits(flagBits, &flag)) {
       break;
diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc
index f4f6b141..521c4ae0 100644
--- a/qt5/src/ArthurOutputDev.cc
+++ b/qt5/src/ArthurOutputDev.cc
@@ -149,13 +149,15 @@ const QPicture& ArthurType3Font::getGlyph(int gid) const
     Dict* resDict = m_font->getResources();
 
     QPainter glyphPainter;
-    glyphs[gid] = std::unique_ptr<QPicture>(new QPicture);
+    glyphs[gid] = std::make_unique<QPicture>();
     glyphPainter.begin(glyphs[gid].get());
-    std::unique_ptr<ArthurOutputDev> output_dev(new ArthurOutputDev(&glyphPainter));
+    auto output_dev = std::make_unique<ArthurOutputDev>(&glyphPainter);
 
-    std::unique_ptr<Gfx> gfx(new Gfx(m_doc, output_dev.get(), resDict,
-                                     &box,  // pagebox
-                                     nullptr));  // cropBox
+    auto gfx = std::make_unique<Gfx>(
+	  m_doc, output_dev.get(), resDict,
+	  &box,  // pagebox
+	  nullptr  // cropBox
+    );
 
     output_dev->startDoc(m_doc);
 
@@ -1059,9 +1061,11 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
 				    int width, int height, GBool invert,
 				    GBool interpolate, GBool inlineImg)
 {
-  std::unique_ptr<ImageStream> imgStr(new ImageStream(str, width,
-                                                      1,    // numPixelComps
-                                                      1));  // getBits
+  auto imgStr = std::make_unique<ImageStream>(
+	str, width,
+	1,  // numPixelComps
+	1  // getBits
+  );
   imgStr->reset();
 
   // TODO: Would using QImage::Format_Mono be more efficient here?
@@ -1102,16 +1106,17 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
   unsigned int *data;
   unsigned int *line;
   int x, y;
-  ImageStream *imgStr;
   Guchar *pix;
   int i;
   QImage image;
   int stride;
   
   /* TODO: Do we want to cache these? */
-  imgStr = new ImageStream(str, width,
-			   colorMap->getNumPixelComps(),
-			   colorMap->getBits());
+  auto imgStr = std::make_unique<ImageStream>(
+	str, width,
+	colorMap->getNumPixelComps(),
+	colorMap->getBits()
+  );
   imgStr->reset();
   
   image = QImage(width, height, QImage::Format_ARGB32);
@@ -1144,7 +1149,6 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
   // At this point, the QPainter coordinate transformation (CTM) is such
   // that QRect(0,0,1,1) is exactly the area of the image.
   m_painter.top()->drawImage( QRect(0,0,1,1), image );
-  delete imgStr;
 
 }
 
@@ -1176,14 +1180,18 @@ void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *
   }
 
   /* TODO: Do we want to cache these? */
-  std::unique_ptr<ImageStream> imgStr(new ImageStream(str, width,
-                                                      colorMap->getNumPixelComps(),
-                                                      colorMap->getBits()));
+  auto imgStr = std::make_unique<ImageStream>(
+	str, width,
+	colorMap->getNumPixelComps(),
+	colorMap->getBits()
+  );
   imgStr->reset();
 
-  std::unique_ptr<ImageStream> maskImageStr(new ImageStream(maskStr, maskWidth,
-                                                            maskColorMap->getNumPixelComps(),
-                                                            maskColorMap->getBits()));
+  auto maskImageStr = std::make_unique<ImageStream>(
+	maskStr, maskWidth,
+	maskColorMap->getNumPixelComps(),
+	maskColorMap->getBits()
+  );
   maskImageStr->reset();
 
   QImage image(width, height, QImage::Format_ARGB32);


More information about the poppler mailing list