thinreports 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +41 -0
- data/.travis.yml +4 -6
- data/CHANGELOG.md +21 -2
- data/Gemfile +2 -4
- data/README.md +4 -5
- data/Rakefile +7 -8
- data/examples/character_spacing/character_spacing.rb +1 -1
- data/examples/dynamic_image/dynamic_image.rb +3 -3
- data/examples/dynamic_style/dynamic_style.rb +1 -1
- data/examples/eudc/eudc.rb +1 -1
- data/examples/helper.rb +2 -2
- data/examples/hidden_shapes/hidden_shapes.rb +1 -1
- data/examples/list_events/list_events.rb +1 -1
- data/examples/list_manual_generation/list_manual_generation.rb +1 -1
- data/examples/list_page_number/list_page_number.rb +1 -1
- data/examples/page_number/page_number.rb +1 -1
- data/examples/palleted_png/palleted_png.rb +1 -3
- data/examples/password_setting/password_setting.rb +1 -1
- data/examples/report_callbacks/report_callbacks.rb +1 -1
- data/examples/single_line_tblock/single_line_tblock.rb +1 -1
- data/examples/tblock_overflow/tblock_overflow.rb +1 -1
- data/examples/tblock_styles/tblock_styles.rb +1 -1
- data/examples/text_align/text_align.rb +1 -1
- data/examples/typeB_page_size/typeB_page_size.rb +1 -1
- data/examples/word_wrap/word_wrap.rb +1 -1
- data/lib/thinreports.rb +16 -15
- data/lib/thinreports/config.rb +2 -24
- data/lib/thinreports/core/errors.rb +6 -17
- data/lib/thinreports/core/format/base.rb +62 -61
- data/lib/thinreports/core/shape.rb +13 -14
- data/lib/thinreports/core/shape/base.rb +3 -12
- data/lib/thinreports/core/shape/base/interface.rb +35 -32
- data/lib/thinreports/core/shape/base/internal.rb +45 -43
- data/lib/thinreports/core/shape/basic.rb +12 -12
- data/lib/thinreports/core/shape/basic/block_format.rb +8 -6
- data/lib/thinreports/core/shape/basic/block_interface.rb +24 -22
- data/lib/thinreports/core/shape/basic/block_internal.rb +28 -26
- data/lib/thinreports/core/shape/basic/format.rb +11 -9
- data/lib/thinreports/core/shape/basic/interface.rb +79 -77
- data/lib/thinreports/core/shape/basic/internal.rb +17 -14
- data/lib/thinreports/core/shape/image_block.rb +9 -9
- data/lib/thinreports/core/shape/image_block/format.rb +7 -5
- data/lib/thinreports/core/shape/image_block/interface.rb +15 -13
- data/lib/thinreports/core/shape/image_block/internal.rb +10 -8
- data/lib/thinreports/core/shape/list.rb +13 -13
- data/lib/thinreports/core/shape/list/format.rb +83 -77
- data/lib/thinreports/core/shape/list/manager.rb +182 -176
- data/lib/thinreports/core/shape/list/page.rb +94 -93
- data/lib/thinreports/core/shape/list/page_state.rb +42 -40
- data/lib/thinreports/core/shape/list/section_format.rb +28 -26
- data/lib/thinreports/core/shape/list/section_interface.rb +42 -40
- data/lib/thinreports/core/shape/list/section_internal.rb +21 -19
- data/lib/thinreports/core/shape/manager.rb +4 -13
- data/lib/thinreports/core/shape/manager/format.rb +21 -19
- data/lib/thinreports/core/shape/manager/internal.rb +88 -84
- data/lib/thinreports/core/shape/manager/target.rb +93 -95
- data/lib/thinreports/core/shape/page_number.rb +9 -9
- data/lib/thinreports/core/shape/page_number/format.rb +20 -18
- data/lib/thinreports/core/shape/page_number/interface.rb +20 -18
- data/lib/thinreports/core/shape/page_number/internal.rb +47 -44
- data/lib/thinreports/core/shape/style.rb +5 -14
- data/lib/thinreports/core/shape/style/base.rb +121 -120
- data/lib/thinreports/core/shape/style/basic.rb +12 -10
- data/lib/thinreports/core/shape/style/graphic.rb +35 -33
- data/lib/thinreports/core/shape/style/text.rb +113 -107
- data/lib/thinreports/core/shape/text.rb +9 -9
- data/lib/thinreports/core/shape/text/format.rb +10 -9
- data/lib/thinreports/core/shape/text/interface.rb +13 -11
- data/lib/thinreports/core/shape/text/internal.rb +14 -12
- data/lib/thinreports/core/shape/text_block.rb +10 -10
- data/lib/thinreports/core/shape/text_block/format.rb +35 -33
- data/lib/thinreports/core/shape/text_block/formatter.rb +26 -24
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +25 -25
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +15 -12
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +45 -39
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +17 -14
- data/lib/thinreports/core/shape/text_block/interface.rb +25 -23
- data/lib/thinreports/core/shape/text_block/internal.rb +68 -68
- data/lib/thinreports/core/utils.rb +4 -3
- data/lib/thinreports/generator/pdf.rb +24 -25
- data/lib/thinreports/generator/pdf/document.rb +109 -110
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +58 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +51 -47
- data/lib/thinreports/generator/pdf/document/font.rb +62 -59
- data/lib/thinreports/generator/pdf/document/graphics.rb +32 -33
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +122 -121
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +113 -114
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +58 -150
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +152 -137
- data/lib/thinreports/generator/pdf/document/page.rb +63 -64
- data/lib/thinreports/generator/pdf/document/parse_color.rb +37 -37
- data/lib/thinreports/generator/pdf/drawer/base.rb +41 -41
- data/lib/thinreports/generator/pdf/drawer/list.rb +48 -45
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +42 -40
- data/lib/thinreports/generator/pdf/drawer/page.rb +101 -96
- data/lib/thinreports/generator/pdf/prawn_ext.rb +4 -30
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +29 -0
- data/lib/thinreports/layout.rb +5 -7
- data/lib/thinreports/layout/base.rb +5 -7
- data/lib/thinreports/layout/format.rb +18 -13
- data/lib/thinreports/layout/legacy_schema.rb +18 -10
- data/lib/thinreports/layout/version.rb +22 -25
- data/lib/thinreports/report.rb +4 -6
- data/lib/thinreports/report/base.rb +24 -51
- data/lib/thinreports/report/internal.rb +9 -11
- data/lib/thinreports/report/page.rb +5 -6
- data/lib/thinreports/version.rb +2 -2
- data/test/schema_helper.rb +4 -3
- data/test/test_helper.rb +9 -3
- data/test/unit/core/format/test_base.rb +1 -1
- data/test/unit/core/shape/base/test_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_block_format.rb +1 -1
- data/test/unit/core/shape/basic/test_block_interface.rb +1 -1
- data/test/unit/core/shape/basic/test_block_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_format.rb +1 -1
- data/test/unit/core/shape/basic/test_interface.rb +1 -1
- data/test/unit/core/shape/basic/test_internal.rb +1 -1
- data/test/unit/core/shape/image_block/test_interface.rb +1 -1
- data/test/unit/core/shape/image_block/test_internal.rb +1 -1
- data/test/unit/core/shape/list/test_format.rb +1 -1
- data/test/unit/core/shape/list/test_manager.rb +4 -4
- data/test/unit/core/shape/list/test_page.rb +1 -1
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/list/test_section_format.rb +1 -1
- data/test/unit/core/shape/list/test_section_interface.rb +2 -2
- data/test/unit/core/shape/list/test_section_internal.rb +1 -1
- data/test/unit/core/shape/manager/test_format.rb +2 -2
- data/test/unit/core/shape/manager/test_internal.rb +3 -3
- data/test/unit/core/shape/manager/test_target.rb +1 -1
- data/test/unit/core/shape/page_number/test_format.rb +1 -1
- data/test/unit/core/shape/page_number/test_interface.rb +1 -1
- data/test/unit/core/shape/page_number/test_internal.rb +1 -1
- data/test/unit/core/shape/styles/test_base.rb +1 -1
- data/test/unit/core/shape/styles/test_basic.rb +1 -1
- data/test/unit/core/shape/styles/test_graphic.rb +1 -1
- data/test/unit/core/shape/styles/test_text.rb +1 -1
- data/test/unit/core/shape/text/test_format.rb +1 -1
- data/test/unit/core/shape/text/test_internal.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_number.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +2 -2
- data/test/unit/core/shape/text_block/test_format.rb +1 -1
- data/test/unit/core/shape/text_block/test_formatter.rb +1 -1
- data/test/unit/core/shape/text_block/test_interface.rb +1 -1
- data/test/unit/core/shape/text_block/test_internal.rb +3 -3
- data/test/unit/core/test_shape.rb +1 -1
- data/test/unit/core/test_utils.rb +2 -2
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +1 -1
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +2 -1
- data/test/unit/generator/pdf/document/graphics/test_image.rb +27 -131
- data/test/unit/generator/pdf/document/graphics/test_text.rb +1 -1
- data/test/unit/generator/pdf/document/test_font.rb +2 -2
- data/test/unit/generator/pdf/document/test_graphics.rb +1 -1
- data/test/unit/generator/pdf/document/test_page.rb +7 -7
- data/test/unit/generator/pdf/document/test_parse_color.rb +1 -1
- data/test/unit/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +41 -0
- data/test/unit/generator/pdf/prawn_ext/test_width_of.rb +22 -0
- data/test/unit/generator/pdf/test_document.rb +8 -6
- data/test/unit/generator/test_pdf.rb +12 -10
- data/test/unit/layout/test_base.rb +1 -1
- data/test/unit/layout/test_format.rb +2 -2
- data/test/unit/layout/test_legacy_schema.rb +4 -4
- data/test/unit/layout/test_version.rb +11 -80
- data/test/unit/report/test_base.rb +45 -59
- data/test/unit/report/test_internal.rb +1 -1
- data/test/unit/test_config.rb +1 -16
- data/test/unit/test_layout.rb +1 -1
- data/test/unit/test_report.rb +1 -1
- data/thinreports.gemspec +11 -14
- metadata +42 -103
- data/lib/thinreports/generator.rb +0 -29
- data/lib/thinreports/generator/base.rb +0 -40
- data/lib/thinreports/generator/configuration.rb +0 -31
- data/lib/thinreports/report/events.rb +0 -32
- data/test/unit/generator/test_base.rb +0 -40
- data/test/unit/generator/test_configuration.rb +0 -21
@@ -1,32 +1,34 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Basic
|
7
|
+
class BlockInternal < Basic::Internal
|
8
|
+
format_delegators :box
|
9
|
+
|
10
|
+
def style
|
11
|
+
@style ||= Style::Basic.new(format)
|
12
|
+
end
|
13
|
+
|
14
|
+
def read_value
|
15
|
+
states.key?(:value) ? states[:value] : format.value.dup
|
16
|
+
end
|
17
|
+
alias value read_value
|
18
|
+
|
19
|
+
def write_value(val)
|
20
|
+
states[:value] = val
|
21
|
+
end
|
22
|
+
|
23
|
+
def real_value
|
24
|
+
read_value
|
25
|
+
end
|
26
|
+
|
27
|
+
def type_of?(type_name)
|
28
|
+
type_name == :block
|
29
|
+
end
|
30
|
+
end
|
28
31
|
end
|
29
32
|
end
|
30
|
-
|
31
33
|
end
|
32
34
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Basic
|
7
|
+
class Format < Core::Format::Base
|
8
|
+
include Utils
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
config_checker true, :display
|
10
|
+
config_reader :type, :id
|
11
|
+
config_reader :style
|
12
|
+
config_checker true, :display
|
13
|
+
end
|
14
|
+
end
|
12
15
|
end
|
13
|
-
|
14
16
|
end
|
15
17
|
end
|
@@ -1,83 +1,85 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Basic
|
7
|
+
class Interface < Base::Interface
|
8
|
+
internal_delegators :type
|
9
|
+
|
10
|
+
# @return [String]
|
11
|
+
def id
|
12
|
+
internal.id.dup
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param [Boolean] visibility
|
16
|
+
# @return [self]
|
17
|
+
def visible(visibility)
|
18
|
+
internal.style.visible = visibility
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Boolean]
|
23
|
+
def visible?
|
24
|
+
internal.style.visible
|
25
|
+
end
|
26
|
+
|
27
|
+
# @overload style(style_name)
|
28
|
+
# @param [Symbol] style_name
|
29
|
+
# @return [Object]
|
30
|
+
# @overload style(style_name, value)
|
31
|
+
# @param [Symbol] style_name
|
32
|
+
# @param [String, Symbol, Number, Array] value
|
33
|
+
# @return [self]
|
34
|
+
# @overload style(style_name, value1, value2)
|
35
|
+
# @param [Symbol] style_name
|
36
|
+
# @param [String, Number] value1
|
37
|
+
# @param [String, Number] value2
|
38
|
+
# @return [self]
|
39
|
+
def style(*args)
|
40
|
+
case args.length
|
41
|
+
when 1
|
42
|
+
internal.style[args.first]
|
43
|
+
when 2
|
44
|
+
internal.style[args.first] = args.last
|
45
|
+
self
|
46
|
+
when 3
|
47
|
+
internal.style[args.shift] = args
|
48
|
+
self
|
49
|
+
else
|
50
|
+
raise ArgumentError, '#style requires 1 or 2, 3 arguments'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param [Hash] settings style_name: value
|
55
|
+
# @return [self]
|
56
|
+
def styles(settings)
|
57
|
+
settings.each { |args| style(*args) }
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
# @see #visible
|
62
|
+
# @return [self]
|
63
|
+
def hide
|
64
|
+
visible(false)
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
# @see #visible
|
69
|
+
# @return [self]
|
70
|
+
def show
|
71
|
+
visible(true)
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
78
|
+
def init_internal(parent, format)
|
79
|
+
Basic::Internal.new(parent, format)
|
80
|
+
end
|
50
81
|
end
|
51
82
|
end
|
52
|
-
|
53
|
-
# @param [Hash] settings style_name: value
|
54
|
-
# @return [self]
|
55
|
-
def styles(settings)
|
56
|
-
settings.each{ |args| style(*args) }
|
57
|
-
self
|
58
|
-
end
|
59
|
-
|
60
|
-
# @see #visible
|
61
|
-
# @return [self]
|
62
|
-
def hide
|
63
|
-
visible(false)
|
64
|
-
self
|
65
|
-
end
|
66
|
-
|
67
|
-
# @see #visible
|
68
|
-
# @return [self]
|
69
|
-
def show
|
70
|
-
visible(true)
|
71
|
-
self
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
77
|
-
def init_internal(parent, format)
|
78
|
-
Basic::Internal.new(parent, format)
|
79
|
-
end
|
80
83
|
end
|
81
|
-
|
82
84
|
end
|
83
|
-
end
|
85
|
+
end
|
@@ -1,22 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Basic
|
7
|
+
class Internal < Base::Internal
|
8
|
+
# Delegate to Format's methods
|
9
|
+
format_delegators :id, :type
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
def style
|
12
|
+
@style ||= Style::Graphic.new(format)
|
13
|
+
end
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def type_of?(type_name)
|
15
|
-
[:basic, self.type].include?(type_name)
|
16
|
-
end
|
15
|
+
def type_of?(type_name)
|
16
|
+
[:basic, type].include?(type_name)
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def identifier
|
20
|
+
"#{id}#{style.identifier}"
|
21
|
+
end
|
22
|
+
end
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module ImageBlock
|
7
|
+
TYPE_NAME = 'image-block'.freeze
|
8
|
+
end
|
8
9
|
end
|
9
|
-
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
require_relative 'image_block/format'
|
14
|
+
require_relative 'image_block/internal'
|
15
|
+
require_relative 'image_block/interface'
|
@@ -1,10 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
5
|
-
|
6
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module ImageBlock
|
7
|
+
class Format < Basic::BlockFormat
|
8
|
+
end
|
9
|
+
end
|
7
10
|
end
|
8
|
-
|
9
11
|
end
|
10
12
|
end
|
@@ -1,21 +1,23 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module ImageBlock
|
7
|
+
class Interface < Basic::BlockInterface
|
8
|
+
# @see #value
|
9
|
+
alias src value
|
10
|
+
# @see #value=
|
11
|
+
alias src= value=
|
5
12
|
|
6
|
-
|
7
|
-
# @see #value
|
8
|
-
alias_method :src, :value
|
9
|
-
# @see #value=
|
10
|
-
alias_method :src=, :value=
|
13
|
+
private
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
16
|
+
def init_internal(parent, format)
|
17
|
+
ImageBlock::Internal.new(parent, format)
|
18
|
+
end
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
|
-
|
20
22
|
end
|
21
23
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module ImageBlock
|
7
|
+
class Internal < Basic::BlockInternal
|
8
|
+
alias src read_value
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
type_name == ImageBlock::TYPE_NAME || super
|
10
|
+
def type_of?(type_name)
|
11
|
+
type_name == ImageBlock::TYPE_NAME || super
|
12
|
+
end
|
13
|
+
end
|
11
14
|
end
|
12
15
|
end
|
13
|
-
|
14
16
|
end
|
15
17
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module List
|
7
|
+
TYPE_NAME = 'list'.freeze
|
8
|
+
end
|
8
9
|
end
|
9
|
-
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
require_relative 'list/format'
|
14
|
+
require_relative 'list/manager'
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
require_relative 'list/page'
|
17
|
+
require_relative 'list/page_state'
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
require_relative 'list/section_format'
|
20
|
+
require_relative 'list/section_interface'
|
21
|
+
require_relative 'list/section_internal'
|
@@ -1,84 +1,90 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module List
|
7
|
+
class Format < Basic::Format
|
8
|
+
config_reader height: %w[content-height]
|
9
|
+
config_checker true, auto_page_break: %w[auto-page-break]
|
10
|
+
|
11
|
+
# @deprecated
|
12
|
+
config_reader :header,
|
13
|
+
:detail,
|
14
|
+
:footer
|
15
|
+
# @deprecated
|
16
|
+
config_reader page_footer: %w[page-footer]
|
17
|
+
|
18
|
+
config_checker true, has_header: %w[header enabled]
|
19
|
+
config_checker true, has_footer: %w[footer enabled]
|
20
|
+
config_checker true, has_page_footer: %w[page-footer enabled]
|
21
|
+
|
22
|
+
config_reader page_footer_height: %w[page-footer height]
|
23
|
+
config_reader footer_height: %w[footer height]
|
24
|
+
config_reader header_height: %w[header height]
|
25
|
+
config_reader detail_height: %w[detail height]
|
26
|
+
|
27
|
+
attr_reader :sections
|
28
|
+
|
29
|
+
def initialize(*)
|
30
|
+
super
|
31
|
+
initialize_sections
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param [Symbol] section_name
|
35
|
+
# @return [Hash]
|
36
|
+
# @deprecated
|
37
|
+
def section(section_name)
|
38
|
+
__send__(section_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @param [Symbol] section_name
|
42
|
+
# @return [Boolean]
|
43
|
+
def has_section?(section_name)
|
44
|
+
section_name == :detail ? true : __send__(:"has_#{section_name}?")
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param [Symbol] section_name
|
48
|
+
# @return [Numeric]
|
49
|
+
def section_height(section_name)
|
50
|
+
has_section?(section_name) ? __send__(:"#{section_name}_height") : 0
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param [:detai, :header, :page_footer, :footer] section_name
|
54
|
+
# @return [Numeric]
|
55
|
+
def section_base_position_top(section_name)
|
56
|
+
section = @sections[section_name]
|
57
|
+
return 0 unless has_section?(section_name)
|
58
|
+
|
59
|
+
top = section.relative_top
|
60
|
+
|
61
|
+
case section_name
|
62
|
+
when :page_footer
|
63
|
+
top - section_height(:detail)
|
64
|
+
when :footer
|
65
|
+
top - section_height(:detail) - section_height(:page_footer)
|
66
|
+
else
|
67
|
+
top
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def initialize_sections
|
74
|
+
@sections = {
|
75
|
+
detail: List::SectionFormat.new(attributes['detail'])
|
76
|
+
}
|
77
|
+
|
78
|
+
@sections[:header] = section_format('header') if has_section?(:header)
|
79
|
+
@sections[:page_footer] = section_format('page-footer') if has_section?(:page_footer)
|
80
|
+
@sections[:footer] = section_format('footer') if has_section?(:footer)
|
81
|
+
end
|
82
|
+
|
83
|
+
def section_format(section_name)
|
84
|
+
List::SectionFormat.new(attributes[section_name])
|
85
|
+
end
|
67
86
|
end
|
68
87
|
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def initialize_sections
|
73
|
-
@sections = {
|
74
|
-
detail: List::SectionFormat.new(attributes['detail'])
|
75
|
-
}
|
76
|
-
|
77
|
-
@sections[:header] = List::SectionFormat.new(attributes['header']) if has_section?(:header)
|
78
|
-
@sections[:page_footer] = List::SectionFormat.new(attributes['page-footer']) if has_section?(:page_footer)
|
79
|
-
@sections[:footer] = List::SectionFormat.new(attributes['footer']) if has_section?(:footer)
|
80
|
-
end
|
81
88
|
end
|
82
|
-
|
83
89
|
end
|
84
90
|
end
|