diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-09 18:53:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-09 18:53:05 +0000 |
commit | 9b0195121df2c53bdd030fdec6d7871f27f057f0 (patch) | |
tree | f58fc29c2856f942f64b30d91a1fc9247e1d5b10 | |
parent | 332064c92a01296b5dd2d25524d0f8286ccdd107 (diff) |
poppler 0.62.0, requiring C++11; luatex not updated yet
git-svn-id: svn://tug.org/texlive/trunk@46257 c570f23f-e606-0410-a88d-b1316a301751
241 files changed, 15201 insertions, 12786 deletions
diff --git a/Build/source/Build b/Build/source/Build index 1cc955f83d5..9229199890d 100755 --- a/Build/source/Build +++ b/Build/source/Build @@ -61,10 +61,12 @@ if test "x$1" = x--debug || test "x$1" = x-g; then # The idea is that with Build -g, you can set TL_COMPILER_GFLAGS in # the environment with options common to all compilers -- # not necessarily anything to do with debugging, e.g., -mcpu=sparvc9. + # Or you can set TL_{C,CXX,OBJCXX}FLAGS for per-language flags, + # notably TL_CFLAGS=-Wdeclaration-after-statement. : ${TL_COMPILER_GFLAGS=-g} - c="CFLAGS='$TL_COMPILER_GFLAGS'" - cxx="CXXFLAGS='$TL_COMPILER_GFLAGS'" - objcxx="OBJCXXFLAGS='$TL_COMPILER_GFLAGS'" # needed only on macs + c="CFLAGS='$TL_COMPILER_GFLAGS $TL_CFLAGS'" + cxx="CXXFLAGS='$TL_COMPILER_GFLAGS $TL_CXXFLAGS'" + objcxx="OBJCXXFLAGS='$TL_COMPILER_GFLAGS $TL_OBJCXXFLAGS'" # only for macs TL_BUILD_ENV="$c $cxx $objcxx $TL_BUILD_ENV" fi diff --git a/Build/source/libs/README b/Build/source/libs/README index 9fe39b71a88..9bffaa1b44a 100644 --- a/Build/source/libs/README +++ b/Build/source/libs/README @@ -49,8 +49,9 @@ mpfr 4.0.0 - checked 26dec17 pixman 0.34.0 - checked 04feb16 http://cairographics.org/releases/ -poppler 0.52.0 - checked 17feb17 +poppler 0.62.0 - checked 9jan18 http://poppler.freedesktop.org/ - used by luatex and xetex + (requires C++11) potrace 1.15 - checked 07aug17 http://potrace.sourceforge.net diff --git a/Build/source/libs/poppler/Makefile.am b/Build/source/libs/poppler/Makefile.am index 09e144bf442..2bfdcf0faba 100644 --- a/Build/source/libs/poppler/Makefile.am +++ b/Build/source/libs/poppler/Makefile.am @@ -1,7 +1,7 @@ ## $Id$ ## Proxy Makefile.am to build poppler for TeX Live. ## -## Copyright 2016-2017 Karl Berry <tex-live@tug.org> +## Copyright 2016-2018 Karl Berry <tex-live@tug.org> ## Copyright 2011-2015 Peter Breitenlohner <tex-live@tug.org> ## ## This file is free software; the copyright holder @@ -125,8 +125,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/UnicodeTypeTable.cc \ @POPPLER_TREE@/poppler/ViewerPreferences.cc \ @POPPLER_TREE@/poppler/XRef.cc \ - @POPPLER_TREE@/poppler/XpdfPluginAPI.cc \ - @POPPLER_TREE@/poppler/strtok_r.cpp + @POPPLER_TREE@/poppler/XpdfPluginAPI.cc $(libpoppler_a_OBJECTS): config.force diff --git a/Build/source/libs/poppler/Makefile.in b/Build/source/libs/poppler/Makefile.in index 00af2b35ac7..cb6698ae7d7 100644 --- a/Build/source/libs/poppler/Makefile.in +++ b/Build/source/libs/poppler/Makefile.in @@ -88,7 +88,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-visibility.m4 \ $(top_srcdir)/../../m4/kpse-warnings.m4 \ $(top_srcdir)/../../m4/kpse-win32.m4 \ @@ -192,8 +193,7 @@ am__objects_3 = @POPPLER_TREE@/poppler/Annot.$(OBJEXT) \ @POPPLER_TREE@/poppler/UnicodeTypeTable.$(OBJEXT) \ @POPPLER_TREE@/poppler/ViewerPreferences.$(OBJEXT) \ @POPPLER_TREE@/poppler/XRef.$(OBJEXT) \ - @POPPLER_TREE@/poppler/XpdfPluginAPI.$(OBJEXT) \ - @POPPLER_TREE@/poppler/strtok_r.$(OBJEXT) + @POPPLER_TREE@/poppler/XpdfPluginAPI.$(OBJEXT) nodist_libpoppler_a_OBJECTS = $(am__objects_1) $(am__objects_2) \ $(am__objects_3) libpoppler_a_OBJECTS = $(nodist_libpoppler_a_OBJECTS) @@ -350,6 +350,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +HAVE_CXX11 = @HAVE_CXX11@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -533,8 +534,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/UnicodeTypeTable.cc \ @POPPLER_TREE@/poppler/ViewerPreferences.cc \ @POPPLER_TREE@/poppler/XRef.cc \ - @POPPLER_TREE@/poppler/XpdfPluginAPI.cc \ - @POPPLER_TREE@/poppler/strtok_r.cpp + @POPPLER_TREE@/poppler/XpdfPluginAPI.cc # Reconfig @@ -549,7 +549,7 @@ all: config.h poppler-config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: -.SUFFIXES: .cc .cpp .o .obj +.SUFFIXES: .cc .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../am/dist_hook.am $(srcdir)/../../am/reconfig.am $(srcdir)/../../am/rebuild.am $(am__configure_deps) @@ -864,9 +864,6 @@ clean-noinstLIBRARIES: @POPPLER_TREE@/poppler/XpdfPluginAPI.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/poppler/strtok_r.$(OBJEXT): \ - @POPPLER_TREE@/poppler/$(am__dirstamp) \ - @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) libpoppler.a: $(libpoppler_a_OBJECTS) $(libpoppler_a_DEPENDENCIES) $(EXTRA_libpoppler_a_DEPENDENCIES) $(AM_V_at)-rm -f libpoppler.a @@ -961,7 +958,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/ViewerPreferences.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/XRef.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/XpdfPluginAPI.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/strtok_r.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -979,22 +975,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` -.cpp.o: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, diff --git a/Build/source/libs/poppler/TLpatches/ChangeLog b/Build/source/libs/poppler/TLpatches/ChangeLog index 99a400e24f6..3e382943737 100644 --- a/Build/source/libs/poppler/TLpatches/ChangeLog +++ b/Build/source/libs/poppler/TLpatches/ChangeLog @@ -1,3 +1,11 @@ +2018-01-08 Karl Berry <karl@freefriends.org> + + Imported poppler-0.52.0 source tree from: + http://poppler.freedesktop.org/ + * patch-02-LLONG_MAX, patch-03-Object-functions: try removing, + seems like the source may have moved on by now, especially + what with requiring C++11. + 2017-02-17 Akira Kakuto <kakuto@fuk.kindai.ac.jp> Imported poppler-0.52.0 source tree from: diff --git a/Build/source/libs/poppler/TLpatches/TL-Changes b/Build/source/libs/poppler/TLpatches/TL-Changes index 883eb5f752a..5d3ec566f77 100644 --- a/Build/source/libs/poppler/TLpatches/TL-Changes +++ b/Build/source/libs/poppler/TLpatches/TL-Changes @@ -1,29 +1,21 @@ -Changes applied to the poppler-0.52.0 tree as obtained from: +Changes applied to the poppler-0.62.0 tree as obtained from: http://poppler.freedesktop.org/ -Removed: - Makefile.in - aclocal.m4 - compile - config.guess - config.sub - configure - depcomp - install-sh - ltmain.sh - missing - test-driver - fofi/Makefile.in - goo/Makefile.in - poppler/Makefile.in - splash/Makefile.in - Removed unused dirs: - cmake - cpp - glib - m4 - qt4 - qt5 - test - utils + cmake cpp glib m4 qt4 qt5 test utils + +General idea: +update version.ac +mv poppler-src poppler-prev +tar xf poppler-*.tar.gz +mv poppler-0.62.0 poppler-src +cd poppler-src +svn status >/tmp/s +svn add # the ? lines +svn remove # the ! lines +# adapt Makefile.am for new files +# adapt configure.ac as needed +autoreconf +make -C .../Work/libs/poppler/ +# until it succeeds +# try build of everything, luatex/xetex may need updating. diff --git a/Build/source/libs/poppler/TLpatches/patch-02-LLONG_MAX b/Build/source/libs/poppler/TLpatches/patch-02-LLONG_MAX deleted file mode 100644 index 27c17477703..00000000000 --- a/Build/source/libs/poppler/TLpatches/patch-02-LLONG_MAX +++ /dev/null @@ -1,25 +0,0 @@ -diff -ur poppler-0.52.0.orig/goo/GooString.h poppler-0.52.0/goo/GooString.h ---- poppler-0.52.0.orig/goo/GooString.h Tue Jan 17 06:36:57 2017 -+++ poppler-0.52.0/goo/GooString.h Tue Mar 21 12:18:41 2017 -@@ -36,6 +36,21 @@ - #endif - - #include <limits.h> // for LLONG_MAX and ULLONG_MAX -+ -+/* <limits.h> and/or the compiler may or may not define these. */ -+/* Minimum and maximum values a `signed long long int' can hold. */ -+#ifndef LLONG_MAX -+# define LLONG_MAX 9223372036854775807LL -+#endif -+#ifndef LLONG_MIN -+# define LLONG_MIN (-LLONG_MAX - 1LL) -+#endif -+ -+/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ -+#ifndef ULLONG_MAX -+# define ULLONG_MAX 18446744073709551615ULL -+#endif -+ - #include <stdarg.h> - #include <stdlib.h> // for NULL - #include "gtypes.h" diff --git a/Build/source/libs/poppler/TLpatches/patch-03-Object-functions b/Build/source/libs/poppler/TLpatches/patch-03-Object-functions deleted file mode 100644 index aa3fc750ceb..00000000000 --- a/Build/source/libs/poppler/TLpatches/patch-03-Object-functions +++ /dev/null @@ -1,43 +0,0 @@ -diff -ur poppler-0.52.0.orig/poppler/Object.h poppler-0.52.0/poppler/Object.h ---- poppler-0.52.0.orig/poppler/Object.h Tue Jan 17 06:36:58 2017 -+++ poppler-0.52.0/poppler/Object.h Tue Mar 21 12:21:07 2017 -@@ -148,7 +148,7 @@ - Object *initStream(Stream *streamA); - Object *initRef(int numA, int genA) - { initObj(objRef); ref.num = numA; ref.gen = genA; return this; } -- Object *initCmd(char *cmdA) -+ Object *initCmd(const char *cmdA) - { initObj(objCmd); cmd = copyString(cmdA); return this; } - Object *initError() - { initObj(objError); return this; } -@@ -195,7 +195,7 @@ - GBool isName(const char *nameA) - { return type == objName && !strcmp(name, nameA); } - GBool isDict(const char *dictType); -- GBool isStream(char *dictType); -+ GBool isStream(const char *dictType); - GBool isCmd(const char *cmdA) - { return type == objCmd && !strcmp(cmd, cmdA); } - -@@ -245,7 +245,7 @@ - Object *dictGetValNF(int i, Object *obj); - - // Stream accessors. -- GBool streamIs(char *dictType); -+ GBool streamIs(const char *dictType); - void streamReset(); - void streamClose(); - int streamGetChar(); -@@ -352,10 +352,10 @@ - - #include "Stream.h" - --inline GBool Object::streamIs(char *dictType) -+inline GBool Object::streamIs(const char *dictType) - { OBJECT_TYPE_CHECK(objStream); return stream->getDict()->is(dictType); } - --inline GBool Object::isStream(char *dictType) -+inline GBool Object::isStream(const char *dictType) - { return type == objStream && streamIs(dictType); } - - inline void Object::streamReset() diff --git a/Build/source/libs/poppler/aclocal.m4 b/Build/source/libs/poppler/aclocal.m4 index 6c6ac012b33..7e3fe32b695 100644 --- a/Build/source/libs/poppler/aclocal.m4 +++ b/Build/source/libs/poppler/aclocal.m4 @@ -1186,6 +1186,7 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +m4_include([../../m4/ax_cxx_compile_stdcxx.m4]) m4_include([../../m4/kpse-common.m4]) m4_include([../../m4/kpse-visibility.m4]) m4_include([../../m4/kpse-warnings.m4]) diff --git a/Build/source/libs/poppler/config.h.in b/Build/source/libs/poppler/config.h.in index 87716071b36..c598ea143ff 100644 --- a/Build/source/libs/poppler/config.h.in +++ b/Build/source/libs/poppler/config.h.in @@ -3,6 +3,12 @@ /* Use zlib instead of builtin zlib decoder. */ #undef ENABLE_ZLIB +/* define if the compiler supports basic C++11 syntax */ +#undef HAVE_CXX11 + +/* Do we have any DCT decoder?. */ +#undef HAVE_DCT_DECODER + /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H @@ -22,6 +28,12 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H +/* Do we have any JPX decoder?. */ +#undef HAVE_JPX_DECODER + +/* Define to 1 if you have the `localtime_r' function. */ +#undef HAVE_LOCALTIME_R + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -49,6 +61,9 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strtok_r' function. */ +#undef HAVE_STRTOK_R + /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H diff --git a/Build/source/libs/poppler/configure b/Build/source/libs/poppler/configure index 5c2651e15f0..30f45bde68d 100755 --- a/Build/source/libs/poppler/configure +++ b/Build/source/libs/poppler/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.52.0. +# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.62.0. # # Report bugs to <tex-k@tug.org>. # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='poppler (TeX Live)' PACKAGE_TARNAME='poppler--tex-live-' -PACKAGE_VERSION='0.52.0' -PACKAGE_STRING='poppler (TeX Live) 0.52.0' +PACKAGE_VERSION='0.62.0' +PACKAGE_STRING='poppler (TeX Live) 0.62.0' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -645,6 +645,7 @@ VISIBILITY_CXXFLAGS VISIBILITY_CFLAGS LN_S RANLIB +HAVE_CXX11 WARNING_CXXFLAGS am__fastdepCXX_FALSE am__fastdepCXX_TRUE @@ -749,6 +750,8 @@ enable_opi enable_multithreaded enable_exceptions enable_fixedpoint +enable_dctdecoder +enable_libopenjpeg enable_largefile with_system_zlib with_zlib_includes @@ -1306,7 +1309,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures poppler (TeX Live) 0.52.0 to adapt to many kinds of systems. +\`configure' configures poppler (TeX Live) 0.62.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1373,7 +1376,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of poppler (TeX Live) 0.52.0:";; + short | recursive ) echo "Configuration of poppler (TeX Live) 0.62.0:";; esac cat <<\_ACEOF @@ -1398,6 +1401,8 @@ Optional Features: --enable-exceptions use C++ exceptions --enable-fixedpoint use fixed point (instead of floating point) arithmetic + --enable-dctdecoder use dctdecoder + --enable-libopenjpeg use openjpeg decoder --disable-largefile omit support for large files Optional Packages: @@ -1486,7 +1491,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -poppler (TeX Live) configure 0.52.0 +poppler (TeX Live) configure 0.62.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2076,7 +2081,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by poppler (TeX Live) $as_me 0.52.0, which was +It was created by poppler (TeX Live) $as_me 0.62.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3999,7 +4004,7 @@ fi # Define the identity of the package. PACKAGE='poppler--tex-live-' - VERSION='0.52.0' + VERSION='0.62.0' # Some tools Automake needs. @@ -5348,6 +5353,992 @@ WARNING_CXXFLAGS=$kpse_cv_warning_cxxflags + + ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + ac_success=no + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx11+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check<void> single_type; + typedef check<check<void>> double_type; + typedef check<check<check<void>>> triple_type; + typedef check<check<check<check<void>>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same<int, decltype(0)>::value == true, ""); + static_assert(is_same<int, decltype(c)>::value == false, ""); + static_assert(is_same<int, decltype(v)>::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same<int, decltype(ac)>::value == true, ""); + static_assert(is_same<int, decltype(av)>::value == true, ""); + static_assert(is_same<int, decltype(sumi)>::value == true, ""); + static_assert(is_same<int, decltype(sumf)>::value == false, ""); + static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template <int...> + struct sum; + + template <int N0, int... N1toN> + struct sum<N0, N1toN...> + { + static constexpr auto value = N0 + sum<N1toN...>::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template<typename T> + using member = typename T::member_type; + + template<typename T> + void func(...) {} + + template<typename T> + void func(member<T>*) {} + + void test(); + + void test() { func<foo>(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx11=yes +else + ax_cv_cxx_compile_cxx11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 +$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check<void> single_type; + typedef check<check<void>> double_type; + typedef check<check<check<void>>> triple_type; + typedef check<check<check<check<void>>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same<int, decltype(0)>::value == true, ""); + static_assert(is_same<int, decltype(c)>::value == false, ""); + static_assert(is_same<int, decltype(v)>::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same<int, decltype(ac)>::value == true, ""); + static_assert(is_same<int, decltype(av)>::value == true, ""); + static_assert(is_same<int, decltype(sumi)>::value == true, ""); + static_assert(is_same<int, decltype(sumf)>::value == false, ""); + static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template <int...> + struct sum; + + template <int N0, int... N1toN> + struct sum<N0, N1toN...> + { + static constexpr auto value = N0 + sum<N1toN...>::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template<typename T> + using member = typename T::member_type; + + template<typename T> + void func(...) {} + + template<typename T> + void func(member<T>*) {} + + void test(); + + void test() { func<foo>(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=yes +else + eval $cachevar=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" +fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check<void> single_type; + typedef check<check<void>> double_type; + typedef check<check<check<void>>> triple_type; + typedef check<check<check<check<void>>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same<int, decltype(0)>::value == true, ""); + static_assert(is_same<int, decltype(c)>::value == false, ""); + static_assert(is_same<int, decltype(v)>::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same<int, decltype(ac)>::value == true, ""); + static_assert(is_same<int, decltype(av)>::value == true, ""); + static_assert(is_same<int, decltype(sumi)>::value == true, ""); + static_assert(is_same<int, decltype(sumf)>::value == false, ""); + static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template <int...> + struct sum; + + template <int N0, int... N1toN> + struct sum<N0, N1toN...> + { + static constexpr auto value = N0 + sum<N1toN...>::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template<typename T> + using member = typename T::member_type; + + template<typename T> + void func(...) {} + + template<typename T> + void func(member<T>*) {} + + void test(); + + void test() { func<foo>(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=yes +else + eval $cachevar=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" +fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + if test x$ac_success = xyes; then + break + fi + done + fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ac_success = xno; then + as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + fi + fi + if test x$ac_success = xno; then + HAVE_CXX11=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 +$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + else + HAVE_CXX11=1 + +$as_echo "#define HAVE_CXX11 1" >>confdefs.h + + fi + + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 @@ -5452,7 +6443,6 @@ $as_echo "no, using $LN_S" >&6; } fi - echo 'dbg:_KPSE_COMPILER_VISIBILITY called.' >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for C to hide external symbols" >&5 $as_echo_n "checking CFLAGS for C to hide external symbols... " >&6; } @@ -5984,7 +6974,10 @@ if test $ac_cv_sizeof_long_long -lt 8; then as_fn_error $? "Sorry, your compiler has no \`long long' with at least 8 bytes." "$LINENO" 5 fi -test "x$GXX" = xyes && NO_WARN_CXXFLAGS='-Wno-write-strings' +if test "x$GXX" = xyes; then + NO_WARN_CXXFLAGS='-Wno-write-strings' +fi + # Check whether --enable-opi was given. @@ -6031,6 +7024,28 @@ fi fi +# Check whether --enable-dctdecoder was given. +if test "${enable_dctdecoder+set}" = set; then : + enableval=$enable_dctdecoder; if test "x$enableval" = xlibjpeg; then + +$as_echo "#define HAVE_DCT_DECODER 1" >>confdefs.h + +fi + +fi + + +# Check whether --enable-libopenjpeg was given. +if test "${enable_libopenjpeg+set}" = set; then : + enableval=$enable_libopenjpeg; if test "x$enableval" = xopenjpeg2; then + +$as_echo "#define HAVE_JPX_DECODER 1" >>confdefs.h + +fi + +fi + + for ac_header in strings.h do : @@ -6203,8 +7218,8 @@ fi fi - -for ac_func in gettimeofday gmtime_r mkstemp popen rand_r timegm +for ac_func in gettimeofday gmtime_r localtime_r mkstemp popen rand_r \ + timegm strtok_r do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -6579,7 +7594,7 @@ ac_config_headers="$ac_config_headers poppler-config.h:poppler-src/poppler/poppl cat >>confdefs.h <<_ACEOF -#define POPPLER_VERSION "0.52.0" +#define POPPLER_VERSION "0.62.0" _ACEOF @@ -7273,7 +8288,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by poppler (TeX Live) $as_me 0.52.0, which was +This file was extended by poppler (TeX Live) $as_me 0.62.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7339,7 +8354,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -poppler (TeX Live) config.status 0.52.0 +poppler (TeX Live) config.status 0.62.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/libs/poppler/configure.ac b/Build/source/libs/poppler/configure.ac index b776063c18b..d7ae76f8e92 100644 --- a/Build/source/libs/poppler/configure.ac +++ b/Build/source/libs/poppler/configure.ac @@ -1,6 +1,8 @@ +dnl $Id$ dnl Process this file with autoconf to produce a configure script. dnl -dnl Copyright (C) 2011-2013 Peter Breitenlohner <tex-live@tug.org> +dnl Copyright 2018 Karl Berry <tex-live@tug.org> +dnl Copyright 2011-2013 Peter Breitenlohner <tex-live@tug.org> dnl dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, @@ -17,6 +19,7 @@ KPSE_BASIC([poppler], [no-define]) AC_PROG_CC AC_PROG_CXX +AX_CXX_COMPILE_STDCXX([11]) AC_PROG_RANLIB AC_PROG_LN_S @@ -27,7 +30,10 @@ if test $ac_cv_sizeof_long_long -lt 8; then AC_MSG_ERROR([Sorry, your compiler has no `long long' with at least 8 bytes.]) fi -test "x$GXX" = xyes && NO_WARN_CXXFLAGS='-Wno-write-strings' +if test "x$GXX" = xyes; then + NO_WARN_CXXFLAGS='-Wno-write-strings' +fi + AC_SUBST([NO_WARN_CXXFLAGS]) dnl ##### Optional features. @@ -63,14 +69,30 @@ AC_ARG_ENABLE([fixedpoint], fi ]) +AC_ARG_ENABLE([dctdecoder], + AS_HELP_STRING([--enable-dctdecoder], + [use dctdecoder]), + [if test "x$enableval" = xlibjpeg; then + AC_DEFINE([HAVE_DCT_DECODER], 1, [Do we have any DCT decoder?.]) +fi +]) + +AC_ARG_ENABLE([libopenjpeg], + AS_HELP_STRING([--enable-libopenjpeg], + [use openjpeg decoder]), + [if test "x$enableval" = xopenjpeg2; then + AC_DEFINE([HAVE_JPX_DECODER], 1, [Do we have any JPX decoder?.]) +fi +]) + dnl **** Checks for header files **** AC_CHECK_HEADERS([strings.h]) AC_HEADER_DIRENT -dnl **** Checks for library functions **** - -AC_CHECK_FUNCS([gettimeofday gmtime_r mkstemp popen rand_r timegm]) +dnl Checks for library functions (from goo/glibc.h and more). +AC_CHECK_FUNCS([gettimeofday gmtime_r localtime_r mkstemp popen rand_r \ + timegm strtok_r]) AC_SYS_LARGEFILE AC_FUNC_FSEEKO AC_CHECK_FUNC([ftell64], [AC_CHECK_FUNCS([fseek64])]) diff --git a/Build/source/libs/poppler/include/Makefile.in b/Build/source/libs/poppler/include/Makefile.in index 3f96123a827..903043db5d4 100644 --- a/Build/source/libs/poppler/include/Makefile.in +++ b/Build/source/libs/poppler/include/Makefile.in @@ -87,7 +87,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = include ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-visibility.m4 \ $(top_srcdir)/../../m4/kpse-warnings.m4 \ $(top_srcdir)/../../m4/kpse-win32.m4 \ @@ -208,6 +209,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +HAVE_CXX11 = @HAVE_CXX11@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ diff --git a/Build/source/libs/poppler/include/fofi/Makefile.in b/Build/source/libs/poppler/include/fofi/Makefile.in index a7c65a50f8e..7e38b686159 100644 --- a/Build/source/libs/poppler/include/fofi/Makefile.in +++ b/Build/source/libs/poppler/include/fofi/Makefile.in @@ -87,7 +87,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = include/fofi ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-visibility.m4 \ $(top_srcdir)/../../m4/kpse-warnings.m4 \ $(top_srcdir)/../../m4/kpse-win32.m4 \ @@ -148,6 +149,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +HAVE_CXX11 = @HAVE_CXX11@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ diff --git a/Build/source/libs/poppler/include/goo/Makefile.in b/Build/source/libs/poppler/include/goo/Makefile.in index 1b173b4f21a..b900e08229e 100644 --- a/Build/source/libs/poppler/include/goo/Makefile.in +++ b/Build/source/libs/poppler/include/goo/Makefile.in @@ -87,7 +87,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : subdir = include/goo ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../../m4/kpse-common.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-visibility.m4 \ $(top_srcdir)/../../m4/kpse-warnings.m4 \ $(top_srcdir)/../../m4/kpse-win32.m4 \ @@ -148,6 +149,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +HAVE_CXX11 = @HAVE_CXX11@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ diff --git a/Build/source/libs/poppler/poppler-src/CMakeLists.txt b/Build/source/libs/poppler/poppler-src/CMakeLists.txt index d36e06e35c7..d8072a936c9 100644 --- a/Build/source/libs/poppler/poppler-src/CMakeLists.txt +++ b/Build/source/libs/poppler/poppler-src/CMakeLists.txt @@ -1,6 +1,6 @@ project(poppler) -cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) @@ -10,47 +10,62 @@ include(MacroOptionalFindPackage) find_package(PkgConfig) include(MacroEnsureVersion) include(MacroBoolTo01) -find_package(Threads) +if (WIN32) + message("-- Using win32 threads") +else() + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + set(THREADS_PREFER_PTHREAD_FLAG TRUE) + find_package(Threads) +endif() include(TestBigEndian) test_big_endian(WORDS_BIGENDIAN) include(CheckFileOffsetBits) CHECK_FILE_OFFSET_BITS() +include(GNUInstallDirs) + find_package (ECM 1.6.0 QUIET NO_MODULE) if (ECM_FOUND) include("${ECM_MODULE_DIR}/ECMEnableSanitizers.cmake") endif() set(POPPLER_MAJOR_VERSION "0") -set(POPPLER_MINOR_VERSION "52") +set(POPPLER_MINOR_VERSION "62") 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_EXTENSIONS OFF) + # command line switches option(ENABLE_XPDF_HEADERS "Install unsupported xpdf headers." OFF) option(BUILD_GTK_TESTS "Whether compile the GTK+ test programs." ON) -option(BUILD_QT4_TESTS "Whether compile the Qt4 test programs." ON) option(BUILD_QT5_TESTS "Whether compile the Qt5 test programs." ON) option(BUILD_CPP_TESTS "Whether compile the CPP test programs." ON) option(ENABLE_SPLASH "Build the Splash graphics backend." ON) option(ENABLE_UTILS "Compile poppler command line utils." ON) option(ENABLE_CPP "Compile poppler cpp wrapper." ON) -set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2. 'auto' prefers openjpeg1 over openjpeg2 if both are available. Unset to not use openjpeg.") -set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available. Unset to disable color management system.") -option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF) +option(ENABLE_GLIB "Compile poppler glib wrapper." ON) +option(ENABLE_GTK_DOC "Whether to generate glib API documentation." OFF) +option(ENABLE_QT5 "Compile poppler qt5 wrapper." ON) +set(ENABLE_LIBOPENJPEG "openjpeg2" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: openjpeg2, unmaintained, none. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no JPX decoder at all. Default: openjpeg2") +set(ENABLE_CMS "lcms2" CACHE STRING "Use color management system. Possible values: lcms2, none. 'none' disables color management system.") +set(ENABLE_DCTDECODER "libjpeg" CACHE STRING "Use libjpeg for DCT streams. Possible values: libjpeg, unmaintained, none. will use libjpeg if available or fail if not. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no DCT decoder at all. Default: libjpeg") +option(ENABLE_LIBCURL "Build libcurl based HTTP support." ON) option(ENABLE_ZLIB "Build with zlib." ON) option(ENABLE_ZLIB_UNCOMPRESS "Use zlib to uncompress flate streams (not totally safe)." OFF) option(SPLASH_CMYK "Include support for CMYK rasterization." OFF) option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF) option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF) +option(BUILD_SHARED_LIBS "Build poppler as a shared library" ON) if(WIN32) option(ENABLE_RELOCATABLE "Do not hardcode the poppler library location (on Windows)." ON) -else(WIN32) +else() set(ENABLE_RELOCATABLE OFF) -endif(WIN32) +endif() +option(EXTRA_WARN "Enable extra compile warnings" OFF) -set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") -set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "Share directory name") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(TESTDATADIR "${CMAKE_SOURCE_DIR}/../test" CACHE STRING "Specify test data dir.") if(NOT (EXISTS ${TESTDATADIR} AND EXISTS ${TESTDATADIR}/test-poppler.c)) @@ -73,9 +88,9 @@ endif() if(WIN32) set(_default_fontconfiguration "win32") -else(WIN32) +else() set(_default_fontconfiguration "fontconfig") -endif(WIN32) +endif() set(FONT_CONFIGURATION "${_default_fontconfiguration}" CACHE STRING "The font configuration backend (win32|fontconfig).") string(TOLOWER "${FONT_CONFIGURATION}" font_configuration) set(WITH_FONTCONFIGURATION_WIN32 OFF) @@ -84,17 +99,19 @@ if(font_configuration STREQUAL "win32") set(WITH_FONTCONFIGURATION_WIN32 ON) elseif(font_configuration STREQUAL "fontconfig") set(WITH_FONTCONFIGURATION_FONTCONFIG ON) -else(font_configuration STREQUAL "win32") +else() message(FATAL_ERROR "Invalid font configuration setting: ${FONT_CONFIGURATION}") -endif(font_configuration STREQUAL "win32") +endif() + +if(CMAKE_USE_PTHREADS_INIT OR WIN32) + set(MULTITHREADED ON) +endif() # Enable these unconditionally. -set(MULTITHREADED ON) set(OPI_SUPPORT ON) set(TEXTOUT_WORD_LIST ON) # setting the minimum required versions for some components -set(QT4_MIN_VERSION "4.7.0") set(CAIRO_VERSION "1.10.0") set(GLIB_REQUIRED "2.41") @@ -102,31 +119,39 @@ macro_bool_to_01(ENABLE_SPLASH HAVE_SPLASH) find_package(Freetype REQUIRED) if(WITH_FONTCONFIGURATION_FONTCONFIG) find_package(Fontconfig REQUIRED) -endif(WITH_FONTCONFIGURATION_FONTCONFIG) +endif() macro_optional_find_package(JPEG) macro_optional_find_package(PNG) macro_optional_find_package(TIFF) macro_optional_find_package(NSS3) -if(JPEG_FOUND) - set(ENABLE_LIBJPEG ${JPEG_FOUND}) -endif(JPEG_FOUND) -macro_optional_find_package(Qt4) -if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) +if(ENABLE_DCTDECODER STREQUAL "libjpeg") + if(JPEG_FOUND) + set(ENABLE_LIBJPEG ${JPEG_FOUND}) + else() + message(FATAL_ERROR "Install libjpeg before trying to build poppler. You can also decide to use the internal unmaintained DCT decoder or none at all.") + endif() + set(HAVE_DCT_DECODER ON) +elseif(ENABLE_DCTDECODER STREQUAL "unmaintained") + set(ENABLE_LIBJPEG OFF) + set(HAVE_DCT_DECODER ON) +elseif(ENABLE_DCTDECODER STREQUAL "none") + set(ENABLE_LIBJPEG OFF) + set(HAVE_DCT_DECODER OFF) +else() + message(FATAL_ERROR "Invalid ENABLE_DCTDECODER value.") +endif() + +if (ENABLE_QT5) find_package(Qt5Core) find_package(Qt5Gui) find_package(Qt5Xml) find_package(Qt5Widgets) find_package(Qt5Test) - if (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Xml_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND) - set(QT5_FOUND true) - else () + if (NOT (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Xml_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND)) message("-- Package Qt5Core or Qt5Gui or Qt5Xml or Qt5Widgets or Qt5Test not found") - set(QT5_FOUND false) + set(ENABLE_QT5 OFF) endif() -else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) - set(QT5_FOUND false) - message("-- CMake >= 2.8.8 is needed to enable Qt5") -endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.7) +endif() macro_optional_find_package(Cairo ${CAIRO_VERSION}) if(CAIRO_FOUND) @@ -135,94 +160,85 @@ if(CAIRO_FOUND) set(CAIRO_REQ "cairo") set(POPPLER_GLIB_DISABLE_DEPRECATED "") set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "") - macro_optional_find_package(GLIB) - if(GLIB_FOUND) - set(ENABLE_GLIB ON) + if(ENABLE_GLIB) + macro_optional_find_package(GLIB) + if(NOT GLIB_FOUND) + set(ENABLE_GLIB OFF) + endif() + endif() + if(ENABLE_GLIB) # Check for introspection macro_optional_find_package(GObjectIntrospection 0.9.12) set(HAVE_INTROSPECTION ${INTROSPECTION_FOUND}) set(POPPLER_GLIB_DISABLE_DEPRECATED "${POPPLER_GLIB_DISABLE_DEPRECATED} -DG_DISABLE_DEPRECATED") set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES} -DG_DISABLE_SINGLE_INCLUDES") macro_optional_find_package(GTK) - endif(GLIB_FOUND) -else(CAIRO_FOUND) + endif() +else() set(CAIRO_FEATURE "#undef POPPLER_HAS_CAIRO") -endif(CAIRO_FOUND) + set(ENABLE_GLIB OFF) +endif() if(ENABLE_CPP) macro_optional_find_package(Iconv) set(ENABLE_CPP ${ICONV_FOUND}) set(HAVE_ICONV ${ICONV_FOUND}) -endif(ENABLE_CPP) +endif() if(ENABLE_ZLIB) find_package(ZLIB) - if(ZLIB_FOUND) - set(HAVE_LIBZ ${ZLIB_FOUND}) - endif(ZLIB_FOUND) set(ENABLE_ZLIB ${ZLIB_FOUND}) -endif(ENABLE_ZLIB) +endif() if(ENABLE_ZLIB_UNCOMPRESS AND NOT ENABLE_ZLIB) message("Warning: ENABLE_ZLIB_UNCOMPRESS requires ENABLE_ZLIB") set(ENABLE_ZLIB_UNCOMPRESS FALSE) -endif(ENABLE_ZLIB_UNCOMPRESS AND NOT ENABLE_ZLIB) -set(USE_OPENJPEG1 FALSE) -set(USE_OPENJPEG2 FALSE) +endif() set(WITH_OPENJPEG FALSE) -if(ENABLE_LIBOPENJPEG STREQUAL "auto") +if(ENABLE_LIBOPENJPEG STREQUAL "openjpeg2") find_package(LIBOPENJPEG2) - set(USE_OPENJPEG2 ${LIBOPENJPEG2_FOUND}) set(WITH_OPENJPEG ${LIBOPENJPEG2_FOUND}) if(NOT LIBOPENJPEG2_FOUND) - find_package(LIBOPENJPEG) - set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND}) - set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND}) + message(FATAL_ERROR "Install libopenjpeg2 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all.") endif() -elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg1") - find_package(LIBOPENJPEG) - set(USE_OPENJPEG1 ${LIBOPENJPEG_FOUND}) - set(WITH_OPENJPEG ${LIBOPENJPEG_FOUND}) -elseif(ENABLE_LIBOPENJPEG STREQUAL "openjpeg2") - find_package(LIBOPENJPEG2) - set(USE_OPENJPEG2 ${LIBOPENJPEG2_FOUND}) - set(WITH_OPENJPEG ${LIBOPENJPEG2_FOUND}) + set(HAVE_JPX_DECODER ON) +elseif(ENABLE_LIBOPENJPEG STREQUAL "unmaintained") + set(WITH_OPENJPEG OFF) + set(HAVE_JPX_DECODER ON) +elseif(ENABLE_LIBOPENJPEG STREQUAL "none") + set(WITH_OPENJPEG OFF) + set(HAVE_JPX_DECODER OFF) +else() + message(FATAL_ERROR "Invalid ENABLE_LIBOPENJPEG value: ${ENABLE_LIBOPENJPEG}") endif() set(ENABLE_LIBOPENJPEG "${WITH_OPENJPEG}") -if(ENABLE_CMS STREQUAL "auto") - find_package(LCMS2) - set(USE_CMS ${LCMS2_FOUND}) - if(NOT LCMS2_FOUND) - find_package(LCMS) - set(USE_CMS ${LCMS_FOUND}) - set(USE_LCMS1 ${LCMS_FOUND}) - endif(NOT LCMS2_FOUND) -elseif(ENABLE_CMS STREQUAL "lcms1") - find_package(LCMS) - set(USE_CMS ${LCMS_FOUND}) - set(USE_LCMS1 ${LCMS_FOUND}) -elseif(ENABLE_CMS STREQUAL "lcms2") +if(ENABLE_CMS STREQUAL "lcms2") find_package(LCMS2) set(USE_CMS ${LCMS2_FOUND}) +elseif(NOT ENABLE_CMS STREQUAL "none") + message(FATAL_ERROR "Invalid ENABLE_CMS value: ${ENABLE_CMS}") endif() if(ENABLE_LIBCURL) find_package(CURL) - include_directories(${CURL_INCLUDE_DIR}) - set(POPPLER_HAS_CURL_SUPPORT ON) -endif(ENABLE_LIBCURL) + if(CURL_FOUND) + include_directories(${CURL_INCLUDE_DIR}) + set(POPPLER_HAS_CURL_SUPPORT ON) + else() + set(ENABLE_LIBCURL OFF) + endif() +endif() -add_definitions(-DHAVE_CONFIG_H=1) if(MINGW) # Use mingw's ansi stdio extensions add_definitions(-D__USE_MINGW_ANSI_STDIO=1) -endif(MINGW) +endif() if(FONTCONFIG_FOUND) add_definitions(${FONTCONFIG_DEFINITIONS}) include_directories(${FONTCONFIG_INCLUDE_DIR}) -endif(FONTCONFIG_FOUND) +endif() if(WITH_FONTCONFIGURATION_WIN32) if(MINGW) # Set the minimum required Internet Explorer version to 5.0 add_definitions(-D_WIN32_IE=0x0500) - endif(MINGW) -endif(WITH_FONTCONFIGURATION_WIN32) + endif() +endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/fofi @@ -232,43 +248,32 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/poppler ${FREETYPE_INCLUDE_DIRS} ) -set(HAVE_FREETYPE_H ON) -if(CMAKE_USE_PTHREADS_INIT) - set(HAVE_PTHREAD ON) -endif(CMAKE_USE_PTHREADS_INIT) if(ENABLE_ZLIB) include_directories(${ZLIB_INCLUDE_DIR}) -endif(ENABLE_ZLIB) +endif() if (NSS3_FOUND) add_definitions(${NSS3_CFLAGS}) set(ENABLE_NSS3 ON) -endif(NSS3_FOUND) +endif() if(JPEG_FOUND) include_directories(${JPEG_INCLUDE_DIR}) - set(ENABLE_LIBJPEG ON) -endif(JPEG_FOUND) +endif() if(PNG_FOUND) include_directories(${PNG_INCLUDE_DIR}) set(ENABLE_LIBPNG ON) -endif(PNG_FOUND) +endif() if(TIFF_FOUND) include_directories(${TIFF_INCLUDE_DIR}) set(ENABLE_LIBTIFF ON) -endif(TIFF_FOUND) -if(LIBOPENJPEG_FOUND) - include_directories(${LIBOPENJPEG_INCLUDE_DIR}) -endif(LIBOPENJPEG_FOUND) +endif() if(LIBOPENJPEG2_FOUND) include_directories(${LIBOPENJPEG2_INCLUDE_DIRS}) endif() -if(LCMS_FOUND) - include_directories(${LCMS_INCLUDE_DIR}) -endif(LCMS_FOUND) if(LCMS2_FOUND) include_directories(${LCMS2_INCLUDE_DIR}) -endif(LCMS2_FOUND) +endif() # Recent versions of poppler-data install a .pc file. # Use it to determine the encoding data path, if available. @@ -280,28 +285,19 @@ if(POPPLER_DATA_FOUND) OUTPUT_VARIABLE _output_var OUTPUT_STRIP_TRAILING_WHITESPACE) if(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") set(POPPLER_DATADIR "${_output_var}") - endif(_result_var STREQUAL "0" AND NOT _output_var STREQUAL "") -endif(POPPLER_DATA_FOUND) + endif() +endif() if(NOT DEFINED POPPLER_DATADIR) set(POPPLER_DATADIR "${CMAKE_INSTALL_PREFIX}/share/poppler") -endif(NOT DEFINED POPPLER_DATADIR) - -if(DEFINED COMPILE_WARNINGS) -else(DEFINED COMPILE_WARNINGS) - set(COMPILE_WARNINGS "yes") -endif(DEFINED COMPILE_WARNINGS) -string(TOLOWER "${COMPILE_WARNINGS}" _comp_warnings) -if(_comp_warnings STREQUAL "no") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_NO} ${CMAKE_CXX_FLAGS}") -endif(_comp_warnings STREQUAL "no") -if(_comp_warnings STREQUAL "yes") +endif() + +if(EXTRA_WARN) set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_YES} ${CMAKE_CXX_FLAGS}") -endif(_comp_warnings STREQUAL "yes") -if(_comp_warnings STREQUAL "kde") + set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_EXTRA} ${CMAKE_CXX_FLAGS}") +else() set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_KDE} ${CMAKE_CXX_FLAGS}") -endif(_comp_warnings STREQUAL "kde") + set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS} ${CMAKE_CXX_FLAGS}") +endif() include(ConfigureChecks.cmake) @@ -326,6 +322,7 @@ set(poppler_SRCS goo/gstrtod.cc goo/grandom.cc goo/glibc.cc + goo/glibc_strtok_r.cc fofi/FoFiBase.cc fofi/FoFiEncodings.cc fofi/FoFiTrueType.cc @@ -380,7 +377,6 @@ set(poppler_SRCS poppler/Stream.cc poppler/StructTreeRoot.cc poppler/StructElement.cc - poppler/strtok_r.cpp poppler/UnicodeMap.cc poppler/UnicodeTypeTable.cc poppler/UTF.cc @@ -415,58 +411,48 @@ if(ENABLE_SPLASH) splash/SplashPattern.cc splash/SplashScreen.cc splash/SplashState.cc - splash/SplashT1Font.cc - splash/SplashT1FontEngine.cc - splash/SplashT1FontFile.cc splash/SplashXPath.cc splash/SplashXPathScanner.cc ) -endif(ENABLE_SPLASH) +endif() if(FONTCONFIG_FOUND) set(poppler_LIBS ${poppler_LIBS} ${FONTCONFIG_LIBRARIES}) -endif(FONTCONFIG_FOUND) +endif() if(JPEG_FOUND) set(poppler_SRCS ${poppler_SRCS} poppler/DCTStream.cc ) set(poppler_LIBS ${poppler_LIBS} ${JPEG_LIBRARIES}) -endif(JPEG_FOUND) +endif() if(ENABLE_ZLIB) set(poppler_SRCS ${poppler_SRCS} poppler/FlateEncoder.cc ) set(poppler_LIBS ${poppler_LIBS} ${ZLIB_LIBRARIES}) -endif(ENABLE_ZLIB) +endif() if(ENABLE_ZLIB_UNCOMPRESS) set(poppler_SRCS ${poppler_SRCS} poppler/FlateStream.cc ) -endif(ENABLE_ZLIB_UNCOMPRESS) +endif() if(ENABLE_LIBCURL) set(poppler_SRCS ${poppler_SRCS} poppler/CurlCachedFile.cc poppler/CurlPDFDocBuilder.cc ) set(poppler_LIBS ${poppler_LIBS} ${CURL_LIBRARIES}) -endif(ENABLE_LIBCURL) +endif() if (ENABLE_NSS3) set(poppler_SRCS ${poppler_SRCS} poppler/SignatureHandler.cc ) set(poppler_LIBS ${poppler_LIBS} ${NSS3_LIBRARIES}) -endif(ENABLE_NSS3) -if(LIBOPENJPEG_FOUND) - set(poppler_SRCS ${poppler_SRCS} - poppler/JPEG2000Stream.cc - ) - set(poppler_LIBS ${poppler_LIBS} ${LIBOPENJPEG_LIBRARIES}) - add_definitions(-DUSE_OPENJPEG1) -elseif (LIBOPENJPEG2_FOUND) +endif() +if (LIBOPENJPEG2_FOUND) set(poppler_SRCS ${poppler_SRCS} poppler/JPEG2000Stream.cc ) - add_definitions(-DUSE_OPENJPEG2) set(poppler_LIBS ${poppler_LIBS} ${LIBOPENJPEG2_LIBRARIES}) else () set(poppler_SRCS ${poppler_SRCS} @@ -474,37 +460,38 @@ else () ) endif() if(USE_CMS) - if(LCMS_FOUND) - set(poppler_LIBS ${poppler_LIBS} ${LCMS_LIBRARIES}) - endif(LCMS_FOUND) - if(LCMS2_FOUND) - set(poppler_LIBS ${poppler_LIBS} ${LCMS2_LIBRARIES}) - endif(LCMS2_FOUND) -endif(USE_CMS) + set(poppler_LIBS ${poppler_LIBS} ${LCMS2_LIBRARIES}) +endif() if(WIN32) + # use clean APIs + add_definitions(-DWIN32_LEAN_AND_MEAN) # gdi32 is needed under win32 set(poppler_LIBS ${poppler_LIBS} gdi32) -endif(WIN32) +endif() if(PNG_FOUND) set(poppler_LIBS ${poppler_LIBS} ${PNG_LIBRARIES}) -endif(PNG_FOUND) +endif() if(TIFF_FOUND) set(poppler_LIBS ${poppler_LIBS} ${TIFF_LIBRARIES}) -endif(TIFF_FOUND) -if(HAVE_PTHREAD) - set(poppler_LIBS ${poppler_LIBS} ${CMAKE_THREAD_LIBS_INIT}) endif() if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) set(CMAKE_CXX_FLAGS "/Zc:wchar_t- ${CMAKE_CXX_FLAGS}") add_library(poppler STATIC ${poppler_SRCS}) -else(MSVC) -add_library(poppler SHARED ${poppler_SRCS}) -endif(MSVC) -set_target_properties(poppler PROPERTIES VERSION 66.0.0 SOVERSION 66) +else() +add_library(poppler ${poppler_SRCS}) +endif() +set_target_properties(poppler PROPERTIES VERSION 73.0.0 SOVERSION 73) +if(MINGW) + get_target_property(POPPLER_SOVERSION poppler SOVERSION) + set_target_properties(poppler PROPERTIES SUFFIX "-${POPPLER_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") +endif() target_link_libraries(poppler LINK_PRIVATE ${poppler_LIBS}) -install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) +if(CMAKE_USE_PTHREADS_INIT) + target_link_libraries(poppler LINK_PRIVATE Threads::Threads) +endif() +install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(ENABLE_XPDF_HEADERS) install(FILES @@ -524,7 +511,6 @@ if(ENABLE_XPDF_HEADERS) poppler/FontEncodingTables.h poppler/FontInfo.h poppler/Form.h - poppler/Function.cc poppler/Function.h poppler/Gfx.h poppler/GfxFont.h @@ -562,6 +548,7 @@ if(ENABLE_XPDF_HEADERS) poppler/StructElement.h poppler/StructTreeRoot.h poppler/UnicodeMap.h + poppler/UnicodeMapFuncs.h poppler/UnicodeMapTables.h poppler/UnicodeTypeTable.h poppler/UnicodeCClassTables.h @@ -579,7 +566,6 @@ if(ENABLE_XPDF_HEADERS) poppler/StdinCachedFile.h poppler/StdinPDFDocBuilder.h poppler/UTF.h - poppler/UTF8.h poppler/XpdfPluginAPI.h poppler/Sound.h ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h @@ -603,17 +589,17 @@ if(ENABLE_XPDF_HEADERS) install(FILES goo/PNGWriter.h DESTINATION include/poppler/goo) - endif(PNG_FOUND) + endif() if(TIFF_FOUND) install(FILES goo/TiffWriter.h DESTINATION include/poppler/goo) - endif(TIFF_FOUND) + endif() if(JPEG_FOUND) install(FILES goo/JpegWriter.h DESTINATION include/poppler/goo) - endif(JPEG_FOUND) + endif() install(FILES fofi/FoFiBase.h fofi/FoFiEncodings.h @@ -627,12 +613,8 @@ if(ENABLE_XPDF_HEADERS) poppler/CurlCachedFile.h poppler/CurlPDFDocBuilder.h DESTINATION include/poppler) - endif(ENABLE_LIBCURL) - if(LIBOPENJPEG_FOUND) - install(FILES - poppler/JPEG2000Stream.h - DESTINATION include/poppler) - elseif(LIBOPENJPEG2_FOUND) + endif() + if(LIBOPENJPEG2_FOUND) install(FILES poppler/JPEG2000Stream.h DESTINATION include/poppler) @@ -663,66 +645,57 @@ if(ENABLE_XPDF_HEADERS) splash/SplashPattern.h splash/SplashScreen.h splash/SplashState.h - splash/SplashT1Font.h - splash/SplashT1FontEngine.h - splash/SplashT1FontFile.h splash/SplashTypes.h splash/SplashXPath.h splash/SplashXPathScanner.h DESTINATION include/poppler/splash) - endif(ENABLE_SPLASH) -endif(ENABLE_XPDF_HEADERS) + endif() +endif() if(ENABLE_UTILS) add_subdirectory(utils) -endif(ENABLE_UTILS) +endif() if(ENABLE_GLIB) add_subdirectory(glib) -endif(ENABLE_GLIB) +endif() add_subdirectory(test) -if(QT4_FOUND) - add_subdirectory(qt4) -endif(QT4_FOUND) -if(QT5_FOUND) +if(ENABLE_QT5) add_subdirectory(qt5) -endif(QT5_FOUND) +endif() if(ENABLE_CPP) add_subdirectory(cpp) -endif(ENABLE_CPP) +endif() set(PKG_CONFIG_VERSION_0_18 TRUE) if(PKG_CONFIG_EXECUTABLE) exec_program(${PKG_CONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _output_VAR) macro_ensure_version("0.18" "${_output_VAR}" PKG_CONFIG_VERSION_0_18) -endif(PKG_CONFIG_EXECUTABLE) +endif() if(PKG_CONFIG_VERSION_0_18) set(PC_REQUIRES "") set(PC_REQUIRES_PRIVATE "Requires.private: poppler = ${POPPLER_VERSION}") -else(PKG_CONFIG_VERSION_0_18) +else() set(PC_REQUIRES "poppler = ${POPPLER_VERSION}") set(PC_REQUIRES_PRIVATE "") -endif(PKG_CONFIG_VERSION_0_18) +endif() -poppler_create_install_pkgconfig(poppler.pc lib${LIB_SUFFIX}/pkgconfig) +poppler_create_install_pkgconfig(poppler.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) if(ENABLE_SPLASH) - poppler_create_install_pkgconfig(poppler-splash.pc lib${LIB_SUFFIX}/pkgconfig) -endif(ENABLE_SPLASH) -if(QT4_FOUND) - poppler_create_install_pkgconfig(poppler-qt4.pc lib${LIB_SUFFIX}/pkgconfig) -endif(QT4_FOUND) -if(QT5_FOUND) - poppler_create_install_pkgconfig(poppler-qt5.pc lib${LIB_SUFFIX}/pkgconfig) -endif(QT5_FOUND) + poppler_create_install_pkgconfig(poppler-splash.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() +if(ENABLE_QT5) + poppler_create_install_pkgconfig(poppler-qt5.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() if(ENABLE_GLIB) - poppler_create_install_pkgconfig(poppler-glib.pc lib${LIB_SUFFIX}/pkgconfig) -endif(ENABLE_GLIB) + poppler_create_install_pkgconfig(poppler-glib.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() if(CAIRO_FOUND) - poppler_create_install_pkgconfig(poppler-cairo.pc lib${LIB_SUFFIX}/pkgconfig) -endif(CAIRO_FOUND) + poppler_create_install_pkgconfig(poppler-cairo.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() if(ENABLE_CPP) - poppler_create_install_pkgconfig(poppler-cpp.pc lib${LIB_SUFFIX}/pkgconfig) -endif(ENABLE_CPP) + poppler_create_install_pkgconfig(poppler-cpp.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() message("Building Poppler with support for:") @@ -732,12 +705,11 @@ if(SPLASH_CMYK) message(" with CMYK support") endif() show_end_message_yesno("cairo output" CAIRO_FOUND) -show_end_message_yesno("qt4 wrapper" QT4_FOUND) -show_end_message_yesno("qt5 wrapper" QT5_FOUND) +show_end_message_yesno("qt5 wrapper" ENABLE_QT5) show_end_message_yesno("glib wrapper" ENABLE_GLIB) show_end_message_yesno(" introspection" INTROSPECTION_FOUND) +show_end_message_yesno(" gtk-doc" ENABLE_GTK_DOC) show_end_message_yesno("cpp wrapper" ENABLE_CPP) -show_end_message("use gtk-doc" "not supported with this CMake build system") show_end_message_yesno("use libjpeg" ENABLE_LIBJPEG) show_end_message_yesno("use libpng" ENABLE_LIBPNG) show_end_message_yesno("use libtiff" ENABLE_LIBTIFF) @@ -745,39 +717,45 @@ show_end_message_yesno("use zlib compress" ENABLE_ZLIB) show_end_message_yesno("use zlib uncompress" ENABLE_ZLIB_UNCOMPRESS) show_end_message_yesno("use nss3" ENABLE_NSS3) show_end_message_yesno("use curl" ENABLE_LIBCURL) -show_end_message_yesno("use libopenjpeg" WITH_OPENJPEG) -if(USE_OPENJPEG1) - message(" with openjpeg1") -endif() -if(USE_OPENJPEG2) - message(" with openjpeg2") -endif() -show_end_message_yesno("use cms" USE_CMS) -if(LCMS_FOUND) - message(" with lcms1") -endif(LCMS_FOUND) -if(LCMS2_FOUND) - message(" with lcms2") -endif(LCMS2_FOUND) +show_end_message_yesno("use libopenjpeg2" WITH_OPENJPEG) +show_end_message_yesno("use lcms2" USE_CMS) show_end_message_yesno("command line utils" ENABLE_UTILS) show_end_message("test data dir" ${TESTDATADIR}) if(NOT ENABLE_SPLASH AND NOT CAIRO_FOUND) message("Warning: There is no rendering backend enabled") -endif(NOT ENABLE_SPLASH AND NOT CAIRO_FOUND) +endif() if(USE_FIXEDPOINT AND USE_FLOAT) message("Warning: Single precision and fixed point options should not be enabled at the same time") -endif(USE_FIXEDPOINT AND USE_FLOAT) +endif() -if(NOT ENABLE_LIBJPEG) +if(NOT ENABLE_LIBJPEG AND HAVE_DCT_DECODER) message("Warning: Using libjpeg is recommended. The internal DCT decoder is unmaintained.") -endif(NOT ENABLE_LIBJPEG) +endif() + +if(NOT HAVE_DCT_DECODER) + message("Warning: You're not compiling any DCT decoder. Some files will fail to display properly.") +endif() if(ENABLE_ZLIB_UNCOMPRESS) message("Warning: Using zlib is not totally safe") -endif(ENABLE_ZLIB_UNCOMPRESS) +endif() -if(NOT WITH_OPENJPEG) +if(NOT WITH_OPENJPEG AND HAVE_JPX_DECODER) message("Warning: Using libopenjpeg2 is recommended. The internal JPX decoder is unmaintained.") -endif(NOT WITH_OPENJPEG) +endif() + +if(NOT HAVE_JPX_DECODER) + message("Warning: You're not compiling any JPX decoder. Some files will fail to display properly.") +endif() + +set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${POPPLER_VERSION}) +add_custom_target(dist + COMMAND + COMMAND git log --stat | fmt --split-only > ${CMAKE_BINARY_DIR}/ChangeLog + COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar + COMMAND tar -C ${CMAKE_BINARY_DIR} -rf ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar ChangeLog --transform='s,,${ARCHIVE_NAME}/,' + COMMAND tar -C ${CMAKE_BINARY_DIR} -rf ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar glib/reference/html --transform='s,,${ARCHIVE_NAME}/,' + COMMAND xz -9 ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) diff --git a/Build/source/libs/poppler/poppler-src/COPYING3 b/Build/source/libs/poppler/poppler-src/COPYING3 new file mode 100644 index 00000000000..94a9ed024d3 --- /dev/null +++ b/Build/source/libs/poppler/poppler-src/COPYING3 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/Build/source/libs/poppler/poppler-src/ChangeLog b/Build/source/libs/poppler/poppler-src/ChangeLog index b485fb46a50..590171350fe 100644 --- a/Build/source/libs/poppler/poppler-src/ChangeLog +++ b/Build/source/libs/poppler/poppler-src/ChangeLog @@ -1,3 +1,4098 @@ +commit 72e0a3a087f160d819f7697a8536bbee12240c7a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 3 20:25:06 2017 +0100 + + 0.62.0 + + CMakeLists.txt | 6 +++--- + NEWS | 26 ++++++++++++++++++++++++++ + cpp/Doxyfile | 2 +- + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Doxyfile | 2 +- + 5 files changed, 32 insertions(+), 6 deletions(-) + +commit 90958363fd5e8c5e74a889e0c2140c71a0c09eb6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Dec 3 20:23:09 2017 +0100 + + Add missing (C) + + poppler/Error.cc | 2 +- + poppler/UTF.cc | 2 +- + poppler/UTF.h | 2 +- + poppler/UnicodeMapFuncs.h | 1 + + utils/JSInfo.cc | 2 +- + utils/pdfdetach.cc | 2 +- + utils/pdffonts.cc | 2 +- + utils/pdfseparate.cc | 1 + + utils/pdfsig.cc | 1 + + utils/pdftohtml.cc | 1 + + utils/pdftotext.cc | 1 + + utils/printencodings.cc | 1 + + 12 files changed, 12 insertions(+), 6 deletions(-) + +commit f007ab6beb2616850488271da5162f4ef0dbe789 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Dec 2 14:13:50 2017 +1030 + + INSTALL: add debug options + + also ensure cmake commands are lowercase to be consistent with our + code style. + + INSTALL | 38 +++++++++++++++++++++++++++++++++----- + 1 file changed, 33 insertions(+), 5 deletions(-) + +commit cef42ac807f4da7ae91be1b6b81b50adb9684975 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Dec 2 14:01:42 2017 +1030 + + Fix UTF test fail + + The buffer size was not large enough. Increase it and add an assert to + check the buffer size. + + qt5/tests/check_utf_conversion.cpp | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +commit fb4c69d270a618bb23791e52f46ec73c86574294 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 1 23:44:17 2017 +0100 + + Remove the Qt4 frontend + + .gitignore | 2 - + CMakeLists.txt | 17 - + cmake/modules/FindQt4.cmake | 1311 ------- + poppler-qt4.pc.cmake | 12 - + qt4/.gitignore | 4 - + qt4/CMakeLists.txt | 6 - + qt4/demos/.gitignore | 4 - + qt4/demos/CMakeLists.txt | 28 - + qt4/demos/abstractinfodock.cpp | 57 - + qt4/demos/abstractinfodock.h | 48 - + qt4/demos/documentobserver.cpp | 50 - + qt4/demos/documentobserver.h | 50 - + qt4/demos/embeddedfiles.cpp | 82 - + qt4/demos/embeddedfiles.h | 44 - + qt4/demos/fonts.cpp | 72 - + qt4/demos/fonts.h | 43 - + qt4/demos/info.cpp | 72 - + qt4/demos/info.h | 43 - + qt4/demos/main_viewer.cpp | 33 - + qt4/demos/metadata.cpp | 50 - + qt4/demos/metadata.h | 43 - + qt4/demos/navigationtoolbar.cpp | 144 - + qt4/demos/navigationtoolbar.h | 65 - + qt4/demos/optcontent.cpp | 69 - + qt4/demos/optcontent.h | 47 - + qt4/demos/pageview.cpp | 101 - + qt4/demos/pageview.h | 53 - + qt4/demos/permissions.cpp | 66 - + qt4/demos/permissions.h | 43 - + qt4/demos/thumbnails.cpp | 84 - + qt4/demos/thumbnails.h | 48 - + qt4/demos/toc.cpp | 88 - + qt4/demos/toc.h | 43 - + qt4/demos/viewer.cpp | 319 -- + qt4/demos/viewer.h | 73 - + qt4/src/.gitignore | 9 - + qt4/src/ArthurOutputDev.cc | 812 ---- + qt4/src/ArthurOutputDev.h | 170 - + qt4/src/CMakeLists.txt | 54 - + qt4/src/Doxyfile | 1637 --------- + qt4/src/Mainpage.dox | 85 - + qt4/src/poppler-annotation-helper.h | 181 - + qt4/src/poppler-annotation-private.h | 112 - + qt4/src/poppler-annotation.cc | 5089 + -------------------------- + qt4/src/poppler-annotation.h | 1375 ------- + qt4/src/poppler-base-converter.cc | 105 - + qt4/src/poppler-converter-private.h | 49 - + qt4/src/poppler-document.cc | 850 ----- + qt4/src/poppler-embeddedfile-private.h | 42 - + qt4/src/poppler-embeddedfile.cc | 135 - + qt4/src/poppler-export.h | 20 - + qt4/src/poppler-fontinfo.cc | 150 - + qt4/src/poppler-form.cc | 416 --- + qt4/src/poppler-form.h | 343 -- + qt4/src/poppler-link-extractor-private.h | 57 - + qt4/src/poppler-link-extractor.cc | 84 - + qt4/src/poppler-link-private.h | 57 - + qt4/src/poppler-link.cc | 710 ---- + qt4/src/poppler-link.h | 641 ---- + qt4/src/poppler-media.cc | 168 - + qt4/src/poppler-media.h | 100 - + qt4/src/poppler-movie.cc | 110 - + qt4/src/poppler-optcontent-private.h | 124 - + qt4/src/poppler-optcontent.cc | 456 --- + qt4/src/poppler-optcontent.h | 84 - + qt4/src/poppler-page-private.h | 57 - + qt4/src/poppler-page-transition-private.h | 28 - + qt4/src/poppler-page-transition.cc | 101 - + qt4/src/poppler-page-transition.h | 158 - + qt4/src/poppler-page.cc | 810 ---- + qt4/src/poppler-pdf-converter.cc | 115 - + qt4/src/poppler-private.cc | 296 -- + qt4/src/poppler-private.h | 241 -- + qt4/src/poppler-ps-converter.cc | 280 -- + qt4/src/poppler-qiodeviceoutstream-private.h | 47 - + qt4/src/poppler-qiodeviceoutstream.cc | 64 - + qt4/src/poppler-qt4.h | 1990 ---------- + qt4/src/poppler-sound.cc | 132 - + qt4/src/poppler-textbox.cc | 63 - + qt4/tests/.gitignore | 33 - + qt4/tests/CMakeLists.txt | 67 - + qt4/tests/README.unittest | 23 - + qt4/tests/check_actualtext.cpp | 33 - + qt4/tests/check_attachments.cpp | 157 - + qt4/tests/check_dateConversion.cpp | 142 - + qt4/tests/check_fonts.cpp | 248 -- + qt4/tests/check_goostring.cpp | 127 - + qt4/tests/check_lexer.cpp | 107 - + qt4/tests/check_links.cpp | 98 - + qt4/tests/check_metadata.cpp | 275 -- + qt4/tests/check_optcontent.cpp | 446 --- + qt4/tests/check_pagelabelinfo.cpp | 43 - + qt4/tests/check_pagelayout.cpp | 49 - + qt4/tests/check_pagemode.cpp | 73 - + qt4/tests/check_password.cpp | 88 - + qt4/tests/check_permissions.cpp | 44 - + qt4/tests/check_search.cpp | 175 - + qt4/tests/check_strings.cpp | 250 -- + qt4/tests/poppler-attachments.cpp | 39 - + qt4/tests/poppler-fonts.cpp | 89 - + qt4/tests/poppler-forms.cpp | 166 - + qt4/tests/poppler-texts.cpp | 40 - + qt4/tests/stress-poppler-dir.cpp | 67 - + qt4/tests/stress-poppler-qt4.cpp | 74 - + qt4/tests/stress-threads-qt4.cpp | 309 -- + qt4/tests/test-password-qt4.cpp | 136 - + qt4/tests/test-poppler-qt4.cpp | 235 -- + qt4/tests/test-render-to-file.cpp | 69 - + 108 files changed, 25623 deletions(-) + +commit bb0011b74093cfbf5a21b72861ac46a2b8699c0e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 1 23:37:38 2017 +0100 + + Make the disable for ENABLE_CMS be none + + as it is for ENABLE_LIBOPENJPEG and for ENABLE_DCTDECODER + + CMakeLists.txt | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 0ea5ad393601f0b1c060268cf1c310b47f928f7b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 1 23:35:28 2017 +0100 + + Stop supporting openjpeg1, you really want to use openjpeg2 :) + + CMakeLists.txt | 54 ++--------------- + config.h.cmake | 6 -- + poppler/JPEG2000Stream.cc | 145 + ---------------------------------------------- + 3 files changed, 5 insertions(+), 200 deletions(-) + +commit ce8e17e4fa96b7dd639c72818bba5a26c16cc1cb +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Dec 1 23:19:39 2017 +0100 + + Stop supporting lcms1, you really want to use lcms2 :) + + CMakeLists.txt | 36 ++++++------------------------------ + config.h.cmake | 3 --- + poppler/Gfx.cc | 5 ----- + poppler/GfxState.cc | 40 ---------------------------------------- + 4 files changed, 6 insertions(+), 78 deletions(-) + +commit 42d8d7ffd8b5393dc3103a45932b70bc8ca61c2e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Nov 22 21:50:24 2017 +0100 + + Open files that state 8 bits as third field of W + + Even we only really accept 32 bits since it is really strange to have + more than 2^31 generations + + Bug #103469 + + poppler/XRef.cc | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit 6ab81a63323e8339647f883649bf74f9d96820ae +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Tue Nov 7 17:25:27 2017 +0100 + + Document the meaning of the 'type' integer of a shading + + poppler/GfxState.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 0a9d6debdb3d4e28d9125a007244bca0c1cd760a +Author: Jean Ghali <jghali@libertysurf.fr> +Date: Fri Nov 17 23:13:56 2017 +0100 + + Include glibc.h where needed + + at least for strtok_r + + fofi/FoFiType1.cc | 2 ++ + poppler/CharCodeToUnicode.cc | 2 ++ + poppler/GlobalParams.cc | 2 ++ + poppler/PDFDoc.cc | 2 ++ + poppler/UnicodeMap.cc | 2 ++ + 5 files changed, 10 insertions(+) + +commit e0302537ec0919d9f3dbf180ebbc6e2653b1049b +Author: Albert Astals Cid <albert.astals.cid@kdab.com> +Date: Wed Nov 15 10:44:14 2017 +0100 + + qt5: Add API to let the rendering process callback to get a partial + rendering + + Bug #103372 + + qt5/src/poppler-page.cc | 254 + +++++++++++++++++++++++++++++++++--------------- + qt5/src/poppler-qt5.h | 78 +++++++++++++++ + 2 files changed, 254 insertions(+), 78 deletions(-) + +commit 33b8e6220d06a26378d7d21c88ead6e2280c2e52 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Nov 15 19:58:53 2017 +1030 + + fix MSC macro + + poppler/GlobalParams.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a6dd3f957f5979fa34a05ba963862de7d0d9df61 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Nov 12 10:33:07 2017 +1030 + + Support unicode on windows console + + The Win32Console should be used in programs that require unicode + support for command line arguments and stdio ouput on windows. On + windows it gets the command line arguments from GetCommandLineW and + converts to UTF-8, and redefines the stdio output functions to convert + UTF-8 to calls to WriteConsoleW. On other platforms this class is a + no-op. + + poppler/PDFDoc.cc | 9 +- + poppler/UTF.cc | 287 + ++++++++++++++++++++++++++++++++++++- + poppler/UTF.h | 39 +++++ + qt5/tests/CMakeLists.txt | 1 + + qt5/tests/check_utf_conversion.cpp | 87 +++++++++++ + utils/CMakeLists.txt | 1 + + utils/JSInfo.cc | 1 + + utils/Win32Console.cc | 167 +++++++++++++++++++++ + utils/Win32Console.h | 63 ++++++++ + utils/pdfdetach.cc | 2 + + utils/pdffonts.cc | 2 + + utils/pdfimages.cc | 2 + + utils/pdfinfo.cc | 2 + + utils/pdfseparate.cc | 2 + + utils/pdfsig.cc | 2 + + utils/pdftocairo-win32.cc | 1 + + utils/pdftocairo.cc | 2 + + utils/pdftohtml.cc | 2 + + utils/pdftoppm.cc | 2 + + utils/pdftops.cc | 2 + + utils/pdftotext.cc | 2 + + 21 files changed, 676 insertions(+), 2 deletions(-) + +commit 49107ffcd4d3c9b18fc950d37bede08f89bcfcda +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Nov 12 10:33:07 2017 +1030 + + Fix some mingw warnings + + - Include poppler-config.h for mingw PRINTF_FORMAT + - Only redefine strcasecmp for MSVC + - Recent versions of MSVC have snprintf and vsnprintf + + poppler/Error.cc | 1 + + poppler/GlobalParams.cc | 2 +- + poppler/PDFDoc.cc | 1 + + test/perf-test.cc | 15 +++------------ + 4 files changed, 6 insertions(+), 13 deletions(-) + +commit 4f687665c39da743e802fc71ba05fb5966095293 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Nov 12 10:33:07 2017 +1030 + + sort encoding list + + makes it easier to find encodings listed by -listenc + + utils/printencodings.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit 5c394f71f03d27507db3446ad34f299393fa3621 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Nov 12 10:33:07 2017 +1030 + + Move UTF8.h to UnicodeMapFuncs.h and rename UCS2 to UTF16 + + UTF8.h is not exclusively UTF-8 code. Renaming to UnicodeMapFuncs.h + identifies the file as containing maps for UnicodeMap and is + consistent with the name UnicodeMapTables.h. + + The mapUCS2 code was changed to support UTF-16 in 979ef1ca without + changing the name. + + CMakeLists.txt | 2 +- + poppler/GlobalParams.cc | 4 ++-- + poppler/{UTF8.h => UnicodeMapFuncs.h} | 6 +++--- + 3 files changed, 6 insertions(+), 6 deletions(-) + +commit 9ff60568ab420e86295bfa81cef9375d7c5600b8 +Author: Thomas Zajic <zlatko@gmx.at> +Date: Tue Nov 14 22:25:37 2017 +0100 + + pdfsig: install man page + + utils/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit d63ddd1fb762e536dd78f24bd3e3ddbc3504e1eb +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Tue Nov 14 20:05:33 2017 +0100 + + Use GfxLabColorSpace::transform only when USE_CMS is set + + The recent commit e84338a44f27afb9872cb108fc29683b35ac55f7 + introduced an unqualified use of GfxLabColorSpace::transform, + even though that member only exists if USE_CMS is set. + + Fix this by adding the appropriate preprocessor conditionals. + + poppler/GfxState.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 19909998a2f1f703c9978510ae1fc3baed84de31 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Nov 11 05:38:25 2017 +1030 + + glib demo: fix warning + + glib/demo/selections.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e84338a44f27afb9872cb108fc29683b35ac55f7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Nov 13 00:37:00 2017 +0100 + + GfxLabColorSpace::parse: Fix crash in broken documents + + Bug #103582 + + poppler/GfxState.cc | 28 ++++++++++++++++++---------- + 1 file changed, 18 insertions(+), 10 deletions(-) + +commit fea27db14358c8342c9f5bdbe6cb3bff02cebc2b +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 12 19:54:52 2017 +0100 + + Fix leak if parseDA fails + + poppler/Form.cc | 1 + + 1 file changed, 1 insertion(+) + +commit faeb48920d64a776911a259bcf1bb6231ac1d24c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Nov 12 19:14:32 2017 +0100 + + 0.61.1 + + CMakeLists.txt | 2 +- + NEWS | 11 +++++++++++ + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 5 files changed, 15 insertions(+), 4 deletions(-) + +commit 155597a09b2c7fcbd0eea2b5a2021a5b65476e4c +Author: Jeroen Ooms <jeroenooms@gmail.com> +Date: Sat Nov 4 05:33:09 2017 -0700 + + Fix for corrupted image files on Windows + + Bug #102494 + + cpp/poppler-image.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit c45efa2d7e0db8a4ace0e8c6955b3fa48dc6d070 +Author: Adam Sampson <ats@offog.org> +Date: Sun Nov 5 11:45:00 2017 +0000 + + Fix incorrect paths in .pc files. + + The change in 67c3878ef10449b241c37d1022e2518029860335 used the + CMAKE_INSTALL_x variables instead of CMAKE_INSTALL_FULL_x; the former + contain things like "include" instead of full paths, so the resulting + .pc files break packages that depend on poppler. Use the latter. + + Also fix a missing @ in the qt5 file. + + Bug #103578 + + poppler-cairo.pc.cmake | 4 ++-- + poppler-cpp.pc.cmake | 4 ++-- + poppler-glib.pc.cmake | 4 ++-- + poppler-qt4.pc.cmake | 4 ++-- + poppler-qt5.pc.cmake | 4 ++-- + poppler-splash.pc.cmake | 4 ++-- + poppler.pc.cmake | 4 ++-- + 7 files changed, 14 insertions(+), 14 deletions(-) + +commit 7ccedf2b082e4d46257fb247e1f6e1197d66eead +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Nov 8 21:07:45 2017 +1030 + + cairo: don't overflow y * stride when accessing image data + + poppler/CairoOutputDev.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 6ae4293fce77290f4fbdc643c999809d5924bf2c +Author: Roland Hieber <r.hieber@pengutronix.de> +Date: Wed Nov 8 08:22:01 2017 +0100 + + CMake: add the custom buildtests target only once + + Make BUILDTESTS_ADDED a global property, so the `buildtests` target + gets added only once. As far as I understood, this seems to fulfil + the requirements of CMP0002. + + Bug #103003 + + cmake/modules/PopplerMacros.cmake | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit aaa9c5308766a88d0512b87051d7c7082f152a9f +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 3 11:25:02 2017 +0100 + + Poppler 0.61 + + CMakeLists.txt | 6 +++--- + NEWS | 20 ++++++++++++++++++++ + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 5 files changed, 26 insertions(+), 6 deletions(-) + +commit 79b704b4017cf66dc3c39b49425c8b02760e5165 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Nov 3 11:14:10 2017 +0100 + + Update (C) for commits since last release + + fofi/FoFiTrueType.cc | 2 +- + goo/FixedPoint.cc | 14 ++++++++++++++ + goo/FixedPoint.h | 15 +++++++++++++++ + goo/GooMutex.h | 1 + + goo/GooString.cc | 2 +- + goo/GooString.h | 1 + + goo/gfile.cc | 2 +- + goo/gfile.h | 2 +- + goo/glibc.h | 2 +- + goo/glibc_strtok_r.cc | 1 + + poppler/Annot.cc | 2 +- + poppler/Annot.h | 2 +- + poppler/Array.cc | 1 + + poppler/Array.h | 1 + + poppler/CMap.cc | 1 + + poppler/CMap.h | 2 +- + poppler/CairoFontEngine.cc | 2 +- + poppler/CairoFontEngine.h | 2 +- + poppler/CairoRescaleBox.cc | 2 +- + poppler/Catalog.cc | 2 +- + poppler/Catalog.h | 2 +- + poppler/CharCodeToUnicode.cc | 2 +- + poppler/CharCodeToUnicode.h | 1 + + poppler/DCTStream.cc | 1 + + poppler/Decrypt.cc | 2 +- + poppler/Dict.cc | 1 + + poppler/Dict.h | 1 + + poppler/FlateEncoder.cc | 1 + + poppler/FlateStream.cc | 1 + + poppler/GlobalParams.cc | 2 +- + poppler/GlobalParams.h | 2 +- + poppler/GlobalParamsWin.cc | 2 +- + poppler/Object.h | 2 +- + poppler/OutputDev.cc | 2 +- + poppler/OutputDev.h | 2 +- + poppler/PDFDoc.cc | 2 +- + poppler/PDFDoc.h | 2 +- + poppler/PDFDocFactory.cc | 1 + + poppler/PSOutputDev.cc | 2 +- + poppler/PSOutputDev.h | 2 +- + poppler/Page.cc | 2 +- + poppler/Page.h | 2 +- + poppler/SplashOutputDev.cc | 2 +- + poppler/SplashOutputDev.h | 2 +- + poppler/StructTreeRoot.cc | 1 + + poppler/TextOutputDev.cc | 2 +- + poppler/TextOutputDev.h | 2 +- + poppler/UnicodeMap.cc | 1 + + poppler/UnicodeMap.h | 14 ++++++++++++++ + poppler/XRef.cc | 2 +- + poppler/XRef.h | 2 +- + poppler/poppler-config.h.cmake | 1 + + qt4/src/ArthurOutputDev.cc | 1 + + qt4/src/poppler-document.cc | 1 + + qt4/src/poppler-page.cc | 1 + + qt5/src/ArthurOutputDev.cc | 1 + + qt5/src/poppler-document.cc | 1 + + qt5/src/poppler-page.cc | 1 + + splash/Splash.cc | 2 +- + splash/Splash.h | 2 +- + splash/SplashFTFont.cc | 1 + + splash/SplashFTFont.h | 1 + + splash/SplashFTFontEngine.cc | 1 + + splash/SplashFTFontEngine.h | 1 + + splash/SplashFTFontFile.cc | 2 +- + splash/SplashFTFontFile.h | 1 + + splash/SplashFontEngine.cc | 1 + + splash/SplashFontEngine.h | 1 + + splash/SplashMath.h | 1 + + splash/SplashState.cc | 1 + + splash/SplashState.h | 1 + + splash/SplashTypes.h | 1 + + splash/SplashXPath.cc | 1 + + utils/pdfimages.cc | 2 +- + utils/pdftocairo-win32.cc | 2 +- + utils/pdftoppm.cc | 2 +- + utils/pdftops.cc | 2 +- + 77 files changed, 117 insertions(+), 40 deletions(-) + +commit b8b6a7c9240d1b98e79463ea93245127ac56e764 +Author: Sandro Mani <manisandro@gmail.com> +Date: Fri Nov 3 10:37:25 2017 +0100 + + mingw: change library names to include the soversion + + Bug #103157 + + CMakeLists.txt | 4 ++++ + cpp/CMakeLists.txt | 4 ++++ + glib/CMakeLists.txt | 4 ++++ + qt4/src/CMakeLists.txt | 4 ++++ + qt5/src/CMakeLists.txt | 4 ++++ + 5 files changed, 20 insertions(+) + +commit f6ad64878d91cbd0c19531c7ff669af0e0fa0912 +Author: Sandro Mani <manisandro@gmail.com> +Date: Tue Oct 31 00:24:11 2017 +0100 + + Install pkg-config files also on mingw + + cmake/modules/PopplerMacros.cmake | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 67c3878ef10449b241c37d1022e2518029860335 +Author: Emilio Pozuelo Monfort <pochu27@gmail.com> +Date: Tue Oct 31 00:20:29 2017 +0100 + + cmake: support GNUInstallDirs + + This allows users to set various install directories, e.g. + libdir, includedir, mandir... + + Bug #103211 + + CMakeLists.txt | 21 ++++++++++----------- + cmake/modules/GObjectIntrospectionMacros.cmake | 4 ++-- + cpp/CMakeLists.txt | 2 +- + glib/CMakeLists.txt | 2 +- + glib/reference/CMakeLists.txt | 2 +- + poppler-cairo.pc.cmake | 5 ++--- + poppler-cpp.pc.cmake | 5 ++--- + poppler-glib.pc.cmake | 5 ++--- + poppler-qt4.pc.cmake | 5 ++--- + poppler-qt5.pc.cmake | 5 ++--- + poppler-splash.pc.cmake | 5 ++--- + poppler.pc.cmake | 5 ++--- + qt4/src/CMakeLists.txt | 2 +- + qt5/src/CMakeLists.txt | 2 +- + utils/CMakeLists.txt | 22 + +++++++++++----------- + 15 files changed, 42 insertions(+), 50 deletions(-) + +commit 4d109589e5d2ac989d4fd7ac318ddf976f3106ed +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Sun Oct 29 20:28:52 2017 +0100 + + Fix leak in ArthurOutputDev::updateFont + + Bug #103508 + + qt5/src/ArthurOutputDev.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit b9ae2fd75c147988653093d0ecbf66188d81f8fc +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 22 18:29:31 2017 +1030 + + glib demo: correct the previous warnings fix + + Bug 103050 + + glib/demo/utils.c | 20 +++++++++++++------- + 1 file changed, 13 insertions(+), 7 deletions(-) + +commit d72f0383b959d8495a452d2d32377e588b15ad65 +Author: Kay Dohmann <k.dohmann@gmx.net> +Date: Mon Oct 23 23:31:13 2017 +0200 + + Tweak LZWStream::processNextCode + + Fixes file attached at bug 103174 and doesn't seem to cause any + regression in the files we have around + + Bug #103174 + + poppler/Stream.cc | 16 +++++++--------- + 1 file changed, 7 insertions(+), 9 deletions(-) + +commit e0926ca8a94bafa6d5bfd694064c5e30da2b79db +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Thu Oct 5 18:32:40 2017 +0200 + + Properly implement saveState / restoreState + + Not all of the internal state was actually saved/restored in + those methods, which lead to inconsistencies between the + ArthurOutputDev state and the GfxState object. + + Bug #103118 + + qt5/src/ArthurOutputDev.cc | 14 ++++++++++++++ + qt5/src/ArthurOutputDev.h | 9 +++++++++ + 2 files changed, 23 insertions(+) + +commit ebf6d1ca736fecad49fbf543875c794770bd4d57 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Sep 15 11:18:58 2017 +0200 + + Clean up the remaining Splash code in Arthur backend + + - remove some goto-style error handling + - use nullptr + - use std::unique_ptr (fixes a leak) + - remove unused data member m_currentFont + - remove some unused forward declarations + + Bug #103117 + + qt5/src/ArthurOutputDev.cc | 48 + +++++++++++++++++----------------------------- + qt5/src/ArthurOutputDev.h | 4 ---- + 2 files changed, 18 insertions(+), 34 deletions(-) + +commit 0a8174945379142348ce1006ce88cb1a75c01c96 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Oct 22 12:45:05 2017 +0200 + + isfinite -> std::isfinite + + Fixes build on the travis CI + + poppler/SplashOutputDev.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 9c7b557da043c897292219a16f419ba9650e6dfc +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 20:22:02 2017 +1030 + + Fix mingw warnings + + poppler/Annot.cc | 6 +++--- + poppler/DCTStream.cc | 6 ++++-- + poppler/GlobalParams.cc | 29 +++++++++++++++++------------ + poppler/XRef.cc | 1 + + poppler/poppler-config.h.cmake | 3 +-- + 5 files changed, 26 insertions(+), 19 deletions(-) + +commit 69414f14f60c49f9e0a8243603c6330fa3d11837 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 18:40:58 2017 +1030 + + mingw build fix - use win32 threads + + The cmake FindThreads detects both win32 and pthreads on mingw. + It also attempts a TryRun test for pthreads which won't work with + a cross compile. + + CMakeLists.txt | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit ecd2b7bf71b110b0e245e2866a13f2c0a901921f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 17:03:19 2017 +1030 + + Remove VC7 workaround + + VC7 (2002) does not support C++11 + + poppler/Gfx.cc | 8 -------- + 1 file changed, 8 deletions(-) + +commit 6e3e639c632f8527f9dc75061605e4a55f2faae9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 16:59:31 2017 +1030 + + Use <cmath> for isfinite() + + poppler/SplashOutputDev.cc | 21 +-------------------- + 1 file changed, 1 insertion(+), 20 deletions(-) + +commit f9cef28b504445c7976baa0a51676204f95397fc +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 15:13:42 2017 +1030 + + c++11 has long long + + fofi/FoFiTrueType.cc | 1 + + fofi/FoFiType1.cc | 1 + + goo/GooString.cc | 36 ------------------------------------ + goo/GooString.h | 13 ------------- + poppler/Object.h | 1 + + poppler/PDFDoc.cc | 1 + + 6 files changed, 4 insertions(+), 49 deletions(-) + +commit 4f2bd307711f792f8caf93a560444e17bd98611a +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 13:45:38 2017 +1030 + + Remove fmax/fmin from poppler-config.h + + C++11 has fmax/fmin in <cmath> so use it and remove the #ifdefs + for MSVC. + + poppler/TextOutputDev.cc | 2 +- + poppler/poppler-config.h.cmake | 6 ------ + 2 files changed, 1 insertion(+), 7 deletions(-) + +commit 555e2ea6b6f80a6f79eeaa44a39c24dc8461e78c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 13:33:07 2017 +1030 + + Move strtok_r to goo/glibc + + Move strtok_r out of poppler-config.h as it is not used in any + header files + + Move strtok_r.cpp to goo/glibc_strtok_r.cc to keep it with the + other emulated + glibc functions. But keep it in a separate file due to the different + license. + + CMakeLists.txt | 2 +- + ConfigureChecks.cmake | 1 + + config.h.cmake | 3 +++ + goo/glibc.h | 4 ++++ + poppler/strtok_r.cpp => goo/glibc_strtok_r.cc | 4 +++- + poppler/poppler-config.h.cmake | 8 -------- + 6 files changed, 12 insertions(+), 10 deletions(-) + +commit 2ca32d2cfc57626bbc833d4981c7d0a071ccc985 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 13:18:12 2017 +1030 + + move/remove macros from poppler-config.h that don't need to be there + + popen/pclose are not used in any .h files - move to config.h + + POPEN_READ_MODE is not used - remove + + config.h.cmake | 8 ++++++++ + poppler/poppler-config.h.cmake | 15 --------------- + 2 files changed, 8 insertions(+), 15 deletions(-) + +commit bf3931016614c434f7229e00bb75e3b113803d04 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 12:55:41 2017 +1030 + + Remove unused HAVE_ZLIB_H/HAVE_LIBZ macros + + CMakeLists.txt | 3 --- + config.h.cmake | 3 --- + 2 files changed, 6 deletions(-) + +commit 82e7f4bad79d122fe8cf16be54901d1f1668ca37 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 12:05:10 2017 +1030 + + Make poppler compile if threads not available + + CMakeLists.txt | 5 ++++- + goo/GooMutex.h | 6 +++++- + 2 files changed, 9 insertions(+), 2 deletions(-) + +commit 350b905537f59323a6b9a854cf019e8e95940bd6 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Oct 2 11:36:42 2017 +1030 + + Use -pthread flag instead of -lpthread + + The -pthread flag should be used for compiling with threads as it sets + flags for both the preprocessor and linker. + + In cmake this is achieved with the set(THREADS_PREFER_PTHREAD_FLAG + TRUE) + before find_package(Threads) and using the Threads::Threads import + target. + + Also added set(CMAKE_THREAD_PREFER_PTHREAD TRUE) as we only support + pthread on non windows platforms. + + CMakeLists.txt | 11 +++++------ + glib/CMakeLists.txt | 4 ++-- + utils/CMakeLists.txt | 4 ++-- + 3 files changed, 9 insertions(+), 10 deletions(-) + +commit e01e6db4e0643b7b318a3d7dc49442bb2d6ade00 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 20:51:13 2017 +1030 + + HAVE_PTHREAD is not used + + config.h.cmake | 3 --- + 1 file changed, 3 deletions(-) + +commit 36010177e9c168d110c44407512c93b49a9cf95c +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 19:28:13 2017 +1030 + + Remove unused macros + + The jpeg.h HAVE_BOOLEAN is only required if the application defines + type 'boolean' to prevent jpeg.h from redefining it. + + ConfigureChecks.cmake | 6 ------ + config.h.cmake | 36 ------------------------------------ + 2 files changed, 42 deletions(-) + +commit 6658754b9b8dfd1ba692da2681d95e21e9c1c2d4 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 19:09:28 2017 +1030 + + We always have config.h so drop the macro + + CMakeLists.txt | 1 - + poppler/CairoRescaleBox.cc | 2 -- + 2 files changed, 3 deletions(-) + +commit 7b0d736ccd5d3e1327684d21d6afbe2dec01188f +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 19:04:39 2017 +1030 + + c++11 has <cstdint> so we can drop the stdint.h checks and emulation + + ConfigureChecks.cmake | 1 - + config.h.cmake | 3 --- + goo/gtypes_p.h | 30 ------------------------------ + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoRescaleBox.cc | 2 +- + poppler/Decrypt.cc | 2 +- + utils/pdftocairo-win32.h | 2 +- + utils/pdftocairo.cc | 2 +- + 8 files changed, 5 insertions(+), 39 deletions(-) + +commit 465edbbffcc94f9af9fac7606086a28362f92d09 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 18:48:07 2017 +1030 + + Fix remaining -Wundef warnings + + and make -Wundef a default warning + + cmake/modules/PopplerMacros.cmake | 2 +- + goo/FixedPoint.h | 2 +- + goo/TiffWriter.cc | 2 +- + goo/gfile.cc | 20 ++++++++--------- + goo/gfile.h | 10 ++++----- + poppler/Annot.cc | 12 +++++----- + poppler/Annot.h | 2 +- + poppler/Array.cc | 6 ++--- + poppler/Array.h | 2 +- + poppler/CMap.cc | 14 ++++++------ + poppler/CMap.h | 4 ++-- + poppler/CairoFontEngine.cc | 10 ++++----- + poppler/CairoFontEngine.h | 2 +- + poppler/Catalog.cc | 6 ++--- + poppler/Catalog.h | 2 +- + poppler/CharCodeToUnicode.cc | 16 +++++++------- + poppler/CharCodeToUnicode.h | 4 ++-- + poppler/Dict.cc | 8 +++---- + poppler/Dict.h | 2 +- + poppler/FlateStream.cc | 2 +- + poppler/Gfx.cc | 4 ++-- + poppler/GlobalParams.cc | 12 +++++----- + poppler/GlobalParams.h | 4 ++-- + poppler/GlobalParamsWin.cc | 2 +- + poppler/OutputDev.cc | 2 +- + poppler/OutputDev.h | 2 +- + poppler/PDFDoc.cc | 6 ++--- + poppler/PDFDoc.h | 2 +- + poppler/PDFDocFactory.cc | 4 ++-- + poppler/PSOutputDev.cc | 24 ++++++++++---------- + poppler/PSOutputDev.h | 8 +++---- + poppler/Page.cc | 6 ++--- + poppler/Page.h | 2 +- + poppler/Stream.cc | 8 +++---- + poppler/Stream.h | 2 +- + poppler/TextOutputDev.cc | 14 ++++++------ + poppler/TextOutputDev.h | 14 ++++++------ + poppler/UnicodeMap.cc | 16 +++++++------- + poppler/UnicodeMap.h | 4 ++-- + poppler/XRef.cc | 10 ++++----- + poppler/XRef.h | 2 +- + utils/ImageOutputDev.cc | 4 ++-- + utils/pdfimages.cc | 4 ++-- + utils/pdftocairo.cc | 46 + +++++++++++++++++++-------------------- + utils/pdftoppm.cc | 6 ++--- + utils/pdftops.cc | 6 ++--- + 46 files changed, 171 insertions(+), 171 deletions(-) + +commit b424862bf5df75db651076c780c7242eaf887479 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 18:18:42 2017 +1030 + + Remove HAVE_FREETYPE macros + + Freetype is a mandatory dependency so we can drop the macros. + + CMakeLists.txt | 1 - + config.h.cmake | 3 --- + poppler/SplashOutputDev.cc | 8 -------- + poppler/poppler-config.h.cmake | 7 +------ + qt4/src/ArthurOutputDev.cc | 2 -- + qt5/src/ArthurOutputDev.cc | 2 -- + splash/SplashFTFont.cc | 4 ---- + splash/SplashFTFont.h | 4 ---- + splash/SplashFTFontEngine.cc | 4 ---- + splash/SplashFTFontEngine.h | 4 ---- + splash/SplashFTFontFile.cc | 4 ---- + splash/SplashFTFontFile.h | 4 ---- + splash/SplashFontEngine.cc | 20 -------------------- + splash/SplashFontEngine.h | 6 ------ + utils/pdftoppm.cc | 2 -- + 15 files changed, 1 insertion(+), 74 deletions(-) + +commit e0428ef002e9c8d6e2046fcdeeedcf7462367501 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 18:02:15 2017 +1030 + + Remove unused t1lib code + + CMakeLists.txt | 6 - + poppler/SplashOutputDev.cc | 3 - + poppler/poppler-config.h.cmake | 2 +- + qt4/src/ArthurOutputDev.cc | 3 - + qt5/src/ArthurOutputDev.cc | 3 - + splash/SplashFontEngine.cc | 30 ---- + splash/SplashFontEngine.h | 6 - + splash/SplashT1Font.cc | 309 + ----------------------------------------- + splash/SplashT1Font.h | 69 --------- + splash/SplashT1FontEngine.cc | 138 ------------------ + splash/SplashT1FontEngine.h | 50 ------- + splash/SplashT1FontFile.cc | 134 ------------------ + splash/SplashT1FontFile.h | 70 ---------- + 13 files changed, 1 insertion(+), 822 deletions(-) + +commit 7f01a804455dcc9d87fa17b566b8bd269b2d5489 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 17:31:23 2017 +1030 + + Use _WIN32 to check for windows, not WIN32 + + These should have been fixed in #24259 but must have been missed. + + goo/gfile.cc | 4 ++-- + goo/gfile.h | 2 +- + poppler/GlobalParams.cc | 4 ++-- + splash/SplashMath.h | 6 +++--- + 4 files changed, 8 insertions(+), 8 deletions(-) + +commit e38ffea64dc9c113607168e298c7ccdf8edaa61e +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 17:25:19 2017 +1030 + + Fix some -Wundef warnings + + goo/FixedPoint.cc | 2 +- + poppler/GlobalParams.cc | 2 +- + poppler/PSOutputDev.cc | 8 +-- + poppler/SplashOutputDev.cc | 158 + ++++++++++++++++++++++---------------------- + poppler/SplashOutputDev.h | 2 +- + qt4/src/poppler-document.cc | 2 +- + qt4/src/poppler-page.cc | 4 +- + qt5/src/poppler-document.cc | 2 +- + qt5/src/poppler-page.cc | 4 +- + splash/Splash.cc | 76 ++++++++++----------- + splash/Splash.h | 10 +-- + splash/SplashBitmap.cc | 20 +++--- + splash/SplashBitmap.h | 2 +- + splash/SplashFTFont.cc | 6 +- + splash/SplashFontEngine.h | 4 +- + splash/SplashMath.h | 42 ++++++------ + splash/SplashState.cc | 10 +-- + splash/SplashState.h | 2 +- + splash/SplashTypes.h | 16 ++--- + splash/SplashXPath.cc | 6 +- + utils/pdftoppm.cc | 12 ++-- + utils/pdftops.cc | 6 +- + 22 files changed, 198 insertions(+), 198 deletions(-) + +commit 9bb84057624c3b2f8fc5d137e70ae34efa46fe31 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 13:27:10 2017 +1030 + + glib demo: fix deprecated warnings + + glib/demo/utils.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +commit 5d954d1c4f25447f70d949e31afeeefb70c2a8d5 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 12:53:38 2017 +1030 + + Fix warning: implicit declaration of function ‘localtime_r’ + + poppler/glib/demo/utils.c:488:20: warning: implicit declaration of + function ‘localtime_r’ [-Wimplicit-function-declaration] + if (time == 0 || !localtime_r (&time, &t)) return NULL; + ^~~~~~~~~~~ + + The c files also need the -D_DEFAULT_SOURCE feature macro to enable + non standard C++11 functons. + + cmake/modules/PopplerMacros.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 8ccc9efb6c5f717b8cd206a92f802c66bc0a69c7 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Oct 1 12:35:19 2017 +1030 + + Fix warning: comparison of unsigned expression < 0 is always false + + poppler/FlateEncoder.cc | 1 - + poppler/StructTreeRoot.cc | 4 ++-- + 2 files changed, 2 insertions(+), 3 deletions(-) + +commit 88571e7877f729eec2f7a3552b0fa6cc913ae1a6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 19 18:11:49 2017 +0200 + + Move setPSCenter from GlobalParams to PSOutputDev + + poppler/GlobalParams.cc | 16 ---------------- + poppler/GlobalParams.h | 3 --- + poppler/PSOutputDev.cc | 3 ++- + poppler/PSOutputDev.h | 4 +++- + utils/pdftops.cc | 8 ++++---- + 5 files changed, 9 insertions(+), 25 deletions(-) + +commit 5b8fe4ee986673f15fcf8f58409cc85e8bf7ca12 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 19 17:49:06 2017 +0200 + + Remove various never called internal setters from GlobalParams.h + + TextKeepTinyChars: false, simplify if in TextOutputDev + DisableFreeTypeHinting: didn't actually have a getter :D + StrokeAdjust: true, adjust the code in Cairo/SplashOutputDev to + use gTrue + ScreenType: unset, simplify switch in SplashOutputDev + ScreenSize: -1, simplify code in SplashOutputDev + ScreenDotRadius: -1, simplify code in SplashOutputDev + ScreenGamma: 1.0, simplify code in SplashOutputDev + ScreenBlackThreshold: 0.0, simplify code in SplashOutputDev + ScreenWhiteThreshold: 1.0, simplify code in SplashOutputDev + MinLineWidth: 0.0, define it as static const in SplashOutputDev + since was used in various places + MapNumericCharNames: true, remove GfxFont.cc if guard + MapUnknownCharNames: true, remove GfxFont.cc if guard + + poppler/CairoOutputDev.cc | 2 +- + poppler/GfxFont.cc | 94 +++++++++++----------- + poppler/GlobalParams.cc | 193 + --------------------------------------------- + poppler/GlobalParams.h | 44 ----------- + poppler/SplashOutputDev.cc | 66 +++++----------- + poppler/TextOutputDev.cc | 3 +- + 6 files changed, 68 insertions(+), 334 deletions(-) + +commit 19ebd40547186a8ea6da08c8d8e2a6d6b7e84f5d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Oct 13 00:55:49 2017 +0200 + + CairoOutputDev: Fix crash in broken files + + Bug #103016 + + poppler/CairoOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 7ee9dadef37b20bca707a6b1e858e17d191e368b +Author: Jason Crain <jason@inspiresomeone.us> +Date: Thu Oct 5 15:32:13 2017 -0500 + + TextOutputDev: Fix crash in fuzzed file + + This file crashes pdftotext because it positions texts past INT_MIN, + leading to overflow in subsequent calculations. + + Bug #103116 + + poppler/TextOutputDev.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 369cd504e70e55378c6395355056fa8676679e56 +Author: David Tardon <dtardon@redhat.com> +Date: Fri Oct 6 08:07:35 2017 +0200 + + do not install Function.cc, as it's not a header + + CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +commit f09a9923bb65755e183694c5f1be6af4a50e96e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 5 19:15:44 2017 +0200 + + Poppler 0.60.1 + + CMakeLists.txt | 2 +- + NEWS | 7 +++++++ + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 5 files changed, 11 insertions(+), 4 deletions(-) + +commit e816c7a47caa0c3f5261d467333f8c2eb6a2ad51 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Oct 5 18:51:49 2017 +0200 + + FindLIBOPENJPEG.cmake: Add CheckCXXSourceCompiles + + Since we use check_cxx_source_compiles + + cmake/modules/FindLIBOPENJPEG.cmake | 2 ++ + 1 file changed, 2 insertions(+) + +commit f538b74a38acb53b877e000a64647ce8043133ac +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Tue Oct 3 00:04:17 2017 +0200 + + qt5: ArthurOutputDev: Add missing 'return' in error paths + + qt5/src/ArthurOutputDev.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit c2ba8fd8cf51af48a9e789d29e9fd5512d1688e3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 2 23:46:49 2017 +0200 + + Poppler 0.60.0 + + CMakeLists.txt | 4 ++-- + NEWS | 28 ++++++++++++++++++++++++++++ + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 34 insertions(+), 6 deletions(-) + +commit 9432e0bfc4c4f2e16b7c152aa8b04d6d19ed4898 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 2 23:29:21 2017 +0200 + + Add missing (C) + + cpp/poppler-private.cpp | 1 + + fofi/FoFiTrueType.cc | 2 +- + goo/GooString.cc | 2 +- + goo/GooString.h | 2 +- + goo/JpegWriter.cc | 1 + + goo/gmem.h | 2 +- + poppler/CairoOutputDev.cc | 2 +- + poppler/CurlPDFDocBuilder.cc | 2 +- + poppler/Decrypt.cc | 2 +- + poppler/GfxState.h | 2 +- + poppler/GlobalParams.cc | 2 +- + poppler/PSOutputDev.cc | 2 +- + poppler/PSOutputDev.h | 2 +- + poppler/UnicodeMap.cc | 1 + + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-private.cc | 2 +- + qt5/src/poppler-link.cc | 2 +- + qt5/src/poppler-private.cc | 2 +- + qt5/src/poppler-qt5.h | 1 + + splash/Splash.cc | 2 +- + splash/SplashFTFontFile.cc | 1 + + splash/SplashFTFontFile.h | 1 + + utils/pdfseparate.cc | 2 +- + 23 files changed, 23 insertions(+), 17 deletions(-) + +commit da02d7c683f1788d38cccb3716edd1ba011cb94c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 2 23:05:59 2017 +0200 + + remove m4 gtk-doc.make and add comments to poppler-features.h.cmake + + glib/poppler-features.h.cmake | 55 ++++++++ + gtk-doc.make | 305 + ---------------------------------------- + m4/.gitignore | 5 - + m4/ax_pthread.m4 | 317 + ------------------------------------------ + m4/define-dir.m4 | 34 ----- + m4/gtk-doc.m4 | 88 ------------ + m4/iconv.m4 | 180 ------------------------ + m4/introspection.m4 | 94 ------------- + m4/libjpeg.m4 | 114 --------------- + 9 files changed, 55 insertions(+), 1137 deletions(-) + +commit f871b82edfd632f79ec7bdd0b4d560cd348d8b1a +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Sep 8 23:27:45 2017 +0200 + + qt5: ArthurOutputDev: Fix several small bugs related to dash pattern + handling + + qt5/src/ArthurOutputDev.cc | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +commit 3ec5e86ca000653525650a99755c85e512a04bdc +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Sep 29 21:24:23 2017 +0200 + + qt5: ArthurOutputDev: Implement the drawSoftMaskedImage method + + qt5/src/ArthurOutputDev.cc | 67 + ++++++++++++++++++++++++++++++++++++++++++++++ + qt5/src/ArthurOutputDev.h | 9 +++++++ + 2 files changed, 76 insertions(+) + +commit 376ae2f8b8a92fd7bd751fbfcd0aa46530b59ca4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 30 11:27:44 2017 +0200 + + Remove the gir-girs target + + It depends on the same files (subset) as the gir-typelibs target + meaning that sometimes when doing a parallel build you'd get the + two commands trying to generate the same file at once and bad + things happen + + cmake/modules/GObjectIntrospectionMacros.cmake | 1 - + 1 file changed, 1 deletion(-) + +commit 19eedc6fb693a62f305e13079501e3105f869f3c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 30 11:12:31 2017 +0200 + + Fix crash in broken files + + Bug #103045 + + fofi/FoFiTrueType.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5df4a8b0ad56b11c9be3b362e33810c5af57952b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 26 23:49:41 2017 +0200 + + Enable libcurl support by default + + CMakeLists.txt | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit 2c92c7b6a828c9db8a38f079ea7a3d51c12a481d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 25 19:33:44 2017 +0200 + + Fix infinite recursion on broken files + + Bug #102969 + + poppler/Gfx.cc | 46 ++++++++++++++++++++++++++++++++++------------ + poppler/GfxState.cc | 33 ++++++++++++++++++--------------- + poppler/GfxState.h | 15 +++++++++------ + 3 files changed, 61 insertions(+), 33 deletions(-) + +commit d3f12611b30e6421f05603a9838ed9131b1aa61e +Author: Bernd Kuhls <berndkuhls@hotmail.com> +Date: Sun Sep 24 23:56:29 2017 +0200 + + include ctype.h for isdigit + + Bug #102951 + + poppler/Form.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit a1a4be92323ae45f1ecc16595438520309554eb0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 24 13:21:58 2017 +0200 + + cairo: do not use the custom downscaling for rendering images when + using cairo >= 1.14 + + poppler/CairoOutputDev.cc | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +commit 3b64fc488e7ff10634aa2dd76ad4f152ebfe7edc +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 24 12:39:06 2017 +0200 + + regtest: change default value of utils dir to ../build/utils + + regtest/main.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit deba5f3c57929a96105d822c8cba46e5334694c7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 24 12:31:43 2017 +0200 + + cairo: Do not extend the pattern in drawImageMaskRegular + + This is causing some documents with tiling patterns to take ages + to render, + since we switched to use drawImageMaskRegular in 00a536a4. This patch + applies the same changes made in 7d8dfb09 and db87dc7f for + drawImageMaskPrescaled to drawImageMaskRegular. + + poppler/CairoOutputDev.cc | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit cceb80b353ca748d1e04373d238195fd548319b8 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Sun Sep 24 08:24:44 2017 +0200 + + glib: Make g-ir-scanner always link to the libs in build directory + + It was using the installed libraries, causing a build failure when + there's new API added to the poppler core. + + glib/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2afde7084ab55893182c2da59c429b48eb5d5a35 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:54 2017 +0200 + + Remove GlobalParams::splashResolution + + Noone was setting or getting the variable + + poppler/GlobalParams.h | 1 - + 1 file changed, 1 deletion(-) + +commit df783c5d10490e94e911316a6f42bb2d91a22dea +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:50 2017 +0200 + + Add a const to the static structure + + poppler/GlobalParamsWin.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a309cbfdd831b37461284b95763ca5a872e6af2b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:46 2017 +0200 + + Remove GlobalParams::setPSFile + + It had a setter but not a getter so wasn't used for anything + + poppler/GlobalParams.cc | 13 ------------- + poppler/GlobalParams.h | 2 -- + 2 files changed, 15 deletions(-) + +commit 7af5f7cadbdb89e0eaab148940c2c65cb12cc6d6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:42 2017 +0200 + + Remove GlobalParams::ccFontFiles + + it was never filled so it was basically a noop + + poppler/GfxFont.cc | 10 ---------- + poppler/GlobalParams.cc | 14 -------------- + poppler/GlobalParams.h | 3 --- + 3 files changed, 27 deletions(-) + +commit b5f8be7ede64e55d44ed484797a66ca068ba955f +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:39 2017 +0200 + + Remove GlobalParams::fontDirs + + It was only read but never filled so it was basically a noop + + poppler/GlobalParams.cc | 31 +------------------------------ + poppler/GlobalParams.h | 1 - + 2 files changed, 1 insertion(+), 31 deletions(-) + +commit 3463537624a24e3bdcaa42c135d337c6cd452ea5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:22 2017 +0200 + + Remove GlobalParams::getPSResidentFont* + + There was no way to set its contents so it's basically a noop + + poppler/GfxFont.cc | 38 ---------------------- + poppler/GlobalParams.cc | 85 + ------------------------------------------------- + poppler/GlobalParams.h | 29 ----------------- + poppler/PSOutputDev.cc | 6 ---- + 4 files changed, 158 deletions(-) + +commit 851bc59c6f4b007333d064af5c6992702b92cdf6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 21 20:45:52 2017 +0200 + + Remove the autotools based build system + + .gitignore | 20 +- + INSTALL | 244 ++------ + INSTALL.cmake | 76 --- + Makefile.am | 133 ----- + autogen.sh | 117 ---- + configure.ac | 1154 + -------------------------------------- + cpp/Makefile.am | 74 --- + cpp/tests/Makefile.am | 21 - + fofi/Makefile.am | 28 - + glib/Makefile.am | 122 ---- + glib/demo/Makefile.am | 56 -- + glib/poppler-features.h.in | 88 --- + glib/reference/Makefile.am | 92 --- + glib/reference/version.xml.in | 1 - + goo/Makefile.am | 69 --- + poppler-cairo-uninstalled.pc.in | 6 - + poppler-cairo.pc.in | 9 - + poppler-cpp-uninstalled.pc.in | 7 - + poppler-cpp.pc.in | 13 - + poppler-glib-uninstalled.pc.in | 7 - + poppler-glib.pc.in | 13 - + poppler-qt4-uninstalled.pc.in | 7 - + poppler-qt4.pc.in | 13 - + poppler-qt5-uninstalled.pc.in | 7 - + poppler-qt5.pc.in | 13 - + poppler-splash-uninstalled.pc.in | 7 - + poppler-splash.pc.in | 9 - + poppler-uninstalled.pc.in | 6 - + poppler.pc.in | 11 - + poppler/Makefile.am | 348 ------------ + poppler/poppler-config.h.in | 196 ------- + qt4/Makefile.am | 1 - + qt4/demos/Makefile.am | 65 --- + qt4/src/Makefile.am | 76 --- + qt4/tests/Makefile.am | 141 ----- + qt5/Makefile.am | 1 - + qt5/demos/Makefile.am | 65 --- + qt5/src/Makefile.am | 78 --- + qt5/tests/Makefile.am | 141 ----- + splash/Makefile.am | 73 --- + test/Makefile.am | 67 --- + utils/Makefile.am | 155 ----- + 42 files changed, 43 insertions(+), 3787 deletions(-) + +commit 1a33f60da2996ea64c1b903580885697940cf046 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 21 20:32:25 2017 +0200 + + Add some constness to the basic classes + + goo/GooString.cc | 2 +- + goo/GooString.h | 2 +- + poppler/Array.cc | 8 +-- + poppler/Array.h | 12 ++--- + poppler/Dict.cc | 18 +++---- + poppler/Dict.h | 26 +++++----- + poppler/Object.cc | 4 +- + poppler/Object.h | 152 + +++++++++++++++++++++++++++--------------------------- + 8 files changed, 112 insertions(+), 112 deletions(-) + +commit 135843fa8398364e0559c2b0b96f9be4a44572c5 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Wed Sep 20 19:38:14 2017 +0200 + + Add gtk-doc support to CMake build + + CMakeLists.txt | 4 +- + glib/CMakeLists.txt | 4 + + glib/reference/CMakeLists.txt | 12 ++ + gtkdoc.py | 440 + ++++++++++++++++++++++++++++++++++++++++++ + make-glib-api-docs | 66 +++++++ + 5 files changed, 525 insertions(+), 1 deletion(-) + +commit e51db61a33cdbe6307f048b65912a85f6cd1ec5b +Author: William Bader <william@newspapersystems.com> +Date: Wed Sep 20 19:36:46 2017 +0200 + + PSOutputDev: Fix wrong text generation + + This patch moves the code to update the max valid glyph hash into its + own function and updates the max valid glyph only if the new value is + higher than the previous value. + This fixes a problem with pages that have multiple copies of the same + font with different glyph counts. If poppler processed the font + with the + smaller count last, and then the PDF wrote text in the font with the + larger count, pdftops would not show the glyphs above the maximum + of the + smaller font. + + Bug #102760 + + poppler/PSOutputDev.cc | 16 ++++++++++------ + poppler/PSOutputDev.h | 1 + + 2 files changed, 11 insertions(+), 6 deletions(-) + +commit 6665839b5ce2e4f6fb2acc682ce2f91ed2404ce8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 20 19:36:29 2017 +0200 + + qt5: The tests don't need GUI + + qt5/tests/check_actualtext.cpp | 2 +- + qt5/tests/check_attachments.cpp | 2 +- + qt5/tests/check_dateConversion.cpp | 2 +- + qt5/tests/check_fonts.cpp | 2 +- + qt5/tests/check_goostring.cpp | 2 +- + qt5/tests/check_lexer.cpp | 2 +- + qt5/tests/check_links.cpp | 2 +- + qt5/tests/check_metadata.cpp | 2 +- + qt5/tests/check_optcontent.cpp | 2 +- + qt5/tests/check_pagelabelinfo.cpp | 2 +- + qt5/tests/check_pagelayout.cpp | 2 +- + qt5/tests/check_pagemode.cpp | 2 +- + qt5/tests/check_password.cpp | 2 +- + qt5/tests/check_permissions.cpp | 2 +- + qt5/tests/check_search.cpp | 2 +- + qt5/tests/check_strings.cpp | 2 +- + 16 files changed, 16 insertions(+), 16 deletions(-) + +commit 26a067d4a84f80eeb892e30a5ab608d0fbea1de5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 20 10:36:04 2017 +0200 + + Remove the moc includes + + Some people are having trouble with them and automoc really should + be taking care of this so no need to have the include. Let's hope this + doesn't break some other people :D + + qt5/demos/abstractinfodock.cpp | 1 - + qt5/demos/embeddedfiles.cpp | 1 - + qt5/demos/fonts.cpp | 1 - + qt5/demos/info.cpp | 1 - + qt5/demos/metadata.cpp | 1 - + qt5/demos/navigationtoolbar.cpp | 1 - + qt5/demos/optcontent.cpp | 1 - + qt5/demos/pageview.cpp | 1 - + qt5/demos/permissions.cpp | 1 - + qt5/demos/thumbnails.cpp | 1 - + qt5/demos/toc.cpp | 1 - + qt5/demos/viewer.cpp | 1 - + qt5/src/poppler-optcontent.cc | 1 - + 13 files changed, 13 deletions(-) + +commit 939465c40902d72e0c05d4f3a27ee67e4a007ed7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 19 21:19:03 2017 +0200 + + Fix crash in broken files + + Bug #102854 + + poppler/Stream.cc | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit a8aa61f774503c9ebd840e148c4fa31a6959600d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 19 21:17:49 2017 +0200 + + autotools: Fix build + + qt5/src/Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 6b82904b717994c887f33bfc72e4999363fc8e72 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 17 23:03:48 2017 +0200 + + Fix printf-like format warnings + + poppler/Stream.h | 2 +- + test/perf-test.cc | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit b26924e32128b7ba57260e9fdc54be1893bcff77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 17 02:06:32 2017 +0200 + + A few more static markers + + test/perf-test.cc | 2 +- + utils/pdftocairo-win32.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 4a4e291246f238731429729e10633ee1f627eb77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 17 01:58:36 2017 +0200 + + Make newer gcc happy about fallthrough + + on HtmlOutputDev.cc fixes a leak when printHtml is false + + fofi/FoFiTrueType.cc | 2 ++ + poppler/Annot.cc | 4 ++-- + poppler/SplashOutputDev.cc | 8 ++++++++ + splash/Splash.cc | 2 ++ + utils/HtmlOutputDev.cc | 9 ++++----- + 5 files changed, 18 insertions(+), 7 deletions(-) + +commit 0790dd3afb8370aebca8e7e154bbd2b5ae5cd5a2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 18:01:49 2017 +0200 + + Fix missing-declarations warnings + + ... and add it to default warning set + + cmake/modules/PopplerMacros.cmake | 2 +- + cpp/tests/poppler-dump.cpp | 2 +- + glib/poppler-action.cc | 1 + + goo/JpegWriter.cc | 2 +- + goo/gmem.h | 2 +- + poppler/Annot.cc | 6 ++-- + poppler/Decrypt.cc | 2 +- + poppler/TextOutputDev.cc | 2 +- + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-private.cc | 6 ++-- + qt4/tests/check_links.cpp | 4 +-- + qt4/tests/poppler-forms.cpp | 14 ++++----- + qt5/src/poppler-link.cc | 2 +- + qt5/src/poppler-private.cc | 6 ++-- + qt5/tests/check_links.cpp | 4 +-- + qt5/tests/poppler-forms.cpp | 18 ++++++------ + test/perf-test-preview-dummy.cc | 4 +++ + test/perf-test.cc | 62 + +++++++++++++++++++-------------------- + utils/pdfinfo.cc | 4 +-- + utils/pdfseparate.cc | 2 +- + utils/pdfsig.cc | 6 ++-- + utils/pdftotext.cc | 2 +- + utils/pdfunite.cc | 6 ++-- + 23 files changed, 83 insertions(+), 78 deletions(-) + +commit afd91b148d3d0ba025821740ff4c075b1de2fdc5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 17:47:42 2017 +0200 + + Fix warning: format ‘%x’ expects argument of type ‘unsigned + int*’, but argument 3 has type ‘int*’ + + poppler/UnicodeMap.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit a0ed20f3fb8025706ad9a580f6a692316bf6df66 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 17:45:42 2017 +0200 + + -Woverflow fixes + + cpp/poppler-private.cpp | 4 ++-- + glib/poppler-document.cc | 3 +-- + goo/GooString.cc | 6 ++++++ + goo/GooString.h | 1 + + poppler/Annot.cc | 9 +++------ + poppler/Form.cc | 13 +++++-------- + qt4/src/poppler-private.cc | 4 ++-- + qt5/src/poppler-private.cc | 4 ++-- + 8 files changed, 22 insertions(+), 22 deletions(-) + +commit d51cc34d7d51b6ddb7bfba318ed12bcbe763be6a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 17:35:15 2017 +0200 + + -pedantic fixes + + glib/poppler-media.cc | 2 +- + glib/poppler-movie.cc | 2 +- + glib/poppler-structure-element.cc | 2 +- + goo/glibc.h | 2 +- + poppler/StructElement.cc | 14 +++++++------- + utils/JSInfo.cc | 2 +- + 6 files changed, 12 insertions(+), 12 deletions(-) + +commit 804a823a67fedc3e633e89f817232d3c15715b56 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 16 20:16:58 2017 +0930 + + cmake: restructure the warnings into a "default" and "extra" group + + Most of the previous warnings are now in default. Extra warnings that + should be fixed but currently result in a lot of warnings are in the + extra group. + + The old no/yes/kde COMPILE_WARNINGS option has been replaced with the + boolean option EXTRA_WARN (default off) to enable the extra warnings. + + CMakeLists.txt | 18 +++++------------- + cmake/modules/PopplerMacros.cmake | 32 ++++++++++++++++++++++++-------- + 2 files changed, 29 insertions(+), 21 deletions(-) + +commit 6d40d4bad46ce1b53624feca7410b35e4fe0048d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 15 01:07:59 2017 +0200 + + CurlPDFDocBuilder don't crash if given a url that doesn't exist + + poppler/CurlPDFDocBuilder.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit cc43c720e857548175a9e35b0686a1a7a8957f50 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Aug 18 11:51:06 2017 +0200 + + Replace Splash font rendering by Qt font rendering + + Previously, the Arthur backend would use Splash code to do + its font rendering. That was not a satisfactory solution: + Qt can do font rendering directly. Also, the Splash font + rendering in the Arthur code had a few bugs, which lead + to legible-but-not-pretty fonts. + + This patch replaces the Splash font rendering by Qt font + rendering. Some Splash code will have to remain, because + Qt seems unable to do the proper charcode-to-glyph-index + transformations. + + I took a lot of inspiration from Mihai Niculescu's patch at + + https://lists.freedesktop.org/archives/poppler/2013-June/010370.html + + That's why the patch adds Mihai's name in the copyright list. + + qt5/src/ArthurOutputDev.cc | 254 + +++++++++++++++++++++++++-------------------- + qt5/src/ArthurOutputDev.h | 31 +++++- + splash/SplashFTFontFile.cc | 4 + + splash/SplashFTFontFile.h | 3 + + 4 files changed, 177 insertions(+), 115 deletions(-) + +commit da63c35549e8852a410946ab016a3f25ac701bdf +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 14 19:14:41 2017 +0200 + + FoFiType1C::convertToType0: Fix crash in broken files + + Bug #102724 + + fofi/FoFiType1C.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 504b3590182175390f474657a372e78fb1508262 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 14 19:14:23 2017 +0200 + + Splash::scaleImage: Do not try to scale if srcHeight or srcWidth + are < 1 + + Bug #102719 + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 500ce88a3b5b0bd556ac6941ba66a86cae44663a +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Wed Sep 13 12:12:29 2017 +0200 + + Fix two minor typos + + qt5/tests/test-render-to-file.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 80f9819b6233f9f9b5fd44f0e4cad026e5d048c2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 13 23:09:45 2017 +0200 + + isImageInterpolationRequired: Fix divide by 0 on broken documents + + Bug #102688 + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit aaf5327649e8f7371c9d3270e7813c43ddfd47ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 13 23:01:03 2017 +0200 + + Gfx::doShowText: Fix infinite recursion on broken files + + Bug #102701 + + poppler/Gfx.cc | 25 +++++++++++++++++++++++-- + poppler/Gfx.h | 1 + + poppler/GfxFont.cc | 8 ++++++++ + poppler/GfxFont.h | 1 + + 4 files changed, 33 insertions(+), 2 deletions(-) + +commit 476394e7a025e02e4897da2e765df2c895d0708f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 13 22:58:14 2017 +0200 + + XRef::parseEntry: Fix crash in broken file + + Bug #102687 + + poppler/XRef.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 0f891b85169dabd3d23348aba40266547bd4bcf6 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Sep 13 20:12:52 2017 +0930 + + pdfinfo: don't truncate dest name + + utils/pdfinfo.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 951e7b3c1f337ceaf490edce3c575f89c45cb6d4 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Sep 13 19:24:07 2017 +0930 + + cmake: ensure user cflags/cxxflags are appended to end + + cmake/modules/PopplerMacros.cmake | 44 + +++++++++++++++++++++------------------ + 1 file changed, 24 insertions(+), 20 deletions(-) + +commit a5c616a65a77bf597836cced6f987e5b93480ca5 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Sep 11 20:55:01 2017 +0930 + + cmake INSTALL file + + INSTALL.cmake | 76 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 76 insertions(+) + +commit a5e5649ecf16fa05770620dbbd4985935dc2bbff +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 11 12:35:16 2017 +0200 + + Fix crash in FoFiType1C::convertToType0 in broken files + + Bug #102653 + + fofi/FoFiType1C.cc | 435 + +++++++++++++++++++++++++++-------------------------- + 1 file changed, 220 insertions(+), 215 deletions(-) + +commit 325887ebef8ea1c6ef9d3607a59d95ffea383986 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 10 17:41:47 2017 +0200 + + Make JBIG2Stream::readGenericBitmap return cleanly on error + + instead of causing abort + + Also fixes warning when compiled with newer gcc + + poppler/JBIG2Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f253a28f4c5bb65c363d31b8b46f984c660499ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 19:05:36 2017 +0200 + + qt5: in development -> is stable + + The API itself is done-ish even if it gets improvements from time to + time. In development seems to imply "don't use me yet" + + qt5/src/Mainpage.dox | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1316c7a41f4dd7276f404f775ebb5fef2d24ab1c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:29:42 2017 +0200 + + Annot: Fix crash on broken files + + Bug #102607 + + poppler/Annot.cc | 42 +++++++++++++++++++++++------------------- + 1 file changed, 23 insertions(+), 19 deletions(-) + +commit 2532df6060092e9fab7f041ae9598aff9cdd94bb +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:28:15 2017 +0200 + + Annot: Fix crash on broken files + + Bug #102601 + + poppler/Annot.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 6472d8493f7e82cc78b41da20a2bf19fcb4e0a7d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:26:05 2017 +0200 + + SplashOutputDev: Fix crash on broken files + + Bug #102604 + + poppler/SplashOutputDev.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 3ab44e2a77b560198c1e1616cfb39c1ac7374e29 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:21:40 2017 +0200 + + Remove unmaintained TODO file + + TODO | 40 ---------------------------------------- + 1 file changed, 40 deletions(-) + +commit dfcf997e6fbca31dbe051fbd9c32aca818825e38 +Author: Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +Date: Wed Sep 6 11:03:52 2017 +0200 + + Added methods to get and set the font size of text fields + + Fixes bug #101692 + + poppler/Annot.cc | 24 +++---------- + poppler/Form.cc | 92 + +++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Form.h | 16 +++++++++ + qt5/src/poppler-form.cc | 12 ++++++- + qt5/src/poppler-form.h | 10 ++++++ + 5 files changed, 134 insertions(+), 20 deletions(-) + +commit 0bda8bb8eda838316a61238441665abfd24eb020 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Thu Sep 7 19:55:54 2017 +0200 + + Disable glib if cairo is not found + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 118cd73a3c4eba78bbfed16cfc2996dec5491944 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 6 19:42:26 2017 +0200 + + cmake: Give people the option to build poppler as a static library + + CMakeLists.txt | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 766a32ff59dadd9ae4639d8a79861a17be6aec52 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Sep 5 20:55:45 2017 +0930 + + cmake: add options to disable glib/qt4/qt5 + + CMakeLists.txt | 54 + ++++++++++++++++++++++++++++++++++-------------------- + 1 file changed, 34 insertions(+), 20 deletions(-) + +commit 101aba9a8d6623bca419946262fea6b46a790454 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 5 19:34:12 2017 +0200 + + cmake: Fix build when using a cairo different than the system one + + glib/demo/CMakeLists.txt | 2 +- + test/CMakeLists.txt | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 1d3f00e8c53dbbd3a8409993b7b66667df434b5d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Sep 5 06:39:49 2017 +0930 + + ignore build directory + + .gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 340a99f580b9f7b6add831e9a0252574bfea66f2 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Sep 1 22:16:49 2017 +0200 + + Control whether renderToImage shows annotations + + I'd like to control whether the renderToImage and renderToPainter + methods show annotations or not. To this end, this patch introduces + a new value 'HideAnnotations' to the Document::RenderHint enum. + + qt5/src/poppler-page.cc | 36 ++++++++++++++++++++++++++++++++++-- + qt5/src/poppler-qt5.h | 3 ++- + 2 files changed, 36 insertions(+), 3 deletions(-) + +commit dd80c182cbcb188af0dd590f222ba9bbb31e3fb7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 4 19:36:06 2017 +0200 + + Fix building with old clang + + poppler/StructElement.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit a22cd0badbc177f8a2eedb0386895ddf3379c618 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 3 23:35:08 2017 +0200 + + Initial make dist support in cmake + + .gitattributes | 5 +++++ + CMakeLists.txt | 9 +++++++++ + 2 files changed, 14 insertions(+) + +commit 85bfedad416906b1a5dff377d470387692b5ca70 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 3 22:54:32 2017 +0200 + + Poppler 0.59 + + CMakeLists.txt | 4 ++-- + NEWS | 15 +++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 22 insertions(+), 7 deletions(-) + +commit 98b4c23cf6f6eb0dbc167ed0606932b0d8de39f1 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 3 22:50:31 2017 +0200 + + Update (C) + + utils/pdfinfo.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5c8dfc90603111aea36add20c88abde79a351d85 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 3 22:32:09 2017 +0200 + + Remove the old if/else cmake syntax + + that was weird and forced you to replicate the if clause in the + else and + endif + + CMakeLists.txt | 154 + +++++++++++++++++++++++------------------------ + cpp/tests/CMakeLists.txt | 2 +- + glib/CMakeLists.txt | 2 +- + qt4/src/CMakeLists.txt | 2 +- + qt4/tests/CMakeLists.txt | 8 +-- + qt5/src/CMakeLists.txt | 2 +- + qt5/tests/CMakeLists.txt | 8 +-- + test/CMakeLists.txt | 10 +-- + utils/CMakeLists.txt | 10 +-- + 9 files changed, 99 insertions(+), 99 deletions(-) + +commit 251bb42e9af251c86b8fec120e14972ac7c07106 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 3 22:23:18 2017 +0200 + + Remove the check for cmake >= 2.8.8 since we're requiring 3.1 already + + CMakeLists.txt | 25 ++++++++++--------------- + 1 file changed, 10 insertions(+), 15 deletions(-) + +commit 3ea09e735f81a2a16a204388bc474871aaa10271 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 2 17:50:58 2017 +0930 + + Fix warning when compiling with cygwin + + ImageOutputDev.cc:532:14: warning: ‘f’ may be used uninitialized + in this function [-Wmaybe-uninitialized] + + utils/ImageOutputDev.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6ef21aea5bb8b87f9a7e9217c316cd5e10612a62 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 2 17:50:35 2017 +0930 + + Fix cygwin 32-bit compile + + poppler/goo/gfile.cc: In function ‘GBool openTempFile(GooString**, + FILE**, const char*)’: + poppler/goo/gfile.cc:409:37: error: ‘mkstemp’ was not declared + in this scope + fd = mkstemp((*name)->getCString()); + ^ + poppler/goo/gfile.cc:417:39: error: ‘fdopen’ was not declared + in this scope + if (fd < 0 || !(*f = fdopen(fd, mode))) { + ^ + poppler/goo/gfile.cc: In function ‘int Gfseek(FILE*, Goffset, + int)’: + poppler/goo/gfile.cc:558:34: error: ‘fseeko’ was not declared + in this scope + return fseeko(f, offset, whence); + ^ + poppler/goo/gfile.cc: In function ‘Goffset Gftell(FILE*)’: + poppler/goo/gfile.cc:572:18: error: ‘ftello’ was not declared + in this scope + return ftello(f); + ^ + + cmake/modules/PopplerMacros.cmake | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 048237db6a7122a5769a15c7dd3ae3680e06e9bb +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 2 22:59:32 2017 +0200 + + pdfunite: Fix API porting error that caused abort in some cases + + We need to check for xRef->getTrailerDict() existing before accessing + xRef->getDocInfo(); + + poppler/PDFDoc.cc | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +commit 4459d817194431f4f00553d5ad67b960a37e4c9d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 2 20:16:44 2017 +0930 + + pdfinfo: use GooString.append instead of sprintf/strcat + + https://lists.freedesktop.org/archives/poppler/2017-September/012437.html + + utils/pdfinfo.cc | 46 +++++++++++++++++++++++----------------------- + 1 file changed, 23 insertions(+), 23 deletions(-) + +commit 267ff8af69ae7e8526d9bfe5063207c87a9b70b5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 2 13:27:33 2017 +0200 + + Fix infinite recursion in NameTree parsing in broken files + + poppler/Catalog.cc | 16 +++++++++++++--- + poppler/Catalog.h | 2 +- + 2 files changed, 14 insertions(+), 4 deletions(-) + +commit c5487b653b1c37882af32a25296611e64d7ba867 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 2 11:55:17 2017 +0200 + + pdfinfo: -dests don't crash in broken documents + + That have pages that don't have ref + + utils/pdfinfo.cc | 38 ++++++++++++++++++++------------------ + 1 file changed, 20 insertions(+), 18 deletions(-) + +commit 10660b359dc960f4b0f3728243c64eec79c39851 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 2 11:50:00 2017 +0200 + + pdfinfo: Fix memory leaks when using -dests + + utils/pdfinfo.cc | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +commit ea6174def73f7478ae76843bb88ef85c5a6150f9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 2 11:31:51 2017 +0200 + + pdfinfo: Fix crash if getDest* returns nullptr + + utils/pdfinfo.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 73e12716f3e4643c2ea13421902b8220596454d7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 1 20:11:27 2017 +0200 + + Poppler 0.58 + + CMakeLists.txt | 4 ++-- + NEWS | 30 ++++++++++++++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 37 insertions(+), 7 deletions(-) + +commit 8a5c7be5b5772672b34638532793cf62be78e9b8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 1 20:02:17 2017 +0200 + + Add missing includes + + goo/JpegWriter.cc | 2 +- + goo/JpegWriter.h | 2 +- + goo/gfile.cc | 1 + + goo/gfile.h | 1 + + poppler/CairoOutputDev.cc | 2 +- + poppler/Gfx.cc | 2 +- + poppler/GlobalParams.cc | 1 + + poppler/GlobalParamsWin.cc | 2 ++ + poppler/Outline.cc | 1 + + poppler/Stream.cc | 2 +- + poppler/Stream.h | 2 +- + splash/SplashBitmap.cc | 2 +- + splash/SplashBitmap.h | 2 +- + utils/pdftocairo.cc | 2 +- + 14 files changed, 15 insertions(+), 9 deletions(-) + +commit 26f64a2a34a9273897c34045ea7af5e8c3c603cb +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 31 15:37:07 2017 +0200 + + cmake: enable glib for windows too + + There's no need to not having it enabled + + cmake/modules/FindGLIB.cmake | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +commit 90bc39daf9d3276b166b4c88e1d2c1988aa41c71 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Mon Aug 28 10:25:12 2017 +0200 + + Document some parameters of the drawChar method + + Thanks to Adrian Johnson, who explained their meaning to me. + + poppler/OutputDev.h | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 59e6e9b3e4d77229051cafeeeb65a82e9a966204 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 27 12:54:03 2017 +0200 + + Add missing inlcudes when compiling with cmake+mingw + + utils/pdftocairo-win32.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 13cf327cd512ebc26c8bd31cdd80d61027634bcb +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 27 12:51:19 2017 +0200 + + cmake: Use -std=c++11 instead of -std=gnu++11 + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 1602610ce2bbab2feb0177f0876e1ed0ee40a472 +Author: Tobias C. Berner <tcberner@freebsd.org> +Date: Sun Aug 27 12:16:05 2017 +0200 + + Include time.h for time_t + + qt5/src/poppler-form.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit 40cb9f4bf6f35ea62bc7b9e5c23008f98ebd4b36 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Aug 24 11:14:34 2017 +0200 + + Fix build with mingw + + config.h.cmake | 6 ++++++ + poppler/GlobalParamsWin.cc | 21 ++++++--------------- + poppler/Link.cc | 14 ++------------ + poppler/PDFDoc.cc | 4 +--- + 4 files changed, 15 insertions(+), 30 deletions(-) + +commit 5be33ba49071a9ffeb62be93e5dc01267318d1c2 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 23 21:00:09 2017 +0930 + + Fix Outline title + + poppler/Outline.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 1b84a71ee2550ae4b14cb1e40576de1f022eb2e8 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Tue Aug 22 11:43:08 2017 +0200 + + Use Qt::SvgMiterJoin instead of Qt::MiterJoin + + The two differ in what happens when the miter limit is exceeded. + According to + + https://bugreports.qt.io/browse/QTBUG-52640 + + Qt::SvgMiterJoin is what the pdf standard requires. + + Closes: https://bugs.freedesktop.org/show_bug.cgi?id=102356 + + qt5/src/ArthurOutputDev.cc | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 0793b6740121f4af07360800bebdc6238fc43087 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Sun Aug 13 19:47:15 2017 +0200 + + Document the updateCTM method + + poppler/OutputDev.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 488d28ec9507eb99c7cb4cd2cafb54995a8bc9f8 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 16 21:01:07 2017 +0930 + + pdfimages: support listing/extracting inline images + + The difficulty with extracting inline images is that inline images do + not provide any way of determining the length or end of image data + without decoding the image. We can get the length by using ImageStream + to decode the data then check the stream position. But then we are + still unable to extract the undecoded image data because embedded + streams can only be read once. + + Since inline images tend to be small the solution implemented is to + modify EmbedStream to keep a copy of the data read from it in memory + and then allow the data to be read again. + + Two new functions have been added to EmbedStream. rewind() will cause + EmbedStream.getChar() to stop recording data and switch to replaying + the saved data, returning EOF when the end of the saved data is + reached. The restore() function will make getChar() switch back to + reading from the parent stream. + + ImageOutputDev can now extract or get the image size by first using + ImageStream to read data from the embedded stream. After calling + rewind() the undecoded image data can be read from the embedded stream + until EOF is returned. Then restore() is called so that Gfx can read + the 'EI' from the end of the embedded stream. + + Bug 25625 + + poppler/Gfx.cc | 2 +- + poppler/Stream.cc | 96 + +++++++++++++++++++++++++++++++++++++++++++------ + poppler/Stream.h | 14 ++++++-- + utils/ImageOutputDev.cc | 67 ++++++++++++++++++++++++++++++---- + utils/ImageOutputDev.h | 1 + + 5 files changed, 159 insertions(+), 21 deletions(-) + +commit b9030a069756c84669ed6f408399cc7e2ce4fd10 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sun Jul 16 12:23:28 2017 +0930 + + pdftoppm: add -jpegopt for setting jpeg compression parameters + + Bug 45727 + + splash/SplashBitmap.cc | 25 ++++++++++++---- + splash/SplashBitmap.h | 15 ++++++++-- + utils/pdftoppm.1 | 15 ++++++++++ + utils/pdftoppm.cc | 80 + ++++++++++++++++++++++++++++++++++++++++++++++---- + 4 files changed, 120 insertions(+), 15 deletions(-) + +commit dd54243f00557e84dba887403912d12463c8b1e9 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Jul 15 21:26:29 2017 +0930 + + pdftocairo: add -jpegopt for setting jpeg compression parameters + + Bug 45727 + + goo/JpegWriter.cc | 10 ++++++++ + goo/JpegWriter.h | 2 ++ + utils/pdftocairo.1 | 17 ++++++++++++- + utils/pdftocairo.cc | 71 + +++++++++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 99 insertions(+), 1 deletion(-) + +commit 00a536a455e4dd396c6b8b74d3e6a5c82d987eed +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Aug 16 21:21:58 2017 +0930 + + cairo 1.14 now has high quality downscaling + + The filter needs to be GOOD or BEST to activate the high quality + downscaling. + + poppler/CairoOutputDev.cc | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 535bc8eeaf8d354a84129fe00c3a5e3ac0a85aa3 +Author: Christoph Cullmann <cullmann@kde.org> +Date: Wed Aug 16 21:11:36 2017 +0930 + + win32: call ANSI functions directly + + to be able to compile with different -DUNICODE variants + + Bug 100312 + + goo/gfile.cc | 14 +++++++------- + goo/gfile.h | 2 +- + poppler/GlobalParams.cc | 2 +- + poppler/GlobalParamsWin.cc | 20 ++++++++++---------- + 4 files changed, 19 insertions(+), 19 deletions(-) + +commit a8d670b59b0301040e716f3a11a78fce1177337d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 15 21:35:27 2017 +0930 + + pdfinfo: add -dests option to print named destinations + + Bug 97262 + + utils/pdfinfo.1 | 4 ++ + utils/pdfinfo.cc | 140 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 143 insertions(+), 1 deletion(-) + +commit 6d3239a2fd04595fecfb81a8703794877f4d8dec +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Aug 15 20:09:25 2017 +0200 + + Fix build with autotools + + qt5/src/Makefile.am | 1 + + utils/Makefile.am | 4 ++++ + 2 files changed, 5 insertions(+) + +commit b56a697c58bcf09063827b9c109be9c04a033b8a +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 15 12:25:26 2017 +0200 + + Improvements to the previous Signature commit + + * Remove FormWidgetSignature::setFormSignatureType, the API was + weird, + make it be an output parameter of getCheckedSignature + + * include cleanup + + * Make validation time mandatory, marking to use -1 for *now* + + * Remove setFormSignatureType noone uses + + * Fix compilation wihtout NSS3 + + * Don't static cast between NSS3 HASH_HashType and poppler-qt5 + HashAlgorithm + + * Actually pass validationTime down in FormFieldSignature::validate + + * Add since markers to poppler-qt5 functions/enums + + * Fix spacing + + * Remove SignatureValidationInfo::signingDateTime that returns + QDateTime, having two functions that return the same is a bit + confusing, + and we're not filling the timezone info anyway, so let it be a time_t + + poppler/Form.cc | 17 ++++--------- + poppler/Form.h | 20 ++++++---------- + poppler/SignatureHandler.h | 5 ++-- + poppler/SignatureInfo.cc | 7 +++++- + poppler/SignatureInfo.h | 4 ++-- + qt5/src/poppler-form.cc | 52 ++++++++++++++++++++++------------------ + qt5/src/poppler-form.h | 59 + +++++++++++++++++++++++++++++----------------- + utils/pdfsig.cc | 25 +++++--------------- + 8 files changed, 96 insertions(+), 93 deletions(-) + +commit a81700dfa638872fe9641289971ca9a2b50b42ad +Author: Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +Date: Tue Aug 15 10:27:26 2017 +0200 + + Various signature related improvements + + Export signature via Qt5 interface. + Add support for signatures of SubFilter "ETSI.CAdES.detached". + Add an optional validation time to method validateSignature(). + Print full Subject Distinguished Name, signing time, hash algorithm + and a statement wether the total document is signed in pdfsig. + + Fixes bug #99271 + + poppler/Form.cc | 178 + ++++++++++++++++++++++++++++++++++++++++++-- + poppler/Form.h | 34 ++++++++- + poppler/SignatureHandler.cc | 34 ++++++++- + poppler/SignatureHandler.h | 5 +- + poppler/SignatureInfo.cc | 33 +++++++- + poppler/SignatureInfo.h | 9 ++- + qt5/src/poppler-form.cc | 112 ++++++++++++++++++++++++++++ + qt5/src/poppler-form.h | 58 +++++++++++++++ + utils/pdfsig.1 | 6 +- + utils/pdfsig.cc | 73 ++++++++++++++++++ + 10 files changed, 523 insertions(+), 19 deletions(-) + +commit e15a0df15b89e1c7ba98cd7bbbf8ef97e541d231 +Author: Hannah von Reth <vonreth@kde.org> +Date: Sun Aug 13 20:26:44 2017 +0200 + + Remove old/wrong cmake code for MSVC + + cpp/CMakeLists.txt | 3 --- + 1 file changed, 3 deletions(-) + +commit 236f4ff4f516cb68a2d102627b0a3da73578c67f +Author: Hannah von Reth <vonreth@kde.org> +Date: Sun Aug 13 20:24:15 2017 +0200 + + Use WIN32_LEAN_AND_MEAN on Windows + + CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit 1abf98b76ba134adc44883cd2ae345f769ca0d5a +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Sat Aug 12 16:42:40 2017 +0200 + + qt5: ArthurOutputDev: Properly set the QPainter transformation + + Previously, the code did not touch the QPainter world transformation + matrix. Rather, the code contained ad hoc coordinate transformations + scattered throughout the code. This patch does a cleanup: the + QPainter + transformation matrix is set properly, and the hand-coded + transformations are removed. This should not affect the rendering + output, but it makes the current (and future!) code simpler to + read and write. + + qt5/src/ArthurOutputDev.cc | 56 + ++++++++++++++++++++++++---------------------- + qt5/src/ArthurOutputDev.h | 4 ++++ + 2 files changed, 33 insertions(+), 27 deletions(-) + +commit 2baaa02087ef66b97bf3c4bce49785a10632178f +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Aug 13 12:35:39 2017 +0200 + + Revert part of last commit, we wants tests not to fail :) + + qt5/tests/check_metadata.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3af2e18fc31f18efb36408281ca5879f284edaa4 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Aug 11 22:55:41 2017 +0200 + + Fix copy'n'paste bugs: Qt4 -> Qt5 + + qt5/src/ArthurOutputDev.h | 2 +- + qt5/src/poppler-annotation.h | 2 +- + qt5/tests/check_metadata.cpp | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit a9581e624fa62b3905b790ac10d1349b1f96048a +Author: Roland Hieber <r.hieber@pengutronix.de> +Date: Fri Aug 11 11:44:26 2017 +0200 + + Form.h: fix error: 'vector' in namespace 'std' does not name a type + + Bug #102147 + + Original error message while compiling with + OSELAS.Toolchain-2016.06.1-arm-v7a-linux-gnueabi, + gcc-5.4.0-glibc-2.23-binutils-2.26-kernel-4.6-sanitized: + + make[5]: Entering directory + '/ptx/work/dude/WORK_B/rhi/OSELAS.BSP-Miele-PST/platform-cpu20/build-target/poppler-0.57.0/qt4/src' + CXX libpoppler_qt4_la-poppler-form.lo + In file included from poppler-form.cc:26:0: + ../../poppler/Form.h:544:14: error: 'vector' in namespace + 'std' does not name a template type + ../../poppler/Form.h:556:8: error: 'vector' in namespace + 'std' does not name a template type + Makefile:735: recipe for target + 'libpoppler_qt4_la-poppler-form.lo' failed + + configure arguments were: + + --prefix=/usr --sysconfdir=/etc --localstatedir=/var + --libdir=/usr/lib --host=arm-v7a-linux-gnueabi + --build=x86_64-host-linux-gnu --enable-option-checking + --disable-silent-rules --disable-dependency-tracking + --enable-shared --enable-fast-install --enable-libtool-lock + --enable-xpdf-headers --enable-build-type=release + --disable-single-precision --enable-fixedpoint --enable-cmyk + --disable-relocatable --enable-libopenjpeg=none + --disable-libnss + --disable-libtiff --enable-largefile --enable-zlib + --disable-zlib-uncompress --enable-libcurl + --enable-dctdecoder=libjpeg --enable-libpng + --disable-splash-output --enable-cairo-output + --enable-poppler-glib --disable-introspection + --disable-gtk-doc + --disable-gtk-doc-html --disable-gtk-doc-pdf + --enable-poppler-qt4 --disable-poppler-qt5 + --enable-poppler-cpp + --disable-gtk-test --enable-utils --disable-compile-warnings + --enable-cms=lcms1 --without-x + --with-font-configuration=fontconfig --without-libiconv-prefix + --with-testdatadir= + + Signed-off-by: Roland Hieber <r.hieber@pengutronix.de> + + poppler/Form.h | 2 ++ + 1 file changed, 2 insertions(+) + +commit f0ecbc6f988aa19ffb2b7e583dca4e609f2f6c65 +Author: Thomas Freitag <Thomas.Freitag@alfa.de> +Date: Thu Aug 10 09:17:27 2017 +0200 + + Tweak which cmap we use + + Bug #101855 + + poppler/GfxFont.cc | 20 +++++++++----------- + 1 file changed, 9 insertions(+), 11 deletions(-) + +commit 7e844eae94bc4eda1c6dcc3460840b25f4ca7898 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Wed Aug 9 11:09:50 2017 +0200 + + qt5: Arthur: initialize the image with the paper color + + Bug #102129 + + qt5/src/poppler-page.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit d7b800933e1b57c180247708991f5c3a282f8305 +Author: Jason Alan Palmer <jalanpalmer@gmail.com> +Date: Wed Aug 9 00:41:05 2017 +0200 + + cpp: Fix page.text() not taking page orientation into account + + Bug #94517 + + cpp/poppler-page.cpp | 10 +++++++++- + cpp/tests/poppler-dump.cpp | 3 ++- + 2 files changed, 11 insertions(+), 2 deletions(-) + +commit cd04a81343fd5cba824a891f25c01eeffee5f906 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 8 22:42:46 2017 +0200 + + Fix use of uninitialized value use + + Bug #102117 + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit fe97135ffb18eaaec7d23a7394641ba103bfe48d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 1 19:30:28 2017 +0200 + + Make the openjpeg1 code compile with the new Object API + + poppler/JPEG2000Stream.cc | 13 ++++--------- + 1 file changed, 4 insertions(+), 9 deletions(-) + +commit e5ff049c3d11e6ea24b624807730acd21a6ef4d5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 1 01:07:00 2017 +0200 + + Gfx::doImage: Simplify memory management + + of maskColorMap by using a std::unique_ptr + + Fixes a memory leak reported by Coverity + + poppler/Gfx.cc | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +commit 19eda068ae1866e4f46efc9534b34779007fdc16 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 1 00:53:52 2017 +0200 + + Fix memory leak on corner case condition + + poppler/Parser.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit dbe7a5da3dce56210bd4ca2deaf8f5ad4a9d0529 +Merge: 687474e1 c167f35b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Aug 1 00:12:13 2017 +0200 + + Merge remote-tracking branch 'origin/master' into better_object + +commit c167f35b8c3fd7e94fa97385949b2c133d918ed4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 31 23:39:37 2017 +0200 + + Poppler 0.57 + + CMakeLists.txt | 4 ++-- + NEWS | 14 ++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 7 files changed, 21 insertions(+), 7 deletions(-) + +commit be0384d2220a75d2666b1fd2228e156b1595a57f +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 31 23:34:57 2017 +0200 + + Add missing (C) + + poppler/StructTreeRoot.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 0e7f6cb1c42db3d65395365833472ff859def87a +Author: Jannick <thirdedition@gmx.net> +Date: Mon Jul 31 19:53:12 2017 +0200 + + Fix some warnings in some unusual #ifdef combinations + + Bug #101812 + + poppler/PSOutputDev.cc | 2 +- + poppler/Stream.cc | 5 ++--- + 2 files changed, 3 insertions(+), 4 deletions(-) + +commit f55d6a64dd3f69fa9c1ba984218809cc50c9b052 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 31 19:45:32 2017 +0200 + + Add missing (C) + + utils/pdfseparate.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 543b0ea219191122fee0583ce62c19e31de34109 +Author: Roland Hieber <r.hieber@pengutronix.de> +Date: Mon Jul 17 11:35:32 2017 +0200 + + configure.ac: fix --disable-FEATURE actually enabling the feature + + Forwarded: https://bugs.freedesktop.org/show_bug.cgi?id=101818 + + A frequently seen antipattern is to use + AC_ARG_ENABLE(feature, help, action-if-given, action-if-not-given) as + AC_ARG_ENABLE(feature, help, action-if-enabled, action-if-disabled). + However, action-if-given is also evaluated for --disable-FEATURE (with + enableval=no), which results in --disable-FEATURE and --enable-FEATURE + doing the same in this case. + + Rewrite the single-precision, fixedpoint and cmyk arguments + accordingly + so the user is not confused if they explicitely want to disable those + options. + + Signed-off-by: Roland Hieber <r.hieber@pengutronix.de> + + configure.ac | 32 ++++++++++++++++++++++++++------ + 1 file changed, 26 insertions(+), 6 deletions(-) + +commit 92ad743b63c3e82211ea0b2e4d4471dd3f71cebc +Author: Léonard Michelet <leonard.michelet@smile.fr> +Date: Mon Jul 31 19:40:06 2017 +0200 + + pdfseparate: minor improvement to the documentation + + Bug #101800 + + utils/pdfseparate.1 | 7 ++++--- + utils/pdfseparate.cc | 2 +- + 2 files changed, 5 insertions(+), 4 deletions(-) + +commit 0a2096743fa749a8a7d4caa714eecbe8a9661619 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 31 16:52:46 2017 +0200 + + Add some more overrides + + poppler/CurlCachedFile.h | 4 ++-- + poppler/CurlPDFDocBuilder.h | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +commit 687474e17db59482dc4538740701bdb32bc9d6bd +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 31 16:47:31 2017 +0200 + + Build++ + + poppler/CurlPDFDocBuilder.cc | 5 +---- + poppler/Stream.cc | 2 +- + 2 files changed, 2 insertions(+), 5 deletions(-) + +commit 66e718e753a527289ce86cd206fcffd23fc28d81 +Merge: 9cecd78f 213ae24b +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 31 16:39:53 2017 +0200 + + Merge remote-tracking branch 'origin/master' into better_object + +commit 213ae24b4df97f557e771060e37197d0e57f6f7f +Author: Jannick <thirdedition@gmx.net> +Date: Sun Jul 16 19:51:49 2017 +0200 + + added override tag to function declarations + + poppler/FlateStream.h | 16 ++++++++-------- + poppler/JPXStream.h | 16 ++++++++-------- + poppler/Stream.h | 16 ++++++++-------- + 3 files changed, 24 insertions(+), 24 deletions(-) + +commit ab371fe60568947e355d89e28d489f7f9a1a7404 +Author: Jason Crain <jason@inspiresomeone.us> +Date: Sun Jul 16 12:07:54 2017 -0500 + + pdftohtml: skip control characters + + W3C disallows them and they cause a warning in PHP. + + https://bugs.freedesktop.org/show_bug.cgi?id=101770 + + utils/HtmlFonts.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit 0f4ea2f18b1953ccc88bcbd6b16ede828b44e561 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Jul 10 21:06:30 2017 +0930 + + Fix parsing of Type 1 fonts with newlines in encoding sequences + + Adobe Type 1 font spec states that the encoding sequences should be of + the form: + + dup index /name put + + The bug 101728 test case has the encoding sequences in the form: + + dup + index /name put + + Make the Type 1 parse handle encoding sequences split over more than + one line. + + Bug 101728 + + fofi/FoFiType1.cc | 40 +++++++++++++++++++++++++++++++++++----- + 1 file changed, 35 insertions(+), 5 deletions(-) + +commit 75fff6556eaf0ef3a6fcdef2c2229d0b6d1c58d9 +Author: Caolán McNamara <caolanm@redhat.com> +Date: Wed Jul 12 14:12:46 2017 +0100 + + CVE-2017-9865 (fdo#100774) avoid stack buffer overflow + + in GfxImageColorMap:getGray + + by passing first arg to getGray of maximum possibly required size + + and similar in HtmlOutputDev::drawPngImage + + utils/HtmlOutputDev.cc | 6 ++++-- + utils/ImageOutputDev.cc | 6 ++++-- + 2 files changed, 8 insertions(+), 4 deletions(-) + +commit 5d0c23a9f6cdc3fd216335124788958f46932158 +Author: Jan-Erik S <janerik234678@gmail.com> +Date: Sat Jul 29 18:23:39 2017 +0200 + + Fix crash in broken document + + poppler/StructTreeRoot.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 852fd28674e14f25c6902c0adab19909f73f2632 +Author: David Faure <faure@kde.org> +Date: Sat Jul 29 18:18:23 2017 +0200 + + Set RUNPATH for poppler shared libs + + Bug #101945 + + CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +commit 771c82623e8e1e0c92b8ca6f7c2b8a81ccbb60d3 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jul 3 22:44:42 2017 +0200 + + pdfunite: fix crash in broken documents + + Bug #101208 + + poppler/PDFDoc.cc | 70 + +++++++++++++++++++++++++++++++++++++++++-------------- + poppler/PDFDoc.h | 21 +++++++---------- + 2 files changed, 62 insertions(+), 29 deletions(-) + +commit 02d9b182b80d5745b79480b0b8d0eb49b0be304e +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 21 22:49:26 2017 +0200 + + Poppler 0.56 + + CMakeLists.txt | 2 +- + NEWS | 8 ++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 13 insertions(+), 5 deletions(-) + +commit 3a2759aa2a98c2157cb35731b95e393b8882f8d3 +Author: Jose Aliste <jaliste@src.gnome.org> +Date: Tue May 16 18:44:49 2017 -0400 + + Check numComps is between reasonable bounds + + Before this patch, some PDF might crash because of an overflow + if numComps does not lie between 0 and 4. + This is a security fix for CVE-2017-0319. + + poppler/Stream.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit d9c88e1c8892c79b8865a0dabdcc0d3ffd55c195 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 21 00:56:38 2017 +0200 + + Fix crash in malformed documents + + poppler/GfxState.cc | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +commit 55db66c69fd56826b8523710046deab1a8d14ba2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Jun 21 00:55:20 2017 +0200 + + Fix crash in malformed documents + + poppler/JBIG2Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5266fa426d73c5dbdb3dd903d50885097833acc6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 20 23:58:26 2017 +0200 + + Fix crash in malformed document + + Bug #101526 + + poppler/Stream.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 112b8ab16128c6e7f80fe7c1890f7b63abd85cce +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 20 23:51:16 2017 +0200 + + Fix crash in broken documents + + Fixes bug #101525 + + poppler/JBIG2Stream.cc | 8 ++++++++ + 1 file changed, 8 insertions(+) + +commit 4e68bf998f886cab8a45fa315164d8ba7aa0dee4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 20 23:43:23 2017 +0200 + + Fix crash on broken documents + + Fixes bug #101524 + + poppler/JBIG2Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 558cdb4a4efbb2227f4009f5d87cdd94bfb40107 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Jun 20 23:37:26 2017 +0200 + + Fix crash in malformed documents + + Fixes bug #101523 + + poppler/GfxFont.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f7030a0176ed0ab484a401acc26072060e420679 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 19 23:45:24 2017 +0200 + + Fix crash on broken documents + + Bug #101505 + + goo/GooHash.cc | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +commit e465d36b8ecf46b80af4ac6b941ae56eb4883a89 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 19 23:35:29 2017 +0200 + + Fix crash on malformed files + + Bug #101502 + + poppler/GfxState.cc | 9 +++++++++ + 1 file changed, 9 insertions(+) + +commit e2ab2fa9d8c41e0115b2c276a2594cd2f7c217e6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Jun 19 23:18:51 2017 +0200 + + Fix crash on malformed files + + Bug #101500 + + poppler/Function.cc | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit 17e4111da1ae5c9798ca0c040bf75c01bbb72a8a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 17:47:23 2017 +0200 + + Break earlier on reaching recursion limit + + Bug #101379 + + poppler/Parser.cc | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +commit 8e1a2474c5513f7b2f4718258ca90e2d6e03f127 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 12:35:41 2017 +0200 + + pdftohmtl: Initialize rotSkewMat + + Fixes uninitialized memory read at bug #100314 + + utils/HtmlFonts.cc | 1 + + 1 file changed, 1 insertion(+) + +commit dd7b0eec87ffc389ee3ba7319442e681e19b15ba +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 12:33:35 2017 +0200 + + Remove unused constructor + + utils/HtmlFonts.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 5b05222ccd18a121ea2ae1d67b8b5d4947cdfce0 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 12:33:06 2017 +0200 + + Fix crash in malformed file + + Bug #101429 + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e1b5053e54b0ef7d6b09f3b9c97883db533d509a +Author: Even Rouault <even.rouault@spatialys.com> +Date: Fri Jun 16 00:21:53 2017 +0200 + + Fix crash on broken file + + Fixes bug #101366 + + poppler/SplashOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 9e05af3da0ce14c48f0652e01718960c6bc7b4b0 +Author: Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +Date: Wed Jun 14 23:19:48 2017 +0200 + + FormFieldButton::setState() shouldn't check the field is readOnly + + Bug #101419 + + poppler/Form.cc | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +commit 9cecd78ff12a145fd7a61d226d54fd8f9ce19638 +Merge: b5ca57db 23a2f6a2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 18:35:14 2017 +0200 + + Merge remote-tracking branch 'origin/master' into better_object + +commit 23a2f6a2492a0957489eac31b6700b4d68180bdb +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 17:47:23 2017 +0200 + + Break earlier on reaching recursion limit + + Bug #101379 + + poppler/Parser.cc | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +commit 5323bc8baf9add8c28a0a6970ab94b6386f38d14 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 12:35:41 2017 +0200 + + pdftohmtl: Initialize rotSkewMat + + Fixes uninitialized memory read at bug #100314 + + utils/HtmlFonts.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 67159370014e5cb3ef296b256bf410e0468fe71e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 12:33:35 2017 +0200 + + Remove unused constructor + + utils/HtmlFonts.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit d52bba350acb3023ebdba8537854206641cd0998 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Jun 17 12:33:06 2017 +0200 + + Fix crash in malformed file + + Bug #101429 + + poppler/Annot.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit db254b4b5b1ac2dae46b9fd5ad23af311e481489 +Author: Even Rouault <even.rouault@spatialys.com> +Date: Fri Jun 16 00:21:53 2017 +0200 + + Fix crash on broken file + + Fixes bug #101366 + + poppler/SplashOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 9fc5ed2176da68442927127bea8c427800eb244c +Author: Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +Date: Wed Jun 14 23:19:48 2017 +0200 + + FormFieldButton::setState() should check the field isn't readOnly + + Bug #101419 + + poppler/Form.cc | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +commit 5c9b08a875b07853be6c44e43ff5f7f059df666a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 27 00:09:17 2017 +0200 + + pdfunite: Fix crash with broken documents + + Sometimes we can't parse pages so check before accessing them + + Thanks to Jiaqi Peng for the report + + Fixes bugs #101153 and #101149 + + utils/pdfunite.cc | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +commit ff05069f34a00d67cdddb033f6240a3407e90057 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 23:39:38 2017 +0200 + + Poppler 0.55.0 + + CMakeLists.txt | 2 +- + NEWS | 16 ++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 21 insertions(+), 5 deletions(-) + +commit 680b3f6b80e6d342a6b6e3fe8f1953857784f737 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 23:20:56 2017 +0200 + + Update (C) + + poppler/Object.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0bf38541443cb8dee4d9a5197fdfcf91f6043a2d +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 23:20:38 2017 +0200 + + Don't forget to ship this file ^_^ + + Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit aa03a71c3a1127cffd19bb0f596c4b361a7f2269 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 22:37:23 2017 +0200 + + Fix abort in files with broken Decode arrays + + Fixes KDE bug #379835 + + poppler/GfxState.cc | 18 ++++++++++++------ + poppler/Object.h | 7 +++++++ + 2 files changed, 19 insertions(+), 6 deletions(-) + +commit 65c5a5266462244130f110599ac5d1011a04216e +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 18:42:15 2017 +0200 + + Fail by default if libopenjpeg2/1 is not available + + You can "force" to use the unmaintained JPX decoder or none at all + + CMakeLists.txt | 30 +++++++++++++++++++++++++++--- + config.h.cmake | 3 +++ + configure.ac | 29 +++++++++++++++++++++++++---- + poppler/Stream.cc | 5 +++++ + 4 files changed, 60 insertions(+), 7 deletions(-) + +commit ea6d3200ae26775dcc26ed80fad18ca51e7f7f07 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 18:08:41 2017 +0200 + + Fix openjpeg text + + We've prefered openjpeg2 over 1 for a while + + CMakeLists.txt | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit b286a6b5b1a63563263072305da04604cb022488 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun May 21 17:45:00 2017 +0200 + + Fail by default if libjpeg is not available + + You can "force" to use the unmaintained DCT decoder or none at all + + CMakeLists.txt | 29 +++++++++++++++++++++++------ + config.h.cmake | 3 +++ + configure.ac | 40 +++++++++++++++++++++++++++++++--------- + poppler/Stream.cc | 7 ++++++- + 4 files changed, 63 insertions(+), 16 deletions(-) + +commit b5ca57dbfecd9e680b3bd4b293b0eac400d24cfb +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 13 01:05:43 2017 +0200 + + Fix memory leak in XRef::constructXRef + + poppler/XRef.cc | 1 + + 1 file changed, 1 insertion(+) + +commit b21c5f7741bb0af47c64c042a8586d922d26b47a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 13 00:13:43 2017 +0200 + + Use initNullAfterMalloc since this is after a greallocn + + poppler/XRef.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e98ca09fafadbf7d37b838ed2f8953dc6a53a034 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat May 13 00:01:05 2017 +0200 + + Forgot to add my (C) here + + poppler/Rendition.h | 1 + + 1 file changed, 1 insertion(+) + +commit 47aa71cf39764135f3e3a39cbfb8efc50de1ac28 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 23:38:26 2017 +0200 + + Make Dict incRef/decRef private + + poppler/Catalog.cc | 40 +++++++++++----------------------------- + poppler/Catalog.h | 2 +- + poppler/Dict.h | 9 +++++---- + poppler/PDFDoc.cc | 37 ++++++++++++++++--------------------- + poppler/PDFDoc.h | 7 +++---- + poppler/Page.cc | 17 ++++++++--------- + poppler/Page.h | 2 +- + utils/pdfunite.cc | 12 +++++------- + 8 files changed, 50 insertions(+), 76 deletions(-) + +commit 0d7aa8c8aa491e005f78b019eff78f400764a61c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 23:10:53 2017 +0200 + + Make Array incRef/decRef private + + poppler/Array.h | 9 +++++---- + poppler/PDFDoc.cc | 14 +++++++------- + 2 files changed, 12 insertions(+), 11 deletions(-) + +commit b1f4e35fa2da8909dee07529ce1dd9445639793b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 23:03:28 2017 +0200 + + Make Stream incRef/decRef private + + Object handles it for us + + Also remove incRef/decRef from OutStream + + glib/poppler-action.cc | 2 +- + glib/poppler-attachment.cc | 15 ++++--------- + glib/poppler-media.cc | 19 +++++++---------- + poppler/FileSpec.h | 1 + + poppler/Rendition.cc | 53 + +++++++++++++++++++++++----------------------- + poppler/Rendition.h | 6 ++++-- + poppler/Stream.cc | 1 - + poppler/Stream.h | 18 ++++++---------- + 8 files changed, 50 insertions(+), 65 deletions(-) + +commit d34e5304a9094d505ffce8ec4069d4ddf2ee5950 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 22:41:03 2017 +0200 + + Get rid of another incRef() call + + poppler/Annot.cc | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +commit a7f2baa21a09454cb393dce806896e62e548f63e +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 22:38:41 2017 +0200 + + Pass the Object around instead of the Dict + + Saves an awkard incRef call + + poppler/Annot.cc | 198 + +++++++++++++++++++++++++++---------------------------- + poppler/Annot.h | 46 ++++++------- + poppler/Form.cc | 2 +- + 3 files changed, 122 insertions(+), 124 deletions(-) + +commit 0321bca7a3f6f5bd8b8f3e6ad13f4441e53c909b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 12 22:25:36 2017 +0200 + + SplashOutputDev::doUpdateFont - Fix crash on broken file + + poppler/SplashOutputDev.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit 96ff78d63d2173671d07f62910b1d85c5fc509ff +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed May 10 11:20:56 2017 +0200 + + cpp: Return nullptr if the page at index can't be fethed + + That is the same of what the glib/qt frontends do. + + Bug #100981 + + cpp/poppler-document.cpp | 13 ++++++++++++- + cpp/tests/poppler-dump.cpp | 18 +++++++++++++----- + 2 files changed, 25 insertions(+), 6 deletions(-) + +commit d83b11300386c7f0364acff06bd809e9efcbe4ca +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 9 16:08:18 2017 +0200 + + JPXStreamPrivate::init2 - Fix memory leak in broken files + + poppler/JPEG2000Stream.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 270866ebac7920503c0856a5dd1e7937ab68dd5f +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 9 14:34:57 2017 +0200 + + GfxDeviceNColorSpace::parse - Fix memory leak on broken files + + poppler/GfxState.cc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +commit 22123c836b35c1e8a1feb831899aacd991597c45 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 9 10:59:21 2017 +0200 + + TextPool::addWord - Fix memory leak on broken files + + poppler/TextOutputDev.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit d7a102f49e2ea63c1cf3ed79134ce6fc2b2c6a59 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 9 10:50:27 2017 +0200 + + FoFiType1::parse - Fix memory leak on broken files + + fofi/FoFiType1.cc | 1 + + 1 file changed, 1 insertion(+) + +commit 9773c1534668d84b8267c3e5c9d612076fa231a5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue May 9 00:38:07 2017 +0200 + + New Object API + + Implement the move operators and copy construtor + + Almost all the init() functions are gone and we just have simple + constructors now + + Also made free() public since you're not supposed to call it anymore, + unless you're being evil and malloc'ing Objects like Array/Dict/XRef + + This has a huge reaction chain, most importantly we + don't get objects by passing a pointer Object parameter, we + just get the object as a return value, which is a much clearer API + - aobj->copy(&obj); + + obj = aobj->copy(); + before I was never sure what was being copied into what + + Comes with a huge diff, I probably made some mistake in the porting + since there was lots of copy & paste involved + + cpp/poppler-document.cpp | 14 +- + cpp/poppler-page.cpp | 5 +- + glib/poppler-action.cc | 27 +- + glib/poppler-attachment.cc | 4 +- + glib/poppler-document.cc | 30 +- + glib/poppler-input-stream.cc | 10 +- + glib/poppler-input-stream.h | 4 +- + glib/poppler-movie.cc | 5 +- + glib/poppler-page.cc | 13 +- + glib/poppler-structure-element.cc | 37 +- + poppler/Annot.cc | 1779 + +++++++++++++++-------------------- + poppler/Annot.h | 27 +- + poppler/Array.cc | 34 +- + poppler/Array.h | 8 +- + poppler/CMap.cc | 12 +- + poppler/CairoFontEngine.cc | 6 +- + poppler/CairoOutputDev.cc | 5 +- + poppler/Catalog.cc | 383 +++----- + poppler/Catalog.h | 2 +- + poppler/DCTStream.cc | 8 +- + poppler/Dict.cc | 49 +- + poppler/Dict.h | 12 +- + poppler/FileSpec.cc | 133 ++- + poppler/FileSpec.h | 5 +- + poppler/FontInfo.cc | 43 +- + poppler/Form.cc | 337 +++---- + poppler/Form.h | 2 +- + poppler/Function.cc | 225 ++--- + poppler/Gfx.cc | 767 ++++++--------- + poppler/Gfx.h | 14 +- + poppler/GfxFont.cc | 350 +++---- + poppler/GfxFont.h | 4 +- + poppler/GfxState.cc | 794 ++++++---------- + poppler/Hints.cc | 25 +- + poppler/JBIG2Stream.cc | 5 +- + poppler/JPEG2000Stream.cc | 17 +- + poppler/Lexer.cc | 74 +- + poppler/Lexer.h | 7 +- + poppler/Linearization.cc | 57 +- + poppler/Link.cc | 197 ++-- + poppler/Movie.cc | 112 +-- + poppler/Movie.h | 2 +- + poppler/Object.cc | 67 +- + poppler/Object.h | 153 ++- + poppler/OptionalContent.cc | 144 +-- + poppler/Outline.cc | 49 +- + poppler/PDFDoc.cc | 371 +++----- + poppler/PDFDoc.h | 8 +- + poppler/PSOutputDev.cc | 406 +++----- + poppler/Page.cc | 192 ++-- + poppler/Page.h | 17 +- + poppler/PageLabelInfo.cc | 52 +- + poppler/PageTransition.cc | 34 +- + poppler/Parser.cc | 96 +- + poppler/Parser.h | 9 +- + poppler/PopplerCache.cc | 21 +- + poppler/PopplerCache.h | 4 +- + poppler/Rendition.cc | 169 ++-- + poppler/SecurityHandler.cc | 85 +- + poppler/Sound.cc | 40 +- + poppler/Sound.h | 5 +- + poppler/SplashOutputDev.cc | 15 +- + poppler/StdinPDFDocBuilder.cc | 7 +- + poppler/Stream.cc | 133 +-- + poppler/Stream.h | 24 +- + poppler/StructElement.cc | 244 ++--- + poppler/StructTreeRoot.cc | 74 +- + poppler/ViewerPreferences.cc | 43 +- + poppler/XRef.cc | 404 +++----- + poppler/XRef.h | 16 +- + qt4/src/poppler-annotation-helper.h | 39 +- + qt4/src/poppler-document.cc | 13 +- + qt4/src/poppler-form.cc | 7 +- + qt4/src/poppler-optcontent.cc | 17 +- + qt4/src/poppler-page.cc | 18 +- + qt4/src/poppler-private.h | 6 +- + qt4/tests/check_lexer.cpp | 63 +- + qt4/tests/check_optcontent.cpp | 114 +-- + qt5/src/poppler-annotation-helper.h | 39 +- + qt5/src/poppler-document.cc | 11 +- + qt5/src/poppler-form.cc | 5 +- + qt5/src/poppler-optcontent.cc | 17 +- + qt5/src/poppler-page.cc | 16 +- + qt5/src/poppler-private.h | 6 +- + qt5/tests/check_lexer.cpp | 91 +- + qt5/tests/check_optcontent.cpp | 114 +-- + test/pdf-fullrewrite.cc | 21 +- + utils/pdfinfo.cc | 21 +- + utils/pdftohtml.cc | 13 +- + utils/pdftotext.cc | 24 +- + utils/pdfunite.cc | 208 ++-- + 91 files changed, 3539 insertions(+), 5850 deletions(-) + +commit 3c29ded4bee5eadb829ed46af2ec92be57b0077b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 5 23:32:32 2017 +0200 + + Make Object free itself on init and destruction + + Will make for a *much* easier way to code. + + Patches with more std::move coming on top. + + Most things seem to work though i'm pretty sure some things are + broken. + + NEEDS TESTING + + poppler/Annot.cc | 3 +- + poppler/Array.cc | 5 +-- + poppler/Array.h | 4 ++- + poppler/Catalog.cc | 29 ++++++++++------- + poppler/Catalog.h | 6 ++-- + poppler/DCTStream.cc | 8 ++--- + poppler/DCTStream.h | 4 +-- + poppler/Dict.cc | 29 ++++++++--------- + poppler/Dict.h | 4 ++- + poppler/Form.cc | 1 - + poppler/Gfx.cc | 25 ++++++--------- + poppler/Movie.cc | 30 +++++++++++------- + poppler/Movie.h | 2 ++ + poppler/Object.cc | 51 +++++++++++++++++++++++++++--- + poppler/Object.h | 79 + +++++++++++++++++++++++++++++----------------- + poppler/OptionalContent.cc | 2 +- + poppler/Page.cc | 4 +-- + poppler/Page.h | 6 ++-- + poppler/Parser.cc | 4 +-- + poppler/Stream.cc | 36 ++++++++++++++------- + poppler/Stream.h | 8 ++--- + poppler/StructElement.cc | 10 ++---- + poppler/XRef.cc | 19 ++++++++--- + utils/pdfunite.cc | 4 +-- + 24 files changed, 234 insertions(+), 139 deletions(-) + +commit d73bcd3721f3b53bb97241cc53a6abf807aff782 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 5 15:12:42 2017 +0200 + + auto_ptr -> unique_ptr + + cpp/poppler-document.cpp | 25 +++++++++++++------------ + cpp/poppler-image.cpp | 9 +++++---- + cpp/poppler-page.cpp | 3 ++- + cpp/tests/poppler-dump.cpp | 9 +++++---- + cpp/tests/poppler-render.cpp | 5 +++-- + qt4/tests/check_fonts.cpp | 4 ++-- + qt4/tests/check_links.cpp | 4 ++-- + qt5/tests/check_fonts.cpp | 4 ++-- + qt5/tests/check_links.cpp | 4 ++-- + 9 files changed, 36 insertions(+), 31 deletions(-) + +commit 9ad9d92591a6389f84919ff2de3668c2b6158dc9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 5 00:57:35 2017 +0200 + + Fix memory leak in error condition + + Coverity was complaining we missed one delete in one of the error + conditions, so just made colorMap not be newer, no need to care about + deletes ;) + + poppler/Gfx.cc | 18 ++++++++---------- + 1 file changed, 8 insertions(+), 10 deletions(-) + +commit cdab9a2dc27a10c84550db28fac8dbdcdcd4d29d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri May 5 00:47:45 2017 +0200 + + Move the bits sanity checking a bit higher in the function + + Saves some time and makes the code simpler as we have to delete one + thing less + + poppler/Gfx.cc | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +commit b2545e9368a58a6987614f75d39da4568a076881 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 4 21:24:23 2017 +0200 + + Fix regression in GfxIndexedColorSpace::mapColorToBase + + The bounds check was off by one, making file from bug 100931 render + incorrectly. Bug #100931 + + poppler/GfxState.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 09000ce81397eba1eed383f730e48b92b932e0b4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu May 4 18:35:16 2017 +0200 + + Minor optimization + + Do not create a timer for every single operation since we hardly + run the + profileCommands if branch + + poppler/Gfx.cc | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +commit b21b041f7948680c03109f0c404400a9dbc4544c +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 25 19:48:24 2017 +0200 + + Fix memory leak when reconstructing broken files + + Need to free the catalog variable if we're going to fetch over + it again + + Bug #100776 + + poppler/XRef.cc | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +commit 278439531b13b0b047dbe3a75aa3f1b3407c8bd4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Apr 25 19:42:15 2017 +0200 + + Fix memory leak (and probably logic bug) parsing broken XRef entries + + Don't need to get obj1 again to ask if it's an int64 instead of an int + + Bug #100775 + + poppler/XRef.cc | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit 478be219772a6c298baad568da3643895cd50d35 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 21 16:29:44 2017 +0200 + + Poppler 0.54 + + CMakeLists.txt | 2 +- + NEWS | 14 ++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + glib/CMakeLists.txt | 2 +- + glib/Makefile.am | 2 +- + gtk-doc.make | 1 + + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 9 files changed, 22 insertions(+), 7 deletions(-) + +commit d627a38b3a25906b356413a1de29aaad9f7a0f28 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Apr 21 16:03:49 2017 +0200 + + Update (C) + + poppler/XRef.cc | 2 +- + qt5/src/poppler-private.h | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +commit 3a13817da1fff5244267bbc7dee178ac665de4e0 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Fri Apr 21 19:23:07 2017 +0930 + + pdfimages: don't fail listing if inline image data contains 'EI' + + Normally when listing images we don't read the image data. But for + inline images we should read the image data to advance the stream + position to the end of the image data. If we don't advance the stream + position and the image data happens to contain 'EI', Gfx will resume + reading the content stream from the middle of the image data. + + Bug 100737 + + utils/ImageOutputDev.cc | 61 + ++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 45 insertions(+), 16 deletions(-) + +commit e3779c849c86685c9bc294af407b364daf4b2202 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sat Apr 8 09:56:59 2017 +0200 + + glib: Fix return value in API doc comment of + poppler_movie_get_play_mode + + glib/poppler-movie.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit cc7809e73c71e0e6b7db29dc8a12cfb573448b77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Apr 5 23:18:52 2017 +0200 + + Make XRef reconstruction a bit better + + Also detect streams whose endstream is on the middle of a line and + not only at the beginning + + Bug #100509 + + poppler/XRef.cc | 30 +++++++++++++++++++----------- + 1 file changed, 19 insertions(+), 11 deletions(-) + +commit 2bbd110113f789c56609b3288258f667e0f3851a +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Apr 2 15:49:48 2017 +0200 + + glib-demo: Show play mode in movie properties view + + glib/demo/utils.c | 3 +++ + 1 file changed, 3 insertions(+) + +commit dad9b36e0e91524e8e342cf924026c37fcb1730e +Author: Francesco Poli (wintermute) <invernomuto@paranoici.org> +Date: Sun Apr 2 15:28:20 2017 +0200 + + glib: Expose movie play mode + + With this patch the movie play mode can be queried via the glib + interface. An enum value is obtained that reports whether the movie + should be played once, in loop, and so forth... + + https://bugs.freedesktop.org/show_bug.cgi?id=99625 + + glib/poppler-movie.cc | 35 + +++++++++++++++++++++++++++++++++++ + glib/poppler-movie.h | 31 ++++++++++++++++++++++++++----- + glib/reference/poppler-sections.txt | 4 ++++ + 3 files changed, 65 insertions(+), 5 deletions(-) + +commit 0dbec24428d96ae78be8ca06b230d68cde445614 +Author: Christoph Cullmann <cullmann@kde.org> +Date: Wed Mar 22 23:45:41 2017 +0100 + + qt5: Compile with -DQT_NO_CAST_FROM_BYTEARRAY + + Bug #100311 + + qt5/src/poppler-private.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 7ba4eb3ac3f23236e3df1ef992160d702dc5e4e9 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 22 23:42:57 2017 +0100 + + Poppler 0.53 + + CMakeLists.txt | 4 ++-- + NEWS | 18 ++++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + poppler/Makefile.am | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/CMakeLists.txt | 2 +- + qt5/src/Doxyfile | 2 +- + qt5/src/Makefile.am | 2 +- + 9 files changed, 27 insertions(+), 9 deletions(-) + +commit 411c963a9fe7d0d51bc96f046792688a020bfc66 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Mar 19 12:40:37 2017 +0100 + + Update (C) + + goo/PNGWriter.cc | 2 +- + goo/PNGWriter.h | 2 +- + goo/TiffWriter.cc | 2 +- + goo/TiffWriter.h | 2 +- + poppler/GfxState.h | 2 +- + utils/ImageOutputDev.cc | 2 +- + utils/ImageOutputDev.h | 2 +- + 7 files changed, 7 insertions(+), 7 deletions(-) + +commit 96333f6dcd93afadea35f9301c7a919545037ed4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 8 23:33:00 2017 +0100 + + Add override markers + + cmake/modules/PopplerMacros.cmake | 4 + + fofi/FoFiIdentifier.cc | 42 +-- + fofi/FoFiTrueType.h | 2 +- + fofi/FoFiType1.h | 2 +- + glib/poppler-cached-file-loader.h | 4 +- + glib/poppler-input-stream.h | 34 +-- + goo/JpegWriter.h | 10 +- + goo/NetPBMWriter.h | 8 +- + goo/PNGWriter.h | 8 +- + goo/TiffWriter.h | 10 +- + poppler/Annot.h | 50 ++-- + poppler/CairoFontEngine.h | 6 +- + poppler/CairoOutputDev.cc | 2 +- + poppler/CairoOutputDev.h | 344 +++++++++++----------- + poppler/DCTStream.h | 18 +- + poppler/Decrypt.h | 24 +- + poppler/FlateEncoder.h | 16 +- + poppler/Form.h | 18 +- + poppler/Function.h | 52 ++-- + poppler/GfxFont.h | 20 +- + poppler/GfxState.cc | 2 +- + poppler/GfxState.h | 366 + +++++++++++------------ + poppler/JBIG2Stream.cc | 16 +- + poppler/JBIG2Stream.h | 22 +- + poppler/JPEG2000Stream.h | 24 +- + poppler/Link.h | 66 ++--- + poppler/LocalPDFDocBuilder.h | 5 +- + poppler/MarkedContentOutputDev.h | 22 +- + poppler/PSOutputDev.cc | 16 +- + poppler/PSOutputDev.h | 142 ++++----- + poppler/PopplerCache.cc | 2 +- + poppler/PreScanOutputDev.h | 110 +++---- + poppler/SecurityHandler.h | 30 +- + poppler/SplashOutputDev.cc | 2 +- + poppler/SplashOutputDev.h | 210 ++++++------- + poppler/StdinCachedFile.h | 5 +- + poppler/StdinPDFDocBuilder.h | 5 +- + poppler/Stream.h | 422 + +++++++++++++-------------- + poppler/TextOutputDev.cc | 38 +-- + poppler/TextOutputDev.h | 46 +-- + poppler/XRef.cc | 2 +- + poppler/XRef.h | 12 +- + qt4/CMakeLists.txt | 3 + + qt4/src/poppler-annotation.h | 8 +- + qt4/src/poppler-link.h | 2 +- + qt5/demos/abstractinfodock.h | 6 +- + qt5/demos/embeddedfiles.h | 6 +- + qt5/demos/fonts.h | 4 +- + qt5/demos/info.h | 4 +- + qt5/demos/metadata.h | 4 +- + qt5/demos/navigationtoolbar.h | 6 +- + qt5/demos/optcontent.h | 6 +- + qt5/demos/pageview.h | 6 +- + qt5/demos/permissions.h | 4 +- + qt5/demos/thumbnails.h | 4 +- + qt5/demos/toc.h | 4 +- + qt5/demos/viewer.h | 2 +- + qt5/src/ArthurOutputDev.cc | 2 +- + qt5/src/ArthurOutputDev.h | 90 +++--- + qt5/src/poppler-annotation.cc | 56 ++-- + qt5/src/poppler-annotation.h | 84 +++--- + qt5/src/poppler-form.h | 16 +- + qt5/src/poppler-link-extractor-private.h | 10 +- + qt5/src/poppler-link.h | 24 +- + qt5/src/poppler-optcontent.h | 18 +- + qt5/src/poppler-qiodeviceoutstream-private.h | 10 +- + qt5/src/poppler-qt5.h | 6 +- + qt5/tests/stress-threads-qt5.cpp | 4 +- + qt5/tests/test-password-qt5.cpp | 4 +- + qt5/tests/test-poppler-qt5.cpp | 6 +- + splash/SplashFTFont.h | 12 +- + splash/SplashFTFontFile.h | 6 +- + splash/SplashPattern.h | 12 +- + test/gtk-test.cc | 6 +- + utils/HtmlOutputDev.h | 56 ++-- + utils/ImageOutputDev.h | 62 ++-- + utils/pdftohtml.cc | 12 +- + 77 files changed, 1404 insertions(+), 1400 deletions(-) + +commit da490581b1b4d50efdba1e25115697e17bb0ef51 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Mar 8 22:07:34 2017 +0100 + + Compile in C++11 mode + + I tried using AX_CXX_COMPILE_STDCXX_11 for the autotools side but + could not get it to fill CXXFLAGS or any other variable i could find, + help welcome + + CMakeLists.txt | 4 +++- + configure.ac | 1 + + 2 files changed, 4 insertions(+), 1 deletion(-) + +commit aa8633267d1d0e2079bb4a2b82bc7b36a4d306f5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 6 22:45:52 2017 +0100 + + pdfinfo: Fix memory leak when printing JS + + utils/JSInfo.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit d30e66cf39ef69a81bdd91e21203c876f38d9a09 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 6 22:43:27 2017 +0100 + + pdfinfo: fix leak when printing JS + + utils/JSInfo.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit a7632c5db6875828500dce7c984ec933d5349f26 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 6 22:34:20 2017 +0100 + + pdftohtml: fix small memory leak when constructing some filenames + + utils/HtmlOutputDev.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +commit 8ebec831c2abea9f13761474990c0d94346c1a35 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Mar 6 22:24:06 2017 +0100 + + SplashOutputDev: Fix memory leak when rendering images with colormap + and matte color + + poppler/SplashOutputDev.cc | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit cfaeeadbc642a297486481d9efd6068fd9ef7ea3 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Mar 4 10:54:29 2017 +1030 + + pdfimages: support 16bpc png and tiff images + + bug 99988 + + goo/PNGWriter.cc | 4 ++++ + goo/PNGWriter.h | 3 ++- + goo/TiffWriter.cc | 6 ++++++ + goo/TiffWriter.h | 3 ++- + poppler/GfxState.h | 4 ++++ + utils/ImageOutputDev.cc | 38 +++++++++++++++++++++++++++++++++++++- + utils/ImageOutputDev.h | 1 + + 7 files changed, 56 insertions(+), 3 deletions(-) + +commit 1b0653ce395242547b2b34b99034a19cd2d3ea6b +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 2 01:00:12 2017 +0100 + + Qt5: Expose Form additional actions + + qt5/src/poppler-form.cc | 20 ++++++++++++++++++++ + qt5/src/poppler-form.h | 19 +++++++++++++++++++ + 2 files changed, 39 insertions(+) + +commit a4c6433c423bd0dcc5056d9ee0375188fea9a0bc +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 2 00:56:43 2017 +0100 + + Update (C) of previous commit + + poppler/Form.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 0151e6e3824a6db907d871a2e56f5c20c001b588 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 2 00:56:27 2017 +0100 + + Qt5: expose form calculate order + + qt5/src/poppler-document.cc | 18 +++++++++++++++++- + qt5/src/poppler-qt5.h | 9 ++++++++- + 2 files changed, 25 insertions(+), 2 deletions(-) + +commit 0ae3d40a79c25feb5cb9bce6fc8cc48c30bfd1b6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 2 00:52:21 2017 +0100 + + Parse AcroForm CO (calculateOrder) + + poppler/Form.cc | 19 +++++++++++++++++++ + poppler/Form.h | 4 ++++ + 2 files changed, 23 insertions(+) + +commit bbfc56b3c9a1e613e6db008a56c9c3333ae1427a +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Mar 2 00:45:44 2017 +0100 + + Make FormWidget* setters ignore isReadOnly + + isReadOnly is for the user but poppler needs to be able to set the + value for example for fields whose value is autocalculated + + poppler/Form.cc | 23 +---------------------- + 1 file changed, 1 insertion(+), 22 deletions(-) + +commit f853145556a61a3d1104d6fd62261924d9fc9e50 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Feb 19 23:25:47 2017 +0100 + + There's no config file + + poppler/GlobalParams.h | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit c7a7c34fcb875414eb3092df84f8e8e8e523648d +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Feb 15 23:26:10 2017 +0100 + + Poppler 0.52.0 + + CMakeLists.txt | 2 +- + NEWS | 16 ++++++++++++++++ + configure.ac | 2 +- + cpp/Doxyfile | 2 +- + qt4/src/Doxyfile | 2 +- + qt5/src/Doxyfile | 2 +- + 6 files changed, 21 insertions(+), 5 deletions(-) + commit baad9bd0406f63cffa8054c5831ccc3cb5d207e3 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Feb 15 23:05:55 2017 +0100 @@ -2301,7 +6396,7 @@ Date: Wed Mar 2 00:49:00 2016 +0100 1 file changed, 3 insertions(+), 2 deletions(-) commit 9d33825e6f6167f07b2739645b93249b2bc043da -Merge: a8853b1 f3e3ebe +Merge: a8853b1d f3e3ebe5 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Mar 2 00:37:11 2016 +0100 @@ -6231,7 +10326,7 @@ Date: Sun Sep 14 11:45:12 2014 +0200 1 file changed, 1 insertion(+) commit 8ce31485faa26994c52f4d032cc5a8355aba23d1 -Merge: 4589ce1 303287e +Merge: 4589ce17 303287eb Author: Albert Astals Cid <aacid@kde.org> Date: Fri Sep 26 00:40:43 2014 +0200 @@ -6271,7 +10366,7 @@ Date: Fri Sep 12 19:22:20 2014 +0200 1 file changed, 4 insertions(+), 1 deletion(-) commit fe67324d450c356b7c876cf50da705156112513a -Merge: e62e18e f74a596 +Merge: e62e18e1 f74a5964 Author: Albert Astals Cid <aacid@kde.org> Date: Thu Aug 21 21:39:52 2014 +0200 @@ -6378,7 +10473,7 @@ Date: Fri Aug 1 07:51:10 2014 +0200 1 file changed, 1 insertion(+), 4 deletions(-) commit b72a534d6c7d8bc026812b68f9d9ac6bf9a2200a -Merge: f2e4154 ef3f758 +Merge: f2e4154e ef3f7585 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Aug 3 01:06:57 2014 +0200 @@ -6532,7 +10627,7 @@ Date: Mon Jul 21 00:29:28 2014 +0200 4 files changed, 38 insertions(+), 6 deletions(-) commit ce782112746f629a8e7be6f2daf6ece6ab19917d -Merge: 2c0cb68 26372cf +Merge: 2c0cb689 26372cfa Author: Albert Astals Cid <aacid@kde.org> Date: Sun Jul 20 20:35:13 2014 +0200 @@ -6591,7 +10686,7 @@ Date: Thu Jul 17 07:33:10 2014 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 2c0cb689910e8579bf428b3999bcac0cb27b0e51 -Merge: 0b639cd 1161e72 +Merge: 0b639cd2 1161e728 Author: Albert Astals Cid <aacid@kde.org> Date: Sat Jul 12 17:21:07 2014 +0200 @@ -6619,7 +10714,7 @@ Date: Sat Jul 12 08:35:45 2014 +0200 1 file changed, 5 insertions(+), 2 deletions(-) commit 0b639cd2ac1071f5b741031a78d8e2bc18d2b7d7 -Merge: bb16c71 a5ad55b +Merge: bb16c716 a5ad55b7 Author: Albert Astals Cid <aacid@kde.org> Date: Fri Jul 11 00:32:46 2014 +0200 @@ -6684,7 +10779,7 @@ Date: Sat Jun 7 12:00:52 2014 +0200 2 files changed, 1 insertion(+), 19 deletions(-) commit 74c72223cf609e7c24594f95cab6f9865ad562ac -Merge: f8f7b3a 47a947f +Merge: f8f7b3a6 47a947f1 Author: Albert Astals Cid <aacid@kde.org> Date: Fri Jul 11 00:23:04 2014 +0200 @@ -6702,7 +10797,7 @@ Date: Thu Jun 19 10:11:21 2014 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit f8f7b3a61bc7eb1e569c25a630b5e127b5dcae62 -Merge: 805ff76 aa6205d +Merge: 805ff761 aa6205d1 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Jul 9 00:23:22 2014 +0200 @@ -6835,7 +10930,7 @@ Date: Thu Jun 19 19:57:31 2014 +0200 2 files changed, 2 insertions(+), 1 deletion(-) commit 8a5e59c6ea7ccd0ecbdb4b37bf3fe4e74e1c0e8e -Merge: 1b70533 310fbee +Merge: 1b705331 310fbeec Author: Albert Astals Cid <aacid@kde.org> Date: Wed Jun 18 00:37:03 2014 +0200 @@ -7026,7 +11121,7 @@ Date: Sun Jun 8 12:57:25 2014 +0200 3 files changed, 22 insertions(+), 6 deletions(-) commit 2dd9b95fd910023a7d9d23f2c2e41dcab91d3c31 -Merge: fed71eb b36d27b +Merge: fed71ebd b36d27b4 Author: Albert Astals Cid <aacid@kde.org> Date: Fri Jun 6 21:43:49 2014 +0200 @@ -7113,7 +11208,7 @@ Date: Sun May 11 18:31:10 2014 +0200 8 files changed, 137 insertions(+), 10 deletions(-) commit d2892cd893e4379914a08e66682ed5c423743a41 -Merge: 0844220 7e9fc61 +Merge: 08442203 7e9fc61e Author: Albert Astals Cid <aacid@kde.org> Date: Wed May 7 22:27:41 2014 +0200 @@ -7134,7 +11229,7 @@ Date: Wed May 7 22:25:59 2014 +0200 1 file changed, 4 insertions(+), 1 deletion(-) commit 0844220347f984c3d9b04fe53e690ee0e8c74afe -Merge: 84278d8 0a6c1ff +Merge: 84278d8a 0a6c1ff7 Author: Albert Astals Cid <aacid@kde.org> Date: Wed May 7 21:56:07 2014 +0200 @@ -7155,7 +11250,7 @@ Date: Wed May 7 21:54:46 2014 +0200 3 files changed, 162 insertions(+), 4 deletions(-) commit 84278d8adbb1f6e9a28588fcb4db30c9ef70adde -Merge: 7b94b11 5b2cdef +Merge: 7b94b119 5b2cdef4 Author: Albert Astals Cid <aacid@kde.org> Date: Sun May 4 22:21:25 2014 +0200 @@ -7173,7 +11268,7 @@ Date: Sun May 4 22:20:30 2014 +0200 1 file changed, 2 insertions(+), 1 deletion(-) commit 7b94b119f07713af7b8b9f1ac3ea3f1d35c1e240 -Merge: c859d2b bae836c +Merge: c859d2b8 bae836cd Author: Albert Astals Cid <aacid@kde.org> Date: Sun May 4 16:21:24 2014 +0200 @@ -7413,7 +11508,7 @@ Date: Sun Apr 6 15:14:50 2014 +0200 1 file changed, 2 insertions(+), 1 deletion(-) commit 07621ebbda8ab85cf4cd76a6092efc67aa14454d -Merge: 8d3a2c9 9fcd46a +Merge: 8d3a2c9d 9fcd46ac Author: Pino Toscano <pino@kde.org> Date: Sat Apr 5 15:49:31 2014 +0200 @@ -9001,7 +13096,7 @@ Date: Fri Jan 3 00:29:28 2014 +0100 1 file changed, 4 insertions(+), 4 deletions(-) commit 381ae2877acace4e8908b07ee5fb442bc19bf814 -Merge: 64100e7 a2f0e4b +Merge: 64100e7f a2f0e4b1 Author: Albert Astals Cid <aacid@kde.org> Date: Fri Jan 3 00:04:29 2014 +0100 @@ -9093,7 +13188,7 @@ Date: Fri Dec 20 20:25:26 2013 +0100 1 file changed, 7 insertions(+), 1 deletion(-) commit 8e24fcc0d296e07327e9cbe297f627bfc6471ee3 -Merge: 85efba3 b02f873 +Merge: 85efba38 b02f8731 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Dec 18 21:51:57 2013 +0100 @@ -9270,7 +13365,7 @@ Date: Tue Dec 10 20:14:39 2013 +0100 5 files changed, 82 insertions(+), 20 deletions(-) commit f77bc21813ae7234ec4ce94ce4e92230fe5c174a -Merge: 06e9dc9 58e04a0 +Merge: 06e9dc91 58e04a08 Author: Albert Astals Cid <aacid@kde.org> Date: Sat Dec 7 16:56:11 2013 +0000 @@ -9721,7 +13816,7 @@ Date: Mon Oct 28 22:41:41 2013 -0700 1 file changed, 15 insertions(+), 55 deletions(-) commit 770a7ac9833a3c4f4f0399093272d4d0bdc7923b -Merge: e7a0f2b 9ae29c7 +Merge: e7a0f2b9 9ae29c7a Author: Albert Astals Cid <aacid@kde.org> Date: Thu Nov 21 23:58:29 2013 +0100 @@ -9805,7 +13900,7 @@ Date: Sun Nov 17 23:30:14 2013 -0800 4 files changed, 80 insertions(+) commit c01cee165392ba8297e4168111a66d2acb272a99 -Merge: 07c2554 47605a8 +Merge: 07c25548 47605a8a Author: Albert Astals Cid <aacid@kde.org> Date: Mon Nov 18 22:58:28 2013 +0100 @@ -9871,7 +13966,7 @@ Date: Fri Nov 15 20:35:12 2013 +0100 1 file changed, 4 insertions(+), 2 deletions(-) commit 4da94680d4d2d6b1bd3351d476a20f9c7ae565bc -Merge: 3ea3d7c 78c407a +Merge: 3ea3d7c6 78c407ac Author: Albert Astals Cid <aacid@kde.org> Date: Fri Nov 15 20:27:00 2013 +0100 @@ -9959,7 +14054,7 @@ Date: Fri Nov 15 19:55:19 2013 +0100 1 file changed, 4 insertions(+), 2 deletions(-) commit 33e703ac9bb6cf69664d6c6fddd3bebd56336074 -Merge: 8294d18 7c74bcc +Merge: 8294d18e 7c74bccd Author: Albert Astals Cid <aacid@kde.org> Date: Fri Nov 15 19:50:10 2013 +0100 @@ -10095,7 +14190,7 @@ Date: Sat Oct 26 18:48:50 2013 +0200 2 files changed, 2 insertions(+), 2 deletions(-) commit 9f09b9596f1fc52481914019d68c8f9b85b5c438 -Merge: bd893d4 61f79b8 +Merge: bd893d4a 61f79b84 Author: Albert Astals Cid <aacid@kde.org> Date: Thu Oct 24 01:03:02 2013 +0200 @@ -10117,7 +14212,7 @@ Date: Thu Oct 24 00:54:56 2013 +0200 1 file changed, 30 insertions(+), 1 deletion(-) commit bd893d4a543a6cc3a525655f37def38440944f28 -Merge: 93e8b05 daa0990 +Merge: 93e8b05f daa0990a Author: Albert Astals Cid <aacid@kde.org> Date: Thu Oct 10 02:19:34 2013 +0200 @@ -10314,7 +14409,7 @@ Date: Tue Oct 1 22:57:55 2013 +0200 2 files changed, 113 insertions(+) commit 9bc8f3240698d5a8ae4c0129e768840664d28c22 -Merge: a2742c8 e2fe851 +Merge: a2742c8f e2fe8513 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Oct 1 19:19:32 2013 +0200 @@ -10333,7 +14428,7 @@ Date: Tue Oct 1 19:15:08 2013 +0200 1 file changed, 46 insertions(+), 6 deletions(-) commit a2742c8fce0594ccbdb036dd0c29c6e15d2229f3 -Merge: 6b30a52 06dabe1 +Merge: 6b30a521 06dabe1e Author: Albert Astals Cid <aacid@kde.org> Date: Mon Sep 30 19:32:41 2013 +0200 @@ -10363,7 +14458,7 @@ Date: Fri Sep 27 12:39:00 2013 +0200 1 file changed, 1 insertion(+) commit 6b30a5214e39993025cf2fb9f221e1360de7fa9c -Merge: 4966b6f dc344b4 +Merge: 4966b6f4 dc344b41 Author: Albert Astals Cid <aacid@kde.org> Date: Sat Sep 21 10:38:45 2013 +0200 @@ -10379,7 +14474,7 @@ Date: Sat Sep 21 10:37:30 2013 +0200 1 file changed, 7 insertions(+) commit 4966b6f4193cc9d13f63e92bdc2aac0c8b78298d -Merge: 0f074b1 1e612d3 +Merge: 0f074b16 1e612d33 Author: Albert Astals Cid <aacid@kde.org> Date: Sat Sep 21 10:15:28 2013 +0200 @@ -10397,7 +14492,7 @@ Date: Sat Sep 21 10:10:16 2013 +0200 1 file changed, 3 insertions(+), 2 deletions(-) commit 0f074b16317d874fe58d7042f8434282786ca757 -Merge: d277432 b8682d8 +Merge: d2774325 b8682d86 Author: Pino Toscano <pino@kde.org> Date: Mon Sep 16 19:53:10 2013 +0200 @@ -10666,7 +14761,7 @@ Date: Sun Aug 25 20:13:12 2013 +0200 4 files changed, 355 insertions(+), 17 deletions(-) commit d006ac567e59e82c4c6cb42c5e429a4aa516ac0b -Merge: d391af7 ed3585e +Merge: d391af7e ed3585ef Author: Albert Astals Cid <aacid@kde.org> Date: Sun Aug 25 19:36:33 2013 +0200 @@ -10745,7 +14840,7 @@ Date: Sat Aug 3 09:05:21 2013 +0930 14 files changed, 322 insertions(+), 1 deletion(-) commit c2453fc1307ebb222747f976e1311ecc5e99abfa -Merge: 3bb8c2e 70298a0 +Merge: 3bb8c2e3 70298a02 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Aug 20 19:53:17 2013 +0200 @@ -10764,7 +14859,7 @@ Date: Tue Aug 20 19:46:01 2013 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 3bb8c2e34039cf473bf72ed9dab55664deab3ab7 -Merge: 71c1d16 fc78330 +Merge: 71c1d162 fc783300 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Aug 20 00:41:13 2013 +0200 @@ -10784,14 +14879,14 @@ Date: Tue Aug 20 00:37:56 2013 +0200 1 file changed, 19 insertions(+), 11 deletions(-) commit 71c1d162477a243db07b62ef3c056a2946f8986e -Merge: 7d1de78 678c767 +Merge: 7d1de78a 678c7675 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Aug 18 16:41:20 2013 +0200 Merge remote-tracking branch 'origin/poppler-0.24' commit 7d1de78ad79162217ee0ca6c2e99ce51017a327d -Merge: 7e0d969 fbea224 +Merge: 7e0d969d fbea2241 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Aug 18 16:40:34 2013 +0200 @@ -10842,7 +14937,7 @@ Date: Sat Aug 17 01:32:38 2013 +0200 1 file changed, 2 insertions(+), 6 deletions(-) commit 7e0d969dc2439637ab16e609df8223504316f87d -Merge: 6efc0c7 ef64206 +Merge: 6efc0c7a ef642065 Author: Albert Astals Cid <aacid@kde.org> Date: Sat Aug 17 01:13:30 2013 +0200 @@ -10940,7 +15035,7 @@ Date: Tue Aug 13 19:39:30 2013 +0200 2 files changed, 27 insertions(+), 2 deletions(-) commit 8a1740b0b6ee4b217ecbe9d0046e4afa491e9f17 -Merge: b27588c c3f953d +Merge: b27588c4 c3f953dc Author: Albert Astals Cid <aacid@kde.org> Date: Mon Aug 12 22:47:44 2013 +0200 @@ -10965,7 +15060,7 @@ Date: Mon Aug 12 22:42:13 2013 +0200 1 file changed, 3 insertions(+), 3 deletions(-) commit b8b5773386ee4f57e72c2b867421cdff8a2eab5a -Merge: 5f9d385 62d079b +Merge: 5f9d385d 62d079b4 Author: Albert Astals Cid <aacid@kde.org> Date: Thu Aug 8 20:47:05 2013 +0200 @@ -10985,7 +15080,7 @@ Date: Thu Aug 8 20:45:08 2013 +0200 1 file changed, 6 insertions(+), 9 deletions(-) commit 5f9d385dbec3148614b84ae24cae47177e18dbfc -Merge: af450a8 86dbc5f +Merge: af450a88 86dbc5f6 Author: Albert Astals Cid <aacid@kde.org> Date: Thu Aug 8 20:41:25 2013 +0200 @@ -11590,7 +15685,7 @@ Date: Wed Jun 26 11:33:55 2013 +0200 1 file changed, 4 insertions(+), 4 deletions(-) commit e27c1057caf4d878a0dc43c92c9e0b565db8fe40 -Merge: c55b577 ee8cfbc +Merge: c55b577c ee8cfbc7 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Jun 25 19:17:13 2013 +0200 @@ -12044,7 +16139,7 @@ Date: Thu May 16 16:16:32 2013 +0200 1 file changed, 18 insertions(+) commit 07992075a6d1d29db57f997f67d5a4a6deacbbb4 -Merge: 4a0bd6f 25f453e +Merge: 4a0bd6fd 25f453ef Author: Albert Astals Cid <aacid@kde.org> Date: Sun Jun 9 12:17:53 2013 +0200 @@ -12090,7 +16185,7 @@ Date: Sun Jun 9 12:08:06 2013 +0200 1 file changed, 2 insertions(+), 1 deletion(-) commit 4a0bd6fdb2e9e3c589e1bdb282e7c2bfca8567b1 -Merge: bbd27c9 17a16a2 +Merge: bbd27c92 17a16a27 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Jun 9 12:06:10 2013 +0200 @@ -12309,7 +16404,7 @@ Date: Fri May 31 12:24:55 2013 +0200 1 file changed, 2 insertions(+), 2 deletions(-) commit 01a825f3f9f5dcf686fc123d2cf80b9c525d0d89 -Merge: a57f937 b4b1310 +Merge: a57f9378 b4b13102 Author: Albert Astals Cid <aacid@kde.org> Date: Sat Jun 1 13:47:29 2013 +0200 @@ -12370,7 +16465,7 @@ Date: Mon May 27 23:40:07 2013 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 30282d3fdbbb3029d9a0f838b2cd979bb962235c -Merge: 61f6658 56044ef +Merge: 61f66588 56044ef4 Author: Albert Astals Cid <aacid@kde.org> Date: Mon May 27 00:20:12 2013 +0200 @@ -12431,7 +16526,7 @@ Date: Mon May 20 00:09:45 2013 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 71d327194293cb3d1a0e274eaf4451c7afe81e8a -Merge: 7b2df1f 6a98b56 +Merge: 7b2df1f9 6a98b56f Author: Albert Astals Cid <aacid@kde.org> Date: Fri May 17 23:04:12 2013 +0200 @@ -12461,7 +16556,7 @@ Date: Fri May 17 20:56:51 2013 +0200 2 files changed, 167 insertions(+) commit 54f539b4436a1a3e0eab2ef0904c302865082982 -Merge: b3d8f51 3a6e2de +Merge: b3d8f510 3a6e2de1 Author: Albert Astals Cid <aacid@kde.org> Date: Thu May 16 21:27:47 2013 +0200 @@ -12565,7 +16660,7 @@ Date: Mon May 13 23:00:40 2013 +0200 1 file changed, 1 insertion(+) commit 30a519f21dd5df8d41a43a58b2cbd95fe657df73 -Merge: 998a9e7 0c0aef2 +Merge: 998a9e7c 0c0aef20 Author: Albert Astals Cid <aacid@kde.org> Date: Mon May 13 20:40:04 2013 +0200 @@ -12605,7 +16700,7 @@ Date: Mon May 13 19:51:52 2013 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 998a9e7c982a72b0e931304b719de40f30094d12 -Merge: 5e73cb0 73d09cd +Merge: 5e73cb05 73d09cd5 Author: Albert Astals Cid <aacid@kde.org> Date: Mon May 13 19:30:26 2013 +0200 @@ -12626,7 +16721,7 @@ Date: Mon May 13 19:28:40 2013 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 5e73cb059e27f68b329513de609d52e84d73f8af -Merge: 5e9654a b3e44fc +Merge: 5e9654a3 b3e44fc5 Author: Albert Astals Cid <aacid@kde.org> Date: Tue May 7 22:00:02 2013 +0200 @@ -12644,7 +16739,7 @@ Date: Tue May 7 21:53:31 2013 +0200 1 file changed, 2 insertions(+), 2 deletions(-) commit 5e9654a3eb28b2c8b0985545778dd0e45829f8e1 -Merge: eeecd97 a107428 +Merge: eeecd971 a107428e Author: Albert Astals Cid <aacid@kde.org> Date: Thu Apr 25 20:45:34 2013 +0200 @@ -12753,7 +16848,7 @@ Date: Sat Apr 20 16:41:56 2013 +0200 1 file changed, 19 insertions(+), 18 deletions(-) commit fd648e83e60db7157b7273ffddc02308b0c5813b -Merge: 970e9f6 53b9cec +Merge: 970e9f63 53b9cec6 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Apr 21 23:30:16 2013 +0200 @@ -12782,7 +16877,7 @@ Date: Fri Apr 12 13:26:55 2013 +0200 1 file changed, 3 insertions(+), 5 deletions(-) commit f8bf602620b3c7570f483ac66fc4d6a76a81a882 -Merge: bbd27dc 62a5b4d +Merge: bbd27dc4 62a5b4d5 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Apr 14 16:40:51 2013 +0200 @@ -12808,7 +16903,7 @@ Date: Sun Apr 14 16:37:14 2013 +0200 3 files changed, 7 insertions(+), 2 deletions(-) commit bbd27dc4ce7b24af890d80f597f74e5d7ee0215a -Merge: ea3698c 5bc0080 +Merge: ea3698cf 5bc00809 Author: Albert Astals Cid <aacid@kde.org> Date: Fri Apr 12 00:10:27 2013 +0200 @@ -12861,7 +16956,7 @@ Date: Thu Apr 11 23:22:20 2013 +0200 4 files changed, 4 insertions(+), 4 deletions(-) commit ea3698cfffc9c132081f5691287ef1fd17911b2a -Merge: fcc1468 aaaea5d +Merge: fcc14682 aaaea5d0 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Apr 10 20:42:01 2013 +0200 @@ -12880,7 +16975,7 @@ Date: Wed Apr 10 16:41:48 2013 +0200 2 files changed, 4 insertions(+), 4 deletions(-) commit fcc14682899ff4981bfece74dbc8c290a625b05c -Merge: f11e216 e6559a0 +Merge: f11e2162 e6559a0d Author: Albert Astals Cid <aacid@kde.org> Date: Sun Apr 7 17:44:12 2013 +0200 @@ -12904,7 +16999,7 @@ Date: Sun Apr 7 17:42:23 2013 +0200 4 files changed, 15 insertions(+), 6 deletions(-) commit f11e21627121c3ff81c0ec7f4d71936a2dd590c3 -Merge: e1ffa91 b9fdb0c +Merge: e1ffa910 b9fdb0cb Author: Albert Astals Cid <aacid@kde.org> Date: Sat Apr 6 23:26:54 2013 +0200 @@ -12953,7 +17048,7 @@ Date: Sat Apr 6 23:20:48 2013 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 94bee4601cbbda0e7c6205a04650e0510f198aee -Merge: 42368fb b312210 +Merge: 42368fb9 b312210b Author: Albert Astals Cid <aacid@kde.org> Date: Sat Apr 6 23:19:25 2013 +0200 @@ -13154,7 +17249,7 @@ Date: Sat Mar 9 08:44:36 2013 -0600 2 files changed, 25 insertions(+), 8 deletions(-) commit 8cbdbc64897a34beb226d4dc4c58095f10013f29 -Merge: 2bce2cf a01e2d4 +Merge: 2bce2cf2 a01e2d41 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Mar 20 22:37:06 2013 +0100 @@ -13184,7 +17279,7 @@ Date: Tue Mar 19 22:53:47 2013 +0100 2 files changed, 36 insertions(+) commit b2d07cbf0c2f94bd25e1422e366ff78031815867 -Merge: 80cf78f 3206950 +Merge: 80cf78f2 32069506 Author: Albert Astals Cid <aacid@kde.org> Date: Mon Mar 18 21:06:59 2013 +0100 @@ -13220,7 +17315,7 @@ Date: Mon Mar 18 18:15:14 2013 +0100 1 file changed, 2 insertions(+), 1 deletion(-) commit 80cf78f2020e2f4cf33ed49fe522c6861d710588 -Merge: b21780e 72c8312 +Merge: b21780e6 72c8312d Author: Adrian Johnson <ajohnson@redneon.com> Date: Mon Mar 18 20:02:08 2013 +1030 @@ -13247,7 +17342,7 @@ Date: Sat Mar 16 23:20:35 2013 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit 75849a0d7c205c048714b90883695b6bebd2298c -Merge: ec7140b 5a51812 +Merge: ec7140b3 5a51812b Author: Albert Astals Cid <aacid@kde.org> Date: Tue Mar 12 20:27:59 2013 +0100 @@ -13280,7 +17375,7 @@ Date: Mon Mar 11 19:20:06 2013 +0100 6 files changed, 22 insertions(+), 6 deletions(-) commit ec7140b3f56b034fbbc53cb8066ba01fe9f60f47 -Merge: c86062f 5db6585 +Merge: c86062f9 5db6585c Author: Albert Astals Cid <aacid@kde.org> Date: Fri Mar 8 16:41:21 2013 +0100 @@ -13314,7 +17409,7 @@ Date: Fri Mar 8 16:37:11 2013 +0100 4 files changed, 30 insertions(+), 10 deletions(-) commit c86062f982d6eb08cb27b654b6317c71ab77c692 -Merge: 677e5b2 4e142b6 +Merge: 677e5b26 4e142b60 Author: Albert Astals Cid <aacid@kde.org> Date: Mon Mar 4 20:13:36 2013 +0100 @@ -13390,7 +17485,7 @@ Date: Sun Mar 3 18:00:11 2013 +0100 14 files changed, 145 insertions(+), 237 deletions(-) commit 1f4a012f7570ffd2120e3e8c2236de5408f3dda3 -Merge: 15d4039 a766740 +Merge: 15d40392 a766740c Author: Albert Astals Cid <aacid@kde.org> Date: Fri Mar 1 19:16:52 2013 +0100 @@ -13408,7 +17503,7 @@ Date: Fri Mar 1 19:12:22 2013 +0100 1 file changed, 10 insertions(+), 4 deletions(-) commit 15d40392a29dded8a29c2dc9d7c15b402515e033 -Merge: be5d9af 39882df +Merge: be5d9af3 39882dfe Author: Albert Astals Cid <aacid@kde.org> Date: Thu Feb 28 19:46:59 2013 +0100 @@ -13467,7 +17562,7 @@ Date: Wed Feb 20 23:12:17 2013 +0100 11 files changed, 139 insertions(+), 45 deletions(-) commit 60c5e072d4b930507469e6e8c234971725a4aa26 -Merge: 0d42a6d 8d62625 +Merge: 0d42a6da 8d626256 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Feb 20 21:08:53 2013 +0100 @@ -13485,7 +17580,7 @@ Date: Wed Feb 20 21:07:10 2013 +0100 1 file changed, 2 insertions(+), 1 deletion(-) commit 0d42a6dab479d27de1ecb2b47ad3f7568b1ee638 -Merge: 7eb7880 8fb243b +Merge: 7eb78809 8fb243bf Author: Albert Astals Cid <aacid@kde.org> Date: Wed Feb 20 00:00:09 2013 +0100 @@ -13512,7 +17607,7 @@ Date: Tue Feb 19 23:11:46 2013 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit 7eb7880907cb7b6bd1032013d6ce4c49aa3525c4 -Merge: 2c84acb 1389aa4 +Merge: 2c84acbf 1389aa41 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Feb 19 22:26:37 2013 +0100 @@ -13528,7 +17623,7 @@ Date: Tue Feb 19 22:25:56 2013 +0100 1 file changed, 2 insertions(+), 2 deletions(-) commit 2c84acbfd02eeeaf0d20542798e907cb011c1e57 -Merge: 401c35b ffd33e7 +Merge: 401c35b7 ffd33e7b Author: Albert Astals Cid <aacid@kde.org> Date: Tue Feb 19 11:32:11 2013 +0100 @@ -13562,7 +17657,7 @@ Date: Mon Feb 18 22:33:07 2013 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit 94364adade4dc27e5d80bc14511d4f2b7ea4ab0d -Merge: 164805b 47f30fa +Merge: 164805b4 47f30fa9 Author: Albert Astals Cid <aacid@kde.org> Date: Mon Feb 18 20:34:34 2013 +0100 @@ -13594,7 +17689,7 @@ Date: Mon Feb 18 20:05:12 2013 +0100 6 files changed, 198 insertions(+), 160 deletions(-) commit 527b91a0ef97906041ffe57e88f0d26e1c407af0 -Merge: df35562 95609be +Merge: df355624 95609be5 Author: Albert Astals Cid <aacid@kde.org> Date: Mon Feb 18 19:49:14 2013 +0100 @@ -13613,7 +17708,7 @@ Date: Mon Feb 18 19:47:19 2013 +0100 1 file changed, 4 insertions(+), 4 deletions(-) commit df3556240d5e4b4546b3c42b29be6d2be83a2802 -Merge: 4dacd7c 5c7057c +Merge: 4dacd7cd 5c7057c6 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Feb 12 23:55:24 2013 +0100 @@ -13630,7 +17725,7 @@ Date: Tue Feb 12 23:54:47 2013 +0100 2 files changed, 10 insertions(+), 10 deletions(-) commit 4dacd7cdeb19d16fe7737c71e34904c7363c6b63 -Merge: 7f2c255 9fc4b9f +Merge: 7f2c255f 9fc4b9f7 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Feb 12 22:59:56 2013 +0100 @@ -13669,7 +17764,7 @@ Date: Tue Feb 12 22:48:40 2013 +0100 11 files changed, 110 insertions(+), 24 deletions(-) commit c2ebcbea2267f861c491c0cd6c1fbf2dc2aff7d2 -Merge: 48ed05d dca21f8 +Merge: 48ed05d9 dca21f86 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Feb 10 12:01:13 2013 +0100 @@ -14703,7 +18798,7 @@ Date: Sat Dec 1 22:34:00 2012 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit c7ae96b162e8a05269a54c31f8e7c411edc84553 -Merge: 1f279c3 b1dacd1 +Merge: 1f279c32 b1dacd1e Author: Albert Astals Cid <aacid@kde.org> Date: Sat Dec 1 21:26:24 2012 +0100 @@ -15439,7 +19534,7 @@ Date: Fri Nov 9 20:02:25 2012 +0100 8 files changed, 22 insertions(+), 8 deletions(-) commit 98b7cfd289abb53a745a88d6ec99e95df477fc8f -Merge: 40efa72 d254174 +Merge: 40efa729 d254174e Author: Albert Astals Cid <aacid@kde.org> Date: Fri Nov 9 00:38:19 2012 +0100 @@ -15679,7 +19774,7 @@ Date: Wed Oct 24 18:37:06 2012 +0200 1 file changed, 438 insertions(+), 438 deletions(-) commit 77a980472e76b568346a49057b0217111a14a4cd -Merge: 74d6217 46fb365 +Merge: 74d6217b 46fb3653 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Oct 23 00:23:53 2012 +0200 @@ -15737,7 +19832,7 @@ Date: Fri Oct 19 17:22:13 2012 +0200 1 file changed, 4 insertions(+), 2 deletions(-) commit f38194cfae8f8690bc3767cbdcf140519564366c -Merge: 80cf434 5312984 +Merge: 80cf4347 5312984b Author: Albert Astals Cid <aacid@kde.org> Date: Fri Oct 19 00:02:02 2012 +0200 @@ -15764,7 +19859,7 @@ Date: Wed Oct 17 08:27:13 2012 +0200 2 files changed, 38 insertions(+) commit 0b3ff2dc4e1ba37dd66f5913b10a9d69e31c40ce -Merge: fb5cb0f 528b64b +Merge: fb5cb0fb 528b64bb Author: Albert Astals Cid <aacid@kde.org> Date: Wed Oct 17 00:28:40 2012 +0200 @@ -16040,7 +20135,7 @@ Date: Sat Oct 6 10:26:55 2012 +0200 2 files changed, 8 insertions(+) commit 042d332c1c9f628e3bfaabf3da9e04436a8677b5 -Merge: 7b9a9f8 e044814 +Merge: 7b9a9f80 e044814c Author: Albert Astals Cid <aacid@kde.org> Date: Thu Oct 4 00:53:01 2012 +0200 @@ -16058,7 +20153,7 @@ Date: Thu Oct 4 00:51:04 2012 +0200 1 file changed, 4 insertions(+) commit 7b9a9f809d07303fe5adff9210731613df8b2adf -Merge: 3b0962c 9451b7a +Merge: 3b0962cd 9451b7a6 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Oct 3 01:24:04 2012 +0200 @@ -16076,7 +20171,7 @@ Date: Wed Oct 3 01:21:45 2012 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 3b0962cd14b15ce92c0916f58ed5ba00aebe80b0 -Merge: a9d7ea2 42908e6 +Merge: a9d7ea2e 42908e6e Author: Albert Astals Cid <aacid@kde.org> Date: Tue Oct 2 19:51:48 2012 +0200 @@ -16094,7 +20189,7 @@ Date: Tue Oct 2 19:31:04 2012 +0200 1 file changed, 8 insertions(+), 7 deletions(-) commit a9d7ea2eb549acbf6ca7e2a299ffed46ff3d8758 -Merge: 397d7b4 9bb6845 +Merge: 397d7b45 9bb68456 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Sep 26 15:31:29 2012 +0200 @@ -16115,7 +20210,7 @@ Date: Wed Sep 26 15:13:47 2012 +0200 1 file changed, 1 insertion(+) commit 397d7b4597ad4bc8ab41fd7a99078473a3c93eb0 -Merge: 6013d49 2c0f70a +Merge: 6013d49d 2c0f70af Author: Albert Astals Cid <aacid@kde.org> Date: Wed Sep 26 15:00:04 2012 +0200 @@ -16198,7 +20293,7 @@ Date: Wed Sep 26 11:48:14 2012 +0200 1 file changed, 8 insertions(+) commit 6013d49d852c58c4c23f787fd7dd64731c0918f1 -Merge: b97c28c 671df5d +Merge: b97c28c4 671df5da Author: Albert Astals Cid <aacid@kde.org> Date: Wed Sep 26 00:53:28 2012 +0200 @@ -16214,7 +20309,7 @@ Date: Wed Sep 26 00:52:32 2012 +0200 1 file changed, 3 insertions(+), 1 deletion(-) commit b97c28c42a18d1c2a8fabea52c092d948811d582 -Merge: 32bb874 f8c116f +Merge: 32bb8741 f8c116f1 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Sep 25 23:22:23 2012 +0200 @@ -16383,7 +20478,7 @@ Date: Sun Sep 16 17:53:47 2012 +0200 3 files changed, 48 insertions(+), 34 deletions(-) commit e8b6d2ac3a874dd5de166b52625fa628004ea5fe -Merge: 7cb4072 9f51baa +Merge: 7cb40726 9f51baaf Author: Albert Astals Cid <aacid@kde.org> Date: Sun Sep 16 14:08:34 2012 +0200 @@ -16408,7 +20503,7 @@ Date: Sun Sep 16 14:05:01 2012 +0200 1 file changed, 6 insertions(+), 1 deletion(-) commit 7cb40726f9e80ee2b2f27ca6ce151b46c6ec091d -Merge: e980d11 c6d7084 +Merge: e980d110 c6d7084d Author: Albert Astals Cid <aacid@kde.org> Date: Sun Sep 16 13:50:19 2012 +0200 @@ -16430,7 +20525,7 @@ Date: Sun Sep 16 13:48:51 2012 +0200 3 files changed, 131 insertions(+), 2 deletions(-) commit e980d11061c19f13c75f93506e07903b4d1c7f97 -Merge: b72c02d 3658088 +Merge: b72c02d1 36580883 Author: Albert Astals Cid <aacid@kde.org> Date: Sat Sep 15 20:41:50 2012 +0200 @@ -16603,7 +20698,7 @@ Date: Tue Sep 11 23:33:25 2012 +0200 14 files changed, 1415 insertions(+), 487 deletions(-) commit cb2ed646c4ef4161e443ee0a377d1111b3be28ff -Merge: f3a1b76 3ce4d21 +Merge: f3a1b765 3ce4d213 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Sep 11 19:29:19 2012 +0200 @@ -16679,7 +20774,7 @@ Date: Mon Sep 10 19:29:01 2012 +0200 6 files changed, 19 insertions(+), 6 deletions(-) commit 1b40cdd9f863cd3868db85b5ccfa77a8350c56d6 -Merge: 6c40a55 b3e86db +Merge: 6c40a553 b3e86dbd Author: Albert Astals Cid <aacid@kde.org> Date: Mon Sep 10 18:49:52 2012 +0200 @@ -16698,7 +20793,7 @@ Date: Sun Sep 9 23:35:45 2012 +0200 2 files changed, 14 insertions(+), 4 deletions(-) commit 6c40a553a3c8825931c59797059392fd110531cc -Merge: 17fc1bf 558a7d9 +Merge: 17fc1bfa 558a7d9b Author: Albert Astals Cid <aacid@kde.org> Date: Sun Sep 9 23:27:40 2012 +0200 @@ -16807,7 +20902,7 @@ Date: Sun Sep 9 21:15:06 2012 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 17fc1bfa8013cafe3b348f0cc07ef08bf9c7dd9a -Merge: e0118be a4f5911 +Merge: e0118be3 a4f59113 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Sep 9 12:52:49 2012 +0200 @@ -16832,7 +20927,7 @@ Date: Sun Sep 9 12:48:26 2012 +0200 1 file changed, 8 insertions(+) commit e0118be3ba38bd00fa2a9c20c5b4cd82e820ba0b -Merge: 2c41430 ccd3db5 +Merge: 2c414307 ccd3db5a Author: Albert Astals Cid <aacid@kde.org> Date: Sat Sep 8 18:15:43 2012 +0200 @@ -21346,7 +25441,7 @@ Date: Tue Feb 14 19:37:21 2012 +0100 9 files changed, 308 insertions(+), 167 deletions(-) commit b505920db6d3dac58c7e9f4f8917f4c4449b08a0 -Merge: 9250449 a631281 +Merge: 9250449a a6312817 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Feb 14 19:18:54 2012 +0100 @@ -21490,7 +25585,7 @@ Date: Mon Feb 6 19:55:07 2012 +0100 12 files changed, 26 insertions(+), 49 deletions(-) commit ea6bc19564865e04431d9154802ae7fba975a716 -Merge: e17f095 92ce79f +Merge: e17f0956 92ce79f4 Author: Albert Astals Cid <aacid@kde.org> Date: Mon Feb 6 01:18:25 2012 +0100 @@ -23215,7 +27310,7 @@ Date: Sat Sep 24 09:43:05 2011 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 718c735aed540aa49b8dde250ca886c6ad93f5b6 -Merge: 6721916 69707f0 +Merge: 6721916c 69707f0a Author: Carlos Garcia Campos <carlosgc@gnome.org> Date: Sat Sep 24 09:38:52 2011 +0200 @@ -23313,7 +27408,7 @@ Date: Sun Sep 18 18:16:14 2011 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit 6721916c92d720947b3285c85fdbe6610c6bf013 -Merge: 8456a6e e23f6b9 +Merge: 8456a6e1 e23f6b9c Author: Carlos Garcia Campos <carlosgc@gnome.org> Date: Sun Sep 18 16:31:10 2011 +0200 @@ -23435,7 +27530,7 @@ Date: Sun Sep 18 11:36:11 2011 +0200 2 files changed, 91 insertions(+), 25 deletions(-) commit 258d56ba85902a8ab50eec3fe66dd6425226fa59 -Merge: 72a7736 12c6239 +Merge: 72a77363 12c6239c Author: Carlos Garcia Campos <carlosgc@gnome.org> Date: Sun Sep 18 11:12:38 2011 +0200 @@ -25122,7 +29217,7 @@ Date: Tue Aug 30 16:21:40 2011 +0200 4 files changed, 69 insertions(+), 66 deletions(-) commit f298e7f844105f2d9a36144e59be86c341e37507 -Merge: 2a6bd7a 0ca5453 +Merge: 2a6bd7aa 0ca5453f Author: Albert Astals Cid <aacid@kde.org> Date: Tue Aug 30 16:21:58 2011 +0200 @@ -33711,7 +37806,7 @@ Date: Mon Mar 22 21:49:22 2010 +0100 1 file changed, 7 insertions(+), 2 deletions(-) commit 0819acd52a2ce74f0e176626d7b2233e10232d53 -Merge: c4ddbe8 92738eb +Merge: c4ddbe89 92738ebb Author: Pino Toscano <pino@kde.org> Date: Mon Mar 22 21:43:01 2010 +0100 @@ -35115,7 +39210,7 @@ Date: Sun Feb 21 21:06:31 2010 +0100 1 file changed, 2 insertions(+), 2 deletions(-) commit a18dab9e53a20a76eb46fa3a868fffdd3c754ce2 -Merge: fa09892 f3862f7 +Merge: fa098929 f3862f7d Author: Pino Toscano <pino@kde.org> Date: Sun Feb 21 19:56:38 2010 +0100 @@ -41537,7 +45632,7 @@ Date: Mon Dec 22 00:46:49 2008 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit bfb975466f0ff78e9e292b6af7cac66e4c331456 -Merge: 3e27892 ea3546f +Merge: 3e278925 ea3546f8 Author: Pino Toscano <pino@kde.org> Date: Mon Dec 22 00:29:38 2008 +0100 @@ -42649,7 +46744,7 @@ Date: Mon Sep 29 21:14:40 2008 +0200 1 file changed, 2 insertions(+), 1 deletion(-) commit a29984ab777c64a1cb286b667a6a91ad9b191f40 -Merge: f399afe 6865872 +Merge: f399afe6 68658721 Author: Pino Toscano <pino@kde.org> Date: Sun Sep 28 23:39:08 2008 +0200 @@ -43271,7 +47366,7 @@ Date: Tue Sep 2 19:16:55 2008 +0200 1 file changed, 3 insertions(+) commit 630aa133017d15ddc7bf96c79f43c5b60fa9749a -Merge: b2bc9b3 de82255 +Merge: b2bc9b3f de822554 Author: Pino Toscano <pino@kde.org> Date: Tue Sep 2 01:25:55 2008 +0200 @@ -43576,7 +47671,7 @@ Date: Sun Aug 24 19:25:27 2008 +0200 4 files changed, 5 insertions(+), 5 deletions(-) commit 22f6af73961686895f207fe13022a21333455862 -Merge: 12a9e42 6d6913a +Merge: 12a9e427 6d6913a7 Author: Pino Toscano <pino@kde.org> Date: Sun Aug 24 19:03:24 2008 +0200 @@ -45064,7 +49159,7 @@ Date: Sat Apr 26 18:12:51 2008 +0200 1 file changed, 2 insertions(+), 2 deletions(-) commit f9c7e8037b7165b6271ce7aea0d315053c4d66a5 -Merge: 59d33d8 f5fec4f +Merge: 59d33d8e f5fec4fd Author: Pino Toscano <pino@kde.org> Date: Sat Apr 26 18:09:59 2008 +0200 @@ -45366,7 +49461,7 @@ Date: Sat Apr 12 21:08:54 2008 +0200 1 file changed, 1 insertion(+), 1 deletion(-) commit bc2b2ffd2144f951c311e968fba4bc50b7c43ff3 -Merge: cd5afe6 bacc1dd +Merge: cd5afe6d bacc1dd9 Author: Iñigo MartÃnez <inigomartinez@gmail.com> Date: Sat Apr 12 17:40:49 2008 +0200 @@ -46270,7 +50365,7 @@ Date: Wed Mar 12 21:43:12 2008 +1030 1 file changed, 4 insertions(+), 3 deletions(-) commit 0b2c3bb25c908b07e760d824dbfe93c6051812aa -Merge: 362fe01 9c472f7 +Merge: 362fe013 9c472f76 Author: Iñigo MartÃnez <inigomartinez@gmail.com> Date: Wed Mar 12 00:23:58 2008 +0100 @@ -46311,7 +50406,7 @@ Date: Tue Mar 11 23:58:05 2008 +0100 4 files changed, 11 insertions(+), 10 deletions(-) commit d7e642732ced592362d9787bddadb7a110dcc5a5 -Merge: 3642f0c 2d6c605 +Merge: 3642f0c4 2d6c6053 Author: Iñigo MartÃnez <inigomartinez@gmail.com> Date: Tue Mar 11 23:41:59 2008 +0100 @@ -46358,7 +50453,7 @@ Date: Tue Mar 11 22:49:00 2008 +0100 2 files changed, 620 insertions(+) commit 43e5dd941d4bc35c4eebbad66c13235639e0c1a0 -Merge: aab1768 4fdd254 +Merge: aab17684 4fdd2543 Author: Albert Astals Cid <aacid@kde.org> Date: Tue Mar 11 22:31:22 2008 +0100 @@ -46445,7 +50540,7 @@ Date: Mon Mar 10 22:08:43 2008 +0100 1 file changed, 40 insertions(+), 5 deletions(-) commit 94ceb3cae79dc7786fa59fd889a87160780ed5df -Merge: 0f9e843 35f34bd +Merge: 0f9e8430 35f34bd4 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Mar 9 23:34:11 2008 +0100 @@ -46589,7 +50684,7 @@ Date: Wed Feb 27 22:56:33 2008 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit 5b2f8f21fca63508570a0c77c6f7221a322e6e57 -Merge: 7e65118 4254f12 +Merge: 7e651186 4254f123 Author: Pino Toscano <pino@kde.org> Date: Wed Feb 27 22:10:12 2008 +0100 @@ -46614,7 +50709,7 @@ Date: Wed Feb 27 22:03:17 2008 +0100 2 files changed, 39 insertions(+), 6 deletions(-) commit 4254f1237ebed09b8e1c85f935a20bde3d8f36ff -Merge: ed6c0c2 0569ae7 +Merge: ed6c0c26 0569ae76 Author: Albert Astals Cid <aacid@kde.org> Date: Wed Feb 27 20:44:27 2008 +0100 @@ -46664,7 +50759,7 @@ Date: Wed Feb 27 20:42:55 2008 +0100 4 files changed, 6 insertions(+), 6 deletions(-) commit 0569ae76b6af1723b4606af189242a23199f387d -Merge: f395531 d8eba8c +Merge: f395531a d8eba8c1 Author: Brad Hards <bradh@kde.org> Date: Thu Feb 28 06:26:09 2008 +1100 @@ -47304,7 +51399,7 @@ Date: Mon Feb 18 23:34:06 2008 +0100 5 files changed, 102 insertions(+), 6 deletions(-) commit 3c407efe9f1f0cc3f6366d3a2b6e9b687656cc95 -Merge: 51f0cea 7f4acb8 +Merge: 51f0cea0 7f4acb87 Author: Pino Toscano <pino@kde.org> Date: Mon Feb 18 21:30:42 2008 +0100 @@ -47630,7 +51725,7 @@ Date: Wed Feb 13 20:55:18 2008 +0100 1 file changed, 1 insertion(+) commit 9cfe10ab7f51d329647e102e446baaef043d8cc6 -Merge: e918729 7d65b4d +Merge: e9187292 7d65b4da Author: Pino Toscano <pino@kde.org> Date: Wed Feb 13 20:53:43 2008 +0100 @@ -47719,7 +51814,7 @@ Date: Wed Feb 13 18:42:49 2008 +0100 2 files changed, 4 insertions(+), 4 deletions(-) commit 7574cb71f24ce5b32427f243c39b6029fb58ec81 -Merge: e798802 4e45e5c +Merge: e798802f 4e45e5ca Author: Pino Toscano <pino@kde.org> Date: Wed Feb 13 01:07:31 2008 +0100 @@ -47867,7 +51962,7 @@ Date: Mon Feb 11 02:27:19 2008 +0100 3 files changed, 115 insertions(+) commit 278b33f25df418ef12798100002845a3e2ceebd3 -Merge: c730b33 fdb0a4a +Merge: c730b33f fdb0a4a2 Author: Pino Toscano <pino@kde.org> Date: Mon Feb 11 00:57:24 2008 +0100 @@ -47938,7 +52033,7 @@ Date: Sun Feb 10 01:09:57 2008 +0100 1 file changed, 3 insertions(+), 3 deletions(-) commit d3275e4263372b534c276f81d0c997ecb6675487 -Merge: c2186c1 5347a97 +Merge: c2186c18 5347a97e Author: Albert Astals Cid <aacid@kde.org> Date: Sat Feb 9 23:57:03 2008 +0100 @@ -47978,7 +52073,7 @@ Date: Sat Feb 9 18:23:59 2008 +0100 2 files changed, 37 insertions(+), 2 deletions(-) commit afb255366d56551bdc307766199bef9c5021d3ac -Merge: 8c44b17 8cb0e75 +Merge: 8c44b175 8cb0e752 Author: Pino Toscano <pino@kde.org> Date: Sat Feb 9 17:58:49 2008 +0100 @@ -48015,7 +52110,7 @@ Date: Sat Feb 9 13:37:04 2008 +0100 1 file changed, 2 insertions(+), 2 deletions(-) commit 5fb0c9d31c1abf2e6ad306c112fbd2a7c33d8772 -Merge: 2655663 2255c85 +Merge: 26556636 2255c85e Author: Carlos Garcia Campos <carlosgc@gnome.org> Date: Sat Feb 9 13:15:15 2008 +0100 @@ -48036,7 +52131,7 @@ Date: Sat Feb 9 13:14:41 2008 +0100 4 files changed, 79 insertions(+), 7 deletions(-) commit 2255c85e4939a0752083dca21984ff4398baf8d2 -Merge: 5ba9287 56c9246 +Merge: 5ba92876 56c92460 Author: Pino Toscano <pino@kde.org> Date: Sat Feb 9 12:49:45 2008 +0100 @@ -48165,7 +52260,7 @@ Date: Fri Feb 8 02:21:32 2008 +0100 3 files changed, 11 insertions(+), 11 deletions(-) commit 1aeba15b5eb9b30943259824678ebc9e4f56e870 -Merge: a489063 22d10c1 +Merge: a4890637 22d10c19 Author: Pino Toscano <pino@kde.org> Date: Fri Feb 8 01:39:16 2008 +0100 @@ -48278,7 +52373,7 @@ Date: Thu Feb 7 01:07:28 2008 +0100 1 file changed, 13 insertions(+), 13 deletions(-) commit c31990dfe50c7a0e3999e6d967699fce5ccb3339 -Merge: 7701e2a 6d58cda +Merge: 7701e2a5 6d58cda8 Author: Pino Toscano <pino@kde.org> Date: Tue Feb 5 00:38:00 2008 +0100 @@ -48305,7 +52400,7 @@ Date: Mon Feb 4 23:33:51 2008 +0100 1 file changed, 4 insertions(+), 1 deletion(-) commit aa0435f1544fe1adcf10173e34eaeaf2a7a703c7 -Merge: b43f4e9 37600b5 +Merge: b43f4e9a 37600b5e Author: Pino Toscano <pino@kde.org> Date: Mon Feb 4 20:56:53 2008 +0100 @@ -48491,7 +52586,7 @@ Date: Tue Jan 29 20:23:08 2008 +0100 4 files changed, 13 insertions(+), 8 deletions(-) commit 77b91c852ad3d5554afc03aee92a1d928f233401 -Merge: 0babb0e 0533696 +Merge: 0babb0eb 05336967 Author: Albert Astals Cid <aacid@kde.org> Date: Mon Jan 28 20:44:34 2008 +0100 @@ -48927,7 +53022,7 @@ Date: Thu Jan 10 23:51:54 2008 +0100 1 file changed, 2 insertions(+), 2 deletions(-) commit 348f4f9d9d5b0f91da6f46e0fcefec80255d4179 -Merge: 8a8a4f0 4eca2e0 +Merge: 8a8a4f01 4eca2e04 Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> Date: Sat Jan 5 23:03:06 2008 +0100 @@ -49223,7 +53318,7 @@ Date: Mon Dec 10 22:00:30 2007 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit e807f9c72c7f0c5cc0655918f676f4af54739442 -Merge: bf57117 e2ea743 +Merge: bf57117d e2ea7430 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Dec 9 18:07:30 2007 +0100 @@ -49271,7 +53366,7 @@ Date: Thu Dec 6 23:58:26 2007 +0100 1 file changed, 1 insertion(+), 1 deletion(-) commit bb0ec68f21d355081ff75aad641bc3809141e398 -Merge: 5a34cdd b925ea2 +Merge: 5a34cddf b925ea23 Author: Albert Astals Cid <aacid@kde.org> Date: Thu Dec 6 18:38:54 2007 +0100 @@ -49448,7 +53543,7 @@ Date: Thu Nov 8 23:34:07 2007 +0100 1 file changed, 15 insertions(+), 6 deletions(-) commit 944d327fd7036332a33b4ad6476ceca7a650ef6e -Merge: fb1d1f4 c340255 +Merge: fb1d1f45 c340255f Author: Albert Astals Cid <aacid@kde.org> Date: Wed Nov 7 23:52:47 2007 +0100 @@ -49496,7 +53591,7 @@ Date: Mon Nov 5 20:31:18 2007 +1100 2 files changed, 46 insertions(+), 1 deletion(-) commit 570fe464a2aae4f22d0b47cce73b8bc36b116e9f -Merge: 1c7b7a0 7875067 +Merge: 1c7b7a0c 78750679 Author: Brad Hards <bradh@kde.org> Date: Mon Nov 5 15:55:39 2007 +1100 @@ -49616,7 +53711,7 @@ Date: Sun Nov 4 14:03:35 2007 +0100 1 file changed, 8 deletions(-) commit d694e1dd042fb97fbc62046b69cafe30d6f9ea58 -Merge: ba5b31c 432e657 +Merge: ba5b31c6 432e657a Author: Albert Astals Cid <aacid@kde.org> Date: Sun Nov 4 13:26:47 2007 +0100 @@ -49745,7 +53840,7 @@ Date: Thu Oct 25 20:56:58 2007 +0200 3 files changed, 522 insertions(+), 1 deletion(-) commit 6bd637dc135045b20abf024d394538d7a3160795 -Merge: c01ab71 25b273d +Merge: c01ab714 25b273db Author: Albert Astals Cid <tsdgeos@bluebox.localdomain> Date: Tue Oct 23 23:27:01 2007 +0200 @@ -50006,7 +54101,7 @@ Date: Fri Sep 28 21:01:50 2007 +0200 5 files changed, 527 insertions(+), 4 deletions(-) commit d0c0f26d2c95232c216e3daa15e98a3aff14ac27 -Merge: 59d55f7 38d5bb1 +Merge: 59d55f73 38d5bb15 Author: Krzysztof Kowalczyk <kkowalczyk@gmail.com> Date: Tue Sep 25 03:33:52 2007 -0700 diff --git a/Build/source/libs/poppler/poppler-src/ConfigureChecks.cmake b/Build/source/libs/poppler/poppler-src/ConfigureChecks.cmake index 345f29c56fb..21bad506d68 100644 --- a/Build/source/libs/poppler/poppler-src/ConfigureChecks.cmake +++ b/Build/source/libs/poppler/poppler-src/ConfigureChecks.cmake @@ -13,15 +13,9 @@ include(CheckCSourceCompiles) check_include_files(dlfcn.h HAVE_DLFCN_H) check_include_files(fcntl.h HAVE_FCNTL_H) -check_include_files(inttypes.h HAVE_INTTYPES_H) -check_include_files(memory.h HAVE_MEMORY_H) -check_include_files(stdint.h HAVE_STDINT_H) check_include_files(stdlib.h HAVE_STDLIB_H) -check_include_files(strings.h HAVE_STRINGS_H) -check_include_files(string.h HAVE_STRING_H) check_include_files(sys/mman.h HAVE_SYS_MMAN_H) check_include_files(sys/stat.h HAVE_SYS_STAT_H) -check_include_files(sys/types.h HAVE_SYS_TYPES_H) check_include_files(unistd.h HAVE_UNISTD_H) check_function_exists(fseek64 HAVE_FSEEK64) @@ -35,10 +29,10 @@ check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) check_function_exists(localtime_r HAVE_LOCALTIME_R) check_function_exists(popen HAVE_POPEN) check_function_exists(mkstemp HAVE_MKSTEMP) -check_function_exists(mkstemps HAVE_MKSTEMPS) check_function_exists(rand_r HAVE_RAND_R) check_function_exists(strcpy_s HAVE_STRCPY_S) check_function_exists(strcat_s HAVE_STRCAT_S) +check_function_exists(strtok_r HAVE_STRTOK_R) macro(CHECK_FOR_DIR include var) check_c_source_compiles( diff --git a/Build/source/libs/poppler/poppler-src/INSTALL b/Build/source/libs/poppler/poppler-src/INSTALL index 56b077d6a0b..a38a8c009a5 100644 --- a/Build/source/libs/poppler/poppler-src/INSTALL +++ b/Build/source/libs/poppler/poppler-src/INSTALL @@ -1,236 +1,104 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free -Software Foundation, Inc. - -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - Basic Installation ================== -These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - -You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== +mkdir build +cd build +cmake .. +make +make install -By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PREFIX'. - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PREFIX', the package will -use PREFIX as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. +CMake configuration options can be set using the -D option. eg - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. + cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=release - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. -Optional Features -================= +Build Options +============= -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. +Set install prefix: - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. + -DCMAKE_INSTALL_PREFIX=<path> -Specifying the System Type -========================== +Set build type. This sets the standard compiler flags for the build +type. -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: + -DCMAKE_BUILD_TYPE=debug or -DCMAKE_BUILD_TYPE=release - CPU-COMPANY-SYSTEM +Set compiler flags: -where SYSTEM can have one of these forms: + -DCMAKE_CXX_FLAGS=<flags> or set CXXFLAGS environment variable - OS KERNEL-OS +Set linker flags: - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. + -DCMAKE_LD_FLAGS=<flags> or set LDFLAGS environment variable - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. +Optional Features +================= -Sharing Defaults -================ + -D<FEATURE>=<ON|OFF> -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. +eg -Defining Variables -================== + -DENABLE_SPLASH=ON -DBUILD_GTK_TESTS=OFF + +A list of all options can be display with the commmand: + + egrep '^ *(option|set.*STRING)' CMakeLists.txt -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: +Alternatively, the options can be edited by running "ccmake ." in the +build directory. - ./configure CC=/usr/local2/bin/gcc -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). Here is a another example: +Cross Compiling +=============== - /bin/bash ./configure CONFIG_SHELL=/bin/bash +A toolchain file is required to specify the target specific compiler +tools. Run cmake with the option: -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. + -DCMAKE_TOOLCHAIN_FILE=<Toolchain file> -`configure' Invocation -====================== +A sample toolchain for a 64-bit mingw build is shown below. Replace +/path/to/win/root with the install prefix for the target environment. -`configure' recognizes the following options to control how it operates. + set(CMAKE_SYSTEM_NAME Windows) + set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) + set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /path/to/win/root ) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + + +Debugging Options +================= -`--help' -`-h' - Print a summary of the options to `configure', and exit. +Debug Build Types +----------------- +Release build with debugging information: + -DCMAKE_BUILD_TYPE=relwithdebinfo -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. +Debug build with optimization except for some code re-ordering optimizations: + -DCMAKE_BUILD_TYPE=debug -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. +Debug build with no optimization: + -DCMAKE_BUILD_TYPE=debugfull -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. +Release build with debugging and profiling information: + -DCMAKE_BUILD_TYPE=profile -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. +Address Sanitizer +----------------- +Ensure the extra cmake modules are available (may be a separate +package) then use -DECM_ENABLE_SANITIZERS to specify the santizers. eg -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. + -DECM_ENABLE_SANITIZERS='address;leak;undefined' +Some options may only be available with clang. Use +-DCMAKE_CXX_COMPILER=clang++ to build with clang. diff --git a/Build/source/libs/poppler/poppler-src/Makefile.am b/Build/source/libs/poppler/poppler-src/Makefile.am deleted file mode 100644 index 9540b6ad321..00000000000 --- a/Build/source/libs/poppler/poppler-src/Makefile.am +++ /dev/null @@ -1,132 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 -DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --with-testdatadir=$(TESTDATADIR) - -if BUILD_SPLASH_OUTPUT -splash_subdir = splash -splash_pc_file = poppler-splash.pc -endif - -if BUILD_CAIRO_OUTPUT -cairo_pc_file = poppler-cairo.pc -endif - -if BUILD_POPPLER_GLIB -glib_subdir = glib -glib_pc_file = poppler-glib.pc -endif - -if BUILD_POPPLER_QT5 -qt5_subdir = qt5 -qt5_pc_file = poppler-qt5.pc -endif - -if BUILD_POPPLER_QT4 -qt4_subdir = qt4 -qt4_pc_file = poppler-qt4.pc -endif - - -if BUILD_POPPLER_CPP -cpp_subdir = cpp -cpp_pc_file = poppler-cpp.pc -endif - -SUBDIRS = goo fofi $(splash_subdir) poppler utils $(glib_subdir) test $(qt4_subdir) $(qt5_subdir) $(cpp_subdir) - -EXTRA_DIST = \ - README-XPDF \ - poppler.pc.in \ - poppler-uninstalled.pc.in \ - poppler-cairo.pc.in \ - poppler-cairo-uninstalled.pc.in \ - poppler-splash.pc.in \ - poppler-splash-uninstalled.pc.in \ - poppler-qt4.pc.in \ - poppler-qt4-uninstalled.pc.in \ - poppler-qt5.pc.in \ - poppler-qt5-uninstalled.pc.in \ - poppler-cpp.pc.in \ - poppler-cpp-uninstalled.pc.in - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = \ - poppler.pc \ - $(cairo_pc_file) \ - $(splash_pc_file) \ - $(glib_pc_file) \ - $(qt4_pc_file) \ - $(qt5_pc_file) \ - $(cpp_pc_file) - -# Add CMake buildsystem files here so they get added on make dist -EXTRA_DIST += \ - cpp/tests/CMakeLists.txt \ - cpp/CMakeLists.txt \ - glib/demo/CMakeLists.txt \ - glib/CMakeLists.txt \ - glib/poppler-features.h.cmake \ - qt4/src/CMakeLists.txt \ - qt4/tests/CMakeLists.txt \ - qt4/CMakeLists.txt \ - qt4/demos/CMakeLists.txt \ - qt5/src/CMakeLists.txt \ - qt5/tests/CMakeLists.txt \ - qt5/CMakeLists.txt \ - qt5/demos/CMakeLists.txt \ - test/CMakeLists.txt \ - utils/CMakeLists.txt \ - CMakeLists.txt \ - ConfigureChecks.cmake \ - cmake/modules/CheckFileOffsetBits.c \ - cmake/modules/CheckFileOffsetBits.cmake \ - cmake/modules/COPYING-CMAKE-SCRIPTS \ - cmake/modules/FindCairo.cmake \ - cmake/modules/FindFontconfig.cmake \ - cmake/modules/FindGLIB.cmake \ - cmake/modules/FindGObjectIntrospection.cmake \ - cmake/modules/FindGTK.cmake \ - cmake/modules/FindIconv.cmake \ - cmake/modules/FindLCMS.cmake \ - cmake/modules/FindLCMS2.cmake \ - cmake/modules/FindNSS3.cmake \ - cmake/modules/FindQt4.cmake \ - cmake/modules/GObjectIntrospectionMacros.cmake \ - cmake/modules/MacroBoolTo01.cmake \ - cmake/modules/MacroEnsureVersion.cmake \ - cmake/modules/MacroOptionalFindPackage.cmake \ - cmake/modules/MacroPushRequiredVars.cmake \ - cmake/modules/PopplerDefaults.cmake \ - cmake/modules/PopplerMacros.cmake \ - cmake/modules/FindLIBOPENJPEG.cmake \ - config.h.cmake \ - poppler-cairo.pc.cmake \ - poppler/poppler-config.h.cmake \ - poppler-cpp.pc.cmake \ - poppler-glib.pc.cmake \ - poppler-qt4.pc.cmake \ - poppler-qt5.pc.cmake \ - poppler-splash.pc.cmake \ - poppler.pc.cmake - - - -distclean-local: - if test "$(srcdir)" = "."; then :; else \ - rm -f ChangeLog; \ - fi - -ChangeLog: - $(AM_V_GEN) if test -d "$(srcdir)/.git"; then \ - (GIT_DIR=$(top_srcdir)/.git ./missing --run git log --stat) | fmt --split-only > $@.tmp \ - && mv -f $@.tmp $@ \ - || ($(RM) $@.tmp; \ - echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \ - (test -f $@ || echo git log is required to generate this file >> $@)); \ - else \ - test -f $@ || \ - (echo A git checkout and git log is required to generate ChangeLog >&2 && \ - echo A git checkout and git log is required to generate this file >> $@); \ - fi - -.PHONY: ChangeLog - diff --git a/Build/source/libs/poppler/poppler-src/NEWS b/Build/source/libs/poppler/poppler-src/NEWS index cf7de77bf94..283dfc423b8 100644 --- a/Build/source/libs/poppler/poppler-src/NEWS +++ b/Build/source/libs/poppler/poppler-src/NEWS @@ -1,3 +1,210 @@ +Release 0.62.0 + core: + * Stop supporting lcms1, you really want to use lcms2 :) + * Stop supporting openjpeg1, you really want to use openjpeg2 :) + * Open files that state 8 bits as third field of W. Bug #103469 + * GfxLabColorSpace::parse: Fix crash in broken documents. Bug #103582 + * Fix leak if parseDA fails + * Include glibc.h where needed + * Document the meaning of the 'type' integer of a shading + * Fix UTF test fail + * INSTALL: add debug options + + qt5: + * Add API to let the rendering process callback to get a partial rendering. Bug #103372 + + qt4: + * Remove the Qt4 frontend + + utils: + * Support unicode on windows console + * pdfsig: install man page + * sort encoding list + + glib: + * demo: fix warning + +Release 0.61.1 + core: + * CairoOutputDev: don't overflow y * stride when accessing image data + + cpp: + * Fix for corrupted image files on Windows. Bug #102494 + + build system: + * Fix incorrect paths in .pc files. Bug #103578 + * add the custom buildtests target only once. Bug #103003 + +Release 0.61.0 + core: + * Fix crashes in broken files + * Cleanup unused functions from GlobalParams + * Tweak LZWStream::processNextCode error handling. Bug #103174 + * Warning fixes + * Remove t1lib code + + qt5: + * Clean up the remaining Splash code in Arthur backend. Bug #103117 + * ArthurOutputDev: Properly implement saveState/restoreState. Bug #103118 + * Fix leak in ArthurOutputDev::updateFont. Bug #103508 + + build system: + * Use GNUInstallDirs. Bug #103211 + * mingw: Install pkg-config files + * mingw: change library names to include the soversion. Bug #103157 + * Fix installing a .cc file as header + * Use -pthread flag instead of -lpthread + +Release 0.60.1 + qt5: + * ArthurOutputDev: Add missing 'return' in error paths + + build system: + * FindLIBOPENJPEG.cmake: Add CheckCXXSourceCompiles + +Release 0.60.0 + core: + * Enable libcurl support by default + * PSOutputDev: Fix wrong text generation. Bug #102760 + * Added methods to get and set the font size of text fields. Bug #101692 + * CairoOutputDev: Do not extend the pattern in drawImageMaskRegular + * CairoOutputDev: do not use the custom downscaling for rendering images when using cairo >= 1.14 + * Fix build with old clang + * Fix various crashes in broken files + * Fix some warnings + * Add some constness to the basic classes + * Remove unused functions from GlobalParams + + qt5: + * Added methods to get and set the font size of text fields. Bug #101692 + * Add whether renderToImage shows annotations + * ArthurOutputDev: Replace Splash font rendering by Qt font rendering + * ArthurOutputDev: Implement the drawSoftMaskedImage method + * ArthurOutputDev: Fix several small bugs related to dash pattern handling + * Fix two minor typos + + build system: + * cmake is now the default build system + * autotools based build system has been removed + + utils: + * pdfinfo: don't truncate dest name + +Release 0.59.0 + core: + * Fix infinite recursion in NameTree parsing in broken files + + utils: + * pdfunite: Fix API porting error that caused abort in some cases + * pdfinfo: Fix crashes and memory leaks when using -dests + * pdfinfo: use GooString.append instead of sprintf/strcat + * pdfimages: Fix warning when compiling with cygwin + + build system: + * Fix cygwin 32-bit compile + * cmake tweaks + + +Release 0.58.0 + core: + * CairoOutputDev: cairo 1.14 now has high quality downscaling + * Signature related improvements. Bug #99271 + * Tweak which cmap we use. Bug #101855 + * Memory leak fixes + * Substantial rework of the internals + * win32: call ANSI functions directly. Bug #100312 + * Add some documentation + + qt5: + * Expose signature information. + * ArthurOutputDev: initialize the image with the paper color. Bug #102129 + * Fix copy'n'paste bugs: Qt4 -> Qt5 + * ArthurOutputDev: Properly set the QPainter transformation + * ArthurOutputDev: Use Qt::SvgMiterJoin instead of Qt::MiterJoin. Bug #102356 + + utils: + * pdfinfo: add -dests option to print named destinations. Bug #97262 + * pdftocairo: add -jpegopt for setting jpeg compression parameters. Bug #45727 + * pdftoppm: add -jpegopt for setting jpeg compression parameters. Bug #45727 + * pdfimages: support listing/extracting inline images. Bug #25625 + + build system: + * cmake: Various Windows fixes + * cmake: Use -std=c++11 instead of -std=gnu++11 + + cpp: + * Fix page.text() not taking page orientation into account. Bug #94517 + +Release 0.57.0 + core: + * Fix parsing of Type 1 fonts with newlines in encoding sequences. Bug #101728 + * Fix crash in broken documents + + utils: + * pdfunite: Fix crash with broken documents. Bug #101208 + * pdftohtml: skip control characters Bug #101770 + * pdfseparate: minor improvement to the documentation. Bug #101800 + + build system: + * cmake: Set RUNPATH for poppler shared libs. Bug #101945 + * configure: fix --disable-FEATURE actually enabling the feature + +Release 0.56.0 + core: + * FormFieldButton::setState() shouldn't check the field is readOnly + * Fix crashes on multiple broken files + + utils: + * pdfunite: Fix crash with broken documents. Bugs #101153 #101149 + +Release 0.55.0 + core: + * Fix abort in files with broken Decode arrays. KDE bug #379835 + * Fix memory leak (and probably logic bug) parsing broken XRef entries. Bug #100775 + * Fix memory leak when reconstructing broken files. Bug #100776 + * Minor optimization + * Fix regression in GfxIndexedColorSpace::mapColorToBase. Bug #100931 + * Fix memory leak in error condition + + cpp: + * Return nullptr if the page at index can't be fetched. Bug #100981 + + build system: + * Fail by default if libjpeg is not available + * Fail by default if libopenjpeg2/1 is not available + +Release 0.54.0 + core: + * Make XRef reconstruction a bit better. Bug #100509 + + glib: + * Expose movie play mode. Bug #99625 + * demo: Show play mode in movie properties view + + qt5: + * Compile with -DQT_NO_CAST_FROM_BYTEARRAY. Bug #100311 + + utils: + * pdfimages: don't fail listing if inline image data contains 'EI'. Bug #100737 + +Release 0.53.0 + core: + * Form support improvements + * SplashOutputDev: Fix memory leak when rendering images with colormap and matte color + * Minor fix in GlobalParams documentation + + qt5: + * Expose form calculate order + * Expose Form additional actions + + utils: + * pdfimages: support 16bpc png and tiff images. Bug #99988 + * pdftohtml: fix small memory leak when constructing some filenames + * pdfinfo: fix leak when printing JS + + build sytem: + * Compile in C++11 mode + Release 0.52.0 core: * Fix assert on reading some OCGs. Bug #99768 diff --git a/Build/source/libs/poppler/poppler-src/README.contributors b/Build/source/libs/poppler/poppler-src/README.contributors new file mode 100644 index 00000000000..5e45331e65f --- /dev/null +++ b/Build/source/libs/poppler/poppler-src/README.contributors @@ -0,0 +1,21 @@ +If you want to become or are a poppler contributor, this is a README for you, keep reading! + +Licensing +--------- +Only send patches to poppler if you agree to license (or relicense) them under +GPLv2 and later (or something more permissive that can be "upgraded" to GPLv2 +and later). If you do not agree to this license, please explain the problem / bug +and how you would solve it in words instead of code. + +By default all patches attached to the bugzilla or sent to the mailing list will +be assumed to agree with the licensing expressed here. + +Channels of contact +------------------- +Poppler has three main channels of contact: + * The poppler mailing list http://lists.freedesktop.org/mailman/listinfo/poppler + * The poppler bug tracker (bugzilla) http://bugs.freedesktop.org + * The #poppler channel at the freenode network +Do not hesitate to drop by talk to people there. + +And keep hacking on poppler! diff --git a/Build/source/libs/poppler/poppler-src/TODO b/Build/source/libs/poppler/poppler-src/TODO deleted file mode 100644 index e067c2a3156..00000000000 --- a/Build/source/libs/poppler/poppler-src/TODO +++ /dev/null @@ -1,40 +0,0 @@ -* general items: - - Investigate better (that is, normal) text selection. - - Use PDF font descriptors to create an FcPattern. - - Add simle performance benchmark that takes a pdf and renders - every page 100 times or so. Start keeping track of - performance. - - make color space conversion stuff more sane (right now we - hack around some of it in the cairo backend) - - move away from getChar to a more read(2) like interface - -* core: - - use libtiff for ccitt decoding? - -* Qt4 frontend: - - expose Rendition media through the MovieObject API - - use Q_GLOBAL_STATIC for GlobalParams? - - use QSettings or another system for loading/saving Document/global settings? - - expose API for lcms/color management system - - make the ArthurOutputDev optional - -* glib frontend: - - Sound/Movie actions support - - API to create annotations - -* new frontends: - - Java/JNI-based frontend for Android - -* cairo backend: - - Implement linear/radial gradients with cairo gradients - - PDF Blend Modes - - Make the cairo backend feature complete and optimize the - heck out of it. - -Jeff Muizelaar's TODO: - Short Term: - - factor out some of the color conversion code from CairoOutputDev and ArthurOutputDev. - - fix patterned text fills. - Long Term: - - use cairo glyph cache for type3 fonts. - - try to use cairo pattern support. diff --git a/Build/source/libs/poppler/poppler-src/config.h.cmake b/Build/source/libs/poppler/poppler-src/config.h.cmake index 7988b74e31a..10ce5580567 100644 --- a/Build/source/libs/poppler/poppler-src/config.h.cmake +++ b/Build/source/libs/poppler/poppler-src/config.h.cmake @@ -30,6 +30,12 @@ /* Use cairo for rendering. */ #cmakedefine HAVE_CAIRO 1 +/* Do we have any DCT decoder?. */ +#cmakedefine HAVE_DCT_DECODER 1 + +/* Do we have any JPX decoder?. */ +#cmakedefine HAVE_JPX_DECODER 1 + /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ #cmakedefine HAVE_DIRENT_H 1 @@ -40,9 +46,6 @@ /* Define to 1 if you have the <fcntl.h> header file. */ #cmakedefine HAVE_FCNTL_H 1 -/* Have FreeType2 include files */ -#cmakedefine HAVE_FREETYPE_H 1 - /* Define to 1 if you have the `fseek64' function. */ #cmakedefine HAVE_FSEEK64 1 @@ -70,57 +73,36 @@ /* Define if you have the iconv() function and it works. */ #cmakedefine HAVE_ICONV 1 -/* Define to 1 if you have the <inttypes.h> header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `openjpeg' library (-lopenjpeg). */ -#cmakedefine HAVE_LIBOPENJPEG 1 - /* Define to 1 if you have the `z' library (-lz). */ #cmakedefine HAVE_LIBZ 1 /* Defines if localtime_r is available on your system */ #cmakedefine HAVE_LOCALTIME_R 1 -/* Define to 1 if you have the <memory.h> header file. */ -#cmakedefine HAVE_MEMORY_H 1 - /* Define to 1 if you have the `mkstemp' function. */ #cmakedefine HAVE_MKSTEMP 1 -/* Define to 1 if you have the `mkstemps' function. */ -#cmakedefine HAVE_MKSTEMPS 1 - /* Define to 1 if you have the `rand_r' function. */ #cmakedefine HAVE_RAND_R 1 +/* Define to 1 if you have the `strcpy_s' function. */ +#cmakedefine HAVE_STRCPY_S 1 + +/* Define to 1 if you have the `strcat_s' function. */ +#cmakedefine HAVE_STRCAT_S 1 + +/* Defines if strtok_r is available on your system */ +#cmakedefine HAVE_STRTOK_R 1 + /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ #cmakedefine HAVE_NDIR_H 1 -/* Define to 1 if you have the <openjpeg.h> header file. */ -#cmakedefine HAVE_OPENJPEG_H 1 - /* Define to 1 if you have the `popen' function. */ #cmakedefine HAVE_POPEN 1 -/* Define if you have POSIX threads libraries and header files. */ -#cmakedefine HAVE_PTHREAD 1 - /* Use splash for rendering. */ #cmakedefine HAVE_SPLASH 1 -/* Define to 1 if you have the <stdint.h> header file. */ -#cmakedefine HAVE_STDINT_H 1 - -/* Define to 1 if you have the <stdlib.h> header file. */ -#cmakedefine HAVE_STDLIB_H 1 - -/* Define to 1 if you have the <strings.h> header file. */ -#cmakedefine HAVE_STRINGS_H 1 - -/* Define to 1 if you have the <string.h> header file. */ -#cmakedefine HAVE_STRING_H 1 - /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. */ #cmakedefine HAVE_SYS_DIR_H 1 @@ -135,15 +117,9 @@ /* Define to 1 if you have the <sys/stat.h> header file. */ #cmakedefine HAVE_SYS_STAT_H 1 -/* Define to 1 if you have the <sys/types.h> header file. */ -#cmakedefine HAVE_SYS_TYPES_H 1 - /* Define to 1 if you have the <unistd.h> header file. */ #cmakedefine HAVE_UNISTD_H 1 -/* Define to 1 if you have the <zlib.h> header file. */ -#cmakedefine HAVE_ZLIB_H 1 - /* Define to 1 if you have a big endian machine */ #cmakedefine WORDS_BIGENDIAN 1 @@ -186,9 +162,6 @@ /* Include support for CMYK rasterization */ #cmakedefine SPLASH_CMYK 1 -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - /* Enable word list support. */ #cmakedefine TEXTOUT_WORD_LIST 1 @@ -201,9 +174,6 @@ /* Use single precision arithmetic in the Splash backend */ #cmakedefine USE_FLOAT 1 -/* Defines if use lcms1 */ -#cmakedefine USE_LCMS1 1 - /* Version number of package */ #define VERSION "${POPPLER_VERSION}" @@ -216,23 +186,19 @@ /* OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag */ #cmakedefine WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG 1 -/* Define to 1 if the X Window System is missing or not being used. */ -/* #undef X_DISPLAY_MISSING */ - -/* - * jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system - * headers and I'm too lazy to write a configure test as long as only - * unixware is related - */ -#ifdef _UNIXWARE -#define HAVE_BOOLEAN -#endif - /* MS defined snprintf as deprecated but then added it in Visual Studio 2015. */ #if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf #endif +//------------------------------------------------------------------------ +// popen +//------------------------------------------------------------------------ +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define popen _popen +#define pclose _pclose +#endif + /* Number of bits in a file offset, on hosts where this is settable. */ #cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@ diff --git a/Build/source/libs/poppler/poppler-src/config.h.in b/Build/source/libs/poppler/poppler-src/config.h.in deleted file mode 100644 index 302f7b9ccea..00000000000 --- a/Build/source/libs/poppler/poppler-src/config.h.in +++ /dev/null @@ -1,284 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Build against libcurl. */ -#undef ENABLE_LIBCURL - -/* Use libjpeg instead of builtin jpeg decoder. */ -#undef ENABLE_LIBJPEG - -/* Use libopenjpeg instead of builtin jpeg2000 decoder. */ -#undef ENABLE_LIBOPENJPEG - -/* Build against libpng. */ -#undef ENABLE_LIBPNG - -/* Build against libtiff. */ -#undef ENABLE_LIBTIFF - -/* Build Poppler against NSS for digital signature support. */ -#undef ENABLE_NSS3 - -/* Do not hardcode the library location */ -#undef ENABLE_RELOCATABLE - -/* Build against zlib. */ -#undef ENABLE_ZLIB - -/* Use zlib instead of builtin zlib decoder to uncompress flate streams. */ -#undef ENABLE_ZLIB_UNCOMPRESS - -/* Use cairo for rendering. */ -#undef HAVE_CAIRO - -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the <fcntl.h> header file. */ -#undef HAVE_FCNTL_H - -/* Have FreeType2 include files */ -#undef HAVE_FREETYPE_H - -/* Define to 1 if you have the `fseek64' function. */ -#undef HAVE_FSEEK64 - -/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ -#undef HAVE_FSEEKO - -/* Define to 1 if you have the `ftell64' function. */ -#undef HAVE_FTELL64 - -/* Defines if gettimeofday is available on your system */ -#undef HAVE_GETTIMEOFDAY - -/* Defines if gmtime_r is available on your system */ -#undef HAVE_GMTIME_R - -/* Define if you have the iconv() function and it works. */ -#undef HAVE_ICONV - -/* Define to 1 if you have the <inttypes.h> header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `tiff' library (-ltiff). */ -#undef HAVE_LIBTIFF - -/* Define to 1 if you have the `z' library (-lz). */ -#undef HAVE_LIBZ - -/* Defines if localtime_r is available on your system */ -#undef HAVE_LOCALTIME_R - -/* Define to 1 if you have the `lseek64' function. */ -#undef HAVE_LSEEK64 - -/* Define to 1 if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - -/* Define to 1 if you have the `mkstemps' function. */ -#undef HAVE_MKSTEMPS - -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - -/* Define to 1 if you have the <openjpeg.h> header file. */ -#undef HAVE_OPENJPEG_H - -/* Define to 1 if you have the `popen' function. */ -#undef HAVE_POPEN - -/* Define to 1 if you have the `pread64' function. */ -#undef HAVE_PREAD64 - -/* Define if you have POSIX threads libraries and header files. */ -#undef HAVE_PTHREAD - -/* Have PTHREAD_PRIO_INHERIT. */ -#undef HAVE_PTHREAD_PRIO_INHERIT - -/* Defines if rand_r is available on your system */ -#undef HAVE_RAND_R - -/* Use splash for rendering. */ -#undef HAVE_SPLASH - -/* Define to 1 if you have the <stdint.h> header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the <stdlib.h> header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcat_s' function. */ -#undef HAVE_STRCAT_S - -/* Define to 1 if you have the `strcpy_s' function. */ -#undef HAVE_STRCPY_S - -/* Define to 1 if you have the <strings.h> header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the <string.h> header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - -/* Define to 1 if you have the <sys/mman.h> header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the <sys/types.h> header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the <tiffio.h> header file. */ -#undef HAVE_TIFFIO_H - -/* Defines if timegm is available on your system */ -#undef HAVE_TIMEGM - -/* Define to 1 if you have the <unistd.h> header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the <zlib.h> header file. */ -#undef HAVE_ZLIB_H - -/* Define as const if the declaration of iconv() needs const. */ -#undef ICONV_CONST - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#undef LT_OBJDIR - -/* Enable multithreading support. */ -#undef MULTITHREADED - -/* Generate OPI comments in PS output. */ -#undef OPI_SUPPORT - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Poppler data dir */ -#undef POPPLER_DATADIR - -/* Support for curl based doc builder is compiled in. */ -#undef POPPLER_HAS_CURL_SUPPORT - -/* Defines the poppler version */ -#undef POPPLER_VERSION - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -#undef PTHREAD_CREATE_JOINABLE - -/* Include support for CMYK rasterization */ -#undef SPLASH_CMYK - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Enable word list support. */ -#undef TEXTOUT_WORD_LIST - -/* Defines if use cms */ -#undef USE_CMS - -/* Use fixed point arithmetic in the Splash backend */ -#undef USE_FIXEDPOINT - -/* Use single precision arithmetic in the Splash backend */ -#undef USE_FLOAT - -/* Defines if use lcms1 */ -#undef USE_LCMS1 - -/* Defined if using openjpeg1 */ -#undef USE_OPENJPEG1 - -/* Defined if using openjpeg2 */ -#undef USE_OPENJPEG2 - -/* Version number of package */ -#undef VERSION - -/* Use fontconfig font configuration backend */ -#undef WITH_FONTCONFIGURATION_FONTCONFIG - -/* Use win32 font configuration backend */ -#undef WITH_FONTCONFIGURATION_WIN32 - -/* OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag. */ -#undef WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define to 1 if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* - * jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system - * headers and I'm too lazy to write a configure test as long as only - * unixware is related - */ -#ifdef _UNIXWARE -#define HAVE_BOOLEAN -#endif - - -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ -#undef _LARGEFILE_SOURCE - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES diff --git a/Build/source/libs/poppler/poppler-src/configure.ac b/Build/source/libs/poppler/poppler-src/configure.ac deleted file mode 100644 index 5caa8ae5167..00000000000 --- a/Build/source/libs/poppler/poppler-src/configure.ac +++ /dev/null @@ -1,1090 +0,0 @@ -m4_define([poppler_version_major],[0]) -m4_define([poppler_version_minor],[52]) -m4_define([poppler_version_micro],[0]) -m4_define([poppler_version],[poppler_version_major.poppler_version_minor.poppler_version_micro]) - -AC_PREREQ(2.59) -AC_INIT([poppler],[poppler_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=poppler]) -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([1.7 foreign]) -m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) -AC_CONFIG_HEADERS([config.h poppler/poppler-config.h]) -AC_C_BIGENDIAN - -dnl ##### Initialize libtool. -AC_LIBTOOL_WIN32_DLL -define([AC_LIBTOOL_LANG_F77_CONFIG], [:]) -AC_PROG_LIBTOOL - -dnl ##### Checks for programs. -AC_PROG_CC -AC_PROG_CXX -AC_ISC_POSIX -AC_PROG_CC_STDC -#if test -z "$CXX" -a "$CC" = "gcc"; then -# CXX="gcc" -#fi -AC_PROG_CXX -AC_PROG_INSTALL - -dnl ##### Check for pkgconfig -PKG_PROG_PKG_CONFIG - -dnl ##### Export the version -AC_DEFINE_UNQUOTED([POPPLER_VERSION], ["poppler_version"], [Defines the poppler version]) - -dnl Enable these unconditionally. -AC_DEFINE([OPI_SUPPORT], [1], [Generate OPI comments in PS output.]) -AC_DEFINE([MULTITHREADED], [1], [Enable multithreading support.]) -AC_DEFINE([TEXTOUT_WORD_LIST], [1], [Enable word list support.]) - -dnl Check for OS specific flags -win32_libs="" -create_shared_lib="" -auto_import_flags="" -case "$host_os" in - cygwin*) - create_shared_lib="-no-undefined" - ;; - mingw*) - os_win32=yes - win32_libs="-lgdi32 -lwinspool -lcomdlg32" - create_shared_lib="-no-undefined" - auto_import_flags="-Wl,--enable-auto-import" - - # Use mingw's ansi stdio extensions - CXXFLAGS="$CXXFLAGS -D__USE_MINGW_ANSI_STDIO=1" - ;; -esac - -AC_SUBST(win32_libs) -AC_SUBST(create_shared_lib) -AC_SUBST(auto_import_flags) - -AX_PTHREAD() - -dnl Install xpdf headers -AC_ARG_ENABLE(xpdf-headers, - AC_HELP_STRING([--enable-xpdf-headers], - [Install unsupported xpdf headers.]), - enable_xpdf_headers=$enableval, - enable_xpdf_headers="no") -AM_CONDITIONAL(ENABLE_XPDF_HEADERS, test x$enable_xpdf_headers = xyes) - -dnl ##### Emulate cmake -DCMAKE_BUILD_TYPE=Release using options from cmake/modules/PopplerMacros.cmake - -AC_ARG_ENABLE(build-type, - AC_HELP_STRING([--enable-build-type=@<:@relwithdebinfo/release/debug/debugfull/profile@:>@], - [Build with options similar to 'cmake -DCMAKE_BUILD_TYPE=' values.]), - [enable_build_type=no; - case "$enableval" in - relwithdebinfo|release|debug|debugfull|profile) enable_build_type="$enableval" ;; - *) AC_MSG_ERROR([bad value $enableval for --enable-build-type option. - Options are relwithdebinfo, release, debug, debugfull, and profile.]) ;; - esac], - enable_build_type=no) - -if test "x$GCC" = "xyes"; then - case "$enable_build_type" in - relwithdebinfo) - CFLAGS="-O2 -g $CFLAGS" - CXXFLAGS="-O2 -g $CXXFLAGS" - ;; - release) - CFLAGS="-O2 $CFLAGS -g0 -DNDEBUG" - CXXFLAGS="-O2 $CXXFLAGS -g0 -DNDEBUG" - ;; - debug) - CFLAGS="-O2 -g $CFLAGS -fno-reorder-blocks -fno-schedule-insns -fno-inline" - CXXFLAGS="-O2 -g $CXXFLAGS -fno-reorder-blocks -fno-schedule-insns -fno-inline" - ;; - debugfull) - CFLAGS="$CFLAGS -g3 -fno-inline" - CXXFLAGS="$CXXFLAGS -g3 -fno-inline" - ;; - profile) - CFLAGS="$CFLAGS -g3 -fno-inline -ftest-coverage -fprofile-arcs" - CXXFLAGS="$CXXFLAGS -g3 -fno-inline -ftest-coverage -fprofile-arcs" - LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage -lgcov" - ;; - *) - enable_build_type=no - ;; - esac -else - case "$enable_build_type" in - relwithdebinfo|release|debug|debugfull|profile) - echo " Warning: --enable-build-type ignored for non-gcc compiler." - ;; - esac - enable_build_type=no -fi - -AC_ARG_ENABLE(single-precision, -[ --enable-single-precision use single precision arithmetic (instead of double precision) in the Splash backend], -AC_DEFINE(USE_FLOAT, [1], [Use single precision arithmetic in the Splash backend])) - -AC_ARG_ENABLE(fixedpoint, -[ --enable-fixedpoint use fixed point (instead of double precision) arithmetic in the Splash backend], -AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic in the Splash backend])) - -AC_ARG_ENABLE(cmyk, -[ --enable-cmyk Include support for CMYK rasterization], -AC_DEFINE(SPLASH_CMYK, [1], [Include support for CMYK rasterization])) - -dnl Relocation support -AC_ARG_ENABLE(relocatable, - AC_HELP_STRING([--disable-relocatable], - [Hardcode the poppler library location (on Windows).]), - enable_relocatable=$enableval, - [if test x$os_win32 = xyes; then - # default to yes on native Windows. - enable_relocatable="yes" - else - # default to no everywhere else. - enable_relocatable="no" - fi - ] -) - -if test x$enable_relocatable = xyes; then - if test x$os_win32 = xyes; then - AC_DEFINE([ENABLE_RELOCATABLE], - [1],[Do not hardcode the library location]) - else - AC_MSG_ERROR( - [Invalid setting for relocatable, only supported on windows]) - - fi -fi - -dnl ##### Check for installed poppler-data. Use the same datarootdir as default otherwise. -PKG_CHECK_EXISTS(poppler-data, - [POPPLER_DATADIR=`$PKG_CONFIG --variable=poppler_datadir poppler-data` - AC_DEFINE_DIR(POPPLER_DATADIR, "{POPPLER_DATADIR}", [Poppler data dir])], - [AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])] - ) - -dnl ##### Checks for header files. -AC_PATH_XTRA -AC_HEADER_DIRENT -AC_CHECK_HEADERS([stdint.h]) - -dnl ##### Switch over to C++. This will make the checks below a little -dnl ##### bit stricter (requiring function prototypes in include files). -dnl ##### (99% of xpdf is written in C++.) -AC_LANG_CPLUSPLUS - -AC_CHECK_DECL(gettimeofday, [AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defines if gettimeofday is available on your system]))],[],[#include <sys/time.h>]) -AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system])) -AC_CHECK_FUNC(gmtime_r, AC_DEFINE(HAVE_GMTIME_R, 1, [Defines if gmtime_r is available on your system])) -AC_CHECK_FUNC(timegm, AC_DEFINE(HAVE_TIMEGM, 1, [Defines if timegm is available on your system])) -AC_CHECK_FUNC(rand_r, AC_DEFINE(HAVE_RAND_R, 1, [Defines if rand_r is available on your system])) - -dnl ##### Check for extra libraries needed by X. (LynxOS needs this.) -AC_CHECK_FUNC(nanosleep,,) -dnl try in librt if not found in current LIBS -if test x$ac_cv_func_nanosleep = xno -then - AC_CHECK_LIB(rt,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lrt") -fi - -dnl try in libposix4, if not found so far -if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno -then - AC_CHECK_LIB(posix4,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix4") -fi - - -dnl ##### Test for libopenjpeg. Versions prior to 1.4 do not provide a pkgconfig file. -openjpeg1="no" -openjpeg2="no" -AC_ARG_ENABLE(libopenjpeg, - AC_HELP_STRING([--enable-libopenjpeg=@<:@auto/openjpeg1/openjpeg2/none@:>@], - [Use openjpeg for JPEG2000 images. 'auto' prefers openjpeg1 over openjpeg2 if both are available due to regressions in openjpeg2 [[default=auto]]]), - [enable_libopenjpeg=$enableval], - [enable_libopenjpeg="auto"]) - -openjpeg_header=yes - -dnl test for libopenjpeg2 -if test x$enable_libopenjpeg = xopenjpeg2 || test x$enable_libopenjpeg = xauto; then - PKG_CHECK_MODULES(LIBOPENJPEG, libopenjp2, - [openjpeg2=yes],[openjpeg2=no]) -fi - -dnl test for libopenjpeg1 -if test x$openjpeg2 = xno; then - if test x$enable_libopenjpeg = xopenjpeg1 || test x$enable_libopenjpeg = xauto; then - PKG_CHECK_MODULES(LIBOPENJPEG, libopenjpeg, - [openjpeg1="yes"], - [AC_CHECK_LIB([openjpeg], [opj_cio_open], - [openjpeg1="yes" - LIBOPENJPEG_LIBS="-lopenjpeg"],[openjpeg_header=no]) - AC_CHECK_HEADERS([openjpeg.h],, - [openjpeg_header="no"])]) - fi -fi - - -if test x$enable_libopenjpeg = xopenjpeg1 && test x$openjpeg1 = xno; then - if test x$openjpeg_header = xno; then - AC_MSG_ERROR("*** libopenjpeg headers not found ***") - else - AC_MSG_ERROR("*** libopenjpeg library not found ***") - fi -fi - -if test x$enable_libopenjpeg = xopenjpeg2 && test x$openjpeg2 = xno; then - AC_MSG_ERROR("*** libopenjp2 library not found ***") -fi - -if test x$openjpeg1 = xyes || test x$openjpeg2 = xyes; then - enable_libopenjpeg=yes - if test x$openjpeg1 = xyes; then - AC_DEFINE(USE_OPENJPEG1, 1, [Defined if using openjpeg1]) - fi - if test x$openjpeg2 = xyes; then - AC_DEFINE(USE_OPENJPEG2, 1, [Defined if using openjpeg2]) - fi - - AC_SUBST(LIBOPENJPEG_CFLAGS) - AC_SUBST(LIBOPENJPEG_LIBS) - AC_DEFINE(ENABLE_LIBOPENJPEG) - PKG_CHECK_EXISTS(libopenjpeg >= 1.5, - [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], - [PKG_CHECK_EXISTS(libopenjpeg1 >= 1.5, - [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], - []) - ]) -else - enable_libopenjpeg=no -fi - -dnl Test for NSS -AC_ARG_ENABLE(libnss, - AC_HELP_STRING([--disable-libnss], - [Do not build against libnss3.]), - enable_libnss=$enableval, - enable_libnss="try") - -if test x$enable_libnss != xno; then - PKG_CHECK_MODULES(NSS3, nss, [enable_nss="yes"], - [enable_nss="no"]) -fi - -if test x$enable_nss = xyes; then - AC_DEFINE(ENABLE_NSS3, 1, [Build against NSS.]) -fi - -AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$openjpeg1 = xyes || test x$openjpeg2 = xyes) -AH_TEMPLATE([ENABLE_LIBOPENJPEG], - [Use libopenjpeg instead of builtin jpeg2000 decoder.]) - -AM_CONDITIONAL(BUILD_NSS, test x$enable_nss = xyes) -AH_TEMPLATE([ENABLE_NSS3], [Build Poppler against NSS for digital signature support.]) - -dnl ##### Test for libtiff -AC_ARG_ENABLE(libtiff, - AC_HELP_STRING([--disable-libtiff], - [Don't build against libtiff.]), - enable_libtiff=$enableval, - enable_libtiff="try") - -AC_ARG_VAR([LIBTIFF_CFLAGS], [C compiler flags for LIBTIFF]) -AC_ARG_VAR([LIBTIFF_LIBS], [linker flags to link LIBTIFF (default is -ltiff)]) -ac_save_CPPFLAGS="$CPPFLAGS" -ac_save_CXXFLAGS="$CXXFLAGS" -ac_save_LIBS="$LDFLAGS" -CPPFLAGS="$CPPFLAGS $LIBTIFF_CFLAGS" -CXXFLAGS="$CXXFLAGS $LIBTIFF_CFLAGS" -LIBS="$LIBS $LIBTIFF_LIBS" -if test x$enable_libtiff = xyes; then - if test x"$LIBTIFF_LIBS" != x; then - AC_CHECK_FUNC([TIFFOpen],, - AC_MSG_ERROR("*** libtiff library not found ***")) - else - AC_CHECK_LIB([tiff], [TIFFOpen],, - AC_MSG_ERROR("*** libtiff library not found ***")) - fi - AC_CHECK_HEADERS([tiffio.h],, - AC_MSG_ERROR("*** libtiff headers not found ***")) -elif test x$enable_libtiff = xtry; then - if test x"$LIBTIFF_LIBS" != x; then - AC_CHECK_FUNC([TIFFOpen], - [enable_libtiff="yes"], - [enable_libtiff="no"]) - else - AC_CHECK_LIB([tiff], [TIFFOpen], - [enable_libtiff="yes"], - [enable_libtiff="no"]) - fi - AC_CHECK_HEADERS([tiffio.h],, - [enable_libtiff="no"]) -fi -CPPFLAGS="$ac_save_CPPFLAGS" -CXXFLAGS="$ac_save_CXXFLAGS" -LIBS="$ac_save_LIBS" - -if test x$enable_libtiff = xyes; then - if test x"$LIBTIFF_LIBS" = x; then - LIBTIFF_LIBS="-ltiff" - fi - AC_SUBST(LIBTIFF_CFLAGS) - AC_SUBST(LIBTIFF_LIBS) - AC_DEFINE(ENABLE_LIBTIFF) -fi - -AM_CONDITIONAL(BUILD_LIBTIFF, test x$enable_libtiff = xyes) -AH_TEMPLATE([ENABLE_LIBTIFF], [Build against libtiff.]) -if test x$enable_libtiff = xyes; then - AC_DEFINE(ENABLE_LIBTIFF, 1, [Build against libtiff.]) -fi - -dnl ##### Checks for library functions. -AC_CHECK_FUNCS(popen mkstemp mkstemps) -AC_CHECK_FUNCS(strcpy_s strcat_s) - -dnl ##### Back to C for the library tests. -AC_LANG_C - -dnl ##### Check for fseeko/ftello or fseek64/ftell64 -dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode. -AC_SYS_LARGEFILE -AC_FUNC_FSEEKO -AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no) -AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no) -if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then - AC_DEFINE(HAVE_FSEEK64) -fi -AC_CHECK_FUNCS(pread64 lseek64) - -dnl Test for zlib -AC_ARG_ENABLE(zlib, - AC_HELP_STRING([--disable-zlib], - [Don't build against zlib.]), - enable_zlib=$enableval, - enable_zlib="try") - -AC_ARG_ENABLE([zlib_uncompress], - AS_HELP_STRING([--enable-zlib-uncompress], - [Use zlib to uncompress flate streams (not totally safe)]), - enable_zlib_uncompress=$enableval, - enable_zlib_uncompress="no") - -if test x$enable_zlib = xyes; then - AC_CHECK_LIB([z], [inflate],, - AC_MSG_ERROR("*** zlib library not found ***")) - AC_CHECK_HEADERS([zlib.h],, - AC_MSG_ERROR("*** zlib headers not found ***")) -elif test x$enable_zlib = xtry; then - AC_CHECK_LIB([z], [inflate], - [enable_zlib="yes"], - [enable_zlib="no"]) - AC_CHECK_HEADERS([zlib.h],, - [enable_zlib="no"]) -fi - -if test x$enable_zlib = xyes; then - ZLIB_LIBS="-lz" - AC_SUBST(ZLIB_LIBS) - AC_DEFINE(ENABLE_ZLIB, 1, [Build against zlib.]) - - if test x$enable_zlib_uncompress = xyes; then - AC_DEFINE(ENABLE_ZLIB_UNCOMPRESS, 1, - [Use zlib instead of builtin zlib decoder to uncompress flate streams.]) - fi -else - if test x$enable_zlib_uncompress = xyes; then - echo " Warning: --enable-zlib-uncompress is incompatible with --disable-zlib." - fi - enable_zlib_uncompress="no" -fi - -AM_CONDITIONAL(BUILD_ZLIB, test x$enable_zlib = xyes) -AH_TEMPLATE([ENABLE_ZLIB], - [Build against zlib.]) -AM_CONDITIONAL(BUILD_ZLIB_UNCOMPRESS, test x$enable_zlib_uncompress = xyes) -AH_TEMPLATE([ENABLE_ZLIB_UNCOMPRESS], - [Use zlib instead of builtin zlib decoder to uncompress flate streams.]) - -dnl Test for libcurl -AC_ARG_ENABLE(libcurl, - AC_HELP_STRING([--enable-libcurl], - [Build with libcurl based HTTP support.]), - enable_libcurl=$enableval, - enable_libcurl="no") - -if test x$enable_libcurl = xyes; then - PKG_CHECK_MODULES(LIBCURL, libcurl) - AC_DEFINE(ENABLE_LIBCURL, 1, [Build against libcurl.]) - AC_DEFINE(POPPLER_HAS_CURL_SUPPORT, 1, - [Support for curl based doc builder is compiled in.]) -fi - -AM_CONDITIONAL(BUILD_LIBCURL, test x$enable_libcurl = xyes) - -dnl Test for libjpeg -AC_ARG_ENABLE(libjpeg, - AC_HELP_STRING([--disable-libjpeg], - [Don't build against libjpeg.]), - enable_libjpeg=$enableval, - enable_libjpeg="try") -AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for LIBJPEG]) -if test x$enable_libjpeg != xno; then - - dnl - dnl POPPLER_FIND_JPEG uses "USER_INCLUDES" and "USER_LIBS" - dnl to receive the flags for header and library directories. - dnl - ac_save_USER_INCLUDES="$USER_INCLUDES" - ac_save_USER_LDFLAGS="$USER_LDFLAGS" - USER_INCLUDES="$USER_INCLUDES $LIBJPEG_CFLAGS" - USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_CFLAGS" - POPPLER_FIND_JPEG - - dnl check INT16, INT32 typedef conflict in jmorecfg.h - ac_save_CPPFLAGS="$CPPFLAGS" - ac_save_CFLAGS="$CFLAGS" - CPPFLAGS="$CPPFLAGS $LIBJPEG_CFLAGS" - CFLAGS="$CFLAGS $LIBJPEG_CFLAGS" - AC_MSG_CHECKING([libjpeg.h works correctly]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#ifdef _WIN32 -#include <windows.h> -#endif -#include <sys/types.h> -#include <stdio.h> -#include <jpeglib.h> -],[{return 0;}])],[ - AC_MSG_RESULT([ok]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_CHECKING([libjpeg.h problem can be fixed by XMD_H macro]) - CPPFLAGS="$CPPFLAGS -DXMD_H" - CFLAGS="$CFLAGS -DXMD_H" - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#ifdef _WIN32 -#include <windows.h> -#endif -#include <sys/types.h> -#include <stdio.h> -#include <jpeglib.h> -],[{return 0;}])],[ - AC_MSG_RESULT([ok, -DXMD_H is added to LIBJPEG_CFLAGS]) - LIBJPEG_CFLAGS="$LIBJPEG_CFLAGS -DXMD_H" - ],[ - AC_MSG_RESULT([no, disable libjpeg]) - enable_libjpeg="no" - ]) - ]) - CPPFLAGS="$ac_save_CPPFLAGS" - CFLAGS="$ac_save_CFLAGS" - - dnl POPPLER_FIND_JPEG sets LIBJPEG_LIBS - AC_SUBST(LIBJPEG_CFLAGS) - USER_INCLUDES="$ac_save_USER_INCLUDES" - USER_LDFLAGS="$ac_save_USER_LDFLAGS" -fi - -AM_CONDITIONAL(BUILD_LIBJPEG, test x$enable_libjpeg = xyes) -AH_TEMPLATE([ENABLE_LIBJPEG], - [Use libjpeg instead of builtin jpeg decoder.]) - -dnl Test for libpng -AC_ARG_ENABLE(libpng, - AC_HELP_STRING([--disable-libpng], - [Do not build against libpng.]), - enable_libpng=$enableval, - enable_libpng="try") - -if test x$enable_libpng != xno; then - PKG_CHECK_MODULES(LIBPNG, libpng, [enable_libpng="yes"], - [enable_libpng="no"]) -fi - -if test x$enable_libpng = xyes; then - AC_DEFINE(ENABLE_LIBPNG, 1, [Build against libpng.]) -fi - -AM_CONDITIONAL(BUILD_LIBPNG, test x$enable_libpng = xyes) - -dnl Check for freetype headers - -PKG_CHECK_MODULES(FREETYPE, freetype2, - [freetype_pkgconfig=yes], [freetype_pkgconfig=no]) - -if test "x$freetype_pkgconfig" = "xyes"; then - - AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) - -else - - FREETYPE_LIBS= - FREETYPE_CFLAGS= - - AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) - if test "x$FREETYPE_CONFIG" != "xno" ; then - - FREETYPE_CFLAGS=`$FREETYPE_CONFIG --cflags` - FREETYPE_LIBS=`$FREETYPE_CONFIG --libs` - AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) - - fi - -fi - -AC_SUBST(FREETYPE_CFLAGS) -AC_SUBST(FREETYPE_LIBS) - -AC_MSG_CHECKING([which font configuration to use]) -AC_ARG_WITH([font_configuration], - [AS_HELP_STRING([--with-font-configuration=fontconfig|win32], - [Select font configuration backend])], - [], - [if test x$os_win32 = xyes; then - # default to win32 on native Windows. - with_font_configuration=win32 - else - # default to fontconig everywhere else. - with_font_configuration=fontconfig - fi - ] -) -AC_MSG_RESULT([$with_font_configuration]) - -case $with_font_configuration in - win32) - AC_DEFINE([WITH_FONTCONFIGURATION_WIN32], - [1],[Use win32 font configuration backend]) - # Set the minimum required Internet Explorer version to 5.0 - CPPFLAGS="$CPPFLAGS -D_WIN32_IE=0x0500" - ;; - fontconfig) - AC_DEFINE([WITH_FONTCONFIGURATION_FONTCONFIG], - [1],[Use fontconfig font configuration backend]) - PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0) - ;; - *) - AC_MSG_ERROR( - [Invalid font configuration setting: $with_font_configuration]) - ;; -esac - -AM_CONDITIONAL(BUILD_WITH_WIN32_FONTCONFIGURATION, - test x$with_font_configuration = xwin32) - -AC_ARG_ENABLE(splash-output, - AC_HELP_STRING([--disable-splash-output], - [Don't build the Splash graphics backend.]),, - enable_splash_output="yes") -AM_CONDITIONAL(BUILD_SPLASH_OUTPUT, test x$enable_splash_output = xyes) -AH_TEMPLATE([HAVE_SPLASH], [Use splash for rendering.]) -if test x$enable_splash_output = xyes; then - AC_DEFINE(HAVE_SPLASH) -fi - -CAIRO_VERSION="1.10.0" -AC_SUBST(CAIRO_VERSION) -CAIRO_DEPS="cairo >= $CAIRO_VERSION cairo-ft >= $CAIRO_VERSION" -AC_ARG_ENABLE(cairo-output, - AC_HELP_STRING([--disable-cairo-output], - [Don't build the cairo graphics backend.]), - enable_cairo_output=$enableval, - enable_cairo_output="try") -use_cairo="" -if test x$enable_cairo_output = xyes; then - PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS) -elif test x$enable_cairo_output = xtry; then - PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS, - [enable_cairo_output="yes"], - [enable_cairo_output="no" - use_cairo="no (requires cairo >= $CAIRO_VERSION)"]) -fi -if test "x$use_cairo" = "x"; then - use_cairo=$enable_cairo_output -fi - -AC_SUBST(CAIRO_CFLAGS) -AC_SUBST(CAIRO_LIBS) - -AM_CONDITIONAL(BUILD_CAIRO_OUTPUT, test x$enable_cairo_output = xyes) -AH_TEMPLATE([HAVE_CAIRO], [Use cairo for rendering.]) -if test x$enable_cairo_output = xyes; then - PDFTOCAIRO_DEPS="cairo cairo-ft" - dnl Check for optional cairo backends used by pdftocairo - PKG_CHECK_EXISTS(cairo-pdf, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-pdf"], []) - PKG_CHECK_EXISTS(cairo-ps, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-ps"], []) - PKG_CHECK_EXISTS(cairo-svg, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-svg"], []) - - PKG_CHECK_MODULES(PDFTOCAIRO, $PDFTOCAIRO_DEPS) - AC_SUBST(PDFTOCAIRO_CFLAGS) - AC_SUBST(PDFTOCAIRO_LIBS) - - AC_DEFINE(HAVE_CAIRO) - CAIRO_FEATURE="#define POPPLER_HAS_CAIRO 1" - CAIRO_REQ="cairo" - AC_CHECK_HEADERS(fcntl.h sys/mman.h sys/stat.h) -else - CAIRO_FEATURE="#undef POPPLER_HAS_CAIRO" - CAIRO_REQ="" -fi -AC_SUBST(CAIRO_FEATURE) -AC_SUBST(CAIRO_REQ) - -use_glib="" -found_introspection=no -if test x$enable_cairo_output = xyes; then - POPPLER_GLIB_DISABLE_DEPRECATED="" - POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="" - - GLIB_REQUIRED=2.41 - AC_SUBST(GLIB_REQUIRED) - AC_ARG_ENABLE(poppler-glib, - AC_HELP_STRING([--disable-poppler-glib], - [Don't compile poppler glib wrapper.]), - enable_poppler_glib=$enableval, - enable_poppler_glib="try") - if test x$enable_poppler_glib = xyes; then - PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION) - elif test x$enable_poppler_glib = xtry; then - PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION, - [enable_poppler_glib="yes"], - [enable_poppler_glib="no" - use_glib="no (requires glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION)"]) - fi - if test x$enable_poppler_glib = xyes; then - # Check for introspection - GOBJECT_INTROSPECTION_CHECK([0.6.7]) - - AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) - POPPLER_GLIB_DISABLE_DEPRECATED="$POPPLER_GLIB_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED" - POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="$POPPLER_GLIB_DISABLE_SINGLE_INCLUDES -DG_DISABLE_SINGLE_INCLUDES" - fi -else - if test x$enable_poppler_glib = xyes; then - AC_MSG_ERROR("Cairo output is required to build glib frontend") - fi - use_glib="no (requires cairo output)" - enable_poppler_glib="no" -fi -if test x"$use_glib" = x; then - use_glib="$enable_poppler_glib" -fi -AM_CONDITIONAL(BUILD_POPPLER_GLIB, test x$enable_poppler_glib = xyes) -AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") -AC_SUBST(GLIB_REQ) -AC_SUBST(POPPLER_GLIB_DISABLE_DEPRECATED) -AC_SUBST(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES) - -GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) - -dnl -dnl Try Qt4 -dnl - -AC_ARG_ENABLE(poppler-qt4, - AC_HELP_STRING([--disable-poppler-qt4], - [Don't compile poppler Qt4 wrapper.]), - enable_poppler_qt4=$enableval, - enable_poppler_qt4="try") -if test x$enable_poppler_qt4 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT4, - QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0) - PKG_CHECK_MODULES(POPPLER_QT4_TEST, - QtTest >= 4.7.0) -elif test x$enable_poppler_qt4 = xtry; then - PKG_CHECK_MODULES(POPPLER_QT4, - QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0, - [enable_poppler_qt4="yes"], - [enable_poppler_qt4="no"]) - if test x$enable_poppler_qt4 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT4_TEST, - QtTest >= 4.7.0, - [enable_poppler_qt4="yes"], - [enable_poppler_qt4="no"]) - fi -fi - -AC_SUBST(POPPLER_QT4_CXXFLAGS) -AC_SUBST(POPPLER_QT4_LIBS) -AC_SUBST(POPPLER_QT4_TEST_LIBS) - -if test x$enable_poppler_qt4 = xyes; then - AC_CHECK_TOOL(MOCQT4, moc) - AC_MSG_CHECKING([for Qt4 moc]) - mocversion=`$MOCQT4 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 4"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_MSG_RESULT([no]) - # moc was not the qt4 one, try with moc-qt4 - AC_CHECK_TOOL(MOCQT42, moc-qt4) - AC_MSG_CHECKING([for Qt4 moc-qt4]) - mocversion=`$MOCQT42 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 4"` - if test x"$mocversiongrep" != x"$mocversion"; then - # no valid moc found - enable_poppler_qt4=no; - MOCQT4="not found" - else - MOCQT4=$MOCQT42 - fi - fi - AC_SUBST(MOCQT4) - AC_MSG_RESULT([$MOCQT4]) -fi - -AM_CONDITIONAL(BUILD_POPPLER_QT4, test "x$enable_poppler_qt4" = "xyes") - -dnl -dnl Try Qt5 -dnl - -AC_ARG_ENABLE(poppler-qt5, - AC_HELP_STRING([--disable-poppler-qt5], - [Don't compile poppler Qt5 wrapper.]), - enable_poppler_qt5=$enableval, - enable_poppler_qt5="try") -if test x$enable_poppler_qt5 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT5, - Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0) - PKG_CHECK_MODULES(POPPLER_QT5_TEST, - Qt5Test >= 5.0.0 ) -elif test x$enable_poppler_qt5 = xtry; then - PKG_CHECK_MODULES(POPPLER_QT5, - Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0, - [enable_poppler_qt5="yes"], - [enable_poppler_qt5="no"]) - if test x$enable_poppler_qt5 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT5_TEST, - Qt5Test >= 5.0.0, - [enable_poppler_qt5="yes"], - [enable_poppler_qt5="no"]) - fi -fi - -AC_SUBST(POPPLER_QT5_CXXFLAGS) -AC_SUBST(POPPLER_QT5_LIBS) -AC_SUBST(POPPLER_QT5_TEST_LIBS) - -if test x$enable_poppler_qt5 = xyes; then - AC_CHECK_TOOL(MOCQT5, moc) - AC_MSG_CHECKING([for Qt5 moc]) - mocversion=`$MOCQT5 -v 2>&1` - mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_MSG_RESULT([no]) - # moc was not the qt5 one, try with moc-qt5 - AC_CHECK_TOOL(MOCQT52, moc-qt5) - AC_MSG_CHECKING([for Qt5 moc-qt5]) - mocversion=`$MOCQT52 -v 2>&1` - mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc-qt5 5|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_CHECK_TOOL(QTCHOOSER, qtchooser) - AC_MSG_CHECKING([for qtchooser]) - qt5tooldir=`QT_SELECT=qt5 qtchooser -print-env | grep QTTOOLDIR | cut -d '=' -f 2 | cut -d \" -f 2` - mocversion=`$qt5tooldir/moc -v 2>&1` - mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - # no valid moc found - enable_poppler_qt5=no; - MOCQT5="not found" - else - MOCQT5=$qt5tooldir/moc - fi - else - MOCQT5=$MOCQT52 - fi - fi - AC_SUBST(MOCQT5) - AC_MSG_RESULT([$MOCQT5]) -fi - -AM_CONDITIONAL(BUILD_POPPLER_QT5, test "x$enable_poppler_qt5" = "xyes") - -dnl -dnl CPP frontend -dnl - -AC_ARG_ENABLE(poppler-cpp, - AC_HELP_STRING([--disable-poppler-cpp], - [Don't compile poppler cpp wrapper.]), - enable_poppler_cpp=$enableval, - enable_poppler_cpp="yes") -if test x$enable_poppler_cpp = xyes; then - AM_ICONV() - if test x$am_func_iconv != xyes; then - enable_poppler_cpp=no - fi -fi - -AM_CONDITIONAL(BUILD_POPPLER_CPP, test "x$enable_poppler_cpp" = "xyes") - - -GTK_TEST_DEPS='gtk+-3.0 >= 3.8 gdk-pixbuf-2.0' -if test x$enable_cairo_output = xyes; then - GTK_TEST_DEPS="$GTK_TEST_DEPS $CAIRO_DEPS" -fi -AC_ARG_ENABLE(gtk-test, - AC_HELP_STRING([--disable-gtk-test], - [Don't compile GTK+ test program.]), - enable_gtk_test=$enableval, - enable_gtk_test="try") -if test x$enable_gtk_test = xyes; then - PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS) -elif test x$enable_gtk_test = xtry; then - PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS, - [enable_gtk_test="yes"], - [enable_gtk_test="no"]) -fi -AM_CONDITIONAL(BUILD_GTK_TEST, test x$enable_gtk_test = xyes -a x$enable_poppler_glib = xyes) - -AC_ARG_ENABLE(utils, - AC_HELP_STRING([--disable-utils], - [Don't compile poppler command line utils.]), - enable_utils=$enableval, - enable_utils="yes") -AM_CONDITIONAL(BUILD_UTILS, test x$enable_utils = xyes) - -AC_ARG_ENABLE(compile-warnings, - AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/kde@:>@], - [Turn on compiler warnings.]),, - [enable_compile_warnings="yes"]) - -dnl -dnl Color Management -dnl - -AC_ARG_ENABLE(cms, - AC_HELP_STRING([--enable-cms=@<:@auto/lcms1/lcms2/none@:>@], - [Use color management system. 'auto' prefers lcms2 over lcms1 if both are available [[default=auto]]]), - [enable_cms=$enableval], - [enable_cms="auto"]) -if test x$enable_cms = xauto; then - PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) - if test x$lcms2 = xno; then - PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) - fi -elif test x$enable_cms = xlcms1; then - PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) -elif test x$enable_cms = xlcms2; then - PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) -fi - -if test x$lcms1 = xyes || test x$lcms2 = xyes; then - enable_cms=yes - AC_DEFINE(USE_CMS, 1, [Defines if use cms]) - if test x$lcms1 = xyes; then - lcms1=yes; - AC_DEFINE(USE_LCMS1, 1, [Defines if use lcms1]) - fi -else - enable_cms=no -fi - -AM_CONDITIONAL(USE_CMS, test x$enable_cms = xyes) -AM_CONDITIONAL(USE_LCMS1, test x$lcms1 = xyes) - -AC_ARG_WITH([testdatadir], - [AS_HELP_STRING([--with-testdatadir=/path/to/testdatadir], - [Specify test data dir])], - [case $withval in - [[\\/]]* | ?:[[\\/]]* ) # Absolute name. - TESTDATADIR=$withval ;; - *) # Relative name. - TESTDATADIR=$ac_pwd/$withval ;; - esac - ], - [case $srcdir in - [[\\/]]* | ?:[[\\/]]* ) # Absolute name. - TESTDATADIR=$srcdir/../test ;; - *) # Relative name. - TESTDATADIR=$ac_pwd/$srcdir/../test ;; - esac - ] -) -AC_MSG_CHECKING([for test data in $TESTDATADIR]) -if test -d $TESTDATADIR && test -f $TESTDATADIR/test-poppler.c; then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) - AC_MSG_WARN([ - No test data found in $TESTDATADIR. - You will not be able to run 'make check' successfully. - - The test data is not included in the source packages - and is also not part of the main git repository. Instead, - you can checkout the test data from its own git - repository with: - - git clone git://git.freedesktop.org/git/poppler/test - - You should checkout the test data as a sibling of your - poppler source folder or specify the location of your - checkout with --with-testdatadir=/path/to/checkoutdir/test. -]) -fi -AC_SUBST(TESTDATADIR) - -# some compilers do not support this flag (see bug #76963) -fno_check_new= -AC_MSG_CHECKING([for -fno-check-new compiler flag]) -AC_LANG_PUSH([C++]) -saved_CXXFLAGS=$CXXFLAGS -CXXFLAGS="-fno-check-new $CXXFLAGS" -AC_TRY_COMPILE([], [], - [AC_MSG_RESULT([yes]) - fno_check_new="-fno-check-new"], - AC_MSG_RESULT([no]) -) -CXXFLAGS=$saved_CXXFLAGS -AC_LANG_POP - -if test "x$GCC" != xyes; then - enable_compile_warnings=no -fi -case "$enable_compile_warnings" in - no) ;; - yes) CXXFLAGS="-Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions $fno_check_new -fno-common $CXXFLAGS"; - CFLAGS="-Wall $CFLAGS" ;; - kde) CXXFLAGS="-Wnon-virtual-dtor -Wno-long-long -Wundef \ - -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -Wcast-align \ - -Wconversion -Wall -W -Wpointer-arith \ - -Wwrite-strings -O2 -Wformat-security \ - -Wmissing-format-attribute -fno-exceptions $fno_check_new \ - -fno-common $CXXFLAGS" ;; -esac - -case "$host_os" in - mingw*|cygwin*) - # mingw and cygwin print "warning: -fPIC ignored for target (all code is position independent)" - # for every file - ;; - *) - CXXFLAGS="-fPIC $CXXFLAGS"; - ;; -esac - - -case `$PKG_CONFIG --version` in - 0.?|0.1[0-7]) - PC_REQUIRES_PRIVATE=""; - PC_REQUIRES="poppler = $VERSION";; - *) - PC_REQUIRES_PRIVATE="Requires.private: poppler = $VERSION"; - PC_REQUIRES="";; -esac - -AC_SUBST(PC_REQUIRES) -AC_SUBST(PC_REQUIRES_PRIVATE) - -AC_SUBST([POPPLER_MAJOR_VERSION],[poppler_version_major]) -AC_SUBST([POPPLER_MINOR_VERSION],[poppler_version_minor]) -AC_SUBST([POPPLER_MICRO_VERSION],[poppler_version_micro]) -AC_SUBST([POPPLER_VERSION],[poppler_version]) - -AC_OUTPUT([ -Makefile -goo/Makefile -fofi/Makefile -splash/Makefile -poppler/Makefile -utils/Makefile -glib/Makefile -glib/poppler-features.h -glib/reference/Makefile -glib/reference/version.xml -glib/demo/Makefile -test/Makefile -qt4/Makefile -qt4/src/Makefile -qt4/tests/Makefile -qt4/demos/Makefile -qt5/Makefile -qt5/src/Makefile -qt5/tests/Makefile -qt5/demos/Makefile -cpp/Makefile -cpp/poppler-version.h -cpp/tests/Makefile -poppler.pc -poppler-uninstalled.pc -poppler-cairo.pc -poppler-cairo-uninstalled.pc -poppler-splash.pc -poppler-splash-uninstalled.pc -poppler-glib.pc -poppler-glib-uninstalled.pc -poppler-qt4.pc -poppler-qt4-uninstalled.pc -poppler-qt5.pc -poppler-qt5-uninstalled.pc -poppler-cpp.pc -poppler-cpp-uninstalled.pc]) - - -echo "" -echo "Building poppler with support for:" -echo " font configuration: $with_font_configuration" -echo " splash output: $enable_splash_output" -if test x$enable_cmyk = xyes;then - echo " with CMYK support" -fi -echo " cairo output: $use_cairo" -echo " qt4 wrapper: $enable_poppler_qt4" -echo " qt5 wrapper: $enable_poppler_qt5" -echo " glib wrapper: $use_glib" -echo " introspection: $found_introspection" -echo " cpp wrapper: $enable_poppler_cpp" -echo " use gtk-doc: $enable_gtk_doc" -echo " use libjpeg: $enable_libjpeg" -echo " use libpng: $enable_libpng" -echo " use libtiff: $enable_libtiff" -echo " use zlib compress: $enable_zlib" -echo " use zlib uncompress: $enable_zlib_uncompress" -echo " use nss: $enable_nss" -echo " use libcurl: $enable_libcurl" -echo " use libopenjpeg: $enable_libopenjpeg" -if test x$enable_libopenjpeg = xyes;then - if test x$openjpeg1 = xyes;then - echo " with openjpeg1" - else - echo " with openjpeg2" - fi -fi -echo " use cms: $enable_cms" -if test x$enable_cms = xyes;then - if test x$lcms1 = xyes;then - echo " with lcms1" - else - echo " with lcms2" - fi -fi -if test x$enable_build_type != xno;then - echo " build type: $enable_build_type" -fi -echo " command line utils: $enable_utils" -echo " test data dir: $TESTDATADIR" -echo "" - -if test x$enable_splash_output = xno -a x$enable_cairo_output = xno; then - echo " Warning: There is no rendering backend enabled" -fi - -if test x$enable_single_precision = xyes -a x$enable_fixedpoint = xyes; then - echo " Warning: Single precision and fixed point options should not be enabled at the same time" -fi - -if test x$enable_libjpeg != xyes; then - echo " Warning: Using libjpeg is recommended. The internal DCT decoder is unmaintained." -fi - -if test x$enable_zlib_uncompress != xno; then - echo " Warning: Using zlib for decompression is not totally safe" -fi - -if test x$enable_libopenjpeg != xyes; then - echo " Warning: Using libopenjpeg2 is recommended. The internal JPX decoder is unmaintained." -fi diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiIdentifier.cc b/Build/source/libs/poppler/poppler-src/fofi/FoFiIdentifier.cc index be28e2568eb..00b240fdf07 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiIdentifier.cc +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiIdentifier.cc @@ -69,13 +69,13 @@ class MemReader: public Reader { public: static MemReader *make(char *bufA, int lenA); - virtual ~MemReader(); - virtual int getByte(int pos); - virtual GBool getU16BE(int pos, int *val); - virtual GBool getU32BE(int pos, Guint *val); - virtual GBool getU32LE(int pos, Guint *val); - virtual GBool getUVarBE(int pos, int size, Guint *val); - virtual GBool cmp(int pos, const char *s); + ~MemReader(); + int getByte(int pos) override; + GBool getU16BE(int pos, int *val) override; + GBool getU32BE(int pos, Guint *val) override; + GBool getU32LE(int pos, Guint *val) override; + GBool getUVarBE(int pos, int size, Guint *val) override; + GBool cmp(int pos, const char *s) override; private: @@ -164,13 +164,13 @@ class FileReader: public Reader { public: static FileReader *make(char *fileName); - virtual ~FileReader(); - virtual int getByte(int pos); - virtual GBool getU16BE(int pos, int *val); - virtual GBool getU32BE(int pos, Guint *val); - virtual GBool getU32LE(int pos, Guint *val); - virtual GBool getUVarBE(int pos, int size, Guint *val); - virtual GBool cmp(int pos, const char *s); + ~FileReader(); + int getByte(int pos) override; + GBool getU16BE(int pos, int *val) override; + GBool getU32BE(int pos, Guint *val) override; + GBool getU32LE(int pos, Guint *val) override; + GBool getUVarBE(int pos, int size, Guint *val) override; + GBool cmp(int pos, const char *s) override; private: @@ -287,13 +287,13 @@ class StreamReader: public Reader { public: static StreamReader *make(int (*getCharA)(void *data), void *dataA); - virtual ~StreamReader(); - virtual int getByte(int pos); - virtual GBool getU16BE(int pos, int *val); - virtual GBool getU32BE(int pos, Guint *val); - virtual GBool getU32LE(int pos, Guint *val); - virtual GBool getUVarBE(int pos, int size, Guint *val); - virtual GBool cmp(int pos, const char *s); + ~StreamReader(); + int getByte(int pos) override; + GBool getU16BE(int pos, int *val) override; + GBool getU32BE(int pos, Guint *val) override; + GBool getU32LE(int pos, Guint *val) override; + GBool getUVarBE(int pos, int size, Guint *val) override; + GBool cmp(int pos, const char *s) override; private: diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc index f1a15e004da..2bbf04680dd 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc @@ -16,10 +16,10 @@ // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> // Copyright (C) 2007 Koji Otani <sho@bbr.jp> // Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2008, 2009, 2012, 2014-2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2009, 2012, 2014-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com> // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // 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> @@ -37,6 +37,7 @@ #include <stdlib.h> #include <string.h> +#include <limits.h> #include <algorithm> #include "goo/gtypes.h" #include "goo/gmem.h" @@ -451,7 +452,7 @@ int FoFiTrueType::mapNameToGID(char *name) { GBool FoFiTrueType::getCFFBlock(char **start, int *length) { int i; - if (!openTypeCFF) { + if (!openTypeCFF || !tables) { return gFalse; } i = seekTable("CFF "); @@ -1307,8 +1308,10 @@ Guint FoFiTrueType::computeTableChecksum(Guchar *data, int length) { switch (length & 3) { case 3: word |= (data[i+2] & 0xff) << 8; + // fallthrough case 2: word |= (data[i+1] & 0xff) << 16; + // fallthrough case 1: word |= (data[i ] & 0xff) << 24; break; diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h index a4e28f27a4c..0c42c837f0d 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiTrueType.h @@ -53,7 +53,7 @@ public: // Create a FoFiTrueType object from a file on disk. static FoFiTrueType *load(char *fileName, int faceIndexA=0); - virtual ~FoFiTrueType(); + ~FoFiTrueType(); // Returns true if this an OpenType font containing CFF data, false // if it's a TrueType font (or OpenType font with TrueType data). diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.cc b/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.cc index 151f2d5f5bb..a73b77c2914 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.cc +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.cc @@ -17,6 +17,8 @@ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2010 Jakub Wilk <jwilk@jwilk.net> // Copyright (C) 2014 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr> // // 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 @@ -31,6 +33,8 @@ #include <stdlib.h> #include <string.h> +#include <limits.h> +#include "goo/glibc.h" #include "goo/gmem.h" #include "goo/GooLikely.h" #include "FoFiEncodings.h" @@ -209,12 +213,12 @@ char *FoFiType1::getNextLine(char *line) { } void FoFiType1::parse() { - char *line, *line1, *p, *p2; + char *line, *line1, *firstLine, *p, *p2; char buf[256]; char c; int n, code, base, i, j; char *tokptr; - GBool gotMatrix; + GBool gotMatrix, continueLine; gotMatrix = gFalse; for (i = 1, line = (char *)file; @@ -241,6 +245,7 @@ void FoFiType1::parse() { for (j = 0; j < 256; ++j) { encoding[j] = NULL; } + continueLine = gFalse; for (j = 0, line = getNextLine(line); j < 300 && line && (line1 = getNextLine(line)); ++j, line = line1) { @@ -248,8 +253,26 @@ void FoFiType1::parse() { error(errSyntaxWarning, -1, "FoFiType1::parse a line has more than 255 characters, we don't support this"); n = 255; } - strncpy(buf, line, n); - buf[n] = '\0'; + if (continueLine) { + continueLine = gFalse; + if ((line1 - firstLine) + 1 > (int)sizeof(buf)) + break; + p = firstLine; + p2 = buf; + while (p < line1) { + if (*p == '\n' || *p == '\r') { + *p2++ = ' '; + p++; + } else { + *p2++ = *p++; + } + } + *p2 = '\0'; + } else { + firstLine = line; + strncpy(buf, line, n); + buf[n] = '\0'; + } for (p = buf; *p == ' ' || *p == '\t'; ++p) ; if (!strncmp(p, "dup", 3)) { while (1) { @@ -261,6 +284,9 @@ void FoFiType1::parse() { p += 2; } else if (*p >= '0' && *p <= '9') { base = 10; + } else if (*p == '\n' || *p == '\r') { + continueLine = gTrue; + break; } else { break; } @@ -268,7 +294,10 @@ void FoFiType1::parse() { code = code * base + (*p - '0'); } for (; *p == ' ' || *p == '\t'; ++p) ; - if (*p != '/') { + if (*p == '\n' || *p == '\r') { + continueLine = gTrue; + break; + } else if (*p != '/') { break; } ++p; @@ -276,10 +305,15 @@ void FoFiType1::parse() { if (code >= 0 && code < 256) { c = *p2; *p2 = '\0'; + gfree(encoding[code]); encoding[code] = copyString(p); *p2 = c; } for (p = p2; *p == ' ' || *p == '\t'; ++p) ; + if (*p == '\n' || *p == '\r') { + continueLine = gTrue; + break; + } if (strncmp(p, "put", 3)) { break; } diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.h b/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.h index f4e29b4ef0b..ac0b9c973cd 100644 --- a/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.h +++ b/Build/source/libs/poppler/poppler-src/fofi/FoFiType1.h @@ -29,7 +29,7 @@ public: // Create a FoFiType1 object from a file on disk. static FoFiType1 *load(char *fileName); - virtual ~FoFiType1(); + ~FoFiType1(); // Return the font name. char *getName(); diff --git a/Build/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc b/Build/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc index c4595a3260e..7c9494f57c6 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 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009, 2010, 2017 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 @@ -33,6 +33,7 @@ #include "goo/gmem.h" #include "goo/gstrtod.h" #include "goo/GooString.h" +#include "poppler/Error.h" #include "FoFiEncodings.h" #include "FoFiType1C.h" @@ -879,253 +880,260 @@ void FoFiType1C::convertToType0(char *psName, int *codeMap, int nCodes, } } + if (privateDicts) { // write the descendant Type 1 fonts - for (i = 0; i < nCIDs; i += 256) { - - //~ this assumes that all CIDs in this block have the same FD -- - //~ to handle multiple FDs correctly, need to somehow divide the - //~ font up by FD; as a kludge we ignore CID 0, which is .notdef - fd = 0; - // if fdSelect is NULL, we have an 8-bit font, so just leave fd=0 - if (fdSelect) { - for (j = i==0 ? 1 : 0; j < 256 && i+j < nCIDs; ++j) { - if (cidMap[i+j] >= 0) { - fd = fdSelect[cidMap[i+j]]; - break; - } + for (i = 0; i < nCIDs; i += 256) { + + //~ this assumes that all CIDs in this block have the same FD -- + //~ to handle multiple FDs correctly, need to somehow divide the + //~ font up by FD; as a kludge we ignore CID 0, which is .notdef + fd = 0; + // if fdSelect is NULL, we have an 8-bit font, so just leave fd=0 + if (fdSelect) { + for (j = i==0 ? 1 : 0; j < 256 && i+j < nCIDs; ++j) { + if (cidMap[i+j] >= 0) { + fd = fdSelect[cidMap[i+j]]; + break; + } + } } - } - // font dictionary (unencrypted section) - (*outputFunc)(outputStream, "16 dict begin\n", 14); - (*outputFunc)(outputStream, "/FontName /", 11); - (*outputFunc)(outputStream, psName, strlen(psName)); - buf = GooString::format("_{0:02x} def\n", i >> 8); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - (*outputFunc)(outputStream, "/FontType 1 def\n", 16); - if (privateDicts[fd].hasFontMatrix) { - buf = GooString::format("/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] def\n", - privateDicts[fd].fontMatrix[0], - privateDicts[fd].fontMatrix[1], - privateDicts[fd].fontMatrix[2], - privateDicts[fd].fontMatrix[3], - privateDicts[fd].fontMatrix[4], - privateDicts[fd].fontMatrix[5]); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - } else if (topDict.hasFontMatrix) { - (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); - } else { - (*outputFunc)(outputStream, - "/FontMatrix [0.001 0 0 0.001 0 0] def\n", 38); - } - buf = GooString::format("/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] def\n", - topDict.fontBBox[0], topDict.fontBBox[1], - topDict.fontBBox[2], topDict.fontBBox[3]); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - buf = GooString::format("/PaintType {0:d} def\n", topDict.paintType); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - if (topDict.paintType != 0) { - buf = GooString::format("/StrokeWidth {0:.4g} def\n", topDict.strokeWidth); + if (fd >= nFDs) + continue; + + // font dictionary (unencrypted section) + (*outputFunc)(outputStream, "16 dict begin\n", 14); + (*outputFunc)(outputStream, "/FontName /", 11); + (*outputFunc)(outputStream, psName, strlen(psName)); + buf = GooString::format("_{0:02x} def\n", i >> 8); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; - } - (*outputFunc)(outputStream, "/Encoding 256 array\n", 20); - for (j = 0; j < 256 && i+j < nCIDs; ++j) { - buf = GooString::format("dup {0:d} /c{1:02x} put\n", j, j); + (*outputFunc)(outputStream, "/FontType 1 def\n", 16); + if (privateDicts[fd].hasFontMatrix) { + buf = GooString::format("/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] def\n", + privateDicts[fd].fontMatrix[0], + privateDicts[fd].fontMatrix[1], + privateDicts[fd].fontMatrix[2], + privateDicts[fd].fontMatrix[3], + privateDicts[fd].fontMatrix[4], + privateDicts[fd].fontMatrix[5]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } else if (topDict.hasFontMatrix) { + (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); + } else { + (*outputFunc)(outputStream, + "/FontMatrix [0.001 0 0 0.001 0 0] def\n", 38); + } + buf = GooString::format("/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] def\n", + topDict.fontBBox[0], topDict.fontBBox[1], + topDict.fontBBox[2], topDict.fontBBox[3]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; - } - if (j < 256) { - buf = GooString::format("{0:d} 1 255 {{ 1 index exch /.notdef put }} for\n", - j); + buf = GooString::format("/PaintType {0:d} def\n", topDict.paintType); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; - } - (*outputFunc)(outputStream, "readonly def\n", 13); - (*outputFunc)(outputStream, "currentdict end\n", 16); - - // start the binary section - (*outputFunc)(outputStream, "currentfile eexec\n", 18); - eb.outputFunc = outputFunc; - eb.outputStream = outputStream; - eb.ascii = gTrue; - eb.r1 = 55665; - eb.line = 0; - - // start the private dictionary - eexecWrite(&eb, "\x83\xca\x73\xd5"); - eexecWrite(&eb, "dup /Private 32 dict dup begin\n"); - eexecWrite(&eb, "/RD {string currentfile exch readstring pop}" - " executeonly def\n"); - eexecWrite(&eb, "/ND {noaccess def} executeonly def\n"); - eexecWrite(&eb, "/NP {noaccess put} executeonly def\n"); - eexecWrite(&eb, "/MinFeature {16 16} def\n"); - eexecWrite(&eb, "/password 5839 def\n"); - if (privateDicts[fd].nBlueValues) { - eexecWrite(&eb, "/BlueValues ["); - for (k = 0; k < privateDicts[fd].nBlueValues; ++k) { - buf = GooString::format("{0:s}{1:d}", - k > 0 ? " " : "", - privateDicts[fd].blueValues[k]); + if (topDict.paintType != 0) { + buf = GooString::format("/StrokeWidth {0:.4g} def\n", topDict.strokeWidth); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + (*outputFunc)(outputStream, "/Encoding 256 array\n", 20); + for (j = 0; j < 256 && i+j < nCIDs; ++j) { + buf = GooString::format("dup {0:d} /c{1:02x} put\n", j, j); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + if (j < 256) { + buf = GooString::format("{0:d} 1 255 {{ 1 index exch /.notdef put }} for\n", + j); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + (*outputFunc)(outputStream, "readonly def\n", 13); + (*outputFunc)(outputStream, "currentdict end\n", 16); + + // start the binary section + (*outputFunc)(outputStream, "currentfile eexec\n", 18); + eb.outputFunc = outputFunc; + eb.outputStream = outputStream; + eb.ascii = gTrue; + eb.r1 = 55665; + eb.line = 0; + + // start the private dictionary + eexecWrite(&eb, "\x83\xca\x73\xd5"); + eexecWrite(&eb, "dup /Private 32 dict dup begin\n"); + eexecWrite(&eb, "/RD {string currentfile exch readstring pop}" + " executeonly def\n"); + eexecWrite(&eb, "/ND {noaccess def} executeonly def\n"); + eexecWrite(&eb, "/NP {noaccess put} executeonly def\n"); + eexecWrite(&eb, "/MinFeature {16 16} def\n"); + eexecWrite(&eb, "/password 5839 def\n"); + if (privateDicts[fd].nBlueValues) { + eexecWrite(&eb, "/BlueValues ["); + for (k = 0; k < privateDicts[fd].nBlueValues; ++k) { + buf = GooString::format("{0:s}{1:d}", + k > 0 ? " " : "", + privateDicts[fd].blueValues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nOtherBlues) { + eexecWrite(&eb, "/OtherBlues ["); + for (k = 0; k < privateDicts[fd].nOtherBlues; ++k) { + buf = GooString::format("{0:s}{1:d}", + k > 0 ? " " : "", + privateDicts[fd].otherBlues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nFamilyBlues) { + eexecWrite(&eb, "/FamilyBlues ["); + for (k = 0; k < privateDicts[fd].nFamilyBlues; ++k) { + buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", + privateDicts[fd].familyBlues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nFamilyOtherBlues) { + eexecWrite(&eb, "/FamilyOtherBlues ["); + for (k = 0; k < privateDicts[fd].nFamilyOtherBlues; ++k) { + buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", + privateDicts[fd].familyOtherBlues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].blueScale != 0.039625) { + buf = GooString::format("/BlueScale {0:.4g} def\n", + privateDicts[fd].blueScale); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nOtherBlues) { - eexecWrite(&eb, "/OtherBlues ["); - for (k = 0; k < privateDicts[fd].nOtherBlues; ++k) { - buf = GooString::format("{0:s}{1:d}", - k > 0 ? " " : "", - privateDicts[fd].otherBlues[k]); + if (privateDicts[fd].blueShift != 7) { + buf = GooString::format("/BlueShift {0:d} def\n", + privateDicts[fd].blueShift); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nFamilyBlues) { - eexecWrite(&eb, "/FamilyBlues ["); - for (k = 0; k < privateDicts[fd].nFamilyBlues; ++k) { - buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", - privateDicts[fd].familyBlues[k]); + if (privateDicts[fd].blueFuzz != 1) { + buf = GooString::format("/BlueFuzz {0:d} def\n", + privateDicts[fd].blueFuzz); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nFamilyOtherBlues) { - eexecWrite(&eb, "/FamilyOtherBlues ["); - for (k = 0; k < privateDicts[fd].nFamilyOtherBlues; ++k) { - buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", - privateDicts[fd].familyOtherBlues[k]); + if (privateDicts[fd].hasStdHW) { + buf = GooString::format("/StdHW [{0:.4g}] def\n", privateDicts[fd].stdHW); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].blueScale != 0.039625) { - buf = GooString::format("/BlueScale {0:.4g} def\n", - privateDicts[fd].blueScale); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].blueShift != 7) { - buf = GooString::format("/BlueShift {0:d} def\n", - privateDicts[fd].blueShift); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].blueFuzz != 1) { - buf = GooString::format("/BlueFuzz {0:d} def\n", - privateDicts[fd].blueFuzz); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].hasStdHW) { - buf = GooString::format("/StdHW [{0:.4g}] def\n", privateDicts[fd].stdHW); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].hasStdVW) { - buf = GooString::format("/StdVW [{0:.4g}] def\n", privateDicts[fd].stdVW); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].nStemSnapH) { - eexecWrite(&eb, "/StemSnapH ["); - for (k = 0; k < privateDicts[fd].nStemSnapH; ++k) { - buf = GooString::format("{0:s}{1:.4g}", - k > 0 ? " " : "", privateDicts[fd].stemSnapH[k]); + if (privateDicts[fd].hasStdVW) { + buf = GooString::format("/StdVW [{0:.4g}] def\n", privateDicts[fd].stdVW); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nStemSnapV) { - eexecWrite(&eb, "/StemSnapV ["); - for (k = 0; k < privateDicts[fd].nStemSnapV; ++k) { - buf = GooString::format("{0:s}{1:.4g}", - k > 0 ? " " : "", privateDicts[fd].stemSnapV[k]); + if (privateDicts[fd].nStemSnapH) { + eexecWrite(&eb, "/StemSnapH ["); + for (k = 0; k < privateDicts[fd].nStemSnapH; ++k) { + buf = GooString::format("{0:s}{1:.4g}", + k > 0 ? " " : "", privateDicts[fd].stemSnapH[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nStemSnapV) { + eexecWrite(&eb, "/StemSnapV ["); + for (k = 0; k < privateDicts[fd].nStemSnapV; ++k) { + buf = GooString::format("{0:s}{1:.4g}", + k > 0 ? " " : "", privateDicts[fd].stemSnapV[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].hasForceBold) { + buf = GooString::format("/ForceBold {0:s} def\n", + privateDicts[fd].forceBold ? "true" : "false"); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[fd].forceBoldThreshold != 0) { + buf = GooString::format("/ForceBoldThreshold {0:.4g} def\n", + privateDicts[fd].forceBoldThreshold); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[fd].languageGroup != 0) { + buf = GooString::format("/LanguageGroup {0:d} def\n", + privateDicts[fd].languageGroup); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[fd].expansionFactor != 0.06) { + buf = GooString::format("/ExpansionFactor {0:.4g} def\n", + privateDicts[fd].expansionFactor); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].hasForceBold) { - buf = GooString::format("/ForceBold {0:s} def\n", - privateDicts[fd].forceBold ? "true" : "false"); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].forceBoldThreshold != 0) { - buf = GooString::format("/ForceBoldThreshold {0:.4g} def\n", - privateDicts[fd].forceBoldThreshold); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].languageGroup != 0) { - buf = GooString::format("/LanguageGroup {0:d} def\n", - privateDicts[fd].languageGroup); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].expansionFactor != 0.06) { - buf = GooString::format("/ExpansionFactor {0:.4g} def\n", - privateDicts[fd].expansionFactor); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - // set up the subroutines - ok = gTrue; - getIndex(privateDicts[fd].subrsOffset, &subrIdx, &ok); - if (!ok) { - subrIdx.pos = -1; - } + // set up the subroutines + ok = gTrue; + getIndex(privateDicts[fd].subrsOffset, &subrIdx, &ok); + if (!ok) { + subrIdx.pos = -1; + } - // start the CharStrings - eexecWrite(&eb, "2 index /CharStrings 256 dict dup begin\n"); + // start the CharStrings + eexecWrite(&eb, "2 index /CharStrings 256 dict dup begin\n"); - // write the .notdef CharString - ok = gTrue; - getIndexVal(&charStringsIdx, 0, &val, &ok); - if (ok) { - eexecCvtGlyph(&eb, ".notdef", val.pos, val.len, - &subrIdx, &privateDicts[fd]); - } - - // write the CharStrings - for (j = 0; j < 256 && i+j < nCIDs; ++j) { - if (cidMap[i+j] >= 0) { - ok = gTrue; - getIndexVal(&charStringsIdx, cidMap[i+j], &val, &ok); - if (ok) { - buf = GooString::format("c{0:02x}", j); - eexecCvtGlyph(&eb, buf->getCString(), val.pos, val.len, - &subrIdx, &privateDicts[fd]); - delete buf; - } + // write the .notdef CharString + ok = gTrue; + getIndexVal(&charStringsIdx, 0, &val, &ok); + if (ok) { + eexecCvtGlyph(&eb, ".notdef", val.pos, val.len, + &subrIdx, &privateDicts[fd]); } - } - eexecWrite(&eb, "end\n"); - eexecWrite(&eb, "end\n"); - eexecWrite(&eb, "readonly put\n"); - eexecWrite(&eb, "noaccess put\n"); - eexecWrite(&eb, "dup /FontName get exch definefont pop\n"); - eexecWrite(&eb, "mark currentfile closefile\n"); - // trailer - if (eb.line > 0) { - (*outputFunc)(outputStream, "\n", 1); - } - for (j = 0; j < 8; ++j) { - (*outputFunc)(outputStream, "0000000000000000000000000000000000000000000000000000000000000000\n", 65); + // write the CharStrings + for (j = 0; j < 256 && i+j < nCIDs; ++j) { + if (cidMap[i+j] >= 0) { + ok = gTrue; + getIndexVal(&charStringsIdx, cidMap[i+j], &val, &ok); + if (ok) { + buf = GooString::format("c{0:02x}", j); + eexecCvtGlyph(&eb, buf->getCString(), val.pos, val.len, + &subrIdx, &privateDicts[fd]); + delete buf; + } + } + } + eexecWrite(&eb, "end\n"); + eexecWrite(&eb, "end\n"); + eexecWrite(&eb, "readonly put\n"); + eexecWrite(&eb, "noaccess put\n"); + eexecWrite(&eb, "dup /FontName get exch definefont pop\n"); + eexecWrite(&eb, "mark currentfile closefile\n"); + + // trailer + if (eb.line > 0) { + (*outputFunc)(outputStream, "\n", 1); + } + for (j = 0; j < 8; ++j) { + (*outputFunc)(outputStream, "0000000000000000000000000000000000000000000000000000000000000000\n", 65); + } + (*outputFunc)(outputStream, "cleartomark\n", 12); } - (*outputFunc)(outputStream, "cleartomark\n", 12); + } else { + error(errSyntaxError, -1, "FoFiType1C::convertToType0 without privateDicts"); } // write the Type 0 parent font diff --git a/Build/source/libs/poppler/poppler-src/fofi/Makefile.am b/Build/source/libs/poppler/poppler-src/fofi/Makefile.am deleted file mode 100644 index 4deb7d5e063..00000000000 --- a/Build/source/libs/poppler/poppler-src/fofi/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -noinst_LTLIBRARIES = libfofi.la - -if ENABLE_XPDF_HEADERS -poppler_fofi_includedir = $(includedir)/poppler/fofi -poppler_fofi_include_HEADERS = \ - FoFiBase.h \ - FoFiEncodings.h \ - FoFiTrueType.h \ - FoFiType1.h \ - FoFiIdentifier.h \ - FoFiType1C.h -endif - -libfofi_la_SOURCES = \ - FoFiBase.cc \ - FoFiBase.h \ - FoFiEncodings.cc \ - FoFiEncodings.h \ - FoFiTrueType.cc \ - FoFiTrueType.h \ - FoFiType1.cc \ - FoFiType1.h \ - FoFiType1C.cc \ - FoFiIdentifier.cc \ - FoFiType1C.h - -libfofi_la_CPPFLAGS = \ - -I$(top_srcdir) diff --git a/Build/source/libs/poppler/poppler-src/goo/FixedPoint.cc b/Build/source/libs/poppler/poppler-src/goo/FixedPoint.cc index 26b2f0fe890..b51446bfbc3 100644 --- a/Build/source/libs/poppler/poppler-src/goo/FixedPoint.cc +++ b/Build/source/libs/poppler/poppler-src/goo/FixedPoint.cc @@ -8,9 +8,23 @@ // //======================================================================== +//======================================================================== +// +// 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 Adrian Johnson <ajohnson@redneon.com> +// +// 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> -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT #ifdef USE_GCC_PRAGMAS #pragma implementation diff --git a/Build/source/libs/poppler/poppler-src/goo/FixedPoint.h b/Build/source/libs/poppler/poppler-src/goo/FixedPoint.h index 99749802db7..408dfc6f483 100644 --- a/Build/source/libs/poppler/poppler-src/goo/FixedPoint.h +++ b/Build/source/libs/poppler/poppler-src/goo/FixedPoint.h @@ -8,12 +8,27 @@ // //======================================================================== + +//======================================================================== +// +// 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 Adrian Johnson <ajohnson@redneon.com> +// +// 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 FIXEDPOINT_H #define FIXEDPOINT_H #include "poppler-config.h" -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT #ifdef USE_GCC_PRAGMAS #pragma interface diff --git a/Build/source/libs/poppler/poppler-src/goo/GooHash.cc b/Build/source/libs/poppler/poppler-src/goo/GooHash.cc index f4a92f17506..49f58c5f00a 100644 --- a/Build/source/libs/poppler/poppler-src/goo/GooHash.cc +++ b/Build/source/libs/poppler/poppler-src/goo/GooHash.cc @@ -6,6 +6,20 @@ // //======================================================================== +//======================================================================== +// +// 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> +// +// 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 @@ -15,6 +29,7 @@ #include "gmem.h" #include "GooString.h" #include "GooHash.h" +#include "GooLikely.h" //------------------------------------------------------------------------ @@ -339,6 +354,9 @@ void GooHash::expand() { GooHashBucket *GooHash::find(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)) { diff --git a/Build/source/libs/poppler/poppler-src/goo/GooMutex.h b/Build/source/libs/poppler/poppler-src/goo/GooMutex.h index b2714b048c7..68dabc4028c 100644 --- a/Build/source/libs/poppler/poppler-src/goo/GooMutex.h +++ b/Build/source/libs/poppler/poppler-src/goo/GooMutex.h @@ -21,6 +21,7 @@ // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> // Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com> // Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -30,6 +31,8 @@ #ifndef GMUTEX_H #define GMUTEX_H +#ifdef MULTITHREADED + // Usage: // // GooMutex m; @@ -82,4 +85,6 @@ private: GooMutex *mutex; }; -#endif +#endif // MULTITHREADED + +#endif // GMUTEX_H diff --git a/Build/source/libs/poppler/poppler-src/goo/GooString.cc b/Build/source/libs/poppler/poppler-src/goo/GooString.cc index 12592e4902f..e23c2b76d6b 100644 --- a/Build/source/libs/poppler/poppler-src/goo/GooString.cc +++ b/Build/source/libs/poppler/poppler-src/goo/GooString.cc @@ -18,10 +18,10 @@ // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2008-2011, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008-2011, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2011 Kenji Uno <ku@digitaldolphins.jp> // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Pino Toscano <pino@kde.org> // Copyright (C) 2013 Jason Crain <jason@aquaticape.us> // Copyright (C) 2015 William Bader <williambader@hotmail.com> @@ -56,12 +56,8 @@ union GooStringFormatArg { Guint ui; long l; Gulong ul; -#ifdef LLONG_MAX long long ll; -#endif -#ifdef ULLONG_MAX unsigned long long ull; -#endif double f; char c; char *s; @@ -89,20 +85,16 @@ enum GooStringFormatType { fmtULongHexUpper, fmtULongOctal, fmtULongBinary, -#ifdef LLONG_MAX fmtLongLongDecimal, fmtLongLongHex, fmtLongLongHexUpper, fmtLongLongOctal, fmtLongLongBinary, -#endif -#ifdef ULLONG_MAX fmtULongLongDecimal, fmtULongLongHex, fmtULongLongHexUpper, fmtULongLongOctal, fmtULongLongBinary, -#endif fmtDouble, fmtDoubleTrimSmallAware, fmtDoubleTrim, @@ -115,12 +107,8 @@ enum GooStringFormatType { static const char *formatStrings[] = { "d", "x", "X", "o", "b", "ud", "ux", "uX", "uo", "ub", "ld", "lx", "lX", "lo", "lb", "uld", "ulx", "ulX", "ulo", "ulb", -#ifdef LLONG_MAX "lld", "llx", "llX", "llo", "llb", -#endif -#ifdef ULLONG_MAX "ulld", "ullx", "ullX", "ullo", "ullb", -#endif "f", "gs", "g", "c", "s", @@ -424,7 +412,6 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { case fmtULongBinary: args[argsLen].ul = va_arg(argList, Gulong); break; -#ifdef LLONG_MAX case fmtLongLongDecimal: case fmtLongLongHex: case fmtLongLongHexUpper: @@ -432,8 +419,6 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { case fmtLongLongBinary: args[argsLen].ll = va_arg(argList, long long); break; -#endif -#ifdef ULLONG_MAX case fmtULongLongDecimal: case fmtULongLongHex: case fmtULongLongHexUpper: @@ -441,7 +426,6 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { case fmtULongLongBinary: args[argsLen].ull = va_arg(argList, unsigned long long); break; -#endif case fmtDouble: case fmtDoubleTrim: case fmtDoubleTrimSmallAware: @@ -531,7 +515,6 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { case fmtULongBinary: formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 2, &str, &len); break; -#ifdef LLONG_MAX case fmtLongLongDecimal: formatInt(arg.ll, buf, sizeof(buf), zeroFill, width, 10, &str, &len); break; @@ -548,8 +531,6 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { case fmtLongLongBinary: formatInt(arg.ll, buf, sizeof(buf), zeroFill, width, 2, &str, &len); break; -#endif -#ifdef ULLONG_MAX case fmtULongLongDecimal: formatUInt(arg.ull, buf, sizeof(buf), zeroFill, width, 10, &str, &len); @@ -570,7 +551,6 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { formatUInt(arg.ull, buf, sizeof(buf), zeroFill, width, 2, &str, &len); break; -#endif case fmtDouble: formatDouble(arg.f, buf, sizeof(buf), prec, gFalse, &str, &len); break; @@ -641,23 +621,13 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) { static const char lowerCaseDigits[17] = "0123456789abcdef"; static const char upperCaseDigits[17] = "0123456789ABCDEF"; -#ifdef LLONG_MAX void GooString::formatInt(long long x, char *buf, int bufSize, GBool zeroFill, int width, int base, char **p, int *len, GBool upperCase) { -#else -void GooString::formatInt(long x, char *buf, int bufSize, - GBool zeroFill, int width, int base, - char **p, int *len, GBool upperCase) { -#endif const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits; GBool neg; int start, i, j; -#ifdef LLONG_MAX unsigned long long abs_x; -#else - unsigned long abs_x; -#endif i = bufSize; if ((neg = x < 0)) { @@ -686,15 +656,9 @@ void GooString::formatInt(long x, char *buf, int bufSize, *len = bufSize - i; } -#ifdef ULLONG_MAX void GooString::formatUInt(unsigned long long x, char *buf, int bufSize, GBool zeroFill, int width, int base, char **p, int *len, GBool upperCase) { -#else -void GooString::formatUInt(Gulong x, char *buf, int bufSize, - GBool zeroFill, int width, int base, - char **p, int *len, GBool upperCase) { -#endif const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits; int i, j; @@ -917,7 +881,13 @@ GBool GooString::hasUnicodeMarker(void) const return length > 1 && (s[0] & 0xff) == 0xfe && (s[1] & 0xff) == 0xff; } -GooString *GooString::sanitizedName(GBool psmode) +void GooString::prependUnicodeMarker() +{ + insert(0, (char)0xff); + insert(0, (char)0xfe); +} + +GooString *GooString::sanitizedName(GBool psmode) const { GooString *name; char buf[8]; diff --git a/Build/source/libs/poppler/poppler-src/goo/GooString.h b/Build/source/libs/poppler/poppler-src/goo/GooString.h index 5deeda7e870..49f2888eb28 100644 --- a/Build/source/libs/poppler/poppler-src/goo/GooString.h +++ b/Build/source/libs/poppler/poppler-src/goo/GooString.h @@ -17,11 +17,12 @@ // // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> -// Copyright (C) 2008-2010, 2012, 2014 Albert Astals Cid <aacid@kde.org> +// 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) 2016 Jakub Alba <jakubalba@gmail.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -35,22 +36,6 @@ #pragma interface #endif -#include <limits.h> // for LLONG_MAX and ULLONG_MAX - -/* <limits.h> and/or the compiler may or may not define these. */ -/* Minimum and maximum values a `signed long long int' can hold. */ -#ifndef LLONG_MAX -# define LLONG_MAX 9223372036854775807LL -#endif -#ifndef LLONG_MIN -# define LLONG_MIN (-LLONG_MAX - 1LL) -#endif - -/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ -#ifndef ULLONG_MAX -# define ULLONG_MAX 18446744073709551615ULL -#endif - #include <stdarg.h> #include <stdlib.h> // for NULL #include "gtypes.h" @@ -176,13 +161,14 @@ public: GBool endsWith(const char *suffix) const; GBool hasUnicodeMarker(void) const; + void prependUnicodeMarker(); GBool hasJustUnicodeMarker(void) const { return length == 2 && hasUnicodeMarker(); } // Sanitizes the string so that it does // not contain any ( ) < > [ ] { } / % // The postscript mode also has some more strict checks // The caller owns the return value - GooString *sanitizedName(GBool psmode); + GooString *sanitizedName(GBool psmode) const; private: GooString(const GooString &other); @@ -201,24 +187,12 @@ private: char *s; void resize(int newLength); -#ifdef LLONG_MAX static void formatInt(long long x, char *buf, int bufSize, GBool zeroFill, int width, int base, char **p, int *len, GBool upperCase = gFalse); -#else - static void formatInt(long x, char *buf, int bufSize, - GBool zeroFill, int width, int base, - char **p, int *len, GBool upperCase = gFalse); -#endif -#ifdef ULLONG_MAX static void formatUInt(unsigned long long x, char *buf, int bufSize, GBool zeroFill, int width, int base, char **p, int *len, GBool upperCase = gFalse); -#else - static void formatUInt(Gulong x, char *buf, int bufSize, - GBool zeroFill, int width, int base, - char **p, int *len, GBool upperCase = gFalse); -#endif static void formatDouble(double x, char *buf, int bufSize, int prec, GBool trim, char **p, int *len); static void formatDoubleSmallAware(double x, char *buf, int bufSize, int prec, diff --git a/Build/source/libs/poppler/poppler-src/goo/JpegWriter.cc b/Build/source/libs/poppler/poppler-src/goo/JpegWriter.cc index 9b7c5051838..37c15c2ab85 100644 --- a/Build/source/libs/poppler/poppler-src/goo/JpegWriter.cc +++ b/Build/source/libs/poppler/poppler-src/goo/JpegWriter.cc @@ -5,10 +5,11 @@ // This file is licensed under the GPLv2 or later // // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010, 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2010, 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org> // Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de> +// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -30,7 +31,7 @@ struct JpegWriterPrivate { struct jpeg_error_mgr jerr; }; -void outputMessage(j_common_ptr cinfo) +static void outputMessage(j_common_ptr cinfo) { char buffer[JMSG_LENGTH_MAX]; @@ -64,6 +65,16 @@ JpegWriter::~JpegWriter() delete priv; } +void JpegWriter::setQuality(int quality) +{ + priv->quality = quality; +} + +void JpegWriter::setProgressive(bool progressive) +{ + priv->progressive = progressive; +} + bool JpegWriter::init(FILE *f, int width, int height, int hDPI, int vDPI) { // Setup error handler diff --git a/Build/source/libs/poppler/poppler-src/goo/JpegWriter.h b/Build/source/libs/poppler/poppler-src/goo/JpegWriter.h index d69bbbb8dda..9a68bcc9180 100644 --- a/Build/source/libs/poppler/poppler-src/goo/JpegWriter.h +++ b/Build/source/libs/poppler/poppler-src/goo/JpegWriter.h @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010, 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2010, 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2010 Jürg Billeter <j@bitron.ch> // Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org> // Copyright (C) 2010 Brian Cameron <brian.cameron@oracle.com> @@ -39,13 +39,15 @@ public: JpegWriter(Format format = RGB); ~JpegWriter(); - bool init(FILE *f, int width, int height, int hDPI, int vDPI); + void setQuality(int quality); + void setProgressive(bool progressive); + bool init(FILE *f, int width, int height, int hDPI, int vDPI) override; - bool writePointers(unsigned char **rowPointers, int rowCount); - bool writeRow(unsigned char **row); + bool writePointers(unsigned char **rowPointers, int rowCount) override; + bool writeRow(unsigned char **row) override; - bool close(); - bool supportCMYK(); + bool close() override; + bool supportCMYK() override; private: JpegWriter(const JpegWriter &other); diff --git a/Build/source/libs/poppler/poppler-src/goo/Makefile.am b/Build/source/libs/poppler/poppler-src/goo/Makefile.am deleted file mode 100644 index 004775a487c..00000000000 --- a/Build/source/libs/poppler/poppler-src/goo/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -noinst_LTLIBRARIES = libgoo.la - -if ENABLE_XPDF_HEADERS - -poppler_goo_includedir = $(includedir)/poppler/goo -poppler_goo_include_HEADERS = \ - GooHash.h \ - GooList.h \ - GooTimer.h \ - GooMutex.h \ - GooString.h \ - gtypes.h \ - gmem.h \ - gfile.h \ - FixedPoint.h \ - NetPBMWriter.h \ - PNGWriter.h \ - JpegWriter.h \ - TiffWriter.h \ - ImgWriter.h \ - GooLikely.h \ - gstrtod.h \ - grandom.h - -endif - -libgoo_la_SOURCES = \ - gfile.cc \ - gmempp.cc \ - GooHash.cc \ - GooList.cc \ - GooTimer.cc \ - GooString.cc \ - gmem.cc \ - FixedPoint.cc \ - NetPBMWriter.cc \ - PNGWriter.cc \ - JpegWriter.cc \ - TiffWriter.cc \ - ImgWriter.cc \ - gtypes_p.h \ - gstrtod.cc \ - grandom.cc \ - glibc.cc - -if BUILD_LIBJPEG -libjpeg_includes = $(LIBJPEG_CFLAGS) -endif - -if BUILD_LIBTIFF -libtiff_includes = $(LIBTIFF_CFLAGS) -endif - -if BUILD_LIBOPENJPEG -libjpeg2000_includes = $(LIBOPENJPEG_CFLAGS) -endif - -if BUILD_LIBPNG -libpng_includes = $(LIBPNG_CFLAGS) -endif - -libgoo_la_CPPFLAGS = \ - -I$(top_srcdir) \ - $(libjpeg_includes) \ - $(libtiff_includes) \ - $(libjpeg2000_includes) \ - $(libpng_includes) - -EXTRA_DIST = glibc.h
\ No newline at end of file diff --git a/Build/source/libs/poppler/poppler-src/goo/NetPBMWriter.h b/Build/source/libs/poppler/poppler-src/goo/NetPBMWriter.h index 21a19ee7508..ffdd7e17513 100644 --- a/Build/source/libs/poppler/poppler-src/goo/NetPBMWriter.h +++ b/Build/source/libs/poppler/poppler-src/goo/NetPBMWriter.h @@ -36,12 +36,12 @@ public: NetPBMWriter(Format formatA = RGB); ~NetPBMWriter() {}; - bool init(FILE *f, int width, int height, int hDPI, int vDPI); + bool init(FILE *f, int width, int height, int hDPI, int vDPI) override; - bool writePointers(unsigned char **rowPointers, int rowCount); - bool writeRow(unsigned char **row); + bool writePointers(unsigned char **rowPointers, int rowCount) override; + bool writeRow(unsigned char **row) override; - bool close(); + bool close() override; private: FILE *file; diff --git a/Build/source/libs/poppler/poppler-src/goo/PNGWriter.cc b/Build/source/libs/poppler/poppler-src/goo/PNGWriter.cc index c9d5199d040..ed06edb3d15 100644 --- a/Build/source/libs/poppler/poppler-src/goo/PNGWriter.cc +++ b/Build/source/libs/poppler/poppler-src/goo/PNGWriter.cc @@ -8,7 +8,7 @@ // Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> // Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010, 2011, 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2010, 2011, 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2011 Thomas Klausner <wiz@danbala.tuwien.ac.at> // Copyright (C) 2012 Pino Toscano <pino@kde.org> // @@ -117,6 +117,10 @@ bool PNGWriter::init(FILE *f, int width, int height, int hDPI, int vDPI) bit_depth = 8; color_type = PNG_COLOR_TYPE_RGB; break; + case RGB48: + bit_depth = 16; + color_type = PNG_COLOR_TYPE_RGB; + break; case RGBA: bit_depth = 8; color_type = PNG_COLOR_TYPE_RGB_ALPHA; diff --git a/Build/source/libs/poppler/poppler-src/goo/PNGWriter.h b/Build/source/libs/poppler/poppler-src/goo/PNGWriter.h index 90a298e7ef3..93f54369290 100644 --- a/Build/source/libs/poppler/poppler-src/goo/PNGWriter.h +++ b/Build/source/libs/poppler/poppler-src/goo/PNGWriter.h @@ -8,7 +8,7 @@ // Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> // Copyright (C) 2009, 2011-2013 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010, 2011, 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2010, 2011, 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Pino Toscano <pino@kde.org> // //======================================================================== @@ -32,8 +32,9 @@ public: * RGBA - 4 bytes/pixel * GRAY - 1 byte/pixel * MONOCHROME - 8 pixels/byte + * RGB48 - 6 bytes/pixel */ - enum Format { RGB, RGBA, GRAY, MONOCHROME }; + enum Format { RGB, RGBA, GRAY, MONOCHROME, RGB48 }; PNGWriter(Format format = RGB); ~PNGWriter(); @@ -42,12 +43,12 @@ public: void setSRGBProfile(); - bool init(FILE *f, int width, int height, int hDPI, int vDPI); + bool init(FILE *f, int width, int height, int hDPI, int vDPI) override; - bool writePointers(unsigned char **rowPointers, int rowCount); - bool writeRow(unsigned char **row); + bool writePointers(unsigned char **rowPointers, int rowCount) override; + bool writeRow(unsigned char **row) override; - bool close(); + bool close() override; private: PNGWriter(const PNGWriter &other); diff --git a/Build/source/libs/poppler/poppler-src/goo/TiffWriter.cc b/Build/source/libs/poppler/poppler-src/goo/TiffWriter.cc index 316008778b1..35ceae69f6a 100644 --- a/Build/source/libs/poppler/poppler-src/goo/TiffWriter.cc +++ b/Build/source/libs/poppler/poppler-src/goo/TiffWriter.cc @@ -6,7 +6,7 @@ // // Copyright (C) 2010, 2012 William Bader <williambader@hotmail.com> // Copyright (C) 2012 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Pino Toscano <pino@kde.org> // Copyright (C) 2014 Steven Lee <roc.sky@gmail.com> // @@ -14,7 +14,7 @@ #include "TiffWriter.h" -#if ENABLE_LIBTIFF +#ifdef ENABLE_LIBTIFF #include <string.h> @@ -147,6 +147,12 @@ bool TiffWriter::init(FILE *openedFile, int width, int height, int hDPI, int vDP samplesperpixel = 4; photometric = PHOTOMETRIC_SEPARATED; break; + + case RGB48: + samplesperpixel = 3; + bitspersample = 16; + photometric = PHOTOMETRIC_RGB; + break; } // Open the file diff --git a/Build/source/libs/poppler/poppler-src/goo/TiffWriter.h b/Build/source/libs/poppler/poppler-src/goo/TiffWriter.h index 52fdd53efa5..9126e8847c0 100644 --- a/Build/source/libs/poppler/poppler-src/goo/TiffWriter.h +++ b/Build/source/libs/poppler/poppler-src/goo/TiffWriter.h @@ -6,7 +6,7 @@ // // Copyright (C) 2010, 2012 William Bader <williambader@hotmail.com> // Copyright (C) 2011, 2012 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Pino Toscano <pino@kde.org> // //======================================================================== @@ -31,22 +31,23 @@ public: * GRAY - 1 byte/pixel * MONOCHROME - 8 pixels/byte * CMYK - 4 bytes/pixel + * RGB48 - 6 bytes/pixel */ - enum Format { RGB, RGBA_PREMULTIPLIED, GRAY, MONOCHROME, CMYK }; + enum Format { RGB, RGBA_PREMULTIPLIED, GRAY, MONOCHROME, CMYK, RGB48 }; TiffWriter(Format format = RGB); ~TiffWriter(); void setCompressionString(const char *compressionStringArg); - bool init(FILE *openedFile, int width, int height, int hDPI, int vDPI); + bool init(FILE *openedFile, int width, int height, int hDPI, int vDPI) override; - bool writePointers(unsigned char **rowPointers, int rowCount); - bool writeRow(unsigned char **rowData); + bool writePointers(unsigned char **rowPointers, int rowCount) override; + bool writeRow(unsigned char **rowData) override; - bool supportCMYK() { return true; } + bool supportCMYK() override { return true; } - bool close(); + bool close() override; private: TiffWriter(const TiffWriter &other); diff --git a/Build/source/libs/poppler/poppler-src/goo/gfile.cc b/Build/source/libs/poppler/poppler-src/goo/gfile.cc index 3528bb357d8..fe05de67b5e 100644 --- a/Build/source/libs/poppler/poppler-src/goo/gfile.cc +++ b/Build/source/libs/poppler/poppler-src/goo/gfile.cc @@ -22,9 +22,10 @@ // Copyright (C) 2009, 2012, 2014 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org> // // 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 @@ -72,7 +73,7 @@ GooString *getCurrentDir() { #if defined(__EMX__) if (_getcwd2(buf, sizeof(buf))) #elif defined(_WIN32) - if (GetCurrentDirectory(sizeof(buf), buf)) + if (GetCurrentDirectoryA(sizeof(buf), buf)) #elif defined(ACORN) if (strcpy(buf, "@")) #elif defined(MACOS) @@ -134,7 +135,7 @@ GooString *appendToPath(GooString *path, const char *fileName) { tmp = new GooString(path); tmp->append('/'); tmp->append(fileName); - GetFullPathName(tmp->getCString(), sizeof(buf), buf, &fp); + GetFullPathNameA(tmp->getCString(), sizeof(buf), buf, &fp); delete tmp; path->clear(); path->append(buf); @@ -398,7 +399,7 @@ GBool openTempFile(GooString **name, FILE **f, const char *mode) { char *s; int fd; -#if HAVE_MKSTEMP +#ifdef HAVE_MKSTEMP if ((s = getenv("TMPDIR"))) { *name = new GooString(s); } else { @@ -422,7 +423,7 @@ GBool openTempFile(GooString **name, FILE **f, const char *mode) { #endif } -#ifdef WIN32 +#ifdef _WIN32 GooString *fileNameToUTF8(char *path) { GooString *s; char *p; @@ -461,7 +462,7 @@ GooString *fileNameToUTF8(wchar_t *path) { #endif FILE *openFile(const char *path, const char *mode) { -#ifdef WIN32 +#ifdef _WIN32 OSVERSIONINFO version; wchar_t wPath[_MAX_PATH + 1]; char nPath[_MAX_PATH + 1]; @@ -553,13 +554,13 @@ char *getLine(char *buf, int size, FILE *f) { } int Gfseek(FILE *f, Goffset offset, int whence) { -#if HAVE_FSEEKO +#if defined(HAVE_FSEEKO) return fseeko(f, offset, whence); -#elif HAVE_FSEEK64 +#elif defined(HAVE_FSEEK64) return fseek64(f, offset, whence); #elif defined(__MINGW32__) return fseeko64(f, offset, whence); -#elif _WIN32 +#elif defined(_WIN32) return _fseeki64(f, offset, whence); #else return fseek(f, offset, whence); @@ -567,13 +568,13 @@ int Gfseek(FILE *f, Goffset offset, int whence) { } Goffset Gftell(FILE *f) { -#if HAVE_FSEEKO +#if defined(HAVE_FSEEKO) return ftello(f); -#elif HAVE_FSEEK64 +#elif defined(HAVE_FSEEK64) return ftell64(f); #elif defined(__MINGW32__) return ftello64(f); -#elif _WIN32 +#elif defined(_WIN32) return _ftelli64(f); #else return ftell(f); @@ -581,11 +582,11 @@ Goffset Gftell(FILE *f) { } Goffset GoffsetMax() { -#if HAVE_FSEEKO +#if defined(HAVE_FSEEKO) return (std::numeric_limits<off_t>::max)(); -#elif HAVE_FSEEK64 || defined(__MINGW32__) +#elif defined(HAVE_FSEEK64) || defined(__MINGW32__) return (std::numeric_limits<off64_t>::max)(); -#elif _WIN32 +#elif defined(_WIN32) return (std::numeric_limits<__int64>::max)(); #else return (std::numeric_limits<long>::max)(); @@ -620,7 +621,7 @@ Goffset GooFile::size() const { } GooFile* GooFile::open(const GooString *fileName) { - HANDLE handle = CreateFile(fileName->getCString(), + HANDLE handle = CreateFileA(fileName->getCString(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, @@ -697,7 +698,7 @@ GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) { #elif defined(ACORN) #else #ifdef _WIN32 - fa = GetFileAttributes(fullPath->getCString()); + fa = GetFileAttributesA(fullPath->getCString()); dir = (fa != 0xFFFFFFFF && (fa & FILE_ATTRIBUTE_DIRECTORY)); #else if (stat(fullPath->getCString(), &st) == 0) @@ -720,7 +721,7 @@ GDir::GDir(char *name, GBool doStatA) { tmp = path->copy(); tmp->append("/*.*"); - hnd = FindFirstFile(tmp->getCString(), &ffd); + hnd = FindFirstFileA(tmp->getCString(), &ffd); delete tmp; #elif defined(ACORN) #elif defined(MACOS) @@ -753,7 +754,7 @@ GDirEntry *GDir::getNextEntry() { #if defined(_WIN32) if (hnd != INVALID_HANDLE_VALUE) { e = new GDirEntry(path->getCString(), ffd.cFileName, doStat); - if (!FindNextFile(hnd, &ffd)) { + if (!FindNextFileA(hnd, &ffd)) { FindClose(hnd); hnd = INVALID_HANDLE_VALUE; } @@ -797,7 +798,7 @@ void GDir::rewind() { FindClose(hnd); tmp = path->copy(); tmp->append("/*.*"); - hnd = FindFirstFile(tmp->getCString(), &ffd); + hnd = FindFirstFileA(tmp->getCString(), &ffd); delete tmp; #elif defined(ACORN) #elif defined(MACOS) diff --git a/Build/source/libs/poppler/poppler-src/goo/gfile.h b/Build/source/libs/poppler/poppler-src/goo/gfile.h index 1365a9cf2ab..805e5232262 100644 --- a/Build/source/libs/poppler/poppler-src/goo/gfile.h +++ b/Build/source/libs/poppler/poppler-src/goo/gfile.h @@ -19,9 +19,10 @@ // Copyright (C) 2009, 2011, 2012 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com> // Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de> +// Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org> // // 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 @@ -52,21 +53,21 @@ extern "C" { #else # include <unistd.h> # include <sys/types.h> -# ifdef VMS +# if defined(VMS) # include "vms_dirent.h" -# elif HAVE_DIRENT_H +# elif defined(HAVE_DIRENT_H) # include <dirent.h> # define NAMLEN(d) strlen((d)->d_name) # else # define dirent direct # define NAMLEN(d) (d)->d_namlen -# if HAVE_SYS_NDIR_H +# ifdef HAVE_SYS_NDIR_H # include <sys/ndir.h> # endif -# if HAVE_SYS_DIR_H +# ifdef HAVE_SYS_DIR_H # include <sys/dir.h> # endif -# if HAVE_NDIR_H +# ifdef HAVE_NDIR_H # include <ndir.h> # endif # endif @@ -104,7 +105,7 @@ extern time_t getModTime(char *fileName); // should be "w" or "wb". Returns true on success. extern GBool openTempFile(GooString **name, FILE **f, const char *mode); -#ifdef WIN32 +#ifdef _WIN32 // Convert a file name from Latin-1 to UTF-8. extern GooString *fileNameToUTF8(char *path); @@ -194,7 +195,7 @@ private: GooString *path; // directory path GBool doStat; // call stat() for each entry? #if defined(_WIN32) - WIN32_FIND_DATA ffd; + WIN32_FIND_DATAA ffd; HANDLE hnd; #elif defined(ACORN) #elif defined(MACOS) diff --git a/Build/source/libs/poppler/poppler-src/goo/glibc.h b/Build/source/libs/poppler/poppler-src/goo/glibc.h index 49479e9d2a6..8b372bcaa30 100644 --- a/Build/source/libs/poppler/poppler-src/goo/glibc.h +++ b/Build/source/libs/poppler/poppler-src/goo/glibc.h @@ -6,7 +6,7 @@ // // This file is licensed under the GPLv2 or later // -// Copyright (C) 2016 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2016, 2017 Adrian Johnson <ajohnson@redneon.com> // //======================================================================== @@ -31,7 +31,11 @@ struct tm *localtime_r(const time_t *timep, struct tm *result); time_t timegm(struct tm *tm); #endif -}; +#ifndef HAVE_STRTOK_R +char * strtok_r (char *s, const char *delim, char **save_ptr); +#endif + +} #endif // GLIBC_H diff --git a/Build/source/libs/poppler/poppler-src/poppler/strtok_r.cpp b/Build/source/libs/poppler/poppler-src/goo/glibc_strtok_r.cc index 6483e0f7be9..e779bf50a2f 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/strtok_r.cpp +++ b/Build/source/libs/poppler/poppler-src/goo/glibc_strtok_r.cc @@ -49,13 +49,15 @@ // // Copyright (C) 2012 Alexey Pavlov <alexpux@gmail.com> // Copyright (C) 2012 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 // //======================================================================== -#if defined(__MINGW32__) && !defined(__WINPTHREADS_VERSION) +#ifndef HAVE_STRTOK_R + #include <string.h> #define __rawmemchr strchr @@ -89,4 +91,5 @@ char * strtok_r (char *s, const char *delim, char **save_ptr) } return token; } + #endif diff --git a/Build/source/libs/poppler/poppler-src/goo/gmem.h b/Build/source/libs/poppler/poppler-src/goo/gmem.h index 898f33933f9..4c76f0fb65e 100644 --- a/Build/source/libs/poppler/poppler-src/goo/gmem.h +++ b/Build/source/libs/poppler/poppler-src/goo/gmem.h @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2007-2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007-2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> // // To see a description of the changes please see the Changelog file that @@ -44,7 +44,7 @@ extern void *gmalloc_checkoverflow(size_t size); * returns NULL. If <p> is NULL, calls malloc instead of realloc(). */ extern void *grealloc(void *p, size_t size); -extern void *grealloc_checkoverflow(size_t size); +extern void *grealloc_checkoverflow(void *p, size_t size); /* * These are similar to gmalloc and grealloc, but take an object count diff --git a/Build/source/libs/poppler/poppler-src/goo/gtypes_p.h b/Build/source/libs/poppler/poppler-src/goo/gtypes_p.h deleted file mode 100644 index cc4866e1389..00000000000 --- a/Build/source/libs/poppler/poppler-src/goo/gtypes_p.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * gtypes_p.h - * - * Some useful simple types. - * - * Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com> - */ - -#ifndef GTYPES_P_H -#define GTYPES_P_H - -#include "config.h" - -/* - * Define precise integer types. - */ -#if HAVE_STDINT_H -#include <stdint.h> -#elif _MSC_VER -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -#endif - -#endif diff --git a/Build/source/libs/poppler/poppler-src/gtk-doc.make b/Build/source/libs/poppler/poppler-src/gtk-doc.make deleted file mode 100644 index e4a12a5b255..00000000000 --- a/Build/source/libs/poppler/poppler-src/gtk-doc.make +++ /dev/null @@ -1,304 +0,0 @@ -# -*- mode: makefile -*- - -#################################### -# Everything below here is generic # -#################################### - -if GTK_DOC_USE_LIBTOOL -GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -GTKDOC_RUN = $(LIBTOOL) --mode=execute -else -GTKDOC_CC = $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -GTKDOC_LD = $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -GTKDOC_RUN = -endif - -# We set GPATH here; this gives us semantics for GNU make -# which are more like other make's VPATH, when it comes to -# whether a source that is a target of one rule is then -# searched for in VPATH/GPATH. -# -GPATH = $(srcdir) - -TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) - -SETUP_FILES = \ - $(content_files) \ - $(expand_content_files) \ - $(DOC_MAIN_SGML_FILE) \ - $(DOC_MODULE)-sections.txt \ - $(DOC_MODULE)-overrides.txt - -EXTRA_DIST = \ - $(HTML_IMAGES) \ - $(SETUP_FILES) - -DOC_STAMPS=setup-build.stamp scan-build.stamp sgml-build.stamp \ - html-build.stamp pdf-build.stamp \ - sgml.stamp html.stamp pdf.stamp - -SCANOBJ_FILES = \ - $(DOC_MODULE).args \ - $(DOC_MODULE).hierarchy \ - $(DOC_MODULE).interfaces \ - $(DOC_MODULE).prerequisites \ - $(DOC_MODULE).signals - -REPORT_FILES = \ - $(DOC_MODULE)-undocumented.txt \ - $(DOC_MODULE)-undeclared.txt \ - $(DOC_MODULE)-unused.txt - -gtkdoc-check.test: Makefile - $(AM_V_GEN)echo "#!/bin/sh -e" > $@; \ - echo "$(GTKDOC_CHECK_PATH) || exit 1" >> $@; \ - chmod +x $@ - -CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) gtkdoc-check.test - -if GTK_DOC_BUILD_HTML -HTML_BUILD_STAMP=html-build.stamp -else -HTML_BUILD_STAMP= -endif -if GTK_DOC_BUILD_PDF -PDF_BUILD_STAMP=pdf-build.stamp -else -PDF_BUILD_STAMP= -endif - -all-gtk-doc: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) -.PHONY: all-gtk-doc - -if ENABLE_GTK_DOC -all-local: all-gtk-doc -endif - -docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) - -$(REPORT_FILES): sgml-build.stamp - -#### setup #### - -GTK_DOC_V_SETUP=$(GTK_DOC_V_SETUP_$(V)) -GTK_DOC_V_SETUP_=$(GTK_DOC_V_SETUP_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_SETUP_0=@echo " DOC Preparing build"; - -setup-build.stamp: - -$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ - files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \ - if test "x$$files" != "x" ; then \ - for file in $$files ; do \ - destdir=`dirname $(abs_builddir)/$$file`; \ - test -d "$$destdir" || mkdir -p "$$destdir"; \ - test -f $(abs_srcdir)/$$file && \ - cp -pf $(abs_srcdir)/$$file $(abs_builddir)/$$file || true; \ - done; \ - fi; \ - fi - $(AM_V_at)touch setup-build.stamp - - -#### scan #### - -GTK_DOC_V_SCAN=$(GTK_DOC_V_SCAN_$(V)) -GTK_DOC_V_SCAN_=$(GTK_DOC_V_SCAN_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_SCAN_0=@echo " DOC Scanning header files"; - -GTK_DOC_V_INTROSPECT=$(GTK_DOC_V_INTROSPECT_$(V)) -GTK_DOC_V_INTROSPECT_=$(GTK_DOC_V_INTROSPECT_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_INTROSPECT_0=@echo " DOC Introspecting gobjects"; - -scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB) - $(GTK_DOC_V_SCAN)_source_dir='' ; \ - for i in $(DOC_SOURCE_DIR) ; do \ - _source_dir="$${_source_dir} --source-dir=$$i" ; \ - done ; \ - gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES) - $(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \ - scanobj_options=""; \ - gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$$?" = "0"; then \ - if test "x$(V)" = "x1"; then \ - scanobj_options="--verbose"; \ - fi; \ - fi; \ - CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" \ - gtkdoc-scangobj $(SCANGOBJ_OPTIONS) $$scanobj_options --module=$(DOC_MODULE); \ - else \ - for i in $(SCANOBJ_FILES) ; do \ - test -f $$i || touch $$i ; \ - done \ - fi - $(AM_V_at)touch scan-build.stamp - -$(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp - @true - -#### xml #### - -GTK_DOC_V_XML=$(GTK_DOC_V_XML_$(V)) -GTK_DOC_V_XML_=$(GTK_DOC_V_XML_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_XML_0=@echo " DOC Building XML"; - -sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(HFILE_GLOB) $(CFILE_GLOB) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files) xml/gtkdocentities.ent - $(GTK_DOC_V_XML)_source_dir='' ; \ - for i in $(DOC_SOURCE_DIR) ; do \ - _source_dir="$${_source_dir} --source-dir=$$i" ; \ - done ; \ - gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS) - $(AM_V_at)touch sgml-build.stamp - -sgml.stamp: sgml-build.stamp - @true - -xml/gtkdocentities.ent: Makefile - $(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \ - echo "<!ENTITY package \"$(PACKAGE)\">"; \ - echo "<!ENTITY package_bugreport \"$(PACKAGE_BUGREPORT)\">"; \ - echo "<!ENTITY package_name \"$(PACKAGE_NAME)\">"; \ - echo "<!ENTITY package_string \"$(PACKAGE_STRING)\">"; \ - echo "<!ENTITY package_tarname \"$(PACKAGE_TARNAME)\">"; \ - echo "<!ENTITY package_url \"$(PACKAGE_URL)\">"; \ - echo "<!ENTITY package_version \"$(PACKAGE_VERSION)\">"; \ - ) > $@ - -#### html #### - -GTK_DOC_V_HTML=$(GTK_DOC_V_HTML_$(V)) -GTK_DOC_V_HTML_=$(GTK_DOC_V_HTML_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_HTML_0=@echo " DOC Building HTML"; - -GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_$(V)) -GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references"; - -html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files) - $(GTK_DOC_V_HTML)rm -rf html && mkdir html && \ - mkhtml_options=""; \ - gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$$?" = "0"; then \ - if test "x$(V)" = "x1"; then \ - mkhtml_options="$$mkhtml_options --verbose"; \ - fi; \ - fi; \ - gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \ - if test "$$?" = "0"; then \ - mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \ - fi; \ - cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) - -@test "x$(HTML_IMAGES)" = "x" || \ - for file in $(HTML_IMAGES) ; do \ - if test -f $(abs_srcdir)/$$file ; then \ - cp $(abs_srcdir)/$$file $(abs_builddir)/html; \ - fi; \ - if test -f $(abs_builddir)/$$file ; then \ - cp $(abs_builddir)/$$file $(abs_builddir)/html; \ - fi; \ - done; - $(GTK_DOC_V_XREF)gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS) - $(AM_V_at)touch html-build.stamp - -#### pdf #### - -GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_$(V)) -GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_PDF_0=@echo " DOC Building PDF"; - -pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files) - $(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \ - mkpdf_options=""; \ - gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$$?" = "0"; then \ - if test "x$(V)" = "x1"; then \ - mkpdf_options="$$mkpdf_options --verbose"; \ - fi; \ - fi; \ - if test "x$(HTML_IMAGES)" != "x"; then \ - for img in $(HTML_IMAGES); do \ - part=`dirname $$img`; \ - echo $$mkpdf_options | grep >/dev/null "\-\-imgdir=$$part "; \ - if test $$? != 0; then \ - mkpdf_options="$$mkpdf_options --imgdir=$$part"; \ - fi; \ - done; \ - fi; \ - gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS) - $(AM_V_at)touch pdf-build.stamp - -############## - -clean-local: - @rm -f *~ *.bak - @rm -rf .libs - @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \ - rm -f $(DOC_MODULE).types; \ - fi - @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \ - rm -f $(DOC_MODULE)-sections.txt; \ - fi - -distclean-local: - @rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \ - $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt - @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ - rm -f $(SETUP_FILES) $(DOC_MODULE).types; \ - fi - -maintainer-clean-local: - @rm -rf xml html - -install-data-local: - @installfiles=`echo $(builddir)/html/*`; \ - if test "$$installfiles" = '$(builddir)/html/*'; \ - then echo 1>&2 'Nothing to install' ; \ - else \ - if test -n "$(DOC_MODULE_VERSION)"; then \ - installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ - else \ - installdir="$(DESTDIR)$(TARGET_DIR)"; \ - fi; \ - $(mkinstalldirs) $${installdir} ; \ - for i in $$installfiles; do \ - echo ' $(INSTALL_DATA) '$$i ; \ - $(INSTALL_DATA) $$i $${installdir}; \ - done; \ - if test -n "$(DOC_MODULE_VERSION)"; then \ - mv -f $${installdir}/$(DOC_MODULE).devhelp2 \ - $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \ - fi; \ - $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \ - fi - -uninstall-local: - @if test -n "$(DOC_MODULE_VERSION)"; then \ - installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ - else \ - installdir="$(DESTDIR)$(TARGET_DIR)"; \ - fi; \ - rm -rf $${installdir} - -# -# Require gtk-doc when making dist -# -if HAVE_GTK_DOC -dist-check-gtkdoc: docs -else -dist-check-gtkdoc: - @echo "*** gtk-doc is needed to run 'make dist'. ***" - @echo "*** gtk-doc was not found when 'configure' ran. ***" - @echo "*** please install gtk-doc and rerun 'configure'. ***" - @false -endif - -dist-hook: dist-check-gtkdoc all-gtk-doc dist-hook-local - @mkdir $(distdir)/html - @cp ./html/* $(distdir)/html - @-cp ./$(DOC_MODULE).pdf $(distdir)/ - @-cp ./$(DOC_MODULE).types $(distdir)/ - @-cp ./$(DOC_MODULE)-sections.txt $(distdir)/ - @cd $(distdir) && rm -f $(DISTCLEANFILES) - @$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html - -.PHONY : dist-hook-local docs diff --git a/Build/source/libs/poppler/poppler-src/gtkdoc.py b/Build/source/libs/poppler/poppler-src/gtkdoc.py new file mode 100644 index 00000000000..48f862a31fa --- /dev/null +++ b/Build/source/libs/poppler/poppler-src/gtkdoc.py @@ -0,0 +1,440 @@ +# Copyright (C) 2011 Igalia S.L. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import errno +import logging +import os +import os.path +import subprocess +import sys + + +class GTKDoc(object): + + """Class that controls a gtkdoc run. + + Each instance of this class represents one gtkdoc configuration + and set of documentation. The gtkdoc package is a series of tools + run consecutively which converts inline C/C++ documentation into + docbook files and then into HTML. This class is suitable for + generating documentation or simply verifying correctness. + + Keyword arguments: + output_dir -- The path where gtkdoc output should be placed. Generation + may overwrite file in this directory. Required. + module_name -- The name of the documentation module. For libraries this + is typically the library name. Required if not library path + is given. + source_dirs -- A list of paths to directories of source code to be scanned. + Required if headers is not specified. + ignored_files -- A list of filenames to ignore in the source directory. It is + only necessary to provide the basenames of these files. + Typically it is important to provide an updated list of + ignored files to prevent warnings about undocumented symbols. + headers -- A list of paths to headers to be scanned. Required if source_dirs + is not specified. + namespace -- The library namespace. + decorator -- If a decorator is used to unhide certain symbols in header + files this parameter is required for successful scanning. + (default '') + deprecation_guard -- gtkdoc tries to ensure that symbols marked as deprecated + are encased in this C preprocessor define. This is required + to avoid gtkdoc warnings. (default '') + cflags -- This parameter specifies any preprocessor flags necessary for + building the scanner binary during gtkdoc-scanobj. Typically + this includes all absolute include paths necessary to resolve + all header dependencies. (default '') + ldflags -- This parameter specifies any linker flags necessary for + building the scanner binary during gtkdoc-scanobj. Typically + this includes "-lyourlibraryname". (default '') + library_path -- This parameter specifies the path to the directory where you + library resides used for building the scanner binary during + gtkdoc-scanobj. (default '') + + doc_dir -- The path to other documentation files necessary to build + the documentation. This files in this directory as well as + the files in the 'html' subdirectory will be copied + recursively into the output directory. (default '') + main_sgml_file -- The path or name (if a doc_dir is given) of the SGML file + that is the considered the main page of your documentation. + (default: <module_name>-docs.sgml) + version -- The version number of the module. If this is provided, + a version.xml file containing the version will be created + in the output directory during documentation generation. + + interactive -- Whether or not errors or warnings should prompt the user + to continue or not. When this value is false, generation + will continue despite warnings. (default False) + + virtual_root -- A temporary installation directory which is used as the root + where the actual installation prefix lives; this is mostly + useful for packagers, and should be set to what is given to + make install as DESTDIR. + """ + + def __init__(self, args): + + # Parameters specific to scanning. + self.module_name = '' + self.source_dirs = [] + self.headers = [] + self.ignored_files = [] + self.namespace = '' + self.decorator = '' + self.deprecation_guard = '' + + # Parameters specific to gtkdoc-scanobj. + self.cflags = '' + self.ldflags = '' + self.library_path = '' + + # Parameters specific to generation. + self.output_dir = '' + self.doc_dir = '' + self.main_sgml_file = '' + + # Parameters specific to gtkdoc-fixxref. + self.cross_reference_deps = [] + + self.interactive = False + + self.logger = logging.getLogger('gtkdoc') + + for key, value in iter(args.items()): + setattr(self, key, value) + + if not getattr(self, 'output_dir'): + raise Exception('output_dir not specified.') + if not getattr(self, 'module_name'): + raise Exception('module_name not specified.') + if not getattr(self, 'source_dirs') and not getattr(self, 'headers'): + raise Exception('Neither source_dirs nor headers specified.' % key) + + # Make all paths absolute in case we were passed relative paths, since + # we change the current working directory when executing subcommands. + self.output_dir = os.path.abspath(self.output_dir) + self.source_dirs = [os.path.abspath(x) for x in self.source_dirs] + self.headers = [os.path.abspath(x) for x in self.headers] + if self.library_path: + self.library_path = os.path.abspath(self.library_path) + + if not self.main_sgml_file: + self.main_sgml_file = self.module_name + "-docs.sgml" + + def generate(self, html=True): + self.saw_warnings = False + + self._copy_doc_files_to_output_dir(html) + self._write_version_xml() + self._run_gtkdoc_scan() + self._run_gtkdoc_scangobj() + self._run_gtkdoc_mkdb() + + if not html: + return + + self._run_gtkdoc_mkhtml() + self._run_gtkdoc_fixxref() + + def _delete_file_if_exists(self, path): + if not os.access(path, os.F_OK | os.R_OK): + return + self.logger.debug('deleting %s', path) + os.unlink(path) + + def _create_directory_if_nonexistent(self, path): + try: + os.makedirs(path) + except OSError as error: + if error.errno != errno.EEXIST: + raise + + def _raise_exception_if_file_inaccessible(self, path): + if not os.path.exists(path) or not os.access(path, os.R_OK): + raise Exception("Could not access file at: %s" % path) + + def _output_has_warnings(self, outputs): + for output in outputs: + if output and output.find('warning'): + return True + return False + + def _ask_yes_or_no_question(self, question): + if not self.interactive: + return True + + question += ' [y/N] ' + answer = None + while answer != 'y' and answer != 'n' and answer != '': + answer = raw_input(question).lower() + return answer == 'y' + + def _run_command(self, args, env=None, cwd=None, print_output=True, ignore_warnings=False): + if print_output: + self.logger.debug("Running %s", args[0]) + self.logger.debug("Full command args: %s", str(args)) + + process = subprocess.Popen(args, env=env, cwd=cwd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = [b.decode("utf-8") for b in process.communicate()] + + if print_output: + if stdout: + try: + sys.stdout.write(stdout.encode("utf-8")) + except UnicodeDecodeError: + sys.stdout.write(stdout) + if stderr: + try: + sys.stderr.write(stderr.encode("utf-8")) + except UnicodeDecodeError: + sys.stderr.write(stderr) + + if process.returncode != 0: + raise Exception('%s produced a non-zero return code %i' + % (args[0], process.returncode)) + + if not ignore_warnings and ('warning' in stderr or 'warning' in stdout): + self.saw_warnings = True + if not self._ask_yes_or_no_question('%s produced warnings, ' + 'try to continue?' % args[0]): + raise Exception('%s step failed' % args[0]) + + return stdout.strip() + + def _copy_doc_files_to_output_dir(self, html=True): + if not self.doc_dir: + self.logger.info('Not copying any files from doc directory,' + ' because no doc directory given.') + return + + def copy_file_replacing_existing(src, dest): + if os.path.isdir(src): + self.logger.debug('skipped directory %s', src) + return + if not os.access(src, os.F_OK | os.R_OK): + self.logger.debug('skipped unreadable %s', src) + return + + self._delete_file_if_exists(dest) + + self.logger.debug('created %s', dest) + try: + os.link(src, dest) + except OSError: + os.symlink(src, dest) + + def copy_all_files_in_directory(src, dest): + for path in os.listdir(src): + copy_file_replacing_existing(os.path.join(src, path), + os.path.join(dest, path)) + + self.logger.debug('Copying template files to output directory...') + self._create_directory_if_nonexistent(self.output_dir) + copy_all_files_in_directory(self.doc_dir, self.output_dir) + + if not html: + return + + self.logger.debug('Copying HTML files to output directory...') + html_src_dir = os.path.join(self.doc_dir, 'html') + html_dest_dir = os.path.join(self.output_dir, 'html') + self._create_directory_if_nonexistent(html_dest_dir) + + if os.path.exists(html_src_dir): + copy_all_files_in_directory(html_src_dir, html_dest_dir) + + def _write_version_xml(self): + if not self.version: + self.logger.info('No version specified, so not writing version.xml') + return + + version_xml_path = os.path.join(self.output_dir, 'version.xml') + src_version_xml_path = os.path.join(self.doc_dir, 'version.xml') + + # Don't overwrite version.xml if it was in the doc directory. + if os.path.exists(version_xml_path) and \ + os.path.exists(src_version_xml_path): + return + + output_file = open(version_xml_path, 'w') + output_file.write(self.version) + output_file.close() + + def _ignored_files_basenames(self): + return ' '.join([os.path.basename(x) for x in self.ignored_files]) + + def _run_gtkdoc_scan(self): + args = ['gtkdoc-scan', + '--module=%s' % self.module_name, + '--rebuild-types'] + + if not self.headers: + # Each source directory should be have its own "--source-dir=" prefix. + args.extend(['--source-dir=%s' % path for path in self.source_dirs]) + + if self.decorator: + args.append('--ignore-decorators=%s' % self.decorator) + if self.deprecation_guard: + args.append('--deprecated-guards=%s' % self.deprecation_guard) + if self.output_dir: + args.append('--output-dir=%s' % self.output_dir) + + # We only need to pass the list of ignored files if the we are not using an explicit list of headers. + if not self.headers: + # gtkdoc-scan wants the basenames of ignored headers, so strip the + # dirname. Different from "--source-dir", the headers should be + # specified as one long string. + ignored_files_basenames = self._ignored_files_basenames() + if ignored_files_basenames: + args.append('--ignore-headers=%s' % ignored_files_basenames) + + if self.headers: + args.extend(self.headers) + + self._run_command(args) + + def _run_gtkdoc_scangobj(self): + env = os.environ + ldflags = self.ldflags + if self.library_path: + additional_ldflags = '' + for arg in env.get('LDFLAGS', '').split(' '): + if arg.startswith('-L'): + additional_ldflags = '%s %s' % (additional_ldflags, arg) + ldflags = ' "-L%s" %s ' % (self.library_path, additional_ldflags) + ldflags + current_ld_library_path = env.get('LD_LIBRARY_PATH') + if current_ld_library_path: + env['RUN'] = 'LD_LIBRARY_PATH="%s:%s" ' % (self.library_path, current_ld_library_path) + else: + env['RUN'] = 'LD_LIBRARY_PATH="%s" ' % self.library_path + + if ldflags: + env['LDFLAGS'] = '%s %s' % (ldflags, env.get('LDFLAGS', '')) + if self.cflags: + env['CFLAGS'] = '%s %s' % (self.cflags, env.get('CFLAGS', '')) + + if 'CFLAGS' in env: + self.logger.debug('CFLAGS=%s', env['CFLAGS']) + if 'LDFLAGS' in env: + self.logger.debug('LDFLAGS %s', env['LDFLAGS']) + if 'RUN' in env: + self.logger.debug('RUN=%s', env['RUN']) + self._run_command(['gtkdoc-scangobj', '--module=%s' % self.module_name], + env=env, cwd=self.output_dir) + + def _run_gtkdoc_mkdb(self): + sgml_file = os.path.join(self.output_dir, self.main_sgml_file) + self._raise_exception_if_file_inaccessible(sgml_file) + + args = ['gtkdoc-mkdb', + '--module=%s' % self.module_name, + '--main-sgml-file=%s' % sgml_file, + '--source-suffixes=h,c,cpp,cc', + '--output-format=xml', + '--sgml-mode'] + + if self.namespace: + args.append('--name-space=%s' % self.namespace) + + ignored_files_basenames = self._ignored_files_basenames() + if ignored_files_basenames: + args.append('--ignore-files=%s' % ignored_files_basenames) + + # Each directory should be have its own "--source-dir=" prefix. + args.extend(['--source-dir=%s' % path for path in self.source_dirs]) + self._run_command(args, cwd=self.output_dir) + + def _run_gtkdoc_mkhtml(self): + html_dest_dir = os.path.join(self.output_dir, 'html') + if not os.path.isdir(html_dest_dir): + raise Exception("%s is not a directory, could not generate HTML" + % html_dest_dir) + elif not os.access(html_dest_dir, os.X_OK | os.R_OK | os.W_OK): + raise Exception("Could not access %s to generate HTML" + % html_dest_dir) + + # gtkdoc-mkhtml expects the SGML path to be absolute. + sgml_file = os.path.join(os.path.abspath(self.output_dir), + self.main_sgml_file) + self._raise_exception_if_file_inaccessible(sgml_file) + + self._run_command(['gtkdoc-mkhtml', self.module_name, sgml_file], + cwd=html_dest_dir) + + def _run_gtkdoc_fixxref(self): + args = ['gtkdoc-fixxref', + '--module=%s' % self.module_name, + '--module-dir=html', + '--html-dir=html'] + args.extend(['--extra-dir=%s' % extra_dir for extra_dir in self.cross_reference_deps]) + self._run_command(args, cwd=self.output_dir, ignore_warnings=True) + + def rebase_installed_docs(self): + if not os.path.isdir(self.output_dir): + raise Exception("Tried to rebase documentation before generating it.") + html_dir = os.path.join(self.virtual_root + self.prefix, 'share', 'gtk-doc', 'html', self.module_name) + if not os.path.isdir(html_dir): + return + args = ['gtkdoc-rebase', + '--relative', + '--html-dir=%s' % html_dir] + args.extend(['--other-dir=%s' % extra_dir for extra_dir in self.cross_reference_deps]) + if self.virtual_root: + args.extend(['--dest-dir=%s' % self.virtual_root]) + self._run_command(args, cwd=self.output_dir) + + def api_missing_documentation(self): + unused_doc_file = os.path.join(self.output_dir, self.module_name + "-unused.txt") + if not os.path.exists(unused_doc_file) or not os.access(unused_doc_file, os.R_OK): + return [] + return open(unused_doc_file).read().splitlines() + +class PkgConfigGTKDoc(GTKDoc): + + """Class reads a library's pkgconfig file to guess gtkdoc parameters. + + Some gtkdoc parameters can be guessed by reading a library's pkgconfig + file, including the cflags, ldflags and version parameters. If you + provide these parameters as well, they will be appended to the ones + guessed via the pkgconfig file. + + Keyword arguments: + pkg_config_path -- Path to the pkgconfig file for the library. Required. + """ + + def __init__(self, pkg_config_path, args): + super(PkgConfigGTKDoc, self).__init__(args) + + pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config') + + if not os.path.exists(pkg_config_path): + raise Exception('Could not find pkg-config file at: %s' + % pkg_config_path) + + self.cflags += " " + self._run_command([pkg_config, + pkg_config_path, + '--cflags'], print_output=False) + self.ldflags += " " + self._run_command([pkg_config, + pkg_config_path, + '--libs'], print_output=False) + self.version = self._run_command([pkg_config, + pkg_config_path, + '--modversion'], print_output=False) + self.prefix = self._run_command([pkg_config, + pkg_config_path, + '--variable=prefix'], print_output=False) diff --git a/Build/source/libs/poppler/poppler-src/make-glib-api-docs b/Build/source/libs/poppler/poppler-src/make-glib-api-docs new file mode 100755 index 00000000000..6fbe4494cf0 --- /dev/null +++ b/Build/source/libs/poppler/poppler-src/make-glib-api-docs @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# +# Copyright (C) 2017 Carlos Garcia Campos <carlosgc@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import argparse +import logging +import os +from gtkdoc import PkgConfigGTKDoc + +def configure_logging(verbose): + level = logging.DEBUG if verbose else logging.INFO + logger = logging.getLogger('gtkdoc') + logger.setLevel(level) + handler = logging.StreamHandler() + handler.setLevel(level) + logger.addHandler(handler) + if level == logging.DEBUG: + handler.setFormatter(logging.Formatter('[%(asctime)s] %(message)s')) + else: + handler.setFormatter(logging.Formatter('%(message)s')) + + +parser = argparse.ArgumentParser(description='Make poppler GLib API documentation.') +parser.add_argument('-v', '--verbose', action='store_true', default = False, + help='Whether or not to run in verbose mode.') +parser.add_argument('--skip-html', action='store_true', + help='Whether or not to skip HTML generation, which can be slow.') +parser.add_argument('-s', '--src-dir', action='store', default='.', dest='src_dir', + help='The source directory') +parser.add_argument('-b', '--build-dir', action='store', default='build', dest='build_dir', + help='The build directory') +args = parser.parse_args() +configure_logging(args.verbose) + +pkgconfig_file = os.path.join(args.build_dir, 'poppler-glib.pc') +pkgconfig_path = os.environ.get("PKG_CONFIG_PATH") +os.environ['PKG_CONFIG_PATH'] = args.build_dir +if pkgconfig_path: + os.environ['PKG_CONFIG_PATH'] += ':' + pkgconfig_path + +gtkdoc = PkgConfigGTKDoc(pkgconfig_file, { + 'library_path': os.path.join(args.build_dir, 'glib'), + 'module_name': 'poppler', + 'doc_dir': os.path.join(args.src_dir, 'glib', 'reference'), + 'output_dir': os.path.join(args.build_dir, 'glib', 'reference'), + 'main_sgml_file': 'poppler-docs.sgml', + 'source_dirs': [os.path.join(args.src_dir, 'glib')], + 'cflags': '-I%s' % os.path.join(args.src_dir, 'glib'), + 'ignored_files': ['poppler-private.h', 'poppler-input-stream.h', 'poppler-cached-file-loader.h', 'demo'] +}) + +gtkdoc.generate(not args.skip_html) diff --git a/Build/source/libs/poppler/poppler-src/poppler-cairo-uninstalled.pc.in b/Build/source/libs/poppler/poppler-src/poppler-cairo-uninstalled.pc.in deleted file mode 100644 index 2458eb20df8..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-cairo-uninstalled.pc.in +++ /dev/null @@ -1,6 +0,0 @@ -Name: poppler-cairo -Description: Cairo backend for Poppler PDF rendering library - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ cairo >= @CAIRO_VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/poppler/libpoppler-cairo.la diff --git a/Build/source/libs/poppler/poppler-src/poppler-cairo.pc.cmake b/Build/source/libs/poppler/poppler-src/poppler-cairo.pc.cmake index b32f118314b..e68cceab381 100644 --- a/Build/source/libs/poppler/poppler-src/poppler-cairo.pc.cmake +++ b/Build/source/libs/poppler/poppler-src/poppler-cairo.pc.cmake @@ -1,7 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Name: poppler-cairo Description: Cairo backend for Poppler PDF rendering library diff --git a/Build/source/libs/poppler/poppler-src/poppler-cairo.pc.in b/Build/source/libs/poppler/poppler-src/poppler-cairo.pc.in deleted file mode 100644 index 367a5b690bf..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-cairo.pc.in +++ /dev/null @@ -1,9 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-cairo -Description: Cairo backend for Poppler PDF rendering library -Version: @VERSION@ -Requires: poppler = @VERSION@ cairo >= @CAIRO_VERSION@ diff --git a/Build/source/libs/poppler/poppler-src/poppler-cpp-uninstalled.pc.in b/Build/source/libs/poppler/poppler-src/poppler-cpp-uninstalled.pc.in deleted file mode 100644 index af3640eb2c1..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-cpp-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-cpp -Description: cpp backend for Poppler PDF rendering library - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/cpp/libpoppler-cpp.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/cpp diff --git a/Build/source/libs/poppler/poppler-src/poppler-cpp.pc.cmake b/Build/source/libs/poppler/poppler-src/poppler-cpp.pc.cmake index 3f56b3d9d90..3eb68b3810c 100644 --- a/Build/source/libs/poppler/poppler-src/poppler-cpp.pc.cmake +++ b/Build/source/libs/poppler/poppler-src/poppler-cpp.pc.cmake @@ -1,7 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Name: poppler-cpp Description: cpp backend for Poppler PDF rendering library diff --git a/Build/source/libs/poppler/poppler-src/poppler-cpp.pc.in b/Build/source/libs/poppler/poppler-src/poppler-cpp.pc.in deleted file mode 100644 index a7e97c25dfe..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-cpp.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-cpp -Description: cpp backend for Poppler PDF rendering library -Version: @VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-cpp -Cflags: -I${includedir}/poppler/cpp diff --git a/Build/source/libs/poppler/poppler-src/poppler-glib-uninstalled.pc.in b/Build/source/libs/poppler/poppler-src/poppler-glib-uninstalled.pc.in deleted file mode 100644 index 5506c4e53ac..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-glib-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-glib -Description: GLib wrapper for poppler - uninstalled -Version: @VERSION@ -Requires: glib-2.0 >= @GLIB_REQUIRED@ gobject-2.0 >= @GLIB_REQUIRED@ gio-2.0 >= @GLIB_REQUIRED@ cairo >= @CAIRO_VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/glib/libpoppler-glib.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/glib diff --git a/Build/source/libs/poppler/poppler-src/poppler-glib.pc.cmake b/Build/source/libs/poppler/poppler-src/poppler-glib.pc.cmake index e15e6699a43..ac248192509 100644 --- a/Build/source/libs/poppler/poppler-src/poppler-glib.pc.cmake +++ b/Build/source/libs/poppler/poppler-src/poppler-glib.pc.cmake @@ -1,7 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Name: poppler-glib Description: GLib wrapper for poppler diff --git a/Build/source/libs/poppler/poppler-src/poppler-glib.pc.in b/Build/source/libs/poppler/poppler-src/poppler-glib.pc.in deleted file mode 100644 index cd30feb728f..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-glib.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-glib -Description: GLib wrapper for poppler -Version: @VERSION@ -Requires: glib-2.0 >= @GLIB_REQUIRED@ gobject-2.0 >= @GLIB_REQUIRED@ gio-2.0 >= @GLIB_REQUIRED@ cairo >= @CAIRO_VERSION@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-glib -Cflags: -I${includedir}/poppler/glib diff --git a/Build/source/libs/poppler/poppler-src/poppler-qt4-uninstalled.pc.in b/Build/source/libs/poppler/poppler-src/poppler-qt4-uninstalled.pc.in deleted file mode 100644 index 3a336c6c294..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-qt4-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-qt4 -Description: Qt4 bindings for poppler - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/qt4/src/libpoppler-qt4.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/qt4/src diff --git a/Build/source/libs/poppler/poppler-src/poppler-qt4.pc.cmake b/Build/source/libs/poppler/poppler-src/poppler-qt4.pc.cmake deleted file mode 100644 index b17fd5d8453..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-qt4.pc.cmake +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler-qt4 -Description: Qt4 bindings for poppler -Version: @POPPLER_VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-qt4 -Cflags: -I${includedir}/poppler/qt4 diff --git a/Build/source/libs/poppler/poppler-src/poppler-qt4.pc.in b/Build/source/libs/poppler/poppler-src/poppler-qt4.pc.in deleted file mode 100644 index 306ae46e0b0..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-qt4.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-qt4 -Description: Qt4 bindings for poppler -Version: @VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-qt4 -Cflags: -I${includedir}/poppler/qt4 diff --git a/Build/source/libs/poppler/poppler-src/poppler-qt5-uninstalled.pc.in b/Build/source/libs/poppler/poppler-src/poppler-qt5-uninstalled.pc.in deleted file mode 100644 index a91e1d5a3bd..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-qt5-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-qt5 -Description: Qt5 bindings for poppler - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/qt5/src/libpoppler-qt5.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/qt5/src diff --git a/Build/source/libs/poppler/poppler-src/poppler-qt5.pc.cmake b/Build/source/libs/poppler/poppler-src/poppler-qt5.pc.cmake index b4d87b76675..94636892208 100644 --- a/Build/source/libs/poppler/poppler-src/poppler-qt5.pc.cmake +++ b/Build/source/libs/poppler/poppler-src/poppler-qt5.pc.cmake @@ -1,7 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Name: poppler-qt5 Description: Qt5 bindings for poppler diff --git a/Build/source/libs/poppler/poppler-src/poppler-qt5.pc.in b/Build/source/libs/poppler/poppler-src/poppler-qt5.pc.in deleted file mode 100644 index cda4c6f80fe..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-qt5.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-qt5 -Description: Qt5 bindings for poppler -Version: @VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-qt5 -Cflags: -I${includedir}/poppler/qt5 diff --git a/Build/source/libs/poppler/poppler-src/poppler-splash-uninstalled.pc.in b/Build/source/libs/poppler/poppler-src/poppler-splash-uninstalled.pc.in deleted file mode 100644 index 436ecdb8f1b..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-splash-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-splash -Description: Splash backend for Poppler PDF rendering library - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/splash/libsplash.la - diff --git a/Build/source/libs/poppler/poppler-src/poppler-splash.pc.cmake b/Build/source/libs/poppler/poppler-src/poppler-splash.pc.cmake index cb95b3d2d27..f9eceebe815 100644 --- a/Build/source/libs/poppler/poppler-src/poppler-splash.pc.cmake +++ b/Build/source/libs/poppler/poppler-src/poppler-splash.pc.cmake @@ -1,7 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Name: poppler-splash Description: Splash backend for Poppler PDF rendering library diff --git a/Build/source/libs/poppler/poppler-src/poppler-splash.pc.in b/Build/source/libs/poppler/poppler-src/poppler-splash.pc.in deleted file mode 100644 index cf3491fc7cf..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-splash.pc.in +++ /dev/null @@ -1,9 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-splash -Description: Splash backend for Poppler PDF rendering library -Version: @VERSION@ -Requires: poppler = @VERSION@ diff --git a/Build/source/libs/poppler/poppler-src/poppler-uninstalled.pc.in b/Build/source/libs/poppler/poppler-src/poppler-uninstalled.pc.in deleted file mode 100644 index 6076e80c5b3..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler-uninstalled.pc.in +++ /dev/null @@ -1,6 +0,0 @@ -Name: poppler -Description: PDF rendering library - uninstalled -Version: @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/poppler/libpoppler.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/poppler diff --git a/Build/source/libs/poppler/poppler-src/poppler.pc.cmake b/Build/source/libs/poppler/poppler-src/poppler.pc.cmake index f1aebedbefd..00b734883c3 100644 --- a/Build/source/libs/poppler/poppler-src/poppler.pc.cmake +++ b/Build/source/libs/poppler/poppler-src/poppler.pc.cmake @@ -1,7 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ Name: poppler Description: PDF rendering library diff --git a/Build/source/libs/poppler/poppler-src/poppler.pc.in b/Build/source/libs/poppler/poppler-src/poppler.pc.in deleted file mode 100644 index 8605b28673b..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler -Description: PDF rendering library -Version: @VERSION@ - -Libs: -L${libdir} -lpoppler -Cflags: -I${includedir}/poppler diff --git a/Build/source/libs/poppler/poppler-src/poppler/Annot.cc b/Build/source/libs/poppler/poppler-src/poppler/Annot.cc index 279f650d186..7f249d5a919 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Annot.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Annot.cc @@ -28,13 +28,14 @@ // Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012, 2015 Tobias Koenig <tokoe@kdab.com> // Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2014, 2015 Marek Kasik <mkasik@redhat.com> // Copyright (C) 2014 Jiri Slaby <jirislaby@gmail.com> // Copyright (C) 2014 Anuj Khare <khareanuj18@gmail.com> // Copyright (C) 2015 Petr Gajdos <pgajdos@suse.cz> // Copyright (C) 2015 Philipp Reinkemeier <philipp.reinkemeier@offis.de> // Copyright (C) 2015 Tamas Szekeres <szekerest@gmail.com> +// Copyright (C) 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.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 @@ -76,7 +77,7 @@ #include <string.h> #include <algorithm> -#if MULTITHREADED +#ifdef MULTITHREADED # define annotLocker() MutexLocker locker(&mutex) # define annotCondLocker(X) MutexLocker locker(&mutex, (X)) #else @@ -112,7 +113,7 @@ // = (4 * (sqrt(2) - 1) / 3) * r #define bezierCircle 0.55228475 -AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { +static AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { if (string != NULL) { if (!string->cmp("Square")) { return annotLineEndingSquare; @@ -140,7 +141,7 @@ AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { } } -const char* convertAnnotLineEndingStyle(AnnotLineEndingStyle style) { +static const char* convertAnnotLineEndingStyle(AnnotLineEndingStyle style) { switch (style) { case annotLineEndingSquare: return "Square"; @@ -166,10 +167,10 @@ const char* convertAnnotLineEndingStyle(AnnotLineEndingStyle style) { } static AnnotExternalDataType parseAnnotExternalData(Dict* dict) { - Object obj1; AnnotExternalDataType type; - if (dict->lookup("Subtype", &obj1)->isName()) { + Object obj1 = dict->lookup("Subtype"); + if (obj1.isName()) { const char *typeName = obj1.getName(); if (!strcmp(typeName, "Markup3D")) { @@ -180,24 +181,19 @@ static AnnotExternalDataType parseAnnotExternalData(Dict* dict) { } else { type = annotExternalDataMarkupUnknown; } - obj1.free(); return type; } -PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) { +static PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) { PDFRectangle *newRect = NULL; if (array->getLength() == 4) { // deltas Object obj1; - double dx1 = (array->get(0, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); - double dy1 = (array->get(1, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); - double dx2 = (array->get(2, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); - double dy2 = (array->get(3, &obj1)->isNum() ? obj1.getNum() : 0); - obj1.free(); + double dx1 = (obj1 = array->get(0), obj1.isNum() ? obj1.getNum() : 0); + double dy1 = (obj1 = array->get(1), obj1.isNum() ? obj1.getNum() : 0); + double dx2 = (obj1 = array->get(2), obj1.isNum() ? obj1.getNum() : 0); + double dy2 = (obj1 = array->get(3), obj1.isNum() ? obj1.getNum() : 0); // checking that the numbers are valid (i.e. >= 0), // and that applying the differences still give us a valid rect @@ -215,10 +211,10 @@ PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) { } static LinkAction* getAdditionalAction(Annot::AdditionalActionsType type, Object *additionalActions, PDFDoc *doc) { - Object additionalActionsObject; - LinkAction *linkAction = NULL; + LinkAction *linkAction = nullptr; + Object additionalActionsObject = additionalActions->fetch(doc->getXRef()); - if (additionalActions->fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { + if (additionalActionsObject.isDict()) { const char *key = (type == Annot::actionCursorEntering ? "E" : type == Annot::actionCursorLeaving ? "X" : type == Annot::actionMousePressed ? "D" : @@ -230,37 +226,29 @@ static LinkAction* getAdditionalAction(Annot::AdditionalActionsType type, Object type == Annot::actionPageVisible ? "PV" : type == Annot::actionPageInvisible ? "PI" : NULL); - Object actionObject; - - if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) + Object actionObject = additionalActionsObject.dictLookup(key); + if (actionObject.isDict()) linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); - actionObject.free(); } - additionalActionsObject.free(); - return linkAction; } static LinkAction* getFormAdditionalAction(Annot::FormAdditionalActionsType type, Object *additionalActions, PDFDoc *doc) { - Object additionalActionsObject; - LinkAction *linkAction = NULL; + LinkAction *linkAction = nullptr; + Object additionalActionsObject = additionalActions->fetch(doc->getXRef()); - if (additionalActions->fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { + if (additionalActionsObject.isDict()) { const char *key = (type == Annot::actionFieldModified ? "K" : type == Annot::actionFormatField ? "F" : type == Annot::actionValidateField ? "V" : type == Annot::actionCalculateField ? "C" : NULL); - Object actionObject; - - if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) + Object actionObject = additionalActionsObject.dictLookup(key); + if (actionObject.isDict()) linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); - actionObject.free(); } - additionalActionsObject.free(); - return linkAction; } @@ -271,7 +259,8 @@ static LinkAction* getFormAdditionalAction(Annot::FormAdditionalActionsType type AnnotBorderEffect::AnnotBorderEffect(Dict *dict) { Object obj1; - if (dict->lookup("S", &obj1)->isName()) { + obj1 = dict->lookup("S"); + if (obj1.isName()) { const char *effectName = obj1.getName(); if (!strcmp(effectName, "C")) @@ -281,14 +270,13 @@ AnnotBorderEffect::AnnotBorderEffect(Dict *dict) { } else { effectType = borderEffectNoEffect; } - obj1.free(); - if ((dict->lookup("I", &obj1)->isNum()) && effectType == borderEffectCloudy) { + obj1 = dict->lookup("I"); + if (obj1.isNum() && effectType == borderEffectCloudy) { intensity = obj1.getNum(); } else { intensity = 0; } - obj1.free(); } //------------------------------------------------------------------------ @@ -351,22 +339,21 @@ void AnnotPath::parsePathArray(Array *array) { tempCoords = (AnnotCoord **) gmallocn (tempLength, sizeof(AnnotCoord *)); memset(tempCoords, 0, tempLength * sizeof(AnnotCoord *)); for (int i = 0; i < tempLength && correct; i++) { - Object obj1; double x = 0, y = 0; - if (array->get(i * 2, &obj1)->isNum()) { + Object obj1 = array->get(i * 2); + if (obj1.isNum()) { x = obj1.getNum(); } else { correct = gFalse; } - obj1.free(); - if (array->get((i * 2) + 1, &obj1)->isNum()) { + obj1 = array->get((i * 2) + 1); + if (obj1.isNum()) { y = obj1.getNum(); } else { correct = gFalse; } - obj1.free(); if (!correct) { for (int j = i - 1; j >= 0; j--) @@ -424,16 +411,14 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) { for (i = 0; i < quadsLength; i++) { for (int j = 0; j < 8; j++) { - Object obj; - if (array->get(i * 8 + j, &obj)->isNum()) { + Object obj = array->get(i * 8 + j); + if (obj.isNum()) { quadArray[j] = obj.getNum(); } else { correct = gFalse; - obj.free(); error (errSyntaxError, -1, "Invalid QuadPoint in annot"); break; } - obj.free(); } if (!correct) @@ -540,13 +525,11 @@ GBool AnnotBorder::parseDashArray(Object *dashObj) { // TODO: check not all zero (Line Dash Pattern Page 217 PDF 8.1) for (int i = 0; i < tempLength && i < DASH_LIMIT && correct; i++) { - Object obj1; - - if (dashObj->arrayGet(i, &obj1)->isNum()) { + Object obj1 = dashObj->arrayGet(i); + if (obj1.isNum()) { tempDash[i] = obj1.getNum(); correct = tempDash[i] >= 0; - obj1.free(); } } @@ -583,30 +566,30 @@ AnnotBorderArray::AnnotBorderArray(Array *array) { if (arrayLength == 3 || arrayLength == 4) { // implementation note 81 in Appendix H. - if (array->get(0, &obj1)->isNum()) + obj1 = array->get(0); + if (obj1.isNum()) horizontalCorner = obj1.getNum(); else correct = gFalse; - obj1.free(); - if (array->get(1, &obj1)->isNum()) + obj1 = array->get(1); + if (obj1.isNum()) verticalCorner = obj1.getNum(); else correct = gFalse; - obj1.free(); - if (array->get(2, &obj1)->isNum()) + obj1 = array->get(2); + if (obj1.isNum()) width = obj1.getNum(); else correct = gFalse; - obj1.free(); if (arrayLength == 4) { - if (array->get(3, &obj1)->isArray()) + obj1 = array->get(3); + if (obj1.isArray()) correct = parseDashArray(&obj1); else correct = gFalse; - obj1.free(); } } else { correct = gFalse; @@ -617,21 +600,22 @@ AnnotBorderArray::AnnotBorderArray(Array *array) { } } -void AnnotBorderArray::writeToObject(XRef *xref, Object *obj1) const { - Object obj2; - - obj1->initArray(xref); - obj1->arrayAdd(obj2.initReal(horizontalCorner)); - obj1->arrayAdd(obj2.initReal(verticalCorner)); - obj1->arrayAdd(obj2.initReal(width)); +Object AnnotBorderArray::writeToObject(XRef *xref) const { + Array *borderArray = new Array(xref); + borderArray->add(Object(horizontalCorner)); + borderArray->add(Object(verticalCorner)); + borderArray->add(Object(width)); if (dashLength > 0) { - Object obj3; + Array *a = new Array(xref); - obj1->arrayAdd(obj3.initArray(xref)); for (int i = 0; i < dashLength; i++) - obj3.arrayAdd(obj2.initReal(dash[i])); + a->add(Object(dash[i])); + + borderArray->add(Object(a)); } + + return Object(borderArray); } //------------------------------------------------------------------------ @@ -650,8 +634,8 @@ AnnotBorderBS::AnnotBorderBS(Dict *dict) { // that behaviour by veryifying both entries exist // otherwise we set the borderWidth to 0 // --jrmuizel - dict->lookup("W", &obj1); - dict->lookup("S", &obj2); + obj1 = dict->lookup("W"); + obj2 = dict->lookup("S"); if (obj1.isNum() && obj2.isName()) { const char *styleName = obj2.getName(); @@ -673,13 +657,11 @@ AnnotBorderBS::AnnotBorderBS(Dict *dict) { } else { width = 0; } - obj2.free(); - obj1.free(); if (style == borderDashed) { - if (dict->lookup("D", &obj1)->isArray()) + obj1 = dict->lookup("D"); + if (obj1.isArray()) parseDashArray(&obj1); - obj1.free(); if (!dash) { dashLength = 1; @@ -706,19 +688,18 @@ const char *AnnotBorderBS::getStyleName() const { return "S"; } -void AnnotBorderBS::writeToObject(XRef *xref, Object *obj1) const { - Object obj2; - - obj1->initDict(xref); - obj1->dictSet("W", obj2.initReal(width)); - obj1->dictSet("S", obj2.initName(getStyleName())); +Object AnnotBorderBS::writeToObject(XRef *xref) const { + Dict *dict = new Dict(xref); + dict->set("W", Object(width)); + dict->set("S", Object(objName, getStyleName())); if (style == borderDashed && dashLength > 0) { - Object obj3; + Array *a = new Array(xref); - obj1->dictSet("D", obj3.initArray(xref)); for (int i = 0; i < dashLength; i++) - obj3.arrayAdd(obj2.initReal(dash[i])); + a->add(Object(dash[i])); + dict->set("D", Object(a)); } + return Object(dict); } //------------------------------------------------------------------------ @@ -763,9 +744,8 @@ AnnotColor::AnnotColor(Array *array, int adjust) { length = 4; for (i = 0; i < length; i++) { - Object obj1; - - if (array->get(i, &obj1)->isNum()) { + Object obj1 = array->get(i); + if (obj1.isNum()) { values[i] = obj1.getNum(); if (values[i] < 0 || values[i] > 1) @@ -773,7 +753,6 @@ AnnotColor::AnnotColor(Array *array, int adjust) { } else { values[i] = 0; } - obj1.free(); } if (adjust != 0) @@ -797,16 +776,14 @@ void AnnotColor::adjustColor(int adjust) { } } -void AnnotColor::writeToObject(XRef *xref, Object *obj1) const { - Object obj2; - int i; - +Object AnnotColor::writeToObject(XRef *xref) const { if (length == 0) { - obj1->initNull(); // Transparent (no color) + return Object(objNull); // Transparent (no color) } else { - obj1->initArray(xref); - for (i = 0; i < length; ++i) - obj1->arrayAdd( obj2.initReal( values[i] ) ); + Array *a = new Array(xref); + for (int i = 0; i < length; ++i) + a->add( Object( values[i] ) ); + return Object(a); } } @@ -817,7 +794,8 @@ void AnnotColor::writeToObject(XRef *xref, Object *obj1) const { AnnotIconFit::AnnotIconFit(Dict* dict) { Object obj1; - if (dict->lookup("SW", &obj1)->isName()) { + obj1 = dict->lookup("SW"); + if (obj1.isName()) { const char *scaleName = obj1.getName(); if(!strcmp(scaleName, "B")) { @@ -832,9 +810,9 @@ AnnotIconFit::AnnotIconFit(Dict* dict) { } else { scaleWhen = scaleAlways; } - obj1.free(); - if (dict->lookup("S", &obj1)->isName()) { + obj1 = dict->lookup("S"); + if (obj1.isName()) { const char *scaleName = obj1.getName(); if(!strcmp(scaleName, "A")) { @@ -845,14 +823,12 @@ AnnotIconFit::AnnotIconFit(Dict* dict) { } else { scale = scaleProportional; } - obj1.free(); - if (dict->lookup("A", &obj1)->isArray() && obj1.arrayGetLength() == 2) { + obj1 = dict->lookup("A"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { Object obj2; - (obj1.arrayGet(0, &obj2)->isNum() ? left = obj2.getNum() : left = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? bottom = obj2.getNum() : bottom = 0); - obj2.free(); + (obj2 = obj1.arrayGet(0), obj2.isNum() ? left = obj2.getNum() : left = 0); + (obj2 = obj1.arrayGet(1), obj2.isNum() ? bottom = obj2.getNum() : bottom = 0); if (left < 0 || left > 1) left = 0.5; @@ -863,14 +839,13 @@ AnnotIconFit::AnnotIconFit(Dict* dict) { } else { left = bottom = 0.5; } - obj1.free(); - if (dict->lookup("FB", &obj1)->isBool()) { + obj1 = dict->lookup("FB"); + if (obj1.isBool()) { fullyBounds = obj1.getBool(); } else { fullyBounds = gFalse; } - obj1.free(); } //------------------------------------------------------------------------ @@ -881,55 +856,54 @@ AnnotAppearance::AnnotAppearance(PDFDoc *docA, Object *dict) { assert(dict->isDict()); doc = docA; xref = docA->getXRef(); - dict->copy(&appearDict); + appearDict = dict->copy(); } AnnotAppearance::~AnnotAppearance() { - appearDict.free(); } -void AnnotAppearance::getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest) { - Object apData, stream; - apData.initNull(); +Object AnnotAppearance::getAppearanceStream(AnnotAppearanceType type, const char *state) { + Object apData; // Obtain dictionary or stream associated to appearance type switch (type) { case appearRollover: - if (appearDict.dictLookupNF("R", &apData)->isNull()) - appearDict.dictLookupNF("N", &apData); + apData = appearDict.dictLookupNF("R"); + if (apData.isNull()) + apData = appearDict.dictLookupNF("N"); break; case appearDown: - if (appearDict.dictLookupNF("D", &apData)->isNull()) - appearDict.dictLookupNF("N", &apData); + apData = appearDict.dictLookupNF("D"); + if (apData.isNull()) + apData = appearDict.dictLookupNF("N"); break; case appearNormal: - appearDict.dictLookupNF("N", &apData); + apData = appearDict.dictLookupNF("N"); break; } - dest->initNull(); + Object res; if (apData.isDict() && state) - apData.dictLookupNF(state, dest); + res = apData.dictLookupNF(state); else if (apData.isRef()) - apData.copy(dest); - apData.free(); + res = apData.copy(); + + return res; } GooString * AnnotAppearance::getStateKey(int i) { - Object obj1; GooString * res = NULL; - if (appearDict.dictLookupNF("N", &obj1)->isDict()) + Object obj1 = appearDict.dictLookupNF("N"); + if (obj1.isDict()) res = new GooString(obj1.dictGetKey(i)); - obj1.free(); return res; } int AnnotAppearance::getNumStates() { - Object obj1; int res = 0; - if (appearDict.dictLookupNF("N", &obj1)->isDict()) + Object obj1 = appearDict.dictLookupNF("N"); + if (obj1.isDict()) res = obj1.dictGetLength(); - obj1.free(); return res; } @@ -943,15 +917,13 @@ GBool AnnotAppearance::referencesStream(Object *stateObj, Ref refToStream) { } else if (stateObj->isDict()) { // Test each value const int size = stateObj->dictGetLength(); for (int i = 0; i < size; ++i) { - Object obj1; - stateObj->dictGetValNF(i, &obj1); + Object obj1 = stateObj->dictGetValNF(i); if (obj1.isRef()) { Ref r = obj1.getRef(); if (r.num == refToStream.num && r.gen == refToStream.gen) { return gTrue; } } - obj1.free(); } } return gFalse; // Not found @@ -963,21 +935,18 @@ GBool AnnotAppearance::referencesStream(Ref refToStream) { GBool found; // Scan each state's ref/subdictionary - appearDict.dictLookupNF("N", &obj1); + obj1 = appearDict.dictLookupNF("N"); found = referencesStream(&obj1, refToStream); - obj1.free(); if (found) return gTrue; - appearDict.dictLookupNF("R", &obj1); + obj1 = appearDict.dictLookupNF("R"); found = referencesStream(&obj1, refToStream); - obj1.free(); if (found) return gTrue; - appearDict.dictLookupNF("D", &obj1); + obj1 = appearDict.dictLookupNF("D"); found = referencesStream(&obj1, refToStream); - obj1.free(); return found; } @@ -1011,27 +980,22 @@ void AnnotAppearance::removeStateStreams(Object *obj1) { } else if (obj1->isDict()) { const int size = obj1->dictGetLength(); for (int i = 0; i < size; ++i) { - Object obj2; - obj1->dictGetValNF(i, &obj2); + Object obj2 = obj1->dictGetValNF(i); if (obj2.isRef()) { removeStream(obj2.getRef()); } - obj2.free(); } } } void AnnotAppearance::removeAllStreams() { Object obj1; - appearDict.dictLookupNF("N", &obj1); + obj1 = appearDict.dictLookupNF("N"); removeStateStreams(&obj1); - obj1.free(); - appearDict.dictLookupNF("R", &obj1); + obj1 = appearDict.dictLookupNF("R"); removeStateStreams(&obj1); - obj1.free(); - appearDict.dictLookupNF("D", &obj1); + obj1 = appearDict.dictLookupNF("D"); removeStateStreams(&obj1); - obj1.free(); } //------------------------------------------------------------------------ @@ -1041,14 +1005,15 @@ void AnnotAppearance::removeAllStreams() { AnnotAppearanceCharacs::AnnotAppearanceCharacs(Dict *dict) { Object obj1; - if (dict->lookup("R", &obj1)->isInt()) { + obj1 = dict->lookup("R"); + if (obj1.isInt()) { rotation = obj1.getInt(); } else { rotation = 0; } - obj1.free(); - if (dict->lookup("BC", &obj1)->isArray()) { + obj1 = dict->lookup("BC"); + if (obj1.isArray()) { Array *colorComponents = obj1.getArray(); if (colorComponents->getLength() > 0) { borderColor = new AnnotColor(colorComponents); @@ -1058,9 +1023,9 @@ AnnotAppearanceCharacs::AnnotAppearanceCharacs(Dict *dict) { } else { borderColor = NULL; } - obj1.free(); - if (dict->lookup("BG", &obj1)->isArray()) { + obj1 = dict->lookup("BG"); + if (obj1.isArray()) { Array *colorComponents = obj1.getArray(); if (colorComponents->getLength() > 0) { backColor = new AnnotColor(colorComponents); @@ -1070,42 +1035,41 @@ AnnotAppearanceCharacs::AnnotAppearanceCharacs(Dict *dict) { } else { backColor = NULL; } - obj1.free(); - if (dict->lookup("CA", &obj1)->isString()) { + obj1 = dict->lookup("CA"); + if (obj1.isString()) { normalCaption = new GooString(obj1.getString()); } else { normalCaption = NULL; } - obj1.free(); - if (dict->lookup("RC", &obj1)->isString()) { + obj1 = dict->lookup("RC"); + if (obj1.isString()) { rolloverCaption = new GooString(obj1.getString()); } else { rolloverCaption = NULL; } - obj1.free(); - if (dict->lookup("AC", &obj1)->isString()) { + obj1 = dict->lookup("AC"); + if (obj1.isString()) { alternateCaption = new GooString(obj1.getString()); } else { alternateCaption = NULL; } - obj1.free(); - if (dict->lookup("IF", &obj1)->isDict()) { + obj1 = dict->lookup("IF"); + if (obj1.isDict()) { iconFit = new AnnotIconFit(obj1.getDict()); } else { iconFit = NULL; } - obj1.free(); - if (dict->lookup("TP", &obj1)->isInt()) { + obj1 = dict->lookup("TP"); + if (obj1.isInt()) { position = (AnnotAppearanceCharacsTextPos) obj1.getInt(); } else { position = captionNoIcon; } - obj1.free(); } AnnotAppearanceCharacs::~AnnotAppearanceCharacs() { @@ -1185,40 +1149,36 @@ double AnnotAppearanceBBox::getPageYMax() const { //------------------------------------------------------------------------ Annot::Annot(PDFDoc *docA, PDFRectangle *rectA) { - Object obj1; refCnt = 1; flags = flagUnknown; type = typeUnknown; - obj1.initArray (docA->getXRef()); - Object obj2; - obj1.arrayAdd (obj2.initReal (rectA->x1)); - obj1.arrayAdd (obj2.initReal (rectA->y1)); - obj1.arrayAdd (obj2.initReal (rectA->x2)); - obj1.arrayAdd (obj2.initReal (rectA->y2)); - obj2.free (); + Array *a = new Array(docA->getXRef()); + a->add(Object(rectA->x1)); + a->add(Object(rectA->y1)); + a->add(Object(rectA->x2)); + a->add(Object(rectA->y2)); - annotObj.initDict (docA->getXRef()); - annotObj.dictSet ("Type", obj2.initName ("Annot")); - annotObj.dictSet ("Rect", &obj1); - // obj1 is owned by the dict + annotObj = Object(new Dict(docA->getXRef())); + annotObj.dictSet ("Type", Object(objName, "Annot")); + annotObj.dictSet ("Rect", Object(a)); ref = docA->getXRef()->addIndirectObject (&annotObj); initialize (docA, annotObj.getDict()); } -Annot::Annot(PDFDoc *docA, Dict *dict) { +Annot::Annot(PDFDoc *docA, Object *dictObject) { refCnt = 1; hasRef = false; flags = flagUnknown; type = typeUnknown; - annotObj.initDict (dict); - initialize (docA, dict); + annotObj = dictObject->copy(); + initialize (docA, dictObject->getDict()); } -Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) { +Annot::Annot(PDFDoc *docA, Object *dictObject, Object *obj) { refCnt = 1; if (obj->isRef()) { hasRef = gTrue; @@ -1228,12 +1188,12 @@ Annot::Annot(PDFDoc *docA, Dict *dict, Object *obj) { } flags = flagUnknown; type = typeUnknown; - annotObj.initDict (dict); - initialize (docA, dict); + annotObj = dictObject->copy(); + initialize (docA, dictObject->getDict()); } void Annot::initialize(PDFDoc *docA, Dict *dict) { - Object apObj, asObj, obj1, obj2; + Object apObj, asObj, obj1; ok = gTrue; doc = docA; @@ -1244,20 +1204,17 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) { appearBuf = NULL; fontSize = 0; - appearance.initNull(); + appearance.setToNull(); //----- parse the rectangle rect = new PDFRectangle(); - if (dict->lookup("Rect", &obj1)->isArray() && obj1.arrayGetLength() == 4) { + obj1 = dict->lookup("Rect"); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { Object obj2; - (obj1.arrayGet(0, &obj2)->isNum() ? rect->x1 = obj2.getNum() : rect->x1 = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? rect->y1 = obj2.getNum() : rect->y1 = 0); - obj2.free(); - (obj1.arrayGet(2, &obj2)->isNum() ? rect->x2 = obj2.getNum() : rect->x2 = 1); - obj2.free(); - (obj1.arrayGet(3, &obj2)->isNum() ? rect->y2 = obj2.getNum() : rect->y2 = 1); - obj2.free(); + (obj2 = obj1.arrayGet(0), obj2.isNum() ? rect->x1 = obj2.getNum() : rect->x1 = 0); + (obj2 = obj1.arrayGet(1), obj2.isNum() ? rect->y1 = obj2.getNum() : rect->y1 = 0); + (obj2 = obj1.arrayGet(2), obj2.isNum() ? rect->x2 = obj2.getNum() : rect->x2 = 1); + (obj2 = obj1.arrayGet(3), obj2.isNum() ? rect->y2 = obj2.getNum() : rect->y2 = 1); if (rect->x1 > rect->x2) { double t = rect->x1; @@ -1276,56 +1233,54 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) { error(errSyntaxError, -1, "Bad bounding box for annotation"); ok = gFalse; } - obj1.free(); - if (dict->lookup("Contents", &obj1)->isString()) { + obj1 = dict->lookup("Contents"); + if (obj1.isString()) { contents = obj1.getString()->copy(); } else { contents = new GooString(); } - obj1.free(); // Note: This value is overwritten by Annots ctor - if (dict->lookupNF("P", &obj1)->isRef()) { + obj1 = dict->lookupNF("P"); + if (obj1.isRef()) { Ref ref = obj1.getRef(); page = doc->getCatalog()->findPage (ref.num, ref.gen); } else { page = 0; } - obj1.free(); - if (dict->lookup("NM", &obj1)->isString()) { + obj1 = dict->lookup("NM"); + if (obj1.isString()) { name = obj1.getString()->copy(); } else { name = NULL; } - obj1.free(); - if (dict->lookup("M", &obj1)->isString()) { + obj1 = dict->lookup("M"); + if (obj1.isString()) { modified = obj1.getString()->copy(); } else { modified = NULL; } - obj1.free(); //----- get the flags - if (dict->lookup("F", &obj1)->isInt()) { + obj1 = dict->lookup("F"); + if (obj1.isInt()) { flags |= obj1.getInt(); } else { flags = flagUnknown; } - obj1.free(); //----- get the annotation appearance dictionary - dict->lookup("AP", &apObj); + apObj = dict->lookup("AP"); if (apObj.isDict()) { appearStreams = new AnnotAppearance(doc, &apObj); } - apObj.free(); //----- get the appearance state - dict->lookup("AS", &asObj); + asObj = dict->lookup("AS"); if (asObj.isName()) { appearState = new GooString(asObj.getName()); } else if (appearStreams && appearStreams->getNumStates() != 0) { @@ -1340,11 +1295,10 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) { if (!appearState) { appearState = new GooString("Off"); } - asObj.free(); //----- get the annotation appearance if (appearStreams) { - appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString(), &appearance); + appearance = appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString()); } //----- parse the border style @@ -1352,29 +1306,29 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) { // the border shall be drawn as a solid line with a width of 1 point. But acroread // seems to ignore the Border entry for annots that can't have a BS entry. So, we only // follow this rule for annots tha can have a BS entry. - if (dict->lookup("Border", &obj1)->isArray()) + obj1 = dict->lookup("Border"); + if (obj1.isArray()) border = new AnnotBorderArray(obj1.getArray()); else border = NULL; - obj1.free(); - if (dict->lookup("C", &obj1)->isArray()) { + obj1 = dict->lookup("C"); + if (obj1.isArray()) { color = new AnnotColor(obj1.getArray()); } else { color = NULL; } - obj1.free(); - if (dict->lookup("StructParent", &obj1)->isInt()) { + obj1 = dict->lookup("StructParent"); + if (obj1.isInt()) { treeKey = obj1.getInt(); } else { treeKey = 0; } - obj1.free(); - dict->lookupNF("OC", &oc); + oc = dict->lookupNF("OC"); -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -1391,8 +1345,6 @@ void Annot::setRect(PDFRectangle *rect) { } void Annot::setRect(double x1, double y1, double x2, double y2) { - Object obj1, obj2; - if (x1 < x2) { rect->x1 = x1; rect->x2 = x2; @@ -1409,13 +1361,13 @@ void Annot::setRect(double x1, double y1, double x2, double y2) { rect->y2 = y1; } - obj1.initArray (xref); - obj1.arrayAdd (obj2.initReal (rect->x1)); - obj1.arrayAdd (obj2.initReal (rect->y1)); - obj1.arrayAdd (obj2.initReal (rect->x2)); - obj1.arrayAdd (obj2.initReal (rect->y2)); + Array *a = new Array(xref); + a->add(Object(rect->x1)); + a->add(Object(rect->y1)); + a->add(Object(rect->x2)); + a->add(Object(rect->y2)); - update("Rect", &obj1); + update("Rect", Object(a)); invalidateAppearance(); } @@ -1423,19 +1375,17 @@ GBool Annot::inRect(double x, double y) const { return rect->contains(x, y); } -void Annot::update(const char *key, Object *value) { +void Annot::update(const char *key, Object &&value) { annotLocker(); /* Set M to current time, unless we are updating M itself */ if (strcmp(key, "M") != 0) { delete modified; modified = timeToDateString(NULL); - Object obj1; - obj1.initString (modified->copy()); - annotObj.dictSet("M", &obj1); + annotObj.dictSet("M", Object(modified->copy())); } - annotObj.dictSet(const_cast<char*>(key), value); + annotObj.dictSet(const_cast<char*>(key), std::move(value)); xref->setModifiedObject(&annotObj, ref); } @@ -1448,16 +1398,13 @@ void Annot::setContents(GooString *new_content) { contents = new GooString(new_content); //append the unicode marker <FE FF> if needed if (!contents->hasUnicodeMarker()) { - contents->insert(0, 0xff); - contents->insert(0, 0xfe); + contents->prependUnicodeMarker(); } } else { contents = new GooString(); } - Object obj1; - obj1.initString(contents->copy()); - update ("Contents", &obj1); + update ("Contents", Object(contents->copy())); } void Annot::setName(GooString *new_name) { @@ -1470,9 +1417,7 @@ void Annot::setName(GooString *new_name) { name = new GooString(); } - Object obj1; - obj1.initString(name->copy()); - update ("NM", &obj1); + update ("NM", Object(name->copy())); } void Annot::setModified(GooString *new_modified) { @@ -1484,17 +1429,13 @@ void Annot::setModified(GooString *new_modified) { else modified = new GooString(); - Object obj1; - obj1.initString(modified->copy()); - update ("M", &obj1); + update ("M", Object(modified->copy())); } void Annot::setFlags(Guint new_flags) { annotLocker(); - Object obj1; flags = new_flags; - obj1.initInt(flags); - update ("F", &obj1); + update ("F", Object(int(flags))); } void Annot::setBorder(AnnotBorder *new_border) { @@ -1502,9 +1443,8 @@ void Annot::setBorder(AnnotBorder *new_border) { delete border; if (new_border) { - Object obj1; - new_border->writeToObject(xref, &obj1); - update(new_border->getType() == AnnotBorder::typeArray ? "Border" : "BS", &obj1); + Object obj1 = new_border->writeToObject(xref); + update(new_border->getType() == AnnotBorder::typeArray ? "Border" : "BS", std::move(obj1)); border = new_border; } else { border = NULL; @@ -1517,9 +1457,8 @@ void Annot::setColor(AnnotColor *new_color) { delete color; if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("C", &obj1); + Object obj1 = new_color->writeToObject(xref); + update ("C", std::move(obj1)); color = new_color; } else { color = NULL; @@ -1530,19 +1469,18 @@ void Annot::setColor(AnnotColor *new_color) { void Annot::setPage(int pageIndex, GBool updateP) { annotLocker(); Page *pageobj = doc->getPage(pageIndex); - Object obj1; + Object obj1(objNull); if (pageobj) { Ref pageRef = pageobj->getRef(); - obj1.initRef(pageRef.num, pageRef.gen); + obj1 = Object(pageRef.num, pageRef.gen); page = pageIndex; } else { - obj1.initNull(); page = 0; } if (updateP) { - update("P", &obj1); + update("P", std::move(obj1)); } } @@ -1557,16 +1495,13 @@ void Annot::setAppearanceState(const char *state) { delete appearBBox; appearBBox = NULL; - Object obj1; - obj1.initName(state); - update ("AS", &obj1); + update ("AS", Object(objName, state)); // The appearance state determines the current appearance stream - appearance.free(); if (appearStreams) { - appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString(), &appearance); + appearance = appearStreams->getAppearanceStream(AnnotAppearance::appearNormal, appearState->getCString()); } else { - appearance.initNull(); + appearance.setToNull(); } } @@ -1584,18 +1519,15 @@ void Annot::invalidateAppearance() { delete appearBBox; appearBBox = NULL; - appearance.free(); - appearance.initNull(); + appearance.setToNull(); - Object obj1, obj2; - obj1.initNull(); - if (!annotObj.dictLookup("AP", &obj2)->isNull()) - update ("AP", &obj1); // Remove AP - obj2.free(); + Object obj2 = annotObj.dictLookup("AP"); + if (!obj2.isNull()) + update ("AP", Object(objNull)); // Remove AP - if (!annotObj.dictLookup("AS", &obj2)->isNull()) - update ("AS", &obj1); // Remove AS - obj2.free(); + obj2 = annotObj.dictLookup("AS"); + if (!obj2.isNull()) + update ("AS", Object(objNull)); // Remove AS } double Annot::getXMin() { @@ -1615,16 +1547,13 @@ double Annot::getYMax() { } void Annot::readArrayNum(Object *pdfArray, int key, double *value) { - Object valueObject; - - pdfArray->arrayGet(key, &valueObject); + Object valueObject = pdfArray->arrayGet(key); if (valueObject.isNum()) { *value = valueObject.getNum(); } else { *value = 0; ok = gFalse; } - valueObject.free(); } void Annot::removeReferencedObjects() { @@ -1638,24 +1567,22 @@ void Annot::incRefCnt() { } void Annot::decRefCnt() { -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif if (--refCnt == 0) { -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif delete this; return; } -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif } Annot::~Annot() { - annotObj.free(); - delete rect; delete contents; @@ -1667,7 +1594,6 @@ Annot::~Annot() { delete appearStreams; delete appearBBox; - appearance.free(); if (appearState) delete appearState; @@ -1678,9 +1604,7 @@ Annot::~Annot() { if (color) delete color; - oc.free(); - -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } @@ -1804,74 +1728,66 @@ void Annot::drawCircleBottomRight(double cx, double cy, double r) { appearBuf->append("S\n"); } -void Annot::createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream) { - Object obj1, obj2; - Object appearDict; - - appearDict.initDict(xref); - appearDict.dictSet("Length", obj1.initInt(appearBuf->getLength())); - appearDict.dictSet("Subtype", obj1.initName("Form")); - obj1.initArray(xref); - obj1.arrayAdd(obj2.initReal(bbox[0])); - obj1.arrayAdd(obj2.initReal(bbox[1])); - obj1.arrayAdd(obj2.initReal(bbox[2])); - obj1.arrayAdd(obj2.initReal(bbox[3])); - appearDict.dictSet("BBox", &obj1); +Object Annot::createForm(double *bbox, GBool transparencyGroup, Dict *resDict) { + Dict *appearDict = new Dict(xref); + appearDict->set("Length", Object(appearBuf->getLength())); + appearDict->set("Subtype", Object(objName, "Form")); + + Array *a = new Array(xref); + a->add(Object(bbox[0])); + a->add(Object(bbox[1])); + a->add(Object(bbox[2])); + a->add(Object(bbox[3])); + appearDict->set("BBox", Object(a)); if (transparencyGroup) { - Object transDict; - transDict.initDict(xref); - transDict.dictSet("S", obj1.initName("Transparency")); - appearDict.dictSet("Group", &transDict); + Dict *d = new Dict(xref); + d->set("S", Object(objName, "Transparency")); + appearDict->set("Group", Object(d)); } if (resDict) - appearDict.dictSet("Resources", resDict); + appearDict->set("Resources", Object(resDict)); MemStream *mStream = new MemStream(copyString(appearBuf->getCString()), 0, - appearBuf->getLength(), &appearDict); + appearBuf->getLength(), Object(appearDict)); mStream->setNeedFree(gTrue); - aStream->initStream(mStream); + return Object(static_cast<Stream*>(mStream)); } -void Annot::createResourcesDict(const char *formName, Object *formStream, +Dict *Annot::createResourcesDict(const char *formName, Object &&formStream, const char *stateName, - double opacity, const char *blendMode, - Object *resDict) { - Object gsDict, stateDict, formDict, obj1; - - gsDict.initDict(xref); + double opacity, const char *blendMode) { + Dict *gsDict = new Dict(xref); if (opacity != 1) { - gsDict.dictSet("CA", obj1.initReal(opacity)); - gsDict.dictSet("ca", obj1.initReal(opacity)); + gsDict->set("CA", Object(opacity)); + gsDict->set("ca", Object(opacity)); } if (blendMode) - gsDict.dictSet("BM", obj1.initName(blendMode)); - stateDict.initDict(xref); - stateDict.dictSet(stateName, &gsDict); - formDict.initDict(xref); - formDict.dictSet(formName, formStream); + gsDict->set("BM", Object(objName, blendMode)); + Dict *stateDict = new Dict(xref); + stateDict->set(stateName, Object(gsDict)); + Dict *formDict = new Dict(xref); + formDict->set(formName, std::move(formStream)); - resDict->initDict(xref); - resDict->dictSet("ExtGState", &stateDict); - resDict->dictSet("XObject", &formDict); + Dict *resDict = new Dict(xref); + resDict->set("ExtGState", Object(stateDict)); + resDict->set("XObject", Object(formDict)); + + return resDict; } -Object *Annot::getAppearanceResDict(Object *dest) { +Object Annot::getAppearanceResDict() { Object obj1, obj2; - dest->initNull(); // Default value - // Fetch appearance's resource dict (if any) - appearance.fetch(xref, &obj1); + obj1 = appearance.fetch(xref); if (obj1.isStream()) { - obj1.streamGetDict()->lookup("Resources", &obj2); + obj2 = obj1.streamGetDict()->lookup("Resources"); if (obj2.isDict()) { - obj2.copy(dest); + return obj2; } - obj2.free(); } - obj1.free(); - return dest; + return Object(objNull); } GBool Annot::isVisible(GBool printing) { @@ -1905,17 +1821,14 @@ int Annot::getRotation() const } void Annot::draw(Gfx *gfx, GBool printing) { - Object obj; - annotLocker(); if (!isVisible (printing)) return; // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); } //------------------------------------------------------------------------ @@ -1928,52 +1841,45 @@ AnnotPopup::AnnotPopup(PDFDoc *docA, PDFRectangle *rect) : type = typePopup; - annotObj.dictSet ("Subtype", obj1.initName ("Popup")); + annotObj.dictSet ("Subtype", Object(objName, "Popup")); initialize (docA, annotObj.getDict()); } -AnnotPopup::AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { +AnnotPopup::AnnotPopup(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { type = typePopup; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotPopup::~AnnotPopup() { - parent.free(); } void AnnotPopup::initialize(PDFDoc *docA, Dict *dict) { - Object obj1; - - if (!dict->lookupNF("Parent", &parent)->isRef()) { - parent.initNull(); + parent = dict->lookupNF("Parent"); + if (!parent.isRef()) { + parent.setToNull(); } - if (dict->lookup("Open", &obj1)->isBool()) { + Object obj1 = dict->lookup("Open"); + if (obj1.isBool()) { open = obj1.getBool(); } else { open = gFalse; } - obj1.free(); } void AnnotPopup::setParent(Object *parentA) { - parentA->copy(&parent); - update ("Parent", &parent); + update ("Parent", parentA->copy()); } void AnnotPopup::setParent(Annot *parentA) { - Ref parentRef = parentA->getRef(); - parent.initRef(parentRef.num, parentRef.gen); - update ("Parent", &parent); + const Ref parentRef = parentA->getRef(); + update ("Parent", Object(parentRef.num, parentRef.gen)); } void AnnotPopup::setOpen(GBool openA) { - Object obj1; - open = openA; - obj1.initBool(open); - update ("Open", &obj1); + update ("Open", Object(open)); } //------------------------------------------------------------------------ @@ -1984,9 +1890,9 @@ AnnotMarkup::AnnotMarkup(PDFDoc *docA, PDFRectangle *rect) : initialize(docA, annotObj.getDict(), &annotObj); } -AnnotMarkup::AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { - initialize(docA, dict, obj); +AnnotMarkup::AnnotMarkup(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { + initialize(docA, dictObject->getDict(), obj); } AnnotMarkup::~AnnotMarkup() { @@ -2006,50 +1912,52 @@ AnnotMarkup::~AnnotMarkup() { void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, Object *obj) { Object obj1, obj2; - if (dict->lookup("T", &obj1)->isString()) { + obj1 = dict->lookup("T"); + if (obj1.isString()) { label = obj1.getString()->copy(); } else { label = NULL; } - obj1.free(); - if (dict->lookup("Popup", &obj1)->isDict() && dict->lookupNF("Popup", &obj2)->isRef()) { - popup = new AnnotPopup(docA, obj1.getDict(), &obj2); + obj1 = dict->lookup("Popup"); + obj2 = dict->lookupNF("Popup"); + if (obj1.isDict() && obj2.isRef()) { + popup = new AnnotPopup(docA, &obj1, &obj2); } else { popup = NULL; } - obj1.free(); - if (dict->lookup("CA", &obj1)->isNum()) { + obj1 = dict->lookup("CA"); + if (obj1.isNum()) { opacity = obj1.getNum(); } else { opacity = 1.0; } - obj1.free(); - if (dict->lookup("CreationDate", &obj1)->isString()) { + obj1 = dict->lookup("CreationDate"); + if (obj1.isString()) { date = obj1.getString()->copy(); } else { date = NULL; } - obj1.free(); - if (dict->lookupNF("IRT", &obj1)->isRef()) { + obj1 = dict->lookupNF("IRT"); + if (obj1.isRef()) { inReplyTo = obj1.getRef(); } else { inReplyTo.num = 0; inReplyTo.gen = 0; } - obj1.free(); - if (dict->lookup("Subj", &obj1)->isString()) { + obj1 = dict->lookup("Subj"); + if (obj1.isString()) { subject = obj1.getString()->copy(); } else { subject = NULL; } - obj1.free(); - if (dict->lookup("RT", &obj1)->isName()) { + obj1 = dict->lookup("RT"); + if (obj1.isName()) { const char *replyName = obj1.getName(); if (!strcmp(replyName, "R")) { @@ -2062,14 +1970,13 @@ void AnnotMarkup::initialize(PDFDoc *docA, Dict *dict, Object *obj) { } else { replyTo = replyTypeR; } - obj1.free(); - if (dict->lookup("ExData", &obj1)->isDict()) { + obj1 = dict->lookup("ExData"); + if (obj1.isDict()) { exData = parseAnnotExternalData(obj1.getDict()); } else { exData = annotExternalDataMarkupUnknown; } - obj1.free(); } void AnnotMarkup::setLabel(GooString *new_label) { @@ -2079,16 +1986,13 @@ void AnnotMarkup::setLabel(GooString *new_label) { label = new GooString(new_label); //append the unicode marker <FE FF> if needed if (!label->hasUnicodeMarker()) { - label->insert(0, 0xff); - label->insert(0, 0xfe); + label->prependUnicodeMarker(); } } else { label = new GooString(); } - Object obj1; - obj1.initString(label->copy()); - update ("T", &obj1); + update ("T", Object(label->copy())); } void AnnotMarkup::setPopup(AnnotPopup *new_popup) { @@ -2105,11 +2009,8 @@ void AnnotMarkup::setPopup(AnnotPopup *new_popup) { delete popup; if (new_popup) { - Object obj1; - Ref popupRef = new_popup->getRef(); - - obj1.initRef (popupRef.num, popupRef.gen); - update ("Popup", &obj1); + const Ref popupRef = new_popup->getRef(); + update ("Popup", Object(popupRef.num, popupRef.gen)); new_popup->setParent(this); popup = new_popup; @@ -2128,11 +2029,8 @@ void AnnotMarkup::setPopup(AnnotPopup *new_popup) { } void AnnotMarkup::setOpacity(double opacityA) { - Object obj1; - opacity = opacityA; - obj1.initReal(opacity); - update ("CA", &obj1); + update ("CA", Object(opacity)); invalidateAppearance(); } @@ -2144,9 +2042,7 @@ void AnnotMarkup::setDate(GooString *new_date) { else date = new GooString(); - Object obj1; - obj1.initString(date->copy()); - update ("CreationDate", &obj1); + update ("CreationDate", Object(date->copy())); } void AnnotMarkup::removeReferencedObjects() { @@ -2167,21 +2063,19 @@ void AnnotMarkup::removeReferencedObjects() { AnnotText::AnnotText(PDFDoc *docA, PDFRectangle *rect) : AnnotMarkup(docA, rect) { - Object obj1; - type = typeText; flags |= flagNoZoom | flagNoRotate; - annotObj.dictSet ("Subtype", obj1.initName ("Text")); + annotObj.dictSet ("Subtype", Object(objName, "Text")); initialize (docA, annotObj.getDict()); } -AnnotText::AnnotText(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotText::AnnotText(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeText; flags |= flagNoZoom | flagNoRotate; - initialize (docA, dict); + initialize (docA, dictObject->getDict()); } AnnotText::~AnnotText() { @@ -2191,24 +2085,25 @@ AnnotText::~AnnotText() { void AnnotText::initialize(PDFDoc *docA, Dict *dict) { Object obj1; - if (dict->lookup("Open", &obj1)->isBool()) + obj1 = dict->lookup("Open"); + if (obj1.isBool()) open = obj1.getBool(); else open = gFalse; - obj1.free(); - if (dict->lookup("Name", &obj1)->isName()) { + obj1 = dict->lookup("Name"); + if (obj1.isName()) { icon = new GooString(obj1.getName()); } else { icon = new GooString("Note"); } - obj1.free(); - if (dict->lookup("StateModel", &obj1)->isString()) { - Object obj2; + obj1 = dict->lookup("StateModel"); + if (obj1.isString()) { GooString *modelName = obj1.getString(); - if (dict->lookup("State", &obj2)->isString()) { + Object obj2 = dict->lookup("State"); + if (obj2.isString()) { GooString *stateName = obj2.getString(); if (!stateName->cmp("Marked")) { @@ -2231,7 +2126,6 @@ void AnnotText::initialize(PDFDoc *docA, Dict *dict) { } else { state = stateUnknown; } - obj2.free(); if (!modelName->cmp("Marked")) { switch (state) { @@ -2266,15 +2160,13 @@ void AnnotText::initialize(PDFDoc *docA, Dict *dict) { } else { state = stateUnknown; } - obj1.free(); } void AnnotText::setOpen(GBool openA) { Object obj1; open = openA; - obj1.initBool(open); - update ("Open", &obj1); + update ("Open", Object(open)); } void AnnotText::setIcon(GooString *new_icon) { @@ -2289,9 +2181,7 @@ void AnnotText::setIcon(GooString *new_icon) { icon = new GooString("Note"); } - Object obj1; - obj1.initName (icon->getCString()); - update("Name", &obj1); + update("Name", Object(objName, icon->getCString())); invalidateAppearance(); } @@ -2540,7 +2430,6 @@ void AnnotText::setIcon(GooString *new_icon) { "19.5 12.5 m S\n" void AnnotText::draw(Gfx *gfx, GBool printing) { - Object obj; double ca = 1; if (!isVisible (printing)) @@ -2583,22 +2472,20 @@ void AnnotText::draw(Gfx *gfx, GBool printing) { double bbox[4]; appearBBox->getBBoxRect(bbox); if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); + appearance = createForm(bbox, gFalse, nullptr); } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); + Object aStream = createForm(bbox, gTrue, nullptr); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); if (appearBBox) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, appearBBox->getPageXMin(), appearBBox->getPageYMin(), @@ -2608,7 +2495,6 @@ void AnnotText::draw(Gfx *gfx, GBool printing) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); } - obj.free(); } //------------------------------------------------------------------------ @@ -2619,15 +2505,15 @@ AnnotLink::AnnotLink(PDFDoc *docA, PDFRectangle *rect) : Object obj1; type = typeLink; - annotObj.dictSet ("Subtype", obj1.initName ("Link")); + annotObj.dictSet ("Subtype", Object(objName, "Link")); initialize (docA, annotObj.getDict()); } -AnnotLink::AnnotLink(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { +AnnotLink::AnnotLink(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { type = typeLink; - initialize (docA, dict); + initialize (docA, dictObject->getDict()); } AnnotLink::~AnnotLink() { @@ -2646,18 +2532,19 @@ void AnnotLink::initialize(PDFDoc *docA, Dict *dict) { action = NULL; // look for destination - if (!dict->lookup("Dest", &obj1)->isNull()) { + obj1 = dict->lookup("Dest"); + if (!obj1.isNull()) { action = LinkAction::parseDest(&obj1); // look for action } else { - obj1.free(); - if (dict->lookup("A", &obj1)->isDict()) { + obj1 = dict->lookup("A"); + if (obj1.isDict()) { action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); } } - obj1.free(); - if (dict->lookup("H", &obj1)->isName()) { + obj1 = dict->lookup("H"); + if (obj1.isName()) { const char *effect = obj1.getName(); if (!strcmp(effect, "N")) { @@ -2674,43 +2561,40 @@ void AnnotLink::initialize(PDFDoc *docA, Dict *dict) { } else { linkEffect = effectInvert; } - obj1.free(); /* - if (dict->lookup("PA", &obj1)->isDict()) { + obj1 = dict->lookup("PA"); + if (obj1.isDict()) { uriAction = NULL; } else { uriAction = NULL; } obj1.free(); */ - if (dict->lookup("QuadPoints", &obj1)->isArray()) { + obj1 = dict->lookup("QuadPoints"); + if (obj1.isArray()) { quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); } else { quadrilaterals = NULL; } - obj1.free(); - if (dict->lookup("BS", &obj1)->isDict()) { + obj1 = dict->lookup("BS"); + if (obj1.isDict()) { delete border; border = new AnnotBorderBS(obj1.getDict()); } else if (!border) { border = new AnnotBorderBS(); } - obj1.free(); } void AnnotLink::draw(Gfx *gfx, GBool printing) { - Object obj; - if (!isVisible (printing)) return; annotLocker(); // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); gfx->drawAnnot(&obj, border, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); } //------------------------------------------------------------------------ @@ -2722,19 +2606,16 @@ AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da) : type = typeFreeText; - annotObj.dictSet ("Subtype", obj1.initName ("FreeText")); - - Object obj2; - obj2.initString (da->copy()); - annotObj.dictSet("DA", &obj2); + annotObj.dictSet ("Subtype", Object(objName, "FreeText")); + annotObj.dictSet("DA", Object(da->copy())); initialize (docA, annotObj.getDict()); } -AnnotFreeText::AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotFreeText::AnnotFreeText(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeFreeText; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotFreeText::~AnnotFreeText() { @@ -2756,48 +2637,43 @@ AnnotFreeText::~AnnotFreeText() { void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) { Object obj1; - if (dict->lookup("DA", &obj1)->isString()) { + obj1 = dict->lookup("DA"); + if (obj1.isString()) { appearanceString = obj1.getString()->copy(); } else { appearanceString = new GooString(); error(errSyntaxError, -1, "Bad appearance for annotation"); ok = gFalse; } - obj1.free(); - if (dict->lookup("Q", &obj1)->isInt()) { + obj1 = dict->lookup("Q"); + if (obj1.isInt()) { quadding = (AnnotFreeTextQuadding) obj1.getInt(); } else { quadding = quaddingLeftJustified; } - obj1.free(); - if (dict->lookup("DS", &obj1)->isString()) { + obj1 = dict->lookup("DS"); + if (obj1.isString()) { styleString = obj1.getString()->copy(); } else { styleString = NULL; } - obj1.free(); - if (dict->lookup("CL", &obj1)->isArray() && obj1.arrayGetLength() >= 4) { + obj1 = dict->lookup("CL"); + if (obj1.isArray() && obj1.arrayGetLength() >= 4) { double x1, y1, x2, y2; Object obj2; - (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? y1 = obj2.getNum() : y1 = 0); - obj2.free(); - (obj1.arrayGet(2, &obj2)->isNum() ? x2 = obj2.getNum() : x2 = 0); - obj2.free(); - (obj1.arrayGet(3, &obj2)->isNum() ? y2 = obj2.getNum() : y2 = 0); - obj2.free(); + (obj2 = obj1.arrayGet(0), obj2.isNum() ? x1 = obj2.getNum() : x1 = 0); + (obj2 = obj1.arrayGet(1), obj2.isNum() ? y1 = obj2.getNum() : y1 = 0); + (obj2 = obj1.arrayGet(2), obj2.isNum() ? x2 = obj2.getNum() : x2 = 0); + (obj2 = obj1.arrayGet(3), obj2.isNum() ? y2 = obj2.getNum() : y2 = 0); if (obj1.arrayGetLength() == 6) { double x3, y3; - (obj1.arrayGet(4, &obj2)->isNum() ? x3 = obj2.getNum() : x3 = 0); - obj2.free(); - (obj1.arrayGet(5, &obj2)->isNum() ? y3 = obj2.getNum() : y3 = 0); - obj2.free(); + (obj2 = obj1.arrayGet(4), obj2.isNum() ? x3 = obj2.getNum() : x3 = 0); + (obj2 = obj1.arrayGet(5), obj2.isNum() ? y3 = obj2.getNum() : y3 = 0); calloutLine = new AnnotCalloutMultiLine(x1, y1, x2, y2, x3, y3); } else { calloutLine = new AnnotCalloutLine(x1, y1, x2, y2); @@ -2805,9 +2681,9 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) { } else { calloutLine = NULL; } - obj1.free(); - if (dict->lookup("IT", &obj1)->isName()) { + obj1 = dict->lookup("IT"); + if (obj1.isName()) { const char *intentName = obj1.getName(); if (!strcmp(intentName, "FreeText")) { @@ -2822,37 +2698,36 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) { } else { intent = intentFreeText; } - obj1.free(); - if (dict->lookup("BS", &obj1)->isDict()) { + obj1 = dict->lookup("BS"); + if (obj1.isDict()) { delete border; border = new AnnotBorderBS(obj1.getDict()); } else if (!border) { border = new AnnotBorderBS(); } - obj1.free(); - if (dict->lookup("BE", &obj1)->isDict()) { + obj1 = dict->lookup("BE"); + if (obj1.isDict()) { borderEffect = new AnnotBorderEffect(obj1.getDict()); } else { borderEffect = NULL; } - obj1.free(); - if (dict->lookup("RD", &obj1)->isArray()) { + obj1 = dict->lookup("RD"); + if (obj1.isArray()) { rectangle = parseDiffRectangle(obj1.getArray(), rect); } else { rectangle = NULL; } - obj1.free(); - if (dict->lookup("LE", &obj1)->isName()) { + obj1 = dict->lookup("LE"); + if (obj1.isName()) { GooString styleName(obj1.getName()); endStyle = parseAnnotLineEndingStyle(&styleName); } else { endStyle = annotLineEndingNone; } - obj1.free(); } void AnnotFreeText::setContents(GooString *new_content) { @@ -2869,17 +2744,14 @@ void AnnotFreeText::setAppearanceString(GooString *new_string) { appearanceString = new GooString(); } - Object obj1; - obj1.initString(appearanceString->copy()); - update ("DA", &obj1); + update ("DA", Object(appearanceString->copy())); invalidateAppearance(); } void AnnotFreeText::setQuadding(AnnotFreeTextQuadding new_quadding) { Object obj1; quadding = new_quadding; - obj1.initInt((int)quadding); - update ("Q", &obj1); + update ("Q", Object((int)quadding)); invalidateAppearance(); } @@ -2890,16 +2762,13 @@ void AnnotFreeText::setStyleString(GooString *new_string) { styleString = new GooString(new_string); //append the unicode marker <FE FF> if needed if (!styleString->hasUnicodeMarker()) { - styleString->insert(0, 0xff); - styleString->insert(0, 0xfe); + styleString->prependUnicodeMarker(); } } else { styleString = new GooString(); } - Object obj1; - obj1.initString(styleString->copy()); - update ("DS", &obj1); + update ("DS", Object(styleString->copy())); } void AnnotFreeText::setCalloutLine(AnnotCalloutLine *line) { @@ -2907,73 +2776,59 @@ void AnnotFreeText::setCalloutLine(AnnotCalloutLine *line) { Object obj1; if (line == NULL) { - obj1.initNull(); + obj1.setToNull(); calloutLine = NULL; } else { double x1 = line->getX1(), y1 = line->getY1(); double x2 = line->getX2(), y2 = line->getY2(); - Object obj2; - obj1.initArray(xref); - obj1.arrayAdd( obj2.initReal(x1) ); - obj1.arrayAdd( obj2.initReal(y1) ); - obj1.arrayAdd( obj2.initReal(x2) ); - obj1.arrayAdd( obj2.initReal(y2) ); + obj1 = Object( new Array(xref) ); + obj1.arrayAdd( Object(x1) ); + obj1.arrayAdd( Object(y1) ); + obj1.arrayAdd( Object(x2) ); + obj1.arrayAdd( Object(y2) ); AnnotCalloutMultiLine *mline = dynamic_cast<AnnotCalloutMultiLine*>(line); if (mline) { double x3 = mline->getX3(), y3 = mline->getY3(); - obj1.arrayAdd( obj2.initReal(x3) ); - obj1.arrayAdd( obj2.initReal(y3) ); + obj1.arrayAdd( Object(x3) ); + obj1.arrayAdd( Object(y3) ); calloutLine = new AnnotCalloutMultiLine(x1, y1, x2, y2, x3, y3); } else { calloutLine = new AnnotCalloutLine(x1, y1, x2, y2); } } - update("CL", &obj1); + update("CL", std::move(obj1)); invalidateAppearance(); } void AnnotFreeText::setIntent(AnnotFreeTextIntent new_intent) { - Object obj1; + const char *intentName; intent = new_intent; if (new_intent == intentFreeText) - obj1.initName("FreeText"); + intentName = "FreeText"; else if (new_intent == intentFreeTextCallout) - obj1.initName("FreeTextCallout"); + intentName = "FreeTextCallout"; else // intentFreeTextTypeWriter - obj1.initName("FreeTextTypeWriter"); - update ("IT", &obj1); + intentName = "FreeTextTypeWriter"; + update ("IT", Object(objName, intentName)); } -static GfxFont * createAnnotDrawFont(XRef * xref, Object *fontResDict) +static GfxFont * createAnnotDrawFont(XRef * xref, Dict *fontResDict) { - Ref dummyRef = { -1, -1 }; - - Object baseFontObj, subtypeObj, encodingObj; - baseFontObj.initName("Helvetica"); - subtypeObj.initName("Type0"); - encodingObj.initName("WinAnsiEncoding"); + const Ref dummyRef = { -1, -1 }; - Object fontDictObj; Dict *fontDict = new Dict(xref); - fontDict->decRef(); - fontDict->add(copyString("BaseFont"), &baseFontObj); - fontDict->add(copyString("Subtype"), &subtypeObj); - fontDict->add(copyString("Encoding"), &encodingObj); - fontDictObj.initDict(fontDict); + fontDict->add(copyString("BaseFont"), Object(objName, "Helvetica")); + fontDict->add(copyString("Subtype"), Object(objName, "Type0")); + fontDict->add(copyString("Encoding"), Object(objName, "WinAnsiEncoding")); - Object fontsDictObj; Dict *fontsDict = new Dict(xref); - fontsDict->decRef(); - fontsDict->add(copyString("AnnotDrawFont"), &fontDictObj); - fontsDictObj.initDict(fontsDict); + fontsDict->add(copyString("AnnotDrawFont"), Object(fontDict)); - Dict *dict = new Dict(xref); - dict->add(copyString("Font"), &fontsDictObj); + fontResDict->add(copyString("Font"), Object(fontsDict)); - fontResDict->initDict(dict); return GfxFont::makeFont(xref, "AnnotDrawFont", dummyRef, fontDict); } @@ -2982,29 +2837,14 @@ void AnnotFreeText::parseAppearanceString(GooString *da, double &fontsize, Annot fontcolor = NULL; if (da) { GooList * daToks = new GooList(); - int j, i = 0; + int i = FormFieldText::tokenizeDA(da, daToks, "Tf"); - // Tokenize - while (i < da->getLength()) { - while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { - ++i; - } - if (i < da->getLength()) { - for (j = i + 1; j < da->getLength() && !Lexer::isSpace(da->getChar(j)); ++j) { - } - daToks->append(new GooString(da, i, j - i)); - i = j; - } + if (i >= 1) { + fontsize = gatof(( (GooString *)daToks->get(i-1) )->getCString()); + // TODO: Font name } - // Scan backwards: we are looking for the last set value for (i = daToks->getLength()-1; i >= 0; --i) { - if (fontsize == -1) { - if (!((GooString *)daToks->get(i))->cmp("Tf") && i >= 2) { - // TODO: Font name - fontsize = gatof(( (GooString *)daToks->get(i-1) )->getCString()); - } - } if (fontcolor == NULL) { if (!((GooString *)daToks->get(i))->cmp("g") && i >= 1) { fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-1) )->getCString())); @@ -3072,8 +2912,8 @@ void AnnotFreeText::generateFreeTextAppearance() const double textwidth = width - 2*textmargin; appearBuf->appendf ("{0:.2f} {0:.2f} {1:.2f} {2:.2f} re W n\n", textmargin, textwidth, height - 2*textmargin); - Object fontResDict; - GfxFont *font = createAnnotDrawFont(xref, &fontResDict); + Dict *fontResDict = new Dict(xref); + GfxFont *font = createAnnotDrawFont(xref, fontResDict); // Set font state setColor(fontcolor, gTrue); @@ -3114,23 +2954,19 @@ void AnnotFreeText::generateFreeTextAppearance() bbox[3] = rect->y2 - rect->y1; if (ca == 1) { - createForm(bbox, gFalse, &fontResDict, &appearance); + appearance = createForm(bbox, gFalse, fontResDict); } else { - Object aStream, resDict; - - createForm(bbox, gTrue, &fontResDict, &aStream); + Object aStream = createForm(bbox, gTrue, fontResDict); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } void AnnotFreeText::draw(Gfx *gfx, GBool printing) { - Object obj; - if (!isVisible (printing)) return; @@ -3140,19 +2976,18 @@ void AnnotFreeText::draw(Gfx *gfx, GBool printing) { } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); } // Before retrieving the res dict, regenerate the appearance stream if needed, // because AnnotFreeText::draw needs to store font info in the res dict -Object *AnnotFreeText::getAppearanceResDict(Object *dest) { +Object AnnotFreeText::getAppearanceResDict() { if (appearance.isNull()) { generateFreeTextAppearance(); } - return Annot::getAppearanceResDict(dest); + return Annot::getAppearanceResDict(); } //------------------------------------------------------------------------ @@ -3164,15 +2999,15 @@ AnnotLine::AnnotLine(PDFDoc *docA, PDFRectangle *rect) : Object obj1; type = typeLine; - annotObj.dictSet ("Subtype", obj1.initName ("Line")); + annotObj.dictSet ("Subtype", Object(objName, "Line")); initialize (docA, annotObj.getDict()); } -AnnotLine::AnnotLine(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotLine::AnnotLine(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeLine; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotLine::~AnnotLine() { @@ -3189,18 +3024,15 @@ AnnotLine::~AnnotLine() { void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { Object obj1; - if (dict->lookup("L", &obj1)->isArray() && obj1.arrayGetLength() == 4) { + obj1 = dict->lookup("L"); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { Object obj2; double x1, y1, x2, y2; - (obj1.arrayGet(0, &obj2)->isNum() ? x1 = obj2.getNum() : x1 = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? y1 = obj2.getNum() : y1 = 0); - obj2.free(); - (obj1.arrayGet(2, &obj2)->isNum() ? x2 = obj2.getNum() : x2 = 0); - obj2.free(); - (obj1.arrayGet(3, &obj2)->isNum() ? y2 = obj2.getNum() : y2 = 0); - obj2.free(); + (obj2 = obj1.arrayGet(0), obj2.isNum() ? x1 = obj2.getNum() : x1 = 0); + (obj2 = obj1.arrayGet(1), obj2.isNum() ? y1 = obj2.getNum() : y1 = 0); + (obj2 = obj1.arrayGet(2), obj2.isNum() ? x2 = obj2.getNum() : x2 = 0); + (obj2 = obj1.arrayGet(3), obj2.isNum() ? y2 = obj2.getNum() : y2 = 0); coord1 = new AnnotCoord(x1, y1); coord2 = new AnnotCoord(x2, y2); @@ -3208,43 +3040,43 @@ void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { coord1 = new AnnotCoord(); coord2 = new AnnotCoord(); } - obj1.free(); - if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) { + obj1 = dict->lookup("LE"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { Object obj2; - if(obj1.arrayGet(0, &obj2)->isString()) + obj2 = obj1.arrayGet(0); + if (obj2.isString()) startStyle = parseAnnotLineEndingStyle(obj2.getString()); else startStyle = annotLineEndingNone; - obj2.free(); - if(obj1.arrayGet(1, &obj2)->isString()) + obj2 = obj1.arrayGet(1); + if (obj2.isString()) endStyle = parseAnnotLineEndingStyle(obj2.getString()); else endStyle = annotLineEndingNone; - obj2.free(); } else { startStyle = endStyle = annotLineEndingNone; } - obj1.free(); - if (dict->lookup("IC", &obj1)->isArray()) { + obj1 = dict->lookup("IC"); + if (obj1.isArray()) { interiorColor = new AnnotColor(obj1.getArray()); } else { interiorColor = NULL; } - obj1.free(); - if (dict->lookup("LL", &obj1)->isNum()) { + obj1 = dict->lookup("LL"); + if (obj1.isNum()) { leaderLineLength = obj1.getNum(); } else { leaderLineLength = 0; } - obj1.free(); - if (dict->lookup("LLE", &obj1)->isNum()) { + obj1 = dict->lookup("LLE"); + if (obj1.isNum()) { leaderLineExtension = obj1.getNum(); if (leaderLineExtension < 0) @@ -3252,16 +3084,16 @@ void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { } else { leaderLineExtension = 0; } - obj1.free(); - if (dict->lookup("Cap", &obj1)->isBool()) { + obj1 = dict->lookup("Cap"); + if (obj1.isBool()) { caption = obj1.getBool(); } else { caption = gFalse; } - obj1.free(); - if (dict->lookup("IT", &obj1)->isName()) { + obj1 = dict->lookup("IT"); + if (obj1.isName()) { const char *intentName = obj1.getName(); if(!strcmp(intentName, "LineArrow")) { @@ -3274,9 +3106,9 @@ void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { } else { intent = intentLineArrow; } - obj1.free(); - if (dict->lookup("LLO", &obj1)->isNum()) { + obj1 = dict->lookup("LLO"); + if (obj1.isNum()) { leaderLineOffset = obj1.getNum(); if (leaderLineOffset < 0) @@ -3284,9 +3116,9 @@ void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { } else { leaderLineOffset = 0; } - obj1.free(); - if (dict->lookup("CP", &obj1)->isName()) { + obj1 = dict->lookup("CP"); + if (obj1.isName()) { const char *captionName = obj1.getName(); if(!strcmp(captionName, "Inline")) { @@ -3299,36 +3131,33 @@ void AnnotLine::initialize(PDFDoc *docA, Dict *dict) { } else { captionPos = captionPosInline; } - obj1.free(); - if (dict->lookup("Measure", &obj1)->isDict()) { + obj1 = dict->lookup("Measure"); + if (obj1.isDict()) { measure = NULL; } else { measure = NULL; } - obj1.free(); - if ((dict->lookup("CO", &obj1)->isArray()) && (obj1.arrayGetLength() == 2)) { + obj1 = dict->lookup("CO"); + if (obj1.isArray() && (obj1.arrayGetLength() == 2)) { Object obj2; - (obj1.arrayGet(0, &obj2)->isNum() ? captionTextHorizontal = obj2.getNum() : - captionTextHorizontal = 0); - obj2.free(); - (obj1.arrayGet(1, &obj2)->isNum() ? captionTextVertical = obj2.getNum() : - captionTextVertical = 0); - obj2.free(); + obj2 = obj1.arrayGet(0); + captionTextHorizontal = obj2.isNum() ? obj2.getNum() : 0; + obj2 = obj1.arrayGet(1); + captionTextVertical = obj2.isNum() ? obj2.getNum() : 0; } else { captionTextHorizontal = captionTextVertical = 0; } - obj1.free(); - if (dict->lookup("BS", &obj1)->isDict()) { + obj1 = dict->lookup("BS"); + if (obj1.isDict()) { delete border; border = new AnnotBorderBS(obj1.getDict()); } else if (!border) { border = new AnnotBorderBS(); } - obj1.free(); } void AnnotLine::setContents(GooString *new_content) { @@ -3338,34 +3167,30 @@ void AnnotLine::setContents(GooString *new_content) { } void AnnotLine::setVertices(double x1, double y1, double x2, double y2) { - Object obj1, obj2; - delete coord1; coord1 = new AnnotCoord(x1, y1); delete coord2; coord2 = new AnnotCoord(x2, y2); - obj1.initArray(xref); - obj1.arrayAdd( obj2.initReal(x1) ); - obj1.arrayAdd( obj2.initReal(y1) ); - obj1.arrayAdd( obj2.initReal(x2) ); - obj1.arrayAdd( obj2.initReal(y2) ); + Array *lArray = new Array(xref); + lArray->add( Object(x1) ); + lArray->add( Object(y1) ); + lArray->add( Object(x2) ); + lArray->add( Object(y2) ); - update("L", &obj1); + update("L", Object(lArray)); invalidateAppearance(); } void AnnotLine::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) { - Object obj1, obj2; - startStyle = start; endStyle = end; - obj1.initArray(xref); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( startStyle )) ); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) ); + Array *leArray = new Array(xref); + leArray->add( Object(objName, convertAnnotLineEndingStyle( startStyle )) ); + leArray->add( Object(objName, convertAnnotLineEndingStyle( endStyle )) ); - update("LE", &obj1); + update("LE", Object(leArray)); invalidateAppearance(); } @@ -3373,9 +3198,8 @@ void AnnotLine::setInteriorColor(AnnotColor *new_color) { delete interiorColor; if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("IC", &obj1); + Object obj1 = new_color->writeToObject(xref); + update ("IC", std::move(obj1)); interiorColor = new_color; } else { interiorColor = NULL; @@ -3384,45 +3208,35 @@ void AnnotLine::setInteriorColor(AnnotColor *new_color) { } void AnnotLine::setLeaderLineLength(double len) { - Object obj1; - leaderLineLength = len; - obj1.initReal(len); - update ("LL", &obj1); + update ("LL", Object(len)); invalidateAppearance(); } void AnnotLine::setLeaderLineExtension(double len) { - Object obj1; - leaderLineExtension = len; - obj1.initReal(len); - update ("LLE", &obj1); + update ("LLE", Object(len)); // LL is required if LLE is present - obj1.initReal(leaderLineLength); - update ("LL", &obj1); + update ("LL", Object(leaderLineLength)); invalidateAppearance(); } void AnnotLine::setCaption(bool new_cap) { - Object obj1; - caption = new_cap; - obj1.initBool(new_cap); - update ("Cap", &obj1); + update ("Cap", Object(new_cap)); invalidateAppearance(); } void AnnotLine::setIntent(AnnotLineIntent new_intent) { - Object obj1; + const char *intentName; intent = new_intent; if (new_intent == intentLineArrow) - obj1.initName("LineArrow"); + intentName = "LineArrow"; else // intentLineDimension - obj1.initName("LineDimension"); - update ("IT", &obj1); + intentName = "LineDimension"; + update ("IT", Object(objName, intentName)); } void AnnotLine::generateLineAppearance() @@ -3463,12 +3277,13 @@ void AnnotLine::generateLineAppearance() const double captionhmargin = 2; // Left and right margin (inline caption only) const double captionmaxwidth = main_len - 2 * captionhmargin; - Object fontResDict; + Dict *fontResDict; GfxFont *font; // Calculate caption width and height if (caption) { - font = createAnnotDrawFont(xref, &fontResDict); + fontResDict = new Dict(xref); + font = createAnnotDrawFont(xref, fontResDict); int lines = 0; int i = 0; while (i < contents->getLength()) { @@ -3487,7 +3302,7 @@ void AnnotLine::generateLineAppearance() actualCaptionPos = captionPosTop; } } else { - fontResDict.initNull(); + fontResDict = nullptr; font = NULL; } @@ -3579,23 +3394,19 @@ void AnnotLine::generateLineAppearance() double bbox[4]; appearBBox->getBBoxRect(bbox); if (ca == 1) { - createForm(bbox, gFalse, &fontResDict, &appearance); + appearance = createForm(bbox, gFalse, fontResDict); } else { - Object aStream, resDict; - - createForm(bbox, gTrue, &fontResDict, &aStream); + Object aStream = createForm(bbox, gTrue, fontResDict); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } void AnnotLine::draw(Gfx *gfx, GBool printing) { - Object obj; - if (!isVisible (printing)) return; @@ -3605,7 +3416,7 @@ void AnnotLine::draw(Gfx *gfx, GBool printing) { } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); if (appearBBox) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, appearBBox->getPageXMin(), appearBBox->getPageYMin(), @@ -3615,16 +3426,15 @@ void AnnotLine::draw(Gfx *gfx, GBool printing) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); } - obj.free(); } // Before retrieving the res dict, regenerate the appearance stream if needed, // because AnnotLine::draw may need to store font info in the res dict -Object *AnnotLine::getAppearanceResDict(Object *dest) { +Object AnnotLine::getAppearanceResDict() { if (appearance.isNull()) { generateLineAppearance(); } - return Annot::getAppearanceResDict(dest); + return Annot::getAppearanceResDict(); } //------------------------------------------------------------------------ @@ -3636,43 +3446,43 @@ AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype switch (subType) { case typeHighlight: - annotObj.dictSet ("Subtype", obj1.initName ("Highlight")); + annotObj.dictSet ("Subtype", Object(objName, "Highlight")); break; case typeUnderline: - annotObj.dictSet ("Subtype", obj1.initName ("Underline")); + annotObj.dictSet ("Subtype", Object(objName, "Underline")); break; case typeSquiggly: - annotObj.dictSet ("Subtype", obj1.initName ("Squiggly")); + annotObj.dictSet ("Subtype", Object(objName, "Squiggly")); break; case typeStrikeOut: - annotObj.dictSet ("Subtype", obj1.initName ("StrikeOut")); + annotObj.dictSet ("Subtype", Object(objName, "StrikeOut")); break; default: assert (0 && "Invalid subtype for AnnotTextMarkup\n"); } // Store dummy quadrilateral with null coordinates - Object obj2, obj3; - obj2.initArray (doc->getXRef()); + Array *quadPoints = new Array(doc->getXRef()); for (int i = 0; i < 4*2; ++i) { - obj2.arrayAdd (obj3.initReal (0)); + quadPoints->add(Object(0.)); } - annotObj.dictSet ("QuadPoints", &obj2); + annotObj.dictSet ("QuadPoints", Object(quadPoints)); initialize(docA, annotObj.getDict()); } -AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotTextMarkup::AnnotTextMarkup(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { // the real type will be read in initialize() type = typeHighlight; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } void AnnotTextMarkup::initialize(PDFDoc *docA, Dict *dict) { Object obj1; - if (dict->lookup("Subtype", &obj1)->isName()) { + obj1 = dict->lookup("Subtype"); + if (obj1.isName()) { GooString typeName(obj1.getName()); if (!typeName.cmp("Highlight")) { type = typeHighlight; @@ -3684,76 +3494,70 @@ void AnnotTextMarkup::initialize(PDFDoc *docA, Dict *dict) { type = typeStrikeOut; } } - obj1.free(); - if(dict->lookup("QuadPoints", &obj1)->isArray()) { + obj1 = dict->lookup("QuadPoints"); + if (obj1.isArray()) { quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); } else { error(errSyntaxError, -1, "Bad Annot Text Markup QuadPoints"); quadrilaterals = NULL; ok = gFalse; } - obj1.free(); } AnnotTextMarkup::~AnnotTextMarkup() { - if(quadrilaterals) { - delete quadrilaterals; - } + delete quadrilaterals; } void AnnotTextMarkup::setType(AnnotSubtype new_type) { - Object obj1; + const char *typeName = nullptr; /* squelch bogus compiler warning */ switch (new_type) { case typeHighlight: - obj1.initName("Highlight"); + typeName = "Highlight"; break; case typeUnderline: - obj1.initName("Underline"); + typeName = "Underline"; break; case typeSquiggly: - obj1.initName("Squiggly"); + typeName = "Squiggly"; break; case typeStrikeOut: - obj1.initName("StrikeOut"); + typeName = "StrikeOut"; break; default: assert(!"Invalid subtype"); } type = new_type; - update("Subtype", &obj1); + update("Subtype", Object(objName, typeName)); invalidateAppearance(); } void AnnotTextMarkup::setQuadrilaterals(AnnotQuadrilaterals *quadPoints) { - Object obj1, obj2; - obj1.initArray (xref); + Array *a = new Array(xref); for (int i = 0; i < quadPoints->getQuadrilateralsLength(); ++i) { - obj1.arrayAdd (obj2.initReal (quadPoints->getX1(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY1(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getX2(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY2(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getX3(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY3(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getX4(i))); - obj1.arrayAdd (obj2.initReal (quadPoints->getY4(i))); + a->add(Object(quadPoints->getX1(i))); + a->add(Object(quadPoints->getY1(i))); + a->add(Object(quadPoints->getX2(i))); + a->add(Object(quadPoints->getY2(i))); + a->add(Object(quadPoints->getX3(i))); + a->add(Object(quadPoints->getY3(i))); + a->add(Object(quadPoints->getX4(i))); + a->add(Object(quadPoints->getY4(i))); } delete quadrilaterals; - quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); + quadrilaterals = new AnnotQuadrilaterals(a, rect); - annotObj.dictSet ("QuadPoints", &obj1); + annotObj.dictSet ("QuadPoints", Object(a)); invalidateAppearance(); } void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) { - Object obj; double ca = 1; int i; - Object obj1, obj2; if (!isVisible (printing)) return; @@ -3850,8 +3654,6 @@ void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) { break; default: case typeHighlight: - appearance.free(); - if (color) setColor(color, gTrue); @@ -3887,32 +3689,32 @@ void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) { } appearBuf->append ("Q\n"); - Object aStream, resDict; + Object aStream; double bbox[4]; bbox[0] = appearBBox->getPageXMin(); bbox[1] = appearBBox->getPageYMin(); bbox[2] = appearBBox->getPageXMax(); bbox[3] = appearBBox->getPageYMax(); - createForm(bbox, gTrue, NULL, &aStream); + aStream = createForm(bbox, gTrue, NULL); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", 1, blendMultiply ? "Multiply" : NULL, &resDict); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", 1, blendMultiply ? "Multiply" : NULL); if (ca == 1) { - createForm(bbox, gFalse, &resDict, &appearance); + appearance = createForm(bbox, gFalse, resDict); } else { - createForm(bbox, gTrue, &resDict, &aStream); + aStream = createForm(bbox, gTrue, resDict); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict2 = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict2); } delete appearBuf; } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); if (appearBBox) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, appearBBox->getPageXMin(), appearBBox->getPageYMin(), @@ -3922,25 +3724,24 @@ void AnnotTextMarkup::draw(Gfx *gfx, GBool printing) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); } - obj.free(); } //------------------------------------------------------------------------ // AnnotWidget //------------------------------------------------------------------------ -AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { +AnnotWidget::AnnotWidget(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { type = typeWidget; field = NULL; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } -AnnotWidget::AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA) : - Annot(docA, dict, obj) { +AnnotWidget::AnnotWidget(PDFDoc *docA, Object *dictObject, Object *obj, FormField *fieldA) : + Annot(docA, dictObject, obj) { type = typeWidget; field = fieldA; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotWidget::~AnnotWidget() { @@ -3950,8 +3751,6 @@ AnnotWidget::~AnnotWidget() { if (action) delete action; - additionalActions.free(); - if (parent) delete parent; } @@ -3961,7 +3760,8 @@ void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) { form = doc->getCatalog()->getForm(); - if(dict->lookup("H", &obj1)->isName()) { + obj1 = dict->lookup("H"); + if (obj1.isName()) { const char *modeName = obj1.getName(); if(!strcmp(modeName, "N")) { @@ -3976,35 +3776,34 @@ void AnnotWidget::initialize(PDFDoc *docA, Dict *dict) { } else { mode = highlightModeInvert; } - obj1.free(); - if(dict->lookup("MK", &obj1)->isDict()) { + obj1 = dict->lookup("MK"); + if (obj1.isDict()) { appearCharacs = new AnnotAppearanceCharacs(obj1.getDict()); } else { appearCharacs = NULL; } - obj1.free(); action = NULL; - if(dict->lookup("A", &obj1)->isDict()) { + obj1 = dict->lookup("A"); + if (obj1.isDict()) { action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); } - obj1.free(); - dict->lookupNF("AA", &additionalActions); + additionalActions = dict->lookupNF("AA"); - if(dict->lookup("Parent", &obj1)->isDict()) { + obj1 = dict->lookup("Parent"); + if (obj1.isDict()) { parent = NULL; } else { parent = NULL; } - obj1.free(); - if (dict->lookup("BS", &obj1)->isDict()) { + obj1 = dict->lookup("BS"); + if (obj1.isDict()) { delete border; border = new AnnotBorderBS(obj1.getDict()); } - obj1.free(); updatedAppearanceStream.num = updatedAppearanceStream.gen = -1; } @@ -4882,7 +4681,7 @@ void AnnotWidget::drawBorder() { appearBuf->appendf(" {0:.2f}", dash[i]); } appearBuf->append("] 0 d\n"); - // fall through to the solid case + // fallthrough case AnnotBorder::borderSolid: case AnnotBorder::borderUnderlined: appearBuf->appendf("{0:.2f} w\n", w); @@ -4914,7 +4713,7 @@ void AnnotWidget::drawBorder() { appearBuf->appendf(" {0:.2f}", dash[i]); } appearBuf->append("] 0 d\n"); - // fall through to the solid case + // fallthrough case AnnotBorder::borderSolid: appearBuf->appendf("{0:.2f} w\n", w); setColor(aColor, gFalse); @@ -5037,9 +4836,7 @@ void AnnotWidget::drawFormFieldChoice(GfxResources *resources, GooString *da) { } void AnnotWidget::generateFieldAppearance() { - Object appearDict, obj1, obj2; GfxResources *resources; - MemStream *appearStream; GooString *da; appearBuf = new GooString (); @@ -5084,28 +4881,26 @@ void AnnotWidget::generateFieldAppearance() { } // build the appearance stream dictionary - appearDict.initDict(xref); - appearDict.dictAdd(copyString("Length"), - obj1.initInt(appearBuf->getLength())); - appearDict.dictAdd(copyString("Subtype"), obj1.initName("Form")); - obj1.initArray(xref); - obj1.arrayAdd(obj2.initReal(0)); - obj1.arrayAdd(obj2.initReal(0)); - obj1.arrayAdd(obj2.initReal(rect->x2 - rect->x1)); - obj1.arrayAdd(obj2.initReal(rect->y2 - rect->y1)); - appearDict.dictAdd(copyString("BBox"), &obj1); + Dict *appearDict = new Dict(xref); + appearDict->add(copyString("Length"), Object(appearBuf->getLength())); + appearDict->add(copyString("Subtype"), Object(objName, "Form")); + Array *bbox = new Array(xref); + bbox->add(Object(0)); + bbox->add(Object(0)); + bbox->add(Object(rect->x2 - rect->x1)); + bbox->add(Object(rect->y2 - rect->y1)); + appearDict->add(copyString("BBox"), Object(bbox)); // set the resource dictionary Object *resDict = form->getDefaultResourcesObj(); if (resDict->isDict()) { - appearDict.dictAdd(copyString("Resources"), resDict->copy(&obj1)); + appearDict->add(copyString("Resources"), resDict->copy()); } // build the appearance stream - appearStream = new MemStream(copyString(appearBuf->getCString()), 0, - appearBuf->getLength(), &appearDict); - appearance.free(); - appearance.initStream(appearStream); + MemStream *appearStream = new MemStream(copyString(appearBuf->getCString()), 0, + appearBuf->getLength(), Object(appearDict)); + appearance = Object(static_cast<Stream*>(appearStream)); delete appearBuf; appearStream->setNeedFree(gTrue); @@ -5128,8 +4923,7 @@ void AnnotWidget::updateAppearanceStream() generateFieldAppearance(); // Fetch the appearance stream we've just created - Object obj1; - appearance.fetch(xref, &obj1); + Object obj1 = appearance.fetch(xref); // If this the first time updateAppearanceStream() is called on this widget, // create a new AP dictionary containing the new appearance stream. @@ -5137,26 +4931,22 @@ void AnnotWidget::updateAppearanceStream() if (updatedAppearanceStream.num == -1) { // Write the appearance stream updatedAppearanceStream = xref->addIndirectObject(&obj1); - obj1.free(); // Write the AP dictionary - Object obj2; - obj1.initDict(xref); - obj1.dictAdd(copyString("N"), obj2.initRef(updatedAppearanceStream.num, updatedAppearanceStream.gen)); - update("AP", &obj1); + obj1 = Object(new Dict(xref)); + obj1.dictAdd(copyString("N"), Object(updatedAppearanceStream.num, updatedAppearanceStream.gen)); // Update our internal pointers to the appearance dictionary appearStreams = new AnnotAppearance(doc, &obj1); + + update("AP", std::move(obj1)); } else { // Replace the existing appearance stream xref->setModifiedObject(&obj1, updatedAppearanceStream); - obj1.free(); } } void AnnotWidget::draw(Gfx *gfx, GBool printing) { - Object obj; - if (!isVisible (printing)) return; @@ -5172,29 +4962,19 @@ void AnnotWidget::draw(Gfx *gfx, GBool printing) { } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); if (addDingbatsResource) { // We are forcing ZaDb but the font does not exist // so create a fake one - Object baseFontObj, subtypeObj; - baseFontObj.initName("ZapfDingbats"); - subtypeObj.initName("Type1"); - - Object fontDictObj; Dict *fontDict = new Dict(gfx->getXRef()); - fontDict->decRef(); - fontDict->add(copyString("BaseFont"), &baseFontObj); - fontDict->add(copyString("Subtype"), &subtypeObj); - fontDictObj.initDict(fontDict); + fontDict->add(copyString("BaseFont"), Object(objName, "ZapfDingbats")); + fontDict->add(copyString("Subtype"), Object(objName, "Type1")); - Object fontsDictObj; Dict *fontsDict = new Dict(gfx->getXRef()); - fontsDict->decRef(); - fontsDict->add(copyString("ZaDb"), &fontDictObj); - fontsDictObj.initDict(fontsDict); + fontsDict->add(copyString("ZaDb"), Object(fontDict)); Dict *dict = new Dict(gfx->getXRef()); - dict->add(copyString("Font"), &fontsDictObj); + dict->add(copyString("Font"), Object(fontsDict)); gfx->pushResources(dict); delete dict; } @@ -5203,7 +4983,6 @@ void AnnotWidget::draw(Gfx *gfx, GBool printing) { if (addDingbatsResource) { gfx->popResources(); } - obj.free(); } @@ -5215,7 +4994,7 @@ AnnotMovie::AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA) : Object obj1; type = typeMovie; - annotObj.dictSet ("Subtype", obj1.initName ("Movie")); + annotObj.dictSet ("Subtype", Object(objName, "Movie")); movie = movieA->copy(); // TODO: create movie dict from movieA @@ -5223,10 +5002,10 @@ AnnotMovie::AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA) : initialize(docA, annotObj.getDict()); } -AnnotMovie::AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { +AnnotMovie::AnnotMovie(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { type = typeMovie; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotMovie::~AnnotMovie() { @@ -5238,17 +5017,16 @@ AnnotMovie::~AnnotMovie() { void AnnotMovie::initialize(PDFDoc *docA, Dict* dict) { Object obj1; - if (dict->lookup("T", &obj1)->isString()) { + obj1 = dict->lookup("T"); + if (obj1.isString()) { title = obj1.getString()->copy(); } else { title = NULL; } - obj1.free(); - Object movieDict; - if (dict->lookup("Movie", &movieDict)->isDict()) { - Object obj2; - dict->lookup("A", &obj2); + Object movieDict = dict->lookup("Movie"); + if (movieDict.isDict()) { + Object obj2 = dict->lookup("A"); if (obj2.isDict()) movie = new Movie (&movieDict, &obj2); else @@ -5258,79 +5036,66 @@ void AnnotMovie::initialize(PDFDoc *docA, Dict* dict) { movie = NULL; ok = gFalse; } - obj2.free(); } else { error(errSyntaxError, -1, "Bad Annot Movie"); movie = NULL; ok = gFalse; } - movieDict.free(); } void AnnotMovie::draw(Gfx *gfx, GBool printing) { - Object obj; - if (!isVisible (printing)) return; annotLocker(); if (appearance.isNull() && movie->getShowPoster()) { int width, height; - Object poster; - movie->getPoster(&poster); + Object poster = movie->getPoster(); movie->getAspect(&width, &height); if (width != -1 && height != -1 && !poster.isNone()) { - MemStream *mStream; - appearBuf = new GooString (); appearBuf->append ("q\n"); appearBuf->appendf ("{0:d} 0 0 {1:d} 0 0 cm\n", width, height); appearBuf->append ("/MImg Do\n"); appearBuf->append ("Q\n"); - Object imgDict; - imgDict.initDict(gfx->getXRef()); - imgDict.dictSet ("MImg", &poster); - - Object resDict; - resDict.initDict(gfx->getXRef()); - resDict.dictSet ("XObject", &imgDict); - - Object formDict, obj1, obj2; - formDict.initDict(gfx->getXRef()); - formDict.dictSet("Length", obj1.initInt(appearBuf->getLength())); - formDict.dictSet("Subtype", obj1.initName("Form")); - formDict.dictSet("Name", obj1.initName("FRM")); - obj1.initArray(gfx->getXRef()); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(width)); - obj1.arrayAdd(obj2.initInt(height)); - formDict.dictSet("BBox", &obj1); - obj1.initArray(gfx->getXRef()); - obj1.arrayAdd(obj2.initInt(1)); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(0)); - obj1.arrayAdd(obj2.initInt(1)); - obj1.arrayAdd(obj2.initInt(-width / 2)); - obj1.arrayAdd(obj2.initInt(-height / 2)); - formDict.dictSet("Matrix", &obj1); - formDict.dictSet("Resources", &resDict); - - Object aStream; - mStream = new MemStream(copyString(appearBuf->getCString()), 0, - appearBuf->getLength(), &formDict); + Dict *imgDict = new Dict(gfx->getXRef()); + imgDict->set("MImg", std::move(poster)); + + Dict *resDict = new Dict(gfx->getXRef()); + resDict->set("XObject", Object(imgDict)); + + Dict *formDict = new Dict(gfx->getXRef()); + formDict->set("Length", Object(appearBuf->getLength())); + formDict->set("Subtype", Object(objName, "Form")); + formDict->set("Name", Object(objName, "FRM")); + Array *bboxArray = new Array(gfx->getXRef()); + bboxArray->add(Object(0)); + bboxArray->add(Object(0)); + bboxArray->add(Object(width)); + bboxArray->add(Object(height)); + formDict->set("BBox", Object(bboxArray)); + Array *matrix = new Array(gfx->getXRef()); + matrix->add(Object(1)); + matrix->add(Object(0)); + matrix->add(Object(0)); + matrix->add(Object(1)); + matrix->add(Object(-width / 2)); + matrix->add(Object(-height / 2)); + formDict->set("Matrix", Object(matrix)); + formDict->set("Resources", Object(resDict)); + + MemStream *mStream = new MemStream(copyString(appearBuf->getCString()), 0, + appearBuf->getLength(), Object(formDict)); mStream->setNeedFree(gTrue); - aStream.initStream(mStream); delete appearBuf; - Object objDict; - objDict.initDict(gfx->getXRef()); - objDict.dictSet ("FRM", &aStream); + Dict *dict = new Dict(gfx->getXRef()); + dict->set("FRM", Object(static_cast<Stream*>(mStream))); - resDict.initDict(gfx->getXRef()); - resDict.dictSet ("XObject", &objDict); + Dict *resDict2 = new Dict(gfx->getXRef()); + resDict2->set("XObject", Object(dict)); appearBuf = new GooString (); appearBuf->append ("q\n"); @@ -5346,17 +5111,15 @@ void AnnotMovie::draw(Gfx *gfx, GBool printing) { bbox[0] = bbox[1] = 0; bbox[2] = width; bbox[3] = height; - createForm(bbox, gFalse, &resDict, &appearance); + appearance = createForm(bbox, gFalse, resDict2); delete appearBuf; } - poster.free(); } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); } //------------------------------------------------------------------------ @@ -5368,55 +5131,50 @@ AnnotScreen::AnnotScreen(PDFDoc *docA, PDFRectangle *rect) : type = typeScreen; - annotObj.dictSet ("Subtype", obj1.initName ("Screen")); + annotObj.dictSet ("Subtype", Object(objName, "Screen")); initialize(docA, annotObj.getDict()); } -AnnotScreen::AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { +AnnotScreen::AnnotScreen(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { type = typeScreen; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotScreen::~AnnotScreen() { - if (title) - delete title; - if (appearCharacs) - delete appearCharacs; - if (action) - delete action; - - additionalActions.free(); + delete title; + delete appearCharacs; + delete action; } void AnnotScreen::initialize(PDFDoc *docA, Dict* dict) { Object obj1; title = NULL; - if (dict->lookup("T", &obj1)->isString()) { + obj1 = dict->lookup("T"); + if (obj1.isString()) { title = obj1.getString()->copy(); } - obj1.free(); action = NULL; - if (dict->lookup("A", &obj1)->isDict()) { + obj1 = dict->lookup("A"); + if (obj1.isDict()) { action = LinkAction::parseAction(&obj1, doc->getCatalog()->getBaseURI()); - if (action->getKind() == actionRendition && page == 0) { + if (action && action->getKind() == actionRendition && page == 0) { error (errSyntaxError, -1, "Invalid Rendition action: associated screen annotation without P"); delete action; action = NULL; ok = gFalse; } } - obj1.free(); - dict->lookupNF("AA", &additionalActions); + additionalActions = dict->lookupNF("AA"); appearCharacs = NULL; - if(dict->lookup("MK", &obj1)->isDict()) { + obj1 = dict->lookup("MK"); + if (obj1.isDict()) { appearCharacs = new AnnotAppearanceCharacs(obj1.getDict()); } - obj1.free(); } LinkAction* AnnotScreen::getAdditionalAction(AdditionalActionsType type) @@ -5435,14 +5193,14 @@ AnnotStamp::AnnotStamp(PDFDoc *docA, PDFRectangle *rect) : Object obj1; type = typeStamp; - annotObj.dictSet ("Subtype", obj1.initName ("Stamp")); + annotObj.dictSet ("Subtype", Object(objName, "Stamp")); initialize(docA, annotObj.getDict()); } -AnnotStamp::AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotStamp::AnnotStamp(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeStamp; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotStamp::~AnnotStamp() { @@ -5450,14 +5208,12 @@ AnnotStamp::~AnnotStamp() { } void AnnotStamp::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("Name", &obj1)->isName()) { + Object obj1 = dict->lookup("Name"); + if (obj1.isName()) { icon = new GooString(obj1.getName()); } else { icon = new GooString("Draft"); } - obj1.free(); } @@ -5470,9 +5226,7 @@ void AnnotStamp::setIcon(GooString *new_icon) { icon = new GooString(); } - Object obj1; - obj1.initName (icon->getCString()); - update("Name", &obj1); + update("Name", Object(objName, icon->getCString())); invalidateAppearance(); } @@ -5485,10 +5239,10 @@ AnnotGeometry::AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subT switch (subType) { case typeSquare: - annotObj.dictSet ("Subtype", obj1.initName ("Square")); + annotObj.dictSet ("Subtype", Object(objName, "Square")); break; case typeCircle: - annotObj.dictSet ("Subtype", obj1.initName ("Circle")); + annotObj.dictSet ("Subtype", Object(objName, "Circle")); break; default: assert (0 && "Invalid subtype for AnnotGeometry\n"); @@ -5497,11 +5251,11 @@ AnnotGeometry::AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subT initialize(docA, annotObj.getDict()); } -AnnotGeometry::AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotGeometry::AnnotGeometry(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { // the real type will be read in initialize() type = typeSquare; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotGeometry::~AnnotGeometry() { @@ -5513,7 +5267,8 @@ AnnotGeometry::~AnnotGeometry() { void AnnotGeometry::initialize(PDFDoc *docA, Dict* dict) { Object obj1; - if (dict->lookup("Subtype", &obj1)->isName()) { + obj1 = dict->lookup("Subtype"); + if (obj1.isName()) { GooString typeName(obj1.getName()); if (!typeName.cmp("Square")) { type = typeSquare; @@ -5521,54 +5276,52 @@ void AnnotGeometry::initialize(PDFDoc *docA, Dict* dict) { type = typeCircle; } } - obj1.free(); - if (dict->lookup("IC", &obj1)->isArray()) { + obj1 = dict->lookup("IC"); + if (obj1.isArray()) { interiorColor = new AnnotColor(obj1.getArray()); } else { interiorColor = NULL; } - obj1.free(); - if (dict->lookup("BS", &obj1)->isDict()) { + obj1 = dict->lookup("BS"); + if (obj1.isDict()) { delete border; border = new AnnotBorderBS(obj1.getDict()); } else if (!border) { border = new AnnotBorderBS(); } - obj1.free(); - if (dict->lookup("BE", &obj1)->isDict()) { + obj1 = dict->lookup("BE"); + if (obj1.isDict()) { borderEffect = new AnnotBorderEffect(obj1.getDict()); } else { borderEffect = NULL; } - obj1.free(); geometryRect = NULL; - if (dict->lookup("RD", &obj1)->isArray()) { + obj1 = dict->lookup("RD"); + if (obj1.isArray()) { geometryRect = parseDiffRectangle(obj1.getArray(), rect); } - obj1.free(); - } void AnnotGeometry::setType(AnnotSubtype new_type) { - Object obj1; + const char *typeName = nullptr; /* squelch bogus compiler warning */ switch (new_type) { case typeSquare: - obj1.initName("Square"); + typeName = "Square"; break; case typeCircle: - obj1.initName("Circle"); + typeName = "Circle"; break; default: assert(!"Invalid subtype"); } type = new_type; - update("Subtype", &obj1); + update("Subtype", Object(objName, typeName)); invalidateAppearance(); } @@ -5576,9 +5329,8 @@ void AnnotGeometry::setInteriorColor(AnnotColor *new_color) { delete interiorColor; if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("IC", &obj1); + Object obj1 = new_color->writeToObject(xref); + update ("IC", std::move(obj1)); interiorColor = new_color; } else { interiorColor = NULL; @@ -5587,7 +5339,6 @@ void AnnotGeometry::setInteriorColor(AnnotColor *new_color) { } void AnnotGeometry::draw(Gfx *gfx, GBool printing) { - Object obj; double ca = 1; if (!isVisible (printing)) @@ -5673,26 +5424,22 @@ void AnnotGeometry::draw(Gfx *gfx, GBool printing) { bbox[2] = rect->x2 - rect->x1; bbox[3] = rect->y2 - rect->y1; if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); + appearance = createForm(bbox, gFalse, nullptr); } else { - Object aStream; - - createForm(bbox, gTrue, NULL, &aStream); + Object aStream = createForm(bbox, gTrue, nullptr); delete appearBuf; - Object resDict; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); } //------------------------------------------------------------------------ @@ -5704,30 +5451,29 @@ AnnotPolygon::AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subTyp switch (subType) { case typePolygon: - annotObj.dictSet ("Subtype", obj1.initName ("Polygon")); + annotObj.dictSet ("Subtype", Object(objName, "Polygon")); break; case typePolyLine: - annotObj.dictSet ("Subtype", obj1.initName ("PolyLine")); + annotObj.dictSet ("Subtype", Object(objName, "PolyLine")); break; default: assert (0 && "Invalid subtype for AnnotGeometry\n"); } // Store dummy path with one null vertex only - Object obj2, obj3; - obj2.initArray (doc->getXRef()); - obj2.arrayAdd (obj3.initReal (0)); - obj2.arrayAdd (obj3.initReal (0)); - annotObj.dictSet ("Vertices", &obj2); + Array *a = new Array(doc->getXRef()); + a->add(Object(0.)); + a->add(Object(0.)); + annotObj.dictSet("Vertices", Object(a)); initialize(docA, annotObj.getDict()); } -AnnotPolygon::AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotPolygon::AnnotPolygon(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { // the real type will be read in initialize() type = typePolygon; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotPolygon::~AnnotPolygon() { @@ -5743,7 +5489,8 @@ AnnotPolygon::~AnnotPolygon() { void AnnotPolygon::initialize(PDFDoc *docA, Dict* dict) { Object obj1; - if (dict->lookup("Subtype", &obj1)->isName()) { + obj1 = dict->lookup("Subtype"); + if (obj1.isName()) { GooString typeName(obj1.getName()); if (!typeName.cmp("Polygon")) { type = typePolygon; @@ -5751,60 +5498,58 @@ void AnnotPolygon::initialize(PDFDoc *docA, Dict* dict) { type = typePolyLine; } } - obj1.free(); - if (dict->lookup("Vertices", &obj1)->isArray()) { + obj1 = dict->lookup("Vertices"); + if (obj1.isArray()) { vertices = new AnnotPath(obj1.getArray()); } else { vertices = new AnnotPath(); error(errSyntaxError, -1, "Bad Annot Polygon Vertices"); ok = gFalse; } - obj1.free(); - if (dict->lookup("LE", &obj1)->isArray() && obj1.arrayGetLength() == 2) { - Object obj2; - - if(obj1.arrayGet(0, &obj2)->isString()) + obj1 = dict->lookup("LE"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + Object obj2 = obj1.arrayGet(0); + if(obj2.isString()) startStyle = parseAnnotLineEndingStyle(obj2.getString()); else startStyle = annotLineEndingNone; - obj2.free(); - if(obj1.arrayGet(1, &obj2)->isString()) + obj2 = obj1.arrayGet(1); + if(obj2.isString()) endStyle = parseAnnotLineEndingStyle(obj2.getString()); else endStyle = annotLineEndingNone; - obj2.free(); } else { startStyle = endStyle = annotLineEndingNone; } - obj1.free(); - if (dict->lookup("IC", &obj1)->isArray()) { + obj1 = dict->lookup("IC"); + if (obj1.isArray()) { interiorColor = new AnnotColor(obj1.getArray()); } else { interiorColor = NULL; } - obj1.free(); - if (dict->lookup("BS", &obj1)->isDict()) { + obj1 = dict->lookup("BS"); + if (obj1.isDict()) { delete border; border = new AnnotBorderBS(obj1.getDict()); } else if (!border) { border = new AnnotBorderBS(); } - obj1.free(); - if (dict->lookup("BE", &obj1)->isDict()) { + obj1 = dict->lookup("BE"); + if (obj1.isDict()) { borderEffect = new AnnotBorderEffect(obj1.getDict()); } else { borderEffect = NULL; } - obj1.free(); - if (dict->lookup("IT", &obj1)->isName()) { + obj1 = dict->lookup("IT"); + if (obj1.isName()) { const char *intentName = obj1.getName(); if(!strcmp(intentName, "PolygonCloud")) { @@ -5817,56 +5562,51 @@ void AnnotPolygon::initialize(PDFDoc *docA, Dict* dict) { } else { intent = polygonCloud; } - obj1.free(); } void AnnotPolygon::setType(AnnotSubtype new_type) { - Object obj1; + const char *typeName = nullptr; /* squelch bogus compiler warning */ switch (new_type) { case typePolygon: - obj1.initName("Polygon"); + typeName = "Polygon"; break; case typePolyLine: - obj1.initName("PolyLine"); + typeName = "PolyLine"; break; default: assert(!"Invalid subtype"); } type = new_type; - update("Subtype", &obj1); + update("Subtype", Object(objName, typeName)); invalidateAppearance(); } void AnnotPolygon::setVertices(AnnotPath *path) { - Object obj1, obj2; delete vertices; - obj1.initArray(xref); - + Array *a = new Array(xref); for (int i = 0; i < path->getCoordsLength(); i++) { - obj1.arrayAdd (obj2.initReal (path->getX(i))); - obj1.arrayAdd (obj2.initReal (path->getY(i))); + a->add(Object(path->getX(i))); + a->add(Object(path->getY(i))); } - vertices = new AnnotPath(obj1.getArray()); + vertices = new AnnotPath(a); - update("Vertices", &obj1); + update("Vertices", Object(a)); invalidateAppearance(); } void AnnotPolygon::setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end) { - Object obj1, obj2; - startStyle = start; endStyle = end; - obj1.initArray(xref); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( startStyle )) ); - obj1.arrayAdd( obj2.initName(convertAnnotLineEndingStyle( endStyle )) ); + Array *a = new Array(xref); + a->add( Object(objName, convertAnnotLineEndingStyle( startStyle )) ); + a->add( Object(objName, convertAnnotLineEndingStyle( endStyle )) ); - update("LE", &obj1); + update("LE", Object(a)); invalidateAppearance(); } @@ -5874,9 +5614,8 @@ void AnnotPolygon::setInteriorColor(AnnotColor *new_color) { delete interiorColor; if (new_color) { - Object obj1; - new_color->writeToObject(xref, &obj1); - update ("IC", &obj1); + Object obj1 = new_color->writeToObject(xref); + update ("IC", std::move(obj1)); interiorColor = new_color; } else { interiorColor = NULL; @@ -5885,20 +5624,19 @@ void AnnotPolygon::setInteriorColor(AnnotColor *new_color) { } void AnnotPolygon::setIntent(AnnotPolygonIntent new_intent) { - Object obj1; + const char *intentName; intent = new_intent; if (new_intent == polygonCloud) - obj1.initName("PolygonCloud"); + intentName = "PolygonCloud"; else if (new_intent == polylineDimension) - obj1.initName("PolyLineDimension"); + intentName = "PolyLineDimension"; else // polygonDimension - obj1.initName("PolygonDimension"); - update ("IT", &obj1); + intentName = "PolygonDimension"; + update ("IT", Object(objName, intentName)); } void AnnotPolygon::draw(Gfx *gfx, GBool printing) { - Object obj; double ca = 1; if (!isVisible (printing)) @@ -5948,22 +5686,20 @@ void AnnotPolygon::draw(Gfx *gfx, GBool printing) { double bbox[4]; appearBBox->getBBoxRect(bbox); if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); + appearance = createForm(bbox, gFalse, nullptr); } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); + Object aStream = createForm(bbox, gTrue, nullptr); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); if (appearBBox) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, appearBBox->getPageXMin(), appearBBox->getPageYMin(), @@ -5973,7 +5709,6 @@ void AnnotPolygon::draw(Gfx *gfx, GBool printing) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); } - obj.free(); } //------------------------------------------------------------------------ @@ -5985,14 +5720,14 @@ AnnotCaret::AnnotCaret(PDFDoc *docA, PDFRectangle *rect) : type = typeCaret; - annotObj.dictSet ("Subtype", obj1.initName ("Caret")); + annotObj.dictSet ("Subtype", Object(objName, "Caret")); initialize(docA, annotObj.getDict()); } -AnnotCaret::AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotCaret::AnnotCaret(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeCaret; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotCaret::~AnnotCaret() { @@ -6003,7 +5738,8 @@ void AnnotCaret::initialize(PDFDoc *docA, Dict* dict) { Object obj1; symbol = symbolNone; - if (dict->lookup("Sy", &obj1)->isName()) { + obj1 = dict->lookup("Sy"); + if (obj1.isName()) { GooString typeName(obj1.getName()); if (!typeName.cmp("P")) { symbol = symbolP; @@ -6011,22 +5747,18 @@ void AnnotCaret::initialize(PDFDoc *docA, Dict* dict) { symbol = symbolNone; } } - obj1.free(); - if (dict->lookup("RD", &obj1)->isArray()) { + obj1 = dict->lookup("RD"); + if (obj1.isArray()) { caretRect = parseDiffRectangle(obj1.getArray(), rect); } else { caretRect = NULL; } - obj1.free(); - } void AnnotCaret::setSymbol(AnnotCaretSymbol new_symbol) { - Object obj1; - obj1.initName( new_symbol == symbolP ? "P" : "None" ); symbol = new_symbol; - update("Sy", &obj1); + update("Sy", Object(objName, new_symbol == symbolP ? "P" : "None")); invalidateAppearance(); } @@ -6039,23 +5771,24 @@ AnnotInk::AnnotInk(PDFDoc *docA, PDFRectangle *rect) : type = typeInk; - annotObj.dictSet ("Subtype", obj1.initName ("Ink")); + annotObj.dictSet ("Subtype", Object(objName, "Ink")); // Store dummy path with one null vertex only - Object obj2, obj3, obj4; - obj2.initArray (doc->getXRef()); - obj2.arrayAdd (obj3.initArray (doc->getXRef())); - obj3.arrayAdd (obj4.initReal (0)); - obj3.arrayAdd (obj4.initReal (0)); - annotObj.dictSet ("InkList", &obj2); + Object obj3, obj4; + Array *inkList = new Array(doc->getXRef()); + Array *vList = new Array(doc->getXRef()); + vList->add(Object(0.)); + vList->add(Object(0.)); + inkList->add(Object(vList)); + annotObj.dictSet("InkList", Object(inkList)); initialize(docA, annotObj.getDict()); } -AnnotInk::AnnotInk(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotInk::AnnotInk(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeInk; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotInk::~AnnotInk() { @@ -6065,7 +5798,8 @@ AnnotInk::~AnnotInk() { void AnnotInk::initialize(PDFDoc *docA, Dict* dict) { Object obj1; - if (dict->lookup("InkList", &obj1)->isArray()) { + obj1 = dict->lookup("InkList"); + if (obj1.isArray()) { parseInkList(obj1.getArray()); } else { inkListLength = 0; @@ -6073,27 +5807,25 @@ void AnnotInk::initialize(PDFDoc *docA, Dict* dict) { error(errSyntaxError, -1, "Bad Annot Ink List"); ok = gFalse; } - obj1.free(); - if (dict->lookup("BS", &obj1)->isDict()) { + obj1 = dict->lookup("BS"); + if (obj1.isDict()) { delete border; border = new AnnotBorderBS(obj1.getDict()); } else if (!border) { border = new AnnotBorderBS(); } - obj1.free(); } void AnnotInk::writeInkList(AnnotPath **paths, int n_paths, Array *dest_array) { - Object obj1, obj2; for (int i = 0; i < n_paths; ++i) { AnnotPath *path = paths[i]; - obj1.initArray (xref); + Array *a = new Array(xref); for (int j = 0; j < path->getCoordsLength(); ++j) { - obj1.arrayAdd (obj2.initReal (path->getX(j))); - obj1.arrayAdd (obj2.initReal (path->getY(j))); + a->add(Object(path->getX(j))); + a->add(Object(path->getY(j))); } - dest_array->add (&obj1); + dest_array->add(Object(a)); } } @@ -6102,10 +5834,9 @@ void AnnotInk::parseInkList(Array *array) { inkList = (AnnotPath **) gmallocn ((inkListLength), sizeof(AnnotPath *)); memset(inkList, 0, inkListLength * sizeof(AnnotPath *)); for (int i = 0; i < inkListLength; i++) { - Object obj2; - if (array->get(i, &obj2)->isArray()) + Object obj2 = array->get(i); + if (obj2.isArray()) inkList[i] = new AnnotPath(obj2.getArray()); - obj2.free(); } } @@ -6118,20 +5849,17 @@ void AnnotInk::freeInkList() { } void AnnotInk::setInkList(AnnotPath **paths, int n_paths) { - Object obj1; - freeInkList(); - obj1.initArray (xref); - writeInkList(paths, n_paths, obj1.getArray()); + Array *a = new Array(xref); + writeInkList(paths, n_paths, a); - parseInkList(obj1.getArray()); - annotObj.dictSet ("InkList", &obj1); + parseInkList(a); + annotObj.dictSet ("InkList", Object(a)); invalidateAppearance(); } void AnnotInk::draw(Gfx *gfx, GBool printing) { - Object obj; double ca = 1; if (!isVisible (printing)) @@ -6172,22 +5900,20 @@ void AnnotInk::draw(Gfx *gfx, GBool printing) { double bbox[4]; appearBBox->getBBoxRect(bbox); if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); + appearance = createForm(bbox, gFalse, nullptr); } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); + Object aStream = createForm(bbox, gTrue, nullptr); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); if (appearBBox) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, appearBBox->getPageXMin(), appearBBox->getPageYMin(), @@ -6197,7 +5923,6 @@ void AnnotInk::draw(Gfx *gfx, GBool printing) { gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); } - obj.free(); } //------------------------------------------------------------------------ @@ -6209,45 +5934,39 @@ AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooSt type = typeFileAttachment; - annotObj.dictSet ("Subtype", obj1.initName ("FileAttachment")); - - Object obj2; - obj2.initString(filename->copy()); - annotObj.dictSet ("FS", &obj2); + annotObj.dictSet("Subtype", Object(objName, "FileAttachment")); + annotObj.dictSet("FS", Object(filename->copy())); initialize(docA, annotObj.getDict()); } -AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotFileAttachment::AnnotFileAttachment(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeFileAttachment; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotFileAttachment::~AnnotFileAttachment() { - file.free(); - - if (name) - delete name; + delete name; } void AnnotFileAttachment::initialize(PDFDoc *docA, Dict* dict) { Object obj1; - if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) { - obj1.copy(&file); + obj1 = dict->lookup("FS"); + if (obj1.isDict() || obj1.isString()) { + file = obj1.copy(); } else { error(errSyntaxError, -1, "Bad Annot File Attachment"); ok = gFalse; } - obj1.free(); - if (dict->lookup("Name", &obj1)->isName()) { + obj1 = dict->lookup("Name"); + if (obj1.isName()) { name = new GooString(obj1.getName()); } else { name = new GooString("PushPin"); } - obj1.free(); } #define ANNOT_FILE_ATTACHMENT_AP_PUSHPIN \ @@ -6363,7 +6082,6 @@ void AnnotFileAttachment::initialize(PDFDoc *docA, Dict* dict) { "19.5 17.699 20.91 17.418 22.5 17.5 c S\n" void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) { - Object obj; double ca = 1; if (!isVisible (printing)) @@ -6394,26 +6112,22 @@ void AnnotFileAttachment::draw(Gfx *gfx, GBool printing) { bbox[0] = bbox[1] = 0; bbox[2] = bbox[3] = 24; if (ca == 1) { - createForm (bbox, gFalse, NULL, &appearance); + appearance = createForm (bbox, gFalse, nullptr); } else { - Object aStream; - - createForm (bbox, gTrue, NULL, &aStream); + Object aStream = createForm (bbox, gTrue, nullptr); delete appearBuf; - Object resDict; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + Object obj = appearance.fetch(gfx->getXRef()); gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); } //------------------------------------------------------------------------ @@ -6425,21 +6139,16 @@ AnnotSound::AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA) : type = typeSound; - annotObj.dictSet ("Subtype", obj1.initName ("Sound")); - - Object obj2; - Stream *str = soundA->getStream(); - obj2.initStream (str); - str->incRef(); //FIXME: initStream should do this? - annotObj.dictSet ("Sound", &obj2); + annotObj.dictSet ("Subtype", Object(objName, "Sound")); + annotObj.dictSet ("Sound", soundA->getObject()->copy()); initialize(docA, annotObj.getDict()); } -AnnotSound::AnnotSound(PDFDoc *docA, Dict *dict, Object *obj) : - AnnotMarkup(docA, dict, obj) { +AnnotSound::AnnotSound(PDFDoc *docA, Object *dictObject, Object *obj) : + AnnotMarkup(docA, dictObject, obj) { type = typeSound; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotSound::~AnnotSound() { @@ -6449,21 +6158,20 @@ AnnotSound::~AnnotSound() { } void AnnotSound::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; + Object obj1 = dict->lookup("Sound"); - sound = Sound::parseSound(dict->lookup("Sound", &obj1)); + sound = Sound::parseSound(&obj1); if (!sound) { error(errSyntaxError, -1, "Bad Annot Sound"); ok = gFalse; } - obj1.free(); - if (dict->lookup("Name", &obj1)->isName()) { + obj1 = dict->lookup("Name"); + if (obj1.isName()) { name = new GooString(obj1.getName()); } else { name = new GooString("Speaker"); } - obj1.free(); } #define ANNOT_SOUND_AP_SPEAKER \ @@ -6557,25 +6265,22 @@ void AnnotSound::draw(Gfx *gfx, GBool printing) { bbox[0] = bbox[1] = 0; bbox[2] = bbox[3] = 24; if (ca == 1) { - createForm(bbox, gFalse, NULL, &appearance); + appearance = createForm(bbox, gFalse, nullptr); } else { - Object aStream, resDict; - - createForm(bbox, gTrue, NULL, &aStream); + Object aStream = createForm(bbox, gTrue, nullptr); delete appearBuf; appearBuf = new GooString ("/GS0 gs\n/Fm0 Do"); - createResourcesDict("Fm0", &aStream, "GS0", ca, NULL, &resDict); - createForm(bbox, gFalse, &resDict, &appearance); + Dict *resDict = createResourcesDict("Fm0", std::move(aStream), "GS0", ca, NULL); + appearance = createForm(bbox, gFalse, resDict); } delete appearBuf; } // draw the appearance stream - appearance.fetch(gfx->getXRef(), &obj); + obj = appearance.fetch(gfx->getXRef()); gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color, rect->x1, rect->y1, rect->x2, rect->y2, getRotation()); - obj.free(); } //------------------------------------------------------------------------ @@ -6587,15 +6292,15 @@ Annot3D::Annot3D(PDFDoc *docA, PDFRectangle *rect) : type = type3D; - annotObj.dictSet ("Subtype", obj1.initName ("3D")); + annotObj.dictSet ("Subtype", Object(objName, "3D")); initialize(docA, annotObj.getDict()); } -Annot3D::Annot3D(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { +Annot3D::Annot3D(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { type = type3D; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } Annot3D::~Annot3D() { @@ -6604,20 +6309,19 @@ Annot3D::~Annot3D() { } void Annot3D::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("3DA", &obj1)->isDict()) { + Object obj1 = dict->lookup("3DA"); + if (obj1.isDict()) { activation = new Activation(obj1.getDict()); } else { activation = NULL; } - obj1.free(); } Annot3D::Activation::Activation(Dict *dict) { Object obj1; - if (dict->lookup("A", &obj1)->isName()) { + obj1 = dict->lookup("A"); + if (obj1.isName()) { const char *name = obj1.getName(); if(!strcmp(name, "PO")) { @@ -6632,9 +6336,9 @@ Annot3D::Activation::Activation(Dict *dict) { } else { aTrigger = aTriggerUnknown; } - obj1.free(); - if(dict->lookup("AIS", &obj1)->isName()) { + obj1 = dict->lookup("AIS"); + if (obj1.isName()) { const char *name = obj1.getName(); if(!strcmp(name, "I")) { @@ -6647,9 +6351,9 @@ Annot3D::Activation::Activation(Dict *dict) { } else { aState = aStateUnknown; } - obj1.free(); - if(dict->lookup("D", &obj1)->isName()) { + obj1 = dict->lookup("D"); + if (obj1.isName()) { const char *name = obj1.getName(); if(!strcmp(name, "PC")) { @@ -6664,9 +6368,9 @@ Annot3D::Activation::Activation(Dict *dict) { } else { dTrigger = dTriggerUnknown; } - obj1.free(); - if(dict->lookup("DIS", &obj1)->isName()) { + obj1 = dict->lookup("DIS"); + if (obj1.isName()) { const char *name = obj1.getName(); if(!strcmp(name, "U")) { @@ -6681,21 +6385,20 @@ Annot3D::Activation::Activation(Dict *dict) { } else { dState = dStateUnknown; } - obj1.free(); - if (dict->lookup("TB", &obj1)->isBool()) { + obj1 = dict->lookup("TB"); + if (obj1.isBool()) { displayToolbar = obj1.getBool(); } else { displayToolbar = gTrue; } - obj1.free(); - if (dict->lookup("NP", &obj1)->isBool()) { + obj1 = dict->lookup("NP"); + if (obj1.isBool()) { displayNavigation = obj1.getBool(); } else { displayNavigation = gFalse; } - obj1.free(); } //------------------------------------------------------------------------ @@ -6707,15 +6410,15 @@ AnnotRichMedia::AnnotRichMedia(PDFDoc *docA, PDFRectangle *rect) : type = typeRichMedia; - annotObj.dictSet ("Subtype", obj1.initName ("RichMedia")); + annotObj.dictSet ("Subtype", Object(objName, "RichMedia")); initialize(docA, annotObj.getDict()); } -AnnotRichMedia::AnnotRichMedia(PDFDoc *docA, Dict *dict, Object *obj) : - Annot(docA, dict, obj) { +AnnotRichMedia::AnnotRichMedia(PDFDoc *docA, Object *dictObject, Object *obj) : + Annot(docA, dictObject, obj) { type = typeRichMedia; - initialize(docA, dict); + initialize(docA, dictObject->getDict()); } AnnotRichMedia::~AnnotRichMedia() { @@ -6724,21 +6427,19 @@ AnnotRichMedia::~AnnotRichMedia() { } void AnnotRichMedia::initialize(PDFDoc *docA, Dict* dict) { - Object obj1; - - if (dict->lookup("RichMediaContent", &obj1)->isDict()) { + Object obj1 = dict->lookup("RichMediaContent"); + if (obj1.isDict()) { content = new AnnotRichMedia::Content(obj1.getDict()); } else { content = NULL; } - obj1.free(); - if (dict->lookup("RichMediaSettings", &obj1)->isDict()) { + obj1 = dict->lookup("RichMediaSettings"); + if (obj1.isDict()) { settings = new AnnotRichMedia::Settings(obj1.getDict()); } else { settings = NULL; } - obj1.free(); } AnnotRichMedia::Content* AnnotRichMedia::getContent() const { @@ -6750,21 +6451,19 @@ AnnotRichMedia::Settings* AnnotRichMedia::getSettings() const { } AnnotRichMedia::Settings::Settings(Dict *dict) { - Object obj1; - - if (dict->lookup("Activation", &obj1)->isDict()) { + Object obj1 = dict->lookup("Activation"); + if (obj1.isDict()) { activation = new AnnotRichMedia::Activation(obj1.getDict()); } else { activation = NULL; } - obj1.free(); - if (dict->lookup("Deactivation", &obj1)->isDict()) { + obj1 = dict->lookup("Deactivation"); + if (obj1.isDict()) { deactivation = new AnnotRichMedia::Deactivation(obj1.getDict()); } else { deactivation = NULL; } - obj1.free(); } AnnotRichMedia::Settings::~Settings() { @@ -6781,9 +6480,8 @@ AnnotRichMedia::Deactivation* AnnotRichMedia::Settings::getDeactivation() const } AnnotRichMedia::Activation::Activation(Dict *dict) { - Object obj1; - - if (dict->lookup("Condition", &obj1)->isName()) { + Object obj1 = dict->lookup("Condition"); + if (obj1.isName()) { const char *name = obj1.getName(); if (!strcmp(name, "PO")) { @@ -6798,7 +6496,6 @@ AnnotRichMedia::Activation::Activation(Dict *dict) { } else { condition = conditionUserAction; } - obj1.free(); } AnnotRichMedia::Activation::Condition AnnotRichMedia::Activation::getCondition() const { @@ -6806,9 +6503,8 @@ AnnotRichMedia::Activation::Condition AnnotRichMedia::Activation::getCondition() } AnnotRichMedia::Deactivation::Deactivation(Dict *dict) { - Object obj1; - - if (dict->lookup("Condition", &obj1)->isName()) { + Object obj1 = dict->lookup("Condition"); + if (obj1.isName()) { const char *name = obj1.getName(); if (!strcmp(name, "PC")) { @@ -6823,7 +6519,6 @@ AnnotRichMedia::Deactivation::Deactivation(Dict *dict) { } else { condition = conditionUserAction; } - obj1.free(); } AnnotRichMedia::Deactivation::Condition AnnotRichMedia::Deactivation::getCondition() const { @@ -6831,57 +6526,48 @@ AnnotRichMedia::Deactivation::Condition AnnotRichMedia::Deactivation::getConditi } AnnotRichMedia::Content::Content(Dict *dict) { - Object obj1; - - if (dict->lookup("Configurations", &obj1)->isArray()) { + Object obj1 = dict->lookup("Configurations"); + if (obj1.isArray()) { nConfigurations = obj1.arrayGetLength(); configurations = (Configuration **)gmallocn(nConfigurations, sizeof(Configuration *)); for (int i = 0; i < nConfigurations; ++i) { - Object obj2; - - if (obj1.arrayGet(i, &obj2)->isDict()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isDict()) { configurations[i] = new AnnotRichMedia::Configuration(obj2.getDict()); } else { configurations[i] = NULL; } - obj2.free(); } } else { nConfigurations = 0; configurations = NULL; } - obj1.free(); nAssets = 0; assets = NULL; - if (dict->lookup("Assets", &obj1)->isDict()) { - Object obj2; - - if (obj1.getDict()->lookup("Names", &obj2)->isArray()) { + obj1 = dict->lookup("Assets"); + if (obj1.isDict()) { + Object obj2 = obj1.getDict()->lookup("Names"); + if (obj2.isArray()) { nAssets = obj2.arrayGetLength() / 2; assets = (Asset **)gmallocn(nAssets, sizeof(Asset *)); int counter = 0; - for (int i = 0; i < obj2.arrayGetLength(); i += 2) { - Object objKey; - + for (int i = 0; i < nAssets; ++i) { assets[counter] = new AnnotRichMedia::Asset; - obj2.arrayGet(i, &objKey); - obj2.arrayGet(i + 1, &assets[counter]->fileSpec); + Object objKey = obj2.arrayGet(i * 2); + assets[counter]->fileSpec = obj2.arrayGet(i * 2 + 1); assets[counter]->name = new GooString( objKey.getString() ); ++counter; - objKey.free(); } } - obj2.free(); } - obj1.free(); } AnnotRichMedia::Content::~Content() { @@ -6928,7 +6614,6 @@ AnnotRichMedia::Asset::Asset() AnnotRichMedia::Asset::~Asset() { delete name; - fileSpec.free(); } GooString* AnnotRichMedia::Asset::getName() const { @@ -6941,36 +6626,33 @@ Object* AnnotRichMedia::Asset::getFileSpec() const { AnnotRichMedia::Configuration::Configuration(Dict *dict) { - Object obj1; - - if (dict->lookup("Instances", &obj1)->isArray()) { + Object obj1 = dict->lookup("Instances"); + if (obj1.isArray()) { nInstances = obj1.arrayGetLength(); instances = (Instance **)gmallocn(nInstances, sizeof(Instance *)); for (int i = 0; i < nInstances; ++i) { - Object obj2; - - if (obj1.arrayGet(i, &obj2)->isDict()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isDict()) { instances[i] = new AnnotRichMedia::Instance(obj2.getDict()); } else { instances[i] = NULL; } - obj2.free(); } } else { instances = NULL; } - obj1.free(); - if (dict->lookup("Name", &obj1)->isString()) { + obj1 = dict->lookup("Name"); + if (obj1.isString()) { name = new GooString(obj1.getString()); } else { name = NULL; } - obj1.free(); - if (dict->lookup("Subtype", &obj1)->isName()) { + obj1 = dict->lookup("Subtype"); + if (obj1.isName()) { const char *name = obj1.getName(); if (!strcmp(name, "3D")) { @@ -6982,30 +6664,33 @@ AnnotRichMedia::Configuration::Configuration(Dict *dict) } else if (!strcmp(name, "Video")) { type = typeVideo; } else { - // determine from first instance + // determine from first non null instance + type = typeFlash; // default in case all instances are null if (instances && nInstances > 0) { - AnnotRichMedia::Instance *instance = instances[0]; - switch (instance->getType()) { - case AnnotRichMedia::Instance::type3D: - type = type3D; - break; - case AnnotRichMedia::Instance::typeFlash: - type = typeFlash; - break; - case AnnotRichMedia::Instance::typeSound: - type = typeSound; - break; - case AnnotRichMedia::Instance::typeVideo: - type = typeVideo; - break; - default: - type = typeFlash; - break; - } + for (int i = 0; i < nInstances; ++i) { + AnnotRichMedia::Instance *instance = instances[i]; + if (instance) { + switch (instance->getType()) { + case AnnotRichMedia::Instance::type3D: + type = type3D; + break; + case AnnotRichMedia::Instance::typeFlash: + type = typeFlash; + break; + case AnnotRichMedia::Instance::typeSound: + type = typeSound; + break; + case AnnotRichMedia::Instance::typeVideo: + type = typeVideo; + break; + } + // break the loop since we found the first non null instance + break; + } + } } } } - obj1.free(); } AnnotRichMedia::Configuration::~Configuration() @@ -7040,9 +6725,7 @@ AnnotRichMedia::Configuration::Type AnnotRichMedia::Configuration::getType() con AnnotRichMedia::Instance::Instance(Dict *dict) { - Object obj1; - - dict->lookup("Subtype", &obj1); + Object obj1 = dict->lookup("Subtype"); const char *name = obj1.isName() ? obj1.getName() : ""; if (!strcmp(name, "3D")) { @@ -7056,14 +6739,13 @@ AnnotRichMedia::Instance::Instance(Dict *dict) } else { type = typeFlash; } - obj1.free(); - if (dict->lookup("Params", &obj1)->isDict()) { + obj1 = dict->lookup("Params"); + if (obj1.isDict()) { params = new AnnotRichMedia::Params(obj1.getDict()); } else { params = NULL; } - obj1.free(); } AnnotRichMedia::Instance::~Instance() @@ -7081,14 +6763,12 @@ AnnotRichMedia::Params* AnnotRichMedia::Instance::getParams() const { AnnotRichMedia::Params::Params(Dict *dict) { - Object obj1; - - if (dict->lookup("FlashVars", &obj1)->isString()) { + Object obj1 = dict->lookup("FlashVars"); + if (obj1.isString()) { flashVars = new GooString(obj1.getString()); } else { flashVars = NULL; } - obj1.free(); } AnnotRichMedia::Params::~Params() @@ -7106,7 +6786,6 @@ GooString* AnnotRichMedia::Params::getFlashVars() const { Annots::Annots(PDFDoc *docA, int page, Object *annotsObj) { Annot *annot; - Object obj1; int i; doc = docA; @@ -7119,10 +6798,10 @@ Annots::Annots(PDFDoc *docA, int page, Object *annotsObj) { //get the Ref to this annot and pass it to Annot constructor //this way, it'll be possible for the annot to retrieve the corresponding //form widget - Object obj2; - if (annotsObj->arrayGet(i, &obj1)->isDict()) { - annotsObj->arrayGetNF(i, &obj2); - annot = createAnnot (obj1.getDict(), &obj2); + Object obj1 = annotsObj->arrayGet(i); + if (obj1.isDict()) { + Object obj2 = annotsObj->arrayGetNF(i); + annot = createAnnot (&obj1, &obj2); if (annot) { if (annot->isOk()) { annot->setPage(page, gFalse); // Don't change /P @@ -7131,8 +6810,6 @@ Annots::Annots(PDFDoc *docA, int page, Object *annotsObj) { annot->decRefCnt(); } } - obj2.free(); - obj1.free(); } } } @@ -7166,49 +6843,48 @@ GBool Annots::removeAnnot(Annot *annot) { } } -Annot *Annots::createAnnot(Dict* dict, Object *obj) { - Annot *annot = NULL; - Object obj1; - - if (dict->lookup("Subtype", &obj1)->isName()) { +Annot *Annots::createAnnot(Object* dictObject, Object *obj) { + Annot *annot = nullptr; + Object obj1 = dictObject->dictLookup("Subtype"); + if (obj1.isName()) { const char *typeName = obj1.getName(); if (!strcmp(typeName, "Text")) { - annot = new AnnotText(doc, dict, obj); + annot = new AnnotText(doc, dictObject, obj); } else if (!strcmp(typeName, "Link")) { - annot = new AnnotLink(doc, dict, obj); + annot = new AnnotLink(doc, dictObject, obj); } else if (!strcmp(typeName, "FreeText")) { - annot = new AnnotFreeText(doc, dict, obj); + annot = new AnnotFreeText(doc, dictObject, obj); } else if (!strcmp(typeName, "Line")) { - annot = new AnnotLine(doc, dict, obj); + annot = new AnnotLine(doc, dictObject, obj); } else if (!strcmp(typeName, "Square")) { - annot = new AnnotGeometry(doc, dict, obj); + annot = new AnnotGeometry(doc, dictObject, obj); } else if (!strcmp(typeName, "Circle")) { - annot = new AnnotGeometry(doc, dict, obj); + annot = new AnnotGeometry(doc, dictObject, obj); } else if (!strcmp(typeName, "Polygon")) { - annot = new AnnotPolygon(doc, dict, obj); + annot = new AnnotPolygon(doc, dictObject, obj); } else if (!strcmp(typeName, "PolyLine")) { - annot = new AnnotPolygon(doc, dict, obj); + annot = new AnnotPolygon(doc, dictObject, obj); } else if (!strcmp(typeName, "Highlight")) { - annot = new AnnotTextMarkup(doc, dict, obj); + annot = new AnnotTextMarkup(doc, dictObject, obj); } else if (!strcmp(typeName, "Underline")) { - annot = new AnnotTextMarkup(doc, dict, obj); + annot = new AnnotTextMarkup(doc, dictObject, obj); } else if (!strcmp(typeName, "Squiggly")) { - annot = new AnnotTextMarkup(doc, dict, obj); + annot = new AnnotTextMarkup(doc, dictObject, obj); } else if (!strcmp(typeName, "StrikeOut")) { - annot = new AnnotTextMarkup(doc, dict, obj); + annot = new AnnotTextMarkup(doc, dictObject, obj); } else if (!strcmp(typeName, "Stamp")) { - annot = new AnnotStamp(doc, dict, obj); + annot = new AnnotStamp(doc, dictObject, obj); } else if (!strcmp(typeName, "Caret")) { - annot = new AnnotCaret(doc, dict, obj); + annot = new AnnotCaret(doc, dictObject, obj); } else if (!strcmp(typeName, "Ink")) { - annot = new AnnotInk(doc, dict, obj); + annot = new AnnotInk(doc, dictObject, obj); } else if (!strcmp(typeName, "FileAttachment")) { - annot = new AnnotFileAttachment(doc, dict, obj); + annot = new AnnotFileAttachment(doc, dictObject, obj); } else if (!strcmp(typeName, "Sound")) { - annot = new AnnotSound(doc, dict, obj); + annot = new AnnotSound(doc, dictObject, obj); } else if(!strcmp(typeName, "Movie")) { - annot = new AnnotMovie(doc, dict, obj); + annot = new AnnotMovie(doc, dictObject, obj); } else if(!strcmp(typeName, "Widget")) { // Find the annot in forms if (obj->isRef()) { @@ -7222,37 +6898,33 @@ Annot *Annots::createAnnot(Dict* dict, Object *obj) { } } if (!annot) - annot = new AnnotWidget(doc, dict, obj); + annot = new AnnotWidget(doc, dictObject, obj); } else if(!strcmp(typeName, "Screen")) { - annot = new AnnotScreen(doc, dict, obj); + annot = new AnnotScreen(doc, dictObject, obj); } else if(!strcmp(typeName, "PrinterMark")) { - annot = new Annot(doc, dict, obj); + annot = new Annot(doc, dictObject, obj); } else if (!strcmp(typeName, "TrapNet")) { - annot = new Annot(doc, dict, obj); + annot = new Annot(doc, dictObject, obj); } else if (!strcmp(typeName, "Watermark")) { - annot = new Annot(doc, dict, obj); + annot = new Annot(doc, dictObject, obj); } else if (!strcmp(typeName, "3D")) { - annot = new Annot3D(doc, dict, obj); + annot = new Annot3D(doc, dictObject, obj); } else if (!strcmp(typeName, "RichMedia")) { - annot = new AnnotRichMedia(doc, dict, obj); + annot = new AnnotRichMedia(doc, dictObject, obj); } else if (!strcmp(typeName, "Popup")) { /* Popup annots are already handled by markup annots * Here we only care about popup annots without a * markup annotation associated */ - Object obj2; - - if (dict->lookup("Parent", &obj2)->isNull()) - annot = new AnnotPopup(doc, dict, obj); + Object obj2 = dictObject->dictLookup("Parent"); + if (obj2.isNull()) + annot = new AnnotPopup(doc, dictObject, obj); else annot = NULL; - - obj2.free(); } else { - annot = new Annot(doc, dict, obj); + annot = new Annot(doc, dictObject, obj); } } - obj1.free(); return annot; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Annot.h b/Build/source/libs/poppler/poppler-src/poppler/Annot.h index 02311cb4278..82279bdfddf 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Annot.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Annot.h @@ -21,11 +21,11 @@ // Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com> // Copyright (C) 2008 Pino Toscano <pino@kde.org> // Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com> -// Copyright (C) 2009-2011, 2013, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009-2011, 2013, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2012, 2015 Tobias Koenig <tokoe@kdab.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -239,7 +239,7 @@ public: virtual double *getDash() const { return dash; } virtual AnnotBorderStyle getStyle() const { return style; } - virtual void writeToObject(XRef *xref, Object *obj1) const = 0; + virtual Object writeToObject(XRef *xref) const = 0; protected: AnnotBorder(); @@ -270,8 +270,8 @@ public: double getVerticalCorner() const { return verticalCorner; } private: - virtual AnnotBorderType getType() const { return typeArray; } - virtual void writeToObject(XRef *xref, Object *obj1) const; + AnnotBorderType getType() const override { return typeArray; } + Object writeToObject(XRef *xref) const override; double horizontalCorner; // (Default 0) double verticalCorner; // (Default 0) @@ -289,8 +289,8 @@ public: AnnotBorderBS(Dict *dict); private: - virtual AnnotBorderType getType() const { return typeBS; } - virtual void writeToObject(XRef *xref, Object *obj1) const; + AnnotBorderType getType() const override { return typeBS; } + Object writeToObject(XRef *xref) const override; const char *getStyleName() const; @@ -324,7 +324,7 @@ public: AnnotColorSpace getSpace() const { return (AnnotColorSpace) length; } const double *getValues() const { return values; } - void writeToObject(XRef *xref, Object *dest) const; + Object writeToObject(XRef *xref) const; private: @@ -385,7 +385,7 @@ public: ~AnnotAppearance(); // State is ignored if no subdictionary is present - void getAppearanceStream(AnnotAppearanceType type, const char *state, Object *dest); + Object getAppearanceStream(AnnotAppearanceType type, const char *state); // Access keys in normal appearance subdictionary (N) GooString * getStateKey(int i); @@ -555,8 +555,8 @@ public: }; Annot(PDFDoc *docA, PDFRectangle *rectA); - Annot(PDFDoc *docA, Dict *dict); - Annot(PDFDoc *docA, Dict *dict, Object *obj); + Annot(PDFDoc *docA, Object *dictObject); + Annot(PDFDoc *docA, Object *dictObject, Object *obj); GBool isOk() { return ok; } void incRefCnt(); @@ -564,7 +564,7 @@ public: virtual void draw(Gfx *gfx, GBool printing); // Get the resource dict of the appearance stream - virtual Object *getAppearanceResDict(Object *dest); + virtual Object getAppearanceResDict(); GBool match(Ref *refA) { return ref.num == refA->num && ref.gen == refA->gen; } @@ -638,15 +638,15 @@ protected: double *width, double widthLimit, int *charCount, GBool noReencode); void writeString(GooString *str, GooString *appearBuf); - void createForm(double *bbox, GBool transparencyGroup, Object *resDict, Object *aStream); - void createResourcesDict(const char *formName, Object *formStream, const char *stateName, - double opacity, const char *blendMode, Object *resDict); + Object createForm(double *bbox, GBool transparencyGroup, Dict *resDict); + Dict *createResourcesDict(const char *formName, Object &&formStream, const char *stateName, + double opacity, const char *blendMode); GBool isVisible(GBool printing); int getRotation() const; // Updates the field key of the annotation dictionary // and sets M to the current time - void update(const char *key, Object *value); + void update(const char *key, Object &&value); // Delete appearance streams and reset appearance state void invalidateAppearance(); @@ -683,7 +683,7 @@ protected: GBool ok; bool hasRef; -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; @@ -695,10 +695,9 @@ protected: class AnnotPopup: public Annot { public: AnnotPopup(PDFDoc *docA, PDFRectangle *rect); - AnnotPopup(PDFDoc *docA, Dict *dict, Object *obj); + AnnotPopup(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotPopup(); - Object *getParent(Object *obj) { return parent.fetch (xref, obj); } Object *getParentNF() { return &parent; } void setParent(Object *parentA); void setParent(Annot *parentA); @@ -724,8 +723,8 @@ public: }; AnnotMarkup(PDFDoc *docA, PDFRectangle *rect); - AnnotMarkup(PDFDoc *docA, Dict *dict, Object *obj); - virtual ~AnnotMarkup(); + AnnotMarkup(PDFDoc *docA, Object *dictObject, Object *obj); + ~AnnotMarkup(); // getters GooString *getLabel() const { return label; } @@ -745,7 +744,7 @@ public: void setDate(GooString *new_date); protected: - virtual void removeReferencedObjects(); + void removeReferencedObjects() override; GooString *label; // T (Default autor) AnnotPopup *popup; // Popup @@ -784,10 +783,10 @@ public: }; AnnotText(PDFDoc *docA, PDFRectangle *rect); - AnnotText(PDFDoc *docA, Dict *dict, Object *obj); + AnnotText(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotText(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; // getters GBool getOpen() const { return open; } @@ -817,10 +816,10 @@ private: class AnnotMovie: public Annot { public: AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA); - AnnotMovie(PDFDoc *docA, Dict *dict, Object *obj); + AnnotMovie(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotMovie(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; GooString* getTitle() { return title; } Movie* getMovie() { return movie; } @@ -841,7 +840,7 @@ class AnnotScreen: public Annot { public: AnnotScreen(PDFDoc *docA, PDFRectangle *rect); - AnnotScreen(PDFDoc *docA, Dict *dict, Object *obj); + AnnotScreen(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotScreen(); GooString* getTitle() { return title; } @@ -877,10 +876,10 @@ public: }; AnnotLink(PDFDoc *docA, PDFRectangle *rect); - AnnotLink(PDFDoc *docA, Dict *dict, Object *obj); - virtual ~AnnotLink(); + AnnotLink(PDFDoc *docA, Object *dictObject, Object *obj); + ~AnnotLink(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; // getters LinkAction *getAction() const { return action; } @@ -919,12 +918,12 @@ public: }; AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da); - AnnotFreeText(PDFDoc *docA, Dict *dict, Object *obj); + AnnotFreeText(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotFreeText(); - virtual void draw(Gfx *gfx, GBool printing); - virtual Object *getAppearanceResDict(Object *dest); - virtual void setContents(GooString *new_content); + void draw(Gfx *gfx, GBool printing) override; + Object getAppearanceResDict() override; + void setContents(GooString *new_content) override; void setAppearanceString(GooString *new_string); void setQuadding(AnnotFreeTextQuadding new_quadding); @@ -983,12 +982,12 @@ public: }; AnnotLine(PDFDoc *docA, PDFRectangle *rect); - AnnotLine(PDFDoc *docA, Dict *dict, Object *obj); + AnnotLine(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotLine(); - virtual void draw(Gfx *gfx, GBool printing); - virtual Object *getAppearanceResDict(Object *dest); - virtual void setContents(GooString *new_content); + void draw(Gfx *gfx, GBool printing) override; + Object getAppearanceResDict() override; + void setContents(GooString *new_content) override; void setVertices(double x1, double y1, double x2, double y2); void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end); @@ -1049,10 +1048,10 @@ class AnnotTextMarkup: public AnnotMarkup { public: AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); - AnnotTextMarkup(PDFDoc *docA, Dict *dict, Object *obj); - virtual ~AnnotTextMarkup(); + AnnotTextMarkup(PDFDoc *docA, Object *dictObject, Object *obj); + ~AnnotTextMarkup(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; // typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut void setType(AnnotSubtype new_type); @@ -1076,7 +1075,7 @@ class AnnotStamp: public AnnotMarkup { public: AnnotStamp(PDFDoc *docA, PDFRectangle *rect); - AnnotStamp(PDFDoc *docA, Dict *dict, Object *obj); + AnnotStamp(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotStamp(); void setIcon(GooString *new_icon); @@ -1099,10 +1098,10 @@ class AnnotGeometry: public AnnotMarkup { public: AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); - AnnotGeometry(PDFDoc *docA, Dict *dict, Object *obj); + AnnotGeometry(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotGeometry(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; void setType(AnnotSubtype new_type); // typeSquare or typeCircle void setInteriorColor(AnnotColor *new_color); @@ -1135,10 +1134,10 @@ public: }; AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); - AnnotPolygon(PDFDoc *docA, Dict *dict, Object *obj); + AnnotPolygon(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotPolygon(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; void setType(AnnotSubtype new_type); // typePolygon or typePolyLine void setVertices(AnnotPath *path); @@ -1185,7 +1184,7 @@ public: }; AnnotCaret(PDFDoc *docA, PDFRectangle *rect); - AnnotCaret(PDFDoc *docA, Dict *dict, Object *obj); + AnnotCaret(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotCaret(); void setSymbol(AnnotCaretSymbol new_symbol); @@ -1210,10 +1209,10 @@ class AnnotInk: public AnnotMarkup { public: AnnotInk(PDFDoc *docA, PDFRectangle *rect); - AnnotInk(PDFDoc *docA, Dict *dict, Object *obj); + AnnotInk(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotInk(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; void setInkList(AnnotPath **paths, int n_paths); @@ -1245,10 +1244,10 @@ class AnnotFileAttachment: public AnnotMarkup { public: AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename); - AnnotFileAttachment(PDFDoc *docA, Dict *dict, Object *obj); + AnnotFileAttachment(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotFileAttachment(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; // getters Object *getFile() { return &file; } @@ -1273,10 +1272,10 @@ class AnnotSound: public AnnotMarkup { public: AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA); - AnnotSound(PDFDoc *docA, Dict *dict, Object *obj); + AnnotSound(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotSound(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; // getters Sound *getSound() { return sound; } @@ -1307,11 +1306,11 @@ public: highlightModePush // P,T }; - AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj); - AnnotWidget(PDFDoc *docA, Dict *dict, Object *obj, FormField *fieldA); - virtual ~AnnotWidget(); + AnnotWidget(PDFDoc *docA, Object *dictObject, Object *obj); + AnnotWidget(PDFDoc *docA, Object *dictObject, Object *obj, FormField *fieldA); + ~AnnotWidget(); - virtual void draw(Gfx *gfx, GBool printing); + void draw(Gfx *gfx, GBool printing) override; void drawBorder(); void drawFormFieldButton(GfxResources *resources, GooString *da); @@ -1398,7 +1397,7 @@ class Annot3D: public Annot { public: Annot3D(PDFDoc *docA, PDFRectangle *rect); - Annot3D(PDFDoc *docA, Dict *dict, Object *obj); + Annot3D(PDFDoc *docA, Object *dictObject, Object *obj); ~Annot3D(); // getters @@ -1560,7 +1559,7 @@ public: }; AnnotRichMedia(PDFDoc *docA, PDFRectangle *rect); - AnnotRichMedia(PDFDoc *docA, Dict *dict, Object *obj); + AnnotRichMedia(PDFDoc *docA, Object *dictObject, Object *obj); ~AnnotRichMedia(); Content* getContent() const; @@ -1597,7 +1596,7 @@ public: GBool removeAnnot(Annot *annot); private: - Annot* createAnnot(Dict* dict, Object *obj); + Annot* createAnnot(Object* dictObject, Object *obj); Annot *findAnnot(Ref *ref); PDFDoc *doc; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Array.cc b/Build/source/libs/poppler/poppler-src/poppler/Array.cc index 230c3287683..c6de53ef03e 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Array.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Array.cc @@ -16,7 +16,8 @@ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2013, 2017 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -35,7 +36,7 @@ #include "Object.h" #include "Array.h" -#if MULTITHREADED +#ifdef MULTITHREADED # define arrayLocker() MutexLocker locker(&mutex) #else # define arrayLocker() @@ -49,7 +50,7 @@ Array::Array(XRef *xrefA) { elems = NULL; size = length = 0; ref = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -60,19 +61,18 @@ Array::~Array() { for (i = 0; i < length; ++i) elems[i].free(); gfree(elems); -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } -Object *Array::copy(XRef *xrefA, Object *obj) { +Object Array::copy(XRef *xrefA) const { arrayLocker(); - obj->initArray(xrefA); + Array *a = new Array(xrefA); for (int i = 0; i < length; ++i) { - Object obj1; - obj->arrayAdd(elems[i].copy(&obj1)); + a->add(elems[i].copy()); } - return obj; + return Object(a); } int Array::incRef() { @@ -87,7 +87,7 @@ int Array::decRef() { return ref; } -void Array::add(Object *elem) { +void Array::add(Object &&elem) { arrayLocker(); if (length == size) { if (length == 0) { @@ -97,7 +97,8 @@ void Array::add(Object *elem) { } elems = (Object *)greallocn(elems, size, sizeof(Object)); } - elems[length] = *elem; + elems[length].initNullAfterMalloc(); + elems[length] = std::move(elem); ++length; } @@ -114,39 +115,36 @@ void Array::remove(int i) { memmove( elems + i, elems + i + 1, sizeof(elems[0]) * (length - i) ); } -Object *Array::get(int i, Object *obj, int recursion) { +Object Array::get(int i, int recursion) const { if (i < 0 || i >= length) { #ifdef DEBUG_MEM abort(); #else - return obj->initNull(); + return Object(objNull); #endif } - return elems[i].fetch(xref, obj, recursion); + return elems[i].fetch(xref, recursion); } -Object *Array::getNF(int i, Object *obj) { +Object Array::getNF(int i) const { if (i < 0 || i >= length) { #ifdef DEBUG_MEM abort(); #else - return obj->initNull(); + return Object(objNull); #endif } - return elems[i].copy(obj); + return elems[i].copy(); } -GBool Array::getString(int i, GooString *string) +GBool Array::getString(int i, GooString *string) const { - Object obj; - - if (getNF(i, &obj)->isString()) { + Object obj = getNF(i); + if (obj.isString()) { string->clear(); string->append(obj.getString()); - obj.free(); return gTrue; } else { - obj.free(); return gFalse; } } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Array.h b/Build/source/libs/poppler/poppler-src/poppler/Array.h index e78e399baf2..2babc8be52f 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Array.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Array.h @@ -16,6 +16,8 @@ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -48,36 +50,38 @@ public: // Destructor. ~Array(); - // Reference counting. - int incRef(); - int decRef(); - // Get number of elements. - int getLength() { return length; } + int getLength() const { return length; } // Copy array with new xref - Object *copy(XRef *xrefA, Object *obj); + Object copy(XRef *xrefA) const; - // Add an element. - void add(Object *elem); + // Add an element + // elem becomes a dead object after this call + void add(Object &&elem); // Remove an element by position void remove(int i); // Accessors. - Object *get(int i, Object *obj, int resursion = 0); - Object *getNF(int i, Object *obj); - GBool getString(int i, GooString *string); + Object get(int i, int resursion = 0) const; + Object getNF(int i) const; + GBool getString(int i, GooString *string) const; private: + friend class Object; // for incRef/decRef + + // Reference counting. + int incRef(); + int decRef(); XRef *xref; // the xref table for this PDF file Object *elems; // array of elements int size; // size of <elems> array int length; // number of elements in array int ref; // reference count -#if MULTITHREADED - GooMutex mutex; +#ifdef MULTITHREADED + mutable GooMutex mutex; #endif }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/CMap.cc b/Build/source/libs/poppler/poppler-src/poppler/CMap.cc index 6731ab5a1fa..2d2a7d75754 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CMap.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/CMap.cc @@ -14,8 +14,9 @@ // under GPL version 2 or later // // Copyright (C) 2008 Koji Otani <sho@bbr.jp> -// Copyright (C) 2008, 2009 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2009, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -116,15 +117,11 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA, } CMap *CMap::parse(CMapCache *cache, GooString *collectionA, Stream *str) { - Object obj1; - CMap *cMap; - - cMap = new CMap(collectionA->copy(), NULL); - - if (!str->getDict()->lookup("UseCMap", &obj1)->isNull()) { + CMap *cMap = new CMap(collectionA->copy(), NULL); + Object obj1 = str->getDict()->lookup("UseCMap"); + if (!obj1.isNull()) { cMap->useCMap(cache, &obj1); } - obj1.free(); str->reset(); cMap->parse2(cache, &getCharFromStream, str); @@ -316,7 +313,7 @@ CMap::CMap(GooString *collectionA, GooString *cMapNameA) { vector[i].cid = 0; } refCnt = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -328,7 +325,7 @@ CMap::CMap(GooString *collectionA, GooString *cMapNameA, int wModeA) { wMode = wModeA; vector = NULL; refCnt = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -436,7 +433,7 @@ CMap::~CMap() { if (vector) { freeCMapVector(vector); } -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } @@ -453,11 +450,11 @@ void CMap::freeCMapVector(CMapVectorEntry *vec) { } void CMap::incRefCnt() { -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif ++refCnt; -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif } @@ -465,11 +462,11 @@ void CMap::incRefCnt() { void CMap::decRefCnt() { GBool done; -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif done = --refCnt == 0; -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif if (done) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/CMap.h b/Build/source/libs/poppler/poppler-src/poppler/CMap.h index f4f5a9141c8..e85c086a56d 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CMap.h +++ b/Build/source/libs/poppler/poppler-src/poppler/CMap.h @@ -15,7 +15,7 @@ // // Copyright (C) 2008 Koji Otani <sho@bbr.jp> // Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // // 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,7 +33,7 @@ #include "goo/gtypes.h" #include "CharTypes.h" -#if MULTITHREADED +#ifdef MULTITHREADED #include "goo/GooMutex.h" #endif @@ -114,7 +114,7 @@ private: CMapVectorEntry *vector; // vector for first byte (NULL for // identity CMap) int refCnt; -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.cc b/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.cc index 6676f898ad7..a375e0afc6a 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.cc @@ -17,11 +17,11 @@ // Copyright (C) 2005-2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> -// Copyright (C) 2005, 2009, 2012, 2013, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2009, 2012, 2013, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006, 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2007 Koji Otani <sho@bbr.jp> // Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk> -// Copyright (C) 2008, 2012, 2014, 2016 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2008, 2012, 2014, 2016, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2009 Darren Kenny <darren.kenny@sun.com> // Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2010 Jan Kümmel <jan+freedesktop@snorc.org> @@ -49,7 +49,7 @@ #include "Gfx.h" #include "Page.h" -#if HAVE_FCNTL_H && HAVE_SYS_MMAN_H && HAVE_SYS_STAT_H +#if defined(HAVE_FCNTL_H) && defined(HAVE_SYS_MMAN_H) && defined(HAVE_SYS_STAT_H) #include <fcntl.h> #include <sys/stat.h> #include <sys/mman.h> @@ -60,7 +60,7 @@ #pragma implementation #endif -#if MULTITHREADED +#ifdef MULTITHREADED # define fontEngineLocker() MutexLocker locker(&mutex) #else # define fontEngineLocker() @@ -207,7 +207,7 @@ _ft_new_face_uncached (FT_Library lib, return gTrue; } -#if CAN_CHECK_OPEN_FACES +#ifdef CAN_CHECK_OPEN_FACES static struct _ft_face_data { struct _ft_face_data *prev, *next, **head; @@ -708,7 +708,8 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font, output_dev->startDoc(info->doc, info->fontEngine); output_dev->startPage (1, gfx->getState(), gfx->getXRef()); output_dev->setInType3Char(gTrue); - gfx->display(charProcs->getVal(glyph, &charProc)); + charProc = charProcs->getVal(glyph); + gfx->display(&charProc); output_dev->getType3GlyphWidth (&wx, &wy); cairo_matrix_transform_distance (&matrix, &wx, &wy); @@ -727,7 +728,6 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font, delete gfx; delete output_dev; - charProc.free(); return CAIRO_STATUS_SUCCESS; } @@ -817,7 +817,7 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) { FT_Library_Version(lib, &major, &minor, &patch); useCIDs = major > 2 || (major == 2 && (minor > 1 || (minor == 1 && patch > 7))); -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -829,7 +829,7 @@ CairoFontEngine::~CairoFontEngine() { if (fontCache[i]) delete fontCache[i]; } -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } diff --git a/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.h b/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.h index 8c0dba116d5..12fa598f152 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.h +++ b/Build/source/libs/poppler/poppler-src/poppler/CairoFontEngine.h @@ -18,7 +18,7 @@ // Copyright (C) 2005 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2008 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2008, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // // To see a description of the changes please see the Changelog file that @@ -74,7 +74,7 @@ protected: class CairoFreeTypeFont : public CairoFont { public: static CairoFreeTypeFont *create(GfxFont *gfxFont, XRef *xref, FT_Library lib, GBool useCIDs); - virtual ~CairoFreeTypeFont(); + ~CairoFreeTypeFont(); private: CairoFreeTypeFont(Ref ref, cairo_font_face_t *cairo_font_face, @@ -88,9 +88,9 @@ public: static CairoType3Font *create(GfxFont *gfxFont, PDFDoc *doc, CairoFontEngine *fontEngine, GBool printing, XRef *xref); - virtual ~CairoType3Font(); + ~CairoType3Font(); - virtual GBool matches(Ref &other, GBool printing); + GBool matches(Ref &other, GBool printing) override; private: CairoType3Font(Ref ref, PDFDoc *doc, @@ -121,7 +121,7 @@ private: CairoFont *fontCache[cairoFontCacheSize]; FT_Library lib; GBool useCIDs; -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc index 89d0c996872..cc8a161bee3 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc @@ -16,11 +16,11 @@ // // Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005, 2009, 2012 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2009, 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> -// Copyright (C) 2006-2011, 2013, 2014 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2006-2011, 2013, 2014, 2017 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2008 Carl Worth <cworth@cworth.org> -// Copyright (C) 2008-2016 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2008-2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> // Copyright (C) 2008, 2009 Chris Wilson <chris@chris-wilson.co.uk> // Copyright (C) 2008, 2012 Hib Eris <hib@hiberis.nl> @@ -41,13 +41,13 @@ #pragma implementation #endif +#include <cstdint> #include <string.h> #include <math.h> #include <assert.h> #include <cairo.h> #include "goo/gfile.h" -#include "goo/gtypes_p.h" #include "GlobalParams.h" #include "Error.h" #include "Object.h" @@ -143,7 +143,11 @@ CairoOutputDev::CairoOutputDev() { strokePathClip = NULL; cairo = NULL; currentFont = NULL; +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) + prescaleImages = gFalse; +#else prescaleImages = gTrue; +#endif printing = gTrue; use_show_text_glyphs = gFalse; inUncoloredPattern = gFalse; @@ -165,7 +169,7 @@ CairoOutputDev::CairoOutputDev() { // the SA parameter supposedly defaults to false, but Acrobat // apparently hardwires it to true - stroke_adjust = globalParams->getStrokeAdjust(); + stroke_adjust = gTrue; align_stroke_coords = gFalse; adjusted_stroke_width = gFalse; xref = NULL; @@ -1830,7 +1834,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, /* convert to a luminocity map */ uint32_t *source_data = (uint32_t*)cairo_image_surface_get_data(source); /* get stride in units of 32 bits */ - int stride = cairo_image_surface_get_stride(source)/4; + ptrdiff_t stride = cairo_image_surface_get_stride(source)/4; for (int y=0; y<height; y++) { for (int x=0; x<width; x++) { int lum = alpha ? fill_opacity : luminocity(source_data[y*stride + x]); @@ -1961,7 +1965,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image, GBool interpolate) { if (interpolate) - return CAIRO_FILTER_BILINEAR; + return CAIRO_FILTER_BEST; int orig_width = cairo_image_surface_get_width (image); int orig_height = cairo_image_surface_get_height (image); @@ -1981,7 +1985,7 @@ CairoOutputDev::getFilterForSurface(cairo_surface_t *image, if (scaled_width / orig_width >= 4 || scaled_height / orig_height >= 4) return CAIRO_FILTER_NEAREST; - return CAIRO_FILTER_BILINEAR; + return CAIRO_FILTER_BEST; } void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, @@ -2123,7 +2127,7 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream * Guchar *pix; cairo_matrix_t matrix; int invert_bit; - int row_stride; + ptrdiff_t row_stride; cairo_filter_t filter; /* TODO: Do we want to cache these? */ @@ -2174,9 +2178,6 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream * cairo_pattern_set_filter (pattern, filter); - if (!printing) - cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); - cairo_matrix_init_translate (&matrix, 0, height); cairo_matrix_scale (&matrix, width, -height); cairo_pattern_set_matrix (pattern, &matrix); @@ -2192,6 +2193,11 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream * cairo_save (cairo); cairo_rectangle (cairo, 0., 0., 1., 1.); cairo_clip (cairo); + if (strokePathClip) { + cairo_push_group (cairo); + fillToStrokePathClip (state); + cairo_pop_group_to_source (cairo); + } cairo_mask (cairo, pattern); cairo_restore (cairo); } else { @@ -2228,7 +2234,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream Guchar *pix; cairo_matrix_t matrix; int invert_bit; - int row_stride; + ptrdiff_t row_stride; /* cairo does a very poor job of scaling down images so we scale them ourselves */ @@ -2521,7 +2527,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref, GBool maskInterpolate) { ImageStream *maskImgStr, *imgStr; - int row_stride; + ptrdiff_t row_stride; unsigned char *maskBuffer, *buffer; unsigned char *maskDest; unsigned int *dest; @@ -2679,7 +2685,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s GBool maskInterpolate) { ImageStream *maskImgStr, *imgStr; - int row_stride; + ptrdiff_t row_stride; unsigned char *maskBuffer, *buffer; unsigned char *maskDest; unsigned int *dest; @@ -2708,7 +2714,9 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s for (y = 0; y < maskHeight; y++) { maskDest = (unsigned char *) (maskBuffer + y * row_stride); pix = maskImgStr->getLine(); - maskColorMap->getGrayLine (pix, maskDest, maskWidth); + if (likely(pix != nullptr)) { + maskColorMap->getGrayLine (pix, maskDest, maskWidth); + } } maskImgStr->close(); @@ -2956,9 +2964,8 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, return; } - str->getDict()->lookup("ColorSpace", &obj); + obj = str->getDict()->lookup("ColorSpace"); colorSpace = GfxColorSpace::parse(NULL, &obj, this, state); - obj.free(); // colorspace in stream dict may be different from colorspace in jpx // data @@ -3072,10 +3079,16 @@ public: } } - if (printing || scaledWidth >= width || scaledHeight >= height) { +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) + bool needsCustomDownscaling = false; +#else + bool needsCustomDownscaling = true; +#endif + + if (!needsCustomDownscaling || printing || scaledWidth >= width || scaledHeight >= height) { // No downscaling. Create cairo image containing the source image data. unsigned char *buffer; - int stride; + ptrdiff_t stride; image = cairo_image_surface_create (maskColors ? CAIRO_FORMAT_ARGB32 : @@ -3119,7 +3132,7 @@ public: return image; } - void getRow(int row_num, uint32_t *row_data) { + void getRow(int row_num, uint32_t *row_data) override { int i; Guchar *pix; @@ -3186,7 +3199,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, cairo_matrix_t matrix; int width, height; int scaledWidth, scaledHeight; - cairo_filter_t filter = CAIRO_FILTER_BILINEAR; + cairo_filter_t filter = CAIRO_FILTER_BEST; RescaleDrawImage rescale; LOG (printf ("drawImage %dx%d\n", widthA, heightA)); diff --git a/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.h index 4a1cd9918e2..1fee8121719 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/CairoOutputDev.h @@ -97,121 +97,121 @@ public: // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gTrue; } + GBool upsideDown() override { return gTrue; } // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gTrue; } + GBool useDrawChar() override { return gTrue; } // Does this device use tilingPatternFill()? If this returns false, // tiling pattern fills will be reduced to a series of other drawing // operations. - virtual GBool useTilingPatternFill() { return gTrue; } + GBool useTilingPatternFill() override { return gTrue; } // Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) - virtual GBool useShadedFills(int type) { return type <= 7; } + GBool useShadedFills(int type) override { return type <= 7; } #else - virtual GBool useShadedFills(int type) { return type > 1 && type < 4; } + GBool useShadedFills(int type) override { return type > 1 && type < 4; } #endif // Does this device use FillColorStop()? - virtual GBool useFillColorStop() { return gTrue; } + GBool useFillColorStop() override { return gTrue; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gFalse; } + GBool interpretType3Chars() override { return gFalse; } // Does this device need to clip pages to the crop box even when the // box is the crop box? - virtual GBool needClipToCropBox() { return gTrue; } + GBool needClipToCropBox() override { return gTrue; } //----- initialization and control // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef *xref); + void startPage(int pageNum, GfxState *state, XRef *xref) override; // End a page. - virtual void endPage(); + void endPage() override; //----- save/restore graphics state - virtual void saveState(GfxState *state); - virtual void restoreState(GfxState *state); + void saveState(GfxState *state) override; + void restoreState(GfxState *state) override; //----- update graphics state - virtual void updateAll(GfxState *state); - virtual void setDefaultCTM(double *ctm); - virtual void updateCTM(GfxState *state, double m11, double m12, - double m21, double m22, double m31, double m32); - virtual void updateLineDash(GfxState *state); - virtual void updateFlatness(GfxState *state); - virtual void updateLineJoin(GfxState *state); - virtual void updateLineCap(GfxState *state); - virtual void updateMiterLimit(GfxState *state); - virtual void updateLineWidth(GfxState *state); - virtual void updateFillColor(GfxState *state); - virtual void updateStrokeColor(GfxState *state); - virtual void updateFillOpacity(GfxState *state); - virtual void updateStrokeOpacity(GfxState *state); - virtual void updateFillColorStop(GfxState *state, double offset); - virtual void updateBlendMode(GfxState *state); + void updateAll(GfxState *state) override; + void setDefaultCTM(double *ctm) override; + void updateCTM(GfxState *state, double m11, double m12, + double m21, double m22, double m31, double m32) override; + void updateLineDash(GfxState *state) override; + void updateFlatness(GfxState *state) override; + void updateLineJoin(GfxState *state) override; + void updateLineCap(GfxState *state) override; + void updateMiterLimit(GfxState *state) override; + void updateLineWidth(GfxState *state) override; + void updateFillColor(GfxState *state) override; + void updateStrokeColor(GfxState *state) override; + void updateFillOpacity(GfxState *state) override; + void updateStrokeOpacity(GfxState *state) override; + void updateFillColorStop(GfxState *state, double offset) override; + void updateBlendMode(GfxState *state) override; //----- update text state - virtual void updateFont(GfxState *state); + void updateFont(GfxState *state) override; //----- path painting - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); - virtual void clipToStrokePath(GfxState *state); - virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep); + void stroke(GfxState *state) override; + void fill(GfxState *state) override; + void eoFill(GfxState *state) override; + void clipToStrokePath(GfxState *state) override; + GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) override; #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) - virtual GBool functionShadedFill(GfxState *state, GfxFunctionShading *shading); + GBool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override; #endif - virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); - virtual GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading); - virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax); - virtual GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading); + GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override; + GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) override; + GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override; + GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) override; #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) - virtual GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading); - virtual GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading); + GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override; + GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override; #endif //----- path clipping - virtual void clip(GfxState *state); - virtual void eoClip(GfxState *state); + void clip(GfxState *state) override; + void eoClip(GfxState *state) override; //----- text drawing - void beginString(GfxState *state, GooString *s); - void endString(GfxState *state); + void beginString(GfxState *state, GooString *s) override; + void endString(GfxState *state) override; void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, - CharCode code, int nBytes, Unicode *u, int uLen); - void beginActualText(GfxState *state, GooString *text); - void endActualText(GfxState *state); + CharCode code, int nBytes, Unicode *u, int uLen) override; + void beginActualText(GfxState *state, GooString *text) override; + void endActualText(GfxState *state) override; - virtual GBool beginType3Char(GfxState *state, double x, double y, - double dx, double dy, - CharCode code, Unicode *u, int uLen); - virtual void endType3Char(GfxState *state); - virtual void beginTextObject(GfxState *state); - virtual void endTextObject(GfxState *state); + GBool beginType3Char(GfxState *state, double x, double y, + double dx, double dy, + CharCode code, Unicode *u, int uLen) override; + void endType3Char(GfxState *state) override; + void beginTextObject(GfxState *state) override; + void endTextObject(GfxState *state) override; //----- image drawing - virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, GBool interpolate, - GBool inlineImg); - virtual void setSoftMaskFromImageMask(GfxState *state, - Object *ref, Stream *str, - int width, int height, GBool invert, - GBool inlineImg, double *baseMatrix); - virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); + void drawImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, GBool interpolate, + GBool inlineImg) override; + void setSoftMaskFromImageMask(GfxState *state, + Object *ref, Stream *str, + int width, int height, GBool invert, + GBool inlineImg, double *baseMatrix) override; + void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override; void drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool interpolate, GBool inlineImg); @@ -219,42 +219,42 @@ public: int width, int height, GBool invert, GBool interpolate, GBool inlineImg); - virtual void drawImage(GfxState *state, Object *ref, Stream *str, - int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, int *maskColors, GBool inlineImg); - virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, - int maskWidth, int maskHeight, - GfxImageColorMap *maskColorMap, - GBool maskInterpolate); - - virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, - int maskWidth, int maskHeight, - GBool maskInvert, GBool maskInterpolate); + void drawImage(GfxState *state, Object *ref, Stream *str, + int width, int height, GfxImageColorMap *colorMap, + GBool interpolate, int *maskColors, GBool inlineImg) override; + void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GfxImageColorMap *maskColorMap, + GBool maskInterpolate) override; + + void drawMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GBool maskInvert, GBool maskInterpolate) override; //----- transparency groups and soft masks - virtual void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/, + void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, GBool /*isolated*/, GBool /*knockout*/, - GBool /*forSoftMask*/); - virtual void endTransparencyGroup(GfxState * /*state*/); + GBool /*forSoftMask*/) override; + void endTransparencyGroup(GfxState * /*state*/) override; void popTransparencyGroup(); - virtual void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/); - virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, - Function * /*transferFunc*/, GfxColor * /*backdropColor*/); - virtual void clearSoftMask(GfxState * /*state*/); + void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) override; + void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, + Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override; + void clearSoftMask(GfxState * /*state*/) override; //----- Type 3 font operators - virtual void type3D0(GfxState *state, double wx, double wy); - virtual void type3D1(GfxState *state, double wx, double wy, - double llx, double lly, double urx, double ury); + void type3D0(GfxState *state, double wx, double wy) override; + void type3D1(GfxState *state, double wx, double wy, + double llx, double lly, double urx, double ury) override; //----- special access @@ -388,118 +388,118 @@ public: // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gTrue; } + GBool upsideDown() override { return gTrue; } // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gFalse; } + GBool useDrawChar() override { return gFalse; } // Does this device use tilingPatternFill()? If this returns false, // tiling pattern fills will be reduced to a series of other drawing // operations. - virtual GBool useTilingPatternFill() { return gTrue; } + GBool useTilingPatternFill() override { return gTrue; } // Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2) - virtual GBool useShadedFills(int type) { return type <= 7; } + GBool useShadedFills(int type) override { return type <= 7; } #else - virtual GBool useShadedFills(int type) { return type < 4; } + GBool useShadedFills(int type) override { return type < 4; } #endif // Does this device use FillColorStop()? - virtual GBool useFillColorStop() { return gFalse; } + GBool useFillColorStop() override { return gFalse; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gFalse; } + GBool interpretType3Chars() override { return gFalse; } // Does this device need non-text content? - virtual GBool needNonText() { return gTrue; } + GBool needNonText() override { return gTrue; } //----- save/restore graphics state - virtual void saveState(GfxState *state) { } - virtual void restoreState(GfxState *state) { } + void saveState(GfxState *state) override { } + void restoreState(GfxState *state) override { } //----- update graphics state - virtual void updateAll(GfxState *state) { } - virtual void setDefaultCTM(double *ctm) { } - virtual void updateCTM(GfxState *state, double m11, double m12, - double m21, double m22, double m31, double m32) { } - virtual void updateLineDash(GfxState *state) { } - virtual void updateFlatness(GfxState *state) { } - virtual void updateLineJoin(GfxState *state) { } - virtual void updateLineCap(GfxState *state) { } - virtual void updateMiterLimit(GfxState *state) { } - virtual void updateLineWidth(GfxState *state) { } - virtual void updateFillColor(GfxState *state) { } - virtual void updateStrokeColor(GfxState *state) { } - virtual void updateFillOpacity(GfxState *state) { } - virtual void updateStrokeOpacity(GfxState *state) { } - virtual void updateBlendMode(GfxState *state) { } + void updateAll(GfxState *state) override { } + void setDefaultCTM(double *ctm) override { } + void updateCTM(GfxState *state, double m11, double m12, + double m21, double m22, double m31, double m32) override { } + void updateLineDash(GfxState *state) override { } + void updateFlatness(GfxState *state) override { } + void updateLineJoin(GfxState *state) override { } + void updateLineCap(GfxState *state) override { } + void updateMiterLimit(GfxState *state) override { } + void updateLineWidth(GfxState *state) override { } + void updateFillColor(GfxState *state) override { } + void updateStrokeColor(GfxState *state) override { } + void updateFillOpacity(GfxState *state) override { } + void updateStrokeOpacity(GfxState *state) override { } + void updateBlendMode(GfxState *state) override { } //----- update text state - virtual void updateFont(GfxState *state) { } + void updateFont(GfxState *state) override { } //----- path painting - virtual void stroke(GfxState *state) { } - virtual void fill(GfxState *state) { } - virtual void eoFill(GfxState *state) { } - virtual void clipToStrokePath(GfxState *state) { } - virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep) { return gTrue; } - virtual GBool axialShadedFill(GfxState *state, - GfxAxialShading *shading, - double tMin, double tMax) { return gTrue; } - virtual GBool radialShadedFill(GfxState *state, - GfxRadialShading *shading, - double sMin, double sMax) { return gTrue; } + void stroke(GfxState *state) override { } + void fill(GfxState *state) override { } + void eoFill(GfxState *state) override { } + void clipToStrokePath(GfxState *state) override { } + GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) override { return gTrue; } + GBool axialShadedFill(GfxState *state, + GfxAxialShading *shading, + double tMin, double tMax) override { return gTrue; } + GBool radialShadedFill(GfxState *state, + GfxRadialShading *shading, + double sMin, double sMax) override { return gTrue; } //----- path clipping - virtual void clip(GfxState *state) { } - virtual void eoClip(GfxState *state) { } + void clip(GfxState *state) override { } + void eoClip(GfxState *state) override { } //----- image drawing - virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, - GBool interpolate, GBool inlineImg); - virtual void drawImage(GfxState *state, Object *ref, Stream *str, - int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, int *maskColors, GBool inlineImg); - virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, - int maskWidth, int maskHeight, - GfxImageColorMap *maskColorMap, - GBool maskInterpolate); - virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, - int maskWidth, int maskHeight, - GBool maskInvert, GBool maskInterpolate); - virtual void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, - GBool inlineImg, double *baseMatrix); - virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) {} + void drawImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, + GBool interpolate, GBool inlineImg) override; + void drawImage(GfxState *state, Object *ref, Stream *str, + int width, int height, GfxImageColorMap *colorMap, + GBool interpolate, int *maskColors, GBool inlineImg) override; + void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GfxImageColorMap *maskColorMap, + GBool maskInterpolate) override; + void drawMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GBool maskInvert, GBool maskInterpolate) override; + void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, + GBool inlineImg, double *baseMatrix) override; + void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override {} //----- transparency groups and soft masks - virtual void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/, - GfxColorSpace * /*blendingColorSpace*/, - GBool /*isolated*/, GBool /*knockout*/, - GBool /*forSoftMask*/) {} - virtual void endTransparencyGroup(GfxState * /*state*/) {} - virtual void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) {} - virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, - Function * /*transferFunc*/, GfxColor * /*backdropColor*/) {} - virtual void clearSoftMask(GfxState * /*state*/) {} + void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/, + GfxColorSpace * /*blendingColorSpace*/, + GBool /*isolated*/, GBool /*knockout*/, + GBool /*forSoftMask*/) override {} + void endTransparencyGroup(GfxState * /*state*/) override {} + void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) override {} + void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/, + Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override {} + void clearSoftMask(GfxState * /*state*/) override {} //----- Image list // By default images are not rendred diff --git a/Build/source/libs/poppler/poppler-src/poppler/CairoRescaleBox.cc b/Build/source/libs/poppler/poppler-src/poppler/CairoRescaleBox.cc index 3c96f45e5d3..aa9e9e7d517 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CairoRescaleBox.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/CairoRescaleBox.cc @@ -31,7 +31,7 @@ // under GPL version 2 or later // // Copyright (C) 2012 Hib Eris <hib@hiberis.nl> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -41,17 +41,15 @@ /* This implements a box filter that supports non-integer box sizes */ -#ifdef HAVE_CONFIG_H #include <config.h> -#endif +#include <cstdint> #include <stdint.h> #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <math.h> #include "goo/gmem.h" -#include "goo/gtypes_p.h" #include "CairoRescaleBox.h" diff --git a/Build/source/libs/poppler/poppler-src/poppler/Catalog.cc b/Build/source/libs/poppler/poppler-src/poppler/Catalog.cc index 0e37c843db6..eebbbb42407 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Catalog.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Catalog.cc @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005-2013, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2013, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Jeff Muizelaar <jrmuizel@nit.ca> // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> @@ -28,7 +28,7 @@ // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Julien Nabet <serval2412@yahoo.fr> // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> // Copyright (C) 2014 Ed Porras <ed@moto-research.com> // Copyright (C) 2015 Even Rouault <even.rouault@spatialys.com> @@ -64,7 +64,7 @@ #include "FileSpec.h" #include "StructTreeRoot.h" -#if MULTITHREADED +#ifdef MULTITHREADED # define catalogLocker() MutexLocker locker(&mutex) #else # define catalogLocker() @@ -74,11 +74,7 @@ //------------------------------------------------------------------------ Catalog::Catalog(PDFDoc *docA) { - Object catDict, pagesDict, pagesDictRef; - Object obj, obj2; - Object optContentProps; - -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif ok = gTrue; @@ -107,44 +103,39 @@ Catalog::Catalog(PDFDoc *docA) { lastCachedPage = 0; markInfo = markInfoNull; - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (!catDict.isDict()) { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - goto err1; + ok = gFalse; + return; } // get the AcroForm dictionary - catDict.dictLookup("AcroForm", &acroForm); + acroForm = catDict.dictLookup("AcroForm"); // read base URI - if (catDict.dictLookup("URI", &obj)->isDict()) { - if (obj.dictLookup("Base", &obj2)->isString()) { + Object obj = catDict.dictLookup("URI"); + if (obj.isDict()) { + Object obj2 = obj.dictLookup("Base"); + if (obj2.isString()) { baseURI = obj2.getString()->copy(); } - obj2.free(); } - obj.free(); // get the Optional Content dictionary - if (catDict.dictLookup("OCProperties", &optContentProps)->isDict()) { + Object optContentProps = catDict.dictLookup("OCProperties"); + if (optContentProps.isDict()) { optContent = new OCGs(&optContentProps, xref); if (!optContent->isOk ()) { delete optContent; optContent = NULL; } } - optContentProps.free(); // actions - catDict.dictLookupNF("AA", &additionalActions); + additionalActions = catDict.dictLookupNF("AA"); // get the ViewerPreferences dictionary - catDict.dictLookup("ViewerPreferences", &viewerPreferences); - catDict.free(); - return; - - err1: - catDict.free(); - ok = gFalse; + viewerPreferences = catDict.dictLookup("ViewerPreferences"); } Catalog::~Catalog() { @@ -157,15 +148,7 @@ Catalog::~Catalog() { delete attrsList; } delete pagesRefList; - if (pagesList) { - std::vector<Dict *>::iterator it; - for (it = pagesList->begin() ; it != pagesList->end(); ++it ) { - if (!(*it)->decRef()) { - delete *it; - } - } - delete pagesList; - } + delete pagesList; if (pages) { for (int i = 0; i < pagesSize; ++i) { if (pages[i]) { @@ -175,8 +158,6 @@ Catalog::~Catalog() { gfree(pages); } gfree(pageRefs); - names.free(); - dests.free(); delete destNameTree; delete embeddedFileNameTree; delete jsNameTree; @@ -188,45 +169,32 @@ Catalog::~Catalog() { delete optContent; delete viewerPrefs; delete structTreeRoot; - metadata.free(); - outline.free(); - acroForm.free(); - viewerPreferences.free(); - additionalActions.free(); -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } GooString *Catalog::readMetadata() { - GooString *s; - Dict *dict; - Object obj; - catalogLocker(); if (metadata.isNone()) { - Object catDict; - - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (catDict.isDict()) { - catDict.dictLookup("Metadata", &metadata); + metadata = catDict.dictLookup("Metadata"); } else { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - metadata.initNull(); + metadata.setToNull(); } - catDict.free(); } if (!metadata.isStream()) { - return NULL; + return nullptr; } - dict = metadata.streamGetDict(); - if (!dict->lookup("Subtype", &obj)->isName("XML")) { + Object obj = metadata.streamGetDict()->lookup("Subtype"); + if (!obj.isName("XML")) { error(errSyntaxWarning, -1, "Unknown Metadata type: '{0:s}'", obj.isName() ? obj.getName() : "???"); } - obj.free(); - s = new GooString(); + GooString *s = new GooString(); metadata.getStream()->fillGooString(s); metadata.streamClose(); return s; @@ -262,47 +230,32 @@ Ref *Catalog::getPageRef(int i) GBool Catalog::cachePageTree(int page) { - Dict *pagesDict; - if (pagesList == NULL) { - Object catDict; Ref pagesRef; - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (catDict.isDict()) { - Object pagesDictRef; - if (catDict.dictLookupNF("Pages", &pagesDictRef)->isRef() && + Object pagesDictRef = catDict.dictLookupNF("Pages"); + if (pagesDictRef.isRef() && pagesDictRef.getRefNum() >= 0 && pagesDictRef.getRefNum() < xref->getNumObjects()) { pagesRef = pagesDictRef.getRef(); - pagesDictRef.free(); } else { error(errSyntaxError, -1, "Catalog dictionary does not contain a valid \"Pages\" entry"); - pagesDictRef.free(); - catDict.free(); return gFalse; } } else { error(errSyntaxError, -1, "Could not find catalog dictionary"); - catDict.free(); return gFalse; } - Object obj; - catDict.dictLookup("Pages", &obj); - catDict.free(); + Object obj = catDict.dictLookup("Pages"); // This should really be isDict("Pages"), but I've seen at least one // PDF file where the /Type entry is missing. - if (obj.isDict()) { - obj.getDict()->incRef(); - pagesDict = obj.getDict(); - obj.free(); - } - else { + if (!obj.isDict()) { error(errSyntaxError, -1, "Top-level pages object is wrong type ({0:s})", obj.getTypeName()); - obj.free(); return gFalse; } @@ -311,7 +264,6 @@ GBool Catalog::cachePageTree(int page) pageRefs = (Ref *)gmallocn_checkoverflow(pagesSize, sizeof(Ref)); if (pages == NULL || pageRefs == NULL ) { error(errSyntaxError, -1, "Cannot allocate page cache"); - pagesDict->decRef(); pagesSize = 0; return gFalse; } @@ -321,12 +273,12 @@ GBool Catalog::cachePageTree(int page) pageRefs[i].gen = -1; } - pagesList = new std::vector<Dict *>(); - pagesList->push_back(pagesDict); + attrsList = new std::vector<PageAttrs *>(); + attrsList->push_back(new PageAttrs(NULL, obj.getDict())); + pagesList = new std::vector<Object>(); + pagesList->push_back(std::move(obj)); pagesRefList = new std::vector<Ref>(); pagesRefList->push_back(pagesRef); - attrsList = new std::vector<PageAttrs *>(); - attrsList->push_back(new PageAttrs(NULL, pagesDict)); kidsIdxList = new std::vector<int>(); kidsIdxList->push_back(0); lastCachedPage = 0; @@ -339,38 +291,29 @@ GBool Catalog::cachePageTree(int page) if (pagesList->empty()) return gFalse; - pagesDict = pagesList->back(); - Object kids; - pagesDict->lookup("Kids", &kids); + Object pagesDict = pagesList->back().copy(); + Object kids = pagesDict.dictLookup("Kids"); if (!kids.isArray()) { error(errSyntaxError, -1, "Kids object (page {0:d}) is wrong type ({1:s})", lastCachedPage+1, kids.getTypeName()); - kids.free(); return gFalse; } int kidsIdx = kidsIdxList->back(); if (kidsIdx >= kids.arrayGetLength()) { - if (!pagesList->back()->decRef()) { - delete pagesList->back(); - } pagesList->pop_back(); pagesRefList->pop_back(); delete attrsList->back(); attrsList->pop_back(); kidsIdxList->pop_back(); if (!kidsIdxList->empty()) kidsIdxList->back()++; - kids.free(); continue; } - Object kidRef; - kids.arrayGetNF(kidsIdx, &kidRef); + Object kidRef = kids.arrayGetNF(kidsIdx); if (!kidRef.isRef()) { error(errSyntaxError, -1, "Kid object (page {0:d}) is not an indirect reference ({1:s})", lastCachedPage+1, kidRef.getTypeName()); - kidRef.free(); - kids.free(); return gFalse; } @@ -383,31 +326,23 @@ GBool Catalog::cachePageTree(int page) } if (loop) { error(errSyntaxError, -1, "Loop in Pages tree"); - kidRef.free(); - kids.free(); kidsIdxList->back()++; continue; } - Object kid; - kids.arrayGet(kidsIdx, &kid); - kids.free(); + Object kid = kids.arrayGet(kidsIdx); if (kid.isDict("Page") || (kid.isDict() && !kid.getDict()->hasKey("Kids"))) { PageAttrs *attrs = new PageAttrs(attrsList->back(), kid.getDict()); - Page *p = new Page(doc, lastCachedPage+1, kid.getDict(), + Page *p = new Page(doc, lastCachedPage+1, &kid, kidRef.getRef(), attrs, form); if (!p->isOk()) { error(errSyntaxError, -1, "Failed to create page (page {0:d})", lastCachedPage+1); delete p; - kidRef.free(); - kid.free(); return gFalse; } if (lastCachedPage >= numPages) { error(errSyntaxError, -1, "Page count in top-level pages object is incorrect"); - kidRef.free(); - kid.free(); return gFalse; } @@ -423,17 +358,13 @@ GBool Catalog::cachePageTree(int page) } else if (kid.isDict()) { attrsList->push_back(new PageAttrs(attrsList->back(), kid.getDict())); pagesRefList->push_back(kidRef.getRef()); - kid.getDict()->incRef(); - pagesList->push_back(kid.getDict()); + pagesList->push_back(std::move(kid)); kidsIdxList->push_back(0); } else { error(errSyntaxError, -1, "Kid object (page {0:d}) is wrong type ({1:s})", lastCachedPage+1, kid.getTypeName()); kidsIdxList->back()++; } - kidRef.free(); - kid.free(); - } return gFalse; @@ -451,48 +382,28 @@ int Catalog::findPage(int num, int gen) { } LinkDest *Catalog::findDest(GooString *name) { - LinkDest *dest; - Object obj1; - GBool found; - // try named destination dictionary then name tree - found = gFalse; if (getDests()->isDict()) { - if (!getDests()->dictLookup(name->getCString(), &obj1)->isNull()) - found = gTrue; - else - obj1.free(); - } - if (!found) { - catalogLocker(); - if (getDestNameTree()->lookup(name, &obj1)) - found = gTrue; - else - obj1.free(); + Object obj1 = getDests()->dictLookup(name->getCString()); + return createLinkDest(&obj1); } - if (!found) - return NULL; - - dest = createLinkDest(&obj1); - obj1.free(); - return dest; + catalogLocker(); + Object obj2 = getDestNameTree()->lookup(name); + return createLinkDest(&obj2); } LinkDest *Catalog::createLinkDest(Object *obj) { - LinkDest *dest; - Object obj2; - - dest = NULL; + LinkDest *dest = nullptr; if (obj->isArray()) { dest = new LinkDest(obj->getArray()); } else if (obj->isDict()) { - if (obj->dictLookup("D", &obj2)->isArray()) + Object obj2 = obj->dictLookup("D"); + if (obj2.isArray()) dest = new LinkDest(obj2.getArray()); else error(errSyntaxWarning, -1, "Bad named destination value"); - obj2.free(); } else { error(errSyntaxWarning, -1, "Bad named destination value"); } @@ -528,46 +439,37 @@ char *Catalog::getDestsName(int i) LinkDest *Catalog::getDestsDest(int i) { - LinkDest *dest; - Object *obj, obj1; - - obj= getDests(); + Object *obj = getDests(); if (!obj->isDict()) { return NULL; } - obj->dictGetVal(i, &obj1); - dest = createLinkDest(&obj1); - obj1.free(); - - return dest; + Object obj1 = obj->dictGetVal(i); + return createLinkDest(&obj1); } LinkDest *Catalog::getDestNameTreeDest(int i) { - LinkDest *dest; Object obj; catalogLocker(); - getDestNameTree()->getValue(i).fetch(xref, &obj); - dest = createLinkDest(&obj); - obj.free(); - - return dest; + Object *aux = getDestNameTree()->getValue(i); + if (aux) { + obj = aux->fetch(xref); + } + return createLinkDest(&obj); } FileSpec *Catalog::embeddedFile(int i) { Object efDict; - Object obj; catalogLocker(); - obj = getEmbeddedFileNameTree()->getValue(i); + Object *obj = getEmbeddedFileNameTree()->getValue(i); FileSpec *embeddedFile = 0; - if (obj.isRef()) { - Object fsDict; - embeddedFile = new FileSpec(obj.fetch(xref, &fsDict)); - fsDict.free(); - } else if (obj.isDict()) { - embeddedFile = new FileSpec(&obj); + if (obj->isRef()) { + Object fsDict = obj->fetch(xref); + embeddedFile = new FileSpec(&fsDict); + } else if (obj->isDict()) { + embeddedFile = new FileSpec(obj); } else { Object null; embeddedFile = new FileSpec(&null); @@ -581,26 +483,23 @@ GooString *Catalog::getJS(int i) // getJSNameTree()->getValue(i) returns a shallow copy of the object so we // do not need to free it catalogLocker(); - getJSNameTree()->getValue(i).fetch(xref, &obj); + Object *aux = getJSNameTree()->getValue(i); + if (aux) { + obj = aux->fetch(xref); + } if (!obj.isDict()) { - obj.free(); - return 0; + return nullptr; } - Object obj2; - if (!obj.dictLookup("S", &obj2)->isName()) { - obj2.free(); - obj.free(); - return 0; + Object obj2 = obj.dictLookup("S"); + if (!obj2.isName()) { + return nullptr; } if (strcmp(obj2.getName(), "JavaScript")) { - obj2.free(); - obj.free(); - return 0; + return nullptr; } - obj2.free(); - obj.dictLookup("JS", &obj2); - GooString *js = 0; + obj2 = obj.dictLookup("JS"); + GooString *js = nullptr; if (obj2.isString()) { js = new GooString(obj2.getString()); } @@ -609,8 +508,6 @@ GooString *Catalog::getJS(int i) js = new GooString(); stream->fillGooString(js); } - obj2.free(); - obj.free(); return js; } @@ -619,18 +516,16 @@ Catalog::PageMode Catalog::getPageMode() { catalogLocker(); if (pageMode == pageModeNull) { - Object catDict, obj; - pageMode = pageModeNone; - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (!catDict.isDict()) { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - catDict.free(); return pageMode; } - if (catDict.dictLookup("PageMode", &obj)->isName()) { + Object obj = catDict.dictLookup("PageMode"); + if (obj.isName()) { if (obj.isName("UseNone")) pageMode = pageModeNone; else if (obj.isName("UseOutlines")) @@ -644,8 +539,6 @@ Catalog::PageMode Catalog::getPageMode() { else if (obj.isName("UseAttachments")) pageMode = pageModeAttach; } - obj.free(); - catDict.free(); } return pageMode; } @@ -655,19 +548,17 @@ Catalog::PageLayout Catalog::getPageLayout() { catalogLocker(); if (pageLayout == pageLayoutNull) { - Object catDict, obj; - pageLayout = pageLayoutNone; - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (!catDict.isDict()) { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - catDict.free(); return pageLayout; } pageLayout = pageLayoutNone; - if (catDict.dictLookup("PageLayout", &obj)->isName()) { + Object obj = catDict.dictLookup("PageLayout"); + if (obj.isName()) { if (obj.isName("SinglePage")) pageLayout = pageLayoutSinglePage; if (obj.isName("OneColumn")) @@ -681,8 +572,6 @@ Catalog::PageLayout Catalog::getPageLayout() { if (obj.isName("TwoPageRight")) pageLayout = pageLayoutTwoPageRight; } - obj.free(); - catDict.free(); } return pageLayout; } @@ -705,20 +594,19 @@ NameTree::~NameTree() } NameTree::Entry::Entry(Array *array, int index) { - if (!array->getString(index, &name) || !array->getNF(index + 1, &value)) { - Object aux; - array->get(index, &aux); - if (aux.isString() && array->getNF(index + 1, &value) ) - { - name.append(aux.getString()); - } - else - error(errSyntaxError, -1, "Invalid page tree"); + if (!array->getString(index, &name)) { + Object aux = array->get(index); + if (aux.isString()) + { + name.append(aux.getString()); } + else + error(errSyntaxError, -1, "Invalid page tree"); + } + value = array->getNF(index + 1); } NameTree::Entry::~Entry() { - value.free(); } void NameTree::addEntry(Entry *entry) @@ -746,40 +634,46 @@ int NameTree::Entry::cmpEntry(const void *voidEntry, const void *voidOtherEntry) void NameTree::init(XRef *xrefA, Object *tree) { xref = xrefA; - parse(tree); + std::set<int> seen; + parse(tree, seen); if (entries && length > 0) { qsort(entries, length, sizeof(Entry *), Entry::cmpEntry); } } -void NameTree::parse(Object *tree) { - Object names; - Object kids, kid; - int i; - +void NameTree::parse(Object *tree, std::set<int> &seen) { if (!tree->isDict()) return; // leaf node - if (tree->dictLookup("Names", &names)->isArray()) { - for (i = 0; i < names.arrayGetLength(); i += 2) { + Object names = tree->dictLookup("Names"); + if (names.isArray()) { + for (int i = 0; i < names.arrayGetLength(); i += 2) { NameTree::Entry *entry; entry = new Entry(names.getArray(), i); addEntry(entry); } } - names.free(); // root or intermediate node - if (tree->dictLookup("Kids", &kids)->isArray()) { - for (i = 0; i < kids.arrayGetLength(); ++i) { - if (kids.arrayGet(i, &kid)->isDict()) - parse(&kid); - kid.free(); + Object kids = tree->dictLookup("Kids"); + if (kids.isArray()) { + for (int i = 0; i < kids.arrayGetLength(); ++i) { + Object kidRef = kids.arrayGetNF(i); + if (kidRef.isRef()) { + const int numObj = kidRef.getRef().num; + if (seen.find(numObj) != seen.end()) { + error(errSyntaxError, -1, "loop in NameTree (numObj: {0:d})", numObj); + continue; + } + seen.insert(numObj); + } + Object kid = kids.arrayGet(i); + if (kid.isDict()) + parse(&kid, seen); } } - kids.free(); } int NameTree::Entry::cmp(const void *voidKey, const void *voidEntry) @@ -790,28 +684,26 @@ int NameTree::Entry::cmp(const void *voidKey, const void *voidEntry) return key->cmp(&entry->name); } -GBool NameTree::lookup(GooString *name, Object *obj) +Object NameTree::lookup(GooString *name) { Entry **entry; entry = (Entry **) bsearch(name, entries, length, sizeof(Entry *), Entry::cmp); if (entry != NULL) { - (*entry)->value.fetch(xref, obj); - return gTrue; + return (*entry)->value.fetch(xref); } else { error(errSyntaxError, -1, "failed to look up ({0:s})", name->getCString()); - obj->initNull(); - return gFalse; + return Object(objNull); } } -Object NameTree::getValue(int index) +Object *NameTree::getValue(int index) { if (index < length) { - return entries[index]->value; + return &entries[index]->value; } else { - return Object(); + return nullptr; } } @@ -866,39 +758,33 @@ int Catalog::getNumPages() catalogLocker(); if (numPages == -1) { - Object catDict, pagesDict, obj; - - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (!catDict.isDict()) { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - catDict.free(); return 0; } - catDict.dictLookup("Pages", &pagesDict); + Object pagesDict = catDict.dictLookup("Pages"); // This should really be isDict("Pages"), but I've seen at least one // PDF file where the /Type entry is missing. if (!pagesDict.isDict()) { error(errSyntaxError, -1, "Top-level pages object is wrong type ({0:s})", pagesDict.getTypeName()); - pagesDict.free(); - catDict.free(); return 0; } - pagesDict.dictLookup("Count", &obj); + Object obj = pagesDict.dictLookup("Count"); // some PDF files actually use real numbers here ("/Count 9.0") if (!obj.isNum()) { if (pagesDict.dictIs("Page")) { - Object pageRootRef; - catDict.dictLookupNF("Pages", &pageRootRef); + Object pageRootRef = catDict.dictLookupNF("Pages"); error(errSyntaxError, -1, "Pages top-level is a single Page. The document is malformed, trying to recover..."); Dict *pageDict = pagesDict.getDict(); if (pageRootRef.isRef()) { const Ref pageRef = pageRootRef.getRef(); - Page *p = new Page(doc, 1, pageDict, pageRef, new PageAttrs(NULL, pageDict), form); + Page *p = new Page(doc, 1, &pagesDict, pageRef, new PageAttrs(NULL, pageDict), form); if (p->isOk()) { pages = (Page **)gmallocn(1, sizeof(Page *)); pageRefs = (Ref *)gmallocn(1, sizeof(Ref)); @@ -936,10 +822,6 @@ int Catalog::getNumPages() } } - - catDict.free(); - obj.free(); - pagesDict.free(); } return numPages; @@ -949,21 +831,16 @@ PageLabelInfo *Catalog::getPageLabelInfo() { catalogLocker(); if (!pageLabelInfo) { - Object catDict; - Object obj; - - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (!catDict.isDict()) { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - catDict.free(); - return NULL; + return nullptr; } - if (catDict.dictLookup("PageLabels", &obj)->isDict()) { + Object obj = catDict.dictLookup("PageLabels"); + if (obj.isDict()) { pageLabelInfo = new PageLabelInfo(&obj, getNumPages()); } - obj.free(); - catDict.free(); } return pageLabelInfo; @@ -973,22 +850,16 @@ StructTreeRoot *Catalog::getStructTreeRoot() { catalogLocker(); if (!structTreeRoot) { - Object catalog; - Object root; - - xref->getCatalog(&catalog); + Object catalog = xref->getCatalog(); if (!catalog.isDict()) { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catalog.getTypeName()); - catalog.free(); return NULL; } - if (catalog.dictLookup("StructTreeRoot", &root)->isDict("StructTreeRoot")) { + Object root = catalog.dictLookup("StructTreeRoot"); + if (root.isDict("StructTreeRoot")) { structTreeRoot = new StructTreeRoot(doc, root.getDict()); } - - root.free(); - catalog.free(); } return structTreeRoot; } @@ -998,41 +869,35 @@ Guint Catalog::getMarkInfo() if (markInfo == markInfoNull) { markInfo = 0; - Object catDict; catalogLocker(); - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (catDict.isDict()) { - Object markInfoDict; - catDict.dictLookup("MarkInfo", &markInfoDict); + Object markInfoDict = catDict.dictLookup("MarkInfo"); if (markInfoDict.isDict()) { - Object value; - - if (markInfoDict.dictLookup("Marked", &value)->isBool() && value.getBool()) + Object value = markInfoDict.dictLookup("Marked"); + if (value.isBool() && value.getBool()) markInfo |= markInfoMarked; else if (!value.isNull()) error(errSyntaxError, -1, "Marked object is wrong type ({0:s})", value.getTypeName()); - value.free(); - if (markInfoDict.dictLookup("Suspects", &value)->isBool() && value.getBool()) + value = markInfoDict.dictLookup("Suspects"); + if (value.isBool() && value.getBool()) markInfo |= markInfoSuspects; else if (!value.isNull()) error(errSyntaxError, -1, "Suspects object is wrong type ({0:s})", value.getTypeName()); - value.free(); - if (markInfoDict.dictLookup("UserProperties", &value)->isBool() && value.getBool()) + value = markInfoDict.dictLookup("UserProperties"); + if (value.isBool() && value.getBool()) markInfo |= markInfoUserProperties; else if (!value.isNull()) error(errSyntaxError, -1, "UserProperties object is wrong type ({0:s})", value.getTypeName()); - value.free(); } else if (!markInfoDict.isNull()) { error(errSyntaxError, -1, "MarkInfo object is wrong type ({0:s})", markInfoDict.getTypeName()); } - markInfoDict.free(); } else { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); } - catDict.free(); } return markInfo; } @@ -1042,16 +907,13 @@ Object *Catalog::getOutline() catalogLocker(); if (outline.isNone()) { - Object catDict; - - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (catDict.isDict()) { - catDict.dictLookup("Outlines", &outline); + outline = catDict.dictLookup("Outlines"); } else { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - outline.initNull(); + outline.setToNull(); } - catDict.free(); } return &outline; @@ -1062,16 +924,13 @@ Object *Catalog::getDests() catalogLocker(); if (dests.isNone()) { - Object catDict; - - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (catDict.isDict()) { - catDict.dictLookup("Dests", &dests); + dests = catDict.dictLookup("Dests"); } else { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - dests.initNull(); + dests.setToNull(); } - catDict.free(); } return &dests; @@ -1083,13 +942,12 @@ Catalog::FormType Catalog::getFormType() FormType res = NoForm; if (acroForm.isDict()) { - acroForm.dictLookup("XFA", &xfa); + xfa = acroForm.dictLookup("XFA"); if (xfa.isStream() || xfa.isArray()) { res = XfaForm; } else { res = AcroForm; } - xfa.free(); } return res; @@ -1125,16 +983,13 @@ Object *Catalog::getNames() { if (names.isNone()) { - Object catDict; - - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (catDict.isDict()) { - catDict.dictLookup("Names", &names); + names = catDict.dictLookup("Names"); } else { error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName()); - names.initNull(); + names.setToNull(); } - catDict.free(); } return &names; @@ -1147,11 +1002,8 @@ NameTree *Catalog::getDestNameTree() destNameTree = new NameTree(); if (getNames()->isDict()) { - Object obj; - - getNames()->dictLookup("Dests", &obj); + Object obj = getNames()->dictLookup("Dests"); destNameTree->init(xref, &obj); - obj.free(); } } @@ -1166,11 +1018,8 @@ NameTree *Catalog::getEmbeddedFileNameTree() embeddedFileNameTree = new NameTree(); if (getNames()->isDict()) { - Object obj; - - getNames()->dictLookup("EmbeddedFiles", &obj); + Object obj = getNames()->dictLookup("EmbeddedFiles"); embeddedFileNameTree->init(xref, &obj); - obj.free(); } } @@ -1185,11 +1034,8 @@ NameTree *Catalog::getJSNameTree() jsNameTree = new NameTree(); if (getNames()->isDict()) { - Object obj; - - getNames()->dictLookup("JavaScript", &obj); + Object obj = getNames()->dictLookup("JavaScript"); jsNameTree->init(xref, &obj); - obj.free(); } } @@ -1198,24 +1044,18 @@ NameTree *Catalog::getJSNameTree() } LinkAction* Catalog::getAdditionalAction(DocumentAdditionalActionsType type) { - Object additionalActionsObject; - LinkAction *linkAction = NULL; - - if (additionalActions.fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { + LinkAction *linkAction = nullptr; + Object additionalActionsObject = additionalActions.fetch(doc->getXRef()); + if (additionalActionsObject.isDict()) { const char *key = (type == actionCloseDocument ? "WC" : type == actionSaveDocumentStart ? "WS" : type == actionSaveDocumentFinish ? "DS" : type == actionPrintDocumentStart ? "WP" : type == actionPrintDocumentFinish ? "DP" : NULL); - Object actionObject; - - if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) + Object actionObject = additionalActionsObject.dictLookup(key); + if (actionObject.isDict()) linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); - actionObject.free(); } - - additionalActionsObject.free(); - return linkAction; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Catalog.h b/Build/source/libs/poppler/poppler-src/poppler/Catalog.h index 81b0e125c6d..a2dd7fded48 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Catalog.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Catalog.h @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005, 2007, 2009-2011, 2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2007, 2009-2011, 2013, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> // Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net> // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> @@ -23,7 +23,7 @@ // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> // Copyright (C) 2016 Masamichi Hosoda <trueroad@trueroad.jp> // @@ -69,10 +69,10 @@ public: NameTree(); ~NameTree(); void init(XRef *xref, Object *tree); - GBool lookup(GooString *name, Object *obj); + Object lookup(GooString *name); int numEntries() { return length; }; - // iterator accessor, note it returns a shallow copy, do not free the object - Object getValue(int i); + // iterator accessor, note it returns a pointer to the internal object, do not free nor delete it + Object *getValue(int i); GooString *getName(int i); private: @@ -86,7 +86,7 @@ private: static int cmp(const void *key, const void *entry); }; - void parse(Object *tree); + void parse(Object *tree, std::set<int> &seen); void addEntry(Entry *entry); XRef *xref; @@ -248,7 +248,7 @@ private: Page **pages; // array of pages Ref *pageRefs; // object ID for each page int lastCachedPage; - std::vector<Dict *> *pagesList; + std::vector<Object> *pagesList; std::vector<Ref> *pagesRefList; std::vector<PageAttrs *> *attrsList; std::vector<int> *kidsIdxList; @@ -283,7 +283,7 @@ private: NameTree *getEmbeddedFileNameTree(); NameTree *getJSNameTree(); LinkDest *createLinkDest(Object *obj); -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc index fdb787d6470..abf5d51c8fc 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.cc @@ -21,9 +21,10 @@ // Copyright (C) 2010 William Bader <williambader@hotmail.com> // Copyright (C) 2010 Jakub Wilk <jwilk@jwilk.net> // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2014 Jiri Slaby <jirislaby@gmail.com> // Copyright (C) 2015 Marek Kasik <mkasik@redhat.com> +// Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr> // // 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 @@ -38,6 +39,7 @@ #include <stdio.h> #include <string.h> +#include "goo/glibc.h" #include "goo/gmem.h" #include "goo/gfile.h" #include "goo/GooLikely.h" @@ -484,7 +486,7 @@ CharCodeToUnicode::CharCodeToUnicode() { sMapLen = sMapSize = 0; refCnt = 1; isIdentity = gFalse; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -502,7 +504,7 @@ CharCodeToUnicode::CharCodeToUnicode(GooString *tagA) { sMapLen = sMapSize = 0; refCnt = 1; isIdentity = gFalse; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -524,7 +526,7 @@ CharCodeToUnicode::CharCodeToUnicode(GooString *tagA, Unicode *mapA, sMapSize = sMapSizeA; refCnt = 1; isIdentity = gFalse; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -538,17 +540,17 @@ CharCodeToUnicode::~CharCodeToUnicode() { for (int i = 0; i < sMapLen; ++i) gfree(sMap[i].u); gfree(sMap); } -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } void CharCodeToUnicode::incRefCnt() { -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif ++refCnt; -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif } @@ -556,11 +558,11 @@ void CharCodeToUnicode::incRefCnt() { void CharCodeToUnicode::decRefCnt() { GBool done; -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif done = --refCnt == 0; -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif if (done) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h index 1672105a8f4..e2b12ae3dd6 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h +++ b/Build/source/libs/poppler/poppler-src/poppler/CharCodeToUnicode.h @@ -18,6 +18,7 @@ // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2007 Koji Otani <sho@bbr.jp> // Copyright (C) 2008, 2011, 2012 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -35,7 +36,7 @@ #include "CharTypes.h" #include "goo/gtypes.h" -#if MULTITHREADED +#ifdef MULTITHREADED #include "goo/GooMutex.h" #endif @@ -116,7 +117,7 @@ private: int sMapLen, sMapSize; int refCnt; GBool isIdentity; -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/CurlCachedFile.h b/Build/source/libs/poppler/poppler-src/poppler/CurlCachedFile.h index 49882aba8ac..80e69727a48 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CurlCachedFile.h +++ b/Build/source/libs/poppler/poppler-src/poppler/CurlCachedFile.h @@ -25,8 +25,8 @@ public: CurlCachedFileLoader(); ~CurlCachedFileLoader(); - size_t init(GooString *url, CachedFile* cachedFile); - int load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer); + size_t init(GooString *url, CachedFile* cachedFile) override; + int load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer) override; private: diff --git a/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc b/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc index 5b02b14a784..4dae58e7e3d 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2010 Hib Eris <hib@hiberis.nl> -// Copyright 2010 Albert Astals Cid <aacid@kde.org> +// Copyright 2010, 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -15,6 +15,7 @@ #include "CachedFile.h" #include "CurlCachedFile.h" +#include "ErrorCodes.h" //------------------------------------------------------------------------ // CurlPDFDocBuilder @@ -24,14 +25,16 @@ PDFDoc * CurlPDFDocBuilder::buildPDFDoc(const GooString &uri, GooString *ownerPassword, GooString *userPassword, void *guiDataA) { - Object obj; - CachedFile *cachedFile = new CachedFile( new CurlCachedFileLoader(), uri.copy()); - obj.initNull(); + if (cachedFile->getLength() == ((Guint) -1)) { + cachedFile->decRefCnt(); + return PDFDoc::ErrorPDFDoc(errOpenFile, uri.copy()); + } + BaseStream *str = new CachedFileStream( - cachedFile, 0, gFalse, cachedFile->getLength(), &obj); + cachedFile, 0, gFalse, cachedFile->getLength(), Object(objNull)); return new PDFDoc(str, ownerPassword, userPassword, guiDataA); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.h b/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.h index fb34862057c..43b442db25e 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.h +++ b/Build/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.h @@ -25,8 +25,8 @@ class CurlPDFDocBuilder : public PDFDocBuilder { public: PDFDoc *buildPDFDoc(const GooString &uri, GooString *ownerPassword = NULL, - GooString *userPassword = NULL, void *guiDataA = NULL); - GBool supports(const GooString &uri); + GooString *userPassword = NULL, void *guiDataA = NULL) override; + GBool supports(const GooString &uri) override; }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/DCTStream.cc b/Build/source/libs/poppler/poppler-src/poppler/DCTStream.cc index bfdb0eaf80a..7a4d5930ade 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/DCTStream.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/DCTStream.cc @@ -5,12 +5,13 @@ // This file is licensed under the GPLv2 or later // // Copyright 2005 Jeff Muizelaar <jeff@infidigm.net> -// Copyright 2005-2010, 2012 Albert Astals Cid <aacid@kde.org> +// Copyright 2005-2010, 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright 2009 Ryszard Trojnacki <rysiek@menel.com> // Copyright 2010 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright 2011 Daiki Ueno <ueno@unixuser.org> // Copyright 2011 Tomas Hoger <thoger@redhat.com> // Copyright 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright 2017 Adrian Johnson <ajohnson@redneon.com> // //======================================================================== @@ -60,18 +61,14 @@ static void str_term_source(j_decompress_ptr cinfo) { } -DCTStream::DCTStream(Stream *strA, int colorXformA, Object *dict, int recursion) : +DCTStream::DCTStream(Stream *strA, int colorXformA, Dict *dict, int recursion) : FilterStream(strA) { colorXform = colorXformA; if (dict != NULL) { - Object obj; - - dict->dictLookup("Width", &obj, recursion); + Object obj = dict->lookup("Width", recursion); err.width = (obj.isInt() && obj.getInt() <= JPEG_MAX_DIMENSION) ? obj.getInt() : 0; - obj.free(); - dict->dictLookup("Height", &obj, recursion); + obj = dict->lookup("Height", recursion); err.height = (obj.isInt() && obj.getInt() <= JPEG_MAX_DIMENSION) ? obj.getInt() : 0; - obj.free(); } else err.height = err.width = 0; init(); @@ -232,8 +229,10 @@ int DCTStream::getChar() { } int DCTStream::getChars(int nChars, Guchar *buffer) { - int c; - for (int i = 0; i < nChars; ++i) { + // Use volatile to prevent the compiler optimizing + // variables into registers. See setjmp man page. + volatile int i, c; + for (i = 0; i < nChars; ++i) { DO_GET_CHAR if (likely(c != EOF)) buffer[i] = c; else return i; diff --git a/Build/source/libs/poppler/poppler-src/poppler/DCTStream.h b/Build/source/libs/poppler/poppler-src/poppler/DCTStream.h index bc20a7aaab6..00e0484c861 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/DCTStream.h +++ b/Build/source/libs/poppler/poppler-src/poppler/DCTStream.h @@ -6,7 +6,7 @@ // // Copyright 2005 Jeff Muizelaar <jeff@infidigm.net> // Copyright 2005 Martin Kretzschmar <martink@gnome.org> -// Copyright 2005-2007, 2009-2011 Albert Astals Cid <aacid@kde.org> +// Copyright 2005-2007, 2009-2011, 2017 Albert Astals Cid <aacid@kde.org> // Copyright 2010 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright 2011 Daiki Ueno <ueno@unixuser.org> // Copyright 2013 Thomas Freitag <Thomas.Freitag@alfa.de> @@ -64,20 +64,20 @@ struct str_error_mgr { class DCTStream: public FilterStream { public: - DCTStream(Stream *strA, int colorXformA, Object *dict, int recursion); - virtual ~DCTStream(); - virtual StreamKind getKind() { return strDCT; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + DCTStream(Stream *strA, int colorXformA, Dict *dict, int recursion); + ~DCTStream(); + StreamKind getKind() override { return strDCT; } + void reset() override; + int getChar() override; + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; private: void init(); - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; int colorXform; JSAMPLE *current; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Decrypt.cc b/Build/source/libs/poppler/poppler-src/poppler/Decrypt.cc index c8246fab76d..db755812713 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Decrypt.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Decrypt.cc @@ -14,11 +14,11 @@ // under GPL version 2 or later // // Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net> -// Copyright (C) 2008, 2010, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2010, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Matthias Franz <matthias@ktug.or.kr> // Copyright (C) 2009 David Benjamin <davidben@mit.edu> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2016 Alok Anand <alok4nand@gmail.com> // Copyright (C) 2016 Thomas Freitag <Thomas.Freitag@alfa.de> // @@ -33,10 +33,10 @@ #pragma implementation #endif +#include <cstdint> #include <string.h> #include "goo/gmem.h" #include "goo/grandom.h" -#include "goo/gtypes_p.h" #include "Decrypt.h" #include "Error.h" @@ -1345,7 +1345,7 @@ static inline Guint sha256sigma1(Guint x) { return rotr(x, 17) ^ rotr(x, 19) ^ (x >> 10); } -void sha256HashBlock(Guchar *blk, Guint *H) { +static void sha256HashBlock(Guchar *blk, Guint *H) { Guint W[64]; Guint a, b, c, d, e, f, g, h; Guint T1, T2; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Decrypt.h b/Build/source/libs/poppler/poppler-src/poppler/Decrypt.h index 10a6386c6b5..61b0b453a24 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Decrypt.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Decrypt.h @@ -105,14 +105,14 @@ public: BaseCryptStream(Stream *strA, Guchar *fileKey, CryptAlgorithm algoA, int keyLength, int objNum, int objGen); - virtual ~BaseCryptStream(); - virtual StreamKind getKind() { return strCrypt; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar() = 0; - virtual Goffset getPos(); - virtual GBool isBinary(GBool last); - virtual Stream *getUndecodedStream() { return this; } + ~BaseCryptStream(); + StreamKind getKind() override { return strCrypt; } + void reset() override; + int getChar() override; + int lookChar() override = 0; + Goffset getPos() override; + GBool isBinary(GBool last) override; + Stream *getUndecodedStream() override { return this; } void setAutoDelete(GBool val); protected: @@ -140,8 +140,8 @@ public: EncryptStream(Stream *strA, Guchar *fileKey, CryptAlgorithm algoA, int keyLength, int objNum, int objGen); ~EncryptStream(); - virtual void reset(); - virtual int lookChar(); + void reset() override; + int lookChar() override; }; class DecryptStream : public BaseCryptStream { @@ -150,8 +150,8 @@ public: DecryptStream(Stream *strA, Guchar *fileKey, CryptAlgorithm algoA, int keyLength, int objNum, int objGen); ~DecryptStream(); - virtual void reset(); - virtual int lookChar(); + void reset() override; + int lookChar() override; }; //------------------------------------------------------------------------ diff --git a/Build/source/libs/poppler/poppler-src/poppler/Dict.cc b/Build/source/libs/poppler/poppler-src/poppler/Dict.cc index c2a94f4a1fa..89814708859 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Dict.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Dict.cc @@ -16,11 +16,12 @@ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org> -// Copyright (C) 2008, 2010, 2013, 2014 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2010, 2013, 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 PaweÅ‚ Wiejacha <pawel.wiejacha@gmail.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2014 Scott West <scott.gregory.west@gmail.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -41,7 +42,7 @@ #include "XRef.h" #include "Dict.h" -#if MULTITHREADED +#ifdef MULTITHREADED # define dictLocker() MutexLocker locker(&mutex) #else # define dictLocker() @@ -81,7 +82,7 @@ Dict::Dict(XRef *xrefA) { size = length = 0; ref = 1; sorted = gFalse; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -90,7 +91,7 @@ Dict::Dict(Dict* dictA) { xref = dictA->xref; size = length = dictA->length; ref = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif @@ -98,7 +99,8 @@ Dict::Dict(Dict* dictA) { entries = (DictEntry *)gmallocn(size, sizeof(DictEntry)); for (int i=0; i<length; i++) { entries[i].key = copyString(dictA->entries[i].key); - dictA->entries[i].val.copy(&entries[i].val); + entries[i].val.initNullAfterMalloc(); + entries[i].val = dictA->entries[i].val.copy(); } } @@ -108,12 +110,8 @@ Dict *Dict::copy(XRef *xrefA) { dictA->xref = xrefA; for (int i=0; i<length; i++) { if (dictA->entries[i].val.getType() == objDict) { - Dict *dict = dictA->entries[i].val.getDict(); - Object obj; - obj.initDict(dict->copy(xrefA)); - dictA->entries[i].val.free(); - dictA->entries[i].val = obj; - obj.free(); + Dict *copy = dictA->entries[i].val.getDict()->copy(xrefA); + dictA->entries[i].val = Object(copy); } } return dictA; @@ -127,7 +125,7 @@ Dict::~Dict() { entries[i].val.free(); } gfree(entries); -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } @@ -144,7 +142,7 @@ int Dict::decRef() { return ref; } -void Dict::add(char *key, Object *val) { +void Dict::add(char *key, Object &&val) { dictLocker(); if (sorted) { // We use add on very few occasions so @@ -161,11 +159,12 @@ void Dict::add(char *key, Object *val) { entries = (DictEntry *)greallocn(entries, size, sizeof(DictEntry)); } entries[length].key = key; - entries[length].val = *val; + entries[length].val.initNullAfterMalloc(); + entries[length].val = std::move(val); ++length; } -inline DictEntry *Dict::find(const char *key) { +inline DictEntry *Dict::find(const char *key) const { if (!sorted && length >= SORT_LENGTH_LOWER_LIMIT) { dictLocker(); @@ -189,7 +188,7 @@ inline DictEntry *Dict::find(const char *key) { return NULL; } -GBool Dict::hasKey(const char *key) { +GBool Dict::hasKey(const char *key) const { return find(key) != NULL; } @@ -208,7 +207,6 @@ void Dict::remove(const char *key) { } else { int i; bool found = false; - DictEntry tmp; if(length == 0) { return; } @@ -226,56 +224,55 @@ void Dict::remove(const char *key) { gfree(entries[i].key); entries[i].val.free(); length -= 1; - tmp = entries[length]; - if (i!=length) //don't copy the last entry if it is deleted - entries[i] = tmp; + if (i!=length) { + //don't copy the last entry if it is deleted + entries[i].key = entries[length].key; + entries[i].val = std::move(entries[length].val); + } } } -void Dict::set(const char *key, Object *val) { +void Dict::set(const char *key, Object &&val) { DictEntry *e; - if (val->isNull()) { + if (val.isNull()) { remove(key); return; } e = find (key); if (e) { dictLocker(); - e->val.free(); - e->val = *val; + e->val = std::move(val); } else { - add (copyString(key), val); + add (copyString(key), std::move(val)); } } -GBool Dict::is(const char *type) { +GBool Dict::is(const char *type) const { DictEntry *e; return (e = find("Type")) && e->val.isName(type); } -Object *Dict::lookup(const char *key, Object *obj, int recursion) { +Object Dict::lookup(const char *key, int recursion) const { DictEntry *e; - return (e = find(key)) ? e->val.fetch(xref, obj, recursion) : obj->initNull(); + return (e = find(key)) ? e->val.fetch(xref, recursion) : Object(objNull); } -Object *Dict::lookupNF(const char *key, Object *obj) { +Object Dict::lookupNF(const char *key) const { DictEntry *e; - return (e = find(key)) ? e->val.copy(obj) : obj->initNull(); + return (e = find(key)) ? e->val.copy() : Object(objNull); } -GBool Dict::lookupInt(const char *key, const char *alt_key, int *value) +GBool Dict::lookupInt(const char *key, const char *alt_key, int *value) const { - Object obj1; GBool success = gFalse; - - lookup ((char *) key, &obj1); + Object obj1 = lookup ((char *) key); if (obj1.isNull () && alt_key != NULL) { obj1.free (); - lookup ((char *) alt_key, &obj1); + obj1 = lookup ((char *) alt_key); } if (obj1.isInt ()) { *value = obj1.getInt (); @@ -287,14 +284,14 @@ GBool Dict::lookupInt(const char *key, const char *alt_key, int *value) return success; } -char *Dict::getKey(int i) { +char *Dict::getKey(int i) const { return entries[i].key; } -Object *Dict::getVal(int i, Object *obj) { - return entries[i].val.fetch(xref, obj); +Object Dict::getVal(int i) const { + return entries[i].val.fetch(xref); } -Object *Dict::getValNF(int i, Object *obj) { - return entries[i].val.copy(obj); +Object Dict::getValNF(int i) const { + return entries[i].val.copy(); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Dict.h b/Build/source/libs/poppler/poppler-src/poppler/Dict.h index fba99edc513..328f422c8e6 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Dict.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Dict.h @@ -16,9 +16,10 @@ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org> -// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 PaweÅ‚ Wiejacha <pawel.wiejacha@gmail.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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,57 +57,60 @@ public: // Destructor. ~Dict(); - // Reference counting. - int incRef(); - int decRef(); - // Get number of entries. - int getLength() { return length; } + int getLength() const { return length; } // Add an entry. NB: does not copy key. - void add(char *key, Object *val); + // val becomes a dead object after the call + void add(char *key, Object &&val); // Update the value of an existing entry, otherwise create it - void set(const char *key, Object *val); + // val becomes a dead object after the call + void set(const char *key, Object &&val); // Remove an entry. This invalidate indexes void remove(const char *key); // Check if dictionary is of specified type. - GBool is(const char *type); + GBool is(const char *type) const; // Look up an entry and return the value. Returns a null object // if <key> is not in the dictionary. - Object *lookup(const char *key, Object *obj, int recursion = 0); - Object *lookupNF(const char *key, Object *obj); - GBool lookupInt(const char *key, const char *alt_key, int *value); + Object lookup(const char *key, int recursion = 0) const; + Object lookupNF(const char *key) const; + GBool lookupInt(const char *key, const char *alt_key, int *value) const; // Iterative accessors. - char *getKey(int i); - Object *getVal(int i, Object *obj); - Object *getValNF(int i, Object *obj); + char *getKey(int i) const; + Object getVal(int i) const; + Object getValNF(int i) const; // Set the xref pointer. This is only used in one special case: the // trailer dictionary, which is read before the xref table is // parsed. void setXRef(XRef *xrefA) { xref = xrefA; } - XRef *getXRef() { return xref; } + XRef *getXRef() const { return xref; } - GBool hasKey(const char *key); + GBool hasKey(const char *key) const; private: + friend class Object; // for incRef/decRef + + // Reference counting. + int incRef(); + int decRef(); - GBool sorted; + mutable GBool sorted; XRef *xref; // the xref table for this PDF file DictEntry *entries; // array of entries int size; // size of <entries> array int length; // number of entries in dictionary int ref; // reference count -#if MULTITHREADED - GooMutex mutex; +#ifdef MULTITHREADED + mutable GooMutex mutex; #endif - DictEntry *find(const char *key); + DictEntry *find(const char *key) const; }; #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/Error.cc b/Build/source/libs/poppler/poppler-src/poppler/Error.cc index 99ca3ad3f53..ab43654dbeb 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Error.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Error.cc @@ -17,7 +17,7 @@ // Copyright (C) 2005 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2012 Marek Kasik <mkasik@redhat.com> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -25,6 +25,7 @@ //======================================================================== #include <config.h> +#include <poppler-config.h> #ifdef USE_GCC_PRAGMAS #pragma implementation diff --git a/Build/source/libs/poppler/poppler-src/poppler/FileSpec.cc b/Build/source/libs/poppler/poppler-src/poppler/FileSpec.cc index bac1eaea0d7..5ebef9777f8 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/FileSpec.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/FileSpec.cc @@ -7,7 +7,7 @@ // // Copyright (C) 2008-2009 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> -// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012 Hib Eris <hib@hiberis.nl> // // To see a description of the changes please see the Changelog file that @@ -35,40 +35,37 @@ EmbFile::EmbFile(Object *efStream) m_checksum = NULL; m_mimetype = NULL; - efStream->copy(&m_objStr); + m_objStr = efStream->copy(); if (efStream->isStream()) { // dataDict corresponds to Table 3.41 in the PDF1.6 spec. Dict *dataDict = efStream->streamGetDict(); // subtype is normally the mimetype - Object subtypeName; - if (dataDict->lookup("Subtype", &subtypeName)->isName()) { + Object subtypeName = dataDict->lookup("Subtype"); + if (subtypeName.isName()) { m_mimetype = new GooString(subtypeName.getName()); } - subtypeName.free(); // paramDict corresponds to Table 3.42 in the PDF1.6 spec - Object paramDict; - if (dataDict->lookup("Params", ¶mDict)->isDict()) { - Object paramObj; - if (paramDict.dictLookup("ModDate", ¶mObj)->isString()) + Object paramDict = dataDict->lookup("Params"); + if (paramDict.isDict()) { + Object paramObj = paramDict.dictLookup("ModDate"); + if (paramObj.isString()) m_modDate = new GooString(paramObj.getString()); - paramObj.free(); - if (paramDict.dictLookup("CreationDate", ¶mObj)->isString()) + paramObj = paramDict.dictLookup("CreationDate"); + if (paramObj.isString()) m_createDate = new GooString(paramObj.getString()); - paramObj.free(); - if (paramDict.dictLookup("Size", ¶mObj)->isInt()) + paramObj = paramDict.dictLookup("Size"); + if (paramObj.isInt()) m_size = paramObj.getInt(); - paramObj.free(); - if (paramDict.dictLookup("CheckSum", ¶mObj)->isString()) + paramObj = paramDict.dictLookup("CheckSum"); + if (paramObj.isString()) m_checksum = new GooString(paramObj.getString()); - paramObj.free(); } - paramDict.free(); } } @@ -78,7 +75,6 @@ EmbFile::~EmbFile() delete m_modDate; delete m_checksum; delete m_mimetype; - m_objStr.free(); } GBool EmbFile::save(const char *path) { @@ -110,41 +106,37 @@ FileSpec::FileSpec(Object *fileSpecA) platformFileName = NULL; embFile = NULL; desc = NULL; - fileSpecA->copy(&fileSpec); + fileSpec = fileSpecA->copy(); - Object obj1; - if (!getFileSpecName(fileSpecA, &obj1)) { + Object obj1 = getFileSpecName(fileSpecA); + if (!obj1.isString()) { ok = gFalse; - obj1.free(); error(errSyntaxError, -1, "Invalid FileSpec"); return; } fileName = obj1.getString()->copy(); - obj1.free(); if (fileSpec.isDict()) { - if (fileSpec.dictLookup("EF", &obj1)->isDict()) { - if (!obj1.dictLookupNF("F", &fileStream)->isRef()) { + obj1 = fileSpec.dictLookup("EF"); + if (obj1.isDict()) { + fileStream = obj1.dictLookupNF("F"); + if (!fileStream.isRef()) { ok = gFalse; - fileStream.free(); + fileStream.setToNull(); error(errSyntaxError, -1, "Invalid FileSpec: Embedded file stream is not an indirect reference"); - obj1.free(); return; } } - obj1.free(); } - if (fileSpec.dictLookup("Desc", &obj1)->isString()) + obj1 = fileSpec.dictLookup("Desc"); + if (obj1.isString()) desc = obj1.getString()->copy(); - obj1.free(); } FileSpec::~FileSpec() { - fileSpec.free(); - fileStream.free(); delete fileName; delete platformFileName; delete embFile; @@ -161,8 +153,8 @@ EmbFile *FileSpec::getEmbeddedFile() Object obj1; XRef *xref = fileSpec.getDict()->getXRef(); - embFile = new EmbFile(fileStream.fetch(xref, &obj1)); - obj1.free(); + obj1 = fileStream.fetch(xref); + embFile = new EmbFile(&obj1); return embFile; } @@ -172,84 +164,77 @@ GooString *FileSpec::getFileNameForPlatform() if (platformFileName) return platformFileName; - Object obj1; - if (getFileSpecNameForPlatform(&fileSpec, &obj1)) + Object obj1 = getFileSpecNameForPlatform(&fileSpec); + if (obj1.isString()) platformFileName = obj1.getString()->copy(); - obj1.free(); return platformFileName; } -GBool getFileSpecName (Object *fileSpec, Object *fileName) +Object getFileSpecName (Object *fileSpec) { if (fileSpec->isString()) { - fileSpec->copy(fileName); - return gTrue; + return fileSpec->copy(); } if (fileSpec->isDict()) { - fileSpec->dictLookup("UF", fileName); - if (fileName->isString()) { - return gTrue; + Object fileName = fileSpec->dictLookup("UF"); + if (fileName.isString()) { + return fileName; } - fileName->free(); - fileSpec->dictLookup("F", fileName); - if (fileName->isString()) { - return gTrue; + fileName = fileSpec->dictLookup("F"); + if (fileName.isString()) { + return fileName; } - fileName->free(); - fileSpec->dictLookup("DOS", fileName); - if (fileName->isString()) { - return gTrue; + fileName = fileSpec->dictLookup("DOS"); + if (fileName.isString()) { + return fileName; } - fileName->free(); - fileSpec->dictLookup("Mac", fileName); - if (fileName->isString()) { - return gTrue; + fileName = fileSpec->dictLookup("Mac"); + if (fileName.isString()) { + return fileName; } - fileName->free(); - fileSpec->dictLookup("Unix", fileName); - if (fileName->isString()) { - return gTrue; + fileName = fileSpec->dictLookup("Unix"); + if (fileName.isString()) { + return fileName; } - fileName->free(); } - return gFalse; + return Object(); } -GBool getFileSpecNameForPlatform (Object *fileSpec, Object *fileName) +Object getFileSpecNameForPlatform (Object *fileSpec) { if (fileSpec->isString()) { - fileSpec->copy(fileName); - return gTrue; + return fileSpec->copy(); } + Object fileName; if (fileSpec->isDict()) { - if (!fileSpec->dictLookup("UF", fileName)->isString ()) { - fileName->free(); - if (!fileSpec->dictLookup("F", fileName)->isString ()) { - fileName->free(); + fileName = fileSpec->dictLookup("UF"); + if (!fileName.isString ()) { + fileName = fileSpec->dictLookup("F"); + if (!fileName.isString ()) { #ifdef _WIN32 const char *platform = "DOS"; #else const char *platform = "Unix"; #endif - if (!fileSpec->dictLookup(platform, fileName)->isString ()) { - fileName->free(); + fileName = fileSpec->dictLookup(platform); + if (!fileName.isString ()) { error(errSyntaxError, -1, "Illegal file spec"); - return gFalse; + return Object(); } } } } else { error(errSyntaxError, -1, "Illegal file spec"); - return gFalse; + return Object(); } // system-dependent path manipulation #ifdef _WIN32 int i, j; - GooString *name = fileName->getString(); + GooString *name = fileName.getString(); // "//...." --> "\...." // "/x/...." --> "x:\...." // "/server/share/...." --> "\\server\share\...." @@ -291,5 +276,5 @@ GBool getFileSpecNameForPlatform (Object *fileSpec, Object *fileName) } #endif /* _WIN32 */ - return gTrue; + return fileName; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/FileSpec.h b/Build/source/libs/poppler/poppler-src/poppler/FileSpec.h index 9f2f6fcd131..6133117b12c 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/FileSpec.h +++ b/Build/source/libs/poppler/poppler-src/poppler/FileSpec.h @@ -6,6 +6,7 @@ // under GPL version 2 or later // // Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> // // 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 @@ -31,6 +32,7 @@ public: GooString *createDate() { return m_createDate; } GooString *checksum() { return m_checksum; } GooString *mimeType() { return m_mimetype; } + Object *streamObject() { return &m_objStr; } Stream *stream() { return isOk() ? m_objStr.getStream() : NULL; } GBool isOk() { return m_objStr.isStream(); } GBool save(const char *path); @@ -70,7 +72,7 @@ private: GooString *desc; // Desc }; -GBool getFileSpecName (Object *fileSpec, Object *fileName); -GBool getFileSpecNameForPlatform (Object *fileSpec, Object *fileName); +Object getFileSpecName (Object *fileSpec); +Object getFileSpecNameForPlatform (Object *fileSpec); #endif /* FILE_SPEC_H */ diff --git a/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.cc b/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.cc index 49a0fa37209..c6e4a042c3e 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.cc @@ -3,6 +3,7 @@ // FlateEncoder.cc // // Copyright (C) 2016, William Bader <williambader@hotmail.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // This file is under the GPLv2 or later license // @@ -127,7 +128,6 @@ GBool FlateEncoder::fillBuf() { zlib_status = deflate(&zlib_stream, (inBufEof? Z_FINISH: Z_NO_FLUSH)); if (zlib_status == Z_STREAM_ERROR || - zlib_stream.avail_out < 0 || zlib_stream.avail_out > starting_avail_out) { /* Unrecoverable error */ inBufEof = outBufEof = gTrue; diff --git a/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.h b/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.h index 6dee292876d..093104ade1f 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.h +++ b/Build/source/libs/poppler/poppler-src/poppler/FlateEncoder.h @@ -44,16 +44,16 @@ class FlateEncoder: public FilterStream { public: FlateEncoder(Stream *strA); - virtual ~FlateEncoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() + ~FlateEncoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override { return (outBufPtr >= outBufEnd && !fillBuf()) ? EOF : (*outBufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (outBufPtr >= outBufEnd && !fillBuf()) ? EOF : (*outBufPtr & 0xff); } - virtual GooString *getPSFilter(int psLevel, const char *indent) { return NULL; } - virtual GBool isBinary(GBool last = gTrue) { return gTrue; } - virtual GBool isEncoder() { return gTrue; } + GooString *getPSFilter(int psLevel, const char *indent) override { return NULL; } + GBool isBinary(GBool last = gTrue) override { return gTrue; } + GBool isEncoder() override { return gTrue; } private: diff --git a/Build/source/libs/poppler/poppler-src/poppler/FlateStream.cc b/Build/source/libs/poppler/poppler-src/poppler/FlateStream.cc index acc716c1cce..d23435ff649 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/FlateStream.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/FlateStream.cc @@ -5,6 +5,7 @@ // Copyright (C) 2005, Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2010, Albert Astals Cid <aacid@kde.org> // Copyright (C) 2016, William Bader <williambader@hotmail.com> +// Copyright (C) 2017, Adrian Johnson <ajohnson@redneon.com> // // This file is under the GPLv2 or later license // @@ -18,7 +19,7 @@ #include "poppler-config.h" -#if ENABLE_ZLIB_UNCOMPRESS +#ifdef ENABLE_ZLIB_UNCOMPRESS #include "FlateStream.h" diff --git a/Build/source/libs/poppler/poppler-src/poppler/FlateStream.h b/Build/source/libs/poppler/poppler-src/poppler/FlateStream.h index 9e3835f042a..6a88a234e7d 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/FlateStream.h +++ b/Build/source/libs/poppler/poppler-src/poppler/FlateStream.h @@ -46,14 +46,14 @@ public: FlateStream(Stream *strA, int predictor, int columns, int colors, int bits); virtual ~FlateStream(); - virtual StreamKind getKind() { return strFlate; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar(); - virtual int getRawChar(); - virtual void getRawChars(int nChars, int *buffer); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + virtual StreamKind getKind() override { return strFlate; } + virtual void reset() override; + virtual int getChar() override; + virtual int lookChar() override; + virtual int getRawChar() override; + virtual void getRawChars(int nChars, int *buffer) override; + virtual GooString *getPSFilter(int psLevel, const char *indent) override; + virtual GBool isBinary(GBool last = gTrue) override; private: inline int doGetRawChar() { diff --git a/Build/source/libs/poppler/poppler-src/poppler/FontInfo.cc b/Build/source/libs/poppler/poppler-src/poppler/FontInfo.cc index 8fc89e9d827..3730f529b30 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/FontInfo.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/FontInfo.cc @@ -3,7 +3,7 @@ // FontInfo.cc // // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005-2008, 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2008, 2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Brad Hards <bradh@frogmouth.net> // Copyright (C) 2006 Kouhei Sutou <kou@cozmixng.org> // Copyright (C) 2009 Pino Toscano <pino@kde.org> @@ -54,7 +54,6 @@ GooList *FontInfoScanner::scan(int nPages) { Page *page; Dict *resDict; Annots *annots; - Object obj1; int lastPage; if (currentPage > doc->getNumPages()) { @@ -79,10 +78,10 @@ GooList *FontInfoScanner::scan(int nPages) { } annots = page->getAnnots(); for (int i = 0; i < annots->getNumAnnots(); ++i) { - if (annots->getAnnot(i)->getAppearanceResDict(&obj1)->isDict()) { + Object obj1 = annots->getAnnot(i)->getAppearanceResDict(); + if (obj1.isDict()) { scanFonts(xrefA, obj1.getDict(), result); } - obj1.free(); } } @@ -93,27 +92,24 @@ GooList *FontInfoScanner::scan(int nPages) { } void FontInfoScanner::scanFonts(XRef *xrefA, Dict *resDict, GooList *fontsList) { - Object obj1, obj2, objDict, resObj; Ref r; GfxFontDict *gfxFontDict; GfxFont *font; - int i; // scan the fonts in this resource dictionary gfxFontDict = NULL; - resDict->lookupNF("Font", &obj1); + Object obj1 = resDict->lookupNF("Font"); if (obj1.isRef()) { - obj1.fetch(xrefA, &obj2); + Object obj2 = obj1.fetch(xrefA); if (obj2.isDict()) { r = obj1.getRef(); gfxFontDict = new GfxFontDict(xrefA, &r, obj2.getDict()); } - obj2.free(); } else if (obj1.isDict()) { gfxFontDict = new GfxFontDict(xrefA, NULL, obj1.getDict()); } if (gfxFontDict) { - for (i = 0; i < gfxFontDict->getNumFonts(); ++i) { + for (int i = 0; i < gfxFontDict->getNumFonts(); ++i) { if ((font = gfxFontDict->getFont(i))) { Ref fontRef = *font->getID(); @@ -126,48 +122,39 @@ void FontInfoScanner::scanFonts(XRef *xrefA, Dict *resDict, GooList *fontsList) } delete gfxFontDict; } - obj1.free(); // recursively scan any resource dictionaries in objects in this // resource dictionary const char *resTypes[] = { "XObject", "Pattern" }; for (Guint resType = 0; resType < sizeof(resTypes) / sizeof(resTypes[0]); ++resType) { - resDict->lookup(resTypes[resType], &objDict); + Object objDict = resDict->lookup(resTypes[resType]); if (objDict.isDict()) { - for (i = 0; i < objDict.dictGetLength(); ++i) { - objDict.dictGetValNF(i, &obj1); + for (int i = 0; i < objDict.dictGetLength(); ++i) { + obj1 = objDict.dictGetValNF(i); if (obj1.isRef()) { // check for an already-seen object const Ref r = obj1.getRef(); if (visitedObjects.find(r.num) != visitedObjects.end()) { - obj1.free(); continue; } visitedObjects.insert(r.num); } - obj1.fetch(xrefA, &obj2); - + Object obj2 = obj1.fetch(xrefA); if (obj2.isStream()) { - obj2.streamGetDict()->lookup("Resources", &resObj); + Object resObj = obj2.streamGetDict()->lookup("Resources"); if (resObj.isDict() && resObj.getDict() != resDict) { scanFonts(xrefA, resObj.getDict(), fontsList); } - resObj.free(); } - obj1.free(); - obj2.free(); } } - objDict.free(); } } FontInfo::FontInfo(GfxFont *font, XRef *xref) { GooString *origName; - Object fontObj, toUnicodeObj; - int i; fontRef = *font->getID(); @@ -204,16 +191,16 @@ FontInfo::FontInfo(GfxFont *font, XRef *xref) { // look for a ToUnicode map hasToUnicode = gFalse; - if (xref->fetch(fontRef.num, fontRef.gen, &fontObj)->isDict()) { - hasToUnicode = fontObj.dictLookup("ToUnicode", &toUnicodeObj)->isStream(); - toUnicodeObj.free(); + Object fontObj = xref->fetch(fontRef.num, fontRef.gen); + if (fontObj.isDict()) { + hasToUnicode = fontObj.dictLookup("ToUnicode").isStream(); } - fontObj.free(); // check for a font subset name: capital letters followed by a '+' // sign subset = gFalse; if (name) { + int i; for (i = 0; i < name->getLength(); ++i) { if (name->getChar(i) < 'A' || name->getChar(i) > 'Z') { break; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Form.cc b/Build/source/libs/poppler/poppler-src/poppler/Form.cc index 8f8d14c4ebd..3c23dd3f651 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Form.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Form.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2006-2008 Julien Rebetez <julienr@svn.gnome.org> -// Copyright 2007-2012, 2015, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright 2007-2012, 2015-2017 Albert Astals Cid <aacid@kde.org> // Copyright 2007-2008, 2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright 2007, 2013, 2016 Adrian Johnson <ajohnson@redneon.com> // Copyright 2007 Iñigo MartÃnez <inigomartinez@gmail.com> @@ -17,6 +17,8 @@ // Copyright 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com> // Copyright 2015 André Esser <bepandre@hotmail.com> +// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +// Copyright 2017 Bernd Kuhls <berndkuhls@hotmail.com> // //======================================================================== @@ -27,8 +29,11 @@ #endif #include <set> +#include <limits> #include <stddef.h> +#include <stdlib.h> #include <string.h> +#include <ctype.h> #include "goo/gmem.h" #include "goo/GooString.h" #include "Error.h" @@ -47,6 +52,7 @@ #include "PDFDocEncoding.h" #include "Annot.h" #include "Link.h" +#include "Lexer.h" //return a newly allocated char* containing an UTF16BE string of size length char* pdfDocEncodingToUTF16 (GooString* orig, int* length) @@ -56,8 +62,8 @@ char* pdfDocEncodingToUTF16 (GooString* orig, int* length) char *result = new char[(*length)]; char *cstring = orig->getCString(); //unicode marker - result[0] = 0xfe; - result[1] = 0xff; + result[0] = (char)0xfe; + result[1] = (char)0xff; //convert to utf16 for(int i=2,j=0; i<(*length); i+=2,j++) { Unicode u = pdfDocEncoding[(unsigned int)((unsigned char)cstring[j])]&0xffff; @@ -85,7 +91,7 @@ FormWidget::FormWidget(PDFDoc *docA, Object *aobj, unsigned num, Ref aref, FormF childNum = num; doc = docA; xref = doc->getXRef(); - aobj->copy(&obj); + obj = aobj->copy(); type = formUndef; field = fieldA; widget = NULL; @@ -95,7 +101,6 @@ FormWidget::~FormWidget() { if (widget) widget->decRefCnt(); - obj.free (); } #ifdef DEBUG_FORMS @@ -108,10 +113,8 @@ void FormWidget::createWidgetAnnotation() { if (widget) return; - Object obj1; - obj1.initRef(ref.num, ref.gen); - widget = new AnnotWidget(doc, obj.getDict(), &obj1, field); - obj1.free(); + Object obj1(ref.num, ref.gen); + widget = new AnnotWidget(doc, &obj, &obj1, field); } GBool FormWidget::inRect(double x, double y) const { @@ -178,13 +181,13 @@ FormWidgetButton::FormWidgetButton (PDFDoc *docA, Object *aobj, unsigned num, Re type = formButton; onStr = NULL; - Object obj1, obj2; - // Find the name of the ON state in the AP dictionnary // The reference say the Off state, if it existe, _must_ be stored in the AP dict under the name /Off // The "on" state may be stored under any other name - if (obj.dictLookup("AP", &obj1)->isDict()) { - if (obj1.dictLookup("N", &obj2)->isDict()) { + Object obj1 = obj.dictLookup("AP"); + if (obj1.isDict()) { + Object obj2 = obj1.dictLookup("N"); + if (obj2.isDict()) { for (int i = 0; i < obj2.dictGetLength(); i++) { char *key = obj2.dictGetKey(i); if (strcmp (key, "Off") != 0) { @@ -193,9 +196,7 @@ FormWidgetButton::FormWidgetButton (PDFDoc *docA, Object *aobj, unsigned num, Re } } } - obj2.free(); } - obj1.free(); } char *FormWidgetButton::getOnStr() { @@ -315,13 +316,18 @@ int FormWidgetText::getMaxLen () const return parent()->getMaxLen (); } -void FormWidgetText::setContent(GooString* new_content) +double FormWidgetText::getTextFontSize() { - if (isReadOnly()) { - error(errInternal, -1, "FormWidgetText::setContentCopy called on a read only field\n"); - return; - } + return parent()->getTextFontSize(); +} +void FormWidgetText::setTextFontSize(int fontSize) +{ + parent()->setTextFontSize(fontSize); +} + +void FormWidgetText::setContent(GooString* new_content) +{ parent()->setContentCopy(new_content); } @@ -351,30 +357,18 @@ bool FormWidgetChoice::_checkRange (int i) void FormWidgetChoice::select (int i) { - if (isReadOnly()) { - error(errInternal, -1, "FormWidgetChoice::select called on a read only field\n"); - return; - } if (!_checkRange(i)) return; parent()->select(i); } void FormWidgetChoice::toggle (int i) { - if (isReadOnly()) { - error(errInternal, -1, "FormWidgetChoice::toggle called on a read only field\n"); - return; - } if (!_checkRange(i)) return; parent()->toggle(i); } void FormWidgetChoice::deselectAll () { - if (isReadOnly()) { - error(errInternal, -1, "FormWidgetChoice::deselectAll called on a read only field\n"); - return; - } parent()->deselectAll(); } @@ -401,10 +395,6 @@ bool FormWidgetChoice::isSelected (int i) void FormWidgetChoice::setEditChoice (GooString* new_content) { - if (isReadOnly()) { - error(errInternal, -1, "FormWidgetText::setEditChoice called on a read only field\n"); - return; - } if (!hasEdit()) { error(errInternal, -1, "FormFieldChoice::setEditChoice : trying to edit an non-editable choice\n"); return; @@ -464,9 +454,148 @@ FormWidgetSignature::FormWidgetSignature(PDFDoc *docA, Object *aobj, unsigned nu type = formSignature; } -SignatureInfo *FormWidgetSignature::validateSignature(bool doVerifyCert, bool forceRevalidation) +SignatureInfo *FormWidgetSignature::validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime) +{ + return static_cast<FormFieldSignature*>(field)->validateSignature(doVerifyCert, forceRevalidation, validationTime); +} + +std::vector<Goffset> FormWidgetSignature::getSignedRangeBounds() +{ + Object* obj = static_cast<FormFieldSignature*>(field)->getByteRange(); + std::vector<Goffset> range_vec; + if (obj->isArray()) + { + if (obj->arrayGetLength() == 4) + { + for (int i = 0; i < 2; ++i) + { + Object offsetObj(obj->arrayGet(2*i)); + Object lenObj(obj->arrayGet(2*i+1)); + if (offsetObj.isIntOrInt64() && lenObj.isIntOrInt64()) + { + Goffset offset = offsetObj.getIntOrInt64(); + Goffset len = lenObj.getIntOrInt64(); + range_vec.push_back(offset); + range_vec.push_back(offset+len); + } + } + } + } + return range_vec; +} + +GooString* FormWidgetSignature::getCheckedSignature(Goffset *checkedFileSize) { - return static_cast<FormFieldSignature*>(field)->validateSignature(doVerifyCert, forceRevalidation); + Goffset start = 0; + Goffset end = 0; + const std::vector<Goffset> ranges = getSignedRangeBounds(); + if (ranges.size() == 4) + { + start = ranges[1]; + end = ranges[2]; + } + if (end >= start+6) + { + BaseStream* stream = doc->getBaseStream(); + *checkedFileSize = stream->getLength(); + Goffset len = end-start; + stream->setPos(end-1); + int c2 = stream->lookChar(); + stream->setPos(start); + int c1 = stream->getChar(); + // PDF signatures are first ASN1 DER, then hex encoded PKCS#7 structures, + // possibly padded with 0 characters and enclosed in '<' and '>'. + // The ASN1 DER encoding of a PKCS#7 structure must start with the tag 0x30 + // for SEQUENCE. The next byte must be 0x80 for ASN1 DER indefinite length + // encoding or (0x80 + n) for ASN1 DER definite length encoding + // where n is the number of subsequent "length bytes" which big-endian + // encode the length of the content of the SEQUENCE following them. + if (len <= std::numeric_limits<int>::max() && *checkedFileSize > end && c1 == '<' && c2 == '>') + { + GooString gstr; + ++start; + --end; + len = end-start; + Goffset pos = 0; + do + { + c1 = stream->getChar(); + if (c1 == EOF) + return nullptr; + gstr.append(static_cast<char>(c1)); + } while (++pos < len); + if (gstr.getChar(0) == '3' && gstr.getChar(1) == '0') + { + if (gstr.getChar(2) == '8' && gstr.getChar(3) == '0') + { + // ASN1 DER indefinite length encoding: + // We only check that all characters up to the enclosing '>' + // are hex characters and that there are two hex encoded 0 bytes + // just before the enclosing '>' marking the end of the indefinite + // length encoding. + int paddingCount = 0; + while (gstr.getChar(len-1) == '0' && gstr.getChar(len-2) == '0') + { + ++paddingCount; + len -= 2; + } + if (paddingCount < 2 || len%2 == 1) + len = 0; + } + else if (gstr.getChar(2) == '8') + { + // ASN1 DER definite length encoding: + // We calculate the length of the following bytes from the length bytes and + // check that after the length bytes and the following calculated number of + // bytes all bytes up to the enclosing '>' character are hex encoded 0 bytes. + int lenBytes = gstr.getChar(3) - '0'; + if (lenBytes > 0 && lenBytes <= 4) + { + int sigLen = 0; + for (int i = 0; i < 2*lenBytes; ++i) + { + sigLen <<= 4; + char c = gstr.getChar(i+4); + if (isdigit(c)) + sigLen += c - '0'; + else if (isxdigit(c) && c >= 'a') + sigLen += c - 'a' + 10; + else if (isxdigit(c) && c >= 'A') + sigLen += c - 'A' + 10; + else + { + len = 0; + break; + } + } + if (sigLen > 0 && 2*(sigLen+lenBytes) <= len-4) + { + for (int i = 2*(sigLen+lenBytes)+4; i < len; ++i) + { + if (gstr.getChar(i) != '0') + { + len = 0; + break; + } + } + } + else + len = 0; + } + } + for (int i = 0; i < len; ++i) + { + if (!isxdigit(gstr.getChar(i))) + len = 0; + } + if (len > 0) + { + return new GooString(&gstr, 0, len); + } + } + } + } + return nullptr; } void FormWidgetSignature::updateWidgetAppearance() @@ -483,7 +612,7 @@ FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *par { doc = docA; xref = doc->getXRef(); - aobj->copy(&obj); + obj = aobj->copy(); Dict* dict = obj.getDict(); ref.num = ref.gen = 0; type = ty; @@ -500,76 +629,65 @@ FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *par ref = aref; - Object obj1; //childs - if (dict->lookup("Kids", &obj1)->isArray()) { + Object obj1 = dict->lookup("Kids"); + if (obj1.isArray()) { // Load children for (int i = 0 ; i < obj1.arrayGetLength(); i++) { - Object childRef, childObj; - - if (!obj1.arrayGetNF(i, &childRef)->isRef()) { + Object childRef = obj1.arrayGetNF(i); + if (!childRef.isRef()) { error (errSyntaxError, -1, "Invalid form field renference"); - childRef.free(); continue; } - if (!obj1.arrayGet(i, &childObj)->isDict()) { + Object childObj = obj1.arrayGet(i); + if (!childObj.isDict()) { error (errSyntaxError, -1, "Form field child is not a dictionary"); - childObj.free(); - childRef.free(); continue; } const Ref ref = childRef.getRef(); if (usedParents->find(ref.num) == usedParents->end()) { - Object obj2, obj3; // Field child: it could be a form field or a widget or composed dict - if (childObj.dictLookupNF("Parent", &obj2)->isRef() || childObj.dictLookup("Parent", &obj3)->isDict()) { + Object obj2 = childObj.dictLookupNF("Parent"); + Object obj3 = childObj.dictLookup("Parent"); + if (obj2.isRef() || obj3.isDict()) { // Child is a form field or composed dict // We create the field, if it's composed // it will create the widget as a child std::set<int> usedParentsAux = *usedParents; usedParentsAux.insert(ref.num); - obj2.free(); - obj3.free(); if (terminal) { error(errSyntaxWarning, -1, "Field can't have both Widget AND Field as kids\n"); - childObj.free(); - childRef.free(); continue; } numChildren++; children = (FormField**)greallocn(children, numChildren, sizeof(FormField*)); children[numChildren - 1] = Form::createFieldFromDict(&childObj, doc, ref, this, &usedParentsAux); - } else if (childObj.dictLookup("Subtype", &obj2)->isName("Widget")) { - // Child is a widget annotation - if (!terminal && numChildren > 0) { - error(errSyntaxWarning, -1, "Field can't have both Widget AND Field as kids\n"); - obj2.free(); - obj3.free(); - childObj.free(); - childRef.free(); - continue; - } - _createWidget(&childObj, ref); - } - obj2.free(); - obj3.free(); + } else { + obj2 = childObj.dictLookup("Subtype"); + if (obj2.isName("Widget")) { + // Child is a widget annotation + if (!terminal && numChildren > 0) { + error(errSyntaxWarning, -1, "Field can't have both Widget AND Field as kids\n"); + continue; + } + _createWidget(&childObj, ref); + } + } } - childObj.free(); - childRef.free(); } } else { // No children, if it's a composed dict, create the child widget - obj1.free(); - if (dict->lookup("Subtype", &obj1)->isName("Widget")) + obj1 = dict->lookup("Subtype"); + if (obj1.isName("Widget")) _createWidget(&obj, ref); } - obj1.free(); //flags - if (Form::fieldLookup(dict, "Ff", &obj1)->isInt()) { + obj1 = Form::fieldLookup(dict, "Ff"); + if (obj1.isInt()) { int flags = obj1.getInt(); if (flags & 0x1) { // 1 -> ReadOnly readOnly = true; @@ -581,39 +699,38 @@ FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *par //TODO } } - obj1.free(); // Variable Text - if (Form::fieldLookup(dict, "DA", &obj1)->isString()) + obj1 = Form::fieldLookup(dict, "DA"); + if (obj1.isString()) defaultAppearance = obj1.getString()->copy(); - obj1.free(); - if (Form::fieldLookup(dict, "Q", &obj1)->isInt()) { + obj1 = Form::fieldLookup(dict, "Q"); + if (obj1.isInt()) { quadding = static_cast<VariableTextQuadding>(obj1.getInt()); hasQuadding = gTrue; } - obj1.free(); - if (dict->lookup("T", &obj1)->isString()) { + obj1 = dict->lookup("T"); + if (obj1.isString()) { partialName = obj1.getString()->copy(); } else { partialName = NULL; } - obj1.free(); - if (dict->lookup("TU", &obj1)->isString()) { + obj1 = dict->lookup("TU"); + if (obj1.isString()) { alternateUiName = obj1.getString()->copy(); } else { alternateUiName = NULL; } - obj1.free(); - if(dict->lookup("TM", &obj1)->isString()) { + obj1 = dict->lookup("TM"); + if(obj1.isString()) { mappingName = obj1.getString()->copy(); } else { mappingName = NULL; } - obj1.free(); } void FormField::setPartialName(const GooString &name) @@ -621,9 +738,7 @@ void FormField::setPartialName(const GooString &name) delete partialName; partialName = name.copy(); - Object obj1; - obj1.initString(name.copy()); - obj.getDict()->set("T", &obj1); + obj.getDict()->set("T", Object(name.copy())); xref->setModifiedObject(&obj, ref); } @@ -640,7 +755,6 @@ FormField::~FormField() delete widgets[i]; gfree (widgets); } - obj.free(); delete defaultAppearance; delete partialName; @@ -710,7 +824,6 @@ void FormField::_createWidget (Object *obj, Ref aref) default: error(errSyntaxWarning, -1, "SubType on non-terminal field, invalid document?"); numChildren--; - terminal = false; } } @@ -732,7 +845,7 @@ FormWidget* FormField::findWidgetByRef (Ref aref) } GooString* FormField::getFullyQualifiedName() { - Object obj1, obj2; + Object obj1; Object parent; GooString *parent_name; GooString *full_name; @@ -743,9 +856,10 @@ GooString* FormField::getFullyQualifiedName() { full_name = new GooString(); - obj.copy(&obj1); - while (obj1.dictLookup("Parent", &parent)->isDict()) { - if (parent.dictLookup("T", &obj2)->isString()) { + obj1 = obj.copy(); + while (parent = obj1.dictLookup("Parent"), parent.isDict()) { + Object obj2 = parent.dictLookup("T"); + if (obj2.isString()) { parent_name = obj2.getString(); if (unicode_encoded) { @@ -768,14 +882,9 @@ GooString* FormField::getFullyQualifiedName() { full_name->insert(0, parent_name); } } - obj2.free(); } - obj1.free(); - parent.copy(&obj1); - parent.free(); + obj1 = parent.copy(); } - obj1.free(); - parent.free(); if (partialName) { if (unicode_encoded) { @@ -811,8 +920,7 @@ GooString* FormField::getFullyQualifiedName() { } if (unicode_encoded) { - full_name->insert(0, 0xff); - full_name->insert(0, 0xfe); + full_name->prependUnicodeMarker(); } fullyQualifiedName = full_name; @@ -842,11 +950,11 @@ FormFieldButton::FormFieldButton(PDFDoc *docA, Object *aobj, const Ref& ref, For noAllOff = false; siblings = NULL; numSiblings = 0; - appearanceState.initNull(); + appearanceState.setToNull(); - Object obj1; - btype = formButtonCheck; - if (Form::fieldLookup(dict, "Ff", &obj1)->isInt()) { + btype = formButtonCheck; + Object obj1 = Form::fieldLookup(dict, "Ff"); + if (obj1.isInt()) { int flags = obj1.getInt(); if (flags & 0x10000) { // 17 -> push button @@ -865,7 +973,7 @@ FormFieldButton::FormFieldButton(PDFDoc *docA, Object *aobj, const Ref& ref, For if (btype != formButtonPush) { // Even though V is inheritable we are interested in the value of this // field, if not present it's probably because it's a button in a set. - dict->lookup("V", &appearanceState); + appearanceState = dict->lookup("V"); } } @@ -924,11 +1032,6 @@ void FormFieldButton::fillChildrenSiblingsID() GBool FormFieldButton::setState(char *state) { - if (readOnly) { - error(errInternal, -1, "FormFieldButton::setState called on a readOnly field\n"); - return gFalse; - } - // A check button could behave as a radio button // when it's in a set of more than 1 buttons if (btype != formButtonRadio && btype != formButtonCheck) @@ -994,19 +1097,13 @@ GBool FormFieldButton::getState(char *state) { } void FormFieldButton::updateState(char *state) { - Object obj1; - - appearanceState.free(); - appearanceState.initName(state); - - appearanceState.copy(&obj1); - obj.getDict()->set("V", &obj1); + appearanceState = Object(objName, state); + obj.getDict()->set("V", appearanceState.copy()); xref->setModifiedObject(&obj, ref); } FormFieldButton::~FormFieldButton() { - appearanceState.free(); if (siblings) gfree(siblings); } @@ -1023,7 +1120,8 @@ FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref& ref, FormFie multiline = password = fileSelect = doNotSpellCheck = doNotScroll = comb = richText = false; maxLen = 0; - if (Form::fieldLookup(dict, "Ff", &obj1)->isInt()) { + obj1 = Form::fieldLookup(dict, "Ff"); + if (obj1.isInt()) { int flags = obj1.getInt(); if (flags & 0x1000) // 13 -> Multiline multiline = true; @@ -1040,14 +1138,14 @@ FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref& ref, FormFie if (flags & 0x2000000)// 26 -> RichText richText = true; } - obj1.free(); - if (Form::fieldLookup(dict, "MaxLen", &obj1)->isInt()) { + obj1 = Form::fieldLookup(dict, "MaxLen"); + if (obj1.isInt()) { maxLen = obj1.getInt(); } - obj1.free(); - if (Form::fieldLookup(dict, "V", &obj1)->isString()) { + obj1 = Form::fieldLookup(dict, "V"); + if (obj1.isString()) { if (obj1.getString()->hasUnicodeMarker()) { if (obj1.getString()->getLength() > 2) content = obj1.getString()->copy(); @@ -1059,7 +1157,6 @@ FormFieldText::FormFieldText(PDFDoc *docA, Object *aobj, const Ref& ref, FormFie delete [] tmp_str; } } - obj1.free(); } #ifdef DEBUG_FORMS @@ -1086,14 +1183,11 @@ void FormFieldText::setContentCopy (GooString* new_content) //append the unicode marker <FE FF> if needed if (!content->hasUnicodeMarker()) { - content->insert(0, 0xff); - content->insert(0, 0xfe); + content->prependUnicodeMarker(); } } - Object obj1; - obj1.initString(content ? content->copy() : new GooString("")); - obj.getDict()->set("V", &obj1); + obj.getDict()->set("V", Object(content ? content->copy() : new GooString(""))); xref->setModifiedObject(&obj, ref); updateChildrenAppearance(); } @@ -1103,6 +1197,87 @@ FormFieldText::~FormFieldText() delete content; } +double FormFieldText::getTextFontSize() +{ + GooList* daToks = new GooList(); + int idx = parseDA(daToks); + double fontSize = -1; + if (idx >= 0) { + char* p = nullptr; + fontSize = strtod(static_cast<GooString*>(daToks->get(idx))->getCString(), &p); + if (!p || *p) + fontSize = -1; + } + deleteGooList(daToks, GooString); + return fontSize; +} + +void FormFieldText::setTextFontSize(int fontSize) +{ + if (fontSize > 0 && obj.isDict()) { + GooList* daToks = new GooList(); + int idx = parseDA(daToks); + if (idx == -1) { + error(errSyntaxError, -1, "FormFieldText:: invalid DA object\n"); + deleteGooList(daToks, GooString); + return; + } + if (defaultAppearance) + delete defaultAppearance; + defaultAppearance = new GooString; + for (int i = 0; i < daToks->getLength(); ++i) { + if (i > 0) + defaultAppearance->append(' '); + if (i == idx) { + defaultAppearance->appendf("{0:d}", fontSize); + } else { + defaultAppearance->append(static_cast<GooString*>(daToks->get(i))); + } + } + deleteGooList(daToks, GooString); + obj.dictSet("DA", Object(defaultAppearance->copy())); + xref->setModifiedObject(&obj, ref); + updateChildrenAppearance(); + } +} + +int FormFieldText::tokenizeDA(GooString* da, GooList* daToks, const char* searchTok) +{ + int idx = -1; + if(da && daToks) { + int i = 0; + int j = 0; + while (i < da->getLength()) { + while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { + ++i; + } + if (i < da->getLength()) { + for (j = i + 1; j < da->getLength() && !Lexer::isSpace(da->getChar(j)); ++j) { + } + GooString* tok = new GooString(da, i, j - i); + if (searchTok && !tok->cmp(searchTok)) + idx = daToks->getLength(); + daToks->append(tok); + i = j; + } + } + } + return idx; +} + +int FormFieldText::parseDA(GooList* daToks) +{ + int idx = -1; + if (obj.isDict()) { + Object objDA(obj.dictLookup("DA")); + if (objDA.isString()) { + GooString* da = objDA.getString(); + idx = tokenizeDA(da, daToks, "Tf") - 1; + } + } + return idx; +} + //------------------------------------------------------------------------ // FormFieldChoice @@ -1120,7 +1295,8 @@ FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, For combo = edit = multiselect = doNotSpellCheck = doCommitOnSelChange = false; - if (Form::fieldLookup(dict, "Ff", &obj1)->isInt()) { + obj1 = Form::fieldLookup(dict, "Ff"); + if (obj1.isInt()) { int flags = obj1.getInt(); if (flags & 0x20000) // 18 -> Combo combo = true; @@ -1133,67 +1309,62 @@ FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, For if (flags & 0x4000000) // 27 -> CommitOnSelChange doCommitOnSelChange = true; } - obj1.free(); - if (dict->lookup("TI", &obj1)->isInt()) + obj1 = dict->lookup("TI"); + if (obj1.isInt()) topIdx = obj1.getInt(); - obj1.free(); - - if (dict->lookup("Opt", &obj1)->isArray()) { - Object obj2; + obj1 = dict->lookup("Opt"); + if (obj1.isArray()) { numChoices = obj1.arrayGetLength(); choices = new ChoiceOpt[numChoices]; memset(choices, 0, sizeof(ChoiceOpt) * numChoices); for (int i = 0; i < numChoices; i++) { - if (obj1.arrayGet(i, &obj2)->isString()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isString()) { choices[i].optionName = obj2.getString()->copy(); } else if (obj2.isArray()) { // [Export_value, Displayed_text] - Object obj3; - if (obj2.arrayGetLength() < 2) { error(errSyntaxError, -1, "FormWidgetChoice:: invalid Opt entry -- array's length < 2\n"); continue; } - if (obj2.arrayGet(0, &obj3)->isString()) + Object obj3 = obj2.arrayGet(0); + if (obj3.isString()) choices[i].exportVal = obj3.getString()->copy(); else error(errSyntaxError, -1, "FormWidgetChoice:: invalid Opt entry -- exported value not a string\n"); - obj3.free(); - if (obj2.arrayGet(1, &obj3)->isString()) + obj3 = obj2.arrayGet(1); + if (obj3.isString()) choices[i].optionName = obj3.getString()->copy(); else error(errSyntaxError, -1, "FormWidgetChoice:: invalid Opt entry -- choice name not a string\n"); - obj3.free(); } else { error(errSyntaxError, -1, "FormWidgetChoice:: invalid {0:d} Opt entry\n", i); } - obj2.free(); } } else { //empty choice } - obj1.free(); // Find selected items // Note: PDF specs say that /V has precedence over /I, but acroread seems to // do the opposite. We do the same. - if (Form::fieldLookup(dict, "I", &obj1)->isArray()) { + obj1 = Form::fieldLookup(dict, "I"); + if (obj1.isArray()) { for (int i = 0; i < obj1.arrayGetLength(); i++) { - Object obj2; - if (obj1.arrayGet(i, &obj2)->isInt() && obj2.getInt() >= 0 && obj2.getInt() < numChoices) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isInt() && obj2.getInt() >= 0 && obj2.getInt() < numChoices) { choices[obj2.getInt()].selected = true; } - obj2.free(); } } else { - obj1.free(); // Note: According to PDF specs, /V should *never* contain the exportVal. // However, if /Opt is an array of (exportVal,optionName) pairs, acroread // seems to expect the exportVal instead of the optionName and so we do too. - if (Form::fieldLookup(dict, "V", &obj1)->isString()) { + obj1 = Form::fieldLookup(dict, "V"); + if (obj1.isString()) { GBool optionFound = gFalse; for (int i = 0; i < numChoices; i++) { @@ -1220,8 +1391,7 @@ FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, For } else if (obj1.isArray()) { for (int i = 0; i < numChoices; i++) { for (int j = 0; j < obj1.arrayGetLength(); j++) { - Object obj2; - obj1.arrayGet(j, &obj2); + Object obj2 = obj1.arrayGet(j); GBool matches = gFalse; if (choices[i].exportVal) { @@ -1234,8 +1404,6 @@ FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, For } } - obj2.free(); - if (matches) { choices[i].selected = true; break; // We've determined that this option is selected. No need to keep on scanning @@ -1244,7 +1412,6 @@ FormFieldChoice::FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, For } } } - obj1.free(); } FormFieldChoice::~FormFieldChoice() @@ -1266,35 +1433,35 @@ void FormFieldChoice::print(int indent) #endif void FormFieldChoice::updateSelection() { - Object objV, objI, obj1; - objI.initNull(); + Object objV, obj1; + Object objI(objNull); if (edit && editedChoice) { // This is an editable combo-box with user-entered text - objV.initString(editedChoice->copy()); + objV = Object(editedChoice->copy()); } else { const int numSelected = getNumSelected(); // Create /I array only if multiple selection is allowed (as per PDF spec) if (multiselect) { - objI.initArray(xref); + objI = Object(new Array(xref)); } if (numSelected == 0) { // No options are selected - objV.initString(new GooString("")); + objV = Object(new GooString("")); } else if (numSelected == 1) { // Only one option is selected for (int i = 0; i < numChoices; i++) { if (choices[i].selected) { if (multiselect) { - objI.arrayAdd(obj1.initInt(i)); + objI.arrayAdd(Object(i)); } if (choices[i].exportVal) { - objV.initString(choices[i].exportVal->copy()); + objV = Object(choices[i].exportVal->copy()); } else if (choices[i].optionName) { - objV.initString(choices[i].optionName->copy()); + objV = Object(choices[i].optionName->copy()); } break; // We've just written the selected option. No need to keep on scanning @@ -1302,25 +1469,25 @@ void FormFieldChoice::updateSelection() { } } else { // More than one option is selected - objV.initArray(xref); + objV = Object(new Array(xref)); for (int i = 0; i < numChoices; i++) { if (choices[i].selected) { if (multiselect) { - objI.arrayAdd(obj1.initInt(i)); + objI.arrayAdd(Object(i)); } if (choices[i].exportVal) { - objV.arrayAdd(obj1.initString(choices[i].exportVal->copy())); + objV.arrayAdd(Object(choices[i].exportVal->copy())); } else if (choices[i].optionName) { - objV.arrayAdd(obj1.initString(choices[i].optionName->copy())); + objV.arrayAdd(Object(choices[i].optionName->copy())); } } } } } - obj.getDict()->set("V", &objV); - obj.getDict()->set("I", &objI); + obj.getDict()->set("V", std::move(objV)); + obj.getDict()->set("I", std::move(objI)); xref->setModifiedObject(&obj, ref); updateChildrenAppearance(); } @@ -1373,8 +1540,7 @@ void FormFieldChoice::setEditChoice (GooString* new_content) //append the unicode marker <FE FF> if needed if (!editedChoice->hasUnicodeMarker()) { - editedChoice->insert(0, 0xff); - editedChoice->insert(0, 0xfe); + editedChoice->prependUnicodeMarker(); } } updateSelection(); @@ -1411,7 +1577,9 @@ GooString *FormFieldChoice::getSelectedChoice() { // FormFieldSignature //------------------------------------------------------------------------ FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents) - : FormField(docA, dict, ref, parent, usedParents, formSignature) + : FormField(docA, dict, ref, parent, usedParents, formSignature), + signature_type(adbe_pkcs7_detached), + signature(nullptr), signature_info(nullptr) { signature = NULL; @@ -1421,7 +1589,6 @@ FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& re FormFieldSignature::~FormFieldSignature() { - byte_range.free(); delete signature_info; delete signature; } @@ -1431,39 +1598,40 @@ void FormFieldSignature::parseInfo() if (!obj.isDict()) return; - Object sig_dict, contents_obj, time_of_signing, subfilterName; - // retrieve PKCS#7 - obj.dictLookup("V", &sig_dict); + Object sig_dict = obj.dictLookup("V"); if (!sig_dict.isDict()) { - sig_dict.free(); return; } - sig_dict.dictLookup("Contents", &contents_obj); + Object contents_obj = sig_dict.dictLookup("Contents"); if (contents_obj.isString()) { signature = contents_obj.getString()->copy(); } - contents_obj.free(); - sig_dict.dictLookup("ByteRange", &byte_range); + byte_range = sig_dict.dictLookup("ByteRange"); // retrieve SigningTime - sig_dict.dictLookup("M", &time_of_signing); + Object time_of_signing = sig_dict.dictLookup("M"); if (time_of_signing.isString()) { GooString *time_str = time_of_signing.getString(); signature_info->setSigningTime(dateStringToTime(time_str)); // Put this information directly in SignatureInfo object - time_of_signing.free(); } // check if subfilter is supported for signature validation, only detached signatures work for now - sig_dict.dictLookup("SubFilter", &subfilterName); - if (subfilterName.isName("adbe.pkcs7.detached") || subfilterName.isName("adbe.pkcs7.sha1")) { + Object subfilterName = sig_dict.dictLookup("SubFilter"); + if (subfilterName.isName("adbe.pkcs7.sha1")) { + signature_type = adbe_pkcs7_sha1; + signature_info->setSubFilterSupport(true); + } + else if (subfilterName.isName("adbe.pkcs7.detached")) { + signature_type = adbe_pkcs7_detached; + signature_info->setSubFilterSupport(true); + } + else if (subfilterName.isName("ETSI.CAdES.detached")) { + signature_type = ETSI_CAdES_detached; signature_info->setSubFilterSupport(true); } - - subfilterName.free(); - sig_dict.free(); } void FormFieldSignature::hashSignedDataBlock(SignatureHandler *handler, Goffset block_len) @@ -1492,8 +1660,12 @@ void FormFieldSignature::hashSignedDataBlock(SignatureHandler *handler, Goffset #endif } +FormSignatureType FormWidgetSignature::signatureType() +{ + return static_cast<FormFieldSignature*>(field)->signature_type; +} -SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool forceRevalidation) +SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime) { #ifdef ENABLE_NSS3 if (!signature_info->isSubfilterSupported()) { @@ -1530,9 +1702,8 @@ SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool for Goffset fileLength = doc->getBaseStream()->getLength(); for (int i = 0; i < arrayLen/2; i++) { - Object offsetObj, lenObj; - byte_range.arrayGet(i*2, &offsetObj); - byte_range.arrayGet(i*2+1, &lenObj); + Object offsetObj = byte_range.arrayGet(i*2); + Object lenObj = byte_range.arrayGet(i*2+1); if (!offsetObj.isIntOrInt64() || !lenObj.isIntOrInt64()) { error(errSyntaxError, 0, "Illegal values in ByteRange array"); @@ -1554,6 +1725,8 @@ SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool for sig_val_state = signature_handler.validateSignature(); signature_info->setSignatureValStatus(SignatureHandler::NSS_SigTranslate(sig_val_state)); signature_info->setSignerName(signature_handler.getSignerName()); + signature_info->setSubjectDN(signature_handler.getSignerSubjectDN()); + signature_info->setHashAlgorithm(signature_handler.getHashAlgorithm()); // verify if signature contains a 'signing time' attribute if (signature_handler.getSigningTime() != 0) { @@ -1564,7 +1737,7 @@ SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool for return signature_info; } - cert_val_state = signature_handler.validateCertificate(); + cert_val_state = signature_handler.validateCertificate(validationTime); signature_info->setCertificateValStatus(SignatureHandler::NSS_CertTranslate(cert_val_state)); #endif @@ -1598,50 +1771,41 @@ Form::Form(PDFDoc *docA, Object* acroFormA) defaultAppearance = NULL; defaultResources = NULL; - acroForm->dictLookup("NeedAppearances", &obj1); + obj1 = acroForm->dictLookup("NeedAppearances"); needAppearances = (obj1.isBool() && obj1.getBool()); - obj1.free(); - if (acroForm->dictLookup("DA", &obj1)->isString()) + obj1 = acroForm->dictLookup("DA"); + if (obj1.isString()) defaultAppearance = obj1.getString()->copy(); - obj1.free(); - if (acroForm->dictLookup("Q", &obj1)->isInt()) + obj1 = acroForm->dictLookup("Q"); + if (obj1.isInt()) quadding = static_cast<VariableTextQuadding>(obj1.getInt()); - obj1.free(); - acroForm->dictLookup("DR", &resDict); + resDict = acroForm->dictLookup("DR"); if (resDict.isDict()) { // At a minimum, this dictionary shall contain a Font entry - if (resDict.dictLookup("Font", &obj1)->isDict()) + obj1 = resDict.dictLookup("Font"); + if (obj1.isDict()) defaultResources = new GfxResources(xref, resDict.getDict(), NULL); - obj1.free(); } if (!defaultResources) { - resDict.free(); - resDict.initNull(); + resDict.setToNull(); } - acroForm->dictLookup("Fields", &obj1); + obj1 = acroForm->dictLookup("Fields"); if (obj1.isArray()) { Array *array = obj1.getArray(); - Object obj2; - for(int i=0; i<array->getLength(); i++) { - Object oref; - array->get(i, &obj2); - array->getNF(i, &oref); + Object obj2 = array->get(i); + Object oref = array->getNF(i); if (!oref.isRef()) { error(errSyntaxWarning, -1, "Direct object in rootFields"); - obj2.free(); - oref.free(); continue; } if (!obj2.isDict()) { error(errSyntaxWarning, -1, "Reference in Fields array to an invalid or non existent object"); - obj2.free(); - oref.free(); continue; } @@ -1653,13 +1817,24 @@ Form::Form(PDFDoc *docA, Object* acroFormA) std::set<int> usedParents; rootFields[numFields++] = createFieldFromDict (&obj2, doc, oref.getRef(), NULL, &usedParents); - obj2.free(); - oref.free(); } } else { error(errSyntaxError, -1, "Can't get Fields array\n"); } - obj1.free (); + + obj1 = acroForm->dictLookup("CO"); + if (obj1.isArray()) { + Array *array = obj1.getArray(); + calculateOrder.reserve(array->getLength()); + for(int i=0; i<array->getLength(); i++) { + Object oref = array->getNF(i); + if (!oref.isRef()) { + error(errSyntaxWarning, -1, "Direct object in CO"); + continue; + } + calculateOrder.push_back(oref.getRef()); + } + } #ifdef DEBUG_FORMS for (int i = 0; i < numFields; i++) @@ -1674,54 +1849,43 @@ Form::~Form() { gfree (rootFields); delete defaultAppearance; delete defaultResources; - resDict.free(); } // Look up an inheritable field dictionary entry. -static Object *fieldLookup(Dict *field, const char *key, Object *obj, std::set<int> *usedParents) { - Dict *dict; - Object parent; - - dict = field; - if (!dict->lookup(key, obj)->isNull()) { +static Object fieldLookup(Dict *field, const char *key, std::set<int> *usedParents) { + Dict *dict = field; + Object obj = dict->lookup(key); + if (!obj.isNull()) { return obj; } - obj->free(); - dict->lookupNF("Parent", &parent); + Object parent = dict->lookupNF("Parent"); if (parent.isRef()) { const Ref ref = parent.getRef(); if (usedParents->find(ref.num) == usedParents->end()) { usedParents->insert(ref.num); - Object obj2; - parent.fetch(dict->getXRef(), &obj2); + Object obj2 = parent.fetch(dict->getXRef()); if (obj2.isDict()) { - fieldLookup(obj2.getDict(), key, obj, usedParents); - } else { - obj->initNull(); + return fieldLookup(obj2.getDict(), key, usedParents); } - obj2.free(); } } else if (parent.isDict()) { - fieldLookup(parent.getDict(), key, obj, usedParents); - } else { - obj->initNull(); + return fieldLookup(parent.getDict(), key, usedParents); } - parent.free(); - return obj; + return Object(objNull); } -Object *Form::fieldLookup(Dict *field, const char *key, Object *obj) { +Object Form::fieldLookup(Dict *field, const char *key) { std::set<int> usedParents; - return ::fieldLookup(field, key, obj, &usedParents); + return ::fieldLookup(field, key, &usedParents); } FormField *Form::createFieldFromDict (Object* obj, PDFDoc *docA, const Ref& pref, FormField *parent, std::set<int> *usedParents) { - Object obj2; FormField *field; - if (Form::fieldLookup(obj->getDict (), "FT", &obj2)->isName("Btn")) { + Object obj2 = Form::fieldLookup(obj->getDict (), "FT"); + if (obj2.isName("Btn")) { field = new FormFieldButton(docA, obj, pref, parent, usedParents); } else if (obj2.isName("Tx")) { field = new FormFieldText(docA, obj, pref, parent, usedParents); @@ -1732,7 +1896,6 @@ FormField *Form::createFieldFromDict (Object* obj, PDFDoc *docA, const Ref& pref } else { //we don't have an FT entry => non-terminal field field = new FormField(docA, obj, pref, parent, usedParents); } - obj2.free(); return field; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Form.h b/Build/source/libs/poppler/poppler-src/poppler/Form.h index 52651336249..8e72334d058 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Form.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Form.h @@ -6,13 +6,15 @@ // // Copyright 2006 Julien Rebetez <julienr@svn.gnome.org> // Copyright 2007, 2008, 2011 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright 2007-2010, 2012, 2015, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright 2007-2010, 2012, 2015-2017 Albert Astals Cid <aacid@kde.org> // Copyright 2010 Mark Riedesel <mark@klowner.com> // Copyright 2011 Pino Toscano <pino@kde.org> // Copyright 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com> // Copyright 2015 André Esser <bepandre@hotmail.com> +// Copyright 2017 Roland Hieber <r.hieber@pengutronix.de> +// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> // //======================================================================== @@ -23,10 +25,12 @@ #pragma interface #endif +#include "goo/GooList.h" #include "Object.h" #include "Annot.h" #include <set> +#include <vector> class GooString; class Array; @@ -60,6 +64,12 @@ enum VariableTextQuadding { quaddingRightJustified }; +enum FormSignatureType { + adbe_pkcs7_sha1, + adbe_pkcs7_detached, + ETSI_CAdES_detached +}; + class Form; class FormField; class FormFieldButton; @@ -165,7 +175,7 @@ public: char* getOnStr(); void setAppearanceState(const char *state); - void updateWidgetAppearance(); + void updateWidgetAppearance() override; protected: FormFieldButton *parent() const; @@ -187,7 +197,7 @@ public: //except a UTF16BE string void setContent(GooString* new_content); - void updateWidgetAppearance(); + void updateWidgetAppearance() override; bool isMultiline () const; bool isPassword () const; @@ -197,6 +207,11 @@ public: bool isComb () const; bool isRichText () const; int getMaxLen () const; + //return the font size of the field's text + double getTextFontSize(); + //set the font size of the field's text (currently only integer values) + void setTextFontSize(int fontSize); + protected: FormFieldText *parent() const; }; @@ -228,7 +243,7 @@ public: GooString* getEditChoice (); - void updateWidgetAppearance(); + void updateWidgetAppearance() override; bool isSelected (int i); bool isCombo () const; @@ -249,9 +264,20 @@ protected: class FormWidgetSignature: public FormWidget { public: FormWidgetSignature(PDFDoc *docA, Object *dict, unsigned num, Ref ref, FormField *p); - void updateWidgetAppearance(); + void updateWidgetAppearance() override; - SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation); + FormSignatureType signatureType(); + // Use -1 for now as validationTime + SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime); + + // returns a list with the boundaries of the signed ranges + // the elements of the list are of type Goffset + std::vector<Goffset> getSignedRangeBounds(); + + // checks the length encoding of the signature and returns the hex encoded signature + // if the check passed (and the checked file size as output parameter in checkedFileSize) + // otherwise a nullptr is returned + GooString* getCheckedSignature(Goffset *checkedFileSize); }; //------------------------------------------------------------------------ @@ -350,7 +376,7 @@ public: char *getAppearanceState() { return appearanceState.isName() ? appearanceState.getName() : NULL; } - void fillChildrenSiblingsID (); + void fillChildrenSiblingsID () override; void setNumSiblings (int num); void setSibling (int i, FormFieldButton *id) { siblings[i] = id; } @@ -363,7 +389,7 @@ public: void print(int indent = 0); #endif - virtual ~FormFieldButton(); + ~FormFieldButton(); protected: void updateState(char *state); @@ -389,7 +415,7 @@ public: GooString* getContent () { return content; } GooString* getContentCopy (); void setContentCopy (GooString* new_content); - virtual ~FormFieldText(); + ~FormFieldText(); bool isMultiline () const { return multiline; } bool isPassword () const { return password; } @@ -401,10 +427,20 @@ public: int getMaxLen () const { return maxLen; } + //return the font size of the field's text + double getTextFontSize(); + //set the font size of the field's text (currently only integer values) + void setTextFontSize(int fontSize); + #ifdef DEBUG_FORMS void print(int indent = 0); #endif + + static int tokenizeDA(GooString* daString, GooList* daToks, const char* searchTok); + protected: + int parseDA(GooList* daToks); + GooString* content; bool multiline; bool password; @@ -424,7 +460,7 @@ class FormFieldChoice: public FormField { public: FormFieldChoice(PDFDoc *docA, Object *aobj, const Ref& ref, FormField *parent, std::set<int> *usedParents); - virtual ~FormFieldChoice(); + ~FormFieldChoice(); int getNumChoices() { return numChoices; } GooString* getChoice(int i) { return choices ? choices[i].optionName : NULL; } @@ -490,16 +526,22 @@ protected: //------------------------------------------------------------------------ class FormFieldSignature: public FormField { + friend class FormWidgetSignature; public: FormFieldSignature(PDFDoc *docA, Object *dict, const Ref& ref, FormField *parent, std::set<int> *usedParents); - SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation); + // Use -1 for now as validationTime + SignatureInfo *validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime); - virtual ~FormFieldSignature(); + ~FormFieldSignature(); + Object* getByteRange() { return &byte_range; } + GooString* getSignature() { return signature; } private: void parseInfo(); void hashSignedDataBlock(SignatureHandler *handler, Goffset block_len); + + FormSignatureType signature_type; Object byte_range; GooString *signature; SignatureInfo *signature_info; @@ -522,7 +564,7 @@ public: ~Form(); // Look up an inheritable field dictionary entry. - static Object *fieldLookup(Dict *field, const char *key, Object *obj); + static Object fieldLookup(Dict *field, const char *key); /* Creates a new Field of the type specified in obj's dict. used in Form::Form and FormField::FormField */ @@ -540,6 +582,9 @@ public: FormWidget* findWidgetByRef (Ref aref); void postWidgetsLoad(); + + const std::vector<Ref> &getCalculateOrder() const { return calculateOrder; } + private: FormField** rootFields; int numFields; @@ -550,6 +595,7 @@ private: GBool needAppearances; GfxResources *defaultResources; Object resDict; + std::vector<Ref> calculateOrder; // Variable Text GooString *defaultAppearance; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Function.cc b/Build/source/libs/poppler/poppler-src/poppler/Function.cc index 7f359b8eb05..92ba5f74f5c 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Function.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Function.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) 2006, 2008-2010, 2013-2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2008-2010, 2013-2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> @@ -67,7 +67,6 @@ Function *Function::parse(Object *funcObj, std::set<int> *usedParents) { Function *func; Dict *dict; int funcType; - Object obj1; if (funcObj->isStream()) { dict = funcObj->streamGetDict(); @@ -80,13 +79,12 @@ Function *Function::parse(Object *funcObj, std::set<int> *usedParents) { return NULL; } - if (!dict->lookup("FunctionType", &obj1)->isInt()) { + Object obj1 = dict->lookup("FunctionType"); + if (!obj1.isInt()) { error(errSyntaxError, -1, "Function type is missing or wrong type"); - obj1.free(); - return NULL; + return nullptr; } funcType = obj1.getInt(); - obj1.free(); if (funcType == 0) { func = new SampledFunction(funcObj, dict); @@ -119,75 +117,65 @@ Function::Function(const Function *func) { } GBool Function::init(Dict *dict) { - Object obj1, obj2; + Object obj1; int i; //----- Domain - if (!dict->lookup("Domain", &obj1)->isArray()) { + obj1 = dict->lookup("Domain"); + if (!obj1.isArray()) { error(errSyntaxError, -1, "Function is missing domain"); - goto err2; + return gFalse; } m = obj1.arrayGetLength() / 2; if (m > funcMaxInputs) { error(errSyntaxError, -1, "Functions with more than {0:d} inputs are unsupported", funcMaxInputs); - goto err2; + return gFalse; } for (i = 0; i < m; ++i) { - obj1.arrayGet(2*i, &obj2); + Object obj2 = obj1.arrayGet(2*i); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function domain array"); - goto err1; + return gFalse; } domain[i][0] = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2*i+1, &obj2); + obj2 = obj1.arrayGet(2*i+1); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function domain array"); - goto err1; + return gFalse; } domain[i][1] = obj2.getNum(); - obj2.free(); } - obj1.free(); //----- Range hasRange = gFalse; n = 0; - if (dict->lookup("Range", &obj1)->isArray()) { + obj1 = dict->lookup("Range"); + if (obj1.isArray()) { hasRange = gTrue; n = obj1.arrayGetLength() / 2; if (n > funcMaxOutputs) { error(errSyntaxError, -1, "Functions with more than {0:d} outputs are unsupported", funcMaxOutputs); - goto err2; + return gFalse; } for (i = 0; i < n; ++i) { - obj1.arrayGet(2*i, &obj2); + Object obj2 = obj1.arrayGet(2*i); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function range array"); - goto err1; + return gFalse; } range[i][0] = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2*i+1, &obj2); + obj2 = obj1.arrayGet(2*i+1); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function range array"); - goto err1; + return gFalse; } range[i][1] = obj2.getNum(); - obj2.free(); } } - obj1.free(); return gTrue; - - err1: - obj2.free(); - err2: - obj1.free(); - return gFalse; } //------------------------------------------------------------------------ @@ -227,7 +215,7 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) { Stream *str; int sampleBits; double sampleMul; - Object obj1, obj2; + Object obj1; Guint buf, bitMask; int bits; Guint s; @@ -241,16 +229,16 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) { //----- initialize the generic stuff if (!init(dict)) { - goto err1; + return; } if (!hasRange) { error(errSyntaxError, -1, "Type 0 function is missing range"); - goto err1; + return; } if (m > sampledFuncMaxInputs) { error(errSyntaxError, -1, "Sampled functions with more than {0:d} inputs are unsupported", sampledFuncMaxInputs); - goto err1; + return; } //----- buffer @@ -259,30 +247,28 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) { //----- get the stream if (!funcObj->isStream()) { error(errSyntaxError, -1, "Type 0 function isn't a stream"); - goto err1; + return; } str = funcObj->getStream(); //----- Size - if (!dict->lookup("Size", &obj1)->isArray() || - obj1.arrayGetLength() != m) { + obj1 = dict->lookup("Size"); + if (!obj1.isArray() || obj1.arrayGetLength() != m) { error(errSyntaxError, -1, "Function has missing or invalid size array"); - goto err2; + return; } for (i = 0; i < m; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (!obj2.isInt()) { error(errSyntaxError, -1, "Illegal value in function size array"); - goto err3; + return; } sampleSize[i] = obj2.getInt(); if (sampleSize[i] <= 0) { error(errSyntaxError, -1, "Illegal non-positive value in function size array"); - goto err3; + return; } - obj2.free(); } - obj1.free(); idxOffset = (int *)gmallocn(1 << m, sizeof(int)); for (i = 0; i < (1<<m); ++i) { idx = 0; @@ -303,32 +289,30 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) { } //----- BitsPerSample - if (!dict->lookup("BitsPerSample", &obj1)->isInt()) { + obj1 = dict->lookup("BitsPerSample"); + if (!obj1.isInt()) { error(errSyntaxError, -1, "Function has missing or invalid BitsPerSample"); - goto err2; + return; } sampleBits = obj1.getInt(); sampleMul = 1.0 / (pow(2.0, (double)sampleBits) - 1); - obj1.free(); //----- Encode - if (dict->lookup("Encode", &obj1)->isArray() && - obj1.arrayGetLength() == 2*m) { + obj1 = dict->lookup("Encode"); + if (obj1.isArray() && obj1.arrayGetLength() == 2*m) { for (i = 0; i < m; ++i) { - obj1.arrayGet(2*i, &obj2); + Object obj2 = obj1.arrayGet(2*i); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function encode array"); - goto err3; + return; } encode[i][0] = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2*i+1, &obj2); + obj2 = obj1.arrayGet(2*i+1); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function encode array"); - goto err3; + return; } encode[i][1] = obj2.getNum(); - obj2.free(); } } else { for (i = 0; i < m; ++i) { @@ -336,30 +320,28 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) { encode[i][1] = sampleSize[i] - 1; } } - obj1.free(); for (i = 0; i < m; ++i) { inputMul[i] = (encode[i][1] - encode[i][0]) / (domain[i][1] - domain[i][0]); } //----- Decode - if (dict->lookup("Decode", &obj1)->isArray() && + obj1 = dict->lookup("Decode"); + if (obj1.isArray() && obj1.arrayGetLength() == 2*n) { for (i = 0; i < n; ++i) { - obj1.arrayGet(2*i, &obj2); + Object obj2 = obj1.arrayGet(2*i); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function decode array"); - goto err3; + return; } decode[i][0] = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2*i+1, &obj2); + obj2 = obj1.arrayGet(2*i+1); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function decode array"); - goto err3; + return; } decode[i][1] = obj2.getNum(); - obj2.free(); } } else { for (i = 0; i < n; ++i) { @@ -367,7 +349,6 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) { decode[i][1] = range[i][1]; } } - obj1.free(); //----- samples nSamples = n; @@ -409,14 +390,6 @@ SampledFunction::SampledFunction(Object *funcObj, Dict *dict) { transform(in, cacheOut); ok = gTrue; - return; - - err3: - obj2.free(); - err2: - obj1.free(); - err1: - return; } SampledFunction::~SampledFunction() { @@ -556,92 +529,81 @@ GBool SampledFunction::hasDifferentResultSet(Function *func) { //------------------------------------------------------------------------ ExponentialFunction::ExponentialFunction(Object *funcObj, Dict *dict) { - Object obj1, obj2; - int i; + Object obj1; ok = gFalse; //----- initialize the generic stuff if (!init(dict)) { - goto err1; + return; } if (m != 1) { error(errSyntaxError, -1, "Exponential function with more than one input"); - goto err1; + return; } //----- C0 - if (dict->lookup("C0", &obj1)->isArray()) { + obj1 = dict->lookup("C0"); + if (obj1.isArray()) { if (hasRange && obj1.arrayGetLength() != n) { error(errSyntaxError, -1, "Function's C0 array is wrong length"); - goto err2; + return; } n = obj1.arrayGetLength(); if (unlikely(n > funcMaxOutputs)) { error(errSyntaxError, -1, "Function's C0 array is wrong length"); n = funcMaxOutputs; } - for (i = 0; i < n; ++i) { - obj1.arrayGet(i, &obj2); + for (int i = 0; i < n; ++i) { + Object obj2 = obj1.arrayGet(i); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function C0 array"); - goto err3; + return; } c0[i] = obj2.getNum(); - obj2.free(); } } else { if (hasRange && n != 1) { error(errSyntaxError, -1, "Function's C0 array is wrong length"); - goto err2; + return; } n = 1; c0[0] = 0; } - obj1.free(); //----- C1 - if (dict->lookup("C1", &obj1)->isArray()) { + obj1 = dict->lookup("C1"); + if (obj1.isArray()) { if (obj1.arrayGetLength() != n) { error(errSyntaxError, -1, "Function's C1 array is wrong length"); - goto err2; + return; } - for (i = 0; i < n; ++i) { - obj1.arrayGet(i, &obj2); + for (int i = 0; i < n; ++i) { + Object obj2 = obj1.arrayGet(i); if (!obj2.isNum()) { error(errSyntaxError, -1, "Illegal value in function C1 array"); - goto err3; + return; } c1[i] = obj2.getNum(); - obj2.free(); } } else { if (n != 1) { error(errSyntaxError, -1, "Function's C1 array is wrong length"); - goto err2; + return; } c1[0] = 1; } - obj1.free(); //----- N (exponent) - if (!dict->lookup("N", &obj1)->isNum()) { + obj1 = dict->lookup("N"); + if (!obj1.isNum()) { error(errSyntaxError, -1, "Function has missing or invalid N"); - goto err2; + return; } e = obj1.getNum(); - obj1.free(); isLinear = fabs(e-1.) < 1e-10; ok = gTrue; - return; - - err3: - obj2.free(); - err2: - obj1.free(); - err1: - return; } ExponentialFunction::~ExponentialFunction() { @@ -685,7 +647,7 @@ void ExponentialFunction::transform(double *in, double *out) { //------------------------------------------------------------------------ StitchingFunction::StitchingFunction(Object *funcObj, Dict *dict, std::set<int> *usedParents) { - Object obj1, obj2; + Object obj1; int i; ok = gFalse; @@ -696,17 +658,18 @@ StitchingFunction::StitchingFunction(Object *funcObj, Dict *dict, std::set<int> //----- initialize the generic stuff if (!init(dict)) { - goto err1; + return; } if (m != 1) { error(errSyntaxError, -1, "Stitching function with more than one input"); - goto err1; + return; } //----- Functions - if (!dict->lookup("Functions", &obj1)->isArray()) { + obj1 = dict->lookup("Functions"); + if (!obj1.isArray()) { error(errSyntaxError, -1, "Missing 'Functions' entry in stitching function"); - goto err1; + return; } k = obj1.arrayGetLength(); funcs = (Function **)gmallocn(k, sizeof(Function *)); @@ -718,63 +681,58 @@ StitchingFunction::StitchingFunction(Object *funcObj, Dict *dict, std::set<int> } for (i = 0; i < k; ++i) { std::set<int> usedParentsAux = *usedParents; - obj1.arrayGetNF(i, &obj2); + Object obj2 = obj1.arrayGetNF(i); if (obj2.isRef()) { const Ref ref = obj2.getRef(); if (usedParentsAux.find(ref.num) == usedParentsAux.end()) { usedParentsAux.insert(ref.num); - obj2.free(); - obj1.arrayGet(i, &obj2); + obj2 = obj1.arrayGet(i); } else { - goto err2; + return; } } if (!(funcs[i] = Function::parse(&obj2, &usedParentsAux))) { - goto err2; + return; } if (funcs[i]->getInputSize() != 1 || (i > 0 && funcs[i]->getOutputSize() != funcs[0]->getOutputSize())) { error(errSyntaxError, -1, "Incompatible subfunctions in stitching function"); - goto err2; + return; } - obj2.free(); } - obj1.free(); //----- Bounds - if (!dict->lookup("Bounds", &obj1)->isArray() || - obj1.arrayGetLength() != k - 1) { + obj1 = dict->lookup("Bounds"); + if (!obj1.isArray() || obj1.arrayGetLength() != k - 1) { error(errSyntaxError, -1, "Missing or invalid 'Bounds' entry in stitching function"); - goto err1; + return; } bounds[0] = domain[0][0]; for (i = 1; i < k; ++i) { - if (!obj1.arrayGet(i - 1, &obj2)->isNum()) { + Object obj2 = obj1.arrayGet(i - 1); + if (!obj2.isNum()) { error(errSyntaxError, -1, "Invalid type in 'Bounds' array in stitching function"); - goto err2; + return; } bounds[i] = obj2.getNum(); - obj2.free(); } bounds[k] = domain[0][1]; - obj1.free(); //----- Encode - if (!dict->lookup("Encode", &obj1)->isArray() || - obj1.arrayGetLength() != 2 * k) { + obj1 = dict->lookup("Encode"); + if (!obj1.isArray() || obj1.arrayGetLength() != 2 * k) { error(errSyntaxError, -1, "Missing or invalid 'Encode' entry in stitching function"); - goto err1; + return; } for (i = 0; i < 2 * k; ++i) { - if (!obj1.arrayGet(i, &obj2)->isNum()) { + Object obj2 = obj1.arrayGet(i); + if (!obj2.isNum()) { error(errSyntaxError, -1, "Invalid type in 'Encode' array in stitching function"); - goto err2; + return; } encode[i] = obj2.getNum(); - obj2.free(); } - obj1.free(); //----- pre-compute the scale factors for (i = 0; i < k; ++i) { @@ -790,11 +748,6 @@ StitchingFunction::StitchingFunction(Object *funcObj, Dict *dict, std::set<int> n = funcs[0]->getOutputSize(); ok = gTrue; return; - - err2: - obj2.free(); - err1: - obj1.free(); } StitchingFunction::StitchingFunction(const StitchingFunction *func) : Function(func) { @@ -1623,7 +1576,9 @@ void PostScriptFunction::exec(PSStack *stack, int codePtr) { case psOpIdiv: i2 = stack->popInt(); i1 = stack->popInt(); - stack->pushInt(i1 / i2); + if (likely(i2 != 0)) { + stack->pushInt(i1 / i2); + } break; case psOpIndex: stack->index(stack->popInt()); @@ -1659,7 +1614,9 @@ void PostScriptFunction::exec(PSStack *stack, int codePtr) { case psOpMod: i2 = stack->popInt(); i1 = stack->popInt(); - stack->pushInt(i1 % i2); + if (likely(i2 != 0)) { + stack->pushInt(i1 % i2); + } break; case psOpMul: if (stack->topTwoAreInts()) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/Function.h b/Build/source/libs/poppler/poppler-src/poppler/Function.h index 90e2a768ad0..56e5495d958 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Function.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Function.h @@ -109,11 +109,11 @@ class IdentityFunction: public Function { public: IdentityFunction(); - virtual ~IdentityFunction(); - virtual Function *copy() { return new IdentityFunction(); } - virtual int getType() { return -1; } - virtual void transform(double *in, double *out); - virtual GBool isOk() { return gTrue; } + ~IdentityFunction(); + Function *copy() override { return new IdentityFunction(); } + int getType() override { return -1; } + void transform(double *in, double *out) override; + GBool isOk() override { return gTrue; } private: }; @@ -126,12 +126,12 @@ class SampledFunction: public Function { public: SampledFunction(Object *funcObj, Dict *dict); - virtual ~SampledFunction(); - virtual Function *copy() { return new SampledFunction(this); } - virtual int getType() { return 0; } - virtual void transform(double *in, double *out); - virtual GBool isOk() { return ok; } - virtual GBool hasDifferentResultSet(Function *func); + ~SampledFunction(); + Function *copy() override { return new SampledFunction(this); } + int getType() override { return 0; } + void transform(double *in, double *out) override; + GBool isOk() override { return ok; } + GBool hasDifferentResultSet(Function *func) override; int getSampleSize(int i) { return sampleSize[i]; } double getEncodeMin(int i) { return encode[i][0]; } @@ -170,11 +170,11 @@ class ExponentialFunction: public Function { public: ExponentialFunction(Object *funcObj, Dict *dict); - virtual ~ExponentialFunction(); - virtual Function *copy() { return new ExponentialFunction(this); } - virtual int getType() { return 2; } - virtual void transform(double *in, double *out); - virtual GBool isOk() { return ok; } + ~ExponentialFunction(); + Function *copy() override { return new ExponentialFunction(this); } + int getType() override { return 2; } + void transform(double *in, double *out) override; + GBool isOk() override { return ok; } double *getC0() { return c0; } double *getC1() { return c1; } @@ -199,11 +199,11 @@ class StitchingFunction: public Function { public: StitchingFunction(Object *funcObj, Dict *dict, std::set<int> *usedParents); - virtual ~StitchingFunction(); - virtual Function *copy() { return new StitchingFunction(this); } - virtual int getType() { return 3; } - virtual void transform(double *in, double *out); - virtual GBool isOk() { return ok; } + ~StitchingFunction(); + Function *copy() override { return new StitchingFunction(this); } + int getType() override { return 3; } + void transform(double *in, double *out) override; + GBool isOk() override { return ok; } int getNumFuncs() { return k; } Function *getFunc(int i) { return funcs[i]; } @@ -231,11 +231,11 @@ class PostScriptFunction: public Function { public: PostScriptFunction(Object *funcObj, Dict *dict); - virtual ~PostScriptFunction(); - virtual Function *copy() { return new PostScriptFunction(this); } - virtual int getType() { return 4; } - virtual void transform(double *in, double *out); - virtual GBool isOk() { return ok; } + ~PostScriptFunction(); + Function *copy() override { return new PostScriptFunction(this); } + int getType() override { return 4; } + void transform(double *in, double *out) override; + GBool isOk() override { return ok; } GooString *getCodeString() { return codeString; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc b/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc index a8f5be95e4b..531acbd41a2 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Gfx.cc @@ -14,13 +14,13 @@ // under GPL version 2 or later // // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> -// Copyright (C) 2005-2013, 2015, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2013, 2015-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no> // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006-2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> -// Copyright (C) 2007, 2011 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2007, 2011, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2007, 2008 Iñigo MartÃnez <inigomartinez@gmail.com> // Copyright (C) 2007 Koji Otani <sho@bbr.jp> // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com> @@ -55,6 +55,7 @@ #include <stddef.h> #include <string.h> #include <math.h> +#include <memory> #include "goo/gmem.h" #include "goo/GooTimer.h" #include "goo/GooHash.h" @@ -132,10 +133,6 @@ // Operator table //------------------------------------------------------------------------ -#ifdef _MSC_VER // this works around a bug in the VC7 compiler -# pragma optimize("",off) -#endif - Operator Gfx::opTab[] = { {"\"", 3, {tchkNum, tchkNum, tchkString}, &Gfx::opMoveSetShowText}, @@ -305,10 +302,6 @@ Operator Gfx::opTab[] = { &Gfx::opCurveTo2}, }; -#ifdef _MSC_VER // this works around a bug in the VC7 compiler -# pragma optimize("",on) -#endif - #define numOps (sizeof(opTab) / sizeof(Operator)) static inline GBool isSameGfxColor(const GfxColor &colorA, const GfxColor &colorB, Guint nComps, double delta) { @@ -334,61 +327,51 @@ GfxResources::GfxResources(XRef *xref, Dict *resDictA, GfxResources *nextA) : // build font dictionary Dict *resDict = resDictA->copy(xref); fonts = NULL; - resDict->lookupNF("Font", &obj1); + obj1 = resDict->lookupNF("Font"); if (obj1.isRef()) { - obj1.fetch(xref, &obj2); + obj2 = obj1.fetch(xref); if (obj2.isDict()) { r = obj1.getRef(); fonts = new GfxFontDict(xref, &r, obj2.getDict()); } - obj2.free(); } else if (obj1.isDict()) { fonts = new GfxFontDict(xref, NULL, obj1.getDict()); } - obj1.free(); // get XObject dictionary - resDict->lookup("XObject", &xObjDict); + xObjDict = resDict->lookup("XObject"); // get color space dictionary - resDict->lookup("ColorSpace", &colorSpaceDict); + colorSpaceDict = resDict->lookup("ColorSpace"); // get pattern dictionary - resDict->lookup("Pattern", &patternDict); + patternDict = resDict->lookup("Pattern"); // get shading dictionary - resDict->lookup("Shading", &shadingDict); + shadingDict = resDict->lookup("Shading"); // get graphics state parameter dictionary - resDict->lookup("ExtGState", &gStateDict); + gStateDict = resDict->lookup("ExtGState"); // get properties dictionary - resDict->lookup("Properties", &propertiesDict); + propertiesDict = resDict->lookup("Properties"); delete resDict; } else { fonts = NULL; - xObjDict.initNull(); - colorSpaceDict.initNull(); - patternDict.initNull(); - shadingDict.initNull(); - gStateDict.initNull(); - propertiesDict.initNull(); + xObjDict.setToNull(); + colorSpaceDict.setToNull(); + patternDict.setToNull(); + shadingDict.setToNull(); + gStateDict.setToNull(); + propertiesDict.setToNull(); } next = nextA; } GfxResources::~GfxResources() { - if (fonts) { - delete fonts; - } - xObjDict.free(); - colorSpaceDict.free(); - patternDict.free(); - shadingDict.free(); - gStateDict.free(); - propertiesDict.free(); + delete fonts; } GfxFont *GfxResources::lookupFont(char *name) { @@ -405,75 +388,79 @@ GfxFont *GfxResources::lookupFont(char *name) { return NULL; } -GBool GfxResources::lookupXObject(char *name, Object *obj) { +Object GfxResources::lookupXObject(char *name) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->xObjDict.isDict()) { - if (!resPtr->xObjDict.dictLookup(name, obj)->isNull()) - return gTrue; - obj->free(); + Object obj = resPtr->xObjDict.dictLookup(name); + if (!obj.isNull()) + return obj; } } error(errSyntaxError, -1, "XObject '{0:s}' is unknown", name); - return gFalse; + return Object(objNull); } -GBool GfxResources::lookupXObjectNF(char *name, Object *obj) { +Object GfxResources::lookupXObjectNF(char *name) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->xObjDict.isDict()) { - if (!resPtr->xObjDict.dictLookupNF(name, obj)->isNull()) - return gTrue; - obj->free(); + Object obj = resPtr->xObjDict.dictLookupNF(name); + if (!obj.isNull()) + return obj; } } error(errSyntaxError, -1, "XObject '{0:s}' is unknown", name); - return gFalse; + return Object(objNull); } -GBool GfxResources::lookupMarkedContentNF(char *name, Object *obj) { +Object GfxResources::lookupMarkedContentNF(char *name) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->propertiesDict.isDict()) { - if (!resPtr->propertiesDict.dictLookupNF(name, obj)->isNull()) - return gTrue; - obj->free(); + Object obj = resPtr->propertiesDict.dictLookupNF(name); + if (!obj.isNull()) + return obj; } } error(errSyntaxError, -1, "Marked Content '{0:s}' is unknown", name); - return gFalse; + return Object(objNull); } -void GfxResources::lookupColorSpace(const char *name, Object *obj) { +Object GfxResources::lookupColorSpace(const char *name) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->colorSpaceDict.isDict()) { - if (!resPtr->colorSpaceDict.dictLookup(name, obj)->isNull()) { - return; + Object obj = resPtr->colorSpaceDict.dictLookup(name); + if (!obj.isNull()) { + return obj; } - obj->free(); } } - obj->initNull(); + return Object(objNull); } GfxPattern *GfxResources::lookupPattern(char *name, OutputDev *out, GfxState *state) { GfxResources *resPtr; GfxPattern *pattern; - Object obj; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->patternDict.isDict()) { - if (!resPtr->patternDict.dictLookup(name, &obj)->isNull()) { - pattern = GfxPattern::parse(resPtr, &obj, out, state); - obj.free(); + Object obj = resPtr->patternDict.dictLookupNF(name); + if (!obj.isNull()) { + Ref patternRef = { -1, -1 }; + if (obj.isRef()) { + patternRef = obj.getRef(); + obj = obj.fetch(resPtr->patternDict.getDict()->getXRef()); + } + + pattern = GfxPattern::parse(resPtr, &obj, out, state, patternRef.num); return pattern; } - obj.free(); } } error(errSyntaxError, -1, "Unknown pattern '{0:s}'", name); @@ -483,51 +470,50 @@ GfxPattern *GfxResources::lookupPattern(char *name, OutputDev *out, GfxState *st GfxShading *GfxResources::lookupShading(char *name, OutputDev *out, GfxState *state) { GfxResources *resPtr; GfxShading *shading; - Object obj; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->shadingDict.isDict()) { - if (!resPtr->shadingDict.dictLookup(name, &obj)->isNull()) { + Object obj = resPtr->shadingDict.dictLookup(name); + if (!obj.isNull()) { shading = GfxShading::parse(resPtr, &obj, out, state); - obj.free(); return shading; } - obj.free(); } } error(errSyntaxError, -1, "ExtGState '{0:s}' is unknown", name); return NULL; } -GBool GfxResources::lookupGState(char *name, Object *obj) { - if (!lookupGStateNF(name, obj)) - return gFalse; +Object GfxResources::lookupGState(char *name) { + Object obj = lookupGStateNF(name); + if (obj.isNull()) + return Object(objNull); - if (!obj->isRef()) - return gTrue; + if (!obj.isRef()) + return obj; - const Ref ref = obj->getRef(); - if (!gStateCache.lookup(ref, obj)->isNull()) - return gTrue; - obj->free(); + const Ref ref = obj.getRef(); + obj = gStateCache.lookup(ref); + if (!obj.isNull()) + return obj; - gStateCache.put(ref)->copy(obj); - return gTrue; + obj = gStateCache.put(ref)->copy(); + return obj; } -GBool GfxResources::lookupGStateNF(char *name, Object *obj) { +Object GfxResources::lookupGStateNF(char *name) { GfxResources *resPtr; for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->gStateDict.isDict()) { - if (!resPtr->gStateDict.dictLookupNF(name, obj)->isNull()) { - return gTrue; + Object obj = resPtr->gStateDict.dictLookupNF(name); + if (!obj.isNull()) { + return obj; } - obj->free(); } } error(errSyntaxError, -1, "ExtGState '{0:s}' is unknown", name); - return gFalse; + return Object(objNull); } //------------------------------------------------------------------------ @@ -644,25 +630,16 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, Dict *resDict, #ifdef USE_CMS -#ifdef USE_LCMS1 -#include <lcms.h> -#else #include <lcms2.h> -#define LCMS_FLAGS cmsFLAGS_NOOPTIMIZE -#endif void Gfx::initDisplayProfile() { - Object catDict; - xref->getCatalog(&catDict); + Object catDict = xref->getCatalog(); if (catDict.isDict()) { - Object outputIntents; - catDict.dictLookup("OutputIntents", &outputIntents); + Object outputIntents = catDict.dictLookup("OutputIntents"); if (outputIntents.isArray() && outputIntents.arrayGetLength() == 1) { - Object firstElement; - outputIntents.arrayGet(0, &firstElement); + Object firstElement = outputIntents.arrayGet(0); if (firstElement.isDict()) { - Object profile; - firstElement.dictLookup("DestOutputProfile", &profile); + Object profile = firstElement.dictLookup("DestOutputProfile"); if (profile.isStream()) { Stream *iccStream = profile.getStream(); int length = 0; @@ -675,13 +652,9 @@ void Gfx::initDisplayProfile() { } gfree(profBuf); } - profile.free(); } - firstElement.free(); } - outputIntents.free(); } - catDict.free(); } #endif @@ -708,18 +681,15 @@ Gfx::~Gfx() { } void Gfx::display(Object *obj, GBool topLevel) { - Object obj2; int i; if (obj->isArray()) { for (i = 0; i < obj->arrayGetLength(); ++i) { - obj->arrayGet(i, &obj2); + Object obj2 = obj->arrayGet(i); if (!obj2.isStream()) { error(errSyntaxError, -1, "Weird page contents"); - obj2.free(); return; } - obj2.free(); } } else if (!obj->isStream()) { error(errSyntaxError, -1, "Weird page contents"); @@ -742,7 +712,7 @@ void Gfx::go(GBool topLevel) { updateLevel = 1; // make sure even empty pages trigger a call to dump() lastAbortCheck = 0; numArgs = 0; - parser->getObj(&obj); + obj = parser->getObj(); while (!obj.isEOF()) { commandAborted = gFalse; @@ -757,13 +727,17 @@ void Gfx::go(GBool topLevel) { printf("\n"); fflush(stdout); } - GooTimer timer; + GooTimer *timer = nullptr; + + if (unlikely(profileCommands)) { + timer = new GooTimer(); + } // Run the operation execOp(&obj, args, numArgs); // Update the profile information - if (profileCommands) { + if (unlikely(profileCommands)) { GooHash *hash; hash = out->getProfileHash (); @@ -778,12 +752,12 @@ void Gfx::go(GBool topLevel) { hash->add (cmd_g, data_p); } - data_p->addElement(timer.getElapsed ()); + data_p->addElement(timer->getElapsed ()); } + delete timer; } - obj.free(); for (i = 0; i < numArgs; ++i) - args[i].free(); + args[i].setToNull(); // Free memory early numArgs = 0; // periodically update display @@ -812,8 +786,7 @@ void Gfx::go(GBool topLevel) { // got an argument - save it } else if (numArgs < maxArgs) { - args[numArgs++] = obj; - + args[numArgs++] = std::move(obj); // too many arguments - something is wrong } else { error(errSyntaxError, getPos(), "Too many args in content stream"); @@ -823,13 +796,11 @@ void Gfx::go(GBool topLevel) { printf("\n"); fflush(stdout); } - obj.free(); } // grab the next object - parser->getObj(&obj); + obj = parser->getObj(); } - obj.free(); // args at end with no command if (numArgs > 0) { @@ -843,8 +814,6 @@ void Gfx::go(GBool topLevel) { printf("\n"); fflush(stdout); } - for (i = 0; i < numArgs; ++i) - args[i].free(); } popStateGuard(); @@ -970,7 +939,6 @@ void Gfx::opConcat(Object args[], int numArgs) { void Gfx::opSetDash(Object args[], int numArgs) { Array *a; int length; - Object obj; double *dash; int i; @@ -981,11 +949,10 @@ void Gfx::opSetDash(Object args[], int numArgs) { } else { dash = (double *)gmallocn(length, sizeof(double)); for (i = 0; i < length; ++i) { - a->get(i, &obj); + Object obj = a->get(i); if (obj.isNum()) { dash[i] = obj.getNum(); } - obj.free(); } } state->setLineDash(dash, length, args[1].getNum()); @@ -1018,8 +985,7 @@ void Gfx::opSetLineWidth(Object args[], int numArgs) { } void Gfx::opSetExtGState(Object args[], int numArgs) { - Object obj1, obj2, obj3, obj4, obj5; - Object args2[2]; + Object obj1, obj2; GfxBlendMode mode; GBool haveFillOP; Function *funcs[4]; @@ -1030,12 +996,12 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { double opac; int i; - if (!res->lookupGState(args[0].getName(), &obj1)) { + obj1 = res->lookupGState(args[0].getName()); + if (obj1.isNull()) { return; } if (!obj1.isDict()) { error(errSyntaxError, getPos(), "ExtGState '{0:s}' is wrong type", args[0].getName()); - obj1.free(); return; } if (printCommands) { @@ -1045,33 +1011,31 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { } // parameters that are also set by individual PDF operators - if (obj1.dictLookup("LW", &obj2)->isNum()) { + obj2 = obj1.dictLookup("LW"); + if (obj2.isNum()) { opSetLineWidth(&obj2, 1); } - obj2.free(); - if (obj1.dictLookup("LC", &obj2)->isInt()) { + obj2 = obj1.dictLookup("LC"); + if (obj2.isInt()) { opSetLineCap(&obj2, 1); } - obj2.free(); - if (obj1.dictLookup("LJ", &obj2)->isInt()) { + obj2 = obj1.dictLookup("LJ"); + if (obj2.isInt()) { opSetLineJoin(&obj2, 1); } - obj2.free(); - if (obj1.dictLookup("ML", &obj2)->isNum()) { + obj2 = obj1.dictLookup("ML"); + if (obj2.isNum()) { opSetMiterLimit(&obj2, 1); } - obj2.free(); - if (obj1.dictLookup("D", &obj2)->isArray() && - obj2.arrayGetLength() == 2) { - obj2.arrayGet(0, &args2[0]); - obj2.arrayGet(1, &args2[1]); + obj2 = obj1.dictLookup("D"); + if (obj2.isArray() && obj2.arrayGetLength() == 2) { + Object args2[2]; + args2[0] = obj2.arrayGet(0); + args2[1] = obj2.arrayGet(1); if (args2[0].isArray() && args2[1].isNum()) { opSetDash(args2, 2); } - args2[0].free(); - args2[1].free(); } - obj2.free(); #if 0 //~ need to add a new version of GfxResources::lookupFont() that //~ takes an indirect ref instead of a name if (obj1.dictLookup("Font", &obj2)->isArray() && @@ -1086,13 +1050,14 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { } obj2.free(); #endif - if (obj1.dictLookup("FL", &obj2)->isNum()) { + obj2 = obj1.dictLookup("FL"); + if (obj2.isNum()) { opSetFlat(&obj2, 1); } - obj2.free(); // transparency support: blend mode, fill/stroke opacity - if (!obj1.dictLookup("BM", &obj2)->isNull()) { + obj2 = obj1.dictLookup("BM"); + if (!obj2.isNull()) { if (state->parseBlendMode(&obj2, &mode)) { state->setBlendMode(mode); out->updateBlendMode(state); @@ -1100,27 +1065,27 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { error(errSyntaxError, getPos(), "Invalid blend mode in ExtGState"); } } - obj2.free(); - if (obj1.dictLookup("ca", &obj2)->isNum()) { + obj2 = obj1.dictLookup("ca"); + if (obj2.isNum()) { opac = obj2.getNum(); state->setFillOpacity(opac < 0 ? 0 : opac > 1 ? 1 : opac); out->updateFillOpacity(state); } - obj2.free(); - if (obj1.dictLookup("CA", &obj2)->isNum()) { + obj2 = obj1.dictLookup("CA"); + if (obj2.isNum()) { opac = obj2.getNum(); state->setStrokeOpacity(opac < 0 ? 0 : opac > 1 ? 1 : opac); out->updateStrokeOpacity(state); } - obj2.free(); // fill/stroke overprint, overprint mode - if ((haveFillOP = (obj1.dictLookup("op", &obj2)->isBool()))) { + obj2 = obj1.dictLookup("op"); + if ((haveFillOP = obj2.isBool())) { state->setFillOverprint(obj2.getBool()); out->updateFillOverprint(state); } - obj2.free(); - if (obj1.dictLookup("OP", &obj2)->isBool()) { + obj2 = obj1.dictLookup("OP"); + if (obj2.isBool()) { state->setStrokeOverprint(obj2.getBool()); out->updateStrokeOverprint(state); if (!haveFillOP) { @@ -1128,24 +1093,23 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { out->updateFillOverprint(state); } } - obj2.free(); - if (obj1.dictLookup("OPM", &obj2)->isInt()) { + obj2 = obj1.dictLookup("OPM"); + if (obj2.isInt()) { state->setOverprintMode(obj2.getInt()); out->updateOverprintMode(state); } - obj2.free(); // stroke adjust - if (obj1.dictLookup("SA", &obj2)->isBool()) { + obj2 = obj1.dictLookup("SA"); + if (obj2.isBool()) { state->setStrokeAdjust(obj2.getBool()); out->updateStrokeAdjust(state); } - obj2.free(); // transfer function - if (obj1.dictLookup("TR2", &obj2)->isNull()) { - obj2.free(); - obj1.dictLookup("TR", &obj2); + obj2 = obj1.dictLookup("TR2"); + if (obj2.isNull()) { + obj2 = obj1.dictLookup("TR"); } if (obj2.isName("Default") || obj2.isName("Identity")) { @@ -1154,9 +1118,8 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { out->updateTransfer(state); } else if (obj2.isArray() && obj2.arrayGetLength() == 4) { for (i = 0; i < 4; ++i) { - obj2.arrayGet(i, &obj3); + Object obj3 = obj2.arrayGet(i); funcs[i] = Function::parse(&obj3); - obj3.free(); if (!funcs[i]) { break; } @@ -1174,80 +1137,81 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { } else if (!obj2.isNull()) { error(errSyntaxError, getPos(), "Invalid transfer function in ExtGState"); } - obj2.free(); // alpha is shape - if (obj1.dictLookup("AIS", &obj2)->isBool()) { + obj2 = obj1.dictLookup("AIS"); + if (obj2.isBool()) { state->setAlphaIsShape(obj2.getBool()); out->updateAlphaIsShape(state); } - obj2.free(); // text knockout - if (obj1.dictLookup("TK", &obj2)->isBool()) { + obj2 = obj1.dictLookup("TK"); + if (obj2.isBool()) { state->setTextKnockout(obj2.getBool()); out->updateTextKnockout(state); } - obj2.free(); // soft mask - if (!obj1.dictLookup("SMask", &obj2)->isNull()) { + obj2 = obj1.dictLookup("SMask"); + if (!obj2.isNull()) { if (obj2.isName("None")) { out->clearSoftMask(state); } else if (obj2.isDict()) { - if (obj2.dictLookup("S", &obj3)->isName("Alpha")) { + Object obj3 = obj2.dictLookup("S"); + if (obj3.isName("Alpha")) { alpha = gTrue; } else { // "Luminosity" alpha = gFalse; } - obj3.free(); funcs[0] = NULL; - if (!obj2.dictLookup("TR", &obj3)->isNull()) { + obj3 = obj2.dictLookup("TR"); + if (!obj3.isNull()) { if (obj3.isName("Default") || obj3.isName("Identity")) { funcs[0] = NULL; } else { funcs[0] = Function::parse(&obj3); - if (funcs[0] == NULL || - funcs[0]->getInputSize() != 1 || - funcs[0]->getOutputSize() != 1) { - error(errSyntaxError, getPos(), + if (funcs[0] == NULL || + funcs[0]->getInputSize() != 1 || + funcs[0]->getOutputSize() != 1) { + error(errSyntaxError, getPos(), "Invalid transfer function in soft mask in ExtGState"); - delete funcs[0]; - funcs[0] = NULL; + delete funcs[0]; + funcs[0] = NULL; } } } - obj3.free(); - if ((haveBackdropColor = obj2.dictLookup("BC", &obj3)->isArray())) { + obj3 = obj2.dictLookup("BC"); + if ((haveBackdropColor = obj3.isArray())) { for (i = 0; i < gfxColorMaxComps; ++i) { backdropColor.c[i] = 0; } for (i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; ++i) { - obj3.arrayGet(i, &obj4); + Object obj4 = obj3.arrayGet(i); if (obj4.isNum()) { backdropColor.c[i] = dblToCol(obj4.getNum()); } - obj4.free(); } } - obj3.free(); - if (obj2.dictLookup("G", &obj3)->isStream()) { - if (obj3.streamGetDict()->lookup("Group", &obj4)->isDict()) { + obj3 = obj2.dictLookup("G"); + if (obj3.isStream()) { + Object obj4 = obj3.streamGetDict()->lookup("Group"); + if (obj4.isDict()) { blendingColorSpace = NULL; isolated = knockout = gFalse; - if (!obj4.dictLookup("CS", &obj5)->isNull()) { + Object obj5 = obj4.dictLookup("CS"); + if (!obj5.isNull()) { blendingColorSpace = GfxColorSpace::parse(res, &obj5, out, state); } - obj5.free(); - if (obj4.dictLookup("I", &obj5)->isBool()) { + obj5 = obj4.dictLookup("I"); + if (obj5.isBool()) { isolated = obj5.getBool(); } - obj5.free(); - if (obj4.dictLookup("K", &obj5)->isBool()) { + obj5 = obj4.dictLookup("K"); + if (obj5.isBool()) { knockout = obj5.getBool(); } - obj5.free(); if (!haveBackdropColor) { if (blendingColorSpace) { blendingColorSpace->getDefaultColor(&backdropColor); @@ -1266,85 +1230,70 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { } else { error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group"); } - obj4.free(); } else { error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - missing group"); } - obj3.free(); } else if (!obj2.isNull()) { error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState"); } } - obj2.free(); - if (obj1.dictLookup("Font", &obj2)->isArray()) { + obj2 = obj1.dictLookup("Font"); + if (obj2.isArray()) { GfxFont *font; if (obj2.arrayGetLength() == 2) { - Object fargs0, fargs1; - - obj2.arrayGetNF(0,&fargs0); - obj2.arrayGet(1,&fargs1); + Object fargs0 = obj2.arrayGetNF(0); + Object fargs1 = obj2.arrayGet(1); if (fargs0.isRef() && fargs1.isNum()) { - Object fobj; - Ref r; - - fargs0.fetch(xref, &fobj); + Object fobj = fargs0.fetch(xref); if (fobj.isDict()) { - r = fargs0.getRef(); + Ref r = fargs0.getRef(); font = GfxFont::makeFont(xref,args[0].getName(),r,fobj.getDict()); state->setFont(font,fargs1.getNum()); fontChanged = gTrue; } - fobj.free(); } - fargs0.free(); - fargs1.free(); } else { error(errSyntaxError, getPos(), "Number of args mismatch for /Font in ExtGState"); } } - obj2.free(); - if (obj1.dictLookup("LW", &obj2)->isNum()) { + obj2 = obj1.dictLookup("LW"); + if (obj2.isNum()) { opSetLineWidth(&obj2,1); } - obj2.free(); - if (obj1.dictLookup("LC", &obj2)->isInt()) { + obj2 = obj1.dictLookup("LC"); + if (obj2.isInt()) { opSetLineCap(&obj2,1); } - obj2.free(); - if (obj1.dictLookup("LJ", &obj2)->isInt()) { + obj2 = obj1.dictLookup("LJ"); + if (obj2.isInt()) { opSetLineJoin(&obj2,1); } - obj2.free(); - if (obj1.dictLookup("ML", &obj2)->isNum()) { + obj2 = obj1.dictLookup("ML"); + if (obj2.isNum()) { opSetMiterLimit(&obj2,1); } - obj2.free(); - if (obj1.dictLookup("D", &obj2)->isArray()) { + obj2 = obj1.dictLookup("D"); + if (obj2.isArray()) { if (obj2.arrayGetLength() == 2) { Object dargs[2]; - obj2.arrayGetNF(0,&dargs[0]); - obj2.arrayGet(1,&dargs[1]); + dargs[0] = obj2.arrayGetNF(0); + dargs[1] = obj2.arrayGet(1); if (dargs[0].isArray() && dargs[1].isInt()) { opSetDash(dargs,2); } - dargs[0].free(); - dargs[1].free(); } else { error(errSyntaxError, getPos(), "Number of args mismatch for /D in ExtGState"); } } - obj2.free(); - if (obj1.dictLookup("RI", &obj2)->isName()) { + obj2 = obj1.dictLookup("RI"); + if (obj2.isName()) { opSetRenderingIntent(&obj2,1); } - obj2.free(); - if (obj1.dictLookup("FL", &obj2)->isNum()) { + obj2 = obj1.dictLookup("FL"); + if (obj2.isNum()) { opSetFlat(&obj2,1); } - obj2.free(); - - obj1.free(); } void Gfx::doSoftMask(Object *str, GBool alpha, @@ -1353,7 +1302,7 @@ void Gfx::doSoftMask(Object *str, GBool alpha, Function *transferFunc, GfxColor *backdropColor) { Dict *dict, *resDict; double m[6], bbox[4]; - Object obj1, obj2; + Object obj1; int i; // check for excessive recursion @@ -1365,50 +1314,42 @@ void Gfx::doSoftMask(Object *str, GBool alpha, dict = str->streamGetDict(); // check form type - dict->lookup("FormType", &obj1); + obj1 = dict->lookup("FormType"); if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { error(errSyntaxError, getPos(), "Unknown form type"); } - obj1.free(); // get bounding box - dict->lookup("BBox", &obj1); + obj1 = dict->lookup("BBox"); if (!obj1.isArray()) { - obj1.free(); error(errSyntaxError, getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (likely(obj2.isNum())) bbox[i] = obj2.getNum(); else { - obj2.free(); - obj1.free(); error(errSyntaxError, getPos(), "Bad form bounding box (non number)"); return; } - obj2.free(); } - obj1.free(); // get matrix - dict->lookup("Matrix", &obj1); + obj1 = dict->lookup("Matrix"); if (obj1.isArray()) { for (i = 0; i < 6; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (likely(obj2.isNum())) m[i] = obj2.getNum(); else m[i] = 0; - obj2.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } - obj1.free(); // get resources - dict->lookup("Resources", &obj1); + obj1 = dict->lookup("Resources"); resDict = obj1.isDict() ? obj1.getDict() : (Dict *)NULL; // draw it @@ -1421,7 +1362,6 @@ void Gfx::doSoftMask(Object *str, GBool alpha, if (blendingColorSpace) { delete blendingColorSpace; } - obj1.free(); } void Gfx::opSetRenderingIntent(Object args[], int numArgs) { @@ -1435,17 +1375,15 @@ void Gfx::opSetRenderingIntent(Object args[], int numArgs) { void Gfx::opSetFillGray(Object args[], int numArgs) { GfxColor color; GfxColorSpace *colorSpace = NULL; - Object obj; state->setFillPattern(NULL); - res->lookupColorSpace("DefaultGray", &obj); + Object obj = res->lookupColorSpace("DefaultGray"); if (!obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceGrayColorSpace(); } - obj.free(); state->setFillColorSpace(colorSpace); out->updateFillColorSpace(state); color.c[0] = dblToCol(args[0].getNum()); @@ -1456,17 +1394,15 @@ void Gfx::opSetFillGray(Object args[], int numArgs) { void Gfx::opSetStrokeGray(Object args[], int numArgs) { GfxColor color; GfxColorSpace *colorSpace = NULL; - Object obj; state->setStrokePattern(NULL); - res->lookupColorSpace("DefaultGray", &obj); + Object obj = res->lookupColorSpace("DefaultGray"); if (!obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceGrayColorSpace(); } - obj.free(); state->setStrokeColorSpace(colorSpace); out->updateStrokeColorSpace(state); color.c[0] = dblToCol(args[0].getNum()); @@ -1477,17 +1413,15 @@ void Gfx::opSetStrokeGray(Object args[], int numArgs) { void Gfx::opSetFillCMYKColor(Object args[], int numArgs) { GfxColor color; GfxColorSpace *colorSpace = NULL; - Object obj; int i; - res->lookupColorSpace("DefaultCMYK", &obj); + Object obj = res->lookupColorSpace("DefaultCMYK"); if (!obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceCMYKColorSpace(); } - obj.free(); state->setFillPattern(NULL); state->setFillColorSpace(colorSpace); out->updateFillColorSpace(state); @@ -1501,18 +1435,16 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) { void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) { GfxColor color; GfxColorSpace *colorSpace = NULL; - Object obj; int i; state->setStrokePattern(NULL); - res->lookupColorSpace("DefaultCMYK", &obj); + Object obj = res->lookupColorSpace("DefaultCMYK"); if (!obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceCMYKColorSpace(); } - obj.free(); state->setStrokeColorSpace(colorSpace); out->updateStrokeColorSpace(state); for (i = 0; i < 4; ++i) { @@ -1523,20 +1455,18 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) { } void Gfx::opSetFillRGBColor(Object args[], int numArgs) { - Object obj; GfxColorSpace *colorSpace = NULL; GfxColor color; int i; state->setFillPattern(NULL); - res->lookupColorSpace("DefaultRGB", &obj); + Object obj = res->lookupColorSpace("DefaultRGB"); if (!obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceRGBColorSpace(); } - obj.free(); state->setFillColorSpace(colorSpace); out->updateFillColorSpace(state); for (i = 0; i < 3; ++i) { @@ -1547,20 +1477,18 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) { } void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) { - Object obj; GfxColorSpace *colorSpace = NULL; GfxColor color; int i; state->setStrokePattern(NULL); - res->lookupColorSpace("DefaultRGB", &obj); + Object obj = res->lookupColorSpace("DefaultRGB"); if (!obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceRGBColorSpace(); } - obj.free(); state->setStrokeColorSpace(colorSpace); out->updateStrokeColorSpace(state); for (i = 0; i < 3; ++i) { @@ -1571,17 +1499,15 @@ void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) { } void Gfx::opSetFillColorSpace(Object args[], int numArgs) { - Object obj; GfxColorSpace *colorSpace; GfxColor color; - res->lookupColorSpace(args[0].getName(), &obj); + Object obj = res->lookupColorSpace(args[0].getName()); if (obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &args[0], out, state); } else { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } - obj.free(); if (colorSpace) { state->setFillPattern(NULL); state->setFillColorSpace(colorSpace); @@ -1595,18 +1521,16 @@ void Gfx::opSetFillColorSpace(Object args[], int numArgs) { } void Gfx::opSetStrokeColorSpace(Object args[], int numArgs) { - Object obj; GfxColorSpace *colorSpace; GfxColor color; state->setStrokePattern(NULL); - res->lookupColorSpace(args[0].getName(), &obj); + Object obj = res->lookupColorSpace(args[0].getName()); if (obj.isNull()) { colorSpace = GfxColorSpace::parse(res, &args[0], out, state); } else { colorSpace = GfxColorSpace::parse(res, &obj, out, state); } - obj.free(); if (colorSpace) { state->setStrokeColorSpace(colorSpace); out->updateStrokeColorSpace(state); @@ -2293,18 +2217,34 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat, xi0, yi0, xi1, yi1, xstep, ystep)) { goto restore; } else { - out->updatePatternOpacity(state); - for (yi = yi0; yi < yi1; ++yi) { - for (xi = xi0; xi < xi1; ++xi) { - x = xi * xstep; - y = yi * ystep; - m1[4] = x * m[0] + y * m[2] + m[4]; - m1[5] = x * m[1] + y * m[3] + m[5]; - drawForm(tPat->getContentStream(), tPat->getResDict(), - m1, tPat->getBBox()); + bool shouldDrawForm = gTrue; + std::set<int>::iterator patternRefIt; + const int patternRefNum = tPat->getPatternRefNum(); + if (patternRefNum != -1) { + if (formsDrawing.find(patternRefNum) == formsDrawing.end()) { + patternRefIt = formsDrawing.insert(patternRefNum).first; + } else { + shouldDrawForm = gFalse; + } + } + + if (shouldDrawForm) { + out->updatePatternOpacity(state); + for (yi = yi0; yi < yi1; ++yi) { + for (xi = xi0; xi < xi1; ++xi) { + x = xi * xstep; + y = yi * ystep; + m1[4] = x * m[0] + y * m[2] + m[4]; + m1[5] = x * m[1] + y * m[3] + m[5]; + drawForm(tPat->getContentStream(), tPat->getResDict(), + m1, tPat->getBBox()); + } + } + out->clearPatternOpacity(state); + if (patternRefNum != -1) { + formsDrawing.erase(patternRefIt); } } - out->clearPatternOpacity(state); } // restore graphics state @@ -3881,7 +3821,6 @@ void Gfx::opMoveSetShowText(Object args[], int numArgs) { void Gfx::opShowSpaceText(Object args[], int numArgs) { Array *a; - Object obj; int wMode; int i; @@ -3897,7 +3836,7 @@ void Gfx::opShowSpaceText(Object args[], int numArgs) { wMode = state->getFont()->getWMode(); a = args[0].getArray(); for (i = 0; i < a->getLength(); ++i) { - a->get(i, &obj); + Object obj = a->get(i); if (obj.isNum()) { // this uses the absolute value of the font size to match // Acrobat's behavior @@ -3916,17 +3855,15 @@ void Gfx::opShowSpaceText(Object args[], int numArgs) { error(errSyntaxError, getPos(), "Element of show/space array must be number or string"); } - obj.free(); } out->endStringOp(state); if (!ocState) { a = args[0].getArray(); for (i = 0; i < a->getLength(); ++i) { - a->get(i, &obj); + Object obj = a->get(i); if (obj.isString()) { doIncCharCount(obj.getString()); } - obj.free(); } } } @@ -3942,7 +3879,6 @@ void Gfx::doShowText(GooString *s) { double x0, y0, x1, y1; double oldCTM[6], newCTM[6]; double *mat; - Object charProc; Dict *resDict; Parser *oldParser; GfxState *savedState; @@ -4026,12 +3962,33 @@ void Gfx::doShowText(GooString *s) { state->transformDelta(dx, dy, &ddx, &ddy); if (!out->beginType3Char(state, curX + riseX, curY + riseY, ddx, ddy, code, u, uLen)) { - ((Gfx8BitFont *)font)->getCharProc(code, &charProc); + Object charProc = ((Gfx8BitFont *)font)->getCharProcNF(code); + int refNum = -1; + if (charProc.isRef()) { + refNum = charProc.getRef().num; + charProc = charProc.fetch(((Gfx8BitFont *)font)->getCharProcs()->getXRef()); + } if ((resDict = ((Gfx8BitFont *)font)->getResources())) { pushResources(resDict); } if (charProc.isStream()) { - display(&charProc, gFalse); + std::set<int>::iterator charProcDrawingIt; + bool displayCharProc = true; + if (refNum != -1) { + if (charProcDrawing.find(refNum) == charProcDrawing.end()) { + charProcDrawingIt = charProcDrawing.insert(refNum).first; + } else { + displayCharProc = false; + error(errSyntaxError, -1, "CharProc wants to draw a CharProc that is already beign drawn"); + } + } + if (displayCharProc) { + display(&charProc, gFalse); + + if (refNum != -1) { + charProcDrawing.erase(charProcDrawingIt); + } + } } else { error(errSyntaxError, getPos(), "Missing or bad Type3 CharProc entry"); } @@ -4039,7 +3996,6 @@ void Gfx::doShowText(GooString *s) { if (resDict) { popResources(); } - charProc.free(); } restoreStateStack(savedState); // GfxState::restore() does *not* restore the current position, @@ -4177,39 +4133,34 @@ void Gfx::doIncCharCount(GooString *s) { void Gfx::opXObject(Object args[], int numArgs) { char *name; - Object obj1, obj2, obj3, refObj; -#if OPI_SUPPORT - Object opiDict; -#endif if (!ocState && !out->needCharCount()) { return; } name = args[0].getName(); - if (!res->lookupXObject(name, &obj1)) { + Object obj1 = res->lookupXObject(name); + if (obj1.isNull()) { return; } if (!obj1.isStream()) { error(errSyntaxError, getPos(), "XObject '{0:s}' is wrong type", name); - obj1.free(); return; } -#if OPI_SUPPORT - obj1.streamGetDict()->lookup("OPI", &opiDict); +#ifdef OPI_SUPPORT + Object opiDict = obj1.streamGetDict()->lookup("OPI"); if (opiDict.isDict()) { out->opiBegin(state, opiDict.getDict()); } #endif - obj1.streamGetDict()->lookup("Subtype", &obj2); + Object obj2 = obj1.streamGetDict()->lookup("Subtype"); if (obj2.isName("Image")) { if (out->needNonText()) { - res->lookupXObjectNF(name, &refObj); + Object refObj = res->lookupXObjectNF(name); doImage(&refObj, obj1.getStream(), gFalse); - refObj.free(); } } else if (obj2.isName("Form")) { - res->lookupXObjectNF(name, &refObj); + Object refObj = res->lookupXObjectNF(name); GBool shouldDoForm = gTrue; std::set<int>::iterator drawingFormIt; if (refObj.isRef()) { @@ -4230,9 +4181,8 @@ void Gfx::opXObject(Object args[], int numArgs) { if (refObj.isRef() && shouldDoForm) { formsDrawing.erase(drawingFormIt); } - refObj.free(); } else if (obj2.isName("PS")) { - obj1.streamGetDict()->lookup("Level1", &obj3); + Object obj3 = obj1.streamGetDict()->lookup("Level1"); out->psXObject(obj1.getStream(), obj3.isStream() ? obj3.getStream() : (Stream *)NULL); } else if (obj2.isName()) { @@ -4240,14 +4190,11 @@ void Gfx::opXObject(Object args[], int numArgs) { } else { error(errSyntaxError, getPos(), "XObject subtype is missing or wrong type"); } - obj2.free(); -#if OPI_SUPPORT +#ifdef OPI_SUPPORT if (opiDict.isDict()) { out->opiEnd(state, opiDict.getDict()); } - opiDict.free(); #endif - obj1.free(); } void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { @@ -4259,15 +4206,13 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { GBool mask; GBool invert; GfxColorSpace *colorSpace, *maskColorSpace; - GfxImageColorMap *colorMap, *maskColorMap; - Object maskObj, smaskObj; GBool haveColorKeyMask, haveExplicitMask, haveSoftMask; int maskColors[2*gfxColorMaxComps]; int maskWidth, maskHeight; GBool maskInvert; GBool maskInterpolate; Stream *maskStr; - Object obj1, obj2; + Object obj1; int i, n; // get info from the stream @@ -4280,84 +4225,72 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { // check for optional content key if (ref) { - dict->lookupNF("OC", &obj1); + obj1 = dict->lookupNF("OC"); if (catalog->getOptContentConfig() && !catalog->getOptContentConfig()->optContentIsVisible(&obj1)) { - obj1.free(); return; } - obj1.free(); } // get size - dict->lookup("Width", &obj1); + obj1 = dict->lookup("Width"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("W", &obj1); + obj1 = dict->lookup("W"); } if (obj1.isInt()) width = obj1.getInt(); else if (obj1.isReal()) width = (int)obj1.getReal(); else - goto err2; - obj1.free(); - dict->lookup("Height", &obj1); + goto err1; + obj1 = dict->lookup("Height"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("H", &obj1); + obj1 = dict->lookup("H"); } if (obj1.isInt()) height = obj1.getInt(); else if (obj1.isReal()) height = (int)obj1.getReal(); else - goto err2; - obj1.free(); + goto err1; if (width < 1 || height < 1) goto err1; // image interpolation - dict->lookup("Interpolate", &obj1); + obj1 = dict->lookup("Interpolate"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("I", &obj1); + obj1 = dict->lookup("I"); } if (obj1.isBool()) interpolate = obj1.getBool(); else interpolate = gFalse; - obj1.free(); maskInterpolate = gFalse; // image or mask? - dict->lookup("ImageMask", &obj1); + obj1 = dict->lookup("ImageMask"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("IM", &obj1); + obj1 = dict->lookup("IM"); } mask = gFalse; if (obj1.isBool()) mask = obj1.getBool(); else if (!obj1.isNull()) - goto err2; - obj1.free(); + goto err1; // bit depth if (bits == 0) { - dict->lookup("BitsPerComponent", &obj1); + obj1 = dict->lookup("BitsPerComponent"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("BPC", &obj1); + obj1 = dict->lookup("BPC"); } if (obj1.isInt()) { bits = obj1.getInt(); } else if (mask) { bits = 1; } else { - goto err2; + goto err1; } - obj1.free(); } // display a mask @@ -4367,22 +4300,20 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { if (bits != 1) goto err1; invert = gFalse; - dict->lookup("Decode", &obj1); + obj1 = dict->lookup("Decode"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("D", &obj1); + obj1 = dict->lookup("D"); } if (obj1.isArray()) { - obj1.arrayGet(0, &obj2); + Object obj2; + obj2 = obj1.arrayGet(0); // Table 4.39 says /Decode must be [1 0] or [0 1]. Adobe // accepts [1.0 0.0] as well. if (obj2.isNum() && obj2.getNum() >= 0.9) invert = gTrue; - obj2.free(); } else if (!obj1.isNull()) { - goto err2; + goto err1; } - obj1.free(); // if drawing is disabled, skip over inline image data if (!ocState || !out->needNonText()) { @@ -4402,26 +4333,24 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { } } } else { + if (bits == 0) { + goto err1; + } // get color space and color map - dict->lookup("ColorSpace", &obj1); + obj1 = dict->lookup("ColorSpace"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("CS", &obj1); + obj1 = dict->lookup("CS"); } if (obj1.isName() && inlineImg) { - res->lookupColorSpace(obj1.getName(), &obj2); + Object obj2 = res->lookupColorSpace(obj1.getName()); if (!obj2.isNull()) { - obj1.free(); - obj1 = obj2; - } else { - obj2.free(); + obj1 = std::move(obj2); } } if (!obj1.isNull()) { - Object objIntent; char *tempIntent = NULL; - dict->lookup("Intent", &objIntent); + Object objIntent = dict->lookup("Intent"); if (objIntent.isName()) { tempIntent = state->getRenderingIntent(); if (tempIntent != NULL) { @@ -4434,54 +4363,39 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { state->setRenderingIntent(tempIntent); free(tempIntent); } - objIntent.free(); } else if (csMode == streamCSDeviceGray) { - Object objCS; - res->lookupColorSpace("DefaultGray", &objCS); + Object objCS = res->lookupColorSpace("DefaultGray"); if (objCS.isNull()) { colorSpace = new GfxDeviceGrayColorSpace(); } else { colorSpace = GfxColorSpace::parse(res, &objCS, out, state); } - objCS.free(); } else if (csMode == streamCSDeviceRGB) { - Object objCS; - res->lookupColorSpace("DefaultRGB", &objCS); + Object objCS = res->lookupColorSpace("DefaultRGB"); if (objCS.isNull()) { colorSpace = new GfxDeviceRGBColorSpace(); } else { colorSpace = GfxColorSpace::parse(res, &objCS, out, state); } - objCS.free(); } else if (csMode == streamCSDeviceCMYK) { - Object objCS; - res->lookupColorSpace("DefaultCMYK", &objCS); + Object objCS = res->lookupColorSpace("DefaultCMYK"); if (objCS.isNull()) { colorSpace = new GfxDeviceCMYKColorSpace(); } else { colorSpace = GfxColorSpace::parse(res, &objCS, out, state); } - objCS.free(); } else { colorSpace = NULL; } - obj1.free(); if (!colorSpace) { goto err1; } - dict->lookup("Decode", &obj1); + obj1 = dict->lookup("Decode"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("D", &obj1); + obj1 = dict->lookup("D"); } - if (bits == 0) { - delete colorSpace; - goto err2; - } - colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); - obj1.free(); - if (!colorMap->isOk()) { - delete colorMap; + GfxImageColorMap colorMap(bits, &obj1, colorSpace); + if (!colorMap.isOk()) { goto err1; } @@ -4490,9 +4404,9 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { maskStr = NULL; // make gcc happy maskWidth = maskHeight = 0; // make gcc happy maskInvert = gFalse; // make gcc happy - maskColorMap = NULL; // make gcc happy - dict->lookup("Mask", &maskObj); - dict->lookup("SMask", &smaskObj); + std::unique_ptr<GfxImageColorMap> maskColorMap; + Object maskObj = dict->lookup("Mask"); + Object smaskObj = dict->lookup("SMask"); if (smaskObj.isStream()) { // soft mask if (inlineImg) { @@ -4500,78 +4414,62 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { } maskStr = smaskObj.getStream(); maskDict = smaskObj.streamGetDict(); - maskDict->lookup("Width", &obj1); + obj1 = maskDict->lookup("Width"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("W", &obj1); + obj1 = maskDict->lookup("W"); } if (!obj1.isInt()) { - goto err2; + goto err1; } maskWidth = obj1.getInt(); - obj1.free(); - maskDict->lookup("Height", &obj1); + obj1 = maskDict->lookup("Height"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("H", &obj1); + obj1 = maskDict->lookup("H"); } if (!obj1.isInt()) { - goto err2; + goto err1; } maskHeight = obj1.getInt(); - obj1.free(); - maskDict->lookup("Interpolate", &obj1); + obj1 = maskDict->lookup("Interpolate"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("I", &obj1); + obj1 = maskDict->lookup("I"); } if (obj1.isBool()) maskInterpolate = obj1.getBool(); else maskInterpolate = gFalse; - obj1.free(); - maskDict->lookup("BitsPerComponent", &obj1); + obj1 = maskDict->lookup("BitsPerComponent"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("BPC", &obj1); + obj1 = maskDict->lookup("BPC"); } if (!obj1.isInt()) { - goto err2; + goto err1; } maskBits = obj1.getInt(); - obj1.free(); - maskDict->lookup("ColorSpace", &obj1); + obj1 = maskDict->lookup("ColorSpace"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("CS", &obj1); + obj1 = maskDict->lookup("CS"); } if (obj1.isName()) { - res->lookupColorSpace(obj1.getName(), &obj2); + Object obj2 = res->lookupColorSpace(obj1.getName()); if (!obj2.isNull()) { - obj1.free(); - obj1 = obj2; - } else { - obj2.free(); + obj1 = std::move(obj2); } } maskColorSpace = GfxColorSpace::parse(NULL, &obj1, out, state); - obj1.free(); if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { goto err1; } - maskDict->lookup("Decode", &obj1); + obj1 = maskDict->lookup("Decode"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("D", &obj1); + obj1 = maskDict->lookup("D"); } - maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace); - obj1.free(); + maskColorMap.reset(new GfxImageColorMap(maskBits, &obj1, maskColorSpace)); if (!maskColorMap->isOk()) { - delete maskColorMap; goto err1; } // handle the Matte entry - maskDict->lookup("Matte", &obj1); + obj1 = maskDict->lookup("Matte"); if (obj1.isArray()) { if (obj1.getArray()->getLength() != colorSpace->getNComps()) { error(errSyntaxError, -1, "Matte entry should have {0:d} components but has {1:d}", @@ -4582,29 +4480,26 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { } else { GfxColor matteColor; for (i = 0; i < colorSpace->getNComps(); i++) { - obj1.getArray()->get(i, &obj2); + Object obj2 = obj1.getArray()->get(i); if (!obj2.isNum()) { - obj2.free(); error(errSyntaxError, -1, "Matte entry {0:d} should be a number but it's of type {1:d}", i, obj2.getType()); break; } matteColor.c[i] = dblToCol(obj2.getNum()); - obj2.free(); } if (i == colorSpace->getNComps()) { maskColorMap->setMatteColor(&matteColor); } } } - obj1.free(); haveSoftMask = gTrue; } else if (maskObj.isArray()) { // color key mask for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) { - maskObj.arrayGet(i, &obj1); + obj1 = maskObj.arrayGet(i); if (obj1.isInt()) { maskColors[i] = obj1.getInt(); } else if (obj1.isReal()) { @@ -4612,10 +4507,8 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { maskColors[i] = (int) obj1.getReal(); } else { error(errSyntaxError, -1, "Mask entry should be an integer but it's of type {0:d}", obj1.getType()); - obj1.free(); goto err1; } - obj1.free(); } haveColorKeyMask = gTrue; } else if (maskObj.isStream()) { @@ -4625,71 +4518,60 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { } maskStr = maskObj.getStream(); maskDict = maskObj.streamGetDict(); - maskDict->lookup("Width", &obj1); + obj1 = maskDict->lookup("Width"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("W", &obj1); + obj1 = maskDict->lookup("W"); } if (!obj1.isInt()) { - goto err2; + goto err1; } maskWidth = obj1.getInt(); - obj1.free(); - maskDict->lookup("Height", &obj1); + obj1 = maskDict->lookup("Height"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("H", &obj1); + obj1 = maskDict->lookup("H"); } if (!obj1.isInt()) { - goto err2; + goto err1; } maskHeight = obj1.getInt(); - obj1.free(); - maskDict->lookup("Interpolate", &obj1); + obj1 = maskDict->lookup("Interpolate"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("I", &obj1); + obj1 = maskDict->lookup("I"); } if (obj1.isBool()) maskInterpolate = obj1.getBool(); else maskInterpolate = gFalse; - obj1.free(); - maskDict->lookup("ImageMask", &obj1); + obj1 = maskDict->lookup("ImageMask"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("IM", &obj1); + obj1 = maskDict->lookup("IM"); } if (!obj1.isBool() || !obj1.getBool()) { - goto err2; + goto err1; } - obj1.free(); maskInvert = gFalse; - maskDict->lookup("Decode", &obj1); + obj1 = maskDict->lookup("Decode"); if (obj1.isNull()) { - obj1.free(); - maskDict->lookup("D", &obj1); + obj1 = maskDict->lookup("D"); } if (obj1.isArray()) { - obj1.arrayGet(0, &obj2); + Object obj2 = obj1.arrayGet(0); // Table 4.39 says /Decode must be [1 0] or [0 1]. Adobe // accepts [1.0 0.0] as well. if (obj2.isNum() && obj2.getNum() >= 0.9) { maskInvert = gTrue; } - obj2.free(); } else if (!obj1.isNull()) { - goto err2; + goto err1; } - obj1.free(); haveExplicitMask = gTrue; } // if drawing is disabled, skip over inline image data if (!ocState || !out->needNonText()) { str->reset(); - n = height * ((width * colorMap->getNumPixelComps() * - colorMap->getBits() + 7) / 8); + n = height * ((width * colorMap.getNumPixelComps() * + colorMap.getBits() + 7) / 8); for (i = 0; i < n; ++i) { str->getChar(); } @@ -4698,21 +4580,16 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { // draw it } else { if (haveSoftMask) { - out->drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate, - maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); - delete maskColorMap; + out->drawSoftMaskedImage(state, ref, str, width, height, &colorMap, interpolate, + maskStr, maskWidth, maskHeight, maskColorMap.get(), maskInterpolate); } else if (haveExplicitMask) { - out->drawMaskedImage(state, ref, str, width, height, colorMap, interpolate, + out->drawMaskedImage(state, ref, str, width, height, &colorMap, interpolate, maskStr, maskWidth, maskHeight, maskInvert, maskInterpolate); } else { - out->drawImage(state, ref, str, width, height, colorMap, interpolate, + out->drawImage(state, ref, str, width, height, &colorMap, interpolate, haveColorKeyMask ? maskColors : (int *)NULL, inlineImg); } } - delete colorMap; - - maskObj.free(); - smaskObj.free(); } if ((i = width * height) > 1000) { @@ -4722,8 +4599,6 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { return; - err2: - obj1.free(); err1: error(errSyntaxError, getPos(), "Bad image parameters"); } @@ -4731,22 +4606,22 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { GBool Gfx::checkTransparencyGroup(Dict *resDict) { // check the effect of compositing objects as a group: // look for ExtGState entries with ca != 1 or CA != 1 or BM != normal - Object extGStates; GBool transpGroup = gFalse; double opac; if (resDict == NULL) return gFalse; pushResources(resDict); - resDict->lookup("ExtGState", &extGStates); + Object extGStates = resDict->lookup("ExtGState"); if (extGStates.isDict()) { Dict *dict = extGStates.getDict(); for (int i = 0; i < dict->getLength() && !transpGroup; i++) { - Object obj1, obj2; GfxBlendMode mode; - if (res->lookupGState(dict->getKey(i), &obj1) && obj1.isDict()) { - if (!obj1.dictLookup("BM", &obj2)->isNull()) { + Object obj1 = res->lookupGState(dict->getKey(i)); + if (obj1.isDict()) { + Object obj2 = obj1.dictLookup("BM"); + if (!obj2.isNull()) { if (state->parseBlendMode(&obj2, &mode)) { if (mode != gfxBlendNormal) transpGroup = gTrue; @@ -4754,38 +4629,35 @@ GBool Gfx::checkTransparencyGroup(Dict *resDict) { error(errSyntaxError, getPos(), "Invalid blend mode in ExtGState"); } } - obj2.free(); - if (obj1.dictLookup("ca", &obj2)->isNum()) { + obj2 = obj1.dictLookup("ca"); + if (obj2.isNum()) { opac = obj2.getNum(); opac = opac < 0 ? 0 : opac > 1 ? 1 : opac; if (opac != 1) transpGroup = gTrue; } - obj2.free(); - if (obj1.dictLookup("CA", &obj2)->isNum()) { + obj2 = obj1.dictLookup("CA"); + if (obj2.isNum()) { opac = obj2.getNum(); opac = opac < 0 ? 0 : opac > 1 ? 1 : opac; if (opac != 1) transpGroup = gTrue; } - obj2.free(); // alpha is shape - if (!transpGroup && obj1.dictLookup("AIS", &obj2)->isBool()) { + obj2 = obj1.dictLookup("AIS"); + if (!transpGroup && obj2.isBool()) { transpGroup = obj2.getBool(); } - obj2.free(); // soft mask - if (!transpGroup && !obj1.dictLookup("SMask", &obj2)->isNull()) { + obj2 = obj1.dictLookup("SMask"); + if (!transpGroup && !obj2.isNull()) { if (!obj2.isName("None")) { transpGroup = gTrue; } } - obj2.free(); } - obj1.free(); } } - extGStates.free(); popResources(); return transpGroup; } @@ -4794,12 +4666,10 @@ void Gfx::doForm(Object *str) { Dict *dict; GBool transpGroup, isolated, knockout; GfxColorSpace *blendingColorSpace; - Object matrixObj, bboxObj; double m[6], bbox[4]; - Object resObj; Dict *resDict; GBool ocSaved; - Object obj1, obj2, obj3; + Object obj1; int i; // check for excessive recursion @@ -4811,88 +4681,79 @@ void Gfx::doForm(Object *str) { dict = str->streamGetDict(); // check form type - dict->lookup("FormType", &obj1); + obj1 = dict->lookup("FormType"); if (!(obj1.isNull() || (obj1.isInt() && obj1.getInt() == 1))) { error(errSyntaxError, getPos(), "Unknown form type"); } - obj1.free(); // check for optional content key ocSaved = ocState; - dict->lookupNF("OC", &obj1); + obj1 = dict->lookupNF("OC"); if (catalog->getOptContentConfig() && !catalog->getOptContentConfig()->optContentIsVisible(&obj1)) { - obj1.free(); if (out->needCharCount()) { ocState = gFalse; } else { return; } } - obj1.free(); // get bounding box - dict->lookup("BBox", &bboxObj); + Object bboxObj = dict->lookup("BBox"); if (!bboxObj.isArray()) { - bboxObj.free(); error(errSyntaxError, getPos(), "Bad form bounding box"); ocState = ocSaved; return; } for (i = 0; i < 4; ++i) { - bboxObj.arrayGet(i, &obj1); + obj1 = bboxObj.arrayGet(i); if (likely(obj1.isNum())) { bbox[i] = obj1.getNum(); - obj1.free(); } else { - obj1.free(); error(errSyntaxError, getPos(), "Bad form bounding box value"); return; } } - bboxObj.free(); // get matrix - dict->lookup("Matrix", &matrixObj); + Object matrixObj = dict->lookup("Matrix"); if (matrixObj.isArray()) { for (i = 0; i < 6; ++i) { - matrixObj.arrayGet(i, &obj1); + obj1 = matrixObj.arrayGet(i); if (likely(obj1.isNum())) m[i] = obj1.getNum(); else m[i] = 0; - obj1.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } - matrixObj.free(); // get resources - dict->lookup("Resources", &resObj); + Object resObj = dict->lookup("Resources"); resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; // check for a transparency group transpGroup = isolated = knockout = gFalse; blendingColorSpace = NULL; - if (dict->lookup("Group", &obj1)->isDict()) { - if (obj1.dictLookup("S", &obj2)->isName("Transparency")) { - if (!obj1.dictLookup("CS", &obj3)->isNull()) { + obj1 = dict->lookup("Group"); + if (obj1.isDict()) { + Object obj2 = obj1.dictLookup("S"); + if (obj2.isName("Transparency")) { + Object obj3 = obj1.dictLookup("CS"); + if (!obj3.isNull()) { blendingColorSpace = GfxColorSpace::parse(res, &obj3, out, state); } - obj3.free(); - if (obj1.dictLookup("I", &obj3)->isBool()) { + obj3 = obj1.dictLookup("I"); + if (obj3.isBool()) { isolated = obj3.getBool(); } - obj3.free(); - if (obj1.dictLookup("K", &obj3)->isBool()) { + obj3 = obj1.dictLookup("K"); + if (obj3.isBool()) { knockout = obj3.getBool(); } - obj3.free(); transpGroup = isolated || out->checkTransparencyGroup(state, knockout) || checkTransparencyGroup(resDict); } - obj2.free(); } - obj1.free(); // draw it ++formDepth; @@ -4903,7 +4764,6 @@ void Gfx::doForm(Object *str) { if (blendingColorSpace) { delete blendingColorSpace; } - resObj.free(); ocState = ocSaved; } @@ -5044,45 +4904,37 @@ void Gfx::opBeginImage(Object args[], int numArgs) { } Stream *Gfx::buildImageStream() { - Object dict; - Object obj; char *key; Stream *str; // build dictionary - dict.initDict(xref); - parser->getObj(&obj); + Object dict(new Dict(xref)); + Object obj = parser->getObj(); while (!obj.isCmd("ID") && !obj.isEOF()) { if (!obj.isName()) { error(errSyntaxError, getPos(), "Inline image dictionary key must be a name object"); - obj.free(); } else { key = copyString(obj.getName()); - obj.free(); - parser->getObj(&obj); + obj = parser->getObj(); if (obj.isEOF() || obj.isError()) { gfree(key); break; } - dict.dictAdd(key, &obj); + dict.dictAdd(key, std::move(obj)); } - parser->getObj(&obj); + obj = parser->getObj(); } if (obj.isEOF()) { error(errSyntaxError, getPos(), "End of file in inline image"); - obj.free(); - dict.free(); return NULL; } - obj.free(); // make stream if (parser->getStream()) { - str = new EmbedStream(parser->getStream(), &dict, gFalse, 0); - str = str->addFilters(&dict); + str = new EmbedStream(parser->getStream(), std::move(dict), gFalse, 0, gTrue); + str = str->addFilters(str->getDict()); } else { str = NULL; - dict.free(); } return str; @@ -5175,27 +5027,25 @@ void Gfx::opBeginMarkedContent(Object args[], int numArgs) { error(errSyntaxError, getPos(), "Unexpected MC Type: {0:d}", args[1].getType()); } char* name1 = args[1].getName(); - Object markedContent; MarkedContentStack *mc = mcStack; mc->kind = gfxMCOptionalContent; - if ( res->lookupMarkedContentNF( name1, &markedContent ) ) { + Object markedContent = res->lookupMarkedContentNF( name1 ); + if (!markedContent.isNull()) { bool visible = contentConfig->optContentIsVisible(&markedContent); mc->ocSuppressed = !(visible); } else { error(errSyntaxError, getPos(), "DID NOT find {0:s}", name1); } - markedContent.free(); } else { error(errSyntaxError, getPos(), "insufficient arguments for Marked Content"); } } else if (args[0].isName("Span") && numArgs == 2 && args[1].isDict()) { - Object obj; - if (args[1].dictLookup("ActualText", &obj)->isString()) { + Object obj = args[1].dictLookup("ActualText"); + if (obj.isString()) { out->beginActualText(state, obj.getString()); MarkedContentStack *mc = mcStack; mc->kind = gfxMCActualText; } - obj.free(); } if (printCommands) { @@ -5269,7 +5119,6 @@ struct GfxStackStateSaver { void Gfx::drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, double xMin, double yMin, double xMax, double yMax, int rotate) { Dict *dict, *resDict; - Object matrixObj, bboxObj, resObj, obj1; double formXMin, formYMin, formXMax, formYMax; double x, y, sx, sy, tx, ty; double m[6], bbox[4]; @@ -5317,37 +5166,29 @@ void Gfx::drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, dict = str->streamGetDict(); // get the form bounding box - dict->lookup("BBox", &bboxObj); + Object bboxObj = dict->lookup("BBox"); if (!bboxObj.isArray()) { - bboxObj.free(); error(errSyntaxError, getPos(), "Bad form bounding box"); return; } for (i = 0; i < 4; ++i) { - bboxObj.arrayGet(i, &obj1); + Object obj1 = bboxObj.arrayGet(i); if (likely(obj1.isNum())) { bbox[i] = obj1.getNum(); - obj1.free(); } else { - obj1.free(); - bboxObj.free(); error(errSyntaxError, getPos(), "Bad form bounding box value"); return; } } - bboxObj.free(); // get the form matrix - dict->lookup("Matrix", &matrixObj); + Object matrixObj = dict->lookup("Matrix"); if (matrixObj.isArray() && matrixObj.arrayGetLength() >= 6) { for (i = 0; i < 6; ++i) { - matrixObj.arrayGet(i, &obj1); + Object obj1 = matrixObj.arrayGet(i); if (likely(obj1.isNum())) { m[i] = obj1.getNum(); - obj1.free(); } else { - obj1.free(); - matrixObj.free(); error(errSyntaxError, getPos(), "Bad form matrix"); return; } @@ -5357,7 +5198,6 @@ void Gfx::drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } - matrixObj.free(); // transform the four corners of the form bbox to default user // space, and construct the transformed bbox @@ -5430,13 +5270,11 @@ void Gfx::drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor, m[5] = m[5] * sy + ty; // get the resources - dict->lookup("Resources", &resObj); + Object resObj = dict->lookup("Resources"); resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; // draw it drawForm(str, resDict, m, bbox); - - resObj.free(); } // draw the border diff --git a/Build/source/libs/poppler/poppler-src/poppler/Gfx.h b/Build/source/libs/poppler/poppler-src/poppler/Gfx.h index a82f9f4af24..293f4551eaa 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Gfx.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Gfx.h @@ -17,7 +17,7 @@ // Copyright (C) 2007 Iñigo MartÃnez <inigomartinez@gmail.com> // Copyright (C) 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008, 2010 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009-2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009-2013, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009, 2010, 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2010 David Benjamin <davidben@mit.edu> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> @@ -113,14 +113,14 @@ public: ~GfxResources(); GfxFont *lookupFont(char *name); - GBool lookupXObject(char *name, Object *obj); - GBool lookupXObjectNF(char *name, Object *obj); - GBool lookupMarkedContentNF(char *name, Object *obj); - void lookupColorSpace(const char *name, Object *obj); + Object lookupXObject(char *name); + Object lookupXObjectNF(char *name); + Object lookupMarkedContentNF(char *name); + Object lookupColorSpace(const char *name); GfxPattern *lookupPattern(char *name, OutputDev *out, GfxState *state); GfxShading *lookupShading(char *name, OutputDev *out, GfxState *state); - GBool lookupGState(char *name, Object *obj); - GBool lookupGStateNF(char *name, Object *obj); + Object lookupGState(char *name); + Object lookupGStateNF(char *name); GfxResources *getNext() { return next; } @@ -228,6 +228,7 @@ private: Parser *parser; // parser for page content stream(s) std::set<int> formsDrawing; // the forms that are being drawn + std::set<int> charProcDrawing; // the charProc that are being drawn GBool // callback to check for an abort (*abortCheckCbk)(void *data); diff --git a/Build/source/libs/poppler/poppler-src/poppler/GfxFont.cc b/Build/source/libs/poppler/poppler-src/poppler/GfxFont.cc index ea23e03a534..d06eadffbe2 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GfxFont.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/GfxFont.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) 2005, 2006, 2008-2010, 2012, 2014, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2006, 2008-2010, 2012, 2014, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> @@ -29,7 +29,7 @@ // Copyright (C) 2011, 2012, 2014 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Yi Yang <ahyangyi@gmail.com> // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2012, 2017 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013-2016 Jason Crain <jason@aquaticape.us> // Copyright (C) 2014 Olly Betts <olly@survex.com> // @@ -210,15 +210,13 @@ GfxFont *GfxFont::makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict Ref embFontIDA; GfxFontType typeA; GfxFont *font; - Object obj1; // get base font name nameA = NULL; - fontDict->lookup("BaseFont", &obj1); + Object obj1 = fontDict->lookup("BaseFont"); if (obj1.isName()) { nameA = new GooString(obj1.getName()); } - obj1.free(); // get embedded font ID and font type typeA = getFontType(xref, fontDict, &embFontIDA); @@ -290,14 +288,13 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { GfxFontType t, expectedType; FoFiIdentifierType fft; Dict *fontDict2; - Object subtype, fontDesc, obj1, obj2, obj3, obj4; GBool isType0, err; t = fontUnknownType; embID->num = embID->gen = -1; err = gFalse; - fontDict->lookup("Subtype", &subtype); + Object subtype = fontDict->lookup("Subtype"); expectedType = fontUnknownType; isType0 = gFalse; if (subtype.isName("Type1") || subtype.isName("MMType1")) { @@ -314,44 +311,45 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { error(errSyntaxWarning, -1, "Unknown font type: '{0:s}'", subtype.isName() ? subtype.getName() : "???"); } - subtype.free(); fontDict2 = fontDict; - if (fontDict->lookup("DescendantFonts", &obj1)->isArray()) { + Object obj1 = fontDict->lookup("DescendantFonts"); + Object obj2; // Do not move to inside the if + // we need it around so that fontDict2 remains valid + if (obj1.isArray()) { if (obj1.arrayGetLength() == 0) { error(errSyntaxWarning, -1, "Empty DescendantFonts array in font"); - obj2.initNull(); - } else if (obj1.arrayGet(0, &obj2)->isDict()) { - if (!isType0) { - error(errSyntaxWarning, -1, "Non-CID font with DescendantFonts array"); - } - fontDict2 = obj2.getDict(); - fontDict2->lookup("Subtype", &subtype); - if (subtype.isName("CIDFontType0")) { - if (isType0) { - expectedType = fontCIDType0; + } else { + obj2 = obj1.arrayGet(0); + if (obj2.isDict()) { + if (!isType0) { + error(errSyntaxWarning, -1, "Non-CID font with DescendantFonts array"); } - } else if (subtype.isName("CIDFontType2")) { - if (isType0) { - expectedType = fontCIDType2; + fontDict2 = obj2.getDict(); + subtype = fontDict2->lookup("Subtype"); + if (subtype.isName("CIDFontType0")) { + if (isType0) { + expectedType = fontCIDType0; + } + } else if (subtype.isName("CIDFontType2")) { + if (isType0) { + expectedType = fontCIDType2; + } } } - subtype.free(); } - } else { - obj2.initNull(); } - if (fontDict2->lookup("FontDescriptor", &fontDesc)->isDict()) { - if (fontDesc.dictLookupNF("FontFile", &obj3)->isRef()) { + Object fontDesc = fontDict2->lookup("FontDescriptor"); + if (fontDesc.isDict()) { + Object obj3 = fontDesc.dictLookupNF("FontFile"); + if (obj3.isRef()) { *embID = obj3.getRef(); if (expectedType != fontType1) { err = gTrue; } } - obj3.free(); - if (embID->num == -1 && - fontDesc.dictLookupNF("FontFile2", &obj3)->isRef()) { + if (embID->num == -1 && (obj3 = fontDesc.dictLookupNF("FontFile2"), obj3.isRef())) { *embID = obj3.getRef(); if (isType0) { expectedType = fontCIDType2; @@ -359,12 +357,11 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { err = gTrue; } } - obj3.free(); - if (embID->num == -1 && - fontDesc.dictLookupNF("FontFile3", &obj3)->isRef()) { + if (embID->num == -1 && (obj3 = fontDesc.dictLookupNF("FontFile3"), obj3.isRef())) { *embID = obj3.getRef(); - if (obj3.fetch(xref, &obj4)->isStream()) { - obj4.streamGetDict()->lookup("Subtype", &subtype); + Object obj4 = obj3.fetch(xref); + if (obj4.isStream()) { + subtype = obj4.streamGetDict()->lookup("Subtype"); if (subtype.isName("Type1")) { if (expectedType != fontType1) { err = gTrue; @@ -405,18 +402,14 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { error(errSyntaxError, -1, "Unknown font type '{0:s}'", subtype.isName() ? subtype.getName() : "???"); } - subtype.free(); } - obj4.free(); } - obj3.free(); } - fontDesc.free(); t = fontUnknownType; if (embID->num >= 0) { - obj3.initRef(embID->num, embID->gen); - obj3.fetch(xref, &obj4); + Object obj3(embID->num, embID->gen); + Object obj4 = obj3.fetch(xref); if (obj4.isStream()) { obj4.streamReset(); fft = FoFiIdentifier::identifyStream(&readFromStream, obj4.getStream()); @@ -447,8 +440,6 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { break; } } - obj4.free(); - obj3.free(); } if (t == fontUnknownType) { @@ -464,53 +455,46 @@ GfxFontType GfxFont::getFontType(XRef *xref, Dict *fontDict, Ref *embID) { "Mismatch between font type and embedded font file"); } - obj2.free(); - obj1.free(); - return t; } void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { - Object obj1, obj2, obj3, obj4; double t; - int i; // assume Times-Roman by default (for substitution purposes) flags = fontSerif; missingWidth = 0; - if (fontDict->lookup("FontDescriptor", &obj1)->isDict()) { + Object obj1 = fontDict->lookup("FontDescriptor"); + if (obj1.isDict()) { // get flags - if (obj1.dictLookup("Flags", &obj2)->isInt()) { + Object obj2 = obj1.dictLookup("Flags"); + if (obj2.isInt()) { flags = obj2.getInt(); } - obj2.free(); // get name - obj1.dictLookup("FontName", &obj2); + obj2 = obj1.dictLookup("FontName"); if (obj2.isName()) { embFontName = new GooString(obj2.getName()); } - obj2.free(); if (embFontName == NULL) { // get name with typo - obj1.dictLookup("Fontname", &obj2); + obj2 = obj1.dictLookup("Fontname"); if (obj2.isName()) { embFontName = new GooString(obj2.getName()); error(errSyntaxWarning, -1, "The file uses Fontname instead of FontName please notify the creator that the file is broken"); } - obj2.free(); } // get family - obj1.dictLookup("FontFamily", &obj2); + obj2 = obj1.dictLookup("FontFamily"); if (obj2.isString()) family = new GooString(obj2.getString()); - obj2.free(); // get stretch - obj1.dictLookup("FontStretch", &obj2); + obj2 = obj1.dictLookup("FontStretch"); if (obj2.isName()) { if (strcmp(obj2.getName(), "UltraCondensed") == 0) stretch = UltraCondensed; else if (strcmp(obj2.getName(), "ExtraCondensed") == 0) stretch = ExtraCondensed; @@ -523,10 +507,9 @@ void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { else if (strcmp(obj2.getName(), "UltraExpanded") == 0) stretch = UltraExpanded; else error(errSyntaxWarning, -1, "Invalid Font Stretch"); } - obj2.free(); // get weight - obj1.dictLookup("FontWeight", &obj2); + obj2 = obj1.dictLookup("FontWeight"); if (obj2.isNum()) { if (obj2.getNum() == 100) weight = W100; else if (obj2.getNum() == 200) weight = W200; @@ -539,17 +522,15 @@ void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { else if (obj2.getNum() == 900) weight = W900; else error(errSyntaxWarning, -1, "Invalid Font Weight"); } - obj2.free(); // look for MissingWidth - obj1.dictLookup("MissingWidth", &obj2); + obj2 = obj1.dictLookup("MissingWidth"); if (obj2.isNum()) { missingWidth = obj2.getNum(); } - obj2.free(); // get Ascent and Descent - obj1.dictLookup("Ascent", &obj2); + obj2 = obj1.dictLookup("Ascent"); if (obj2.isNum()) { t = 0.001 * obj2.getNum(); // some broken font descriptors specify a negative ascent @@ -562,8 +543,7 @@ void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { ascent = t; } } - obj2.free(); - obj1.dictLookup("Descent", &obj2); + obj2 = obj1.dictLookup("Descent"); if (obj2.isNum()) { t = 0.001 * obj2.getNum(); // some broken font descriptors specify a positive descent @@ -575,36 +555,31 @@ void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { descent = t; } } - obj2.free(); // font FontBBox - if (obj1.dictLookup("FontBBox", &obj2)->isArray()) { - for (i = 0; i < 4 && i < obj2.arrayGetLength(); ++i) { - if (obj2.arrayGet(i, &obj3)->isNum()) { + obj2 = obj1.dictLookup("FontBBox"); + if (obj2.isArray()) { + for (int i = 0; i < 4 && i < obj2.arrayGetLength(); ++i) { + Object obj3 = obj2.arrayGet(i); + if (obj3.isNum()) { fontBBox[i] = 0.001 * obj3.getNum(); } - obj3.free(); } } - obj2.free(); - } - obj1.free(); } CharCodeToUnicode *GfxFont::readToUnicodeCMap(Dict *fontDict, int nBits, CharCodeToUnicode *ctu) { GooString *buf; - Object obj1; - if (!fontDict->lookup("ToUnicode", &obj1)->isStream()) { - obj1.free(); + Object obj1 = fontDict->lookup("ToUnicode"); + if (!obj1.isStream()) { return NULL; } buf = new GooString(); obj1.getStream()->fillGooString(buf); obj1.streamClose(); - obj1.free(); if (ctu) { ctu->mergeCMap(buf, nBits); } else { @@ -619,8 +594,6 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { GfxFontLoc *fontLoc; SysFontType sysFontType; GooString *path, *base14Name, *substName; - PSFontParam16 *psFont16; - Object refObj, embFontObj; int substIdx, fontNum; GBool embed; @@ -631,14 +604,12 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { //----- embedded font if (embFontID.num >= 0) { embed = gTrue; - refObj.initRef(embFontID.num, embFontID.gen); - refObj.fetch(xref, &embFontObj); + Object refObj(embFontID.num, embFontID.gen); + Object embFontObj = refObj.fetch(xref); if (!embFontObj.isStream()) { error(errSyntaxError, -1, "Embedded font object is wrong type"); embed = gFalse; } - embFontObj.free(); - refObj.free(); if (embed) { if (ps) { switch (type) { @@ -743,17 +714,6 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { if (!isCIDFont()) { - //----- 8-bit PS resident font - if (name && ps) { - if ((path = globalParams->getPSResidentFont(name))) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontType1; - fontLoc->path = path; - return fontLoc; - } - } - //----- 8-bit font substitution if (flags & fontFixedWidth) { substIdx = 0; @@ -796,42 +756,6 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { return NULL; } - //----- 16-bit PS resident font - if (ps && ((psFont16 = globalParams->getPSResidentFont16( - name, - ((GfxCIDFont *)this)->getWMode())))) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontCIDType0; // this is not used - fontLoc->path = psFont16->psFontName->copy(); - fontLoc->encoding = psFont16->encoding->copy(); - fontLoc->wMode = psFont16->wMode; - return fontLoc; - } - if (ps && ((psFont16 = globalParams->getPSResidentFontCC( - ((GfxCIDFont *)this)->getCollection(), - ((GfxCIDFont *)this)->getWMode())))) { - error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", - psFont16->psFontName, name); - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontCIDType0; // this is not used - fontLoc->path = psFont16->psFontName->copy(); - fontLoc->encoding = psFont16->encoding->copy(); - fontLoc->wMode = psFont16->wMode; - return fontLoc; - } - - //----- CID font substitution - if ((path = globalParams->findCCFontFile( - ((GfxCIDFont *)this)->getCollection()))) { - if ((fontLoc = getExternalFont(path, gTrue))) { - error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", - fontLoc->path, name); - return fontLoc; - } - } - // failed to find a substitute font return NULL; } @@ -894,15 +818,12 @@ GfxFontLoc *GfxFont::getExternalFont(GooString *path, GBool cid) { char *GfxFont::readEmbFontFile(XRef *xref, int *len) { char *buf; - Object obj1, obj2; Stream *str; - obj1.initRef(embFontID.num, embFontID.gen); - obj1.fetch(xref, &obj2); + Object obj1(embFontID.num, embFontID.gen); + Object obj2 = obj1.fetch(xref); if (!obj2.isStream()) { error(errSyntaxError, -1, "Embedded font file is not a stream"); - obj2.free(); - obj1.free(); embFontID.num = -1; *len = 0; return NULL; @@ -912,9 +833,6 @@ char *GfxFont::readEmbFontFile(XRef *xref, int *len) { buf = (char*)str->toUnsignedChars(len); str->close(); - obj2.free(); - obj1.free(); - return buf; } @@ -995,24 +913,20 @@ static GBool parseNumericName(char *s, GBool hex, unsigned int *u) { // Returns gTrue if the font has character names like xx or Axx which // should be parsed for hex or decimal values. static GBool testForNumericNames(Dict *fontDict, GBool hex) { - Object enc, diff, obj; GBool numeric = gTrue; - fontDict->lookup("Encoding", &enc); + Object enc = fontDict->lookup("Encoding"); if (!enc.isDict()) { - enc.free(); return gFalse; } - enc.dictLookup("Differences", &diff); - enc.free(); + Object diff = enc.dictLookup("Differences"); if (!diff.isArray()) { - diff.free(); return gFalse; } for (int i = 0; i < diff.arrayGetLength() && numeric; ++i) { - diff.arrayGet(i, &obj); + Object obj = diff.arrayGet(i); if (obj.isInt()) { // All sequences must start between character codes 0 and 5. if (obj.getInt() > 5) @@ -1024,10 +938,8 @@ static GBool testForNumericNames(Dict *fontDict, GBool hex) { } else { numeric = gFalse; } - obj.free(); } - diff.free(); return numeric; } @@ -1052,7 +964,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA double mul; int firstChar, lastChar; Gushort w; - Object obj1, obj2, obj3; + Object obj1; int n, i, a, b, m; refCnt = 1; @@ -1130,34 +1042,36 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA // get font matrix fontMat[0] = fontMat[3] = 1; fontMat[1] = fontMat[2] = fontMat[4] = fontMat[5] = 0; - if (fontDict->lookup("FontMatrix", &obj1)->isArray()) { + obj1 = fontDict->lookup("FontMatrix"); + if (obj1.isArray()) { for (i = 0; i < 6 && i < obj1.arrayGetLength(); ++i) { - if (obj1.arrayGet(i, &obj2)->isNum()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isNum()) { fontMat[i] = obj2.getNum(); } - obj2.free(); } } - obj1.free(); // get Type 3 bounding box, font definition, and resources if (type == fontType3) { - if (fontDict->lookup("FontBBox", &obj1)->isArray()) { + obj1 = fontDict->lookup("FontBBox"); + if (obj1.isArray()) { for (i = 0; i < 4 && i < obj1.arrayGetLength(); ++i) { - if (obj1.arrayGet(i, &obj2)->isNum()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isNum()) { fontBBox[i] = obj2.getNum(); } - obj2.free(); } } - obj1.free(); - if (!fontDict->lookup("CharProcs", &charProcs)->isDict()) { + charProcs = fontDict->lookup("CharProcs"); + if (!charProcs.isDict()) { error(errSyntaxError, -1, "Missing or invalid CharProcs dictionary in Type 3 font"); - charProcs.free(); + charProcs.setToNull(); } - if (!fontDict->lookup("Resources", &resources)->isDict()) { - resources.free(); + resources = fontDict->lookup("Resources"); + if (!resources.isDict()) { + resources.setToNull(); } } @@ -1180,9 +1094,9 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA usesMacRomanEnc = gFalse; baseEnc = NULL; baseEncFromFontFile = gFalse; - fontDict->lookup("Encoding", &obj1); + obj1 = fontDict->lookup("Encoding"); if (obj1.isDict()) { - obj1.dictLookup("BaseEncoding", &obj2); + Object obj2 = obj1.dictLookup("BaseEncoding"); if (obj2.isName("MacRomanEncoding")) { hasEncoding = gTrue; usesMacRomanEnc = gTrue; @@ -1194,7 +1108,6 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA hasEncoding = gTrue; baseEnc = winAnsiEncoding; } - obj2.free(); } else if (obj1.isName("MacRomanEncoding")) { hasEncoding = gTrue; usesMacRomanEnc = gTrue; @@ -1298,13 +1211,13 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA // merge differences into encoding if (obj1.isDict()) { - obj1.dictLookup("Differences", &obj2); + Object obj2 = obj1.dictLookup("Differences"); if (obj2.isArray()) { encodingName->Set("Custom"); hasEncoding = gTrue; code = 0; for (i = 0; i < obj2.arrayGetLength(); ++i) { - obj2.arrayGet(i, &obj3); + Object obj3 = obj2.arrayGet(i); if (obj3.isInt()) { code = obj3.getInt(); } else if (obj3.isName()) { @@ -1321,18 +1234,11 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA "Wrong type in font encoding resource differences ({0:s})", obj3.getTypeName()); } - obj3.free(); } } - obj2.free(); - } - obj1.free(); - if (ffT1) { - delete ffT1; - } - if (ffT1C) { - delete ffT1C; } + delete ffT1; + delete ffT1C; //----- build the mapping to Unicode ----- @@ -1405,12 +1311,10 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA continue; } - // if the 'mapUnknownCharNames' flag is set, do a simple pass-through + // do a simple pass-through // mapping for unknown character names - if (globalParams->getMapUnknownCharNames()) { - uBuf[0] = code; - ctu->setMapping((CharCode)code, uBuf, 1); - } + uBuf[0] = code; + ctu->setMapping((CharCode)code, uBuf, 1); } } } @@ -1450,34 +1354,31 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA } // use widths from font dict, if present - fontDict->lookup("FirstChar", &obj1); + obj1 = fontDict->lookup("FirstChar"); firstChar = obj1.isInt() ? obj1.getInt() : 0; - obj1.free(); if (firstChar < 0 || firstChar > 255) { firstChar = 0; } - fontDict->lookup("LastChar", &obj1); + obj1 = fontDict->lookup("LastChar"); lastChar = obj1.isInt() ? obj1.getInt() : 255; - obj1.free(); if (lastChar < 0 || lastChar > 255) { lastChar = 255; } mul = (type == fontType3) ? fontMat[0] : 0.001; - fontDict->lookup("Widths", &obj1); + obj1 = fontDict->lookup("Widths"); if (obj1.isArray()) { flags |= fontFixedWidth; if (obj1.arrayGetLength() < lastChar - firstChar + 1) { lastChar = firstChar + obj1.arrayGetLength() - 1; } for (code = firstChar; code <= lastChar; ++code) { - obj1.arrayGet(code - firstChar, &obj2); + Object obj2 = obj1.arrayGet(code - firstChar); if (obj2.isNum()) { widths[code] = obj2.getNum() * mul; if (fabs(widths[code] - widths[firstChar]) > 0.00001) { flags &= ~fontFixedWidth; } } - obj2.free(); } // use widths from built-in font @@ -1523,7 +1424,6 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA } } } - obj1.free(); ok = gTrue; } @@ -1537,12 +1437,6 @@ Gfx8BitFont::~Gfx8BitFont() { } } ctu->decRefCnt(); - if (charProcs.isDict()) { - charProcs.free(); - } - if (resources.isDict()) { - resources.free(); - } } // This function is in part a derived work of the Adobe Glyph Mapping @@ -1609,54 +1503,52 @@ static int parseCharName(char *charName, Unicode *uBuf, int uLen, if (names && (uBuf[0] = globalParams->mapNameToUnicodeText(charName))) { return 1; } - if (globalParams->getMapNumericCharNames()) { - unsigned int n = strlen(charName); - // 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E - // U+0069) followed by a sequence of uppercase hexadecimal digits (0 .. 9, - // A .. F, i.e. U+0030 .. U+0039, U+0041 .. U+0046), the length of that - // sequence is a multiple of four, and each group of four digits represents - // a number in the set {0x0000 .. 0xD7FF, 0xE000 .. 0xFFFF}, then interpret - // each such number as a Unicode scalar value and map the component to the - // string made of those scalar values. Note that the range and digit length - // restrictions mean that the "uni" prefix can be used only with Unicode - // values from the Basic Multilingual Plane (BMP). - if (n >= 7 && (n % 4) == 3 && !strncmp(charName, "uni", 3)) { - int i; - unsigned int m; - for (i = 0, m = 3; i < uLen && m < n; m += 4) { - if (isxdigit(charName[m]) && isxdigit(charName[m + 1]) && - isxdigit(charName[m + 2]) && isxdigit(charName[m + 3])) { - unsigned int u; - sscanf(charName + m, "%4x", &u); - if (u <= 0xD7FF || (0xE000 <= u && u <= 0xFFFF)) { - uBuf[i++] = u; - } - } - } - return i; - } - // 3.4. otherwise, if the component is of the form "u" (U+0075) followed by - // a sequence of four to six uppercase hexadecimal digits {0 .. 9, A .. F} - // (U+0030 .. U+0039, U+0041 .. U+0046), and those digits represent a - // number in {0x0000 .. 0xD7FF, 0xE000 .. 0x10FFFF}, then interpret this - // number as a Unicode scalar value and map the component to the string - // made of this scalar value. - if (n >= 5 && n <= 7 && charName[0] == 'u' && isxdigit(charName[1]) && - isxdigit(charName[2]) && isxdigit(charName[3]) && isxdigit(charName[4]) - && (n <= 5 || isxdigit(charName[5])) - && (n <= 6 || isxdigit(charName[6]))) { - unsigned int u; - sscanf(charName + 1, "%x", &u); - if (u <= 0xD7FF || (0xE000 <= u && u <= 0x10FFFF)) { - uBuf[0] = u; - return 1; + unsigned int n = strlen(charName); + // 3.3. otherwise, if the component is of the form "uni" (U+0075 U+006E + // U+0069) followed by a sequence of uppercase hexadecimal digits (0 .. 9, + // A .. F, i.e. U+0030 .. U+0039, U+0041 .. U+0046), the length of that + // sequence is a multiple of four, and each group of four digits represents + // a number in the set {0x0000 .. 0xD7FF, 0xE000 .. 0xFFFF}, then interpret + // each such number as a Unicode scalar value and map the component to the + // string made of those scalar values. Note that the range and digit length + // restrictions mean that the "uni" prefix can be used only with Unicode + // values from the Basic Multilingual Plane (BMP). + if (n >= 7 && (n % 4) == 3 && !strncmp(charName, "uni", 3)) { + int i; + unsigned int m; + for (i = 0, m = 3; i < uLen && m < n; m += 4) { + if (isxdigit(charName[m]) && isxdigit(charName[m + 1]) && + isxdigit(charName[m + 2]) && isxdigit(charName[m + 3])) { + unsigned int u; + sscanf(charName + m, "%4x", &u); + if (u <= 0xD7FF || (0xE000 <= u && u <= 0xFFFF)) { + uBuf[i++] = u; + } } } - // Not in Adobe Glyph Mapping convention: look for names like xx - // or Axx and parse for hex or decimal values. - if (numeric && parseNumericName(charName, hex, uBuf)) + return i; + } + // 3.4. otherwise, if the component is of the form "u" (U+0075) followed by + // a sequence of four to six uppercase hexadecimal digits {0 .. 9, A .. F} + // (U+0030 .. U+0039, U+0041 .. U+0046), and those digits represent a + // number in {0x0000 .. 0xD7FF, 0xE000 .. 0x10FFFF}, then interpret this + // number as a Unicode scalar value and map the component to the string + // made of this scalar value. + if (n >= 5 && n <= 7 && charName[0] == 'u' && isxdigit(charName[1]) && + isxdigit(charName[2]) && isxdigit(charName[3]) && isxdigit(charName[4]) + && (n <= 5 || isxdigit(charName[5])) + && (n <= 6 || isxdigit(charName[6]))) { + unsigned int u; + sscanf(charName + 1, "%x", &u); + if (u <= 0xD7FF || (0xE000 <= u && u <= 0x10FFFF)) { + uBuf[0] = u; return 1; + } } + // Not in Adobe Glyph Mapping convention: look for names like xx + // or Axx and parse for hex or decimal values. + if (numeric && parseNumericName(charName, hex, uBuf)) + return 1; // 3.5. otherwise, map the component to the empty string return 0; } @@ -1695,14 +1587,13 @@ int *Gfx8BitFont::getCodeToGIDMap(FoFiTrueType *ff) { // To match up with the Adobe-defined behaviour, we choose a cmap // like this: // 1. If the PDF font has an encoding: - // 1a. If the PDF font specified MacRomanEncoding and the + // 1a. If the TrueType font has a Microsoft Unicode + // cmap or a non-Microsoft Unicode cmap, use it, and use the + // Unicode indexes, not the char codes. + // 1b. If the PDF font specified MacRomanEncoding and the // TrueType font has a Macintosh Roman cmap, use it, and // reverse map the char names through MacRomanEncoding to // get char codes. - // 1b. If the PDF font is not symbolic or the PDF font is not - // embedded, and the TrueType font has a Microsoft Unicode - // cmap or a non-Microsoft Unicode cmap, use it, and use the - // Unicode indexes, not the char codes. // 1c. If the PDF font is symbolic and the TrueType font has a // Microsoft Symbol cmap, use it, and use char codes // directly (possibly with an offset of 0xf000). @@ -1735,13 +1626,12 @@ int *Gfx8BitFont::getCodeToGIDMap(FoFiTrueType *ff) { useMacRoman = gFalse; useUnicode = gFalse; if (hasEncoding || type == fontType1) { - if (usesMacRomanEnc && macRomanCmap >= 0) { - cmap = macRomanCmap; - useMacRoman = gTrue; - } else if ((!(flags & fontSymbolic) || embFontID.num < 0) && - unicodeCmap >= 0) { + if (unicodeCmap >= 0) { cmap = unicodeCmap; useUnicode = gTrue; + } else if (usesMacRomanEnc && macRomanCmap >= 0) { + cmap = macRomanCmap; + useMacRoman = gTrue; } else if ((flags & fontSymbolic) && msSymbolCmap >= 0) { cmap = msSymbolCmap; } else if ((flags & fontSymbolic) && macRomanCmap >= 0) { @@ -1809,13 +1699,20 @@ Dict *Gfx8BitFont::getCharProcs() { return charProcs.isDict() ? charProcs.getDict() : (Dict *)NULL; } -Object *Gfx8BitFont::getCharProc(int code, Object *proc) { +Object Gfx8BitFont::getCharProc(int code) { + if (enc[code] && charProcs.isDict()) { + return charProcs.dictLookup(enc[code]); + } else { + return Object(objNull); + } +} + +Object Gfx8BitFont::getCharProcNF(int code) { if (enc[code] && charProcs.isDict()) { - charProcs.dictLookup(enc[code], proc); + return charProcs.dictLookupNF(enc[code]); } else { - proc->initNull(); + return Object(objNull); } - return proc; } Dict *Gfx8BitFont::getResources() { @@ -1872,17 +1769,16 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, cidToGIDLen = 0; // get the descendant font - if (!fontDict->lookup("DescendantFonts", &obj1)->isArray() || - obj1.arrayGetLength() == 0) { + obj1 = fontDict->lookup("DescendantFonts"); + if (!obj1.isArray() || obj1.arrayGetLength() == 0) { error(errSyntaxError, -1, "Missing or empty DescendantFonts entry in Type 0 font"); - obj1.free(); - goto err1; + return; } - if (!obj1.arrayGet(0, &desFontDictObj)->isDict()) { + desFontDictObj = obj1.arrayGet(0); + if (!desFontDictObj.isDict()) { error(errSyntaxError, -1, "Bad descendant font in Type 0 font"); - goto err3; + return; } - obj1.free(); desFontDict = desFontDictObj.getDict(); // get info from font descriptor @@ -1891,20 +1787,18 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, //----- encoding info ----- // char collection - if (!desFontDict->lookup("CIDSystemInfo", &obj1)->isDict()) { + obj1 = desFontDict->lookup("CIDSystemInfo"); + if (!obj1.isDict()) { error(errSyntaxError, -1, "Missing CIDSystemInfo dictionary in Type 0 descendant font"); - goto err3; + return; } - obj1.dictLookup("Registry", &obj2); - obj1.dictLookup("Ordering", &obj3); + obj2 = obj1.dictLookup("Registry"); + obj3 = obj1.dictLookup("Ordering"); if (!obj2.isString() || !obj3.isString()) { error(errSyntaxError, -1, "Invalid CIDSystemInfo dictionary in Type 0 descendant font"); - goto err3; + return; } collection = obj2.getString()->copy()->append('-')->append(obj3.getString()); - obj3.free(); - obj2.free(); - obj1.free(); // look for a ToUnicode CMap if (!(ctu = readToUnicodeCMap(fontDict, 16, NULL))) { @@ -1933,7 +1827,7 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, for (size_t i = 0; i < sizeof(knownCollections)/sizeof(knownCollections[0]); i++) { if (collection->cmp(knownCollections[i]) == 0) { error(errSyntaxError, -1, "Missing language pack for '{0:t}' mapping", collection); - goto err2; + return; } } error(errSyntaxError, -1, "Unknown character collection '{0:t}'", @@ -1963,14 +1857,14 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } // encoding (i.e., CMap) - if (fontDict->lookup("Encoding", &obj1)->isNull()) { + obj1 = fontDict->lookup("Encoding"); + if (obj1.isNull()) { error(errSyntaxError, -1, "Missing Encoding entry in Type 0 font"); - goto err2; + return; } if (!(cMap = CMap::parse(NULL, collection, &obj1))) { - goto err2; + return; } - obj1.free(); if (cMap->getCMapName()) { encodingName->Set(cMap->getCMapName()->getCString()); } else { @@ -1979,7 +1873,7 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, // CIDToGIDMap (for embedded TrueType fonts) if (type == fontCIDType2 || type == fontCIDType2OT) { - desFontDict->lookup("CIDToGIDMap", &obj1); + obj1 = desFontDict->lookup("CIDToGIDMap"); if (obj1.isStream()) { cidToGIDLen = 0; i = 64; @@ -1996,26 +1890,27 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } else if (!obj1.isName("Identity") && !obj1.isNull()) { error(errSyntaxError, -1, "Invalid CIDToGIDMap entry in CID font"); } - obj1.free(); } //----- character metrics ----- // default char width - if (desFontDict->lookup("DW", &obj1)->isInt()) { + obj1 = desFontDict->lookup("DW"); + if (obj1.isInt()) { widths.defWidth = obj1.getInt() * 0.001; } - obj1.free(); // char width exceptions - if (desFontDict->lookup("W", &obj1)->isArray()) { + obj1 = desFontDict->lookup("W"); + if (obj1.isArray()) { excepsSize = 0; i = 0; while (i + 1 < obj1.arrayGetLength()) { - obj1.arrayGet(i, &obj2); - obj1.arrayGet(i + 1, &obj3); + obj2 = obj1.arrayGet(i); + obj3 = obj1.arrayGet(i + 1); if (obj2.isInt() && obj3.isInt() && i + 2 < obj1.arrayGetLength()) { - if (obj1.arrayGet(i + 2, &obj4)->isNum()) { + obj4 = obj1.arrayGet(i + 2); + if (obj4.isNum()) { if (widths.nExceps == excepsSize) { excepsSize += 16; widths.exceps = (GfxFontCIDWidthExcep *) @@ -2029,7 +1924,6 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } else { error(errSyntaxError, -1, "Bad widths array in Type 0 font"); } - obj4.free(); i += 3; } else if (obj2.isInt() && obj3.isArray()) { if (widths.nExceps + obj3.arrayGetLength() > excepsSize) { @@ -2040,7 +1934,8 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } j = obj2.getInt(); for (k = 0; k < obj3.arrayGetLength(); ++k) { - if (obj3.arrayGet(k, &obj4)->isNum()) { + obj4 = obj3.arrayGet(k); + if (obj4.isNum()) { widths.exceps[widths.nExceps].first = j; widths.exceps[widths.nExceps].last = j; widths.exceps[widths.nExceps].width = obj4.getNum() * 0.001; @@ -2049,46 +1944,43 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } else { error(errSyntaxError, -1, "Bad widths array in Type 0 font"); } - obj4.free(); } i += 2; } else { error(errSyntaxError, -1, "Bad widths array in Type 0 font"); ++i; } - obj3.free(); - obj2.free(); } std::sort(widths.exceps, widths.exceps + widths.nExceps, cmpWidthExcepFunctor()); } - obj1.free(); // default metrics for vertical font - if (desFontDict->lookup("DW2", &obj1)->isArray() && + obj1 = desFontDict->lookup("DW2"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { - if (obj1.arrayGet(0, &obj2)->isNum()) { + obj2 = obj1.arrayGet(0); + if (obj2.isNum()) { widths.defVY = obj2.getNum() * 0.001; } - obj2.free(); - if (obj1.arrayGet(1, &obj2)->isNum()) { + obj2 = obj1.arrayGet(1); + if (obj2.isNum()) { widths.defHeight = obj2.getNum() * 0.001; } - obj2.free(); } - obj1.free(); // char metric exceptions for vertical font - if (desFontDict->lookup("W2", &obj1)->isArray()) { + obj1 = desFontDict->lookup("W2"); + if (obj1.isArray()) { excepsSize = 0; i = 0; while (i + 1 < obj1.arrayGetLength()) { - obj1.arrayGet(i, &obj2); - obj1.arrayGet(i+ 1, &obj3); + obj2 = obj1.arrayGet(i); + obj3 = obj1.arrayGet(i+ 1); if (obj2.isInt() && obj3.isInt() && i + 4 < obj1.arrayGetLength()) { - if (obj1.arrayGet(i + 2, &obj4)->isNum() && - obj1.arrayGet(i + 3, &obj5)->isNum() && - obj1.arrayGet(i + 4, &obj6)->isNum()) { + if ((obj4 = obj1.arrayGet(i + 2), obj4.isNum()) && + (obj5 = obj1.arrayGet(i + 3), obj5.isNum()) && + (obj6 = obj1.arrayGet(i + 4), obj6.isNum())) { if (widths.nExcepsV == excepsSize) { excepsSize += 16; widths.excepsV = (GfxFontCIDWidthExcepV *) @@ -2104,9 +1996,6 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } else { error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); } - obj6.free(); - obj5.free(); - obj4.free(); i += 5; } else if (obj2.isInt() && obj3.isArray()) { if (widths.nExcepsV + obj3.arrayGetLength() / 3 > excepsSize) { @@ -2118,9 +2007,9 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } j = obj2.getInt(); for (k = 0; k < obj3.arrayGetLength(); k += 3) { - if (obj3.arrayGet(k, &obj4)->isNum() && - obj3.arrayGet(k+1, &obj5)->isNum() && - obj3.arrayGet(k+2, &obj6)->isNum()) { + if ((obj4 = obj3.arrayGet(k), obj4.isNum()) && + (obj5 = obj3.arrayGet(k+1), obj5.isNum()) && + (obj6 = obj3.arrayGet(k+2), obj6.isNum())) { widths.excepsV[widths.nExcepsV].first = j; widths.excepsV[widths.nExcepsV].last = j; widths.excepsV[widths.nExcepsV].height = obj4.getNum() * 0.001; @@ -2131,34 +2020,18 @@ GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, } else { error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); } - obj6.free(); - obj5.free(); - obj4.free(); } i += 2; } else { error(errSyntaxError, -1, "Bad widths (W2) array in Type 0 font"); ++i; } - obj3.free(); - obj2.free(); } std::sort(widths.excepsV, widths.excepsV + widths.nExcepsV, cmpWidthExcepVFunctor()); } - obj1.free(); - desFontDictObj.free(); ok = gTrue; - return; - - err3: - obj3.free(); - obj2.free(); - err2: - obj1.free(); - desFontDictObj.free(); - err1:; } GfxCIDFont::~GfxCIDFont() { @@ -2371,7 +2244,7 @@ int *GfxCIDFont::getCodeToGIDMap(FoFiTrueType *ff, int *mapsizep) { Ref embID; *mapsizep = 0; - if (!ctu) return NULL; + if (!ctu || !getCollection()) return NULL; if (getCollection()->cmp("Adobe-Identity") == 0) return NULL; if (getEmbeddedFontID(&embID)) { /* if this font is embedded font, @@ -2560,14 +2433,13 @@ double GfxCIDFont::getWidth (char* s, int len) { GfxFontDict::GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict) { int i; - Object obj1, obj2; Ref r; numFonts = fontDict->getLength(); fonts = (GfxFont **)gmallocn(numFonts, sizeof(GfxFont *)); for (i = 0; i < numFonts; ++i) { - fontDict->getValNF(i, &obj1); - obj1.fetch(xref, &obj2); + Object obj1 = fontDict->getValNF(i); + Object obj2 = obj1.fetch(xref); if (obj2.isDict()) { if (obj1.isRef()) { r = obj1.getRef(); @@ -2596,8 +2468,6 @@ GfxFontDict::GfxFontDict(XRef *xref, Ref *fontDictRef, Dict *fontDict) { error(errSyntaxError, -1, "font resource is not a dictionary"); fonts[i] = NULL; } - obj1.free(); - obj2.free(); } } diff --git a/Build/source/libs/poppler/poppler-src/poppler/GfxFont.h b/Build/source/libs/poppler/poppler-src/poppler/GfxFont.h index 85bdea13785..5985912a8c2 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GfxFont.h +++ b/Build/source/libs/poppler/poppler-src/poppler/GfxFont.h @@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2008, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2008, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> @@ -322,15 +322,15 @@ public: Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, GfxFontType typeA, Ref embFontIDA, Dict *fontDict); - virtual int getNextChar(char *s, int len, CharCode *code, + int getNextChar(char *s, int len, CharCode *code, Unicode **u, int *uLen, - double *dx, double *dy, double *ox, double *oy); + double *dx, double *dy, double *ox, double *oy) override; // Return the encoding. char **getEncoding() { return enc; } // Return the Unicode map. - CharCodeToUnicode *getToUnicode(); + CharCodeToUnicode *getToUnicode() override; // Return the character name associated with <code>. char *getCharName(int code) { return enc[code]; } @@ -352,13 +352,14 @@ public: Dict *getCharProcs(); // Return the Type 3 CharProc for the character associated with <code>. - Object *getCharProc(int code, Object *proc); + Object getCharProc(int code); + Object getCharProcNF(int code); // Return the Type 3 Resources dictionary, or NULL if none. Dict *getResources(); private: - virtual ~Gfx8BitFont(); + ~Gfx8BitFont(); const Base14FontMapEntry *base14; // for Base-14 fonts only; NULL otherwise char *enc[256]; // char code --> char name @@ -384,17 +385,17 @@ public: GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GooString *nameA, GfxFontType typeA, Ref embFontIDA, Dict *fontDict); - virtual GBool isCIDFont() { return gTrue; } + GBool isCIDFont() override { return gTrue; } - virtual int getNextChar(char *s, int len, CharCode *code, + int getNextChar(char *s, int len, CharCode *code, Unicode **u, int *uLen, - double *dx, double *dy, double *ox, double *oy); + double *dx, double *dy, double *ox, double *oy) override; // Return the writing mode (0=horizontal, 1=vertical). - virtual int getWMode(); + int getWMode() override; // Return the Unicode map. - CharCodeToUnicode *getToUnicode(); + CharCodeToUnicode *getToUnicode() override; // Get the collection name (<registry>-<ordering>). GooString *getCollection(); @@ -409,7 +410,7 @@ public: double getWidth(char* s, int len); private: - virtual ~GfxCIDFont(); + ~GfxCIDFont(); int mapCodeToGID(FoFiTrueType *ff, int cmapi, Unicode unicode, GBool wmode); diff --git a/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc b/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc index 6ac18748ade..3ad10381ed8 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/GfxState.cc @@ -16,7 +16,7 @@ // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2006-2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009, 2012 Koji Otani <sho@bbr.jp> // Copyright (C) 2009, 2011-2016 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009 Christian Persch <chpe@gnome.org> @@ -29,6 +29,7 @@ // Copyright (C) 2013 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2015 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2016 Marek Kasik <mkasik@redhat.com> +// Copyright (C) 2017 Oliver Sander <oliver.sander@tu-dresden.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 @@ -178,40 +179,8 @@ static const char *gfxColorSpaceModeNames[] = { static const std::map<unsigned int, unsigned int>::size_type CMSCACHE_LIMIT = 2048; -#ifdef USE_LCMS1 -#include <lcms.h> -#define cmsColorSpaceSignature icColorSpaceSignature -#define cmsSetLogErrorHandler cmsSetErrorHandler -#define cmsSigXYZData icSigXYZData -#define cmsSigLuvData icSigLuvData -#define cmsSigLabData icSigLabData -#define cmsSigYCbCrData icSigYCbCrData -#define cmsSigYxyData icSigYxyData -#define cmsSigRgbData icSigRgbData -#define cmsSigHsvData icSigHsvData -#define cmsSigHlsData icSigHlsData -#define cmsSigCmyData icSigCmyData -#define cmsSig3colorData icSig3colorData -#define cmsSigGrayData icSigGrayData -#define cmsSigCmykData icSigCmykData -#define cmsSig4colorData icSig4colorData -#define cmsSig2colorData icSig2colorData -#define cmsSig5colorData icSig5colorData -#define cmsSig6colorData icSig6colorData -#define cmsSig7colorData icSig7colorData -#define cmsSig8colorData icSig8colorData -#define cmsSig9colorData icSig9colorData -#define cmsSig10colorData icSig10colorData -#define cmsSig11colorData icSig11colorData -#define cmsSig12colorData icSig12colorData -#define cmsSig13colorData icSig13colorData -#define cmsSig14colorData icSig14colorData -#define cmsSig15colorData icSig15colorData -#define LCMS_FLAGS 0 -#else #include <lcms2.h> #define LCMS_FLAGS cmsFLAGS_NOOPTIMIZE | cmsFLAGS_BLACKPOINTCOMPENSATION -#endif #define COLOR_PROFILE_DIR "/ColorProfiles/" #define GLOBAL_COLOR_PROFILE_DIR POPPLER_DATADIR COLOR_PROFILE_DIR @@ -314,40 +283,34 @@ GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev if (csObj->isName()) { if (csObj->isName("DeviceGray") || csObj->isName("G")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultGray", &objCS); + Object objCS = res->lookupColorSpace("DefaultGray"); if (objCS.isNull()) { cs = new GfxDeviceGrayColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceGrayColorSpace(); } } else if (csObj->isName("DeviceRGB") || csObj->isName("RGB")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultRGB", &objCS); + Object objCS = res->lookupColorSpace("DefaultRGB"); if (objCS.isNull()) { cs = new GfxDeviceRGBColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceRGBColorSpace(); } } else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultCMYK", &objCS); + Object objCS = res->lookupColorSpace("DefaultCMYK"); if (objCS.isNull()) { cs = new GfxDeviceCMYKColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceCMYKColorSpace(); } @@ -357,43 +320,37 @@ GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev error(errSyntaxWarning, -1, "Bad color space '{0:s}'", csObj->getName()); } } else if (csObj->isArray() && csObj->arrayGetLength() > 0) { - csObj->arrayGet(0, &obj1); + obj1 = csObj->arrayGet(0); if (obj1.isName("DeviceGray") || obj1.isName("G")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultGray", &objCS); + Object objCS = res->lookupColorSpace("DefaultGray"); if (objCS.isNull()) { cs = new GfxDeviceGrayColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceGrayColorSpace(); } } else if (obj1.isName("DeviceRGB") || obj1.isName("RGB")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultRGB", &objCS); + Object objCS = res->lookupColorSpace("DefaultRGB"); if (objCS.isNull()) { cs = new GfxDeviceRGBColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceRGBColorSpace(); } } else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultCMYK", &objCS); + Object objCS = res->lookupColorSpace("DefaultCMYK"); if (objCS.isNull()) { cs = new GfxDeviceCMYKColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceCMYKColorSpace(); } @@ -416,52 +373,44 @@ GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev } else { error(errSyntaxWarning, -1, "Bad color space"); } - obj1.free(); } else if (csObj->isDict()) { - csObj->dictLookup("ColorSpace", &obj1); + obj1 = csObj->dictLookup("ColorSpace"); if (obj1.isName("DeviceGray")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultGray", &objCS); + Object objCS = res->lookupColorSpace("DefaultGray"); if (objCS.isNull()) { cs = new GfxDeviceGrayColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceGrayColorSpace(); } } else if (obj1.isName("DeviceRGB")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultRGB", &objCS); + Object objCS = res->lookupColorSpace("DefaultRGB"); if (objCS.isNull()) { cs = new GfxDeviceRGBColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceRGBColorSpace(); } } else if (obj1.isName("DeviceCMYK")) { if (res != NULL) { - Object objCS; - res->lookupColorSpace("DefaultCMYK", &objCS); + Object objCS = res->lookupColorSpace("DefaultCMYK"); if (objCS.isNull()) { cs = new GfxDeviceCMYKColorSpace(); } else { cs = GfxColorSpace::parse(NULL, &objCS, out, state); } - objCS.free(); } else { cs = new GfxDeviceCMYKColorSpace(); } } else { error(errSyntaxWarning, -1, "Bad color space dict'"); } - obj1.free(); } else { error(errSyntaxWarning, -1, "Bad color space - expected name or array or dict"); } @@ -517,18 +466,10 @@ cmsHPROFILE loadColorProfile(const char *fileName) return hp; } -#ifdef USE_LCMS1 -static int CMSError(int ecode, const char *msg) -{ - error(errSyntaxWarning, -1, "{0:s}", msg); - return 1; -} -#else static void CMSError(cmsContext /*contextId*/, cmsUInt32Number /*ecode*/, const char *text) { error(errSyntaxWarning, -1, "{0:s}", text); } -#endif int GfxColorSpace::setupColorProfiles() { @@ -830,52 +771,42 @@ static const double xyzrgb[3][3] = { GfxColorSpace *GfxCalGrayColorSpace::parse(Array *arr, GfxState *state) { GfxCalGrayColorSpace *cs; - Object obj1, obj2, obj3; + Object obj1, obj2; - arr->get(1, &obj1); + obj1 = arr->get(1); if (!obj1.isDict()) { error(errSyntaxWarning, -1, "Bad CalGray color space"); - obj1.free(); return NULL; } cs = new GfxCalGrayColorSpace(); - if (obj1.dictLookup("WhitePoint", &obj2)->isArray() && - obj2.arrayGetLength() == 3) { - obj2.arrayGet(0, &obj3); + obj2 = obj1.dictLookup("WhitePoint"); + if (obj2.isArray() && obj2.arrayGetLength() == 3) { + Object obj3 = obj2.arrayGet(0); if (likely(obj3.isNum())) cs->whiteX = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); + obj3 = obj2.arrayGet(1); if (likely(obj3.isNum())) cs->whiteY = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); + obj3 = obj2.arrayGet(2); if (likely(obj3.isNum())) cs->whiteZ = obj3.getNum(); - obj3.free(); } - obj2.free(); - if (obj1.dictLookup("BlackPoint", &obj2)->isArray() && - obj2.arrayGetLength() == 3) { - obj2.arrayGet(0, &obj3); + obj2 = obj1.dictLookup("BlackPoint"); + if (obj2.isArray() && obj2.arrayGetLength() == 3) { + Object obj3 = obj2.arrayGet(0); if (likely(obj3.isNum())) cs->blackX = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); + obj3 = obj2.arrayGet(1); if (likely(obj3.isNum())) cs->blackY = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); + obj3 = obj2.arrayGet(2); if (likely(obj3.isNum())) cs->blackZ = obj3.getNum(); - obj3.free(); } - obj2.free(); - if (obj1.dictLookup("Gamma", &obj2)->isNum()) { + obj2 = obj1.dictLookup("Gamma"); + if (obj2.isNum()) { cs->gamma = obj2.getNum(); } - obj2.free(); - obj1.free(); cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX + xyzrgb[0][1] * cs->whiteY + @@ -1209,75 +1140,59 @@ GfxColorSpace *GfxCalRGBColorSpace::copy() { GfxColorSpace *GfxCalRGBColorSpace::parse(Array *arr, GfxState *state) { GfxCalRGBColorSpace *cs; - Object obj1, obj2, obj3; + Object obj1, obj2; int i; - arr->get(1, &obj1); + obj1 = arr->get(1); if (!obj1.isDict()) { error(errSyntaxWarning, -1, "Bad CalRGB color space"); - obj1.free(); return NULL; } cs = new GfxCalRGBColorSpace(); - if (obj1.dictLookup("WhitePoint", &obj2)->isArray() && - obj2.arrayGetLength() == 3) { - obj2.arrayGet(0, &obj3); + obj2 = obj1.dictLookup("WhitePoint"); + if (obj2.isArray() && obj2.arrayGetLength() == 3) { + Object obj3 = obj2.arrayGet(0); if (likely(obj3.isNum())) cs->whiteX = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); + obj3 = obj2.arrayGet(1); if (likely(obj3.isNum())) cs->whiteY = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); + obj3 = obj2.arrayGet(2); if (likely(obj3.isNum())) cs->whiteZ = obj3.getNum(); - obj3.free(); } - obj2.free(); - if (obj1.dictLookup("BlackPoint", &obj2)->isArray() && - obj2.arrayGetLength() == 3) { - obj2.arrayGet(0, &obj3); + obj2 = obj1.dictLookup("BlackPoint"); + if (obj2.isArray() && obj2.arrayGetLength() == 3) { + Object obj3 = obj2.arrayGet(0); if (likely(obj3.isNum())) cs->blackX = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); + obj3 = obj2.arrayGet(1); if (likely(obj3.isNum())) cs->blackY = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); + obj3 = obj2.arrayGet(2); if (likely(obj3.isNum())) cs->blackZ = obj3.getNum(); - obj3.free(); } - obj2.free(); - if (obj1.dictLookup("Gamma", &obj2)->isArray() && - obj2.arrayGetLength() == 3) { - obj2.arrayGet(0, &obj3); + obj2 = obj1.dictLookup("Gamma"); + if (obj2.isArray() && obj2.arrayGetLength() == 3) { + Object obj3 = obj2.arrayGet(0); if (likely(obj3.isNum())) cs->gammaR = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); + obj3 = obj2.arrayGet(1); if (likely(obj3.isNum())) cs->gammaG = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); + obj3 = obj2.arrayGet(2); if (likely(obj3.isNum())) cs->gammaB = obj3.getNum(); - obj3.free(); } - obj2.free(); - if (obj1.dictLookup("Matrix", &obj2)->isArray() && - obj2.arrayGetLength() == 9) { + obj2 = obj1.dictLookup("Matrix"); + if (obj2.isArray() && obj2.arrayGetLength() == 9) { for (i = 0; i < 9; ++i) { - obj2.arrayGet(i, &obj3); + Object obj3 = obj2.arrayGet(i); if (likely(obj3.isNum())) cs->mat[i] = obj3.getNum(); - obj3.free(); } } - obj2.free(); - obj1.free(); cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX + xyzrgb[0][1] * cs->whiteY + @@ -1596,58 +1511,53 @@ GfxColorSpace *GfxLabColorSpace::copy() { GfxColorSpace *GfxLabColorSpace::parse(Array *arr, GfxState *state) { GfxLabColorSpace *cs; - Object obj1, obj2, obj3; + Object obj1, obj2; - arr->get(1, &obj1); + obj1 = arr->get(1); if (!obj1.isDict()) { error(errSyntaxWarning, -1, "Bad Lab color space"); - obj1.free(); return NULL; } cs = new GfxLabColorSpace(); - if (obj1.dictLookup("WhitePoint", &obj2)->isArray() && - obj2.arrayGetLength() == 3) { - obj2.arrayGet(0, &obj3); - cs->whiteX = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); - cs->whiteY = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); - cs->whiteZ = obj3.getNum(); - obj3.free(); - } - obj2.free(); - if (obj1.dictLookup("BlackPoint", &obj2)->isArray() && - obj2.arrayGetLength() == 3) { - obj2.arrayGet(0, &obj3); - cs->blackX = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); - cs->blackY = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); - cs->blackZ = obj3.getNum(); - obj3.free(); - } - obj2.free(); - if (obj1.dictLookup("Range", &obj2)->isArray() && - obj2.arrayGetLength() == 4) { - obj2.arrayGet(0, &obj3); - cs->aMin = obj3.getNum(); - obj3.free(); - obj2.arrayGet(1, &obj3); - cs->aMax = obj3.getNum(); - obj3.free(); - obj2.arrayGet(2, &obj3); - cs->bMin = obj3.getNum(); - obj3.free(); - obj2.arrayGet(3, &obj3); - cs->bMax = obj3.getNum(); - obj3.free(); - } - obj2.free(); - obj1.free(); + bool ok = true; + obj2 = obj1.dictLookup("WhitePoint"); + if (obj2.isArray() && obj2.arrayGetLength() == 3) { + Object obj3 = obj2.arrayGet(0); + cs->whiteX = obj3.getNum(&ok); + obj3 = obj2.arrayGet(1); + cs->whiteY = obj3.getNum(&ok); + obj3 = obj2.arrayGet(2); + cs->whiteZ = obj3.getNum(&ok); + } + obj2 = obj1.dictLookup("BlackPoint"); + if (obj2.isArray() && obj2.arrayGetLength() == 3) { + Object obj3 = obj2.arrayGet(0); + cs->blackX = obj3.getNum(&ok); + obj3 = obj2.arrayGet(1); + cs->blackY = obj3.getNum(&ok); + obj3 = obj2.arrayGet(2); + cs->blackZ = obj3.getNum(&ok); + } + obj2 = obj1.dictLookup("Range"); + if (obj2.isArray() && obj2.arrayGetLength() == 4) { + Object obj3 = obj2.arrayGet(0); + cs->aMin = obj3.getNum(&ok); + obj3 = obj2.arrayGet(1); + cs->aMax = obj3.getNum(&ok); + obj3 = obj2.arrayGet(2); + cs->bMin = obj3.getNum(&ok); + obj3 = obj2.arrayGet(3); + cs->bMax = obj3.getNum(&ok); + } + + if (!ok) { + error(errSyntaxWarning, -1, "Bad Lab color space"); +#ifdef USE_CMS + cs->transform = nullptr; +#endif + delete cs; + return nullptr; + } cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX + xyzrgb[0][1] * cs->whiteY + @@ -1855,7 +1765,7 @@ class GfxICCBasedColorSpaceKey : public PopplerCacheKey { } - bool operator==(const PopplerCacheKey &key) const + bool operator==(const PopplerCacheKey &key) const override { const GfxICCBasedColorSpaceKey *k = static_cast<const GfxICCBasedColorSpaceKey*>(&key); return k->num == num && k->gen == gen; @@ -1936,14 +1846,13 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState error(errSyntaxError, -1, "Bad ICCBased color space"); return NULL; } - arr->getNF(1, &obj1); + obj1 = arr->getNF(1); if (obj1.isRef()) { iccProfileStreamA = obj1.getRef(); } else { iccProfileStreamA.num = 0; iccProfileStreamA.gen = 0; } - obj1.free(); #ifdef USE_CMS // check cache if (out && iccProfileStreamA.num > 0) { @@ -1973,28 +1882,26 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState } } #endif - arr->get(1, &obj1); + obj1 = arr->get(1); if (!obj1.isStream()) { error(errSyntaxWarning, -1, "Bad ICCBased color space (stream)"); - obj1.free(); return NULL; } dict = obj1.streamGetDict(); - if (!dict->lookup("N", &obj2)->isInt()) { + obj2 = dict->lookup("N"); + if (!obj2.isInt()) { error(errSyntaxWarning, -1, "Bad ICCBased color space (N)"); - obj2.free(); - obj1.free(); - return NULL; + return nullptr; } nCompsA = obj2.getInt(); - obj2.free(); if (nCompsA > 4) { error(errSyntaxError, -1, "ICCBased color space with too many ({0:d} > 4) components", nCompsA); nCompsA = 4; } - if (dict->lookup("Alternate", &obj2)->isNull() || + obj2 = dict->lookup("Alternate"); + if (obj2.isNull() || !(altA = GfxColorSpace::parse(NULL, &obj2, out, state, recursion + 1))) { switch (nCompsA) { case 1: @@ -2008,38 +1915,30 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState break; default: error(errSyntaxWarning, -1, "Bad ICCBased color space - invalid N"); - obj2.free(); - obj1.free(); return NULL; } } - obj2.free(); if (altA->getNComps() != nCompsA) { error(errSyntaxWarning, -1, "Bad ICCBased color space - N doesn't match alt color space"); delete altA; - obj1.free(); return NULL; } cs = new GfxICCBasedColorSpace(nCompsA, altA, &iccProfileStreamA); - if (dict->lookup("Range", &obj2)->isArray() && - obj2.arrayGetLength() == 2 * nCompsA) { + obj2 = dict->lookup("Range"); + if (obj2.isArray() && obj2.arrayGetLength() == 2 * nCompsA) { Object obj4; for (i = 0; i < nCompsA; ++i) { - obj2.arrayGet(2*i, &obj3); - obj2.arrayGet(2*i+1, &obj4); + obj3 = obj2.arrayGet(2*i); + obj4 = obj2.arrayGet(2*i+1); if (obj3.isNum() && obj4.isNum()) { cs->rangeMin[i] = obj3.getNum(); cs->rangeMax[i] = obj4.getNum(); } - obj3.free(); - obj4.free(); } } - obj2.free(); - obj1.free(); #ifdef USE_CMS - arr->get(1, &obj1); + obj1 = arr->get(1); Guchar *profBuf; Stream *iccStream = obj1.getStream(); int length = 0; @@ -2099,7 +1998,6 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState } cmsCloseProfile(hp); } - obj1.free(); // put this colorSpace into cache if (out && iccProfileStreamA.num > 0) { GfxICCBasedColorSpaceKey *k = new GfxICCBasedColorSpaceKey(iccProfileStreamA.num, iccProfileStreamA.gen); @@ -2581,27 +2479,26 @@ GfxColorSpace *GfxIndexedColorSpace::copy() { } GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) { - GfxIndexedColorSpace *cs; GfxColorSpace *baseA; int indexHighA; Object obj1; char *s; - int n, i, j; + int i, j; if (arr->getLength() != 4) { error(errSyntaxWarning, -1, "Bad Indexed color space"); - goto err1; + return nullptr; } - arr->get(1, &obj1); + obj1 = arr->get(1); if (!(baseA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad Indexed color space (base color space)"); - goto err2; + return nullptr; } - obj1.free(); - if (!arr->get(2, &obj1)->isInt()) { + obj1 = arr->get(2); + if (!obj1.isInt()) { error(errSyntaxWarning, -1, "Bad Indexed color space (hival)"); delete baseA; - goto err2; + return nullptr; } indexHighA = obj1.getInt(); if (indexHighA < 0 || indexHighA > 255) { @@ -2614,10 +2511,9 @@ GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, Output else indexHighA = 255; error(errSyntaxWarning, -1, "Bad Indexed color space (invalid indexHigh value, was {0:d} using {1:d} to try to recover)", previousValue, indexHighA); } - obj1.free(); - cs = new GfxIndexedColorSpace(baseA, indexHighA); - arr->get(3, &obj1); - n = baseA->getNComps(); + GfxIndexedColorSpace *cs = new GfxIndexedColorSpace(baseA, indexHighA); + obj1 = arr->get(3); + const int n = baseA->getNComps(); if (obj1.isStream()) { obj1.streamReset(); for (i = 0; i <= indexHighA; ++i) { @@ -2643,15 +2539,11 @@ GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, Output error(errSyntaxWarning, -1, "Bad Indexed color space (lookup table)"); goto err3; } - obj1.free(); return cs; err3: delete cs; - err2: - obj1.free(); - err1: - return NULL; + return nullptr; } GfxColor *GfxIndexedColorSpace::mapColorToBase(GfxColor *color, @@ -2663,7 +2555,7 @@ GfxColor *GfxIndexedColorSpace::mapColorToBase(GfxColor *color, n = base->getNComps(); base->getDefaultRanges(low, range, indexHigh); const int idx = (int)(colToDbl(color->c[0]) + 0.5) * n; - if (likely((idx + n < (indexHigh + 1) * base->getNComps()) && idx >= 0)) { + if (likely((idx + n - 1 < (indexHigh + 1) * base->getNComps()) && idx >= 0)) { p = &lookup[idx]; for (i = 0; i < n; ++i) { baseColor->c[i] = dblToCol(low[i] + (p[i] / 255.0) * range[i]); @@ -2856,19 +2748,18 @@ GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, Out error(errSyntaxWarning, -1, "Bad Separation color space"); goto err1; } - if (!arr->get(1, &obj1)->isName()) { + obj1 = arr->get(1); + if (!obj1.isName()) { error(errSyntaxWarning, -1, "Bad Separation color space (name)"); - goto err2; + goto err1; } nameA = new GooString(obj1.getName()); - obj1.free(); - arr->get(2, &obj1); + obj1 = arr->get(2); if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad Separation color space (alternate color space)"); goto err3; } - obj1.free(); - arr->get(3, &obj1); + obj1 = arr->get(3); if (!(funcA = Function::parse(&obj1))) { goto err4; } @@ -2876,7 +2767,6 @@ GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, Out error(errSyntaxWarning, -1, "Bad SeparationColorSpace function"); goto err5; } - obj1.free(); cs = new GfxSeparationColorSpace(nameA, altA, funcA); return cs; @@ -2886,10 +2776,8 @@ GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, Out delete altA; err3: delete nameA; - err2: - obj1.free(); err1: - return NULL; + return nullptr; } void GfxSeparationColorSpace::getGray(GfxColor *color, GfxGray *gray) { @@ -3131,12 +3019,11 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() { //~ handle the 'None' colorant GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) { - GfxDeviceNColorSpace *cs; int nCompsA; GooString *namesA[gfxColorMaxComps]; GfxColorSpace *altA; Function *funcA; - Object obj1, obj2; + Object obj1; int i; GooList *separationList = new GooList(); @@ -3144,9 +3031,10 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, Output error(errSyntaxWarning, -1, "Bad DeviceN color space"); goto err1; } - if (!arr->get(1, &obj1)->isArray()) { + obj1 = arr->get(1); + if (!obj1.isArray()) { error(errSyntaxWarning, -1, "Bad DeviceN color space (names)"); - goto err2; + goto err1; } nCompsA = obj1.arrayGetLength(); if (nCompsA > gfxColorMaxComps) { @@ -3155,63 +3043,53 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, Output nCompsA = gfxColorMaxComps; } for (i = 0; i < nCompsA; ++i) { - if (!obj1.arrayGet(i, &obj2)->isName()) { + Object obj2 = obj1.arrayGet(i); + if (!obj2.isName()) { error(errSyntaxWarning, -1, "Bad DeviceN color space (names)"); - obj2.free(); - goto err2; + goto err1; } namesA[i] = new GooString(obj2.getName()); - obj2.free(); } - obj1.free(); - arr->get(2, &obj1); + obj1 = arr->get(2); if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad DeviceN color space (alternate color space)"); goto err3; } - obj1.free(); - arr->get(3, &obj1); + obj1 = arr->get(3); if (!(funcA = Function::parse(&obj1))) { goto err4; } - obj1.free(); if (arr->getLength() == 5) { - if (!arr->get(4, &obj1)->isDict()) { + obj1 = arr->get(4); + if (!obj1.isDict()) { error(errSyntaxWarning, -1, "Bad DeviceN color space (attributes)"); - goto err4; + goto err5; } Dict *attribs = obj1.getDict(); - attribs->lookup("Colorants", &obj2); + Object obj2 = attribs->lookup("Colorants"); if (obj2.isDict()) { Dict *colorants = obj2.getDict(); for (i = 0; i < colorants->getLength(); i++) { - Object obj3; - colorants->getVal(i, &obj3); + Object obj3 = colorants->getVal(i); if (obj3.isArray()) { separationList->append(GfxSeparationColorSpace::parse(res, obj3.getArray(), out, state, recursion)); } else { - obj3.free(); - obj2.free(); error(errSyntaxWarning, -1, "Bad DeviceN color space (colorant value entry is not an Array)"); - goto err4; + goto err5; } - obj3.free(); } } - obj2.free(); - obj1.free(); } - cs = new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA, separationList); - return cs; + return new GfxDeviceNColorSpace(nCompsA, namesA, altA, funcA, separationList); + err5: + delete funcA; err4: delete altA; err3: for (i = 0; i < nCompsA; ++i) { delete namesA[i]; } - err2: - obj1.free(); err1: delete separationList; return NULL; @@ -3407,13 +3285,11 @@ GfxColorSpace *GfxPatternColorSpace::parse(GfxResources *res, Array *arr, Output } underA = NULL; if (arr->getLength() == 2) { - arr->get(1, &obj1); + obj1 = arr->get(1); if (!(underA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad Pattern color space (underlying color space)"); - obj1.free(); return NULL; } - obj1.free(); } cs = new GfxPatternColorSpace(underA); return cs; @@ -3446,31 +3322,33 @@ void GfxPatternColorSpace::getDefaultColor(GfxColor *color) { // Pattern //------------------------------------------------------------------------ -GfxPattern::GfxPattern(int typeA) { - type = typeA; +GfxPattern::GfxPattern(int typeA, int patternRefNumA) + : type(typeA) + , patternRefNum(patternRefNumA) +{ + } GfxPattern::~GfxPattern() { } -GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state) { +GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum) { GfxPattern *pattern; Object obj1; if (obj->isDict()) { - obj->dictLookup("PatternType", &obj1); + obj1 = obj->dictLookup("PatternType"); } else if (obj->isStream()) { - obj->streamGetDict()->lookup("PatternType", &obj1); + obj1 = obj->streamGetDict()->lookup("PatternType"); } else { - return NULL; + return nullptr; } pattern = NULL; if (obj1.isInt() && obj1.getInt() == 1) { - pattern = GfxTilingPattern::parse(obj); + pattern = GfxTilingPattern::parse(obj, patternRefNum); } else if (obj1.isInt() && obj1.getInt() == 2) { - pattern = GfxShadingPattern::parse(res, obj, out, state); + pattern = GfxShadingPattern::parse(res, obj, out, state, patternRefNum); } - obj1.free(); return pattern; } @@ -3478,14 +3356,13 @@ GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, Gf // GfxTilingPattern //------------------------------------------------------------------------ -GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) { - GfxTilingPattern *pat; +GfxTilingPattern *GfxTilingPattern::parse(Object *patObj, int patternRefNum) { Dict *dict; int paintTypeA, tilingTypeA; double bboxA[4], matrixA[6]; double xStepA, yStepA; Object resDictA; - Object obj1, obj2; + Object obj1; int i; if (!patObj->isStream()) { @@ -3493,78 +3370,73 @@ GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) { } dict = patObj->streamGetDict(); - if (dict->lookup("PaintType", &obj1)->isInt()) { + obj1 = dict->lookup("PaintType"); + if (obj1.isInt()) { paintTypeA = obj1.getInt(); } else { paintTypeA = 1; error(errSyntaxWarning, -1, "Invalid or missing PaintType in pattern"); } - obj1.free(); - if (dict->lookup("TilingType", &obj1)->isInt()) { + obj1 = dict->lookup("TilingType"); + if (obj1.isInt()) { tilingTypeA = obj1.getInt(); } else { tilingTypeA = 1; error(errSyntaxWarning, -1, "Invalid or missing TilingType in pattern"); } - obj1.free(); bboxA[0] = bboxA[1] = 0; bboxA[2] = bboxA[3] = 1; - if (dict->lookup("BBox", &obj1)->isArray() && - obj1.arrayGetLength() == 4) { + obj1 = dict->lookup("BBox"); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { for (i = 0; i < 4; ++i) { - if (obj1.arrayGet(i, &obj2)->isNum()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isNum()) { bboxA[i] = obj2.getNum(); } - obj2.free(); } } else { error(errSyntaxWarning, -1, "Invalid or missing BBox in pattern"); } - obj1.free(); - if (dict->lookup("XStep", &obj1)->isNum()) { + obj1 = dict->lookup("XStep"); + if (obj1.isNum()) { xStepA = obj1.getNum(); } else { xStepA = 1; error(errSyntaxWarning, -1, "Invalid or missing XStep in pattern"); } - obj1.free(); - if (dict->lookup("YStep", &obj1)->isNum()) { + obj1 = dict->lookup("YStep"); + if (obj1.isNum()) { yStepA = obj1.getNum(); } else { yStepA = 1; error(errSyntaxWarning, -1, "Invalid or missing YStep in pattern"); } - obj1.free(); - if (!dict->lookup("Resources", &resDictA)->isDict()) { - resDictA.free(); - resDictA.initNull(); + resDictA = dict->lookup("Resources"); + if (!resDictA.isDict()) { error(errSyntaxWarning, -1, "Invalid or missing Resources in pattern"); } matrixA[0] = 1; matrixA[1] = 0; matrixA[2] = 0; matrixA[3] = 1; matrixA[4] = 0; matrixA[5] = 0; - if (dict->lookup("Matrix", &obj1)->isArray() && - obj1.arrayGetLength() == 6) { + obj1 = dict->lookup("Matrix"); + if (obj1.isArray() && obj1.arrayGetLength() == 6) { for (i = 0; i < 6; ++i) { - if (obj1.arrayGet(i, &obj2)->isNum()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isNum()) { matrixA[i] = obj2.getNum(); } - obj2.free(); } } - obj1.free(); - pat = new GfxTilingPattern(paintTypeA, tilingTypeA, bboxA, xStepA, yStepA, - &resDictA, matrixA, patObj); - resDictA.free(); - return pat; + return new GfxTilingPattern(paintTypeA, tilingTypeA, bboxA, xStepA, yStepA, + &resDictA, matrixA, patObj, patternRefNum); } GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA, double *bboxA, double xStepA, double yStepA, Object *resDictA, double *matrixA, - Object *contentStreamA): - GfxPattern(1) + Object *contentStreamA, int patternRefNumA) : + GfxPattern(1, patternRefNumA) { int i; @@ -3575,32 +3447,30 @@ GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA, } xStep = xStepA; yStep = yStepA; - resDictA->copy(&resDict); + resDict = resDictA->copy(); for (i = 0; i < 6; ++i) { matrix[i] = matrixA[i]; } - contentStreamA->copy(&contentStream); + contentStream = contentStreamA->copy(); } GfxTilingPattern::~GfxTilingPattern() { - resDict.free(); - contentStream.free(); } GfxPattern *GfxTilingPattern::copy() { return new GfxTilingPattern(paintType, tilingType, bbox, xStep, yStep, - &resDict, matrix, &contentStream); + &resDict, matrix, &contentStream, getPatternRefNum()); } //------------------------------------------------------------------------ // GfxShadingPattern //------------------------------------------------------------------------ -GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state) { +GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum) { Dict *dict; GfxShading *shadingA; double matrixA[6]; - Object obj1, obj2; + Object obj1; int i; if (!patObj->isDict()) { @@ -3608,9 +3478,8 @@ GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, O } dict = patObj->getDict(); - dict->lookup("Shading", &obj1); + obj1 = dict->lookup("Shading"); shadingA = GfxShading::parse(res, &obj1, out, state); - obj1.free(); if (!shadingA) { return NULL; } @@ -3618,22 +3487,21 @@ GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, O matrixA[0] = 1; matrixA[1] = 0; matrixA[2] = 0; matrixA[3] = 1; matrixA[4] = 0; matrixA[5] = 0; - if (dict->lookup("Matrix", &obj1)->isArray() && - obj1.arrayGetLength() == 6) { + obj1 = dict->lookup("Matrix"); + if (obj1.isArray() && obj1.arrayGetLength() == 6) { for (i = 0; i < 6; ++i) { - if (obj1.arrayGet(i, &obj2)->isNum()) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isNum()) { matrixA[i] = obj2.getNum(); } - obj2.free(); } } - obj1.free(); - return new GfxShadingPattern(shadingA, matrixA); + return new GfxShadingPattern(shadingA, matrixA, patternRefNum); } -GfxShadingPattern::GfxShadingPattern(GfxShading *shadingA, double *matrixA): - GfxPattern(2) +GfxShadingPattern::GfxShadingPattern(GfxShading *shadingA, double *matrixA, int patternRefNumA): + GfxPattern(2, patternRefNumA) { int i; @@ -3648,7 +3516,7 @@ GfxShadingPattern::~GfxShadingPattern() { } GfxPattern *GfxShadingPattern::copy() { - return new GfxShadingPattern(shading->copy(), matrix); + return new GfxShadingPattern(shading->copy(), matrix, getPatternRefNum()); } //------------------------------------------------------------------------ @@ -3696,13 +3564,12 @@ GfxShading *GfxShading::parse(GfxResources *res, Object *obj, OutputDev *out, Gf return NULL; } - if (!dict->lookup("ShadingType", &obj1)->isInt()) { + obj1 = dict->lookup("ShadingType"); + if (!obj1.isInt()) { error(errSyntaxWarning, -1, "Invalid ShadingType in shading dictionary"); - obj1.free(); return NULL; } typeA = obj1.getInt(); - obj1.free(); switch (typeA) { case 1: @@ -3758,43 +3625,41 @@ GfxShading *GfxShading::parse(GfxResources *res, Object *obj, OutputDev *out, Gf } GBool GfxShading::init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) { - Object obj1, obj2; + Object obj1; int i; - dict->lookup("ColorSpace", &obj1); + obj1 = dict->lookup("ColorSpace"); if (!(colorSpace = GfxColorSpace::parse(res, &obj1, out, state))) { error(errSyntaxWarning, -1, "Bad color space in shading dictionary"); - obj1.free(); return gFalse; } - obj1.free(); for (i = 0; i < gfxColorMaxComps; ++i) { background.c[i] = 0; } hasBackground = gFalse; - if (dict->lookup("Background", &obj1)->isArray()) { + obj1 = dict->lookup("Background"); + if (obj1.isArray()) { if (obj1.arrayGetLength() == colorSpace->getNComps()) { hasBackground = gTrue; for (i = 0; i < colorSpace->getNComps(); ++i) { - background.c[i] = dblToCol(obj1.arrayGet(i, &obj2)->getNum()); - obj2.free(); + Object obj2 = obj1.arrayGet(i); + background.c[i] = dblToCol(obj2.getNum()); } } else { error(errSyntaxWarning, -1, "Bad Background in shading dictionary"); } } - obj1.free(); xMin = yMin = xMax = yMax = 0; hasBBox = gFalse; - if (dict->lookup("BBox", &obj1)->isArray()) { + obj1 = dict->lookup("BBox"); + if (obj1.isArray()) { if (obj1.arrayGetLength() == 4) { - Object obj3, obj4, obj5; - obj1.arrayGet(0, &obj2); - obj1.arrayGet(1, &obj3); - obj1.arrayGet(2, &obj4); - obj1.arrayGet(3, &obj5); + Object obj2 = obj1.arrayGet(0); + Object obj3 = obj1.arrayGet(1); + Object obj4 = obj1.arrayGet(2); + Object obj5 = obj1.arrayGet(3); if (obj2.isNum() && obj3.isNum() && obj4.isNum() && obj5.isNum()) { hasBBox = gTrue; @@ -3805,15 +3670,10 @@ GBool GfxShading::init(GfxResources *res, Dict *dict, OutputDev *out, GfxState * } else { error(errSyntaxWarning, -1, "Bad BBox in shading dictionary (Values not numbers)"); } - obj2.free(); - obj3.free(); - obj4.free(); - obj5.free(); } else { error(errSyntaxWarning, -1, "Bad BBox in shading dictionary"); } } - obj1.free(); return gTrue; } @@ -3875,65 +3735,53 @@ GfxFunctionShading *GfxFunctionShading::parse(GfxResources *res, Dict *dict, Out double matrixA[6]; Function *funcsA[gfxColorMaxComps]; int nFuncsA; - Object obj1, obj2; + Object obj1; int i; x0A = y0A = 0; x1A = y1A = 1; - if (dict->lookup("Domain", &obj1)->isArray() && - obj1.arrayGetLength() == 4) { - x0A = obj1.arrayGet(0, &obj2)->getNum(); - obj2.free(); - x1A = obj1.arrayGet(1, &obj2)->getNum(); - obj2.free(); - y0A = obj1.arrayGet(2, &obj2)->getNum(); - obj2.free(); - y1A = obj1.arrayGet(3, &obj2)->getNum(); - obj2.free(); - } - obj1.free(); + obj1 = dict->lookup("Domain"); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { + Object obj2; + x0A = (obj2 = obj1.arrayGet(0), obj2.getNum()); + x1A = (obj2 = obj1.arrayGet(1), obj2.getNum()); + y0A = (obj2 = obj1.arrayGet(2), obj2.getNum()); + y1A = (obj2 = obj1.arrayGet(3), obj2.getNum()); + } matrixA[0] = 1; matrixA[1] = 0; matrixA[2] = 0; matrixA[3] = 1; matrixA[4] = 0; matrixA[5] = 0; - if (dict->lookup("Matrix", &obj1)->isArray() && - obj1.arrayGetLength() == 6) { - matrixA[0] = obj1.arrayGet(0, &obj2)->getNum(); - obj2.free(); - matrixA[1] = obj1.arrayGet(1, &obj2)->getNum(); - obj2.free(); - matrixA[2] = obj1.arrayGet(2, &obj2)->getNum(); - obj2.free(); - matrixA[3] = obj1.arrayGet(3, &obj2)->getNum(); - obj2.free(); - matrixA[4] = obj1.arrayGet(4, &obj2)->getNum(); - obj2.free(); - matrixA[5] = obj1.arrayGet(5, &obj2)->getNum(); - obj2.free(); - } - obj1.free(); - - dict->lookup("Function", &obj1); + obj1 = dict->lookup("Matrix"); + if (obj1.isArray() && obj1.arrayGetLength() == 6) { + Object obj2; + matrixA[0] = (obj2 = obj1.arrayGet(0), obj2.getNum()); + matrixA[1] = (obj2 = obj1.arrayGet(1), obj2.getNum()); + matrixA[2] = (obj2 = obj1.arrayGet(2), obj2.getNum()); + matrixA[3] = (obj2 = obj1.arrayGet(3), obj2.getNum()); + matrixA[4] = (obj2 = obj1.arrayGet(4), obj2.getNum()); + matrixA[5] = (obj2 = obj1.arrayGet(5), obj2.getNum()); + } + + obj1 = dict->lookup("Function"); if (obj1.isArray()) { nFuncsA = obj1.arrayGetLength(); if (nFuncsA > gfxColorMaxComps || nFuncsA <= 0) { error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary"); - goto err1; + return nullptr; } for (i = 0; i < nFuncsA; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (!(funcsA[i] = Function::parse(&obj2))) { - goto err2; + return nullptr; } - obj2.free(); } } else { nFuncsA = 1; if (!(funcsA[0] = Function::parse(&obj1))) { - goto err1; + return nullptr; } } - obj1.free(); shading = new GfxFunctionShading(x0A, y0A, x1A, y1A, matrixA, funcsA, nFuncsA); @@ -3942,12 +3790,6 @@ GfxFunctionShading *GfxFunctionShading::parse(GfxResources *res, Dict *dict, Out return NULL; } return shading; - - err2: - obj2.free(); - err1: - obj1.free(); - return NULL; } GfxShading *GfxFunctionShading::copy() { @@ -4034,11 +3876,17 @@ GfxUnivariateShading::~GfxUnivariateShading() { void GfxUnivariateShading::getColor(double t, GfxColor *color) { double out[gfxColorMaxComps]; - int i, nComps; + int i; // NB: there can be one function with n outputs or n functions with // one output each (where n = number of color components) - nComps = nFuncs * funcs[0]->getOutputSize(); + const int nComps = nFuncs * funcs[0]->getOutputSize(); + + if (unlikely(nFuncs < 1 || nComps > gfxColorMaxComps)) { + for (int i = 0; i < gfxColorMaxComps; i++) + color->c[i] = 0; + return; + } if (cacheSize > 0) { double x, ix, *l, *u, *upper; @@ -4089,6 +3937,9 @@ void GfxUnivariateShading::setupCache(const Matrix *ctm, cacheBounds = NULL; cacheSize = 0; + if (unlikely(nFuncs < 1)) + return; + // NB: there can be one function with n outputs or n functions with // one output each (where n = number of color components) nComps = nFuncs * funcs[0]->getOutputSize(); @@ -4195,104 +4046,83 @@ GfxAxialShading *GfxAxialShading::parse(GfxResources *res, Dict *dict, OutputDev Function *funcsA[gfxColorMaxComps]; int nFuncsA; GBool extend0A, extend1A; - Object obj1, obj2; + Object obj1; int i; x0A = y0A = x1A = y1A = 0; - if (dict->lookup("Coords", &obj1)->isArray() && - obj1.arrayGetLength() == 4) { - Object obj3, obj4, obj5; - obj1.arrayGet(0, &obj2); - obj1.arrayGet(1, &obj3); - obj1.arrayGet(2, &obj4); - obj1.arrayGet(3, &obj5); + obj1 = dict->lookup("Coords"); + if (obj1.isArray() && obj1.arrayGetLength() == 4) { + Object obj2 = obj1.arrayGet(0); + Object obj3 = obj1.arrayGet(1); + Object obj4 = obj1.arrayGet(2); + Object obj5 = obj1.arrayGet(3); if (obj2.isNum() && obj3.isNum() && obj4.isNum() && obj5.isNum()) { x0A = obj2.getNum(); y0A = obj3.getNum(); x1A = obj4.getNum(); y1A = obj5.getNum(); } - obj2.free(); - obj3.free(); - obj4.free(); - obj5.free(); } else { error(errSyntaxWarning, -1, "Missing or invalid Coords in shading dictionary"); - goto err1; + return nullptr; } - obj1.free(); t0A = 0; t1A = 1; - if (dict->lookup("Domain", &obj1)->isArray() && - obj1.arrayGetLength() == 2) { - Object obj3; - obj1.arrayGet(0, &obj2); - obj1.arrayGet(1, &obj3); + obj1 = dict->lookup("Domain"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + Object obj2 = obj1.arrayGet(0); + Object obj3 = obj1.arrayGet(1); if (obj2.isNum() && obj3.isNum()) { t0A = obj2.getNum(); t1A = obj3.getNum(); } - obj2.free(); - obj3.free(); } - obj1.free(); - dict->lookup("Function", &obj1); + obj1 = dict->lookup("Function"); if (obj1.isArray()) { nFuncsA = obj1.arrayGetLength(); if (nFuncsA > gfxColorMaxComps || nFuncsA == 0) { error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary"); - goto err1; + return nullptr; } for (i = 0; i < nFuncsA; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (!(funcsA[i] = Function::parse(&obj2))) { - obj1.free(); - obj2.free(); - goto err1; + return nullptr; } - obj2.free(); } } else { nFuncsA = 1; if (!(funcsA[0] = Function::parse(&obj1))) { - obj1.free(); - goto err1; + return nullptr; } } - obj1.free(); extend0A = extend1A = gFalse; - if (dict->lookup("Extend", &obj1)->isArray() && - obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); + obj1 = dict->lookup("Extend"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + Object obj2 = obj1.arrayGet(0); if (obj2.isBool()) { extend0A = obj2.getBool(); } else { error(errSyntaxWarning, -1, "Invalid axial shading extend (0)"); } - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); if (obj2.isBool()) { extend1A = obj2.getBool(); } else { error(errSyntaxWarning, -1, "Invalid axial shading extend (1)"); } - obj2.free(); } - obj1.free(); shading = new GfxAxialShading(x0A, y0A, x1A, y1A, t0A, t1A, funcsA, nFuncsA, extend0A, extend1A); if (!shading->init(res, dict, out, state)) { delete shading; - return NULL; + shading = nullptr; } return shading; - - err1: - return NULL; } GfxShading *GfxAxialShading::copy() { @@ -4403,75 +4233,60 @@ GfxRadialShading *GfxRadialShading::parse(GfxResources *res, Dict *dict, OutputD Function *funcsA[gfxColorMaxComps]; int nFuncsA; GBool extend0A, extend1A; - Object obj1, obj2; + Object obj1; int i; x0A = y0A = r0A = x1A = y1A = r1A = 0; - if (dict->lookup("Coords", &obj1)->isArray() && - obj1.arrayGetLength() == 6) { - x0A = obj1.arrayGet(0, &obj2)->getNum(); - obj2.free(); - y0A = obj1.arrayGet(1, &obj2)->getNum(); - obj2.free(); - r0A = obj1.arrayGet(2, &obj2)->getNum(); - obj2.free(); - x1A = obj1.arrayGet(3, &obj2)->getNum(); - obj2.free(); - y1A = obj1.arrayGet(4, &obj2)->getNum(); - obj2.free(); - r1A = obj1.arrayGet(5, &obj2)->getNum(); - obj2.free(); + obj1 = dict->lookup("Coords"); + if (obj1.isArray() && obj1.arrayGetLength() == 6) { + Object obj2; + x0A = (obj2 = obj1.arrayGet(0), obj2.getNum()); + y0A = (obj2 = obj1.arrayGet(1), obj2.getNum()); + r0A = (obj2 = obj1.arrayGet(2), obj2.getNum()); + x1A = (obj2 = obj1.arrayGet(3), obj2.getNum()); + y1A = (obj2 = obj1.arrayGet(4), obj2.getNum()); + r1A = (obj2 = obj1.arrayGet(5), obj2.getNum()); } else { error(errSyntaxWarning, -1, "Missing or invalid Coords in shading dictionary"); - goto err1; + return nullptr; } - obj1.free(); t0A = 0; t1A = 1; - if (dict->lookup("Domain", &obj1)->isArray() && - obj1.arrayGetLength() == 2) { - t0A = obj1.arrayGet(0, &obj2)->getNum(); - obj2.free(); - t1A = obj1.arrayGet(1, &obj2)->getNum(); - obj2.free(); + obj1 = dict->lookup("Domain"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + Object obj2; + t0A = (obj2 = obj1.arrayGet(0), obj2.getNum()); + t1A = (obj2 = obj1.arrayGet(1), obj2.getNum()); } - obj1.free(); - dict->lookup("Function", &obj1); + obj1 = dict->lookup("Function"); if (obj1.isArray()) { nFuncsA = obj1.arrayGetLength(); if (nFuncsA > gfxColorMaxComps) { error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary"); - goto err1; + return nullptr; } for (i = 0; i < nFuncsA; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (!(funcsA[i] = Function::parse(&obj2))) { - obj1.free(); - obj2.free(); - goto err1; + return nullptr; } - obj2.free(); } } else { nFuncsA = 1; if (!(funcsA[0] = Function::parse(&obj1))) { - obj1.free(); - goto err1; + return nullptr; } } - obj1.free(); extend0A = extend1A = gFalse; - if (dict->lookup("Extend", &obj1)->isArray() && - obj1.arrayGetLength() == 2) { - extend0A = obj1.arrayGet(0, &obj2)->getBool(); - obj2.free(); - extend1A = obj1.arrayGet(1, &obj2)->getBool(); - obj2.free(); + obj1 = dict->lookup("Extend"); + if (obj1.isArray() && obj1.arrayGetLength() == 2) { + Object obj2; + extend0A = (obj2 = obj1.arrayGet(0), obj2.getBool()); + extend1A = (obj2 = obj1.arrayGet(1), obj2.getBool()); } - obj1.free(); shading = new GfxRadialShading(x0A, y0A, r0A, x1A, y1A, r1A, t0A, t1A, funcsA, nFuncsA, extend0A, extend1A); @@ -4480,9 +4295,6 @@ GfxRadialShading *GfxRadialShading::parse(GfxResources *res, Dict *dict, OutputD return NULL; } return shading; - - err1: - return NULL; } GfxShading *GfxRadialShading::copy() { @@ -4934,94 +4746,84 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(GfxResources *res, i Guint x, y, flag; Guint c[gfxColorMaxComps]; GfxShadingBitBuf *bitBuf; - Object obj1, obj2; + Object obj1; int i, j, k, state; - if (dict->lookup("BitsPerCoordinate", &obj1)->isInt()) { + obj1 = dict->lookup("BitsPerCoordinate"); + if (obj1.isInt()) { coordBits = obj1.getInt(); } else { error(errSyntaxWarning, -1, "Missing or invalid BitsPerCoordinate in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); - if (dict->lookup("BitsPerComponent", &obj1)->isInt()) { + obj1 = dict->lookup("BitsPerComponent"); + if (obj1.isInt()) { compBits = obj1.getInt(); } else { error(errSyntaxWarning, -1, "Missing or invalid BitsPerComponent in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); flagBits = vertsPerRow = 0; // make gcc happy if (typeA == 4) { - if (dict->lookup("BitsPerFlag", &obj1)->isInt()) { + obj1 = dict->lookup("BitsPerFlag"); + if (obj1.isInt()) { flagBits = obj1.getInt(); } else { error(errSyntaxWarning, -1, "Missing or invalid BitsPerFlag in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); } else { - if (dict->lookup("VerticesPerRow", &obj1)->isInt()) { + obj1 = dict->lookup("VerticesPerRow"); + if (obj1.isInt()) { vertsPerRow = obj1.getInt(); } else { error(errSyntaxWarning, -1, "Missing or invalid VerticesPerRow in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); } - if (dict->lookup("Decode", &obj1)->isArray() && - obj1.arrayGetLength() >= 6) { - xMin = obj1.arrayGet(0, &obj2)->getNum(); - obj2.free(); - xMax = obj1.arrayGet(1, &obj2)->getNum(); - obj2.free(); + obj1 = dict->lookup("Decode"); + if (obj1.isArray() && obj1.arrayGetLength() >= 6) { + Object obj2; + xMin = (obj2 = obj1.arrayGet(0), obj2.getNum()); + xMax = (obj2 = obj1.arrayGet(1), obj2.getNum()); xMul = (xMax - xMin) / (pow(2.0, coordBits) - 1); - yMin = obj1.arrayGet(2, &obj2)->getNum(); - obj2.free(); - yMax = obj1.arrayGet(3, &obj2)->getNum(); - obj2.free(); + yMin = (obj2 = obj1.arrayGet(2), obj2.getNum()); + yMax = (obj2 = obj1.arrayGet(3), obj2.getNum()); yMul = (yMax - yMin) / (pow(2.0, coordBits) - 1); for (i = 0; 5 + 2*i < obj1.arrayGetLength() && i < gfxColorMaxComps; ++i) { - cMin[i] = obj1.arrayGet(4 + 2*i, &obj2)->getNum(); - obj2.free(); - cMax[i] = obj1.arrayGet(5 + 2*i, &obj2)->getNum(); - obj2.free(); + cMin[i] = (obj2 = obj1.arrayGet(4 + 2*i), obj2.getNum()); + cMax[i] = (obj2 = obj1.arrayGet(5 + 2*i), obj2.getNum()); cMul[i] = (cMax[i] - cMin[i]) / (double)((1 << compBits) - 1); } nComps = i; } else { error(errSyntaxWarning, -1, "Missing or invalid Decode array in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); - if (!dict->lookup("Function", &obj1)->isNull()) { + obj1 = dict->lookup("Function"); + if (!obj1.isNull()) { if (obj1.isArray()) { nFuncsA = obj1.arrayGetLength(); if (nFuncsA > gfxColorMaxComps) { error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary"); - goto err1; + return nullptr; } for (i = 0; i < nFuncsA; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (!(funcsA[i] = Function::parse(&obj2))) { - obj1.free(); - obj2.free(); - goto err1; + return nullptr; } - obj2.free(); } } else { nFuncsA = 1; if (!(funcsA[0] = Function::parse(&obj1))) { - obj1.free(); - goto err1; + return nullptr; } } } else { nFuncsA = 0; } - obj1.free(); nVerticesA = nTrianglesA = 0; verticesA = NULL; @@ -5120,11 +4922,6 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(GfxResources *res, i return NULL; } return shading; - - err2: - obj1.free(); - err1: - return NULL; } GfxShading *GfxGouraudTriangleShading::copy() { @@ -5285,83 +5082,79 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di double c[4][gfxColorMaxComps]; Guint ci; GfxShadingBitBuf *bitBuf; - Object obj1, obj2; + Object obj1; int i, j; - if (dict->lookup("BitsPerCoordinate", &obj1)->isInt()) { + obj1 = dict->lookup("BitsPerCoordinate"); + if (obj1.isInt()) { coordBits = obj1.getInt(); } else { error(errSyntaxWarning, -1, "Missing or invalid BitsPerCoordinate in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); - if (dict->lookup("BitsPerComponent", &obj1)->isInt()) { + obj1 = dict->lookup("BitsPerComponent"); + if (obj1.isInt()) { compBits = obj1.getInt(); } else { error(errSyntaxWarning, -1, "Missing or invalid BitsPerComponent in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); - if (dict->lookup("BitsPerFlag", &obj1)->isInt()) { + obj1 = dict->lookup("BitsPerFlag"); + if (obj1.isInt()) { flagBits = obj1.getInt(); } else { error(errSyntaxWarning, -1, "Missing or invalid BitsPerFlag in shading dictionary"); - goto err2; - } - obj1.free(); - if (dict->lookup("Decode", &obj1)->isArray() && - obj1.arrayGetLength() >= 6) { - xMin = obj1.arrayGet(0, &obj2)->getNum(); - obj2.free(); - xMax = obj1.arrayGet(1, &obj2)->getNum(); - obj2.free(); + return nullptr; + } + obj1 = dict->lookup("Decode"); + if (obj1.isArray() && obj1.arrayGetLength() >= 6) { + bool decodeOk = true; + Object obj2; + xMin = (obj2 = obj1.arrayGet(0), obj2.getNum(&decodeOk)); + xMax = (obj2 = obj1.arrayGet(1), obj2.getNum(&decodeOk)); xMul = (xMax - xMin) / (pow(2.0, coordBits) - 1); - yMin = obj1.arrayGet(2, &obj2)->getNum(); - obj2.free(); - yMax = obj1.arrayGet(3, &obj2)->getNum(); - obj2.free(); + yMin = (obj2 = obj1.arrayGet(2), obj2.getNum(&decodeOk)); + yMax = (obj2 = obj1.arrayGet(3), obj2.getNum(&decodeOk)); yMul = (yMax - yMin) / (pow(2.0, coordBits) - 1); for (i = 0; 5 + 2*i < obj1.arrayGetLength() && i < gfxColorMaxComps; ++i) { - cMin[i] = obj1.arrayGet(4 + 2*i, &obj2)->getNum(); - obj2.free(); - cMax[i] = obj1.arrayGet(5 + 2*i, &obj2)->getNum(); - obj2.free(); + cMin[i] = (obj2 = obj1.arrayGet(4 + 2*i), obj2.getNum(&decodeOk)); + cMax[i] = (obj2 = obj1.arrayGet(5 + 2*i), obj2.getNum(&decodeOk)); cMul[i] = (cMax[i] - cMin[i]) / (double)((1 << compBits) - 1); } nComps = i; + + if (!decodeOk) { + error(errSyntaxWarning, -1, "Missing or invalid Decode array in shading dictionary"); + return nullptr; + } } else { error(errSyntaxWarning, -1, "Missing or invalid Decode array in shading dictionary"); - goto err2; + return nullptr; } - obj1.free(); - if (!dict->lookup("Function", &obj1)->isNull()) { + obj1 = dict->lookup("Function"); + if (!obj1.isNull()) { if (obj1.isArray()) { nFuncsA = obj1.arrayGetLength(); if (nFuncsA > gfxColorMaxComps) { error(errSyntaxWarning, -1, "Invalid Function array in shading dictionary"); - goto err1; + return nullptr; } for (i = 0; i < nFuncsA; ++i) { - obj1.arrayGet(i, &obj2); + Object obj2 = obj1.arrayGet(i); if (!(funcsA[i] = Function::parse(&obj2))) { - obj1.free(); - obj2.free(); - goto err1; + return nullptr; } - obj2.free(); } } else { nFuncsA = 1; if (!(funcsA[0] = Function::parse(&obj1))) { - obj1.free(); - goto err1; + return nullptr; } } } else { nFuncsA = 0; } - obj1.free(); nPatchesA = 0; patchesA = NULL; @@ -5462,7 +5255,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di break; case 1: if (nPatchesA == 0) { - goto err1; + return nullptr; } p->x[0][0] = patchesA[nPatchesA-1].x[0][3]; p->y[0][0] = patchesA[nPatchesA-1].y[0][3]; @@ -5497,7 +5290,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di break; case 2: if (nPatchesA == 0) { - goto err1; + return nullptr; } p->x[0][0] = patchesA[nPatchesA-1].x[3][3]; p->y[0][0] = patchesA[nPatchesA-1].y[3][3]; @@ -5532,7 +5325,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di break; case 3: if (nPatchesA == 0) { - goto err1; + return nullptr; } p->x[0][0] = patchesA[nPatchesA-1].x[3][0]; p->y[0][0] = patchesA[nPatchesA-1].y[3][0]; @@ -5610,7 +5403,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di break; case 1: if (nPatchesA == 0) { - goto err1; + return nullptr; } p->x[0][0] = patchesA[nPatchesA-1].x[0][3]; p->y[0][0] = patchesA[nPatchesA-1].y[0][3]; @@ -5653,7 +5446,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di break; case 2: if (nPatchesA == 0) { - goto err1; + return nullptr; } p->x[0][0] = patchesA[nPatchesA-1].x[3][3]; p->y[0][0] = patchesA[nPatchesA-1].y[3][3]; @@ -5696,7 +5489,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di break; case 3: if (nPatchesA == 0) { - goto err1; + return nullptr; } p->x[0][0] = patchesA[nPatchesA-1].x[3][0]; p->y[0][0] = patchesA[nPatchesA-1].y[3][0]; @@ -5794,14 +5587,9 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Di funcsA, nFuncsA); if (!shading->init(res, dict, out, state)) { delete shading; - return NULL; + return nullptr; } return shading; - - err2: - obj1.free(); - err1: - return NULL; } void GfxPatchMeshShading::getParameterizedColor(double t, GfxColor *color) { @@ -5830,7 +5618,6 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, int maxPixel, indexHigh; Guchar *indexedLookup; Function *sepFunc; - Object obj; double x[gfxColorMaxComps]; double y[gfxColorMaxComps]; int i, j, k; @@ -5872,18 +5659,16 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, nComps = colorSpace->getNComps(); } for (i = 0; i < nComps; ++i) { - decode->arrayGet(2*i, &obj); + Object obj = decode->arrayGet(2*i); if (!obj.isNum()) { - goto err2; + goto err1; } decodeLow[i] = obj.getNum(); - obj.free(); - decode->arrayGet(2*i+1, &obj); + obj = decode->arrayGet(2*i+1); if (!obj.isNum()) { - goto err2; + goto err1; } decodeRange[i] = obj.getNum() - decodeLow[i]; - obj.free(); } } else { goto err1; @@ -5988,8 +5773,6 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, return; - err2: - obj.free(); err1: ok = gFalse; } @@ -7313,7 +7096,6 @@ GfxState *GfxState::restore() { } GBool GfxState::parseBlendMode(Object *obj, GfxBlendMode *mode) { - Object obj2; int i, j; if (obj->isName()) { @@ -7326,19 +7108,16 @@ GBool GfxState::parseBlendMode(Object *obj, GfxBlendMode *mode) { return gFalse; } else if (obj->isArray()) { for (i = 0; i < obj->arrayGetLength(); ++i) { - obj->arrayGet(i, &obj2); + Object obj2 = obj->arrayGet(i); if (!obj2.isName()) { - obj2.free(); return gFalse; } for (j = 0; j < nGfxBlendModeNames; ++j) { if (!strcmp(obj2.getName(), gfxBlendModeNames[j].name)) { - obj2.free(); *mode = gfxBlendModeNames[j].mode; return gTrue; } } - obj2.free(); } *mode = gfxBlendNormal; return gTrue; diff --git a/Build/source/libs/poppler/poppler-src/poppler/GfxState.h b/Build/source/libs/poppler/poppler-src/poppler/GfxState.h index 38888717aae..bfbf53cd64f 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GfxState.h +++ b/Build/source/libs/poppler/poppler-src/poppler/GfxState.h @@ -17,12 +17,13 @@ // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009 Koji Otani <sho@bbr.jp> -// Copyright (C) 2009-2011, 2013, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009-2011, 2013, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> // Copyright (C) 2011-2014, 2016 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com> -// Copyright (C) 2015 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2015, 2017 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2017 Oliver Sander <oliver.sander@tu-dresden.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 @@ -132,6 +133,10 @@ static inline Guchar colToByte(GfxColorComp x) { return (Guchar)(((x << 8) - x + 0x8000) >> 16); } +static inline Gushort colToShort(GfxColorComp x) { + return (Gushort)(x); +} + //------------------------------------------------------------------------ // GfxColor //------------------------------------------------------------------------ @@ -288,28 +293,28 @@ class GfxDeviceGrayColorSpace: public GfxColorSpace { public: GfxDeviceGrayColorSpace(); - virtual ~GfxDeviceGrayColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csDeviceGray; } - - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); - virtual void getGrayLine(Guchar *in, Guchar *out, int length); - virtual void getRGBLine(Guchar *in, unsigned int *out, int length); - virtual void getRGBLine(Guchar *in, Guchar *out, int length); - virtual void getRGBXLine(Guchar *in, Guchar *out, int length); - virtual void getCMYKLine(Guchar *in, Guchar *out, int length); - virtual void getDeviceNLine(Guchar *in, Guchar *out, int length); - - virtual GBool useGetRGBLine() { return gTrue; } - virtual GBool useGetGrayLine() { return gTrue; } - virtual GBool useGetCMYKLine() { return gTrue; } - virtual GBool useGetDeviceNLine() { return gTrue; } - - virtual int getNComps() { return 1; } - virtual void getDefaultColor(GfxColor *color); + ~GfxDeviceGrayColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csDeviceGray; } + + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; + void getGrayLine(Guchar *in, Guchar *out, int length) override; + void getRGBLine(Guchar *in, unsigned int *out, int length) override; + void getRGBLine(Guchar *in, Guchar *out, int length) override; + void getRGBXLine(Guchar *in, Guchar *out, int length) override; + void getCMYKLine(Guchar *in, Guchar *out, int length) override; + void getDeviceNLine(Guchar *in, Guchar *out, int length) override; + + GBool useGetRGBLine() override { return gTrue; } + GBool useGetGrayLine() override { return gTrue; } + GBool useGetCMYKLine() override { return gTrue; } + GBool useGetDeviceNLine() override { return gTrue; } + + int getNComps() override { return 1; } + void getDefaultColor(GfxColor *color) override; private: }; @@ -322,20 +327,20 @@ class GfxCalGrayColorSpace: public GfxColorSpace { public: GfxCalGrayColorSpace(); - virtual ~GfxCalGrayColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csCalGray; } + ~GfxCalGrayColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csCalGray; } // Construct a CalGray color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr, GfxState *state); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; - virtual int getNComps() { return 1; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return 1; } + void getDefaultColor(GfxColor *color) override; // CalGray-specific access. double getWhiteX() { return whiteX; } @@ -366,28 +371,28 @@ class GfxDeviceRGBColorSpace: public GfxColorSpace { public: GfxDeviceRGBColorSpace(); - virtual ~GfxDeviceRGBColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csDeviceRGB; } - - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); - virtual void getGrayLine(Guchar *in, Guchar *out, int length); - virtual void getRGBLine(Guchar *in, unsigned int *out, int length); - virtual void getRGBLine(Guchar *in, Guchar *out, int length); - virtual void getRGBXLine(Guchar *in, Guchar *out, int length); - virtual void getCMYKLine(Guchar *in, Guchar *out, int length); - virtual void getDeviceNLine(Guchar *in, Guchar *out, int length); - - virtual GBool useGetRGBLine() { return gTrue; } - virtual GBool useGetGrayLine() { return gTrue; } - virtual GBool useGetCMYKLine() { return gTrue; } - virtual GBool useGetDeviceNLine() { return gTrue; } - - virtual int getNComps() { return 3; } - virtual void getDefaultColor(GfxColor *color); + ~GfxDeviceRGBColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csDeviceRGB; } + + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; + void getGrayLine(Guchar *in, Guchar *out, int length) override; + void getRGBLine(Guchar *in, unsigned int *out, int length) override; + void getRGBLine(Guchar *in, Guchar *out, int length) override; + void getRGBXLine(Guchar *in, Guchar *out, int length) override; + void getCMYKLine(Guchar *in, Guchar *out, int length) override; + void getDeviceNLine(Guchar *in, Guchar *out, int length) override; + + GBool useGetRGBLine() override { return gTrue; } + GBool useGetGrayLine() override { return gTrue; } + GBool useGetCMYKLine() override { return gTrue; } + GBool useGetDeviceNLine() override { return gTrue; } + + int getNComps() override { return 3; } + void getDefaultColor(GfxColor *color) override; private: }; @@ -400,20 +405,20 @@ class GfxCalRGBColorSpace: public GfxColorSpace { public: GfxCalRGBColorSpace(); - virtual ~GfxCalRGBColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csCalRGB; } + ~GfxCalRGBColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csCalRGB; } // Construct a CalRGB color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr, GfxState *state); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; - virtual int getNComps() { return 3; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return 3; } + void getDefaultColor(GfxColor *color) override; // CalRGB-specific access. double getWhiteX() { return whiteX; } @@ -448,25 +453,25 @@ class GfxDeviceCMYKColorSpace: public GfxColorSpace { public: GfxDeviceCMYKColorSpace(); - virtual ~GfxDeviceCMYKColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csDeviceCMYK; } - - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); - virtual void getRGBLine(Guchar *in, unsigned int *out, int length); - virtual void getRGBLine(Guchar *, Guchar *out, int length); - virtual void getRGBXLine(Guchar *in, Guchar *out, int length); - virtual void getCMYKLine(Guchar *in, Guchar *out, int length); - virtual void getDeviceNLine(Guchar *in, Guchar *out, int length); - virtual GBool useGetRGBLine() { return gTrue; } - virtual GBool useGetCMYKLine() { return gTrue; } - virtual GBool useGetDeviceNLine() { return gTrue; } - - virtual int getNComps() { return 4; } - virtual void getDefaultColor(GfxColor *color); + ~GfxDeviceCMYKColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csDeviceCMYK; } + + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; + void getRGBLine(Guchar *in, unsigned int *out, int length) override; + void getRGBLine(Guchar *, Guchar *out, int length) override; + void getRGBXLine(Guchar *in, Guchar *out, int length) override; + void getCMYKLine(Guchar *in, Guchar *out, int length) override; + void getDeviceNLine(Guchar *in, Guchar *out, int length) override; + GBool useGetRGBLine() override { return gTrue; } + GBool useGetCMYKLine() override { return gTrue; } + GBool useGetDeviceNLine() override { return gTrue; } + + int getNComps() override { return 4; } + void getDefaultColor(GfxColor *color) override; private: }; @@ -479,23 +484,23 @@ class GfxLabColorSpace: public GfxColorSpace { public: GfxLabColorSpace(); - virtual ~GfxLabColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csLab; } + ~GfxLabColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csLab; } // Construct a Lab color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr, GfxState *state); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; - virtual int getNComps() { return 3; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return 3; } + void getDefaultColor(GfxColor *color) override; - virtual void getDefaultRanges(double *decodeLow, double *decodeRange, - int maxImgPixel); + void getDefaultRanges(double *decodeLow, double *decodeRange, + int maxImgPixel) override; // Lab-specific access. double getWhiteX() { return whiteX; } @@ -530,32 +535,32 @@ public: GfxICCBasedColorSpace(int nCompsA, GfxColorSpace *altA, Ref *iccProfileStreamA); - virtual ~GfxICCBasedColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csICCBased; } + ~GfxICCBasedColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csICCBased; } // Construct an ICCBased color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); - virtual void getRGBLine(Guchar *in, unsigned int *out, int length); - virtual void getRGBLine(Guchar *in, Guchar *out, int length); - virtual void getRGBXLine(Guchar *in, Guchar *out, int length); - virtual void getCMYKLine(Guchar *in, Guchar *out, int length); - virtual void getDeviceNLine(Guchar *in, Guchar *out, int length); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; + void getRGBLine(Guchar *in, unsigned int *out, int length) override; + void getRGBLine(Guchar *in, Guchar *out, int length) override; + void getRGBXLine(Guchar *in, Guchar *out, int length) override; + void getCMYKLine(Guchar *in, Guchar *out, int length) override; + void getDeviceNLine(Guchar *in, Guchar *out, int length) override; - virtual GBool useGetRGBLine(); - virtual GBool useGetCMYKLine(); - virtual GBool useGetDeviceNLine(); + GBool useGetRGBLine() override; + GBool useGetCMYKLine() override; + GBool useGetDeviceNLine() override; - virtual int getNComps() { return nComps; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return nComps; } + void getDefaultColor(GfxColor *color) override; - virtual void getDefaultRanges(double *decodeLow, double *decodeRange, - int maxImgPixel); + void getDefaultRanges(double *decodeLow, double *decodeRange, + int maxImgPixel) override; // ICCBased-specific access. GfxColorSpace *getAlt() { return alt; } @@ -582,32 +587,32 @@ class GfxIndexedColorSpace: public GfxColorSpace { public: GfxIndexedColorSpace(GfxColorSpace *baseA, int indexHighA); - virtual ~GfxIndexedColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csIndexed; } + ~GfxIndexedColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csIndexed; } // Construct an Indexed color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); - virtual void getRGBLine(Guchar *in, unsigned int *out, int length); - virtual void getRGBLine(Guchar *in, Guchar *out, int length); - virtual void getRGBXLine(Guchar *in, Guchar *out, int length); - virtual void getCMYKLine(Guchar *in, Guchar *out, int length); - virtual void getDeviceNLine(Guchar *in, Guchar *out, int length); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; + void getRGBLine(Guchar *in, unsigned int *out, int length) override; + void getRGBLine(Guchar *in, Guchar *out, int length) override; + void getRGBXLine(Guchar *in, Guchar *out, int length) override; + void getCMYKLine(Guchar *in, Guchar *out, int length) override; + void getDeviceNLine(Guchar *in, Guchar *out, int length) override; - virtual GBool useGetRGBLine() { return gTrue; } - virtual GBool useGetCMYKLine() { return gTrue; } - virtual GBool useGetDeviceNLine() { return gTrue; } + GBool useGetRGBLine() override { return gTrue; } + GBool useGetCMYKLine() override { return gTrue; } + GBool useGetDeviceNLine() override { return gTrue; } - virtual int getNComps() { return 1; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return 1; } + void getDefaultColor(GfxColor *color) override; - virtual void getDefaultRanges(double *decodeLow, double *decodeRange, - int maxImgPixel); + void getDefaultRanges(double *decodeLow, double *decodeRange, + int maxImgPixel) override; // Indexed-specific access. GfxColorSpace *getBase() { return base; } @@ -615,7 +620,7 @@ public: Guchar *getLookup() { return lookup; } GfxColor *mapColorToBase(GfxColor *color, GfxColor *baseColor); Guint getOverprintMask() { return base->getOverprintMask(); } - virtual void createMapping(GooList *separationList, int maxSepComps) + void createMapping(GooList *separationList, int maxSepComps) override { base->createMapping(separationList, maxSepComps); } @@ -635,24 +640,24 @@ public: GfxSeparationColorSpace(GooString *nameA, GfxColorSpace *altA, Function *funcA); - virtual ~GfxSeparationColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csSeparation; } + ~GfxSeparationColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csSeparation; } // Construct a Separation color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; - virtual void createMapping(GooList *separationList, int maxSepComps); + void createMapping(GooList *separationList, int maxSepComps) override; - virtual int getNComps() { return 1; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return 1; } + void getDefaultColor(GfxColor *color) override; - virtual GBool isNonMarking() { return nonMarking; } + GBool isNonMarking() override { return nonMarking; } // Separation-specific access. GooString *getName() { return name; } @@ -680,24 +685,24 @@ public: GfxDeviceNColorSpace(int nCompsA, GooString **namesA, GfxColorSpace *alt, Function *func, GooList *sepsCS); - virtual ~GfxDeviceNColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csDeviceN; } + ~GfxDeviceNColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csDeviceN; } // Construct a DeviceN color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; - virtual void createMapping(GooList *separationList, int maxSepComps); + void createMapping(GooList *separationList, int maxSepComps) override; - virtual int getNComps() { return nComps; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return nComps; } + void getDefaultColor(GfxColor *color) override; - virtual GBool isNonMarking() { return nonMarking; } + GBool isNonMarking() override { return nonMarking; } // DeviceN-specific access. GooString *getColorantName(int i) { return names[i]; } @@ -727,20 +732,20 @@ class GfxPatternColorSpace: public GfxColorSpace { public: GfxPatternColorSpace(GfxColorSpace *underA); - virtual ~GfxPatternColorSpace(); - virtual GfxColorSpace *copy(); - virtual GfxColorSpaceMode getMode() { return csPattern; } + ~GfxPatternColorSpace(); + GfxColorSpace *copy() override; + GfxColorSpaceMode getMode() override { return csPattern; } // Construct a Pattern color space. Returns NULL if unsuccessful. static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); - virtual void getGray(GfxColor *color, GfxGray *gray); - virtual void getRGB(GfxColor *color, GfxRGB *rgb); - virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk); - virtual void getDeviceN(GfxColor *color, GfxColor *deviceN); + void getGray(GfxColor *color, GfxGray *gray) override; + void getRGB(GfxColor *color, GfxRGB *rgb) override; + void getCMYK(GfxColor *color, GfxCMYK *cmyk) override; + void getDeviceN(GfxColor *color, GfxColor *deviceN) override; - virtual int getNComps() { return 0; } - virtual void getDefaultColor(GfxColor *color); + int getNComps() override { return 0; } + void getDefaultColor(GfxColor *color) override; // Pattern-specific access. GfxColorSpace *getUnder() { return under; } @@ -758,18 +763,21 @@ private: class GfxPattern { public: - GfxPattern(int typeA); + GfxPattern(int typeA, int patternRefNumA); virtual ~GfxPattern(); - static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state); + static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum); virtual GfxPattern *copy() = 0; int getType() { return type; } + int getPatternRefNum() const { return patternRefNum; } + private: int type; + int patternRefNum; }; //------------------------------------------------------------------------ @@ -779,10 +787,10 @@ private: class GfxTilingPattern: public GfxPattern { public: - static GfxTilingPattern *parse(Object *patObj); - virtual ~GfxTilingPattern(); + static GfxTilingPattern *parse(Object *patObj, int patternRefNum); + ~GfxTilingPattern(); - virtual GfxPattern *copy(); + GfxPattern *copy() override; int getPaintType() { return paintType; } int getTilingType() { return tilingType; } @@ -799,7 +807,7 @@ private: GfxTilingPattern(int paintTypeA, int tilingTypeA, double *bboxA, double xStepA, double yStepA, Object *resDictA, double *matrixA, - Object *contentStreamA); + Object *contentStreamA, int patternRefNumA); int paintType; int tilingType; @@ -817,17 +825,17 @@ private: class GfxShadingPattern: public GfxPattern { public: - static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state); - virtual ~GfxShadingPattern(); + static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum); + ~GfxShadingPattern(); - virtual GfxPattern *copy(); + GfxPattern *copy() override; GfxShading *getShading() { return shading; } double *getMatrix() { return matrix; } private: - GfxShadingPattern(GfxShading *shadingA, double *matrixA); + GfxShadingPattern(GfxShading *shadingA, double *matrixA, int patternRefNumA); GfxShading *shading; double matrix[6]; @@ -860,6 +868,13 @@ protected: GBool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); + // 1: Function-based shading + // 2: Axial shading + // 3: Radial shading + // 4: Free-form Gouraud-shaded triangle mesh + // 5: Lattice-form Gouraud-shaded triangle mesh + // 6: Coons patch mesh + // 7: Tensor-product patch mesh int type; GBool hasBackground; GBool hasBBox; @@ -880,7 +895,7 @@ public: Function **funcsA, int nFuncsA, GBool extend0A, GBool extend1A); GfxUnivariateShading(GfxUnivariateShading *shading); - virtual ~GfxUnivariateShading(); + ~GfxUnivariateShading(); double getDomain0() { return t0; } double getDomain1() { return t1; } @@ -925,11 +940,11 @@ public: double *matrixA, Function **funcsA, int nFuncsA); GfxFunctionShading(GfxFunctionShading *shading); - virtual ~GfxFunctionShading(); + ~GfxFunctionShading(); static GfxFunctionShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); - virtual GfxShading *copy(); + GfxShading *copy() override; void getDomain(double *x0A, double *y0A, double *x1A, double *y1A) { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; } @@ -959,20 +974,20 @@ public: Function **funcsA, int nFuncsA, GBool extend0A, GBool extend1A); GfxAxialShading(GfxAxialShading *shading); - virtual ~GfxAxialShading(); + ~GfxAxialShading(); static GfxAxialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); - virtual GfxShading *copy(); + GfxShading *copy() override; void getCoords(double *x0A, double *y0A, double *x1A, double *y1A) { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; } - virtual void getParameterRange(double *lower, double *upper, + void getParameterRange(double *lower, double *upper, double xMin, double yMin, - double xMax, double yMax); + double xMax, double yMax) override; - virtual double getDistance(double tMin, double tMax); + double getDistance(double tMin, double tMax) override; private: @@ -992,21 +1007,21 @@ public: Function **funcsA, int nFuncsA, GBool extend0A, GBool extend1A); GfxRadialShading(GfxRadialShading *shading); - virtual ~GfxRadialShading(); + ~GfxRadialShading(); static GfxRadialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); - virtual GfxShading *copy(); + GfxShading *copy() override; void getCoords(double *x0A, double *y0A, double *r0A, double *x1A, double *y1A, double *r1A) { *x0A = x0; *y0A = y0; *r0A = r0; *x1A = x1; *y1A = y1; *r1A = r1; } - virtual void getParameterRange(double *lower, double *upper, + void getParameterRange(double *lower, double *upper, double xMin, double yMin, - double xMax, double yMax); + double xMax, double yMax) override; - virtual double getDistance(double tMin, double tMax); + double getDistance(double tMin, double tMax) override; private: @@ -1030,11 +1045,11 @@ public: int (*trianglesA)[3], int nTrianglesA, Function **funcsA, int nFuncsA); GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading); - virtual ~GfxGouraudTriangleShading(); + ~GfxGouraudTriangleShading(); static GfxGouraudTriangleShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state); - virtual GfxShading *copy(); + GfxShading *copy() override; int getNTriangles() { return nTriangles; } @@ -1116,11 +1131,11 @@ public: GfxPatchMeshShading(int typeA, GfxPatch *patchesA, int nPatchesA, Function **funcsA, int nFuncsA); GfxPatchMeshShading(GfxPatchMeshShading *shading); - virtual ~GfxPatchMeshShading(); + ~GfxPatchMeshShading(); static GfxPatchMeshShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state); - virtual GfxShading *copy(); + GfxShading *copy() override; int getNPatches() { return nPatches; } GfxPatch *getPatch(int i) { return &patches[i]; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc index e5434084c31..1f2b4ec07d6 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005, 2007-2010, 2012, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2007-2010, 2012, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> @@ -31,10 +31,12 @@ // Copyright (C) 2011 Pino Toscano <pino@kde.org> // Copyright (C) 2011 Koji Otani <sho@bbr.jp> // Copyright (C) 2012 Yi Yang <ahyangyi@gmail.com> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Peter Breitenlohner <peb@mppmu.mpg.de> // Copyright (C) 2013, 2014 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org> +// Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr> // // 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,6 +61,7 @@ # include <shlobj.h> # include <mbstring.h> #endif +#include "goo/glibc.h" #include "goo/gmem.h" #include "goo/GooString.h" #include "goo/GooList.h" @@ -77,17 +80,17 @@ #include "GlobalParams.h" #include "GfxFont.h" -#if WITH_FONTCONFIGURATION_FONTCONFIG +#ifdef WITH_FONTCONFIGURATION_FONTCONFIG #include <fontconfig/fontconfig.h> #endif -#ifdef _WIN32 +#ifdef _MSC_VER # define strcasecmp stricmp #else # include <strings.h> #endif -#if MULTITHREADED +#ifdef MULTITHREADED # define lockGlobalParams gLockMutex(&mutex) # define lockUnicodeMapCache gLockMutex(&unicodeMapCacheMutex) # define lockCMapCache gLockMutex(&cMapCacheMutex) @@ -109,7 +112,7 @@ #include "NameToUnicodeTable.h" #include "UnicodeMapTables.h" -#include "UTF8.h" +#include "UnicodeMapFuncs.h" #ifdef ENABLE_PLUGINS # ifdef _WIN32 @@ -126,45 +129,32 @@ extern XpdfPluginVecTable xpdfPluginVecTable; GlobalParams *globalParams = NULL; -//------------------------------------------------------------------------ -// PSFontParam16 -//------------------------------------------------------------------------ - -PSFontParam16::PSFontParam16(GooString *nameA, int wModeA, - GooString *psFontNameA, GooString *encodingA) { - name = nameA; - wMode = wModeA; - psFontName = psFontNameA; - encoding = encodingA; -} - -PSFontParam16::~PSFontParam16() { - delete name; - delete psFontName; - delete encoding; -} - -#if ENABLE_RELOCATABLE && defined(_WIN32) +#if defined(ENABLE_RELOCATABLE) && defined(_WIN32) /* search for data relative to where we are installed */ static HMODULE hmodule; extern "C" { -BOOL WINAPI -DllMain (HINSTANCE hinstDLL, - DWORD fdwReason, - LPVOID lpvReserved) -{ - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - hmodule = hinstDLL; - break; + /* Provide declaration to squelch -Wmissing-declarations warning */ + BOOL WINAPI + DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved); + + BOOL WINAPI + DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) + { + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + hmodule = hinstDLL; + break; } - return TRUE; -} + return TRUE; + } } static const char * @@ -178,7 +168,7 @@ get_poppler_datadir (void) if (beenhere) return retval; - if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 20)) + if (!GetModuleFileNameA (hmodule, (CHAR *) retval, sizeof(retval) - 20)) return POPPLER_DATADIR; p = _mbsrchr ((unsigned char *) retval, '\\'); @@ -270,7 +260,7 @@ public: ~SysFontList(); SysFontInfo *find(GooString *name, GBool isFixedWidth, GBool exact); -#ifdef WIN32 +#ifdef _WIN32 void scanWindowsFonts(GooString *winFontDir); #endif #ifdef WITH_FONTCONFIGURATION_FONTCONFIG @@ -278,7 +268,7 @@ public: #endif private: -#ifdef WIN32 +#ifdef _WIN32 SysFontInfo *makeWindowsFont(char *name, int fontNum, char *path); #endif @@ -557,7 +547,7 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) UnicodeMap *map; int i; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); gInitMutex(&unicodeMapCacheMutex); gInitMutex(&cMapCacheMutex); @@ -586,17 +576,10 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) cMapDirs = new GooHash(gTrue); toUnicodeDirs = new GooList(); fontFiles = new GooHash(gTrue); - fontDirs = new GooList(); - ccFontFiles = new GooHash(gTrue); sysFonts = new SysFontList(); psExpandSmaller = gFalse; psShrinkLarger = gTrue; - psCenter = gTrue; psLevel = psLevel2; - psFile = NULL; - psResidentFonts = new GooHash(gTrue); - psResidentFonts16 = new GooList(); - psResidentFontsCC = new GooList(); textEncoding = new GooString("UTF-8"); #if defined(_WIN32) textEOL = eolDOS; @@ -606,19 +589,8 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) textEOL = eolUnix; #endif textPageBreaks = gTrue; - textKeepTinyChars = gFalse; enableFreeType = gTrue; - strokeAdjust = gTrue; - screenType = screenUnset; - screenSize = -1; - screenDotRadius = -1; - screenGamma = 1.0; - screenBlackThreshold = 0.0; - screenWhiteThreshold = 1.0; - minLineWidth = 0.0; overprintPreview = gFalse; - mapNumericCharNames = gTrue; - mapUnknownCharNames = gTrue; printCommands = gFalse; profileCommands = gFalse; errQuiet = gFalse; @@ -659,7 +631,7 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) residentUnicodeMaps->add(map->getEncodingName(), map); map = new UnicodeMap("UTF-8", gTrue, &mapUTF8); residentUnicodeMaps->add(map->getEncodingName(), map); - map = new UnicodeMap("UCS-2", gTrue, &mapUCS2); + map = new UnicodeMap("UTF-16", gTrue, &mapUTF16); residentUnicodeMaps->add(map->getEncodingName(), map); scanEncodingDirs(); @@ -795,18 +767,10 @@ GlobalParams::~GlobalParams() { deleteGooHash(unicodeMaps, GooString); deleteGooList(toUnicodeDirs, GooString); deleteGooHash(fontFiles, GooString); - deleteGooList(fontDirs, GooString); - deleteGooHash(ccFontFiles, GooString); #ifdef _WIN32 deleteGooHash(substFiles, GooString); #endif delete sysFonts; - if (psFile) { - delete psFile; - } - deleteGooHash(psResidentFonts, GooString); - deleteGooList(psResidentFonts16, PSFontParam16); - deleteGooList(psResidentFontsCC, PSFontParam16); delete textEncoding; GooHashIter *iter; @@ -829,7 +793,7 @@ GlobalParams::~GlobalParams() { deleteGooList(plugins, Plugin); #endif -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); gDestroyMutex(&unicodeMapCacheMutex); gDestroyMutex(&cMapCacheMutex); @@ -930,7 +894,7 @@ FILE *GlobalParams::findToUnicodeFile(GooString *name) { return NULL; } -#if WITH_FONTCONFIGURATION_FONTCONFIG +#ifdef WITH_FONTCONFIGURATION_FONTCONFIG static GBool findModifier(const char *name, const char *modifier, const char **start) { const char *match; @@ -1104,14 +1068,7 @@ static FcPattern *buildFcPattern(GfxFont *font, GooString *base14Name) #endif GooString *GlobalParams::findFontFile(GooString *fontName) { - static const char *exts[] = { ".pfa", ".pfb", ".ttf", ".ttc", ".otf" }; - GooString *path, *dir; -#ifdef WIN32 - GooString *fontNameU; -#endif - const char *ext; - FILE *f; - int i, j; + GooString *path; setupBaseFonts(NULL); lockGlobalParams; @@ -1120,26 +1077,6 @@ GooString *GlobalParams::findFontFile(GooString *fontName) { unlockGlobalParams; return path; } - for (i = 0; i < fontDirs->getLength(); ++i) { - dir = (GooString *)fontDirs->get(i); - for (j = 0; j < (int)(sizeof(exts) / sizeof(exts[0])); ++j) { - ext = exts[j]; -#ifdef WIN32 - fontNameU = fileNameToUTF8(fontName->getCString()); - path = appendToPath(dir->copy(), fontNameU->getCString()); - delete fontNameU; -#else - path = appendToPath(dir->copy(), fontName->getCString()); -#endif - path->append(ext); - if ((f = openFile(path->getCString(), "rb"))) { - fclose(f); - unlockGlobalParams; - return path; - } - delete path; - } - } unlockGlobalParams; return NULL; } @@ -1147,7 +1084,7 @@ GooString *GlobalParams::findFontFile(GooString *fontName) { /* if you can't or don't want to use Fontconfig, you need to implement this function for your platform. For Windows, it's in GlobalParamsWin.cc */ -#if WITH_FONTCONFIGURATION_FONTCONFIG +#ifdef WITH_FONTCONFIGURATION_FONTCONFIG // not needed for fontconfig void GlobalParams::setupBaseFonts(char *dir) { } @@ -1424,18 +1361,6 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font, } #endif -GooString *GlobalParams::findCCFontFile(GooString *collection) { - GooString *path; - - lockGlobalParams; - if ((path = (GooString *)ccFontFiles->lookup(collection))) { - path = path->copy(); - } - unlockGlobalParams; - return path; -} - - GBool GlobalParams::getPSExpandSmaller() { GBool f; @@ -1454,15 +1379,6 @@ GBool GlobalParams::getPSShrinkLarger() { return f; } -GBool GlobalParams::getPSCenter() { - GBool f; - - lockGlobalParams; - f = psCenter; - unlockGlobalParams; - return f; -} - PSLevel GlobalParams::getPSLevel() { PSLevel level; @@ -1472,67 +1388,6 @@ PSLevel GlobalParams::getPSLevel() { return level; } -GooString *GlobalParams::getPSResidentFont(GooString *fontName) { - GooString *psName; - - lockGlobalParams; - psName = (GooString *)psResidentFonts->lookup(fontName); - unlockGlobalParams; - return psName; -} - -GooList *GlobalParams::getPSResidentFonts() { - GooList *names; - GooHashIter *iter; - GooString *name; - GooString *psName; - - names = new GooList(); - lockGlobalParams; - psResidentFonts->startIter(&iter); - while (psResidentFonts->getNext(&iter, &name, (void **)&psName)) { - names->append(psName->copy()); - } - unlockGlobalParams; - return names; -} - -PSFontParam16 *GlobalParams::getPSResidentFont16(GooString *fontName, - int wMode) { - PSFontParam16 *p; - int i; - - lockGlobalParams; - p = NULL; - for (i = 0; i < psResidentFonts16->getLength(); ++i) { - p = (PSFontParam16 *)psResidentFonts16->get(i); - if (!(p->name->cmp(fontName)) && p->wMode == wMode) { - break; - } - p = NULL; - } - unlockGlobalParams; - return p; -} - -PSFontParam16 *GlobalParams::getPSResidentFontCC(GooString *collection, - int wMode) { - PSFontParam16 *p; - int i; - - lockGlobalParams; - p = NULL; - for (i = 0; i < psResidentFontsCC->getLength(); ++i) { - p = (PSFontParam16 *)psResidentFontsCC->get(i); - if (!(p->name->cmp(collection)) && p->wMode == wMode) { - break; - } - p = NULL; - } - unlockGlobalParams; - return p; -} - GooString *GlobalParams::getTextEncodingName() { GooString *s; @@ -1560,15 +1415,6 @@ GBool GlobalParams::getTextPageBreaks() { return pageBreaks; } -GBool GlobalParams::getTextKeepTinyChars() { - GBool tiny; - - lockGlobalParams; - tiny = textKeepTinyChars; - unlockGlobalParams; - return tiny; -} - GBool GlobalParams::getEnableFreeType() { GBool f; @@ -1578,96 +1424,6 @@ GBool GlobalParams::getEnableFreeType() { return f; } -GBool GlobalParams::getStrokeAdjust() { - GBool f; - - lockGlobalParams; - f = strokeAdjust; - unlockGlobalParams; - return f; -} - -ScreenType GlobalParams::getScreenType() { - ScreenType t; - - lockGlobalParams; - t = screenType; - unlockGlobalParams; - return t; -} - -int GlobalParams::getScreenSize() { - int size; - - lockGlobalParams; - size = screenSize; - unlockGlobalParams; - return size; -} - -int GlobalParams::getScreenDotRadius() { - int r; - - lockGlobalParams; - r = screenDotRadius; - unlockGlobalParams; - return r; -} - -double GlobalParams::getScreenGamma() { - double gamma; - - lockGlobalParams; - gamma = screenGamma; - unlockGlobalParams; - return gamma; -} - -double GlobalParams::getScreenBlackThreshold() { - double thresh; - - lockGlobalParams; - thresh = screenBlackThreshold; - unlockGlobalParams; - return thresh; -} - -double GlobalParams::getScreenWhiteThreshold() { - double thresh; - - lockGlobalParams; - thresh = screenWhiteThreshold; - unlockGlobalParams; - return thresh; -} - -double GlobalParams::getMinLineWidth() { - double minLineWidthA; - - lockGlobalParams; - minLineWidthA = minLineWidth; - unlockGlobalParams; - return minLineWidthA; -} - -GBool GlobalParams::getMapNumericCharNames() { - GBool map; - - lockGlobalParams; - map = mapNumericCharNames; - unlockGlobalParams; - return map; -} - -GBool GlobalParams::getMapUnknownCharNames() { - GBool map; - - lockGlobalParams; - map = mapUnknownCharNames; - unlockGlobalParams; - return map; -} - GBool GlobalParams::getPrintCommands() { GBool p; @@ -1790,15 +1546,6 @@ void GlobalParams::addFontFile(GooString *fontName, GooString *path) { unlockGlobalParams; } -void GlobalParams::setPSFile(char *file) { - lockGlobalParams; - if (psFile) { - delete psFile; - } - psFile = new GooString(file); - unlockGlobalParams; -} - void GlobalParams::setPSExpandSmaller(GBool expand) { lockGlobalParams; psExpandSmaller = expand; @@ -1811,12 +1558,6 @@ void GlobalParams::setPSShrinkLarger(GBool shrink) { unlockGlobalParams; } -void GlobalParams::setPSCenter(GBool center) { - lockGlobalParams; - psCenter = center; - unlockGlobalParams; -} - void GlobalParams::setPSLevel(PSLevel level) { lockGlobalParams; psLevel = level; @@ -1852,12 +1593,6 @@ void GlobalParams::setTextPageBreaks(GBool pageBreaks) { unlockGlobalParams; } -void GlobalParams::setTextKeepTinyChars(GBool keep) { - lockGlobalParams; - textKeepTinyChars = keep; - unlockGlobalParams; -} - GBool GlobalParams::setEnableFreeType(char *s) { GBool ok; @@ -1867,89 +1602,12 @@ GBool GlobalParams::setEnableFreeType(char *s) { return ok; } -GBool GlobalParams::setDisableFreeTypeHinting(char *s) { - GBool ok; - - lockGlobalParams; - ok = parseYesNo2(s, &disableFreeTypeHinting); - unlockGlobalParams; - return ok; -} - -void GlobalParams::setStrokeAdjust(GBool adjust) -{ - lockGlobalParams; - strokeAdjust = adjust; - unlockGlobalParams; -} - -void GlobalParams::setScreenType(ScreenType st) -{ - lockGlobalParams; - screenType = st; - unlockGlobalParams; -} - -void GlobalParams::setScreenSize(int size) -{ - lockGlobalParams; - screenSize = size; - unlockGlobalParams; -} - -void GlobalParams::setScreenDotRadius(int radius) -{ - lockGlobalParams; - screenDotRadius = radius; - unlockGlobalParams; -} - -void GlobalParams::setScreenGamma(double gamma) -{ - lockGlobalParams; - screenGamma = gamma; - unlockGlobalParams; -} - -void GlobalParams::setScreenBlackThreshold(double blackThreshold) -{ - lockGlobalParams; - screenBlackThreshold = blackThreshold; - unlockGlobalParams; -} - -void GlobalParams::setScreenWhiteThreshold(double whiteThreshold) -{ - lockGlobalParams; - screenWhiteThreshold = whiteThreshold; - unlockGlobalParams; -} - -void GlobalParams::setMinLineWidth(double minLineWidthA) -{ - lockGlobalParams; - minLineWidth = minLineWidthA; - unlockGlobalParams; -} - void GlobalParams::setOverprintPreview(GBool overprintPreviewA) { lockGlobalParams; overprintPreview = overprintPreviewA; unlockGlobalParams; } -void GlobalParams::setMapNumericCharNames(GBool map) { - lockGlobalParams; - mapNumericCharNames = map; - unlockGlobalParams; -} - -void GlobalParams::setMapUnknownCharNames(GBool map) { - lockGlobalParams; - mapUnknownCharNames = map; - unlockGlobalParams; -} - void GlobalParams::setPrintCommands(GBool printCommandsA) { lockGlobalParams; printCommands = printCommandsA; diff --git a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h index 16d615ae6d9..7c61ae44781 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h +++ b/Build/source/libs/poppler/poppler-src/poppler/GlobalParams.h @@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005, 2007-2010, 2012, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2007-2010, 2012, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> @@ -23,7 +23,7 @@ // Copyright (C) 2009, 2011, 2012, 2014, 2015 William Bader <williambader@hotmail.com> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2011 Pino Toscano <pino@kde.org> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// 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> // @@ -45,7 +45,7 @@ #include "goo/gtypes.h" #include "CharTypes.h" -#if MULTITHREADED +#ifdef MULTITHREADED #include "goo/GooMutex.h" #endif @@ -81,22 +81,6 @@ enum SysFontType { //------------------------------------------------------------------------ -class PSFontParam16 { -public: - - GooString *name; // PDF font name for psResidentFont16; - // char collection name for psResidentFontCC - int wMode; // writing mode (0=horiz, 1=vert) - GooString *psFontName; // PostScript font name - GooString *encoding; // encoding - - PSFontParam16(GooString *nameA, int wModeA, - GooString *psFontNameA, GooString *encodingA); - ~PSFontParam16(); -}; - -//------------------------------------------------------------------------ - enum PSLevel { psLevel1, psLevel1Sep, @@ -116,20 +100,10 @@ enum EndOfLineKind { //------------------------------------------------------------------------ -enum ScreenType { - screenUnset, - screenDispersed, - screenClustered, - screenStochasticClustered -}; - -//------------------------------------------------------------------------ - class GlobalParams { public: - // Initialize the global parameters by attempting to read a config - // file. + // Initialize the global parameters GlobalParams(const char *customPopplerDataDir = NULL); ~GlobalParams(); @@ -157,31 +131,14 @@ public: GooString *findSystemFontFile(GfxFont *font, SysFontType *type, int *fontNum, GooString *substituteFontName = NULL, GooString *base14Name = NULL); - GooString *findCCFontFile(GooString *collection); GBool getPSExpandSmaller(); GBool getPSShrinkLarger(); - GBool getPSCenter(); PSLevel getPSLevel(); - GooString *getPSResidentFont(GooString *fontName); - GooList *getPSResidentFonts(); - PSFontParam16 *getPSResidentFont16(GooString *fontName, int wMode); - PSFontParam16 *getPSResidentFontCC(GooString *collection, int wMode); GooString *getTextEncodingName(); EndOfLineKind getTextEOL(); GBool getTextPageBreaks(); - GBool getTextKeepTinyChars(); GBool getEnableFreeType(); - GBool getStrokeAdjust(); - ScreenType getScreenType(); - int getScreenSize(); - int getScreenDotRadius(); - double getScreenGamma(); - double getScreenBlackThreshold(); - double getScreenWhiteThreshold(); - double getMinLineWidth(); GBool getOverprintPreview() { return overprintPreview; } - GBool getMapNumericCharNames(); - GBool getMapUnknownCharNames(); GBool getPrintCommands(); GBool getProfileCommands(); GBool getErrQuiet(); @@ -199,28 +156,14 @@ public: //----- functions to set parameters void addFontFile(GooString *fontName, GooString *path); - void setPSFile(char *file); void setPSExpandSmaller(GBool expand); void setPSShrinkLarger(GBool shrink); - void setPSCenter(GBool center); void setPSLevel(PSLevel level); void setTextEncoding(char *encodingName); GBool setTextEOL(char *s); void setTextPageBreaks(GBool pageBreaks); - void setTextKeepTinyChars(GBool keep); GBool setEnableFreeType(char *s); - GBool setDisableFreeTypeHinting(char *s); - void setStrokeAdjust(GBool strokeAdjust); - void setScreenType(ScreenType st); - void setScreenSize(int size); - void setScreenDotRadius(int radius); - void setScreenGamma(double gamma); - void setScreenBlackThreshold(double blackThreshold); - void setScreenWhiteThreshold(double whiteThreshold); - void setMinLineWidth(double minLineWidth); void setOverprintPreview(GBool overprintPreviewA); - void setMapNumericCharNames(GBool map); - void setMapUnknownCharNames(GBool map); void setPrintCommands(GBool printCommandsA); void setProfileCommands(GBool profileCommandsA); void setErrQuiet(GBool errQuietA); @@ -271,47 +214,20 @@ private: #endif GooHash *fontFiles; // font files: font name mapped to path // [GString] - GooList *fontDirs; // list of font dirs [GString] - GooHash *ccFontFiles; // character collection font files: - // collection name mapped to path [GString] SysFontList *sysFonts; // system fonts - GooString *psFile; // PostScript file or command (for xpdf) GBool psExpandSmaller; // expand smaller pages to fill paper GBool psShrinkLarger; // shrink larger pages to fit paper - GBool psCenter; // center pages on the paper PSLevel psLevel; // PostScript level to generate - GooHash *psResidentFonts; // 8-bit fonts resident in printer: - // PDF font name mapped to PS font name - // [GString] - GooList *psResidentFonts16; // 16-bit fonts resident in printer: - // PDF font name mapped to font info - // [PSFontParam16] - GooList *psResidentFontsCC; // 16-bit character collection fonts - // resident in printer: collection name - // mapped to font info [PSFontParam16] GooString *textEncoding; // encoding (unicodeMap) to use for text // output EndOfLineKind textEOL; // type of EOL marker to use for text // output GBool textPageBreaks; // insert end-of-page markers? - GBool textKeepTinyChars; // keep all characters in text output GBool enableFreeType; // FreeType enable flag - GBool disableFreeTypeHinting; // FreeType disable hinting flag - GBool strokeAdjust; // stroke adjustment enable flag - ScreenType screenType; // halftone screen type - int screenSize; // screen matrix size - int screenDotRadius; // screen dot radius - double screenGamma; // screen gamma correction - double screenBlackThreshold; // screen black clamping threshold - double screenWhiteThreshold; // screen white clamping threshold - double minLineWidth; // minimum line width GBool overprintPreview; // enable overprint preview - GBool mapNumericCharNames; // map numeric char names (from font subsets)? - GBool mapUnknownCharNames; // map unknown char names? GBool printCommands; // print the drawing commands GBool profileCommands; // profile the drawing commands GBool errQuiet; // suppress error messages? - double splashResolution; // resolution when rasterizing images CharCodeToUnicodeCache *cidToUnicodeCache; CharCodeToUnicodeCache *unicodeToUnicodeCache; @@ -324,7 +240,7 @@ private: // [XpdfSecurityHandler] #endif -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; GooMutex unicodeMapCacheMutex; GooMutex cMapCacheMutex; diff --git a/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc b/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc index f9f40ef4e29..f122fcb6f1b 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc @@ -4,10 +4,12 @@ // Copyright (C) 2010, 2012 Hib Eris <hib@hiberis.nl> // Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> - // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> + // 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 Dmytro Morgun <lztoad@gmail.com> + // Copyright (C) 2017 Christoph Cullmann <cullmann@kde.org> + // Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> TODO: instead of a fixed mapping defined in displayFontTab, it could scan the whole fonts directory, parse TTF files and build font @@ -52,7 +54,7 @@ description for all fonts available in Windows. That's how MuPDF works. #include "Lexer.h" #include "Parser.h" -#if MULTITHREADED +#ifdef MULTITHREADED # define lockGlobalParams gLockMutex(&mutex) # define lockUnicodeMapCache gLockMutex(&unicodeMapCacheMutex) # define lockCMapCache gLockMutex(&cMapCacheMutex) @@ -76,7 +78,7 @@ description for all fonts available in Windows. That's how MuPDF works. #define DEFAULT_CID_FONT_AK1_MSWIN "Batang" /* Adobe-Korea1 */ #define DEFAULT_CID_FONT_MSWIN "ArialUnicode" /* Unknown */ -static struct { +static const struct { const char *name; const char *t1FileName; const char *ttFileName; @@ -180,29 +182,29 @@ static struct { static void GetWindowsFontDir(char *winFontDir, int cbWinFontDirLen) { BOOL (__stdcall *SHGetSpecialFolderPathFunc)(HWND hwndOwner, - LPTSTR lpszPath, + LPSTR lpszPath, int nFolder, BOOL fCreate); HRESULT (__stdcall *SHGetFolderPathFunc)(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, - LPTSTR pszPath); + LPSTR pszPath); // SHGetSpecialFolderPath isn't available in older versions of shell32.dll (Win95 and // WinNT4), so do a dynamic load of ANSI versions. winFontDir[0] = '\0'; - HMODULE hLib = LoadLibrary("shell32.dll"); + HMODULE hLib = LoadLibraryA("shell32.dll"); if (hLib) { - SHGetFolderPathFunc = (HRESULT (__stdcall *)(HWND, int, HANDLE, DWORD, LPTSTR)) + SHGetFolderPathFunc = (HRESULT (__stdcall *)(HWND, int, HANDLE, DWORD, LPSTR)) GetProcAddress(hLib, "SHGetFolderPathA"); if (SHGetFolderPathFunc) (*SHGetFolderPathFunc)(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, winFontDir); if (!winFontDir[0]) { // Try an older function - SHGetSpecialFolderPathFunc = (BOOL (__stdcall *)(HWND, LPTSTR, int, BOOL)) + SHGetSpecialFolderPathFunc = (BOOL (__stdcall *)(HWND, LPSTR, int, BOOL)) GetProcAddress(hLib, "SHGetSpecialFolderPathA"); if (SHGetSpecialFolderPathFunc) (*SHGetSpecialFolderPathFunc)(NULL, winFontDir, CSIDL_FONTS, FALSE); @@ -213,9 +215,9 @@ static void GetWindowsFontDir(char *winFontDir, int cbWinFontDirLen) return; // Try older DLL - hLib = LoadLibrary("SHFolder.dll"); + hLib = LoadLibraryA("SHFolder.dll"); if (hLib) { - SHGetFolderPathFunc = (HRESULT (__stdcall *)(HWND, int, HANDLE, DWORD, LPTSTR)) + SHGetFolderPathFunc = (HRESULT (__stdcall *)(HWND, int, HANDLE, DWORD, LPSTR)) GetProcAddress(hLib, "SHGetFolderPathA"); if (SHGetFolderPathFunc) (*SHGetFolderPathFunc)(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, winFontDir); @@ -225,7 +227,7 @@ static void GetWindowsFontDir(char *winFontDir, int cbWinFontDirLen) return; // Everything else failed so the standard fonts directory. - GetWindowsDirectory(winFontDir, cbWinFontDirLen); + GetWindowsDirectoryA(winFontDir, cbWinFontDirLen); if (winFontDir[0]) { strncat(winFontDir, FONTS_SUBDIR, cbWinFontDirLen); winFontDir[cbWinFontDirLen-1] = 0; @@ -259,14 +261,14 @@ void SysFontList::scanWindowsFonts(GooString *winFontDir) { } else { path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts\\"; } - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0, + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, path, 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, ®Key) == ERROR_SUCCESS) { idx = 0; while (1) { valNameLen = sizeof(valName) - 1; dataLen = sizeof(data) - 1; - if (RegEnumValue(regKey, idx, valName, &valNameLen, NULL, + if (RegEnumValueA(regKey, idx, valName, &valNameLen, NULL, &type, (LPBYTE)data, &dataLen) != ERROR_SUCCESS) { break; } @@ -462,37 +464,28 @@ void GlobalParams::setupBaseFonts(char * dir) if (file != NULL) { Parser *parser; - Object obj1, obj2; - - obj1.initNull(); parser = new Parser(NULL, new Lexer(NULL, - new FileStream(file, 0, gFalse, file->size(), &obj1)), + new FileStream(file, 0, gFalse, file->size(), Object(objNull))), gTrue); - obj1.free(); - parser->getObj(&obj1); + Object obj1 = parser->getObj(); while (!obj1.isEOF()) { - parser->getObj(&obj2); + Object obj2 = parser->getObj(); if (obj1.isName()) { // Substitutions if (obj2.isDict()) { - Object obj3; - obj2.getDict()->lookup("Path", &obj3); + Object obj3 = obj2.getDict()->lookup("Path"); if (obj3.isString()) addFontFile(new GooString(obj1.getName()), obj3.getString()->copy()); - obj3.free(); // Aliases } else if (obj2.isName()) { substFiles->add(new GooString(obj1.getName()), new GooString(obj2.getName())); } } - obj2.free(); - obj1.free(); - parser->getObj(&obj1); + obj1 = parser->getObj(); // skip trailing ';' while (obj1.isCmd(";")) { - obj1.free(); - parser->getObj(&obj1); + obj1 = parser->getObj(); } } delete file; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Hints.cc b/Build/source/libs/poppler/poppler-src/poppler/Hints.cc index 7f11304edd7..270b6e43d3d 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Hints.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Hints.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2010, 2012 Hib Eris <hib@hiberis.nl> -// Copyright 2010, 2011, 2013, 2014, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright 2010, 2011, 2013, 2014, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright 2010, 2013 Pino Toscano <pino@kde.org> // Copyright 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright 2014 Fabio D'Urso <fabiodurso@hotmail.it> @@ -181,42 +181,38 @@ void Hints::readTables(BaseStream *str, Linearization *linearization, XRef *xref hintsLength2 = linearization->getHintsLength2(); Parser *parser; - Object obj; int bufLength = hintsLength + hintsLength2; std::vector<char> buf(bufLength); char *p = &buf[0]; - obj.initNull(); - Stream *s = str->makeSubStream(hintsOffset, gFalse, hintsLength, &obj); + Stream *s = str->makeSubStream(hintsOffset, gFalse, hintsLength, Object(objNull)); s->reset(); for (Guint i=0; i < hintsLength; i++) { *p++ = s->getChar(); } delete s; if (hintsOffset2 && hintsLength2) { - obj.initNull(); - s = str->makeSubStream(hintsOffset2, gFalse, hintsLength2, &obj); + s = str->makeSubStream(hintsOffset2, gFalse, hintsLength2, Object(objNull)); s->reset(); for (Guint i=0; i < hintsLength2; i++) { *p++ = s->getChar(); } delete s; } - obj.initNull(); - MemStream *memStream = new MemStream (&buf[0], 0, bufLength, &obj); + MemStream *memStream = new MemStream (&buf[0], 0, bufLength, Object(objNull)); - obj.initNull(); parser = new Parser(xref, new Lexer(xref, memStream), gTrue); int num, gen; - if (parser->getObj(&obj)->isInt() && - (num = obj.getInt(), obj.free(), parser->getObj(&obj)->isInt()) && - (gen = obj.getInt(), obj.free(), parser->getObj(&obj)->isCmd("obj")) && - (obj.free(), parser->getObj(&obj, gFalse, + Object obj; + if ((obj = parser->getObj(), obj.isInt()) && + (num = obj.getInt(), obj = parser->getObj(), obj.isInt()) && + (gen = obj.getInt(), obj = parser->getObj(), obj.isCmd("obj")) && + (obj = parser->getObj(gFalse, secHdlr ? secHdlr->getFileKey() : (Guchar *)NULL, secHdlr ? secHdlr->getEncAlgorithm() : cryptRC4, secHdlr ? secHdlr->getFileKeyLength() : 0, - num, gen, 0, gTrue)->isStream())) { + num, gen, 0, gTrue), obj.isStream())) { Stream *hintsStream = obj.getStream(); Dict *hintsDict = obj.streamGetDict(); @@ -238,7 +234,6 @@ void Hints::readTables(BaseStream *str, Linearization *linearization, XRef *xref } else { error(errSyntaxWarning, -1, "Failed parsing hints table object"); } - obj.free(); delete parser; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc b/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc index a1d2f97c72e..bda7f42eb7c 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2006 Raj Kumar <rkumar@archive.org> // Copyright (C) 2006 Paul Walmsley <paul@booyaka.com> -// Copyright (C) 2006-2010, 2012, 2014-2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2010, 2012, 2014-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 David Benjamin <davidben@mit.edu> // Copyright (C) 2011 Edward Jiang <ejiang@google.com> // Copyright (C) 2012 William Bader <williambader@hotmail.com> @@ -674,8 +674,8 @@ class JBIG2Bitmap: public JBIG2Segment { public: JBIG2Bitmap(Guint segNumA, int wA, int hA); - virtual ~JBIG2Bitmap(); - virtual JBIG2SegmentType getType() { return jbig2SegBitmap; } + ~JBIG2Bitmap(); + JBIG2SegmentType getType() override { return jbig2SegBitmap; } JBIG2Bitmap *copy() { return new JBIG2Bitmap(0, this); } JBIG2Bitmap *getSlice(Guint x, Guint y, Guint wA, Guint hA); void expand(int newH, Guint pixel); @@ -760,6 +760,10 @@ JBIG2Bitmap *JBIG2Bitmap::getSlice(Guint x, Guint y, Guint wA, Guint hA) { JBIG2Bitmap *slice; Guint xx, yy; + if (!data) { + return nullptr; + } + slice = new JBIG2Bitmap(0, wA, hA); if (slice->isOk()) { slice->clearToZero(); @@ -892,7 +896,7 @@ void JBIG2Bitmap::combine(JBIG2Bitmap *bitmap, int x, int y, oneByte = x0 == ((x1 - 1) & ~7); for (yy = y0; yy < y1; ++yy) { - if (unlikely(y + yy) >= h) + if (unlikely((y + yy >= h) || (y + yy < 0))) continue; // one byte per line -- need to mask both left and right side @@ -1046,8 +1050,8 @@ class JBIG2SymbolDict: public JBIG2Segment { public: JBIG2SymbolDict(Guint segNumA, Guint sizeA); - virtual ~JBIG2SymbolDict(); - virtual JBIG2SegmentType getType() { return jbig2SegSymbolDict; } + ~JBIG2SymbolDict(); + JBIG2SegmentType getType() override { return jbig2SegSymbolDict; } Guint getSize() { return size; } void setBitmap(Guint idx, JBIG2Bitmap *bitmap) { bitmaps[idx] = bitmap; } JBIG2Bitmap *getBitmap(Guint idx) { return bitmaps[idx]; } @@ -1107,8 +1111,8 @@ class JBIG2PatternDict: public JBIG2Segment { public: JBIG2PatternDict(Guint segNumA, Guint sizeA); - virtual ~JBIG2PatternDict(); - virtual JBIG2SegmentType getType() { return jbig2SegPatternDict; } + ~JBIG2PatternDict(); + JBIG2SegmentType getType() override { return jbig2SegPatternDict; } Guint getSize() { return size; } void setBitmap(Guint idx, JBIG2Bitmap *bitmap) { if (likely(idx < size)) bitmaps[idx] = bitmap; } JBIG2Bitmap *getBitmap(Guint idx) { return (idx < size) ? bitmaps[idx] : NULL; } @@ -1148,8 +1152,8 @@ class JBIG2CodeTable: public JBIG2Segment { public: JBIG2CodeTable(Guint segNumA, JBIG2HuffmanTable *tableA); - virtual ~JBIG2CodeTable(); - virtual JBIG2SegmentType getType() { return jbig2SegCodeTable; } + ~JBIG2CodeTable(); + JBIG2SegmentType getType() override { return jbig2SegCodeTable; } JBIG2HuffmanTable *getHuffTable() { return table; } private: @@ -1197,7 +1201,7 @@ JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA, Object *globalsSt mmrDecoder = new JBIG2MMRDecoder(); if (globalsStreamA->isStream()) { - globalsStreamA->copy(&globalsStream); + globalsStream = globalsStreamA->copy(); if (globalsStreamRefA->isRef()) globalsStreamRef = globalsStreamRefA->getRef(); } @@ -1209,7 +1213,6 @@ JBIG2Stream::JBIG2Stream(Stream *strA, Object *globalsStreamA, Object *globalsSt JBIG2Stream::~JBIG2Stream() { close(); - globalsStream.free(); delete arithDecoder; delete genericRegionStats; delete refinementRegionStats; @@ -1304,7 +1307,7 @@ Goffset JBIG2Stream::getPos() { int JBIG2Stream::getChars(int nChars, Guchar *buffer) { int n, i; - if (nChars <= 0) { + if (nChars <= 0 || !dataPtr) { return 0; } if (dataEnd - dataPtr < nChars) { @@ -2961,8 +2964,8 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h, mmrDecoder->reset(); if (w > INT_MAX - 2) { error(errSyntaxError, curStr->getPos(), "Bad width in JBIG2 generic bitmap"); - // force a call to gmalloc(-1), which will throw an exception - w = -3; + delete bitmap; + return NULL; } // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = w // ---> max codingLine size = w + 1 @@ -3827,6 +3830,10 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h, JBIG2BitmapPtr tpgrCXPtr2 = {0}; int x, y, pix; + if (!refBitmap) { + return nullptr; + } + bitmap = new JBIG2Bitmap(0, w, h); if (!bitmap->isOk()) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.h b/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.h index 1e14c5cf783..f28a7d2de06 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.h +++ b/Build/source/libs/poppler/poppler-src/poppler/JBIG2Stream.h @@ -48,21 +48,21 @@ class JBIG2Stream: public FilterStream { public: JBIG2Stream(Stream *strA, Object *globalsStreamA, Object *globalsStreamRefA); - virtual ~JBIG2Stream(); - virtual StreamKind getKind() { return strJBIG2; } - virtual void reset(); - virtual void close(); - virtual Goffset getPos(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + ~JBIG2Stream(); + StreamKind getKind() override { return strJBIG2; } + void reset() override; + void close() override; + Goffset getPos() override; + int getChar() override; + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; virtual Object *getGlobalsStream() { return &globalsStream; } virtual Ref getGlobalsStreamRef() { return globalsStreamRef; } private: - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; void readSegments(); GBool readSymbolDictSeg(Guint segNum, Guint length, diff --git a/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.cc b/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.cc index 7daa23d6135..078465a0393 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.cc @@ -4,7 +4,7 @@ // // A JPX stream decoder using OpenJPEG // -// Copyright 2008-2010, 2012 Albert Astals Cid <aacid@kde.org> +// Copyright 2008-2010, 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright 2011 Daniel Glöckner <daniel-gl@gmx.net> // Copyright 2014, 2016 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright 2013, 2014 Adrian Johnson <ajohnson@redneon.com> @@ -24,7 +24,6 @@ + ((minor) * 100) \ + ((micro) * 1)) -#ifdef USE_OPENJPEG2 #ifdef OPJ_VERSION_MAJOR #define OPENJPEG_VERSION OPENJPEG_VERSION_ENCODE(OPJ_VERSION_MAJOR, OPJ_VERSION_MINOR, OPJ_VERSION_BUILD) #else @@ -33,7 +32,6 @@ // assume there will be no API changes in 2.0.x. #define OPENJPEG_VERSION OPENJPEG_VERSION_ENCODE(2, 0, 0) #endif -#endif struct JPXStreamPrivate { opj_image_t *image; @@ -44,13 +42,7 @@ struct JPXStreamPrivate { GBool indexed; GBool inited; int smaskInData; -#ifdef USE_OPENJPEG1 - opj_dinfo_t *dinfo; - void init2(unsigned char *buf, int bufLen, OPJ_CODEC_FORMAT format, GBool indexed); -#endif -#ifdef USE_OPENJPEG2 void init2(OPJ_CODEC_FORMAT format, unsigned char *data, int length, GBool indexed); -#endif }; static inline Guchar adjustComp(int r, int adjust, int depth, int sgndcorr, GBool indexed) { @@ -90,9 +82,6 @@ JPXStream::JPXStream(Stream *strA) : FilterStream(strA) { priv->npixels = 0; priv->ncomps = 0; priv->indexed = gFalse; -#ifdef USE_OPENJPEG1 - priv->dinfo = NULL; -#endif } JPXStream::~JPXStream() { @@ -112,13 +101,6 @@ void JPXStream::close() { priv->image = NULL; priv->npixels = 0; } - -#ifdef USE_OPENJPEG1 - if (priv->dinfo != NULL) { - opj_destroy_decompress(priv->dinfo); - priv->dinfo = NULL; - } -#endif } Goffset JPXStream::getPos() { @@ -162,13 +144,8 @@ void JPXStream::getImageParams(int *bitsPerComponent, StreamColorSpaceMode *csMo *bitsPerComponent = 8; int numComps = (priv->image) ? priv->image->numcomps : 1; if (priv->image) { -#ifdef USE_OPENJPEG1 - if (priv->image->color_space == CLRSPC_SRGB && numComps == 4) { numComps = 3; } - else if (priv->image->color_space == CLRSPC_SYCC && numComps == 4) { numComps = 3; } -#else if (priv->image->color_space == OPJ_CLRSPC_SRGB && numComps == 4) { numComps = 3; } else if (priv->image->color_space == OPJ_CLRSPC_SYCC && numComps == 4) { numComps = 3; } -#endif else if (numComps == 2) { numComps = 1; } else if (numComps > 4) { numComps = 4; } } @@ -189,132 +166,6 @@ static void libopenjpeg_warning_callback(const char *msg, void * /*client_data*/ error(errSyntaxWarning, -1, "{0:s}", msg); } -#ifdef USE_OPENJPEG1 - -#define BUFFER_INITIAL_SIZE 4096 - -void JPXStream::init() -{ - Object oLen, cspace, smaskInData; - if (getDict()) getDict()->lookup("Length", &oLen); - if (getDict()) getDict()->lookup("ColorSpace", &cspace); - if (getDict()) getDict()->lookup("SMaskInData", &smaskInData); - - int bufSize = BUFFER_INITIAL_SIZE; - if (oLen.isInt()) bufSize = oLen.getInt(); - oLen.free(); - - if (cspace.isArray() && cspace.arrayGetLength() > 0) { - Object cstype; - cspace.arrayGet(0, &cstype); - if (cstype.isName("Indexed")) priv->indexed = gTrue; - cstype.free(); - } - cspace.free(); - - priv->smaskInData = 0; - if (smaskInData.isInt()) priv->smaskInData = smaskInData.getInt(); - smaskInData.free(); - - int length = 0; - unsigned char *buf = str->toUnsignedChars(&length, bufSize); - priv->init2(buf, length, CODEC_JP2, priv->indexed); - free(buf); - - if (priv->image) { - int numComps = (priv->image) ? priv->image->numcomps : 1; - int alpha = 0; - if (priv->image) { - if (priv->image->color_space == CLRSPC_SRGB && numComps == 4) { numComps = 3; alpha = 1; } - else if (priv->image->color_space == CLRSPC_SYCC && numComps == 4) { numComps = 3; alpha = 1; } - else if (numComps == 2) { numComps = 1; alpha = 1; } - else if (numComps > 4) { numComps = 4; alpha = 1; } - else { alpha = 0; } - } - priv->npixels = priv->image->comps[0].w * priv->image->comps[0].h; - priv->ncomps = priv->image->numcomps; - if (alpha == 1 && priv->smaskInData == 0) priv->ncomps--; - for (int component = 0; component < priv->ncomps; component++) { - if (priv->image->comps[component].data == NULL) { - close(); - break; - } - unsigned char *cdata = (unsigned char *)priv->image->comps[component].data; - int adjust = 0; - int depth = priv->image->comps[component].prec; - if (priv->image->comps[component].prec > 8) - adjust = priv->image->comps[component].prec - 8; - int sgndcorr = 0; - if (priv->image->comps[component].sgnd) - sgndcorr = 1 << (priv->image->comps[0].prec - 1); - for (int i = 0; i < priv->npixels; i++) { - int r = priv->image->comps[component].data[i]; - *(cdata++) = adjustComp(r, adjust, depth, sgndcorr, priv->indexed); - } - } - } else - priv->npixels = 0; - - priv->counter = 0; - priv->ccounter = 0; - priv->inited = gTrue; -} - -void JPXStreamPrivate::init2(unsigned char *buf, int bufLen, OPJ_CODEC_FORMAT format, GBool indexed) -{ - opj_cio_t *cio = NULL; - - /* Use default decompression parameters */ - opj_dparameters_t parameters; - opj_set_default_decoder_parameters(¶meters); -#ifdef WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG - if (indexed) - parameters.flags = OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; -#endif - - /* Configure the event manager to receive errors and warnings */ - opj_event_mgr_t event_mgr; - memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); - event_mgr.error_handler = libopenjpeg_error_callback; - event_mgr.warning_handler = libopenjpeg_warning_callback; - - /* Get the decoder handle of the format */ - dinfo = opj_create_decompress(format); - if (dinfo == NULL) goto error; - /* Catch events using our callbacks */ - opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, NULL); - - /* Setup the decoder decoding parameters */ - opj_setup_decoder(dinfo, ¶meters); - - /* Open a byte stream */ - cio = opj_cio_open((opj_common_ptr)dinfo, buf, bufLen); - if (cio == NULL) goto error; - - /* Decode the stream and fill the image structure */ - image = opj_decode(dinfo, cio); - - /* Close the byte stream */ - opj_cio_close(cio); - - if (image == NULL) goto error; - else return; - -error: - if (format == CODEC_JP2) { - error(errSyntaxWarning, -1, "Did not succeed opening JPX Stream as JP2, trying as J2K."); - init2(buf, bufLen, CODEC_J2K, indexed); - } else if (format == CODEC_J2K) { - error(errSyntaxWarning, -1, "Did not succeed opening JPX Stream as J2K, trying as JPT."); - init2(buf, bufLen, CODEC_JPT, indexed); - } else { - error(errSyntaxError, -1, "Did not succeed opening JPX Stream."); - } -} -#endif - - -#ifdef USE_OPENJPEG2 typedef struct JPXData_s { unsigned char *data; @@ -363,25 +214,22 @@ static OPJ_BOOL jpxSeek_callback(OPJ_OFF_T seek_pos, void * p_user_data) void JPXStream::init() { Object oLen, cspace, smaskInData; - if (getDict()) getDict()->lookup("Length", &oLen); - if (getDict()) getDict()->lookup("ColorSpace", &cspace); - if (getDict()) getDict()->lookup("SMaskInData", &smaskInData); + if (getDict()) { + oLen = getDict()->lookup("Length"); + cspace = getDict()->lookup("ColorSpace"); + smaskInData = getDict()->lookup("SMaskInData"); + } int bufSize = BUFFER_INITIAL_SIZE; if (oLen.isInt()) bufSize = oLen.getInt(); - oLen.free(); if (cspace.isArray() && cspace.arrayGetLength() > 0) { - Object cstype; - cspace.arrayGet(0, &cstype); + Object cstype = cspace.arrayGet(0); if (cstype.isName("Indexed")) priv->indexed = gTrue; - cstype.free(); } - cspace.free(); priv->smaskInData = 0; if (smaskInData.isInt()) priv->smaskInData = smaskInData.getInt(); - smaskInData.free(); int length = 0; unsigned char *buf = str->toUnsignedChars(&length, bufSize); @@ -504,6 +352,7 @@ void JPXStreamPrivate::init2(OPJ_CODEC_FORMAT format, unsigned char *buf, int le return; error: + opj_stream_destroy(stream); opj_destroy_codec(decoder); if (format == OPJ_CODEC_JP2) { error(errSyntaxWarning, -1, "Did no succeed opening JPX Stream as JP2, trying as J2K."); @@ -515,4 +364,3 @@ error: error(errSyntaxError, -1, "Did no succeed opening JPX Stream."); } } -#endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.h b/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.h index 73b6bdd97b8..1fb63f1df78 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.h +++ b/Build/source/libs/poppler/poppler-src/poppler/JPEG2000Stream.h @@ -28,16 +28,16 @@ class JPXStream: public FilterStream { public: JPXStream(Stream *strA); - virtual ~JPXStream(); - virtual StreamKind getKind() { return strJPX; } - virtual void reset(); - virtual void close(); - virtual Goffset getPos(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); - virtual void getImageParams(int *bitsPerComponent, StreamColorSpaceMode *csMode); + ~JPXStream(); + StreamKind getKind() override { return strJPX; } + void reset() override; + void close() override; + Goffset getPos() override; + int getChar() override; + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; + void getImageParams(int *bitsPerComponent, StreamColorSpaceMode *csMode) override; int readStream(int nChars, Guchar *buffer) { return str->doGetChars(nChars, buffer); @@ -48,8 +48,8 @@ private: JPXStreamPrivate *priv; void init(); - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; }; #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/JPXStream.h b/Build/source/libs/poppler/poppler-src/poppler/JPXStream.h index 30855431fb4..8926ffe546a 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/JPXStream.h +++ b/Build/source/libs/poppler/poppler-src/poppler/JPXStream.h @@ -262,15 +262,15 @@ public: JPXStream(Stream *strA); virtual ~JPXStream(); - virtual StreamKind getKind() { return strJPX; } - virtual void reset(); - virtual void close(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + virtual StreamKind getKind() override { return strJPX; } + virtual void reset() override; + virtual void close() override; + virtual int getChar() override; + virtual int lookChar() override; + virtual GooString *getPSFilter(int psLevel, const char *indent) override; + virtual GBool isBinary(GBool last = gTrue) override; virtual void getImageParams(int *bitsPerComponent, - StreamColorSpaceMode *csMode); + StreamColorSpaceMode *csMode) override; private: diff --git a/Build/source/libs/poppler/poppler-src/poppler/Lexer.cc b/Build/source/libs/poppler/poppler-src/poppler/Lexer.cc index 952967a998a..d2329b53631 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Lexer.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Lexer.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) 2006-2010, 2012-2014 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2010, 2012-2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2010 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2012, 2013 Adrian Johnson <ajohnson@redneon.com> @@ -70,36 +70,33 @@ static const long long LongLongSafeLimit = (LLONG_MAX - 9) / 10; //------------------------------------------------------------------------ Lexer::Lexer(XRef *xrefA, Stream *str) { - Object obj; - lookCharLastValueCached = LOOK_VALUE_NOT_CACHED; xref = xrefA; - curStr.initStream(str); + curStr = Object(str); streams = new Array(xref); - streams->add(curStr.copy(&obj)); + streams->add(curStr.copy()); strPtr = 0; freeArray = gTrue; curStr.streamReset(); } Lexer::Lexer(XRef *xrefA, Object *obj) { - Object obj2; - lookCharLastValueCached = LOOK_VALUE_NOT_CACHED; xref = xrefA; if (obj->isStream()) { + Object obj2; streams = new Array(xref); freeArray = gTrue; - streams->add(obj->copy(&obj2)); + streams->add(obj->copy()); } else { streams = obj->getArray(); freeArray = gFalse; } strPtr = 0; if (streams->getLength() > 0) { - streams->get(strPtr, &curStr); + curStr = streams->get(strPtr); curStr.streamReset(); } } @@ -107,7 +104,6 @@ Lexer::Lexer(XRef *xrefA, Object *obj) { Lexer::~Lexer() { if (!curStr.isNone()) { curStr.streamClose(); - curStr.free(); } if (freeArray) { delete streams; @@ -129,10 +125,10 @@ int Lexer::getChar(GBool comesFromLook) { return EOF; } else { curStr.streamClose(); - curStr.free(); + curStr = Object(); ++strPtr; if (strPtr < streams->getLength()) { - streams->get(strPtr, &curStr); + curStr = streams->get(strPtr); curStr.streamReset(); } } @@ -154,7 +150,7 @@ int Lexer::lookChar() { } } -Object *Lexer::getObj(Object *obj, int objNum) { +Object Lexer::getObj(int objNum) { char *p; int c, c2; GBool comment, neg, done, overflownInteger, overflownLongLong; @@ -169,7 +165,7 @@ Object *Lexer::getObj(Object *obj, int objNum) { comment = gFalse; while (1) { if ((c = getChar()) == EOF) { - return obj->initEOF(); + return Object(objEOF); } if (comment) { if (c == '\r' || c == '\n') @@ -236,16 +232,16 @@ Object *Lexer::getObj(Object *obj, int objNum) { } if (unlikely(overflownInteger)) { if (overflownLongLong) { - obj->initReal(xf); + return Object(xf); } else { if (unlikely(xll == INT_MIN)) { - obj->initInt(INT_MIN); + return Object(static_cast<int>(INT_MIN)); } else { - obj->initInt64(xll); + return Object(xll); } } } else { - obj->initInt(xi); + return Object(xi); } break; doReal: @@ -274,7 +270,7 @@ Object *Lexer::getObj(Object *obj, int objNum) { if (neg) { xf = -xf; } - obj->initReal(xf); + return Object(xf); break; // string @@ -401,9 +397,9 @@ Object *Lexer::getObj(Object *obj, int objNum) { s = new GooString(tokBuf, n); else s->append(tokBuf, n); - obj->initString(s); + return Object(s); } else { - obj->initEOF(); + return Object(objEOF); } break; @@ -455,10 +451,11 @@ Object *Lexer::getObj(Object *obj, int objNum) { } if (n < tokBufSize) { *p = '\0'; - obj->initName(tokBuf); + return Object(objName, tokBuf); } else { - obj->initName(s->getCString()); + Object obj(objName, s->getCString()); delete s; + return obj; } break; @@ -467,7 +464,7 @@ Object *Lexer::getObj(Object *obj, int objNum) { case ']': tokBuf[0] = c; tokBuf[1] = '\0'; - obj->initCmd(tokBuf); + return Object(objCmd, tokBuf); break; // hex string or dict punctuation @@ -479,7 +476,7 @@ Object *Lexer::getObj(Object *obj, int objNum) { getChar(); tokBuf[0] = tokBuf[1] = '<'; tokBuf[2] = '\0'; - obj->initCmd(tokBuf); + return Object(objCmd, tokBuf); // hex string } else { @@ -526,7 +523,7 @@ Object *Lexer::getObj(Object *obj, int objNum) { s->append(tokBuf, n); if (m == 1) s->append((char)(c2 << 4)); - obj->initString(s); + return Object(s); } break; @@ -537,10 +534,10 @@ Object *Lexer::getObj(Object *obj, int objNum) { getChar(); tokBuf[0] = tokBuf[1] = '>'; tokBuf[2] = '\0'; - obj->initCmd(tokBuf); + return Object(objCmd, tokBuf); } else { error(errSyntaxError, getPos(), "Illegal character '>'"); - obj->initError(); + return Object(objError); } break; @@ -549,7 +546,7 @@ Object *Lexer::getObj(Object *obj, int objNum) { case '{': case '}': error(errSyntaxError, getPos(), "Illegal character '{0:c}'", c); - obj->initError(); + return Object(objError); break; // command @@ -567,21 +564,21 @@ Object *Lexer::getObj(Object *obj, int objNum) { } *p = '\0'; if (tokBuf[0] == 't' && !strcmp(tokBuf, "true")) { - obj->initBool(gTrue); + return Object(gTrue); } else if (tokBuf[0] == 'f' && !strcmp(tokBuf, "false")) { - obj->initBool(gFalse); + return Object(gFalse); } else if (tokBuf[0] == 'n' && !strcmp(tokBuf, "null")) { - obj->initNull(); + return Object(objNull); } else { - obj->initCmd(tokBuf); + return Object(objCmd, tokBuf); } break; } - return obj; + return Object(); } -Object *Lexer::getObj(Object *obj, const char *cmdA, int objNum) { +Object Lexer::getObj(const char *cmdA, int objNum) { char *p; int c; GBool comment; @@ -594,7 +591,7 @@ Object *Lexer::getObj(Object *obj, const char *cmdA, int objNum) { while (strcmp(cmdA, cmd1) && (objNum < 0 || (xref && xref->getNumEntry(getPos()) == objNum))) { while (1) { if ((c = getChar()) == EOF) { - return obj->initEOF(); + return Object(objEOF); } if (comment) { if (c == '\r' || c == '\n') { @@ -618,9 +615,8 @@ Object *Lexer::getObj(Object *obj, const char *cmdA, int objNum) { } *p = '\0'; } - obj->initCmd(tokBuf); - - return obj; + + return Object(objCmd, tokBuf); } void Lexer::skipToNextLine() { diff --git a/Build/source/libs/poppler/poppler-src/poppler/Lexer.h b/Build/source/libs/poppler/poppler-src/poppler/Lexer.h index 02b6cdc6923..ac3334c500f 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Lexer.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Lexer.h @@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2006, 2007, 2010, 2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2007, 2010, 2013, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> @@ -56,8 +56,9 @@ public: ~Lexer(); // Get the next object from the input stream. - Object *getObj(Object *obj, int objNum = -1); - Object *getObj(Object *obj, const char *cmdA, int objNum); + Object getObj(int objNum = -1); + Object getObj(const char *cmdA, int objNum); + template<typename T> Object getObj(T) = delete; // Skip to the beginning of the next line in the input stream. void skipToNextLine(); diff --git a/Build/source/libs/poppler/poppler-src/poppler/Linearization.cc b/Build/source/libs/poppler/poppler-src/poppler/Linearization.cc index be041f96407..49008a31086 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Linearization.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Linearization.cc @@ -6,6 +6,7 @@ // // Copyright 2010, 2012 Hib Eris <hib@hiberis.nl> // Copyright 2015 Jason Crain <jason@aquaticape.us> +// Copyright 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -20,36 +21,26 @@ Linearization::Linearization (BaseStream *str) { Parser *parser; - Object obj1, obj2, obj3, obj5; - - linDict.initNull(); str->reset(); - obj1.initNull(); parser = new Parser(NULL, - new Lexer(NULL, str->makeSubStream(str->getStart(), gFalse, 0, &obj1)), + new Lexer(NULL, str->makeSubStream(str->getStart(), gFalse, 0, Object(objNull))), gFalse); - parser->getObj(&obj1); - parser->getObj(&obj2); - parser->getObj(&obj3); - parser->getObj(&linDict); + Object obj1 = parser->getObj(); + Object obj2 = parser->getObj(); + Object obj3 = parser->getObj(); + linDict = parser->getObj(); if (obj1.isInt() && obj2.isInt() && obj3.isCmd("obj") && linDict.isDict()) { - linDict.dictLookup("Linearized", &obj5); + Object obj5 = linDict.dictLookup("Linearized"); if (!(obj5.isNum() && obj5.getNum() > 0)) { - linDict.free(); - linDict.initNull(); + linDict.setToNull(); } - obj5.free(); } - obj3.free(); - obj2.free(); - obj1.free(); delete parser; } Linearization:: ~Linearization() { - linDict.free(); } Guint Linearization::getLength() @@ -72,17 +63,15 @@ Guint Linearization::getHintsOffset() Object obj1, obj2; if (linDict.isDict() && - linDict.dictLookup("H", &obj1)->isArray() && + (obj1 = linDict.dictLookup("H"), obj1.isArray()) && obj1.arrayGetLength()>=2 && - obj1.arrayGet(0, &obj2)->isInt() && + (obj2 = obj1.arrayGet(0), obj2.isInt()) && obj2.getInt() > 0) { hintsOffset = obj2.getInt(); } else { error(errSyntaxWarning, -1, "Hints table offset in linearization table is invalid"); hintsOffset = 0; } - obj2.free(); - obj1.free(); return hintsOffset; } @@ -93,17 +82,15 @@ Guint Linearization::getHintsLength() Object obj1, obj2; if (linDict.isDict() && - linDict.dictLookup("H", &obj1)->isArray() && + (obj1 = linDict.dictLookup("H"), obj1.isArray()) && obj1.arrayGetLength()>=2 && - obj1.arrayGet(1, &obj2)->isInt() && + (obj2 = obj1.arrayGet(1), obj2.isInt()) && obj2.getInt() > 0) { hintsLength = obj2.getInt(); } else { error(errSyntaxWarning, -1, "Hints table length in linearization table is invalid"); hintsLength = 0; } - obj2.free(); - obj1.free(); return hintsLength; } @@ -112,20 +99,18 @@ Guint Linearization::getHintsOffset2() { int hintsOffset2 = 0; // default to 0 - Object obj1, obj2; + Object obj1; if (linDict.isDict() && - linDict.dictLookup("H", &obj1)->isArray() && + (obj1 = linDict.dictLookup("H"), obj1.isArray()) && obj1.arrayGetLength()>=4) { - if (obj1.arrayGet(2, &obj2)->isInt() && - obj2.getInt() > 0) { + Object obj2 = obj1.arrayGet(2); + if (obj2.isInt() && obj2.getInt() > 0) { hintsOffset2 = obj2.getInt(); } else { error(errSyntaxWarning, -1, "Second hints table offset in linearization table is invalid"); hintsOffset2 = 0; } } - obj2.free(); - obj1.free(); return hintsOffset2; } @@ -134,20 +119,18 @@ Guint Linearization::getHintsLength2() { int hintsLength2 = 0; // default to 0 - Object obj1, obj2; + Object obj1; if (linDict.isDict() && - linDict.dictLookup("H", &obj1)->isArray() && + (obj1 = linDict.dictLookup("H"), obj1.isArray()) && obj1.arrayGetLength()>=4) { - if (obj1.arrayGet(3, &obj2)->isInt() && - obj2.getInt() > 0) { + Object obj2 = obj1.arrayGet(3); + if (obj2.isInt() && obj2.getInt() > 0) { hintsLength2 = obj2.getInt(); } else { error(errSyntaxWarning, -1, "Second hints table length in linearization table is invalid"); hintsLength2 = 0; } } - obj2.free(); - obj1.free(); return hintsLength2; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Link.cc b/Build/source/libs/poppler/poppler-src/poppler/Link.cc index d4680dbc54d..a927c214f9a 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Link.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Link.cc @@ -16,7 +16,7 @@ // Copyright (C) 2006, 2008 Pino Toscano <pino@kde.org> // Copyright (C) 2007, 2010, 2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com> -// Copyright (C) 2008-2010, 2012-2014, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008-2010, 2012-2014, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> // Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com> // Copyright (C) 2012 Tobias Koening <tobias.koenig@kdab.com> @@ -64,7 +64,6 @@ LinkAction *LinkAction::parseDest(Object *obj) { LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { LinkAction *action; - Object obj2, obj3, obj4; if (!obj->isDict()) { error(errSyntaxWarning, -1, "parseAction: Bad annotation action for URI '{0:s}'", @@ -72,21 +71,18 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { return NULL; } - obj->dictLookup("S", &obj2); + Object obj2 = obj->dictLookup("S"); // GoTo action if (obj2.isName("GoTo")) { - obj->dictLookup("D", &obj3); + Object obj3 = obj->dictLookup("D"); action = new LinkGoTo(&obj3); - obj3.free(); // GoToR action } else if (obj2.isName("GoToR")) { - obj->dictLookup("F", &obj3); - obj->dictLookup("D", &obj4); + Object obj3 = obj->dictLookup("F"); + Object obj4 = obj->dictLookup("D"); action = new LinkGoToR(&obj3, &obj4); - obj3.free(); - obj4.free(); // Launch action } else if (obj2.isName("Launch")) { @@ -94,15 +90,13 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { // URI action } else if (obj2.isName("URI")) { - obj->dictLookup("URI", &obj3); + Object obj3 = obj->dictLookup("URI"); action = new LinkURI(&obj3, baseURI); - obj3.free(); // Named action } else if (obj2.isName("Named")) { - obj->dictLookup("N", &obj3); + Object obj3 = obj->dictLookup("N"); action = new LinkNamed(&obj3); - obj3.free(); // Movie action } else if (obj2.isName("Movie")) { @@ -118,9 +112,8 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { // JavaScript action } else if (obj2.isName("JavaScript")) { - obj->dictLookup("JS", &obj3); + Object obj3 = obj->dictLookup("JS"); action = new LinkJavaScript(&obj3); - obj3.free(); // Set-OCG-State action } else if (obj2.isName("SetOCGState")) { @@ -137,8 +130,6 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { action = NULL; } - obj2.free(); - if (action && !action->isOk()) { delete action; return NULL; @@ -151,8 +142,6 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { //------------------------------------------------------------------------ LinkDest::LinkDest(Array *a) { - Object obj1, obj2; - // initialize fields left = bottom = right = top = zoom = 0; changeLeft = changeTop = changeZoom = gFalse; @@ -163,7 +152,7 @@ LinkDest::LinkDest(Array *a) { error(errSyntaxWarning, -1, "Annotation destination array is too short"); return; } - a->getNF(0, &obj1); + Object obj1 = a->getNF(0); if (obj1.isInt()) { pageNum = obj1.getInt() + 1; pageIsRef = gFalse; @@ -173,12 +162,11 @@ LinkDest::LinkDest(Array *a) { pageIsRef = gTrue; } else { error(errSyntaxWarning, -1, "Bad annotation destination"); - goto err2; + return; } - obj1.free(); // get destination type - a->get(1, &obj1); + obj1 = a->get(1); // XYZ link if (obj1.isName("XYZ")) { @@ -186,7 +174,7 @@ LinkDest::LinkDest(Array *a) { if (a->getLength() < 3) { changeLeft = gFalse; } else { - a->get(2, &obj2); + Object obj2 = a->get(2); if (obj2.isNull()) { changeLeft = gFalse; } else if (obj2.isNum()) { @@ -194,14 +182,13 @@ LinkDest::LinkDest(Array *a) { left = obj2.getNum(); } else { error(errSyntaxWarning, -1, "Bad annotation destination position"); - goto err1; + return; } - obj2.free(); } if (a->getLength() < 4) { changeTop = gFalse; } else { - a->get(3, &obj2); + Object obj2 = a->get(3); if (obj2.isNull()) { changeTop = gFalse; } else if (obj2.isNum()) { @@ -209,14 +196,13 @@ LinkDest::LinkDest(Array *a) { top = obj2.getNum(); } else { error(errSyntaxWarning, -1, "Bad annotation destination position"); - goto err1; + return; } - obj2.free(); } if (a->getLength() < 5) { changeZoom = gFalse; } else { - a->get(4, &obj2); + Object obj2 = a->get(4); if (obj2.isNull()) { changeZoom = gFalse; } else if (obj2.isNum()) { @@ -224,9 +210,8 @@ LinkDest::LinkDest(Array *a) { changeZoom = (zoom == 0) ? gFalse : gTrue; } else { error(errSyntaxWarning, -1, "Bad annotation destination position"); - goto err1; + return; } - obj2.free(); } // Fit link @@ -239,7 +224,7 @@ LinkDest::LinkDest(Array *a) { if (a->getLength() < 3) { changeTop = gFalse; } else { - a->get(2, &obj2); + Object obj2 = a->get(2); if (obj2.isNull()) { changeTop = gFalse; } else if (obj2.isNum()) { @@ -249,17 +234,16 @@ LinkDest::LinkDest(Array *a) { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); } // FitV link } else if (obj1.isName("FitV")) { if (a->getLength() < 3) { error(errSyntaxWarning, -1, "Annotation destination array is too short"); - goto err2; + return; } kind = destFitV; - a->get(2, &obj2); + Object obj2 = a->get(2); if (obj2.isNull()) { changeLeft = gFalse; } else if (obj2.isNum()) { @@ -269,43 +253,42 @@ LinkDest::LinkDest(Array *a) { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); // FitR link } else if (obj1.isName("FitR")) { if (a->getLength() < 6) { error(errSyntaxWarning, -1, "Annotation destination array is too short"); - goto err2; + return; } kind = destFitR; - if (a->get(2, &obj2)->isNum()) { + Object obj2 = a->get(2); + if (obj2.isNum()) { left = obj2.getNum(); } else { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); - if (a->get(3, &obj2)->isNum()) { + obj2 = a->get(3); + if (obj2.isNum()) { bottom = obj2.getNum(); } else { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); - if (a->get(4, &obj2)->isNum()) { + obj2 = a->get(4); + if (obj2.isNum()) { right = obj2.getNum(); } else { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); - if (a->get(5, &obj2)->isNum()) { + obj2 = a->get(5); + if (obj2.isNum()) { top = obj2.getNum(); } else { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); // FitB link } else if (obj1.isName("FitB")) { @@ -315,10 +298,10 @@ LinkDest::LinkDest(Array *a) { } else if (obj1.isName("FitBH")) { if (a->getLength() < 3) { error(errSyntaxWarning, -1, "Annotation destination array is too short"); - goto err2; + return; } kind = destFitBH; - a->get(2, &obj2); + Object obj2 = a->get(2); if (obj2.isNull()) { changeTop = gFalse; } else if (obj2.isNum()) { @@ -328,16 +311,15 @@ LinkDest::LinkDest(Array *a) { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); // FitBV link } else if (obj1.isName("FitBV")) { if (a->getLength() < 3) { error(errSyntaxWarning, -1, "Annotation destination array is too short"); - goto err2; + return; } kind = destFitBV; - a->get(2, &obj2); + Object obj2 = a->get(2); if (obj2.isNull()) { changeLeft = gFalse; } else if (obj2.isNum()) { @@ -347,22 +329,14 @@ LinkDest::LinkDest(Array *a) { error(errSyntaxWarning, -1, "Bad annotation destination position"); kind = destFit; } - obj2.free(); // unknown link kind } else { error(errSyntaxWarning, -1, "Unknown annotation destination type"); - goto err2; } - obj1.free(); ok = gTrue; return; - - err1: - obj2.free(); - err2: - obj1.free(); } LinkDest::LinkDest(LinkDest *dest) { @@ -428,10 +402,9 @@ LinkGoToR::LinkGoToR(Object *fileSpecObj, Object *destObj) { namedDest = NULL; // get file name - Object obj1; - if (getFileSpecNameForPlatform (fileSpecObj, &obj1)) { + Object obj1 = getFileSpecNameForPlatform (fileSpecObj); + if (obj1.isString()) { fileName = obj1.getString()->copy(); - obj1.free(); } // named destination @@ -469,54 +442,39 @@ LinkGoToR::~LinkGoToR() { //------------------------------------------------------------------------ LinkLaunch::LinkLaunch(Object *actionObj) { - Object obj1, obj2, obj3; fileName = NULL; params = NULL; if (actionObj->isDict()) { - if (!actionObj->dictLookup("F", &obj1)->isNull()) { - if (getFileSpecNameForPlatform (&obj1, &obj3)) { + Object obj1 = actionObj->dictLookup("F"); + if (!obj1.isNull()) { + Object obj3 = getFileSpecNameForPlatform (&obj1); + if (obj3.isString()) { fileName = obj3.getString()->copy(); - obj3.free(); } } else { - obj1.free(); #ifdef _WIN32 - if (actionObj->dictLookup("Win", &obj1)->isDict()) { - obj1.dictLookup("F", &obj2); - if (getFileSpecNameForPlatform (&obj2, &obj3)) { - fileName = obj3.getString()->copy(); - obj3.free(); - } - obj2.free(); - if (obj1.dictLookup("P", &obj2)->isString()) { - params = obj2.getString()->copy(); - } - obj2.free(); - } else { - error(errSyntaxWarning, -1, "Bad launch-type link action"); - } + obj1 = actionObj->dictLookup("Win"); #else //~ This hasn't been defined by Adobe yet, so assume it looks //~ just like the Win dictionary until they say otherwise. - if (actionObj->dictLookup("Unix", &obj1)->isDict()) { - obj1.dictLookup("F", &obj2); - if (getFileSpecNameForPlatform (&obj2, &obj3)) { + obj1 = actionObj->dictLookup("Unix"); +#endif + if (obj1.isDict()) { + Object obj2 = obj1.dictLookup("F"); + Object obj3 = getFileSpecNameForPlatform (&obj2); + if (obj3.isString()) { fileName = obj3.getString()->copy(); - obj3.free(); } - obj2.free(); - if (obj1.dictLookup("P", &obj2)->isString()) { + obj2 = obj1.dictLookup("P"); + if (obj2.isString()) { params = obj2.getString()->copy(); } - obj2.free(); } else { error(errSyntaxWarning, -1, "Bad launch-type link action"); } -#endif } - obj1.free(); } } @@ -601,23 +559,23 @@ LinkMovie::LinkMovie(Object *obj) { annotRef.num = -1; annotTitle = NULL; - Object tmp; - if (obj->dictLookupNF("Annotation", &tmp)->isRef()) { + Object tmp = obj->dictLookupNF("Annotation"); + if (tmp.isRef()) { annotRef = tmp.getRef(); } - tmp.free(); - if (obj->dictLookup("T", &tmp)->isString()) { + tmp = obj->dictLookup("T"); + if (tmp.isString()) { annotTitle = tmp.getString()->copy(); } - tmp.free(); if ((annotTitle == NULL) && (annotRef.num == -1)) { error(errSyntaxError, -1, "Movie action is missing both the Annot and T keys"); } - if (obj->dictLookup("Operation", &tmp)->isName()) { + tmp = obj->dictLookup("Operation"); + if (tmp.isName()) { char *name = tmp.getName(); if (!strcmp(name, "Play")) { @@ -633,7 +591,6 @@ LinkMovie::LinkMovie(Object *obj) { operation = operationTypeResume; } } - tmp.free(); } LinkMovie::~LinkMovie() { @@ -654,35 +611,29 @@ LinkSound::LinkSound(Object *soundObj) { sound = NULL; if (soundObj->isDict()) { - Object tmp; // volume - soundObj->dictLookup("Volume", &tmp); + Object tmp = soundObj->dictLookup("Volume"); if (tmp.isNum()) { volume = tmp.getNum(); } - tmp.free(); // sync - soundObj->dictLookup("Synchronous", &tmp); + tmp = soundObj->dictLookup("Synchronous"); if (tmp.isBool()) { sync = tmp.getBool(); } - tmp.free(); // repeat - soundObj->dictLookup("Repeat", &tmp); + tmp = soundObj->dictLookup("Repeat"); if (tmp.isBool()) { repeat = tmp.getBool(); } - tmp.free(); // mix - soundObj->dictLookup("Mix", &tmp); + tmp = soundObj->dictLookup("Mix"); if (tmp.isBool()) { mix = tmp.getBool(); } - tmp.free(); // 'Sound' object - soundObj->dictLookup("Sound", &tmp); + tmp = soundObj->dictLookup("Sound"); sound = Sound::parseSound(&tmp); - tmp.free(); } } @@ -701,9 +652,8 @@ LinkRendition::LinkRendition(Object *obj) { int operationCode = -1; if (obj->isDict()) { - Object tmp; - - if (!obj->dictLookup("JS", &tmp)->isNull()) { + Object tmp = obj->dictLookup("JS"); + if (!tmp.isNull()) { if (tmp.isString()) { js = new GooString(tmp.getString()); } else if (tmp.isStream()) { @@ -714,9 +664,9 @@ LinkRendition::LinkRendition(Object *obj) { error(errSyntaxWarning, -1, "Invalid Rendition Action: JS not string or stream"); } } - tmp.free(); - if (obj->dictLookup("OP", &tmp)->isInt()) { + tmp = obj->dictLookup("OP"); + if (tmp.isInt()) { operationCode = tmp.getInt(); if (!js && (operationCode < 0 || operationCode > 4)) { error(errSyntaxWarning, -1, "Invalid Rendition Action: unrecognized operation valued: {0:d}", operationCode); @@ -724,16 +674,18 @@ LinkRendition::LinkRendition(Object *obj) { Object obj1; // retrieve rendition object - if (obj->dictLookup("R", &renditionObj)->isDict()) { + renditionObj = obj->dictLookup("R"); + if (renditionObj.isDict()) { media = new MediaRendition(&renditionObj); } else if (operationCode == 0 || operationCode == 4) { error(errSyntaxWarning, -1, "Invalid Rendition Action: no R field with op = {0:d}", operationCode); - renditionObj.free(); + renditionObj.setToNull(); } - if (!obj->dictLookupNF("AN", &screenRef)->isRef() && operation >= 0 && operation <= 4) { + screenRef = obj->dictLookupNF("AN"); + if (!screenRef.isRef() && operation >= 0 && operation <= 4) { error(errSyntaxWarning, -1, "Invalid Rendition Action: no AN field with op = {0:d}", operationCode); - screenRef.free(); + screenRef.setToNull(); } } @@ -757,18 +709,12 @@ LinkRendition::LinkRendition(Object *obj) { } else if (!js) { error(errSyntaxWarning, -1, "Invalid Rendition action: no OP or JS field defined"); } - tmp.free(); } } LinkRendition::~LinkRendition() { - renditionObj.free(); - screenRef.free(); - - if (js) - delete js; - if (media) - delete media; + delete js; + delete media; } @@ -799,18 +745,15 @@ LinkJavaScript::~LinkJavaScript() { // LinkOCGState //------------------------------------------------------------------------ LinkOCGState::LinkOCGState(Object *obj) { - Object obj1; - stateList = new GooList(); preserveRB = gTrue; - if (obj->dictLookup("State", &obj1)->isArray()) { + Object obj1 = obj->dictLookup("State"); + if (obj1.isArray()) { StateList *stList = NULL; for (int i = 0; i < obj1.arrayGetLength(); ++i) { - Object obj2; - - obj1.arrayGetNF(i, &obj2); + Object obj2 = obj1.arrayGetNF(i); if (obj2.isName()) { if (stList) stateList->append(stList); @@ -842,7 +785,6 @@ LinkOCGState::LinkOCGState(Object *obj) { } else { error(errSyntaxWarning, -1, "Invalid item in OCG Action State array"); } - obj2.free(); } // Add the last group if (stList) @@ -852,12 +794,11 @@ LinkOCGState::LinkOCGState(Object *obj) { delete stateList; stateList = NULL; } - obj1.free(); - if (obj->dictLookup("PreserveRB", &obj1)->isBool()) { + obj1 = obj->dictLookup("PreserveRB"); + if (obj1.isBool()) { preserveRB = obj1.getBool(); } - obj1.free(); } LinkOCGState::~LinkOCGState() { diff --git a/Build/source/libs/poppler/poppler-src/poppler/Link.h b/Build/source/libs/poppler/poppler-src/poppler/Link.h index fc2abe60052..df44a49ff41 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Link.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Link.h @@ -150,13 +150,13 @@ public: LinkGoTo(Object *destObj); // Destructor. - virtual ~LinkGoTo(); + ~LinkGoTo(); // Was the LinkGoTo created successfully? - virtual GBool isOk() { return dest || namedDest; } + GBool isOk() override { return dest || namedDest; } // Accessors. - virtual LinkActionKind getKind() { return actionGoTo; } + LinkActionKind getKind() override { return actionGoTo; } LinkDest *getDest() { return dest; } GooString *getNamedDest() { return namedDest; } @@ -180,13 +180,13 @@ public: LinkGoToR(Object *fileSpecObj, Object *destObj); // Destructor. - virtual ~LinkGoToR(); + ~LinkGoToR(); // Was the LinkGoToR created successfully? - virtual GBool isOk() { return fileName && (dest || namedDest); } + GBool isOk() override { return fileName && (dest || namedDest); } // Accessors. - virtual LinkActionKind getKind() { return actionGoToR; } + LinkActionKind getKind() override { return actionGoToR; } GooString *getFileName() { return fileName; } LinkDest *getDest() { return dest; } GooString *getNamedDest() { return namedDest; } @@ -211,13 +211,13 @@ public: LinkLaunch(Object *actionObj); // Destructor. - virtual ~LinkLaunch(); + ~LinkLaunch(); // Was the LinkLaunch created successfully? - virtual GBool isOk() { return fileName != NULL; } + GBool isOk() override { return fileName != NULL; } // Accessors. - virtual LinkActionKind getKind() { return actionLaunch; } + LinkActionKind getKind() override { return actionLaunch; } GooString *getFileName() { return fileName; } GooString *getParams() { return params; } @@ -238,13 +238,13 @@ public: LinkURI(Object *uriObj, GooString *baseURI); // Destructor. - virtual ~LinkURI(); + ~LinkURI(); // Was the LinkURI created successfully? - virtual GBool isOk() { return uri != NULL; } + GBool isOk() override { return uri != NULL; } // Accessors. - virtual LinkActionKind getKind() { return actionURI; } + LinkActionKind getKind() override { return actionURI; } GooString *getURI() { return uri; } private: @@ -262,11 +262,11 @@ public: // Build a LinkNamed given the action name. LinkNamed(Object *nameObj); - virtual ~LinkNamed(); + ~LinkNamed(); - virtual GBool isOk() { return name != NULL; } + GBool isOk() override { return name != NULL; } - virtual LinkActionKind getKind() { return actionNamed; } + LinkActionKind getKind() override { return actionNamed; } GooString *getName() { return name; } private: @@ -290,10 +290,10 @@ public: }; LinkMovie(Object *obj); - virtual ~LinkMovie(); + ~LinkMovie(); - virtual GBool isOk() { return annotRef.num >= 0 || annotTitle != NULL; } - virtual LinkActionKind getKind() { return actionMovie; } + GBool isOk() override { return annotRef.num >= 0 || annotTitle != NULL; } + LinkActionKind getKind() override { return actionMovie; } // a movie action stores either an indirect reference to a movie annotation // or the movie annotation title @@ -333,11 +333,11 @@ public: LinkRendition(Object *Obj); - virtual ~LinkRendition(); + ~LinkRendition(); - virtual GBool isOk() { return true; } + GBool isOk() override { return true; } - virtual LinkActionKind getKind() { return actionRendition; } + LinkActionKind getKind() override { return actionRendition; } GBool hasRenditionObject() { return renditionObj.isDict(); } Object* getRenditionObject() { return &renditionObj; } @@ -371,11 +371,11 @@ public: LinkSound(Object *soundObj); - virtual ~LinkSound(); + ~LinkSound(); - virtual GBool isOk() { return sound != NULL; } + GBool isOk() override { return sound != NULL; } - virtual LinkActionKind getKind() { return actionSound; } + LinkActionKind getKind() override { return actionSound; } double getVolume() { return volume; } GBool getSynchronous() { return sync; } @@ -402,11 +402,11 @@ public: // Build a LinkJavaScript given the action name. LinkJavaScript(Object *jsObj); - virtual ~LinkJavaScript(); + ~LinkJavaScript(); - virtual GBool isOk() { return js != NULL; } + GBool isOk() override { return js != NULL; } - virtual LinkActionKind getKind() { return actionJavaScript; } + LinkActionKind getKind() override { return actionJavaScript; } GooString *getScript() { return js; } private: @@ -421,11 +421,11 @@ class LinkOCGState: public LinkAction { public: LinkOCGState(Object *obj); - virtual ~LinkOCGState(); + ~LinkOCGState(); - virtual GBool isOk() { return stateList != NULL; } + GBool isOk() override { return stateList != NULL; } - virtual LinkActionKind getKind() { return actionOCGState; } + LinkActionKind getKind() override { return actionOCGState; } enum State { On, Off, Toggle}; struct StateList { @@ -454,13 +454,13 @@ public: LinkUnknown(char *actionA); // Destructor. - virtual ~LinkUnknown(); + ~LinkUnknown(); // Was the LinkUnknown create successfully? - virtual GBool isOk() { return action != NULL; } + GBool isOk() override { return action != NULL; } // Accessors. - virtual LinkActionKind getKind() { return actionUnknown; } + LinkActionKind getKind() override { return actionUnknown; } GooString *getAction() { return action; } private: diff --git a/Build/source/libs/poppler/poppler-src/poppler/LocalPDFDocBuilder.h b/Build/source/libs/poppler/poppler-src/poppler/LocalPDFDocBuilder.h index c2b1d903885..0ebfdc68c85 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/LocalPDFDocBuilder.h +++ b/Build/source/libs/poppler/poppler-src/poppler/LocalPDFDocBuilder.h @@ -23,10 +23,9 @@ class LocalPDFDocBuilder : public PDFDocBuilder { public: - PDFDoc *buildPDFDoc(const GooString &uri, GooString *ownerPassword = NULL, - GooString *userPassword = NULL, void *guiDataA = NULL); - GBool supports(const GooString &uri); + GooString *userPassword = NULL, void *guiDataA = NULL) override; + GBool supports(const GooString &uri) override; }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Makefile.am b/Build/source/libs/poppler/poppler-src/poppler/Makefile.am deleted file mode 100644 index de9c9839988..00000000000 --- a/Build/source/libs/poppler/poppler-src/poppler/Makefile.am +++ /dev/null @@ -1,348 +0,0 @@ -CFLAGS+=$(PTHREAD_CFLAGS) -CXXFLAGS+=$(PTHREAD_CFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/goo - -lib_LTLIBRARIES = libpoppler.la - -if BUILD_CAIRO_OUTPUT -noinst_LTLIBRARIES = libpoppler-cairo.la -endif - -if BUILD_SPLASH_OUTPUT - -splash_sources = \ - SplashOutputDev.cc - -splash_headers = \ - SplashOutputDev.h - -splash_includes = \ - $(SPLASH_CFLAGS) - -splash_libs = \ - $(SPLASH_LIBS) \ - $(top_builddir)/splash/libsplash.la - -endif - -if BUILD_LIBJPEG - -libjpeg_sources = \ - DCTStream.h \ - DCTStream.cc - -libjpeg_libs = \ - $(LIBJPEG_LIBS) -libjpeg_includes = \ - $(LIBJPEG_CFLAGS) - -endif - -if BUILD_LIBPNG - -libpng_libs = \ - $(LIBPNG_LIBS) -libpng_includes = \ - $(LIBPNG_CFLAGS) - -endif - -if BUILD_LIBTIFF - -libtiff_libs = \ - $(LIBTIFF_LIBS) -libtiff_includes = \ - $(LIBTIFF_CFLAGS) - -endif - -if BUILD_LIBOPENJPEG - -libjpeg2000_sources = \ - JPEG2000Stream.h \ - JPEG2000Stream.cc - -libjpeg2000_libs = \ - $(LIBOPENJPEG_LIBS) -libjpeg2000_includes = \ - $(LIBOPENJPEG_CFLAGS) - -else - -libjpeg2000_sources = \ - JPXStream.h \ - JPXStream.cc - -endif - -if BUILD_NSS - -nss_sources = \ - SignatureHandler.cc - -nss_libs = \ - $(NSS3_LIBS) - -nss_includes = \ - $(NSS3_CFLAGS) - -nss_headers = \ - SignatureHandler.h - -endif - - -if BUILD_ZLIB - -zlib_sources = \ - FlateEncoder.h \ - FlateEncoder.cc - -zlib_libs = \ - $(ZLIB_LIBS) - -endif - -if BUILD_ZLIB_UNCOMPRESS - -zlib_uncompress_sources = \ - FlateStream.h \ - FlateStream.cc - -endif - -if BUILD_LIBCURL - -libcurl_libs = \ - $(LIBCURL_LIBS) - -libcurl_includes = \ - $(LIBCURL_CFLAGS) - -curl_headers = \ - CurlCachedFile.h \ - CurlPDFDocBuilder.h - -curl_sources = \ - CurlCachedFile.cc \ - CurlPDFDocBuilder.cc - -endif - -if USE_CMS -cms_includes = $(LCMS_CFLAGS) -cms_libs = $(LCMS_LIBS) -endif - -if ENABLE_XPDF_HEADERS - -poppler_includedir = $(includedir)/poppler -poppler_include_HEADERS = \ - $(splash_headers) \ - $(curl_headers) \ - $(nss_headers) \ - Annot.h \ - Array.h \ - BuiltinFont.h \ - BuiltinFontTables.h \ - CachedFile.h \ - Catalog.h \ - CharCodeToUnicode.h \ - CMap.h \ - DateInfo.h \ - Decrypt.h \ - Dict.h \ - Error.h \ - FileSpec.h \ - FontEncodingTables.h \ - FontInfo.h \ - Form.h \ - Function.h \ - Gfx.h \ - GfxFont.h \ - GfxState.h \ - GfxState_helpers.h \ - GlobalParams.h \ - Hints.h \ - JArithmeticDecoder.h \ - JBIG2Stream.h \ - Lexer.h \ - Linearization.h \ - Link.h \ - LocalPDFDocBuilder.h \ - Movie.h \ - NameToCharCode.h \ - Object.h \ - OptionalContent.h \ - Outline.h \ - OutputDev.h \ - Page.h \ - PageTransition.h \ - Parser.h \ - PDFDoc.h \ - PDFDocBuilder.h \ - PDFDocEncoding.h \ - PDFDocFactory.h \ - PopplerCache.h \ - ProfileData.h \ - PreScanOutputDev.h \ - PSTokenizer.h \ - Rendition.h \ - SignatureInfo.h \ - StdinCachedFile.h \ - StdinPDFDocBuilder.h \ - Stream-CCITT.h \ - Stream.h \ - StructElement.h \ - StructTreeRoot.h \ - UnicodeMap.h \ - UnicodeMapTables.h \ - UnicodeTypeTable.h \ - UnicodeCClassTables.h \ - UnicodeCompTables.h \ - UnicodeDecompTables.h \ - ViewerPreferences.h \ - XRef.h \ - CharTypes.h \ - CompactFontTables.h \ - ErrorCodes.h \ - NameToUnicodeTable.h \ - PSOutputDev.h \ - TextOutputDev.h \ - MarkedContentOutputDev.h \ - SecurityHandler.h \ - UTF.h \ - UTF8.h \ - XpdfPluginAPI.h \ - Sound.h -nodist_poppler_include_HEADERS = poppler-config.h - -endif - -libpoppler_la_SOURCES = \ - $(splash_sources) \ - $(libjpeg_sources) \ - $(zlib_sources) \ - $(zlib_uncompress_sources) \ - $(nss_sources) \ - $(libjpeg2000_sources) \ - $(curl_sources) \ - Annot.cc \ - Array.cc \ - BuiltinFont.cc \ - BuiltinFontTables.cc \ - CachedFile.cc \ - Catalog.cc \ - CharCodeToUnicode.cc \ - CMap.cc \ - DateInfo.cc \ - Decrypt.cc \ - Dict.cc \ - Error.cc \ - FileSpec.cc \ - FontEncodingTables.cc \ - Form.cc \ - FontInfo.cc \ - Function.cc \ - Gfx.cc \ - GfxFont.cc \ - GfxState.cc \ - GlobalParams.cc \ - Hints.cc \ - JArithmeticDecoder.cc \ - JBIG2Stream.cc \ - Lexer.cc \ - Linearization.cc \ - Link.cc \ - LocalPDFDocBuilder.cc \ - Movie.cc \ - NameToCharCode.cc \ - Object.cc \ - OptionalContent.cc \ - Outline.cc \ - OutputDev.cc \ - Page.cc \ - PageTransition.cc \ - Parser.cc \ - PDFDoc.cc \ - PDFDocEncoding.cc \ - PDFDocFactory.cc \ - PopplerCache.cc \ - ProfileData.cc \ - PreScanOutputDev.cc \ - PSTokenizer.cc \ - Rendition.cc \ - SignatureInfo.cc \ - StdinCachedFile.cc \ - StdinPDFDocBuilder.cc \ - Stream.cc \ - StructTreeRoot.cc \ - StructElement.cc \ - strtok_r.cpp \ - UnicodeMap.cc \ - UnicodeTypeTable.cc \ - UTF.cc \ - ViewerPreferences.cc \ - XRef.cc \ - PSOutputDev.cc \ - TextOutputDev.cc \ - MarkedContentOutputDev.cc \ - PageLabelInfo.h \ - PageLabelInfo.cc \ - SecurityHandler.cc \ - Sound.cc \ - XpdfPluginAPI.cc - -libpoppler_la_CPPFLAGS = \ - $(cms_includes) \ - $(splash_includes) \ - $(libjpeg_includes) \ - $(libtiff_includes) \ - $(libjpeg2000_includes) \ - $(libpng_includes) \ - $(libcurl_includes) \ - $(nss_includes) \ - $(FREETYPE_CFLAGS) \ - $(FONTCONFIG_CFLAGS) \ - $(AM_CPPFLAGS) - -libpoppler_la_LIBADD = \ - $(top_builddir)/goo/libgoo.la \ - $(top_builddir)/fofi/libfofi.la \ - $(cms_libs) \ - $(splash_libs) \ - $(libtiff_libs) \ - $(libjpeg_libs) \ - $(libpng_libs) \ - $(zlib_libs) \ - $(libcurl_libs) \ - $(nss_libs) \ - $(libjpeg2000_libs) \ - $(FREETYPE_LIBS) \ - $(FONTCONFIG_LIBS) \ - $(PTHREAD_LIBS) \ - $(win32_libs) - -libpoppler_la_LDFLAGS = \ - -version-info 66:0:0 \ - @create_shared_lib@ \ - @auto_import_flags@ - -libpoppler_cairo_la_SOURCES = \ - CairoFontEngine.cc \ - CairoFontEngine.h \ - CairoOutputDev.cc \ - CairoOutputDev.h \ - CairoRescaleBox.cc \ - CairoRescaleBox.h - -libpoppler_cairo_la_CPPFLAGS = \ - $(CAIRO_CFLAGS) \ - $(AM_CPPFLAGS) - -EXTRA_DIST = gen-unicode-tables.py \ - GlobalParamsWin.cc \ - PageLabelInfo_p.h diff --git a/Build/source/libs/poppler/poppler-src/poppler/MarkedContentOutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/MarkedContentOutputDev.h index 4ea60c255a1..5b9de05fdbf 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/MarkedContentOutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/MarkedContentOutputDev.h @@ -89,24 +89,24 @@ public: virtual ~MarkedContentOutputDev(); virtual GBool isOk() { return gTrue; } - virtual GBool upsideDown() { return gTrue; } - virtual GBool useDrawChar() { return gTrue; } - virtual GBool interpretType3Chars() { return gFalse; } - virtual GBool needNonText() { return gFalse; } - virtual GBool needCharCount() { return gFalse; } + GBool upsideDown() override { return gTrue; } + GBool useDrawChar() override { return gTrue; } + GBool interpretType3Chars() override { return gFalse; } + GBool needNonText() override { return gFalse; } + GBool needCharCount() override { return gFalse; } - virtual void startPage(int pageNum, GfxState *state, XRef *xref); - virtual void endPage(); + void startPage(int pageNum, GfxState *state, XRef *xref) override; + void endPage() override; - virtual void drawChar(GfxState *state, + void drawChar(GfxState *state, double xx, double yy, double dx, double dy, double ox, double oy, CharCode c, int nBytes, - Unicode *u, int uLen); + Unicode *u, int uLen) override; - virtual void beginMarkedContent(char *name, Dict *properties); - virtual void endMarkedContent(GfxState *state); + void beginMarkedContent(char *name, Dict *properties) override; + void endMarkedContent(GfxState *state) override; const TextSpanArray& getTextSpans() const; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Movie.cc b/Build/source/libs/poppler/poppler-src/poppler/Movie.cc index f68b6adcd4d..fa709b3b7db 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Movie.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Movie.cc @@ -6,7 +6,7 @@ // Hugo Mercier <hmercier31[at]gmail.com> (c) 2008 // Pino Toscano <pino@kde.org> (c) 2008 // Carlos Garcia Campos <carlosgc@gnome.org> (c) 2010 -// Albert Astals Cid <aacid@kde.org> (c) 2010 +// Albert Astals Cid <aacid@kde.org> (c) 2010, 2017 // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -47,9 +47,8 @@ MovieActivationParameters::~MovieActivationParameters() { } void MovieActivationParameters::parseMovieActivation(Object* aDict) { - Object obj1; - - if (!aDict->dictLookup("Start", &obj1)->isNull()) { + Object obj1 = aDict->dictLookup("Start"); + if (obj1.isNull()) { if (obj1.isInt()) { // If it is representable as an integer (subject to the implementation limit for // integers, as described in Appendix C), it should be specified as such. @@ -64,26 +63,23 @@ void MovieActivationParameters::parseMovieActivation(Object* aDict) { } else if (obj1.isArray()) { Array* a = obj1.getArray(); - Object tmp; - a->get(0, &tmp); + Object tmp = a->get(0); if (tmp.isInt()) { start.units = tmp.getInt(); } if (tmp.isString()) { // UNSUPPORTED } - tmp.free(); - a->get(1, &tmp); + tmp = a->get(1); if (tmp.isInt()) { start.units_per_second = tmp.getInt(); } - tmp.free(); } } - obj1.free(); - if (!aDict->dictLookup("Duration", &obj1)->isNull()) { + obj1 = aDict->dictLookup("Duration"); + if (obj1.isNull()) { if (obj1.isInt()) { duration.units = obj1.getInt(); } else if (obj1.isString()) { @@ -91,47 +87,44 @@ void MovieActivationParameters::parseMovieActivation(Object* aDict) { } else if (obj1.isArray()) { Array* a = obj1.getArray(); - Object tmp; - a->get(0, &tmp); + Object tmp = a->get(0); if (tmp.isInt()) { duration.units = tmp.getInt(); } if (tmp.isString()) { // UNSUPPORTED } - tmp.free(); - a->get(1, &tmp); + tmp = a->get(1); if (tmp.isInt()) { duration.units_per_second = tmp.getInt(); } - tmp.free(); } } - obj1.free(); - if (aDict->dictLookup("Rate", &obj1)->isNum()) { + obj1 = aDict->dictLookup("Rate"); + if (obj1.isNum()) { rate = obj1.getNum(); } - obj1.free(); - if (aDict->dictLookup("Volume", &obj1)->isNum()) { + obj1 = aDict->dictLookup("Volume"); + if (obj1.isNum()) { // convert volume to [0 100] volume = int((obj1.getNum() + 1.0) * 50); } - obj1.free(); - if (aDict->dictLookup("ShowControls", &obj1)->isBool()) { + obj1 = aDict->dictLookup("ShowControls"); + if (obj1.isBool()) { showControls = obj1.getBool(); } - obj1.free(); - if (aDict->dictLookup("Synchronous", &obj1)->isBool()) { + obj1 = aDict->dictLookup("Synchronous"); + if (obj1.isBool()) { synchronousPlay = obj1.getBool(); } - obj1.free(); - if (aDict->dictLookup("Mode", &obj1)->isName()) { + obj1 = aDict->dictLookup("Mode"); + if (obj1.isName()) { char* name = obj1.getName(); if (!strcmp(name, "Once")) { repeatMode = repeatModeOnce; @@ -143,43 +136,40 @@ void MovieActivationParameters::parseMovieActivation(Object* aDict) { repeatMode = repeatModePalindrome; } } - obj1.free(); - if (aDict->dictLookup("FWScale", &obj1)->isArray()) { + obj1 = aDict->dictLookup("FWScale"); + if (obj1.isArray()) { // the presence of that entry implies that the movie is to be played // in a floating window floatingWindow = gTrue; Array* scale = obj1.getArray(); if (scale->getLength() >= 2) { - Object tmp; - if (scale->get(0, &tmp)->isInt()) { + Object tmp = scale->get(1); + if (tmp.isInt()) { znum = tmp.getInt(); } - tmp.free(); - if (scale->get(1, &tmp)->isInt()) { + tmp = scale->get(1); + if (tmp.isInt()) { zdenum = tmp.getInt(); } - tmp.free(); } } - obj1.free(); - if (aDict->dictLookup("FWPosition", &obj1)->isArray()) { + obj1 = aDict->dictLookup("FWPosition"); + if (obj1.isArray()) { Array* pos = obj1.getArray(); if (pos->getLength() >= 2) { - Object tmp; - if (pos->get(0, &tmp)->isNum()) { + Object tmp = pos->get(0); + if (tmp.isNum()) { xPosition = tmp.getNum(); } - tmp.free(); - if (pos->get(1, &tmp)->isNum()) { + tmp = pos->get(1); + if (tmp.isNum()) { yPosition = tmp.getNum(); } - tmp.free(); } } - obj1.free(); } void Movie::parseMovie (Object *movieDict) { @@ -189,59 +179,55 @@ void Movie::parseMovie (Object *movieDict) { height = -1; showPoster = gFalse; - Object obj1, obj2; - if (getFileSpecNameForPlatform(movieDict->dictLookup("F", &obj1), &obj2)) { + Object obj1 = movieDict->dictLookup("F"); + Object obj2 = getFileSpecNameForPlatform(&obj1); + if (obj2.isString()) { fileName = obj2.getString()->copy(); - obj2.free(); } else { error (errSyntaxError, -1, "Invalid Movie"); ok = gFalse; - obj1.free(); return; } - obj1.free(); - if (movieDict->dictLookup("Aspect", &obj1)->isArray()) { + obj1 = movieDict->dictLookup("Aspect"); + if (obj1.isArray()) { Array* aspect = obj1.getArray(); if (aspect->getLength() >= 2) { - Object tmp; - if( aspect->get(0, &tmp)->isNum() ) { - width = (int)floor( aspect->get(0, &tmp)->getNum() + 0.5 ); + Object tmp = aspect->get(0); + if( tmp.isNum() ) { + width = (int)floor( tmp.getNum() + 0.5 ); } - tmp.free(); - if( aspect->get(1, &tmp)->isNum() ) { - height = (int)floor( aspect->get(1, &tmp)->getNum() + 0.5 ); + tmp = aspect->get(1); + if( tmp.isNum() ) { + height = (int)floor( tmp.getNum() + 0.5 ); } - tmp.free(); } } - obj1.free(); - if (movieDict->dictLookup("Rotate", &obj1)->isInt()) { + obj1 = movieDict->dictLookup("Rotate"); + if (obj1.isInt()) { // round up to 90° rotationAngle = (((obj1.getInt() + 360) % 360) % 90) * 90; } - obj1.free(); // // movie poster // - if (!movieDict->dictLookupNF("Poster", &poster)->isNull()) { + poster = movieDict->dictLookupNF("Poster"); + if (!poster.isNull()) { if (poster.isRef() || poster.isStream()) { showPoster = gTrue; } else if (poster.isBool()) { showPoster = poster.getBool(); - poster.free(); + poster.setToNull(); } else { - poster.free(); + poster.setToNull(); } } } Movie::~Movie() { - if (fileName) - delete fileName; - poster.free(); + delete fileName; } Movie::Movie(Object *movieDict) { @@ -265,6 +251,23 @@ Movie::Movie(Object *movieDict, Object *aDict) { } } +Movie::Movie(const Movie &other) +{ + ok = other.ok; + rotationAngle = other.rotationAngle; + width = other.width; + height = other.height; + showPoster = other.showPoster; + MA = other.MA; + + poster = other.poster.copy(); + + if (other.fileName) + fileName = other.fileName->copy(); + else + fileName = nullptr; +} + void Movie::getFloatingWindowSize(int *widthA, int *heightA) { *widthA = int(width * double(MA.znum) / MA.zdenum); @@ -272,14 +275,5 @@ void Movie::getFloatingWindowSize(int *widthA, int *heightA) } Movie* Movie::copy() { - - // call default copy constructor - Movie* new_movie = new Movie(*this); - - if (fileName) - new_movie->fileName = fileName->copy(); - - poster.copy(&new_movie->poster); - - return new_movie; + return new Movie(*this); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Movie.h b/Build/source/libs/poppler/poppler-src/poppler/Movie.h index 1a162659179..c0fcd8f4ce5 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Movie.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Movie.h @@ -5,6 +5,7 @@ //--------------------------------------------------------------------------------- // Hugo Mercier <hmercier31[at]gmail.com> (c) 2008 // Carlos Garcia Campos <carlosgc@gnome.org> (c) 2010 +// Albert Astals Cid <aacid@kde.org> (c) 2017 // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -71,6 +72,7 @@ class Movie { public: Movie(Object *objMovie, Object *objAct); Movie(Object *objMovie); + Movie(const Movie &movie); ~Movie(); GBool isOk() { return ok; } @@ -81,7 +83,7 @@ class Movie { Gushort getRotationAngle() { return rotationAngle; } void getAspect (int *widthA, int *heightA) { *widthA = width; *heightA = height; } - Object *getPoster(Object *obj) { return poster.copy(obj); } + Object getPoster() { return poster.copy(); } GBool getShowPoster() { return showPoster; } GBool getUseFloatingWindow() { return MA.floatingWindow; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Object.cc b/Build/source/libs/poppler/poppler-src/poppler/Object.cc index d06bb39fb6d..d3adc4473ab 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Object.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Object.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) 2008, 2010, 2012 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2010, 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> // // To see a description of the changes please see the Changelog file that @@ -54,47 +54,48 @@ static const char *objTypeNames[numObjTypes] = { "error", "eof", "none", - "integer64" + "integer64", + "dead" }; #ifdef DEBUG_MEM int Object::numAlloc[numObjTypes] = - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif -Object *Object::initArray(XRef *xref) { - initObj(objArray); - array = new Array(xref); - return this; +Object::Object(Object&& other) +{ + type = other.type; + real = other.real; // this is the biggest of the union so it's enough + other.type = objDead; } -Object *Object::initDict(XRef *xref) { - initObj(objDict); - dict = new Dict(xref); - return this; +Object& Object::operator=(Object&& other) +{ + free(); + type = other.type; + real = other.real; // this is the biggest of the union so it's enough + other.type = objDead; + return *this; } -Object *Object::initDict(Dict *dictA) { - initObj(objDict); - dict = dictA; - dict->incRef(); - return this; +Object::~Object() +{ + free(); } -Object *Object::initStream(Stream *streamA) { - initObj(objStream); - stream = streamA; - return this; -} +Object Object::copy() const { + CHECK_NOT_DEAD; -Object *Object::copy(Object *obj) { - *obj = *this; + Object obj; + obj.type = type; + obj.real = real; // this is the biggest of the union so it's enough switch (type) { case objString: - obj->string = string->copy(); + obj.string = string->copy(); break; case objName: - obj->name = copyString(name); + obj.cString = copyString(cString); break; case objArray: array->incRef(); @@ -106,7 +107,7 @@ Object *Object::copy(Object *obj) { stream->incRef(); break; case objCmd: - obj->cmd = copyString(cmd); + obj.cString = copyString(cString); break; default: break; @@ -117,9 +118,11 @@ Object *Object::copy(Object *obj) { return obj; } -Object *Object::fetch(XRef *xref, Object *obj, int recursion) { +Object Object::fetch(XRef *xref, int recursion) const { + CHECK_NOT_DEAD; + return (type == objRef && xref) ? - xref->fetch(ref.num, ref.gen, obj, recursion) : copy(obj); + xref->fetch(ref.num, ref.gen, recursion) : copy(); } void Object::free() { @@ -128,7 +131,7 @@ void Object::free() { delete string; break; case objName: - gfree(name); + gfree(cString); break; case objArray: if (!array->decRef()) { @@ -146,7 +149,7 @@ void Object::free() { } break; case objCmd: - gfree(cmd); + gfree(cString); break; default: break; @@ -157,11 +160,11 @@ void Object::free() { type = objNone; } -const char *Object::getTypeName() { +const char *Object::getTypeName() const { return objTypeNames[type]; } -void Object::print(FILE *f) { +void Object::print(FILE *f) const { Object obj; int i; @@ -181,7 +184,7 @@ void Object::print(FILE *f) { fprintf(f, ")"); break; case objName: - fprintf(f, "/%s", name); + fprintf(f, "/%s", cString); break; case objNull: fprintf(f, "null"); @@ -191,9 +194,8 @@ void Object::print(FILE *f) { for (i = 0; i < arrayGetLength(); ++i) { if (i > 0) fprintf(f, " "); - arrayGetNF(i, &obj); + obj = arrayGetNF(i); obj.print(f); - obj.free(); } fprintf(f, "]"); break; @@ -201,9 +203,8 @@ void Object::print(FILE *f) { fprintf(f, "<<"); for (i = 0; i < dictGetLength(); ++i) { fprintf(f, " /%s ", dictGetKey(i)); - dictGetValNF(i, &obj); + obj = dictGetValNF(i); obj.print(f); - obj.free(); } fprintf(f, " >>"); break; @@ -214,7 +215,7 @@ void Object::print(FILE *f) { fprintf(f, "%d %d R", ref.num, ref.gen); break; case objCmd: - fprintf(f, "%s", cmd); + fprintf(f, "%s", cString); break; case objError: fprintf(f, "<error>"); @@ -225,6 +226,9 @@ void Object::print(FILE *f) { case objNone: fprintf(f, "<none>"); break; + case objDead: + fprintf(f, "<dead>"); + break; case objInt64: fprintf(f, "%lld", int64g); break; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Object.h b/Build/source/libs/poppler/poppler-src/poppler/Object.h index 312a8eb32cb..f2ca20d1559 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Object.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Object.h @@ -15,11 +15,11 @@ // // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2008 Kees Cook <kees@outflux.net> -// Copyright (C) 2008, 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Jakub Wilk <jwilk@jwilk.net> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com> // Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com> // @@ -38,6 +38,7 @@ #include <set> #include <stdio.h> #include <string.h> +#include <limits.h> #include "goo/gtypes.h" #include "goo/gmem.h" #include "goo/GooString.h" @@ -65,6 +66,12 @@ abort(); \ } +#define CHECK_NOT_DEAD \ + if (unlikely(type == objDead)) { \ + error(errInternal, 0, "Call to dead object"); \ + abort(); \ + } + class XRef; class Array; class Dict; @@ -105,165 +112,187 @@ enum ObjType { objNone, // uninitialized object // poppler-only objects - objInt64 // integer with at least 64-bits + objInt64, // integer with at least 64-bits + objDead // and object after shallowCopy }; -#define numObjTypes 15 // total number of object types +#define numObjTypes 16 // total number of object types //------------------------------------------------------------------------ // Object //------------------------------------------------------------------------ #ifdef DEBUG_MEM -#define initObj(t) zeroUnion(); ++numAlloc[type = t] +#define initObj(t) free(); zeroUnion(); ++numAlloc[type = t] #else -#define initObj(t) zeroUnion(); type = t +#define initObj(t) free(); zeroUnion(); type = t +#endif + +#ifdef DEBUG_MEM +#define constructObj(t) ++numAlloc[type = t] +#else +#define constructObj(t) type = t #endif class Object { public: // clear the anonymous union as best we can -- clear at least a pointer - void zeroUnion() { this->name = NULL; } + void zeroUnion() { this->cString = NULL; } // Default constructor. Object(): type(objNone) { zeroUnion(); } - - // Initialize an object. - Object *initBool(GBool boolnA) - { initObj(objBool); booln = boolnA; return this; } - Object *initInt(int intgA) - { initObj(objInt); intg = intgA; return this; } - Object *initReal(double realA) - { initObj(objReal); real = realA; return this; } - Object *initString(GooString *stringA) - { initObj(objString); string = stringA; return this; } - Object *initName(const char *nameA) - { initObj(objName); name = copyString(nameA); return this; } - Object *initNull() - { initObj(objNull); return this; } - Object *initArray(XRef *xref); - Object *initDict(XRef *xref); - Object *initDict(Dict *dictA); - Object *initStream(Stream *streamA); - Object *initRef(int numA, int genA) - { initObj(objRef); ref.num = numA; ref.gen = genA; return this; } - Object *initCmd(const char *cmdA) - { initObj(objCmd); cmd = copyString(cmdA); return this; } - Object *initError() - { initObj(objError); return this; } - Object *initEOF() - { initObj(objEOF); return this; } - Object *initInt64(long long int64gA) - { initObj(objInt64); int64g = int64gA; return this; } - - // Copy an object. - Object *copy(Object *obj); - Object *shallowCopy(Object *obj) { - *obj = *this; - return obj; - } + ~Object(); + + explicit Object(GBool boolnA) + { constructObj(objBool); booln = boolnA; } + explicit Object(int intgA) + { constructObj(objInt); intg = intgA; } + explicit Object(ObjType typeA) + { constructObj(typeA); } + explicit Object(double realA) + { constructObj(objReal); real = realA; } + explicit Object(GooString *stringA) + { constructObj(objString); string = stringA; } + Object(ObjType typeA, const char *stringA) + { constructObj(typeA); cString = copyString(stringA); } + explicit Object(long long int64gA) + { constructObj(objInt64); int64g = int64gA; } + explicit Object(Array *arrayA) + { constructObj(objArray); array = arrayA; } + explicit Object(Dict *dictA) + { constructObj(objDict); dict = dictA; } + explicit Object(Stream *streamA) + { constructObj(objStream); stream = streamA; } + Object(int numA, int genA) + { constructObj(objRef); ref.num = numA; ref.gen = genA; } + template<typename T> Object(T) = delete; + + Object(Object&& other); + Object& operator=(Object&& other); + + Object &operator=(const Object &other) = delete; + Object(const Object &other) = delete; + + // Set object to null. + void setToNull() { initObj(objNull); } + + // Copy this to obj + Object copy() const; // If object is a Ref, fetch and return the referenced object. // Otherwise, return a copy of the object. - Object *fetch(XRef *xref, Object *obj, int recursion = 0); - - // Free object contents. - void free(); + Object fetch(XRef *xref, int recursion = 0) const; // Type checking. - ObjType getType() { return type; } - GBool isBool() { return type == objBool; } - GBool isInt() { return type == objInt; } - GBool isReal() { return type == objReal; } - GBool isNum() { return type == objInt || type == objReal || type == objInt64; } - GBool isString() { return type == objString; } - GBool isName() { return type == objName; } - GBool isNull() { return type == objNull; } - GBool isArray() { return type == objArray; } - GBool isDict() { return type == objDict; } - GBool isStream() { return type == objStream; } - GBool isRef() { return type == objRef; } - GBool isCmd() { return type == objCmd; } - GBool isError() { return type == objError; } - GBool isEOF() { return type == objEOF; } - GBool isNone() { return type == objNone; } - GBool isInt64() { return type == objInt64; } - GBool isIntOrInt64() { return type == objInt || type == objInt64; } + ObjType getType() const { CHECK_NOT_DEAD; return type; } + GBool isBool() const { CHECK_NOT_DEAD; return type == objBool; } + GBool isInt() const { CHECK_NOT_DEAD; return type == objInt; } + GBool isReal() const { CHECK_NOT_DEAD; return type == objReal; } + GBool isNum() const { CHECK_NOT_DEAD; return type == objInt || type == objReal || type == objInt64; } + GBool isString() const { CHECK_NOT_DEAD; return type == objString; } + GBool isName() const { CHECK_NOT_DEAD; return type == objName; } + GBool isNull() const { CHECK_NOT_DEAD; return type == objNull; } + GBool isArray() const { CHECK_NOT_DEAD; return type == objArray; } + GBool isDict() const { CHECK_NOT_DEAD; return type == objDict; } + GBool isStream() const { CHECK_NOT_DEAD; return type == objStream; } + GBool isRef() const { CHECK_NOT_DEAD; return type == objRef; } + GBool isCmd() const { CHECK_NOT_DEAD; return type == objCmd; } + GBool isError() const { CHECK_NOT_DEAD; return type == objError; } + GBool isEOF() const { CHECK_NOT_DEAD; return type == objEOF; } + GBool isNone() const { CHECK_NOT_DEAD; return type == objNone; } + GBool isInt64() const { CHECK_NOT_DEAD; return type == objInt64; } + GBool isIntOrInt64() const { CHECK_NOT_DEAD; return type == objInt || type == objInt64; } // Special type checking. - GBool isName(const char *nameA) - { return type == objName && !strcmp(name, nameA); } - GBool isDict(const char *dictType); - GBool isStream(const char *dictType); - GBool isCmd(const char *cmdA) - { return type == objCmd && !strcmp(cmd, cmdA); } + GBool isName(const char *nameA) const + { return type == objName && !strcmp(cString, nameA); } + GBool isDict(const char *dictType) const; + GBool isStream(char *dictType) const; + GBool isCmd(const char *cmdA) const + { return type == objCmd && !strcmp(cString, cmdA); } // Accessors. - GBool getBool() { OBJECT_TYPE_CHECK(objBool); return booln; } - int getInt() { OBJECT_TYPE_CHECK(objInt); return intg; } - double getReal() { OBJECT_TYPE_CHECK(objReal); return real; } + GBool getBool() const { OBJECT_TYPE_CHECK(objBool); return booln; } + int getInt() const { OBJECT_TYPE_CHECK(objInt); return intg; } + double getReal() const { OBJECT_TYPE_CHECK(objReal); return real; } // Note: integers larger than 2^53 can not be exactly represented by a double. // Where the exact value of integers up to 2^63 is required, use isInt64()/getInt64(). - double getNum() { OBJECT_3TYPES_CHECK(objInt, objInt64, objReal); + double getNum() const { OBJECT_3TYPES_CHECK(objInt, objInt64, objReal); return type == objInt ? (double)intg : type == objInt64 ? (double)int64g : real; } - GooString *getString() { OBJECT_TYPE_CHECK(objString); return string; } + double getNum(bool *ok) const { + if (unlikely(type != objInt && type != objInt64 && type != objReal)) { + *ok = false; + return 0.; + } + return type == objInt ? (double)intg : type == objInt64 ? (double)int64g : real; + } + GooString *getString() const { OBJECT_TYPE_CHECK(objString); return string; } // After takeString() the only method that should be called for the object is free() // because the object it's not expected to have a NULL string. GooString *takeString() { OBJECT_TYPE_CHECK(objString); GooString *s = string; string = NULL; return s; } - char *getName() { OBJECT_TYPE_CHECK(objName); return name; } - Array *getArray() { OBJECT_TYPE_CHECK(objArray); return array; } - Dict *getDict() { OBJECT_TYPE_CHECK(objDict); return dict; } - Stream *getStream() { OBJECT_TYPE_CHECK(objStream); return stream; } - Ref getRef() { OBJECT_TYPE_CHECK(objRef); return ref; } - int getRefNum() { OBJECT_TYPE_CHECK(objRef); return ref.num; } - int getRefGen() { OBJECT_TYPE_CHECK(objRef); return ref.gen; } - char *getCmd() { OBJECT_TYPE_CHECK(objCmd); return cmd; } - long long getInt64() { OBJECT_TYPE_CHECK(objInt64); return int64g; } - long long getIntOrInt64() { OBJECT_2TYPES_CHECK(objInt, objInt64); + char *getName() const { OBJECT_TYPE_CHECK(objName); return cString; } + Array *getArray() const { OBJECT_TYPE_CHECK(objArray); return array; } + Dict *getDict() const { OBJECT_TYPE_CHECK(objDict); return dict; } + Stream *getStream() const { OBJECT_TYPE_CHECK(objStream); return stream; } + Ref getRef() const { OBJECT_TYPE_CHECK(objRef); return ref; } + int getRefNum() const { OBJECT_TYPE_CHECK(objRef); return ref.num; } + int getRefGen() const { OBJECT_TYPE_CHECK(objRef); return ref.gen; } + char *getCmd() const { OBJECT_TYPE_CHECK(objCmd); return cString; } + long long getInt64() const { OBJECT_TYPE_CHECK(objInt64); return int64g; } + long long getIntOrInt64() const { OBJECT_2TYPES_CHECK(objInt, objInt64); return type == objInt ? intg : int64g; } // Array accessors. - int arrayGetLength(); - void arrayAdd(Object *elem); + int arrayGetLength() const; + void arrayAdd(Object &&elem); void arrayRemove(int i); - Object *arrayGet(int i, Object *obj, int recursion); - Object *arrayGetNF(int i, Object *obj); + Object arrayGet(int i, int recursion) const; + Object arrayGetNF(int i) const; // Dict accessors. - int dictGetLength(); - void dictAdd(char *key, Object *val); - void dictSet(const char *key, Object *val); + int dictGetLength() const; + void dictAdd(char *key, Object &&val); + void dictSet(const char *key, Object &&val); void dictRemove(const char *key); - GBool dictIs(const char *dictType); - Object *dictLookup(const char *key, Object *obj, int recursion = 0); - Object *dictLookupNF(const char *key, Object *obj); - char *dictGetKey(int i); - Object *dictGetVal(int i, Object *obj); - Object *dictGetValNF(int i, Object *obj); + GBool dictIs(const char *dictType) const; + Object dictLookup(const char *key, int recursion = 0) const; + Object dictLookupNF(const char *key) const; + char *dictGetKey(int i) const; + Object dictGetVal(int i) const; + Object dictGetValNF(int i) const; // Stream accessors. - GBool streamIs(const char *dictType); + GBool streamIs(char *dictType) const; void streamReset(); void streamClose(); - int streamGetChar(); - int streamGetChars(int nChars, Guchar *buffer); - int streamLookChar(); - char *streamGetLine(char *buf, int size); - Goffset streamGetPos(); + int streamGetChar() const; + int streamGetChars(int nChars, Guchar *buffer) const; + int streamLookChar() const; + char *streamGetLine(char *buf, int size) const; + Goffset streamGetPos() const; void streamSetPos(Goffset pos, int dir = 0); - Dict *streamGetDict(); + Dict *streamGetDict() const; // Output. - const char *getTypeName(); - void print(FILE *f = stdout); + const char *getTypeName() const; + void print(FILE *f = stdout) const; // Memory testing. static void memCheck(FILE *f); private: + friend class Array; // Needs free and initNullAfterMalloc + friend class Dict; // Needs free and initNullAfterMalloc + friend class XRef; // Needs free and initNullAfterMalloc + + // Free object contents. + void free(); + + // Only use if are mallocing Objects + void initNullAfterMalloc() { constructObj(objNull); } ObjType type; // object type union { // value for each type: @@ -272,12 +301,11 @@ private: long long int64g; // 64-bit integer double real; // real GooString *string; // string - char *name; // name + char *cString; // name or command, depending on objType Array *array; // array Dict *dict; // dictionary Stream *stream; // stream Ref ref; // indirect reference - char *cmd; // command }; #ifdef DEBUG_MEM @@ -292,20 +320,20 @@ private: #include "Array.h" -inline int Object::arrayGetLength() +inline int Object::arrayGetLength() const { OBJECT_TYPE_CHECK(objArray); return array->getLength(); } -inline void Object::arrayAdd(Object *elem) - { OBJECT_TYPE_CHECK(objArray); array->add(elem); } +inline void Object::arrayAdd(Object &&elem) + { OBJECT_TYPE_CHECK(objArray); array->add(std::move(elem)); } inline void Object::arrayRemove(int i) { OBJECT_TYPE_CHECK(objArray); array->remove(i); } -inline Object *Object::arrayGet(int i, Object *obj, int recursion = 0) - { OBJECT_TYPE_CHECK(objArray); return array->get(i, obj, recursion); } +inline Object Object::arrayGet(int i, int recursion = 0) const + { OBJECT_TYPE_CHECK(objArray); return array->get(i, recursion); } -inline Object *Object::arrayGetNF(int i, Object *obj) - { OBJECT_TYPE_CHECK(objArray); return array->getNF(i, obj); } +inline Object Object::arrayGetNF(int i) const + { OBJECT_TYPE_CHECK(objArray); return array->getNF(i); } //------------------------------------------------------------------------ // Dict accessors. @@ -313,38 +341,38 @@ inline Object *Object::arrayGetNF(int i, Object *obj) #include "Dict.h" -inline int Object::dictGetLength() +inline int Object::dictGetLength() const { OBJECT_TYPE_CHECK(objDict); return dict->getLength(); } -inline void Object::dictAdd(char *key, Object *val) - { OBJECT_TYPE_CHECK(objDict); dict->add(key, val); } +inline void Object::dictAdd(char *key, Object &&val) + { OBJECT_TYPE_CHECK(objDict); dict->add(key, std::move(val)); } -inline void Object::dictSet(const char *key, Object *val) - { OBJECT_TYPE_CHECK(objDict); dict->set(key, val); } +inline void Object::dictSet(const char *key, Object &&val) + { OBJECT_TYPE_CHECK(objDict); dict->set(key, std::move(val)); } inline void Object::dictRemove(const char *key) { OBJECT_TYPE_CHECK(objDict); dict->remove(key); } -inline GBool Object::dictIs(const char *dictType) +inline GBool Object::dictIs(const char *dictType) const { OBJECT_TYPE_CHECK(objDict); return dict->is(dictType); } -inline GBool Object::isDict(const char *dictType) +inline GBool Object::isDict(const char *dictType) const { return type == objDict && dictIs(dictType); } -inline Object *Object::dictLookup(const char *key, Object *obj, int recursion) - { OBJECT_TYPE_CHECK(objDict); return dict->lookup(key, obj, recursion); } +inline Object Object::dictLookup(const char *key, int recursion) const + { OBJECT_TYPE_CHECK(objDict); return dict->lookup(key, recursion); } -inline Object *Object::dictLookupNF(const char *key, Object *obj) - { OBJECT_TYPE_CHECK(objDict); return dict->lookupNF(key, obj); } +inline Object Object::dictLookupNF(const char *key) const + { OBJECT_TYPE_CHECK(objDict); return dict->lookupNF(key); } -inline char *Object::dictGetKey(int i) +inline char *Object::dictGetKey(int i) const { OBJECT_TYPE_CHECK(objDict); return dict->getKey(i); } -inline Object *Object::dictGetVal(int i, Object *obj) - { OBJECT_TYPE_CHECK(objDict); return dict->getVal(i, obj); } +inline Object Object::dictGetVal(int i) const + { OBJECT_TYPE_CHECK(objDict); return dict->getVal(i); } -inline Object *Object::dictGetValNF(int i, Object *obj) - { OBJECT_TYPE_CHECK(objDict); return dict->getValNF(i, obj); } +inline Object Object::dictGetValNF(int i) const + { OBJECT_TYPE_CHECK(objDict); return dict->getValNF(i); } //------------------------------------------------------------------------ // Stream accessors. @@ -352,10 +380,10 @@ inline Object *Object::dictGetValNF(int i, Object *obj) #include "Stream.h" -inline GBool Object::streamIs(const char *dictType) +inline GBool Object::streamIs(char *dictType) const { OBJECT_TYPE_CHECK(objStream); return stream->getDict()->is(dictType); } -inline GBool Object::isStream(const char *dictType) +inline GBool Object::isStream(char *dictType) const { return type == objStream && streamIs(dictType); } inline void Object::streamReset() @@ -364,25 +392,25 @@ inline void Object::streamReset() inline void Object::streamClose() { OBJECT_TYPE_CHECK(objStream); stream->close(); } -inline int Object::streamGetChar() +inline int Object::streamGetChar() const { OBJECT_TYPE_CHECK(objStream); return stream->getChar(); } -inline int Object::streamGetChars(int nChars, Guchar *buffer) +inline int Object::streamGetChars(int nChars, Guchar *buffer) const { OBJECT_TYPE_CHECK(objStream); return stream->doGetChars(nChars, buffer); } -inline int Object::streamLookChar() +inline int Object::streamLookChar() const { OBJECT_TYPE_CHECK(objStream); return stream->lookChar(); } -inline char *Object::streamGetLine(char *buf, int size) +inline char *Object::streamGetLine(char *buf, int size) const { OBJECT_TYPE_CHECK(objStream); return stream->getLine(buf, size); } -inline Goffset Object::streamGetPos() +inline Goffset Object::streamGetPos() const { OBJECT_TYPE_CHECK(objStream); return stream->getPos(); } inline void Object::streamSetPos(Goffset pos, int dir) { OBJECT_TYPE_CHECK(objStream); stream->setPos(pos, dir); } -inline Dict *Object::streamGetDict() +inline Dict *Object::streamGetDict() const { OBJECT_TYPE_CHECK(objStream); return stream->getDict(); } #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/OptionalContent.cc b/Build/source/libs/poppler/poppler-src/poppler/OptionalContent.cc index 44eef194dda..d2e878e4257 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/OptionalContent.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/OptionalContent.cc @@ -43,50 +43,40 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) : optionalContentGroups = new GooList(); display = NULL; - Object ocgList; - ocgObject->dictLookup("OCGs", &ocgList); + Object ocgList = ocgObject->dictLookup("OCGs"); if (!ocgList.isArray()) { error(errSyntaxError, -1, "Expected the optional content group list, but wasn't able to find it, or it isn't an Array"); - ocgList.free(); ok = gFalse; return; } // we now enumerate over the ocgList, and build up the optionalContentGroups list. for(int i = 0; i < ocgList.arrayGetLength(); ++i) { - Object ocg; - ocgList.arrayGet(i, &ocg); + Object ocg = ocgList.arrayGet(i); if (!ocg.isDict()) { - ocg.free(); break; } OptionalContentGroup *thisOptionalContentGroup = new OptionalContentGroup(ocg.getDict()); - ocg.free(); - ocgList.arrayGetNF(i, &ocg); + ocg = ocgList.arrayGetNF(i); if (!ocg.isRef()) { - ocg.free(); + delete thisOptionalContentGroup; break; } // TODO: we should create a lookup map from Ref to the OptionalContentGroup thisOptionalContentGroup->setRef( ocg.getRef() ); - ocg.free(); // the default is ON - we change state later, depending on BaseState, ON and OFF thisOptionalContentGroup->setState(OptionalContentGroup::On); optionalContentGroups->append(thisOptionalContentGroup); } - Object defaultOcgConfig; - ocgObject->dictLookup("D", &defaultOcgConfig); + Object defaultOcgConfig = ocgObject->dictLookup("D"); if (!defaultOcgConfig.isDict()) { error(errSyntaxError, -1, "Expected the default config, but wasn't able to find it, or it isn't a Dictionary"); - defaultOcgConfig.free(); - ocgList.free(); ok = gFalse; return; } - Object baseState; - defaultOcgConfig.dictLookup("BaseState", &baseState); + Object baseState = defaultOcgConfig.dictLookup("BaseState"); if (baseState.isName("OFF")) { for (int i = 0; i < optionalContentGroups->getLength(); ++i) { OptionalContentGroup *group; @@ -95,22 +85,17 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) : group->setState(OptionalContentGroup::Off); } } - baseState.free(); - Object on; - defaultOcgConfig.dictLookup("ON", &on); + Object on = defaultOcgConfig.dictLookup("ON"); if (on.isArray()) { // ON is an optional element for (int i = 0; i < on.arrayGetLength(); ++i) { - Object reference; - on.arrayGetNF(i, &reference); + Object reference = on.arrayGetNF(i); if (!reference.isRef()) { // there can be null entries - reference.free(); break; } OptionalContentGroup *group = findOcgByRef( reference.getRef() ); - reference.free(); if (!group) { error(errSyntaxWarning, -1, "Couldn't find group for reference"); break; @@ -118,22 +103,17 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) : group->setState(OptionalContentGroup::On); } } - on.free(); - Object off; - defaultOcgConfig.dictLookup("OFF", &off); + Object off = defaultOcgConfig.dictLookup("OFF"); if (off.isArray()) { // OFF is an optional element for (int i = 0; i < off.arrayGetLength(); ++i) { - Object reference; - off.arrayGetNF(i, &reference); + Object reference = off.arrayGetNF(i); if (!reference.isRef()) { // there can be null entries - reference.free(); break; } OptionalContentGroup *group = findOcgByRef( reference.getRef() ); - reference.free(); if (!group) { error(errSyntaxWarning, -1, "Couldn't find group for reference to set OFF"); break; @@ -141,22 +121,15 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) : group->setState(OptionalContentGroup::Off); } } - off.free(); - defaultOcgConfig.dictLookup("Order", &order); - defaultOcgConfig.dictLookup("RBGroups", &rbgroups); - - ocgList.free(); - defaultOcgConfig.free(); + order = defaultOcgConfig.dictLookup("Order"); + rbgroups = defaultOcgConfig.dictLookup("RBGroups"); } OCGs::~OCGs() { deleteGooList(optionalContentGroups, OptionalContentGroup); - order.free(); - if (display) - delete display; - rbgroups.free(); + delete display; } @@ -193,12 +166,7 @@ OCDisplayNode *OCGs::getDisplayRoot() bool OCGs::optContentIsVisible( Object *dictRef ) { - Object dictObj; Dict *dict; - Object dictType; - Object ocg; - Object policy; - Object ve; bool result = true; if (dictRef->isNull()) @@ -210,22 +178,22 @@ bool OCGs::optContentIsVisible( Object *dictRef ) return oc->getState() == OptionalContentGroup::On; } - dictRef->fetch( m_xref, &dictObj ); + Object dictObj = dictRef->fetch( m_xref); if ( ! dictObj.isDict() ) { error(errSyntaxWarning, -1, "Unexpected oc reference target: {0:d}", dictObj.getType() ); - dictObj.free(); return result; } dict = dictObj.getDict(); // printf("checking if optContent is visible\n"); - dict->lookup("Type", &dictType); + Object dictType = dict->lookup("Type"); if (dictType.isName("OCMD")) { - if (dict->lookup("VE", &ve)->isArray()) { + Object ve = dict->lookup("VE"); + if (ve.isArray()) { result = evalOCVisibilityExpr(&ve, 0); } else { - dict->lookupNF("OCGs", &ocg); + Object ocg = dict->lookupNF("OCGs"); if (ocg.isArray()) { - dict->lookup("P", &policy); + Object policy = dict->lookup("P"); if (policy.isName("AllOn")) { result = allOn( ocg.getArray() ); } else if (policy.isName("AllOff")) { @@ -236,7 +204,6 @@ bool OCGs::optContentIsVisible( Object *dictRef ) // this is the default result = anyOn( ocg.getArray() ); } - policy.free(); } else if (ocg.isRef()) { OptionalContentGroup *oc = findOcgByRef( ocg.getRef() ); if ( oc && oc->getState() == OptionalContentGroup::Off ) { @@ -245,26 +212,20 @@ bool OCGs::optContentIsVisible( Object *dictRef ) result = true ; } } - ocg.free(); } - ve.free(); } else if ( dictType.isName("OCG") ) { OptionalContentGroup* oc = findOcgByRef( dictRef->getRef() ); if ( oc && oc->getState() == OptionalContentGroup::Off ) { result=false; } } - dictType.free(); - dictObj.free(); // printf("visibility: %s\n", result? "on" : "off"); return result; } GBool OCGs::evalOCVisibilityExpr(Object *expr, int recursion) { OptionalContentGroup *ocg; - Object expr2, op, obj; GBool ret; - int i; if (recursion > visibilityExprRecursionLimit) { error(errSyntaxError, -1, @@ -276,19 +237,17 @@ GBool OCGs::evalOCVisibilityExpr(Object *expr, int recursion) { return ocg->getState() == OptionalContentGroup::On; } } - expr->fetch(m_xref, &expr2); + Object expr2 = expr->fetch(m_xref); if (!expr2.isArray() || expr2.arrayGetLength() < 1) { error(errSyntaxError, -1, "Invalid optional content visibility expression"); - expr2.free(); return gTrue; } - expr2.arrayGet(0, &op); + Object op = expr2.arrayGet(0); if (op.isName("Not")) { if (expr2.arrayGetLength() == 2) { - expr2.arrayGetNF(1, &obj); + Object obj = expr2.arrayGetNF(1); ret = !evalOCVisibilityExpr(&obj, recursion + 1); - obj.free(); } else { error(errSyntaxError, -1, "Invalid optional content visibility expression"); @@ -296,33 +255,28 @@ GBool OCGs::evalOCVisibilityExpr(Object *expr, int recursion) { } } else if (op.isName("And")) { ret = gTrue; - for (i = 1; i < expr2.arrayGetLength() && ret; ++i) { - expr2.arrayGetNF(i, &obj); + for (int i = 1; i < expr2.arrayGetLength() && ret; ++i) { + Object obj = expr2.arrayGetNF(i); ret = evalOCVisibilityExpr(&obj, recursion + 1); - obj.free(); } } else if (op.isName("Or")) { ret = gFalse; - for (i = 1; i < expr2.arrayGetLength() && !ret; ++i) { - expr2.arrayGetNF(i, &obj); + for (int i = 1; i < expr2.arrayGetLength() && !ret; ++i) { + Object obj = expr2.arrayGetNF(i); ret = evalOCVisibilityExpr(&obj, recursion + 1); - obj.free(); } } else { error(errSyntaxError, -1, "Invalid optional content visibility expression"); ret = gTrue; } - op.free(); - expr2.free(); return ret; } bool OCGs::allOn( Array *ocgArray ) { for (int i = 0; i < ocgArray->getLength(); ++i) { - Object ocgItem; - ocgArray->getNF(i, &ocgItem); + Object ocgItem = ocgArray->getNF(i); if (ocgItem.isRef()) { OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() ); if ( oc && oc->getState() == OptionalContentGroup::Off ) { @@ -336,8 +290,7 @@ bool OCGs::allOn( Array *ocgArray ) bool OCGs::allOff( Array *ocgArray ) { for (int i = 0; i < ocgArray->getLength(); ++i) { - Object ocgItem; - ocgArray->getNF(i, &ocgItem); + Object ocgItem = ocgArray->getNF(i); if (ocgItem.isRef()) { OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() ); if ( oc && oc->getState() == OptionalContentGroup::On ) { @@ -351,8 +304,7 @@ bool OCGs::allOff( Array *ocgArray ) bool OCGs::anyOn( Array *ocgArray ) { for (int i = 0; i < ocgArray->getLength(); ++i) { - Object ocgItem; - ocgArray->getNF(i, &ocgItem); + Object ocgItem = ocgArray->getNF(i); if (ocgItem.isRef()) { OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() ); if ( oc && oc->getState() == OptionalContentGroup::On ) { @@ -366,8 +318,7 @@ bool OCGs::anyOn( Array *ocgArray ) bool OCGs::anyOff( Array *ocgArray ) { for (int i = 0; i < ocgArray->getLength(); ++i) { - Object ocgItem; - ocgArray->getNF(i, &ocgItem); + Object ocgItem = ocgArray->getNF(i); if (ocgItem.isRef()) { OptionalContentGroup* oc = findOcgByRef( ocgItem.getRef() ); if ( oc && oc->getState() == OptionalContentGroup::Off ) { @@ -382,42 +333,39 @@ bool OCGs::anyOff( Array *ocgArray ) OptionalContentGroup::OptionalContentGroup(Dict *ocgDict) : m_name(NULL) { - Object obj1, obj2, obj3; - Object ocgName; - ocgDict->lookup("Name", &ocgName); + Object ocgName = ocgDict->lookup("Name"); if (!ocgName.isString()) { error(errSyntaxWarning, -1, "Expected the name of the OCG, but wasn't able to find it, or it isn't a String"); } else { m_name = new GooString( ocgName.getString() ); } - ocgName.free(); viewState = printState = ocUsageUnset; - if (ocgDict->lookup("Usage", &obj1)->isDict()) { - if (obj1.dictLookup("View", &obj2)->isDict()) { - if (obj2.dictLookup("ViewState", &obj3)->isName()) { + Object obj1 = ocgDict->lookup("Usage"); + if (obj1.isDict()) { + Object obj2 = obj1.dictLookup("View"); + if (obj2.isDict()) { + Object obj3 = obj2.dictLookup("ViewState"); + if (obj3.isName()) { if (obj3.isName("ON")) { viewState = ocUsageOn; } else { viewState = ocUsageOff; } } - obj3.free(); } - obj2.free(); - if (obj1.dictLookup("Print", &obj2)->isDict()) { - if (obj2.dictLookup("PrintState", &obj3)->isName()) { + obj2 = obj1.dictLookup("Print"); + if (obj2.isDict()) { + Object obj3 = obj2.dictLookup("PrintState"); + if (obj3.isName()) { if (obj3.isName("ON")) { printState = ocUsageOn; } else { printState = ocUsageOff; } } - obj3.free(); } - obj2.free(); } - obj1.free(); } OptionalContentGroup::OptionalContentGroup(GooString *label) @@ -450,7 +398,6 @@ OptionalContentGroup::~OptionalContentGroup() OCDisplayNode *OCDisplayNode::parse(Object *obj, OCGs *oc, XRef *xref, int recursion) { - Object obj2, obj3; OptionalContentGroup *ocgA; OCDisplayNode *node, *child; int i; @@ -464,25 +411,24 @@ OCDisplayNode *OCDisplayNode::parse(Object *obj, OCGs *oc, return new OCDisplayNode(ocgA); } } - obj->fetch(xref, &obj2); + Object obj2 = obj->fetch(xref); if (!obj2.isArray()) { - obj2.free(); return NULL; } i = 0; if (obj2.arrayGetLength() >= 1) { - if (obj2.arrayGet(0, &obj3)->isString()) { + Object obj3 = obj2.arrayGet(0); + if (obj3.isString()) { node = new OCDisplayNode(obj3.getString()); i = 1; } else { node = new OCDisplayNode(); } - obj3.free(); } else { node = new OCDisplayNode(); } for (; i < obj2.arrayGetLength(); ++i) { - obj2.arrayGetNF(i, &obj3); + Object obj3 = obj2.arrayGetNF(i); if ((child = OCDisplayNode::parse(&obj3, oc, xref, recursion + 1))) { if (!child->ocg && !child->name && node->getNumChildren() > 0) { node->getChild(node->getNumChildren() - 1)->addChildren(child->takeChildren()); @@ -491,9 +437,7 @@ OCDisplayNode *OCDisplayNode::parse(Object *obj, OCGs *oc, node->addChild(child); } } - obj3.free(); } - obj2.free(); return node; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Outline.cc b/Build/source/libs/poppler/poppler-src/poppler/Outline.cc index bf46be264fe..82f286633e7 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Outline.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Outline.cc @@ -14,9 +14,10 @@ // under GPL version 2 or later // // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> -// Copyright (C) 2008, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Nick Jones <nick.jones@network-box.com> // Copyright (C) 2016 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -41,15 +42,12 @@ //------------------------------------------------------------------------ Outline::Outline(Object *outlineObj, XRef *xref) { - Object first, last; - - items = NULL; + items = nullptr; if (!outlineObj->isDict()) { return; } - items = OutlineItem::readItemList(outlineObj->dictLookupNF("First", &first), xref); - first.free(); - last.free(); + Object first = outlineObj->dictLookupNF("First"); + items = OutlineItem::readItemList(&first, xref); } Outline::~Outline() { @@ -62,42 +60,42 @@ Outline::~Outline() { OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) { Object obj1; - GooString *s; xref = xrefA; title = NULL; action = NULL; kids = NULL; - if (dict->lookup("Title", &obj1)->isString()) { - s = obj1.getString(); + + obj1 = dict->lookup("Title"); + if (obj1.isString()) { + GooString *s = obj1.getString(); titleLen = TextStringToUCS4(s, &title); } else { titleLen = 0; } - obj1.free(); - if (!dict->lookup("Dest", &obj1)->isNull()) { + obj1 = dict->lookup("Dest"); + if (!obj1.isNull()) { action = LinkAction::parseDest(&obj1); } else { - obj1.free(); - if (!dict->lookup("A", &obj1)->isNull()) { - action = LinkAction::parseAction(&obj1); - } + obj1 = dict->lookup("A"); + if (!obj1.isNull()) { + action = LinkAction::parseAction(&obj1); + } } - obj1.free(); - dict->lookupNF("First", &firstRef); - dict->lookupNF("Last", &lastRef); - dict->lookupNF("Next", &nextRef); + firstRef = dict->lookupNF("First"); + lastRef = dict->lookupNF("Last"); + nextRef = dict->lookupNF("Next"); startsOpen = gFalse; - if (dict->lookup("Count", &obj1)->isInt()) { + obj1 = dict->lookup("Count"); + if (obj1.isInt()) { if (obj1.getInt() > 0) { startsOpen = gTrue; } } - obj1.free(); } OutlineItem::~OutlineItem() { @@ -108,16 +106,12 @@ OutlineItem::~OutlineItem() { if (action) { delete action; } - firstRef.free(); - lastRef.free(); - nextRef.free(); } GooList *OutlineItem::readItemList(Object *firstItemRef, XRef *xrefA) { GooList *items; char* alreadyRead; OutlineItem *item; - Object obj; Object *p; items = new GooList(); @@ -130,13 +124,12 @@ GooList *OutlineItem::readItemList(Object *firstItemRef, XRef *xrefA) { (p->getRefNum() >= 0) && (p->getRefNum() < xrefA->getNumObjects()) && !alreadyRead[p->getRefNum()]) { - if (!p->fetch(xrefA, &obj)->isDict()) { - obj.free(); + Object obj = p->fetch(xrefA); + if (!obj.isDict()) { break; } alreadyRead[p->getRefNum()] = 1; item = new OutlineItem(obj.getDict(), xrefA); - obj.free(); items->append(item); p = &item->nextRef; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc index ee3cf5a30ff..0acdcbdeb80 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> // Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no> -// Copyright (C) 2007 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2007, 2017 Adrian Johnson <ajohnson@redneon.com> // 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> @@ -170,7 +170,7 @@ void OutputDev::markPoint(char *name, Dict *properties) { } -#if OPI_SUPPORT +#ifdef OPI_SUPPORT void OutputDev::opiBegin(GfxState *state, Dict *opiDict) { } diff --git a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h index a15d56b1477..107c94d2a2d 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/OutputDev.h @@ -16,13 +16,14 @@ // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> // Copyright (C) 2006 Thorkild Stray <thorkild@ifi.uio.no> // Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2007, 2011 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2007, 2011, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2009-2013, 2015 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009, 2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009, 2012, 2013 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2012 William Bader <williambader@hotmail.com> +// Copyright (C) 2017 Oliver Sander <oliver.sander@tu-dresden.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 @@ -167,6 +168,12 @@ public: //----- update graphics state virtual void updateAll(GfxState *state); + + // Update the Current Transformation Matrix (CTM), i.e., the new matrix + // given in m11, ..., m32 is combined with the current value of the CTM. + // At the same time, when this method is called, state->getCTM() already + // contains the correct new CTM, so one may as well replace the + // CTM of the renderer with that. virtual void updateCTM(GfxState * /*state*/, double /*m11*/, double /*m12*/, double /*m21*/, double /*m22*/, double /*m31*/, double /*m32*/) {} virtual void updateLineDash(GfxState * /*state*/) {} @@ -242,6 +249,16 @@ public: virtual void endStringOp(GfxState * /*state*/) {} virtual void beginString(GfxState * /*state*/, GooString * /*s*/) {} virtual void endString(GfxState * /*state*/) {} + + // Draw one glyph at a specified position + // + // Arguments are: + // CharCode code: This is the character code in the content stream. It needs to be mapped back to a glyph index. + // int nBytes: The text strings in the content stream can consists of either 8-bit or 16-bit + // character codes depending on the font. nBytes is the number of bytes in the character code. + // Unicode *u: The UCS-4 mapping used for text extraction (TextOutputDev). + // int uLen: The number of unicode entries in u. Usually '1', for a single character, + // but it may also have larger values, for example for ligatures. virtual void drawChar(GfxState * /*state*/, double /*x*/, double /*y*/, double /*dx*/, double /*dy*/, double /*originX*/, double /*originY*/, @@ -292,7 +309,7 @@ public: -#if OPI_SUPPORT +#ifdef OPI_SUPPORT //----- OPI functions virtual void opiBegin(GfxState *state, Dict *opiDict); virtual void opiEnd(GfxState *state, Dict *opiDict); diff --git a/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.cc b/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.cc index f02f192f554..90f039d8ec8 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.cc @@ -28,13 +28,14 @@ // Copyright (C) 2010 Philip Lorenz <lorenzph+freedesktop@gmail.com> // Copyright (C) 2011-2016 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2013, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2014, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> // Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com> // Copyright (C) 2015 Li Junling <lijunling@sina.com> // Copyright (C) 2015 André Guerreiro <aguerreiro1985@gmail.com> // Copyright (C) 2015 André Esser <bepandre@hotmail.com> // Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com> +// Copyright (C) 2017 Jean Ghali <jghali@libertysurf.fr> // // 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 @@ -42,6 +43,7 @@ //======================================================================== #include <config.h> +#include <poppler-config.h> #ifdef USE_GCC_PRAGMAS #pragma implementation @@ -51,11 +53,13 @@ #include <locale.h> #include <stdio.h> #include <errno.h> +#include <limits.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #include <time.h> #include <sys/stat.h> +#include "goo/glibc.h" #include "goo/gstrtod.h" #include "goo/GooString.h" #include "goo/gfile.h" @@ -79,8 +83,9 @@ #endif #include "PDFDoc.h" #include "Hints.h" +#include "UTF.h" -#if MULTITHREADED +#ifdef MULTITHREADED # define pdfdocLocker() MutexLocker locker(&mutex) #else # define pdfdocLocker() @@ -105,7 +110,7 @@ void PDFDoc::init() { -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif ok = gFalse; @@ -132,7 +137,6 @@ PDFDoc::PDFDoc() PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword, GooString *userPassword, void *guiDataA) { - Object obj; #ifdef _WIN32 int n, i; #endif @@ -151,7 +155,13 @@ PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword, #endif // try to open file - file = GooFile::open(fileName); +#ifdef _WIN32 + wchar_t *wFileName = (wchar_t*)utf8ToUtf16(fileName->getCString()); + file = GooFile::open(wFileName); + gfree(wFileName); +#else + file = GooFile::open(fileName); +#endif if (file == NULL) { // fopen() has failed. // Keep a copy of the errno returned by fopen so that it can be @@ -163,8 +173,7 @@ PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword, } // create stream - obj.initNull(); - str = new FileStream(file, 0, gFalse, file->size(), &obj); + str = new FileStream(file, 0, gFalse, file->size(), Object(objNull)); ok = setup(ownerPassword, userPassword); } @@ -173,7 +182,6 @@ PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword, PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, GooString *userPassword, void *guiDataA) { OSVERSIONINFO version; - Object obj; int i; init(); @@ -205,8 +213,7 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, } // create stream - obj.initNull(); - str = new FileStream(file, 0, gFalse, file->size(), &obj); + str = new FileStream(file, 0, gFalse, file->size(), Object(objNull)); ok = setup(ownerPassword, userPassword); } @@ -345,7 +352,7 @@ PDFDoc::~PDFDoc() { gfree(fileNameU); } #endif -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } @@ -419,11 +426,10 @@ void PDFDoc::checkHeader() { } GBool PDFDoc::checkEncryption(GooString *ownerPassword, GooString *userPassword) { - Object encrypt; GBool encrypted; GBool ret; - xref->getTrailerDict()->dictLookup("Encrypt", &encrypt); + Object encrypt = xref->getTrailerDict()->dictLookup("Encrypt"); if ((encrypted = encrypt.isDict())) { if ((secHdlr = SecurityHandler::make(this, &encrypt))) { if (secHdlr->isUnencrypted()) { @@ -451,7 +457,6 @@ GBool PDFDoc::checkEncryption(GooString *ownerPassword, GooString *userPassword) // document is not encrypted ret = gTrue; } - encrypt.free(); return ret; } @@ -565,7 +570,6 @@ GBool PDFDoc::checkLinearization() { return gFalse; } for (int page = 1; page <= linearization->getNumPages(); page++) { - Object obj; Ref pageRef; pageRef.num = hints->getPageObjectNum(page); @@ -581,13 +585,11 @@ GBool PDFDoc::checkLinearization() { } pageRef.gen = xref->getEntry(pageRef.num)->gen; - xref->fetch(pageRef.num, pageRef.gen, &obj); + Object obj = xref->fetch(pageRef.num, pageRef.gen); if (!obj.isDict("Page")) { - obj.free(); linearizationState = 2; return gFalse; } - obj.free(); } linearizationState = 1; return gTrue; @@ -607,10 +609,8 @@ GBool PDFDoc::isLinearized(GBool tryingToReconstruct) { void PDFDoc::setDocInfoModified(Object *infoObj) { - Object infoObjRef; - getDocInfoNF(&infoObjRef); + Object infoObjRef = getDocInfoNF(); xref->setModifiedObject(infoObj, infoObjRef.getRef()); - infoObjRef.free(); } void PDFDoc::setDocInfoStringEntry(const char *key, GooString *value) @@ -620,25 +620,19 @@ void PDFDoc::setDocInfoStringEntry(const char *key, GooString *value) delete value; } - Object infoObj; - getDocInfo(&infoObj); - + Object infoObj = getDocInfo(); if (infoObj.isNull() && removeEntry) { // No info dictionary, so no entry to remove. return; } - createDocInfoIfNoneExists(&infoObj); - - Object gooStrObj; + infoObj = createDocInfoIfNoneExists(); if (removeEntry) { - gooStrObj.initNull(); + infoObj.dictSet(key, Object(objNull)); } else { - gooStrObj.initString(value); + infoObj.dictSet(key, Object(value)); } - // gooStrObj is set to value or null by now. The latter will cause a removal. - infoObj.dictSet(key, &gooStrObj); if (infoObj.dictGetLength() == 0) { // Info dictionary is empty. Remove it altogether. @@ -646,19 +640,15 @@ void PDFDoc::setDocInfoStringEntry(const char *key, GooString *value) } else { setDocInfoModified(&infoObj); } - - infoObj.free(); } GooString *PDFDoc::getDocInfoStringEntry(const char *key) { - Object infoObj; - getDocInfo(&infoObj); + Object infoObj = getDocInfo(); if (!infoObj.isDict()) { return NULL; } - Object entryObj; - infoObj.dictLookup(key, &entryObj); + Object entryObj = infoObj.dictLookup(key); GooString *result; @@ -668,9 +658,6 @@ GooString *PDFDoc::getDocInfoStringEntry(const char *key) { result = NULL; } - entryObj.free(); - infoObj.free(); - return result; } @@ -696,45 +683,35 @@ get_id (GooString *encodedidstring, GooString *id) { } GBool PDFDoc::getID(GooString *permanent_id, GooString *update_id) { - Object obj; - xref->getTrailerDict()->dictLookup ("ID", &obj); + Object obj = xref->getTrailerDict()->dictLookup ("ID"); if (obj.isArray() && obj.arrayGetLength() == 2) { - Object obj2; - if (permanent_id) { - if (obj.arrayGet(0, &obj2)->isString()) { + Object obj2 = obj.arrayGet(0); + if (obj2.isString()) { if (!get_id (obj2.getString(), permanent_id)) { - obj2.free(); return gFalse; } } else { error(errSyntaxError, -1, "Invalid permanent ID"); - obj2.free(); return gFalse; } - obj2.free(); } if (update_id) { - if (obj.arrayGet(1, &obj2)->isString()) { + Object obj2 = obj.arrayGet(1); + if (obj2.isString()) { if (!get_id (obj2.getString(), update_id)) { - obj2.free(); return gFalse; } } else { error(errSyntaxError, -1, "Invalid update ID"); - obj2.free(); return gFalse; } - obj2.free(); } - obj.free(); - return gTrue; } - obj.free(); return gFalse; } @@ -777,8 +754,7 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) getCatalog()->getPage(pageNo)->getMediaBox(), cropBox); Ref *refPage = getCatalog()->getPageRef(pageNo); - Object page; - getXRef()->fetch(refPage->num, refPage->gen, &page); + Object page = getXRef()->fetch(refPage->num, refPage->gen); if (!(f = fopen(name->getCString(), "wb"))) { error(errIO, -1, "Couldn't open file '{0:t}'", name); @@ -801,55 +777,48 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) writeHeader(outStr, getPDFMajorVersion(), getPDFMinorVersion()); // get and mark info dict - Object infoObj; - getXRef()->getDocInfo(&infoObj); + Object infoObj = getXRef()->getDocInfo(); if (infoObj.isDict()) { Dict *infoDict = infoObj.getDict(); markPageObjects(infoDict, yRef, countRef, 0, refPage->num, rootNum + 2); if (trailerObj->isDict()) { Dict *trailerDict = trailerObj->getDict(); - Object ref; - trailerDict->lookupNF("Info", &ref); + Object ref = trailerDict->lookupNF("Info"); if (ref.isRef()) { yRef->add(ref.getRef().num, ref.getRef().gen, 0, gTrue); if (getXRef()->getEntry(ref.getRef().num)->type == xrefEntryCompressed) { yRef->getEntry(ref.getRef().num)->type = xrefEntryCompressed; } } - ref.free(); } } - infoObj.free(); // get and mark output intents etc. - Object catObj, pagesObj, resourcesObj, annotsObj, afObj; - getXRef()->getCatalog(&catObj); + Object catObj = getXRef()->getCatalog(); Dict *catDict = catObj.getDict(); - catDict->lookup("Pages", &pagesObj); - catDict->lookupNF("AcroForm", &afObj); + Object pagesObj = catDict->lookup("Pages"); + Object afObj = catDict->lookupNF("AcroForm"); if (!afObj.isNull()) { markAcroForm(&afObj, yRef, countRef, 0, refPage->num, rootNum + 2); - afObj.free(); } Dict *pagesDict = pagesObj.getDict(); - pagesDict->lookup("Resources", &resourcesObj); + Object resourcesObj = pagesDict->lookup("Resources"); if (resourcesObj.isDict()) markPageObjects(resourcesObj.getDict(), yRef, countRef, 0, refPage->num, rootNum + 2); markPageObjects(catDict, yRef, countRef, 0, refPage->num, rootNum + 2); Dict *pageDict = page.getDict(); if (resourcesObj.isNull() && !pageDict->hasKey("Resources")) { - Dict *resourceDict = getCatalog()->getPage(pageNo)->getResourceDict(); - if (resourceDict != NULL) { - resourcesObj.initDict(resourceDict); + Object *resourceDictObject = getCatalog()->getPage(pageNo)->getResourceDictObject(); + if (resourceDictObject->isDict()) { + resourcesObj = resourceDictObject->copy(); markPageObjects(resourcesObj.getDict(), yRef, countRef, 0, refPage->num, rootNum + 2); } } markPageObjects(pageDict, yRef, countRef, 0, refPage->num, rootNum + 2); - pageDict->lookupNF("Annots", &annotsObj); + Object annotsObj = pageDict->lookupNF("Annots"); if (!annotsObj.isNull()) { markAnnotations(&annotsObj, yRef, countRef, 0, refPage->num, rootNum + 2); - annotsObj.free(); } yRef->markUnencrypted(); writePageObjects(outStr, yRef, 0); @@ -864,14 +833,11 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) strcmp(key, "Pages") != 0) { if (j > 0) outStr->printf(" "); - Object value; catDict->getValNF(j, &value); + Object value = catDict->getValNF(j); outStr->printf("/%s ", key); writeObject(&value, outStr, getXRef(), 0, NULL, cryptRC4, 0, 0, 0); - value.free(); } } - catObj.free(); - pagesObj.free(); outStr->printf(">>\nendobj\n"); yRef->add(rootNum + 1,0,outStr->getPos(),gTrue); @@ -880,7 +846,6 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) if (resourcesObj.isDict()) { outStr->printf("/Resources "); writeObject(&resourcesObj, outStr, getXRef(), 0, NULL, cryptRC4, 0, 0, 0); - resourcesObj.free(); } outStr->printf(">>\n"); outStr->printf("endobj\n"); @@ -891,27 +856,24 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) for (int n = 0; n < pageDict->getLength(); n++) { if (n > 0) outStr->printf(" "); const char *key = pageDict->getKey(n); - Object value; pageDict->getValNF(n, &value); + Object value = pageDict->getValNF(n); if (strcmp(key, "Parent") == 0) { outStr->printf("/Parent %d 0 R", rootNum + 1); } else { outStr->printf("/%s ", key); writeObject(&value, outStr, getXRef(), 0, NULL, cryptRC4, 0, 0, 0); } - value.free(); } outStr->printf(" >>\nendobj\n"); - page.free(); Goffset uxrefOffset = outStr->getPos(); Ref ref; ref.num = rootNum; ref.gen = 0; - Dict *trailerDict = createTrailerDict(rootNum + 3, gFalse, 0, &ref, getXRef(), + Object trailerDict = createTrailerDict(rootNum + 3, gFalse, 0, &ref, getXRef(), name->getCString(), uxrefOffset); - writeXRefTableTrailer(trailerDict, yRef, gFalse /* do not write unnecessary entries */, + writeXRefTableTrailer(std::move(trailerDict), yRef, gFalse /* do not write unnecessary entries */, uxrefOffset, outStr, getXRef()); - delete trailerDict; outStr->close(); fclose(f); @@ -1015,13 +977,11 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) ref.num = i; ref.gen = xref->getEntry(i)->type == xrefEntryCompressed ? 0 : xref->getEntry(i)->gen; if (xref->getEntry(i)->type != xrefEntryFree) { - Object obj1; - xref->fetch(ref.num, ref.gen, &obj1, 1); + Object obj1 = xref->fetch(ref.num, ref.gen, 1); Goffset offset = writeObjectHeader(&ref, outStr); writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, ref.num, ref.gen); writeObjectFooter(outStr); uxref->add(ref.num, ref.gen, offset, gTrue); - obj1.free(); } else { uxref->add(ref.num, ref.gen, 0, gFalse); } @@ -1052,14 +1012,13 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr) uxref->add(uxrefStreamRef.num, uxrefStreamRef.gen, uxrefOffset, gTrue); } - Dict *trailerDict = createTrailerDict(numobjects, gTrue, getStartXRef(), &rootRef, getXRef(), fileNameA, uxrefOffset); + Object trailerDict = createTrailerDict(numobjects, gTrue, getStartXRef(), &rootRef, getXRef(), fileNameA, uxrefOffset); if (xRefStream) { - writeXRefStreamTrailer(trailerDict, uxref, &uxrefStreamRef, uxrefOffset, outStr, getXRef()); + writeXRefStreamTrailer(std::move(trailerDict), uxref, &uxrefStreamRef, uxrefOffset, outStr, getXRef()); } else { - writeXRefTableTrailer(trailerDict, uxref, gFalse, uxrefOffset, outStr, getXRef()); + writeXRefTableTrailer(std::move(trailerDict), uxref, gFalse, uxrefOffset, outStr, getXRef()); } - delete trailerDict; delete uxref; } @@ -1079,7 +1038,6 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr) uxref->add(0, 65535, 0, gFalse); xref->lock(); for(int i=0; i<xref->getNumObjects(); i++) { - Object obj1; Ref ref; XRefEntryType type = xref->getEntry(i)->type; if (type == xrefEntryFree) { @@ -1097,7 +1055,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr) } else if (type == xrefEntryUncompressed){ ref.num = i; ref.gen = xref->getEntry(i)->gen; - xref->fetch(ref.num, ref.gen, &obj1, 1); + Object obj1 = xref->fetch(ref.num, ref.gen, 1); Goffset offset = writeObjectHeader(&ref, outStr); // Write unencrypted objects in unencrypted form if (xref->getEntry(i)->getFlag(XRefEntry::Unencrypted)) { @@ -1107,16 +1065,14 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr) } writeObjectFooter(outStr); uxref->add(ref.num, ref.gen, offset, gTrue); - obj1.free(); } else if (type == xrefEntryCompressed) { ref.num = i; ref.gen = 0; //compressed entries have gen == 0 - xref->fetch(ref.num, ref.gen, &obj1, 1); + Object obj1 = xref->fetch(ref.num, ref.gen, 1); Goffset offset = writeObjectHeader(&ref, outStr); writeObject(&obj1, outStr, fileKey, encAlgorithm, keyLength, ref.num, ref.gen); writeObjectFooter(outStr); uxref->add(ref.num, ref.gen, offset, gTrue); - obj1.free(); } } xref->unlock(); @@ -1127,19 +1083,36 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr) } void PDFDoc::writeDictionnary (Dict* dict, OutStream* outStr, XRef *xRef, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen) + CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, std::set<Dict*> *alreadyWrittenDicts) { - Object obj1; + bool deleteSet = false; + if (!alreadyWrittenDicts) { + alreadyWrittenDicts = new std::set<Dict*>; + deleteSet = true; + } + + if (alreadyWrittenDicts->find(dict) != alreadyWrittenDicts->end()) { + error(errSyntaxWarning, -1, "PDFDoc::writeDictionnary: Found recursive dicts"); + if (deleteSet) delete alreadyWrittenDicts; + return; + } else { + alreadyWrittenDicts->insert(dict); + } + outStr->printf("<<"); for (int i=0; i<dict->getLength(); i++) { GooString keyName(dict->getKey(i)); GooString *keyNameToPrint = keyName.sanitizedName(gFalse /* non ps mode */); outStr->printf("/%s ", keyNameToPrint->getCString()); delete keyNameToPrint; - writeObject(dict->getValNF(i, &obj1), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); - obj1.free(); + Object obj1 = dict->getValNF(i); + writeObject(&obj1, outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen, alreadyWrittenDicts); } outStr->printf(">> "); + + if (deleteSet) { + delete alreadyWrittenDicts; + } } void PDFDoc::writeStream (Stream* str, OutStream* outStr) @@ -1154,8 +1127,7 @@ void PDFDoc::writeStream (Stream* str, OutStream* outStr) void PDFDoc::writeRawStream (Stream* str, OutStream* outStr) { - Object obj1; - str->getDict()->lookup("Length", &obj1); + Object obj1 = str->getDict()->lookup("Length"); if (!obj1.isInt() && !obj1.isInt64()) { error (errSyntaxError, -1, "PDFDoc::writeRawStream, no Length in stream dict"); return; @@ -1166,7 +1138,6 @@ void PDFDoc::writeRawStream (Stream* str, OutStream* outStr) length = obj1.getInt(); else length = obj1.getInt64(); - obj1.free(); outStr->printf("stream\r\n"); str->unfilteredReset(); @@ -1188,8 +1159,7 @@ void PDFDoc::writeString (GooString* s, OutStream* outStr, Guchar *fileKey, // Encrypt string if encryption is enabled GooString *sEnc = NULL; if (fileKey) { - Object obj; - EncryptStream *enc = new EncryptStream(new MemStream(s->getCString(), 0, s->getLength(), obj.initNull()), + EncryptStream *enc = new EncryptStream(new MemStream(s->getCString(), 0, s->getLength(), Object(objNull)), fileKey, encAlgorithm, keyLength, objNum, objGen); sEnc = new GooString(); int c; @@ -1246,11 +1216,9 @@ Goffset PDFDoc::writeObjectHeader (Ref *ref, OutStream* outStr) } void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen) + CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, std::set<Dict*> *alreadyWrittenDicts) { Array *array; - Object obj1; - Goffset tmp; switch (obj->getType()) { case objBool: @@ -1287,13 +1255,13 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO array = obj->getArray(); outStr->printf("["); for (int i=0; i<array->getLength(); i++) { - writeObject(array->getNF(i, &obj1), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); - obj1.free(); + Object obj1 = array->getNF(i); + writeObject(&obj1, outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); } outStr->printf("] "); break; case objDict: - writeDictionnary (obj->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeDictionnary (obj->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen, alreadyWrittenDicts); break; case objStream: { @@ -1307,19 +1275,15 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO EncryptStream *encStream = NULL; GBool removeFilter = gTrue; if (stream->getKind() == strWeird && fileKey) { - Object filter; - stream->getDict()->lookup("Filter", &filter); + Object filter = stream->getDict()->lookup("Filter"); if (!filter.isName("Crypt")) { if (filter.isArray()) { for (int i = 0; i < filter.arrayGetLength(); i++) { - Object filterEle; - filter.arrayGet(i, &filterEle); + Object filterEle = filter.arrayGet(i); if (filterEle.isName("Crypt")) { - filterEle.free(); removeFilter = gFalse; break; } - filterEle.free(); } if (removeFilter) { encStream = new EncryptStream(stream, fileKey, encAlgorithm, keyLength, objNum, objGen); @@ -1334,7 +1298,6 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO } else { removeFilter = gFalse; } - filter.free(); } else if (fileKey != NULL) { // Encrypt stream encStream = new EncryptStream(stream, fileKey, encAlgorithm, keyLength, objNum, objGen); encStream->setAutoDelete(gFalse); @@ -1343,12 +1306,11 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO stream->reset(); //recalculate stream length - tmp = 0; + Goffset tmp = 0; for (int c=stream->getChar(); c!=EOF; c=stream->getChar()) { tmp++; } - obj1.initInt64(tmp); - stream->getDict()->set("Length", &obj1); + stream->getDict()->set("Length", Object(tmp)); //Remove Stream encoding if (removeFilter) { @@ -1356,10 +1318,9 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO } stream->getDict()->remove("DecodeParms"); - writeDictionnary (stream->getDict(),outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeDictionnary (stream->getDict(),outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen, alreadyWrittenDicts); writeStream (stream,outStr); delete encStream; - obj1.free(); } else { //raw stream copy FilterStream *fs = dynamic_cast<FilterStream*>(stream); @@ -1368,13 +1329,12 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO if (bs) { Goffset streamEnd; if (xRef->getStreamEnd(bs->getStart(), &streamEnd)) { - Object val; - val.initInt64(streamEnd - bs->getStart()); - stream->getDict()->set("Length", &val); + Goffset val = streamEnd - bs->getStart(); + stream->getDict()->set("Length", Object(val)); } } } - writeDictionnary (stream->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen); + writeDictionnary (stream->getDict(), outStr, xRef, numOffset, fileKey, encAlgorithm, keyLength, objNum, objGen, alreadyWrittenDicts); writeRawStream (stream, outStr); } break; @@ -1405,14 +1365,11 @@ void PDFDoc::writeObjectFooter (OutStream* outStr) outStr->printf("endobj\r\n"); } -Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxRef, +Object PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxRef, Ref *root, XRef *xRef, const char *fileName, Goffset fileSize) { Dict *trailerDict = new Dict(xRef); - Object obj1; - obj1.initInt(uxrefSize); - trailerDict->set("Size", &obj1); - obj1.free(); + trailerDict->set("Size", Object(uxrefSize)); //build a new ID, as recommended in the reference, uses: // - current time @@ -1431,105 +1388,92 @@ Dict *PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxR message.append(buffer); //info dict -- only use text string - if (!xRef->getTrailerDict()->isNone() && xRef->getDocInfo(&obj1)->isDict()) { - for(int i=0; i<obj1.getDict()->getLength(); i++) { - Object obj2; - obj1.getDict()->getVal(i, &obj2); - if (obj2.isString()) { - message.append(obj2.getString()); + if (!xRef->getTrailerDict()->isNone()) { + Object docInfo = xRef->getDocInfo(); + if (docInfo.isDict()) { + for(int i=0; i<docInfo.getDict()->getLength(); i++) { + Object obj2 = docInfo.getDict()->getVal(i); + if (obj2.isString()) { + message.append(obj2.getString()); + } } - obj2.free(); } } - obj1.free(); GBool hasEncrypt = gFalse; if (!xRef->getTrailerDict()->isNone()) { - Object obj2; - xRef->getTrailerDict()->dictLookupNF("Encrypt", &obj2); + Object obj2 = xRef->getTrailerDict()->dictLookupNF("Encrypt"); if (!obj2.isNull()) { - trailerDict->set("Encrypt", &obj2); + trailerDict->set("Encrypt", std::move(obj2)); hasEncrypt = gTrue; - obj2.free(); } } //calculate md5 digest Guchar digest[16]; md5((Guchar*)message.getCString(), message.getLength(), digest); - obj1.initString(new GooString((const char*)digest, 16)); //create ID array - Object obj2,obj3,obj5; - obj2.initArray(xRef); - // In case of encrypted files, the ID must not be changed because it's used to calculate the key if (incrUpdate || hasEncrypt) { - Object obj4; //only update the second part of the array - xRef->getTrailerDict()->getDict()->lookup("ID", &obj4); + Object obj4 = xRef->getTrailerDict()->getDict()->lookup("ID"); if (!obj4.isArray()) { error(errSyntaxWarning, -1, "PDFDoc::createTrailerDict original file's ID entry isn't an array. Trying to continue"); } else { + Array *array = new Array(xRef); //Get the first part of the ID - obj4.arrayGet(0,&obj3); - - obj2.arrayAdd(&obj3); - obj2.arrayAdd(&obj1); - trailerDict->set("ID", &obj2); + array->add(obj4.arrayGet(0)); + array->add(Object(new GooString((const char*)digest, 16))); + trailerDict->set("ID", Object(array)); } - obj4.free(); } else { //new file => same values for the two identifiers - obj2.arrayAdd(&obj1); - obj1.initString(new GooString((const char*)digest, 16)); - obj2.arrayAdd(&obj1); - trailerDict->set("ID", &obj2); + Array *array = new Array(xRef); + array->add(Object(new GooString((const char*)digest, 16))); + array->add(Object(new GooString((const char*)digest, 16))); + trailerDict->set("ID", Object(array)); } - obj1.initRef(root->num, root->gen); - trailerDict->set("Root", &obj1); + trailerDict->set("Root", Object(root->num, root->gen)); if (incrUpdate) { - obj1.initInt64(startxRef); - trailerDict->set("Prev", &obj1); + trailerDict->set("Prev", Object(startxRef)); } if (!xRef->getTrailerDict()->isNone()) { - xRef->getDocInfoNF(&obj5); + Object obj5 = xRef->getDocInfoNF(); if (!obj5.isNull()) { - trailerDict->set("Info", &obj5); + trailerDict->set("Info", std::move(obj5)); } } - return trailerDict; + return Object(trailerDict); } -void PDFDoc::writeXRefTableTrailer(Dict *trailerDict, XRef *uxref, GBool writeAllEntries, Goffset uxrefOffset, OutStream* outStr, XRef *xRef) +void PDFDoc::writeXRefTableTrailer(Object &&trailerDict, XRef *uxref, GBool writeAllEntries, Goffset uxrefOffset, OutStream* outStr, XRef *xRef) { uxref->writeTableToFile( outStr, writeAllEntries ); outStr->printf( "trailer\r\n"); - writeDictionnary(trailerDict, outStr, xRef, 0, NULL, cryptRC4, 0, 0, 0); + writeDictionnary(trailerDict.getDict(), outStr, xRef, 0, NULL, cryptRC4, 0, 0, 0, nullptr); outStr->printf( "\r\nstartxref\r\n"); outStr->printf( "%lli\r\n", uxrefOffset); outStr->printf( "%%%%EOF\r\n"); } -void PDFDoc::writeXRefStreamTrailer (Dict *trailerDict, XRef *uxref, Ref *uxrefStreamRef, Goffset uxrefOffset, OutStream* outStr, XRef *xRef) +void PDFDoc::writeXRefStreamTrailer (Object &&trailerDict, XRef *uxref, Ref *uxrefStreamRef, Goffset uxrefOffset, OutStream* outStr, XRef *xRef) { GooString stmData; // Fill stmData and some trailerDict fields - uxref->writeStreamToBuffer(&stmData, trailerDict, xRef); + uxref->writeStreamToBuffer(&stmData, trailerDict.getDict(), xRef); // Create XRef stream object and write it - Object obj1; - MemStream *mStream = new MemStream( stmData.getCString(), 0, - stmData.getLength(), obj1.initDict(trailerDict) ); + MemStream *mStream = new MemStream( stmData.getCString(), 0, stmData.getLength(), std::move(trailerDict) ); writeObjectHeader(uxrefStreamRef, outStr); - writeObject(obj1.initStream(mStream), outStr, xRef, 0, NULL, cryptRC4, 0, 0, 0); + Object obj1(static_cast<Stream*>(mStream)); + writeObject(&obj1, outStr, xRef, 0, NULL, cryptRC4, 0, 0, 0); writeObjectFooter(outStr); - obj1.free(); outStr->printf( "startxref\r\n"); outStr->printf( "%lli\r\n", uxrefOffset); @@ -1551,10 +1495,9 @@ void PDFDoc::writeXRefTableTrailer(Goffset uxrefOffset, XRef *uxref, GBool write Ref ref; ref.num = getXRef()->getRootNum(); ref.gen = getXRef()->getRootGen(); - Dict * trailerDict = createTrailerDict(uxrefSize, incrUpdate, getStartXRef(), &ref, + Object trailerDict = createTrailerDict(uxrefSize, incrUpdate, getStartXRef(), &ref, getXRef(), fileNameA, fileSize); - writeXRefTableTrailer(trailerDict, uxref, writeAllEntries, uxrefOffset, outStr, getXRef()); - delete trailerDict; + writeXRefTableTrailer(std::move(trailerDict), uxref, writeAllEntries, uxrefOffset, outStr, getXRef()); } void PDFDoc::writeHeader(OutStream *outStr, int major, int minor) @@ -1563,45 +1506,60 @@ void PDFDoc::writeHeader(OutStream *outStr, int major, int minor) outStr->printf("%%\xE2\xE3\xCF\xD3\n"); } -void PDFDoc::markDictionnary (Dict* dict, XRef * xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum) +void PDFDoc::markDictionnary (Dict* dict, XRef * xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum, std::set<Dict*> *alreadyMarkedDicts) { + bool deleteSet = false; + if (!alreadyMarkedDicts) { + alreadyMarkedDicts = new std::set<Dict*>; + deleteSet = true; + } + + if (alreadyMarkedDicts->find(dict) != alreadyMarkedDicts->end()) { + error(errSyntaxWarning, -1, "PDFDoc::markDictionnary: Found recursive dicts"); + if (deleteSet) delete alreadyMarkedDicts; + return; + } else { + alreadyMarkedDicts->insert(dict); + } + Object obj1; for (int i=0; i<dict->getLength(); i++) { const char *key = dict->getKey(i); if (strcmp(key, "Annots") != 0) { - markObject(dict->getValNF(i, &obj1), xRef, countRef, numOffset, oldRefNum, newRefNum); + Object obj1 = dict->getValNF(i); + markObject(&obj1, xRef, countRef, numOffset, oldRefNum, newRefNum, alreadyMarkedDicts); } else { - Object annotsObj; - dict->getValNF(i, &annotsObj); + Object annotsObj = dict->getValNF(i); if (!annotsObj.isNull()) { - markAnnotations(&annotsObj, xRef, countRef, 0, oldRefNum, newRefNum); - annotsObj.free(); + markAnnotations(&annotsObj, xRef, countRef, 0, oldRefNum, newRefNum, alreadyMarkedDicts); } } - obj1.free(); + } + + if (deleteSet) { + delete alreadyMarkedDicts; } } -void PDFDoc::markObject (Object* obj, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum) +void PDFDoc::markObject (Object* obj, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum, std::set<Dict*> *alreadyMarkedDicts) { Array *array; - Object obj1; switch (obj->getType()) { case objArray: array = obj->getArray(); for (int i=0; i<array->getLength(); i++) { - markObject(array->getNF(i, &obj1), xRef, countRef, numOffset, oldRefNum, newRefNum); - obj1.free(); + Object obj1 = array->getNF(i); + markObject(&obj1, xRef, countRef, numOffset, oldRefNum, newRefNum); } break; case objDict: - markDictionnary (obj->getDict(), xRef, countRef, numOffset, oldRefNum, newRefNum); + markDictionnary (obj->getDict(), xRef, countRef, numOffset, oldRefNum, newRefNum, alreadyMarkedDicts); break; case objStream: { Stream *stream = obj->getStream(); - markDictionnary (stream->getDict(), xRef, countRef, numOffset, oldRefNum, newRefNum); + markDictionnary (stream->getDict(), xRef, countRef, numOffset, oldRefNum, newRefNum, alreadyMarkedDicts); } break; case objRef: @@ -1625,10 +1583,8 @@ void PDFDoc::markObject (Object* obj, XRef *xRef, XRef *countRef, Guint numOffse if (entry->gen > 9) break; } - Object obj1; - getXRef()->fetch(obj->getRef().num, obj->getRef().gen, &obj1); + Object obj1 = getXRef()->fetch(obj->getRef().num, obj->getRef().gen); markObject(&obj1, xRef, countRef, numOffset, oldRefNum, newRefNum); - obj1.free(); } break; default: @@ -1641,8 +1597,7 @@ void PDFDoc::replacePageDict(int pageNo, int rotate, PDFRectangle *cropBox) { Ref *refPage = getCatalog()->getPageRef(pageNo); - Object page; - getXRef()->fetch(refPage->num, refPage->gen, &page); + Object page = getXRef()->fetch(refPage->num, refPage->gen); Dict *pageDict = page.getDict(); pageDict->remove("MediaBoxssdf"); pageDict->remove("MediaBox"); @@ -1651,51 +1606,30 @@ void PDFDoc::replacePageDict(int pageNo, int rotate, pageDict->remove("BleedBox"); pageDict->remove("TrimBox"); pageDict->remove("Rotate"); - Object mediaBoxObj; - mediaBoxObj.initArray(getXRef()); - Object murx; - murx.initReal(mediaBox->x1); - Object mury; - mury.initReal(mediaBox->y1); - Object mllx; - mllx.initReal(mediaBox->x2); - Object mlly; - mlly.initReal(mediaBox->y2); - mediaBoxObj.arrayAdd(&murx); - mediaBoxObj.arrayAdd(&mury); - mediaBoxObj.arrayAdd(&mllx); - mediaBoxObj.arrayAdd(&mlly); - pageDict->add(copyString("MediaBox"), &mediaBoxObj); + Array *mediaBoxArray = new Array(getXRef()); + mediaBoxArray->add(Object(mediaBox->x1)); + mediaBoxArray->add(Object(mediaBox->y1)); + mediaBoxArray->add(Object(mediaBox->x2)); + mediaBoxArray->add(Object(mediaBox->y2)); + Object mediaBoxObject(mediaBoxArray); + Object trimBoxObject = mediaBoxObject.copy(); + pageDict->add(copyString("MediaBox"), std::move(mediaBoxObject)); if (cropBox != NULL) { - Object cropBoxObj; - cropBoxObj.initArray(getXRef()); - Object curx; - curx.initReal(cropBox->x1); - Object cury; - cury.initReal(cropBox->y1); - Object cllx; - cllx.initReal(cropBox->x2); - Object clly; - clly.initReal(cropBox->y2); - cropBoxObj.arrayAdd(&curx); - cropBoxObj.arrayAdd(&cury); - cropBoxObj.arrayAdd(&cllx); - cropBoxObj.arrayAdd(&clly); - pageDict->add(copyString("CropBox"), &cropBoxObj); - cropBoxObj.getArray()->incRef(); - pageDict->add(copyString("TrimBox"), &cropBoxObj); - } else { - mediaBoxObj.getArray()->incRef(); - pageDict->add(copyString("TrimBox"), &mediaBoxObj); - } - Object rotateObj; - rotateObj.initInt(rotate); - pageDict->add(copyString("Rotate"), &rotateObj); + Array *cropBoxArray = new Array(getXRef()); + cropBoxArray->add(Object(cropBox->x1)); + cropBoxArray->add(Object(cropBox->y1)); + cropBoxArray->add(Object(cropBox->x2)); + cropBoxArray->add(Object(cropBox->y2)); + Object cropBoxObject(cropBoxArray); + trimBoxObject = cropBoxObject.copy(); + pageDict->add(copyString("CropBox"), std::move(cropBoxObject)); + } + pageDict->add(copyString("TrimBox"), std::move(trimBoxObject)); + pageDict->add(copyString("Rotate"), Object(rotate)); getXRef()->setModifiedObject(&page, *refPage); - page.free(); } -void PDFDoc::markPageObjects(Dict *pageDict, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum) +void PDFDoc::markPageObjects(Dict *pageDict, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum, std::set<Dict*> *alreadyMarkedDicts) { pageDict->remove("OpenAction"); pageDict->remove("Outlines"); @@ -1703,82 +1637,57 @@ void PDFDoc::markPageObjects(Dict *pageDict, XRef *xRef, XRef *countRef, Guint n for (int n = 0; n < pageDict->getLength(); n++) { const char *key = pageDict->getKey(n); - Object value; pageDict->getValNF(n, &value); + Object value = pageDict->getValNF(n); if (strcmp(key, "Parent") != 0 && strcmp(key, "Pages") != 0 && strcmp(key, "AcroForm") != 0 && strcmp(key, "Annots") != 0 && strcmp(key, "P") != 0 && strcmp(key, "Root") != 0) { - markObject(&value, xRef, countRef, numOffset, oldRefNum, newRefNum); + markObject(&value, xRef, countRef, numOffset, oldRefNum, newRefNum, alreadyMarkedDicts); } - value.free(); } } -GBool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, Guint numOffset, int oldPageNum, int newPageNum) { - Object annots; +GBool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, Guint numOffset, int oldPageNum, int newPageNum, std::set<Dict*> *alreadyMarkedDicts) { GBool modified = gFalse; - annotsObj->fetch(getXRef(), &annots); + Object annots = annotsObj->fetch(getXRef()); if (annots.isArray()) { Array *array = annots.getArray(); for (int i=array->getLength() - 1; i >= 0; i--) { - Object obj1; - if (array->get(i, &obj1)->isDict()) { - Object type; + Object obj1 = array->get(i); + if (obj1.isDict()) { Dict *dict = obj1.getDict(); - dict->lookup("Type", &type); + Object type = dict->lookup("Type"); if (type.isName() && strcmp(type.getName(), "Annot") == 0) { - Object obj2; - if (dict->lookupNF("P", &obj2)->isRef()) { + Object obj2 = dict->lookupNF("P"); + if (obj2.isRef()) { if (obj2.getRef().num == oldPageNum) { - Object obj3; - array->getNF(i, &obj3); + Object obj3 = array->getNF(i); if (obj3.isRef()) { - Object newRef; - newRef.initRef(newPageNum, 0); - dict->set("P", &newRef); + dict->set("P", Object(newPageNum, 0)); getXRef()->setModifiedObject(&obj1, obj3.getRef()); } - obj3.free(); } else if (obj2.getRef().num == newPageNum) { - obj1.free(); - obj2.free(); - type.free(); continue; } else { - Object page; - getXRef()->fetch(obj2.getRef().num, obj2.getRef().gen, &page); + Object page = getXRef()->fetch(obj2.getRef().num, obj2.getRef().gen); if (page.isDict()) { - Object pagetype; Dict *dict = page.getDict(); - dict->lookup("Type", &pagetype); + Object pagetype = dict->lookup("Type"); if (!pagetype.isName() || strcmp(pagetype.getName(), "Page") != 0) { - obj1.free(); - obj2.free(); - type.free(); - page.free(); - pagetype.free(); continue; } - pagetype.free(); } - page.free(); - obj1.free(); - obj2.free(); - type.free(); array->remove(i); modified = gTrue; continue; } } - obj2.free(); } - type.free(); - markPageObjects(dict, xRef, countRef, numOffset, oldPageNum, newPageNum); + markPageObjects(dict, xRef, countRef, numOffset, oldPageNum, newPageNum, alreadyMarkedDicts); } - obj1.free(); - array->getNF(i, &obj1); + obj1 = array->getNF(i); if (obj1.isRef()) { if (obj1.getRef().num + (int) numOffset >= xRef->getNumObjects() || xRef->getEntry(obj1.getRef().num + numOffset)->type == xrefEntryFree) { if (getXRef()->getEntry(obj1.getRef().num)->type == xrefEntryFree) { @@ -1798,7 +1707,6 @@ GBool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, Gui entry->gen++; } } - obj1.free(); } } if (annotsObj->isRef()) { @@ -1821,25 +1729,21 @@ GBool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, Gui } getXRef()->setModifiedObject(&annots, annotsObj->getRef()); } - annots.free(); return modified; } void PDFDoc::markAcroForm(Object *afObj, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum) { - Object acroform; GBool modified = gFalse; - afObj->fetch(getXRef(), &acroform); + Object acroform = afObj->fetch(getXRef()); if (acroform.isDict()) { Dict *dict = acroform.getDict(); for (int i=0; i < dict->getLength(); i++) { if (strcmp(dict->getKey(i), "Fields") == 0) { - Object fields; - modified = markAnnotations(dict->getValNF(i, &fields), xRef, countRef, numOffset, oldRefNum, newRefNum); - fields.free(); + Object fields = dict->getValNF(i); + modified = markAnnotations(&fields, xRef, countRef, numOffset, oldRefNum, newRefNum); } else { - Object obj; - markObject(dict->getValNF(i, &obj), xRef, countRef, numOffset, oldRefNum, newRefNum); - obj.free(); + Object obj = dict->getValNF(i); + markObject(&obj, xRef, countRef, numOffset, oldRefNum, newRefNum); } } } @@ -1865,7 +1769,6 @@ void PDFDoc::markAcroForm(Object *afObj, XRef *xRef, XRef *countRef, Guint numOf getXRef()->setModifiedObject(&acroform, afObj->getRef()); } } - acroform.free(); return; } @@ -1879,12 +1782,11 @@ Guint PDFDoc::writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset, G for (int n = numOffset; n < xRef->getNumObjects(); n++) { if (xRef->getEntry(n)->type != xrefEntryFree) { - Object obj; Ref ref; ref.num = n; ref.gen = xRef->getEntry(n)->gen; objectsCount++; - getXRef()->fetch(ref.num - numOffset, ref.gen, &obj); + Object obj = getXRef()->fetch(ref.num - numOffset, ref.gen); Goffset offset = writeObjectHeader(&ref, outStr); if (combine) { writeObject(&obj, outStr, getXRef(), numOffset, NULL, cryptRC4, 0, 0, 0); @@ -1895,7 +1797,6 @@ Guint PDFDoc::writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset, G } writeObjectFooter(outStr); xRef->add(ref.num, ref.gen, offset, gTrue); - obj.free(); } } return objectsCount; @@ -2032,10 +1933,7 @@ int PDFDoc::getNumPages() Page *PDFDoc::parsePage(int page) { - Page *p = NULL; - Object obj; Ref pageRef; - Dict *pageDict; pageRef.num = getHints()->getPageObjectNum(page); if (!pageRef.num) { @@ -2050,19 +1948,15 @@ Page *PDFDoc::parsePage(int page) } pageRef.gen = xref->getEntry(pageRef.num)->gen; - xref->fetch(pageRef.num, pageRef.gen, &obj); + Object obj = xref->fetch(pageRef.num, pageRef.gen); if (!obj.isDict("Page")) { - obj.free(); error(errSyntaxWarning, -1, "Object ({0:d} {1:d}) is not a pageDict", pageRef.num, pageRef.gen); return NULL; } - pageDict = obj.getDict(); + Dict *pageDict = obj.getDict(); - p = new Page(this, page, pageDict, pageRef, + return new Page(this, page, &obj, pageRef, new PageAttrs(NULL, pageDict), catalog->getForm()); - obj.free(); - - return p; } Page *PDFDoc::getPage(int page) diff --git a/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.h b/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.h index 99de8a21a34..48d8dcf779e 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.h +++ b/Build/source/libs/poppler/poppler-src/poppler/PDFDoc.h @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net> -// Copyright (C) 2005, 2009, 2014, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2009, 2014, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2008 Pino Toscano <pino@kde.org> // Copyright (C) 2008 Carlos Garcia Campos <carlosgc@gnome.org> @@ -24,7 +24,7 @@ // Copyright (C) 2010 Srinivas Adicherla <srinivas.adicherla@geodesic.com> // Copyright (C) 2011, 2013, 2014, 2016 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> // Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com> // Copyright (C) 2015 André Guerreiro <aguerreiro1985@gmail.com> @@ -229,12 +229,12 @@ public: GBool isLinearized(GBool tryingToReconstruct = gFalse); // Return the document's Info dictionary (if any). - Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); } - Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); } + Object getDocInfo() { return xref->getDocInfo(); } + Object getDocInfoNF() { return xref->getDocInfoNF(); } // Create and return the document's Info dictionary if none exists. // Otherwise return the existing one. - Object *createDocInfoIfNoneExists(Object *obj) { return xref->createDocInfoIfNoneExists(obj); } + Object createDocInfoIfNoneExists() { return xref->createDocInfoIfNoneExists(); } // Remove the document's Info dictionary and update the trailer dictionary. void removeDocInfo() { xref->removeDocInfo(); } @@ -292,40 +292,36 @@ public: // rewrite pageDict with MediaBox, CropBox and new page CTM void replacePageDict(int pageNo, int rotate, PDFRectangle *mediaBox, PDFRectangle *cropBox); - void markPageObjects(Dict *pageDict, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum); - GBool markAnnotations(Object *annots, XRef *xRef, XRef *countRef, Guint numOffset, int oldPageNum, int newPageNum); + void markPageObjects(Dict *pageDict, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum, std::set<Dict*> *alreadyMarkedDicts = nullptr); + GBool markAnnotations(Object *annots, XRef *xRef, XRef *countRef, Guint numOffset, int oldPageNum, int newPageNum, std::set<Dict*> *alreadyMarkedDicts = nullptr); void markAcroForm(Object *acrpForm, XRef *xRef, XRef *countRef, Guint numOffset, int oldPageNum, int newPageNum); // write all objects used by pageDict to outStr Guint writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset, GBool combine = gFalse); static void writeObject (Object *obj, OutStream* outStr, XRef *xref, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen); + CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, std::set<Dict*> *alreadyWrittenDicts = nullptr); static void writeHeader(OutStream *outStr, int major, int minor); - // Ownership goes to the caller - static Dict *createTrailerDict (int uxrefSize, GBool incrUpdate, Goffset startxRef, + static Object createTrailerDict (int uxrefSize, GBool incrUpdate, Goffset startxRef, Ref *root, XRef *xRef, const char *fileName, Goffset fileSize); - static void writeXRefTableTrailer (Dict *trailerDict, XRef *uxref, GBool writeAllEntries, + static void writeXRefTableTrailer (Object &&trailerDict, XRef *uxref, GBool writeAllEntries, Goffset uxrefOffset, OutStream* outStr, XRef *xRef); - static void writeXRefStreamTrailer (Dict *trailerDict, XRef *uxref, Ref *uxrefStreamRef, + static void writeXRefStreamTrailer (Object &&trailerDict, XRef *uxref, Ref *uxrefStreamRef, Goffset uxrefOffset, OutStream* outStr, XRef *xRef); private: // insert referenced objects in XRef - void markDictionnary (Dict* dict, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum); - void markObject (Object *obj, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum); + void markDictionnary (Dict* dict, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum, std::set<Dict*> *alreadyMarkedDicts); + void markObject (Object *obj, XRef *xRef, XRef *countRef, Guint numOffset, int oldRefNum, int newRefNum, std::set<Dict*> *alreadyMarkedDicts = nullptr); static void writeDictionnary (Dict* dict, OutStream* outStr, XRef *xRef, Guint numOffset, Guchar *fileKey, - CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen); + CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, std::set<Dict*> *alreadyWrittenDicts); // Write object header to current file stream and return its offset static Goffset writeObjectHeader (Ref *ref, OutStream* outStr); static void writeObjectFooter (OutStream* outStr); void writeObject (Object *obj, OutStream* outStr, Guchar *fileKey, CryptAlgorithm encAlgorithm, - int keyLength, int objNum, int objGen) - { writeObject(obj, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, objNum, objGen); } - void writeDictionnary (Dict* dict, OutStream* outStr, Guchar *fileKey, CryptAlgorithm encAlgorithm, - int keyLength, int objNum, int objGen) - { writeDictionnary(dict, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, objNum, objGen); } + int keyLength, int objNum, int objGen, std::set<Dict*> *alreadyWrittenDicts = nullptr) + { writeObject(obj, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, objNum, objGen, alreadyWrittenDicts); } static void writeStream (Stream* str, OutStream* outStr); static void writeRawStream (Stream* str, OutStream* outStr); void writeXRefTableTrailer (Goffset uxrefOffset, XRef *uxref, GBool writeAllEntries, @@ -386,7 +382,7 @@ private: int fopenErrno; Goffset startXRefPos; // offset of last xref table -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/PDFDocFactory.cc b/Build/source/libs/poppler/poppler-src/poppler/PDFDocFactory.cc index 1ec46477237..cbd1395f5bb 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PDFDocFactory.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/PDFDocFactory.cc @@ -6,6 +6,7 @@ // // Copyright 2010 Hib Eris <hib@hiberis.nl> // Copyright 2010 Albert Astals Cid <aacid@kde.org> +// Copyright 2017 Adrian Johnson <ajohnson@redneon.com> // //======================================================================== @@ -18,7 +19,7 @@ #include "PDFDoc.h" #include "LocalPDFDocBuilder.h" #include "StdinPDFDocBuilder.h" -#if ENABLE_LIBCURL +#ifdef ENABLE_LIBCURL #include "CurlPDFDocBuilder.h" #endif #include "ErrorCodes.h" @@ -34,7 +35,7 @@ PDFDocFactory::PDFDocFactory(GooList *pdfDocBuilders) } else { builders = new GooList(); } -#if ENABLE_LIBCURL +#ifdef ENABLE_LIBCURL builders->insert(0, new CurlPDFDocBuilder()); #endif builders->insert(0, new StdinPDFDocBuilder()); diff --git a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc index 246244f8c57..ac4f028f120 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2009, 2011-2013, 2015, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2009, 2011-2013, 2015-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> // Copyright (C) 2008, 2009 Koji Otani <sho@bbr.jp> @@ -23,9 +23,9 @@ // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009, 2011, 2012, 2014-2016 William Bader <williambader@hotmail.com> +// Copyright (C) 2009, 2011, 2012, 2014-2017 William Bader <williambader@hotmail.com> // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> -// Copyright (C) 2009-2011, 2013-2015 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2009-2011, 2013-2015, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012, 2014 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2012 Lu Wang <coolwanglu@gmail.com> // Copyright (C) 2014 Till Kamppeter <till.kamppeter@gmail.com> @@ -67,10 +67,10 @@ #include "Catalog.h" #include "Page.h" #include "Stream.h" -#if ENABLE_ZLIB +#ifdef ENABLE_ZLIB # include "FlateEncoder.h" #endif -#if ENABLE_ZLIB_UNCOMPRESS +#ifdef ENABLE_ZLIB_UNCOMPRESS # include "FlateStream.h" #endif #include "Annot.h" @@ -78,7 +78,7 @@ #include "PreScanOutputDev.h" #include "FileSpec.h" #include "CharCodeToUnicode.h" -#if HAVE_SPLASH +#ifdef HAVE_SPLASH # include "splash/Splash.h" # include "splash/SplashBitmap.h" # include "SplashOutputDev.h" @@ -989,16 +989,16 @@ public: DeviceNRecoder(Stream *strA, int widthA, int heightA, GfxImageColorMap *colorMapA); - virtual ~DeviceNRecoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() + ~DeviceNRecoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx++]; } - virtual int lookChar() + int lookChar() override { return (bufIdx >= bufSize && !fillBuf()) ? EOF : buf[bufIdx]; } - virtual GooString *getPSFilter(int psLevel, const char *indent) { return NULL; } - virtual GBool isBinary(GBool last = gTrue) { return gTrue; } - virtual GBool isEncoder() { return gTrue; } + GooString *getPSFilter(int psLevel, const char *indent) override { return NULL; } + GBool isBinary(GBool last = gTrue) override { return gTrue; } + GBool isEncoder() override { return gTrue; } private: @@ -1259,6 +1259,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, rasterMono = gFalse; rasterResolution = 300; uncompressPreloadedImages = gFalse; + psCenter = gTrue; rasterAntialias = gFalse; displayText = gTrue; ok = gTrue; @@ -1287,7 +1288,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, inUncoloredPattern = gFalse; t3FillColorOnly = gFalse; -#if OPI_SUPPORT +#ifdef OPI_SUPPORT // initialize OPI nesting levels opi13Nest = 0; opi20Nest = 0; @@ -1311,7 +1312,6 @@ void PSOutputDev::postInit() Catalog *catalog; PDFRectangle *box; PSOutPaperSize *size; - GooList *names; int w, h, i; if (postInitDone || !ok) { @@ -1405,11 +1405,6 @@ void PSOutputDev::postInit() for (i = 0; i < 14; ++i) { fontNames->add(new GooString(psBase14SubstFonts[i].psName), 1); } - names = globalParams->getPSResidentFonts(); - for (i = 0; i < names->getLength(); ++i) { - fontNames->add((GooString *)names->get(i), 1); - } - delete names; t1FontNameSize = 64; t1FontNameLen = 0; t1FontNames = (PST1FontName *)gmallocn(t1FontNameSize, sizeof(PST1FontName)); @@ -1533,7 +1528,6 @@ PSOutputDev::~PSOutputDev() { void PSOutputDev::writeHeader(const std::vector<int> &pages, PDFRectangle *mediaBox, PDFRectangle *cropBox, int pageRotate, char *psTitle) { - Object info, obj1; PSOutPaperSize *size; double x1, y1, x2, y2; int i; @@ -1550,13 +1544,14 @@ void PSOutputDev::writeHeader(const std::vector<int> &pages, break; } writePSFmt("%Produced by poppler pdftops version: {0:s} (http://poppler.freedesktop.org)\n", PACKAGE_VERSION); - xref->getDocInfo(&info); - if (info.isDict() && info.dictLookup("Creator", &obj1)->isString()) { - writePS("%%Creator: "); - writePSTextLine(obj1.getString()); + Object info = xref->getDocInfo(); + if (info.isDict()) { + Object obj1 = info.dictLookup("Creator"); + if (obj1.isString()) { + writePS("%%Creator: "); + writePSTextLine(obj1.getString()); + } } - obj1.free(); - info.free(); if(psTitle) { char *sanitizedTitle = strdup(psTitle); for (Guint i = 0; i < strlen(sanitizedTitle); ++i) { @@ -1677,9 +1672,7 @@ void PSOutputDev::writeDocSetup(PDFDoc *doc, Catalog *catalog, Dict *resDict; Annots *annots; Object *acroForm; - Object obj1, obj2, obj3; GooString *s; - int i; if (mode == psModeForm) { // swap the form and xpdf dicts @@ -1698,30 +1691,30 @@ void PSOutputDev::writeDocSetup(PDFDoc *doc, Catalog *catalog, setupResources(resDict); } annots = page->getAnnots(); - for (i = 0; i < annots->getNumAnnots(); ++i) { - if (annots->getAnnot(i)->getAppearanceResDict(&obj1)->isDict()) { + for (int i = 0; i < annots->getNumAnnots(); ++i) { + Object obj1 = annots->getAnnot(i)->getAppearanceResDict(); + if (obj1.isDict()) { setupResources(obj1.getDict()); } - obj1.free(); } } if ((acroForm = catalog->getAcroForm()) && acroForm->isDict()) { - if (acroForm->dictLookup("DR", &obj1)->isDict()) { + Object obj1 = acroForm->dictLookup("DR"); + if (obj1.isDict()) { setupResources(obj1.getDict()); } - obj1.free(); - if (acroForm->dictLookup("Fields", &obj1)->isArray()) { - for (i = 0; i < obj1.arrayGetLength(); ++i) { - if (obj1.arrayGet(i, &obj2)->isDict()) { - if (obj2.dictLookup("DR", &obj3)->isDict()) { + obj1 = acroForm->dictLookup("Fields"); + if (obj1.isArray()) { + for (int i = 0; i < obj1.arrayGetLength(); ++i) { + Object obj2 = obj1.arrayGet(i); + if (obj2.isDict()) { + Object obj3 = obj2.dictLookup("DR"); + if (obj3.isDict()) { setupResources(obj3.getDict()); } - obj3.free(); } - obj2.free(); } } - obj1.free(); } if (mode != psModeForm) { if (mode != psModeEPS && !manualCtrl) { @@ -1731,7 +1724,7 @@ void PSOutputDev::writeDocSetup(PDFDoc *doc, Catalog *catalog, writePSFmt("{0:d} {1:d} pdfSetupPaper\n", paperWidth, paperHeight); } } -#if OPI_SUPPORT +#ifdef OPI_SUPPORT if (generateOPI) { writePS("/opiMatrix matrix currentmatrix def\n"); } @@ -1795,24 +1788,22 @@ void PSOutputDev::writeTrailer() { } void PSOutputDev::setupResources(Dict *resDict) { - Object xObjDict, xObjRef, xObj, patDict, patRef, pat, resObj; - Ref ref0; GBool skip; - int i; setupFonts(resDict); setupImages(resDict); setupForms(resDict); //----- recursively scan XObjects - resDict->lookup("XObject", &xObjDict); + Object xObjDict = resDict->lookup("XObject"); if (xObjDict.isDict()) { - for (i = 0; i < xObjDict.dictGetLength(); ++i) { + for (int i = 0; i < xObjDict.dictGetLength(); ++i) { // avoid infinite recursion on XObjects skip = gFalse; - if ((xObjDict.dictGetValNF(i, &xObjRef)->isRef())) { - ref0 = xObjRef.getRef(); + Object xObjRef = xObjDict.dictGetValNF(i); + if (xObjRef.isRef()) { + Ref ref0 = xObjRef.getRef(); if (resourceIDs.find(ref0.num) != resourceIDs.end()) { skip = gTrue; } else { @@ -1822,32 +1813,28 @@ void PSOutputDev::setupResources(Dict *resDict) { if (!skip) { // process the XObject's resource dictionary - xObjDict.dictGetVal(i, &xObj); + Object xObj = xObjDict.dictGetVal(i); if (xObj.isStream()) { - xObj.streamGetDict()->lookup("Resources", &resObj); + Object resObj = xObj.streamGetDict()->lookup("Resources"); if (resObj.isDict()) { setupResources(resObj.getDict()); } - resObj.free(); } - xObj.free(); } - - xObjRef.free(); } } - xObjDict.free(); //----- recursively scan Patterns - resDict->lookup("Pattern", &patDict); + Object patDict = resDict->lookup("Pattern"); if (patDict.isDict()) { inType3Char = gTrue; - for (i = 0; i < patDict.dictGetLength(); ++i) { + for (int i = 0; i < patDict.dictGetLength(); ++i) { // avoid infinite recursion on Patterns skip = gFalse; - if ((patDict.dictGetValNF(i, &patRef)->isRef())) { - ref0 = patRef.getRef(); + Object patRef = patDict.dictGetValNF(i); + if (patRef.isRef()) { + Ref ref0 = patRef.getRef(); if (resourceIDs.find(ref0.num) != resourceIDs.end()) { skip = gTrue; } else { @@ -1857,40 +1844,33 @@ void PSOutputDev::setupResources(Dict *resDict) { if (!skip) { // process the Pattern's resource dictionary - patDict.dictGetVal(i, &pat); + Object pat = patDict.dictGetVal(i); if (pat.isStream()) { - pat.streamGetDict()->lookup("Resources", &resObj); + Object resObj = pat.streamGetDict()->lookup("Resources"); if (resObj.isDict()) { setupResources(resObj.getDict()); } - resObj.free(); } - pat.free(); } - - patRef.free(); } inType3Char = gFalse; } - patDict.free(); } void PSOutputDev::setupFonts(Dict *resDict) { - Object obj1, obj2; Ref r; GfxFontDict *gfxFontDict; GfxFont *font; int i; - gfxFontDict = NULL; - resDict->lookupNF("Font", &obj1); + gfxFontDict = nullptr; + Object obj1 = resDict->lookupNF("Font"); if (obj1.isRef()) { - obj1.fetch(xref, &obj2); + Object obj2 = obj1.fetch(xref); if (obj2.isDict()) { r = obj1.getRef(); gfxFontDict = new GfxFontDict(xref, &r, obj2.getDict()); } - obj2.free(); } else if (obj1.isDict()) { gfxFontDict = new GfxFontDict(xref, NULL, obj1.getDict()); } @@ -1902,7 +1882,6 @@ void PSOutputDev::setupFonts(Dict *resDict) { } delete gfxFontDict; } - obj1.free(); } void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { @@ -2136,14 +2115,12 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { static const char hexChar[17] = "0123456789abcdef"; - Object refObj, strObj, obj1, obj2, obj3; Dict *dict; long length1, length2, length3; - int c; + int c, i; int start[4]; GBool binMode; GBool writePadding = gTrue; - int i; // check if font is already embedded if (fontNames->lookupInt(psName)) { @@ -2152,9 +2129,9 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { fontNames->add(psName->copy(), 1); // get the font stream and info - refObj.initRef(id->num, id->gen); - refObj.fetch(xref, &strObj); - refObj.free(); + Object obj1, obj2, obj3; + Object refObj(id->num, id->gen); + Object strObj = refObj.fetch(xref); if (!strObj.isStream()) { error(errSyntaxError, -1, "Embedded font file object is not a stream"); goto err1; @@ -2164,23 +2141,17 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { "Embedded font stream is missing its dictionary"); goto err1; } - dict->lookup("Length1", &obj1); - dict->lookup("Length2", &obj2); - dict->lookup("Length3", &obj3); + obj1 = dict->lookup("Length1"); + obj2 = dict->lookup("Length2"); + obj3 = dict->lookup("Length3"); if (!obj1.isInt() || !obj2.isInt() || !obj3.isInt()) { error(errSyntaxError, -1, "Missing length fields in embedded font stream dictionary"); - obj1.free(); - obj2.free(); - obj3.free(); goto err1; } length1 = obj1.getInt(); length2 = obj2.getInt(); length3 = obj3.getInt(); - obj1.free(); - obj2.free(); - obj3.free(); // beginning comment writePSFmt("%%BeginResource: font {0:t}\n", psName); @@ -2324,7 +2295,6 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) { err1: if (strObj.isStream()) strObj.streamClose(); - strObj.free(); } void PSOutputDev::setupExternalType1Font(GooString *fileName, GooString *psName) { @@ -2569,6 +2539,14 @@ void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, writePS("%%EndResource\n"); } +void PSOutputDev::updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph) { + if (maxValidGlyph >= 0 && font->getName()) { + if (maxValidGlyph > fontMaxValidGlyph->lookupInt(font->getName())) { + fontMaxValidGlyph->replace(font->getName()->copy(), maxValidGlyph); + } + } +} + void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *fileName, GooString *psName, @@ -2619,9 +2597,7 @@ void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, needVerticalMetrics, &maxValidGlyph, outputFunc, outputStream); - if (maxValidGlyph >= 0 && font->getName()) { - fontMaxValidGlyph->replace(font->getName()->copy(), maxValidGlyph); - } + updateFontMaxValidGlyph(font, maxValidGlyph); } gfree(codeToGID); } else { @@ -2721,9 +2697,7 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, needVerticalMetrics, &maxValidGlyph, outputFunc, outputStream); - if (maxValidGlyph > 0 && font->getName()) { - fontMaxValidGlyph->replace(font->getName()->copy(), maxValidGlyph); - } + updateFontMaxValidGlyph(font, maxValidGlyph); } delete ffTT; } @@ -2796,7 +2770,6 @@ void PSOutputDev::setupType3Font(GfxFont *font, GooString *psName, Dict *parentResDict) { Dict *resDict; Dict *charProcs; - Object charProc; Gfx *gfx; PDFRectangle box; double *m; @@ -2854,8 +2827,8 @@ void PSOutputDev::setupType3Font(GfxFont *font, GooString *psName, writePS("/"); writePSName(charProcs->getKey(i)); writePS(" {\n"); - gfx->display(charProcs->getVal(i, &charProc)); - charProc.free(); + Object charProc = charProcs->getVal(i); + gfx->display(&charProc); if (t3String) { if (t3Cacheable) { buf = GooString::format("{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} setcachedevice\n", @@ -2922,25 +2895,24 @@ GooString *PSOutputDev::makePSFontName(GfxFont *font, Ref *id) { } void PSOutputDev::setupImages(Dict *resDict) { - Object xObjDict, xObj, xObjRef, subtypeObj, maskObj, maskRef; Ref imgID; - int i, j; if (!(mode == psModeForm || inType3Char || preloadImagesForms)) { return; } //----- recursively scan XObjects - resDict->lookup("XObject", &xObjDict); + Object xObjDict = resDict->lookup("XObject"); if (xObjDict.isDict()) { - for (i = 0; i < xObjDict.dictGetLength(); ++i) { - xObjDict.dictGetValNF(i, &xObjRef); - xObjDict.dictGetVal(i, &xObj); + for (int i = 0; i < xObjDict.dictGetLength(); ++i) { + Object xObjRef = xObjDict.dictGetValNF(i); + Object xObj = xObjDict.dictGetVal(i); if (xObj.isStream()) { - xObj.streamGetDict()->lookup("Subtype", &subtypeObj); + Object subtypeObj = xObj.streamGetDict()->lookup("Subtype"); if (subtypeObj.isName("Image")) { if (xObjRef.isRef()) { imgID = xObjRef.getRef(); + int j; for (j = 0; j < imgIDLen; ++j) { if (imgIDs[j].num == imgID.num && imgIDs[j].gen == imgID.gen) { break; @@ -2957,24 +2929,21 @@ void PSOutputDev::setupImages(Dict *resDict) { } imgIDs[imgIDLen++] = imgID; setupImage(imgID, xObj.getStream(), gFalse); - if (level >= psLevel3 && - xObj.streamGetDict()->lookup("Mask", &maskObj)->isStream()) { - setupImage(imgID, maskObj.getStream(), gTrue); + if (level >= psLevel3) { + Object maskObj = xObj.streamGetDict()->lookup("Mask"); + if (maskObj.isStream()) { + setupImage(imgID, maskObj.getStream(), gTrue); + } } - maskObj.free(); } } else { error(errSyntaxError, -1, "Image in resource dict is not an indirect reference"); } } - subtypeObj.free(); } - xObj.free(); - xObjRef.free(); } } - xObjDict.free(); } void PSOutputDev::setupImage(Ref id, Stream *str, GBool mask) { @@ -3017,7 +2986,7 @@ void PSOutputDev::setupImage(Ref id, Stream *str, GBool mask) { if (useCompressed) { str = str->getUndecodedStream(); } -#if ENABLE_ZLIB +#ifdef ENABLE_ZLIB if (useFlate) { str = new FlateEncoder(str); } else @@ -3146,20 +3115,17 @@ void PSOutputDev::setupImage(Ref id, Stream *str, GBool mask) { } void PSOutputDev::setupForms(Dict *resDict) { - Object xObjDict, xObj, xObjRef, subtypeObj; - int i; - if (!preloadImagesForms) { return; } - resDict->lookup("XObject", &xObjDict); + Object xObjDict = resDict->lookup("XObject"); if (xObjDict.isDict()) { - for (i = 0; i < xObjDict.dictGetLength(); ++i) { - xObjDict.dictGetValNF(i, &xObjRef); - xObjDict.dictGetVal(i, &xObj); + for (int i = 0; i < xObjDict.dictGetLength(); ++i) { + Object xObjRef = xObjDict.dictGetValNF(i); + Object xObj = xObjDict.dictGetVal(i); if (xObj.isStream()) { - xObj.streamGetDict()->lookup("Subtype", &subtypeObj); + Object subtypeObj = xObj.streamGetDict()->lookup("Subtype"); if (subtypeObj.isName("Form")) { if (xObjRef.isRef()) { setupForm(xObjRef.getRef(), &xObj); @@ -3168,25 +3134,19 @@ void PSOutputDev::setupForms(Dict *resDict) { "Form in resource dict is not an indirect reference"); } } - subtypeObj.free(); } - xObj.free(); - xObjRef.free(); } } - xObjDict.free(); } void PSOutputDev::setupForm(Ref id, Object *strObj) { Dict *dict, *resDict; - Object matrixObj, bboxObj, resObj, obj1; double m[6], bbox[4]; PDFRectangle box; Gfx *gfx; - int i; // check if form is already defined - for (i = 0; i < formIDLen; ++i) { + for (int i = 0; i < formIDLen; ++i) { if (formIDs[i].num == id.num && formIDs[i].gen == id.gen) { return; } @@ -3206,36 +3166,31 @@ void PSOutputDev::setupForm(Ref id, Object *strObj) { dict = strObj->streamGetDict(); // get bounding box - dict->lookup("BBox", &bboxObj); + Object bboxObj = dict->lookup("BBox"); if (!bboxObj.isArray()) { - bboxObj.free(); error(errSyntaxError, -1, "Bad form bounding box"); return; } - for (i = 0; i < 4; ++i) { - bboxObj.arrayGet(i, &obj1); + for (int i = 0; i < 4; ++i) { + Object obj1 = bboxObj.arrayGet(i); bbox[i] = obj1.getNum(); - obj1.free(); } - bboxObj.free(); // get matrix - dict->lookup("Matrix", &matrixObj); + Object matrixObj = dict->lookup("Matrix"); if (matrixObj.isArray()) { - for (i = 0; i < 6; ++i) { - matrixObj.arrayGet(i, &obj1); + for (int i = 0; i < 6; ++i) { + Object obj1 = matrixObj.arrayGet(i); m[i] = obj1.getNum(); - obj1.free(); } } else { m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 1; m[4] = 0; m[5] = 0; } - matrixObj.free(); // get resources - dict->lookup("Resources", &resObj); + Object resObj = dict->lookup("Resources"); resDict = resObj.isDict() ? resObj.getDict() : (Dict *)NULL; writePSFmt("/f_{0:d}_{1:d} {{\n", id.num, id.gen); @@ -3253,8 +3208,6 @@ void PSOutputDev::setupForm(Ref id, Object *strObj) { writePS("Q\n"); writePS("} def\n"); - - resObj.free(); } GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, @@ -3268,7 +3221,7 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, void *annotDisplayDecideCbkData) { PreScanOutputDev *scan; GBool rasterize; -#if HAVE_SPLASH +#ifdef HAVE_SPLASH GBool useFlate, useLZW; SplashOutputDev *splashOut; SplashColor paperColor; @@ -3276,7 +3229,6 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, GfxState *state; SplashBitmap *bitmap; Stream *str0, *str; - Object obj; Guchar *p; Guchar col[4]; double hDPI2, vDPI2; @@ -3284,10 +3236,10 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, int nStripes, stripeH, stripeY; int c, w, h, x, y, comp, i; int numComps, initialNumComps; -#endif char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null Guchar digit; GBool isGray; +#endif if (!postInitDone) { postInit(); @@ -3307,7 +3259,7 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, return gTrue; } -#if HAVE_SPLASH +#ifdef HAVE_SPLASH // get the rasterization parameters useFlate = getEnableFlate() && level >= psLevel3; useLZW = getEnableLZW(); @@ -3330,7 +3282,7 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, paperColor[0] = 0xff; splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, paperColor, gFalse); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK } else if (level == psLevel1Sep || level == psLevel2Sep || level == psLevel3Sep || globalParams->getOverprintPreview()) { numComps = 4; @@ -3594,9 +3546,8 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, case psLevel2Sep: case psLevel3: case psLevel3Sep: - obj.initNull(); p = bitmap->getDataPtr() + (h - 1) * bitmap->getRowSize(); - str0 = new MemStream((char *)p, 0, w * h * numComps, &obj); + str0 = new MemStream((char *)p, 0, w * h * numComps, Object(objNull)); // Check for a color image that uses only gray if (!getOptimizeColorSpace()) { isGray = gFalse; @@ -3625,7 +3576,7 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/, isGray = gFalse; } str0->reset(); -#if ENABLE_ZLIB +#ifdef ENABLE_ZLIB if (useFlate) { if (isGray && numComps == 4) { str = new FlateEncoder(new CMYKGrayEncoder(str0)); @@ -3884,7 +3835,7 @@ void PSOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { if (tx0 >= 0 && ty0 >= 0) { tx += (rotate == 0 || rotate == 180) ? tx0 : ty0; ty += (rotate == 0 || rotate == 180) ? ty0 : -tx0; - } else if (globalParams->getPSCenter()) { + } else if (psCenter) { if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) { tx += (imgWidth2 - xScale * (clipURX0 - clipLLX0)) / 2; ty += (imgHeight2 - yScale * (clipURY0 - clipLLY0)) / 2; @@ -6117,7 +6068,7 @@ void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap, // end of image dictionary writePS(">>\n"); -#if OPI_SUPPORT +#ifdef OPI_SUPPORT if (opi13Nest) { if (inlineImg) { // this can't happen -- OPI dictionaries are in XObjects @@ -6170,7 +6121,7 @@ void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap, // add newline and trailer to the end writePSChar('\n'); writePS("%-EOD-\n"); -#if OPI_SUPPORT +#ifdef OPI_SUPPORT if (opi13Nest) { writePS("%%EndData\n"); } @@ -6267,7 +6218,7 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap, if (maskUseCompressed) { maskStr = maskStr->getUndecodedStream(); } -#if ENABLE_ZLIB +#ifdef ENABLE_ZLIB if (maskUseFlate) { maskStr = new FlateEncoder(maskStr); } else @@ -6316,7 +6267,7 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap, if (inlineImg) { // create an array str2 = new FixedLengthEncoder(str, len); -#if ENABLE_ZLIB +#ifdef ENABLE_ZLIB if (getEnableFlate()) { str2 = new FlateEncoder(str2); } else @@ -6563,7 +6514,7 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap, } // add FlateEncode/LZWEncode/RunLengthEncode and ASCIIHex/85 encode filters -#if ENABLE_ZLIB +#ifdef ENABLE_ZLIB if (useFlate) { str = new FlateEncoder(str); } else @@ -6878,140 +6829,113 @@ void PSOutputDev::dumpColorSpaceL2(GfxColorSpace *colorSpace, } } -#if OPI_SUPPORT +#ifdef OPI_SUPPORT void PSOutputDev::opiBegin(GfxState *state, Dict *opiDict) { - Object dict; - if (generateOPI) { - opiDict->lookup("2.0", &dict); + Object dict = opiDict->lookup("2.0"); if (dict.isDict()) { opiBegin20(state, dict.getDict()); - dict.free(); } else { - dict.free(); - opiDict->lookup("1.3", &dict); + dict = opiDict->lookup("1.3"); if (dict.isDict()) { opiBegin13(state, dict.getDict()); } - dict.free(); } } } void PSOutputDev::opiBegin20(GfxState *state, Dict *dict) { - Object obj1, obj2, obj3, obj4; double width, height, left, right, top, bottom; int w, h; - int i; writePS("%%BeginOPI: 2.0\n"); writePS("%%Distilled\n"); - dict->lookup("F", &obj1); - if (getFileSpecName(&obj1, &obj2)) { + Object obj1 = dict->lookup("F"); + Object obj2 = getFileSpecName(&obj1); + if (obj2.isString()) { writePSFmt("%%ImageFileName: {0:t}\n", obj2.getString()); - obj2.free(); } - obj1.free(); - dict->lookup("MainImage", &obj1); + obj1 = dict->lookup("MainImage"); if (obj1.isString()) { writePSFmt("%%MainImage: {0:t}\n", obj1.getString()); } - obj1.free(); //~ ignoring 'Tags' entry //~ need to use writePSString() and deal with >255-char lines - dict->lookup("Size", &obj1); + obj1 = dict->lookup("Size"); if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); width = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); height = obj2.getNum(); - obj2.free(); writePSFmt("%%ImageDimensions: {0:.6g} {1:.6g}\n", width, height); } - obj1.free(); - dict->lookup("CropRect", &obj1); + obj1 = dict->lookup("CropRect"); if (obj1.isArray() && obj1.arrayGetLength() == 4) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); left = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); top = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); + obj2 = obj1.arrayGet(2); right = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); + obj2 = obj1.arrayGet(3); bottom = obj2.getNum(); - obj2.free(); writePSFmt("%%ImageCropRect: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", left, top, right, bottom); } - obj1.free(); - dict->lookup("Overprint", &obj1); + obj1 = dict->lookup("Overprint"); if (obj1.isBool()) { writePSFmt("%%ImageOverprint: {0:s}\n", obj1.getBool() ? "true" : "false"); } - obj1.free(); - dict->lookup("Inks", &obj1); + obj1 = dict->lookup("Inks"); if (obj1.isName()) { writePSFmt("%%ImageInks: {0:s}\n", obj1.getName()); } else if (obj1.isArray() && obj1.arrayGetLength() >= 1) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); if (obj2.isName()) { writePSFmt("%%ImageInks: {0:s} {1:d}", obj2.getName(), (obj1.arrayGetLength() - 1) / 2); - for (i = 1; i+1 < obj1.arrayGetLength(); i += 2) { - obj1.arrayGet(i, &obj3); - obj1.arrayGet(i+1, &obj4); + for (int i = 1; i+1 < obj1.arrayGetLength(); i += 2) { + Object obj3 = obj1.arrayGet(i); + Object obj4 = obj1.arrayGet(i+1); if (obj3.isString() && obj4.isNum()) { writePS(" "); writePSString(obj3.getString()); writePSFmt(" {0:.6g}", obj4.getNum()); } - obj3.free(); - obj4.free(); } writePS("\n"); } - obj2.free(); } - obj1.free(); writePS("gsave\n"); writePS("%%BeginIncludedImage\n"); - dict->lookup("IncludedImageDimensions", &obj1); + obj1 = dict->lookup("IncludedImageDimensions"); if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); w = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); h = obj2.getInt(); - obj2.free(); writePSFmt("%%IncludedImageDimensions: {0:d} {1:d}\n", w, h); } - obj1.free(); - dict->lookup("IncludedImageQuality", &obj1); + obj1 = dict->lookup("IncludedImageQuality"); if (obj1.isNum()) { writePSFmt("%%IncludedImageQuality: {0:.6g}\n", obj1.getNum()); } - obj1.free(); ++opi20Nest; } void PSOutputDev::opiBegin13(GfxState *state, Dict *dict) { - Object obj1, obj2; int left, right, top, bottom, samples, bits, width, height; double c, m, y, k; double llx, lly, ulx, uly, urx, ury, lrx, lry; @@ -7023,86 +6947,68 @@ void PSOutputDev::opiBegin13(GfxState *state, Dict *dict) { writePS("/opiMatrix2 matrix currentmatrix def\n"); writePS("opiMatrix setmatrix\n"); - dict->lookup("F", &obj1); - if (getFileSpecName(&obj1, &obj2)) { + Object obj1 = dict->lookup("F"); + Object obj2 = getFileSpecName(&obj1); + if (obj2.isString()) { writePSFmt("%ALDImageFileName: {0:t}\n", obj2.getString()); - obj2.free(); } - obj1.free(); - dict->lookup("CropRect", &obj1); + obj1 = dict->lookup("CropRect"); if (obj1.isArray() && obj1.arrayGetLength() == 4) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); left = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); top = obj2.getInt(); - obj2.free(); - obj1.arrayGet(2, &obj2); + obj2 = obj1.arrayGet(2); right = obj2.getInt(); - obj2.free(); - obj1.arrayGet(3, &obj2); + obj2 = obj1.arrayGet(3); bottom = obj2.getInt(); - obj2.free(); writePSFmt("%ALDImageCropRect: {0:d} {1:d} {2:d} {3:d}\n", left, top, right, bottom); } - obj1.free(); - dict->lookup("Color", &obj1); + obj1 = dict->lookup("Color"); if (obj1.isArray() && obj1.arrayGetLength() == 5) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); c = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); m = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); + obj2 = obj1.arrayGet(2); y = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); + obj2 = obj1.arrayGet(3); k = obj2.getNum(); - obj2.free(); - obj1.arrayGet(4, &obj2); + obj2 = obj1.arrayGet(4); if (obj2.isString()) { writePSFmt("%ALDImageColor: {0:.4g} {1:.4g} {2:.4g} {3:.4g} ", c, m, y, k); writePSString(obj2.getString()); writePS("\n"); } - obj2.free(); } - obj1.free(); - dict->lookup("ColorType", &obj1); + obj1 = dict->lookup("ColorType"); if (obj1.isName()) { writePSFmt("%ALDImageColorType: {0:s}\n", obj1.getName()); } - obj1.free(); //~ ignores 'Comments' entry //~ need to handle multiple lines - dict->lookup("CropFixed", &obj1); + obj1 = dict->lookup("CropFixed"); if (obj1.isArray()) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); ulx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); uly = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); + obj2 = obj1.arrayGet(2); lrx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); + obj2 = obj1.arrayGet(3); lry = obj2.getNum(); - obj2.free(); writePSFmt("%ALDImageCropFixed: {0:.6g} {1:.6g} {2:.6g} {3:.6g}\n", ulx, uly, lrx, lry); } - obj1.free(); - dict->lookup("GrayMap", &obj1); + obj1 = dict->lookup("GrayMap"); if (obj1.isArray()) { writePS("%ALDImageGrayMap:"); for (i = 0; i < obj1.arrayGetLength(); i += 16) { @@ -7110,116 +7016,90 @@ void PSOutputDev::opiBegin13(GfxState *state, Dict *dict) { writePS("\n%%+"); } for (j = 0; j < 16 && i+j < obj1.arrayGetLength(); ++j) { - obj1.arrayGet(i+j, &obj2); + obj2 = obj1.arrayGet(i+j); writePSFmt(" {0:d}", obj2.getInt()); - obj2.free(); } } writePS("\n"); } - obj1.free(); - dict->lookup("ID", &obj1); + obj1 = dict->lookup("ID"); if (obj1.isString()) { writePSFmt("%ALDImageID: {0:t}\n", obj1.getString()); } - obj1.free(); - dict->lookup("ImageType", &obj1); + obj1 = dict->lookup("ImageType"); if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); samples = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); bits = obj2.getInt(); - obj2.free(); writePSFmt("%ALDImageType: {0:d} {1:d}\n", samples, bits); } - obj1.free(); - dict->lookup("Overprint", &obj1); + dict->lookup("Overprint"); if (obj1.isBool()) { writePSFmt("%ALDImageOverprint: {0:s}\n", obj1.getBool() ? "true" : "false"); } - obj1.free(); - dict->lookup("Position", &obj1); + obj1 = dict->lookup("Position"); if (obj1.isArray() && obj1.arrayGetLength() == 8) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); llx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); lly = obj2.getNum(); - obj2.free(); - obj1.arrayGet(2, &obj2); + obj2 = obj1.arrayGet(2); ulx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(3, &obj2); + obj2 = obj1.arrayGet(3); uly = obj2.getNum(); - obj2.free(); - obj1.arrayGet(4, &obj2); + obj2 = obj1.arrayGet(4); urx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(5, &obj2); + obj2 = obj1.arrayGet(5); ury = obj2.getNum(); - obj2.free(); - obj1.arrayGet(6, &obj2); + obj2 = obj1.arrayGet(6); lrx = obj2.getNum(); - obj2.free(); - obj1.arrayGet(7, &obj2); + obj2 = obj1.arrayGet(7); lry = obj2.getNum(); - obj2.free(); opiTransform(state, llx, lly, &tllx, &tlly); opiTransform(state, ulx, uly, &tulx, &tuly); opiTransform(state, urx, ury, &turx, &tury); opiTransform(state, lrx, lry, &tlrx, &tlry); writePSFmt("%ALDImagePosition: {0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g} {6:.6g} {7:.6g}\n", tllx, tlly, tulx, tuly, turx, tury, tlrx, tlry); - obj2.free(); } - obj1.free(); - dict->lookup("Resolution", &obj1); + obj1 = dict->lookup("Resolution"); if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); horiz = obj2.getNum(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); vert = obj2.getNum(); - obj2.free(); writePSFmt("%ALDImageResoution: {0:.6g} {1:.6g}\n", horiz, vert); - obj2.free(); } - obj1.free(); - dict->lookup("Size", &obj1); + obj1 = dict->lookup("Size"); if (obj1.isArray() && obj1.arrayGetLength() == 2) { - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); width = obj2.getInt(); - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); height = obj2.getInt(); - obj2.free(); writePSFmt("%ALDImageDimensions: {0:d} {1:d}\n", width, height); } - obj1.free(); //~ ignoring 'Tags' entry //~ need to use writePSString() and deal with >255-char lines - dict->lookup("Tint", &obj1); + obj1 = dict->lookup("Tint"); if (obj1.isNum()) { writePSFmt("%ALDImageTint: {0:.6g}\n", obj1.getNum()); } - obj1.free(); - dict->lookup("Transparency", &obj1); + obj1 = dict->lookup("Transparency"); if (obj1.isBool()) { writePSFmt("%ALDImageTransparency: {0:s}\n", obj1.getBool() ? "true" : "false"); } - obj1.free(); writePS("%%BeginObject: image\n"); writePS("opiMatrix2 setmatrix\n"); @@ -7253,25 +7133,20 @@ void PSOutputDev::opiTransform(GfxState *state, double x0, double y0, } void PSOutputDev::opiEnd(GfxState *state, Dict *opiDict) { - Object dict; - if (generateOPI) { - opiDict->lookup("2.0", &dict); + Object dict = opiDict->lookup("2.0"); if (dict.isDict()) { writePS("%%EndIncludedImage\n"); writePS("%%EndOPI\n"); writePS("grestore\n"); --opi20Nest; - dict.free(); } else { - dict.free(); - opiDict->lookup("1.3", &dict); + dict = opiDict->lookup("1.3"); if (dict.isDict()) { writePS("%%EndObject\n"); writePS("restore\n"); --opi13Nest; } - dict.free(); } } } diff --git a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h index 072608a0a02..fd1bea17b06 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/PSOutputDev.h @@ -15,14 +15,14 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2006-2008, 2012, 2013, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2008, 2012, 2013, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007 Brad Hards <bradh@kde.org> // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009, 2011, 2015-2016 William Bader <williambader@hotmail.com> +// Copyright (C) 2009, 2011, 2015-2017 William Bader <williambader@hotmail.com> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> -// Copyright (C) 2011, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2011, 2014, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // // To see a description of the changes please see the Changelog file that @@ -134,31 +134,31 @@ public: // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gFalse; } + GBool upsideDown() override { return gFalse; } // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gFalse; } + GBool useDrawChar() override { return gFalse; } // Does this device use tilingPatternFill()? If this returns false, // tiling pattern fills will be reduced to a series of other drawing // operations. - virtual GBool useTilingPatternFill() { return gTrue; } + GBool useTilingPatternFill() override { return gTrue; } // Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. - virtual GBool useShadedFills(int type) + GBool useShadedFills(int type) override { return type < 4 && level >= psLevel2; } // Does this device use drawForm()? If this returns false, // form-type XObjects will be interpreted (i.e., unrolled). - virtual GBool useDrawForm() { return preloadImagesForms; } + GBool useDrawForm() override { return preloadImagesForms; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gFalse; } + GBool interpretType3Chars() override { return gFalse; } - virtual GBool needClipToCropBox() { return mode == psModeEPS; } + GBool needClipToCropBox() override { return mode == psModeEPS; } //----- header/trailer (used only if manualCtrl is true) @@ -182,115 +182,115 @@ public: // returns false, the page display is aborted. Typically, an // OutputDev will use some alternate means to display the page // before returning false. - virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI, + GBool checkPageSlice(Page *page, double hDPI, double vDPI, int rotate, GBool useMediaBox, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, GBool printing, GBool (*abortCheckCbk)(void *data) = NULL, void *abortCheckCbkData = NULL, GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL, - void *annotDisplayDecideCbkData = NULL); + void *annotDisplayDecideCbkData = NULL) override; // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef *xref); + void startPage(int pageNum, GfxState *state, XRef *xref) override; // End a page. - virtual void endPage(); + void endPage() override; //----- save/restore graphics state - virtual void saveState(GfxState *state); - virtual void restoreState(GfxState *state); + void saveState(GfxState *state) override; + void restoreState(GfxState *state) override; //----- update graphics state - virtual void updateCTM(GfxState *state, double m11, double m12, - double m21, double m22, double m31, double m32); - virtual void updateLineDash(GfxState *state); - virtual void updateFlatness(GfxState *state); - virtual void updateLineJoin(GfxState *state); - virtual void updateLineCap(GfxState *state); - virtual void updateMiterLimit(GfxState *state); - virtual void updateLineWidth(GfxState *state); - virtual void updateFillColorSpace(GfxState *state); - virtual void updateStrokeColorSpace(GfxState *state); - virtual void updateFillColor(GfxState *state); - virtual void updateStrokeColor(GfxState *state); - virtual void updateFillOverprint(GfxState *state); - virtual void updateStrokeOverprint(GfxState *state); - virtual void updateOverprintMode(GfxState *state); - virtual void updateTransfer(GfxState *state); + void updateCTM(GfxState *state, double m11, double m12, + double m21, double m22, double m31, double m32) override; + void updateLineDash(GfxState *state) override; + void updateFlatness(GfxState *state) override; + void updateLineJoin(GfxState *state) override; + void updateLineCap(GfxState *state) override; + void updateMiterLimit(GfxState *state) override; + void updateLineWidth(GfxState *state) override; + void updateFillColorSpace(GfxState *state) override; + void updateStrokeColorSpace(GfxState *state) override; + void updateFillColor(GfxState *state) override; + void updateStrokeColor(GfxState *state) override; + void updateFillOverprint(GfxState *state) override; + void updateStrokeOverprint(GfxState *state) override; + void updateOverprintMode(GfxState *state) override; + void updateTransfer(GfxState *state) override; //----- update text state - virtual void updateFont(GfxState *state); - virtual void updateTextMat(GfxState *state); - virtual void updateCharSpace(GfxState *state); - virtual void updateRender(GfxState *state); - virtual void updateRise(GfxState *state); - virtual void updateWordSpace(GfxState *state); - virtual void updateHorizScaling(GfxState *state); - virtual void updateTextPos(GfxState *state); - virtual void updateTextShift(GfxState *state, double shift); - virtual void saveTextPos(GfxState *state); - virtual void restoreTextPos(GfxState *state); + void updateFont(GfxState *state) override; + void updateTextMat(GfxState *state) override; + void updateCharSpace(GfxState *state) override; + void updateRender(GfxState *state) override; + void updateRise(GfxState *state) override; + void updateWordSpace(GfxState *state) override; + void updateHorizScaling(GfxState *state) override; + void updateTextPos(GfxState *state) override; + void updateTextShift(GfxState *state, double shift) override; + void saveTextPos(GfxState *state) override; + void restoreTextPos(GfxState *state) override; //----- path painting - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); - virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, + void stroke(GfxState *state) override; + void fill(GfxState *state) override; + void eoFill(GfxState *state) override; + GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, - double xStep, double yStep); - virtual GBool functionShadedFill(GfxState *state, - GfxFunctionShading *shading); - virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/); - virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/); + double xStep, double yStep) override; + GBool functionShadedFill(GfxState *state, + GfxFunctionShading *shading) override; + GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double /*tMin*/, double /*tMax*/) override; + GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double /*sMin*/, double /*sMax*/) override; //----- path clipping - virtual void clip(GfxState *state); - virtual void eoClip(GfxState *state); - virtual void clipToStrokePath(GfxState *state); + void clip(GfxState *state) override; + void eoClip(GfxState *state) override; + void clipToStrokePath(GfxState *state) override; //----- text drawing - virtual void drawString(GfxState *state, GooString *s); - virtual void beginTextObject(GfxState *state); - virtual void endTextObject(GfxState *state); + void drawString(GfxState *state, GooString *s) override; + void beginTextObject(GfxState *state) override; + void endTextObject(GfxState *state) override; //----- image drawing - virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, + void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool interpolate, GBool inlineImg); - virtual void setSoftMaskFromImageMask(GfxState *state, + GBool interpolate, GBool inlineImg) override; + void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg, double *baseMatrix); - virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); - virtual void drawImage(GfxState *state, Object *ref, Stream *str, + GBool inlineImg, double *baseMatrix) override; + void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override; + void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, int *maskColors, GBool inlineImg); - virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, + GBool interpolate, int *maskColors, GBool inlineImg) override; + void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, Stream *maskStr, int maskWidth, int maskHeight, - GBool maskInvert, GBool maskInterpolate); + GBool maskInvert, GBool maskInterpolate) override; -#if OPI_SUPPORT +#ifdef OPI_SUPPORT //----- OPI functions - virtual void opiBegin(GfxState *state, Dict *opiDict); - virtual void opiEnd(GfxState *state, Dict *opiDict); + void opiBegin(GfxState *state, Dict *opiDict) override; + void opiEnd(GfxState *state, Dict *opiDict) override; #endif //----- Type 3 font operators - virtual void type3D0(GfxState *state, double wx, double wy); - virtual void type3D1(GfxState *state, double wx, double wy, - double llx, double lly, double urx, double ury); + void type3D0(GfxState *state, double wx, double wy) override; + void type3D1(GfxState *state, double wx, double wy, + double llx, double lly, double urx, double ury) override; //----- form XObjects - virtual void drawForm(Ref ref); + void drawForm(Ref ref) override; //----- PostScript XObjects - virtual void psXObject(Stream *psStream, Stream *level1Stream); + void psXObject(Stream *psStream, Stream *level1Stream) override; //----- miscellaneous void setOffset(double x, double y) @@ -309,6 +309,7 @@ public: { overlayCbk = cbk; overlayCbkData = data; } void setDisplayText(GBool display) { displayText = display; } + void setPSCenter(GBool center) { psCenter = center; } void setRasterAntialias(GBool a) { rasterAntialias = a; } void setRasterResolution(double r) { rasterResolution = r; } void setRasterMono(GBool b) { rasterMono = b; } @@ -323,7 +324,7 @@ public: GBool getPassLevel1CustomColor() const { return passLevel1CustomColor; } GBool getEnableLZW() const { return enableLZW; }; GBool getEnableFlate() const -#if ENABLE_ZLIB +#ifdef ENABLE_ZLIB { return enableFlate; } #else { return gFalse; } @@ -355,6 +356,7 @@ private: void setupFonts(Dict *resDict); void setupFont(GfxFont *font, Dict *parentResDict); void setupEmbeddedType1Font(Ref *id, GooString *psName); + void updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph); void setupExternalType1Font(GooString *fileName, GooString *psName); void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GooString *psName); void setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GooString *psName); @@ -413,7 +415,7 @@ private: int x0, int y0, int x1, int y1, double xStep, double yStep); -#if OPI_SUPPORT +#ifdef OPI_SUPPORT void opiBegin20(GfxState *state, Dict *dict); void opiBegin13(GfxState *state, Dict *dict); void opiTransform(GfxState *state, double x0, double y0, @@ -526,6 +528,7 @@ private: GBool t3NeedsRestore; // set if a 'q' operator was issued GBool forceRasterize; // forces the page to be rasterized into a image before printing GBool displayText; // displayText + GBool psCenter; // center pages on the paper GBool rasterAntialias; // antialias on rasterize GBool uncompressPreloadedImages; double rasterResolution; // PostScript rasterization resolution (dpi) @@ -550,7 +553,7 @@ private: GBool enableLZW; // enable LZW compression GBool enableFlate; // enable Flate compression -#if OPI_SUPPORT +#ifdef OPI_SUPPORT int opi13Nest; // nesting level of OPI 1.3 objects int opi20Nest; // nesting level of OPI 2.0 objects #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/Page.cc b/Build/source/libs/poppler/poppler-src/poppler/Page.cc index dca52e4faae..ca4a5a6d4d0 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Page.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Page.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2005-2013, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2013, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006-2008 Pino Toscano <pino@kde.org> // Copyright (C) 2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru> // Copyright (C) 2006 Scott Turner <scotty1024@mac.com> @@ -27,7 +27,7 @@ // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Jason Crain <jason@aquaticape.us> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2015 Philipp Reinkemeier <philipp.reinkemeier@offis.de> // // To see a description of the changes please see the Changelog file that @@ -61,7 +61,7 @@ #include "Catalog.h" #include "Form.h" -#if MULTITHREADED +#ifdef MULTITHREADED # define pageLocker() MutexLocker locker(&mutex) #else # define pageLocker() @@ -108,7 +108,7 @@ PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) { cropBox = attrs->cropBox; haveCropBox = attrs->haveCropBox; rotate = attrs->rotate; - attrs->resources.copy(&resources); + resources = attrs->resources.copy(); } else { // set default MediaBox to 8.5" x 11" -- this shouldn't be necessary // but some (non-compliant) PDF files don't specify a MediaBox @@ -119,7 +119,7 @@ PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) { cropBox.x1 = cropBox.y1 = cropBox.x2 = cropBox.y2 = 0; haveCropBox = gFalse; rotate = 0; - resources.initNull(); + resources.setToNull(); } // media box @@ -158,11 +158,10 @@ PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) { readBox(dict, "ArtBox", &artBox); // rotate - dict->lookup("Rotate", &obj1); + obj1 = dict->lookup("Rotate"); if (obj1.isInt()) { rotate = obj1.getInt(); } - obj1.free(); while (rotate < 0) { rotate += 360; } @@ -171,30 +170,21 @@ PageAttrs::PageAttrs(PageAttrs *attrs, Dict *dict) { } // misc attributes - dict->lookup("LastModified", &lastModified); - dict->lookup("BoxColorInfo", &boxColorInfo); - dict->lookup("Group", &group); - dict->lookup("Metadata", &metadata); - dict->lookup("PieceInfo", &pieceInfo); - dict->lookup("SeparationInfo", &separationInfo); + lastModified = dict->lookup("LastModified"); + boxColorInfo = dict->lookup("BoxColorInfo"); + group = dict->lookup("Group"); + metadata = dict->lookup("Metadata"); + pieceInfo = dict->lookup("PieceInfo"); + separationInfo = dict->lookup("SeparationInfo"); // resource dictionary - dict->lookup("Resources", &obj1); + obj1 = dict->lookup("Resources"); if (obj1.isDict()) { - resources.free(); - obj1.copy(&resources); + resources = obj1.copy(); } - obj1.free(); } PageAttrs::~PageAttrs() { - lastModified.free(); - boxColorInfo.free(); - group.free(); - metadata.free(); - pieceInfo.free(); - separationInfo.free(); - resources.free(); } void PageAttrs::clipBoxes() { @@ -210,37 +200,33 @@ GBool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) { Object obj1, obj2; GBool ok; - dict->lookup(key, &obj1); + obj1 = dict->lookup(key); if (obj1.isArray() && obj1.arrayGetLength() == 4) { ok = gTrue; - obj1.arrayGet(0, &obj2); + obj2 = obj1.arrayGet(0); if (obj2.isNum()) { tmp.x1 = obj2.getNum(); } else { ok = gFalse; } - obj2.free(); - obj1.arrayGet(1, &obj2); + obj2 = obj1.arrayGet(1); if (obj2.isNum()) { tmp.y1 = obj2.getNum(); } else { ok = gFalse; } - obj2.free(); - obj1.arrayGet(2, &obj2); + obj2 = obj1.arrayGet(2); if (obj2.isNum()) { tmp.x2 = obj2.getNum(); } else { ok = gFalse; } - obj2.free(); - obj1.arrayGet(3, &obj2); + obj2 = obj1.arrayGet(3); if (obj2.isNum()) { tmp.y2 = obj2.getNum(); } else { ok = gFalse; } - obj2.free(); if (tmp.x1 == 0 && tmp.x2 == 0 && tmp.y1 == 0 && tmp.y2 == 0) ok = gFalse; if (ok) { @@ -255,7 +241,6 @@ GBool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) { } else { ok = gFalse; } - obj1.free(); return ok; } @@ -263,10 +248,8 @@ GBool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) { // Page //------------------------------------------------------------------------ -Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form) { - Object tmp; - -#if MULTITHREADED +Page::Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form) { +#ifdef MULTITHREADED gInitMutex(&mutex); #endif ok = gTrue; @@ -276,7 +259,7 @@ Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attr duration = -1; annots = NULL; - pageObj.initDict(pageDict); + pageObj = pageDict->copy(); pageRef = pageRefA; // get attributes @@ -284,80 +267,68 @@ Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attr attrs->clipBoxes(); // transtion - pageDict->lookupNF("Trans", &trans); + trans = pageDict->dictLookupNF("Trans"); if (!(trans.isRef() || trans.isDict() || trans.isNull())) { error(errSyntaxError, -1, "Page transition object (page {0:d}) is wrong type ({1:s})", num, trans.getTypeName()); - trans.free(); + trans = Object(); } // duration - pageDict->lookupNF("Dur", &tmp); + Object tmp = pageDict->dictLookupNF("Dur"); if (!(tmp.isNum() || tmp.isNull())) { error(errSyntaxError, -1, "Page duration object (page {0:d}) is wrong type ({1:s})", num, tmp.getTypeName()); } else if (tmp.isNum()) { duration = tmp.getNum(); } - tmp.free(); // annotations - pageDict->lookupNF("Annots", &annotsObj); + annotsObj = pageDict->dictLookupNF("Annots"); if (!(annotsObj.isRef() || annotsObj.isArray() || annotsObj.isNull())) { error(errSyntaxError, -1, "Page annotations object (page {0:d}) is wrong type ({1:s})", num, annotsObj.getTypeName()); - annotsObj.free(); goto err2; } // contents - pageDict->lookupNF("Contents", &contents); + contents = pageDict->dictLookupNF("Contents"); if (!(contents.isRef() || contents.isArray() || contents.isNull())) { error(errSyntaxError, -1, "Page contents object (page {0:d}) is wrong type ({1:s})", num, contents.getTypeName()); - contents.free(); goto err1; } // thumb - pageDict->lookupNF("Thumb", &thumb); + thumb = pageDict->dictLookupNF("Thumb"); if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) { error(errSyntaxError, -1, "Page thumb object (page {0:d}) is wrong type ({1:s})", num, thumb.getTypeName()); - thumb.free(); - thumb.initNull(); + thumb.setToNull(); } // actions - pageDict->lookupNF("AA", &actions); + actions = pageDict->dictLookupNF("AA"); if (!(actions.isDict() || actions.isNull())) { error(errSyntaxError, -1, "Page additional action object (page {0:d}) is wrong type ({1:s})", num, actions.getTypeName()); - actions.free(); - actions.initNull(); + actions.setToNull(); } return; - trans.initNull(); err2: - annotsObj.initNull(); + annotsObj.setToNull(); err1: - contents.initNull(); + contents.setToNull(); ok = gFalse; } Page::~Page() { delete attrs; delete annots; - pageObj.free(); - annotsObj.free(); - contents.free(); - trans.free(); - thumb.free(); - actions.free(); -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } @@ -366,6 +337,11 @@ Dict *Page::getResourceDict() { return attrs->getResourceDict(); } +Object *Page::getResourceDictObject() +{ + return attrs->getResourceDictObject(); +} + Dict *Page::getResourceDictCopy(XRef *xrefA) { pageLocker(); Dict *dict = attrs->getResourceDict(); @@ -376,42 +352,32 @@ void Page::replaceXRef(XRef *xrefA) { Object obj1; Dict *pageDict = pageObj.getDict()->copy(xrefA); xref = xrefA; - trans.free(); - pageDict->lookupNF("Trans", &trans); - annotsObj.free(); - pageDict->lookupNF("Annots", &annotsObj); - contents.free(); - pageDict->lookupNF("Contents", &contents); + trans = pageDict->lookupNF("Trans"); + annotsObj = pageDict->lookupNF("Annots"); + contents = pageDict->lookupNF("Contents"); if (contents.isArray()) { - contents.free(); - pageDict->lookupNF("Contents", &obj1)->getArray()->copy(xrefA, &contents); - obj1.free(); - } - thumb.free(); - pageDict->lookupNF("Thumb", &thumb); - actions.free(); - pageDict->lookupNF("AA", &actions); - pageDict->lookup("Resources", &obj1); + obj1 = pageDict->lookupNF("Contents"); + contents = obj1.getArray()->copy(xrefA); + } + thumb = pageDict->lookupNF("Thumb"); + actions = pageDict->lookupNF("AA"); + obj1 = pageDict->lookup("Resources"); if (obj1.isDict()) { - attrs->replaceResource(obj1); + attrs->replaceResource(std::move(obj1)); } - obj1.free(); delete pageDict; } Annots *Page::getAnnots(XRef *xrefA) { if (!annots) { - Object obj; - annots = new Annots(doc, num, getAnnots(&obj, (xrefA == NULL) ? xref : xrefA)); - obj.free(); + Object obj = getAnnotsObject(xrefA); + annots = new Annots(doc, num, &obj); } return annots; } void Page::addAnnot(Annot *annot) { - Object obj1; - Object tmp; Ref annotRef = annot->getRef (); // Make sure we have annots before adding the new one @@ -425,24 +391,22 @@ void Page::addAnnot(Annot *annot) { // page doesn't have annots array, // we have to create it - obj1.initArray(xref); - obj1.arrayAdd(tmp.initRef (annotRef.num, annotRef.gen)); - tmp.free(); + Object obj1 = Object(new Array(xref)); + obj1.arrayAdd(Object(annotRef.num, annotRef.gen)); annotsRef = xref->addIndirectObject (&obj1); - annotsObj.initRef(annotsRef.num, annotsRef.gen); - pageObj.dictSet ("Annots", &annotsObj); + annotsObj = Object(annotsRef.num, annotsRef.gen); + pageObj.dictSet ("Annots", Object(annotsRef.num, annotsRef.gen)); xref->setModifiedObject (&pageObj, pageRef); } else { - getAnnots(&obj1); + Object obj1 = getAnnotsObject(); if (obj1.isArray()) { - obj1.arrayAdd (tmp.initRef (annotRef.num, annotRef.gen)); + obj1.arrayAdd (Object(annotRef.num, annotRef.gen)); if (annotsObj.isRef()) xref->setModifiedObject (&obj1, annotsObj.getRef()); else xref->setModifiedObject (&pageObj, pageRef); } - obj1.free(); } // Popup annots are already handled by markup annots, @@ -464,27 +428,24 @@ void Page::addAnnot(Annot *annot) { void Page::removeAnnot(Annot *annot) { Ref annotRef = annot->getRef(); - Object annArray; pageLocker(); - getAnnots(&annArray); + Object annArray = getAnnotsObject(); if (annArray.isArray()) { int idx = -1; // Get annotation position for (int i = 0; idx == -1 && i < annArray.arrayGetLength(); ++i) { - Object tmp; - if (annArray.arrayGetNF(i, &tmp)->isRef()) { + Object tmp = annArray.arrayGetNF(i); + if (tmp.isRef()) { Ref currAnnot = tmp.getRef(); if (currAnnot.num == annotRef.num && currAnnot.gen == annotRef.gen) { idx = i; } } - tmp.free(); } if (idx == -1) { error(errInternal, -1, "Annotation doesn't belong to this page"); - annArray.free(); return; } annots->removeAnnot(annot); // Gracefully fails on popup windows @@ -497,7 +458,6 @@ void Page::removeAnnot(Annot *annot) { xref->setModifiedObject (&pageObj, pageRef); } } - annArray.free(); annot->removeReferencedObjects(); // Note: Might recurse in removeAnnot again annot->setPage(0, gFalse); } @@ -573,7 +533,6 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI, void *annotDisplayDecideCbkData, GBool copyXRef) { Gfx *gfx; - Object obj; Annots *annotList; int i; @@ -595,7 +554,7 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI, printing, abortCheckCbk, abortCheckCbkData, localXRef); - contents.fetch(localXRef, &obj); + Object obj = contents.fetch(localXRef); if (!obj.isNull()) { gfx->saveState(); gfx->display(&obj); @@ -605,7 +564,6 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI, // OutputDev out->dump(); } - obj.free(); // draw annotations annotList = getAnnots(); @@ -633,15 +591,12 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI, } void Page::display(Gfx *gfx) { - Object obj; - - contents.fetch(xref, &obj); + Object obj = contents.fetch(xref); if (!obj.isNull()) { gfx->saveState(); gfx->display(&obj); gfx->restoreState(); } - obj.free(); } GBool Page::loadThumb(unsigned char **data_out, @@ -650,7 +605,7 @@ GBool Page::loadThumb(unsigned char **data_out, { unsigned int pixbufdatasize; int width, height, bits; - Object obj1, fetched_thumb; + Object obj1; Dict *dict; GfxColorSpace *colorSpace; GBool success = gFalse; @@ -659,9 +614,8 @@ GBool Page::loadThumb(unsigned char **data_out, /* Get stream dict */ pageLocker(); - thumb.fetch(xref, &fetched_thumb); + Object fetched_thumb = thumb.fetch(xref); if (!fetched_thumb.isStream()) { - fetched_thumb.free(); return gFalse; } @@ -683,25 +637,21 @@ GBool Page::loadThumb(unsigned char **data_out, pixbufdatasize = width * height * 3; /* Get color space */ - dict->lookup ("ColorSpace", &obj1); + obj1 = dict->lookup ("ColorSpace"); if (obj1.isNull ()) { - obj1.free (); - dict->lookup ("CS", &obj1); + obj1 = dict->lookup ("CS"); } colorSpace = GfxColorSpace::parse(NULL, &obj1, NULL, NULL); - obj1.free(); if (!colorSpace) { fprintf (stderr, "Error: Cannot parse color space\n"); goto fail1; } - dict->lookup("Decode", &obj1); + obj1 = dict->lookup("Decode"); if (obj1.isNull()) { - obj1.free(); - dict->lookup("D", &obj1); + obj1 = dict->lookup("D"); } colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); - obj1.free(); if (!colorMap->isOk()) { fprintf (stderr, "Error: invalid colormap\n"); delete colorMap; @@ -744,8 +694,6 @@ GBool Page::loadThumb(unsigned char **data_out, delete colorMap; fail1: - fetched_thumb.free(); - return success; } @@ -842,21 +790,16 @@ void Page::getDefaultCTM(double *ctm, double hDPI, double vDPI, } LinkAction* Page::getAdditionalAction(PageAdditionalActionsType type) { - Object additionalActionsObject; - LinkAction *linkAction = NULL; - - if (actions.fetch(doc->getXRef(), &additionalActionsObject)->isDict()) { + LinkAction *linkAction = nullptr; + Object additionalActionsObject = actions.fetch(doc->getXRef()); + if (additionalActionsObject.isDict()) { const char *key = (type == actionOpenPage ? "O" : type == actionClosePage ? "C" : NULL); - Object actionObject; - - if (additionalActionsObject.dictLookup(key, &actionObject)->isDict()) + Object actionObject = additionalActionsObject.dictLookup(key); + if (actionObject.isDict()) linkAction = LinkAction::parseAction(&actionObject, doc->getCatalog()->getBaseURI()); - actionObject.free(); } - additionalActionsObject.free(); - return linkAction; } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Page.h b/Build/source/libs/poppler/poppler-src/poppler/Page.h index 2aaabae9b16..97b70a0cb02 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Page.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Page.h @@ -20,9 +20,9 @@ // Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2008 Iñigo MartÃnez <inigomartinez@gmail.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -107,8 +107,10 @@ public: ? separationInfo.getDict() : (Dict *)NULL; } Dict *getResourceDict() { return resources.isDict() ? resources.getDict() : (Dict *)NULL; } - void replaceResource(Object obj1) - { resources.free(); obj1.copy(&resources); } + Object *getResourceDictObject() + { return &resources; } + void replaceResource(Object &&obj1) + { resources = std::move(obj1); } // Clip all other boxes to the MediaBox. void clipBoxes(); @@ -141,7 +143,7 @@ class Page { public: // Constructor. - Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form); + Page(PDFDoc *docA, int numA, Object *pageDict, Ref pageRefA, PageAttrs *attrsA, Form *form); // Destructor. ~Page(); @@ -177,10 +179,11 @@ public: // Get resource dictionary. Dict *getResourceDict(); + Object *getResourceDictObject(); Dict *getResourceDictCopy(XRef *xrefA); // Get annotations array. - Object *getAnnots(Object *obj, XRef *xrefA = NULL) { return annotsObj.fetch((xrefA == NULL) ? xref : xrefA, obj); } + Object getAnnotsObject(XRef *xrefA = nullptr) { return annotsObj.fetch(xrefA ? xrefA : xref); } // Add a new annotation to the page void addAnnot(Annot *annot); // Remove an existing annotation from the page @@ -193,14 +196,14 @@ public: Annots *getAnnots(XRef *xrefA = NULL); // Get contents. - Object *getContents(Object *obj) { return contents.fetch(xref, obj); } + Object getContents() { return contents.fetch(xref); } // Get thumb. - Object *getThumb(Object *obj) { return thumb.fetch(xref, obj); } + Object getThumb() { return thumb.fetch(xref); } GBool loadThumb(unsigned char **data, int *width, int *height, int *rowstride); // Get transition. - Object *getTrans(Object *obj) { return trans.fetch(xref, obj); } + Object getTrans() { return trans.fetch(xref); } // Get form. FormPageWidgets *getFormWidgets(); @@ -211,7 +214,7 @@ public: double getDuration() { return duration; } // Get actions - Object *getActions(Object *obj) { return actions.fetch(xref, obj); } + Object getActions() { return actions.fetch(xref); } enum PageAdditionalActionsType { actionOpenPage, ///< Performed when opening the page @@ -279,7 +282,7 @@ private: Object actions; // page additional actions double duration; // page duration GBool ok; // true if page is valid -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/PageLabelInfo.cc b/Build/source/libs/poppler/poppler-src/poppler/PageLabelInfo.cc index 3153377f6d3..d771024bbb3 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PageLabelInfo.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/PageLabelInfo.cc @@ -3,7 +3,7 @@ // This file is under the GPLv2 or later license // // Copyright (C) 2005-2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005, 2009, 2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2009, 2013, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2011 Simon Kellner <kellner@kit.edu> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // @@ -22,10 +22,9 @@ #include "PageLabelInfo_p.h" PageLabelInfo::Interval::Interval(Object *dict, int baseA) { - Object obj; - style = None; - if (dict->dictLookup("S", &obj)->isName()) { + Object obj = dict->dictLookup("S"); + if (obj.isName()) { if (obj.isName("D")) { style = Arabic; } else if (obj.isName("R")) { @@ -38,19 +37,18 @@ PageLabelInfo::Interval::Interval(Object *dict, int baseA) { style = LowercaseLatin; } } - obj.free(); - if (dict->dictLookup("P", &obj)->isString()) + obj = dict->dictLookup("P"); + if (obj.isString()) prefix = obj.getString()->copy(); else prefix = new GooString(""); - obj.free(); - if (dict->dictLookup("St", &obj)->isInt()) + obj = dict->dictLookup("St"); + if (obj.isInt()) first = obj.getInt(); else first = 1; - obj.free(); base = baseA; } @@ -86,40 +84,32 @@ PageLabelInfo::~PageLabelInfo() { } void PageLabelInfo::parse(Object *tree) { - Object nums, obj; - Object kids, kid, limits, low, high; - int i, base; - Interval *interval; - // leaf node - if (tree->dictLookup("Nums", &nums)->isArray()) { - for (i = 0; i < nums.arrayGetLength(); i += 2) { - if (!nums.arrayGet(i, &obj)->isInt()) { - obj.free(); + Object nums = tree->dictLookup("Nums"); + if (nums.isArray()) { + for (int i = 0; i < nums.arrayGetLength(); i += 2) { + Object obj = nums.arrayGet(i); + if (!obj.isInt()) { continue; } - base = obj.getInt(); - obj.free(); - if (!nums.arrayGet(i + 1, &obj)->isDict()) { - obj.free(); + int base = obj.getInt(); + obj = nums.arrayGet(i + 1); + if (!obj.isDict()) { continue; } - interval = new Interval(&obj, base); - obj.free(); - intervals.append(interval); + intervals.append(new Interval(&obj, base)); } } - nums.free(); - if (tree->dictLookup("Kids", &kids)->isArray()) { - for (i = 0; i < kids.arrayGetLength(); ++i) { - if (kids.arrayGet(i, &kid)->isDict()) + Object kids = tree->dictLookup("Kids"); + if (kids.isArray()) { + for (int i = 0; i < kids.arrayGetLength(); ++i) { + Object kid = kids.arrayGet(i); + if (kid.isDict()) parse(&kid); - kid.free(); } } - kids.free(); } GBool PageLabelInfo::labelToIndex(GooString *label, int *index) diff --git a/Build/source/libs/poppler/poppler-src/poppler/PageTransition.cc b/Build/source/libs/poppler/poppler-src/poppler/PageTransition.cc index d5a84f89a7b..07a2c65a5f0 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PageTransition.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/PageTransition.cc @@ -1,6 +1,6 @@ /* PageTransition.cc * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2010, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2010, 2017, Albert Astals Cid <aacid@kde.org> * Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> * Copyright (C) 2015, Arseniy Lartsev <arseniy@alumni.chalmers.se> * @@ -50,7 +50,8 @@ PageTransition::PageTransition (Object *trans) { dict = trans->getDict(); // get type - if (dict->lookup("S", &obj)->isName()) { + obj = dict->lookup("S"); + if (obj.isName()) { const char *s = obj.getName(); if (strcmp("R", s) == 0) @@ -78,16 +79,16 @@ PageTransition::PageTransition (Object *trans) { else if (strcmp("Fade", s) == 0) type = transitionFade; } - obj.free(); // get duration - if (dict->lookup("D", &obj)->isNum()) { + obj = dict->lookup("D"); + if (obj.isNum()) { duration = obj.getNum(); } - obj.free(); // get alignment - if (dict->lookup("Dm", &obj)->isName()) { + obj = dict->lookup("Dm"); + if (obj.isName()) { const char *dm = obj.getName(); if (strcmp("H", dm) == 0) @@ -95,10 +96,10 @@ PageTransition::PageTransition (Object *trans) { else if (strcmp("V", dm) == 0) alignment = transitionVertical; } - obj.free(); // get direction - if (dict->lookup("M", &obj)->isName()) { + obj = dict->lookup("M"); + if (obj.isName()) { const char *m = obj.getName(); if (strcmp("I", m) == 0) @@ -106,31 +107,30 @@ PageTransition::PageTransition (Object *trans) { else if (strcmp("O", m) == 0) direction = transitionOutward; } - obj.free(); // get angle - if (dict->lookup("Di", &obj)->isInt()) { + obj = dict->lookup("Di"); + if (obj.isInt()) { angle = obj.getInt(); } - obj.free(); - if (dict->lookup("Di", &obj)->isName()) { + obj = dict->lookup("Di"); + if (obj.isName()) { if (strcmp("None", obj.getName()) == 0) angle = 0; } - obj.free(); // get scale - if (dict->lookup("SS", &obj)->isNum()) { + obj = dict->lookup("SS"); + if (obj.isNum()) { scale = obj.getNum(); } - obj.free(); // get rectangular - if (dict->lookup("B", &obj)->isBool()) { + obj = dict->lookup("B"); + if (obj.isBool()) { rectangular = obj.getBool(); } - obj.free(); } PageTransition::~PageTransition() diff --git a/Build/source/libs/poppler/poppler-src/poppler/Parser.cc b/Build/source/libs/poppler/poppler-src/poppler/Parser.cc index 28a54607f5c..4b399028105 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Parser.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Parser.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) 2006, 2009, 201, 2010, 2013, 2014 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2009, 201, 2010, 2013, 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2009 Ilya Gorenbein <igorenbein@finjan.com> // Copyright (C) 2012 Hib Eris <hib@hiberis.nl> @@ -50,50 +50,49 @@ Parser::Parser(XRef *xrefA, Lexer *lexerA, GBool allowStreamsA) { lexer = lexerA; inlineImg = 0; allowStreams = allowStreamsA; - lexer->getObj(&buf1); - lexer->getObj(&buf2); + buf1 = lexer->getObj(); + buf2 = lexer->getObj(); } Parser::~Parser() { - buf1.free(); - buf2.free(); delete lexer; } -Object *Parser::getObj(Object *obj, int recursion) +Object Parser::getObj(int recursion) { - return getObj(obj, gFalse, NULL, cryptRC4, 0, 0, 0, recursion); + return getObj(gFalse, NULL, cryptRC4, 0, 0, 0, recursion); } -Object *Parser::getObj(Object *obj, GBool simpleOnly, +Object Parser::getObj(GBool simpleOnly, Guchar *fileKey, CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, int recursion, GBool strict) { - char *key; + Object obj; Stream *str; - Object obj2; - int num; DecryptStream *decrypt; GooString *s, *s2; int c; // refill buffer after inline image data if (inlineImg == 2) { - buf1.free(); - buf2.free(); - lexer->getObj(&buf1); - lexer->getObj(&buf2); + buf1 = lexer->getObj(); + buf2 = lexer->getObj(); inlineImg = 0; } + if (unlikely(recursion >= recursionLimit)) { + return Object(objError); + } + // array - if (!simpleOnly && likely(recursion < recursionLimit) && buf1.isCmd("[")) { + if (!simpleOnly && buf1.isCmd("[")) { shift(); - obj->initArray(xref); - while (!buf1.isCmd("]") && !buf1.isEOF()) - obj->arrayAdd(getObj(&obj2, gFalse, fileKey, encAlgorithm, keyLength, - objNum, objGen, recursion + 1)); + obj = Object(new Array(xref)); + while (!buf1.isCmd("]") && !buf1.isEOF()) { + Object obj2 = getObj(gFalse, fileKey, encAlgorithm, keyLength, objNum, objGen, recursion + 1); + obj.arrayAdd(std::move(obj2)); + } if (buf1.isEOF()) { error(errSyntaxError, getPos(), "End of file inside array"); if (strict) goto err; @@ -101,9 +100,9 @@ Object *Parser::getObj(Object *obj, GBool simpleOnly, shift(); // dictionary or stream - } else if (!simpleOnly && likely(recursion < recursionLimit) && buf1.isCmd("<<")) { + } else if (!simpleOnly && buf1.isCmd("<<")) { shift(objNum); - obj->initDict(xref); + obj = Object(new Dict(xref)); while (!buf1.isCmd(">>") && !buf1.isEOF()) { if (!buf1.isName()) { error(errSyntaxError, getPos(), "Dictionary key must be a name object"); @@ -111,14 +110,19 @@ Object *Parser::getObj(Object *obj, GBool simpleOnly, shift(); } else { // buf1 might go away in shift(), so construct the key - key = copyString(buf1.getName()); + char *key = copyString(buf1.getName()); shift(); if (buf1.isEOF() || buf1.isError()) { gfree(key); if (strict && buf1.isError()) goto err; break; } - obj->dictAdd(key, getObj(&obj2, gFalse, fileKey, encAlgorithm, keyLength, objNum, objGen, recursion + 1)); + Object obj2 = getObj(gFalse, fileKey, encAlgorithm, keyLength, objNum, objGen, recursion + 1); + if (unlikely(obj2.isError() && recursion + 1 >= recursionLimit)) { + gfree(key); + break; + } + obj.dictAdd(key, std::move(obj2)); } } if (buf1.isEOF()) { @@ -128,13 +132,12 @@ Object *Parser::getObj(Object *obj, GBool simpleOnly, // stream objects are not allowed inside content streams or // object streams if (buf2.isCmd("stream")) { - if (allowStreams && (str = makeStream(obj, fileKey, encAlgorithm, keyLength, + if (allowStreams && (str = makeStream(std::move(obj), fileKey, encAlgorithm, keyLength, objNum, objGen, recursion + 1, strict))) { - obj->initStream(str); + return Object(str); } else { - obj->free(); - obj->initError(); + return Object(objError); } } else { shift(); @@ -142,23 +145,22 @@ Object *Parser::getObj(Object *obj, GBool simpleOnly, // indirect reference or integer } else if (buf1.isInt()) { - num = buf1.getInt(); + const int num = buf1.getInt(); shift(); if (buf1.isInt() && buf2.isCmd("R")) { - obj->initRef(num, buf1.getInt()); + const int gen = buf1.getInt(); shift(); shift(); + return Object(num, gen); } else { - obj->initInt(num); + return Object(num); } // string } else if (buf1.isString() && fileKey) { s = buf1.getString(); s2 = new GooString(); - obj2.initNull(); - decrypt = new DecryptStream(new MemStream(s->getCString(), 0, - s->getLength(), &obj2), + decrypt = new DecryptStream(new MemStream(s->getCString(), 0, s->getLength(), Object(objNull)), fileKey, encAlgorithm, keyLength, objNum, objGen); decrypt->reset(); @@ -166,7 +168,7 @@ Object *Parser::getObj(Object *obj, GBool simpleOnly, s2->append((char)c); } delete decrypt; - obj->initString(s2); + obj = Object(s2); shift(); // simple object @@ -174,25 +176,20 @@ Object *Parser::getObj(Object *obj, GBool simpleOnly, // avoid re-allocating memory for complex objects like strings by // shallow copy of <buf1> to <obj> and nulling <buf1> so that // subsequent buf1.free() won't free this memory - buf1.shallowCopy(obj); - buf1.initNull(); + obj = std::move(buf1); shift(); } return obj; err: - obj->free(); - obj->initError(); - return obj; - + return Object(objError); } -Stream *Parser::makeStream(Object *dict, Guchar *fileKey, +Stream *Parser::makeStream(Object &&dict, Guchar *fileKey, CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, int recursion, GBool strict) { - Object obj; BaseStream *baseStr; Stream *str; Goffset length; @@ -206,16 +203,13 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey, pos = str->getPos(); // get length - dict->dictLookup("Length", &obj, recursion); + Object obj = dict.dictLookup("Length", recursion); if (obj.isInt()) { length = obj.getInt(); - obj.free(); } else if (obj.isInt64()) { length = obj.getInt64(); - obj.free(); } else { error(errSyntaxError, getPos(), "Bad 'Length' attribute in stream"); - obj.free(); if (strict) return NULL; length = 0; } @@ -252,9 +246,7 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey, // shift until we find the proper endstream or we change to another object or reach eof length = lexer->getPos() - pos; if (buf1.isCmd("endstream")) { - obj.initInt64(length); - dict->dictSet("Length", &obj); - obj.free(); + dict.dictSet("Length", Object(length)); } } else { // When building the xref we can't use it so use this @@ -265,7 +257,7 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey, } // make base stream - str = baseStr->makeSubStream(pos, gTrue, length, dict); + str = baseStr->makeSubStream(pos, gTrue, length, std::move(dict)); // handle decryption if (fileKey) { @@ -274,7 +266,7 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey, } // get filters - str = str->addFilters(dict, recursion); + str = str->addFilters(str->getDict(), recursion); return str; } @@ -292,12 +284,12 @@ void Parser::shift(int objNum) { lexer->skipChar(); // skip char after 'ID' command inlineImg = 1; } - buf1.free(); - buf2.shallowCopy(&buf1); + buf1 = std::move(buf2); if (inlineImg > 0) // don't buffer inline image data - buf2.initNull(); - else - lexer->getObj(&buf2, objNum); + buf2.setToNull(); + else { + buf2 = lexer->getObj(objNum); + } } void Parser::shift(const char *cmdA, int objNum) { @@ -313,13 +305,12 @@ void Parser::shift(const char *cmdA, int objNum) { lexer->skipChar(); // skip char after 'ID' command inlineImg = 1; } - buf1.free(); - buf2.shallowCopy(&buf1); + buf1 = std::move(buf2); if (inlineImg > 0) { - buf2.initNull(); + buf2.setToNull(); } else if (buf1.isCmd(cmdA)) { - lexer->getObj(&buf2, objNum); + buf2 = lexer->getObj(objNum); } else { - lexer->getObj(&buf2, cmdA, objNum); + buf2 = lexer->getObj(cmdA, objNum); } } diff --git a/Build/source/libs/poppler/poppler-src/poppler/Parser.h b/Build/source/libs/poppler/poppler-src/poppler/Parser.h index 1ce9445e19d..d27511080a7 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Parser.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Parser.h @@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2006, 2010, 2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2010, 2013, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012 Hib Eris <hib@hiberis.nl> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> @@ -48,13 +48,14 @@ public: // Get the next object from the input stream. If <simpleOnly> is // true, do not parse compound objects (arrays, dictionaries, or // streams). - Object *getObj(Object *obj, GBool simpleOnly = gFalse, + Object getObj(GBool simpleOnly = gFalse, Guchar *fileKey = NULL, CryptAlgorithm encAlgorithm = cryptRC4, int keyLength = 0, int objNum = 0, int objGen = 0, int recursion = 0, GBool strict = gFalse); - Object *getObj(Object *obj, int recursion); + Object getObj(int recursion); + template<typename T> Object getObj(T) = delete; // Get stream. Stream *getStream() { return lexer->getStream(); } @@ -70,7 +71,7 @@ private: Object buf1, buf2; // next two tokens int inlineImg; // set when inline image data is encountered - Stream *makeStream(Object *dict, Guchar *fileKey, + Stream *makeStream(Object &&dict, Guchar *fileKey, CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, int recursion, GBool strict); diff --git a/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.cc b/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.cc index 6018a77b70f..4fa0a44461a 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright (C) 2009 Koji Otani <sho@bbr.jp> -// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009, 2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 Carlos Garcia Campos <carlosgc@gnome.org> // //======================================================================== @@ -110,7 +110,7 @@ class ObjectKey : public PopplerCacheKey { { } - bool operator==(const PopplerCacheKey &key) const + bool operator==(const PopplerCacheKey &key) const override { const ObjectKey *k = static_cast<const ObjectKey*>(&key); return k->num == num && k->gen == gen; @@ -121,14 +121,9 @@ class ObjectKey : public PopplerCacheKey { class ObjectItem : public PopplerCacheItem { public: - ObjectItem(Object *obj) + ObjectItem(Object &&obj) { - obj->copy(&item); - } - - ~ObjectItem() - { - item.free(); + item = std::move(obj); } Object item; @@ -144,20 +139,18 @@ PopplerObjectCache::~PopplerObjectCache() { } Object *PopplerObjectCache::put(const Ref &ref) { - Object obj; - xref->fetch(ref.num, ref.gen, &obj); + Object obj = xref->fetch(ref.num, ref.gen); ObjectKey *key = new ObjectKey(ref.num, ref.gen); - ObjectItem *item = new ObjectItem(&obj); + ObjectItem *item = new ObjectItem(std::move(obj)); cache->put(key, item); - obj.free(); return &item->item; } -Object *PopplerObjectCache::lookup(const Ref &ref, Object *obj) { +Object PopplerObjectCache::lookup(const Ref &ref) { ObjectKey key(ref.num, ref.gen); ObjectItem *item = static_cast<ObjectItem *>(cache->lookup(key)); - return item ? item->item.copy(obj) : obj->initNull(); + return item ? item->item.copy() : Object(objNull); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.h b/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.h index 74010a2fa6b..f9d8a1dc9b6 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.h +++ b/Build/source/libs/poppler/poppler-src/poppler/PopplerCache.h @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright (C) 2009 Koji Otani <sho@bbr.jp> -// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009, 2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 Carlos Garcia Campos <carlosgc@gnome.org> // //======================================================================== @@ -68,7 +68,7 @@ class PopplerObjectCache ~PopplerObjectCache(); Object *put(const Ref &ref); - Object *lookup(const Ref &ref, Object *obj); + Object lookup(const Ref &ref); private: XRef *xref; diff --git a/Build/source/libs/poppler/poppler-src/poppler/PreScanOutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/PreScanOutputDev.h index 50fcbf22f73..a1fd6b5026c 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/PreScanOutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/PreScanOutputDev.h @@ -48,95 +48,95 @@ public: PreScanOutputDev(PDFDoc *docA); // Destructor. - virtual ~PreScanOutputDev(); + ~PreScanOutputDev(); //----- get info about output device // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gTrue; } + GBool upsideDown() override { return gTrue; } // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gTrue; } + GBool useDrawChar() override { return gTrue; } // Does this device use tilingPatternFill()? If this returns false, // tiling pattern fills will be reduced to a series of other drawing // operations. - virtual GBool useTilingPatternFill() { return gTrue; } + GBool useTilingPatternFill() override { return gTrue; } // Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. - virtual GBool useShadedFills(int type) { return gTrue; } + GBool useShadedFills(int type) override { return gTrue; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gTrue; } + GBool interpretType3Chars() override { return gTrue; } //----- initialization and control // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef *xref); + void startPage(int pageNum, GfxState *state, XRef *xref) override; // End a page. - virtual void endPage(); + void endPage() override; //----- path painting - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); - virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, - double *pmat, int paintType, int tilingType, Dict *resDict, - double *mat, double *bbox, - int x0, int y0, int x1, int y1, - double xStep, double yStep); - virtual GBool functionShadedFill(GfxState *state, - GfxFunctionShading *shading); - virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); - virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax); + void stroke(GfxState *state) override; + void fill(GfxState *state) override; + void eoFill(GfxState *state) override; + GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, + double *pmat, int paintType, int tilingType, Dict *resDict, + double *mat, double *bbox, + int x0, int y0, int x1, int y1, + double xStep, double yStep) override; + GBool functionShadedFill(GfxState *state, + GfxFunctionShading *shading) override; + GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override; + GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax) override; //----- path clipping - virtual void clip(GfxState *state); - virtual void eoClip(GfxState *state); + void clip(GfxState *state) override; + void eoClip(GfxState *state) override; //----- text drawing - virtual void beginStringOp(GfxState *state); - virtual void endStringOp(GfxState *state); - virtual GBool beginType3Char(GfxState *state, double x, double y, - double dx, double dy, - CharCode code, Unicode *u, int uLen); - virtual void endType3Char(GfxState *state); + void beginStringOp(GfxState *state) override; + void endStringOp(GfxState *state) override; + GBool beginType3Char(GfxState *state, double x, double y, + double dx, double dy, + CharCode code, Unicode *u, int uLen) override; + void endType3Char(GfxState *state) override; //----- image drawing - virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, - int width, int height, GBool invert, - GBool interpolate, GBool inlineImg); - virtual void drawImage(GfxState *state, Object *ref, Stream *str, - int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, int *maskColors, GBool inlineImg); - virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, int maskWidth, int maskHeight, - GBool maskInvert, GBool maskInterpolate); - virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, - GBool interpolate, - Stream *maskStr, - int maskWidth, int maskHeight, - GfxImageColorMap *maskColorMap, - GBool maskInterpolate); + void drawImageMask(GfxState *state, Object *ref, Stream *str, + int width, int height, GBool invert, + GBool interpolate, GBool inlineImg) override; + void drawImage(GfxState *state, Object *ref, Stream *str, + int width, int height, GfxImageColorMap *colorMap, + GBool interpolate, int *maskColors, GBool inlineImg) override; + void drawMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, int maskWidth, int maskHeight, + GBool maskInvert, GBool maskInterpolate) override; + void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, + int width, int height, + GfxImageColorMap *colorMap, + GBool interpolate, + Stream *maskStr, + int maskWidth, int maskHeight, + GfxImageColorMap *maskColorMap, + GBool maskInterpolate) override; //----- transparency groups and soft masks - virtual void beginTransparencyGroup(GfxState *state, double *bbox, - GfxColorSpace *blendingColorSpace, - GBool isolated, GBool knockout, - GBool forSoftMask); - virtual void paintTransparencyGroup(GfxState *state, double *bbox); - virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, - Function *transferFunc, GfxColor *backdropColor); + void beginTransparencyGroup(GfxState *state, double *bbox, + GfxColorSpace *blendingColorSpace, + GBool isolated, GBool knockout, + GBool forSoftMask) override; + void paintTransparencyGroup(GfxState *state, double *bbox) override; + void setSoftMask(GfxState *state, double *bbox, GBool alpha, + Function *transferFunc, GfxColor *backdropColor) override; //----- special access diff --git a/Build/source/libs/poppler/poppler-src/poppler/Rendition.cc b/Build/source/libs/poppler/poppler-src/poppler/Rendition.cc index c040bf2b4a8..89bf1a50cf5 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Rendition.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Rendition.cc @@ -7,6 +7,7 @@ // Pino Toscano <pino@kde.org> (c) 2008 // Carlos Garcia Campos <carlosgc@gnome.org> (c) 2010 // Tobias Koenig <tobias.koenig@kdab.com> (c) 2012 +// Albert Astals Cid <aacid@kde.org> (C) 2017 // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -44,26 +45,26 @@ MediaWindowParameters::~MediaWindowParameters() { } void MediaWindowParameters::parseFWParams(Object* obj) { - Object tmp; - - if (obj->dictLookup("D", &tmp)->isArray()) { + Object tmp = obj->dictLookup("D"); + if (tmp.isArray()) { Array * dim = tmp.getArray(); if (dim->getLength() >= 2) { - Object dd; - if (dim->get(0, &dd)->isInt()) { + Object dd = dim->get(0); + if (dd.isInt()) { width = dd.getInt(); } - dd.free(); - if (dim->get(1, &dd)->isInt()) { + + dd = dim->get(1); + if (dd.isInt()) { height = dd.getInt(); } - dd.free(); + } } - tmp.free(); - if (obj->dictLookup("RT", &tmp)->isInt()) { + tmp = obj->dictLookup("RT"); + if (tmp.isInt()) { int t = tmp.getInt(); switch(t) { case 0: relativeTo = windowRelativeToDocument; break; @@ -71,9 +72,9 @@ void MediaWindowParameters::parseFWParams(Object* obj) { case 2: relativeTo = windowRelativeToDesktop; break; } } - tmp.free(); - if (obj->dictLookup("P",&tmp)->isInt()) { + tmp = obj->dictLookup("P"); + if (tmp.isInt()) { int t = tmp.getInt(); switch(t) { @@ -115,21 +116,19 @@ void MediaWindowParameters::parseFWParams(Object* obj) { break; } } - tmp.free(); - if (obj->dictLookup("T", &tmp)->isBool()) { + tmp = obj->dictLookup("T"); + if (tmp.isBool()) { hasTitleBar = tmp.getBool(); } - tmp.free(); - if (obj->dictLookup("UC", &tmp)->isBool()) { + tmp = obj->dictLookup("UC"); + if (tmp.isBool()) { hasCloseButton = tmp.getBool(); } - tmp.free(); - if (obj->dictLookup("R", &tmp)->isInt()) { + tmp = obj->dictLookup("R"); + if (tmp.isInt()) { isResizeable = (tmp.getInt() != 0); } - tmp.free(); - } MediaParameters::MediaParameters() { @@ -148,20 +147,18 @@ MediaParameters::~MediaParameters() { } void MediaParameters::parseMediaPlayParameters(Object* obj) { - - Object tmp; - - if (obj->dictLookup("V", &tmp)->isInt()) { + Object tmp = obj->dictLookup("V"); + if (tmp.isInt()) { volume = tmp.getInt(); } - tmp.free(); - if (obj->dictLookup("C", &tmp)->isBool()) { + tmp = obj->dictLookup("C"); + if (tmp.isBool()) { showControls = tmp.getBool(); } - tmp.free(); - if (obj->dictLookup("F", &tmp)->isInt()) { + tmp = obj->dictLookup("F"); + if (tmp.isInt()) { int t = tmp.getInt(); switch(t) { @@ -173,47 +170,42 @@ void MediaParameters::parseMediaPlayParameters(Object* obj) { case 5: fittingPolicy = fittingUndefined; break; } } - tmp.free(); // duration parsing // duration's default value is set to 0, which means : intrinsinc media duration - if (obj->dictLookup("D", &tmp)->isDict()) { - Object oname, ddict, tmp2; - if (tmp.dictLookup("S", &oname)->isName()) { + tmp = obj->dictLookup("D"); + if (tmp.isDict()) { + Object oname = tmp.dictLookup("S"); + if (oname.isName()) { char* name = oname.getName(); if (!strcmp(name, "F")) duration = -1; // infinity else if (!strcmp(name, "T")) { - if (tmp.dictLookup("T", &ddict)->isDict()) { - if (ddict.dictLookup("V", &tmp2)->isNum()) { + Object ddict = tmp.dictLookup("T"); + if (ddict.isDict()) { + Object tmp2 = ddict.dictLookup("V"); + if (tmp2.isNum()) { duration = Gulong(tmp2.getNum()); } - tmp2.free(); } - ddict.free(); } } - oname.free(); } - tmp.free(); - - if (obj->dictLookup("A", &tmp)->isBool()) { + tmp = obj->dictLookup("A"); + if (tmp.isBool()) { autoPlay = tmp.getBool(); } - tmp.free(); - if (obj->dictLookup("RC", &tmp)->isNum()) { + tmp = obj->dictLookup("RC"); + if (tmp.isNum()) { repeatCount = tmp.getNum(); } - tmp.free(); - } void MediaParameters::parseMediaScreenParameters(Object* obj) { - Object tmp; - - if (obj->dictLookup("W", &tmp)->isInt()) { + Object tmp = obj->dictLookup("W"); + if (tmp.isInt()) { int t = tmp.getInt(); switch(t) { @@ -223,102 +215,84 @@ void MediaParameters::parseMediaScreenParameters(Object* obj) { case 3: windowParams.type = MediaWindowParameters::windowEmbedded; break; } } - tmp.free(); // background color - if (obj->dictLookup("B", &tmp)->isArray()) { + tmp = obj->dictLookup("B"); + if (tmp.isArray()) { Array* color = tmp.getArray(); - Object component; - - color->get(0, &component); + Object component = color->get(0); bgColor.r = component.getNum(); - component.free(); - color->get(1, &component); + component = color->get(1); bgColor.g = component.getNum(); - component.free(); - color->get(2, &component); + component = color->get(2); bgColor.b = component.getNum(); - component.free(); } - tmp.free(); - // opacity - if (obj->dictLookup("O", &tmp)->isNum()) { + tmp = obj->dictLookup("O"); + if (tmp.isNum()) { opacity = tmp.getNum(); } - tmp.free(); if (windowParams.type == MediaWindowParameters::windowFloating) { - Object winDict; - if (obj->dictLookup("F",&winDict)->isDict()) { + Object winDict = obj->dictLookup("F"); + if (winDict.isDict()) { windowParams.parseFWParams(&winDict); } - winDict.free(); } } MediaRendition::~MediaRendition() { - if (fileName) - delete fileName; - if (contentType) - delete contentType; - - if (embeddedStream && (!embeddedStream->decRef())) { - delete embeddedStream; - } + delete fileName; + delete contentType; } MediaRendition::MediaRendition(Object* obj) { - Object tmp, tmp2; GBool hasClip = gFalse; ok = gTrue; fileName = NULL; contentType = NULL; isEmbedded = gFalse; - embeddedStream = NULL; // // Parse media clip data // - if (obj->dictLookup("C", &tmp2)->isDict()) { // media clip + Object tmp2 = obj->dictLookup("C"); + if (tmp2.isDict()) { // media clip hasClip = gTrue; - if (tmp2.dictLookup("S", &tmp)->isName()) { + Object tmp = tmp2.dictLookup("S"); + if (tmp.isName()) { if (!strcmp(tmp.getName(), "MCD")) { // media clip data - Object obj1, obj2; - if (tmp2.dictLookup("D", &obj1)->isDict()) { - if (obj1.dictLookup("F", &obj2)->isString()) { + Object obj1 = tmp2.dictLookup("D"); + if (obj1.isDict()) { + Object obj2 = obj1.dictLookup("F"); + if (obj2.isString()) { fileName = obj2.getString()->copy(); } - obj2.free(); - if (obj1.dictLookup("EF", &obj2)->isDict()) { - Object embedded; - if (obj2.dictLookup("F", &embedded)->isStream()) { + obj2 = obj1.dictLookup("EF"); + if (obj2.isDict()) { + Object embedded = obj2.dictLookup("F"); + if (embedded.isStream()) { isEmbedded = gTrue; - embeddedStream = embedded.getStream(); - // "copy" stream - embeddedStream->incRef(); + embeddedStreamObject = embedded.copy(); } - embedded.free(); } - obj2.free(); // TODO: D might be a form XObject too } else { error (errSyntaxError, -1, "Invalid Media Clip Data"); ok = gFalse; } - obj1.free(); // FIXME: ignore CT if D is a form XObject - if (tmp2.dictLookup("CT", &obj1)->isString()) { + obj1 = tmp2.dictLookup("CT"); + if (obj1.isString()) { contentType = obj1.getString()->copy(); } - obj1.free(); } else if (!strcmp(tmp.getName(), "MCS")) { // media clip data // TODO } @@ -326,55 +300,69 @@ MediaRendition::MediaRendition(Object* obj) { error (errSyntaxError, -1, "Invalid Media Clip"); ok = gFalse; } - tmp.free(); } - tmp2.free(); if (!ok) return; // // parse Media Play Parameters - if (obj->dictLookup("P", &tmp2)->isDict()) { // media play parameters - Object params; - if (tmp2.dictLookup("MH", ¶ms)->isDict()) { + tmp2 = obj->dictLookup("P"); + if (tmp2.isDict()) { // media play parameters + Object params = tmp2.dictLookup("MH"); + if (params.isDict()) { MH.parseMediaPlayParameters(¶ms); } - params.free(); - if (tmp2.dictLookup("BE", ¶ms)->isDict()) { + params = tmp2.dictLookup("BE"); + if (params.isDict()) { BE.parseMediaPlayParameters(¶ms); } - params.free(); } else if (!hasClip) { error (errSyntaxError, -1, "Invalid Media Rendition"); ok = gFalse; } - tmp2.free(); // // parse Media Screen Parameters - if (obj->dictLookup("SP", &tmp2)->isDict()) { // media screen parameters - Object params; - if (tmp2.dictLookup("MH", ¶ms)->isDict()) { + tmp2 = obj->dictLookup("SP"); + if (tmp2.isDict()) { // media screen parameters + Object params = tmp2.dictLookup("MH"); + if (params.isDict()) { MH.parseMediaScreenParameters(¶ms); } - params.free(); - if (tmp2.dictLookup("BE", ¶ms)->isDict()) { + params = tmp2.dictLookup("BE"); + if (params.isDict()) { BE.parseMediaScreenParameters(¶ms); } - params.free(); } - tmp2.free(); +} + +MediaRendition::MediaRendition(const MediaRendition &other) { + ok = other.ok; + MH = other.MH; + BE = other.BE; + isEmbedded = other.isEmbedded; + embeddedStreamObject = other.embeddedStreamObject.copy(); + + if (other.contentType) + contentType = other.contentType->copy(); + else + contentType = nullptr; + + if (other.fileName) + fileName = other.fileName->copy(); + else + fileName = nullptr; } void MediaRendition::outputToFile(FILE* fp) { if (!isEmbedded) return; - embeddedStream->reset(); + embeddedStreamObject.streamReset(); while (1) { - int c = embeddedStream->getChar(); + int c = embeddedStreamObject.streamGetChar(); if (c == EOF) break; @@ -383,19 +371,9 @@ void MediaRendition::outputToFile(FILE* fp) { } -MediaRendition *MediaRendition::copy() { - // call default copy constructor - MediaRendition* new_media = new MediaRendition(*this); - - if (contentType) - new_media->contentType = contentType->copy(); - if (fileName) - new_media->fileName = fileName->copy(); - - if (new_media->embeddedStream) - new_media->embeddedStream->incRef(); - - return new_media; +MediaRendition* MediaRendition::copy() +{ + return new MediaRendition(*this); } // TODO: SelectorRendition diff --git a/Build/source/libs/poppler/poppler-src/poppler/Rendition.h b/Build/source/libs/poppler/poppler-src/poppler/Rendition.h index 75bfeff32c9..5a937f2cc5e 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Rendition.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Rendition.h @@ -5,6 +5,7 @@ //--------------------------------------------------------------------------------- // Hugo Mercier <hmercier31[at]gmail.com> (c) 2008 // Carlos Garcia Campos <carlosgc@gnome.org> (c) 2010 +// Albert Astals Cid <aacid@kde.org> (C) 2017 // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -118,6 +119,7 @@ struct MediaParameters { class MediaRendition { public: MediaRendition(Object *obj); + MediaRendition(const MediaRendition &other); ~MediaRendition(); GBool isOk () { return ok; } @@ -129,7 +131,8 @@ class MediaRendition { GooString* getFileName() { return fileName; } GBool getIsEmbedded() { return isEmbedded; } - Stream* getEmbbededStream() { return embeddedStream; } + Stream* getEmbbededStream() { return isEmbedded ? embeddedStreamObject.getStream() : nullptr; } + Object* getEmbbededStreamObject() { return isEmbedded ? &embeddedStreamObject : nullptr; } // write embedded stream to file void outputToFile(FILE*); @@ -148,7 +151,7 @@ class MediaRendition { GooString* contentType; // if it's embedded - Stream* embeddedStream; + Object embeddedStreamObject; // if it's not embedded GooString* fileName; diff --git a/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.cc b/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.cc index 9e0546e39d5..f774ce83771 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.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) 2010, 2012, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2010, 2012, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2014 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2016 Alok Anand <alok4nand@gmail.com> @@ -46,13 +46,12 @@ //------------------------------------------------------------------------ SecurityHandler *SecurityHandler::make(PDFDoc *docA, Object *encryptDictA) { - Object filterObj; SecurityHandler *secHdlr; #ifdef ENABLE_PLUGINS XpdfSecurityHandler *xsh; #endif - encryptDictA->dictLookup("Filter", &filterObj); + Object filterObj = encryptDictA->dictLookup("Filter"); if (filterObj.isName("Standard")) { secHdlr = new StandardSecurityHandler(docA, encryptDictA); } else if (filterObj.isName()) { @@ -72,7 +71,6 @@ SecurityHandler *SecurityHandler::make(PDFDoc *docA, Object *encryptDictA) { "Missing or invalid 'Filter' entry in encryption dictionary"); secHdlr = NULL; } - filterObj.free(); return secHdlr; } @@ -147,13 +145,6 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, Object *encryptDictA): SecurityHandler(docA) { - Object versionObj, revisionObj, lengthObj; - Object ownerKeyObj, userKeyObj, ownerEncObj, userEncObj; - Object permObj, fileIDObj, fileIDObj1; - Object cryptFiltersObj, streamFilterObj, stringFilterObj; - Object cryptFilterObj, cfmObj, cfLengthObj; - Object encryptMetadataObj; - ok = gFalse; fileID = NULL; ownerKey = NULL; @@ -162,21 +153,20 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, userEnc = NULL; fileKeyLength = 0; - encryptDictA->dictLookup("V", &versionObj); - encryptDictA->dictLookup("R", &revisionObj); - encryptDictA->dictLookup("Length", &lengthObj); - encryptDictA->dictLookup("O", &ownerKeyObj); - encryptDictA->dictLookup("U", &userKeyObj); - encryptDictA->dictLookup("OE", &ownerEncObj); - encryptDictA->dictLookup("UE", &userEncObj); - encryptDictA->dictLookup("P", &permObj); + Object versionObj = encryptDictA->dictLookup("V"); + Object revisionObj = encryptDictA->dictLookup("R"); + Object lengthObj = encryptDictA->dictLookup("Length"); + Object ownerKeyObj = encryptDictA->dictLookup("O"); + Object userKeyObj = encryptDictA->dictLookup("U"); + Object ownerEncObj = encryptDictA->dictLookup("OE"); + Object userEncObj = encryptDictA->dictLookup("UE"); + Object permObj = encryptDictA->dictLookup("P"); if (permObj.isInt64()) { unsigned int permUint = permObj.getInt64(); int perms = permUint - UINT_MAX - 1; - permObj.free(); - permObj.initInt(perms); + permObj = Object(perms); } - doc->getXRef()->getTrailerDict()->dictLookup("ID", &fileIDObj); + Object fileIDObj = doc->getXRef()->getTrailerDict()->dictLookup("ID"); if (versionObj.isInt() && revisionObj.isInt() && permObj.isInt() && @@ -210,9 +200,9 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, //~ same) if ((encVersion == 4 || encVersion == 5) && (encRevision == 4 || encRevision == 5 || encRevision == 6)) { - encryptDictA->dictLookup("CF", &cryptFiltersObj); - encryptDictA->dictLookup("StmF", &streamFilterObj); - encryptDictA->dictLookup("StrF", &stringFilterObj); + Object cryptFiltersObj = encryptDictA->dictLookup("CF"); + Object streamFilterObj = encryptDictA->dictLookup("StmF"); + Object stringFilterObj = encryptDictA->dictLookup("StrF"); if (cryptFiltersObj.isDict() && streamFilterObj.isName() && stringFilterObj.isName() && @@ -221,52 +211,43 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, // no encryption on streams or strings encVersion = encRevision = -1; } else { - if (cryptFiltersObj.dictLookup(streamFilterObj.getName(), - &cryptFilterObj)->isDict()) { - cryptFilterObj.dictLookup("CFM", &cfmObj); + Object cryptFilterObj = cryptFiltersObj.dictLookup(streamFilterObj.getName()); + if (cryptFilterObj.isDict()) { + Object cfmObj = cryptFilterObj.dictLookup("CFM"); if (cfmObj.isName("V2")) { encVersion = 2; encRevision = 3; - if (cryptFilterObj.dictLookup("Length", - &cfLengthObj)->isInt()) { + Object cfLengthObj = cryptFilterObj.dictLookup("Length"); + if (cfLengthObj.isInt()) { //~ according to the spec, this should be cfLengthObj / 8 fileKeyLength = cfLengthObj.getInt(); } - cfLengthObj.free(); } else if (cfmObj.isName("AESV2")) { encVersion = 2; encRevision = 3; encAlgorithm = cryptAES; - if (cryptFilterObj.dictLookup("Length", - &cfLengthObj)->isInt()) { + Object cfLengthObj = cryptFilterObj.dictLookup("Length"); + if (cfLengthObj.isInt()) { //~ according to the spec, this should be cfLengthObj / 8 fileKeyLength = cfLengthObj.getInt(); } - cfLengthObj.free(); } else if (cfmObj.isName("AESV3")) { encVersion = 5; // let encRevision be 5 or 6 encAlgorithm = cryptAES256; - if (cryptFilterObj.dictLookup("Length", - &cfLengthObj)->isInt()) { + Object cfLengthObj = cryptFilterObj.dictLookup("Length"); + if (cfLengthObj.isInt()) { //~ according to the spec, this should be cfLengthObj / 8 fileKeyLength = cfLengthObj.getInt(); } - cfLengthObj.free(); } - cfmObj.free(); } - cryptFilterObj.free(); } } - stringFilterObj.free(); - streamFilterObj.free(); - cryptFiltersObj.free(); - if (encryptDictA->dictLookup("EncryptMetadata", - &encryptMetadataObj)->isBool()) { + Object encryptMetadataObj = encryptDictA->dictLookup("EncryptMetadata"); + if (encryptMetadataObj.isBool()) { encryptMetadata = encryptMetadataObj.getBool(); } - encryptMetadataObj.free(); } permFlags = permObj.getInt(); ownerKey = ownerKeyObj.getString()->copy(); @@ -274,12 +255,12 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, if (encVersion >= 1 && encVersion <= 2 && encRevision >= 2 && encRevision <= 3) { if (fileIDObj.isArray()) { - if (fileIDObj.arrayGet(0, &fileIDObj1)->isString()) { + Object fileIDObj1 = fileIDObj.arrayGet(0); + if (fileIDObj1.isString()) { fileID = fileIDObj1.getString()->copy(); } else { fileID = new GooString(); } - fileIDObj1.free(); } else { fileID = new GooString(); } @@ -310,15 +291,6 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, } else { error(errSyntaxError, -1, "Weird encryption info"); } - fileIDObj.free(); - permObj.free(); - userEncObj.free(); - ownerEncObj.free(); - userKeyObj.free(); - ownerKeyObj.free(); - lengthObj.free(); - revisionObj.free(); - versionObj.free(); } StandardSecurityHandler::~StandardSecurityHandler() { @@ -408,7 +380,6 @@ ExternalSecurityHandler::ExternalSecurityHandler(PDFDoc *docA, ExternalSecurityHandler::~ExternalSecurityHandler() { (*xsh->freeDoc)(xsh->handlerData, docData); - encryptDict.free(); } void *ExternalSecurityHandler::makeAuthData(GooString *ownerPassword, diff --git a/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.h b/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.h index c2991c8f375..f363d3f7267 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.h +++ b/Build/source/libs/poppler/poppler-src/poppler/SecurityHandler.h @@ -107,21 +107,21 @@ class StandardSecurityHandler: public SecurityHandler { public: StandardSecurityHandler(PDFDoc *docA, Object *encryptDictA); - virtual ~StandardSecurityHandler(); - - virtual GBool isUnencrypted(); - virtual void *makeAuthData(GooString *ownerPassword, - GooString *userPassword); - virtual void *getAuthData(); - virtual void freeAuthData(void *authData); - virtual GBool authorize(void *authData); - virtual int getPermissionFlags() { return permFlags; } - virtual GBool getOwnerPasswordOk() { return ownerPasswordOk; } - virtual Guchar *getFileKey() { return fileKey; } - virtual int getFileKeyLength() { return fileKeyLength; } - virtual int getEncVersion() { return encVersion; } - virtual int getEncRevision() { return encRevision; } - virtual CryptAlgorithm getEncAlgorithm() { return encAlgorithm; } + ~StandardSecurityHandler(); + + GBool isUnencrypted() override; + void *makeAuthData(GooString *ownerPassword, + GooString *userPassword) override; + void *getAuthData() override; + void freeAuthData(void *authData) override; + GBool authorize(void *authData) override; + int getPermissionFlags() override { return permFlags; } + GBool getOwnerPasswordOk() override { return ownerPasswordOk; } + Guchar *getFileKey() override { return fileKey; } + int getFileKeyLength() override { return fileKeyLength; } + int getEncVersion() override { return encVersion; } + int getEncRevision() override { return encRevision; } + CryptAlgorithm getEncAlgorithm() override { return encAlgorithm; } private: diff --git a/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.cc b/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.cc index 71644e54dc2..bddc45fe258 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.cc @@ -9,6 +9,7 @@ // Copyright 2015, 2016 Albert Astals Cid <aacid@kde.org> // Copyright 2015 Markus KilÃ¥s <digital@markuspage.com> // Copyright 2017 Sebastian Rasmussen <sebras@gmail.com> +// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> // //======================================================================== @@ -47,6 +48,26 @@ char *SignatureHandler::getSignerName() return CERT_GetCommonName(&cert->subject); } +const char * SignatureHandler::getSignerSubjectDN() +{ + if (!CMSSignerInfo) + return nullptr; + + CERTCertificate *cert = NSS_CMSSignerInfo_GetSigningCertificate(CMSSignerInfo, CERT_GetDefaultCertDB()); + if (!cert) + return nullptr; + return cert->subjectName; +} + +HASH_HashType SignatureHandler::getHashAlgorithm() +{ + if (hash_context && hash_context->hashobj) + { + return hash_context->hashobj->type; + } + return HASH_AlgNULL; +} + time_t SignatureHandler::getSigningTime() { PRTime sTime; // time in microseconds since the epoch @@ -54,7 +75,7 @@ time_t SignatureHandler::getSigningTime() if (NSS_CMSSignerInfo_GetSigningTime (CMSSignerInfo, &sTime) != SECSuccess) return 0; - return (time_t) sTime/1000000; + return static_cast<time_t>(sTime/1000000); } @@ -271,7 +292,7 @@ NSSCMSVerificationStatus SignatureHandler::validateSignature() } } -SECErrorCodes SignatureHandler::validateCertificate() +SECErrorCodes SignatureHandler::validateCertificate(time_t validation_time) { SECErrorCodes retVal; CERTCertificate *cert; @@ -282,10 +303,15 @@ SECErrorCodes SignatureHandler::validateCertificate() if ((cert = NSS_CMSSignerInfo_GetSigningCertificate(CMSSignerInfo, CERT_GetDefaultCertDB())) == NULL) CMSSignerInfo->verificationStatus = NSSCMSVS_SigningCertNotFound; - CERTValInParam inParams[2]; + PRTime vTime = 0; // time in microseconds since the epoch, special value 0 means now + if (validation_time > 0) + vTime = 1000000*(PRTime)validation_time; + CERTValInParam inParams[3]; inParams[0].type = cert_pi_revocationFlags; inParams[0].value.pointer.revocation = CERT_GetClassicOCSPEnabledSoftFailurePolicy(); - inParams[1].type = cert_pi_end; + inParams[1].type = cert_pi_date; + inParams[1].value.scalar.time = vTime; + inParams[2].type = cert_pi_end; CERT_PKIXVerifyCert(cert, certificateUsageEmailSigner, inParams, NULL, CMSSignerInfo->cmsg->pwfn_arg); diff --git a/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.h b/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.h index 8e2a4daf968..3b2f62b9709 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.h +++ b/Build/source/libs/poppler/poppler-src/poppler/SignatureHandler.h @@ -6,7 +6,8 @@ // // Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com> // Copyright 2015 André Esser <bepandre@hotmail.com> -// Copyright 2015 Albert Astals Cid <aacid@kde.org> +// Copyright 2015, 2017 Albert Astals Cid <aacid@kde.org> +// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> // //======================================================================== @@ -36,10 +37,13 @@ public: ~SignatureHandler(); time_t getSigningTime(); char * getSignerName(); + const char * getSignerSubjectDN(); + HASH_HashType getHashAlgorithm(); void setSignature(unsigned char *, int); void updateHash(unsigned char * data_block, int data_len); NSSCMSVerificationStatus validateSignature(); - SECErrorCodes validateCertificate(); + // Use -1 as validation_time for now + SECErrorCodes validateCertificate(time_t validation_time); //Translate NSS error codes static SignatureValidationStatus NSS_SigTranslate(NSSCMSVerificationStatus nss_code); diff --git a/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.cc b/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.cc index 8f7ec454df5..7ca8b969c70 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.cc @@ -6,6 +6,8 @@ // // Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com> // Copyright 2015 André Esser <bepandre@hotmail.com> +// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +// Copyright 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -16,13 +18,21 @@ #include <stdlib.h> #include <string.h> +#ifdef ENABLE_NSS3 + #include <hasht.h> +#else + static const int HASH_AlgNULL = -1; +#endif + /* Constructor & Destructor */ SignatureInfo::SignatureInfo() { sig_status = SIGNATURE_NOT_VERIFIED; cert_status = CERTIFICATE_NOT_VERIFIED; - signer_name = NULL; + signer_name = nullptr; + subject_dn = nullptr; + hash_type = HASH_AlgNULL; signing_time = 0; sig_subfilter_supported = false; } @@ -31,7 +41,9 @@ SignatureInfo::SignatureInfo(SignatureValidationStatus sig_val_status, Certifica { sig_status = sig_val_status; cert_status = cert_val_status; - signer_name = NULL; + signer_name = nullptr; + subject_dn = nullptr; + hash_type = HASH_AlgNULL; signing_time = 0; sig_subfilter_supported = false; } @@ -53,11 +65,21 @@ CertificateValidationStatus SignatureInfo::getCertificateValStatus() return cert_status; } -char *SignatureInfo::getSignerName() +const char *SignatureInfo::getSignerName() { return signer_name; } +const char *SignatureInfo::getSubjectDN() +{ + return subject_dn; +} + +int SignatureInfo::getHashAlgorithm() +{ + return hash_type; +} + time_t SignatureInfo::getSigningTime() { return signing_time; @@ -81,6 +103,16 @@ void SignatureInfo::setSignerName(char *signerName) signer_name = signerName; } +void SignatureInfo::setSubjectDN(const char *subjectDN) +{ + subject_dn = subjectDN; +} + +void SignatureInfo::setHashAlgorithm(int type) +{ + hash_type = type; +} + void SignatureInfo::setSigningTime(time_t signingTime) { signing_time = signingTime; diff --git a/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.h b/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.h index 82b4ec4dd49..35e7568ce7e 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.h +++ b/Build/source/libs/poppler/poppler-src/poppler/SignatureInfo.h @@ -6,7 +6,8 @@ // // Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com> // Copyright 2015 André Esser <bepandre@hotmail.com> -// Copyright 2015 Albert Astals Cid <aacid@kde.org> +// Copyright 2015, 2017 Albert Astals Cid <aacid@kde.org> +// Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> // //======================================================================== @@ -46,7 +47,9 @@ public: /* GETTERS */ SignatureValidationStatus getSignatureValStatus(); CertificateValidationStatus getCertificateValStatus(); - char *getSignerName(); + const char *getSignerName(); + const char *getSubjectDN(); + int getHashAlgorithm(); // Returns a NSS3 HASH_HashType or -1 if compiled without NSS3 time_t getSigningTime(); bool isSubfilterSupported() { return sig_subfilter_supported; } @@ -54,6 +57,8 @@ public: void setSignatureValStatus(enum SignatureValidationStatus ); void setCertificateValStatus(enum CertificateValidationStatus ); void setSignerName(char *); + void setSubjectDN(const char *); + void setHashAlgorithm(int); void setSigningTime(time_t); void setSubFilterSupport(bool isSupported) { sig_subfilter_supported = isSupported; } @@ -64,6 +69,8 @@ private: SignatureValidationStatus sig_status; CertificateValidationStatus cert_status; char *signer_name; + const char *subject_dn; + int hash_type; time_t signing_time; bool sig_subfilter_supported; }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Sound.cc b/Build/source/libs/poppler/poppler-src/poppler/Sound.cc index 6129fdcb47d..c0dd6ccbf77 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Sound.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Sound.cc @@ -1,6 +1,6 @@ /* Sound.cc - an object that holds the sound structure * Copyright (C) 2006-2007, Pino Toscano <pino@kde.org> - * Copyright (C) 2009, Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2009, 2017, Albert Astals Cid <aacid@kde.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,21 +38,18 @@ Sound *Sound::parseSound(Object *obj) Dict *dict = str->getDict(); if (dict == NULL) return NULL; - Object tmp; // the Dict must have the 'R' key of type num - dict->lookup("R", &tmp); + Object tmp = dict->lookup("R"); if (tmp.isNum()) { return new Sound(obj); } else { - return NULL; + return nullptr; } } Sound::Sound(Object *obj, bool readAttrs) { - streamObj = new Object(); - streamObj->initNull(); - obj->copy(streamObj); + streamObj = obj->copy(); fileName = NULL; samplingRate = 0.0; @@ -62,43 +59,37 @@ Sound::Sound(Object *obj, bool readAttrs) if (readAttrs) { - Object tmp; - Dict *dict = streamObj->getStream()->getDict(); - dict->lookup("F", &tmp); + Dict *dict = streamObj.getStream()->getDict(); + Object tmp = dict->lookup("F"); if (!tmp.isNull()) { - Object obj1; // valid 'F' key -> external file kind = soundExternal; - if (getFileSpecNameForPlatform (&tmp, &obj1)) { + Object obj1 = getFileSpecNameForPlatform (&tmp); + if (obj1.isString()) { fileName = obj1.getString()->copy(); - obj1.free(); } } else { // no file specification, then the sound data have to be // extracted from the stream kind = soundEmbedded; } - tmp.free(); // sampling rate - dict->lookup("R", &tmp); + tmp = dict->lookup("R"); if (tmp.isNum()) { samplingRate = tmp.getNum(); } - tmp.free(); // sound channels - dict->lookup("C", &tmp); + tmp = dict->lookup("C"); if (tmp.isInt()) { channels = tmp.getInt(); } - tmp.free(); // bits per sample - dict->lookup("B", &tmp); + tmp = dict->lookup("B"); if (tmp.isInt()) { bitsPerSample = tmp.getInt(); } - tmp.free(); // encoding format - dict->lookup("E", &tmp); + tmp = dict->lookup("E"); if (tmp.isName()) { const char *enc = tmp.getName(); @@ -112,25 +103,22 @@ Sound::Sound(Object *obj, bool readAttrs) encoding = soundALaw; } } - tmp.free(); } } Sound::~Sound() { delete fileName; - streamObj->free(); - delete streamObj; } Stream *Sound::getStream() { - return streamObj->getStream(); + return streamObj.getStream(); } Sound *Sound::copy() { - Sound *newsound = new Sound(streamObj, false); + Sound *newsound = new Sound(&streamObj, false); newsound->kind = kind; if (fileName) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/Sound.h b/Build/source/libs/poppler/poppler-src/poppler/Sound.h index acb0f8d9acd..5e33cb51e79 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Sound.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Sound.h @@ -1,5 +1,6 @@ /* Sound.h - an object that holds the sound structure * Copyright (C) 2006-2007, Pino Toscano <pino@kde.org> + * Copyright (C) 2017, Albert Astals Cid <aacid@kde.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,7 +47,7 @@ public: // Destructor ~Sound(); - Object *getObject() { return streamObj; } + Object *getObject() { return &streamObj; } Stream *getStream(); SoundKind getSoundKind() { return kind; } @@ -62,7 +63,7 @@ private: // Create a sound. The Object obj is ensured to be a Stream with a Dict Sound(Object *obj, bool readAttrs = true); - Object *streamObj; + Object streamObj; SoundKind kind; GooString *fileName; double samplingRate; diff --git a/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc index 093baa94ef9..28174356949 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> // Copyright (C) 2006 Stefan Schweizer <genstef@gentoo.org> -// Copyright (C) 2006-2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2006 Scott Turner <scotty1024@mac.com> // Copyright (C) 2007 Koji Otani <sho@bbr.jp> @@ -29,7 +29,7 @@ // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> -// Copyright (C) 2011, 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2011, 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Lu Wang <coolwanglu@gmail.com> // Copyright (C) 2013 Li Junling <lijunling@sina.com> // Copyright (C) 2014 Ed Porras <ed@moto-research.com> @@ -37,6 +37,7 @@ // Copyright (C) 2015 Tamas Szekeres <szekerest@gmail.com> // Copyright (C) 2015 Kenji Uno <ku@digitaldolphins.jp> // Copyright (C) 2016 Takahiro Hashimoto <kenya888.en@gmail.com> +// Copyright (C) 2017 Even Rouault <even.rouault@spatialys.com> // // 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 @@ -50,7 +51,7 @@ #endif #include <string.h> -#include <math.h> +#include <cmath> #include "goo/gfile.h" #include "GlobalParams.h" #include "Error.h" @@ -83,24 +84,7 @@ extern "C" int unlink(char *filename); #endif #endif -#ifdef _MSC_VER -#include <float.h> -#define isfinite(x) _finite(x) -#endif - -#ifdef __sun -#include <ieeefp.h> -#ifndef isfinite -#define isfinite(x) finite(x) -#endif -#endif - -#if __cplusplus > 199711L -#include <cmath> -#ifndef isfinite -#define isfinite(x) std::isfinite(x) -#endif -#endif +static const double s_minLineWidth = 0.0; static inline void convertGfxColor(SplashColorPtr dest, SplashColorMode colorMode, @@ -109,14 +93,14 @@ static inline void convertGfxColor(SplashColorPtr dest, SplashColor color; GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif // make gcc happy color[0] = color[1] = color[2] = 0; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK color[3] = 0; #endif switch (colorMode) { @@ -127,6 +111,7 @@ static inline void convertGfxColor(SplashColorPtr dest, break; case splashModeXBGR8: color[3] = 255; + // fallthrough case splashModeBGR8: case splashModeRGB8: colorSpace->getRGB(src, &rgb); @@ -134,7 +119,7 @@ static inline void convertGfxColor(SplashColorPtr dest, color[1] = colToByte(rgb.g); color[2] = colToByte(rgb.b); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: colorSpace->getCMYK(src, &cmyk); color[0] = colToByte(cmyk.c); @@ -174,6 +159,7 @@ static inline void convertGfxShortColor(SplashColorPtr dest, break; case splashModeXBGR8: dest[3] = 255; + // fallthrough case splashModeBGR8: case splashModeRGB8: { @@ -184,7 +170,7 @@ static inline void convertGfxShortColor(SplashColorPtr dest, dest[2] = colToByte(rgb.b); } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: { GfxCMYK cmyk; @@ -230,7 +216,7 @@ void SplashGouraudPattern::getParameterizedColor(double colorinterp, SplashColor GfxColor src; GfxColorSpace* srcColorSpace = shading->getColorSpace(); int colorComps = 3; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (mode == splashModeCMYK8) colorComps=4; else if (mode == splashModeDeviceN8) @@ -511,7 +497,7 @@ static inline Guchar div255(int x) { return (Guchar)((x + (x >> 8) + 0x80) >> 8); } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK #include "GfxState_helpers.h" @@ -567,7 +553,7 @@ static void splashOutBlendMultiply(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -580,7 +566,7 @@ static void splashOutBlendMultiply(SplashColorPtr src, SplashColorPtr dest, blend[i] = (dest[i] * src[i]) / 255; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -595,7 +581,7 @@ static void splashOutBlendScreen(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -608,7 +594,7 @@ static void splashOutBlendScreen(SplashColorPtr src, SplashColorPtr dest, blend[i] = dest[i] + src[i] - (dest[i] * src[i]) / 255; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -623,7 +609,7 @@ static void splashOutBlendOverlay(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -638,7 +624,7 @@ static void splashOutBlendOverlay(SplashColorPtr src, SplashColorPtr dest, : 255 - 2 * ((255 - src[i]) * (255 - dest[i])) / 255; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -653,7 +639,7 @@ static void splashOutBlendDarken(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -666,7 +652,7 @@ static void splashOutBlendDarken(SplashColorPtr src, SplashColorPtr dest, blend[i] = dest[i] < src[i] ? dest[i] : src[i]; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -681,7 +667,7 @@ static void splashOutBlendLighten(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -694,7 +680,7 @@ static void splashOutBlendLighten(SplashColorPtr src, SplashColorPtr dest, blend[i] = dest[i] > src[i] ? dest[i] : src[i]; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -710,7 +696,7 @@ static void splashOutBlendColorDodge(SplashColorPtr src, SplashColorPtr dest, SplashColorMode cm) { int i, x; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -728,7 +714,7 @@ static void splashOutBlendColorDodge(SplashColorPtr src, SplashColorPtr dest, } } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -743,7 +729,7 @@ static void splashOutBlendColorBurn(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i, x; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -761,7 +747,7 @@ static void splashOutBlendColorBurn(SplashColorPtr src, SplashColorPtr dest, } } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -776,7 +762,7 @@ static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -791,7 +777,7 @@ static void splashOutBlendHardLight(SplashColorPtr src, SplashColorPtr dest, : 255 - 2 * ((255 - dest[i]) * (255 - src[i])) / 255; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -806,7 +792,7 @@ static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i, x; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -828,7 +814,7 @@ static void splashOutBlendSoftLight(SplashColorPtr src, SplashColorPtr dest, } } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -844,7 +830,7 @@ static void splashOutBlendDifference(SplashColorPtr src, SplashColorPtr dest, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -857,7 +843,7 @@ static void splashOutBlendDifference(SplashColorPtr src, SplashColorPtr dest, blend[i] = dest[i] < src[i] ? src[i] - dest[i] : dest[i] - src[i]; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -878,7 +864,7 @@ static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { int i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -891,7 +877,7 @@ static void splashOutBlendExclusion(SplashColorPtr src, SplashColorPtr dest, blend[i] = dest[i] + src[i] - (2 * dest[i] * src[i]) / 255; } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (cm == splashModeCMYK8 || cm == splashModeDeviceN8) { for (i = 0; i < splashColorModeNComps[cm]; ++i) { dest[i] = 255 - dest[i]; @@ -1002,7 +988,7 @@ static void setSat(Guchar rIn, Guchar gIn, Guchar bIn, int sat, static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { Guchar r0, g0, b0; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guchar r1, g1, b1; int i; SplashColor src2, dest2; @@ -1015,6 +1001,7 @@ static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setSat(src[0], src[1], src[2], getSat(dest[0], dest[1], dest[2]), @@ -1022,7 +1009,7 @@ static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest, setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]), &blend[0], &blend[1], &blend[2]); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: for (i = 0; i < 4; i++) { @@ -1052,7 +1039,7 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { Guchar r0, g0, b0; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guchar r1, g1, b1; int i; SplashColor src2, dest2; @@ -1065,6 +1052,7 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setSat(dest[0], dest[1], dest[2], getSat(src[0], src[1], src[2]), @@ -1072,7 +1060,7 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest, setLum(r0, g0, b0, getLum(dest[0], dest[1], dest[2]), &blend[0], &blend[1], &blend[2]); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: for (i = 0; i < 4; i++) { @@ -1099,7 +1087,7 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest, static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guchar r, g, b; int i; SplashColor src2, dest2; @@ -1112,12 +1100,13 @@ static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setLum(src[0], src[1], src[2], getLum(dest[0], dest[1], dest[2]), &blend[0], &blend[1], &blend[2]); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: for (i = 0; i < 4; i++) { @@ -1143,7 +1132,7 @@ static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest, static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guchar r, g, b; int i; SplashColor src2, dest2; @@ -1156,12 +1145,13 @@ static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setLum(dest[0], dest[1], dest[2], getLum(src[0], src[1], src[2]), &blend[0], &blend[1], &blend[2]); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: for (i = 0; i < 4; i++) { @@ -1215,7 +1205,7 @@ public: ~SplashOutFontFileID() {} - GBool matches(SplashFontFileID *id) { + GBool matches(SplashFontFileID *id) override { return ((SplashOutFontFileID *)id)->r.num == r.num && ((SplashOutFontFileID *)id)->r.gen == r.gen; } @@ -1400,7 +1390,7 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, colorMode != splashModeMono1, bitmapTopDown); splash = new Splash(bitmap, vectorAntialias, &screenParams); - splash->setMinLineWidth(globalParams->getMinLineWidth()); + splash->setMinLineWidth(s_minLineWidth); splash->setThinLineMode(thinLineMode); splash->clear(paperColor, 0); @@ -1418,27 +1408,15 @@ SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, } void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) { - screenParams.size = globalParams->getScreenSize(); - screenParams.dotRadius = globalParams->getScreenDotRadius(); - screenParams.gamma = (SplashCoord)globalParams->getScreenGamma(); - screenParams.blackThreshold = - (SplashCoord)globalParams->getScreenBlackThreshold(); - screenParams.whiteThreshold = - (SplashCoord)globalParams->getScreenWhiteThreshold(); - switch (globalParams->getScreenType()) { - case screenDispersed: - screenParams.type = splashScreenDispersed; - if (screenParams.size < 0) { - screenParams.size = 4; - } - break; - case screenClustered: - screenParams.type = splashScreenClustered; - if (screenParams.size < 0) { - screenParams.size = 10; - } - break; - case screenStochasticClustered: + screenParams.size = -1; + screenParams.dotRadius = -1; + screenParams.gamma = (SplashCoord)1.0; + screenParams.blackThreshold = (SplashCoord)0.0; + screenParams.whiteThreshold = (SplashCoord)1.0; + + // use clustered dithering for resolution >= 300 dpi + // (compare to 299.9 to avoid floating point issues) + if (hDPI > 299.9 && vDPI > 299.9) { screenParams.type = splashScreenStochasticClustered; if (screenParams.size < 0) { screenParams.size = 64; @@ -1446,24 +1424,10 @@ void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) { if (screenParams.dotRadius < 0) { screenParams.dotRadius = 2; } - break; - case screenUnset: - default: - // use clustered dithering for resolution >= 300 dpi - // (compare to 299.9 to avoid floating point issues) - if (hDPI > 299.9 && vDPI > 299.9) { - screenParams.type = splashScreenStochasticClustered; - if (screenParams.size < 0) { - screenParams.size = 64; - } - if (screenParams.dotRadius < 0) { - screenParams.dotRadius = 2; - } - } else { - screenParams.type = splashScreenDispersed; - if (screenParams.size < 0) { - screenParams.size = 4; - } + } else { + screenParams.type = splashScreenDispersed; + if (screenParams.size < 0) { + screenParams.size = 4; } } } @@ -1493,14 +1457,9 @@ void SplashOutputDev::startDoc(PDFDoc *docA) { delete fontEngine; } fontEngine = new SplashFontEngine( -#if HAVE_T1LIB_H - globalParams->getEnableT1lib(), -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H globalParams->getEnableFreeType(), enableFreeTypeHinting, enableSlightHinting, -#endif getFontAntialias() && colorMode != splashModeMono1); for (i = 0; i < nT3Fonts; ++i) { @@ -1551,7 +1510,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { } splash = new Splash(bitmap, vectorAntialias, &screenParams); splash->setThinLineMode(thinLineMode); - splash->setMinLineWidth(globalParams->getMinLineWidth()); + splash->setMinLineWidth(s_minLineWidth); if (state) { ctm = state->getCTM(); mat[0] = (SplashCoord)ctm[0]; @@ -1569,11 +1528,12 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { break; case splashModeXBGR8: color[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: color[0] = color[1] = color[2] = 0; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: color[0] = color[1] = color[2] = color[3] = 0; break; @@ -1592,7 +1552,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { splash->setFlatness(1); // the SA parameter supposedly defaults to false, but Acrobat // apparently hardwires it to true - splash->setStrokeAdjust(globalParams->getStrokeAdjust()); + splash->setStrokeAdjust(gTrue); splash->clear(paperColor, 0); } @@ -1703,14 +1663,14 @@ void SplashOutputDev::updateStrokeAdjust(GfxState * /*state*/) { } void SplashOutputDev::updateFillColorSpace(GfxState *state) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (colorMode == splashModeDeviceN8) state->getFillColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); #endif } void SplashOutputDev::updateStrokeColorSpace(GfxState *state) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (colorMode == splashModeDeviceN8) state->getStrokeColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); #endif @@ -1719,7 +1679,7 @@ void SplashOutputDev::updateStrokeColorSpace(GfxState *state) { void SplashOutputDev::updateFillColor(GfxState *state) { GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif @@ -1736,7 +1696,7 @@ void SplashOutputDev::updateFillColor(GfxState *state) { state->getFillRGB(&rgb); splash->setFillPattern(getColor(&rgb)); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: state->getFillCMYK(&cmyk); splash->setFillPattern(getColor(&cmyk)); @@ -1752,7 +1712,7 @@ void SplashOutputDev::updateFillColor(GfxState *state) { void SplashOutputDev::updateStrokeColor(GfxState *state) { GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif @@ -1769,7 +1729,7 @@ void SplashOutputDev::updateStrokeColor(GfxState *state) { state->getStrokeRGB(&rgb); splash->setStrokePattern(getColor(&rgb)); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: state->getStrokeCMYK(&cmyk); splash->setStrokePattern(getColor(&cmyk)); @@ -1812,7 +1772,7 @@ SplashPattern *SplashOutputDev::getColor(GfxRGB *rgb) { return new SplashSolidColor(color); } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK SplashPattern *SplashOutputDev::getColor(GfxCMYK *cmyk) { SplashColor color; @@ -1835,7 +1795,7 @@ SplashPattern *SplashOutputDev::getColor(GfxColor *deviceN) { void SplashOutputDev::getMatteColor(SplashColorMode colorMode, GfxImageColorMap *colorMap, GfxColor *matteColorIn, SplashColor matteColor) { GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif @@ -1860,7 +1820,7 @@ void SplashOutputDev::getMatteColor(SplashColorMode colorMode, GfxImageColorMap matteColor[2] = colToByte(rgb.b); matteColor[3] = 255; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: colorMap->getColorSpace()->getCMYK(matteColorIn, &cmyk); matteColor[0] = colToByte(cmyk.c); @@ -1882,7 +1842,7 @@ void SplashOutputDev::setOverprintMask(GfxColorSpace *colorSpace, int overprintMode, GfxColor *singleColor, GBool grayIndexed) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guint mask; GfxCMYK cmyk; GBool additive = gFalse; @@ -2075,8 +2035,10 @@ reload: delete id; delete fontLoc; fontLoc = NULL; - if (fontsrc && !fontsrc->isFile) + if (fontsrc && !fontsrc->isFile) { fontsrc->unref(); + fontsrc = nullptr; + } id = new SplashOutFontFileID(gfxFont->getID()); if ((fontFile = fontEngine->getFontFile(id))) { @@ -2713,7 +2675,11 @@ void SplashOutputDev::endType3Char(GfxState *state) { } void SplashOutputDev::type3D0(GfxState *state, double wx, double wy) { - t3GlyphStack->haveDx = gTrue; + if (likely(t3GlyphStack != nullptr)) { + t3GlyphStack->haveDx = gTrue; + } else { + error(errSyntaxWarning, -1, "t3GlyphStack was null in SplashOutputDev::type3D0"); + } } void SplashOutputDev::type3D1(GfxState *state, double wx, double wy, @@ -2725,7 +2691,7 @@ void SplashOutputDev::type3D1(GfxState *state, double wx, double wy, int i, j; // ignore multiple d0/d1 operators - if (t3GlyphStack->haveDx) { + if (!t3GlyphStack || t3GlyphStack->haveDx) { return; } t3GlyphStack->haveDx = gTrue; @@ -2840,7 +2806,7 @@ void SplashOutputDev::type3D1(GfxState *state, double wx, double wy, splash->clear(color); color[0] = 0xff; } - splash->setMinLineWidth(globalParams->getMinLineWidth()); + splash->setMinLineWidth(s_minLineWidth); splash->setThinLineMode(splashThinLineDefault); splash->setFillPattern(new SplashSolidColor(color)); splash->setStrokePattern(new SplashSolidColor(color)); @@ -2918,7 +2884,7 @@ void SplashOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, ctm = state->getCTM(); for (int i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; + if (!std::isfinite(ctm[i])) return; } mat[0] = ctm[0]; mat[1] = ctm[1]; @@ -2964,7 +2930,7 @@ void SplashOutputDev::setSoftMaskFromImageMask(GfxState *state, ctm = state->getCTM(); for (int i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; + if (!std::isfinite(ctm[i])) return; } beginTransparencyGroup(state, bbox, NULL, gFalse, gFalse, gFalse); @@ -3048,7 +3014,7 @@ GBool SplashOutputDev::useIccImageSrc(void *data) { if (colorSpace->getAlt() != NULL && colorSpace->getAlt()->getMode() == csDeviceRGB) return gTrue; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: if (colorSpace->getAlt() != NULL && colorSpace->getAlt()->getMode() == csDeviceCMYK) return gTrue; @@ -3073,7 +3039,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine, SplashColorPtr q, col; GfxRGB rgb; GfxGray gray; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif @@ -3088,7 +3054,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine, destComps = 3; else if (imgData->colorMode == splashModeXBGR8) destComps = 4; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK else if (imgData->colorMode == splashModeCMYK8) destComps = 4; else if (imgData->colorMode == splashModeDeviceN8) @@ -3126,7 +3092,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine, *q++ = col[3]; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: for (x = 0, q = colorLine; x < imgData->width; ++x, ++p) { col = &imgData->lookup[4 * *p]; @@ -3180,7 +3146,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine, } } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: if (imgData->colorMap->useCMYKLine()) { imgData->colorMap->getCMYKLine(p, (Guchar *) colorLine, imgData->width); @@ -3239,7 +3205,7 @@ GBool SplashOutputDev::iccImageSrc(void *data, SplashColorPtr colorLine, destComps = 3; else if (imgData->colorMode == splashModeXBGR8) destComps = 4; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK else if (imgData->colorMode == splashModeCMYK8) destComps = 4; else if (imgData->colorMode == splashModeDeviceN8) @@ -3286,7 +3252,7 @@ void SplashOutputDev::iccTransform(void *data, SplashBitmap *bitmap) { imgData->colorMap->getRGBLine(p, colorLine, bitmap->getWidth()); memcpy(p, colorLine, nComps * bitmap->getWidth()); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: imgData->colorMap->getCMYKLine(p, colorLine, bitmap->getWidth()); memcpy(p, colorLine, nComps * bitmap->getWidth()); @@ -3324,7 +3290,7 @@ GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine, SplashColorPtr q, col; GfxRGB rgb; GfxGray gray; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif @@ -3371,7 +3337,7 @@ GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine, *q++ = col[2]; *q++ = 255; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: col = &imgData->lookup[4 * *p]; *q++ = col[0]; @@ -3403,7 +3369,7 @@ GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine, *q++ = colToByte(rgb.b); if (imgData->colorMode == splashModeXBGR8) *q++ = 255; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: imgData->colorMap->getCMYK(p, &cmyk); *q++ = colToByte(cmyk.c); @@ -3491,7 +3457,7 @@ GBool SplashOutputDev::tilingBitmapSrc(void *data, SplashColorPtr colorLine, imgData->bitmap->getPixel(x, imgData->y, col); imgData->pattern->getColor(x, imgData->y, pat); for (int i = 0; i < splashColorModeNComps[imgData->colorMode]; ++i) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (imgData->colorMode == splashModeCMYK8 || imgData->colorMode == splashModeDeviceN8) dest[i] = div255(pat[i] * (255 - col[0])); else @@ -3531,7 +3497,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, SplashICCTransform tf; GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GBool grayIndexed = gFalse; GfxColor deviceN; @@ -3541,7 +3507,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, ctm = state->getCTM(); for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; + if (!std::isfinite(ctm[i])) return; } mat[0] = ctm[0]; mat[1] = ctm[1]; @@ -3600,7 +3566,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, imgData.lookup[4*i+3] = 255; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: grayIndexed = colorMap->getColorSpace()->getMode() != csDeviceGray; imgData.lookup = (SplashColorPtr)gmallocn(n, 4); @@ -3635,7 +3601,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, } } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), state->getOverprintMode(), NULL, grayIndexed); #else @@ -3685,7 +3651,7 @@ GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine, SplashColorPtr q, col; GfxRGB rgb; GfxGray gray; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif @@ -3734,7 +3700,7 @@ GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine, *q++ = col[2]; *q++ = 255; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: col = &imgData->lookup[4 * *p]; *q++ = col[0]; @@ -3766,7 +3732,7 @@ GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr colorLine, *q++ = colToByte(rgb.b); if (imgData->colorMode == splashModeXBGR8) *q++ = 255; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: imgData->colorMap->getCMYK(p, &cmyk); *q++ = colToByte(cmyk.c); @@ -3797,7 +3763,7 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, int maskHeight, GBool maskInvert, GBool maskInterpolate) { GfxImageColorMap *maskColorMap; - Object maskDecode, decodeLow, decodeHigh; + Object decodeLow, decodeHigh; double *ctm; SplashCoord mat[6]; SplashOutMaskedImageData imgData; @@ -3808,14 +3774,14 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, SplashColor maskColor; GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif Guchar pix; int n, i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); #endif setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), @@ -3824,14 +3790,11 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, // If the mask is higher resolution than the image, use // drawSoftMaskedImage() instead. if (maskWidth > width || maskHeight > height) { - decodeLow.initInt(maskInvert ? 0 : 1); - decodeHigh.initInt(maskInvert ? 1 : 0); - maskDecode.initArray((xref) ? xref : doc->getXRef()); - maskDecode.arrayAdd(&decodeLow); - maskDecode.arrayAdd(&decodeHigh); + Object maskDecode(new Array((xref) ? xref : doc->getXRef())); + maskDecode.arrayAdd(Object(maskInvert ? 0 : 1)); + maskDecode.arrayAdd(Object(maskInvert ? 1 : 0)); maskColorMap = new GfxImageColorMap(1, &maskDecode, new GfxDeviceGrayColorSpace()); - maskDecode.free(); drawSoftMaskedImage(state, ref, str, width, height, colorMap, interpolate, maskStr, maskWidth, maskHeight, maskColorMap, maskInterpolate); delete maskColorMap; @@ -3872,7 +3835,7 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, ctm = state->getCTM(); for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) { + if (!std::isfinite(ctm[i])) { delete maskBitmap; return; } @@ -3932,7 +3895,7 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, imgData.lookup[4*i+3] = 255; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: imgData.lookup = (SplashColorPtr)gmallocn(n, 4); for (i = 0; i < n; ++i) { @@ -3989,14 +3952,14 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, SplashColor maskColor; GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif Guchar pix; int n, i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK colorMap->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); #endif setOverprintMask(colorMap->getColorSpace(), state->getFillOverprint(), @@ -4004,7 +3967,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, ctm = state->getCTM(); for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) return; + if (!std::isfinite(ctm[i])) return; } mat[0] = ctm[0]; mat[1] = ctm[1]; @@ -4020,9 +3983,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, maskStr->reset(); maskStr->doGetChars(maskWidth * maskHeight, data); maskStr->close(); - Object *maskDict = new Object(); - maskDict->initDict(maskStr->getDict()); - maskStr = new MemStream((char *)data, 0, maskWidth * maskHeight, maskDict); + maskStr = new MemStream((char *)data, 0, maskWidth * maskHeight, maskStr->getDictObject()->copy()); ((MemStream *) maskStr)->setNeedFree(gTrue); } imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, @@ -4119,7 +4080,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, imgData.lookup[4*i+3] = 255; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: imgData.lookup = (SplashColorPtr)gmallocn(n, 4); for (i = 0; i < n; ++i) { @@ -4261,9 +4222,7 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, // save state transpGroup->origBitmap = bitmap; transpGroup->origSplash = splash; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H transpGroup->fontAA = fontEngine->getAA(); -#endif //~ this handles the blendingColorSpace arg for soft masks, but //~ not yet for transparency groups @@ -4281,7 +4240,7 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, blendingColorSpace->getNComps() == 3)) { //~ does this need to use BGR8? colorMode = splashModeRGB8; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK } else if (blendingColorSpace->getMode() == csDeviceCMYK || (blendingColorSpace->getMode() == csICCBased && blendingColorSpace->getNComps() == 4)) { @@ -4301,12 +4260,10 @@ void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, splash = new Splash(bitmap, vectorAntialias, transpGroup->origSplash->getScreen()); if (transpGroup->next != NULL && transpGroup->next->knockout) { -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H fontEngine->setAA(gFalse); -#endif } splash->setThinLineMode(transpGroup->origSplash->getThinLineMode()); - splash->setMinLineWidth(globalParams->getMinLineWidth()); + splash->setMinLineWidth(s_minLineWidth); //~ Acrobat apparently copies at least the fill and stroke colors, and //~ maybe other state(?) -- but not the clipping path (and not sure //~ what else) @@ -4367,9 +4324,7 @@ void SplashOutputDev::paintTransparencyGroup(GfxState *state, double *bbox) { splash->composite(tBitmap, 0, 0, tx, ty, tBitmap->getWidth(), tBitmap->getHeight(), gFalse, !isolated, transpGroupStack->next != NULL && transpGroupStack->next->knockout, knockoutOpacity); -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H fontEngine->setAA(transpGroupStack->fontAA); -#endif if (transpGroupStack->next != NULL && transpGroupStack->next->shape != NULL) { transpGroupStack->next->knockout = gTrue; } @@ -4397,7 +4352,7 @@ void SplashOutputDev::setSoftMask(GfxState *state, double *bbox, SplashColorPtr p; GfxGray gray; GfxRGB rgb; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK GfxCMYK cmyk; GfxColor deviceN; #endif @@ -4426,6 +4381,7 @@ void SplashOutputDev::setSoftMask(GfxState *state, double *bbox, break; case splashModeXBGR8: color[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: transpGroupStack->blendingColorSpace->getRGB(backdropColor, &rgb); @@ -4434,7 +4390,7 @@ void SplashOutputDev::setSoftMask(GfxState *state, double *bbox, color[2] = colToByte(rgb.b); tSplash->compositeBackground(color); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: transpGroupStack->blendingColorSpace->getCMYK(backdropColor, &cmyk); color[0] = colToByte(cmyk.c); @@ -4493,7 +4449,7 @@ void SplashOutputDev::setSoftMask(GfxState *state, double *bbox, (0.59 / 255.0) * color[1] + (0.11 / 255.0) * color[2]; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: lum = (1 - color[3] / 255.0) @@ -4612,7 +4568,7 @@ GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *ca state->concatCTM(1, 0, 0, 1, bbox[0], bbox[1]); ctm = state->getCTM(); for (i = 0; i < 6; ++i) { - if (!isfinite(ctm[i])) { + if (!std::isfinite(ctm[i])) { state->setCTM(savedCTM[0], savedCTM[1], savedCTM[2], savedCTM[3], savedCTM[4], savedCTM[5]); return gFalse; } @@ -4711,7 +4667,7 @@ GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *ca splash = new Splash(bitmap, gTrue); if (paintType == 2) { SplashColor clearColor; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK clearColor[0] = (colorMode == splashModeCMYK8 || colorMode == splashModeDeviceN8) ? 0x00 : 0xFF; #else clearColor[0] = 0xFF; @@ -4721,7 +4677,7 @@ GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *ca splash->clear(paperColor, 0); } splash->setThinLineMode(formerSplash->getThinLineMode()); - splash->setMinLineWidth(globalParams->getMinLineWidth()); + splash->setMinLineWidth(s_minLineWidth); box.x1 = bbox[0]; box.y1 = bbox[1]; box.x2 = bbox[2]; box.y2 = bbox[3]; @@ -4787,7 +4743,7 @@ GBool SplashOutputDev::gouraudTriangleShadedFill(GfxState *state, GfxGouraudTria case splashModeRGB8: bDirectColorTranslation = (shadingMode == csDeviceRGB); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: bDirectColorTranslation = (shadingMode == csDeviceCMYK); @@ -4861,7 +4817,7 @@ GBool SplashOutputDev::univariateShadedFill(GfxState *state, SplashUnivariatePat state->closePath(); path = convertPath(state, state->getPath(), gTrue); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK pattern->getShading()->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); #endif setOverprintMask(pattern->getShading()->getColorSpace(), state->getFillOverprint(), @@ -4926,7 +4882,7 @@ GBool SplashOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *s state->closePath(); path = convertPath(state, state->getPath(), gTrue); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK pattern->getShading()->getColorSpace()->createMapping(bitmap->getSeparationList(), SPOT_NCOMPS); #endif setOverprintMask(pattern->getShading()->getColorSpace(), state->getFillOverprint(), diff --git a/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.h index 5c5512ba518..05b7e9433b1 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/SplashOutputDev.h @@ -19,7 +19,7 @@ // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> -// Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2011, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012, 2015 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2015, 2016 William Bader <williambader@hotmail.com> // @@ -64,19 +64,19 @@ public: SplashFunctionPattern(SplashColorMode colorMode, GfxState *state, GfxFunctionShading *shading); - virtual SplashPattern *copy() { return new SplashFunctionPattern(colorMode, state, (GfxFunctionShading *) shading); } + SplashPattern *copy() override { return new SplashFunctionPattern(colorMode, state, (GfxFunctionShading *) shading); } - virtual ~SplashFunctionPattern(); + ~SplashFunctionPattern(); - virtual GBool testPosition(int x, int y) { return gTrue; } + GBool testPosition(int x, int y) override { return gTrue; } - virtual GBool isStatic() { return gFalse; } + GBool isStatic() override { return gFalse; } - virtual GBool getColor(int x, int y, SplashColorPtr c); + GBool getColor(int x, int y, SplashColorPtr c) override; virtual GfxFunctionShading *getShading() { return shading; } - virtual GBool isCMYK() { return gfxMode == csDeviceCMYK; } + GBool isCMYK() override { return gfxMode == csDeviceCMYK; } protected: Matrix ictm; @@ -92,19 +92,19 @@ public: SplashUnivariatePattern(SplashColorMode colorMode, GfxState *state, GfxUnivariateShading *shading); - virtual ~SplashUnivariatePattern(); + ~SplashUnivariatePattern(); - virtual GBool getColor(int x, int y, SplashColorPtr c); + GBool getColor(int x, int y, SplashColorPtr c) override; - virtual GBool testPosition(int x, int y); + GBool testPosition(int x, int y) override; - virtual GBool isStatic() { return gFalse; } + GBool isStatic() override { return gFalse; } virtual GBool getParameter(double xs, double ys, double *t) = 0; virtual GfxUnivariateShading *getShading() { return shading; } - virtual GBool isCMYK() { return gfxMode == csDeviceCMYK; } + GBool isCMYK() override { return gfxMode == csDeviceCMYK; } protected: Matrix ictm; @@ -120,11 +120,11 @@ public: SplashAxialPattern(SplashColorMode colorMode, GfxState *state, GfxAxialShading *shading); - virtual SplashPattern *copy() { return new SplashAxialPattern(colorMode, state, (GfxAxialShading *) shading); } + SplashPattern *copy() override { return new SplashAxialPattern(colorMode, state, (GfxAxialShading *) shading); } - virtual ~SplashAxialPattern(); + ~SplashAxialPattern(); - virtual GBool getParameter(double xs, double ys, double *t); + GBool getParameter(double xs, double ys, double *t) override; private: double x0, y0, x1, y1; @@ -137,26 +137,26 @@ public: SplashGouraudPattern(GBool bDirectColorTranslation, GfxState *state, GfxGouraudTriangleShading *shading, SplashColorMode mode); - virtual SplashPattern *copy() { return new SplashGouraudPattern(bDirectColorTranslation, state, shading, mode); } + SplashPattern *copy() override { return new SplashGouraudPattern(bDirectColorTranslation, state, shading, mode); } - virtual ~SplashGouraudPattern(); + ~SplashGouraudPattern(); - virtual GBool getColor(int x, int y, SplashColorPtr c) { return gFalse; } + GBool getColor(int x, int y, SplashColorPtr c) override { return gFalse; } - virtual GBool testPosition(int x, int y) { return gFalse; } + GBool testPosition(int x, int y) override { return gFalse; } - virtual GBool isStatic() { return gFalse; } + GBool isStatic() override { return gFalse; } - virtual GBool isCMYK() { return gfxMode == csDeviceCMYK; } + GBool isCMYK() override { return gfxMode == csDeviceCMYK; } - virtual GBool isParameterized() { return shading->isParameterized(); } - virtual int getNTriangles() { return shading->getNTriangles(); } - virtual void getTriangle(int i, double *x0, double *y0, double *color0, + GBool isParameterized() override { return shading->isParameterized(); } + int getNTriangles() override { return shading->getNTriangles(); } + void getTriangle(int i, double *x0, double *y0, double *color0, double *x1, double *y1, double *color1, - double *x2, double *y2, double *color2) + double *x2, double *y2, double *color2) override { return shading->getTriangle(i, x0, y0, color0, x1, y1, color1, x2, y2, color2); } - virtual void getParameterizedColor(double t, SplashColorMode mode, SplashColorPtr c); + void getParameterizedColor(double t, SplashColorMode mode, SplashColorPtr c) override; private: GfxGouraudTriangleShading *shading; @@ -172,11 +172,11 @@ public: SplashRadialPattern(SplashColorMode colorMode, GfxState *state, GfxRadialShading *shading); - virtual SplashPattern *copy() { return new SplashRadialPattern(colorMode, state, (GfxRadialShading *) shading); } + SplashPattern *copy() override { return new SplashRadialPattern(colorMode, state, (GfxRadialShading *) shading); } - virtual ~SplashRadialPattern(); + ~SplashRadialPattern(); - virtual GBool getParameter(double xs, double ys, double *t); + GBool getParameter(double xs, double ys, double *t) override; private: double x0, y0, r0, dx, dy, dr; @@ -203,146 +203,146 @@ public: GBool overprintPreviewA = globalParams->getOverprintPreview()); // Destructor. - virtual ~SplashOutputDev(); + ~SplashOutputDev(); //----- get info about output device // Does this device use tilingPatternFill()? If this returns false, // tiling pattern fills will be reduced to a series of other drawing // operations. - virtual GBool useTilingPatternFill() { return gTrue; } + GBool useTilingPatternFill() override { return gTrue; } // Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. - virtual GBool useShadedFills(int type) + GBool useShadedFills(int type) override { return (type >= 1 && type <= 5) ? gTrue : gFalse; } // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return bitmapTopDown ^ bitmapUpsideDown; } + GBool upsideDown() override { return bitmapTopDown ^ bitmapUpsideDown; } // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gTrue; } + GBool useDrawChar() override { return gTrue; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gTrue; } + GBool interpretType3Chars() override { return gTrue; } //----- initialization and control // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef *xref); + void startPage(int pageNum, GfxState *state, XRef *xref) override; // End a page. - virtual void endPage(); + void endPage() override; //----- save/restore graphics state - virtual void saveState(GfxState *state); - virtual void restoreState(GfxState *state); + void saveState(GfxState *state) override; + void restoreState(GfxState *state) override; //----- update graphics state - virtual void updateAll(GfxState *state); - virtual void updateCTM(GfxState *state, double m11, double m12, - double m21, double m22, double m31, double m32); - virtual void updateLineDash(GfxState *state); - virtual void updateFlatness(GfxState *state); - virtual void updateLineJoin(GfxState *state); - virtual void updateLineCap(GfxState *state); - virtual void updateMiterLimit(GfxState *state); - virtual void updateLineWidth(GfxState *state); - virtual void updateStrokeAdjust(GfxState *state); - virtual void updateFillColorSpace(GfxState *state); - virtual void updateStrokeColorSpace(GfxState *state); - virtual void updateFillColor(GfxState *state); - virtual void updateStrokeColor(GfxState *state); - virtual void updateBlendMode(GfxState *state); - virtual void updateFillOpacity(GfxState *state); - virtual void updateStrokeOpacity(GfxState *state); - virtual void updatePatternOpacity(GfxState *state); - virtual void clearPatternOpacity(GfxState *state); - virtual void updateFillOverprint(GfxState *state); - virtual void updateStrokeOverprint(GfxState *state); - virtual void updateOverprintMode(GfxState *state); - virtual void updateTransfer(GfxState *state); + void updateAll(GfxState *state) override; + void updateCTM(GfxState *state, double m11, double m12, + double m21, double m22, double m31, double m32) override; + void updateLineDash(GfxState *state) override; + void updateFlatness(GfxState *state) override; + void updateLineJoin(GfxState *state) override; + void updateLineCap(GfxState *state) override; + void updateMiterLimit(GfxState *state) override; + void updateLineWidth(GfxState *state) override; + void updateStrokeAdjust(GfxState *state) override; + void updateFillColorSpace(GfxState *state) override; + void updateStrokeColorSpace(GfxState *state) override; + void updateFillColor(GfxState *state) override; + void updateStrokeColor(GfxState *state) override; + void updateBlendMode(GfxState *state) override; + void updateFillOpacity(GfxState *state) override; + void updateStrokeOpacity(GfxState *state) override; + void updatePatternOpacity(GfxState *state) override; + void clearPatternOpacity(GfxState *state) override; + void updateFillOverprint(GfxState *state) override; + void updateStrokeOverprint(GfxState *state) override; + void updateOverprintMode(GfxState *state) override; + void updateTransfer(GfxState *state) override; //----- update text state - virtual void updateFont(GfxState *state); + void updateFont(GfxState *state) override; //----- path painting - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); - virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *catalog, Object *str, + void stroke(GfxState *state) override; + void fill(GfxState *state) override; + void eoFill(GfxState *state) override; + GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *catalog, Object *str, double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, - double xStep, double yStep); - virtual GBool functionShadedFill(GfxState *state, GfxFunctionShading *shading); - virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); - virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax); - virtual GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading); + double xStep, double yStep) override; + GBool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override; + GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override; + GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax) override; + GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override; //----- path clipping - virtual void clip(GfxState *state); - virtual void eoClip(GfxState *state); - virtual void clipToStrokePath(GfxState *state); + void clip(GfxState *state) override; + void eoClip(GfxState *state) override; + void clipToStrokePath(GfxState *state) override; //----- text drawing - virtual void drawChar(GfxState *state, double x, double y, + void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, - CharCode code, int nBytes, Unicode *u, int uLen); - virtual GBool beginType3Char(GfxState *state, double x, double y, + CharCode code, int nBytes, Unicode *u, int uLen) override; + GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, - CharCode code, Unicode *u, int uLen); - virtual void endType3Char(GfxState *state); - virtual void beginTextObject(GfxState *state); - virtual void endTextObject(GfxState *state); + CharCode code, Unicode *u, int uLen) override; + void endType3Char(GfxState *state) override; + void beginTextObject(GfxState *state) override; + void endTextObject(GfxState *state) override; //----- image drawing - virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, + void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool interpolate, GBool inlineImg); - virtual void setSoftMaskFromImageMask(GfxState *state, + GBool interpolate, GBool inlineImg) override; + void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, - GBool inlineImg, double *baseMatrix); - virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix); - virtual void drawImage(GfxState *state, Object *ref, Stream *str, + GBool inlineImg, double *baseMatrix) override; + void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override; + void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, int *maskColors, GBool inlineImg); - virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, + GBool interpolate, int *maskColors, GBool inlineImg) override; + void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, Stream *maskStr, int maskWidth, int maskHeight, - GBool maskInvert, GBool maskInterpolate); - virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, + GBool maskInvert, GBool maskInterpolate) override; + void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, - GBool maskInterpolate); + GBool maskInterpolate) override; //----- Type 3 font operators - virtual void type3D0(GfxState *state, double wx, double wy); - virtual void type3D1(GfxState *state, double wx, double wy, - double llx, double lly, double urx, double ury); + void type3D0(GfxState *state, double wx, double wy) override; + void type3D1(GfxState *state, double wx, double wy, + double llx, double lly, double urx, double ury) override; //----- transparency groups and soft masks - virtual GBool checkTransparencyGroup(GfxState *state, GBool knockout); - virtual void beginTransparencyGroup(GfxState *state, double *bbox, + GBool checkTransparencyGroup(GfxState *state, GBool knockout) override; + void beginTransparencyGroup(GfxState *state, double *bbox, GfxColorSpace *blendingColorSpace, GBool isolated, GBool knockout, - GBool forSoftMask); - virtual void endTransparencyGroup(GfxState *state); - virtual void paintTransparencyGroup(GfxState *state, double *bbox); - virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, - Function *transferFunc, GfxColor *backdropColor); - virtual void clearSoftMask(GfxState *state); + GBool forSoftMask) override; + void endTransparencyGroup(GfxState *state) override; + void paintTransparencyGroup(GfxState *state, double *bbox) override; + void setSoftMask(GfxState *state, double *bbox, GBool alpha, + Function *transferFunc, GfxColor *backdropColor) override; + void clearSoftMask(GfxState *state) override; //----- special access @@ -386,8 +386,8 @@ public: int getNestCount() { return nestCount; } #if 1 //~tmp: turn off anti-aliasing temporarily - virtual GBool getVectorAntialias(); - virtual void setVectorAntialias(GBool vaa); + GBool getVectorAntialias() override; + void setVectorAntialias(GBool vaa) override; #endif GBool getFontAntialias() { return fontAntialias; } @@ -404,7 +404,7 @@ private: void setupScreenParams(double hDPI, double vDPI); SplashPattern *getColor(GfxGray gray); SplashPattern *getColor(GfxRGB *rgb); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK SplashPattern *getColor(GfxCMYK *cmyk); SplashPattern *getColor(GfxColor *deviceN); #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/StdinCachedFile.h b/Build/source/libs/poppler/poppler-src/poppler/StdinCachedFile.h index 5be6fa841a3..7d608a747fa 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/StdinCachedFile.h +++ b/Build/source/libs/poppler/poppler-src/poppler/StdinCachedFile.h @@ -17,9 +17,8 @@ class StdinCacheLoader : public CachedFileLoader { public: - - size_t init(GooString *dummy, CachedFile* cachedFile); - int load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer); + size_t init(GooString *dummy, CachedFile* cachedFile) override; + int load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer) override; }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.cc b/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.cc index 571ee46d7f6..f4aa12cf8ef 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2010 Hib Eris <hib@hiberis.nl> -// Copyright 2010 Albert Astals Cid <aacid@kde.org> +// Copyright 2010, 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -23,12 +23,9 @@ PDFDoc * StdinPDFDocBuilder::buildPDFDoc(const GooString &uri, GooString *ownerPassword, GooString *userPassword, void *guiDataA) { - Object obj; - - obj.initNull(); CachedFile *cachedFile = new CachedFile(new StdinCacheLoader(), NULL); return new PDFDoc(new CachedFileStream(cachedFile, 0, gFalse, - cachedFile->getLength(), &obj), + cachedFile->getLength(), Object(objNull)), ownerPassword, userPassword); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.h b/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.h index e9b2f47f636..acc43b05c9a 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.h +++ b/Build/source/libs/poppler/poppler-src/poppler/StdinPDFDocBuilder.h @@ -23,10 +23,9 @@ class StdinPDFDocBuilder : public PDFDocBuilder { public: - PDFDoc *buildPDFDoc(const GooString &uri, GooString *ownerPassword = NULL, - GooString *userPassword = NULL, void *guiDataA = NULL); - GBool supports(const GooString &uri); + GooString *userPassword = NULL, void *guiDataA = NULL) override; + GBool supports(const GooString &uri) override; }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Stream.cc b/Build/source/libs/poppler/poppler-src/poppler/Stream.cc index 4a9babe4662..da1d92675e2 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Stream.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/Stream.cc @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2006-2010, 2012-2014, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006-2010, 2012-2014, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net> // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> @@ -27,11 +27,13 @@ // Copyright (C) 2012 Oliver Sander <sander@mi.fu-berlin.de> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2012 Even Rouault <even.rouault@mines-paris.org> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> // Copyright (C) 2013 Pino Toscano <pino@kde.org> // Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2015 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2017 Jose Aliste <jaliste@src.gnome.org> +// Copyright (C) 2017 Kay Dohmann <k.dohmann@gmx.net> // // 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 @@ -92,7 +94,7 @@ static GBool setDJSYSFLAGS = gFalse; #endif #endif -#if MULTITHREADED +#ifdef MULTITHREADED # define streamLocker() MutexLocker locker(&mutex) #else # define streamLocker() @@ -103,13 +105,13 @@ static GBool setDJSYSFLAGS = gFalse; Stream::Stream() { ref = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } Stream::~Stream() { -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } @@ -168,51 +170,45 @@ GooString *Stream::getPSFilter(int psLevel, const char *indent) { return new GooString(); } -Stream *Stream::addFilters(Object *dict, int recursion) { +Stream *Stream::addFilters(Dict *dict, int recursion) { Object obj, obj2; Object params, params2; Stream *str; int i; str = this; - dict->dictLookup("Filter", &obj, recursion); + obj = dict->lookup("Filter", recursion); if (obj.isNull()) { - obj.free(); - dict->dictLookup("F", &obj, recursion); + obj = dict->lookup("F", recursion); } - dict->dictLookup("DecodeParms", ¶ms, recursion); + params = dict->lookup("DecodeParms", recursion); if (params.isNull()) { - params.free(); - dict->dictLookup("DP", ¶ms, recursion); + params = dict->lookup("DP", recursion); } if (obj.isName()) { str = makeFilter(obj.getName(), str, ¶ms, recursion, dict); } else if (obj.isArray()) { for (i = 0; i < obj.arrayGetLength(); ++i) { - obj.arrayGet(i, &obj2, recursion); + obj2 = obj.arrayGet(i, recursion); if (params.isArray()) - params.arrayGet(i, ¶ms2, recursion); + params2 = params.arrayGet(i, recursion); else - params2.initNull(); + params2.setToNull(); if (obj2.isName()) { str = makeFilter(obj2.getName(), str, ¶ms2, recursion); } else { error(errSyntaxError, getPos(), "Bad filter name"); str = new EOFStream(str); } - obj2.free(); - params2.free(); } } else if (!obj.isNull()) { error(errSyntaxError, getPos(), "Bad 'Filter' attribute in stream"); } - obj.free(); - params.free(); return str; } -Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursion, Object *dict) { +Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursion, Dict *dict) { int pred; // parameters int colors; int bits; @@ -220,7 +216,6 @@ Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursio int encoding; GBool endOfLine, byteAlign, endOfBlock, black; int columns, rows; - int colorXform; Object globals, obj; if (!strcmp(name, "ASCIIHexDecode") || !strcmp(name, "AHx")) { @@ -234,26 +229,21 @@ Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursio bits = 8; early = 1; if (params->isDict()) { - params->dictLookup("Predictor", &obj, recursion); + obj = params->dictLookup("Predictor", recursion); if (obj.isInt()) pred = obj.getInt(); - obj.free(); - params->dictLookup("Columns", &obj, recursion); + obj = params->dictLookup("Columns", recursion); if (obj.isInt()) columns = obj.getInt(); - obj.free(); - params->dictLookup("Colors", &obj, recursion); + obj = params->dictLookup("Colors", recursion); if (obj.isInt()) colors = obj.getInt(); - obj.free(); - params->dictLookup("BitsPerComponent", &obj, recursion); + obj = params->dictLookup("BitsPerComponent", recursion); if (obj.isInt()) bits = obj.getInt(); - obj.free(); - params->dictLookup("EarlyChange", &obj, recursion); + obj = params->dictLookup("EarlyChange", recursion); if (obj.isInt()) early = obj.getInt(); - obj.free(); } str = new LZWStream(str, pred, columns, colors, bits, early); } else if (!strcmp(name, "RunLengthDecode") || !strcmp(name, "RL")) { @@ -267,88 +257,85 @@ Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursio endOfBlock = gTrue; black = gFalse; if (params->isDict()) { - params->dictLookup("K", &obj, recursion); + obj = params->dictLookup("K", recursion); if (obj.isInt()) { encoding = obj.getInt(); } - obj.free(); - params->dictLookup("EndOfLine", &obj, recursion); + obj = params->dictLookup("EndOfLine", recursion); if (obj.isBool()) { endOfLine = obj.getBool(); } - obj.free(); - params->dictLookup("EncodedByteAlign", &obj, recursion); + obj = params->dictLookup("EncodedByteAlign", recursion); if (obj.isBool()) { byteAlign = obj.getBool(); } - obj.free(); - params->dictLookup("Columns", &obj, recursion); + obj = params->dictLookup("Columns", recursion); if (obj.isInt()) { columns = obj.getInt(); } - obj.free(); - params->dictLookup("Rows", &obj, recursion); + obj = params->dictLookup("Rows", recursion); if (obj.isInt()) { rows = obj.getInt(); } - obj.free(); - params->dictLookup("EndOfBlock", &obj, recursion); + obj = params->dictLookup("EndOfBlock", recursion); if (obj.isBool()) { endOfBlock = obj.getBool(); } - obj.free(); - params->dictLookup("BlackIs1", &obj, recursion); + obj = params->dictLookup("BlackIs1", recursion); if (obj.isBool()) { black = obj.getBool(); } - obj.free(); } str = new CCITTFaxStream(str, encoding, endOfLine, byteAlign, columns, rows, endOfBlock, black); } else if (!strcmp(name, "DCTDecode") || !strcmp(name, "DCT")) { - colorXform = -1; +#ifdef HAVE_DCT_DECODER + int colorXform = -1; if (params->isDict()) { - if (params->dictLookup("ColorTransform", &obj, recursion)->isInt()) { + obj = params->dictLookup("ColorTransform", recursion); + if (obj.isInt()) { colorXform = obj.getInt(); } - obj.free(); } str = new DCTStream(str, colorXform, dict, recursion); +#else + error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name); + str = new EOFStream(str); +#endif } else if (!strcmp(name, "FlateDecode") || !strcmp(name, "Fl")) { pred = 1; columns = 1; colors = 1; bits = 8; if (params->isDict()) { - params->dictLookup("Predictor", &obj, recursion); + obj = params->dictLookup("Predictor", recursion); if (obj.isInt()) pred = obj.getInt(); - obj.free(); - params->dictLookup("Columns", &obj, recursion); + obj = params->dictLookup("Columns", recursion); if (obj.isInt()) columns = obj.getInt(); - obj.free(); - params->dictLookup("Colors", &obj, recursion); + obj = params->dictLookup("Colors", recursion); if (obj.isInt()) colors = obj.getInt(); - obj.free(); - params->dictLookup("BitsPerComponent", &obj, recursion); + obj = params->dictLookup("BitsPerComponent", recursion); if (obj.isInt()) bits = obj.getInt(); - obj.free(); } str = new FlateStream(str, pred, columns, colors, bits); } else if (!strcmp(name, "JBIG2Decode")) { if (params->isDict()) { XRef *xref = params->getDict()->getXRef(); - params->dictLookupNF("JBIG2Globals", &obj); - obj.fetch(xref, &globals, recursion); + obj = params->dictLookupNF("JBIG2Globals"); + globals = obj.fetch(xref, recursion); } str = new JBIG2Stream(str, &globals, &obj); - globals.free(); - obj.free(); } else if (!strcmp(name, "JPXDecode")) { +#ifdef HAVE_JPX_DECODER str = new JPXStream(str); +#else + error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name); + str = new EOFStream(str); +#endif } else if (!strcmp(name, "Crypt")) { if (str->getKind() == strCrypt) { str = str->getBaseStream(); @@ -367,7 +354,6 @@ Stream *Stream::makeFilter(char *name, Stream *str, Object *params, int recursio //------------------------------------------------------------------------ OutStream::OutStream () { - ref = 1; } OutStream::~OutStream () @@ -416,13 +402,12 @@ void FileOutStream::printf(const char *format, ...) // BaseStream //------------------------------------------------------------------------ -BaseStream::BaseStream(Object *dictA, Goffset lengthA) { - dict = *dictA; +BaseStream::BaseStream(Object &&dictA, Goffset lengthA) { + dict = std::move(dictA); length = lengthA; } BaseStream::~BaseStream() { - dict.free(); } //------------------------------------------------------------------------ @@ -458,7 +443,7 @@ ImageStream::ImageStream(Stream *strA, int widthA, int nCompsA, int nBitsA) { nVals = width * nComps; inputLineSize = (nVals * nBits + 7) >> 3; - if (nBits <= 0 || nVals > INT_MAX / nBits - 7 || width > INT_MAX / nComps) { + if (nComps <= 0 || nBits <= 0 || nVals > INT_MAX / nBits - 7 || width > INT_MAX / nComps) { inputLineSize = -1; } inputLine = (Guchar *)gmallocn_checkoverflow(inputLineSize, sizeof(char)); @@ -470,11 +455,10 @@ ImageStream::ImageStream(Stream *strA, int widthA, int nCompsA, int nBitsA) { } else { imgLineSize = nVals; } - if (width > INT_MAX / nComps) { - // force a call to gmallocn(-1,...), which will throw an exception + if (nComps <= 0 || width > INT_MAX / nComps) { imgLineSize = -1; } - imgLine = (Guchar *)gmallocn(imgLineSize, sizeof(Guchar)); + imgLine = (Guchar *)gmallocn_checkoverflow(imgLineSize, sizeof(Guchar)); } imgIdx = nVals; } @@ -771,8 +755,8 @@ GBool StreamPredictor::getNextLine() { //------------------------------------------------------------------------ FileStream::FileStream(GooFile* fileA, Goffset startA, GBool limitedA, - Goffset lengthA, Object *dictA): - BaseStream(dictA, lengthA) { + Goffset lengthA, Object &&dictA): + BaseStream(std::move(dictA), lengthA) { file = fileA; offset = start = startA; limited = limitedA; @@ -788,12 +772,12 @@ FileStream::~FileStream() { } BaseStream *FileStream::copy() { - return new FileStream(file, start, limited, length, &dict); + return new FileStream(file, start, limited, length, dict.copy()); } Stream *FileStream::makeSubStream(Goffset startA, GBool limitedA, - Goffset lengthA, Object *dictA) { - return new FileStream(file, startA, limitedA, lengthA, dictA); + Goffset lengthA, Object &&dictA) { + return new FileStream(file, startA, limitedA, lengthA, std::move(dictA)); } void FileStream::reset() { @@ -862,8 +846,8 @@ void FileStream::moveStart(Goffset delta) { //------------------------------------------------------------------------ CachedFileStream::CachedFileStream(CachedFile *ccA, Goffset startA, - GBool limitedA, Goffset lengthA, Object *dictA) - : BaseStream(dictA, lengthA) + GBool limitedA, Goffset lengthA, Object &&dictA) + : BaseStream(std::move(dictA), lengthA) { cc = ccA; start = startA; @@ -883,14 +867,14 @@ CachedFileStream::~CachedFileStream() BaseStream *CachedFileStream::copy() { cc->incRefCnt(); - return new CachedFileStream(cc, start, limited, length, &dict); + return new CachedFileStream(cc, start, limited, length, dict.copy()); } Stream *CachedFileStream::makeSubStream(Goffset startA, GBool limitedA, - Goffset lengthA, Object *dictA) + Goffset lengthA, Object &&dictA) { cc->incRefCnt(); - return new CachedFileStream(cc, startA, limitedA, lengthA, dictA); + return new CachedFileStream(cc, startA, limitedA, lengthA, std::move(dictA)); } void CachedFileStream::reset() @@ -965,8 +949,8 @@ void CachedFileStream::moveStart(Goffset delta) // MemStream //------------------------------------------------------------------------ -MemStream::MemStream(char *bufA, Goffset startA, Goffset lengthA, Object *dictA): - BaseStream(dictA, lengthA) { +MemStream::MemStream(char *bufA, Goffset startA, Goffset lengthA, Object &&dictA): + BaseStream(std::move(dictA), lengthA) { buf = bufA; start = startA; length = lengthA; @@ -982,11 +966,11 @@ MemStream::~MemStream() { } BaseStream *MemStream::copy() { - return new MemStream(buf, start, length, &dict); + return new MemStream(buf, start, length, dict.copy()); } Stream *MemStream::makeSubStream(Goffset startA, GBool limited, - Goffset lengthA, Object *dictA) { + Goffset lengthA, Object &&dictA) { MemStream *subStr; Goffset newLength; @@ -995,7 +979,7 @@ Stream *MemStream::makeSubStream(Goffset startA, GBool limited, } else { newLength = lengthA; } - subStr = new MemStream(buf, startA, newLength, dictA); + subStr = new MemStream(buf, startA, newLength, std::move(dictA)); return subStr; } @@ -1048,15 +1032,26 @@ void MemStream::moveStart(Goffset delta) { // EmbedStream //------------------------------------------------------------------------ -EmbedStream::EmbedStream(Stream *strA, Object *dictA, - GBool limitedA, Goffset lengthA): - BaseStream(dictA, lengthA) { +EmbedStream::EmbedStream(Stream *strA, Object &&dictA, + GBool limitedA, Goffset lengthA, GBool reusableA): + BaseStream(std::move(dictA), lengthA) { str = strA; limited = limitedA; length = lengthA; + reusable = reusableA; + record = gFalse; + replay = gFalse; + if (reusable) { + bufData = (unsigned char*)gmalloc(16384); + bufMax = 16384; + bufLen = 0; + record = gTrue; + } } EmbedStream::~EmbedStream() { + if (reusable) + gfree(bufData); } BaseStream *EmbedStream::copy() { @@ -1065,36 +1060,99 @@ BaseStream *EmbedStream::copy() { } Stream *EmbedStream::makeSubStream(Goffset start, GBool limitedA, - Goffset lengthA, Object *dictA) { + Goffset lengthA, Object &&dictA) { error(errInternal, -1, "Called makeSubStream() on EmbedStream"); return NULL; } +void EmbedStream::rewind() { + record = gFalse; + replay = gTrue; + bufPos = 0; +} + +void EmbedStream::restore() { + replay = gFalse; +} + +Goffset EmbedStream::getPos() { + if (replay) + return bufPos; + else + return str->getPos(); +} + int EmbedStream::getChar() { - if (limited && !length) { - return EOF; + if (replay) { + if (bufPos < bufLen) + return bufData[bufPos++]; + else + return EOF; + } else { + if (limited && !length) { + return EOF; + } + int c = str->getChar(); + --length; + if (record) { + bufData[bufLen] = c; + bufLen++; + if (bufLen >= bufMax) { + bufMax *= 2; + bufData = (unsigned char *)grealloc(bufData, bufMax); + } + } + return c; } - --length; - return str->getChar(); } int EmbedStream::lookChar() { - if (limited && !length) { - return EOF; + if (replay) { + if (bufPos < bufLen) + return bufData[bufPos]; + else + return EOF; + } else { + if (limited && !length) { + return EOF; + } + return str->lookChar(); } - return str->lookChar(); } int EmbedStream::getChars(int nChars, Guchar *buffer) { + int len; + if (nChars <= 0) { return 0; } - if (limited && length < nChars) { - nChars = length; + if (replay) { + if (bufPos >= bufLen) + return EOF; + len = bufLen - bufPos; + if (nChars > len) + nChars = len; + memcpy(buffer, bufData, len); + return len; + } else { + if (limited && length < nChars) { + nChars = length; + } + len = str->doGetChars(nChars, buffer); + if (record) { + if (bufLen + len >= bufMax) { + while (bufLen + len >= bufMax) + bufMax *= 2; + bufData = (unsigned char *)grealloc(bufData, bufMax); + } + memcpy(bufData+bufLen, buffer, len); + bufLen += len; + } } - return str->doGetChars(nChars, buffer); + return len; } + void EmbedStream::setPos(Goffset pos, int dir) { error(errInternal, -1, "Internal: called setPos() on EmbedStream"); } @@ -1404,11 +1462,6 @@ GBool LZWStream::processNextCode() { clearTable(); goto start; } - if (nextCode >= 4097) { - error(errSyntaxError, getPos(), - "Bad LZW stream - expected clear-table code"); - clearTable(); - } // process the next code nextLength = seqLength + 1; @@ -1434,10 +1487,12 @@ GBool LZWStream::processNextCode() { if (first) { first = gFalse; } else { - table[nextCode].length = nextLength; - table[nextCode].head = prevCode; - table[nextCode].tail = newChar; - ++nextCode; + if (nextCode < 4097) { + table[nextCode].length = nextLength; + table[nextCode].head = prevCode; + table[nextCode].tail = newChar; + ++nextCode; + } if (nextCode + early == 512) nextBits = 10; else if (nextCode + early == 1024) @@ -2435,7 +2490,7 @@ static const int dctZigZag[64] = { 63 }; -DCTStream::DCTStream(Stream *strA, int colorXformA, Object *dict, int recursion): +DCTStream::DCTStream(Stream *strA, int colorXformA, Dict *dict, int recursion): FilterStream(strA) { int i, j; @@ -3575,6 +3630,12 @@ GBool DCTStream::readProgressiveSOF() { height = read16(); width = read16(); numComps = str->getChar(); + + if (numComps <= 0 || numComps > 4) { + error(errSyntaxError, getPos(), "Bad number of components in DCT stream"); + numComps = 0; + return gFalse; + } if (prec != 8) { error(errSyntaxError, getPos(), "Bad DCT precision {0:d}", prec); return gFalse; diff --git a/Build/source/libs/poppler/poppler-src/poppler/Stream.h b/Build/source/libs/poppler/poppler-src/poppler/Stream.h index 07b3933ac85..152dbb0fea1 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/Stream.h +++ b/Build/source/libs/poppler/poppler-src/poppler/Stream.h @@ -15,14 +15,14 @@ // // Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net> -// Copyright (C) 2008, 2010, 2011, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2010, 2011, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2011, 2012, 2016 William Bader <williambader@hotmail.com> // Copyright (C) 2012, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de> // Copyright (C) 2013 Adam Reichold <adamreichold@myopera.com> // Copyright (C) 2013 Pino Toscano <pino@kde.org> @@ -105,10 +105,6 @@ public: // Destructor. virtual ~Stream(); - // Reference counting. - int incRef(); - int decRef(); - // Get kind of stream. virtual StreamKind getKind() = 0; @@ -213,6 +209,7 @@ public: // Get the dictionary associated with this stream. virtual Dict *getDict() = 0; + virtual Object *getDictObject() = 0; // Is this an encoding filter? virtual GBool isEncoder() { return gFalse; } @@ -226,16 +223,22 @@ public: // Add filters to this stream according to the parameters in <dict>. // Returns the new stream. - Stream *addFilters(Object *dict, int recursion = 0); + Stream *addFilters(Dict *dict, int recursion = 0); private: + friend class Object; // for incRef/decRef + + // Reference counting. + int incRef(); + int decRef(); + virtual GBool hasGetChars() { return false; } virtual int getChars(int nChars, Guchar *buffer); - Stream *makeFilter(char *name, Stream *str, Object *params, int recursion = 0, Object *dict = NULL); + Stream *makeFilter(char *name, Stream *str, Object *params, int recursion = 0, Dict *dict = nullptr); int ref; // reference count -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; @@ -254,10 +257,6 @@ public: // Desctructor. virtual ~OutStream (); - // Reference counting. - int incRef() { return ++ref; } - int decRef() { return --ref; } - // Close the stream virtual void close() = 0; @@ -268,10 +267,6 @@ public: virtual void put (char c) = 0; virtual void printf (const char *format, ...) GCC_PRINTF_FORMAT(2,3) = 0; - -private: - int ref; // reference count - }; //------------------------------------------------------------------------ @@ -281,15 +276,15 @@ class FileOutStream : public OutStream { public: FileOutStream (FILE* fa, Goffset startA); - virtual ~FileOutStream (); + ~FileOutStream (); - virtual void close(); + void close() override; - virtual Goffset getPos(); + Goffset getPos() override; - virtual void put (char c); + void put (char c) override; - virtual void printf (const char *format, ...); + void printf (const char *format, ...) override GCC_PRINTF_FORMAT(2,3); private: FILE *f; Goffset start; @@ -306,16 +301,18 @@ private: class BaseStream: public Stream { public: - BaseStream(Object *dictA, Goffset lengthA); - virtual ~BaseStream(); + // TODO Mirar si puedo hacer que dictA sea un puntero + BaseStream(Object &&dictA, Goffset lengthA); + ~BaseStream(); virtual BaseStream *copy() = 0; virtual Stream *makeSubStream(Goffset start, GBool limited, - Goffset length, Object *dict) = 0; - virtual void setPos(Goffset pos, int dir = 0) = 0; - virtual GBool isBinary(GBool last = gTrue) { return last; } - virtual BaseStream *getBaseStream() { return this; } - virtual Stream *getUndecodedStream() { return this; } - virtual Dict *getDict() { return dict.getDict(); } + Goffset length, Object &&dict) = 0; + void setPos(Goffset pos, int dir = 0) override = 0; + GBool isBinary(GBool last = gTrue) override { return last; } + BaseStream *getBaseStream() override { return this; } + Stream *getUndecodedStream() override { return this; } + Dict *getDict() override { return dict.getDict(); } + Object *getDictObject() override { return &dict; } virtual GooString *getFileName() { return NULL; } virtual Goffset getLength() { return length; } @@ -339,17 +336,18 @@ class FilterStream: public Stream { public: FilterStream(Stream *strA); - virtual ~FilterStream(); - virtual void close(); - virtual Goffset getPos() { return str->getPos(); } - virtual void setPos(Goffset pos, int dir = 0); - virtual BaseStream *getBaseStream() { return str->getBaseStream(); } - virtual Stream *getUndecodedStream() { return str->getUndecodedStream(); } - virtual Dict *getDict() { return str->getDict(); } - virtual Stream *getNextStream() { return str; } - - virtual int getUnfilteredChar () { return str->getUnfilteredChar(); } - virtual void unfilteredReset () { str->unfilteredReset(); } + ~FilterStream(); + void close() override; + Goffset getPos() override { return str->getPos(); } + void setPos(Goffset pos, int dir = 0) override; + BaseStream *getBaseStream() override { return str->getBaseStream(); } + Stream *getUndecodedStream() override { return str->getUndecodedStream(); } + Dict *getDict() override { return str->getDict(); } + Object *getDictObject() override { return str->getDictObject(); } + Stream *getNextStream() override { return str; } + + int getUnfilteredChar () override { return str->getUnfilteredChar(); } + void unfilteredReset () override { str->unfilteredReset(); } protected: @@ -447,32 +445,32 @@ class FileStream: public BaseStream { public: FileStream(GooFile* fileA, Goffset startA, GBool limitedA, - Goffset lengthA, Object *dictA); - virtual ~FileStream(); - virtual BaseStream *copy(); - virtual Stream *makeSubStream(Goffset startA, GBool limitedA, - Goffset lengthA, Object *dictA); - virtual StreamKind getKind() { return strFile; } - virtual void reset(); - virtual void close(); - virtual int getChar() + Goffset lengthA, Object &&dictA); + ~FileStream(); + BaseStream *copy() override; + Stream *makeSubStream(Goffset startA, GBool limitedA, + Goffset lengthA, Object &&dictA) override; + StreamKind getKind() override { return strFile; } + void reset() override; + void close() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual Goffset getPos() { return bufPos + (bufPtr - buf); } - virtual void setPos(Goffset pos, int dir = 0); - virtual Goffset getStart() { return start; } - virtual void moveStart(Goffset delta); + Goffset getPos() override { return bufPos + (bufPtr - buf); } + void setPos(Goffset pos, int dir = 0) override; + Goffset getStart() override { return start; } + void moveStart(Goffset delta) override; - virtual int getUnfilteredChar () { return getChar(); } - virtual void unfilteredReset () { reset(); } + int getUnfilteredChar () override { return getChar(); } + void unfilteredReset () override { reset(); } private: GBool fillBuf(); - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer) + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override { int n, m; @@ -517,25 +515,25 @@ class CachedFileStream: public BaseStream { public: CachedFileStream(CachedFile *ccA, Goffset startA, GBool limitedA, - Goffset lengthA, Object *dictA); - virtual ~CachedFileStream(); - virtual BaseStream *copy(); - virtual Stream *makeSubStream(Goffset startA, GBool limitedA, - Goffset lengthA, Object *dictA); - virtual StreamKind getKind() { return strCachedFile; } - virtual void reset(); - virtual void close(); - virtual int getChar() + Goffset lengthA, Object &&dictA); + ~CachedFileStream(); + BaseStream *copy() override; + Stream *makeSubStream(Goffset startA, GBool limitedA, + Goffset lengthA, Object &&dictA) override; + StreamKind getKind() override { return strCachedFile; } + void reset() override; + void close() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual Goffset getPos() { return bufPos + (bufPtr - buf); } - virtual void setPos(Goffset pos, int dir = 0); - virtual Goffset getStart() { return start; } - virtual void moveStart(Goffset delta); + Goffset getPos() override { return bufPos + (bufPtr - buf); } + void setPos(Goffset pos, int dir = 0) override; + Goffset getStart() override { return start; } + void moveStart(Goffset delta) override; - virtual int getUnfilteredChar () { return getChar(); } - virtual void unfilteredReset () { reset(); } + int getUnfilteredChar () override { return getChar(); } + void unfilteredReset () override { reset(); } private: @@ -560,34 +558,34 @@ private: class MemStream: public BaseStream { public: - MemStream(char *bufA, Goffset startA, Goffset lengthA, Object *dictA); - virtual ~MemStream(); - virtual BaseStream *copy(); - virtual Stream *makeSubStream(Goffset start, GBool limited, - Goffset lengthA, Object *dictA); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual void close(); - virtual int getChar() + MemStream(char *bufA, Goffset startA, Goffset lengthA, Object &&dictA); + ~MemStream(); + BaseStream *copy() override; + Stream *makeSubStream(Goffset start, GBool limited, + Goffset lengthA, Object &&dictA) override; + StreamKind getKind() override { return strWeird; } + void reset() override; + void close() override; + int getChar() override { return (bufPtr < bufEnd) ? (*bufPtr++ & 0xff) : EOF; } - virtual int lookChar() + int lookChar() override { return (bufPtr < bufEnd) ? (*bufPtr & 0xff) : EOF; } - virtual Goffset getPos() { return (int)(bufPtr - buf); } - virtual void setPos(Goffset pos, int dir = 0); - virtual Goffset getStart() { return start; } - virtual void moveStart(Goffset delta); + Goffset getPos() override { return (int)(bufPtr - buf); } + void setPos(Goffset pos, int dir = 0) override; + Goffset getStart() override { return start; } + void moveStart(Goffset delta) override; //if needFree = true, the stream will delete buf when it is destroyed //otherwise it will not touch it. Default value is false virtual void setNeedFree (GBool val) { needFree = val; } - virtual int getUnfilteredChar () { return getChar(); } - virtual void unfilteredReset () { reset (); } + int getUnfilteredChar () override { return getChar(); } + void unfilteredReset () override { reset (); } private: - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; char *buf; Goffset start; @@ -609,31 +607,41 @@ private: class EmbedStream: public BaseStream { public: - EmbedStream(Stream *strA, Object *dictA, GBool limitedA, Goffset lengthA); - virtual ~EmbedStream(); - virtual BaseStream *copy(); - virtual Stream *makeSubStream(Goffset start, GBool limitedA, - Goffset lengthA, Object *dictA); - virtual StreamKind getKind() { return str->getKind(); } - virtual void reset() {} - virtual int getChar(); - virtual int lookChar(); - virtual Goffset getPos() { return str->getPos(); } - virtual void setPos(Goffset pos, int dir = 0); - virtual Goffset getStart(); - virtual void moveStart(Goffset delta); - - virtual int getUnfilteredChar () { return str->getUnfilteredChar(); } - virtual void unfilteredReset () { str->unfilteredReset(); } - + EmbedStream(Stream *strA, Object &&dictA, GBool limitedA, Goffset lengthA, GBool reusableA = gFalse); + ~EmbedStream(); + BaseStream *copy() override; + Stream *makeSubStream(Goffset start, GBool limitedA, + Goffset lengthA, Object &&dictA) override; + StreamKind getKind() override { return str->getKind(); } + void reset() override {} + int getChar() override; + int lookChar() override; + Goffset getPos() override; + void setPos(Goffset pos, int dir = 0) override; + Goffset getStart() override; + void moveStart(Goffset delta) override; + + int getUnfilteredChar () override { return str->getUnfilteredChar(); } + void unfilteredReset () override { str->unfilteredReset(); } + + void rewind(); + void restore(); private: - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; Stream *str; GBool limited; + GBool reusable; + GBool record; + GBool replay; + unsigned char *bufData; + long bufMax; + long bufLen; + long bufPos; + }; //------------------------------------------------------------------------ @@ -644,14 +652,14 @@ class ASCIIHexStream: public FilterStream { public: ASCIIHexStream(Stream *strA); - virtual ~ASCIIHexStream(); - virtual StreamKind getKind() { return strASCIIHex; } - virtual void reset(); - virtual int getChar() + ~ASCIIHexStream(); + StreamKind getKind() override { return strASCIIHex; } + void reset() override; + int getChar() override { int c = lookChar(); buf = EOF; return c; } - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; private: @@ -667,14 +675,14 @@ class ASCII85Stream: public FilterStream { public: ASCII85Stream(Stream *strA); - virtual ~ASCII85Stream(); - virtual StreamKind getKind() { return strASCII85; } - virtual void reset(); - virtual int getChar() + ~ASCII85Stream(); + StreamKind getKind() override { return strASCII85; } + void reset() override; + int getChar() override { int ch = lookChar(); ++index; return ch; } - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; private: @@ -693,20 +701,20 @@ public: LZWStream(Stream *strA, int predictor, int columns, int colors, int bits, int earlyA); - virtual ~LZWStream(); - virtual StreamKind getKind() { return strLZW; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar(); - virtual int getRawChar(); - virtual void getRawChars(int nChars, int *buffer); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + ~LZWStream(); + StreamKind getKind() override { return strLZW; } + void reset() override; + int getChar() override; + int lookChar() override; + int getRawChar() override; + void getRawChars(int nChars, int *buffer) override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; private: - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; inline int doGetRawChar() { if (eof) { @@ -752,20 +760,20 @@ class RunLengthStream: public FilterStream { public: RunLengthStream(Stream *strA); - virtual ~RunLengthStream(); - virtual StreamKind getKind() { return strRunLength; } - virtual void reset(); - virtual int getChar() + ~RunLengthStream(); + StreamKind getKind() override { return strRunLength; } + void reset() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; private: - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; char buf[128]; // buffer char *bufPtr; // next char to read @@ -787,16 +795,16 @@ public: CCITTFaxStream(Stream *strA, int encodingA, GBool endOfLineA, GBool byteAlignA, int columnsA, int rowsA, GBool endOfBlockA, GBool blackA); - virtual ~CCITTFaxStream(); - virtual StreamKind getKind() { return strCCITTFax; } - virtual void reset(); - virtual int getChar() + ~CCITTFaxStream(); + StreamKind getKind() override { return strCCITTFax; } + void reset() override; + int getChar() override { int c = lookChar(); buf = EOF; return c; } - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; - virtual void unfilteredReset (); + void unfilteredReset () override; int getEncoding() { return encoding; } GBool getEndOfLine() { return endOfLine; } @@ -868,17 +876,17 @@ struct DCTHuffTable { class DCTStream: public FilterStream { public: - DCTStream(Stream *strA, int colorXformA, Object *dict, int recursion); + DCTStream(Stream *strA, int colorXformA, Dict *dict, int recursion); virtual ~DCTStream(); - virtual StreamKind getKind() { return strDCT; } - virtual void reset(); - virtual void close(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); + StreamKind getKind() override { return strDCT; } + void reset() override; + void close() override; + int getChar() override; + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; - virtual void unfilteredReset(); + void unfilteredReset() override; private: @@ -977,16 +985,16 @@ public: FlateStream(Stream *strA, int predictor, int columns, int colors, int bits); - virtual ~FlateStream(); - virtual StreamKind getKind() { return strFlate; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar(); - virtual int getRawChar(); - virtual void getRawChars(int nChars, int *buffer); - virtual GooString *getPSFilter(int psLevel, const char *indent); - virtual GBool isBinary(GBool last = gTrue); - virtual void unfilteredReset (); + ~FlateStream(); + StreamKind getKind() override { return strFlate; } + void reset() override; + int getChar() override; + int lookChar() override; + int getRawChar() override; + void getRawChars(int nChars, int *buffer) override; + GooString *getPSFilter(int psLevel, const char *indent) override; + GBool isBinary(GBool last = gTrue) override; + void unfilteredReset () override; private: void flateReset(GBool unfiltered); @@ -1004,8 +1012,8 @@ private: return c; } - virtual GBool hasGetChars() { return true; } - virtual int getChars(int nChars, Guchar *buffer); + GBool hasGetChars() override { return true; } + int getChars(int nChars, Guchar *buffer) override; StreamPredictor *pred; // predictor Guchar buf[flateWindow]; // output data buffer @@ -1051,13 +1059,13 @@ class EOFStream: public FilterStream { public: EOFStream(Stream *strA); - virtual ~EOFStream(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset() {} - virtual int getChar() { return EOF; } - virtual int lookChar() { return EOF; } - virtual GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) { return NULL; } - virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; } + ~EOFStream(); + StreamKind getKind() override { return strWeird; } + void reset() override {} + int getChar() override { return EOF; } + int lookChar() override { return EOF; } + GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return NULL; } + GBool isBinary(GBool /*last = gTrue*/) override { return gFalse; } }; //------------------------------------------------------------------------ @@ -1068,14 +1076,14 @@ class BufStream: public FilterStream { public: BufStream(Stream *strA, int bufSizeA); - virtual ~BufStream(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent) + ~BufStream(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override; + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override { return NULL; } - virtual GBool isBinary(GBool last = gTrue); + GBool isBinary(GBool last = gTrue) override; int lookChar(int idx); @@ -1094,13 +1102,13 @@ public: FixedLengthEncoder(Stream *strA, int lengthA); ~FixedLengthEncoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) { return NULL; } - virtual GBool isBinary(GBool /*last = gTrue*/); - virtual GBool isEncoder() { return gTrue; } + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override; + int lookChar() override; + GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return NULL; } + GBool isBinary(GBool /*last = gTrue*/) override; + GBool isEncoder() override { return gTrue; } private: @@ -1116,16 +1124,16 @@ class ASCIIHexEncoder: public FilterStream { public: ASCIIHexEncoder(Stream *strA); - virtual ~ASCIIHexEncoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() + ~ASCIIHexEncoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) { return NULL; } - virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; } - virtual GBool isEncoder() { return gTrue; } + GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return NULL; } + GBool isBinary(GBool /*last = gTrue*/) override { return gFalse; } + GBool isEncoder() override { return gTrue; } private: @@ -1146,16 +1154,16 @@ class ASCII85Encoder: public FilterStream { public: ASCII85Encoder(Stream *strA); - virtual ~ASCII85Encoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() + ~ASCII85Encoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) { return NULL; } - virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; } - virtual GBool isEncoder() { return gTrue; } + GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return NULL; } + GBool isBinary(GBool /*last = gTrue*/) override { return gFalse; } + GBool isEncoder() override { return gTrue; } private: @@ -1176,16 +1184,16 @@ class RunLengthEncoder: public FilterStream { public: RunLengthEncoder(Stream *strA); - virtual ~RunLengthEncoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() + ~RunLengthEncoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) { return NULL; } - virtual GBool isBinary(GBool /*last = gTrue*/) { return gTrue; } - virtual GBool isEncoder() { return gTrue; } + GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return NULL; } + GBool isBinary(GBool /*last = gTrue*/) override { return gTrue; } + GBool isEncoder() override { return gTrue; } private: @@ -1212,15 +1220,15 @@ class LZWEncoder: public FilterStream { public: LZWEncoder(Stream *strA); - virtual ~LZWEncoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar(); - virtual int lookChar(); - virtual GooString *getPSFilter(int psLevel, const char *indent) + ~LZWEncoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override; + int lookChar() override; + GooString *getPSFilter(int psLevel, const char *indent) override { return NULL; } - virtual GBool isBinary(GBool last = gTrue) { return gTrue; } - virtual GBool isEncoder() { return gTrue; } + GBool isBinary(GBool last = gTrue) override { return gTrue; } + GBool isEncoder() override { return gTrue; } private: @@ -1244,16 +1252,16 @@ class CMYKGrayEncoder: public FilterStream { public: CMYKGrayEncoder(Stream *strA); - virtual ~CMYKGrayEncoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() + ~CMYKGrayEncoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) { return NULL; } - virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; } - virtual GBool isEncoder() { return gTrue; } + GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return NULL; } + GBool isBinary(GBool /*last = gTrue*/) override { return gFalse; } + GBool isEncoder() override { return gTrue; } private: @@ -1273,16 +1281,16 @@ class RGBGrayEncoder: public FilterStream { public: RGBGrayEncoder(Stream *strA); - virtual ~RGBGrayEncoder(); - virtual StreamKind getKind() { return strWeird; } - virtual void reset(); - virtual int getChar() + ~RGBGrayEncoder(); + StreamKind getKind() override { return strWeird; } + void reset() override; + int getChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } - virtual int lookChar() + int lookChar() override { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) { return NULL; } - virtual GBool isBinary(GBool /*last = gTrue*/) { return gFalse; } - virtual GBool isEncoder() { return gTrue; } + GooString *getPSFilter(int /*psLevel*/, const char * /*indent*/) override { return NULL; } + GBool isBinary(GBool /*last = gTrue*/) override { return gFalse; } + GBool isEncoder() override { return gTrue; } private: diff --git a/Build/source/libs/poppler/poppler-src/poppler/StructElement.cc b/Build/source/libs/poppler/poppler-src/poppler/StructElement.cc index c6688208fee..62925474350 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/StructElement.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/StructElement.cc @@ -6,7 +6,7 @@ // // Copyright 2013, 2014 Igalia S.L. // Copyright 2014 Luigi Scarso <luigi.scarso@gmail.com> -// Copyright 2014 Albert Astals Cid <aacid@kde.org> +// Copyright 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright 2015 Dmytro Morgun <lztoad@gmail.com> // //======================================================================== @@ -170,18 +170,15 @@ static GBool isRGBColor(Object *value) GBool okay = gTrue; for (int i = 0; i < 3; i++) { - Object obj; - if (!value->arrayGet(i, &obj)->isNum()) { + Object obj = value->arrayGet(i); + if (!obj.isNum()) { okay = gFalse; - obj.free(); break; } if (obj.getNum() < 0.0 || obj.getNum() > 1.0) { okay = gFalse; - obj.free(); break; } - obj.free(); } return okay; @@ -220,25 +217,22 @@ static GBool isTextString(Object *value) \ GBool okay = gTrue; \ for (int i = 0; i < value->arrayGetLength(); i++) { \ - Object obj; \ - value->arrayGet(i, &obj); \ + Object obj = value->arrayGet(i); \ if ((!allowNulls && obj.isNull()) || !checkItem(&obj)) { \ okay = gFalse; \ - obj.free(); \ break; \ } \ - obj.free(); \ } \ return okay; \ } -ARRAY_CHECKER(isRGBColorOrOptionalArray4, isRGBColor, 4, gTrue, gTrue ); -ARRAY_CHECKER(isPositiveOrOptionalArray4, isPositive, 4, gTrue, gTrue ); -ARRAY_CHECKER(isPositiveOrArray4, isPositive, 4, gTrue, gFalse); -ARRAY_CHECKER(isBorderStyle, isBorderStyleName, 4, gTrue, gTrue ); -ARRAY_CHECKER(isNumberArray4, isNumber, 4, gFalse, gFalse); -ARRAY_CHECKER(isNumberOrArrayN, isNumber, 0, gTrue, gFalse); -ARRAY_CHECKER(isTableHeaders, isTextString, 0, gFalse, gFalse); +ARRAY_CHECKER(isRGBColorOrOptionalArray4, isRGBColor, 4, gTrue, gTrue ) +ARRAY_CHECKER(isPositiveOrOptionalArray4, isPositive, 4, gTrue, gTrue ) +ARRAY_CHECKER(isPositiveOrArray4, isPositive, 4, gTrue, gFalse) +ARRAY_CHECKER(isBorderStyle, isBorderStyleName, 4, gTrue, gTrue ) +ARRAY_CHECKER(isNumberArray4, isNumber, 4, gFalse, gFalse) +ARRAY_CHECKER(isNumberOrArrayN, isNumber, 0, gTrue, gFalse) +ARRAY_CHECKER(isTableHeaders, isTextString, 0, gFalse, gFalse) // Type of functions used to do type-checking on attribute values @@ -254,46 +248,19 @@ struct AttributeMapEntry { }; struct AttributeDefaults { - Object Inline; - Object LrTb; - Object Normal; - Object Distribute; - Object off; - Object Zero; - Object Auto; - Object Start; - Object None; - Object Before; - Object Nat1; - - AttributeDefaults() { - Inline.initName("Inline"); - LrTb.initName("LrTb"); - Normal.initName("Normal"); - Distribute.initName("Distribute"); - off.initName("off"); - - Zero.initReal(0.0); - Auto.initName("Auto"); - Start.initName("Start"); - None.initName("None"); - Before.initName("Before"); - Nat1.initInt(1); - } - - ~AttributeDefaults() { - Inline.free(); - LrTb.free(); - Normal.free(); - Distribute.free(); - off.free(); - Zero.free(); - Auto.free(); - Start.free(); - None.free(); - Before.free(); - Nat1.free(); - } + AttributeDefaults() {}; // needed to support old clang + + Object Inline = Object(objName, "Inline"); + Object LrTb = Object(objName, "LrTb"); + Object Normal = Object(objName, "Normal"); + Object Distribute = Object(objName, "Distribute"); + Object off = Object(objName, "off"); + Object Zero = Object(0.0); + Object Auto = Object(objName, "Auto"); + Object Start = Object(objName, "Start"); + Object None = Object(objName, "None"); + Object Before = Object(objName, "Before"); + Object Nat1 = Object(1); }; static const AttributeDefaults attributeDefaults; @@ -704,7 +671,7 @@ Attribute::Attribute(const char *nameA, int nameLenA, Object *valueA): formatted(NULL) { assert(valueA); - valueA->copy(&value); + value = valueA->copy(); } Attribute::Attribute(Type type, Object *valueA): @@ -718,7 +685,7 @@ Attribute::Attribute(Type type, Object *valueA): { assert(valueA); - valueA->copy(&value); + value = valueA->copy(); if (!checkType()) type = Unknown; @@ -727,7 +694,6 @@ Attribute::Attribute(Type type, Object *valueA): Attribute::~Attribute() { delete formatted; - value.free(); } const char *Attribute::getTypeName() const @@ -805,10 +771,11 @@ Attribute::Type Attribute::getTypeForName(const char *name, StructElement *eleme Attribute *Attribute::parseUserProperty(Dict *property) { Object obj, value; - const char *name = NULL; + const char *name = nullptr; int nameLen = GooString::CALC_STRING_LEN; - if (property->lookup("N", &obj)->isString()) { + obj = property->lookup("N"); + if (obj.isString()) { GooString *s = obj.getString(); name = s->getCString(); nameLen = s->getLength(); @@ -816,34 +783,29 @@ Attribute *Attribute::parseUserProperty(Dict *property) name = obj.getName(); else { error(errSyntaxError, -1, "N object is wrong type ({0:s})", obj.getTypeName()); - obj.free(); - return NULL; + return nullptr; } - if (property->lookup("V", &value)->isNull()) { + value = property->lookup("V"); + if (value.isNull()) { error(errSyntaxError, -1, "V object is wrong type ({0:s})", value.getTypeName()); - value.free(); - obj.free(); - return NULL; + return nullptr; } Attribute *attribute = new Attribute(name, nameLen, &value); - value.free(); - obj.free(); - - if (property->lookup("F", &obj)->isString()) { + obj = property->lookup("F"); + if (obj.isString()) { attribute->setFormattedValue(obj.getString()->getCString()); } else if (!obj.isNull()) { error(errSyntaxWarning, -1, "F object is wrong type ({0:s})", obj.getTypeName()); } - obj.free(); - if (property->lookup("H", &obj)->isBool()) { + obj = property->lookup("H"); + if (obj.isBool()) { attribute->setHidden(obj.getBool()); } else if (!obj.isNull()) { error(errSyntaxWarning, -1, "H object is wrong type ({0:s})", obj.getTypeName()); } - obj.free(); return attribute; } @@ -871,7 +833,6 @@ StructElement::StructData::~StructData() delete id; delete title; delete language; - parentRef.free(); for (ElemPtrArray::iterator i = elements.begin(); i != elements.end(); ++i) delete *i; for (AttrPtrArray::iterator i = attributes.begin(); i != attributes.end(); ++i) delete *i; } @@ -919,7 +880,6 @@ StructElement::~StructElement() delete c; else delete s; - pageRef.free(); } GBool StructElement::isBlock() const @@ -1058,21 +1018,22 @@ const TextSpanArray& StructElement::getTextSpansInternal(MarkedContentOutputDev& return mcdev.getTextSpans(); } -static StructElement::Type roleMapResolve(Dict *roleMap, const char *name, const char *curName, Object *resolved) +static StructElement::Type roleMapResolve(Dict *roleMap, const char *name, const char *curName) { // Circular reference if (curName && !strcmp(name, curName)) return StructElement::Unknown; - if (roleMap->lookup(curName ? curName : name, resolved)->isName()) { - StructElement::Type type = nameToType(resolved->getName()); + Object resolved = roleMap->lookup(curName ? curName : name); + if (resolved.isName()) { + StructElement::Type type = nameToType(resolved.getName()); return type == StructElement::Unknown - ? roleMapResolve(roleMap, name, resolved->getName(), resolved) + ? roleMapResolve(roleMap, name, resolved.getName()) : type; } - if (!resolved->isNull()) - error(errSyntaxWarning, -1, "RoleMap entry is wrong type ({0:s})", resolved->getTypeName()); + if (!resolved.isNull()) + error(errSyntaxWarning, -1, "RoleMap entry is wrong type ({0:s})", resolved.getTypeName()); return StructElement::Unknown; } @@ -1081,31 +1042,30 @@ void StructElement::parse(Dict *element) Object obj; // Type is optional, but if present must be StructElem - if (!element->lookup("Type", &obj)->isNull() && !obj.isName("StructElem")) { + obj = element->lookup("Type"); + if (!obj.isNull() && !obj.isName("StructElem")) { error(errSyntaxError, -1, "Type of StructElem object is wrong"); - obj.free(); return; } - obj.free(); // Parent object reference (required). - if (!element->lookupNF("P", &s->parentRef)->isRef()) { + s->parentRef = element->lookupNF("P"); + if (!s->parentRef.isRef()) { error(errSyntaxError, -1, "P object is wrong type ({0:s})", obj.getTypeName()); return; } // Check whether the S-type is valid for the top level // element and create a node of the appropriate type. - if (!element->lookup("S", &obj)->isName()) { + obj = element->lookup("S"); + if (!obj.isName()) { error(errSyntaxError, -1, "S object is wrong type ({0:s})", obj.getTypeName()); - obj.free(); return; } // Type name may not be standard, resolve through RoleMap first. if (treeRoot->getRoleMap()) { - Object resolvedName; - type = roleMapResolve(treeRoot->getRoleMap(), obj.getName(), NULL, &resolvedName); + type = roleMapResolve(treeRoot->getRoleMap(), obj.getName(), NULL); } // Resolving through RoleMap may leave type as Unknown, e.g. for types @@ -1116,67 +1076,66 @@ void StructElement::parse(Dict *element) // At this point either the type name must have been resolved. if (type == Unknown) { error(errSyntaxError, -1, "StructElem object is wrong type ({0:s})", obj.getName()); - obj.free(); return; } - obj.free(); // Object ID (optional), to be looked at the IDTree in the tree root. - if (element->lookup("ID", &obj)->isString()) { + obj = element->lookup("ID"); + if (obj.isString()) { s->id = obj.takeString(); } - obj.free(); // Page reference (optional) in which at least one of the child items // is to be rendered in. Note: each element stores only the /Pg value // contained by it, and StructElement::getPageRef() may look in parent // elements to find the page where an element belongs. - element->lookupNF("Pg", &pageRef); + pageRef = element->lookupNF("Pg"); // Revision number (optional). - if (element->lookup("R", &obj)->isInt()) { + obj = element->lookup("R"); + if (obj.isInt()) { s->revision = obj.getInt(); } - obj.free(); // Element title (optional). - if (element->lookup("T", &obj)->isString()) { + obj = element->lookup("T"); + if (obj.isString()) { s->title = obj.takeString(); } - obj.free(); // Language (optional). - if (element->lookup("Lang", &obj)->isString()) { + obj = element->lookup("Lang"); + if (obj.isString()) { s->language = obj.takeString(); } - obj.free(); // Alternative text (optional). - if (element->lookup("Alt", &obj)->isString()) { + obj = element->lookup("Alt"); + if (obj.isString()) { s->altText = obj.takeString(); } - obj.free(); // Expanded form of an abbreviation (optional). - if (element->lookup("E", &obj)->isString()) { + obj = element->lookup("E"); + if (obj.isString()) { s->expandedAbbr = obj.takeString(); } - obj.free(); // Actual text (optional). - if (element->lookup("ActualText", &obj)->isString()) { + obj = element->lookup("ActualText"); + if (obj.isString()) { s->actualText = obj.takeString(); } - obj.free(); // Attributes directly attached to the element (optional). - if (element->lookup("A", &obj)->isDict()) { + obj = element->lookup("A"); + if (obj.isDict()) { parseAttributes(obj.getDict()); } else if (obj.isArray()) { - Object iobj; unsigned attrIndex = getNumAttributes(); for (int i = 0; i < obj.arrayGetLength(); i++) { - if (obj.arrayGet(i, &iobj)->isDict()) { + Object iobj = obj.arrayGet(i); + if (iobj.isDict()) { attrIndex = getNumAttributes(); parseAttributes(iobj.getDict()); } else if (iobj.isInt()) { @@ -1187,25 +1146,23 @@ void StructElement::parse(Dict *element) } else { error(errSyntaxWarning, -1, "A item is wrong type ({0:s})", iobj.getTypeName()); } - iobj.free(); } } else if (!obj.isNull()) { error(errSyntaxWarning, -1, "A is wrong type ({0:s})", obj.getTypeName()); } - obj.free(); // Attributes referenced indirectly through the ClassMap (optional). if (treeRoot->getClassMap()) { - Object classes; - if (element->lookup("C", &classes)->isName()) { - Object attr; - if (treeRoot->getClassMap()->lookup(classes.getName(), &attr)->isDict()) { + Object classes = element->lookup("C"); + if (classes.isName()) { + Object attr = treeRoot->getClassMap()->lookup(classes.getName()); + if (attr.isDict()) { parseAttributes(attr.getDict(), gTrue); } else if (attr.isArray()) { for (int i = 0; i < attr.arrayGetLength(); i++) { - Object iobj; unsigned attrIndex = getNumAttributes(); - if (attr.arrayGet(i, &iobj)->isDict()) { + Object iobj = attr.arrayGet(i); + if (iobj.isDict()) { attrIndex = getNumAttributes(); parseAttributes(iobj.getDict(), gTrue); } else if (iobj.isInt()) { @@ -1216,13 +1173,10 @@ void StructElement::parse(Dict *element) } else { error(errSyntaxWarning, -1, "C item is wrong type ({0:s})", iobj.getTypeName()); } - iobj.free(); } } else if (!attr.isNull()) { error(errSyntaxWarning, -1, "C object is wrong type ({0:s})", classes.getTypeName()); } - classes.free(); - attr.free(); } } } @@ -1243,40 +1197,31 @@ StructElement *StructElement::parseChild(Object *ref, * TODO: The optional Stm/StwOwn attributes are not handled, so all the * page will be always scanned when calling StructElement::getText(). */ - Object mcidObj; - Object pageRefObj; - - if (!childObj->dictLookup("MCID", &mcidObj)->isInt()) { + Object mcidObj = childObj->dictLookup("MCID"); + if (mcidObj.isInt()) { error(errSyntaxError, -1, "MCID object is wrong type ({0:s})", mcidObj.getTypeName()); - mcidObj.free(); return NULL; } child = new StructElement(mcidObj.getInt(), treeRoot, this); - mcidObj.free(); - if (childObj->dictLookupNF("Pg", &pageRefObj)->isRef()) { - child->pageRef = pageRefObj; - } else { - pageRefObj.free(); + Object pageRefObj = childObj->dictLookupNF("Pg"); + if (pageRefObj.isRef()) { + child->pageRef = std::move(pageRefObj); } } else if (childObj->isDict("OBJR")) { - Object refObj; - - if (childObj->dictLookupNF("Obj", &refObj)->isRef()) { - Object pageRefObj; + Object refObj = childObj->dictLookupNF("Obj"); + if (refObj.isRef()) { child = new StructElement(refObj.getRef(), treeRoot, this); - if (childObj->dictLookupNF("Pg", &pageRefObj)->isRef()) { - child->pageRef = pageRefObj; - } else { - pageRefObj.free(); + Object pageRefObj = childObj->dictLookupNF("Pg"); + if (pageRefObj.isRef()) { + child->pageRef = std::move(pageRefObj); } } else { error(errSyntaxError, -1, "Obj object is wrong type ({0:s})", refObj.getTypeName()); } - refObj.free(); } else if (childObj->isDict()) { if (!ref->isRef()) { error(errSyntaxError, -1, @@ -1310,34 +1255,29 @@ StructElement *StructElement::parseChild(Object *ref, void StructElement::parseChildren(Dict *element, std::set<int> &seen) { - Object kids; - - if (element->lookup("K", &kids)->isArray()) { + Object kids = element->lookup("K"); + if (kids.isArray()) { for (int i = 0; i < kids.arrayGetLength(); i++) { - Object obj, ref; - parseChild(kids.arrayGetNF(i, &ref), kids.arrayGet(i, &obj), seen); - obj.free(); - ref.free(); + Object obj = kids.arrayGet(i); + Object ref = kids.arrayGetNF(i); + parseChild(&ref, &obj, seen); } } else if (kids.isDict() || kids.isInt()) { - Object ref; - parseChild(element->lookupNF("K", &ref), &kids, seen); - ref.free(); + Object ref = element->lookupNF("K"); + parseChild(&ref, &kids, seen); } - - kids.free(); } void StructElement::parseAttributes(Dict *attributes, GBool keepExisting) { - Object owner; - if (attributes->lookup("O", &owner)->isName("UserProperties")) { + Object owner = attributes->lookup("O"); + if (owner.isName("UserProperties")) { // In this case /P is an array of UserProperty dictionaries - Object userProperties; - if (attributes->lookup("P", &userProperties)->isArray()) { + Object userProperties = attributes->lookup("P"); + if (userProperties.isArray()) { for (int i = 0; i < userProperties.arrayGetLength(); i++) { - Object property; - if (userProperties.arrayGet(i, &property)->isDict()) { + Object property = userProperties.arrayGet(i); + if (property.isDict()) { Attribute *attribute = Attribute::parseUserProperty(property.getDict()); if (attribute && attribute->isOk()) { appendAttribute(attribute); @@ -1348,10 +1288,8 @@ void StructElement::parseAttributes(Dict *attributes, GBool keepExisting) } else { error(errSyntaxWarning, -1, "Item in P is wrong type ({0:s})", property.getTypeName()); } - property.free(); } } - userProperties.free(); } else if (owner.isName()) { // In this case /P contains standard attributes. // Check first if the owner is a valid standard one. @@ -1378,10 +1316,9 @@ void StructElement::parseAttributes(Dict *attributes, GBool keepExisting) } if (type != Attribute::Unknown) { - Object value; + Object value = attributes->getVal(i); GBool typeCheckOk = gTrue; - Attribute *attribute = new Attribute(type, attributes->getVal(i, &value)); - value.free(); + Attribute *attribute = new Attribute(type, &value); if (attribute->isOk() && (typeCheckOk = attribute->checkType(this))) { appendAttribute(attribute); @@ -1405,5 +1342,4 @@ void StructElement::parseAttributes(Dict *attributes, GBool keepExisting) } else if (!owner.isNull()) { error(errSyntaxWarning, -1, "O is wrong type ({0:s})", owner.getTypeName()); } - owner.free(); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc b/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc index e46e3e28388..5f56111581e 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/StructTreeRoot.cc @@ -6,6 +6,9 @@ // // Copyright 2013, 2014 Igalia S.L. // Copyright 2014 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright 2017 Jan-Erik S <janerik234678@gmail.com> +// Copyright 2017 Albert Astals Cid <aacid@kde.org> +// Copyright 2017 Adrian Johnson <ajohnson@redneon.com> // //======================================================================== @@ -35,8 +38,6 @@ StructTreeRoot::~StructTreeRoot() { for (ElemPtrArray::iterator i = elements.begin(); i != elements.end(); ++i) delete *i; - classMap.free(); - roleMap.free(); } void StructTreeRoot::parse(Dict *root) @@ -44,55 +45,53 @@ void StructTreeRoot::parse(Dict *root) // The RoleMap/ClassMap dictionaries are needed by all the parsing // functions, which will resolve the custom names to canonical // standard names. - root->lookup("RoleMap", &roleMap); - root->lookup("ClassMap", &classMap); + roleMap = root->lookup("RoleMap"); + classMap = root->lookup("ClassMap"); // ParentTree (optional). If present, it must be a number tree, // otherwise it is not possible to map stream objects to their // corresponsing structure element. Here only the references are // loaded into the array, the pointers to the StructElements will // be filled-in later when parsing them. - Object obj; - if (root->lookup("ParentTree", &obj)->isDict()) { - Object nums; - if (obj.dictLookup("Nums", &nums)->isArray()) { + Object obj = root->lookup("ParentTree"); + if (obj.isDict()) { + Object nums = obj.dictLookup("Nums"); + if (nums.isArray()) { if (nums.arrayGetLength() % 2 == 0) { parentTree.resize(nums.arrayGetLength() / 2); // Index numbers in even positions, references in odd ones for (int i = 0; i < nums.arrayGetLength(); i += 2) { - Object index, value; + Object index = nums.arrayGet(i); - if (!nums.arrayGet(i, &index)->isInt()) { + if (!index.isInt()) { error(errSyntaxError, -1, "Nums item at position {0:d} is wrong type ({1:s})", i, index.getTypeName()); - index.free(); continue; } - if (index.getInt() < 0) { - error(errSyntaxError, -1, "Nums item at position {0:d} is invalid value ({1:d})", i, index.getInt()); - index.free(); + const int idx = index.getInt(); + if (idx < 0 || idx >= (int)parentTree.size()) { + error(errSyntaxError, -1, "Nums item at position {0:d} is invalid value ({1:d}): [0..{2:d}]", i, idx, parentTree.size() - 1); continue; } - const unsigned idx = index.getInt(); - if (nums.arrayGetNF(i + 1, &value)->isRef()) { + Object value = nums.arrayGetNF(i + 1); + if (value.isRef()) { parentTree[idx].resize(1); parentTree[idx][0].ref = value.getRef(); - } else if (nums.arrayGet(i + 1, &value)->isArray()) { - parentTree[idx].resize(value.arrayGetLength()); - for (int j = 0; j < value.arrayGetLength(); j++) { - Object itemvalue; - if (value.arrayGetNF(j, &itemvalue)->isRef()) - parentTree[idx][j].ref = itemvalue.getRef(); - else - error(errSyntaxError, -1, "Nums array item at position {0:d}/{1:d} is invalid type ({2:s})", i, j, itemvalue.getTypeName()); - itemvalue.free(); - } } else { - error(errSyntaxError, -1, "Nums item at position {0:d} is wrong type ({1:s})", i + 1, value.getTypeName()); - } - - value.free(); - index.free(); + value = nums.arrayGet(i + 1); + if (value.isArray()) { + parentTree[idx].resize(value.arrayGetLength()); + for (int j = 0; j < value.arrayGetLength(); j++) { + Object itemvalue = value.arrayGetNF(j); + if (itemvalue.isRef()) + parentTree[idx][j].ref = itemvalue.getRef(); + else + error(errSyntaxError, -1, "Nums array item at position {0:d}/{1:d} is invalid type ({2:s})", i, j, itemvalue.getTypeName()); + } + } else { + error(errSyntaxError, -1, "Nums item at position {0:d} is wrong type ({1:s})", i + 1, value.getTypeName()); + } + } } } else { error(errSyntaxError, -1, "Nums array length is not a even ({0:d})", nums.arrayGetLength()); @@ -100,26 +99,24 @@ void StructTreeRoot::parse(Dict *root) } else { error(errSyntaxError, -1, "Nums object is wrong type ({0:s})", nums.getTypeName()); } - nums.free(); } - obj.free(); std::set<int> seenElements; // Parse the children StructElements const GBool marked = doc->getCatalog()->getMarkInfo() & Catalog::markInfoMarked; - Object kids; - if (root->lookup("K", &kids)->isArray()) { + Object kids = root->lookup("K"); + if (kids.isArray()) { if (marked && kids.arrayGetLength() > 1) { error(errSyntaxWarning, -1, "K in StructTreeRoot has more than one children in a tagged PDF"); } for (int i = 0; i < kids.arrayGetLength(); i++) { - Object obj, ref; - kids.arrayGetNF(i, &ref); + Object ref = kids.arrayGetNF(i); if (ref.isRef()) { seenElements.insert(ref.getRefNum()); } - if (kids.arrayGet(i, &obj)->isDict()) { + Object obj = kids.arrayGet(i); + if (obj.isDict()) { StructElement *child = new StructElement(obj.getDict(), this, NULL, seenElements); if (child->isOk()) { if (marked && !(child->getType() == StructElement::Document || @@ -139,8 +136,6 @@ void StructTreeRoot::parse(Dict *root) } else { error(errSyntaxWarning, -1, "K has a child of wrong type ({0:s})", obj.getTypeName()); } - obj.free(); - ref.free(); } } else if (kids.isDict()) { if (marked) { @@ -149,10 +144,9 @@ void StructTreeRoot::parse(Dict *root) StructElement *child = new StructElement(kids.getDict(), this, NULL, seenElements); if (child->isOk()) { appendChild(child); - Object ref; - if (root->lookupNF("K", &ref)->isRef()) + Object ref = root->lookupNF("K"); + if (ref.isRef()) parentTreeAdd(ref.getRef(), child); - ref.free(); } else { error(errSyntaxWarning, -1, "StructTreeRoot element could not be parsed"); delete child; @@ -160,8 +154,6 @@ void StructTreeRoot::parse(Dict *root) } else if (!kids.isNull()) { error(errSyntaxWarning, -1, "K in StructTreeRoot is wrong type ({0:s})", kids.getTypeName()); } - - kids.free(); } void StructTreeRoot::parentTreeAdd(const Ref &objectRef, StructElement *element) diff --git a/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc b/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc index e0dda085c5d..9a77d050005 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc @@ -18,9 +18,9 @@ // Copyright (C) 2006-2008, 2011-2013 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2006, 2007, 2013 Ed Catmur <ed@catmur.co.uk> // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2007, 2008, 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2007, 2008, 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008 Koji Otani <sho@bbr.jp> -// Copyright (C) 2008, 2010-2012, 2014-2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2010-2012, 2014-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Pino Toscano <pino@kde.org> // Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2009 Ross Moore <ross@maths.mq.edu.au> @@ -30,7 +30,7 @@ // Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2011 Sam Liao <phyomh@gmail.com> // Copyright (C) 2012 Horst Prote <prote@fmi.uni-stuttgart.de> -// Copyright (C) 2012, 2013-2016 Jason Crain <jason@aquaticape.us> +// Copyright (C) 2012, 2013-2017 Jason Crain <jason@aquaticape.us> // Copyright (C) 2012 Peter Breitenlohner <peb@mppmu.mpg.de> // Copyright (C) 2013 José Aliste <jaliste@src.gnome.org> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> @@ -51,7 +51,7 @@ #include <stdio.h> #include <stdlib.h> #include <stddef.h> -#include <math.h> +#include <cmath> #include <float.h> #include <ctype.h> #include <algorithm> @@ -306,7 +306,7 @@ TextFontInfo::TextFontInfo(GfxState *state) { gfxFont = state->getFont(); if (gfxFont) gfxFont->incRefCnt(); -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST fontName = (gfxFont && gfxFont->getName()) ? gfxFont->getName()->copy() : (GooString *)NULL; flags = gfxFont ? gfxFont->getFlags() : 0; @@ -316,7 +316,7 @@ TextFontInfo::TextFontInfo(GfxState *state) { TextFontInfo::~TextFontInfo() { if (gfxFont) gfxFont->decRefCnt(); -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST if (fontName) { delete fontName; } @@ -360,7 +360,7 @@ TextWord::TextWord(GfxState *state, int rotA, double fontSizeA) { spaceAfter = gFalse; next = NULL; -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST GfxRGB rgb; if ((state->getRender() & 3) == 1) { @@ -565,7 +565,7 @@ static struct CombiningTable combiningTable[] = { }; // returning combining versions of characters -Unicode getCombiningChar(Unicode u) { +static Unicode getCombiningChar(Unicode u) { int len = sizeof(combiningTable) / sizeof(combiningTable[0]); for (int i = 0; i < len; ++i) { if (u == combiningTable[i].base) @@ -790,7 +790,7 @@ int TextWord::cmpYX(const void *p1, const void *p2) { return cmp < 0 ? -1 : cmp > 0 ? 1 : 0; } -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST GooString *TextWord::getText() { GooString *s; @@ -889,11 +889,12 @@ void TextPool::addWord(TextWord *word) { TextWord *w0, *w1; // expand the array if needed - if (unlikely((word->base / textPoolStep) > INT_MAX)) { - error(errSyntaxWarning, -1, "word->base / textPoolStep > INT_MAX"); + wordBaseIdx = (int)(word->base / textPoolStep); + if (unlikely(wordBaseIdx <= INT_MIN + 128 || wordBaseIdx >= INT_MAX - 128)) { + error(errSyntaxWarning, -1, "wordBaseIdx out of range"); + delete word; return; } - wordBaseIdx = (int)(word->base / textPoolStep); if (minBaseIdx > maxBaseIdx) { minBaseIdx = wordBaseIdx - 128; maxBaseIdx = wordBaseIdx + 128; @@ -2251,7 +2252,7 @@ GBool TextFlow::blockFits(TextBlock *blk, TextBlock *prevBlk) { return fits; } -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST //------------------------------------------------------------------------ // TextWordList @@ -2598,8 +2599,7 @@ void TextPage::addChar(GfxState *state, double x, double y, } // check the tiny chars limit - if (!globalParams->getTextKeepTinyChars() && - fabs(w1) < 3 && fabs(h1) < 3) { + if (fabs(w1) < 3 && fabs(h1) < 3) { if (++nTinyChars > 50000) { charPos += nBytes; return; @@ -4327,20 +4327,20 @@ TextSelectionVisitor::TextSelectionVisitor (TextPage *page) class TextSelectionDumper : public TextSelectionVisitor { public: TextSelectionDumper(TextPage *page); - virtual ~TextSelectionDumper(); + ~TextSelectionDumper(); - virtual void visitBlock (TextBlock *block, + void visitBlock (TextBlock *block, TextLine *begin, TextLine *end, - PDFRectangle *selection) { }; - virtual void visitLine (TextLine *line, + PDFRectangle *selection) override { }; + void visitLine (TextLine *line, TextWord *begin, TextWord *end, int edge_begin, int edge_end, - PDFRectangle *selection); - virtual void visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection); + PDFRectangle *selection) override; + void visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection) override; void endPage(); GooString *getText(void); @@ -4498,18 +4498,18 @@ public: TextSelectionSizer(TextPage *page, double scale); ~TextSelectionSizer() { } - virtual void visitBlock (TextBlock *block, + void visitBlock (TextBlock *block, TextLine *begin, TextLine *end, - PDFRectangle *selection) { }; - virtual void visitLine (TextLine *line, + PDFRectangle *selection) override { }; + void visitLine (TextLine *line, TextWord *begin, TextWord *end, int edge_begin, int edge_end, - PDFRectangle *selection); - virtual void visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection) { }; + PDFRectangle *selection) override; + void visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection) override { }; GooList *getRegion () { return list; } @@ -4559,18 +4559,18 @@ public: GfxColor *glyph_color); ~TextSelectionPainter(); - virtual void visitBlock (TextBlock *block, + void visitBlock (TextBlock *block, TextLine *begin, TextLine *end, - PDFRectangle *selection) { }; - virtual void visitLine (TextLine *line, + PDFRectangle *selection) override { }; + void visitLine (TextLine *line, TextWord *begin, TextWord *end, int edge_begin, int edge_end, - PDFRectangle *selection); - virtual void visitWord (TextWord *word, int begin, int end, - PDFRectangle *selection); + PDFRectangle *selection) override; + void visitWord (TextWord *word, int begin, int end, + PDFRectangle *selection) override; void endPage(); private: @@ -5472,7 +5472,7 @@ int TextPage::dumpFragment(Unicode *text, int len, UnicodeMap *uMap, } } -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST TextWordList *TextPage::makeWordList(GBool physLayout) { return new TextWordList(this, physLayout); } @@ -5858,7 +5858,7 @@ void TextOutputDev::setMergeCombining(GBool merge) { text->setMergeCombining(merge); } -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST TextWordList *TextOutputDev::makeWordList() { return text->makeWordList(physLayout); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.h b/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.h index 005be45f9ec..380301fdeeb 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.h +++ b/Build/source/libs/poppler/poppler-src/poppler/TextOutputDev.h @@ -16,7 +16,7 @@ // Copyright (C) 2005-2007 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Ed Catmur <ed@catmur.co.uk> // Copyright (C) 2007, 2008, 2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2007 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2007, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008, 2010, 2015, 2016 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 Brian Ewins <brian.ewins@gmail.com> // Copyright (C) 2012, 2013, 2015, 2016 Jason Crain <jason@aquaticape.us> @@ -91,7 +91,7 @@ public: // Get the writing mode (0 or 1), or 0 if the font is not set int getWMode(); -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST // Get the font name (which may be NULL). GooString *getFontName() { return fontName; } @@ -106,7 +106,7 @@ public: private: GfxFont *gfxFont; -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST GooString *fontName; int flags; #endif @@ -165,7 +165,7 @@ public: // Get the next TextWord on the linked list. TextWord *getNext() { return next; } -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST int getLength() { return len; } const Unicode *getChar(int idx) { return &text[idx]; } GooString *getText(); @@ -215,7 +215,7 @@ private: GBool underlined; TextWord *next; // next word in line -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST double colorR, // word color colorG, colorB; @@ -471,7 +471,7 @@ private: friend class TextPage; }; -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST //------------------------------------------------------------------------ // TextWordList @@ -628,7 +628,7 @@ public: // character are drawn on eachother. void setMergeCombining(GBool merge); -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST // Build a flat word list, in content stream order (if // this->rawOrder is true), physical layout order (if <physLayout> // is true and this->rawOrder is false), or reading order (if both @@ -745,7 +745,7 @@ public: GBool rawOrderA); // Destructor. - virtual ~TextOutputDev(); + ~TextOutputDev(); // Check if file was successfully created. virtual GBool isOk() { return ok; } @@ -754,54 +754,54 @@ public: // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gTrue; } + GBool upsideDown() override { return gTrue; } // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gTrue; } + GBool useDrawChar() override { return gTrue; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gFalse; } + GBool interpretType3Chars() override { return gFalse; } // Does this device need non-text content? - virtual GBool needNonText() { return gFalse; } + GBool needNonText() override { return gFalse; } // Does this device require incCharCount to be called for text on // non-shown layers? - virtual GBool needCharCount() { return gTrue; } + GBool needCharCount() override { return gTrue; } //----- initialization and control // Start a page. - virtual void startPage(int pageNum, GfxState *state, XRef *xref); + void startPage(int pageNum, GfxState *state, XRef *xref) override; // End a page. - virtual void endPage(); + void endPage() override; //----- save/restore graphics state - virtual void restoreState(GfxState *state); + void restoreState(GfxState *state) override; //----- update text state - virtual void updateFont(GfxState *state); + void updateFont(GfxState *state) override; //----- text drawing - virtual void beginString(GfxState *state, GooString *s); - virtual void endString(GfxState *state); - virtual void drawChar(GfxState *state, double x, double y, - double dx, double dy, - double originX, double originY, - CharCode c, int nBytes, Unicode *u, int uLen); - virtual void incCharCount(int nChars); - virtual void beginActualText(GfxState *state, GooString *text); - virtual void endActualText(GfxState *state); + void beginString(GfxState *state, GooString *s) override; + void endString(GfxState *state) override; + void drawChar(GfxState *state, double x, double y, + double dx, double dy, + double originX, double originY, + CharCode c, int nBytes, Unicode *u, int uLen) override; + void incCharCount(int nChars) override; + void beginActualText(GfxState *state, GooString *text) override; + void endActualText(GfxState *state) override; //----- path painting - virtual void stroke(GfxState *state); - virtual void fill(GfxState *state); - virtual void eoFill(GfxState *state); + void stroke(GfxState *state) override; + void fill(GfxState *state) override; + void eoFill(GfxState *state) override; //----- link borders - virtual void processLink(AnnotLink *link); + void processLink(AnnotLink *link) override; //----- special access @@ -847,7 +847,7 @@ public: // character are drawn on eachother. void setMergeCombining(GBool merge); -#if TEXTOUT_WORD_LIST +#ifdef TEXTOUT_WORD_LIST // Build a flat word list, in content stream order (if // this->rawOrder is true), physical layout order (if // this->physLayout is true and this->rawOrder is false), or reading diff --git a/Build/source/libs/poppler/poppler-src/poppler/UTF.cc b/Build/source/libs/poppler/poppler-src/poppler/UTF.cc index f7b02d14795..878837a8831 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/UTF.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/UTF.cc @@ -1,6 +1,6 @@ //======================================================================== // -// UTF.h +// UTF.cc // // Copyright 2001-2003 Glyph & Cog, LLC // @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2008 Koji Otani <sho@bbr.jp> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Hib Eris <hib@hiberis.nl> // Copyright (C) 2016 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2016 Jason Crain <jason@aquaticape.us> @@ -27,6 +27,7 @@ #include "goo/gmem.h" #include "PDFDocEncoding.h" #include "UTF.h" +#include "UnicodeMapFuncs.h" #include <algorithm> bool UnicodeIsValid(Unicode ucs4) @@ -130,3 +131,287 @@ bool UnicodeIsWhitespace(Unicode ucs4) Unicode const *i = std::lower_bound(spaces, end, ucs4); return (i != end && *i == ucs4); } + +// +// decodeUtf8() and decodeUtf8Table are: +// +// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de> +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. +// +static const uint32_t UTF8_ACCEPT = 0; +static const uint32_t UTF8_REJECT = 12; +static const uint32_t UCS4_MAX = 0x10FFFF; +static const Unicode REPLACEMENT_CHAR = 0xFFFD; + +static const uint8_t decodeUtf8Table[] = { + // The first part of the table maps bytes to character classes + // to reduce the size of the transition table and create bitmasks. + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 60..7f + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, // 80..9f + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, // a0..bf + 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // c0..df + 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, // e0..ff + + // The second part is a transition table that maps a combination + // of a state of the automaton and a character class to a state. + 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12, + 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12, + 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12, + 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12, + 12,36,12,12,12,12,12,12,12,12,12,12, +}; + +// Decode utf8 state machine for fast UTF-8 decoding. Initialise state +// to 0 and call decodeUtf8() for each byte of UTF-8. Return value +// (and state) is UTF8_ACCEPT when it has found a valid codepoint +// (codepoint returned in codep), UTF8_REJECT when the byte is not +// allowed to occur at its position, and some other positive value if +// more bytes have to be read. Reset state to 0 to recover from +// errors. +inline uint32_t decodeUtf8(uint32_t* state, uint32_t* codep, char byte) +{ + uint32_t b = (unsigned char)byte; + uint32_t type = decodeUtf8Table[b]; + + *codep = (*state != UTF8_ACCEPT) ? + (b & 0x3fu) | (*codep << 6) : + (0xff >> type) & (b); + + *state = decodeUtf8Table[256 + *state + type]; + return *state; +} + +// Count number of UTF-16 code units required to convert a UTF-8 string +// (excluding terminating NULL). Each invalid byte is counted as a +// code point since the UTF-8 conversion functions will replace it with +// REPLACEMENT_CHAR. +int utf8CountUtf16CodeUnits(const char *utf8) +{ + uint32_t codepoint; + uint32_t state = 0; + int count = 0; + + while (*utf8) { + decodeUtf8(&state, &codepoint, *utf8); + if (state == UTF8_ACCEPT) { + if (codepoint < 0x10000) + count++; + else if (codepoint <= UCS4_MAX) + count += 2; + else + count++; // replace with REPLACEMENT_CHAR + } else if (state == UTF8_REJECT) { + count++; // replace with REPLACEMENT_CHAR + state = 0; + } + utf8++; + } + if (state != UTF8_ACCEPT && state != UTF8_REJECT) + count++; // replace with REPLACEMENT_CHAR + + return count; +} + + +// Convert UTF-8 to UTF-16 +// utf8- UTF-8 string to convert. If not null terminated, set maxUtf8 to num +// bytes to convert +// utf16 - output buffer to write UTF-16 to. Output will always be null terminated. +// maxUtf16 - maximum size of output buffer including space for null. +// maxUtf8 - maximum number of UTF-8 bytes to convert. Conversion stops when +// either this count is reached or a null is encountered. +// Returns number of UTF-16 code units written (excluding NULL). +int utf8ToUtf16(const char *utf8, uint16_t *utf16, int maxUtf16, int maxUtf8) +{ + uint16_t *p = utf16; + uint32_t codepoint; + uint32_t state = 0; + int nIn = 0; + int nOut = 0; + while (*utf8 && nIn < maxUtf8 && nOut < maxUtf16 - 1) { + decodeUtf8(&state, &codepoint, *utf8); + if (state == UTF8_ACCEPT) { + if (codepoint < 0x10000) { + *p++ = (uint16_t)codepoint; + nOut++; + } else if (codepoint <= UCS4_MAX) { + *p++ = (uint16_t)(0xD7C0 + (codepoint >> 10)); + *p++ = (uint16_t)(0xDC00 + (codepoint & 0x3FF)); + nOut += 2; + } else { + *p++ = REPLACEMENT_CHAR; + nOut++; + state = 0; + } + } else if (state == UTF8_REJECT) { + *p++ = REPLACEMENT_CHAR; // invalid byte for this position + nOut++; + } + utf8++; + nIn++; + } + // replace any trailing bytes too short for a valid UTF-8 with a replacement char + if (state != UTF8_ACCEPT && state != UTF8_REJECT && nOut < maxUtf16 - 1) { + *p++ = REPLACEMENT_CHAR; + nOut++; + } + if (nOut > maxUtf16 - 1) + nOut = maxUtf16 - 1; + utf16[nOut] = 0; + return nOut; +} + +// Allocate utf16 string and convert utf8 into it. +uint16_t *utf8ToUtf16(const char *utf8, int *len) +{ + int n = utf8CountUtf16CodeUnits(utf8); + if (len) + *len = n; + uint16_t *utf16 = (uint16_t*)gmallocn(n + 1, sizeof(uint16_t)); + utf8ToUtf16(utf8, utf16); + return utf16; +} + +static const uint32_t UTF16_ACCEPT = 0; +static const uint32_t UTF16_REJECT = -1; + +// Initialise state to 0. Returns UTF16_ACCEPT when a valid code point +// has been found, UTF16_REJECT when invalid code unit for this state, +// some other valid if another code unit needs to be read. +inline uint32_t decodeUtf16(uint32_t* state, uint32_t* codePoint, uint16_t codeUnit) +{ + if (*state == 0) { + if (codeUnit >= 0xd800 && codeUnit < 0xdc00) { /* surrogate pair */ + *state = codeUnit; + return *state; + } else if (codeUnit >= 0xdc00 && codeUnit < 0xe000) { + /* invalid low surrogate */ + return UTF16_REJECT; + } else { + *codePoint = codeUnit; + return UTF16_ACCEPT; + } + } else { + if (codeUnit >= 0xdc00 && codeUnit < 0xe000) { + *codePoint = (((*state & 0x3ff) << 10) | (codeUnit & 0x3ff)) + 0x10000; + *state = 0; + return UTF16_ACCEPT; + } else { + /* invalid high surrogate */ + return UTF16_REJECT; + } + } +} + +// Count number of UTF-8 bytes required to convert a UTF-16 string to +// UTF-8 (excluding terminating NULL). +int utf16CountUtf8Bytes(const uint16_t *utf16) +{ + uint32_t codepoint; + uint32_t state = 0; + int count = 0; + + while (*utf16) { + decodeUtf16(&state, &codepoint, *utf16); + if (state == UTF16_ACCEPT) { + if (codepoint < 0x80) + count++; + else if (codepoint < 0x800) + count += 2; + else if (codepoint < 0x10000) + count += 3; + else if (codepoint <= UCS4_MAX) + count += 4; + else + count += 3; // replace with REPLACEMENT_CHAR + } else if (state == UTF16_REJECT) { + count += 3; // replace with REPLACEMENT_CHAR + state = 0; + } + utf16++; + } + if (state != UTF8_ACCEPT && state != UTF8_REJECT) + count++; // replace with REPLACEMENT_CHAR + + return count; +} + +// Convert UTF-16 to UTF-8 +// utf16- UTF-16 string to convert. If not null terminated, set maxUtf16 to num +// code units to convert +// utf8 - output buffer to write UTF-8 to. Output will always be null terminated. +// maxUtf8 - maximum size of output buffer including space for null. +// maxUtf16 - maximum number of UTF-16 code units to convert. Conversion stops when +// either this count is reached or a null is encountered. +// Returns number of UTF-8 bytes written (excluding NULL). +int utf16ToUtf8(const uint16_t *utf16, char *utf8, int maxUtf8, int maxUtf16) +{ + uint32_t codepoint = 0; + uint32_t state = 0; + int nIn = 0; + int nOut = 0; + char *p = utf8; + while (*utf16 && nIn < maxUtf16 && nOut < maxUtf8 - 1) { + decodeUtf16(&state, &codepoint, *utf16); + if (state == UTF16_ACCEPT || state == UTF16_REJECT) { + if (state == UTF16_REJECT || codepoint > UCS4_MAX) { + codepoint = REPLACEMENT_CHAR; + state = 0; + } + + int bufSize = maxUtf8 - nOut; + int count = mapUTF8(codepoint, p, bufSize); + p += count; + nOut += count; + } + utf16++; + nIn++; + } + // replace any trailing bytes too short for a valid UTF-8 with a replacement char + if (state != UTF16_ACCEPT && state != UTF16_REJECT && nOut < maxUtf8 - 1) { + int bufSize = maxUtf8 - nOut; + int count = mapUTF8(REPLACEMENT_CHAR, p, bufSize); + p += count; + nOut += count; + nOut++; + } + if (nOut > maxUtf8 - 1) + nOut = maxUtf8 - 1; + utf8[nOut] = 0; + return nOut; +} + +// Allocate utf8 string and convert utf16 into it. +char *utf16ToUtf8(const uint16_t *utf16, int *len) +{ + int n = utf16CountUtf8Bytes(utf16); + if (len) + *len = n; + char *utf8 = (char*)gmalloc(n + 1); + utf16ToUtf8(utf16, utf8); + return utf8; +} diff --git a/Build/source/libs/poppler/poppler-src/poppler/UTF.h b/Build/source/libs/poppler/poppler-src/poppler/UTF.h index c82e165a3ab..704ba4de1df 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/UTF.h +++ b/Build/source/libs/poppler/poppler-src/poppler/UTF.h @@ -4,7 +4,7 @@ // // This file is licensed under the GPLv2 or later // -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2016 Jason Crain <jason@aquaticape.us> // //======================================================================== @@ -16,6 +16,9 @@ #pragma implementation #endif +#include <cstdint> +#include <climits> + #include "goo/GooString.h" #include "CharTypes.h" @@ -39,4 +42,40 @@ bool UnicodeIsValid(Unicode ucs4); // is a unicode whitespace character bool UnicodeIsWhitespace(Unicode ucs4); +// Count number of UTF-16 code units required to convert a UTF-8 string +// (excluding terminating NULL). Each invalid byte is counted as a +// code point since the UTF-8 conversion functions will replace it with +// REPLACEMENT_CHAR. +int utf8CountUtf16CodeUnits(const char *utf8); + +// Convert UTF-8 to UTF-16 +// utf8- UTF-8 string to convert. If not null terminated, set maxUtf8 to num +// bytes to convert +// utf16 - output buffer to write UTF-16 to. Output will always be null terminated. +// maxUtf16 - maximum size of output buffer including space for null. +// maxUtf8 - maximum number of UTF-8 bytes to convert. Conversion stops when +// either this count is reached or a null is encountered. +// Returns number of UTF-16 code units written (excluding NULL). +int utf8ToUtf16(const char *utf8, uint16_t *utf16, int maxUtf16 = INT_MAX, int maxUtf8 = INT_MAX); + +// Allocate utf16 string and convert utf8 into it. +uint16_t *utf8ToUtf16(const char *utf8, int *len = nullptr); + +// Count number of UTF-8 bytes required to convert a UTF-16 string to +// UTF-8 (excluding terminating NULL). +int utf16CountUtf8Bytes(const uint16_t *utf16); + +// Convert UTF-16 to UTF-8 +// utf16- UTF-16 string to convert. If not null terminated, set maxUtf16 to num +// code units to convert +// utf8 - output buffer to write UTF-8 to. Output will always be null terminated. +// maxUtf8 - maximum size of output buffer including space for null. +// maxUtf16 - maximum number of UTF-16 code units to convert. Conversion stops when +// either this count is reached or a null is encountered. +// Returns number of UTF-8 bytes written (excluding NULL). +int utf16ToUtf8(const uint16_t *utf16, char *utf8, int maxUtf8 = INT_MAX, int maxUtf16 = INT_MAX); + +// Allocate utf8 string and convert utf16 into it. +char *utf16ToUtf8(const uint16_t *utf16, int *len = nullptr); + #endif diff --git a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc index 1319666779b..25b3de13d52 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc @@ -14,6 +14,9 @@ // under GPL version 2 or later // // Copyright (C) 2010 Jakub Wilk <jwilk@jwilk.net> +// 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> // // 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 @@ -28,6 +31,7 @@ #include <stdio.h> #include <string.h> +#include "goo/glibc.h" #include "goo/gmem.h" #include "goo/gfile.h" #include "goo/GooString.h" @@ -55,7 +59,7 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) { UnicodeMapExt *eMap; int size, eMapsSize; char buf[256]; - int line, nBytes, i, x; + int line, nBytes, i; char *tok1, *tok2, *tok3; char *tokptr; @@ -102,6 +106,7 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) { eMap = &map->eMaps[map->eMapsLen]; sscanf(tok1, "%x", &eMap->u); for (i = 0; i < nBytes; ++i) { + unsigned int x; sscanf(tok3 + i*2, "%2x", &x); eMap->code[i] = (char)x; } @@ -134,7 +139,7 @@ UnicodeMap::UnicodeMap(GooString *encodingNameA) { eMaps = NULL; eMapsLen = 0; refCnt = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -149,7 +154,7 @@ UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, eMaps = NULL; eMapsLen = 0; refCnt = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -163,7 +168,7 @@ UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, eMaps = NULL; eMapsLen = 0; refCnt = 1; -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif } @@ -176,17 +181,17 @@ UnicodeMap::~UnicodeMap() { if (eMaps) { gfree(eMaps); } -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } void UnicodeMap::incRefCnt() { -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif ++refCnt; -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif } @@ -194,11 +199,11 @@ void UnicodeMap::incRefCnt() { void UnicodeMap::decRefCnt() { GBool done; -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif done = --refCnt == 0; -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif if (done) { diff --git a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h index ba7df2cfb99..46b4c0f95ed 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h +++ b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMap.h @@ -8,6 +8,20 @@ // //======================================================================== +//======================================================================== +// +// 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 Adrian Johnson <ajohnson@redneon.com> +// +// 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 UNICODEMAP_H #define UNICODEMAP_H @@ -19,7 +33,7 @@ #include "goo/gtypes.h" #include "CharTypes.h" -#if MULTITHREADED +#ifdef MULTITHREADED #include "goo/GooMutex.h" #endif @@ -94,7 +108,7 @@ private: UnicodeMapExt *eMaps; // (user) int eMapsLen; // (user) int refCnt; -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/UTF8.h b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMapFuncs.h index 34a07d4082f..b89ee6ebecc 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/UTF8.h +++ b/Build/source/libs/poppler/poppler-src/poppler/UnicodeMapFuncs.h @@ -1,6 +1,6 @@ //======================================================================== // -// UTF8.h +// UnicodeMapFuncs.h // // Copyright 2001-2003 Glyph & Cog, LLC // @@ -14,6 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2008 Koji Otani <sho@bbr.jp> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -21,7 +22,7 @@ //======================================================================== static int mapUTF8(Unicode u, char *buf, int bufSize) { - if (u <= 0x0000007f) { + if (u <= 0x0000007f) { if (bufSize < 1) { return 0; } @@ -56,7 +57,7 @@ static int mapUTF8(Unicode u, char *buf, int bufSize) { } } -static int mapUCS2(Unicode u, char *buf, int bufSize) { +static int mapUTF16(Unicode u, char *buf, int bufSize) { if (u <= 0xffff) { if (bufSize < 2) { return 0; diff --git a/Build/source/libs/poppler/poppler-src/poppler/ViewerPreferences.cc b/Build/source/libs/poppler/poppler-src/poppler/ViewerPreferences.cc index cba8d0ac512..e45134f2bc3 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/ViewerPreferences.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/ViewerPreferences.cc @@ -5,6 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2011 Pino Toscano <pino@kde.org> +// Copyright 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -19,39 +20,38 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict) { init(); - Object obj; - - if (prefDict->lookup("HideToolbar", &obj)->isBool()) { + Object obj = prefDict->lookup("HideToolbar"); + if (obj.isBool()) { hideToolbar = obj.getBool(); } - obj.free(); - if (prefDict->lookup("HideMenubar", &obj)->isBool()) { + obj = prefDict->lookup("HideMenubar"); + if (obj.isBool()) { hideMenubar = obj.getBool(); } - obj.free(); - if (prefDict->lookup("HideWindowUI", &obj)->isBool()) { + obj = prefDict->lookup("HideWindowUI"); + if (obj.isBool()) { hideWindowUI = obj.getBool(); } - obj.free(); - if (prefDict->lookup("FitWindow", &obj)->isBool()) { + obj = prefDict->lookup("FitWindow"); + if (obj.isBool()) { fitWindow = obj.getBool(); } - obj.free(); - if (prefDict->lookup("CenterWindow", &obj)->isBool()) { + obj = prefDict->lookup("CenterWindow"); + if (obj.isBool()) { centerWindow = obj.getBool(); } - obj.free(); - if (prefDict->lookup("DisplayDocTitle", &obj)->isBool()) { + obj = prefDict->lookup("DisplayDocTitle"); + if (obj.isBool()) { displayDocTitle = obj.getBool(); } - obj.free(); - if (prefDict->lookup("NonFullScreenPageMode", &obj)->isName()) { + obj = prefDict->lookup("NonFullScreenPageMode"); + if (obj.isName()) { const char *mode = obj.getName(); if (!strcmp(mode, "UseNone")) { nonFullScreenPageMode = nfpmUseNone; @@ -63,9 +63,9 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict) nonFullScreenPageMode = nfpmUseOC; } } - obj.free(); - if (prefDict->lookup("Direction", &obj)->isName()) { + obj = prefDict->lookup("Direction"); + if (obj.isName()) { const char *dir = obj.getName(); if (!strcmp(dir, "L2R")) { direction = directionL2R; @@ -73,9 +73,9 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict) direction = directionR2L; } } - obj.free(); - if (prefDict->lookup("PrintScaling", &obj)->isName()) { + obj = prefDict->lookup("PrintScaling"); + if (obj.isName()) { const char *ps = obj.getName(); if (!strcmp(ps, "None")) { printScaling = printScalingNone; @@ -83,9 +83,9 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict) printScaling = printScalingAppDefault; } } - obj.free(); - if (prefDict->lookup("Duplex", &obj)->isName()) { + obj = prefDict->lookup("Duplex"); + if (obj.isName()) { const char *d = obj.getName(); if (!strcmp(d, "Simplex")) { duplex = duplexSimplex; @@ -95,7 +95,6 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict) duplex = duplexDuplexFlipLongEdge; } } - obj.free(); } ViewerPreferences::~ViewerPreferences() diff --git a/Build/source/libs/poppler/poppler-src/poppler/XRef.cc b/Build/source/libs/poppler/poppler-src/poppler/XRef.cc index e5ecd632a51..f04a31fc1ed 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/XRef.cc +++ b/Build/source/libs/poppler/poppler-src/poppler/XRef.cc @@ -15,14 +15,14 @@ // // Copyright (C) 2005 Dan Sheridan <dan.sheridan@postman.org.uk> // Copyright (C) 2005 Brad Hards <bradh@frogmouth.net> -// Copyright (C) 2006, 2008, 2010, 2012-2014, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2008, 2010, 2012-2014, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009, 2010 Ilya Gorenbein <igorenbein@finjan.com> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2012, 2013, 2016 Thomas Freitag <Thomas.Freitag@kabelmail.de> // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2013, 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2014, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Pino Toscano <pino@kde.org> // Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com> // @@ -32,6 +32,7 @@ //======================================================================== #include <config.h> +#include "poppler-config.h" #ifdef USE_GCC_PRAGMAS #pragma implementation @@ -71,7 +72,7 @@ #define permHighResPrint (1<<11) // bit 12 #define defPermFlags 0xfffc -#if MULTITHREADED +#ifdef MULTITHREADED # define xrefLocker() MutexLocker locker(&mutex) # define xrefCondLocker(X) MutexLocker locker(&mutex, (X)) #else @@ -99,7 +100,7 @@ public: // Get the <objIdx>th object from this stream, which should be // object number <objNum>, generation 0. - Object *getObject(int objIdx, int objNum, Object *obj); + Object getObject(int objIdx, int objNum); private: @@ -117,7 +118,7 @@ class ObjectStreamKey : public PopplerCacheKey { } - bool operator==(const PopplerCacheKey &key) const + bool operator==(const PopplerCacheKey &key) const override { const ObjectStreamKey *k = static_cast<const ObjectStreamKey*>(&key); return objStrNum == k->objStrNum; @@ -145,7 +146,7 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA, int recursion) { Stream *str; Parser *parser; Goffset *offsets; - Object objStr, obj1, obj2; + Object objStr, obj1; Goffset first; int i; @@ -155,32 +156,30 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA, int recursion) { objNums = NULL; ok = gFalse; - if (!xref->fetch(objStrNum, 0, &objStr, recursion)->isStream()) { - goto err1; + objStr = xref->fetch(objStrNum, 0, recursion); + if (!objStr.isStream()) { + return; } - if (!objStr.streamGetDict()->lookup("N", &obj1, recursion)->isInt()) { - obj1.free(); - goto err1; + obj1 = objStr.streamGetDict()->lookup("N", recursion); + if (!obj1.isInt()) { + return; } nObjects = obj1.getInt(); - obj1.free(); if (nObjects <= 0) { - goto err1; + return; } - objStr.streamGetDict()->lookup("First", &obj1, recursion); + obj1 = objStr.streamGetDict()->lookup("First", recursion); if (!obj1.isInt() && !obj1.isInt64()) { - obj1.free(); - goto err1; + return; } if (obj1.isInt()) first = obj1.getInt(); else first = obj1.getInt64(); - obj1.free(); if (first < 0) { - goto err1; + return; } // this is an arbitrary limit to avoid integer overflow problems @@ -188,7 +187,7 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA, int recursion) { // object streams to 100-200 objects) if (nObjects > 1000000) { error(errSyntaxError, -1, "Too many objects in an object stream"); - goto err1; + return; } objs = new Object[nObjects]; objNums = (int *)gmallocn(nObjects, sizeof(int)); @@ -196,31 +195,26 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA, int recursion) { // parse the header: object numbers and offsets objStr.streamReset(); - obj1.initNull(); - str = new EmbedStream(objStr.getStream(), &obj1, gTrue, first); + str = new EmbedStream(objStr.getStream(), Object(objNull), gTrue, first); parser = new Parser(xref, new Lexer(xref, str), gFalse); for (i = 0; i < nObjects; ++i) { - parser->getObj(&obj1); - parser->getObj(&obj2); + obj1 = parser->getObj(); + Object obj2 = parser->getObj(); if (!obj1.isInt() || !(obj2.isInt() || obj2.isInt64())) { - obj1.free(); - obj2.free(); delete parser; gfree(offsets); - goto err1; + return; } objNums[i] = obj1.getInt(); if (obj2.isInt()) offsets[i] = obj2.getInt(); else offsets[i] = obj2.getInt64(); - obj1.free(); - obj2.free(); if (objNums[i] < 0 || offsets[i] < 0 || (i > 0 && offsets[i] < offsets[i-1])) { delete parser; gfree(offsets); - goto err1; + return; } } while (str->getChar() != EOF) ; @@ -235,43 +229,32 @@ ObjectStream::ObjectStream(XRef *xref, int objStrNumA, int recursion) { // parse the objects for (i = 0; i < nObjects; ++i) { - obj1.initNull(); if (i == nObjects - 1) { - str = new EmbedStream(objStr.getStream(), &obj1, gFalse, 0); + str = new EmbedStream(objStr.getStream(), Object(objNull), gFalse, 0); } else { - str = new EmbedStream(objStr.getStream(), &obj1, gTrue, + str = new EmbedStream(objStr.getStream(), Object(objNull), gTrue, offsets[i+1] - offsets[i]); } parser = new Parser(xref, new Lexer(xref, str), gFalse); - parser->getObj(&objs[i]); + objs[i] = parser->getObj(); while (str->getChar() != EOF) ; delete parser; } gfree(offsets); ok = gTrue; - - err1: - objStr.free(); } ObjectStream::~ObjectStream() { - int i; - - if (objs) { - for (i = 0; i < nObjects; ++i) { - objs[i].free(); - } - delete[] objs; - } + delete[] objs; gfree(objNums); } -Object *ObjectStream::getObject(int objIdx, int objNum, Object *obj) { +Object ObjectStream::getObject(int objIdx, int objNum) { if (objIdx < 0 || objIdx >= nObjects || objNum != objNums[objIdx]) { - return obj->initNull(); + return Object(objNull); } - return objs[objIdx].copy(obj); + return objs[objIdx].copy(); } //------------------------------------------------------------------------ @@ -279,7 +262,7 @@ Object *ObjectStream::getObject(int objIdx, int objNum, Object *obj) { //------------------------------------------------------------------------ void XRef::init() { -#if MULTITHREADED +#ifdef MULTITHREADED gInitMutex(&mutex); #endif ok = gTrue; @@ -311,7 +294,7 @@ XRef::XRef(Object *trailerDictA) { init(); if (trailerDictA->isDict()) - trailerDict.initDict(trailerDictA->getDict()); + trailerDict = trailerDictA->copy(); } XRef::XRef(BaseStream *strA, Goffset pos, Goffset mainXRefEntriesOffsetA, GBool *wasReconstructed, GBool reconstruct) { @@ -356,30 +339,26 @@ XRef::XRef(BaseStream *strA, Goffset pos, Goffset mainXRefEntriesOffsetA, GBool } // set size to (at least) the size specified in trailer dict - trailerDict.dictLookupNF("Size", &obj); + obj = trailerDict.dictLookupNF("Size"); if (!obj.isInt()) { error(errSyntaxWarning, -1, "No valid XRef size in trailer"); } else { if (obj.getInt() > size) { if (resize(obj.getInt()) != obj.getInt()) { if (!(ok = constructXRef(wasReconstructed))) { - obj.free(); errCode = errDamaged; return; } } } } - obj.free(); // get the root dictionary (catalog) object - trailerDict.dictLookupNF("Root", &obj); + obj = trailerDict.dictLookupNF("Root"); if (obj.isRef()) { rootNum = obj.getRefNum(); rootGen = obj.getRefGen(); - obj.free(); } else { - obj.free(); if (!(ok = constructXRef(wasReconstructed))) { errCode = errDamaged; return; @@ -397,7 +376,6 @@ XRef::~XRef() { } gfree(entries); - trailerDict.free(); if (streamEnds) { gfree(streamEnds); } @@ -407,7 +385,7 @@ XRef::~XRef() { if (strOwner) { delete str; } -#if MULTITHREADED +#ifdef MULTITHREADED gDestroyMutex(&mutex); #endif } @@ -426,7 +404,7 @@ XRef *XRef::copy() { xref->prevXRefOffset = prevXRefOffset; xref->mainXRefEntriesOffset = mainXRefEntriesOffset; xref->xRefStream = xRefStream; - trailerDict.copy(&xref->trailerDict); + xref->trailerDict = trailerDict.copy(); xref->encAlgorithm = encAlgorithm; xref->encRevision = encRevision; xref->encVersion = encVersion; @@ -446,7 +424,7 @@ XRef *XRef::copy() { for (int i = 0; i < size; ++i) { xref->entries[i].offset = entries[i].offset; xref->entries[i].type = entries[i].type; - xref->entries[i].obj.initNull (); + xref->entries[i].obj.initNullAfterMalloc(); xref->entries[i].flags = entries[i].flags; xref->entries[i].gen = entries[i].gen; } @@ -495,7 +473,7 @@ int XRef::resize(int newSize) for (int i = size; i < newSize; ++i) { entries[i].offset = -1; entries[i].type = xrefEntryNone; - entries[i].obj.initNull (); + entries[i].obj.initNullAfterMalloc (); entries[i].flags = 0; entries[i].gen = 0; } @@ -529,31 +507,26 @@ GBool XRef::readXRef(Goffset *pos, std::vector<Goffset> *followedXRefStm, std::v GBool more; // start up a parser, parse one token - obj.initNull(); parser = new Parser(NULL, new Lexer(NULL, - str->makeSubStream(start + *pos, gFalse, 0, &obj)), + str->makeSubStream(start + *pos, gFalse, 0, Object(objNull))), gTrue); - parser->getObj(&obj, gTrue); + obj = parser->getObj(gTrue); // parse an old-style xref table if (obj.isCmd("xref")) { - obj.free(); more = readXRefTable(parser, pos, followedXRefStm, xrefStreamObjsNum); // parse an xref stream } else if (obj.isInt()) { const int objNum = obj.getInt(); - obj.free(); - if (!parser->getObj(&obj, gTrue)->isInt()) { + if (obj = parser->getObj(gTrue), !obj.isInt()) { goto err1; } - obj.free(); - if (!parser->getObj(&obj, gTrue)->isCmd("obj")) { + if (obj = parser->getObj(gTrue), !obj.isCmd("obj")) { goto err1; } - obj.free(); - if (!parser->getObj(&obj)->isStream()) { + if (obj = parser->getObj(), !obj.isStream()) { goto err1; } if (trailerDict.isNone()) { @@ -563,7 +536,6 @@ GBool XRef::readXRef(Goffset *pos, std::vector<Goffset> *followedXRefStm, std::v xrefStreamObjsNum->push_back(objNum); } more = readXRefStream(obj.getStream(), pos); - obj.free(); } else { goto err1; @@ -573,7 +545,6 @@ GBool XRef::readXRef(Goffset *pos, std::vector<Goffset> *followedXRefStm, std::v return more; err1: - obj.free(); delete parser; ok = gFalse; return gFalse; @@ -587,21 +558,19 @@ GBool XRef::readXRefTable(Parser *parser, Goffset *pos, std::vector<Goffset> *fo int first, n, i; while (1) { - parser->getObj(&obj, gTrue); + obj = parser->getObj(gTrue); if (obj.isCmd("trailer")) { - obj.free(); break; } if (!obj.isInt()) { - goto err1; + goto err0; } first = obj.getInt(); - obj.free(); - if (!parser->getObj(&obj, gTrue)->isInt()) { - goto err1; + obj = parser->getObj(gTrue); + if (!obj.isInt()) { + goto err0; } n = obj.getInt(); - obj.free(); if (first < 0 || n < 0 || first + n < 0) { goto err0; } @@ -612,33 +581,35 @@ GBool XRef::readXRefTable(Parser *parser, Goffset *pos, std::vector<Goffset> *fo } } for (i = first; i < first + n; ++i) { - parser->getObj(&obj, gTrue); + obj = parser->getObj(gTrue); if (obj.isInt()) { entry.offset = obj.getInt(); } else if (obj.isInt64()) { entry.offset = obj.getInt64(); } else { - goto err1; + goto err0; } - obj.free(); - if (!parser->getObj(&obj, gTrue)->isInt()) { - goto err1; + obj = parser->getObj(gTrue); + if (!obj.isInt()) { + goto err0; } entry.gen = obj.getInt(); - entry.obj.initNull (); entry.flags = 0; - obj.free(); - parser->getObj(&obj, gTrue); + obj = parser->getObj(gTrue); if (obj.isCmd("n")) { entry.type = xrefEntryUncompressed; } else if (obj.isCmd("f")) { entry.type = xrefEntryFree; } else { - goto err1; + goto err0; } - obj.free(); if (entries[i].offset == -1) { - entries[i] = entry; + entries[i].offset = entry.offset; + entries[i].gen = entry.gen; + entries[i].type = entry.type; + entries[i].flags = entry.flags; + entries[i].obj.setToNull(); + // PDF files of patents from the IBM Intellectual Property // Network have a bug: the xref table claims to start at 1 // instead of 0. @@ -646,7 +617,12 @@ GBool XRef::readXRefTable(Parser *parser, Goffset *pos, std::vector<Goffset> *fo entries[1].offset == 0 && entries[1].gen == 65535 && entries[1].type == xrefEntryFree) { i = first = 0; - entries[0] = entries[1]; + entries[0].offset = 0; + entries[0].gen = 65535; + entries[0].type = xrefEntryFree; + entries[0].flags = entries[1].flags; + entries[0].obj = std::move(entries[1].obj); + entries[1].offset = -1; } } @@ -654,12 +630,13 @@ GBool XRef::readXRefTable(Parser *parser, Goffset *pos, std::vector<Goffset> *fo } // read the trailer dictionary - if (!parser->getObj(&obj)->isDict()) { - goto err1; + obj = parser->getObj(); + if (!obj.isDict()) { + goto err0; } // get the 'Prev' pointer - obj.getDict()->lookupNF("Prev", &obj2); + obj2 = obj.getDict()->lookupNF("Prev"); if (obj2.isInt() || obj2.isInt64()) { if (obj2.isInt()) pos2 = obj2.getInt(); @@ -686,15 +663,14 @@ GBool XRef::readXRefTable(Parser *parser, Goffset *pos, std::vector<Goffset> *fo } else { more = gFalse; } - obj2.free(); // save the first trailer dictionary if (trailerDict.isNone()) { - obj.copy(&trailerDict); + trailerDict = obj.copy(); } // check for an 'XRefStm' key - obj.getDict()->lookup("XRefStm", &obj2); + obj2 = obj.getDict()->lookup("XRefStm"); if (obj2.isInt() || obj2.isInt64()) { if (obj2.isInt()) pos2 = obj2.getInt(); @@ -710,97 +686,84 @@ GBool XRef::readXRefTable(Parser *parser, Goffset *pos, std::vector<Goffset> *fo readXRef(&pos2, followedXRefStm, xrefStreamObjsNum); } if (!ok) { - obj2.free(); - goto err1; + goto err0; } } - obj2.free(); - obj.free(); return more; - err1: - obj.free(); err0: ok = gFalse; return gFalse; } GBool XRef::readXRefStream(Stream *xrefStr, Goffset *pos) { - Dict *dict; int w[3]; GBool more; - Object obj, obj2, idx; - int newSize, first, n, i; + Object obj; - dict = xrefStr->getDict(); + ok = gFalse; - if (!dict->lookupNF("Size", &obj)->isInt()) { - goto err1; + Dict *dict = xrefStr->getDict(); + obj = dict->lookupNF("Size"); + if (!obj.isInt()) { + return gFalse; } - newSize = obj.getInt(); - obj.free(); + int newSize = obj.getInt(); if (newSize < 0) { - goto err1; + return gFalse; } if (newSize > size) { if (resize(newSize) != newSize) { error(errSyntaxError, -1, "Invalid 'size' parameter"); - goto err0; + return gFalse; } } - if (!dict->lookupNF("W", &obj)->isArray() || - obj.arrayGetLength() < 3) { - goto err1; + obj = dict->lookupNF("W"); + if (!obj.isArray() || obj.arrayGetLength() < 3) { + return gFalse; } - for (i = 0; i < 3; ++i) { - if (!obj.arrayGet(i, &obj2)->isInt()) { - obj2.free(); - goto err1; + for (int i = 0; i < 3; ++i) { + Object obj2 = obj.arrayGet(i); + if (!obj2.isInt()) { + return gFalse; } w[i] = obj2.getInt(); - obj2.free(); if (w[i] < 0) { - goto err1; + return gFalse; } } - obj.free(); - if (w[0] > (int)sizeof(int) || w[1] > (int)sizeof(long long) || w[2] > (int)sizeof(int)) { - goto err1; + if (w[0] > (int)sizeof(int) || w[1] > (int)sizeof(long long) || w[2] > (int)sizeof(long long)) { + return gFalse; } xrefStr->reset(); - dict->lookupNF("Index", &idx); + Object idx = dict->lookupNF("Index"); if (idx.isArray()) { - for (i = 0; i+1 < idx.arrayGetLength(); i += 2) { - if (!idx.arrayGet(i, &obj)->isInt()) { - idx.free(); - goto err1; + for (int i = 0; i+1 < idx.arrayGetLength(); i += 2) { + obj = idx.arrayGet(i); + if (!obj.isInt()) { + return gFalse; } - first = obj.getInt(); - obj.free(); - if (!idx.arrayGet(i+1, &obj)->isInt()) { - idx.free(); - goto err1; + int first = obj.getInt(); + obj = idx.arrayGet(i+1); + if (!obj.isInt()) { + return gFalse; } - n = obj.getInt(); - obj.free(); + int n = obj.getInt(); if (first < 0 || n < 0 || !readXRefStreamSection(xrefStr, w, first, n)) { - idx.free(); - goto err0; + return gFalse; } } } else { if (!readXRefStreamSection(xrefStr, w, 0, newSize)) { - idx.free(); - goto err0; + return gFalse; } } - idx.free(); - dict->lookupNF("Prev", &obj); + obj = dict->lookupNF("Prev"); if (obj.isInt()) { *pos = obj.getInt(); more = gTrue; @@ -810,23 +773,17 @@ GBool XRef::readXRefStream(Stream *xrefStr, Goffset *pos) { } else { more = gFalse; } - obj.free(); if (trailerDict.isNone()) { - trailerDict.initDict(dict); + trailerDict = xrefStr->getDictObject()->copy(); } + ok = gTrue; return more; - - err1: - obj.free(); - err0: - ok = gFalse; - return gFalse; } GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) { - unsigned long long offset; - int type, gen, c, i, j; + unsigned long long offset, gen; + int type, c, i, j; if (first + n < 0) { return gFalse; @@ -868,6 +825,10 @@ GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) { } gen = (gen << 8) + c; } + if (gen > INT_MAX) { + error(errSyntaxError, -1, "Gen inside xref table too large (bigger than INT_MAX)"); + return gFalse; + } if (entries[i].offset == -1) { switch (type) { case 0: @@ -897,7 +858,7 @@ GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) { // Attempt to construct an xref table for a damaged file. GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { Parser *parser; - Object newTrailerDict, obj; + Object obj; char buf[256]; Goffset pos; int num, gen; @@ -909,6 +870,7 @@ GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { bool oneCycle = true; int offset = 0; + resize(0); // free entries properly gfree(entries); capacity = 0; size = 0; @@ -947,26 +909,20 @@ GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { // got trailer dictionary if (!strncmp(p, "trailer", 7)) { - obj.initNull(); parser = new Parser(NULL, new Lexer(NULL, - str->makeSubStream(pos + 7, gFalse, 0, &obj)), + str->makeSubStream(pos + 7, gFalse, 0, Object(objNull))), gFalse); - parser->getObj(&newTrailerDict); + Object newTrailerDict = parser->getObj(); if (newTrailerDict.isDict()) { - newTrailerDict.dictLookupNF("Root", &obj); + obj = newTrailerDict.dictLookupNF("Root"); if (obj.isRef() && (!gotRoot || !needCatalogDict) && rootNum != obj.getRefNum()) { rootNum = obj.getRefNum(); rootGen = obj.getRefGen(); - if (!trailerDict.isNone()) { - trailerDict.free(); - } - newTrailerDict.copy(&trailerDict); + trailerDict = newTrailerDict.copy(); gotRoot = gTrue; } - obj.free(); } - newTrailerDict.free(); delete parser; // look for object @@ -1023,17 +979,25 @@ GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { } } - } else if (!strncmp(p, "endstream", 9)) { - if (streamEndsLen == streamEndsSize) { - streamEndsSize += 64; - if (streamEndsSize >= INT_MAX / (int)sizeof(int)) { - error(errSyntaxError, -1, "Invalid 'endstream' parameter."); - return gFalse; - } - streamEnds = (Goffset *)greallocn(streamEnds, - streamEndsSize, sizeof(Goffset)); - } - streamEnds[streamEndsLen++] = pos; + } else { + char *endstream = strstr( p, "endstream" ); + if (endstream) { + int endstreamPos = endstream - p; + if ((endstreamPos == 0 || Lexer::isSpace(p[endstreamPos-1] & 0xff)) // endstream is either at beginning or preceeded by space + && (endstreamPos + 9 >= 256 || Lexer::isSpace(p[endstreamPos+9] & 0xff))) // endstream is either at end or followed by space + { + if (streamEndsLen == streamEndsSize) { + streamEndsSize += 64; + if (streamEndsSize >= INT_MAX / (int)sizeof(int)) { + error(errSyntaxError, -1, "Invalid 'endstream' parameter."); + return gFalse; + } + streamEnds = (Goffset *)greallocn(streamEnds, + streamEndsSize, sizeof(Goffset)); + } + streamEnds[streamEndsLen++] = pos + endstreamPos; + } + } } if( token ) { p = token + 6;// strlen( "endobj" ) = 6 @@ -1135,17 +1099,19 @@ GBool XRef::okToAssemble(GBool ignoreOwnerPW) { return (!ignoreOwnerPW && ownerPasswordOk) || (permFlags & permAssemble); } -Object *XRef::getCatalog(Object *catalog) { - Object *obj = fetch(rootNum, rootGen, catalog); - if (obj->isDict()) { - return obj; +Object XRef::getCatalog() { + Object catalog = fetch(rootNum, rootGen); + if (catalog.isDict()) { + return catalog; } GBool wasReconstructed = false; - GBool ok = constructXRef(&wasReconstructed, gTrue); - return (ok) ? fetch(rootNum, rootGen, catalog) : obj; + if (constructXRef(&wasReconstructed, gTrue)) { + catalog = fetch(rootNum, rootGen); + } + return catalog; } -Object *XRef::fetch(int num, int gen, Object *obj, int recursion) { +Object XRef::fetch(int num, int gen, int recursion) { XRefEntry *e; Parser *parser; Object obj1, obj2, obj3; @@ -1158,24 +1124,23 @@ Object *XRef::fetch(int num, int gen, Object *obj, int recursion) { e = getEntry(num); if(!e->obj.isNull ()) { //check for updated object - obj = e->obj.copy(obj); - return obj; + return e->obj.copy(); } switch (e->type) { case xrefEntryUncompressed: + { if (e->gen != gen) { goto err; } - obj1.initNull(); parser = new Parser(this, new Lexer(this, - str->makeSubStream(start + e->offset, gFalse, 0, &obj1)), + str->makeSubStream(start + e->offset, gFalse, 0, Object(objNull))), gTrue); - parser->getObj(&obj1, recursion); - parser->getObj(&obj2, recursion); - parser->getObj(&obj3, recursion); + obj1 = parser->getObj(recursion); + obj2 = parser->getObj(recursion); + obj3 = parser->getObj(recursion); if (!obj1.isInt() || obj1.getInt() != num || !obj2.isInt() || obj2.getInt() != gen || !obj3.isCmd("obj")) { @@ -1194,28 +1159,19 @@ Object *XRef::fetch(int num, int gen, Object *obj, int recursion) { if (longNumber <= INT_MAX && longNumber >= INT_MIN && *end_ptr == '\0') { int number = longNumber; error(errSyntaxWarning, -1, "Cmd was not obj but {0:s}, assuming the creator meant obj {1:d}", cmd, number); - obj->initInt(number); - obj1.free(); - obj2.free(); - obj3.free(); delete parser; - break; + return Object(number); } } } - obj1.free(); - obj2.free(); - obj3.free(); delete parser; goto err; } - parser->getObj(obj, gFalse, (encrypted && !e->getFlag(XRefEntry::Unencrypted)) ? fileKey : NULL, + Object obj = parser->getObj(gFalse, (encrypted && !e->getFlag(XRefEntry::Unencrypted)) ? fileKey : NULL, encAlgorithm, keyLength, num, gen, recursion); - obj1.free(); - obj2.free(); - obj3.free(); delete parser; - break; + return obj; + } case xrefEntryCompressed: { @@ -1252,75 +1208,63 @@ Object *XRef::fetch(int num, int gen, Object *obj, int recursion) { objStrs->put(newkey, newitem); } } - objStr->getObject(e->gen, num, obj); + return objStr->getObject(e->gen, num); } - break; default: goto err; } - return obj; - err: if (!xRefStream && !xrefReconstructed) { error(errInternal, -1, "xref num {0:d} not found but needed, try to reconstruct\n", num); rootNum = -1; constructXRef(&xrefReconstructed); - return fetch(num, gen, obj, ++recursion); + return fetch(num, gen, ++recursion); } - return obj->initNull(); + return Object(objNull); } void XRef::lock() { -#if MULTITHREADED +#ifdef MULTITHREADED gLockMutex(&mutex); #endif } void XRef::unlock() { -#if MULTITHREADED +#ifdef MULTITHREADED gUnlockMutex(&mutex); #endif } -Object *XRef::getDocInfo(Object *obj) { - return trailerDict.dictLookup("Info", obj); +Object XRef::getDocInfo() { + return trailerDict.dictLookup("Info"); } // Added for the pdftex project. -Object *XRef::getDocInfoNF(Object *obj) { - return trailerDict.dictLookupNF("Info", obj); +Object XRef::getDocInfoNF() { + return trailerDict.dictLookupNF("Info"); } -Object *XRef::createDocInfoIfNoneExists(Object *obj) { - getDocInfo(obj); +Object XRef::createDocInfoIfNoneExists() { + Object obj = getDocInfo(); - if (obj->isDict()) { + if (obj.isDict()) { return obj; - } else if (!obj->isNull()) { + } else if (!obj.isNull()) { // DocInfo exists, but isn't a dictionary (doesn't comply with the PDF reference) - obj->free(); removeDocInfo(); } - obj->initDict(this); - - Ref ref = addIndirectObject(obj); - - Object objRef; - objRef.initRef(ref.num, ref.gen); - - trailerDict.dictSet("Info", &objRef); - - objRef.free(); + obj = Object(new Dict(this)); + const Ref ref = addIndirectObject(&obj); + trailerDict.dictSet("Info", Object(ref.num, ref.gen)); return obj; } void XRef::removeDocInfo() { - Object infoObjRef; - getDocInfoNF(&infoObjRef); + Object infoObjRef = getDocInfoNF(); if (infoObjRef.isNull()) { return; } @@ -1328,7 +1272,6 @@ void XRef::removeDocInfo() { trailerDict.dictRemove("Info"); removeIndirectObject(infoObjRef.getRef()); - infoObjRef.free(); } GBool XRef::getStreamEnd(Goffset streamStart, Goffset *streamEnd) { @@ -1385,7 +1328,7 @@ void XRef::add(int num, int gen, Goffset offs, GBool used) { for (int i = size; i < num + 1; ++i) { entries[i].offset = -1; entries[i].type = xrefEntryFree; - entries[i].obj.initNull (); + entries[i].obj.initNullAfterMalloc(); entries[i].flags = 0; entries[i].gen = 0; } @@ -1393,7 +1336,7 @@ void XRef::add(int num, int gen, Goffset offs, GBool used) { } XRefEntry *e = getEntry(num); e->gen = gen; - e->obj.initNull (); + e->obj.setToNull(); e->flags = 0; if (used) { e->type = xrefEntryUncompressed; @@ -1411,8 +1354,7 @@ void XRef::setModifiedObject (Object* o, Ref r) { return; } XRefEntry *e = getEntry(r.num); - e->obj.free(); - o->copy(&(e->obj)); + e->obj = o->copy(); e->setFlag(XRefEntry::Updated, gTrue); setModified(); } @@ -1438,7 +1380,7 @@ Ref XRef::addIndirectObject (Object* o) { //incremented when the object was deleted } e->type = xrefEntryUncompressed; - o->copy(&e->obj); + e->obj = o->copy(); e->setFlag(XRefEntry::Updated, gTrue); setModified(); @@ -1527,16 +1469,15 @@ void XRef::writeTableToFile(OutStream* outStr, GBool writeAllEntries) { writeXRef(&writer, writeAllEntries); } -XRef::XRefStreamWriter::XRefStreamWriter(Object *indexA, GooString *stmBufA, int offsetSizeA) { +XRef::XRefStreamWriter::XRefStreamWriter(Array *indexA, GooString *stmBufA, int offsetSizeA) { index = indexA; stmBuf = stmBufA; offsetSize = offsetSizeA; } void XRef::XRefStreamWriter::startSection(int first, int count) { - Object obj; - index->arrayAdd( obj.initInt(first) ); - index->arrayAdd( obj.initInt(count) ); + index->add( Object(first) ); + index->add( Object(count) ); } void XRef::XRefStreamWriter::writeEntry(Goffset offset, int gen, XRefEntryType type) { @@ -1565,8 +1506,7 @@ void XRef::XRefPreScanWriter::writeEntry(Goffset offset, int gen, XRefEntryType } void XRef::writeStreamToBuffer(GooString *stmBuf, Dict *xrefDict, XRef *xref) { - Object index; - index.initArray(xref); + Array *index = new Array(xref); stmBuf->clear(); // First pass: determine whether all offsets fit in 4 bytes or not @@ -1575,48 +1515,44 @@ void XRef::writeStreamToBuffer(GooString *stmBuf, Dict *xrefDict, XRef *xref) { const int offsetSize = prescan.hasOffsetsBeyond4GB ? sizeof(Goffset) : 4; // Second pass: actually write the xref stream - XRefStreamWriter writer(&index, stmBuf, offsetSize); + XRefStreamWriter writer(index, stmBuf, offsetSize); writeXRef(&writer, gFalse); - Object obj1, obj2; - xrefDict->set("Type", obj1.initName("XRef")); - xrefDict->set("Index", &index); - obj2.initArray(xref); - obj2.arrayAdd( obj1.initInt(1) ); - obj2.arrayAdd( obj1.initInt(offsetSize) ); - obj2.arrayAdd( obj1.initInt(2) ); - xrefDict->set("W", &obj2); + xrefDict->set("Type", Object(objName, "XRef")); + xrefDict->set("Index", Object(index)); + Array *wArray = new Array(xref); + wArray->add( Object(1) ); + wArray->add( Object(offsetSize) ); + wArray->add( Object(2) ); + xrefDict->set("W", Object(wArray)); } GBool XRef::parseEntry(Goffset offset, XRefEntry *entry) { GBool r; - Object obj; - obj.initNull(); - Parser parser = Parser(NULL, new Lexer(NULL, - str->makeSubStream(offset, gFalse, 20, &obj)), gTrue); + if (unlikely(entry == nullptr)) + return gFalse; + + Parser parser(NULL, new Lexer(NULL, + str->makeSubStream(offset, gFalse, 20, Object(objNull))), gTrue); Object obj1, obj2, obj3; - if (((parser.getObj(&obj1)->isInt()) || - parser.getObj(&obj1)->isInt64()) && - (parser.getObj(&obj2)->isInt()) && - (parser.getObj(&obj3)->isCmd("n") || obj3.isCmd("f"))) { + if (((obj1 = parser.getObj(), obj1.isInt()) || obj1.isInt64()) && + (obj2 = parser.getObj(), obj2.isInt()) && + (obj3 = parser.getObj(), obj3.isCmd("n") || obj3.isCmd("f"))) { if (obj1.isInt64()) entry->offset = obj1.getInt64(); else entry->offset = obj1.getInt(); entry->gen = obj2.getInt(); entry->type = obj3.isCmd("n") ? xrefEntryUncompressed : xrefEntryFree; - entry->obj.initNull (); + entry->obj.setToNull(); entry->flags = 0; r = gTrue; } else { r = gFalse; } - obj1.free(); - obj2.free(); - obj3.free(); return r; } @@ -1709,8 +1645,8 @@ void XRef::markUnencrypted(Object *obj) { { Array *array = obj->getArray(); for (int i = 0; i < array->getLength(); i++) { - markUnencrypted(array->getNF(i, &obj1)); - obj1.free(); + obj1 = array->getNF(i); + markUnencrypted(&obj1); } break; } @@ -1725,8 +1661,8 @@ void XRef::markUnencrypted(Object *obj) { dict = obj->getDict(); } for (int i = 0; i < dict->getLength(); i++) { - markUnencrypted(dict->getValNF(i, &obj1)); - obj1.free(); + obj1 = dict->getValNF(i); + markUnencrypted(&obj1); } break; } @@ -1737,9 +1673,8 @@ void XRef::markUnencrypted(Object *obj) { if (e->getFlag(XRefEntry::Unencrypted)) return; // We've already been here: prevent infinite recursion e->setFlag(XRefEntry::Unencrypted, gTrue); - fetch(ref.num, ref.gen, &obj1); + obj1 = fetch(ref.num, ref.gen); markUnencrypted(&obj1); - obj1.free(); break; } default: @@ -1783,19 +1718,16 @@ void XRef::scanSpecialFlags() { } // Mark objects referred from the Encrypt dict as Unencrypted - Object obj; - markUnencrypted(trailerDict.dictLookupNF("Encrypt", &obj)); - obj.free(); + Object obj = trailerDict.dictLookupNF("Encrypt"); + markUnencrypted(); } void XRef::markUnencrypted() { // Mark objects referred from the Encrypt dict as Unencrypted - Object obj; - trailerDict.dictLookupNF("Encrypt", &obj); + Object obj = trailerDict.dictLookupNF("Encrypt"); if (obj.isRef()) { XRefEntry *e = getEntry(obj.getRefNum()); e->setFlag(XRefEntry::Unencrypted, gTrue); } - obj.free(); } diff --git a/Build/source/libs/poppler/poppler-src/poppler/XRef.h b/Build/source/libs/poppler/poppler-src/poppler/XRef.h index 5ae33e5c738..9306a99b9e2 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/XRef.h +++ b/Build/source/libs/poppler/poppler-src/poppler/XRef.h @@ -14,14 +14,14 @@ // under GPL version 2 or later // // Copyright (C) 2005 Brad Hards <bradh@frogmouth.net> -// Copyright (C) 2006, 2008, 2010-2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2008, 2010-2013, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org> // Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2010 Ilya Gorenbein <igorenbein@finjan.com> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2012, 2013, 2016 Thomas Freitag <Thomas.Freitag@kabelmail.de> // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com> // // To see a description of the changes please see the Changelog file that @@ -141,18 +141,18 @@ public: int getPermFlags() { return permFlags; } // Get catalog object. - Object *getCatalog(Object *obj); + Object getCatalog(); // Fetch an indirect reference. - Object *fetch(int num, int gen, Object *obj, int recursion = 0); + Object fetch(int num, int gen, int recursion = 0); // Return the document's Info dictionary (if any). - Object *getDocInfo(Object *obj); - Object *getDocInfoNF(Object *obj); + Object getDocInfo(); + Object getDocInfoNF(); // Create and return the document's Info dictionary if none exists. // Otherwise return the existing one. - Object *createDocInfoIfNoneExists(Object *obj); + Object createDocInfoIfNoneExists(); // Remove the document's Info dictionary and update the trailer dictionary. void removeDocInfo(); @@ -235,7 +235,7 @@ private: Goffset mainXRefOffset; // position of the main XRef table/stream GBool scannedSpecialFlags; // true if scanSpecialFlags has been called GBool strOwner; // true if str is owned by the instance -#if MULTITHREADED +#ifdef MULTITHREADED GooMutex mutex; #endif @@ -262,8 +262,8 @@ private: class XRefTableWriter: public XRefWriter { public: XRefTableWriter(OutStream* outStrA); - void startSection(int first, int count); - void writeEntry(Goffset offset, int gen, XRefEntryType type); + void startSection(int first, int count) override; + void writeEntry(Goffset offset, int gen, XRefEntryType type) override; private: OutStream* outStr; }; @@ -271,11 +271,11 @@ private: // XRefWriter subclass that writes a XRef stream class XRefStreamWriter: public XRefWriter { public: - XRefStreamWriter(Object *index, GooString *stmBuf, int offsetSize); - void startSection(int first, int count); - void writeEntry(Goffset offset, int gen, XRefEntryType type); + XRefStreamWriter(Array *index, GooString *stmBuf, int offsetSize); + void startSection(int first, int count) override; + void writeEntry(Goffset offset, int gen, XRefEntryType type) override; private: - Object *index; + Array *index; GooString *stmBuf; int offsetSize; }; @@ -284,8 +284,8 @@ private: class XRefPreScanWriter: public XRefWriter { public: XRefPreScanWriter(); - void startSection(int first, int count); - void writeEntry(Goffset offset, int gen, XRefEntryType type); + void startSection(int first, int count) override; + void writeEntry(Goffset offset, int gen, XRefEntryType type) override; GBool hasOffsetsBeyond4GB; }; diff --git a/Build/source/libs/poppler/poppler-src/poppler/poppler-config.h.cmake b/Build/source/libs/poppler/poppler-src/poppler/poppler-config.h.cmake index 01c9a48280b..3a13e811554 100644 --- a/Build/source/libs/poppler/poppler-src/poppler/poppler-config.h.cmake +++ b/Build/source/libs/poppler/poppler-src/poppler/poppler-config.h.cmake @@ -16,6 +16,7 @@ // Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com> // Copyright (C) 2014 Hib Eris <hib@hiberis.nl> // Copyright (C) 2016 Tor Lillqvist <tml@collabora.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -25,8 +26,6 @@ #ifndef POPPLER_CONFIG_H #define POPPLER_CONFIG_H -#include <stdio.h> - // We duplicate some of the config.h #define's here since they are // used in some of the header files we install. The #ifndef/#endif // around #undef look odd, but it's to silence warnings about @@ -115,11 +114,6 @@ #cmakedefine HAVE_SYS_NDIR_H 1 #endif -/* Have FreeType2 include files */ -#ifndef HAVE_FREETYPE_H -#cmakedefine HAVE_FREETYPE_H 1 -#endif - /* Defines if use cms */ #ifndef USE_CMS #cmakedefine USE_CMS 1 @@ -127,8 +121,8 @@ // Also, there are preprocessor symbols in the header files // that are used but never defined when building poppler using configure -// or cmake: DISABLE_OUTLINE, DEBUG_MEM, SPLASH_CMYK, HAVE_T1LIB_H, -// ENABLE_PLUGINS, DEBUG_FORMS, HAVE_FREETYPE_FREETYPE_H +// or cmake: DISABLE_OUTLINE, DEBUG_MEM, +// ENABLE_PLUGINS, DEBUG_FORMS //------------------------------------------------------------------------ // version @@ -139,21 +133,6 @@ #define xpdfCopyright "Copyright 1996-2011 Glyph & Cog, LLC" //------------------------------------------------------------------------ -// popen -//------------------------------------------------------------------------ - -#if defined(_MSC_VER) || defined(__BORLANDC__) -#define popen _popen -#define pclose _pclose -#endif - -#if defined(VMS) || defined(VMCMS) || defined(DOS) || defined(OS2) || defined(__EMX__) || defined(_WIN32) || defined(__DJGPP__) || defined(MACOS) -#define POPEN_READ_MODE "rb" -#else -#define POPEN_READ_MODE "r" -#endif - -//------------------------------------------------------------------------ // Win32 stuff //------------------------------------------------------------------------ @@ -163,19 +142,12 @@ #define CDECL #endif -#if defined(_WIN32) -#ifdef _MSC_VER -#define strtok_r strtok_s -#elif __MINGW32__ && !defined(__WINPTHREADS_VERSION) -char * strtok_r (char *s, const char *delim, char **save_ptr); -#endif -#endif - //------------------------------------------------------------------------ // Compiler //------------------------------------------------------------------------ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#include <stdio.h> // __MINGW_PRINTF_FORMAT is defined in the mingw stdio.h #ifdef __MINGW_PRINTF_FORMAT #define GCC_PRINTF_FORMAT(fmt_index, va_index) \ __attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index))) @@ -187,10 +159,4 @@ char * strtok_r (char *s, const char *delim, char **save_ptr); #define GCC_PRINTF_FORMAT(fmt_index, va_index) #endif -#if defined(_MSC_VER) && _MSC_VER < 1800 -#define fmax(a, b) std::max(a, b) -#define fmin(a, b) std::min(a, b) -#endif - - #endif /* POPPLER_CONFIG_H */ diff --git a/Build/source/libs/poppler/poppler-src/splash/Makefile.am b/Build/source/libs/poppler/poppler-src/splash/Makefile.am deleted file mode 100644 index 5c265d6360c..00000000000 --- a/Build/source/libs/poppler/poppler-src/splash/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -noinst_LTLIBRARIES = libsplash.la - -if ENABLE_XPDF_HEADERS - -poppler_splash_includedir = $(includedir)/poppler/splash -poppler_splash_include_HEADERS = \ - Splash.h \ - SplashBitmap.h \ - SplashClip.h \ - SplashErrorCodes.h \ - SplashFTFont.h \ - SplashFTFontEngine.h \ - SplashFTFontFile.h \ - SplashFont.h \ - SplashFontEngine.h \ - SplashFontFile.h \ - SplashFontFileID.h \ - SplashGlyphBitmap.h \ - SplashMath.h \ - SplashPath.h \ - SplashPattern.h \ - SplashScreen.h \ - SplashState.h \ - SplashT1Font.h \ - SplashT1FontEngine.h \ - SplashT1FontFile.h \ - SplashTypes.h \ - SplashXPath.h \ - SplashXPathScanner.h - -endif - -libsplash_la_SOURCES = \ - Splash.cc \ - SplashBitmap.cc \ - SplashClip.cc \ - SplashFTFont.cc \ - SplashFTFontEngine.cc \ - SplashFTFontFile.cc \ - SplashFont.cc \ - SplashFontEngine.cc \ - SplashFontFile.cc \ - SplashFontFileID.cc \ - SplashPath.cc \ - SplashPattern.cc \ - SplashScreen.cc \ - SplashState.cc \ - SplashT1Font.cc \ - SplashT1FontEngine.cc \ - SplashT1FontFile.cc \ - SplashXPath.cc \ - SplashXPathScanner.cc - -# SplashBitmap includes JpegWriter.h, TiffWriter.h, PNGWriter.h -if BUILD_LIBJPEG -libjpeg_includes = $(LIBJPEG_CFLAGS) -endif - -if BUILD_LIBTIFF -libtiff_includes = $(LIBTIFF_CFLAGS) -endif - -if BUILD_LIBPNG -libpng_includes = $(LIBPNG_CFLAGS) -endif - -libsplash_la_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/goo \ - $(libjpeg_includes) \ - $(libtiff_includes) \ - $(libpng_includes) \ - $(FREETYPE_CFLAGS) diff --git a/Build/source/libs/poppler/poppler-src/splash/Splash.cc b/Build/source/libs/poppler/poppler-src/splash/Splash.cc index 46b8ce292c2..129d01f02ce 100644 --- a/Build/source/libs/poppler/poppler-src/splash/Splash.cc +++ b/Build/source/libs/poppler/poppler-src/splash/Splash.cc @@ -11,13 +11,13 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // Copyright (C) 2010-2016 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011-2013, 2015 William Bader <williambader@hotmail.com> // Copyright (C) 2012 Markus Trippelsdorf <markus@trippelsdorf.de> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Matthias Kramm <kramm@quiss.org> // // To see a description of the changes please see the Changelog file that @@ -171,7 +171,7 @@ SplashPipeResultColorCtrl Splash::pipeResultColorNoAlphaBlend[] = { splashPipeResultColorNoAlphaBlendRGB, splashPipeResultColorNoAlphaBlendRGB, splashPipeResultColorNoAlphaBlendRGB -#if SPLASH_CMYK +#ifdef SPLASH_CMYK , splashPipeResultColorNoAlphaBlendCMYK, splashPipeResultColorNoAlphaBlendDeviceN @@ -184,7 +184,7 @@ SplashPipeResultColorCtrl Splash::pipeResultColorAlphaNoBlend[] = { splashPipeResultColorAlphaNoBlendRGB, splashPipeResultColorAlphaNoBlendRGB, splashPipeResultColorAlphaNoBlendRGB -#if SPLASH_CMYK +#ifdef SPLASH_CMYK , splashPipeResultColorAlphaNoBlendCMYK, splashPipeResultColorAlphaNoBlendDeviceN @@ -197,7 +197,7 @@ SplashPipeResultColorCtrl Splash::pipeResultColorAlphaBlend[] = { splashPipeResultColorAlphaBlendRGB, splashPipeResultColorAlphaBlendRGB, splashPipeResultColorAlphaBlendRGB -#if SPLASH_CMYK +#ifdef SPLASH_CMYK , splashPipeResultColorAlphaBlendCMYK, splashPipeResultColorAlphaBlendDeviceN @@ -311,7 +311,7 @@ inline void Splash::pipeInit(SplashPipe *pipe, int x, int y, pipe->run = &Splash::pipeRunSimpleXBGR8; } else if (bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr) { pipe->run = &Splash::pipeRunSimpleBGR8; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK } else if (bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) { pipe->run = &Splash::pipeRunSimpleCMYK8; } else if (bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr) { @@ -332,7 +332,7 @@ inline void Splash::pipeInit(SplashPipe *pipe, int x, int y, pipe->run = &Splash::pipeRunAAXBGR8; } else if (bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr) { pipe->run = &Splash::pipeRunAABGR8; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK } else if (bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) { pipe->run = &Splash::pipeRunAACMYK8; } else if (bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr) { @@ -349,7 +349,7 @@ void Splash::pipeRun(SplashPipe *pipe) { SplashColorPtr cSrc; Guchar cResult0, cResult1, cResult2, cResult3; int t; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK int cp, mask; Guchar cResult[SPOT_NCOMPS+4]; #endif @@ -365,7 +365,7 @@ void Splash::pipeRun(SplashPipe *pipe) { pipeIncX(pipe); return; } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (bitmap->mode == splashModeCMYK8 || bitmap->mode == splashModeDeviceN8) { if (state->fillOverprint && state->overprintMode && pipe->pattern->isCMYK()) { Guint mask = 15; @@ -423,7 +423,7 @@ void Splash::pipeRun(SplashPipe *pipe) { *pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]]; *pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]]; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: if (state->overprintMask & 1) { pipe->destColorPtr[0] = (state->overprintAdditive) ? @@ -482,12 +482,12 @@ void Splash::pipeRun(SplashPipe *pipe) { destColorPtr += (alpha0X+pipe->x) * 3; break; case splashModeXBGR8: -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: #endif destColorPtr += (alpha0X+pipe->x) * 4; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeDeviceN8: destColorPtr += (alpha0X+pipe->x) * (SPOT_NCOMPS + 4); break; @@ -519,7 +519,7 @@ void Splash::pipeRun(SplashPipe *pipe) { cDest[1] = destColorPtr[1]; cDest[2] = destColorPtr[0]; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: cDest[0] = destColorPtr[0]; cDest[1] = destColorPtr[1]; @@ -566,7 +566,7 @@ void Splash::pipeRun(SplashPipe *pipe) { } else { t = (aDest * 255) / pipe->shape - aDest; switch (bitmap->mode) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeDeviceN8: for (cp = 0; cp < SPOT_NCOMPS + 4; cp++) cSrcNonIso[cp] = clip255(pipe->cSrc[cp] + @@ -580,12 +580,14 @@ void Splash::pipeRun(SplashPipe *pipe) { #endif case splashModeXBGR8: cSrcNonIso[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: cSrcNonIso[2] = clip255(pipe->cSrc[2] + ((pipe->cSrc[2] - cDest[2]) * t) / 255); cSrcNonIso[1] = clip255(pipe->cSrc[1] + ((pipe->cSrc[1] - cDest[1]) * t) / 255); + // fallthrough case splashModeMono1: case splashModeMono8: cSrcNonIso[0] = clip255(pipe->cSrc[0] + @@ -605,7 +607,7 @@ void Splash::pipeRun(SplashPipe *pipe) { //----- blend function if (state->blendFunc) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (bitmap->mode == splashModeDeviceN8) { for (int k = 4; k < 4 + SPOT_NCOMPS; k++) { cBlend[k] = 0; @@ -652,7 +654,7 @@ void Splash::pipeRun(SplashPipe *pipe) { cResult2 = state->rgbTransferB[div255((255 - aDest) * cSrc[2] + aDest * cBlend[2])]; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashPipeResultColorNoAlphaBlendCMYK: cResult0 = state->cmykTransferC[div255((255 - aDest) * cSrc[0] + aDest * cBlend[0])]; @@ -692,7 +694,7 @@ void Splash::pipeRun(SplashPipe *pipe) { aSrc * cSrc[2]) / alphaI]; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashPipeResultColorAlphaNoBlendCMYK: if (alphaI == 0) { cResult0 = 0; @@ -752,7 +754,7 @@ void Splash::pipeRun(SplashPipe *pipe) { alphaI]; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashPipeResultColorAlphaBlendCMYK: if (alphaI == 0) { cResult0 = 0; @@ -826,7 +828,7 @@ void Splash::pipeRun(SplashPipe *pipe) { *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult0; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: if (state->overprintMask & 1) { pipe->destColorPtr[0] = (state->overprintAdditive) ? @@ -943,7 +945,7 @@ void Splash::pipeRunSimpleBGR8(SplashPipe *pipe) { ++pipe->x; } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK // special case: // !pipe->pattern && pipe->noTransparency && !state->blendFunc && // bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) { @@ -1204,7 +1206,7 @@ void Splash::pipeRunAABGR8(SplashPipe *pipe) { ++pipe->x; } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK // special case: // !pipe->pattern && !pipe->noTransparency && !state->softMask && // pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && @@ -1343,7 +1345,7 @@ inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) { case splashModeXBGR8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; @@ -1388,7 +1390,7 @@ inline void Splash::pipeIncX(SplashPipe *pipe) { case splashModeXBGR8: pipe->destColorPtr += 4; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr += 4; break; @@ -1965,7 +1967,7 @@ void Splash::clear(SplashColorPtr color, Guchar alpha) { } } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: if (color[0] == color[1] && color[1] == color[2] && color[2] == color[3]) { if (bitmap->rowSize < 0) { @@ -2186,7 +2188,7 @@ SplashPath *Splash::flattenPath(SplashPath *path, SplashCoord *matrix, int i; fPath = new SplashPath(); -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT flatness2 = flatness; #else flatness2 = flatness * flatness; @@ -2255,7 +2257,7 @@ void Splash::flattenCurve(SplashCoord x0, SplashCoord y0, // line) transform(matrix, (xl0 + xr3) * 0.5, (yl0 + yr3) * 0.5, &mx, &my); transform(matrix, xx1, yy1, &tx, &ty); -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT d1 = splashDist(tx, ty, mx, my); #else dx = tx - mx; @@ -2263,7 +2265,7 @@ void Splash::flattenCurve(SplashCoord x0, SplashCoord y0, d1 = dx*dx + dy*dy; #endif transform(matrix, xx2, yy2, &tx, &ty); -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT d2 = splashDist(tx, ty, mx, my); #else dx = tx - mx; @@ -3710,7 +3712,7 @@ SplashError Splash::drawImage(SplashImageSource src, SplashICCTransform tf, void ok = srcMode == splashModeBGR8; nComps = 3; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: ok = srcMode == splashModeCMYK8; nComps = 4; @@ -4134,7 +4136,7 @@ SplashError Splash::arbitraryTransformImage(SplashImageSource src, SplashICCTran static GBool isImageInterpolationRequired(int srcWidth, int srcHeight, int scaledWidth, int scaledHeight, GBool interpolate) { - if (interpolate) + if (interpolate || srcWidth == 0 || srcHeight == 0) return gTrue; /* When scale factor is >= 400% we don't interpolate. See bugs #25268, #9860 */ @@ -4152,7 +4154,7 @@ SplashBitmap *Splash::scaleImage(SplashImageSource src, void *srcData, SplashBitmap *dest; dest = new SplashBitmap(scaledWidth, scaledHeight, 1, srcMode, srcAlpha, gTrue, bitmap->getSeparationList()); - if (dest->getDataPtr() != NULL) { + if (dest->getDataPtr() != NULL && srcHeight > 0 && srcWidth > 0) { if (scaledHeight < srcHeight) { if (scaledWidth < srcWidth) { scaleImageYdXd(src, srcData, srcMode, nComps, srcAlpha, @@ -4190,7 +4192,7 @@ void Splash::scaleImageYdXd(SplashImageSource src, void *srcData, Guchar *lineBuf, *alphaLineBuf; Guint *pixBuf, *alphaPixBuf; Guint pix0, pix1, pix2; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guint pix3; Guint pix[SPOT_NCOMPS+4], cp; #endif @@ -4348,7 +4350,7 @@ void Splash::scaleImageYdXd(SplashImageSource src, void *srcData, *destPtr++ = (Guchar)pix0; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: // compute the final pixel @@ -4533,7 +4535,7 @@ void Splash::scaleImageYdXu(SplashImageSource src, void *srcData, *destPtr++ = (Guchar)pix[0]; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: for (i = 0; i < xStep; ++i) { *destPtr++ = (Guchar)pix[0]; @@ -4683,7 +4685,7 @@ void Splash::scaleImageYuXd(SplashImageSource src, void *srcData, *destPtr++ = (Guchar)pix[0]; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: for (i = 0; i < yStep; ++i) { destPtr = destPtr0 + (i * scaledWidth + x) * nComps; @@ -4836,7 +4838,7 @@ void Splash::scaleImageYuXu(SplashImageSource src, void *srcData, } } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: for (i = 0; i < yStep; ++i) { for (j = 0; j < xStep; ++j) { @@ -4997,7 +4999,7 @@ void Splash::scaleImageYuXuBilinear(SplashImageSource src, void *srcData, *destPtr++ = (Guchar)pix[1]; *destPtr++ = (Guchar)pix[0]; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: *destPtr++ = (Guchar)pix[0]; *destPtr++ = (Guchar)pix[1]; @@ -5324,7 +5326,7 @@ void Splash::compositeBackground(SplashColorPtr color) { SplashColorPtr p; Guchar *q; Guchar alpha, alpha1, c, color0, color1, color2; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guchar color3; Guchar colorsp[SPOT_NCOMPS+4], cp; #endif @@ -5426,7 +5428,7 @@ void Splash::compositeBackground(SplashColorPtr color) { } } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: color0 = color[0]; color1 = color[1]; @@ -5535,7 +5537,7 @@ GBool Splash::gouraudTriangleShadedFill(SplashGouraudColor *shading) case splashModeXBGR8: colorComps=4; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: colorComps=4; break; @@ -5876,7 +5878,7 @@ SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc, } } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: for (y = 0; y < h; ++y) { p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; @@ -6025,7 +6027,7 @@ SplashPath *pathIn, *dashPath, *pathOut; ++k1) ; // compute the deltas for segment (i1, j0) -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT // the 1/d value can be small, which introduces significant // inaccuracies in fixed point mode d = splashDist(pathIn->pts[i1].x, pathIn->pts[i1].y, @@ -6126,7 +6128,7 @@ SplashPath *pathIn, *dashPath, *pathOut; if (!last || closed) { // compute the deltas for segment (j1, k0) -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT // the 1/d value can be small, which introduces significant // inaccuracies in fixed point mode d = splashDist(pathIn->pts[j1].x, pathIn->pts[j1].y, diff --git a/Build/source/libs/poppler/poppler-src/splash/Splash.h b/Build/source/libs/poppler/poppler-src/splash/Splash.h index 3ca15c38bce..907e4c3b6ee 100644 --- a/Build/source/libs/poppler/poppler-src/splash/Splash.h +++ b/Build/source/libs/poppler/poppler-src/splash/Splash.h @@ -15,7 +15,7 @@ // Copyright (C) 2007, 2011 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010-2013, 2015 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -62,7 +62,7 @@ typedef void (*SplashICCTransform)(void *data, SplashBitmap *bitmap); //------------------------------------------------------------------------ enum SplashPipeResultColorCtrl { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK splashPipeResultColorNoAlphaBlendCMYK, splashPipeResultColorNoAlphaBlendDeviceN, #endif @@ -70,13 +70,13 @@ enum SplashPipeResultColorCtrl { splashPipeResultColorNoAlphaBlendMono, splashPipeResultColorAlphaNoBlendMono, splashPipeResultColorAlphaNoBlendRGB, -#if SPLASH_CMYK +#ifdef SPLASH_CMYK splashPipeResultColorAlphaNoBlendCMYK, splashPipeResultColorAlphaNoBlendDeviceN, #endif splashPipeResultColorAlphaBlendMono, splashPipeResultColorAlphaBlendRGB -#if SPLASH_CMYK +#ifdef SPLASH_CMYK , splashPipeResultColorAlphaBlendCMYK, splashPipeResultColorAlphaBlendDeviceN @@ -298,7 +298,7 @@ private: void pipeRunSimpleRGB8(SplashPipe *pipe); void pipeRunSimpleXBGR8(SplashPipe *pipe); void pipeRunSimpleBGR8(SplashPipe *pipe); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK void pipeRunSimpleCMYK8(SplashPipe *pipe); void pipeRunSimpleDeviceN8(SplashPipe *pipe); #endif @@ -307,7 +307,7 @@ private: void pipeRunAARGB8(SplashPipe *pipe); void pipeRunAAXBGR8(SplashPipe *pipe); void pipeRunAABGR8(SplashPipe *pipe); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK void pipeRunAACMYK8(SplashPipe *pipe); void pipeRunAADeviceN8(SplashPipe *pipe); #endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.cc b/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.cc index e9b2be421c8..5acee7d0bd6 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.cc +++ b/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.cc @@ -15,7 +15,7 @@ // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> // Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010, 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2010, 2012, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2010, 2015 William Bader <williambader@hotmail.com> @@ -90,7 +90,7 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPadA, rowSize = -1; } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: if (width > 0 && width <= INT_MAX / 4) { rowSize = width * 4; @@ -247,7 +247,7 @@ SplashError SplashBitmap::writePNMFile(FILE *f) { } break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: // PNM doesn't support CMYK @@ -308,7 +308,7 @@ void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) { pixel[1] = p[1]; pixel[2] = p[0]; break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: p = &data[y * rowSize + 4 * x]; pixel[0] = p[0]; @@ -337,7 +337,7 @@ SplashColorPtr SplashBitmap::takeData() { return data2; } -SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, const char *compressionString) { +SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, WriteImgParams* params) { FILE *f; SplashError e; @@ -345,13 +345,24 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, char *fileN return splashErrOpenFile; } - e = writeImgFile(format, f, hDPI, vDPI, compressionString); - + e = writeImgFile(format, f, hDPI, vDPI, params); + fclose(f); return e; } -SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, const char *compressionString) { +void SplashBitmap::setJpegParams(ImgWriter *writer, WriteImgParams* params) +{ +#ifdef ENABLE_LIBJPEG + if (params) { + static_cast<JpegWriter*>(writer)->setProgressive(params->jpegProgressive); + if (params->jpegQuality >= 0) + static_cast<JpegWriter*>(writer)->setQuality(params->jpegQuality); + } +#endif +} + +SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, WriteImgParams* params) { ImgWriter *writer; SplashError e; @@ -365,13 +376,15 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in #endif #ifdef ENABLE_LIBJPEG - #if SPLASH_CMYK + #ifdef SPLASH_CMYK case splashFormatJpegCMYK: writer = new JpegWriter(JpegWriter::CMYK); + setJpegParams(writer, params); break; #endif case splashFormatJpeg: writer = new JpegWriter(); + setJpegParams(writer, params); break; #endif @@ -390,7 +403,7 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in case splashModeBGR8: writer = new TiffWriter(TiffWriter::RGB); break; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: case splashModeDeviceN8: writer = new TiffWriter(TiffWriter::CMYK); @@ -400,8 +413,8 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in fprintf(stderr, "TiffWriter: Mode %d not supported\n", mode); writer = new TiffWriter(); } - if (writer) { - ((TiffWriter *)writer)->setCompressionString(compressionString); + if (writer && params) { + ((TiffWriter *)writer)->setCompressionString(params->tiffCompression.getCString()); } break; #endif @@ -430,7 +443,7 @@ void SplashBitmap::getRGBLine(int yl, SplashColorPtr line) { m = byteToDbl(col[1]); y = byteToDbl(col[2]); k = byteToDbl(col[3]); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (separationList->getLength() > 0) { for (int i = 0; i < separationList->getLength(); i++) { if (col[i+4] > 0) { @@ -476,7 +489,7 @@ void SplashBitmap::getXBGRLine(int yl, SplashColorPtr line, ConversionMode conve m = byteToDbl(col[1]); y = byteToDbl(col[2]); k = byteToDbl(col[3]); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK if (separationList->getLength() > 0) { for (int i = 0; i < separationList->getLength(); i++) { if (col[i+4] > 0) { @@ -580,7 +593,7 @@ GBool SplashBitmap::convertToXBGR(ConversionMode conversionMode) { return newdata != NULL; } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK void SplashBitmap::getCMYKLine(int yl, SplashColorPtr line) { SplashColor col; @@ -624,7 +637,7 @@ void SplashBitmap::getCMYKLine(int yl, SplashColorPtr line) { SplashError SplashBitmap::writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI, SplashColorMode imageWriterFormat) { if (mode != splashModeRGB8 && mode != splashModeMono8 && mode != splashModeMono1 && mode != splashModeXBGR8 && mode != splashModeBGR8 -#if SPLASH_CMYK +#ifdef SPLASH_CMYK && mode != splashModeCMYK8 && mode != splashModeDeviceN8 #endif ) { @@ -637,7 +650,7 @@ SplashError SplashBitmap::writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int } switch (mode) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK case splashModeCMYK8: if (writer->supportCMYK()) { SplashColorPtr row; diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.h b/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.h index 6858f90f357..ccd3e7d955c 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashBitmap.h @@ -15,7 +15,7 @@ // Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> // Copyright (C) 2009, 2012 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2010, 2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2010 William Bader <williambader@hotmail.com> @@ -72,9 +72,16 @@ public: SplashError writePNMFile(char *fileName); SplashError writePNMFile(FILE *f); SplashError writeAlphaPGMFile(char *fileName); - - SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, const char *compressionString = ""); - SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, const char *compressionString = ""); + + struct WriteImgParams + { + int jpegQuality = -1; + GBool jpegProgressive = gFalse; + GooString tiffCompression; + }; + + SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, WriteImgParams* params = nullptr); + SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, WriteImgParams* params = nullptr); SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI, SplashColorMode imageWriterFormat); enum ConversionMode @@ -89,7 +96,7 @@ public: void getPixel(int x, int y, SplashColorPtr pixel); void getRGBLine(int y, SplashColorPtr line); void getXBGRLine(int y, SplashColorPtr line, ConversionMode conversionMode = conversionOpaque); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK void getCMYKLine(int y, SplashColorPtr line); #endif Guchar getAlpha(int x, int y); @@ -112,6 +119,8 @@ private: GooList *separationList; // list of spot colorants and their mapping functions friend class Splash; + + void setJpegParams(ImgWriter *writer, WriteImgParams* params); }; #endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.cc b/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.cc index b785826d66b..91226da0421 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.cc +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.cc @@ -17,6 +17,7 @@ // Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -25,8 +26,6 @@ #include <config.h> -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #ifdef USE_GCC_PRAGMAS #pragma implementation #endif @@ -65,7 +64,7 @@ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA, FT_Face face; int div; int x, y; -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT SplashCoord scale; #endif @@ -87,7 +86,7 @@ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA, div = face->bbox.xMax > 20000 ? 65536 : 1; -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT scale = (SplashCoord)1 / (SplashCoord)face->units_per_EM; // transform the four corners of the font bounding box -- the min @@ -204,7 +203,7 @@ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA, } // compute the transform matrix -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT matrix.xx = (FT_Fixed)((mat[0] / size).get16Dot16()); matrix.yx = (FT_Fixed)((mat[1] / size).get16Dot16()); matrix.xy = (FT_Fixed)((mat[2] / size).get16Dot16()); @@ -509,5 +508,3 @@ static int glyphPathCubicTo(const FT_Vector *ctrl1, const FT_Vector *ctrl2, p->needClose = gTrue; return 0; } - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.h b/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.h index 98cb29dfbba..5f0d197669b 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFTFont.h @@ -14,6 +14,7 @@ // Copyright (C) 2007-2009, 2011 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -25,8 +26,6 @@ #include "poppler-config.h" -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #ifdef USE_GCC_PRAGMAS #pragma interface #endif @@ -50,19 +49,19 @@ public: virtual ~SplashFTFont(); // Munge xFrac and yFrac before calling SplashFont::getGlyph. - virtual GBool getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); + GBool getGlyph(int c, int xFrac, int yFrac, + SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) override; // Rasterize a glyph. The <xFrac> and <yFrac> values are the same // as described for getGlyph. - virtual GBool makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); + GBool makeGlyph(int c, int xFrac, int yFrac, + SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) override; // Return the path for a glyph. - virtual SplashPath *getGlyphPath(int c); + SplashPath *getGlyphPath(int c) override; // Return the advance of a glyph. (in 0..1 range) - virtual double getGlyphAdvance(int c); + double getGlyphAdvance(int c) override; private: @@ -75,6 +74,4 @@ private: GBool enableSlightHinting; }; -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.cc b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.cc index 9fef8f007d1..9b20f4a17ab 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.cc +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.cc @@ -15,6 +15,7 @@ // Copyright (C) 2009, 2011, 2012 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -23,8 +24,6 @@ #include <config.h> -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #ifdef USE_GCC_PRAGMAS #pragma implementation #endif @@ -176,5 +175,3 @@ SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA, faceIndex); return ret; } - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.h b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.h index 11bbea74a80..899458bc5a7 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.h @@ -16,6 +16,7 @@ // Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -25,8 +26,6 @@ #ifndef SPLASHFTFONTENGINE_H #define SPLASHFTFONTENGINE_H -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #ifdef USE_GCC_PRAGMAS #pragma interface #endif @@ -76,6 +75,4 @@ private: friend class SplashFTFont; }; -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.cc b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.cc index f0dcf50384b..3c070b70178 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.cc +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.cc @@ -12,7 +12,8 @@ // under GPL version 2 or later // // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2014 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2014, 2017 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2017 Oliver Sander <oliver.sander@tu-dresden.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 @@ -21,8 +22,6 @@ #include <config.h> -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #ifdef USE_GCC_PRAGMAS #pragma implementation #endif @@ -145,4 +144,6 @@ SplashFont *SplashFTFontFile::makeFont(SplashCoord *mat, return font; } -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H +int *SplashFTFontFile::getCodeToGID() { + return codeToGID; +} diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.h b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.h index d642af0a0ab..5931be3fe73 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFTFontFile.h @@ -12,6 +12,8 @@ // under GPL version 2 or later // // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> +// Copyright (C) 2017 Oliver Sander <oliver.sander@tu-dresden.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -21,8 +23,6 @@ #ifndef SPLASHFTFONTFILE_H #define SPLASHFTFONTFILE_H -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #ifdef USE_GCC_PRAGMAS #pragma interface #endif @@ -55,12 +55,15 @@ public: int codeToGIDLenA, int faceIndexA=0); - virtual ~SplashFTFontFile(); + ~SplashFTFontFile(); // Create a new SplashFTFont, i.e., a scaled instance of this font // file. - virtual SplashFont *makeFont(SplashCoord *mat, - SplashCoord *textMat); + SplashFont *makeFont(SplashCoord *mat, + SplashCoord *textMat) override; + + // Provide access to the code-to-GID map + int* getCodeToGID(); private: @@ -81,6 +84,4 @@ private: friend class SplashFTFont; }; -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - #endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.cc b/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.cc index 73ef8de0877..62e5a0199bf 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.cc +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.cc @@ -18,6 +18,7 @@ // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2015 Dmytro Morgun <lztoad@gmail.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -30,10 +31,6 @@ #pragma implementation #endif -#if HAVE_T1LIB_H -#include <t1lib.h> -#endif - #include <stdlib.h> #include <stdio.h> #ifdef HAVE_UNISTD_H @@ -42,7 +39,6 @@ #include "goo/gmem.h" #include "goo/GooString.h" #include "SplashMath.h" -#include "SplashT1FontEngine.h" #include "SplashFTFontEngine.h" #include "SplashFontFile.h" #include "SplashFontFileID.h" @@ -66,14 +62,9 @@ extern "C" int unlink(char *filename); //------------------------------------------------------------------------ SplashFontEngine::SplashFontEngine( -#if HAVE_T1LIB_H - GBool enableT1lib, -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H GBool enableFreeType, GBool enableFreeTypeHinting, GBool enableSlightHinting, -#endif GBool aa) { int i; @@ -81,20 +72,11 @@ SplashFontEngine::SplashFontEngine( fontCache[i] = NULL; } -#if HAVE_T1LIB_H - if (enableT1lib) { - t1Engine = SplashT1FontEngine::init(aa); - } else { - t1Engine = NULL; - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (enableFreeType) { ftEngine = SplashFTFontEngine::init(aa, enableFreeTypeHinting, enableSlightHinting); } else { ftEngine = NULL; } -#endif } SplashFontEngine::~SplashFontEngine() { @@ -106,16 +88,9 @@ SplashFontEngine::~SplashFontEngine() { } } -#if HAVE_T1LIB_H - if (t1Engine) { - delete t1Engine; - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (ftEngine) { delete ftEngine; } -#endif } SplashFontFile *SplashFontEngine::getFontFile(SplashFontFileID *id) { @@ -139,16 +114,9 @@ SplashFontFile *SplashFontEngine::loadType1Font(SplashFontFileID *idA, SplashFontFile *fontFile; fontFile = NULL; -#if HAVE_T1LIB_H - if (!fontFile && t1Engine) { - fontFile = t1Engine->loadType1Font(idA, src, enc); - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (!fontFile && ftEngine) { fontFile = ftEngine->loadType1Font(idA, src, enc); } -#endif // delete the (temporary) font file -- with Unix hard link // semantics, this will remove the last link; otherwise it will @@ -166,16 +134,9 @@ SplashFontFile *SplashFontEngine::loadType1CFont(SplashFontFileID *idA, SplashFontFile *fontFile; fontFile = NULL; -#if HAVE_T1LIB_H - if (!fontFile && t1Engine) { - fontFile = t1Engine->loadType1CFont(idA, src, enc); - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (!fontFile && ftEngine) { fontFile = ftEngine->loadType1CFont(idA, src, enc); } -#endif // delete the (temporary) font file -- with Unix hard link // semantics, this will remove the last link; otherwise it will @@ -193,11 +154,9 @@ SplashFontFile *SplashFontEngine::loadOpenTypeT1CFont(SplashFontFileID *idA, SplashFontFile *fontFile; fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (!fontFile && ftEngine) { fontFile = ftEngine->loadOpenTypeT1CFont(idA, src, enc); } -#endif // delete the (temporary) font file -- with Unix hard link // semantics, this will remove the last link; otherwise it will @@ -214,11 +173,9 @@ SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA, SplashFontFile *fontFile; fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (!fontFile && ftEngine) { fontFile = ftEngine->loadCIDFont(idA, src); } -#endif // delete the (temporary) font file -- with Unix hard link // semantics, this will remove the last link; otherwise it will @@ -237,11 +194,9 @@ SplashFontFile *SplashFontEngine::loadOpenTypeCFFFont(SplashFontFileID *idA, SplashFontFile *fontFile; fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (!fontFile && ftEngine) { fontFile = ftEngine->loadOpenTypeCFFFont(idA, src, codeToGID, codeToGIDLen); } -#endif // delete the (temporary) font file -- with Unix hard link // semantics, this will remove the last link; otherwise it will @@ -261,12 +216,10 @@ SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA, SplashFontFile *fontFile; fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H if (!fontFile && ftEngine) { fontFile = ftEngine->loadTrueTypeFont(idA, src, codeToGID, codeToGIDLen, faceIndex); } -#endif if (!fontFile) { gfree(codeToGID); @@ -282,7 +235,6 @@ SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA, return fontFile; } -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H GBool SplashFontEngine::getAA() { return (ftEngine == NULL) ? gFalse : ftEngine->getAA(); } @@ -292,7 +244,6 @@ void SplashFontEngine::setAA(GBool aa) { ftEngine->setAA(aa); } } -#endif SplashFont *SplashFontEngine::getFont(SplashFontFile *fontFile, SplashCoord *textMat, diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.h b/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.h index 6502ea5a7fa..e3ee1ce600d 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashFontEngine.h @@ -16,6 +16,7 @@ // Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -54,14 +55,9 @@ public: // Create a font engine. SplashFontEngine( -#if HAVE_T1LIB_H - GBool enableT1lib, -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H GBool enableFreeType, GBool enableFreeTypeHinting, GBool enableSlightHinting, -#endif GBool aa); ~SplashFontEngine(); @@ -90,21 +86,14 @@ public: // Note that the Splash y axis points downward. SplashFont *getFont(SplashFontFile *fontFile, SplashCoord *textMat, SplashCoord *ctm); -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H GBool getAA(); void setAA(GBool aa); -#endif private: SplashFont *fontCache[splashFontCacheSize]; -#if HAVE_T1LIB_H - SplashT1FontEngine *t1Engine; -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H SplashFTFontEngine *ftEngine; -#endif }; #endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashMath.h b/Build/source/libs/poppler/poppler-src/splash/SplashMath.h index ca73c2bd1f3..36793ea3fcd 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashMath.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashMath.h @@ -12,6 +12,7 @@ // under GPL version 2 or later // // Copyright (C) 2009-2011 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -23,7 +24,7 @@ #include "poppler-config.h" -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT #include "goo/FixedPoint.h" #else #include <math.h> @@ -31,9 +32,9 @@ #include "SplashTypes.h" static inline SplashCoord splashAbs(SplashCoord x) { -#if USE_FIXEDPOINT +#if defined(USE_FIXEDPOINT) return FixedPoint::abs(x); -#elif USE_FLOAT +#elif defined(USE_FLOAT) return fabsf(x); #else return fabs(x); @@ -41,11 +42,11 @@ static inline SplashCoord splashAbs(SplashCoord x) { } static inline int splashFloor(SplashCoord x) { - #if USE_FIXEDPOINT +#if defined(USE_FIXEDPOINT) return FixedPoint::floor(x); - #elif USE_FLOAT +#elif defined(USE_FLOAT) return (int)floorf(x); - #elif __GNUC__ && __i386__ +#elif defined(__GNUC__) && defined(__i386__) // floor() and (int)() are implemented separately, which results // in changing the FPCW multiple times - so we optimize it with // some inline assembly @@ -64,7 +65,7 @@ static inline int splashFloor(SplashCoord x) { : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) : "m" (x)); return result; - #elif defined(WIN32) && defined(_M_IX86) +#elif defined(_WIN32) && defined(_M_IX86) // floor() and (int)() are implemented separately, which results // in changing the FPCW multiple times - so we optimize it with // some inline assembly @@ -81,18 +82,18 @@ static inline int splashFloor(SplashCoord x) { __asm fistp DWORD PTR result __asm fldcw WORD PTR oldCW return result; - #else +#else if (x > 0) return (int)x; else return (int)floor(x); - #endif +#endif } static inline int splashCeil(SplashCoord x) { -#if USE_FIXEDPOINT +#if defined(USE_FIXEDPOINT) return FixedPoint::ceil(x); -#elif USE_FLOAT +#elif defined(USE_FLOAT) return (int)ceilf(x); -#elif __GNUC__ && __i386__ +#elif defined(__GNUC__) && defined(__i386__) // ceil() and (int)() are implemented separately, which results // in changing the FPCW multiple times - so we optimize it with // some inline assembly @@ -111,7 +112,7 @@ static inline int splashCeil(SplashCoord x) { : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) : "m" (x)); return result; -#elif defined(WIN32) && defined(_M_IX86) +#elif defined(_WIN32) && defined(_M_IX86) // ceil() and (int)() are implemented separately, which results // in changing the FPCW multiple times - so we optimize it with // some inline assembly @@ -134,9 +135,9 @@ static inline int splashCeil(SplashCoord x) { } static inline int splashRound(SplashCoord x) { -#if USE_FIXEDPOINT +#if defined(USE_FIXEDPOINT) return FixedPoint::round(x); -#elif __GNUC__ && __i386__ +#elif defined(__GNUC__) && defined(__i386__) // this could use round-to-nearest mode and avoid the "+0.5", // but that produces slightly different results (because i+0.5 // sometimes rounds up and sometimes down using the even rule) @@ -156,7 +157,7 @@ static inline int splashRound(SplashCoord x) { : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) : "m" (x)); return result; -#elif defined(WIN32) && defined(_M_IX86) +#elif defined(_WIN32) && defined(_M_IX86) // this could use round-to-nearest mode and avoid the "+0.5", // but that produces slightly different results (because i+0.5 // sometimes rounds up and sometimes down using the even rule) @@ -180,7 +181,7 @@ static inline int splashRound(SplashCoord x) { } static inline SplashCoord splashAvg(SplashCoord x, SplashCoord y) { -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT return FixedPoint::avg(x, y); #else return 0.5 * (x + y); @@ -188,9 +189,9 @@ static inline SplashCoord splashAvg(SplashCoord x, SplashCoord y) { } static inline SplashCoord splashSqrt(SplashCoord x) { -#if USE_FIXEDPOINT +#if defined(USE_FIXEDPOINT) return FixedPoint::sqrt(x); -#elif USE_FLOAT +#elif defined(USE_FLOAT) return sqrtf(x); #else return sqrt(x); @@ -198,9 +199,9 @@ static inline SplashCoord splashSqrt(SplashCoord x) { } static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) { -#if USE_FIXEDPOINT +#if defined(USE_FIXEDPOINT) return FixedPoint::pow(x, y); -#elif USE_FLOAT +#elif defined(USE_FLOAT) return powf(x, y); #else return pow(x, y); @@ -212,7 +213,7 @@ static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0, SplashCoord dx, dy; dx = x1 - x0; dy = y1 - y0; -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT // this handles the situation where dx*dx or dy*dy is too large to // fit in the 16.16 fixed point format SplashCoord dxa, dya, d; @@ -235,7 +236,7 @@ static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0, static inline GBool splashCheckDet(SplashCoord m11, SplashCoord m12, SplashCoord m21, SplashCoord m22, SplashCoord epsilon) { -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT return FixedPoint::checkDet(m11, m12, m21, m22, epsilon); #else return fabs(m11 * m22 - m12 * m21) >= epsilon; diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashPattern.h b/Build/source/libs/poppler/poppler-src/splash/SplashPattern.h index e678c9e20e6..1e2881c812e 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashPattern.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashPattern.h @@ -66,17 +66,17 @@ public: SplashSolidColor(SplashColorPtr colorA); - virtual SplashPattern *copy() { return new SplashSolidColor(color); } + SplashPattern *copy() override { return new SplashSolidColor(color); } - virtual ~SplashSolidColor(); + ~SplashSolidColor(); - virtual GBool getColor(int x, int y, SplashColorPtr c); + GBool getColor(int x, int y, SplashColorPtr c) override; - virtual GBool testPosition(int x, int y) { return gFalse; } + GBool testPosition(int x, int y) override { return gFalse; } - virtual GBool isStatic() { return gTrue; } + GBool isStatic() override { return gTrue; } - virtual GBool isCMYK() { return gFalse; } + GBool isCMYK() override { return gFalse; } private: diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashState.cc b/Build/source/libs/poppler/poppler-src/splash/SplashState.cc index f0c98c5eff7..abd940842ae 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashState.cc +++ b/Build/source/libs/poppler/poppler-src/splash/SplashState.cc @@ -12,6 +12,7 @@ // under GPL version 2 or later // // Copyright (C) 2009, 2011, 2012, 2015 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -39,7 +40,7 @@ // number of components in each color mode int splashColorModeNComps[] = { 1, 1, 3, 3, 4 -#if SPLASH_CMYK +#ifdef SPLASH_CMYK , 4, 4 + SPOT_NCOMPS #endif }; @@ -83,7 +84,7 @@ SplashState::SplashState(int width, int height, GBool vectorAntialias, rgbTransferG[i] = (Guchar)i; rgbTransferB[i] = (Guchar)i; grayTransfer[i] = (Guchar)i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK cmykTransferC[i] = (Guchar)i; cmykTransferM[i] = (Guchar)i; cmykTransferY[i] = (Guchar)i; @@ -136,7 +137,7 @@ SplashState::SplashState(int width, int height, GBool vectorAntialias, rgbTransferG[i] = (Guchar)i; rgbTransferB[i] = (Guchar)i; grayTransfer[i] = (Guchar)i; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK cmykTransferC[i] = (Guchar)i; cmykTransferM[i] = (Guchar)i; cmykTransferY[i] = (Guchar)i; @@ -187,7 +188,7 @@ SplashState::SplashState(SplashState *state) { memcpy(rgbTransferG, state->rgbTransferG, 256); memcpy(rgbTransferB, state->rgbTransferB, 256); memcpy(grayTransfer, state->grayTransfer, 256); -#if SPLASH_CMYK +#ifdef SPLASH_CMYK memcpy(cmykTransferC, state->cmykTransferC, 256); memcpy(cmykTransferM, state->cmykTransferM, 256); memcpy(cmykTransferY, state->cmykTransferY, 256); @@ -249,7 +250,7 @@ void SplashState::setSoftMask(SplashBitmap *softMaskA) { void SplashState::setTransfer(Guchar *red, Guchar *green, Guchar *blue, Guchar *gray) { -#if SPLASH_CMYK +#ifdef SPLASH_CMYK int i; for (i = 0; i < 256; ++i) { diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashState.h b/Build/source/libs/poppler/poppler-src/splash/SplashState.h index fea7603500e..32270382037 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashState.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashState.h @@ -12,6 +12,7 @@ // under GPL version 2 or later // // Copyright (C) 2011, 2012, 2015 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -124,7 +125,7 @@ private: rgbTransferG[256], rgbTransferB[256]; Guchar grayTransfer[256]; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK Guchar cmykTransferC[256], cmykTransferM[256], cmykTransferY[256], diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashT1Font.cc b/Build/source/libs/poppler/poppler-src/splash/SplashT1Font.cc deleted file mode 100644 index 0fdfaaf5150..00000000000 --- a/Build/source/libs/poppler/poppler-src/splash/SplashT1Font.cc +++ /dev/null @@ -1,309 +0,0 @@ -//======================================================================== -// -// SplashT1Font.cc -// -//======================================================================== - -//======================================================================== -// -// 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) 2007 Albert Astals Cid <aacid@kde.org> -// -// 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> - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <t1lib.h> -#include "goo/gmem.h" -#include "SplashMath.h" -#include "SplashGlyphBitmap.h" -#include "SplashPath.h" -#include "SplashT1FontEngine.h" -#include "SplashT1FontFile.h" -#include "SplashT1Font.h" - -//------------------------------------------------------------------------ - -static Guchar bitReverse[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff -}; - -//------------------------------------------------------------------------ -// SplashT1Font -//------------------------------------------------------------------------ - -SplashT1Font::SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA): - SplashFont(fontFileA, matA, textMatA, fontFileA->engine->aa) -{ - T1_TMATRIX matrix; - BBox bbox; - SplashCoord bbx0, bby0, bbx1, bby1; - int x, y; - - t1libID = T1_CopyFont(fontFileA->t1libID); - outlineID = -1; - - // compute font size - size = (float)splashDist(0, 0, mat[2], mat[3]); - - // transform the four corners of the font bounding box -- the min - // and max values form the bounding box of the transformed font - bbox = T1_GetFontBBox(t1libID); - bbx0 = 0.001 * bbox.llx; - bby0 = 0.001 * bbox.lly; - bbx1 = 0.001 * bbox.urx; - bby1 = 0.001 * bbox.ury; - // some fonts are completely broken, so we fake it (with values - // large enough that most glyphs should fit) - if (bbx0 == 0 && bby0 == 0 && bbx1 == 0 && bby1 == 0) { - bbx0 = bby0 = -0.5; - bbx1 = bby1 = 1.5; - } - x = (int)(mat[0] * bbx0 + mat[2] * bby0); - xMin = xMax = x; - y = (int)(mat[1] * bbx0 + mat[3] * bby0); - yMin = yMax = y; - x = (int)(mat[0] * bbx0 + mat[2] * bby1); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * bbx0 + mat[3] * bby1); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)(mat[0] * bbx1 + mat[2] * bby0); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * bbx1 + mat[3] * bby0); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)(mat[0] * bbx1 + mat[2] * bby1); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * bbx1 + mat[3] * bby1); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - // This is a kludge: some buggy PDF generators embed fonts with - // zero bounding boxes. - if (xMax == xMin) { - xMin = 0; - xMax = (int)size; - } - if (yMax == yMin) { - yMin = 0; - yMax = (int)(1.2 * size); - } - // Another kludge: an unusually large xMin or yMin coordinate is - // probably wrong. - if (xMin > 0) { - xMin = 0; - } - if (yMin > 0) { - yMin = 0; - } - // Another kludge: t1lib doesn't correctly handle fonts with - // real (non-integer) bounding box coordinates. - if (xMax - xMin > 5000) { - xMin = 0; - xMax = (int)size; - } - if (yMax - yMin > 5000) { - yMin = 0; - yMax = (int)(1.2 * size); - } - - // transform the font - matrix.cxx = (double)mat[0] / size; - matrix.cxy = (double)mat[1] / size; - matrix.cyx = (double)mat[2] / size; - matrix.cyy = (double)mat[3] / size; - T1_TransformFont(t1libID, &matrix); -} - -SplashT1Font::~SplashT1Font() { - T1_DeleteFont(t1libID); - if (outlineID >= 0) { - T1_DeleteFont(outlineID); - } -} - -GBool SplashT1Font::getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { - return SplashFont::getGlyph(c, 0, 0, bitmap, x0, y0, clip, clipRes); -} - -GBool SplashT1Font::makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { - GLYPH *glyph; - int n, i; - - if (aa) { - glyph = T1_AASetChar(t1libID, c, size, NULL); - } else { - glyph = T1_SetChar(t1libID, c, size, NULL); - } - if (!glyph) { - return gFalse; - } - - bitmap->x = -glyph->metrics.leftSideBearing; - bitmap->y = glyph->metrics.ascent; - bitmap->w = glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing; - bitmap->h = glyph->metrics.ascent - glyph->metrics.descent; - bitmap->aa = aa; - if (aa) { - bitmap->data = (Guchar *)glyph->bits; - bitmap->freeData = gFalse; - } else { - n = bitmap->h * ((bitmap->w + 7) >> 3); - bitmap->data = (Guchar *)gmalloc(n); - for (i = 0; i < n; ++i) { - bitmap->data[i] = bitReverse[glyph->bits[i] & 0xff]; - } - bitmap->freeData = gTrue; - } - - *clipRes = clip->testRect(x0 - bitmap->x, - y0 - bitmap->y, - x0 - bitmap->x + bitmap->w - 1, - y0 - bitmap->y + bitmap->h - 1); - - return gTrue; -} - -SplashPath *SplashT1Font::getGlyphPath(int c) { - T1_TMATRIX matrix; - SplashPath *path; - T1_OUTLINE *outline; - T1_PATHSEGMENT *seg; - T1_BEZIERSEGMENT *bez; - int x, y, x1, y1; - GBool needClose; - - if (outlineID < 0) { - outlineID = T1_CopyFont(((SplashT1FontFile *)fontFile)->t1libID); - outlineSize = (float)splashDist(0, 0, textMat[2], textMat[3]); - matrix.cxx = (double)textMat[0] / outlineSize; - matrix.cxy = (double)textMat[1] / outlineSize; - matrix.cyx = (double)textMat[2] / outlineSize; - matrix.cyy = (double)textMat[3] / outlineSize; - // t1lib doesn't seem to handle small sizes correctly here, so set - // the size to 1000, and scale the resulting coordinates later - outlineMul = (float)(outlineSize / 65536000.0); - outlineSize = 1000; - T1_TransformFont(outlineID, &matrix); - } - - path = new SplashPath(); - if ((outline = T1_GetCharOutline(outlineID, c, outlineSize, NULL))) { - // NB: t1lib uses integer coordinates here; we keep a running - // (x,y) total as integers, so that the final point in the path is - // exactly the same as the first point, thus avoiding weird - // mitered join glitches - x = y = 0; - needClose = gFalse; - for (seg = outline; seg; seg = seg->link) { - switch (seg->type) { - case T1_PATHTYPE_MOVE: - if (needClose) { - path->close(); - needClose = gFalse; - } - x += seg->dest.x; - y += seg->dest.y; - path->moveTo(outlineMul * x, -outlineMul * y); - break; - case T1_PATHTYPE_LINE: - x += seg->dest.x; - y += seg->dest.y; - path->lineTo(outlineMul * x, -outlineMul * y); - needClose = gTrue; - break; - case T1_PATHTYPE_BEZIER: - bez = (T1_BEZIERSEGMENT *)seg; - x1 = x + bez->dest.x; - y1 = y + bez->dest.y; - path->curveTo(outlineMul * (x + bez->B.x), - -outlineMul * (y + bez->B.y), - outlineMul * (x + bez->C.x), - -outlineMul * (y + bez->C.y), - outlineMul * x1, - -outlineMul * y1); - x = x1; - y = y1; - needClose = gTrue; - break; - } - } - if (needClose) { - path->close(); - } - T1_FreeOutline(outline); - } - - return path; -} - -#endif // HAVE_T1LIB_H diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashT1Font.h b/Build/source/libs/poppler/poppler-src/splash/SplashT1Font.h deleted file mode 100644 index 1dbe66cd7fc..00000000000 --- a/Build/source/libs/poppler/poppler-src/splash/SplashT1Font.h +++ /dev/null @@ -1,69 +0,0 @@ -//======================================================================== -// -// SplashT1Font.h -// -//======================================================================== - -//======================================================================== -// -// 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) 2007 Albert Astals Cid <aacid@kde.org> -// -// 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 SPLASHT1FONT_H -#define SPLASHT1FONT_H - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashFont.h" - -class SplashT1FontFile; - -//------------------------------------------------------------------------ -// SplashT1Font -//------------------------------------------------------------------------ - -class SplashT1Font: public SplashFont { -public: - - SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA); - - virtual ~SplashT1Font(); - - // Munge xFrac and yFrac before calling SplashFont::getGlyph. - virtual GBool getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); - - // Rasterize a glyph. The <xFrac> and <yFrac> values are the same - // as described for getGlyph. - virtual GBool makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); - - // Return the path for a glyph. - virtual SplashPath *getGlyphPath(int c); - -private: - - int t1libID; // t1lib font ID - int outlineID; // t1lib font ID for glyph outlines - float size; - float outlineSize; // size for glyph outlines - float outlineMul; -}; - -#endif // HAVE_T1LIB_H - -#endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.cc b/Build/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.cc deleted file mode 100644 index fb4b38dae88..00000000000 --- a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.cc +++ /dev/null @@ -1,138 +0,0 @@ -//======================================================================== -// -// SplashT1FontEngine.cc -// -//======================================================================== - -//======================================================================== -// -// 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) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// -// 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> - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <stdio.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif -#include <t1lib.h> -#include "goo/GooString.h" -#include "goo/gfile.h" -#include "fofi/FoFiType1C.h" -#include "SplashT1FontFile.h" -#include "SplashT1FontEngine.h" - -#ifdef VMS -#if (__VMS_VER < 70000000) -extern "C" int unlink(char *filename); -#endif -#endif - -//------------------------------------------------------------------------ - -int SplashT1FontEngine::t1libInitCount = 0; - -//------------------------------------------------------------------------ - -static void fileWrite(void *stream, const char *data, int len) { - fwrite(data, 1, len, (FILE *)stream); -} - -//------------------------------------------------------------------------ -// SplashT1FontEngine -//------------------------------------------------------------------------ - -SplashT1FontEngine::SplashT1FontEngine(GBool aaA) { - aa = aaA; -} - -SplashT1FontEngine *SplashT1FontEngine::init(GBool aaA) { - // grayVals[i] = round(i * 255 / 16) - static unsigned long grayVals[17] = { - 0, 16, 32, 48, 64, 80, 96, 112, 128, 143, 159, 175, 191, 207, 223, 239, 255 - }; - - //~ for multithreading: need a mutex here - if (t1libInitCount == 0) { - T1_SetBitmapPad(8); - if (!T1_InitLib(NO_LOGFILE | IGNORE_CONFIGFILE | IGNORE_FONTDATABASE | - T1_NO_AFM)) { - return NULL; - } - if (aaA) { - T1_AASetBitsPerPixel(8); - T1_AASetLevel(T1_AA_HIGH); - T1_AAHSetGrayValues(grayVals); - } else { - T1_AANSetGrayValues(0, 1); - } - } - ++t1libInitCount; - - return new SplashT1FontEngine(aaA); -} - -SplashT1FontEngine::~SplashT1FontEngine() { - //~ for multithreading: need a mutex here - if (--t1libInitCount == 0) { - T1_CloseLib(); - } -} - -SplashFontFile *SplashT1FontEngine::loadType1Font(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - return SplashT1FontFile::loadType1Font(this, idA, src, enc); -} - -SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - FoFiType1C *ff; - GooString *tmpFileName; - FILE *tmpFile; - SplashFontFile *ret; - - SplashFontSrc *newsrc; - - if (src->isFile) - ff = FoFiType1C::load(src->fileName->getCString()); - else - ff = FoFiType1C::make(src->buf, src->bufLen); - if (! ff) - return NULL; - - tmpFileName = NULL; - if (!openTempFile(&tmpFileName, &tmpFile, "wb")) { - delete ff; - return NULL; - } - ff->convertToType1(NULL, NULL, gTrue, &fileWrite, tmpFile); - delete ff; - fclose(tmpFile); - newsrc = new SplashFontSrc; - newsrc->setFile(tmpFileName, gTrue); - delete tmpFileName; - ret = SplashT1FontFile::loadType1Font(this, idA, newsrc, enc); - newsrc->unref(); - return ret; -} - -#endif // HAVE_T1LIB_H diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.h b/Build/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.h deleted file mode 100644 index 268a01479b0..00000000000 --- a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.h +++ /dev/null @@ -1,50 +0,0 @@ -//======================================================================== -// -// SplashT1FontEngine.h -// -//======================================================================== - -#ifndef SPLASHT1FONTENGINE_H -#define SPLASHT1FONTENGINE_H - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "goo/gtypes.h" - -class SplashFontFile; -class SplashFontFileID; -class SplashFontSrc; - -//------------------------------------------------------------------------ -// SplashT1FontEngine -//------------------------------------------------------------------------ - -class SplashT1FontEngine { -public: - - static SplashT1FontEngine *init(GBool aaA); - - ~SplashT1FontEngine(); - - // Load fonts. - SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - -private: - - SplashT1FontEngine(GBool aaA); - - static int t1libInitCount; - GBool aa; - - friend class SplashT1FontFile; - friend class SplashT1Font; -}; - -#endif // HAVE_T1LIB_H - -#endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontFile.cc b/Build/source/libs/poppler/poppler-src/splash/SplashT1FontFile.cc deleted file mode 100644 index 1832a916d9a..00000000000 --- a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontFile.cc +++ /dev/null @@ -1,134 +0,0 @@ -//======================================================================== -// -// SplashT1FontFile.cc -// -//======================================================================== - -//======================================================================== -// -// 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) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// -// 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> - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <string.h> -#include <t1lib.h> -#include "goo/GooString.h" -#include "goo/gfile.h" -#include "goo/gmem.h" -#include "SplashT1FontEngine.h" -#include "SplashT1Font.h" -#include "SplashT1FontFile.h" - -//------------------------------------------------------------------------ -// SplashT1FontFile -//------------------------------------------------------------------------ - -SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - const char **encA) { - int t1libIDA; - const char **encTmp; - char *encStrTmp; - int encStrSize; - char *encPtr; - int i; - - GooString *fileNameA; - SplashFontSrc *newsrc = NULL; - SplashFontFile *ff; - - if (! src->isFile) { - GooString *tmpFileName; - FILE *tmpFile; - if (!openTempFile(&tmpFileName, &tmpFile, "wb")) - return NULL; - fwrite(src->buf, 1, src->bufLen, tmpFile); - fclose(tmpFile); - newsrc = new SplashFontSrc; - newsrc->setFile(tmpFileName, gTrue); - src = newsrc; - delete tmpFileName; - } - fileNameA = src->fileName; - // load the font file - if ((t1libIDA = T1_AddFont(fileNameA->getCString())) < 0) { - delete newsrc; - return NULL; - } - T1_LoadFont(t1libIDA); - - // reencode it - encStrSize = 0; - for (i = 0; i < 256; ++i) { - if (encA[i]) { - encStrSize += strlen(encA[i]) + 1; - } - } - encTmp = (const char **)gmallocn(257, sizeof(char *)); - encStrTmp = (char *)gmallocn(encStrSize, sizeof(char)); - encPtr = encStrTmp; - for (i = 0; i < 256; ++i) { - if (encA[i]) { - strcpy(encPtr, encA[i]); - encTmp[i] = encPtr; - encPtr += strlen(encPtr) + 1; - } else { - encTmp[i] = ".notdef"; - } - } - encTmp[256] = "custom"; - T1_ReencodeFont(t1libIDA, (char **)encTmp); - - ff = new SplashT1FontFile(engineA, idA, src, - t1libIDA, encTmp, encStrTmp); - if (newsrc) - newsrc->unref(); - return ff; -} - -SplashT1FontFile::SplashT1FontFile(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *srcA, - int t1libIDA, const char **encA, char *encStrA): - SplashFontFile(idA, srcA) -{ - engine = engineA; - t1libID = t1libIDA; - enc = encA; - encStr = encStrA; -} - -SplashT1FontFile::~SplashT1FontFile() { - gfree(encStr); - gfree(enc); - T1_DeleteFont(t1libID); -} - -SplashFont *SplashT1FontFile::makeFont(SplashCoord *mat, - SplashCoord *textMat) { - SplashFont *font; - - font = new SplashT1Font(this, mat, textMat); - font->initCache(); - return font; -} - -#endif // HAVE_T1LIB_H diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontFile.h b/Build/source/libs/poppler/poppler-src/splash/SplashT1FontFile.h deleted file mode 100644 index c094b6d8b29..00000000000 --- a/Build/source/libs/poppler/poppler-src/splash/SplashT1FontFile.h +++ /dev/null @@ -1,70 +0,0 @@ -//======================================================================== -// -// SplashT1FontFile.h -// -//======================================================================== - -//======================================================================== -// -// 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) 2006 Takashi Iwai <tiwai@suse.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 -// -//======================================================================== - -#ifndef SPLASHT1FONTFILE_H -#define SPLASHT1FONTFILE_H - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashFontFile.h" - -class SplashT1FontEngine; - -//------------------------------------------------------------------------ -// SplashT1FontFile -//------------------------------------------------------------------------ - -class SplashT1FontFile: public SplashFontFile { -public: - - static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - const char **encA); - - virtual ~SplashT1FontFile(); - - // Create a new SplashT1Font, i.e., a scaled instance of this font - // file. - virtual SplashFont *makeFont(SplashCoord *mat, - SplashCoord *textMat); - -private: - - SplashT1FontFile(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - int t1libIDA, const char **encA, char *encStrA); - - SplashT1FontEngine *engine; - int t1libID; // t1lib font ID - const char **enc; - char *encStr; - - friend class SplashT1Font; -}; - -#endif // HAVE_T1LIB_H - -#endif diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashTypes.h b/Build/source/libs/poppler/poppler-src/splash/SplashTypes.h index 5ea816007f8..ca0e3bc0916 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashTypes.h +++ b/Build/source/libs/poppler/poppler-src/splash/SplashTypes.h @@ -16,6 +16,7 @@ // Copyright (C) 2009, 2011-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> // Copyright (C) 2010 William Bader <williambader@hotmail.com> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -31,10 +32,10 @@ // coordinates //------------------------------------------------------------------------ -#if USE_FIXEDPOINT +#if defined(USE_FIXEDPOINT) #include "goo/FixedPoint.h" typedef FixedPoint SplashCoord; -#elif USE_FLOAT +#elif defined(USE_FLOAT) typedef float SplashCoord; #else typedef double SplashCoord; @@ -64,7 +65,7 @@ enum SplashColorMode { // BGRBGR... splashModeXBGR8 // 1 byte per component, 4 bytes per pixel: // XBGRXBGR... -#if SPLASH_CMYK +#ifdef SPLASH_CMYK , splashModeCMYK8, // 1 byte per component, 4 bytes per pixel: // CMYKCMYK... @@ -85,7 +86,7 @@ enum SplashThinLineMode { extern int splashColorModeNComps[]; // max number of components in any SplashColor -#if SPLASH_CMYK +#ifdef SPLASH_CMYK #define splashMaxColorComps SPOT_NCOMPS+4 #else #define splashMaxColorComps 4 @@ -104,7 +105,7 @@ static inline Guchar splashBGR8R(SplashColorPtr bgr8) { return bgr8[2]; } static inline Guchar splashBGR8G(SplashColorPtr bgr8) { return bgr8[1]; } static inline Guchar splashBGR8B(SplashColorPtr bgr8) { return bgr8[0]; } -#if SPLASH_CMYK +#ifdef SPLASH_CMYK // CMYK8 static inline Guchar splashCMYK8C(SplashColorPtr cmyk8) { return cmyk8[0]; } static inline Guchar splashCMYK8M(SplashColorPtr cmyk8) { return cmyk8[1]; } @@ -123,7 +124,7 @@ static inline void splashClearColor(SplashColorPtr dest) { dest[0] = 0; dest[1] = 0; dest[2] = 0; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK dest[3] = 0; for (int i = SPOT_NCOMPS; i < SPOT_NCOMPS + 4; i++) dest[i] = 0; @@ -134,7 +135,7 @@ static inline void splashColorCopy(SplashColorPtr dest, SplashColorPtr src) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK dest[3] = src[3]; for (int i = SPOT_NCOMPS; i < SPOT_NCOMPS + 4; i++) dest[i] = src[i]; @@ -145,7 +146,7 @@ static inline void splashColorXor(SplashColorPtr dest, SplashColorPtr src) { dest[0] ^= src[0]; dest[1] ^= src[1]; dest[2] ^= src[2]; -#if SPLASH_CMYK +#ifdef SPLASH_CMYK dest[3] ^= src[3]; for (int i = SPOT_NCOMPS; i < SPOT_NCOMPS + 4; i++) dest[i] ^= src[i]; diff --git a/Build/source/libs/poppler/poppler-src/splash/SplashXPath.cc b/Build/source/libs/poppler/poppler-src/splash/SplashXPath.cc index 27106ee3d14..9c5c8813a2c 100644 --- a/Build/source/libs/poppler/poppler-src/splash/SplashXPath.cc +++ b/Build/source/libs/poppler/poppler-src/splash/SplashXPath.cc @@ -14,6 +14,7 @@ // Copyright (C) 2010 PaweÅ‚ Wiejacha <pawel.wiejacha@gmail.com> // Copyright (C) 2010, 2011 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com> // // 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 @@ -289,7 +290,7 @@ void SplashXPath::addCurve(SplashCoord x0, SplashCoord y0, SplashCoord dx, dy, mx, my, d1, d2, flatness2; int p1, p2, p3; -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT flatness2 = flatness; #else flatness2 = flatness * flatness; @@ -333,7 +334,7 @@ void SplashXPath::addCurve(SplashCoord x0, SplashCoord y0, // line) mx = (xl0 + xr3) * 0.5; my = (yl0 + yr3) * 0.5; -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT d1 = splashDist(xx1, yy1, mx, my); d2 = splashDist(xx2, yy2, mx, my); #else @@ -411,7 +412,7 @@ void SplashXPath::addSegment(SplashCoord x0, SplashCoord y0, segs[length].dxdy = segs[length].dydx = 0; segs[length].flags |= splashXPathVert; } else { -#if USE_FIXEDPOINT +#ifdef USE_FIXEDPOINT if (FixedPoint::divCheck(x1 - x0, y1 - y0, &segs[length].dxdy)) { segs[length].dydx = (SplashCoord)1 / segs[length].dxdy; } else { diff --git a/Build/source/libs/poppler/version.ac b/Build/source/libs/poppler/version.ac index 5f16b7877e6..679a2251748 100644 --- a/Build/source/libs/poppler/version.ac +++ b/Build/source/libs/poppler/version.ac @@ -1,5 +1,6 @@ -dnl -dnl Copyright (C) 2011-2015 Peter Breitenlohner <tex-live@tug.org> +dnl $Id$ +dnl Copyright 2018 Karl Berry <tex-live@tug.org> +dnl Copyright 2011-2015 Peter Breitenlohner <tex-live@tug.org> dnl dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, @@ -8,4 +9,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current poppler version -m4_define([poppler_version], [0.52.0]) +m4_define([poppler_version], [0.62.0]) diff --git a/Build/source/m4/ChangeLog b/Build/source/m4/ChangeLog index 8843714b101..a33660429fc 100644 --- a/Build/source/m4/ChangeLog +++ b/Build/source/m4/ChangeLog @@ -1,3 +1,8 @@ +2018-01-08 Karl Berry <karl@freefriends.org> + + * ax_cxx_compile_stdcxx.m4: move from dvisvgm; original from + https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html#ax_cxx_compile_stdcxx + 2017-12-08 Norbert Preining <preining@logic.at> * kpse-icu-flags.m4 (KPSE_ICU_SYSTEM_FLAGS): also check for PKG_CONFIG. diff --git a/Build/source/texk/dvisvgm/m4/ax_cxx_compile_stdcxx.m4 b/Build/source/m4/ax_cxx_compile_stdcxx.m4 index b61fcb6314a..5032bba8091 100644 --- a/Build/source/texk/dvisvgm/m4/ax_cxx_compile_stdcxx.m4 +++ b/Build/source/m4/ax_cxx_compile_stdcxx.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS @@ -40,7 +40,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 6 +#serial 7 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). diff --git a/Build/source/texk/dvisvgm/ChangeLog b/Build/source/texk/dvisvgm/ChangeLog index e3ed4086e21..3eca3f8134f 100644 --- a/Build/source/texk/dvisvgm/ChangeLog +++ b/Build/source/texk/dvisvgm/ChangeLog @@ -1,3 +1,7 @@ +2018-01-08 Karl Berry <karl@freefriends.org> + + * m4/ax_cxx_compile_stdcxx.m4: move to top-level source/m4/. + 2017-03-17 Paul Vojta <vojta@math.berkeley.edu> * configure.ac (LIBGS_INCLUDES, LIBGS_LIBS): always AC_SUBST. diff --git a/Build/source/texk/dvisvgm/Makefile.in b/Build/source/texk/dvisvgm/Makefile.in index e25d4919f45..004a74c71e8 100644 --- a/Build/source/texk/dvisvgm/Makefile.in +++ b/Build/source/texk/dvisvgm/Makefile.in @@ -99,7 +99,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/aclocal.m4 b/Build/source/texk/dvisvgm/aclocal.m4 index 20f74e7083d..7538ad7812c 100644 --- a/Build/source/texk/dvisvgm/aclocal.m4 +++ b/Build/source/texk/dvisvgm/aclocal.m4 @@ -1246,7 +1246,7 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR -m4_include([m4/ax_cxx_compile_stdcxx.m4]) +m4_include([../../m4/ax_cxx_compile_stdcxx.m4]) m4_include([../../m4/kpse-common.m4]) m4_include([../../m4/kpse-cxx-hack.m4]) m4_include([../../m4/kpse-freetype2-flags.m4]) diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/Makefile.in index a90e96ec5b8..cf43821b0b4 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/Makefile.in @@ -89,7 +89,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = dvisvgm-src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/libs/Makefile.in index d1de6b5e50b..c4a40ef40a5 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/Makefile.in @@ -90,7 +90,7 @@ host_triplet = @host@ @ENABLE_WOFF_TRUE@am__append_1 = ff-woff woff2 subdir = dvisvgm-src/libs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/clipper/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/libs/clipper/Makefile.in index c0619324f3b..e7a6f90e497 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/clipper/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/clipper/Makefile.in @@ -90,7 +90,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = dvisvgm-src/libs/clipper ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in index 3f1d19facc2..a8923ec748c 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in @@ -90,7 +90,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = dvisvgm-src/libs/ff-woff ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/Makefile.in index 9945b6e743c..1e952f8501d 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/Makefile.in @@ -90,7 +90,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = dvisvgm-src/libs/woff2 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/brotli/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/brotli/Makefile.in index 2731e49345d..8315a5af294 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/brotli/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/woff2/brotli/Makefile.in @@ -90,7 +90,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = dvisvgm-src/libs/woff2/brotli ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/xxHash/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/libs/xxHash/Makefile.in index d8258f11c77..f9dab5452e1 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/xxHash/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/xxHash/Makefile.in @@ -90,7 +90,7 @@ build_triplet = @build@ host_triplet = @host@ subdir = dvisvgm-src/libs/xxHash ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/src/Makefile.in index 5f998a6d995..5a8296297ff 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Makefile.in @@ -107,7 +107,7 @@ bin_PROGRAMS = dvisvgm$(EXEEXT) @WIN32_TRUE@am__append_5 = -DTEXLIVEWIN32 subdir = dvisvgm-src/src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ $(top_srcdir)/../../m4/kpse-cxx-hack.m4 \ $(top_srcdir)/../../m4/kpse-freetype2-flags.m4 \ diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index 4d7c8156eae..c9d791eb27a 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -336,6 +336,7 @@ TESTS = tangle.test $(am__EXEEXT_41) ctiedir/ctie.test \ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -1929,6 +1930,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ diff --git a/Build/source/texk/web2c/aclocal.m4 b/Build/source/texk/web2c/aclocal.m4 index 4ae7d7fbb1d..f7b20fa6765 100644 --- a/Build/source/texk/web2c/aclocal.m4 +++ b/Build/source/texk/web2c/aclocal.m4 @@ -1224,6 +1224,7 @@ AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/web2c-disable.m4]) +m4_include([../../m4/ax_cxx_compile_stdcxx.m4]) m4_include([../../m4/kpse-asm.m4]) m4_include([../../m4/kpse-cairo-flags.m4]) m4_include([../../m4/kpse-common.m4]) diff --git a/Build/source/texk/web2c/c-auto.in b/Build/source/texk/web2c/c-auto.in index ce18d89e49b..81d750ea7b8 100644 --- a/Build/source/texk/web2c/c-auto.in +++ b/Build/source/texk/web2c/c-auto.in @@ -55,6 +55,9 @@ /* Define to 1 if you have the `atoi' function. */ #undef HAVE_ATOI +/* define if the compiler supports basic C++11 syntax */ +#undef HAVE_CXX11 + /* Define to 1 if you have the declaration of `isascii', and to 0 if you don't. */ #undef HAVE_DECL_ISASCII diff --git a/Build/source/texk/web2c/configure b/Build/source/texk/web2c/configure index ee5a83d76ca..8d1af7c3052 100755 --- a/Build/source/texk/web2c/configure +++ b/Build/source/texk/web2c/configure @@ -823,6 +823,7 @@ MINGW32_TRUE WIN32_FALSE WIN32_TRUE KPSEWHICH +HAVE_CXX11 CXXLD WARNING_OBJCXXFLAGS am__fastdepOBJCXX_FALSE @@ -18975,6 +18976,999 @@ fi +if test "x$enable_xetex" = xyes \ + || test "x$enable_luatex" = xyes \ + || test "x$enable_luajittex" = xyes \ + || test "x$enable_luatex53" = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: LuaTeX enabled" >&5 +$as_echo "$as_me: LuaTeX enabled" >&requiring C++11 support;} + ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + ac_success=no + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx11+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check<void> single_type; + typedef check<check<void>> double_type; + typedef check<check<check<void>>> triple_type; + typedef check<check<check<check<void>>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same<int, decltype(0)>::value == true, ""); + static_assert(is_same<int, decltype(c)>::value == false, ""); + static_assert(is_same<int, decltype(v)>::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same<int, decltype(ac)>::value == true, ""); + static_assert(is_same<int, decltype(av)>::value == true, ""); + static_assert(is_same<int, decltype(sumi)>::value == true, ""); + static_assert(is_same<int, decltype(sumf)>::value == false, ""); + static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template <int...> + struct sum; + + template <int N0, int... N1toN> + struct sum<N0, N1toN...> + { + static constexpr auto value = N0 + sum<N1toN...>::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template<typename T> + using member = typename T::member_type; + + template<typename T> + void func(...) {} + + template<typename T> + void func(member<T>*) {} + + void test(); + + void test() { func<foo>(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx11=yes +else + ax_cv_cxx_compile_cxx11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 +$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check<void> single_type; + typedef check<check<void>> double_type; + typedef check<check<check<void>>> triple_type; + typedef check<check<check<check<void>>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same<int, decltype(0)>::value == true, ""); + static_assert(is_same<int, decltype(c)>::value == false, ""); + static_assert(is_same<int, decltype(v)>::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same<int, decltype(ac)>::value == true, ""); + static_assert(is_same<int, decltype(av)>::value == true, ""); + static_assert(is_same<int, decltype(sumi)>::value == true, ""); + static_assert(is_same<int, decltype(sumf)>::value == false, ""); + static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template <int...> + struct sum; + + template <int N0, int... N1toN> + struct sum<N0, N1toN...> + { + static constexpr auto value = N0 + sum<N1toN...>::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template<typename T> + using member = typename T::member_type; + + template<typename T> + void func(...) {} + + template<typename T> + void func(member<T>*) {} + + void test(); + + void test() { func<foo>(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=yes +else + eval $cachevar=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" +fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi + + if test x$ac_success = xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX="$CXX" + CXX="$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check<void> single_type; + typedef check<check<void>> double_type; + typedef check<check<check<void>>> triple_type; + typedef check<check<check<check<void>>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same<int, decltype(0)>::value == true, ""); + static_assert(is_same<int, decltype(c)>::value == false, ""); + static_assert(is_same<int, decltype(v)>::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same<int, decltype(ac)>::value == true, ""); + static_assert(is_same<int, decltype(av)>::value == true, ""); + static_assert(is_same<int, decltype(sumi)>::value == true, ""); + static_assert(is_same<int, decltype(sumf)>::value == false, ""); + static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template <int...> + struct sum; + + template <int N0, int... N1toN> + struct sum<N0, N1toN...> + { + static constexpr auto value = N0 + sum<N1toN...>::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template<typename T> + using member = typename T::member_type; + + template<typename T> + void func(...) {} + + template<typename T> + void func(member<T>*) {} + + void test(); + + void test() { func<foo>(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=yes +else + eval $cachevar=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX="$ac_save_CXX" +fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + if test x$ac_success = xyes; then + break + fi + done + fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ac_success = xno; then + as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + fi + fi + if test x$ac_success = xno; then + HAVE_CXX11=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 +$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + else + HAVE_CXX11=1 + +$as_echo "#define HAVE_CXX11 1" >>confdefs.h + + fi + + + +fi + if test "x$enable_texlive_build" = xyes; then : banner_pre='TeX Live' else diff --git a/Build/source/texk/web2c/configure.ac b/Build/source/texk/web2c/configure.ac index c6cd65893fe..f8c53aa34dc 100644 --- a/Build/source/texk/web2c/configure.ac +++ b/Build/source/texk/web2c/configure.ac @@ -1,6 +1,8 @@ +dnl $Id$ dnl Process this file with Autoconf to produce a configure script for Web2c. dnl -dnl Copyright (C) 2009-2015 Peter Breitenlohner <tex-live@tug.org> +dnl Copyright 2018 Karl Berry <tex-live@tug.org> +dnl Copyright 2009-2015 Peter Breitenlohner <tex-live@tug.org> dnl dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, @@ -15,9 +17,7 @@ dnl more than 256 fonts. dnl - NONASCII: necessary for the character translation feature. dnl - REGFIX: modern compilers mostly ignore register declarations, anyway. dnl The code for these things remains (where applicable), so you can -dnl get these features if you are willing to hack the sources. If not, -dnl it'll take a good argument to convince me to invest the time to make -dnl them configurable. +dnl get these features if you are willing to hack the sources. dnl m4_include([../../version.ac])[] dnl define tex_live_version AC_INIT([Web2C], tex_live_version(), [tex-k@tug.org]) @@ -46,6 +46,15 @@ dnl Include additional code for web2c. KPSE_WEB2C_PREPARE m4_include([ac/web2c.ac]) +dnl LuaTeX requires C++11 because poppler does :(. +if test "x$enable_xetex" = xyes \ + || test "x$enable_luatex" = xyes \ + || test "x$enable_luajittex" = xyes \ + || test "x$enable_luatex53" = xyes; then + AC_MSG_NOTICE(LuaTeX enabled, requiring C++11 support) + AX_CXX_COMPILE_STDCXX([11]) +fi + AS_IF([test "x$enable_texlive_build" = xyes], [banner_pre='TeX Live'], [banner_pre='Web2C']) diff --git a/Build/source/texk/web2c/doc/Makefile.in b/Build/source/texk/web2c/doc/Makefile.in index 7316008d687..a58e0209f15 100644 --- a/Build/source/texk/web2c/doc/Makefile.in +++ b/Build/source/texk/web2c/doc/Makefile.in @@ -90,6 +90,7 @@ host_triplet = @host@ subdir = doc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -283,6 +284,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ diff --git a/Build/source/texk/web2c/lib/Makefile.in b/Build/source/texk/web2c/lib/Makefile.in index bed496a53aa..f905551cff7 100644 --- a/Build/source/texk/web2c/lib/Makefile.in +++ b/Build/source/texk/web2c/lib/Makefile.in @@ -92,6 +92,7 @@ host_triplet = @host@ subdir = lib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -279,6 +280,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc index 9ad50c99aeb..8bdbcf16535 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc +++ b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc @@ -634,7 +634,7 @@ static int scanner_scan(lua_State * L) int i; for (i=0;i<count;i++) { Object *val = new Object(); - arrayref->get(i, val); + *val = arrayref->get(i); if (val->isStream()) { ObjectList *rover = self->_streams; ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); @@ -944,7 +944,7 @@ LUALIB_API int luaopen_pdfscanner(lua_State * L) luaL_openlib(L, 0, scannerlib_meta, 0); lua_pushvalue(L, -1); lua_setfield(L, -2, "__index"); - luaL_register(L, NULL, scannerlib_m); + luaL_openlib(L, NULL, scannerlib_m, 0); luaL_register(L, "pdfscanner", scannerlib); return 1; } diff --git a/Build/source/texk/web2c/man/Makefile.in b/Build/source/texk/web2c/man/Makefile.in index 7ca61db103c..4bcb578714a 100644 --- a/Build/source/texk/web2c/man/Makefile.in +++ b/Build/source/texk/web2c/man/Makefile.in @@ -107,6 +107,7 @@ host_triplet = @host@ subdir = man ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -261,6 +262,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ diff --git a/Build/source/texk/web2c/omegafonts/Makefile.in b/Build/source/texk/web2c/omegafonts/Makefile.in index e369d0ded4d..4c03b3a9227 100644 --- a/Build/source/texk/web2c/omegafonts/Makefile.in +++ b/Build/source/texk/web2c/omegafonts/Makefile.in @@ -95,6 +95,7 @@ EXTRA_PROGRAMS = omfonts$(EXEEXT) subdir = omegafonts ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -505,6 +506,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ diff --git a/Build/source/texk/web2c/otps/Makefile.in b/Build/source/texk/web2c/otps/Makefile.in index fcb8085b054..f9dc26db66f 100644 --- a/Build/source/texk/web2c/otps/Makefile.in +++ b/Build/source/texk/web2c/otps/Makefile.in @@ -95,6 +95,7 @@ EXTRA_PROGRAMS = $(am__EXEEXT_1) subdir = otps ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -545,6 +546,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ diff --git a/Build/source/texk/web2c/otps/win32/Makefile.in b/Build/source/texk/web2c/otps/win32/Makefile.in index 846384909d1..de340f943c7 100644 --- a/Build/source/texk/web2c/otps/win32/Makefile.in +++ b/Build/source/texk/web2c/otps/win32/Makefile.in @@ -92,6 +92,7 @@ bin_PROGRAMS = mkocp$(EXEEXT) mkofm$(EXEEXT) subdir = otps/win32 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -267,6 +268,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ diff --git a/Build/source/texk/web2c/window/Makefile.in b/Build/source/texk/web2c/window/Makefile.in index 725182562f7..6948342d06e 100644 --- a/Build/source/texk/web2c/window/Makefile.in +++ b/Build/source/texk/web2c/window/Makefile.in @@ -92,6 +92,7 @@ host_triplet = @host@ subdir = window ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ + $(top_srcdir)/../../m4/ax_cxx_compile_stdcxx.m4 \ $(top_srcdir)/../../m4/kpse-asm.m4 \ $(top_srcdir)/../../m4/kpse-cairo-flags.m4 \ $(top_srcdir)/../../m4/kpse-common.m4 \ @@ -277,6 +278,7 @@ GREP = @GREP@ HARFBUZZ_DEPEND = @HARFBUZZ_DEPEND@ HARFBUZZ_INCLUDES = @HARFBUZZ_INCLUDES@ HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HAVE_CXX11 = @HAVE_CXX11@ ICU_CONFIG = @ICU_CONFIG@ ICU_DEPEND = @ICU_DEPEND@ ICU_INCLUDES = @ICU_INCLUDES@ |