From: Kouhei S. <nu...@co...> - 2017-08-06 16:03:27
|
Kouhei Sutou 2017-08-07 01:02:41 +0900 (Mon, 07 Aug 2017) New Revision: ee41666579643d9a83144d4f31b2b28944474015 https://github.com/ruby-gnome2/ruby-gnome2/commit/ee41666579643d9a83144d4f31b2b28944474015 Message: poppler: support ImageMapping#image Added files: poppler/test/fixtures/image.odt Copied files: poppler/lib/poppler/image-mapping.rb (from poppler/lib/poppler/page.rb) Removed files: poppler/test/fixtures/image.png Modified files: poppler/lib/poppler/loader.rb poppler/lib/poppler/page.rb poppler/test/fixtures/image.pdf poppler/test/test-page.rb Copied: poppler/lib/poppler/image-mapping.rb (+5 -9) 80% =================================================================== --- poppler/lib/poppler/page.rb 2017-08-07 00:51:18 +0900 (158d4a902) +++ poppler/lib/poppler/image-mapping.rb 2017-08-07 01:02:41 +0900 (b877e724f) @@ -15,15 +15,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA module Poppler - class Page - alias_method :text_layout_raw, :text_layout - def text_layout - success, rectangles = text_layout_raw - if success - rectangles - else - nil - end + class ImageMapping + attr_accessor :page + + def image + @page.get_image(image_id) end end end Modified: poppler/lib/poppler/loader.rb (+1 -0) =================================================================== --- poppler/lib/poppler/loader.rb 2017-08-07 00:51:18 +0900 (ae5cd7839) +++ poppler/lib/poppler/loader.rb 2017-08-07 01:02:41 +0900 (d7ded8625) @@ -34,6 +34,7 @@ module Poppler require "poppler/cairo" require "poppler/color" require "poppler/document" + require "poppler/image-mapping" require "poppler/index-iter" require "poppler/page" require "poppler/rectangle" Modified: poppler/lib/poppler/page.rb (+9 -0) =================================================================== --- poppler/lib/poppler/page.rb 2017-08-07 00:51:18 +0900 (158d4a902) +++ poppler/lib/poppler/page.rb 2017-08-07 01:02:41 +0900 (60059c7ae) @@ -25,5 +25,14 @@ module Poppler nil end end + + alias_method :image_mapping_raw, :image_mapping + def image_mapping + mappings = image_mapping_raw + mappings.each do |mapping| + mapping.page = self + end + mappings + end end end Added: poppler/test/fixtures/image.odt (+0 -0) 100644 =================================================================== (Binary files differ) Modified: poppler/test/fixtures/image.pdf (+0 -0) =================================================================== (Binary files differ) Deleted: poppler/test/fixtures/image.png (+0 -0) 100644 =================================================================== (Binary files differ) Modified: poppler/test/test-page.rb (+16 -1) =================================================================== --- poppler/test/test-page.rb 2017-08-07 00:51:18 +0900 (220ceb6b1) +++ poppler/test/test-page.rb 2017-08-07 01:02:41 +0900 (cf545def7) @@ -1,6 +1,21 @@ +# Copyright (C) 2008-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 + class TestPage < Test::Unit::TestCase def test_get_image - omit("We don't have PDF that has image...") document = Poppler::Document.new(image_pdf) page, mapping = find_first_image_mapping(document) assert_kind_of(Cairo::ImageSurface, page.get_image(mapping.image_id)) |