diff options
author | Albert Astals Cid <aacid@kde.org> | 2021-01-05 23:55:46 +0100 |
---|---|---|
committer | Albert Astals Cid <tsdgeos@yahoo.es> | 2021-01-05 22:56:33 +0000 |
commit | d0497325555d60c8c44f8945f5a99ab6a4d7c252 (patch) | |
tree | f3bd32049062bf88d85aa415dfcc87da3ac24816 | |
parent | 6c9f9a491a221fb1fccfe758bc92308ff1a692d1 (diff) |
Generalize the EOFStream wrapping EOFStream code
-rw-r--r-- | poppler/Stream.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/poppler/Stream.cc b/poppler/Stream.cc index cd1189d4..666d5b2a 100644 --- a/poppler/Stream.cc +++ b/poppler/Stream.cc @@ -167,6 +167,16 @@ GooString *Stream::getPSFilter(int psLevel, const char *indent) return new GooString(); } +static Stream *wrapEOFStream(Stream *str) +{ + if (dynamic_cast<EOFStream *>(str)) { + // str is already a EOFStream, no need to wrap it in another EOFStream + return str; + } else { + return new EOFStream(str); + } +} + Stream *Stream::addFilters(Dict *dict, int recursion) { Object obj, obj2; @@ -196,11 +206,7 @@ Stream *Stream::addFilters(Dict *dict, int recursion) str = makeFilter(obj2.getName(), str, ¶ms2, recursion); } else { error(errSyntaxError, getPos(), "Bad filter name"); - if (dynamic_cast<EOFStream *>(str)) { - // str is already a EOFStream, no need to wrap it in another EOFStream - } else { - str = new EOFStream(str); - } + str = wrapEOFStream(str); } } } else if (!obj.isNull()) { @@ -342,7 +348,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re str = new DCTStream(str, colorXform, dict, recursion); #else error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name); - str = new EOFStream(str); + str = wrapEOFStream(str); #endif } else if (!strcmp(name, "FlateDecode") || !strcmp(name, "Fl")) { pred = 1; @@ -377,7 +383,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re str = new JPXStream(str); #else error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name); - str = new EOFStream(str); + str = wrapEOFStream(str); #endif } else if (!strcmp(name, "Crypt")) { if (str->getKind() == strCrypt) { @@ -387,7 +393,7 @@ Stream *Stream::makeFilter(const char *name, Stream *str, Object *params, int re } } else { error(errSyntaxError, getPos(), "Unknown filter '{0:s}'", name); - str = new EOFStream(str); + str = wrapEOFStream(str); } return str; } |