From 71a8df2900da253cfcb87517c60b7336d2fdaba5 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Mon, 17 Dec 2012 21:14:42 -0600 Subject: Add methods corresponding to new poppler-glib methods added since poppler 0.20.5. --- .../extradefs/generate_extra_defs_poppler-glib.cc | 1 + codegen/m4/convert_poppler-glib.m4 | 1 + configure.ac | 2 +- poppler-glib/src/annot.hg | 1 + poppler-glib/src/document.ccg | 26 +++ poppler-glib/src/document.hg | 31 +++- poppler-glib/src/page.hg | 3 + poppler-glib/src/poppler-glib_docs.xml | 176 ++++++++++++++++++++- poppler-glib/src/poppler-glib_docs_override.xml | 60 +++++-- poppler-glib/src/poppler-glib_enum.defs | 20 +++ poppler-glib/src/poppler-glib_method.defs | 68 ++++++++ 11 files changed, 368 insertions(+), 21 deletions(-) diff --git a/codegen/extradefs/generate_extra_defs_poppler-glib.cc b/codegen/extradefs/generate_extra_defs_poppler-glib.cc index 154d0f6..413c24a 100644 --- a/codegen/extradefs/generate_extra_defs_poppler-glib.cc +++ b/codegen/extradefs/generate_extra_defs_poppler-glib.cc @@ -51,6 +51,7 @@ int main(int, char**) << get_defs(POPPLER_TYPE_DEST_TYPE) << get_defs(POPPLER_TYPE_DOCUMENT) << get_defs(POPPLER_TYPE_ERROR) + << get_defs(POPPLER_TYPE_FIND_FLAGS) << get_defs(POPPLER_TYPE_FONTS_ITER) << get_defs(POPPLER_TYPE_FONT_INFO) << get_defs(POPPLER_TYPE_FONT_TYPE) diff --git a/codegen/m4/convert_poppler-glib.m4 b/codegen/m4/convert_poppler-glib.m4 index 4068d15..a4b2318 100644 --- a/codegen/m4/convert_poppler-glib.m4 +++ b/codegen/m4/convert_poppler-glib.m4 @@ -12,6 +12,7 @@ _CONV_ENUM(Poppler,AnnotTextState) _CONV_ENUM(Poppler,AnnotType) _CONV_ENUM(Poppler,Backend) _CONV_ENUM(Poppler,DestType) +_CONV_ENUM(Poppler,FindFlags) _CONV_ENUM(Poppler,FontType) _CONV_ENUM(Poppler,FormButtonType) _CONV_ENUM(Poppler,FormChoiceType) diff --git a/configure.ac b/configure.ac index e594468..ec20230 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL -AC_SUBST([POPPLER_GLIBMM_MODULES], ['poppler-glib >= 0.20 glibmm-2.4 >= 2.16 cairomm-1.0 >= 1.10']) +AC_SUBST([POPPLER_GLIBMM_MODULES], ['poppler-glib >= 0.20 glibmm-2.4 >= 2.16 cairomm-1.0 >= 1.10 giomm-2.4 >= 2.16']) PKG_CHECK_MODULES([POPPLER_GLIBMM], [$POPPLER_GLIBMM_MODULES]) # This is only needed for the demos diff --git a/poppler-glib/src/annot.hg b/poppler-glib/src/annot.hg index fb62f61..161c7db 100644 --- a/poppler-glib/src/annot.hg +++ b/poppler-glib/src/annot.hg @@ -52,6 +52,7 @@ class Annot : public Glib::Object public: _WRAP_METHOD(AnnotType get_annot_type() const, poppler_annot_get_annot_type) _WRAP_METHOD(AnnotFlag get_flags() const, poppler_annot_get_flags) + _WRAP_METHOD(void set_flags(AnnotFlag flags) const, poppler_annot_set_flags) _WRAP_METHOD(Glib::ustring get_name() const, poppler_annot_get_name) _WRAP_METHOD(int get_page_index() const, poppler_annot_get_page_index) _WRAP_METHOD(Color get_color() const, poppler_annot_get_color) diff --git a/poppler-glib/src/document.ccg b/poppler-glib/src/document.ccg index 1000b35..ad64334 100644 --- a/poppler-glib/src/document.ccg +++ b/poppler-glib/src/document.ccg @@ -36,6 +36,32 @@ Glib::RefPtr Document::new_from_data(const std::string& data, const st return retvalue; } +Glib::RefPtr Document::new_from_stream(const Glib::RefPtr& stream, + const goffset length, const std::string& password, + const Glib::RefPtr& cancellable) +{ + GError* gerror = 0; + Glib::RefPtr retvalue = Glib::wrap(poppler_document_new_from_stream(stream->gobj(), + length, password.c_str(), cancellable ? cancellable->gobj() : NULL, &gerror)); + if(gerror) + ::Glib::Error::throw_exception(gerror); + + return retvalue; +} + +static Glib::RefPtr new_from_gio_file(const Glib::RefPtr& file, + const std::string& password, + const Glib::RefPtr& cancellable) +{ + GError* gerror = 0; + Glib::RefPtr retvalue = Glib::wrap(poppler_document_new_from_gfile(file->gobj(), + password.c_str(), cancellable ? cancellable->gobj() : NULL, &gerror)); + if(gerror) + ::Glib::Error::throw_exception(gerror); + + return retvalue; +} + bool Document::get_id(Glib::ustring& permanent_id, Glib::ustring& update_id) const { Glib::ScopedPtr permanent_id_array, update_id_array; diff --git a/poppler-glib/src/document.hg b/poppler-glib/src/document.hg index 594811e..a26ce54 100644 --- a/poppler-glib/src/document.hg +++ b/poppler-glib/src/document.hg @@ -21,6 +21,8 @@ _CONFIGINCLUDE(poppler-glibmmconfig.h) _PINCLUDE(glibmm/private/object_p.h) #include +#include +#include #include #include #include @@ -67,7 +69,34 @@ public: */ static Glib::RefPtr new_from_data(const std::string& data, const std::string& password = ""); - /** Saves document. Any change made in the document such as form fields + /** Creates a new Poppler::Document reading the PDF contents from @a stream. + * Note that the given Gio::InputStream must be seekable or + * Gio::IO_ERROR_NOT_SUPPORTED will be thrown. + * If 0 is returned, then an exception will be thrown. + * @param stream A Gio::InputStream to read from. + * @param length The stream length, or -1 if not known. + * @param password Password to unlock the file with. + * @param cancellable A Gio::Cancellable, or 0. + * @return A new Poppler::Document, or 0. + * @throws Poppler::Error, Glib::FileError, and Gio::Error + */ + static Glib::RefPtr new_from_stream(const Glib::RefPtr& stream, + const goffset length = -1, const std::string& password = "", + const Glib::RefPtr& cancellable = Glib::RefPtr()); + + /** Creates a new Poppler::Document reading the PDF contents from @a file. + * If 0 is returned, then an exception will be thrown. + * @param file A Gio::File to load. + * @param password Password to unlock the file with. + * @param cancellable A Gio::Cancellable, or 0. + * @return A new Poppler::Document, or 0. + * @throws Poppler::Error and Glib::FileError + */ + static Glib::RefPtr new_from_gio_file(const Glib::RefPtr& file, + const std::string& password = "", + const Glib::RefPtr& cancellable = Glib::RefPtr()); + + /** Saves document. Any change made in the document such as form fields * filled, annotations added or modified will be saved. * If an error occurs, false will be returned. * @param uri Uri of file to save. diff --git a/poppler-glib/src/page.hg b/poppler-glib/src/page.hg index 554b467..c2d4408 100644 --- a/poppler-glib/src/page.hg +++ b/poppler-glib/src/page.hg @@ -39,6 +39,7 @@ class Annot; _WRAP_ENUM(PrintFlags, PopplerPrintFlags) _WRAP_ENUM(SelectionStyle, PopplerSelectionStyle) +_WRAP_ENUM(FindFlags, PopplerFindFlags) /** Poppler::Page is a class that provides access to information about a page * in a document @@ -83,6 +84,7 @@ public: #m4 _CONVERSION(`GList*',`std::vector', #m4 `Glib::ListHandler::list_to_vector($3, Glib::OWNERSHIP_DEEP)') _WRAP_METHOD(std::vector find_text(const Glib::ustring& text) const, poppler_page_find_text) + _WRAP_METHOD(std::vector find_text_with_options(const Glib::ustring& text, FindFlags options) const, poppler_page_find_text_with_options) _WRAP_METHOD(Glib::ustring get_text() const, poppler_page_get_text) @@ -118,6 +120,7 @@ public: _IGNORE(poppler_page_free_annot_mapping) _WRAP_METHOD(void add_annot(const Glib::RefPtr& annot) const, poppler_page_add_annot) + _WRAP_METHOD(void remove_annot(const Glib::RefPtr& annot) const, poppler_page_remove_annot) _WRAP_PROPERTY("label", Glib::ustring) }; diff --git a/poppler-glib/src/poppler-glib_docs.xml b/poppler-glib/src/poppler-glib_docs.xml index 9ddb0a7..c773cc7 100644 --- a/poppler-glib/src/poppler-glib_docs.xml +++ b/poppler-glib/src/poppler-glib_docs.xml @@ -629,6 +629,26 @@ replacing the current contents. + + +Sets the flag field specifying various characteristics of the +@poppler_annot. + + + + + + a #PopplerAnnot + + + + a #PopplerAnnotFlag + + + + + + Gets name of the icon of @poppler_annot. @@ -1441,6 +1461,74 @@ domains. + + +Creates a new #PopplerDocument reading the PDF contents from @file. +Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR +domains. + + + + + + a #GFile to load + + + + password to unlock the file with, or %NULL + + + + a #GCancellable, or %NULL + + + + Return location for an error, or %NULL + + + + a new #PopplerDocument, or %NULL + + + + + + +Creates a new #PopplerDocument reading the PDF contents from @stream. +Note that the given #GInputStream must be seekable or %G_IO_ERROR_NOT_SUPPORTED +will be returned. +Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR +domains. + + + + + + a #GInputStream to read from + + + + the stream length, or -1 if not known + + + + password to unlock the file with, or %NULL + + + + a #GCancellable, or %NULL + + + + Return location for an error, or %NULL + + + + a new #PopplerDocument, or %NULL + + + + Saves @document. Any change made in the document such as @@ -1584,6 +1672,23 @@ Frees the given #PopplerFontsIter + + +Returns the encoding of the font associated with @iter + + + + + + a #PopplerFontsIter + + + + the font encoding + + + + The filename of the font associated with @iter or %NULL if @@ -1597,7 +1702,7 @@ the font is embedded - the filename of the font or %NULL y font is emebedded + the filename of the font or %NULL if font is embedded @@ -1649,6 +1754,24 @@ Returns the name of the font associated with @iter + + +The name of the substitute font of the font associated with @iter or %NULL if +the font is embedded + + + + + + a #PopplerFontsIter + + + + the name of the substitute font or %NULL if font is embedded + + + + Returns whether the font associated with @iter is embedded in the document @@ -2913,7 +3036,30 @@ Adds annotation @annot to @page. -A #GList of rectangles for each occurance of the text on the page. +Finds @text in @page with the default options (%POPPLER_FIND_DEFAULT) and +returns a #GList of rectangles for each occurance of the text on the page. +The coordinates are in PDF points. + + + + + + a #PopplerPage + + + + the text to search for (UTF-8 encoded) + + + + a #GList of #PopplerRectangle, + + + + + +Finds @text in @page with the given #PopplerFindFlags options and +returns a #GList of rectangles for each occurance of the text on the page. The coordinates are in PDF points. @@ -2927,8 +3073,13 @@ The coordinates are in PDF points. the text to search for (UTF-8 encoded) + + find options + + a #GList of #PopplerRectangle, + @@ -3099,7 +3250,7 @@ Returns a cairo surface for the image of the @page - The image identificator + The image identifier @@ -3419,6 +3570,25 @@ Returns the transition effect of @page + + +Removes annotation @annot from @page + + + + + + a #PopplerPage + + + + a #PopplerAnnot to remove + + + + + + Render the page to the given cairo context. This function diff --git a/poppler-glib/src/poppler-glib_docs_override.xml b/poppler-glib/src/poppler-glib_docs_override.xml index 3cb2ddf..0e9630f 100644 --- a/poppler-glib/src/poppler-glib_docs_override.xml +++ b/poppler-glib/src/poppler-glib_docs_override.xml @@ -325,6 +325,23 @@ Retrieves the flag field specifying various characteristics of the annotation. + + +Sets the flag field specifying various characteristics of the annotation. + + + + a #PopplerAnnot + + + + a #PopplerAnnotFlag + + + + + + Retrieves the name of the annotation. @@ -522,7 +539,8 @@ Returns a region containing the area that would be rendered by render_selection( -Obtaines a vector of rectangles for each occurance of the text on the page. +Finds @text in @page with the default options (%POPPLER_FIND_DEFAULT) and +returns a vector of rectangles for each occurance of the text on the page. The coordinates are in PDF points. @@ -535,7 +553,31 @@ The coordinates are in PDF points. - Returns a vector of #PopplerRectangle + A vector of #PopplerRectangle + + + + + +Finds @text in @page with the given #PopplerFindFlags options and +returns a vector of rectangles for each occurance of the text on the page. +The coordinates are in PDF points. + + + + a #PopplerPage + + + + the text to search for (UTF-8 encoded) + + + + find options + + + + A vector of #PopplerRectangle, @@ -766,18 +808,4 @@ Retrieves the action (#PopplerAction) that shall be performed when the annotatio - - -The filename of the font associated with the iter or %NULL if the font is embedded - - - - a #PopplerFontsIter - - - - The filename of the font or %NULL if the font is emebedded - - - diff --git a/poppler-glib/src/poppler-glib_enum.defs b/poppler-glib/src/poppler-glib_enum.defs index 139817b..b5685f7 100644 --- a/poppler-glib/src/poppler-glib_enum.defs +++ b/poppler-glib/src/poppler-glib_enum.defs @@ -657,6 +657,26 @@ ) ) +;; Original typedef: +;; typedef enum /*< flags >*/ +;; { +;; POPPLER_FIND_DEFAULT = 0, +;; POPPLER_FIND_CASE_SENSITIVE = 1 << 0, +;; POPPLER_FIND_BACKWARDS = 1 << 1, +;; POPPLER_FIND_WHOLE_WORDS_ONLY = 1 << 2 +;; } PopplerFindFlags; + +(define-flags-extended FindFlags + (in-module "Poppler") + (c-name "PopplerFindFlags") + (values + '("default" "POPPLER_FIND_DEFAULT" "0x0") + '("case-sensitive" "POPPLER_FIND_CASE_SENSITIVE" "1 << 0") + '("backwards" "POPPLER_FIND_BACKWARDS" "1 << 1") + '("whole-words-only" "POPPLER_FIND_WHOLE_WORDS_ONLY" "1 << 2") + ) +) + ;; Original typedef: ;; typedef enum ;; { diff --git a/poppler-glib/src/poppler-glib_method.defs b/poppler-glib/src/poppler-glib_method.defs index 5add90c..ccd959c 100644 --- a/poppler-glib/src/poppler-glib_method.defs +++ b/poppler-glib/src/poppler-glib_method.defs @@ -392,6 +392,18 @@ ) ) +(define-flags FindFlags + (in-module "Poppler") + (c-name "PopplerFindFlags") + (gtype-id "POPPLER_TYPE_FIND_FLAGS") + (values + '("default" "POPPLER_FIND_DEFAULT") + '("case-sensitive" "POPPLER_FIND_CASE_SENSITIVE") + '("backwards" "POPPLER_FIND_BACKWARDS") + '("whole-words-only" "POPPLER_FIND_WHOLE_WORDS_ONLY") + ) +) + (define-enum Backend (in-module "Poppler") (c-name "PopplerBackend") @@ -488,6 +500,15 @@ (return-type "PopplerAnnotFlag") ) +(define-method set_flags + (of-object "PopplerAnnot") + (c-name "poppler_annot_set_flags") + (return-type "none") + (parameters + '("PopplerAnnotFlag" "flags") + ) +) + (define-method get_color (of-object "PopplerAnnot") (c-name "poppler_annot_get_color") @@ -816,6 +837,29 @@ ) ) +(define-function poppler_document_new_from_stream + (c-name "poppler_document_new_from_stream") + (return-type "PopplerDocument*") + (parameters + '("GInputStream*" "stream") + '("goffset" "length") + '("const-char*" "password") + '("GCancellable*" "cancellable") + '("GError**" "error") + ) +) + +(define-function poppler_document_new_from_gfile + (c-name "poppler_document_new_from_gfile") + (return-type "PopplerDocument*") + (parameters + '("GFile*" "file") + '("const-char*" "password") + '("GCancellable*" "cancellable") + '("GError**" "error") + ) +) + (define-method save (of-object "PopplerDocument") (c-name "poppler_document_save") @@ -1377,6 +1421,11 @@ (return-type "GType") ) +(define-function poppler_find_flags_get_type + (c-name "poppler_find_flags_get_type") + (return-type "GType") +) + (define-function poppler_backend_get_type (c-name "poppler_backend_get_type") (return-type "GType") @@ -1843,6 +1892,16 @@ ) ) +(define-method find_text_with_options + (of-object "PopplerPage") + (c-name "poppler_page_find_text_with_options") + (return-type "GList*") + (parameters + '("const-char*" "text") + '("PopplerFindFlags" "options") + ) +) + (define-method find_text (of-object "PopplerPage") (c-name "poppler_page_find_text") @@ -1981,6 +2040,15 @@ ) ) +(define-method remove_annot + (of-object "PopplerPage") + (c-name "poppler_page_remove_annot") + (return-type "none") + (parameters + '("PopplerAnnot*" "annot") + ) +) + (define-method get_crop_box (of-object "PopplerPage") (c-name "poppler_page_get_crop_box") -- cgit v1.2.3