thinreports 0.9.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +39 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +59 -2
- data/Dockerfile +12 -0
- data/Gemfile +7 -4
- data/README.md +44 -22
- data/Rakefile +14 -31
- 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 +10 -12
- data/lib/thinreports/core/shape/base.rb +3 -12
- data/lib/thinreports/core/shape/base/interface.rb +34 -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 +179 -176
- data/lib/thinreports/core/shape/list/page.rb +91 -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 +87 -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 +46 -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 +52 -34
- 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 +66 -68
- data/lib/thinreports/core/utils.rb +7 -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 +57 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +50 -47
- data/lib/thinreports/generator/pdf/document/font.rb +67 -58
- data/lib/thinreports/generator/pdf/document/graphics.rb +32 -33
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +121 -121
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +112 -114
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +58 -150
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +149 -137
- data/lib/thinreports/generator/pdf/document/page.rb +60 -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 +56 -54
- 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 +32 -0
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +35 -0
- data/lib/thinreports/layout.rb +5 -7
- data/lib/thinreports/layout/base.rb +5 -9
- data/lib/thinreports/layout/format.rb +17 -13
- data/lib/thinreports/layout/legacy_schema.rb +17 -13
- 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 +13 -15
- data/lib/thinreports/report/page.rb +5 -11
- data/lib/thinreports/version.rb +2 -2
- data/thinreports.gemspec +10 -19
- metadata +13 -288
- data/.travis.yml +0 -19
- data/examples/character_spacing/character_spacing.rb +0 -8
- data/examples/character_spacing/character_spacing.tlf +0 -293
- data/examples/dynamic_image/dynamic_image.rb +0 -31
- data/examples/dynamic_image/dynamic_image.tlf +0 -661
- data/examples/dynamic_image/img200x100.png +0 -0
- data/examples/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +0 -150
- data/examples/dynamic_style/dynamic_style.tlf +0 -1835
- data/examples/dynamic_style/dynamic_style_in_list.tlf +0 -344
- data/examples/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +0 -20
- data/examples/eudc/eudc.tlf +0 -180
- data/examples/eudc/eudc.ttf +0 -0
- data/examples/helper.rb +0 -50
- data/examples/hidden_shapes/hidden_shapes.rb +0 -9
- data/examples/hidden_shapes/hidden_shapes.tlf +0 -449
- data/examples/list_events/list_events.rb +0 -32
- data/examples/list_events/list_events.tlf +0 -361
- data/examples/list_manual_generation/list_manual_generation.rb +0 -22
- data/examples/list_manual_generation/list_manual_generation.tlf +0 -132
- data/examples/list_page_number/list_page_number.rb +0 -17
- data/examples/list_page_number/list_page_number.tlf +0 -254
- data/examples/page_number/page_number.rb +0 -33
- data/examples/page_number/page_number.tlf +0 -215
- data/examples/palleted_png/palleted_png.png +0 -0
- data/examples/palleted_png/palleted_png.rb +0 -11
- data/examples/palleted_png/palleted_png.tlf +0 -47
- data/examples/password_setting/password_setting.rb +0 -10
- data/examples/password_setting/password_setting.tlf +0 -45
- data/examples/report_callbacks/report_callbacks.rb +0 -14
- data/examples/report_callbacks/report_callbacks.tlf +0 -147
- data/examples/single_line_tblock/single_line_tblock.rb +0 -13
- data/examples/single_line_tblock/single_line_tblock.tlf +0 -170
- data/examples/tblock_overflow/tblock_overflow.rb +0 -20
- data/examples/tblock_overflow/tblock_overflow.tlf +0 -538
- data/examples/tblock_styles/font_size.tlf +0 -383
- data/examples/tblock_styles/tblock_styles.rb +0 -43
- data/examples/tblock_styles/tblock_styles.tlf +0 -889
- data/examples/text_align/text_align.rb +0 -8
- data/examples/text_align/text_align.tlf +0 -241
- data/examples/typeB_page_size/B4_ISO.tlf +0 -45
- data/examples/typeB_page_size/B4_JIS.tlf +0 -45
- data/examples/typeB_page_size/typeB_page_size.rb +0 -17
- data/examples/word_wrap/word_wrap.rb +0 -26
- data/examples/word_wrap/word_wrap.tlf +0 -297
- 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/data/font.ttf +0 -0
- data/test/data/image_normal.jpg +0 -0
- data/test/data/image_normal.png +0 -0
- data/test/data/image_normal_jpg_noext +0 -0
- data/test/data/image_normal_png_noext +0 -0
- data/test/data/image_pallete_based.png +0 -0
- data/test/data/legacy_layout/all-items.tlf +0 -1
- data/test/schema_helper.rb +0 -121
- data/test/test_helper.rb +0 -42
- data/test/tmp/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +0 -152
- data/test/unit/core/shape/base/test_internal.rb +0 -87
- data/test/unit/core/shape/basic/test_block_format.rb +0 -23
- data/test/unit/core/shape/basic/test_block_interface.rb +0 -29
- data/test/unit/core/shape/basic/test_block_internal.rb +0 -55
- data/test/unit/core/shape/basic/test_format.rb +0 -37
- data/test/unit/core/shape/basic/test_interface.rb +0 -108
- data/test/unit/core/shape/basic/test_internal.rb +0 -55
- data/test/unit/core/shape/image_block/test_interface.rb +0 -24
- data/test/unit/core/shape/image_block/test_internal.rb +0 -31
- data/test/unit/core/shape/list/test_format.rb +0 -111
- data/test/unit/core/shape/list/test_manager.rb +0 -67
- data/test/unit/core/shape/list/test_page.rb +0 -82
- data/test/unit/core/shape/list/test_page_state.rb +0 -31
- data/test/unit/core/shape/list/test_section_format.rb +0 -36
- data/test/unit/core/shape/list/test_section_interface.rb +0 -75
- data/test/unit/core/shape/list/test_section_internal.rb +0 -50
- data/test/unit/core/shape/manager/test_format.rb +0 -38
- data/test/unit/core/shape/manager/test_internal.rb +0 -132
- data/test/unit/core/shape/manager/test_target.rb +0 -140
- data/test/unit/core/shape/page_number/test_format.rb +0 -55
- data/test/unit/core/shape/page_number/test_interface.rb +0 -33
- data/test/unit/core/shape/page_number/test_internal.rb +0 -81
- data/test/unit/core/shape/styles/test_base.rb +0 -191
- data/test/unit/core/shape/styles/test_basic.rb +0 -24
- data/test/unit/core/shape/styles/test_graphic.rb +0 -50
- data/test/unit/core/shape/styles/test_text.rb +0 -97
- data/test/unit/core/shape/text/test_format.rb +0 -44
- data/test/unit/core/shape/text/test_internal.rb +0 -20
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +0 -24
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +0 -49
- data/test/unit/core/shape/text_block/formatter/test_number.rb +0 -76
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +0 -77
- data/test/unit/core/shape/text_block/test_format.rb +0 -169
- data/test/unit/core/shape/text_block/test_formatter.rb +0 -28
- data/test/unit/core/shape/text_block/test_interface.rb +0 -63
- data/test/unit/core/shape/text_block/test_internal.rb +0 -128
- data/test/unit/core/test_shape.rb +0 -52
- data/test/unit/core/test_utils.rb +0 -68
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +0 -135
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +0 -45
- data/test/unit/generator/pdf/document/graphics/test_image.rb +0 -150
- data/test/unit/generator/pdf/document/graphics/test_text.rb +0 -171
- data/test/unit/generator/pdf/document/test_font.rb +0 -84
- data/test/unit/generator/pdf/document/test_graphics.rb +0 -42
- data/test/unit/generator/pdf/document/test_page.rb +0 -122
- data/test/unit/generator/pdf/document/test_parse_color.rb +0 -30
- data/test/unit/generator/pdf/test_document.rb +0 -20
- data/test/unit/generator/test_base.rb +0 -40
- data/test/unit/generator/test_configuration.rb +0 -21
- data/test/unit/generator/test_pdf.rb +0 -24
- data/test/unit/layout/test_base.rb +0 -41
- data/test/unit/layout/test_format.rb +0 -100
- data/test/unit/layout/test_legacy_schema.rb +0 -574
- data/test/unit/layout/test_version.rb +0 -95
- data/test/unit/report/test_base.rb +0 -262
- data/test/unit/report/test_internal.rb +0 -206
- data/test/unit/test_config.rb +0 -51
- data/test/unit/test_layout.rb +0 -12
- data/test/unit/test_report.rb +0 -18
@@ -1,114 +1,112 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Manager
|
7
|
+
module Target
|
8
|
+
include Utils
|
5
9
|
|
6
|
-
|
7
|
-
include Utils
|
10
|
+
attr_reader :manager
|
8
11
|
|
9
|
-
|
12
|
+
# @example
|
13
|
+
# item(:title).value('Title').style(:fill, 'red')
|
14
|
+
#
|
15
|
+
# item(:title) do
|
16
|
+
# value('Title')
|
17
|
+
# style(:fill, 'red')
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# item(:title) do |t|
|
21
|
+
# t.value('Title')
|
22
|
+
# t.style(:fill, 'red')
|
23
|
+
# end
|
24
|
+
# item(:list) # => Error: UnknownItemId
|
25
|
+
# item(:unknown_id) # => Error: UnknownItemId
|
26
|
+
# @param [String, Symbol] id
|
27
|
+
# @yield [item,]
|
28
|
+
# @yieldparam [Thinreports::Core::Shape::Base::Interface] item
|
29
|
+
# @raise [Thinreports::Errors::UnknownItemId]
|
30
|
+
# @return [Thinreports::Core::Shape::Base::Interface]
|
31
|
+
def item(id, &block)
|
32
|
+
shape = find_item(id, except: Core::Shape::List::TYPE_NAME)
|
10
33
|
|
11
|
-
|
12
|
-
# item(:title).value('Title').style(:fill, 'red')
|
13
|
-
#
|
14
|
-
# item(:title) do
|
15
|
-
# value('Title')
|
16
|
-
# style(:fill, 'red')
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# item(:title) do |t|
|
20
|
-
# t.value('Title')
|
21
|
-
# t.style(:fill, 'red')
|
22
|
-
# end
|
23
|
-
# item(:list) # => Error: UnknownItemId
|
24
|
-
# item(:unknown_id) # => Error: UnknownItemId
|
25
|
-
# @param [String, Symbol] id
|
26
|
-
# @yield [item,]
|
27
|
-
# @yieldparam [Thinreports::Core::Shape::Base::Interface] item
|
28
|
-
# @raise [Thinreports::Errors::UnknownItemId]
|
29
|
-
# @return [Thinreports::Core::Shape::Base::Interface]
|
30
|
-
def item(id, &block)
|
31
|
-
shape = find_item(id, except: Core::Shape::List::TYPE_NAME)
|
34
|
+
raise Thinreports::Errors::UnknownItemId, id unless shape
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
else
|
36
|
-
call_block_in(shape, &block)
|
37
|
-
end
|
38
|
-
end
|
36
|
+
call_block_in(shape, &block)
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
# @example
|
40
|
+
# page[:text_block].style(:bold, true)
|
41
|
+
# page[:rect].style(:border_color, 'red')
|
42
|
+
#
|
43
|
+
# page[:list] # => Error: UnknownItemId
|
44
|
+
# page[:unknown_id] # => Error: UnknownItemId
|
45
|
+
# @param [String, Symbol] id
|
46
|
+
# @return [Thinreports::Core::Shape::Base::Interface]
|
47
|
+
def [](id)
|
48
|
+
item(id)
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
51
|
+
# @example
|
52
|
+
# page[:text_block] = 'Title'
|
53
|
+
# page[:image_block] = '/path/to/image.png'
|
54
|
+
# page[:list] = 'value' # => Error: UnknownItemId
|
55
|
+
# page[:ellipse] = 'value' # => Error: NoMethodError #value
|
56
|
+
# page[:unknown_id] = 'value' # => Error: UnknownItemId
|
57
|
+
# @param [String, Symbol] id
|
58
|
+
# @param [Object] value
|
59
|
+
def []=(id, value)
|
60
|
+
item(id).value = value
|
61
|
+
end
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
63
|
+
# @example
|
64
|
+
# page.values text_block: 'value',
|
65
|
+
# image_block: '/path/to/image.png'
|
66
|
+
# @param [Hash] item_values
|
67
|
+
def values(item_values)
|
68
|
+
item_values.each { |id, val| item(id).value(val) }
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
# @param [Symbol, String] id
|
72
|
+
# @return [Boolean]
|
73
|
+
def item_exists?(id)
|
74
|
+
!manager.find_format(id).nil?
|
75
|
+
end
|
76
|
+
alias exists? item_exists?
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
78
|
+
# @example
|
79
|
+
# report.list.add_row do |row|
|
80
|
+
# row.item(:price).value(1000)
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# report.list(:list_id) # => List
|
84
|
+
# report.list(:text_block_id) # => raises UnknownItemId
|
85
|
+
# @see #item
|
86
|
+
def list(id = nil, &block)
|
87
|
+
shape = find_item(id ||= :default, only: Core::Shape::List::TYPE_NAME)
|
89
88
|
|
90
|
-
|
91
|
-
raise Thinreports::Errors::UnknownItemId.new(id, 'List')
|
92
|
-
else
|
93
|
-
manager.lists[id.to_sym] ||= shape
|
94
|
-
call_block_in(shape, &block)
|
95
|
-
end
|
96
|
-
end
|
89
|
+
raise Thinreports::Errors::UnknownItemId.new(id, 'List') unless shape
|
97
90
|
|
98
|
-
|
91
|
+
manager.lists[id.to_sym] ||= shape
|
92
|
+
call_block_in(shape, &block)
|
93
|
+
end
|
99
94
|
|
100
|
-
|
101
|
-
# @yield [format] Handler for initialize item.
|
102
|
-
# @yieldparam [Thinreports::Core::Shape::Basic::Format] format
|
103
|
-
def initialize_manager(format, &block)
|
104
|
-
@manager = Manager::Internal.new(format, block)
|
105
|
-
end
|
95
|
+
private
|
106
96
|
|
107
|
-
|
108
|
-
|
109
|
-
|
97
|
+
# @param format (see Thinreports::Core::Shape::Manager::Internal#initialize)
|
98
|
+
# @yield [format] Handler for initialize item.
|
99
|
+
# @yieldparam [Thinreports::Core::Shape::Basic::Format] format
|
100
|
+
def initialize_manager(format, &block)
|
101
|
+
@manager = Manager::Internal.new(format, block)
|
102
|
+
end
|
103
|
+
|
104
|
+
# @see Thinreports::Core::Shape::Manager::Internal#find_item
|
105
|
+
def find_item(id, limit = {})
|
106
|
+
manager.find_item(id, limit)
|
107
|
+
end
|
108
|
+
end
|
110
109
|
end
|
111
110
|
end
|
112
|
-
|
113
111
|
end
|
114
112
|
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 PageNumber
|
7
|
+
TYPE_NAME = 'page-number'
|
8
|
+
end
|
8
9
|
end
|
9
|
-
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
require_relative 'page_number/format'
|
14
|
+
require_relative 'page_number/internal'
|
15
|
+
require_relative 'page_number/interface'
|
@@ -1,28 +1,30 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module PageNumber
|
7
|
+
class Format < Basic::Format
|
8
|
+
config_reader :target
|
9
|
+
config_reader default_format: %w[format]
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
config_reader default_format: %w( format )
|
11
|
+
# For saving compatible 0.8.x format API
|
12
|
+
config_reader overflow: %w[style overflow]
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
def id
|
15
|
+
@id ||= blank_value?(read('id')) ? self.class.next_default_id : read('id')
|
16
|
+
end
|
12
17
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def for_report?
|
18
|
-
blank_value?(target)
|
19
|
-
end
|
18
|
+
def for_report?
|
19
|
+
blank_value?(target)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def self.next_default_id
|
23
|
+
@id_counter ||= 0
|
24
|
+
"__pageno#{@id_counter += 1}"
|
25
|
+
end
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
26
|
-
|
27
29
|
end
|
28
30
|
end
|
@@ -1,27 +1,29 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module PageNumber
|
7
|
+
class Interface < Basic::Interface
|
8
|
+
internal_delegators :reset_format
|
5
9
|
|
6
|
-
|
7
|
-
|
10
|
+
def format(*args)
|
11
|
+
if args.empty?
|
12
|
+
internal.read_format
|
13
|
+
else
|
14
|
+
internal.write_format(args.first)
|
15
|
+
self
|
16
|
+
end
|
17
|
+
end
|
8
18
|
|
9
|
-
|
10
|
-
if args.empty?
|
11
|
-
internal.read_format
|
12
|
-
else
|
13
|
-
internal.write_format(args.first)
|
14
|
-
self
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
+
private
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
22
|
+
def init_internal(parent, format)
|
23
|
+
PageNumber::Internal.new(parent, format)
|
24
|
+
end
|
25
|
+
end
|
23
26
|
end
|
24
27
|
end
|
25
|
-
|
26
28
|
end
|
27
29
|
end
|
@@ -1,53 +1,55 @@
|
|
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
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module PageNumber
|
7
|
+
class Internal < Basic::Internal
|
8
|
+
format_delegators :box, :for_report?
|
9
|
+
|
10
|
+
def read_format
|
11
|
+
states.key?(:format) ? states[:format] : format.default_format.dup
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset_format
|
15
|
+
states.delete(:format)
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_format(format)
|
19
|
+
states[:format] = format.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def build_format(page_no, page_count)
|
23
|
+
return '' if blank_value?(read_format)
|
24
|
+
|
25
|
+
if start_page_number > 1
|
26
|
+
page_no += start_page_number - 1
|
27
|
+
page_count += start_page_number - 1
|
28
|
+
end
|
29
|
+
|
30
|
+
read_format.dup.tap do |f|
|
31
|
+
f.gsub! '{page}', page_no.to_s
|
32
|
+
f.gsub! '{total}', page_count.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def style
|
37
|
+
@style ||= PageNumber::Style.new(format)
|
38
|
+
end
|
39
|
+
|
40
|
+
def type_of?(type_name)
|
41
|
+
type_name == PageNumber::TYPE_NAME
|
42
|
+
end
|
43
|
+
|
44
|
+
def start_page_number
|
45
|
+
for_report? ? parent.report.start_page_number : 1
|
46
|
+
end
|
27
47
|
end
|
28
48
|
|
29
|
-
|
30
|
-
|
31
|
-
f.gsub! '{total}', page_count.to_s
|
49
|
+
class Style < Style::Text
|
50
|
+
accessible_styles.delete :valign
|
32
51
|
end
|
33
52
|
end
|
34
|
-
|
35
|
-
def style
|
36
|
-
@style ||= PageNumber::Style.new(format)
|
37
|
-
end
|
38
|
-
|
39
|
-
def type_of?(type_name)
|
40
|
-
type_name == PageNumber::TYPE_NAME
|
41
|
-
end
|
42
|
-
|
43
|
-
def start_page_number
|
44
|
-
for_report? ? parent.report.start_page_number : 1
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
class PageNumber::Style < Style::Text
|
49
|
-
accessible_styles.delete :valign
|
50
53
|
end
|
51
|
-
|
52
54
|
end
|
53
55
|
end
|
@@ -1,15 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'thinreports/core/shape/style/base'
|
13
|
-
require 'thinreports/core/shape/style/basic'
|
14
|
-
require 'thinreports/core/shape/style/graphic'
|
15
|
-
require 'thinreports/core/shape/style/text'
|
3
|
+
require_relative 'style/base'
|
4
|
+
require_relative 'style/basic'
|
5
|
+
require_relative 'style/graphic'
|
6
|
+
require_relative 'style/text'
|