cpp/poppler-embedded-file.cpp | 13 ++- cpp/poppler-private.cpp | 4 - cpp/poppler-private.h | 3 cpp/poppler-toc-private.h | 4 - cpp/poppler-toc.cpp | 9 +- glib/poppler-action.cc | 50 +++++++------- glib/poppler-document.cc | 8 +- glib/poppler-layer.cc | 2 glib/poppler-media.cc | 4 - glib/poppler-movie.cc | 2 glib/poppler-private.h | 6 - goo/GooList.cc | 16 ++++ goo/GooList.h | 8 +- poppler/FileSpec.cc | 10 +- poppler/FileSpec.h | 26 +++---- poppler/Function.h | 2 poppler/Link.cc | 26 +++---- poppler/Link.h | 138 ++++++++++++++++++++-------------------- poppler/Movie.cc | 12 +-- poppler/Movie.h | 26 +++---- poppler/OptionalContent.cc | 8 +- poppler/OptionalContent.h | 14 ++-- poppler/Outline.cc | 10 +- poppler/Outline.h | 20 ++--- poppler/Rendition.cc | 4 - poppler/Rendition.h | 18 ++--- poppler/Sound.cc | 6 - poppler/Sound.h | 18 ++--- qt5/src/poppler-document.cc | 4 - qt5/src/poppler-embeddedfile.cc | 10 +- qt5/src/poppler-link.cc | 4 - qt5/src/poppler-media.cc | 2 qt5/src/poppler-movie.cc | 4 - qt5/src/poppler-optcontent.cc | 4 - qt5/src/poppler-private.cc | 24 +++--- qt5/src/poppler-private.h | 8 +- qt5/src/poppler-sound.cc | 2 utils/HtmlFonts.cc | 4 - utils/HtmlFonts.h | 2 utils/HtmlOutputDev.cc | 12 +-- utils/HtmlOutputDev.h | 4 - utils/pdfdetach.cc | 2 42 files changed, 285 insertions(+), 268 deletions(-)
New commits: commit b4127fb1c45fe5dcabe3751f0b40029405224f49 Author: Albert Astals Cid <aa...@kde.org> Date: Fri Apr 6 23:08:15 2018 +0200 Add some more const const is always good :) diff --git a/cpp/poppler-embedded-file.cpp b/cpp/poppler-embedded-file.cpp index 0ed5a6be..bf7ab4d7 100644 --- a/cpp/poppler-embedded-file.cpp +++ b/cpp/poppler-embedded-file.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2009-2011, Pino Toscano <p...@kde.org> * Copyright (C) 2016 Jakub Alba <jakuba...@gmail.com> + * Copyright (C) 2018 Albert Astals Cid <aa...@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 @@ -78,7 +79,7 @@ bool embedded_file::is_valid() const */ std::string embedded_file::name() const { - GooString *goo = d->file_spec->getFileName(); + const GooString *goo = d->file_spec->getFileName(); return goo ? std::string(goo->getCString()) : std::string(); } @@ -87,7 +88,7 @@ std::string embedded_file::name() const */ ustring embedded_file::description() const { - GooString *goo = d->file_spec->getDescription(); + const GooString *goo = d->file_spec->getDescription(); return goo ? detail::unicode_GooString_to_ustring(goo) : ustring(); } @@ -108,7 +109,7 @@ int embedded_file::size() const */ time_type embedded_file::modification_date() const { - GooString *goo = d->file_spec->getEmbeddedFile()->modDate(); + const GooString *goo = d->file_spec->getEmbeddedFile()->modDate(); return goo ? dateStringToTime(goo) : time_type(-1); } @@ -118,7 +119,7 @@ time_type embedded_file::modification_date() const */ time_type embedded_file::creation_date() const { - GooString *goo = d->file_spec->getEmbeddedFile()->createDate(); + const GooString *goo = d->file_spec->getEmbeddedFile()->createDate(); return goo ? dateStringToTime(goo) : time_type(-1); } @@ -127,7 +128,7 @@ time_type embedded_file::creation_date() const */ byte_array embedded_file::checksum() const { - GooString *cs = d->file_spec->getEmbeddedFile()->checksum(); + const GooString *cs = d->file_spec->getEmbeddedFile()->checksum(); if (!cs) { return byte_array(); } @@ -144,7 +145,7 @@ byte_array embedded_file::checksum() const */ std::string embedded_file::mime_type() const { - GooString *goo = d->file_spec->getEmbeddedFile()->mimeType(); + const GooString *goo = d->file_spec->getEmbeddedFile()->mimeType(); return goo ? std::string(goo->getCString()) : std::string(); } diff --git a/cpp/poppler-private.cpp b/cpp/poppler-private.cpp index d326d1b3..4de2256b 100644 --- a/cpp/poppler-private.cpp +++ b/cpp/poppler-private.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2013 Adrian Johnson <ajohn...@redneon.com> * Copyright (C) 2014, Hans-Peter Deifel <hpdei...@gmx.de> * Copyright (C) 2016 Jakub Alba <jakuba...@gmail.com> - * Copyright (C) 2017 Albert Astals Cid <aa...@kde.org> + * Copyright (C) 2017, 2018 Albert Astals Cid <aa...@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 @@ -56,7 +56,7 @@ rectf detail::pdfrectangle_to_rectf(const PDFRectangle &pdfrect) return rectf(pdfrect.x1, pdfrect.y1, pdfrect.x2 - pdfrect.x1, pdfrect.y2 - pdfrect.y1); } -ustring detail::unicode_GooString_to_ustring(GooString *str) +ustring detail::unicode_GooString_to_ustring(const GooString *str) { const char *data = str->getCString(); const int len = str->getLength(); diff --git a/cpp/poppler-private.h b/cpp/poppler-private.h index d954bdb2..501c4fc4 100644 --- a/cpp/poppler-private.h +++ b/cpp/poppler-private.h @@ -5,6 +5,7 @@ * Copyright (C) 2016 Jakub Alba <jakuba...@gmail.com> * Copyright (C) 2018, Suzuki Toshiya <mpsuz...@hiroshima-u.ac.jp> * Copyright (C) 2018, Adam Reichold <adam.reich...@t-online.de> + * Copyright (C) 2018 Albert Astals Cid <aa...@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 @@ -49,7 +50,7 @@ void error_function(void *data, ErrorCategory category, Goffset pos, char *msg); rectf pdfrectangle_to_rectf(const PDFRectangle &pdfrect); -ustring unicode_GooString_to_ustring(GooString *str); +ustring unicode_GooString_to_ustring(const GooString *str); ustring unicode_to_ustring(const Unicode *u, int length); GooString* ustring_to_unicode_GooString(const ustring &str); diff --git a/cpp/poppler-toc-private.h b/cpp/poppler-toc-private.h index 29d439e5..a8ea8630 100644 --- a/cpp/poppler-toc-private.h +++ b/cpp/poppler-toc-private.h @@ -53,8 +53,8 @@ public: toc_item_private(const toc_item_private &) = delete; toc_item_private& operator=(const toc_item_private &) = delete; - void load(OutlineItem *item); - void load_children(GooList *items); + void load(const OutlineItem *item); + void load_children(const GooList *items); std::vector<toc_item*> children; ustring title; diff --git a/cpp/poppler-toc.cpp b/cpp/poppler-toc.cpp index a2f74ccd..01402370 100644 --- a/cpp/poppler-toc.cpp +++ b/cpp/poppler-toc.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009-2010, Pino Toscano <p...@kde.org> + * Copyright (C) 2018, Albert Astals Cid <aa...@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 @@ -40,7 +41,7 @@ toc* toc_private::load_from_outline(Outline *outline) return nullptr; } - GooList *items = outline->getItems(); + const GooList *items = outline->getItems(); if (!items || items->getLength() < 1) { return nullptr; } @@ -62,7 +63,7 @@ toc_item_private::~toc_item_private() delete_all(children); } -void toc_item_private::load(OutlineItem *item) +void toc_item_private::load(const OutlineItem *item) { const Unicode *title_unicode = item->getTitle(); const int title_length = item->getTitleLength(); @@ -70,7 +71,7 @@ void toc_item_private::load(OutlineItem *item) is_open = item->isOpen(); } -void toc_item_private::load_children(GooList *items) +void toc_item_private::load_children(const GooList *items) { const int num_items = items->getLength(); children.resize(num_items); @@ -82,7 +83,7 @@ void toc_item_private::load_children(GooList *items) children[i] = new_item; item->open(); - GooList *item_children = item->getKids(); + const GooList *item_children = item->getKids(); if (item_children) { new_item->d->load_children(item_children); } diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc index 03a63c23..3fbd3984 100644 --- a/glib/poppler-action.cc +++ b/glib/poppler-action.cc @@ -232,7 +232,7 @@ poppler_action_copy (PopplerAction *action) static PopplerDest * dest_new_goto (PopplerDocument *document, - LinkDest *link_dest) + const LinkDest *link_dest) { PopplerDest *dest; @@ -337,9 +337,9 @@ dest_new_named (const GooString *named_dest) static void build_goto_dest (PopplerDocument *document, PopplerAction *action, - LinkGoTo *link) + const LinkGoTo *link) { - LinkDest *link_dest; + const LinkDest *link_dest; const GooString *named_dest; /* Return if it isn't OK */ @@ -362,9 +362,9 @@ build_goto_dest (PopplerDocument *document, static void build_goto_remote (PopplerAction *action, - LinkGoToR *link) + const LinkGoToR *link) { - LinkDest *link_dest; + const LinkDest *link_dest; const GooString *named_dest; /* Return if it isn't OK */ @@ -389,7 +389,7 @@ build_goto_remote (PopplerAction *action, static void build_launch (PopplerAction *action, - LinkLaunch *link) + const LinkLaunch *link) { if (link->getFileName()) { action->launch.file_name = g_strdup (link->getFileName()->getCString ()); @@ -401,7 +401,7 @@ build_launch (PopplerAction *action, static void build_uri (PopplerAction *action, - LinkURI *link) + const LinkURI *link) { const gchar *uri; @@ -412,7 +412,7 @@ build_uri (PopplerAction *action, static void build_named (PopplerAction *action, - LinkNamed *link) + const LinkNamed *link) { const gchar *name; @@ -423,14 +423,14 @@ build_named (PopplerAction *action, static AnnotMovie * find_annot_movie_for_action (PopplerDocument *document, - LinkMovie *link) + const LinkMovie *link) { AnnotMovie *annot = nullptr; XRef *xref = document->doc->getXRef (); Object annotObj; if (link->hasAnnotRef ()) { - Ref *ref = link->getAnnotRef (); + const Ref *ref = link->getAnnotRef (); annotObj = xref->fetch (ref->num, ref->gen); } else if (link->hasAnnotTitle ()) { @@ -490,7 +490,7 @@ find_annot_movie_for_action (PopplerDocument *document, static void build_movie (PopplerDocument *document, PopplerAction *action, - LinkMovie *link) + const LinkMovie *link) { AnnotMovie *annot; @@ -519,7 +519,7 @@ build_movie (PopplerDocument *document, static void build_javascript (PopplerAction *action, - LinkJavaScript *link) + const LinkJavaScript *link) { const GooString *script; @@ -531,7 +531,7 @@ build_javascript (PopplerAction *action, static void build_rendition (PopplerAction *action, - LinkRendition *link) + const LinkRendition *link) { action->rendition.op = link->getOperation(); if (link->hasRenditionObject()) @@ -575,9 +575,9 @@ get_layer_for_ref (PopplerDocument *document, static void build_ocg_state (PopplerDocument *document, PopplerAction *action, - LinkOCGState *ocg_state) + const LinkOCGState *ocg_state) { - GooList *st_list = ocg_state->getStateList(); + const GooList *st_list = ocg_state->getStateList(); GBool preserve_rb = ocg_state->getPreserveRB(); gint i, j; GList *layer_state = nullptr; @@ -618,7 +618,7 @@ build_ocg_state (PopplerDocument *document, PopplerAction * _poppler_action_new (PopplerDocument *document, - LinkAction *link, + const LinkAction *link, const gchar *title) { PopplerAction *action; @@ -636,39 +636,39 @@ _poppler_action_new (PopplerDocument *document, switch (link->getKind ()) { case actionGoTo: action->type = POPPLER_ACTION_GOTO_DEST; - build_goto_dest (document, action, dynamic_cast <LinkGoTo *> (link)); + build_goto_dest (document, action, dynamic_cast <const LinkGoTo *> (link)); break; case actionGoToR: action->type = POPPLER_ACTION_GOTO_REMOTE; - build_goto_remote (action, dynamic_cast <LinkGoToR *> (link)); + build_goto_remote (action, dynamic_cast <const LinkGoToR *> (link)); break; case actionLaunch: action->type = POPPLER_ACTION_LAUNCH; - build_launch (action, dynamic_cast <LinkLaunch *> (link)); + build_launch (action, dynamic_cast <const LinkLaunch *> (link)); break; case actionURI: action->type = POPPLER_ACTION_URI; - build_uri (action, dynamic_cast <LinkURI *> (link)); + build_uri (action, dynamic_cast <const LinkURI *> (link)); break; case actionNamed: action->type = POPPLER_ACTION_NAMED; - build_named (action, dynamic_cast <LinkNamed *> (link)); + build_named (action, dynamic_cast <const LinkNamed *> (link)); break; case actionMovie: action->type = POPPLER_ACTION_MOVIE; - build_movie (document, action, dynamic_cast<LinkMovie*> (link)); + build_movie (document, action, dynamic_cast<const LinkMovie*> (link)); break; case actionRendition: action->type = POPPLER_ACTION_RENDITION; - build_rendition (action, dynamic_cast<LinkRendition*> (link)); + build_rendition (action, dynamic_cast<const LinkRendition*> (link)); break; case actionOCGState: action->type = POPPLER_ACTION_OCG_STATE; - build_ocg_state (document, action, dynamic_cast<LinkOCGState*> (link)); + build_ocg_state (document, action, dynamic_cast<const LinkOCGState*> (link)); break; case actionJavaScript: action->type = POPPLER_ACTION_JAVASCRIPT; - build_javascript (action, dynamic_cast<LinkJavaScript*> (link)); + build_javascript (action, dynamic_cast<const LinkJavaScript*> (link)); break; case actionUnknown: default: diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index 98fa10e9..b343eb90 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -1735,7 +1735,7 @@ poppler_document_init (PopplerDocument *document) struct _PopplerIndexIter { PopplerDocument *document; - GooList *items; + const GooList *items; int index; }; @@ -1810,7 +1810,7 @@ poppler_index_iter_new (PopplerDocument *document) { PopplerIndexIter *iter; Outline *outline; - GooList *items; + const GooList *items; outline = document->doc->getOutline(); if (outline == nullptr) @@ -1860,7 +1860,7 @@ poppler_index_iter_get_child (PopplerIndexIter *parent) } static gchar * -unicode_to_char (Unicode *unicode, +unicode_to_char (const Unicode *unicode, int len) { static UnicodeMap *uMap = nullptr; @@ -1916,7 +1916,7 @@ PopplerAction * poppler_index_iter_get_action (PopplerIndexIter *iter) { OutlineItem *item; - LinkAction *link_action; + const LinkAction *link_action; PopplerAction *action; gchar *title; diff --git a/glib/poppler-layer.cc b/glib/poppler-layer.cc index f97b8b61..c7fec2e7 100644 --- a/glib/poppler-layer.cc +++ b/glib/poppler-layer.cc @@ -75,7 +75,7 @@ _poppler_layer_new (PopplerDocument *document, GList *rbgroup) { PopplerLayer *poppler_layer; - GooString *layer_name; + const GooString *layer_name; g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL); g_return_val_if_fail (layer != nullptr, NULL); diff --git a/glib/poppler-media.cc b/glib/poppler-media.cc index 309c0d46..b7afa9ab 100644 --- a/glib/poppler-media.cc +++ b/glib/poppler-media.cc @@ -84,7 +84,7 @@ poppler_media_init (PopplerMedia *media) } PopplerMedia * -_poppler_media_new (MediaRendition *poppler_media) +_poppler_media_new (const MediaRendition *poppler_media) { PopplerMedia *media; @@ -93,7 +93,7 @@ _poppler_media_new (MediaRendition *poppler_media) media = POPPLER_MEDIA (g_object_new (POPPLER_TYPE_MEDIA, nullptr)); if (poppler_media->getIsEmbedded()) { - GooString* mime_type; + const GooString* mime_type; media->stream = poppler_media->getEmbbededStreamObject()->copy(); mime_type = poppler_media->getContentType(); diff --git a/glib/poppler-movie.cc b/glib/poppler-movie.cc index 894ae182..3bbc2298 100644 --- a/glib/poppler-movie.cc +++ b/glib/poppler-movie.cc @@ -74,7 +74,7 @@ poppler_movie_init (PopplerMovie *movie) } PopplerMovie * -_poppler_movie_new (Movie *poppler_movie) +_poppler_movie_new (const Movie *poppler_movie) { PopplerMovie *movie; diff --git a/glib/poppler-private.h b/glib/poppler-private.h index 7a0225d7..f2080472 100644 --- a/glib/poppler-private.h +++ b/glib/poppler-private.h @@ -112,7 +112,7 @@ PopplerPage *_poppler_page_new (PopplerDocument *document, Page *page, int index); PopplerAction *_poppler_action_new (PopplerDocument *document, - LinkAction *link, + const LinkAction *link, const gchar *title); PopplerLayer *_poppler_layer_new (PopplerDocument *document, Layer *layer, @@ -122,8 +122,8 @@ PopplerDest *_poppler_dest_new_goto (PopplerDocument *document, PopplerFormField *_poppler_form_field_new (PopplerDocument *document, FormWidget *field); PopplerAttachment *_poppler_attachment_new (FileSpec *file); -PopplerMovie *_poppler_movie_new (Movie *movie); -PopplerMedia *_poppler_media_new (MediaRendition *media); +PopplerMovie *_poppler_movie_new (const Movie *movie); +PopplerMedia *_poppler_media_new (const MediaRendition *media); PopplerAnnot *_poppler_annot_new (Annot *annot); PopplerAnnot *_poppler_annot_text_new (Annot *annot); PopplerAnnot *_poppler_annot_free_text_new (Annot *annot); diff --git a/goo/GooList.cc b/goo/GooList.cc index 6ce4952d..e0e4875b 100644 --- a/goo/GooList.cc +++ b/goo/GooList.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) 2018 Albert Astals Cid <aa...@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 @@ -39,7 +53,7 @@ GooList::~GooList() { gfree(data); } -GooList *GooList::copy() { +GooList *GooList::copy() const { GooList *ret; ret = new GooList(length); diff --git a/goo/GooList.h b/goo/GooList.h index c83a0e36..a0bc525d 100644 --- a/goo/GooList.h +++ b/goo/GooList.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) 2012 Albert Astals Cid <aa...@kde.org> +// Copyright (C) 2012, 2018 Albert Astals Cid <aa...@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 @@ -48,16 +48,16 @@ public: //----- general // Get the number of elements. - int getLength() { return length; } + int getLength() const { return length; } // Returns a (shallow) copy of this list. - GooList *copy(); + GooList *copy() const; //----- ordered list support // Return the <i>th element. // Assumes 0 <= i < length. - void *get(int i) { return data[i]; } + void *get(int i) const { return data[i]; } // Replace the <i>th element. // Assumes 0 <= i < length. diff --git a/poppler/FileSpec.cc b/poppler/FileSpec.cc index a5cb947a..2628c363 100644 --- a/poppler/FileSpec.cc +++ b/poppler/FileSpec.cc @@ -7,7 +7,7 @@ // // Copyright (C) 2008-2009 Carlos Garcia Campos <carlo...@gnome.org> // Copyright (C) 2009 Kovid Goyal <ko...@kovidgoyal.net> -// Copyright (C) 2012, 2017 Albert Astals Cid <aa...@kde.org> +// Copyright (C) 2012, 2017, 2018 Albert Astals Cid <aa...@kde.org> // Copyright (C) 2012 Hib Eris <h...@hiberis.nl> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <i...@kdab.com>. Work sponsored by the LiMux project of the city of Munich // @@ -28,7 +28,7 @@ #include "FileSpec.h" -EmbFile::EmbFile(Object *efStream) +EmbFile::EmbFile(const Object *efStream) { m_size = -1; m_createDate = nullptr; @@ -100,7 +100,7 @@ GBool EmbFile::save2(FILE *f) { return gTrue; } -FileSpec::FileSpec(Object *fileSpecA) +FileSpec::FileSpec(const Object *fileSpecA) { ok = gTrue; fileName = nullptr; @@ -172,7 +172,7 @@ GooString *FileSpec::getFileNameForPlatform() return platformFileName; } -Object getFileSpecName (Object *fileSpec) +Object getFileSpecName (const Object *fileSpec) { if (fileSpec->isString()) { return fileSpec->copy(); @@ -203,7 +203,7 @@ Object getFileSpecName (Object *fileSpec) return Object(); } -Object getFileSpecNameForPlatform (Object *fileSpec) +Object getFileSpecNameForPlatform (const Object *fileSpec) { if (fileSpec->isString()) { return fileSpec->copy(); diff --git a/poppler/FileSpec.h b/poppler/FileSpec.h index 28394650..f40f7705 100644 --- a/poppler/FileSpec.h +++ b/poppler/FileSpec.h @@ -24,20 +24,20 @@ class EmbFile { public: - EmbFile(Object *efStream); + EmbFile(const Object *efStream); ~EmbFile(); EmbFile(const EmbFile &) = delete; EmbFile& operator=(const EmbFile &) = delete; - int size() { return m_size; } - GooString *modDate() { return m_modDate; } - GooString *createDate() { return m_createDate; } - GooString *checksum() { return m_checksum; } - GooString *mimeType() { return m_mimetype; } + int size() const { return m_size; } + const GooString *modDate() const { return m_modDate; } + const GooString *createDate() const { return m_createDate; } + const GooString *checksum() const { return m_checksum; } + const GooString *mimeType() const { return m_mimetype; } Object *streamObject() { return &m_objStr; } Stream *stream() { return isOk() ? m_objStr.getStream() : NULL; } - GBool isOk() { return m_objStr.isStream(); } + GBool isOk() const { return m_objStr.isStream(); } GBool save(const char *path); private: @@ -53,17 +53,17 @@ private: class FileSpec { public: - FileSpec(Object *fileSpec); + FileSpec(const Object *fileSpec); ~FileSpec(); FileSpec(const FileSpec &) = delete; FileSpec& operator=(const FileSpec &) = delete; - GBool isOk() { return ok; } + GBool isOk() const { return ok; } - GooString *getFileName() const { return fileName; } + const GooString *getFileName() const { return fileName; } GooString *getFileNameForPlatform(); - GooString *getDescription() const { return desc; } + const GooString *getDescription() const { return desc; } EmbFile *getEmbeddedFile(); private: @@ -78,7 +78,7 @@ private: GooString *desc; // Desc }; -Object getFileSpecName (Object *fileSpec); -Object getFileSpecNameForPlatform (Object *fileSpec); +Object getFileSpecName (const Object *fileSpec); +Object getFileSpecNameForPlatform (const Object *fileSpec); #endif /* FILE_SPEC_H */ diff --git a/poppler/Function.h b/poppler/Function.h index 65b53251..10adf705 100644 --- a/poppler/Function.h +++ b/poppler/Function.h @@ -240,7 +240,7 @@ public: void transform(double *in, double *out) override; GBool isOk() override { return ok; } - GooString *getCodeString() { return codeString; } + const GooString *getCodeString() const { return codeString; } private: diff --git a/poppler/Link.cc b/poppler/Link.cc index 1abaea2f..9be6a8c1 100644 --- a/poppler/Link.cc +++ b/poppler/Link.cc @@ -16,7 +16,7 @@ // Copyright (C) 2006, 2008 Pino Toscano <p...@kde.org> // Copyright (C) 2007, 2010, 2011 Carlos Garcia Campos <carlo...@gnome.org> // Copyright (C) 2008 Hugo Mercier <hmercie...@gmail.com> -// Copyright (C) 2008-2010, 2012-2014, 2016, 2017 Albert Astals Cid <aa...@kde.org> +// Copyright (C) 2008-2010, 2012-2014, 2016-2018 Albert Astals Cid <aa...@kde.org> // Copyright (C) 2009 Kovid Goyal <ko...@kovidgoyal.net> // Copyright (C) 2009 Ilya Gorenbein <igorenb...@finjan.com> // Copyright (C) 2012 Tobias Koening <tobias.koe...@kdab.com> @@ -52,7 +52,7 @@ // LinkAction //------------------------------------------------------------------------ -LinkAction *LinkAction::parseDest(Object *obj) { +LinkAction *LinkAction::parseDest(const Object *obj) { LinkAction *action; action = new LinkGoTo(obj); @@ -63,7 +63,7 @@ LinkAction *LinkAction::parseDest(Object *obj) { return action; } -LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { +LinkAction *LinkAction::parseAction(const Object *obj, const GooString *baseURI) { LinkAction *action; if (!obj->isDict()) { @@ -142,7 +142,7 @@ LinkAction *LinkAction::parseAction(Object *obj, GooString *baseURI) { // LinkDest //------------------------------------------------------------------------ -LinkDest::LinkDest(Array *a) { +LinkDest::LinkDest(const Array *a) { // initialize fields left = bottom = right = top = zoom = 0; changeLeft = changeTop = changeZoom = gFalse; @@ -340,7 +340,7 @@ LinkDest::LinkDest(Array *a) { return; } -LinkDest::LinkDest(LinkDest *dest) { +LinkDest::LinkDest(const LinkDest *dest) { kind = dest->kind; pageIsRef = dest->pageIsRef; if (pageIsRef) @@ -362,7 +362,7 @@ LinkDest::LinkDest(LinkDest *dest) { // LinkGoTo //------------------------------------------------------------------------ -LinkGoTo::LinkGoTo(Object *destObj) { +LinkGoTo::LinkGoTo(const Object *destObj) { dest = nullptr; namedDest = nullptr; @@ -442,7 +442,7 @@ LinkGoToR::~LinkGoToR() { // LinkLaunch //------------------------------------------------------------------------ -LinkLaunch::LinkLaunch(Object *actionObj) { +LinkLaunch::LinkLaunch(const Object *actionObj) { fileName = nullptr; params = nullptr; @@ -490,7 +490,7 @@ LinkLaunch::~LinkLaunch() { // LinkURI //------------------------------------------------------------------------ -LinkURI::LinkURI(Object *uriObj, GooString *baseURI) { +LinkURI::LinkURI(const Object *uriObj, const GooString *baseURI) { const GooString *uri2; int n; char c; @@ -539,7 +539,7 @@ LinkURI::~LinkURI() { // LinkNamed //------------------------------------------------------------------------ -LinkNamed::LinkNamed(Object *nameObj) { +LinkNamed::LinkNamed(const Object *nameObj) { name = nullptr; if (nameObj->isName()) { name = new GooString(nameObj->getName()); @@ -556,7 +556,7 @@ LinkNamed::~LinkNamed() { // LinkMovie //------------------------------------------------------------------------ -LinkMovie::LinkMovie(Object *obj) { +LinkMovie::LinkMovie(const Object *obj) { annotRef.num = -1; annotTitle = nullptr; @@ -604,7 +604,7 @@ LinkMovie::~LinkMovie() { // LinkSound //------------------------------------------------------------------------ -LinkSound::LinkSound(Object *soundObj) { +LinkSound::LinkSound(const Object *soundObj) { volume = 1.0; sync = gFalse; repeat = gFalse; @@ -646,7 +646,7 @@ LinkSound::~LinkSound() { // LinkRendition //------------------------------------------------------------------------ -LinkRendition::LinkRendition(Object *obj) { +LinkRendition::LinkRendition(const Object *obj) { operation = NoRendition; media = nullptr; js = nullptr; @@ -743,7 +743,7 @@ LinkJavaScript::~LinkJavaScript() { //------------------------------------------------------------------------ // LinkOCGState //------------------------------------------------------------------------ -LinkOCGState::LinkOCGState(Object *obj) { +LinkOCGState::LinkOCGState(const Object *obj) { stateList = new GooList(); preserveRB = gTrue; diff --git a/poppler/Link.h b/poppler/Link.h index d6d1f988..90496c42 100644 --- a/poppler/Link.h +++ b/poppler/Link.h @@ -72,16 +72,16 @@ public: virtual ~LinkAction() {} // Was the LinkAction created successfully? - virtual GBool isOk() = 0; + virtual GBool isOk() const = 0; // Check link action type. - virtual LinkActionKind getKind() = 0; + virtual LinkActionKind getKind() const = 0; // Parse a destination (old-style action) name, string, or array. - static LinkAction *parseDest(Object *obj); + static LinkAction *parseDest(const Object *obj); // Parse an action dictionary. - static LinkAction *parseAction(Object *obj, GooString *baseURI = NULL); + static LinkAction *parseAction(const Object *obj, const GooString *baseURI = NULL); }; //------------------------------------------------------------------------ @@ -103,27 +103,27 @@ class LinkDest { public: // Build a LinkDest from the array. - LinkDest(Array *a); + LinkDest(const Array *a); // Copy a LinkDest. - LinkDest *copy() { return new LinkDest(this); } + LinkDest *copy() const { return new LinkDest(this); } // Was the LinkDest created successfully? - GBool isOk() { return ok; } + GBool isOk() const { return ok; } // Accessors. - LinkDestKind getKind() { return kind; } - GBool isPageRef() { return pageIsRef; } - int getPageNum() { return pageNum; } - Ref getPageRef() { return pageRef; } - double getLeft() { return left; } - double getBottom() { return bottom; } - double getRight() { return right; } - double getTop() { return top; } - double getZoom() { return zoom; } - GBool getChangeLeft() { return changeLeft; } - GBool getChangeTop() { return changeTop; } - GBool getChangeZoom() { return changeZoom; } + LinkDestKind getKind() const { return kind; } + GBool isPageRef() const { return pageIsRef; } + int getPageNum() const { return pageNum; } + Ref getPageRef() const { return pageRef; } + double getLeft() const { return left; } + double getBottom() const { return bottom; } + double getRight() const { return right; } + double getTop() const { return top; } + double getZoom() const { return zoom; } + GBool getChangeLeft() const { return changeLeft; } + GBool getChangeTop() const { return changeTop; } + GBool getChangeZoom() const { return changeZoom; } private: @@ -142,7 +142,7 @@ private: // destFitV/BV use changeLeft GBool ok; // set if created successfully - LinkDest(LinkDest *dest); + LinkDest(const LinkDest *dest); }; //------------------------------------------------------------------------ @@ -153,17 +153,17 @@ class LinkGoTo: public LinkAction { public: // Build a LinkGoTo from a destination (dictionary, name, or string). - LinkGoTo(Object *destObj); + LinkGoTo(const Object *destObj); // Destructor. ~LinkGoTo(); // Was the LinkGoTo created successfully? - GBool isOk() override { return dest || namedDest; } + GBool isOk() const override { return dest || namedDest; } // Accessors. - LinkActionKind getKind() override { return actionGoTo; } - LinkDest *getDest() { return dest; } + LinkActionKind getKind() const override { return actionGoTo; } + const LinkDest *getDest() const { return dest; } const GooString *getNamedDest() const { return namedDest; } private: @@ -189,12 +189,12 @@ public: ~LinkGoToR(); // Was the LinkGoToR created successfully? - GBool isOk() override { return fileName && (dest || namedDest); } + GBool isOk() const override { return fileName && (dest || namedDest); } // Accessors. - LinkActionKind getKind() override { return actionGoToR; } + LinkActionKind getKind() const override { return actionGoToR; } const GooString *getFileName() const { return fileName; } - LinkDest *getDest() { return dest; } + const LinkDest *getDest() const { return dest; } const GooString *getNamedDest() const { return namedDest; } private: @@ -214,16 +214,16 @@ class LinkLaunch: public LinkAction { public: // Build a LinkLaunch from an action dictionary. - LinkLaunch(Object *actionObj); + LinkLaunch(const Object *actionObj); // Destructor. ~LinkLaunch(); // Was the LinkLaunch created successfully? - GBool isOk() override { return fileName != NULL; } + GBool isOk() const override { return fileName != NULL; } // Accessors. - LinkActionKind getKind() override { return actionLaunch; } + LinkActionKind getKind() const override { return actionLaunch; } const GooString *getFileName() const { return fileName; } const GooString *getParams() const { return params; } @@ -241,16 +241,16 @@ class LinkURI: public LinkAction { public: // Build a LinkURI given the URI (string) and base URI. - LinkURI(Object *uriObj, GooString *baseURI); + LinkURI(const Object *uriObj, const GooString *baseURI); // Destructor. ~LinkURI(); // Was the LinkURI created successfully? - GBool isOk() override { return uri != NULL; } + GBool isOk() const override { return uri != NULL; } // Accessors. - LinkActionKind getKind() override { return actionURI; } + LinkActionKind getKind() const override { return actionURI; } const GooString *getURI() const { return uri; } private: @@ -266,13 +266,13 @@ class LinkNamed: public LinkAction { public: // Build a LinkNamed given the action name. - LinkNamed(Object *nameObj); + LinkNamed(const Object *nameObj); ~LinkNamed(); - GBool isOk() override { return name != NULL; } + GBool isOk() const override { return name != NULL; } - LinkActionKind getKind() override { return actionNamed; } + LinkActionKind getKind() const override { return actionNamed; } const GooString *getName() const { return name; } private: @@ -295,21 +295,21 @@ public: operationTypeStop }; - LinkMovie(Object *obj); + LinkMovie(const Object *obj); ~LinkMovie(); - GBool isOk() override { return annotRef.num >= 0 || annotTitle != NULL; } - LinkActionKind getKind() override { return actionMovie; } + GBool isOk() const override { return annotRef.num >= 0 || annotTitle != NULL; } + LinkActionKind getKind() const override { return actionMovie; } // a movie action stores either an indirect reference to a movie annotation // or the movie annotation title - GBool hasAnnotRef() { return annotRef.num >= 0; } - GBool hasAnnotTitle() { return annotTitle != NULL; } - Ref *getAnnotRef() { return &annotRef; } + GBool hasAnnotRef() const { return annotRef.num >= 0; } + GBool hasAnnotTitle() const { return annotTitle != NULL; } + const Ref *getAnnotRef() const { return &annotRef; } const GooString *getAnnotTitle() const { return annotTitle; } - OperationType getOperation() { return operation; } + OperationType getOperation() const { return operation; } private: @@ -337,23 +337,23 @@ public: ResumeRendition }; - LinkRendition(Object *Obj); + LinkRendition(const Object *Obj); ~LinkRendition(); - GBool isOk() override { return true; } + GBool isOk() const override { return true; } - LinkActionKind getKind() override { return actionRendition; } + LinkActionKind getKind() const override { return actionRendition; } - GBool hasRenditionObject() { return renditionObj.isDict(); } - Object* getRenditionObject() { return &renditionObj; } + GBool hasRenditionObject() const { return renditionObj.isDict(); } + const Object* getRenditionObject() const { return &renditionObj; } - GBool hasScreenAnnot() { return screenRef.isRef(); } - Ref getScreenAnnot() { return screenRef.getRef(); } + GBool hasScreenAnnot() const { return screenRef.isRef(); } + Ref getScreenAnnot() const { return screenRef.getRef(); } - RenditionOperation getOperation() { return operation; } + RenditionOperation getOperation() const { return operation; } - MediaRendition* getMedia() { return media; } + const MediaRendition* getMedia() const { return media; } const GooString *getScript() const { return js; } @@ -375,19 +375,19 @@ private: class LinkSound: public LinkAction { public: - LinkSound(Object *soundObj); + LinkSound(const Object *soundObj); ~LinkSound(); - GBool isOk() override { return sound != NULL; } + GBool isOk() const override { return sound != NULL; } - LinkActionKind getKind() override { return actionSound; } + LinkActionKind getKind() const override { return actionSound; } - double getVolume() { return volume; } - GBool getSynchronous() { return sync; } - GBool getRepeat() { return repeat; } - GBool getMix() { return mix; } - Sound *getSound() { return sound; } + double getVolume() const { return volume; } + GBool getSynchronous() const { return sync; } + GBool getRepeat() const { return repeat; } + GBool getMix() const { return mix; } + Sound *getSound() const { return sound; } private: @@ -410,9 +410,9 @@ public: ~LinkJavaScript(); - GBool isOk() override { return js != NULL; } + GBool isOk() const override { return js != NULL; } - LinkActionKind getKind() override { return actionJavaScript; } + LinkActionKind getKind() const override { return actionJavaScript; } const GooString *getScript() const { return js; } private: @@ -425,13 +425,13 @@ private: //------------------------------------------------------------------------ class LinkOCGState: public LinkAction { public: - LinkOCGState(Object *obj); + LinkOCGState(const Object *obj); ~LinkOCGState(); - GBool isOk() override { return stateList != NULL; } + GBool isOk() const override { return stateList != NULL; } - LinkActionKind getKind() override { return actionOCGState; } + LinkActionKind getKind() const override { return actionOCGState; } enum State { On, Off, Toggle}; struct StateList { @@ -443,8 +443,8 @@ public: GooList *list; }; - GooList *getStateList() { return stateList; } - GBool getPreserveRB() { return preserveRB; } + const GooList *getStateList() const { return stateList; } + GBool getPreserveRB() const { return preserveRB; } private: GooList *stateList; @@ -465,10 +465,10 @@ public: ~LinkUnknown(); // Was the LinkUnknown create successfully? - GBool isOk() override { return action != NULL; } + GBool isOk() const override { return action != NULL; } // Accessors. - LinkActionKind getKind() override { return actionUnknown; } + LinkActionKind getKind() const override { return actionUnknown; } const GooString *getAction() const { return action; } private: diff --git a/poppler/Movie.cc b/poppler/Movie.cc index 3cc922ff..2fe05da3 100644 --- a/poppler/Movie.cc +++ b/poppler/Movie.cc @@ -6,7 +6,7 @@ // Hugo Mercier <hmercier31[at]gmail.com> (c) 2008 // Pino Toscano <p...@kde.org> (c) 2008 // Carlos Garcia Campos <carlo...@gnome.org> (c) 2010 -// Albert Astals Cid <aa...@kde.org> (c) 2010, 2017 +// Albert Astals Cid <aa...@kde.org> (c) 2010, 2017, 2018 // // 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 +46,7 @@ MovieActivationParameters::MovieActivationParameters() { MovieActivationParameters::~MovieActivationParameters() { } -void MovieActivationParameters::parseMovieActivation(Object* aDict) { +void MovieActivationParameters::parseMovieActivation(const Object* aDict) { Object obj1 = aDict->dictLookup("Start"); if (obj1.isNull()) { if (obj1.isInt()) { @@ -172,7 +172,7 @@ void MovieActivationParameters::parseMovieActivation(Object* aDict) { } } -void Movie::parseMovie (Object *movieDict) { +void Movie::parseMovie (const Object *movieDict) { fileName = nullptr; rotationAngle = 0; width = -1; @@ -230,7 +230,7 @@ Movie::~Movie() { delete fileName; } -Movie::Movie(Object *movieDict) { +Movie::Movie(const Object *movieDict) { ok = gTrue; if (movieDict->isDict()) @@ -239,7 +239,7 @@ Movie::Movie(Object *movieDict) { ok = gFalse; } -Movie::Movie(Object *movieDict, Object *aDict) { +Movie::Movie(const Object *movieDict, const Object *aDict) { ok = gTrue; if (movieDict->isDict()) { @@ -274,6 +274,6 @@ void Movie::getFloatingWindowSize(int *widthA, int *heightA) *heightA = int(height * double(MA.znum) / MA.zdenum); } -Movie* Movie::copy() { +Movie* Movie::copy() const { return new Movie(*this); } diff --git a/poppler/Movie.h b/poppler/Movie.h index 65379167..5c7f7913 100644 --- a/poppler/Movie.h +++ b/poppler/Movie.h @@ -33,7 +33,7 @@ struct MovieActivationParameters { ~MovieActivationParameters(); // parse from a "Movie Activation" dictionary - void parseMovieActivation(Object* actObj); + void parseMovieActivation(const Object* actObj); enum MovieRepeatMode { repeatModeOnce, @@ -70,30 +70,30 @@ struct MovieActivationParameters { class Movie { public: - Movie(Object *objMovie, Object *objAct); - Movie(Object *objMovie); + Movie(const Object *objMovie, const Object *objAct); + Movie(const Object *objMovie); Movie(const Movie &movie); ~Movie(); Movie& operator=(const Movie &) = delete; - GBool isOk() { return ok; } - MovieActivationParameters* getActivationParameters() { return &MA; } + GBool isOk() const { return ok; } + const MovieActivationParameters* getActivationParameters() const { return &MA; } - GooString* getFileName() { return fileName; } + const GooString* getFileName() const { return fileName; } - Gushort getRotationAngle() { return rotationAngle; } - void getAspect (int *widthA, int *heightA) { *widthA = width; *heightA = height; } + Gushort getRotationAngle() const { return rotationAngle; } + void getAspect (int *widthA, int *heightA) const { *widthA = width; *heightA = height; } - Object getPoster() { return poster.copy(); } - GBool getShowPoster() { return showPoster; } + Object getPoster() const { return poster.copy(); } + GBool getShowPoster() const { return showPoster; } - GBool getUseFloatingWindow() { return MA.floatingWindow; } + GBool getUseFloatingWindow() const { return MA.floatingWindow; } void getFloatingWindowSize(int *width, int *height); - Movie* copy(); + Movie* copy() const ; private: - void parseMovie (Object *movieDict); + void parseMovie (const Object *movieDict); GBool ok; diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc index 8bd6baa4..8376a0e4 100644 --- a/poppler/OptionalContent.cc +++ b/poppler/OptionalContent.cc @@ -133,7 +133,7 @@ OCGs::~OCGs() } -bool OCGs::hasOCGs() +bool OCGs::hasOCGs() const { return ( optionalContentGroups->getLength() > 0 ); } @@ -374,7 +374,7 @@ OptionalContentGroup::OptionalContentGroup(GooString *label) m_state = On; } -GooString* OptionalContentGroup::getName() const +const GooString* OptionalContentGroup::getName() const { return m_name; } @@ -489,13 +489,13 @@ OCDisplayNode::~OCDisplayNode() { } } -int OCDisplayNode::getNumChildren() { +int OCDisplayNode::getNumChildren() const { if (!children) { return 0; } return children->getLength(); } -OCDisplayNode *OCDisplayNode::getChild(int idx) { +OCDisplayNode *OCDisplayNode::getChild(int idx) const { return (OCDisplayNode *)children->get(idx); } diff --git a/poppler/OptionalContent.h b/poppler/OptionalContent.h index a67171df..ea5618e4 100644 --- a/poppler/OptionalContent.h +++ b/poppler/OptionalContent.h @@ -39,9 +39,9 @@ public: OCGs& operator=(const OCGs &) = delete; // Is OCGS valid? - GBool isOk() { return ok; } + GBool isOk() const { return ok; } - bool hasOCGs(); + bool hasOCGs() const; GooList *getOCGs() const { return optionalContentGroups; } OptionalContentGroup* findOcgByRef( const Ref &ref); @@ -96,7 +96,7 @@ public: OptionalContentGroup(const OptionalContentGroup &) = delete; OptionalContentGroup& operator=(const OptionalContentGroup &) = delete; - GooString* getName() const; + const GooString* getName() const; Ref getRef() const; void setRef(const Ref ref); @@ -127,10 +127,10 @@ public: OCDisplayNode(const OCDisplayNode &) = delete; OCDisplayNode& operator=(const OCDisplayNode &) = delete; - GooString *getName() { return name; } - OptionalContentGroup *getOCG() { return ocg; } - int getNumChildren(); - OCDisplayNode *getChild(int idx); + const GooString *getName() const { return name; } + const OptionalContentGroup *getOCG() const { return ocg; } + int getNumChildren() const; + OCDisplayNode *getChild(int idx) const; private: diff --git a/poppler/Outline.cc b/poppler/Outline.cc index f12d9022..c6b12dc0 100644 --- a/poppler/Outline.cc +++ b/poppler/Outline.cc @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Marco Pesenti Gritti <m...@redhat.com> -// Copyright (C) 2008, 2016, 2017 Albert Astals Cid <aa...@kde.org> +// Copyright (C) 2008, 2016-2018 Albert Astals Cid <aa...@kde.org> // Copyright (C) 2009 Nick Jones <nick.jo...@network-box.com> // Copyright (C) 2016 Jason Crain <ja...@aquaticape.us> // Copyright (C) 2017 Adrian Johnson <ajohn...@redneon.com> @@ -42,7 +42,7 @@ //------------------------------------------------------------------------ -Outline::Outline(Object *outlineObj, XRef *xref) { +Outline::Outline(const Object *outlineObj, XRef *xref) { items = nullptr; if (!outlineObj->isDict()) { return; @@ -59,7 +59,7 @@ Outline::~Outline() { //------------------------------------------------------------------------ -OutlineItem::OutlineItem(Dict *dict, int refNumA, OutlineItem *parentA, XRef *xrefA) { +OutlineItem::OutlineItem(const Dict *dict, int refNumA, OutlineItem *parentA, XRef *xrefA) { Object obj1; refNum = refNumA; @@ -111,7 +111,7 @@ OutlineItem::~OutlineItem() { } } -GooList *OutlineItem::readItemList(OutlineItem *parent, Object *firstItemRef, XRef *xrefA) { +GooList *OutlineItem::readItemList(OutlineItem *parent, const Object *firstItemRef, XRef *xrefA) { GooList *items = new GooList(); char* alreadyRead = (char *)gmalloc(xrefA->getNumObjects()); @@ -123,7 +123,7 @@ GooList *OutlineItem::readItemList(OutlineItem *parent, Object *firstItemRef, XR parentO = parentO->parent; } - Object *p = firstItemRef; + const Object *p = firstItemRef; while (p->isRef() && (p->getRefNum() >= 0) && (p->getRefNum() < xrefA->getNumObjects()) && diff --git a/poppler/Outline.h b/poppler/Outline.h index 1584ddcb..a6e9e79a 100644 --- a/poppler/Outline.h +++ b/poppler/Outline.h @@ -41,13 +41,13 @@ class LinkAction; class Outline { public: - Outline(Object *outlineObj, XRef *xref); + Outline(const Object *outlineObj, XRef *xref); ~Outline(); Outline(const Outline &) = delete; Outline& operator=(const Outline &) = delete; - GooList *getItems() { return items; } + const GooList *getItems() const { return items; } private: @@ -60,23 +60,23 @@ private: class OutlineItem { public: - OutlineItem(Dict *dict, int refNumA, OutlineItem *parentA, XRef *xrefA); + OutlineItem(const Dict *dict, int refNumA, OutlineItem *parentA, XRef *xrefA); ~OutlineItem(); OutlineItem(const OutlineItem &) = delete; OutlineItem& operator=(const OutlineItem &) = delete; - static GooList *readItemList(OutlineItem *parent, Object *firstItemRef, XRef *xrefA); + static GooList *readItemList(OutlineItem *parent, const Object *firstItemRef, XRef *xrefA); void open(); void close(); - Unicode *getTitle() { return title; } - int getTitleLength() { return titleLen; } - LinkAction *getAction() { return action; } - GBool isOpen() { return startsOpen; } - GBool hasKids() { return firstRef.isRef(); } - GooList *getKids() { return kids; } + const Unicode *getTitle() const { return title; } + int getTitleLength() const { return titleLen; } + const LinkAction *getAction() const { return action; } + GBool isOpen() const { return startsOpen; } + GBool hasKids() const { return firstRef.isRef(); } + const GooList *getKids() const { return kids; } private: diff --git a/poppler/Rendition.cc b/poppler/Rendition.cc index f090a99a..8d30fb06 100644 --- a/poppler/Rendition.cc +++ b/poppler/Rendition.cc @@ -7,7 +7,7 @@ // Pino Toscano <p...@kde.org> (c) 2008 // Carlos Garcia Campos <carlo...@gnome.org> (c) 2010 // Tobias Koenig <tobias.koe...@kdab.com> (c) 2012 -// Albert Astals Cid <aa...@kde.org> (C) 2017 +// Albert Astals Cid <aa...@kde.org> (C) 2017, 2018 // // 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 @@ -371,7 +371,7 @@ void MediaRendition::outputToFile(FILE* fp) { } -MediaRendition* MediaRendition::copy() +MediaRendition* MediaRendition::copy() const { return new MediaRendition(*this); } diff --git a/poppler/Rendition.h b/poppler/Rendition.h index d84505ff..cfe57170 100644 --- a/poppler/Rendition.h +++ b/poppler/Rendition.h @@ -123,21 +123,21 @@ class MediaRendition { ~MediaRendition(); MediaRendition& operator=(const MediaRendition &) = delete; - GBool isOk () { return ok; } + GBool isOk () const { return ok; } - MediaParameters* getMHParameters() { return &MH; } - MediaParameters* getBEParameters() { return &BE; } + const MediaParameters* getMHParameters() const { return &MH; } + const MediaParameters* getBEParameters() const { return &BE; } - GooString* getContentType() { return contentType; } - GooString* getFileName() { return fileName; } + const GooString* getContentType() const { return contentType; } + const GooString* getFileName() const { return fileName; } - GBool getIsEmbedded() { return isEmbedded; } - Stream* getEmbbededStream() { return isEmbedded ? embeddedStreamObject.getStream() : nullptr; } - Object* getEmbbededStreamObject() { return isEmbedded ? &embeddedStreamObject : nullptr; } + GBool getIsEmbedded() const { return isEmbedded; } + Stream* getEmbbededStream() const { return isEmbedded ? embeddedStreamObject.getStream() : nullptr; } + const Object* getEmbbededStreamObject() const { return isEmbedded ? &embeddedStreamObject : nullptr; } // write embedded stream to file void outputToFile(FILE*); - MediaRendition* copy(); + MediaRendition* copy() const; private: GBool ok; diff --git a/poppler/Sound.cc b/poppler/Sound.cc index 4a59d3fe..aa2ac8f2 100644 --- a/poppler/Sound.cc +++ b/poppler/Sound.cc @@ -1,6 +1,6 @@ /* Sound.cc - an object that holds the sound structure * Copyright (C) 2006-2007, Pino Toscano <p...@kde.org> - * Copyright (C) 2009, 2017, Albert Astals Cid <aa...@kde.org> + * Copyright (C) 2009, 2017, 2018, Albert Astals Cid <aa...@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 @@ -47,7 +47,7 @@ Sound *Sound::parseSound(Object *obj) } } -Sound::Sound(Object *obj, bool readAttrs) +Sound::Sound(const Object *obj, bool readAttrs) { streamObj = obj->copy(); @@ -116,7 +116,7 @@ Stream *Sound::getStream() return streamObj.getStream(); } -Sound *Sound::copy() +Sound *Sound::copy() const { Sound *newsound = new Sound(&streamObj, false); diff --git a/poppler/Sound.h b/poppler/Sound.h index e88de4d6..ae8d0cee 100644 --- a/poppler/Sound.h +++ b/poppler/Sound.h @@ -50,21 +50,21 @@ public: Sound(const Sound &) = delete; Sound& operator=(const Sound &) = delete; - Object *getObject() { return &streamObj; } + const Object *getObject() const { return &streamObj; } Stream *getStream(); - SoundKind getSoundKind() { return kind; } - GooString *getFileName() { return fileName; } - double getSamplingRate() { return samplingRate; } - int getChannels() { return channels; } - int getBitsPerSample() { return bitsPerSample; } - SoundEncoding getEncoding() { return encoding; } + SoundKind getSoundKind() const { return kind; } + const GooString *getFileName() const { return fileName; } + double getSamplingRate() const { return samplingRate; } + int getChannels() const { return channels; } + int getBitsPerSample() const { return bitsPerSample; } + SoundEncoding getEncoding() const { return encoding; } - Sound *copy(); + Sound *copy() const; private: // Create a sound. The Object obj is ensured to be a Stream with a Dict - Sound(Object *obj, bool readAttrs = true); + Sound(const Object *obj, bool readAttrs = true); Object streamObj; SoundKind kind; diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 2d971358..102bd820 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -1,7 +1,7 @@ /* poppler-document.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. * Copyright (C) 2005, 2008, Brad Hards <br...@frogmouth.net> - * Copyright (C) 2005-2010, 2012, 2013, 2015, 2017, Albert Astals Cid <aa...@kde.org> + * Copyright (C) 2005-2010, 2012, 2013, 2015, 2017, 2018, Albert Astals Cid <aa...@kde.org> * Copyright (C) 2006-2010, Pino Toscano <p...@kde.org> * Copyright (C) 2010, 2011 Hib Eris <h...@hiberis.nl> * Copyright (C) 2012 Koji Otani <s...@bbr.jp> @@ -584,7 +584,7 @@ namespace Poppler { if ( !outline ) return nullptr; - GooList * items = outline->getItems(); + const GooList * items = outline->getItems(); if ( !items || items->getLength() < 1 ) return nullptr; diff --git a/qt5/src/poppler-embeddedfile.cc b/qt5/src/poppler-embeddedfile.cc index 02058b75..620b1b1b 100644 --- a/qt5/src/poppler-embeddedfile.cc +++ b/qt5/src/poppler-embeddedfile.cc @@ -1,5 +1,5 @@ /* poppler-document.cc: qt interface to poppler - * Copyright (C) 2005, 2008, 2009, 2012, 2013, Albert Astals Cid <aa...@kde.org> + * Copyright (C) 2005, 2008, 2009, 2012, 2013, 2018, Albert Astals Cid <aa...@kde.org> * Copyright (C) 2005, Brad Hards <br...@frogmouth.net> * Copyright (C) 2008, 2011, Pino Toscano <p...@kde.org> * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <i...@kdab.com>. Work sponsored by the LiMux project of the city of Munich @@ -69,13 +69,13 @@ EmbeddedFile::~EmbeddedFile() QString EmbeddedFile::name() const { - GooString *goo = m_embeddedFile->filespec->getFileName(); + const GooString *goo = m_embeddedFile->filespec->getFileName(); return goo ? UnicodeParsedString(goo) : QString(); } QString EmbeddedFile::description() const { - GooString *goo = m_embeddedFile->filespec->getDescription(); + const GooString *goo = m_embeddedFile->filespec->getDescription(); return goo ? UnicodeParsedString(goo) : QString(); } @@ -98,13 +98,13 @@ QDateTime EmbeddedFile::createDate() const QByteArray EmbeddedFile::checksum() const { - GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->checksum() : nullptr; + const GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->checksum() : nullptr; return goo ? QByteArray::fromRawData(goo->getCString(), goo->getLength()) : QByteArray(); } QString EmbeddedFile::mimeType() const { - GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->mimeType() : nullptr; + const GooString *goo = m_embeddedFile->embFile() ? m_embeddedFile->embFile()->mimeType() : nullptr; return goo ? QString(goo->getCString()) : QString(); } diff --git a/qt5/src/poppler-link.cc b/qt5/src/poppler-link.cc index 626040fb..ffa3e74d 100644 --- a/qt5/src/poppler-link.cc +++ b/qt5/src/poppler-link.cc @@ -1,5 +1,5 @@ /* poppler-link.cc: qt interface to poppler - * Copyright (C) 2006-2007, 2013, 2016, 2017, Albert Astals Cid + * Copyright (C) 2006-2007, 2013, 2016-2018, Albert Astals Cid * Copyright (C) 2007-2008, Pino Toscano <p...@kde.org> * Copyright (C) 2010 Hib Eris <h...@hiberis.nl> * Copyright (C) 2012, Tobias Koenig <to...@kdab.com> @@ -232,7 +232,7 @@ class LinkMoviePrivate : public LinkPrivate : d( new LinkDestinationPrivate ) { bool deleteDest = false; - LinkDest *ld = data.ld; + const LinkDest *ld = data.ld; if ( data.namedDest && !ld && !data.externalDest ) { diff --git a/qt5/src/poppler-media.cc b/qt5/src/poppler-media.cc index 8059153d..53765764 100644 --- a/qt5/src/poppler-media.cc +++ b/qt5/src/poppler-media.cc @@ -154,7 +154,7 @@ QSize MediaRendition::size() const { Q_D( const MediaRendition ); - MediaParameters *mp = nullptr; + const MediaParameters *mp = nullptr; if (d->rendition->getBEParameters()) mp = d->rendition->getBEParameters(); diff --git a/qt5/src/poppler-movie.cc b/qt5/src/poppler-movie.cc index cfa2182d..e37a5d6b 100644 --- a/qt5/src/poppler-movie.cc +++ b/qt5/src/poppler-movie.cc @@ -60,7 +60,7 @@ MovieObject::MovieObject( AnnotMovie *ann ) m_movieData->m_movieObj = ann->getMovie()->copy(); //TODO: copy poster image - MovieActivationParameters *mp = m_movieData->m_movieObj->getActivationParameters(); + const MovieActivationParameters *mp = m_movieData->m_movieObj->getActivationParameters(); int width, height; m_movieData->m_movieObj->getFloatingWindowSize(&width, &height); m_movieData->m_size = QSize(width, height); @@ -76,7 +76,7 @@ MovieObject::~MovieObject() QString MovieObject::url() const { - GooString * goo = m_movieData->m_movieObj->getFileName(); + const GooString * goo = m_movieData->m_movieObj->getFileName(); return goo ? QString( goo->getCString() ) : QString(); } diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc index 36b7d6da..18997b6e 100644 --- a/qt5/src/poppler-optcontent.cc +++ b/qt5/src/poppler-optcontent.cc @@ -3,7 +3,7 @@ * Copyright (C) 2007, Brad Hards <br...@kde.org> * Copyright (C) 2008, 2014, Pino Toscano <p...@kde.org> * Copyright (C) 2008, Carlos Garcia Campos <carlo...@gnome.org> - * Copyright (C) 2015-2017, Albert Astals Cid <aa...@kde.org> + * Copyright (C) 2015-2018, Albert Astals Cid <aa...@kde.org> * Copyright (C) 2017, Hubert Figuière <h...@figuiere.net> * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <i...@kdab.com>. Work sponsored by the LiMux project of the city of Munich * @@ -398,7 +398,7 @@ namespace Poppler QSet<OptContentItem *> changedItems; - GooList *statesList = popplerLinkOCGState->getStateList(); + const GooList *statesList = popplerLinkOCGState->getStateList(); for (int i = 0; i < statesList->getLength(); ++i) { ::LinkOCGState::StateList *stateList = (::LinkOCGState::StateList*)statesList->get(i); diff --git a/qt5/src/poppler-private.cc b/qt5/src/poppler-private.cc index 308343fe..78751f8e 100644 --- a/qt5/src/poppler-private.cc +++ b/qt5/src/poppler-private.cc @@ -1,6 +1,6 @@ /* poppler-private.cc: qt interface to poppler * Copyright (C) 2005, Net Integration Technologies, Inc. - * Copyright (C) 2006, 2011, 2015, 2017 by Albert Astals Cid <aa...@kde.org> + * Copyright (C) 2006, 2011, 2015, 2017, 2018 by Albert Astals Cid <aa...@kde.org> * Copyright (C) 2008, 2010, 2011, 2014 by Pino Toscano <p...@kde.org> * Copyright (C) 2013 by Thomas Freitag <thomas.frei...@alfa.de> * Copyright (C) 2013 Adrian Johnson <ajohn...@redneon.com> @@ -74,7 +74,7 @@ namespace Debug { (*Debug::debugFunction)(emsg, Debug::debugClosure); } - QString unicodeToQString(Unicode* u, int len) { + QString unicodeToQString(const Unicode* u, int len) { if (!utf8Map) { GooString enc("UTF-8"); @@ -163,7 +163,7 @@ namespace Debug { return QStringToUnicodeGooString(dt.toUTC().toString("yyyyMMddhhmmss+00'00'")); } - static void linkActionToTocItem( ::LinkAction * a, DocumentData * doc, QDomElement * e ) + static void linkActionToTocItem( const ::LinkAction * a, DocumentData * doc, QDomElement * e ) { if ( !a || !e ) return; @@ -173,8 +173,8 @@ namespace Debug { case actionGoTo: { // page number is contained/referenced in a LinkGoTo - LinkGoTo * g = static_cast< LinkGoTo * >( a ); - LinkDest * destination = g->getDest(); + const LinkGoTo * g = static_cast< const LinkGoTo * >( a ); + const LinkDest * destination = g->getDest(); if ( !destination && g->getNamedDest() ) { // no 'destination' but an internal 'named reference'. we could @@ -197,8 +197,8 @@ namespace Debug { case actionGoToR: { // page number is contained/referenced in a LinkGoToR - LinkGoToR * g = static_cast< LinkGoToR * >( a ); - LinkDest * destination = g->getDest(); + const LinkGoToR * g = static_cast< const LinkGoToR * >( a ); + const LinkDest * destination = g->getDest(); if ( !destination && g->getNamedDest() ) { // no 'destination' but an internal 'named reference'. we could @@ -221,7 +221,7 @@ namespace Debug { } case actionURI: { - LinkURI * u = static_cast< LinkURI * >( a ); + const LinkURI * u = static_cast< const LinkURI * >( a ); e->setAttribute( QStringLiteral("DestinationURI"), u->getURI()->getCString() ); } default: ; @@ -259,7 +259,7 @@ namespace Debug { } - void DocumentData::addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items ) + void DocumentData::addTocChildren( QDomDocument * docSyn, QDomNode * parent, const GooList * items ) { int numItems = items->getLength(); for ( int i = 0; i < numItems; ++i ) @@ -269,7 +269,7 @@ namespace Debug { // 1. create element using outlineItem's title as tagName QString name; - Unicode * uniChar = outlineItem->getTitle(); + const Unicode * uniChar = outlineItem->getTitle(); int titleLength = outlineItem->getTitleLength(); name = unicodeToQString(uniChar, titleLength); if ( name.isEmpty() ) @@ -279,14 +279,14 @@ namespace Debug { parent->appendChild( item ); // 2. find the page the link refers to - ::LinkAction * a = outlineItem->getAction(); + const ::LinkAction * a = outlineItem->getAction(); linkActionToTocItem( a, this, &item ); item.setAttribute( QStringLiteral("Open"), QVariant( (bool)outlineItem->isOpen() ).toString() ); // 3. recursively descend over children outlineItem->open(); - GooList * children = outlineItem->getKids(); + const GooList * children = outlineItem->getKids(); if ( children ) addTocChildren( docSyn, &item, children ); } diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index d37393a2..52715179 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -58,7 +58,7 @@ class FormWidget; namespace Poppler { /* borrowed from kpdf */ - QString unicodeToQString(Unicode* u, int len); + QString unicodeToQString(const Unicode* u, int len); QString UnicodeParsedString(const GooString *s1); @@ -73,12 +73,12 @@ namespace Poppler { class LinkDestinationData { public: - LinkDestinationData( LinkDest *l, const GooString *nd, Poppler::DocumentData *pdfdoc, bool external ) + LinkDestinationData( const LinkDest *l, const GooString *nd, Poppler::DocumentData *pdfdoc, bool external ) : ld(l), namedDest(nd), doc(pdfdoc), externalDest(external) { } - LinkDest *ld; + const LinkDest *ld; const GooString *namedDest; Poppler::DocumentData *doc; bool externalDest; @@ -119,7 +119,7 @@ namespace Poppler { DocumentData(const DocumentData &) = delete; DocumentData& operator=(const DocumentData &) = delete; - void addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items ); + void addTocChildren( QDomDocument * docSyn, QDomNode * parent, const GooList * items ); void setPaperColor(const QColor &color) { diff --git a/qt5/src/poppler-sound.cc b/qt5/src/poppler-sound.cc index 5e4a0e59..2abdab22 100644 --- a/qt5/src/poppler-sound.cc +++ b/qt5/src/poppler-sound.cc @@ -78,7 +78,7 @@ QString SoundObject::url() const if ( m_soundData->m_type != SoundObject::External ) return QString(); - GooString * goo = m_soundData->m_soundObj->getFileName(); + const GooString * goo = m_soundData->m_soundObj->getFileName(); return goo ? QString( goo->getCString() ) : QString(); } diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index efb584b5..250909b3 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -17,7 +17,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2007, 2010, 2012 Albert Astals Cid <aa...@kde.org> +// Copyright (C) 2007, 2010, 2012, 2018 Albert Astals Cid <aa...@kde.org> // Copyright (C) 2008 Boris Toloknov <tl...@yandex.ru> // Copyright (C) 2008 Tomas Are Haavet <tomas...@gmail.com> // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (lee...@cdacmumbai.in) and Onkar Potdar (on...@cdacmumbai.in) @@ -242,7 +242,7 @@ GooString* HtmlFont::getDefaultFont(){ } // this method if plain wrong todo -GooString* HtmlFont::HtmlFilter(Unicode* u, int uLen) { +GooString* HtmlFont::HtmlFilter(const Unicode* u, int uLen) { GooString *tmp = new GooString(); UnicodeMap *uMap; char buf[8]; diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index 83fea95a..ba4f42ae 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -91,7 +91,7 @@ public: GooString* getFontName(); static GooString* getDefaultFont(); static void setDefaultFont(GooString* defaultFont); - static GooString* HtmlFilter(Unicode* u, int uLen); //char* s); + static GooString* HtmlFilter(const Unicode* u, int uLen); //char* s); GBool isEqual(const HtmlFont& x) const; GBool isEqualIgnoreBold(const HtmlFont& x) const; static GooString* simple(HtmlFont *font, Unicode *content, int uLen); diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index f4d17c65..ace303b3 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -1706,7 +1706,7 @@ GBool HtmlOutputDev::dumpDocOutline(PDFDoc* doc) if (!outline) return gFalse; - GooList *outlines = outline->getItems(); + const GooList *outlines = outline->getItems(); if (!outlines) return gFalse; @@ -1764,7 +1764,7 @@ GBool HtmlOutputDev::dumpDocOutline(PDFDoc* doc) #endif } -GBool HtmlOutputDev::newHtmlOutlineLevel(FILE *output, GooList *outlines, int level) +GBool HtmlOutputDev::newHtmlOutlineLevel(FILE *output, const GooList *outlines, int level) { #ifdef DISABLE_OUTLINE return gFalse; @@ -1836,7 +1836,7 @@ GBool HtmlOutputDev::newHtmlOutlineLevel(FILE *output, GooList *outlines, int le #endif } -void HtmlOutputDev::newXmlOutlineLevel(FILE *output, GooList *outlines) +void HtmlOutputDev::newXmlOutlineLevel(FILE *output, const GooList *outlines) { #ifndef DISABLE_OUTLINE fputs("<outline>\n", output); @@ -1873,15 +1873,15 @@ void HtmlOutputDev::newXmlOutlineLevel(FILE *output, GooList *outlines) #ifndef DISABLE_OUTLINE int HtmlOutputDev::getOutlinePageNum(OutlineItem *item) { - LinkAction *action = item->getAction(); - LinkGoTo *link = nullptr; + const LinkAction *action = item->getAction(); + const LinkGoTo *link = nullptr; LinkDest *linkdest = nullptr; int pagenum = -1; if (!action || action->getKind() != actionGoTo) return pagenum; - link = dynamic_cast<LinkGoTo*>(action); + link = dynamic_cast<const LinkGoTo*>(action); if (!link || !link->isOk()) return pagenum; diff --git a/utils/HtmlOutputDev.h b/utils/HtmlOutputDev.h index b47e40f9..ec552012 100644 --- a/utils/HtmlOutputDev.h +++ b/utils/HtmlOutputDev.h @@ -331,8 +331,8 @@ private: GooString* getLinkDest(AnnotLink *link); void dumpMetaVars(FILE *); void doFrame(int firstPage); - GBool newHtmlOutlineLevel(FILE *output, GooList *outlines, int level = 1); - void newXmlOutlineLevel(FILE *output, GooList *outlines); + GBool newHtmlOutlineLevel(FILE *output, const GooList *outlines, int level = 1); + void newXmlOutlineLevel(FILE *output, const GooList *outlines); #ifndef DISABLE_OUTLINE int getOutlinePageNum(OutlineItem *item); #endif diff --git a/utils/pdfdetach.cc b/utils/pdfdetach.cc index 25fcaae2..bd20df2e 100644 --- a/utils/pdfdetach.cc +++ b/utils/pdfdetach.cc @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) { Page *page; Annots *annots; Annot *annot; - GooString *s1; + const GooString *s1; Unicode u; GBool isUnicode; _______________________________________________ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler