From: Kouhei S. <nu...@co...> - 2017-08-06 15:50:32
|
Kouhei Sutou 2017-08-07 00:49:57 +0900 (Mon, 07 Aug 2017) New Revision: 1ed48cb7cf623d6ae57e2b06e4528bbe2dc44a9b https://github.com/ruby-gnome2/ruby-gnome2/commit/1ed48cb7cf623d6ae57e2b06e4528bbe2dc44a9b Message: poppler: support Document#index_iter Added files: poppler/lib/poppler/index-iter.rb Modified files: poppler/lib/poppler/deprecated.rb poppler/lib/poppler/document.rb poppler/lib/poppler/loader.rb Modified: poppler/lib/poppler/deprecated.rb (+5 -0) =================================================================== --- poppler/lib/poppler/deprecated.rb 2017-08-07 00:15:45 +0900 (775af567b) +++ poppler/lib/poppler/deprecated.rb 2017-08-07 00:49:57 +0900 (b1aba337d) @@ -36,6 +36,11 @@ module Poppler define_deprecated_const(:AnnotationMapping, "Poppler::AnnotMapping") + define_deprecated_const(:ActionURI, + "Poppler::ActionUri") + define_deprecated_const(:ActionJavaScript, + "Poppler::ActionJavascript") + class AnnotMapping extend GLib::Deprecatable Modified: poppler/lib/poppler/document.rb (+4 -0) =================================================================== --- poppler/lib/poppler/document.rb 2017-08-07 00:15:45 +0900 (6418483af) +++ poppler/lib/poppler/document.rb 2017-08-07 00:49:57 +0900 (58b29692f) @@ -86,6 +86,10 @@ module Poppler save_a_copy_raw(ensure_uri(uri)) end + def index_iter + IndexIter.new(self) + end + private def pdf_data?(data) data.start_with?("%PDF-1.") Added: poppler/lib/poppler/index-iter.rb (+30 -0) 100644 =================================================================== --- /dev/null +++ poppler/lib/poppler/index-iter.rb 2017-08-07 00:49:57 +0900 (a3892f681) @@ -0,0 +1,30 @@ +# Copyright (C) 2017 Ruby-GNOME2 Project Team +# +# 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.1 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 + +module Poppler + class IndexIter + include Enumerable + + def each + return to_enum(__method__) unless block_given? + + loop do + yield(self) + break unless self.next + end + end + end +end Modified: poppler/lib/poppler/loader.rb (+31 -0) =================================================================== --- poppler/lib/poppler/loader.rb 2017-08-07 00:15:45 +0900 (798ec8f31) +++ poppler/lib/poppler/loader.rb 2017-08-07 00:49:57 +0900 (ae5cd7839) @@ -23,6 +23,7 @@ module Poppler def post_load(repository, namespace) require_libraries + convert_action_classes convert_field_classes end @@ -33,6 +34,7 @@ module Poppler require "poppler/cairo" require "poppler/color" require "poppler/document" + require "poppler/index-iter" require "poppler/page" require "poppler/rectangle" @@ -80,6 +82,35 @@ module Poppler super(info, klass, method_name) end + def define_struct(info, options={}) + case info.name + when /\AAction.+/ + options[:parent] = Action + end + super(info, options) + end + + def convert_action_classes + unknown_class = Class.new(Action) + @base_module.const_set("ActionUnknown", unknown_class) + + action_map = { + ActionType::UNKNOWN => unknown_class, + ActionType::GOTO_DEST => ActionGotoDest, + ActionType::GOTO_REMOTE => ActionGotoRemote, + ActionType::LAUNCH => ActionLaunch, + ActionType::URI => ActionUri, + ActionType::NAMED => ActionNamed, + ActionType::MOVIE => ActionMovie, + ActionType::RENDITION => ActionRendition, + ActionType::OCG_STATE => ActionOCGState, + ActionType::JAVASCRIPT => ActionJavascript, + } + self.class.register_boxed_class_converter(Action.gtype) do |action| + action_map[action.type] || Action + end + end + def define_field_class(name) klass = @form_field_classes[name] return klass if klass |