diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-05-21 04:55:02 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-05-21 04:55:02 +0000 |
commit | ca62aaaa9193dc1d3375de5ddba1ab1996aea67e (patch) | |
tree | 47ab6dc596be6179dcad3776f45eb1d01b203d71 /Build/source/libs/poppler/poppler-src | |
parent | 0c746006a76d0275c549620a3b4ca5e836aa92c5 (diff) |
poppler 0.65.0
git-svn-id: svn://tug.org/texlive/trunk@47788 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/poppler/poppler-src')
33 files changed, 609 insertions, 903 deletions
diff --git a/Build/source/libs/poppler/poppler-src/CMakeLists.txt b/Build/source/libs/poppler/poppler-src/CMakeLists.txt index ac186d537e3..b5a86a5fde5 100644 --- a/Build/source/libs/poppler/poppler-src/CMakeLists.txt +++ b/Build/source/libs/poppler/poppler-src/CMakeLists.txt @@ -30,7 +30,7 @@ if (ECM_FOUND) endif() set(POPPLER_MAJOR_VERSION "0") -set(POPPLER_MINOR_VERSION "64") +set(POPPLER_MINOR_VERSION "65") set(POPPLER_MICRO_VERSION "0") set(POPPLER_VERSION "${POPPLER_MAJOR_VERSION}.${POPPLER_MINOR_VERSION}.${POPPLER_MICRO_VERSION}") @@ -316,7 +316,6 @@ configure_file(poppler/poppler-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/popple set(poppler_SRCS goo/gfile.cc goo/gmempp.cc - goo/GooHash.cc goo/GooList.cc goo/GooTimer.cc goo/GooString.cc @@ -491,7 +490,7 @@ add_library(poppler STATIC ${poppler_SRCS}) else() add_library(poppler ${poppler_SRCS}) endif() -set_target_properties(poppler PROPERTIES VERSION 75.0.0 SOVERSION 75) +set_target_properties(poppler PROPERTIES VERSION 76.0.0 SOVERSION 76) if(MINGW) get_target_property(POPPLER_SOVERSION poppler SOVERSION) set_target_properties(poppler PROPERTIES SUFFIX "-${POPPLER_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") @@ -580,7 +579,6 @@ if(ENABLE_XPDF_HEADERS) ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h DESTINATION include/poppler) install(FILES - goo/GooHash.h goo/GooList.h goo/GooTimer.h goo/GooMutex.h diff --git a/Build/source/libs/poppler/poppler-src/ChangeLog b/Build/source/libs/poppler/poppler-src/ChangeLog index af6eed92a68..d223f64a791 100644 --- a/Build/source/libs/poppler/poppler-src/ChangeLog +++ b/Build/source/libs/poppler/poppler-src/ChangeLog @@ -1,3 +1,307 @@ +commit c9e2dc7ea7e098875e6b93566bdb1d14451c3673 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 19 17:05:25 2018 +0200 + + Poppler 0.65.0 + + CMakeLists.txt | 4 ++-- + NEWS | 22 ++++++++++++++++++++++ + cpp/CMakeLists.txt | 2 +- + cpp/Doxyfile | 2 +- + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 28 insertions(+), 6 deletions(-) + +commit 921de21733816fc6cd66c70c7a4914fbfee924d6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 18 00:45:59 2018 +0200 + + qt5: remove duplicate code + + Create new toPopplerAdditionalActionType private function + + qt5/src/poppler-annotation.cc | 15 +-------------- + qt5/src/poppler-form.cc | 17 ++--------------- + qt5/src/poppler-private.cc | 18 ++++++++++++++++++ + qt5/src/poppler-private.h | 2 ++ + 4 files changed, 23 insertions(+), 29 deletions(-) + +commit 083139775fd4ee8dd073347bb0e2835aab334444 +Author: Andre Heinecke <aheinecke@intevation.de> +Date: Wed May 2 16:20:40 2018 +0200 + + qt5: Add widget annot actions to FormFields + + This adds API to access AnnotWidget actions which + are associated with a FormField. + + qt5/src/poppler-form.cc | 31 +++++++++++++++++++++++++++++++ + qt5/src/poppler-form.h | 8 ++++++++ + 2 files changed, 39 insertions(+) + +commit 784bf432bffadf654b213caa21ec95fafb963299 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 8 01:16:06 2018 +0200 + + Fix build with -DFONT_CONFIGURATION=generic + + poppler/GlobalParams.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 07b8f838b3d8859a3ad34a3140bb24475bd6ac2c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 7 19:13:07 2018 +0200 + + cast to void * to bypass new gcc -Wclass-memaccess warning + + Yes what we're doing there is a bit nasty but it works :D + + poppler/Array.cc | 2 +- + poppler/Dict.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 2e750862ed5cba42fba2c6dd953820445d9c64cb +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon May 7 19:02:40 2018 +0200 + + Remove useless memset + + Parent already has a proper constructor that initializes stuff and on + top of that the sizeof was of the pointer and not of the class itself + + poppler/StructTreeRoot.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 030c6123c42813818fbb94717d301d4723671545 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 6 17:25:39 2018 +0200 + + Fix windows build + + poppler/GlobalParamsWin.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 62ed50c649670423136a49ae0fc39a6d314336a7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 6 17:01:30 2018 +0200 + + Remove GlobalParams::getUnicodeToUnicode + + As shown by Adam in f559cc94310c149a61eb246e1aff7c093f3406b5 it was a + noop since we were not filling the hash it tried to get info from + + poppler/GfxFont.cc | 45 +-------------------------------------------- + poppler/GlobalParams.h | 1 - + 2 files changed, 1 insertion(+), 45 deletions(-) + +commit 18cc4c3006695bbebd1d99d953d555a0bb3a3a65 +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Wed Feb 21 20:15:22 2018 +0100 + + Make UnicodeMap a move-only type to simplify the initialization of + residentUnicodeMaps s.t. it is closer to the GooHash-based version. + + poppler/GlobalParams.cc | 35 ++++++---------- + poppler/UnicodeMap.cc | 106 + +++++++++++++++++++++++++++++++++++------------- + poppler/UnicodeMap.h | 16 ++++---- + 3 files changed, 97 insertions(+), 60 deletions(-) + +commit 75cba9a1434c991534795d9185d7b755d9ed288c +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Sun Feb 18 16:12:19 2018 +0100 + + Remove GooHash after replacing it by std::unordered_map. + + CMakeLists.txt | 2 - + goo/GooHash.cc | 403 + --------------------------------------------------------- + goo/GooHash.h | 93 ------------- + 3 files changed, 498 deletions(-) + +commit ccf5fbf898a27b02085b7b0707e5f59bee443fb3 +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Sun Feb 18 16:23:36 2018 +0100 + + Also replace the Win32-specific usage of GooHash by std::unordered_map + on a best-effort basis. + + poppler/GlobalParams.cc | 6 ------ + poppler/GlobalParams.h | 3 ++- + poppler/GlobalParamsWin.cc | 25 ++++++++++++------------- + 3 files changed, 14 insertions(+), 20 deletions(-) + +commit 85e43288159804c57b3168fa95f955c41040bd29 +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Sun Feb 18 16:11:55 2018 +0100 + + Replace GooHash by std::unordered_map in PSOutputDev. + + poppler/PSOutputDev.cc | 31 +++++++++++-------------------- + poppler/PSOutputDev.h | 8 +++++--- + 2 files changed, 16 insertions(+), 23 deletions(-) + +commit d5701be9c7daaf097698c0db57e004c4782450ee +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Sun Feb 18 16:11:29 2018 +0100 + + Replace GooHash by std::unordered_map in OutputDev. + + poppler/Gfx.cc | 20 ++++---------------- + poppler/OutputDev.cc | 15 ++++----------- + poppler/OutputDev.h | 15 +++++++++------ + poppler/PSOutputDev.h | 3 ++- + poppler/ProfileData.cc | 10 +--------- + poppler/ProfileData.h | 25 ++++++++++--------------- + test/pdf-inspector.cc | 17 +++++------------ + 7 files changed, 35 insertions(+), 70 deletions(-) + +commit f559cc94310c149a61eb246e1aff7c093f3406b5 +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Sun Feb 18 16:10:59 2018 +0100 + + Replace GooHash by std::unordered_map in GlobalParams. + + poppler/CharCodeToUnicode.cc | 9 +- + poppler/CharCodeToUnicode.h | 3 +- + poppler/GlobalParams.cc | 218 + ++++++++++++++----------------------------- + poppler/GlobalParams.h | 34 +++---- + 4 files changed, 97 insertions(+), 167 deletions(-) + +commit 41ad41d6eb726aabd3bff18db5c08422e0d18807 +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Sun Feb 18 16:10:16 2018 +0100 + + Replace GooHash by std::unordered_map in FoFiTrueType. + + fofi/FoFiTrueType.cc | 39 +++++++++++++++------------------------ + fofi/FoFiTrueType.h | 8 +++++--- + 2 files changed, 20 insertions(+), 27 deletions(-) + +commit 55272138c3835dd9db8733850304ffe966e6478d +Author: Adam Reichold <adam.reichold@t-online.de> +Date: Tue Feb 20 09:07:17 2018 +0100 + + Add conversion methods between GooString and std::string. + + goo/GooString.h | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 08a4ac65d202742209bca6cf3806c4d111a5522c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 4 15:51:18 2018 +0200 + + FindLIBOPENJPEG2.cmake: Remove cache code + + It wasn't working since the if mentioned LIBOPENJPEG2_INCLUDE_DIR + instead of LIBOPENJPEG2_INCLUDE_DIRS + and when fixing the typo it broke the build because we were not + defining USE_OPENJPEG2, so better just + remove the broken if code + + cmake/modules/FindLIBOPENJPEG2.cmake | 22 +++++++--------------- + 1 file changed, 7 insertions(+), 15 deletions(-) + +commit 8f94bc8e6f65420a63411ead3a7e838a9542acbd +Author: Bjarni Ingi Gislason <bjarniig@rhi.hi.is> +Date: Fri May 4 15:29:09 2018 +0200 + + pdffonts: Minor formatting changes in the man page + + Bug #105194 + + utils/pdffonts.1 | 18 ++++++++++-------- + 1 file changed, 10 insertions(+), 8 deletions(-) + +commit 7bd0f774508f543616ebb2ad1f4558fdacfca5b7 +Author: Zsombor Hollay-Horvath <hollay.horvath@gmail.com> +Date: Fri May 4 15:23:21 2018 +0200 + + cpp: Expose more image modes, add option to select mode in renderer + + Bug #105558 + + cpp/poppler-image.cpp | 46 +++++++++++++++- + cpp/poppler-image.h | 5 +- + cpp/poppler-page-renderer.cpp | 124 + +++++++++++++++++++++++++++++++++++++++++- + cpp/poppler-page-renderer.h | 13 +++++ + 4 files changed, 184 insertions(+), 4 deletions(-) + +commit 60b4fe65bc9dc9b82bbadf0be2e3781be796a13d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 1 02:46:17 2018 +0200 + + FoFiType1C::cvtGlyph: Fix infinite recursion on malformed documents + + Bugs #104942, #103238 + + fofi/FoFiType1C.cc | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +commit 8429a67536b7c2f6d752e4a522ee98e6f76a40f9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 1 02:44:37 2018 +0200 + + XRef: Fix runtime undefined behaviour + + Going to the position -1 of an array is undefined behaviour, so + don't do + it + + Bug #105970 + + poppler/XRef.cc | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +commit 9d42769705180d6df4ba8415849ef8790a0e9b1d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 1 02:43:21 2018 +0200 + + Add the invisible character check to SplashOutputDev::beginType3Char + + Bug #106244 + + poppler/SplashOutputDev.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 15d6519933256ffd1746eb6c7988def34228952e +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Apr 30 15:09:26 2018 +0200 + + cpp: add a newline after the error line + + cpp/poppler-private.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6085b7b35b8ee6b0aab2d1b55064f79cb7e2c2fb +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Mar 23 16:46:09 2018 +0100 + + Make poppler_form_field_get_font_size return 0 + + It was doing that anyway but in a more complex way. + + Added a note into the docu so that people can volunteer to come + and fix it if someone is using it + + glib/poppler-form-field.cc | 5 ++++- + poppler/Annot.cc | 1 - + poppler/Annot.h | 3 --- + poppler/Form.cc | 4 ---- + poppler/Form.h | 2 -- + 5 files changed, 4 insertions(+), 11 deletions(-) + +commit a613cd32bcaabe67649536886637ad022685c402 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Apr 19 17:10:23 2018 +0200 + + Fix compilation with libc++ + + qt5/src/ArthurOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + commit 4d851d16aa6a2a9f00b60091a2ef810be1a571ea Author: Albert Astals Cid <aacid@kde.org> Date: Tue Apr 17 20:04:26 2018 +0200 diff --git a/Build/source/libs/poppler/poppler-src/NEWS b/Build/source/libs/poppler/poppler-src/NEWS index 7acec550d87..8e380f15799 100644 --- a/Build/source/libs/poppler/poppler-src/NEWS +++ b/Build/source/libs/poppler/poppler-src/NEWS @@ -1,3 +1,25 @@ +Release 0.65.0 + core: + * SplashOutputDev: Add the invisible character check beginType3Char. Bug #106244 + * XRef: Fix runtime undefined behaviour. Bug #105970 + * Fix issues with malformed documents. Bug #104942, #103238 + * Remove GooHash after replacing it by std::unordered_map + * Add conversion methods between GooString and std::string. + + cpp: + * Add newline after error message + * Expose more image modes, add option to select mode in renderer. Bug #105558 + + build system: + * Fix compilation with libc++ + * Small improvement to FindLIBOPENJPEG2.cmake + + qt5: + * Add widget annot actions to FormFields + + utils: + * pdffonts: Minor formatting changes in the man page. Bug #105194 + Release 0.64.0 core: * Workaround form field text not being drawn on broken files. Bug #103245 diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc index 76299acc3d5..caf84f8da08 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc @@ -23,6 +23,7 @@ // Copyright (C) 2014 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2015 Aleksei Volkov <Aleksei Volkov> // Copyright (C) 2015, 2016 William Bader <williambader@hotmail.com> +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -43,7 +44,6 @@ #include "goo/gmem.h" #include "goo/GooLikely.h" #include "goo/GooString.h" -#include "goo/GooHash.h" #include "FoFiType1C.h" #include "FoFiTrueType.h" #include "poppler/Error.h" @@ -305,7 +305,6 @@ FoFiTrueType::FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceI nTables = 0; cmaps = nullptr; nCmaps = 0; - nameToGID = nullptr; parsedOk = gFalse; faceIndex = faceIndexA; gsubFeatureTable = 0; @@ -317,9 +316,6 @@ FoFiTrueType::FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceI FoFiTrueType::~FoFiTrueType() { gfree(tables); gfree(cmaps); - if (nameToGID) { - delete nameToGID; - } } int FoFiTrueType::getNumCmaps() { @@ -442,11 +438,12 @@ int FoFiTrueType::mapCodeToGID(int i, Guint c) { return gid; } -int FoFiTrueType::mapNameToGID(char *name) { - if (!nameToGID) { +int FoFiTrueType::mapNameToGID(char *name) const { + const auto gid = nameToGID.find(name); + if (gid == nameToGID.end()) { return 0; } - return nameToGID->lookupInt(name); + return gid->second; } GBool FoFiTrueType::getCFFBlock(char **start, int *length) { @@ -1450,7 +1447,7 @@ void FoFiTrueType::parse() { } void FoFiTrueType::readPostTable() { - GooString *name; + std::string name; int tablePos, postFmt, stringIdx, stringPos; GBool ok; int i, j, n, m; @@ -1465,12 +1462,12 @@ void FoFiTrueType::readPostTable() { goto err; } if (postFmt == 0x00010000) { - nameToGID = new GooHash(gTrue); + nameToGID.reserve(258); for (i = 0; i < 258; ++i) { - nameToGID->add(new GooString(macGlyphNames[i]), i); + nameToGID.emplace(macGlyphNames[i], i); } } else if (postFmt == 0x00020000) { - nameToGID = new GooHash(gTrue); + nameToGID.reserve(258); n = getU16BE(tablePos + 32, &ok); if (!ok) { goto err; @@ -1484,8 +1481,7 @@ void FoFiTrueType::readPostTable() { ok = gTrue; j = getU16BE(tablePos + 34 + 2*i, &ok); if (j < 258) { - nameToGID->removeInt(macGlyphNames[j]); - nameToGID->add(new GooString(macGlyphNames[j]), i); + nameToGID[macGlyphNames[j]] = i; } else { j -= 258; if (j != stringIdx) { @@ -1500,23 +1496,21 @@ void FoFiTrueType::readPostTable() { if (!ok || !checkRegion(stringPos + 1, m)) { continue; } - name = new GooString((char *)&file[stringPos + 1], m); - nameToGID->removeInt(name); - nameToGID->add(name, i); + name.assign((char *)&file[stringPos + 1], m); + nameToGID[name] = i; ++stringIdx; stringPos += 1 + m; } } } else if (postFmt == 0x00028000) { - nameToGID = new GooHash(gTrue); + nameToGID.reserve(258); for (i = 0; i < nGlyphs; ++i) { j = getU8(tablePos + 32 + i, &ok); if (!ok) { continue; } if (j < 258) { - nameToGID->removeInt(macGlyphNames[j]); - nameToGID->add(new GooString(macGlyphNames[j]), i); + nameToGID[macGlyphNames[j]] = i; } } } @@ -1524,10 +1518,7 @@ void FoFiTrueType::readPostTable() { return; err: - if (nameToGID) { - delete nameToGID; - nameToGID = nullptr; - } + nameToGID.clear(); } int FoFiTrueType::seekTable(const char *tag) { diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h index 0c42c837f0d..6bc4022f7db 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h @@ -18,6 +18,7 @@ // Copyright (C) 2011, 2012 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2016 William Bader <williambader@hotmail.com> +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -32,11 +33,12 @@ #endif #include "stddef.h" +#include <unordered_map> +#include <string> #include "goo/gtypes.h" #include "FoFiBase.h" class GooString; -class GooHash; struct TrueTypeTable; struct TrueTypeCmap; @@ -82,7 +84,7 @@ public: // Returns the GID corresponding to <name> according to the post // table. Returns 0 if there is no mapping for <name> or if the // font does not have a post table. - int mapNameToGID(char *name); + int mapNameToGID(char *name) const; // Return the mapping from CIDs to GIDs, and return the number of // CIDs in *<nCIDs>. This is only useful for CID fonts. (Only @@ -199,7 +201,7 @@ private: int nGlyphs; int locaFmt; int bbox[4]; - GooHash *nameToGID; + std::unordered_map<std::string,int> nameToGID; GBool openTypeCFF; GBool parsedOk; diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc b/Build/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc index 03e779938f1..b14561ff31e 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc @@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2009, 2010, 2017 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009, 2010, 2017, 2018 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // // To see a description of the changes please see the Changelog file that @@ -32,6 +32,7 @@ #include <math.h> #include "goo/gmem.h" #include "goo/gstrtod.h" +#include "goo/GooLikely.h" #include "goo/GooString.h" #include "poppler/Error.h" #include "FoFiEncodings.h" @@ -1361,7 +1362,7 @@ void FoFiType1C::cvtGlyph(int offset, int nBytes, GooString *charBuf, --nOps; ok = gTrue; getIndexVal(subrIdx, k, &val, &ok); - if (ok) { + if (likely(ok && val.pos != offset)) { cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse); } } else { @@ -1596,7 +1597,7 @@ void FoFiType1C::cvtGlyph(int offset, int nBytes, GooString *charBuf, --nOps; ok = gTrue; getIndexVal(&gsubrIdx, k, &val, &ok); - if (ok) { + if (likely(ok && val.pos != offset)) { cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse); } } else { diff --git a/Build/source/libs/poppler/poppler-src/goo/GooHash.cc b/Build/source/libs/poppler/poppler-src/goo/GooHash.cc deleted file mode 100644 index 620803eb603..00000000000 --- a/Build/source/libs/poppler/poppler-src/goo/GooHash.cc +++ /dev/null @@ -1,403 +0,0 @@ -//======================================================================== -// -// GooHash.cc -// -// Copyright 2001-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include "gmem.h" -#include "GooString.h" -#include "GooHash.h" -#include "GooLikely.h" - -//------------------------------------------------------------------------ - -struct GooHashBucket { - GooString *key; - union { - void *p; - int i; - } val; - GooHashBucket *next; -}; - -struct GooHashIter { - int h; - GooHashBucket *p; -}; - -//------------------------------------------------------------------------ - -GooHash::GooHash(GBool deleteKeysA) { - int h; - - deleteKeys = deleteKeysA; - size = 7; - tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *)); - for (h = 0; h < size; ++h) { - tab[h] = nullptr; - } - len = 0; -} - -GooHash::~GooHash() { - GooHashBucket *p; - int h; - - for (h = 0; h < size; ++h) { - while (tab[h]) { - p = tab[h]; - tab[h] = p->next; - if (deleteKeys) { - delete p->key; - } - delete p; - } - } - gfree(tab); -} - -void GooHash::add(GooString *key, void *val) { - GooHashBucket *p; - int h; - - // expand the table if necessary - if (len >= size) { - expand(); - } - - // add the new symbol - p = new GooHashBucket; - p->key = key; - p->val.p = val; - h = hash(key); - p->next = tab[h]; - tab[h] = p; - ++len; -} - -void GooHash::add(GooString *key, int val) { - GooHashBucket *p; - int h; - - // expand the table if necessary - if (len >= size) { - expand(); - } - - // add the new symbol - p = new GooHashBucket; - p->key = key; - p->val.i = val; - h = hash(key); - p->next = tab[h]; - tab[h] = p; - ++len; -} - -void GooHash::replace(GooString *key, void *val) { - GooHashBucket *p; - int h; - - if ((p = find(key, &h))) { - p->val.p = val; - if (deleteKeys) { - delete key; - } - } else { - add(key, val); - } -} - -void GooHash::replace(GooString *key, int val) { - GooHashBucket *p; - int h; - - if ((p = find(key, &h))) { - p->val.i = val; - if (deleteKeys) { - delete key; - } - } else { - add(key, val); - } -} - -void *GooHash::lookup(GooString *key) { - GooHashBucket *p; - int h; - - if (!(p = find(key, &h))) { - return nullptr; - } - return p->val.p; -} - -int GooHash::lookupInt(const GooString *key) { - GooHashBucket *p; - int h; - - if (!(p = find(key, &h))) { - return 0; - } - return p->val.i; -} - -void *GooHash::lookup(const char *key) { - GooHashBucket *p; - int h; - - if (!(p = find(key, &h))) { - return nullptr; - } - return p->val.p; -} - -int GooHash::lookupInt(const char *key) { - GooHashBucket *p; - int h; - - if (!(p = find(key, &h))) { - return 0; - } - return p->val.i; -} - -void *GooHash::remove(GooString *key) { - GooHashBucket *p; - GooHashBucket **q; - void *val; - int h; - - if (!(p = find(key, &h))) { - return nullptr; - } - q = &tab[h]; - while (*q != p) { - q = &((*q)->next); - } - *q = p->next; - if (deleteKeys) { - delete p->key; - } - val = p->val.p; - delete p; - --len; - return val; -} - -int GooHash::removeInt(GooString *key) { - GooHashBucket *p; - GooHashBucket **q; - int val; - int h; - - if (!(p = find(key, &h))) { - return 0; - } - q = &tab[h]; - while (*q != p) { - q = &((*q)->next); - } - *q = p->next; - if (deleteKeys) { - delete p->key; - } - val = p->val.i; - delete p; - --len; - return val; -} - -void *GooHash::remove(const char *key) { - GooHashBucket *p; - GooHashBucket **q; - void *val; - int h; - - if (!(p = find(key, &h))) { - return nullptr; - } - q = &tab[h]; - while (*q != p) { - q = &((*q)->next); - } - *q = p->next; - if (deleteKeys) { - delete p->key; - } - val = p->val.p; - delete p; - --len; - return val; -} - -int GooHash::removeInt(const char *key) { - GooHashBucket *p; - GooHashBucket **q; - int val; - int h; - - if (!(p = find(key, &h))) { - return 0; - } - q = &tab[h]; - while (*q != p) { - q = &((*q)->next); - } - *q = p->next; - if (deleteKeys) { - delete p->key; - } - val = p->val.i; - delete p; - --len; - return val; -} - -void GooHash::startIter(GooHashIter **iter) { - *iter = new GooHashIter; - (*iter)->h = -1; - (*iter)->p = nullptr; -} - -GBool GooHash::getNext(GooHashIter **iter, GooString **key, void **val) { - if (!*iter) { - return gFalse; - } - if ((*iter)->p) { - (*iter)->p = (*iter)->p->next; - } - while (!(*iter)->p) { - if (++(*iter)->h == size) { - delete *iter; - *iter = nullptr; - return gFalse; - } - (*iter)->p = tab[(*iter)->h]; - } - *key = (*iter)->p->key; - *val = (*iter)->p->val.p; - return gTrue; -} - -GBool GooHash::getNext(GooHashIter **iter, GooString **key, int *val) { - if (!*iter) { - return gFalse; - } - if ((*iter)->p) { - (*iter)->p = (*iter)->p->next; - } - while (!(*iter)->p) { - if (++(*iter)->h == size) { - delete *iter; - *iter = nullptr; - return gFalse; - } - (*iter)->p = tab[(*iter)->h]; - } - *key = (*iter)->p->key; - *val = (*iter)->p->val.i; - return gTrue; -} - -void GooHash::killIter(GooHashIter **iter) { - delete *iter; - *iter = nullptr; -} - -void GooHash::expand() { - GooHashBucket **oldTab; - GooHashBucket *p; - int oldSize, h, i; - - oldSize = size; - oldTab = tab; - size = 2*size + 1; - tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *)); - for (h = 0; h < size; ++h) { - tab[h] = nullptr; - } - for (i = 0; i < oldSize; ++i) { - while (oldTab[i]) { - p = oldTab[i]; - oldTab[i] = oldTab[i]->next; - h = hash(p->key); - p->next = tab[h]; - tab[h] = p; - } - } - gfree(oldTab); -} - -GooHashBucket *GooHash::find(const GooString *key, int *h) { - GooHashBucket *p; - - if (unlikely(!key)) - return nullptr; - - *h = hash(key); - for (p = tab[*h]; p; p = p->next) { - if (!p->key->cmp(key)) { - return p; - } - } - return nullptr; -} - -GooHashBucket *GooHash::find(const char *key, int *h) { - GooHashBucket *p; - - *h = hash(key); - for (p = tab[*h]; p; p = p->next) { - if (!p->key->cmp(key)) { - return p; - } - } - return nullptr; -} - -int GooHash::hash(const GooString *key) { - const char *p; - unsigned int h; - int i; - - h = 0; - for (p = key->getCString(), i = 0; i < key->getLength(); ++p, ++i) { - h = 17 * h + (int)(*p & 0xff); - } - return (int)(h % size); -} - -int GooHash::hash(const char *key) { - const char *p; - unsigned int h; - - h = 0; - for (p = key; *p; ++p) { - h = 17 * h + (int)(*p & 0xff); - } - return (int)(h % size); -} diff --git a/Build/source/libs/poppler/poppler-src/goo/GooHash.h b/Build/source/libs/poppler/poppler-src/goo/GooHash.h deleted file mode 100644 index 57f883c6898..00000000000 --- a/Build/source/libs/poppler/poppler-src/goo/GooHash.h +++ /dev/null @@ -1,93 +0,0 @@ -//======================================================================== -// -// GooHash.h -// -// Copyright 2001-2003 Glyph & Cog, LLC -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich -// -// To see a description of the changes please see the Changelog file that -// came with your tarball or type make ChangeLog if you are building from git -// -//======================================================================== - -#ifndef GHASH_H -#define GHASH_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "gtypes.h" - -class GooString; -struct GooHashBucket; -struct GooHashIter; - -//------------------------------------------------------------------------ - -class GooHash { -public: - - GooHash(GBool deleteKeysA = gFalse); - ~GooHash(); - void add(GooString *key, void *val); - void add(GooString *key, int val); - void replace(GooString *key, void *val); - void replace(GooString *key, int val); - void *lookup(GooString *key); - int lookupInt(const GooString *key); - void *lookup(const char *key); - int lookupInt(const char *key); - void *remove(GooString *key); - int removeInt(GooString *key); - void *remove(const char *key); - int removeInt(const char *key); - int getLength() { return len; } - void startIter(GooHashIter **iter); - GBool getNext(GooHashIter **iter, GooString **key, void **val); - GBool getNext(GooHashIter **iter, GooString **key, int *val); - void killIter(GooHashIter **iter); - -private: - GooHash(const GooHash &other); - GooHash& operator=(const GooHash &other); - - void expand(); - GooHashBucket *find(const GooString *key, int *h); - GooHashBucket *find(const char *key, int *h); - int hash(const GooString *key); - int hash(const char *key); - - GBool deleteKeys; // set if key strings should be deleted - int size; // number of buckets - int len; // number of entries - GooHashBucket **tab; -}; - -#define deleteGooHash(hash, T) \ - do { \ - GooHash *_hash = (hash); \ - { \ - GooHashIter *_iter; \ - GooString *_key; \ - void *_p; \ - _hash->startIter(&_iter); \ - while (_hash->getNext(&_iter, &_key, &_p)) { \ - delete (T*)_p; \ - } \ - delete _hash; \ - } \ - } while(0) - -#endif diff --git a/Build/source/libs/poppler/poppler-src/goo/GooString.h b/Build/source/libs/poppler/poppler-src/goo/GooString.h index 87fd5a8559b..78ebd85b81a 100644 --- a/Build/source/libs/poppler/poppler-src/goo/GooString.h +++ b/Build/source/libs/poppler/poppler-src/goo/GooString.h @@ -20,7 +20,7 @@ // Copyright (C) 2008-2010, 2012, 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Jason Crain <jason@aquaticape.us> -// Copyright (C) 2015 Adam Reichold <adam.reichold@t-online.de> +// Copyright (C) 2015, 2018 Adam Reichold <adam.reichold@t-online.de> // Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com> // Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich @@ -39,6 +39,7 @@ #include <stdarg.h> #include <stdlib.h> // for NULL +#include <string> #include "gtypes.h" #ifdef __clang__ @@ -171,6 +172,10 @@ public: // The caller owns the return value GooString *sanitizedName(GBool psmode) const; + // Conversion from and to std::string + explicit GooString(const std::string& str) : GooString(str.data(), str.size()) {} + std::string toStr() const { return std::string(getCString(), getLength()); } + private: GooString(const GooString &other); GooString& operator=(const GooString &other); diff --git a/Build/source/libs/poppler/poppler-src/poppler/Annot.cc b/Build/source/libs/poppler/poppler-src/poppler/Annot.cc index 9549856076f..d5a66524797 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Annot.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Annot.cc @@ -1203,7 +1203,6 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) { appearStreams = nullptr; appearBBox = nullptr; appearState = nullptr; - fontSize = 0; appearance.setToNull(); diff --git a/Build/source/libs/poppler/poppler-src/poppler/Annot.h b/Build/source/libs/poppler/poppler-src/poppler/Annot.h index c1acc0658e2..83c10b397b1 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Annot.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Annot.h @@ -635,8 +635,6 @@ public: double getXMax(); double getYMax(); - double getFontSize() { return fontSize; } - void setRect(PDFRectangle *rect); void setRect(double x1, double y1, double x2, double y2); @@ -734,7 +732,6 @@ protected: Ref ref; // object ref identifying this annotation AnnotBorder *border; // Border, BS AnnotColor *color; // C - double fontSize; GBool ok; bool hasRef; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Array.cc b/Build/source/libs/poppler/poppler-src/poppler/Array.cc index 3276349fbcc..e8aa34eafe6 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Array.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Array.cc @@ -112,7 +112,7 @@ void Array::remove(int i) { #endif } --length; - memmove( elems + i, elems + i + 1, sizeof(elems[0]) * (length - i) ); + memmove( static_cast<void*>(elems + i), elems + i + 1, sizeof(elems[0]) * (length - i) ); } Object Array::get(int i, int recursion) const { diff --git a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc index 7e0cd895ae8..fed6cdb730c 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc @@ -26,6 +26,7 @@ // Copyright (C) 2015 Marek Kasik <mkasik@redhat.com> // Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -126,7 +127,7 @@ CharCodeToUnicode *CharCodeToUnicode::makeIdentityMapping() { return ctu; } -CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GooString *fileName, +CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(const char *fileName, GooString *collection) { FILE *f; Unicode *mapA; @@ -135,8 +136,8 @@ CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GooString *fileName, Unicode u; CharCodeToUnicode *ctu; - if (!(f = openFile(fileName->getCString(), "r"))) { - error(errIO, -1, "Couldn't open cidToUnicode file '{0:t}'", + if (!(f = openFile(fileName, "r"))) { + error(errIO, -1, "Couldn't open cidToUnicode file '{0:s}'", fileName); return nullptr; } @@ -153,7 +154,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GooString *fileName, if (sscanf(buf, "%x", &u) == 1) { mapA[mapLenA] = u; } else { - error(errSyntaxWarning, -1, "Bad line ({0:d}) in cidToUnicode file '{1:t}'", + error(errSyntaxWarning, -1, "Bad line ({0:d}) in cidToUnicode file '{1:s}'", (int)(mapLenA + 1), fileName); mapA[mapLenA] = 0; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h index 02b92dcb55c..5a10fa243d4 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h +++ b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h @@ -20,6 +20,7 @@ // Copyright (C) 2008, 2011, 2012, 2018 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -56,7 +57,7 @@ public: // Read the CID-to-Unicode mapping for <collection> from the file // specified by <fileName>. Sets the initial reference count to 1. // Returns NULL on failure. - static CharCodeToUnicode *parseCIDToUnicode(GooString *fileName, + static CharCodeToUnicode *parseCIDToUnicode(const char *fileName, GooString *collection); // Create a Unicode-to-Unicode mapping from the file specified by diff --git a/Build/source/libs/poppler/poppler-src/poppler/Dict.cc b/Build/source/libs/poppler/poppler-src/poppler/Dict.cc index a431f7ebf68..bc86fd77ad9 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Dict.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Dict.cc @@ -201,7 +201,7 @@ void Dict::remove(const char *key) { gfree(entries[pos].key); entries[pos].val.free(); if (pos != length) { - memmove(&entries[pos], &entries[pos + 1], (length - pos) * sizeof(DictEntry)); + memmove(static_cast<void*>(&entries[pos]), &entries[pos + 1], (length - pos) * sizeof(DictEntry)); } } } else { diff --git a/Build/source/libs/poppler/poppler-src/poppler/Form.cc b/Build/source/libs/poppler/poppler-src/poppler/Form.cc index 2f5a48e127d..820944e87c3 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Form.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Form.cc @@ -129,10 +129,6 @@ void FormWidget::getRect(double *x1, double *y1, double *x2, double *y2) const { widget->getRect(x1, y1, x2, y2); } -double FormWidget::getFontSize() const { - return widget ? widget->getFontSize() : 0.; -} - bool FormWidget::isReadOnly() const { return field->isReadOnly(); diff --git a/Build/source/libs/poppler/poppler-src/poppler/Form.h b/Build/source/libs/poppler/poppler-src/poppler/Form.h index bb93ac9047f..b83ba9eaa35 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Form.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Form.h @@ -111,8 +111,6 @@ public: void setChildNum (unsigned i) { childNum = i; } unsigned getChildNum () { return childNum; } - double getFontSize() const; - const GooString *getPartialName() const; void setPartialName(const GooString &name); const GooString *getAlternateUiName() const; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc b/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc index 08132072f88..a4d12a70a35 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc @@ -39,6 +39,7 @@ // Copyright (C) 2012 Lu Wang <coolwanglu@gmail.com> // Copyright (C) 2014 Jason Crain <jason@aquaticape.us> // Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -59,7 +60,6 @@ #include <memory> #include "goo/gmem.h" #include "goo/GooTimer.h" -#include "goo/GooHash.h" #include "GlobalParams.h" #include "CharTypes.h" #include "Object.h" @@ -748,21 +748,9 @@ void Gfx::go(GBool topLevel) { // Update the profile information if (unlikely(profileCommands)) { - GooHash *hash; - - hash = out->getProfileHash (); - if (hash) { - GooString *cmd_g; - ProfileData *data_p; - - cmd_g = new GooString (obj.getCmd()); - data_p = (ProfileData *)hash->lookup (cmd_g); - if (data_p == nullptr) { - data_p = new ProfileData(); - hash->add (cmd_g, data_p); - } - - data_p->addElement(timer->getElapsed ()); + if (auto* const hash = out->getProfileHash()) { + auto& data = (*hash)[obj.getCmd()]; + data.addElement(timer->getElapsed()); } delete timer; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/GfxFont.cc b/Build/source/libs/poppler/poppler-src/poppler/GfxFont.cc index 0ab78ad53a7..7b4d4b5487a 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GfxFont.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/GfxFont.cc @@ -960,7 +960,6 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA GBool missing, hex; GBool numeric; Unicode toUnicode[256]; - CharCodeToUnicode *utu, *ctu2; Unicode uBuf[8]; double mul; int firstChar, lastChar; @@ -1326,27 +1325,6 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA // holes readToUnicodeCMap(fontDict, 16, ctu); - // look for a Unicode-to-Unicode mapping - if (name && (utu = globalParams->getUnicodeToUnicode(name))) { - Unicode *uAux; - for (i = 0; i < 256; ++i) { - toUnicode[i] = 0; - } - ctu2 = CharCodeToUnicode::make8BitToUnicode(toUnicode); - for (i = 0; i < 256; ++i) { - n = ctu->mapToUnicode((CharCode)i, &uAux); - if (n >= 1) { - n = utu->mapToUnicode((CharCode)uAux[0], &uAux); - if (n >= 1) { - ctu2->setMapping((CharCode)i, uAux, n); - } - } - } - utu->decRefCnt(); - delete ctu; - ctu = ctu2; - } - //----- get the character widths ----- // initialize all widths @@ -1744,11 +1722,8 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, Dict *desFontDict; Object desFontDictObj; Object obj1, obj2, obj3, obj4, obj5, obj6; - CharCodeToUnicode *utu; - CharCode c; - Unicode *uBuf; int c1, c2; - int excepsSize, j, k, n; + int excepsSize, j, k; refCnt = 1; ascent = 0.95; @@ -1838,24 +1813,6 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } } - // look for a Unicode-to-Unicode mapping - if (name && (utu = globalParams->getUnicodeToUnicode(name))) { - if (ctu) { - for (c = 0; c < ctu->getLength(); ++c) { - n = ctu->mapToUnicode(c, &uBuf); - if (n >= 1) { - n = utu->mapToUnicode((CharCode)uBuf[0], &uBuf); - if (n >= 1) { - ctu->setMapping(c, uBuf, n); - } - } - } - utu->decRefCnt(); - } else { - ctu = utu; - } - } - // encoding (i.e., CMap) obj1 = fontDict->lookup("Encoding"); if (obj1.isNull()) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc index cbb15eb18a8..2d8ecad74c3 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc @@ -38,6 +38,7 @@ // Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org> // Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -66,7 +67,6 @@ #include "goo/gmem.h" #include "goo/GooString.h" #include "goo/GooList.h" -#include "goo/GooHash.h" #include "goo/gfile.h" #include "Error.h" #include "NameToCharCode.h" @@ -549,9 +549,6 @@ Plugin::~Plugin() { GlobalParams::GlobalParams(const char *customPopplerDataDir) : popplerDataDir(customPopplerDataDir) { - UnicodeMap *map; - int i; - #ifdef MULTITHREADED gInitMutex(&mutex); gInitMutex(&unicodeMapCacheMutex); @@ -563,24 +560,15 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) // scan the encoding in reverse because we want the lowest-numbered // index for each char name ('space' is encoded twice) macRomanReverseMap = new NameToCharCode(); - for (i = 255; i >= 0; --i) { + for (int i = 255; i >= 0; --i) { if (macRomanEncoding[i]) { macRomanReverseMap->add(macRomanEncoding[i], (CharCode)i); } } -#ifdef _WIN32 - substFiles = new GooHash(gTrue); -#endif nameToUnicodeZapfDingbats = new NameToCharCode(); nameToUnicodeText = new NameToCharCode(); - cidToUnicodes = new GooHash(gTrue); - unicodeToUnicodes = new GooHash(gTrue); - residentUnicodeMaps = new GooHash(); - unicodeMaps = new GooHash(gTrue); - cMapDirs = new GooHash(gTrue); toUnicodeDirs = new GooList(); - fontFiles = new GooHash(gTrue); sysFonts = new SysFontList(); psExpandSmaller = gFalse; psShrinkLarger = gTrue; @@ -613,31 +601,28 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) #endif // set up the initial nameToUnicode tables - for (i = 0; nameToUnicodeZapfDingbatsTab[i].name; ++i) { + for (int i = 0; nameToUnicodeZapfDingbatsTab[i].name; ++i) { nameToUnicodeZapfDingbats->add(nameToUnicodeZapfDingbatsTab[i].name, nameToUnicodeZapfDingbatsTab[i].u); } - for (i = 0; nameToUnicodeTextTab[i].name; ++i) { + for (int i = 0; nameToUnicodeTextTab[i].name; ++i) { nameToUnicodeText->add(nameToUnicodeTextTab[i].name, nameToUnicodeTextTab[i].u); } // set up the residentUnicodeMaps table - map = new UnicodeMap("Latin1", gFalse, - latin1UnicodeMapRanges, latin1UnicodeMapLen); - residentUnicodeMaps->add(map->getEncodingName(), map); - map = new UnicodeMap("ASCII7", gFalse, - ascii7UnicodeMapRanges, ascii7UnicodeMapLen); - residentUnicodeMaps->add(map->getEncodingName(), map); - map = new UnicodeMap("Symbol", gFalse, - symbolUnicodeMapRanges, symbolUnicodeMapLen); - residentUnicodeMaps->add(map->getEncodingName(), map); - map = new UnicodeMap("ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges, - zapfDingbatsUnicodeMapLen); - residentUnicodeMaps->add(map->getEncodingName(), map); - map = new UnicodeMap("UTF-8", gTrue, &mapUTF8); - residentUnicodeMaps->add(map->getEncodingName(), map); - map = new UnicodeMap("UTF-16", gTrue, &mapUTF16); - residentUnicodeMaps->add(map->getEncodingName(), map); + residentUnicodeMaps.reserve(6); + UnicodeMap map = {"Latin1", gFalse, latin1UnicodeMapRanges, latin1UnicodeMapLen}; + residentUnicodeMaps.emplace(map.getEncodingName()->toStr(), std::move(map)); + map = {"ASCII7", gFalse, ascii7UnicodeMapRanges, ascii7UnicodeMapLen}; + residentUnicodeMaps.emplace(map.getEncodingName()->toStr(), std::move(map)); + map = {"Symbol", gFalse, symbolUnicodeMapRanges, symbolUnicodeMapLen}; + residentUnicodeMaps.emplace(map.getEncodingName()->toStr(), std::move(map)); + map = {"ZapfDingbats", gFalse, zapfDingbatsUnicodeMapRanges, zapfDingbatsUnicodeMapLen}; + residentUnicodeMaps.emplace(map.getEncodingName()->toStr(), std::move(map)); + map = {"UTF-8", gTrue, &mapUTF8}; + residentUnicodeMaps.emplace(map.getEncodingName()->toStr(), std::move(map)); + map = {"UTF-16", gTrue, &mapUTF16}; + residentUnicodeMaps.emplace(map.getEncodingName()->toStr(), std::move(map)); scanEncodingDirs(); } @@ -718,34 +703,16 @@ void GlobalParams::parseNameToUnicode(GooString *name) { fclose(f); } -void GlobalParams::addCIDToUnicode(GooString *collection, - GooString *fileName) { - GooString *old; - - if ((old = (GooString *)cidToUnicodes->remove(collection))) { - delete old; - } - cidToUnicodes->add(collection->copy(), fileName->copy()); +void GlobalParams::addCIDToUnicode(GooString *collection, GooString *fileName) { + cidToUnicodes[collection->toStr()] = fileName->toStr(); } -void GlobalParams::addUnicodeMap(GooString *encodingName, GooString *fileName) -{ - GooString *old; - - if ((old = (GooString *)unicodeMaps->remove(encodingName))) { - delete old; - } - unicodeMaps->add(encodingName->copy(), fileName->copy()); +void GlobalParams::addUnicodeMap(GooString *encodingName, GooString *fileName) { + unicodeMaps[encodingName->toStr()] = fileName->toStr(); } void GlobalParams::addCMapDir(GooString *collection, GooString *dir) { - GooList *list; - - if (!(list = (GooList *)cMapDirs->lookup(collection))) { - list = new GooList(); - cMapDirs->add(collection->copy(), list); - } - list->append(dir->copy()); + cMapDirs.emplace(collection->toStr(), dir->toStr()); } GBool GlobalParams::parseYesNo2(const char *token, GBool *flag) { @@ -766,28 +733,10 @@ GlobalParams::~GlobalParams() { delete nameToUnicodeZapfDingbats; delete nameToUnicodeText; - deleteGooHash(cidToUnicodes, GooString); - deleteGooHash(unicodeToUnicodes, GooString); - deleteGooHash(residentUnicodeMaps, UnicodeMap); - deleteGooHash(unicodeMaps, GooString); deleteGooList(toUnicodeDirs, GooString); - deleteGooHash(fontFiles, GooString); -#ifdef _WIN32 - deleteGooHash(substFiles, GooString); -#endif delete sysFonts; delete textEncoding; - GooHashIter *iter; - GooString *key; - cMapDirs->startIter(&iter); - void *val; - while (cMapDirs->getNext(&iter, &key, &val)) { - GooList* list = (GooList*)val; - deleteGooList(list, GooString); - } - delete cMapDirs; - delete cidToUnicodeCache; delete unicodeToUnicodeCache; delete unicodeMapCache; @@ -828,55 +777,48 @@ Unicode GlobalParams::mapNameToUnicodeText(const char *charName) { } UnicodeMap *GlobalParams::getResidentUnicodeMap(GooString *encodingName) { - UnicodeMap *map; + UnicodeMap *map = nullptr; lockGlobalParams; - map = (UnicodeMap *)residentUnicodeMaps->lookup(encodingName); - unlockGlobalParams; - if (map) { + const auto unicodeMap = residentUnicodeMaps.find(encodingName->toStr()); + if (unicodeMap != residentUnicodeMaps.end()) { + map = &unicodeMap->second; map->incRefCnt(); } + unlockGlobalParams; + return map; } FILE *GlobalParams::getUnicodeMapFile(GooString *encodingName) { - GooString *fileName; - FILE *f; + FILE *file = nullptr; lockGlobalParams; - if ((fileName = (GooString *)unicodeMaps->lookup(encodingName))) { - f = openFile(fileName->getCString(), "r"); - } else { - f = nullptr; + const auto unicodeMap = unicodeMaps.find(encodingName->toStr()); + if (unicodeMap != unicodeMaps.end()) { + file = openFile(unicodeMap->second.c_str(), "r"); } unlockGlobalParams; - return f; + + return file; } FILE *GlobalParams::findCMapFile(GooString *collection, GooString *cMapName) { - GooList *list; - GooString *dir; - GooString *fileName; - FILE *f; - int i; + FILE *file = nullptr; lockGlobalParams; - if (!(list = (GooList *)cMapDirs->lookup(collection))) { - unlockGlobalParams; - return nullptr; - } - for (i = 0; i < list->getLength(); ++i) { - dir = (GooString *)list->get(i); - fileName = appendToPath(dir->copy(), cMapName->getCString()); - f = openFile(fileName->getCString(), "r"); - delete fileName; - if (f) { - unlockGlobalParams; - return f; + const auto cMapDirs = this->cMapDirs.equal_range(collection->toStr()); + for (auto cMapDir = cMapDirs.first; cMapDir != cMapDirs.second; ++cMapDir) { + auto* const path = new GooString(cMapDir->second); + appendToPath(path, cMapName->getCString()); + file = openFile(path->getCString(), "r"); + delete path; + if (file) { + break; } } unlockGlobalParams; - return nullptr; + return file; } FILE *GlobalParams::findToUnicodeFile(GooString *name) { @@ -1074,17 +1016,16 @@ static FcPattern *buildFcPattern(GfxFont *font, const GooString *base14Name) #endif GooString *GlobalParams::findFontFile(GooString *fontName) { - GooString *path; + GooString *path = nullptr; setupBaseFonts(nullptr); lockGlobalParams; - if ((path = (GooString *)fontFiles->lookup(fontName))) { - path = path->copy(); - unlockGlobalParams; - return path; + const auto fontFile = fontFiles.find(fontName->toStr()); + if (fontFile != fontFiles.end()) { + path = new GooString(fontFile->second); } unlockGlobalParams; - return nullptr; + return path; } /* if you can't or don't want to use Fontconfig, you need to implement @@ -1092,7 +1033,7 @@ GooString *GlobalParams::findFontFile(GooString *fontName) { */ #ifdef WITH_FONTCONFIGURATION_FONTCONFIG // not needed for fontconfig -void GlobalParams::setupBaseFonts(char *dir) { +void GlobalParams::setupBaseFonts(char *) { } GooString *GlobalParams::findBase14FontFile(GooString *base14Name, GfxFont *font) { @@ -1313,7 +1254,7 @@ void GlobalParams::setupBaseFonts(char *dir) { int i, j; for (i = 0; displayFontTab[i].name; ++i) { - if (fontFiles->lookup(displayFontTab[i].name)) { + if (fontFiles.count(displayFontTab[i].name) > 0) { continue; } fontName = new GooString(displayFontTab[i].name); @@ -1455,40 +1396,15 @@ GBool GlobalParams::getErrQuiet() { } CharCodeToUnicode *GlobalParams::getCIDToUnicode(GooString *collection) { - GooString *fileName; CharCodeToUnicode *ctu; lockGlobalParams; if (!(ctu = cidToUnicodeCache->getCharCodeToUnicode(collection))) { - if ((fileName = (GooString *)cidToUnicodes->lookup(collection)) && - (ctu = CharCodeToUnicode::parseCIDToUnicode(fileName, collection))) { - cidToUnicodeCache->add(ctu); - } - } - unlockGlobalParams; - return ctu; -} - -CharCodeToUnicode *GlobalParams::getUnicodeToUnicode(GooString *fontName) { - lockGlobalParams; - GooHashIter *iter; - unicodeToUnicodes->startIter(&iter); - GooString *fileName = nullptr; - GooString *fontPattern; - void *val; - while (!fileName && unicodeToUnicodes->getNext(&iter, &fontPattern, &val)) { - if (strstr(fontName->getCString(), fontPattern->getCString())) { - unicodeToUnicodes->killIter(&iter); - fileName = (GooString*)val; - } - } - CharCodeToUnicode *ctu = nullptr; - if (fileName) { - ctu = unicodeToUnicodeCache->getCharCodeToUnicode(fileName); - if (!ctu) { - ctu = CharCodeToUnicode::parseUnicodeToUnicode(fileName); - if (ctu) - unicodeToUnicodeCache->add(ctu); + const auto cidToUnicode = cidToUnicodes.find(collection->toStr()); + if (cidToUnicode != cidToUnicodes.end()) { + if((ctu = CharCodeToUnicode::parseCIDToUnicode(cidToUnicode->second.c_str(), collection))) { + cidToUnicodeCache->add(ctu); + } } } unlockGlobalParams; @@ -1525,20 +1441,13 @@ UnicodeMap *GlobalParams::getTextEncoding() { GooList *GlobalParams::getEncodingNames() { - GooList *result = new GooList; - GooHashIter *iter; - GooString *key; - void *val; - residentUnicodeMaps->startIter(&iter); - while (residentUnicodeMaps->getNext(&iter, &key, &val)) { - result->append(key); + auto* const result = new GooList; + for (const auto& unicodeMap : residentUnicodeMaps) { + result->append(new GooString(unicodeMap.first)); } - residentUnicodeMaps->killIter(&iter); - unicodeMaps->startIter(&iter); - while (unicodeMaps->getNext(&iter, &key, &val)) { - result->append(key); + for (const auto& unicodeMap : unicodeMaps) { + result->append(new GooString(unicodeMap.first)); } - unicodeMaps->killIter(&iter); return result; } @@ -1548,7 +1457,7 @@ GooList *GlobalParams::getEncodingNames() void GlobalParams::addFontFile(GooString *fontName, GooString *path) { lockGlobalParams; - fontFiles->add(fontName, path); + fontFiles[fontName->toStr()] = path->toStr(); unlockGlobalParams; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h index e3d660cfcf9..37124f6bc0c 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h +++ b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h @@ -26,6 +26,7 @@ // Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -44,6 +45,9 @@ #include <stdio.h> #include "goo/gtypes.h" #include "CharTypes.h" +#include "UnicodeMap.h" +#include <unordered_map> +#include <string> #ifdef MULTITHREADED #include "goo/GooMutex.h" @@ -51,11 +55,9 @@ class GooString; class GooList; -class GooHash; class NameToCharCode; class CharCodeToUnicode; class CharCodeToUnicodeCache; -class UnicodeMap; class UnicodeMapCache; class CMap; class CMapCache; @@ -147,7 +149,6 @@ public: GBool getErrQuiet(); CharCodeToUnicode *getCIDToUnicode(GooString *collection); - CharCodeToUnicode *getUnicodeToUnicode(GooString *fontName); UnicodeMap *getUnicodeMap(GooString *encodingName); CMap *getCMap(GooString *collection, GooString *cMapName, Stream *stream = NULL); UnicodeMap *getTextEncoding(); @@ -199,24 +200,25 @@ private: nameToUnicodeZapfDingbats; NameToCharCode * // mapping from char name to Unicode for text nameToUnicodeText; // extraction - GooHash *cidToUnicodes; // files for mappings from char collections - // to Unicode, indexed by collection name - // [GooString] - GooHash *unicodeToUnicodes; // files for Unicode-to-Unicode mappings, - // indexed by font name pattern [GooString] - GooHash *residentUnicodeMaps; // mappings from Unicode to char codes, - // indexed by encoding name [UnicodeMap] - GooHash *unicodeMaps; // files for mappings from Unicode to char - // codes, indexed by encoding name [GooString] - GooHash *cMapDirs; // list of CMap dirs, indexed by collection - // name [GooList[GooString]] + // files for mappings from char collections + // to Unicode, indexed by collection name + std::unordered_map<std::string, std::string> cidToUnicodes; + // mappings from Unicode to char codes, + // indexed by encoding name + std::unordered_map<std::string, UnicodeMap> residentUnicodeMaps; + // files for mappings from Unicode to char + // codes, indexed by encoding name + std::unordered_map<std::string, std::string> unicodeMaps; + // list of CMap dirs, indexed by collection + std::unordered_multimap<std::string, std::string> cMapDirs; GooList *toUnicodeDirs; // list of ToUnicode CMap dirs [GooString] GBool baseFontsInitialized; #ifdef _WIN32 - GooHash *substFiles; // windows font substitutes (for CID fonts) + // windows font substitutes (for CID fonts) + std::unordered_map<std::string, std::string> substFiles; #endif - GooHash *fontFiles; // font files: font name mapped to path - // [GString] + // font files: font name mapped to path + std::unordered_map<std::string, std::string> fontFiles; SysFontList *sysFonts; // system fonts GBool psExpandSmaller; // expand smaller pages to fill paper GBool psShrinkLarger; // shrink larger pages to fit paper diff --git a/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc b/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc index 072d0fbbb1b..9e041777653 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc @@ -6,7 +6,7 @@ // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Mark Brand <mabrand@mabrand.nl> - // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> + // Copyright (C) 2013, 2018 Adam Reichold <adamreichold@myopera.com> // Copyright (C) 2013 Dmytro Morgun <lztoad@gmail.com> // Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org> // Copyright (C) 2017, 2018 Albert Astals Cid <aacid@kde.org> @@ -38,7 +38,6 @@ description for all fonts available in Windows. That's how MuPDF works. #include "goo/gmem.h" #include "goo/GooString.h" #include "goo/GooList.h" -#include "goo/GooHash.h" #include "goo/gfile.h" #include "Error.h" #include "NameToCharCode.h" @@ -423,10 +422,11 @@ void GlobalParams::setupBaseFonts(char * dir) GetWindowsFontDir(winFontDir, sizeof(winFontDir)); for (int i = 0; displayFontTab[i].name; ++i) { - GooString *fontName = new GooString(displayFontTab[i].name); - if (fontFiles->lookup(fontName)) + if (fontFiles.count(displayFontTab[i].name) > 0) continue; + GooString *fontName = new GooString(displayFontTab[i].name); + if (dir) { GooString *fontPath = appendToPath(new GooString(dir), displayFontTab[i].t1FileName); if (FileExists(fontPath->getCString()) || @@ -480,7 +480,7 @@ void GlobalParams::setupBaseFonts(char * dir) addFontFile(new GooString(obj1.getName()), obj3.getString()->copy()); // Aliases } else if (obj2.isName()) { - substFiles->add(new GooString(obj1.getName()), new GooString(obj2.getName())); + substFiles.emplace(obj1.getName(), obj2.getName()); } } obj1 = parser->getObj(); @@ -497,8 +497,8 @@ void GlobalParams::setupBaseFonts(char * dir) } } -static const char *findSubstituteName(GfxFont *font, GooHash *fontFiles, - GooHash *substFiles, +static const char *findSubstituteName(GfxFont *font, const std::unordered_map<std::string, std::string>& fontFiles, + const std::unordered_map<std::string, std::string>& substFiles, const char *origName) { assert(origName); @@ -515,10 +515,10 @@ static const char *findSubstituteName(GfxFont *font, GooHash *fontFiles, name2->del(n - 11, 11); n -= 11; } - GooString *substName = (GooString *)substFiles->lookup(name2); - if (substName != nullptr) { + const auto substFile = substFiles.find(name2->getCString()); + if (substFile != substFiles.end()) { delete name2; - return substName->getCString(); + return substFile->second.c_str(); } /* TODO: try to at least guess bold/italic/bolditalic from the name */ @@ -538,10 +538,10 @@ static const char *findSubstituteName(GfxFont *font, GooHash *fontFiles, else if ( !collection->cmp("Adobe-Korea1") ) name3 = DEFAULT_CID_FONT_AK1_MSWIN; - if (name3 && fontFiles->lookup(name3)) + if (name3 && fontFiles.count(name3) != 0) return name3; - if (fontFiles->lookup(DEFAULT_CID_FONT_MSWIN)) + if (fontFiles.count(DEFAULT_CID_FONT_MSWIN) != 0) return DEFAULT_CID_FONT_MSWIN; } return DEFAULT_SUBSTITUTE_FONT; @@ -573,10 +573,10 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font, GooString *substFontName = new GooString(findSubstituteName(font, fontFiles, substFiles, fontName->getCString())); - GooString *path2 = nullptr; error(errSyntaxError, -1, "Couldn't find a font for '{0:t}', subst is '{1:t}'", fontName, substFontName); - if ((path2 = (GooString *)fontFiles->lookup(substFontName))) { - path = new GooString(path2); + const auto fontFile = fontFiles.find(substFontName->toStr()); + if (fontFile != fontFiles.end()) { + path = new GooString(fontFile->second.c_str()); if (substituteFontName) substituteFontName->Set(path->getCString()); if (!strcasecmp(path->getCString() + path->getLength() - 4, ".ttc")) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc index 6d42fd42f38..1a59d9e8511 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc @@ -19,6 +19,7 @@ // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009, 2012, 2013 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -36,7 +37,6 @@ #include "Stream.h" #include "GfxState.h" #include "OutputDev.h" -#include "goo/GooHash.h" //------------------------------------------------------------------------ // OutputDev @@ -179,18 +179,11 @@ void OutputDev::opiEnd(GfxState *state, Dict *opiDict) { #endif void OutputDev::startProfile() { - if (profileHash) - delete profileHash; - - profileHash = new GooHash (true); + profileHash.reset(new std::unordered_map<std::string, ProfileData>); } -GooHash *OutputDev::endProfile() { - GooHash *profile = profileHash; - - profileHash = nullptr; - - return profile; +std::unique_ptr<std::unordered_map<std::string, ProfileData>> OutputDev::endProfile() { + return std::move(profileHash); } #ifdef USE_CMS diff --git a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h index 9dc4c3e005d..52635743838 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h @@ -25,6 +25,7 @@ // Copyright (C) 2012 William Bader <williambader@hotmail.com> // Copyright (C) 2017, 2018 Oliver Sander <oliver.sander@tu-dresden.de> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -43,10 +44,13 @@ #include "CharTypes.h" #include "Object.h" #include "PopplerCache.h" +#include "ProfileData.h" +#include <memory> +#include <unordered_map> +#include <string> class Annot; class Dict; -class GooHash; class GooString; class GfxState; class Gfx; @@ -80,7 +84,6 @@ public: : iccColorSpaceCache(5) #endif { - profileHash = nullptr; } // Destructor. @@ -333,9 +336,9 @@ public: virtual void psXObject(Stream * /*psStream*/, Stream * /*level1Stream*/) {} //----- Profiling - virtual void startProfile(); - virtual GooHash *getProfileHash() {return profileHash; } - virtual GooHash *endProfile(); + void startProfile(); + std::unordered_map<std::string, ProfileData>* getProfileHash() const { return profileHash.get(); } + std::unique_ptr<std::unordered_map<std::string, ProfileData>> endProfile(); //----- transparency groups and soft masks virtual GBool checkTransparencyGroup(GfxState * /*state*/, GBool /*knockout*/) { return gTrue; } @@ -365,7 +368,7 @@ private: double defCTM[6]; // default coordinate transform matrix double defICTM[6]; // inverse of default CTM - GooHash *profileHash; + std::unique_ptr<std::unordered_map<std::string, ProfileData>> profileHash; #ifdef USE_CMS PopplerCache iccColorSpaceCache; diff --git a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc index c755caa4a9e..b466bc69a61 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc @@ -32,6 +32,7 @@ // Copyright (C) 2015 Marek Kasik <mkasik@redhat.com> // Copyright (C) 2016 Caolán McNamara <caolanm@redhat.com> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -53,7 +54,6 @@ #include <algorithm> #include "goo/GooString.h" #include "goo/GooList.h" -#include "goo/GooHash.h" #include "poppler-config.h" #include "GlobalParams.h" #include "Object.h" @@ -1108,8 +1108,6 @@ PSOutputDev::PSOutputDev(const char *fileName, PDFDoc *doc, customCodeCbkData = customCodeCbkDataA; fontIDs = nullptr; - fontNames = new GooHash(gTrue); - fontMaxValidGlyph = new GooHash(gTrue); t1FontNames = nullptr; font8Info = nullptr; font16Enc = nullptr; @@ -1177,8 +1175,6 @@ PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA, customCodeCbkData = customCodeCbkDataA; fontIDs = nullptr; - fontNames = new GooHash(gTrue); - fontMaxValidGlyph = new GooHash(gTrue); t1FontNames = nullptr; font8Info = nullptr; font16Enc = nullptr; @@ -1409,7 +1405,7 @@ void PSOutputDev::postInit() fontIDLen = 0; fontIDs = (Ref *)gmallocn(fontIDSize, sizeof(Ref)); for (i = 0; i < 14; ++i) { - fontNames->add(new GooString(psBase14SubstFonts[i].psName), 1); + fontNames.emplace(psBase14SubstFonts[i].psName); } t1FontNameSize = 64; t1FontNameLen = 0; @@ -1499,8 +1495,6 @@ PSOutputDev::~PSOutputDev() { if (fontIDs) { gfree(fontIDs); } - delete fontNames; - delete fontMaxValidGlyph; if (t1FontNames) { for (i = 0; i < t1FontNameLen; ++i) { delete t1FontNames[i].psName; @@ -2128,10 +2122,9 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { GBool writePadding = gTrue; // check if font is already embedded - if (fontNames->lookupInt(psName)) { + if (!fontNames.emplace(psName->toStr()).second) { return; } - fontNames->add(psName->copy(), 1); // get the font stream and info Object obj1, obj2, obj3; @@ -2307,10 +2300,9 @@ void PSOutputDev::setupExternalType1Font(GooString *fileName, GooString *psName) FILE *fontFile; int c; - if (fontNames->lookupInt(psName)) { + if (!fontNames.emplace(psName->toStr()).second) { return; } - fontNames->add(psName->copy(), 1); // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); @@ -2546,8 +2538,9 @@ void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, void PSOutputDev::updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph) { if (maxValidGlyph >= 0 && font->getName()) { - if (maxValidGlyph > fontMaxValidGlyph->lookupInt(font->getName())) { - fontMaxValidGlyph->replace(font->getName()->copy(), maxValidGlyph); + auto& fontMaxValidGlyph = this->fontMaxValidGlyph[font->getName()->toStr()]; + if (fontMaxValidGlyph < maxValidGlyph) { + fontMaxValidGlyph = maxValidGlyph; } } } @@ -2872,16 +2865,14 @@ GooString *PSOutputDev::makePSFontName(GfxFont *font, const Ref *id) { if ((s = font->getEmbeddedFontName())) { psName = filterPSName(s); - if (!fontNames->lookupInt(psName)) { - fontNames->add(psName->copy(), 1); + if (fontNames.emplace(psName->toStr()).second) { return psName; } delete psName; } if ((s = font->getName())) { psName = filterPSName(s); - if (!fontNames->lookupInt(psName)) { - fontNames->add(psName->copy(), 1); + if (fontNames.emplace(psName->toStr()).second) { return psName; } delete psName; @@ -2896,7 +2887,7 @@ GooString *PSOutputDev::makePSFontName(GfxFont *font, const Ref *id) { psName->append('_')->append(s); delete s; } - fontNames->add(psName->copy(), 1); + fontNames.emplace(psName->toStr()); return psName; } @@ -5042,7 +5033,7 @@ void PSOutputDev::drawString(GfxState *state, const GooString *s) { if (!(font = state->getFont())) { return; } - maxGlyphInt = (font->getName()? fontMaxValidGlyph->lookupInt(font->getName()): 0); + maxGlyphInt = (font->getName() ? fontMaxValidGlyph[font->getName()->toStr()] : 0); if (maxGlyphInt < 0) maxGlyphInt = 0; maxGlyph = (CharCode) maxGlyphInt; wMode = font->getWMode(); diff --git a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h index e0d6910acd3..b51cf472977 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h @@ -25,6 +25,7 @@ // Copyright (C) 2011, 2014, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -47,8 +48,10 @@ #include <set> #include <map> #include <vector> +#include <unordered_set> +#include <unordered_map> +#include <string> -class GHooash; class PDFDoc; class XRef; class Function; @@ -475,8 +478,8 @@ private: int fontIDLen; // number of entries in fontIDs array int fontIDSize; // size of fontIDs array std::set<int> resourceIDs; // list of object IDs of objects containing Resources we've already set up - GooHash *fontNames; // all used font names - GooHash *fontMaxValidGlyph; // max valid glyph of each font + std::unordered_set<std::string> fontNames; // all used font names + std::unordered_map<std::string, int> fontMaxValidGlyph; // max valid glyph of each font PST1FontName *t1FontNames; // font names for Type 1/1C fonts int t1FontNameLen; // number of entries in t1FontNames array int t1FontNameSize; // size of t1FontNames array diff --git a/Build/source/libs/poppler/poppler-src/poppler/ProfileData.cc b/Build/source/libs/poppler/poppler-src/poppler/ProfileData.cc index a0c44747a56..9e5f2d3e3cc 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/ProfileData.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/ProfileData.cc @@ -3,6 +3,7 @@ // ProfileData.cc // // Copyright 2005 Jonathan Blandford <jrb@gnome.org> +// Copyright 2018 Adam Reichold <adam.reichold@t-online.de> // //======================================================================== @@ -12,21 +13,12 @@ #pragma implementation #endif -#include <stdlib.h> -#include <stddef.h> #include "ProfileData.h" //------------------------------------------------------------------------ // ProfileData //------------------------------------------------------------------------ -ProfileData::ProfileData() { - count = 0; - total = 0.0; - min = 0.0; - max = 0.0; -} - void ProfileData::addElement (double elapsed) { if (count == 0) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/ProfileData.h b/Build/source/libs/poppler/poppler-src/poppler/ProfileData.h index 418ee010755..664a60b0180 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/ProfileData.h +++ b/Build/source/libs/poppler/poppler-src/poppler/ProfileData.h @@ -3,6 +3,7 @@ // ProfileData.h // // Copyright 2005 Jonathan Blandford <jrb@gnome.org> +// Copyright 2018 Adam Reichold <adam.reichold@t-online.de> // //======================================================================== @@ -19,23 +20,17 @@ class ProfileData { public: - - // Constructor. - ProfileData (); - - // Destructor. - ~ProfileData() {} - void addElement (double elapsed); - int getCount () { return count; } - double getTotal () { return total; } - double getMin () { return max; } - double getMax () { return max; } + + int getCount () const { return count; } + double getTotal () const { return total; } + double getMin () const { return max; } + double getMax () const { return max; } private: - int count; // size of <elems> array - double total; // number of elements in array - double min; // reference count - double max; // reference count + int count = 0; // size of <elems> array + double total = 0.0; // number of elements in array + double min = 0.0; // reference count + double max = 0.0; // reference count }; #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc index 73963302b00..a19e8c66e38 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc @@ -2512,6 +2512,13 @@ GBool SplashOutputDev::beginType3Char(GfxState *state, double x, double y, double x1, y1, xMin, yMin, xMax, yMax, xt, yt; int i, j; + // check for invisible text -- this is used by Acrobat Capture + if (state->getRender() == 3) { + // this is a bit of cheating, we say yes, font is already on cache + // so we actually skip the rendering of it + return gTrue; + } + if (skipHorizText || skipRotatedText) { state->getFontTransMat(&m[0], &m[1], &m[2], &m[3]); horiz = m[0] > 0 && fabs(m[1]) < 0.001 && diff --git a/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc b/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc index 9a53d9c9e97..58a4b6a63c7 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc @@ -147,7 +147,6 @@ void StructTreeRoot::parseNumberTreeNode(Dict *node) Object value = nums.arrayGet(i + 1); if (value.isArray()) { vec.resize(value.arrayGetLength()); - memset(vec.data(), 0, vec.size()*sizeof(Parent*)); for (int j = 0; j < value.arrayGetLength(); j++) { Object itemvalue = value.arrayGetNF(j); if (itemvalue.isRef()) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc index dabdce2ad3c..a7c59edf796 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc @@ -17,6 +17,7 @@ // Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr> +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -139,9 +140,6 @@ UnicodeMap::UnicodeMap(GooString *encodingNameA) { eMaps = nullptr; eMapsLen = 0; refCnt = 1; -#ifdef MULTITHREADED - gInitMutex(&mutex); -#endif } UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, @@ -154,9 +152,6 @@ UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, eMaps = nullptr; eMapsLen = 0; refCnt = 1; -#ifdef MULTITHREADED - gInitMutex(&mutex); -#endif } UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, @@ -168,9 +163,6 @@ UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, eMaps = nullptr; eMapsLen = 0; refCnt = 1; -#ifdef MULTITHREADED - gInitMutex(&mutex); -#endif } UnicodeMap::~UnicodeMap() { @@ -181,32 +173,88 @@ UnicodeMap::~UnicodeMap() { if (eMaps) { gfree(eMaps); } -#ifdef MULTITHREADED - gDestroyMutex(&mutex); -#endif +} + +UnicodeMap::UnicodeMap(UnicodeMap &&other) noexcept + : encodingName{other.encodingName} + , kind{other.kind} + , unicodeOut{other.unicodeOut} + , len{other.len} + , eMaps{other.eMaps} + , eMapsLen{other.eMapsLen} + , refCnt{1} +{ + switch (kind) { + case unicodeMapUser: + case unicodeMapResident: + ranges = other.ranges; + other.ranges = nullptr; + break; + case unicodeMapFunc: + func = other.func; + break; + } + other.encodingName = nullptr; + other.eMaps = nullptr; +} + +UnicodeMap& UnicodeMap::operator=(UnicodeMap &&other) noexcept +{ + if (this != &other) + swap(other); + return *this; +} + +void UnicodeMap::swap(UnicodeMap &other) noexcept +{ + using std::swap; + swap(encodingName, other.encodingName); + swap(unicodeOut, other.unicodeOut); + switch (kind) { + case unicodeMapUser: + case unicodeMapResident: + switch (other.kind) { + case unicodeMapUser: + case unicodeMapResident: + swap(ranges, other.ranges); + break; + case unicodeMapFunc: + { + const auto tmp = ranges; + func = other.func; + other.ranges = tmp; + break; + } + } + break; + case unicodeMapFunc: + switch (other.kind) { + case unicodeMapUser: + case unicodeMapResident: + { + const auto tmp = func; + ranges = other.ranges; + other.func = tmp; + break; + } + case unicodeMapFunc: + swap(func, other.func); + break; + } + break; + } + swap(kind, other.kind); + swap(len, other.len); + swap(eMaps, other.eMaps); + swap(eMapsLen, other.eMapsLen); } void UnicodeMap::incRefCnt() { -#ifdef MULTITHREADED - gLockMutex(&mutex); -#endif - ++refCnt; -#ifdef MULTITHREADED - gUnlockMutex(&mutex); -#endif + refCnt.fetch_add(1); } void UnicodeMap::decRefCnt() { - GBool done; - -#ifdef MULTITHREADED - gLockMutex(&mutex); -#endif - done = --refCnt == 0; -#ifdef MULTITHREADED - gUnlockMutex(&mutex); -#endif - if (done) { + if (refCnt.fetch_sub(1) == 1) { delete this; } } diff --git a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h index f3444aa5d43..871c656a8ae 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h +++ b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h @@ -17,6 +17,7 @@ // // Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2018 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -33,10 +34,7 @@ #include "poppler-config.h" #include "goo/gtypes.h" #include "CharTypes.h" - -#ifdef MULTITHREADED -#include "goo/GooMutex.h" -#endif +#include <atomic> class GooString; @@ -75,6 +73,11 @@ public: UnicodeMap(const char *encodingNameA, GBool unicodeOutA, UnicodeMapFunc funcA); + UnicodeMap(UnicodeMap &&other) noexcept; + UnicodeMap& operator=(UnicodeMap &&other) noexcept; + + void swap(UnicodeMap& other) noexcept; + ~UnicodeMap(); UnicodeMap(const UnicodeMap &) = delete; @@ -111,10 +114,7 @@ private: int len; // (user, resident) UnicodeMapExt *eMaps; // (user) int eMapsLen; // (user) - int refCnt; -#ifdef MULTITHREADED - GooMutex mutex; -#endif + std::atomic_int refCnt; }; //------------------------------------------------------------------------ diff --git a/Build/source/libs/poppler/poppler-src/poppler/XRef.cc b/Build/source/libs/poppler/poppler-src/poppler/XRef.cc index 5d3b98ffaec..25bc18a4452 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/XRef.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/XRef.cc @@ -940,11 +940,11 @@ GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { if ((*p & 0xff) == 0) { //new line, continue with next line! str->getLine(buf, 256); - p = buf - 1; - } - do { + p = buf; + } else { ++p; - } while (*p && isspace(*p & 0xff)); + } + while (*p && isspace(*p & 0xff)) ++p; if (isdigit(*p & 0xff)) { gen = atoi(p); do { @@ -954,11 +954,11 @@ GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { if ((*p & 0xff) == 0) { //new line, continue with next line! str->getLine(buf, 256); - p = buf - 1; - } - do { + p = buf; + } else { ++p; - } while (*p && isspace(*p & 0xff)); + } + while (*p && isspace(*p & 0xff)) ++p; if (!strncmp(p, "obj", 3)) { if (num >= size) { newSize = (num + 1 + 255) & ~255; |