thinreports 0.6.0.pre3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. data/.yardopts +1 -0
  2. data/README.rdoc +100 -0
  3. data/Rakefile +10 -0
  4. data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
  5. data/lib/thinreports.rb +11 -0
  6. data/lib/thinreports/core.rb +20 -0
  7. data/lib/thinreports/core/errors.rb +58 -0
  8. data/lib/thinreports/core/events.rb +71 -0
  9. data/lib/thinreports/core/ext.rb +5 -0
  10. data/lib/thinreports/core/ext/array.rb +19 -0
  11. data/lib/thinreports/core/ext/hash.rb +19 -0
  12. data/lib/thinreports/core/ext/object.rb +25 -0
  13. data/lib/thinreports/core/format.rb +14 -0
  14. data/lib/thinreports/core/format/base.rb +93 -0
  15. data/lib/thinreports/core/format/builder.rb +65 -0
  16. data/lib/thinreports/core/ordered_hash.rb +39 -0
  17. data/lib/thinreports/core/page.rb +91 -0
  18. data/lib/thinreports/core/shape.rb +53 -0
  19. data/lib/thinreports/core/shape/base.rb +16 -0
  20. data/lib/thinreports/core/shape/base/interface.rb +38 -0
  21. data/lib/thinreports/core/shape/base/internal.rb +60 -0
  22. data/lib/thinreports/core/shape/basic.rb +15 -0
  23. data/lib/thinreports/core/shape/basic/format.rb +26 -0
  24. data/lib/thinreports/core/shape/basic/interface.rb +57 -0
  25. data/lib/thinreports/core/shape/basic/internal.rb +29 -0
  26. data/lib/thinreports/core/shape/list.rb +25 -0
  27. data/lib/thinreports/core/shape/list/configuration.rb +33 -0
  28. data/lib/thinreports/core/shape/list/events.rb +30 -0
  29. data/lib/thinreports/core/shape/list/format.rb +72 -0
  30. data/lib/thinreports/core/shape/list/manager.rb +209 -0
  31. data/lib/thinreports/core/shape/list/page.rb +118 -0
  32. data/lib/thinreports/core/shape/list/page_state.rb +40 -0
  33. data/lib/thinreports/core/shape/list/section_format.rb +32 -0
  34. data/lib/thinreports/core/shape/list/section_interface.rb +48 -0
  35. data/lib/thinreports/core/shape/list/section_internal.rb +29 -0
  36. data/lib/thinreports/core/shape/list/store.rb +34 -0
  37. data/lib/thinreports/core/shape/manager.rb +14 -0
  38. data/lib/thinreports/core/shape/manager/format.rb +28 -0
  39. data/lib/thinreports/core/shape/manager/internal.rb +87 -0
  40. data/lib/thinreports/core/shape/manager/target.rb +85 -0
  41. data/lib/thinreports/core/shape/tblock.rb +16 -0
  42. data/lib/thinreports/core/shape/tblock/format.rb +36 -0
  43. data/lib/thinreports/core/shape/tblock/formatter.rb +32 -0
  44. data/lib/thinreports/core/shape/tblock/formatter/basic.rb +38 -0
  45. data/lib/thinreports/core/shape/tblock/formatter/datetime.rb +21 -0
  46. data/lib/thinreports/core/shape/tblock/formatter/number.rb +49 -0
  47. data/lib/thinreports/core/shape/tblock/formatter/padding.rb +43 -0
  48. data/lib/thinreports/core/shape/tblock/interface.rb +52 -0
  49. data/lib/thinreports/core/shape/tblock/internal.rb +70 -0
  50. data/lib/thinreports/core/shape/text.rb +15 -0
  51. data/lib/thinreports/core/shape/text/format.rb +25 -0
  52. data/lib/thinreports/core/shape/text/interface.rb +16 -0
  53. data/lib/thinreports/core/shape/text/internal.rb +17 -0
  54. data/lib/thinreports/core/utils.rb +48 -0
  55. data/lib/thinreports/generator.rb +30 -0
  56. data/lib/thinreports/generator/base.rb +49 -0
  57. data/lib/thinreports/generator/pdf.rb +63 -0
  58. data/lib/thinreports/generator/pdf/document.rb +171 -0
  59. data/lib/thinreports/generator/pdf/document/draw_shape.rb +74 -0
  60. data/lib/thinreports/generator/pdf/document/font.rb +59 -0
  61. data/lib/thinreports/generator/pdf/document/graphics.rb +42 -0
  62. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +92 -0
  63. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +132 -0
  64. data/lib/thinreports/generator/pdf/document/graphics/image.rb +51 -0
  65. data/lib/thinreports/generator/pdf/document/graphics/text.rb +130 -0
  66. data/lib/thinreports/generator/pdf/document/parse_color.rb +51 -0
  67. data/lib/thinreports/generator/pdf/document/parse_svg.rb +102 -0
  68. data/lib/thinreports/generator/pdf/drawer.rb +16 -0
  69. data/lib/thinreports/generator/pdf/drawer/base.rb +56 -0
  70. data/lib/thinreports/generator/pdf/drawer/list.rb +39 -0
  71. data/lib/thinreports/generator/pdf/drawer/list_section.rb +46 -0
  72. data/lib/thinreports/generator/pdf/drawer/page.rb +101 -0
  73. data/lib/thinreports/generator/pdf/prawn_ext.rb +36 -0
  74. data/lib/thinreports/generator/pxd.rb +75 -0
  75. data/lib/thinreports/generator/pxd/helper.rb +33 -0
  76. data/lib/thinreports/generator/pxd/list_renderer.rb +58 -0
  77. data/lib/thinreports/generator/pxd/page_renderer.rb +75 -0
  78. data/lib/thinreports/layout.rb +17 -0
  79. data/lib/thinreports/layout/base.rb +78 -0
  80. data/lib/thinreports/layout/configuration.rb +27 -0
  81. data/lib/thinreports/layout/format.rb +77 -0
  82. data/lib/thinreports/layout/version.rb +43 -0
  83. data/lib/thinreports/report.rb +31 -0
  84. data/lib/thinreports/report/base.rb +160 -0
  85. data/lib/thinreports/report/events.rb +32 -0
  86. data/lib/thinreports/report/internal.rb +131 -0
  87. data/resources/fonts/IPA_Font_License_Agreement_v1.0.txt +117 -0
  88. data/resources/fonts/ipag.ttf +0 -0
  89. data/resources/fonts/ipagp.ttf +0 -0
  90. data/resources/fonts/ipam.ttf +0 -0
  91. data/resources/fonts/ipamp.ttf +0 -0
  92. data/tasks/clean.rake +6 -0
  93. data/tasks/doc.rake +13 -0
  94. data/tasks/test.rake +18 -0
  95. data/test/unit/core/ext/array_spec.rb +29 -0
  96. data/test/unit/core/ext/hash_spec.rb +29 -0
  97. data/test/unit/core/ext/object_spec.rb +30 -0
  98. data/test/unit/core/format/test_base.rb +148 -0
  99. data/test/unit/core/format/test_builder.rb +114 -0
  100. data/test/unit/core/ordered_hash_spec.rb +51 -0
  101. data/test/unit/core/shape/base/test_interface.rb +52 -0
  102. data/test/unit/core/shape/base/test_internal.rb +109 -0
  103. data/test/unit/core/shape/basic/test_format.rb +59 -0
  104. data/test/unit/core/shape/basic/test_interface.rb +70 -0
  105. data/test/unit/core/shape/basic/test_internal.rb +42 -0
  106. data/test/unit/core/shape/list/test_configuration.rb +52 -0
  107. data/test/unit/core/shape/list/test_events.rb +28 -0
  108. data/test/unit/core/shape/list/test_format.rb +71 -0
  109. data/test/unit/core/shape/list/test_page.rb +10 -0
  110. data/test/unit/core/shape/list/test_page_state.rb +31 -0
  111. data/test/unit/core/shape/list/test_section_format.rb +46 -0
  112. data/test/unit/core/shape/list/test_section_interface.rb +52 -0
  113. data/test/unit/core/shape/list/test_section_internal.rb +30 -0
  114. data/test/unit/core/shape/list/test_store.rb +41 -0
  115. data/test/unit/core/shape/manager/test_format.rb +40 -0
  116. data/test/unit/core/shape/manager/test_internal.rb +137 -0
  117. data/test/unit/core/shape/manager/test_target.rb +109 -0
  118. data/test/unit/core/shape/tblock/formatter/test_basic.rb +24 -0
  119. data/test/unit/core/shape/tblock/formatter/test_datetime.rb +47 -0
  120. data/test/unit/core/shape/tblock/formatter/test_number.rb +76 -0
  121. data/test/unit/core/shape/tblock/formatter/test_padding.rb +72 -0
  122. data/test/unit/core/shape/tblock/test_format.rb +125 -0
  123. data/test/unit/core/shape/tblock/test_formatter.rb +28 -0
  124. data/test/unit/core/shape/tblock/test_interface.rb +40 -0
  125. data/test/unit/core/shape/tblock/test_internal.rb +139 -0
  126. data/test/unit/core/shape/text/test_format.rb +73 -0
  127. data/test/unit/core/shape/text/test_internal.rb +21 -0
  128. data/test/unit/core/test_events.rb +91 -0
  129. data/test/unit/core/test_shape.rb +35 -0
  130. data/test/unit/core/utils_spec.rb +56 -0
  131. data/test/unit/generator/pdf/document/graphics/test_attributes.rb +103 -0
  132. data/test/unit/generator/pdf/document/test_font.rb +54 -0
  133. data/test/unit/generator/pdf/document/test_graphics.rb +43 -0
  134. data/test/unit/generator/pdf/document/test_parse_color.rb +30 -0
  135. data/test/unit/generator/test_base.rb +51 -0
  136. data/test/unit/helper.rb +37 -0
  137. data/test/unit/layout/test_base.rb +92 -0
  138. data/test/unit/layout/test_configuration.rb +46 -0
  139. data/test/unit/layout/test_format.rb +104 -0
  140. data/test/unit/layout/test_version.rb +62 -0
  141. data/test/unit/report/test_base.rb +187 -0
  142. data/test/unit/report/test_events.rb +22 -0
  143. data/test/unit/report/test_internal.rb +234 -0
  144. data/test/unit/test_layout.rb +12 -0
  145. data/test/unit/test_report.rb +30 -0
  146. metadata +218 -0
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+
3
+ module ThinReports
4
+ module Core::Shape
5
+
6
+ # @private
7
+ class Basic::Internal < Base::Internal
8
+ # Delegate to Format's methods
9
+ format_delegators :id, :svg_tag, :svg_attrs, :type
10
+
11
+ def visible(visibility)
12
+ states[:display] = visibility
13
+ end
14
+
15
+ def visible?
16
+ states.key?(:display) ? states[:display] : format.display?
17
+ end
18
+
19
+ def svg_attr(attr_name, value)
20
+ attrs[attr_name.to_s] = value
21
+ end
22
+
23
+ def type_of?(type_name)
24
+ ['s-basic', self.type].include?("s-#{type_name}")
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+
3
+ module ThinReports
4
+ module Core::Shape
5
+
6
+ module List
7
+ TYPE_NAME = 's-list'
8
+ end
9
+
10
+ end
11
+ end
12
+
13
+ require 'thinreports/core/shape/list/format'
14
+ require 'thinreports/core/shape/list/manager'
15
+
16
+ require 'thinreports/core/shape/list/page'
17
+ require 'thinreports/core/shape/list/page_state'
18
+
19
+ require 'thinreports/core/shape/list/section_format'
20
+ require 'thinreports/core/shape/list/section_interface'
21
+ require 'thinreports/core/shape/list/section_internal'
22
+
23
+ require 'thinreports/core/shape/list/store'
24
+ require 'thinreports/core/shape/list/events'
25
+ require 'thinreports/core/shape/list/configuration'
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+
3
+ module ThinReports
4
+ module Core::Shape
5
+
6
+ class List::Configuration
7
+ # @return [ThinReports::Core::Shape::List::Events]
8
+ attr_reader :events
9
+
10
+ # @return [ThinReports::Core::Shape::List::Store]
11
+ attr_reader :store
12
+
13
+ # @param [ThinReports::Core::Shape::List::Events, nil] events (nil)
14
+ # @param [ThinReports::Core::Shape::List::Store, nil] store (nil)
15
+ def initialize(events = nil, store = nil)
16
+ @events = events || List::Events.new
17
+ @store = store
18
+ end
19
+
20
+ # @param [Hash] stores :name => default value
21
+ def use_stores(stores)
22
+ @store = List::Store.init(stores)
23
+ end
24
+
25
+ # @return [ThinReports::Core::Shape::List::Configuration]
26
+ # @private
27
+ def copy
28
+ self.class.new(@events.copy, @store && @store.copy)
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ module ThinReports
4
+ module Core::Shape
5
+
6
+ class List::Events < Core::Events
7
+ def initialize
8
+ super(:page_footer_insert,
9
+ :footer_insert)
10
+ end
11
+
12
+ class SectionEvent < Event
13
+ # @return [ThinReports::Core::Shape::List::Store]
14
+ attr_reader :store
15
+
16
+ # @param type (see ThinReports::Core::Events::Event#initialize)
17
+ # @param target (see ThinReports::Core::Events::Event#initialize)
18
+ # @param [ThinReports::Core::Shape::List::Store] store
19
+ def initialize(type, target, store)
20
+ super(type, target)
21
+ @store = store
22
+ end
23
+
24
+ # @return [ThinReports::Core::Shape::List::SectionInterface]
25
+ alias_method :section, :target
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,72 @@
1
+ # coding: utf-8
2
+
3
+ module ThinReports
4
+ module Core::Shape
5
+
6
+ # @private
7
+ class List::Format < Basic::Format
8
+ config_reader :height => %w( content-height )
9
+ config_checker 'true', :auto_page_break => %w( page-break )
10
+
11
+ config_reader :header,
12
+ :detail,
13
+ :footer
14
+ config_reader :page_footer => %w( page-footer )
15
+
16
+ config_checker 'true', :has_header => %w( header-enabled )
17
+ config_checker 'true', :has_footer => %w( footer-enabled )
18
+ config_checker 'true', :has_page_footer => %w( page-footer-enabled )
19
+
20
+ config_reader :page_footer_height => %w( page-footer height )
21
+ config_reader :footer_height => %w( footer height )
22
+ config_reader :header_height => %w( header height )
23
+ config_reader :detail_height => %w( detail height )
24
+
25
+ config_accessor :sections
26
+
27
+ # @param [Symbol] section_name
28
+ # @return [Hash]
29
+ def section(section_name)
30
+ __send__(section_name)
31
+ end
32
+
33
+ # @param [Symbol] section_name
34
+ # @return [Boolean]
35
+ def has_section?(section_name)
36
+ section_name == :detail ? true : __send__(:"has_#{section_name}?")
37
+ end
38
+
39
+ # @param [Symbol] section_name
40
+ # @return [Numeric]
41
+ def section_height(section_name)
42
+ has_section?(section_name) ? __send__(:"#{section_name}_height") : 0
43
+ end
44
+
45
+ class << self
46
+
47
+ private
48
+
49
+ # @param [Hash] raw_format
50
+ # @return [ThinReports::Core::Shape::List::Format]
51
+ def build_internal(raw_format)
52
+ new(raw_format) do |f|
53
+ f.sections = {}
54
+ build_section(:detail, f)
55
+ build_section(:header, f) if f.has_header?
56
+ build_section(:footer, f) if f.has_footer?
57
+ build_section(:page_footer, f) if f.has_page_footer?
58
+ end
59
+ end
60
+
61
+ # @param [Symbol] section_name
62
+ # @param [ThinReports::Core::Shape::List::Format] list
63
+ # @return [ThinReports::Core::Shape::List::SectionFormat]
64
+ def build_section(section_name, list)
65
+ list.sections[section_name] =
66
+ List::SectionFormat.build(list.section(section_name))
67
+ end
68
+ end
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,209 @@
1
+ # coding: utf-8
2
+
3
+ module ThinReports
4
+ module Core::Shape
5
+
6
+ # @private
7
+ class List::Manager
8
+ attr_reader :config
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
+ # @param [ThinReports::Core::Shape::List::Page] page
17
+ def initialize(page)
18
+ switch_current!(page)
19
+
20
+ @config = init_config
21
+ @finalized = false
22
+ end
23
+
24
+ # @param [ThinReports::Core::Shape::List::Page] page
25
+ # @return [ThinReports::Core::Shape::List::Manager]
26
+ def switch_current!(page)
27
+ @current_page = page
28
+ @current_page_state = page.internal
29
+ self
30
+ end
31
+
32
+ # @yield [new_list]
33
+ # @yieldparam [ThinReports::Core::Shape::List::Page] new_list
34
+ def change_new_page(&block)
35
+ finalize_page
36
+ new_page = report.internal.copy_page
37
+
38
+ if block_given?
39
+ block.call(new_page.list(current_page.id))
40
+ end
41
+ end
42
+
43
+ # @see List::Page#header
44
+ def header(values = {}, &block)
45
+ unless format.has_header?
46
+ raise ThinReports::Errors::DisabledListSection, 'header'
47
+ end
48
+ current_page_state.header ||= init_section(:header)
49
+ build_section(current_page_state.header, values, &block)
50
+ end
51
+
52
+ # @param (see #build_section)
53
+ # @return [Boolean]
54
+ def insert_new_detail(values = {}, &block)
55
+ return false if current_page_state.finalized?
56
+
57
+ successful = true
58
+
59
+ if overflow_with?(:detail)
60
+ if auto_page_break?
61
+ change_new_page do |new_list|
62
+ new_list.manager.insert_new_row(:detail, values, &block)
63
+ end
64
+ else
65
+ finalize
66
+ successful = false
67
+ end
68
+ else
69
+ insert_new_row(:detail, values, &block)
70
+ end
71
+ successful
72
+ end
73
+
74
+ # @see #build_section
75
+ def insert_new_row(section_name, values = {}, &block)
76
+ row = build_section(init_section(section_name), values, &block)
77
+ row.internal.move_top_to(current_page_state.height)
78
+
79
+ current_page_state.rows << row
80
+ current_page_state.height += row.height
81
+ row
82
+ end
83
+
84
+ # @param [ThinReports::Core::Shape::List::SectionInterface] section
85
+ # @param values (see ThinReports::Core::Shape::Manager::Target#values)
86
+ # @yield [section,]
87
+ # @yieldparam [ThinReports::Core::Shape::List::SectionInterface] section
88
+ # @return [ThinReports::Core::Shape::List::SectionInterface]
89
+ def build_section(section, values = {}, &block)
90
+ section.values(values)
91
+ block_exec_on(section, &block)
92
+ end
93
+
94
+ # @param [Symbol] section_name
95
+ # @return [ThinReports::Core::Shape::List::SectionInterface]
96
+ def init_section(section_name)
97
+ List::SectionInterface.new(current_page,
98
+ format.sections[section_name],
99
+ section_name)
100
+ end
101
+
102
+ # @param [Symbol] section_name
103
+ # @return [Boolean]
104
+ def overflow_with?(section_name = :detail)
105
+ height = format.section_height(section_name)
106
+ current_page_state.height + height > page_max_height
107
+ end
108
+
109
+ # @return [Numeric]
110
+ def page_max_height
111
+ unless @page_max_height
112
+ h = format.height
113
+ h -= format.section_height(:page_footer)
114
+ h -= format.section_height(:footer) unless auto_page_break?
115
+ @page_max_height = h
116
+ end
117
+ @page_max_height
118
+ end
119
+
120
+ # @return [ThinReports::Core::Shape::List::Store]
121
+ def store
122
+ config.store
123
+ end
124
+
125
+ # @return [ThinReports::Core::Shape::List::Events]
126
+ def events
127
+ config.events
128
+ end
129
+
130
+ # @return [Boolean]
131
+ def auto_page_break?
132
+ format.auto_page_break?
133
+ end
134
+
135
+ # @param [Hash] options
136
+ # @option [Boolean] :ignore_page_footer (false)
137
+ # @private
138
+ def finalize_page(options = {})
139
+ return if current_page_state.finalized?
140
+
141
+ if format.has_header?
142
+ current_page_state.header ||= init_section(:header)
143
+ end
144
+
145
+ if !options[:ignore_page_footer] && format.has_page_footer?
146
+ footer = insert_new_row(:page_footer)
147
+ # Dispatch event on footer insert.
148
+ events.
149
+ dispatch(List::Events::SectionEvent.new(:page_footer_insert,
150
+ footer, store))
151
+ end
152
+ current_page_state.finalized!
153
+ end
154
+
155
+ # @private
156
+ def finalize
157
+ return if finalized?
158
+
159
+ finalize_page
160
+
161
+ if format.has_footer?
162
+ footer = nil
163
+
164
+ if auto_page_break? && overflow_with?(:footer)
165
+ change_new_page do |new_list|
166
+ footer = new_list.manager.insert_new_row(:footer)
167
+ new_list.manager.finalize_page(:ignore_page_footer => true)
168
+ end
169
+ else
170
+ footer = insert_new_row(:footer)
171
+ end
172
+ # Dispatch event on footer insert.
173
+ events.dispatch(List::Events::SectionEvent.new(:footer_insert,
174
+ footer, store))
175
+ end
176
+ @finalized = true
177
+ end
178
+
179
+ # @return [Boolean]
180
+ # @private
181
+ def finalized?
182
+ @finalized
183
+ end
184
+
185
+ private
186
+
187
+ # @return [ThinReports::Report::Base]
188
+ def report
189
+ current_page_state.parent.report
190
+ end
191
+
192
+ # @return [ThinReports::Layout::Base]
193
+ def layout
194
+ current_page_state.parent.layout
195
+ end
196
+
197
+ # @return [ThinReports::Core::Shape::List::Format]
198
+ def format
199
+ current_page_state.format
200
+ end
201
+
202
+ # @return [ThinReports::Core::Shape::List::Configuration]
203
+ def init_config
204
+ layout.config.activate(current_page.id) || List::Configuration.new
205
+ end
206
+ end
207
+
208
+ end
209
+ end
@@ -0,0 +1,118 @@
1
+ # coding: utf-8
2
+
3
+ module ThinReports
4
+ module Core::Shape
5
+
6
+ class List::Page < Basic::Interface
7
+
8
+ # @param [ThinReports::Core::Page] parent
9
+ # @param [ThinReports::Core::Shape::Basic::Format] format
10
+ # @param [ThinReports::Core::Shape::List::PageState] internal (nil)
11
+ # @param [ThinReports::Core::Shape::List::Manager] manager (nil)
12
+ def initialize(parent, format, internal = nil, manager = nil)
13
+ super(parent, format, internal)
14
+
15
+ @manager = if manager
16
+ manager.switch_current!(self)
17
+ else
18
+ List::Manager.new(self)
19
+ end
20
+ end
21
+
22
+ # @param [Hash] values ({})
23
+ # @yield [header,]
24
+ # @yieldparam [ThinReports::Core::Shape::List::SectionInterface] header
25
+ # @return [ThinReports::Core::Shape::List::SectionInterface]
26
+ # @raise [ThinReports::Errors::DisabledListSection]
27
+ def header(values = {}, &block)
28
+ manager.header(values, &block)
29
+ end
30
+
31
+ # @param [Hash] values ({})
32
+ # @yield [row,]
33
+ # @yieldparam [ThinReports::Core::Shape::List::SectionInterface] row
34
+ # @return [Boolean]
35
+ def add_row(values = {}, &block)
36
+ manager.insert_new_detail(values, &block)
37
+ end
38
+
39
+ # If enabled, the auto-page-break of the list will force a page break
40
+ # at the time this method is called. Otherwise, this list will be finalized.
41
+ def page_break
42
+ if manager.auto_page_break?
43
+ manager.change_new_page
44
+ else
45
+ manager.finalize_page
46
+ end
47
+ end
48
+ alias_method :finalize, :page_break
49
+
50
+ # @return [Boolean] If overfilling the list to insert a detail row
51
+ # or already finalized, return the true. Otherwise false.
52
+ def overflow?
53
+ finalized? || manager.overflow_with?(:detail)
54
+ end
55
+
56
+ # @return [Boolean] Return the true,
57
+ # if the current page of list is already finalized.
58
+ def finalized?
59
+ internal.finalized?
60
+ end
61
+
62
+ # @return [ThinReports::Core::Shape::List::Configuration]
63
+ def config
64
+ manager.config
65
+ end
66
+
67
+ # @return [ThinReports::Core::Shape::List::Store]
68
+ def store
69
+ config.store
70
+ end
71
+
72
+ # @return [ThinReports::Core::Shape::List::Events]
73
+ def events
74
+ config.events
75
+ end
76
+
77
+ # @param [ThinReports::Core::Page] new_parent
78
+ # @return [ThinReports::Core::Shape::List::Page]
79
+ # @private
80
+ def copy(new_parent)
81
+ if manager.auto_page_break?
82
+ new_list = self.class.new(new_parent, internal.format,
83
+ nil, manager)
84
+ else
85
+ manager.finalize
86
+
87
+ new_list = self.class.new(new_parent, internal.format,
88
+ internal.copy(new_parent), manager)
89
+
90
+ new_list.internal.header = internal.header.copy(new_list)
91
+ internal.rows.each do |row|
92
+ new_list.internal.rows << row.copy(new_list)
93
+ end
94
+ new_list.finalized!
95
+ end
96
+ new_list
97
+ end
98
+
99
+ # @private
100
+ def manager
101
+ @manager
102
+ end
103
+
104
+ private
105
+
106
+ # @see ThinReports::Core::Shape::Base::Interface#init_internal
107
+ def init_internal(parent, format)
108
+ List::PageState.new(parent, format)
109
+ end
110
+ end
111
+
112
+ # Alias to List::Page.
113
+ # @see ThinReports::Core::Shape::List::Page
114
+ # @private
115
+ List::Interface = List::Page
116
+
117
+ end
118
+ end