thinreports 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -6
- data/.travis.yml +4 -10
- data/CHANGELOG.md +220 -0
- data/Gemfile +3 -3
- data/MIT-LICENSE +1 -1
- data/README.md +286 -0
- data/Rakefile +38 -8
- data/examples/character_spacing/character_spacing.rb +8 -0
- data/examples/character_spacing/character_spacing.tlf +1 -0
- data/examples/dynamic_image/dynamic_image.rb +31 -0
- data/examples/dynamic_image/dynamic_image.tlf +1 -0
- data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
- data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +150 -0
- data/examples/dynamic_style/dynamic_style.tlf +1 -0
- data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/{test/case → examples}/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +20 -0
- data/examples/eudc/eudc.tlf +1 -0
- data/{test/case → examples}/eudc/eudc.ttf +0 -0
- data/{test/case → examples}/helper.rb +14 -12
- data/examples/hidden_shapes/hidden_shapes.rb +9 -0
- data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
- data/examples/list_events/list_events.rb +59 -0
- data/examples/list_events/list_events_0_7_7.tlf +1 -0
- data/examples/list_events/list_events_0_8.tlf +1 -0
- data/{test/case → examples}/list_manual_generation/list_manual_generation.rb +4 -4
- data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
- data/{test/case → examples}/list_page_number/list_page_number.rb +3 -3
- data/examples/list_page_number/list_page_number.tlf +1 -0
- data/examples/page_number/page_number.rb +33 -0
- data/examples/page_number/page_number.tlf +1 -0
- data/examples/password_setting/password_setting.rb +10 -0
- data/examples/password_setting/password_setting.tlf +1 -0
- data/examples/report_callbacks/report_callbacks.rb +31 -0
- data/examples/report_callbacks/report_callbacks.tlf +1 -0
- data/{test/case → examples}/single_line_tblock/single_line_tblock.rb +2 -2
- data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
- data/examples/tblock_overflow/tblock_overflow.rb +20 -0
- data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
- data/examples/tblock_styles/font_size.tlf +1 -0
- data/examples/tblock_styles/tblock_styles.rb +43 -0
- data/examples/tblock_styles/tblock_styles.tlf +1 -0
- data/examples/text_align/text_align.rb +8 -0
- data/examples/text_align/text_align.tlf +1 -0
- data/examples/typeB_page_size/B4_ISO.tlf +1 -0
- data/examples/typeB_page_size/B4_JIS.tlf +1 -0
- data/{test/case → examples}/typeB_page_size/typeB_page_size.rb +3 -3
- data/examples/word_wrap/word_wrap.rb +26 -0
- data/examples/word_wrap/word_wrap.tlf +1 -0
- data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
- data/{resources/fonts → fonts}/ipag.ttf +0 -0
- data/{resources/fonts → fonts}/ipagp.ttf +0 -0
- data/{resources/fonts → fonts}/ipam.ttf +0 -0
- data/{resources/fonts → fonts}/ipamp.ttf +0 -0
- data/lib/thinreports.rb +14 -2
- data/lib/thinreports/config.rb +30 -10
- data/lib/thinreports/core/errors.rb +23 -20
- data/lib/thinreports/core/events.rb +18 -19
- data/lib/thinreports/core/format/base.rb +20 -20
- data/lib/thinreports/core/format/builder.rb +14 -22
- data/lib/thinreports/core/shape.rb +9 -13
- data/lib/thinreports/core/shape/base.rb +4 -5
- data/lib/thinreports/core/shape/base/interface.rb +15 -15
- data/lib/thinreports/core/shape/base/internal.rb +15 -20
- data/lib/thinreports/core/shape/basic.rb +1 -1
- data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
- data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
- data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
- data/lib/thinreports/core/shape/basic/format.rb +11 -10
- data/lib/thinreports/core/shape/basic/interface.rb +3 -3
- data/lib/thinreports/core/shape/basic/internal.rb +4 -5
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/image_block/format.rb +5 -6
- data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
- data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/list/configuration.rb +30 -15
- data/lib/thinreports/core/shape/list/events.rb +11 -11
- data/lib/thinreports/core/shape/list/format.rb +27 -28
- data/lib/thinreports/core/shape/list/manager.rb +128 -95
- data/lib/thinreports/core/shape/list/page.rb +54 -50
- data/lib/thinreports/core/shape/list/page_state.rb +15 -16
- data/lib/thinreports/core/shape/list/section_format.rb +14 -15
- data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
- data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
- data/lib/thinreports/core/shape/list/store.rb +10 -11
- data/lib/thinreports/core/shape/manager.rb +1 -1
- data/lib/thinreports/core/shape/manager/format.rb +10 -11
- data/lib/thinreports/core/shape/manager/internal.rb +21 -20
- data/lib/thinreports/core/shape/manager/target.rb +63 -34
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +3 -3
- data/lib/thinreports/core/shape/page_number/interface.rb +2 -2
- data/lib/thinreports/core/shape/page_number/internal.rb +3 -3
- data/lib/thinreports/core/shape/style.rb +1 -1
- data/lib/thinreports/core/shape/style/base.rb +29 -29
- data/lib/thinreports/core/shape/style/basic.rb +1 -1
- data/lib/thinreports/core/shape/style/graphic.rb +10 -25
- data/lib/thinreports/core/shape/style/text.rb +36 -30
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text/format.rb +8 -9
- data/lib/thinreports/core/shape/text/interface.rb +2 -2
- data/lib/thinreports/core/shape/text/internal.rb +6 -7
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/format.rb +17 -18
- data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
- data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
- data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
- data/lib/thinreports/core/utils.rb +33 -32
- data/lib/thinreports/generator.rb +6 -8
- data/lib/thinreports/generator/base.rb +15 -24
- data/lib/thinreports/generator/configuration.rb +10 -9
- data/lib/thinreports/generator/pdf.rb +27 -30
- data/lib/thinreports/generator/pdf/configuration.rb +11 -6
- data/lib/thinreports/generator/pdf/document.rb +28 -28
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +30 -31
- data/lib/thinreports/generator/pdf/document/font.rb +53 -44
- data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +40 -41
- data/lib/thinreports/generator/pdf/document/page.rb +20 -21
- data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
- data/lib/thinreports/generator/pdf/drawer/base.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/page.rb +16 -17
- data/lib/thinreports/generator/pdf/prawn_ext.rb +17 -33
- data/lib/thinreports/layout.rb +2 -2
- data/lib/thinreports/layout/base.rb +22 -36
- data/lib/thinreports/layout/configuration.rb +11 -9
- data/lib/thinreports/layout/format.rb +26 -27
- data/lib/thinreports/layout/version.rb +8 -9
- data/lib/thinreports/report.rb +10 -14
- data/lib/thinreports/report/base.rb +104 -126
- data/lib/thinreports/report/events.rb +5 -5
- data/lib/thinreports/report/internal.rb +41 -33
- data/lib/thinreports/{core → report}/page.rb +38 -30
- data/lib/thinreports/version.rb +2 -3
- data/test/data/font.ttf +0 -0
- data/test/data/layout_block.tlf +1 -0
- data/test/data/layout_list.tlf +1 -0
- data/test/data/layout_list_noheader.tlf +1 -0
- data/test/data/layout_text1.tlf +1 -0
- data/test/data/layout_text2.tlf +1 -0
- data/test/test_helper.rb +74 -0
- data/test/{unit/tmp → tmp}/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +14 -14
- data/test/unit/core/format/test_builder.rb +19 -23
- data/test/unit/core/shape/base/test_internal.rb +34 -37
- data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
- data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
- data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
- data/test/unit/core/shape/basic/test_format.rb +4 -4
- data/test/unit/core/shape/basic/test_interface.rb +36 -46
- data/test/unit/core/shape/basic/test_internal.rb +23 -20
- data/test/unit/core/shape/image_block/test_format.rb +5 -5
- data/test/unit/core/shape/image_block/test_interface.rb +17 -16
- data/test/unit/core/shape/image_block/test_internal.rb +19 -16
- data/test/unit/core/shape/list/test_configuration.rb +45 -33
- data/test/unit/core/shape/list/test_events.rb +7 -7
- data/test/unit/core/shape/list/test_format.rb +16 -18
- data/test/unit/core/shape/list/test_manager.rb +5 -5
- data/test/unit/core/shape/list/test_page.rb +80 -22
- data/test/unit/core/shape/list/test_page_state.rb +12 -12
- data/test/unit/core/shape/list/test_section_format.rb +16 -17
- data/test/unit/core/shape/list/test_section_interface.rb +30 -22
- data/test/unit/core/shape/list/test_section_internal.rb +21 -19
- data/test/unit/core/shape/list/test_store.rb +7 -7
- data/test/unit/core/shape/manager/test_format.rb +11 -15
- data/test/unit/core/shape/manager/test_internal.rb +9 -9
- data/test/unit/core/shape/manager/test_target.rb +85 -57
- data/test/unit/core/shape/page_number/test_format.rb +4 -4
- data/test/unit/core/shape/page_number/test_interface.rb +11 -8
- data/test/unit/core/shape/page_number/test_internal.rb +5 -5
- data/test/unit/core/shape/styles/test_base.rb +9 -9
- data/test/unit/core/shape/styles/test_basic.rb +5 -5
- data/test/unit/core/shape/styles/test_graphic.rb +19 -33
- data/test/unit/core/shape/styles/test_text.rb +18 -7
- data/test/unit/core/shape/text/test_format.rb +6 -6
- data/test/unit/core/shape/text/test_internal.rb +11 -12
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +4 -4
- data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
- data/test/unit/core/shape/text_block/test_format.rb +8 -8
- data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
- data/test/unit/core/shape/text_block/test_interface.rb +37 -20
- data/test/unit/core/shape/text_block/test_internal.rb +38 -38
- data/test/unit/core/test_events.rb +5 -5
- data/test/unit/core/test_shape.rb +6 -6
- data/test/unit/core/test_utils.rb +68 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +4 -4
- data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
- data/test/unit/generator/pdf/document/test_draw_shape.rb +9 -7
- data/test/unit/generator/pdf/document/test_font.rb +79 -58
- data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
- data/test/unit/generator/pdf/document/test_page.rb +44 -45
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/pdf/test_configuration.rb +16 -9
- data/test/unit/generator/pdf/test_document.rb +8 -16
- data/test/unit/generator/test_base.rb +31 -42
- data/test/unit/generator/test_configuration.rb +6 -6
- data/test/unit/generator/test_pdf.rb +17 -14
- data/test/unit/layout/test_base.rb +34 -79
- data/test/unit/layout/test_configuration.rb +12 -37
- data/test/unit/layout/test_format.rb +36 -39
- data/test/unit/layout/test_version.rb +4 -4
- data/test/unit/report/test_base.rb +134 -213
- data/test/unit/report/test_events.rb +4 -4
- data/test/unit/report/test_internal.rb +84 -86
- data/test/unit/test_config.rb +31 -12
- data/test/unit/test_layout.rb +7 -7
- data/test/unit/test_report.rb +12 -24
- data/thinreports.gemspec +18 -22
- metadata +101 -200
- data/LICENSE +0 -1
- data/README.rdoc +0 -166
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/thinreports/core.rb +0 -20
- data/lib/thinreports/core/ext.rb +0 -5
- data/lib/thinreports/core/ext/array.rb +0 -19
- data/lib/thinreports/core/ext/hash.rb +0 -19
- data/lib/thinreports/core/ext/object.rb +0 -25
- data/lib/thinreports/core/format.rb +0 -14
- data/lib/thinreports/core/ordered_hash.rb +0 -39
- data/lib/thinreports/generator/pdf/drawer.rb +0 -16
- data/tasks/doc.rake +0 -12
- data/tasks/test.rake +0 -56
- data/test/benchmark/basic_estimate.tlf +0 -1
- data/test/benchmark/bench_basic_estimate.rb +0 -95
- data/test/case/character_spacing/character_spacing.rb +0 -8
- data/test/case/character_spacing/character_spacing.tlf +0 -1
- data/test/case/dynamic_image/dynamic_image.rb +0 -41
- data/test/case/dynamic_image/dynamic_image.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style.rb +0 -154
- data/test/case/dynamic_style/dynamic_style.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
- data/test/case/eudc/eudc.rb +0 -20
- data/test/case/eudc/eudc.tlf +0 -1
- data/test/case/hidden_shapes/hidden_shapes.rb +0 -9
- data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
- data/test/case/list_events/list_events.rb +0 -32
- data/test/case/list_events/list_events.tlf +0 -1
- data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
- data/test/case/list_page_number/list_page_number.tlf +0 -1
- data/test/case/page_number/page_number.rb +0 -33
- data/test/case/page_number/page_number.tlf +0 -1
- data/test/case/password_setting/password_setting.rb +0 -10
- data/test/case/password_setting/password_setting.tlf +0 -1
- data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
- data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
- data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
- data/test/case/tblock_styles/tblock_styles.rb +0 -27
- data/test/case/tblock_styles/tblock_styles.tlf +0 -1
- data/test/case/text_align/text_align.rb +0 -8
- data/test/case/text_align/text_align.tlf +0 -1
- data/test/case/typeB_page_size/B4_ISO.tlf +0 -1
- data/test/case/typeB_page_size/B4_JIS.tlf +0 -1
- data/test/case/word_wrap/word_wrap.rb +0 -26
- data/test/case/word_wrap/word_wrap.tlf +0 -1
- data/test/unit/core/ext/array_spec.rb +0 -29
- data/test/unit/core/ext/hash_spec.rb +0 -29
- data/test/unit/core/ext/object_spec.rb +0 -30
- data/test/unit/core/ordered_hash_spec.rb +0 -51
- data/test/unit/core/shape/base/test_interface.rb +0 -52
- data/test/unit/core/utils_spec.rb +0 -56
- data/test/unit/data/basic_layout1.tlf +0 -1
- data/test/unit/data/basic_layout2.tlf +0 -1
- data/test/unit/data/basic_list_layout.tlf +0 -1
- data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
- data/test/unit/helper.rb +0 -87
@@ -1,49 +1,48 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator::PDF::Drawer
|
5
|
-
|
5
|
+
|
6
6
|
# @abstract
|
7
|
-
# @private
|
8
7
|
class Base
|
9
|
-
# @param [
|
10
|
-
# @param [
|
8
|
+
# @param [Thinreports::Generator::PDF::Document] pdf
|
9
|
+
# @param [Thinreports::Core::Shape::Manager::Format] format
|
11
10
|
def initialize(pdf, format)
|
12
11
|
@pdf = pdf
|
13
12
|
@format = format
|
14
13
|
@stamps = []
|
15
14
|
@draw_at = nil
|
16
15
|
end
|
17
|
-
|
16
|
+
|
18
17
|
# @abstract
|
19
18
|
def draw
|
20
19
|
raise NotImplementedError
|
21
20
|
end
|
22
|
-
|
21
|
+
|
23
22
|
private
|
24
|
-
|
25
|
-
# @param [
|
23
|
+
|
24
|
+
# @param [Thinreports::Core::Shape::Base::Internal] shape
|
26
25
|
# @return [String]
|
27
26
|
def pdf_stamp_id(shape)
|
28
27
|
"#{@format.identifier}#{shape.identifier}"
|
29
28
|
end
|
30
|
-
|
29
|
+
|
31
30
|
# @overload pdf_stamp(shape_id)
|
32
31
|
# @param [String] shape_id
|
33
32
|
# @overload pdf_stamp(shape)
|
34
|
-
# @param [
|
33
|
+
# @param [Thinreports::Core::Shape::Base::Internal] shape
|
35
34
|
def pdf_stamp(shape)
|
36
35
|
unless shape.is_a?(::String)
|
37
36
|
shape = pdf_stamp_id(shape)
|
38
37
|
end
|
39
38
|
@pdf.stamp(shape, @draw_at)
|
40
39
|
end
|
41
|
-
|
42
|
-
# @param [
|
40
|
+
|
41
|
+
# @param [Thinreports::Core::Shape::Base::Internal] shape
|
43
42
|
def create_pdf_stamp(shape, &block)
|
44
43
|
@pdf.create_stamp(pdf_stamp_id(shape), &block)
|
45
44
|
end
|
46
45
|
end
|
47
|
-
|
46
|
+
|
48
47
|
end
|
49
48
|
end
|
@@ -1,24 +1,23 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator::PDF::Drawer
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class List < Base
|
8
7
|
# @param (see PDF::Drawer::Base#initialize)
|
9
8
|
def initialize(pdf, format)
|
10
9
|
super
|
11
10
|
@sections = {}
|
12
11
|
end
|
13
|
-
|
14
|
-
# @param [
|
12
|
+
|
13
|
+
# @param [Thinreports::Core::Shape::List::PageState] list_page
|
15
14
|
def draw(list_page)
|
16
15
|
draw_section(list_page.header) if list_page.header
|
17
16
|
list_page.rows.each do |row|
|
18
17
|
draw_section(row)
|
19
18
|
end
|
20
19
|
|
21
|
-
# Returns
|
20
|
+
# Returns Thinreports::Report::Page object
|
22
21
|
manager = list_page.parent.manager
|
23
22
|
|
24
23
|
list_id = list_page.id.to_s
|
@@ -26,7 +25,7 @@ module ThinReports
|
|
26
25
|
next unless list_pageno?(list_id, shape)
|
27
26
|
|
28
27
|
shape = manager.final_shape(id)
|
29
|
-
@pdf.draw_shape_pageno(shape.internal,
|
28
|
+
@pdf.draw_shape_pageno(shape.internal,
|
30
29
|
list_page.no, list_page.manager.page_count)
|
31
30
|
end
|
32
31
|
end
|
@@ -34,25 +33,25 @@ module ThinReports
|
|
34
33
|
private
|
35
34
|
|
36
35
|
# @param [String] list_id
|
37
|
-
# @param [
|
36
|
+
# @param [Thinreports::Core::Shape::Base::Format] shape
|
38
37
|
# @return [Boolean]
|
39
38
|
def list_pageno?(list_id, shape)
|
40
|
-
shape.type ==
|
39
|
+
shape.type == Thinreports::Core::Shape::PageNumber::TYPE_NAME &&
|
41
40
|
shape.target == list_id
|
42
41
|
end
|
43
42
|
|
44
|
-
# @param [
|
43
|
+
# @param [Thinreports::Core::Shape::List::SectionInterface] section
|
45
44
|
def draw_section(section)
|
46
45
|
internal = section.internal
|
47
46
|
drawer(internal).draw(section, internal.relative_position)
|
48
47
|
end
|
49
|
-
|
50
|
-
# @param [
|
51
|
-
# @return [
|
48
|
+
|
49
|
+
# @param [Thinreports::Core::Shape::List::SectionInternal] section
|
50
|
+
# @return [Thinreports::Generator::PDF::Drawer::ListSection]
|
52
51
|
def drawer(section)
|
53
52
|
@sections[section.section_name] ||= ListSection.new(@pdf, section)
|
54
53
|
end
|
55
54
|
end
|
56
|
-
|
55
|
+
|
57
56
|
end
|
58
57
|
end
|
@@ -1,31 +1,30 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator::PDF::Drawer
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class ListSection < Page
|
8
7
|
# @param pdf (see PDF::Drawer::Page#initialize)
|
9
|
-
# @param section [
|
8
|
+
# @param section [Thinreports::Core::Shape::List::SectionInternal] section
|
10
9
|
def initialize(pdf, section)
|
11
10
|
super(pdf, section.format)
|
12
11
|
@section = section
|
13
12
|
@stamp_created = false
|
14
13
|
end
|
15
|
-
|
16
|
-
# @param [
|
14
|
+
|
15
|
+
# @param [Thinreports::Core::Shape::List::SectionInternal] section
|
17
16
|
# @param [Array<Numeric>] at
|
18
17
|
def draw(section, at)
|
19
18
|
@draw_at = at
|
20
19
|
draw_section
|
21
20
|
super(section)
|
22
21
|
end
|
23
|
-
|
22
|
+
|
24
23
|
private
|
25
|
-
|
24
|
+
|
26
25
|
def draw_section
|
27
26
|
id = @format.identifier.to_s
|
28
|
-
|
27
|
+
|
29
28
|
unless @stamp_created
|
30
29
|
@pdf.create_stamp(id) do
|
31
30
|
@pdf.parse_svg('<svg xmlns:xlink="http://www.w3.org/1999/xlink">' +
|
@@ -35,17 +34,17 @@ module ThinReports
|
|
35
34
|
end
|
36
35
|
pdf_stamp(id)
|
37
36
|
end
|
38
|
-
|
39
|
-
# @see
|
37
|
+
|
38
|
+
# @see Thinreports::Generator::PDF::Drawer::Page#draw_tblock_shape
|
40
39
|
def draw_tblock_shape(shape)
|
41
40
|
@pdf.translate(*@draw_at) { super }
|
42
41
|
end
|
43
|
-
|
44
|
-
# @see
|
42
|
+
|
43
|
+
# @see Thinreports::Generator::PDF::Drawer::Page#draw_iblock_shape
|
45
44
|
def draw_iblock_shape(shape)
|
46
45
|
@pdf.translate(*@draw_at) { super }
|
47
46
|
end
|
48
47
|
end
|
49
|
-
|
48
|
+
|
50
49
|
end
|
51
50
|
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator::PDF::Drawer
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class Page < Base
|
8
7
|
# @param (see PDF::Drawer::Base#initialize)
|
9
8
|
def initialize(pdf, format)
|
10
9
|
super
|
11
10
|
@lists = {}
|
12
11
|
end
|
13
|
-
|
14
|
-
# @param [
|
12
|
+
|
13
|
+
# @param [Thinreports::Report::Page] page
|
15
14
|
def draw(page)
|
16
15
|
manager = page.manager
|
17
16
|
|
@@ -28,7 +27,7 @@ module ThinReports
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
31
|
-
|
30
|
+
|
32
31
|
private
|
33
32
|
|
34
33
|
def draw_shape(shape)
|
@@ -48,7 +47,7 @@ module ThinReports
|
|
48
47
|
pdf_stamp(shape)
|
49
48
|
end
|
50
49
|
end
|
51
|
-
|
50
|
+
|
52
51
|
def draw_pageno_shape(shape, page)
|
53
52
|
@pdf.draw_shape_pageno(shape, page.no, page.report.page_count)
|
54
53
|
end
|
@@ -58,18 +57,18 @@ module ThinReports
|
|
58
57
|
drawer = @lists[shape.id] ||= List.new(@pdf, shape.format)
|
59
58
|
drawer.draw(shape)
|
60
59
|
end
|
61
|
-
|
60
|
+
|
62
61
|
# @see #draw_shape
|
63
62
|
def draw_tblock_shape(shape)
|
64
63
|
@pdf.draw_shape_tblock(shape)
|
65
64
|
end
|
66
|
-
|
65
|
+
|
67
66
|
# @see #draw_shape
|
68
67
|
def draw_iblock_shape(shape)
|
69
68
|
@pdf.draw_shape_iblock(shape)
|
70
69
|
end
|
71
|
-
|
72
|
-
# @param [
|
70
|
+
|
71
|
+
# @param [Thinreports::Core::Shape::Base::Internal] shape
|
73
72
|
def create_basic_shape_stamp(shape)
|
74
73
|
case
|
75
74
|
when shape.type_of?(:text) then create_text_stamp(shape)
|
@@ -79,35 +78,35 @@ module ThinReports
|
|
79
78
|
when shape.type_of?(:line) then create_line_stamp(shape)
|
80
79
|
end
|
81
80
|
end
|
82
|
-
|
81
|
+
|
83
82
|
# @see #create_basic_shape_stamp
|
84
83
|
def create_image_stamp(shape)
|
85
84
|
create_pdf_stamp(shape) do
|
86
85
|
@pdf.draw_shape_image(shape)
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
88
|
+
|
90
89
|
# @see #create_basic_shape_stamp
|
91
90
|
def create_rect_stamp(shape)
|
92
91
|
create_pdf_stamp(shape) do
|
93
92
|
@pdf.draw_shape_rect(shape)
|
94
93
|
end
|
95
94
|
end
|
96
|
-
|
95
|
+
|
97
96
|
# @see #create_basic_shape_stamp
|
98
97
|
def create_ellipse_stamp(shape)
|
99
98
|
create_pdf_stamp(shape) do
|
100
99
|
@pdf.draw_shape_ellipse(shape)
|
101
100
|
end
|
102
101
|
end
|
103
|
-
|
102
|
+
|
104
103
|
# @see #create_basic_shape_stamp
|
105
104
|
def create_line_stamp(shape)
|
106
105
|
create_pdf_stamp(shape) do
|
107
106
|
@pdf.draw_shape_line(shape)
|
108
107
|
end
|
109
108
|
end
|
110
|
-
|
109
|
+
|
111
110
|
# @see #create_basic_shape_stamp
|
112
111
|
def create_text_stamp(shape)
|
113
112
|
create_pdf_stamp(shape) do
|
@@ -115,6 +114,6 @@ module ThinReports
|
|
115
114
|
end
|
116
115
|
end
|
117
116
|
end
|
118
|
-
|
117
|
+
|
119
118
|
end
|
120
119
|
end
|
@@ -1,47 +1,31 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
# @private
|
4
3
|
module Prawn
|
5
4
|
class Document
|
6
|
-
# Create around alias.
|
7
5
|
alias_method :original_width_of, :width_of
|
8
|
-
|
6
|
+
|
9
7
|
def width_of(string, options={})
|
10
8
|
font.compute_width_of(string, options) +
|
11
9
|
(character_spacing * (font.character_count(string) - 1))
|
12
10
|
end
|
13
|
-
|
14
|
-
private
|
15
|
-
# Create around alias.
|
16
|
-
alias_method :original_calc_image_dimensions, :calc_image_dimensions
|
17
|
-
|
18
|
-
def calc_image_dimensions(info, options)
|
19
|
-
if options[:auto_fit]
|
20
|
-
w, h = info.width, info.height
|
21
|
-
sw, sh = options.delete(:auto_fit)
|
22
|
-
|
23
|
-
if w > sw || h > sh
|
24
|
-
options[:fit] = [sw, sh]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
original_calc_image_dimensions(info, options)
|
28
|
-
end
|
29
11
|
end
|
30
12
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
13
|
+
module Images
|
14
|
+
class Image
|
15
|
+
alias_method :original_calc_image_dimensions, :calc_image_dimensions
|
16
|
+
|
17
|
+
def calc_image_dimensions(options)
|
18
|
+
if options[:auto_fit]
|
19
|
+
w = options[:width] || width
|
20
|
+
h = options[:height] || height
|
21
|
+
|
22
|
+
box_width, box_height = options.delete(:auto_fit)
|
23
|
+
|
24
|
+
if w > box_width || h > box_height
|
25
|
+
options[:fit] = [box_width, box_height]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
original_calc_image_dimensions(options)
|
45
29
|
end
|
46
30
|
end
|
47
31
|
end
|
data/lib/thinreports/layout.rb
CHANGED
@@ -1,49 +1,36 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Layout
|
5
|
-
|
5
|
+
|
6
6
|
class Base
|
7
7
|
EXT_NAME = 'tlf'
|
8
|
-
|
8
|
+
include Utils
|
9
|
+
|
9
10
|
class << self
|
10
11
|
# @param [String] filename
|
11
|
-
# @return [
|
12
|
-
# @raise [
|
13
|
-
# @raise [
|
14
|
-
# @private
|
12
|
+
# @return [Thinreports::Layout::Format]
|
13
|
+
# @raise [Thinreports::Errors::InvalidLayoutFormat]
|
14
|
+
# @raise [Thinreports::Errors::IncompatibleLayoutFormat]
|
15
15
|
def load_format(filename)
|
16
16
|
filename += ".#{EXT_NAME}" unless filename =~/\.#{EXT_NAME}$/
|
17
|
-
|
17
|
+
|
18
18
|
unless File.exists?(filename)
|
19
|
-
raise
|
19
|
+
raise Thinreports::Errors::LayoutFileNotFound
|
20
20
|
end
|
21
21
|
# Build format.
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
# @private
|
26
|
-
def Page
|
27
|
-
const_defined?(:Page) ? Page : Core::Page
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
# @private
|
33
|
-
def PageHelpers(&block)
|
34
|
-
const_set(:Page, ::Class.new(Core::Page, &block))
|
22
|
+
Thinreports::Layout::Format.build(filename)
|
35
23
|
end
|
36
24
|
end
|
37
|
-
|
38
|
-
# @private
|
25
|
+
|
39
26
|
attr_reader :format
|
40
|
-
|
27
|
+
|
41
28
|
# @return [String]
|
42
29
|
attr_reader :filename
|
43
|
-
|
30
|
+
|
44
31
|
# @return [Symbol]
|
45
32
|
attr_reader :id
|
46
|
-
|
33
|
+
|
47
34
|
# @param [String] filename
|
48
35
|
# @param [Hash] options
|
49
36
|
# @option options [Symbol] :id (nil)
|
@@ -52,29 +39,28 @@ module ThinReports
|
|
52
39
|
@format = self.class.load_format(filename)
|
53
40
|
@id = options[:id]
|
54
41
|
end
|
55
|
-
|
42
|
+
|
56
43
|
# @return [Boolean] Return the true if is default layout.
|
57
44
|
def default?
|
58
45
|
@id.nil?
|
59
46
|
end
|
60
|
-
|
47
|
+
|
61
48
|
# @yield [config]
|
62
49
|
# @yieldparam [List::Configuration] config
|
63
50
|
# @return [List::Configuration]
|
64
51
|
def config(&block)
|
65
52
|
@config ||= Layout::Configuration.new(self)
|
66
|
-
|
53
|
+
call_block_in(@config, &block)
|
67
54
|
end
|
68
|
-
|
69
|
-
# @param [
|
55
|
+
|
56
|
+
# @param [Thinreports::Report::Base] parent
|
70
57
|
# @param [Hash] options ({})
|
71
58
|
# @option option [Boolean] :count (true)
|
72
59
|
# @return [Page]
|
73
|
-
|
74
|
-
|
75
|
-
self.class.Page.new(parent, self, options)
|
60
|
+
def new_page(parent, options = {})
|
61
|
+
Report::Page.new(parent, self, options)
|
76
62
|
end
|
77
63
|
end
|
78
|
-
|
64
|
+
|
79
65
|
end
|
80
66
|
end
|