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,122 +1,154 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class List::Manager
|
8
|
-
|
7
|
+
include Utils
|
8
|
+
|
9
|
+
# @return [Thinreports::Core::Shape::List::Configuration]
|
9
10
|
attr_reader :config
|
10
|
-
|
11
|
-
# @return [
|
11
|
+
|
12
|
+
# @return [Thinreports::Core::Shape:::List::Page]
|
12
13
|
attr_reader :current_page
|
13
|
-
|
14
|
-
# @return [
|
14
|
+
|
15
|
+
# @return [Thinreports::Core::Shape::List::PageState]
|
15
16
|
attr_reader :current_page_state
|
16
17
|
|
17
18
|
# @return [Integer]
|
18
19
|
attr_accessor :page_count
|
19
|
-
|
20
|
-
# @
|
20
|
+
|
21
|
+
# @return [Proc]
|
22
|
+
attr_accessor :page_finalize_handler
|
23
|
+
|
24
|
+
# @return [Proc]
|
25
|
+
attr_accessor :page_footer_handler
|
26
|
+
|
27
|
+
# @return [Proc]
|
28
|
+
attr_accessor :footer_handler
|
29
|
+
|
30
|
+
# @param [Thinreports::Core::Shape::List::Page] page
|
21
31
|
def initialize(page)
|
22
32
|
switch_current!(page)
|
23
33
|
|
24
|
-
@config
|
25
|
-
@finalized
|
34
|
+
@config = init_config
|
35
|
+
@finalized = false
|
26
36
|
@page_count = 0
|
37
|
+
|
38
|
+
@page_finalize_handler = nil
|
39
|
+
@page_footer_handler = nil
|
40
|
+
@footer_handler = nil
|
27
41
|
end
|
28
|
-
|
29
|
-
# @param [
|
30
|
-
# @return [
|
42
|
+
|
43
|
+
# @param [Thinreports::Core::Shape::List::Page] page
|
44
|
+
# @return [Thinreports::Core::Shape::List::Manager]
|
31
45
|
def switch_current!(page)
|
32
46
|
@current_page = page
|
33
47
|
@current_page_state = page.internal
|
34
48
|
self
|
35
49
|
end
|
36
|
-
|
50
|
+
|
37
51
|
# @yield [new_list]
|
38
|
-
# @yieldparam [
|
52
|
+
# @yieldparam [Thinreports::Core::Shape::List::Page] new_list
|
39
53
|
def change_new_page(&block)
|
40
54
|
finalize_page
|
41
55
|
new_page = report.internal.copy_page
|
42
|
-
|
56
|
+
|
43
57
|
if block_given?
|
44
58
|
block.call(new_page.list(current_page.id))
|
45
59
|
end
|
46
60
|
end
|
47
|
-
|
48
|
-
# @
|
49
|
-
|
61
|
+
|
62
|
+
# @param [Hash] values ({})
|
63
|
+
# @yield [header]
|
64
|
+
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] header
|
65
|
+
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
66
|
+
# @raise [Thinreports::Errors::DisabledListSection]
|
67
|
+
def build_header(values = {}, &block)
|
50
68
|
unless format.has_header?
|
51
|
-
raise
|
52
|
-
end
|
69
|
+
raise Thinreports::Errors::DisabledListSection.new('header')
|
70
|
+
end
|
53
71
|
current_page_state.header ||= init_section(:header)
|
54
|
-
build_section(
|
72
|
+
build_section(header_section, values, &block)
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
76
|
+
def header_section
|
77
|
+
current_page_state.header
|
55
78
|
end
|
56
|
-
|
79
|
+
|
57
80
|
# @param (see #build_section)
|
58
81
|
# @return [Boolean]
|
59
|
-
def
|
82
|
+
def add_detail(values = {}, &block)
|
60
83
|
return false if current_page_state.finalized?
|
61
|
-
|
84
|
+
|
62
85
|
successful = true
|
63
|
-
|
86
|
+
|
64
87
|
if overflow_with?(:detail)
|
65
88
|
if auto_page_break?
|
66
89
|
change_new_page do |new_list|
|
67
|
-
new_list.manager.
|
90
|
+
new_list.manager.insert_detail(values, &block)
|
68
91
|
end
|
69
92
|
else
|
70
93
|
finalize
|
71
94
|
successful = false
|
72
95
|
end
|
73
96
|
else
|
74
|
-
|
97
|
+
insert_detail(values, &block)
|
75
98
|
end
|
76
99
|
successful
|
77
100
|
end
|
78
|
-
|
79
|
-
# @see #
|
80
|
-
|
81
|
-
|
101
|
+
|
102
|
+
# @param values (see Thinreports::Core::Shape::Manager::Target#values)
|
103
|
+
# @yield [section,]
|
104
|
+
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] section
|
105
|
+
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
106
|
+
def insert_detail(values = {}, &block)
|
107
|
+
detail = build_section(init_section(:detail), values, &block)
|
108
|
+
insert_row(detail)
|
109
|
+
end
|
110
|
+
|
111
|
+
# @param [Thinreports::Core::Shape::List::SectionInterface] row
|
112
|
+
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
113
|
+
def insert_row(row)
|
82
114
|
row.internal.move_top_to(current_page_state.height)
|
83
|
-
|
115
|
+
|
84
116
|
current_page_state.rows << row
|
85
117
|
current_page_state.height += row.height
|
86
118
|
row
|
87
119
|
end
|
88
|
-
|
89
|
-
# @param [
|
90
|
-
# @param values (see
|
120
|
+
|
121
|
+
# @param [Thinreports::Core::Shape::List::SectionInterface] section
|
122
|
+
# @param values (see Thinreports::Core::Shape::Manager::Target#values)
|
91
123
|
# @yield [section,]
|
92
|
-
# @yieldparam [
|
93
|
-
# @return [
|
124
|
+
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] section
|
125
|
+
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
94
126
|
def build_section(section, values = {}, &block)
|
95
127
|
section.values(values)
|
96
|
-
|
128
|
+
call_block_in(section, &block)
|
97
129
|
end
|
98
|
-
|
130
|
+
|
99
131
|
# @param [Symbol] section_name
|
100
|
-
# @return [
|
132
|
+
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
101
133
|
def init_section(section_name)
|
102
134
|
List::SectionInterface.new(current_page,
|
103
135
|
format.sections[section_name],
|
104
136
|
section_name)
|
105
|
-
end
|
106
|
-
|
137
|
+
end
|
138
|
+
|
107
139
|
# @param [Symbol] section_name
|
108
140
|
# @return [Boolean]
|
109
141
|
def overflow_with?(section_name = :detail)
|
110
142
|
max_height = page_max_height
|
111
|
-
|
143
|
+
|
112
144
|
if section_name == :footer && format.has_page_footer?
|
113
145
|
max_height += format.section_height(:page_footer)
|
114
146
|
end
|
115
|
-
|
147
|
+
|
116
148
|
height = format.section_height(section_name)
|
117
149
|
(current_page_state.height + height) > max_height
|
118
150
|
end
|
119
|
-
|
151
|
+
|
120
152
|
# @return [Numeric]
|
121
153
|
def page_max_height
|
122
154
|
unless @page_max_height
|
@@ -127,103 +159,104 @@ module ThinReports
|
|
127
159
|
end
|
128
160
|
@page_max_height
|
129
161
|
end
|
130
|
-
|
131
|
-
# @return [
|
162
|
+
|
163
|
+
# @return [Thinreports::Core::Shape::List::Store]
|
132
164
|
def store
|
133
165
|
config.store
|
134
166
|
end
|
135
|
-
|
136
|
-
# @return [
|
167
|
+
|
168
|
+
# @return [Thinreports::Core::Shape::List::Events]
|
137
169
|
def events
|
138
|
-
config.
|
170
|
+
config.internal_events
|
139
171
|
end
|
140
|
-
|
172
|
+
|
141
173
|
# @return [Boolean]
|
142
174
|
def auto_page_break?
|
143
175
|
format.auto_page_break?
|
144
176
|
end
|
145
177
|
|
146
178
|
# @param [Hash] options
|
147
|
-
# @option [Boolean] :ignore_page_footer (false)
|
148
|
-
# When the switch of the page is generated by #finalize, it is used.
|
149
|
-
# @private
|
179
|
+
# @option options [Boolean] :ignore_page_footer (false)
|
180
|
+
# When the switch of the page is generated by #finalize, it is used.
|
150
181
|
def finalize_page(options = {})
|
151
182
|
return if current_page_state.finalized?
|
152
|
-
|
153
|
-
if format.has_header?
|
154
|
-
|
155
|
-
end
|
156
|
-
|
183
|
+
|
184
|
+
build_header if format.has_header?
|
185
|
+
|
157
186
|
if !options[:ignore_page_footer] && format.has_page_footer?
|
158
|
-
|
159
|
-
|
187
|
+
page_footer = insert_row(init_section(:page_footer))
|
188
|
+
|
189
|
+
# [DEPRECATION] Use List::Interface#on_page_footer_insert instead.
|
160
190
|
events.
|
161
191
|
dispatch(List::Events::SectionEvent.new(:page_footer_insert,
|
162
|
-
|
192
|
+
page_footer, store))
|
193
|
+
# In 0.8 or later
|
194
|
+
@page_footer_handler.call(page_footer) if @page_footer_handler
|
163
195
|
end
|
164
196
|
current_page_state.finalized!
|
165
|
-
|
166
|
-
#
|
197
|
+
|
198
|
+
# [DEPRECATION] Use List::Interface#on_page_finalize instead.
|
167
199
|
events.
|
168
200
|
dispatch(List::Events::PageEvent.new(:page_finalize,
|
169
|
-
current_page,
|
201
|
+
current_page,
|
170
202
|
current_page_state.parent))
|
203
|
+
# In 0.8 or later
|
204
|
+
@page_finalize_handler.call if @page_finalize_handler
|
205
|
+
|
171
206
|
@page_count += 1
|
172
207
|
current_page_state.no = @page_count
|
173
208
|
end
|
174
|
-
|
175
|
-
# @private
|
209
|
+
|
176
210
|
def finalize
|
177
211
|
return if finalized?
|
178
|
-
|
179
212
|
finalize_page
|
180
|
-
|
213
|
+
|
181
214
|
if format.has_footer?
|
182
|
-
footer =
|
183
|
-
|
215
|
+
footer = init_section(:footer)
|
216
|
+
|
217
|
+
# [DEPRECATION] Use List::Interface#on_footer_insert instead.
|
218
|
+
events.dispatch(List::Events::SectionEvent.new(:footer_insert, footer, store))
|
219
|
+
|
220
|
+
# In 0.8 or later
|
221
|
+
@footer_handler.call(footer) if @footer_handler
|
222
|
+
|
184
223
|
if auto_page_break? && overflow_with?(:footer)
|
185
224
|
change_new_page do |new_list|
|
186
|
-
|
187
|
-
new_list.manager.finalize_page(:
|
225
|
+
new_list.manager.insert_row(footer)
|
226
|
+
new_list.manager.finalize_page(ignore_page_footer: true)
|
188
227
|
end
|
189
228
|
else
|
190
|
-
|
229
|
+
insert_row(footer)
|
191
230
|
end
|
192
|
-
# Dispatch footer insert event.
|
193
|
-
events.dispatch(List::Events::SectionEvent.new(:footer_insert,
|
194
|
-
footer, store))
|
195
231
|
end
|
196
232
|
@finalized = true
|
197
233
|
end
|
198
|
-
|
234
|
+
|
199
235
|
# @return [Boolean]
|
200
|
-
# @private
|
201
236
|
def finalized?
|
202
237
|
@finalized
|
203
|
-
end
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
# @return [ThinReports::Report::Base]
|
238
|
+
end
|
239
|
+
|
240
|
+
# @return [Thinreports::Report::Base]
|
208
241
|
def report
|
209
242
|
current_page_state.parent.report
|
210
243
|
end
|
211
|
-
|
212
|
-
# @return [
|
244
|
+
|
245
|
+
# @return [Thinreports::Layout::Base]
|
213
246
|
def layout
|
214
247
|
current_page_state.parent.layout
|
215
248
|
end
|
216
|
-
|
217
|
-
# @return [
|
249
|
+
|
250
|
+
# @return [Thinreports::Core::Shape::List::Format]
|
218
251
|
def format
|
219
252
|
current_page_state.format
|
220
253
|
end
|
221
|
-
|
222
|
-
# @return [
|
254
|
+
|
255
|
+
# @return [Thinreports::Core::Shape::List::Configuration]
|
223
256
|
def init_config
|
224
257
|
layout.config.activate(current_page.id) || List::Configuration.new
|
225
258
|
end
|
226
259
|
end
|
227
|
-
|
260
|
+
|
228
261
|
end
|
229
|
-
end
|
262
|
+
end
|
@@ -1,16 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
5
|
+
|
6
6
|
class List::Page < Basic::Interface
|
7
|
-
|
8
|
-
|
9
|
-
# @param [
|
10
|
-
# @param [
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
# @param [Thinreports::Report::Page] parent
|
10
|
+
# @param [Thinreports::Core::Shape::Basic::Format] format
|
11
|
+
# @param [Thinreports::Core::Shape::List::PageState] internal (nil)
|
12
|
+
# @param [Thinreports::Core::Shape::List::Manager] manager (nil)
|
11
13
|
def initialize(parent, format, internal = nil, manager = nil)
|
12
14
|
super(parent, format, internal)
|
13
|
-
|
15
|
+
|
14
16
|
@manager = if manager
|
15
17
|
manager.switch_current!(self)
|
16
18
|
else
|
@@ -20,24 +22,35 @@ module ThinReports
|
|
20
22
|
# Set a reference to List::PageState List::Manager
|
21
23
|
self.internal.manager = self.manager
|
22
24
|
end
|
23
|
-
|
24
|
-
# @
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
def header(values = {}, &block)
|
30
|
-
manager.header(values, &block)
|
25
|
+
|
26
|
+
# @see Thinreports::Core::Shape::List::Manager#build_header
|
27
|
+
def_delegator :manager, :build_header, :header
|
28
|
+
|
29
|
+
def on_page_finalize(&block)
|
30
|
+
manager.page_finalize_handler = block
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
|
+
# @yield [page_footer]
|
34
|
+
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] page_footer
|
35
|
+
def on_page_footer_insert(&block)
|
36
|
+
manager.page_footer_handler = block
|
37
|
+
end
|
38
|
+
|
39
|
+
# @yield [footer]
|
40
|
+
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] footer
|
41
|
+
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
42
|
+
def on_footer_insert(&block)
|
43
|
+
manager.footer_handler = block
|
44
|
+
end
|
45
|
+
|
33
46
|
# @param [Hash] values ({})
|
34
47
|
# @yield [row,]
|
35
|
-
# @yieldparam [
|
48
|
+
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] row
|
36
49
|
# @return [Boolean]
|
37
50
|
def add_row(values = {}, &block)
|
38
|
-
manager.
|
51
|
+
manager.add_detail(values, &block)
|
39
52
|
end
|
40
|
-
|
53
|
+
|
41
54
|
# If enabled, the auto-page-break of the list will force a page break
|
42
55
|
# at the time this method is called. Otherwise, this list will be finalized.
|
43
56
|
def page_break
|
@@ -48,44 +61,37 @@ module ThinReports
|
|
48
61
|
end
|
49
62
|
end
|
50
63
|
alias_method :finalize, :page_break
|
51
|
-
|
52
|
-
# @return [Boolean]
|
53
|
-
#
|
64
|
+
|
65
|
+
# @return [Boolean] Returns true if list has overflowed
|
66
|
+
# when `list#add_row` is called at the next time.
|
54
67
|
def overflow?
|
55
|
-
|
68
|
+
manager.overflow_with?(:detail)
|
56
69
|
end
|
57
|
-
|
58
|
-
# @return [
|
59
|
-
# if the current page of list is already finalized.
|
60
|
-
def finalized?
|
61
|
-
internal.finalized?
|
62
|
-
end
|
63
|
-
|
64
|
-
# @return [ThinReports::Core::Shape::List::Configuration]
|
70
|
+
|
71
|
+
# @return [Thinreports::Core::Shape::List::Configuration]
|
65
72
|
def config
|
66
73
|
manager.config
|
67
74
|
end
|
68
|
-
|
69
|
-
# @return [
|
75
|
+
|
76
|
+
# @return [Thinreports::Core::Shape::List::Store]
|
70
77
|
def store
|
71
78
|
config.store
|
72
79
|
end
|
73
|
-
|
74
|
-
# @return [
|
80
|
+
|
81
|
+
# @return [Thinreports::Core::Shape::List::Events]
|
75
82
|
def events
|
76
83
|
config.events
|
77
84
|
end
|
78
|
-
|
79
|
-
# @param [
|
80
|
-
# @return [
|
81
|
-
# @private
|
85
|
+
|
86
|
+
# @param [Thinreports::Report::Page] new_parent
|
87
|
+
# @return [Thinreports::Core::Shape::List::Page]
|
82
88
|
def copy(new_parent)
|
83
89
|
if manager.auto_page_break?
|
84
90
|
new_list = self.class.new(new_parent, internal.format,
|
85
91
|
nil, manager)
|
86
92
|
else
|
87
93
|
manager.finalize
|
88
|
-
|
94
|
+
|
89
95
|
new_list = self.class.new(new_parent, internal.format,
|
90
96
|
internal.copy(new_parent), manager)
|
91
97
|
internal.rows.each do |row|
|
@@ -93,30 +99,28 @@ module ThinReports
|
|
93
99
|
end
|
94
100
|
new_list.finalized!
|
95
101
|
end
|
96
|
-
|
102
|
+
|
97
103
|
if internal.format.has_header?
|
98
104
|
new_list.internal.header = internal.header.copy(new_list)
|
99
105
|
end
|
100
106
|
new_list
|
101
107
|
end
|
102
|
-
|
103
|
-
# @private
|
108
|
+
|
104
109
|
def manager
|
105
110
|
@manager
|
106
111
|
end
|
107
|
-
|
112
|
+
|
108
113
|
private
|
109
|
-
|
110
|
-
# @see
|
114
|
+
|
115
|
+
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
111
116
|
def init_internal(parent, format)
|
112
117
|
List::PageState.new(parent, format)
|
113
118
|
end
|
114
119
|
end
|
115
|
-
|
120
|
+
|
116
121
|
# Alias to List::Page.
|
117
|
-
# @see
|
118
|
-
# @private
|
122
|
+
# @see Thinreports::Core::Shape::List::Page
|
119
123
|
List::Interface = List::Page
|
120
|
-
|
124
|
+
|
121
125
|
end
|
122
126
|
end
|