thinreports 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +3 -3
- data/.github/workflows/test.yml +28 -36
- data/.gitignore +1 -1
- data/CHANGELOG.md +19 -1
- data/Gemfile +11 -0
- data/README.md +12 -17
- data/Rakefile +17 -11
- data/lib/thinreports/basic_report/core/errors.rb +62 -0
- data/lib/thinreports/basic_report/core/format/base.rb +91 -0
- data/lib/thinreports/basic_report/core/shape/base/interface.rb +42 -0
- data/lib/thinreports/basic_report/core/shape/base/internal.rb +53 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_format.rb +15 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_interface.rb +34 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_internal.rb +36 -0
- data/lib/thinreports/basic_report/core/shape/basic/format.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/basic/interface.rb +87 -0
- data/lib/thinreports/basic_report/core/shape/basic/internal.rb +28 -0
- data/lib/thinreports/{core → basic_report/core}/shape/basic.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/image_block/format.rb +14 -0
- data/lib/thinreports/basic_report/core/shape/image_block/interface.rb +25 -0
- data/lib/thinreports/basic_report/core/shape/image_block/internal.rb +19 -0
- data/lib/thinreports/{core → basic_report/core}/shape/image_block.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/list/format.rb +92 -0
- data/lib/thinreports/basic_report/core/shape/list/manager.rb +231 -0
- data/lib/thinreports/basic_report/core/shape/list/page.rb +112 -0
- data/lib/thinreports/basic_report/core/shape/list/page_state.rb +50 -0
- data/lib/thinreports/basic_report/core/shape/list/section_format.rb +37 -0
- data/lib/thinreports/basic_report/core/shape/list/section_interface.rb +51 -0
- data/lib/thinreports/basic_report/core/shape/list/section_internal.rb +33 -0
- data/lib/thinreports/{core → basic_report/core}/shape/list.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/manager/format.rb +33 -0
- data/lib/thinreports/basic_report/core/shape/manager/internal.rb +109 -0
- data/lib/thinreports/basic_report/core/shape/manager/target.rb +114 -0
- data/lib/thinreports/basic_report/core/shape/page_number/format.rb +32 -0
- data/lib/thinreports/basic_report/core/shape/page_number/interface.rb +31 -0
- data/lib/thinreports/basic_report/core/shape/page_number/internal.rb +57 -0
- data/lib/thinreports/{core → basic_report/core}/shape/page_number.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/stack_view/format.rb +29 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/interface.rb +19 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/internal.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/row_format.rb +41 -0
- data/lib/thinreports/{core → basic_report/core}/shape/stack_view.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/style/base.rb +149 -0
- data/lib/thinreports/basic_report/core/shape/style/basic.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/style/graphic.rb +43 -0
- data/lib/thinreports/basic_report/core/shape/style/text.rb +122 -0
- data/lib/thinreports/basic_report/core/shape/text/format.rb +17 -0
- data/lib/thinreports/basic_report/core/shape/text/interface.rb +20 -0
- data/lib/thinreports/basic_report/core/shape/text/internal.rb +24 -0
- data/lib/thinreports/{core → basic_report/core}/shape/text.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/text_block/format.rb +43 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb +41 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/datetime.rb +25 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/number.rb +69 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/padding.rb +27 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter.rb +38 -0
- data/lib/thinreports/basic_report/core/shape/text_block/interface.rb +37 -0
- data/lib/thinreports/basic_report/core/shape/text_block/internal.rb +75 -0
- data/lib/thinreports/{core → basic_report/core}/shape/text_block.rb +6 -4
- data/lib/thinreports/basic_report/core/shape.rb +44 -0
- data/lib/thinreports/basic_report/core/utils.rb +47 -0
- data/lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb +108 -0
- data/lib/thinreports/basic_report/generator/pdf/document/draw_template_items.rb +71 -0
- data/lib/thinreports/basic_report/generator/pdf/document/font.rb +90 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/attributes.rb +149 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/basic.rb +137 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/image.rb +99 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/text.rb +180 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics.rb +42 -0
- data/lib/thinreports/basic_report/generator/pdf/document/page.rb +96 -0
- data/lib/thinreports/basic_report/generator/pdf/document/parse_color.rb +51 -0
- data/lib/thinreports/basic_report/generator/pdf/document.rb +132 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/base.rb +50 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/list.rb +65 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/list_section.rb +51 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/page.rb +127 -0
- data/lib/thinreports/basic_report/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
- data/lib/thinreports/basic_report/generator/pdf/prawn_ext/width_of.rb +31 -0
- data/lib/thinreports/basic_report/generator/pdf.rb +66 -0
- data/lib/thinreports/basic_report/layout/base.rb +48 -0
- data/lib/thinreports/basic_report/layout/format.rb +67 -0
- data/lib/thinreports/basic_report/layout/legacy_schema.rb +383 -0
- data/lib/thinreports/basic_report/layout/version.rb +41 -0
- data/lib/thinreports/{layout.rb → basic_report/layout.rb} +6 -4
- data/lib/thinreports/basic_report/report/base.rb +173 -0
- data/lib/thinreports/basic_report/report/internal.rb +107 -0
- data/lib/thinreports/basic_report/report/page.rb +97 -0
- data/lib/thinreports/basic_report/report.rb +26 -0
- data/lib/thinreports/basic_report.rb +15 -0
- data/lib/thinreports/config.rb +1 -1
- data/lib/thinreports/section_report.rb +12 -0
- data/lib/thinreports/version.rb +1 -1
- data/lib/thinreports.rb +2 -13
- data/thinreports.gemspec +3 -7
- metadata +97 -154
- data/gemfiles/prawn-2.2.gemfile +0 -5
- data/gemfiles/prawn-2.3.gemfile +0 -5
- data/gemfiles/prawn-2.4.gemfile +0 -5
- data/lib/thinreports/core/errors.rb +0 -60
- data/lib/thinreports/core/format/base.rb +0 -89
- data/lib/thinreports/core/shape/base/interface.rb +0 -40
- data/lib/thinreports/core/shape/base/internal.rb +0 -51
- data/lib/thinreports/core/shape/basic/block_format.rb +0 -13
- data/lib/thinreports/core/shape/basic/block_interface.rb +0 -32
- data/lib/thinreports/core/shape/basic/block_internal.rb +0 -34
- data/lib/thinreports/core/shape/basic/format.rb +0 -22
- data/lib/thinreports/core/shape/basic/interface.rb +0 -85
- data/lib/thinreports/core/shape/basic/internal.rb +0 -26
- data/lib/thinreports/core/shape/image_block/format.rb +0 -12
- data/lib/thinreports/core/shape/image_block/interface.rb +0 -23
- data/lib/thinreports/core/shape/image_block/internal.rb +0 -17
- data/lib/thinreports/core/shape/list/format.rb +0 -90
- data/lib/thinreports/core/shape/list/manager.rb +0 -229
- data/lib/thinreports/core/shape/list/page.rb +0 -110
- data/lib/thinreports/core/shape/list/page_state.rb +0 -48
- data/lib/thinreports/core/shape/list/section_format.rb +0 -35
- data/lib/thinreports/core/shape/list/section_interface.rb +0 -49
- data/lib/thinreports/core/shape/list/section_internal.rb +0 -31
- data/lib/thinreports/core/shape/manager/format.rb +0 -31
- data/lib/thinreports/core/shape/manager/internal.rb +0 -107
- data/lib/thinreports/core/shape/manager/target.rb +0 -112
- data/lib/thinreports/core/shape/page_number/format.rb +0 -30
- data/lib/thinreports/core/shape/page_number/interface.rb +0 -29
- data/lib/thinreports/core/shape/page_number/internal.rb +0 -55
- data/lib/thinreports/core/shape/stack_view/format.rb +0 -27
- data/lib/thinreports/core/shape/stack_view/interface.rb +0 -17
- data/lib/thinreports/core/shape/stack_view/internal.rb +0 -22
- data/lib/thinreports/core/shape/stack_view/row_format.rb +0 -39
- data/lib/thinreports/core/shape/style/base.rb +0 -146
- data/lib/thinreports/core/shape/style/basic.rb +0 -22
- data/lib/thinreports/core/shape/style/graphic.rb +0 -41
- data/lib/thinreports/core/shape/style/text.rb +0 -120
- data/lib/thinreports/core/shape/text/format.rb +0 -15
- data/lib/thinreports/core/shape/text/interface.rb +0 -18
- data/lib/thinreports/core/shape/text/internal.rb +0 -22
- data/lib/thinreports/core/shape/text_block/format.rb +0 -41
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +0 -39
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +0 -23
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +0 -67
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +0 -25
- data/lib/thinreports/core/shape/text_block/formatter.rb +0 -34
- data/lib/thinreports/core/shape/text_block/interface.rb +0 -35
- data/lib/thinreports/core/shape/text_block/internal.rb +0 -73
- data/lib/thinreports/core/shape.rb +0 -42
- data/lib/thinreports/core/utils.rb +0 -45
- data/lib/thinreports/generate.rb +0 -11
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +0 -106
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +0 -69
- data/lib/thinreports/generator/pdf/document/font.rb +0 -88
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +0 -147
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +0 -135
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +0 -98
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +0 -178
- data/lib/thinreports/generator/pdf/document/graphics.rb +0 -40
- data/lib/thinreports/generator/pdf/document/page.rb +0 -94
- data/lib/thinreports/generator/pdf/document/parse_color.rb +0 -49
- data/lib/thinreports/generator/pdf/document.rb +0 -130
- data/lib/thinreports/generator/pdf/drawer/base.rb +0 -48
- data/lib/thinreports/generator/pdf/drawer/list.rb +0 -63
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +0 -49
- data/lib/thinreports/generator/pdf/drawer/page.rb +0 -125
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +0 -32
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +0 -29
- data/lib/thinreports/generator/pdf.rb +0 -63
- data/lib/thinreports/layout/base.rb +0 -46
- data/lib/thinreports/layout/format.rb +0 -65
- data/lib/thinreports/layout/legacy_schema.rb +0 -381
- data/lib/thinreports/layout/version.rb +0 -39
- data/lib/thinreports/report/base.rb +0 -169
- data/lib/thinreports/report/internal.rb +0 -105
- data/lib/thinreports/report/page.rb +0 -95
- data/lib/thinreports/report.rb +0 -24
- /data/lib/thinreports/{core → basic_report/core}/shape/base.rb +0 -0
- /data/lib/thinreports/{core → basic_report/core}/shape/manager.rb +0 -0
- /data/lib/thinreports/{core → basic_report/core}/shape/style.rb +0 -0
- /data/lib/thinreports/{generator → basic_report/generator}/pdf/prawn_ext.rb +0 -0
@@ -1,229 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module List
|
7
|
-
class Manager
|
8
|
-
include Utils
|
9
|
-
|
10
|
-
# @return [Thinreports::Core::Shape:::List::Page]
|
11
|
-
attr_reader :current_page
|
12
|
-
|
13
|
-
# @return [Thinreports::Core::Shape::List::PageState]
|
14
|
-
attr_reader :current_page_state
|
15
|
-
|
16
|
-
# @return [Integer]
|
17
|
-
attr_accessor :page_count
|
18
|
-
|
19
|
-
# @return [Proc]
|
20
|
-
attr_accessor :page_finalize_handler
|
21
|
-
|
22
|
-
# @return [Proc]
|
23
|
-
attr_accessor :page_footer_handler
|
24
|
-
|
25
|
-
# @return [Proc]
|
26
|
-
attr_accessor :footer_handler
|
27
|
-
|
28
|
-
# @param [Thinreports::Core::Shape::List::Page] page
|
29
|
-
def initialize(page)
|
30
|
-
switch_current!(page)
|
31
|
-
|
32
|
-
@finalized = false
|
33
|
-
@page_count = 0
|
34
|
-
|
35
|
-
@page_finalize_handler = nil
|
36
|
-
@page_footer_handler = nil
|
37
|
-
@footer_handler = nil
|
38
|
-
end
|
39
|
-
|
40
|
-
# @param [Thinreports::Core::Shape::List::Page] page
|
41
|
-
# @return [Thinreports::Core::Shape::List::Manager]
|
42
|
-
def switch_current!(page)
|
43
|
-
@current_page = page
|
44
|
-
@current_page_state = page.internal
|
45
|
-
self
|
46
|
-
end
|
47
|
-
|
48
|
-
# @yield [new_list]
|
49
|
-
# @yieldparam [Thinreports::Core::Shape::List::Page] new_list
|
50
|
-
def change_new_page(&block)
|
51
|
-
finalize_page
|
52
|
-
new_page = report.internal.copy_page
|
53
|
-
|
54
|
-
block.call(new_page.list(current_page.id)) if block_given?
|
55
|
-
end
|
56
|
-
|
57
|
-
# @param [Hash] values ({})
|
58
|
-
# @yield [header]
|
59
|
-
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] header
|
60
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
61
|
-
# @raise [Thinreports::Errors::DisabledListSection]
|
62
|
-
def build_header(values = {}, &block)
|
63
|
-
raise Thinreports::Errors::DisabledListSection, 'header' unless format.has_header?
|
64
|
-
|
65
|
-
current_page_state.header ||= init_section(:header)
|
66
|
-
build_section(header_section, values, &block)
|
67
|
-
end
|
68
|
-
|
69
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
70
|
-
def header_section
|
71
|
-
current_page_state.header
|
72
|
-
end
|
73
|
-
|
74
|
-
# @param (see #build_section)
|
75
|
-
# @return [Boolean]
|
76
|
-
def add_detail(values = {}, &block)
|
77
|
-
return false if current_page_state.finalized?
|
78
|
-
|
79
|
-
successful = true
|
80
|
-
|
81
|
-
if overflow_with?(:detail)
|
82
|
-
if auto_page_break?
|
83
|
-
change_new_page do |new_list|
|
84
|
-
new_list.manager.insert_detail(values, &block)
|
85
|
-
end
|
86
|
-
else
|
87
|
-
finalize
|
88
|
-
successful = false
|
89
|
-
end
|
90
|
-
else
|
91
|
-
insert_detail(values, &block)
|
92
|
-
end
|
93
|
-
successful
|
94
|
-
end
|
95
|
-
|
96
|
-
# @param values (see Thinreports::Core::Shape::Manager::Target#values)
|
97
|
-
# @yield [section,]
|
98
|
-
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] section
|
99
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
100
|
-
def insert_detail(values = {}, &block)
|
101
|
-
detail = build_section(init_section(:detail), values, &block)
|
102
|
-
insert_row(detail)
|
103
|
-
end
|
104
|
-
|
105
|
-
# @param [Thinreports::Core::Shape::List::SectionInterface] row
|
106
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
107
|
-
def insert_row(row)
|
108
|
-
row.internal.move_top_to(current_page_state.height)
|
109
|
-
|
110
|
-
current_page_state.rows << row
|
111
|
-
current_page_state.height += row.height
|
112
|
-
row
|
113
|
-
end
|
114
|
-
|
115
|
-
# @param [Thinreports::Core::Shape::List::SectionInterface] section
|
116
|
-
# @param values (see Thinreports::Core::Shape::Manager::Target#values)
|
117
|
-
# @yield [section,]
|
118
|
-
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] section
|
119
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
120
|
-
def build_section(section, values = {}, &block)
|
121
|
-
section.values(values)
|
122
|
-
call_block_in(section, &block)
|
123
|
-
end
|
124
|
-
|
125
|
-
# @param [Symbol] section_name
|
126
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
127
|
-
def init_section(section_name)
|
128
|
-
List::SectionInterface.new(current_page,
|
129
|
-
format.sections[section_name],
|
130
|
-
section_name)
|
131
|
-
end
|
132
|
-
|
133
|
-
# @param [Symbol] section_name
|
134
|
-
# @return [Boolean]
|
135
|
-
def overflow_with?(section_name = :detail)
|
136
|
-
max_height = page_max_height
|
137
|
-
|
138
|
-
max_height += format.section_height(:page_footer) if section_name == :footer && format.has_page_footer?
|
139
|
-
|
140
|
-
height = format.section_height(section_name)
|
141
|
-
(current_page_state.height + height) > max_height
|
142
|
-
end
|
143
|
-
|
144
|
-
# @return [Numeric]
|
145
|
-
def page_max_height
|
146
|
-
@page_max_height ||= begin
|
147
|
-
h = format.height
|
148
|
-
h -= format.section_height(:page_footer)
|
149
|
-
h -= format.section_height(:footer) unless auto_page_break?
|
150
|
-
h
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# @return [Boolean]
|
155
|
-
def auto_page_break?
|
156
|
-
format.auto_page_break?
|
157
|
-
end
|
158
|
-
|
159
|
-
# @param [Hash] options
|
160
|
-
# @option options [Boolean] :ignore_page_footer (false)
|
161
|
-
# When the switch of the page is generated by #finalize, it is used.
|
162
|
-
def finalize_page(options = {})
|
163
|
-
return if current_page_state.finalized?
|
164
|
-
|
165
|
-
build_header if format.has_header?
|
166
|
-
|
167
|
-
finalize_page_footer unless options[:ignore_page_footer]
|
168
|
-
|
169
|
-
current_page_state.finalized!
|
170
|
-
@page_finalize_handler.call if @page_finalize_handler
|
171
|
-
|
172
|
-
@page_count += 1
|
173
|
-
current_page_state.no = @page_count
|
174
|
-
end
|
175
|
-
|
176
|
-
def finalize_page_footer
|
177
|
-
return unless format.has_page_footer?
|
178
|
-
|
179
|
-
page_footer = init_section(:page_footer)
|
180
|
-
insert_row(page_footer)
|
181
|
-
|
182
|
-
@page_footer_handler.call(page_footer) if @page_footer_handler
|
183
|
-
end
|
184
|
-
|
185
|
-
def finalize
|
186
|
-
return if finalized?
|
187
|
-
finalize_page
|
188
|
-
|
189
|
-
if format.has_footer?
|
190
|
-
footer = init_section(:footer)
|
191
|
-
|
192
|
-
@footer_handler.call(footer) if @footer_handler
|
193
|
-
|
194
|
-
if auto_page_break? && overflow_with?(:footer)
|
195
|
-
change_new_page do |new_list|
|
196
|
-
new_list.manager.insert_row(footer)
|
197
|
-
new_list.manager.finalize_page(ignore_page_footer: true)
|
198
|
-
end
|
199
|
-
else
|
200
|
-
insert_row(footer)
|
201
|
-
end
|
202
|
-
end
|
203
|
-
@finalized = true
|
204
|
-
end
|
205
|
-
|
206
|
-
# @return [Boolean]
|
207
|
-
def finalized?
|
208
|
-
@finalized
|
209
|
-
end
|
210
|
-
|
211
|
-
# @return [Thinreports::Report::Base]
|
212
|
-
def report
|
213
|
-
current_page_state.parent.report
|
214
|
-
end
|
215
|
-
|
216
|
-
# @return [Thinreports::Layout::Base]
|
217
|
-
def layout
|
218
|
-
current_page_state.parent.layout
|
219
|
-
end
|
220
|
-
|
221
|
-
# @return [Thinreports::Core::Shape::List::Format]
|
222
|
-
def format
|
223
|
-
current_page_state.format
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module List
|
7
|
-
class Page < Basic::Interface
|
8
|
-
extend Forwardable
|
9
|
-
|
10
|
-
attr_reader :manager
|
11
|
-
|
12
|
-
# @param [Thinreports::Report::Page] parent
|
13
|
-
# @param [Thinreports::Core::Shape::Basic::Format] format
|
14
|
-
# @param [Thinreports::Core::Shape::List::PageState] internal (nil)
|
15
|
-
# @param [Thinreports::Core::Shape::List::Manager] manager (nil)
|
16
|
-
def initialize(parent, format, internal = nil, manager = nil)
|
17
|
-
super(parent, format, internal)
|
18
|
-
|
19
|
-
@manager =
|
20
|
-
if manager
|
21
|
-
manager.switch_current!(self)
|
22
|
-
else
|
23
|
-
List::Manager.new(self)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Set a reference to List::PageState List::Manager
|
27
|
-
self.internal.manager = self.manager
|
28
|
-
end
|
29
|
-
|
30
|
-
# @see Thinreports::Core::Shape::List::Manager#build_header
|
31
|
-
def_delegator :manager, :build_header, :header
|
32
|
-
|
33
|
-
def on_page_finalize(&block)
|
34
|
-
manager.page_finalize_handler = block
|
35
|
-
end
|
36
|
-
|
37
|
-
# @yield [page_footer]
|
38
|
-
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] page_footer
|
39
|
-
def on_page_footer_insert(&block)
|
40
|
-
manager.page_footer_handler = block
|
41
|
-
end
|
42
|
-
|
43
|
-
# @yield [footer]
|
44
|
-
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] footer
|
45
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
46
|
-
def on_footer_insert(&block)
|
47
|
-
manager.footer_handler = block
|
48
|
-
end
|
49
|
-
|
50
|
-
# @param [Hash] values ({})
|
51
|
-
# @yield [row,]
|
52
|
-
# @yieldparam [Thinreports::Core::Shape::List::SectionInterface] row
|
53
|
-
# @return [Boolean]
|
54
|
-
def add_row(values = {}, &block)
|
55
|
-
manager.add_detail(values, &block)
|
56
|
-
end
|
57
|
-
|
58
|
-
# If enabled, the auto-page-break of the list will force a page break
|
59
|
-
# at the time this method is called. Otherwise, this list will be finalized.
|
60
|
-
def page_break
|
61
|
-
if manager.auto_page_break?
|
62
|
-
manager.change_new_page
|
63
|
-
else
|
64
|
-
manager.finalize_page
|
65
|
-
end
|
66
|
-
end
|
67
|
-
alias finalize page_break
|
68
|
-
|
69
|
-
# @return [Boolean] Returns true if list has overflowed
|
70
|
-
# when `list#add_row` is called at the next time.
|
71
|
-
def overflow?
|
72
|
-
manager.overflow_with?(:detail)
|
73
|
-
end
|
74
|
-
|
75
|
-
# @param [Thinreports::Report::Page] new_parent
|
76
|
-
# @return [Thinreports::Core::Shape::List::Page]
|
77
|
-
def copy(new_parent)
|
78
|
-
if manager.auto_page_break?
|
79
|
-
new_list = self.class.new(new_parent, internal.format,
|
80
|
-
nil, manager)
|
81
|
-
else
|
82
|
-
manager.finalize
|
83
|
-
|
84
|
-
new_list = self.class.new(new_parent, internal.format,
|
85
|
-
internal.copy(new_parent), manager)
|
86
|
-
internal.rows.each do |row|
|
87
|
-
new_list.internal.rows << row.copy(new_list)
|
88
|
-
end
|
89
|
-
new_list.internal.finalized!
|
90
|
-
end
|
91
|
-
|
92
|
-
new_list.internal.header = internal.header.copy(new_list) if internal.format.has_header?
|
93
|
-
new_list
|
94
|
-
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
99
|
-
def init_internal(parent, format)
|
100
|
-
List::PageState.new(parent, format)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Alias to List::Page.
|
105
|
-
# @see Thinreports::Core::Shape::List::Page
|
106
|
-
List::Interface = List::Page
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module List
|
7
|
-
class PageState < Basic::Internal
|
8
|
-
attr_reader :rows
|
9
|
-
|
10
|
-
attr_accessor :height
|
11
|
-
attr_accessor :header
|
12
|
-
attr_accessor :no
|
13
|
-
attr_accessor :manager
|
14
|
-
|
15
|
-
def initialize(*args)
|
16
|
-
super(*args)
|
17
|
-
|
18
|
-
@rows = []
|
19
|
-
@height = 0
|
20
|
-
@finalized = false
|
21
|
-
|
22
|
-
@header = nil
|
23
|
-
end
|
24
|
-
|
25
|
-
def style
|
26
|
-
@style ||= Style::Basic.new(format)
|
27
|
-
end
|
28
|
-
|
29
|
-
def finalized?
|
30
|
-
@finalized
|
31
|
-
end
|
32
|
-
|
33
|
-
def finalized!
|
34
|
-
@finalized = true
|
35
|
-
end
|
36
|
-
|
37
|
-
def type_of?(type_name)
|
38
|
-
type_name == List::TYPE_NAME
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Alias to List::PageState.
|
43
|
-
# @see Thinreports::Core::Shape::List::PageState
|
44
|
-
List::Internal = List::PageState
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module List
|
7
|
-
class SectionFormat < Shape::Manager::Format
|
8
|
-
config_reader :height
|
9
|
-
config_reader relative_left: %w[translate x],
|
10
|
-
relative_top: %w[translate y]
|
11
|
-
config_reader :style
|
12
|
-
|
13
|
-
# For compatible 0.8.x format API
|
14
|
-
config_checker true, display: %w[enabled]
|
15
|
-
|
16
|
-
def initialize(*)
|
17
|
-
super
|
18
|
-
initialize_items(attributes['items'])
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def initialize_items(item_schemas)
|
24
|
-
item_schemas.each do |item_schema|
|
25
|
-
id, type = item_schema.values_at 'id', 'type'
|
26
|
-
next if id.empty?
|
27
|
-
|
28
|
-
shapes[id.to_sym] = Core::Shape::Format(type).new(item_schema)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module List
|
7
|
-
class SectionInterface < Base::Interface
|
8
|
-
include Core::Shape::Manager::Target
|
9
|
-
|
10
|
-
undef_method :list
|
11
|
-
internal_delegators :height
|
12
|
-
|
13
|
-
# @param [Thinreports::Core::Shape::List::Page] parent
|
14
|
-
# @param [Thinreports::Core::Shape::List::SectionFormat] format
|
15
|
-
# @param [Symbol] section_name
|
16
|
-
def initialize(parent, format, section_name)
|
17
|
-
super(parent, format)
|
18
|
-
internal.section_name = section_name
|
19
|
-
|
20
|
-
initialize_manager(format) do |f|
|
21
|
-
Core::Shape::Interface(self, f)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param [Thinreports::Core::Shape::List::Page] parent
|
26
|
-
# @return [Thinreports::Core::Shape::List::SectionInterface]
|
27
|
-
def copy(parent)
|
28
|
-
new_sec = super
|
29
|
-
new_sec.internal.section_name = internal.section_name
|
30
|
-
|
31
|
-
manager.shapes.each do |id, shape|
|
32
|
-
new_sec.manager.shapes[id] = shape.copy(new_sec)
|
33
|
-
end
|
34
|
-
new_sec
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# @param parent (see #initialize)
|
40
|
-
# @param format (see #initialize)
|
41
|
-
# @return [Thinreports::Core::Shape::List::SectionInternal]
|
42
|
-
def init_internal(parent, format)
|
43
|
-
List::SectionInternal.new(parent, format)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module List
|
7
|
-
class SectionInternal < Base::Internal
|
8
|
-
format_delegators :height,
|
9
|
-
:relative_left
|
10
|
-
|
11
|
-
# @return [Symbol]
|
12
|
-
attr_accessor :section_name
|
13
|
-
|
14
|
-
def style
|
15
|
-
@style ||= Style::Base.new(format)
|
16
|
-
end
|
17
|
-
|
18
|
-
# @param [Numeric] ry
|
19
|
-
def move_top_to(ry)
|
20
|
-
states[:relative_top] = ry
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [Float]
|
24
|
-
def relative_top
|
25
|
-
states[:relative_top] || 0
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module Manager
|
7
|
-
class Format < Core::Format::Base
|
8
|
-
# @return [Symbol, Integer]
|
9
|
-
attr_reader :identifier
|
10
|
-
|
11
|
-
def initialize(config, id = nil, &block)
|
12
|
-
super(config, &block)
|
13
|
-
@identifier = id || object_id
|
14
|
-
end
|
15
|
-
|
16
|
-
def find_shape(id)
|
17
|
-
shapes[id]
|
18
|
-
end
|
19
|
-
|
20
|
-
def has_shape?(id)
|
21
|
-
shapes.key?(id)
|
22
|
-
end
|
23
|
-
|
24
|
-
def shapes
|
25
|
-
@shapes ||= {}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Thinreports
|
4
|
-
module Core
|
5
|
-
module Shape
|
6
|
-
module Manager
|
7
|
-
class Internal
|
8
|
-
include Utils
|
9
|
-
|
10
|
-
attr_reader :format
|
11
|
-
attr_reader :shapes
|
12
|
-
attr_reader :lists
|
13
|
-
|
14
|
-
# @param [Thinreports::Core::Manager::Format] format
|
15
|
-
# @param [Proc] init_item_handler
|
16
|
-
def initialize(format, init_item_handler)
|
17
|
-
@format = format
|
18
|
-
@shapes = {}
|
19
|
-
@lists = {}
|
20
|
-
@init_item_handler = init_item_handler
|
21
|
-
end
|
22
|
-
|
23
|
-
# @param [String, Symbol] id
|
24
|
-
# @return [Thinreports::Core::Shape::Basic::Format]
|
25
|
-
def find_format(id)
|
26
|
-
format.find_shape(id.to_sym)
|
27
|
-
end
|
28
|
-
|
29
|
-
# @param [String, Symbol] id
|
30
|
-
# @param limit (see #valid_type?)
|
31
|
-
def find_item(id, limit = {})
|
32
|
-
id = id.to_sym
|
33
|
-
|
34
|
-
if shapes.key?(id)
|
35
|
-
shape = shapes[id]
|
36
|
-
valid_type?(shape.type, limit) ? shape : nil
|
37
|
-
elsif find_format(id)
|
38
|
-
shape_format = find_format(id)
|
39
|
-
return nil unless valid_type?(shape_format.type, limit)
|
40
|
-
|
41
|
-
shape = init_item(shape_format)
|
42
|
-
shapes[id] = shape
|
43
|
-
|
44
|
-
shape
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# @param [String, Symbol] id
|
49
|
-
# @return [Thinreports::Core::Shape::Base::Interface, nil]
|
50
|
-
def final_shape(id)
|
51
|
-
shape = shapes[id]
|
52
|
-
|
53
|
-
# When shape was found in registry.
|
54
|
-
if shape
|
55
|
-
return nil unless shape.visible?
|
56
|
-
|
57
|
-
# In the case of TextBlock or ImageBlock.
|
58
|
-
if shape.internal.type_of?(:block)
|
59
|
-
blank_value?(shape.internal.real_value) ? nil : shape
|
60
|
-
else
|
61
|
-
shape
|
62
|
-
end
|
63
|
-
# When shape was not found in registry.
|
64
|
-
elsif format.has_shape?(id)
|
65
|
-
shape_format = find_format(id)
|
66
|
-
return nil unless shape_format.display?
|
67
|
-
|
68
|
-
case shape_format.type
|
69
|
-
# In the case of TextBlock.
|
70
|
-
when TextBlock::TYPE_NAME
|
71
|
-
return nil if !shape_format.has_reference? && blank_value?(shape_format.value)
|
72
|
-
init_item(shape_format)
|
73
|
-
# In the case of ImageBlock, Return the nil constantly.
|
74
|
-
when ImageBlock::TYPE_NAME
|
75
|
-
nil
|
76
|
-
else
|
77
|
-
init_item(shape_format)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# @param [Thinreports::Core::Shape::Basic::Format] format
|
83
|
-
def init_item(format)
|
84
|
-
@init_item_handler.call(format)
|
85
|
-
end
|
86
|
-
|
87
|
-
# @param [String] type
|
88
|
-
# @param [Hash] limit
|
89
|
-
# @option limit [String] :only
|
90
|
-
# @option limit [String] :except
|
91
|
-
# @return [Booldan]
|
92
|
-
def valid_type?(type, limit = {})
|
93
|
-
return true if limit.empty?
|
94
|
-
|
95
|
-
if limit[:only]
|
96
|
-
type == limit[:only]
|
97
|
-
elsif limit[:except]
|
98
|
-
type != limit[:except]
|
99
|
-
else
|
100
|
-
raise ArgumentError
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|