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,145 +1,146 @@
|
|
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
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Style
|
7
|
+
class Base
|
8
|
+
include Utils
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# @param [Symbol] style_method
|
12
|
+
# @param [String] style
|
13
|
+
# @return [void]
|
14
|
+
def style_accessor(style_method, style)
|
15
|
+
style_reader(style_method, style)
|
16
|
+
style_writer(style_method, style)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @see .style_accessor
|
20
|
+
def style_reader(style_method, style)
|
21
|
+
define_method(style_method) do
|
22
|
+
read_internal_style(style)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @see .style_accessor
|
27
|
+
def style_writer(style_method, style)
|
28
|
+
define_method(:"#{style_method}=") do |value|
|
29
|
+
write_internal_style(style, value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [Array<Symbol>] style_methods
|
34
|
+
def style_accessible(*style_methods)
|
35
|
+
accessible_styles.concat(style_methods)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [Array<Symbol>]
|
39
|
+
def accessible_styles
|
40
|
+
@accessible_styles ||= []
|
41
|
+
end
|
42
|
+
|
43
|
+
def inherited(s)
|
44
|
+
s.accessible_styles.concat(accessible_styles.dup)
|
45
|
+
end
|
22
46
|
end
|
23
|
-
end
|
24
47
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# @param [Array<Symbol>] style_methods
|
33
|
-
def style_accessible(*style_methods)
|
34
|
-
accessible_styles.concat(style_methods)
|
35
|
-
end
|
36
|
-
|
37
|
-
# @return [Array<Symbol>]
|
38
|
-
def accessible_styles
|
39
|
-
@accessible_styles ||= []
|
40
|
-
end
|
48
|
+
# @return [Hash]
|
49
|
+
attr_accessor :styles
|
50
|
+
# @see .accessible_styles
|
51
|
+
attr_reader :accessible_styles
|
41
52
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
53
|
+
# @param [Thinreports::Core::Format::Base] format
|
54
|
+
# @param [Hash] default_styles ({})
|
55
|
+
def initialize(format, default_styles = {})
|
56
|
+
@format = format
|
57
|
+
@styles = default_styles
|
58
|
+
@base_styles = format.style || {}
|
46
59
|
|
47
|
-
|
48
|
-
|
49
|
-
# @see .accessible_styles
|
50
|
-
attr_reader :accessible_styles
|
60
|
+
@accessible_styles = self.class.accessible_styles.dup
|
61
|
+
end
|
51
62
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
63
|
+
# @param [Symbol] style_method
|
64
|
+
# @return [Object]
|
65
|
+
def [](style_method)
|
66
|
+
verify_style_method(style_method)
|
67
|
+
send(style_method.to_sym)
|
68
|
+
end
|
58
69
|
|
59
|
-
|
60
|
-
|
70
|
+
# @param [Symbol] style_method
|
71
|
+
# @param [String, Number, Array<String, Number>] value
|
72
|
+
def []=(style_method, value)
|
73
|
+
verify_style_method(style_method)
|
74
|
+
send(:"#{style_method}=", value)
|
75
|
+
end
|
61
76
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
send(style_method.to_sym)
|
67
|
-
end
|
77
|
+
# @return [String]
|
78
|
+
def identifier
|
79
|
+
create_identifier(@styles)
|
80
|
+
end
|
68
81
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
send(:"#{style_method}=", value)
|
74
|
-
end
|
82
|
+
# @return [self]
|
83
|
+
def copy
|
84
|
+
self.class.new(@format, @styles.empty? ? {} : deep_copy(@styles))
|
85
|
+
end
|
75
86
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
87
|
+
# @param [String, Symbol] style
|
88
|
+
# @return [Object]
|
89
|
+
def read_internal_style(style)
|
90
|
+
style = style.to_s
|
91
|
+
@styles.key?(style) ? @styles[style] : @base_styles[style]
|
92
|
+
end
|
80
93
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
94
|
+
# @param [String, Symbol] style
|
95
|
+
# @param [Object] value
|
96
|
+
def write_internal_style(style, value)
|
97
|
+
@styles[style.to_s] = value
|
98
|
+
end
|
85
99
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
100
|
+
# @param [Symbol] style_method
|
101
|
+
# @return [Boolean]
|
102
|
+
def has_style?(style_method)
|
103
|
+
accessible_styles.include?(style_method)
|
104
|
+
end
|
92
105
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
106
|
+
# @return [Hash]
|
107
|
+
def finalized_styles
|
108
|
+
@finalized_styles ||=
|
109
|
+
if @styles.empty?
|
110
|
+
@base_styles.dup
|
111
|
+
else
|
112
|
+
@base_styles.merge(@styles)
|
113
|
+
end
|
114
|
+
end
|
98
115
|
|
99
|
-
|
100
|
-
# @return [Boolean]
|
101
|
-
def has_style?(style_method)
|
102
|
-
accessible_styles.include?(style_method)
|
103
|
-
end
|
116
|
+
private
|
104
117
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
@base_styles.dup
|
110
|
-
else
|
111
|
-
@base_styles.merge(@styles)
|
118
|
+
# @param [Hash] s
|
119
|
+
# @return [String]
|
120
|
+
def create_identifier(s)
|
121
|
+
s.empty? ? '' : s.hash.to_s
|
112
122
|
end
|
113
|
-
end
|
114
123
|
|
115
|
-
|
124
|
+
# @param [Symbol] style_method
|
125
|
+
# @raise Thinreports::Errors::UnknownShapeStyleName
|
126
|
+
def verify_style_method(style_method)
|
127
|
+
return if has_style?(style_method)
|
116
128
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
# @param [Symbol] style_method
|
124
|
-
# @return [Boolean]
|
125
|
-
# @raise Thinreports::Errors::UnknownShapeStyleName
|
126
|
-
def verify_style_method(style_method)
|
127
|
-
unless has_style?(style_method)
|
128
|
-
raise Thinreports::Errors::UnknownShapeStyleName.new(style_method,
|
129
|
-
accessible_styles)
|
130
|
-
end
|
131
|
-
end
|
129
|
+
raise Thinreports::Errors::UnknownShapeStyleName.new(
|
130
|
+
style_method,
|
131
|
+
accessible_styles
|
132
|
+
)
|
133
|
+
end
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
135
|
+
# @param [Object] value
|
136
|
+
# @param [Array<Object>] allows
|
137
|
+
# @param [String] msg (nil)
|
138
|
+
# @raise ArgumentError
|
139
|
+
def verify_style_value(value, allows, msg = nil)
|
140
|
+
raise ArgumentError, msg unless allows.include?(value)
|
141
|
+
end
|
140
142
|
end
|
141
143
|
end
|
142
144
|
end
|
143
|
-
|
144
145
|
end
|
145
146
|
end
|
@@ -1,17 +1,19 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module Core
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Style
|
7
|
+
class Basic < Style::Base
|
8
|
+
style_accessible :visible
|
9
|
+
attr_accessor :visible
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
super
|
12
|
-
@visible = @format.display?
|
11
|
+
def initialize(*args)
|
12
|
+
super
|
13
|
+
@visible = @format.display?
|
14
|
+
end
|
15
|
+
end
|
13
16
|
end
|
14
17
|
end
|
15
|
-
|
16
18
|
end
|
17
19
|
end
|
@@ -1,39 +1,41 @@
|
|
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
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Style
|
7
|
+
class Graphic < Style::Basic
|
8
|
+
style_accessible :border_color, :border_width, :fill_color, :border
|
9
|
+
|
10
|
+
# @method border_color
|
11
|
+
# @return [String]
|
12
|
+
# @method border_color=(color)
|
13
|
+
# @param [String] color
|
14
|
+
style_accessor :border_color, 'border-color'
|
15
|
+
|
16
|
+
# @method border_width
|
17
|
+
# @return [Number]
|
18
|
+
style_accessor :border_width, 'border-width'
|
19
|
+
|
20
|
+
# @method fill_color
|
21
|
+
# @return [String]
|
22
|
+
# @method fill_color=(color)
|
23
|
+
# @param [String] color
|
24
|
+
style_accessor :fill_color, 'fill-color'
|
25
|
+
|
26
|
+
# @return [Array<String, Number>]
|
27
|
+
def border
|
28
|
+
[border_width, border_color]
|
29
|
+
end
|
30
|
+
|
31
|
+
# @param [Array<String, Number>] width_and_color
|
32
|
+
def border=(width_and_color)
|
33
|
+
w, c = width_and_color
|
34
|
+
self.border_width = w
|
35
|
+
self.border_color = c
|
36
|
+
end
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
|
-
|
38
40
|
end
|
39
41
|
end
|
@@ -1,114 +1,120 @@
|
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
4
|
+
module Core
|
5
|
+
module Shape
|
6
|
+
module Style
|
7
|
+
class Text < Style::Basic
|
8
|
+
style_accessible :bold, :italic, :underline, :linethrough,
|
9
|
+
:align, :valign, :color, :font_size
|
10
|
+
|
11
|
+
# @method color
|
12
|
+
# @return [String]
|
13
|
+
# @method color=(v)
|
14
|
+
# @param [String] v
|
15
|
+
style_accessor :color, 'color'
|
16
|
+
|
17
|
+
# @method font_size
|
18
|
+
# @return [Numeric, String]
|
19
|
+
# @method font_size=(v)
|
20
|
+
# @param [Numeric, String] v
|
21
|
+
style_accessor :font_size, 'font-size'
|
22
|
+
|
23
|
+
def initialize(*)
|
24
|
+
super
|
25
|
+
initialize_font_style
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Boolean]
|
29
|
+
def bold
|
30
|
+
read_internal_style('font-style').include?('bold')
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [Boolean] enable
|
34
|
+
def bold=(enable)
|
35
|
+
write_font_style('bold', enable)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [Boolean]
|
39
|
+
def italic
|
40
|
+
read_internal_style('font-style').include?('italic')
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [Boolean] enable
|
44
|
+
def italic=(enable)
|
45
|
+
write_font_style('italic', enable)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Boolean]
|
49
|
+
def underline
|
50
|
+
read_internal_style('font-style').include?('underline')
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param [Boolean] enable
|
54
|
+
def underline=(enable)
|
55
|
+
write_font_style('underline', enable)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Boolean]
|
59
|
+
def linethrough
|
60
|
+
read_internal_style('font-style').include?('linethrough')
|
61
|
+
end
|
62
|
+
|
63
|
+
# @param [Boolean] enable
|
64
|
+
def linethrough=(enable)
|
65
|
+
write_font_style('linethrough', enable)
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [:left, :center, :right]
|
69
|
+
def align
|
70
|
+
read_internal_style('text-align').to_sym
|
71
|
+
end
|
72
|
+
|
73
|
+
# @param [:left, :center, :right] align_name
|
74
|
+
def align=(align_name)
|
75
|
+
verify_style_value(align_name, %i[left center right],
|
76
|
+
'Only :left or :center, :right can be specified as align.')
|
77
|
+
write_internal_style('text-align', align_name.to_s)
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [:top, :middle, :bottom]
|
81
|
+
def valign
|
82
|
+
vertical_align = read_internal_style('vertical-align')
|
83
|
+
blank_value?(vertical_align) ? :top : vertical_align.to_sym
|
84
|
+
end
|
85
|
+
|
86
|
+
# @param [:top, :center, :middle, :bottom] valign_name
|
87
|
+
def valign=(valign_name)
|
88
|
+
if valign_name == :center
|
89
|
+
warn '[DEPRECATION] :center value for valign style is deprecated' \
|
90
|
+
' and will be removed in thinreports-generator 1.0.' \
|
91
|
+
' Please use :middle instead of :center.'
|
92
|
+
valign_name = :middle
|
93
|
+
end
|
94
|
+
|
95
|
+
verify_style_value(
|
96
|
+
valign_name,
|
97
|
+
%i[top middle bottom],
|
98
|
+
'Only :top or :middle (:center), :bottom can be specified as valign.'
|
99
|
+
)
|
100
|
+
write_internal_style('vertical-align', valign_name.to_s)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def initialize_font_style
|
106
|
+
styles['font-style'] ||= (@base_styles['font-style'] || []).dup
|
107
|
+
end
|
108
|
+
|
109
|
+
def write_font_style(style_name, enable)
|
110
|
+
if enable
|
111
|
+
styles['font-style'].push(style_name).uniq!
|
112
|
+
else
|
113
|
+
styles['font-style'].delete(style_name)
|
114
|
+
end
|
115
|
+
end
|
109
116
|
end
|
110
117
|
end
|
111
118
|
end
|
112
|
-
|
113
119
|
end
|
114
120
|
end
|