thinreports 0.6.0.pre3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +37 -32
- data/doc/yardoc_templates/default/layout/html/footer.erb +1 -1
- data/lib/thinreports.rb +2 -1
- data/lib/thinreports/config.rb +21 -0
- data/lib/thinreports/core/errors.rb +14 -1
- data/lib/thinreports/core/format/builder.rb +6 -1
- data/lib/thinreports/core/page.rb +6 -6
- data/lib/thinreports/core/shape.rb +8 -9
- data/lib/thinreports/core/shape/base/internal.rb +6 -12
- data/lib/thinreports/core/shape/basic.rb +3 -0
- data/lib/thinreports/core/shape/basic/block_format.rb +12 -0
- data/lib/thinreports/core/shape/basic/block_interface.rb +25 -0
- data/lib/thinreports/core/shape/basic/block_internal.rb +33 -0
- data/lib/thinreports/core/shape/basic/interface.rb +37 -11
- data/lib/thinreports/core/shape/basic/internal.rb +3 -12
- data/lib/thinreports/core/shape/image_block.rb +15 -0
- data/lib/thinreports/core/shape/image_block/format.rb +13 -0
- data/lib/thinreports/core/shape/image_block/interface.rb +19 -0
- data/lib/thinreports/core/shape/image_block/internal.rb +16 -0
- data/lib/thinreports/core/shape/list/events.rb +19 -2
- data/lib/thinreports/core/shape/list/manager.rb +17 -4
- data/lib/thinreports/core/shape/list/page.rb +2 -2
- data/lib/thinreports/core/shape/list/page_state.rb +4 -0
- data/lib/thinreports/core/shape/list/section_internal.rb +4 -0
- data/lib/thinreports/core/shape/manager/format.rb +1 -1
- data/lib/thinreports/core/shape/manager/internal.rb +24 -11
- data/lib/thinreports/core/shape/manager/target.rb +2 -2
- data/lib/thinreports/core/shape/style.rb +15 -0
- data/lib/thinreports/core/shape/style/base.rb +149 -0
- data/lib/thinreports/core/shape/style/basic.rb +17 -0
- data/lib/thinreports/core/shape/style/graphic.rb +60 -0
- data/lib/thinreports/core/shape/style/text.rb +138 -0
- data/lib/thinreports/core/shape/text/internal.rb +4 -0
- data/lib/thinreports/core/shape/text_block.rb +16 -0
- data/lib/thinreports/core/shape/{tblock → text_block}/format.rb +3 -3
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter.rb +7 -7
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/basic.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/datetime.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/number.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/padding.rb +10 -8
- data/lib/thinreports/core/shape/{tblock → text_block}/interface.rb +2 -21
- data/lib/thinreports/core/shape/{tblock → text_block}/internal.rb +16 -10
- data/lib/thinreports/core/utils.rb +0 -8
- data/lib/thinreports/generator.rb +2 -2
- data/lib/thinreports/generator/configuration.rb +30 -0
- data/lib/thinreports/generator/pdf.rb +13 -10
- data/lib/thinreports/generator/pdf/configuration.rb +28 -0
- data/lib/thinreports/generator/pdf/document.rb +16 -56
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +35 -17
- data/lib/thinreports/generator/pdf/document/font.rb +25 -9
- data/lib/thinreports/generator/pdf/document/graphics.rb +1 -1
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +18 -4
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +1 -1
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +18 -1
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +29 -6
- data/lib/thinreports/generator/pdf/document/page.rb +70 -0
- data/lib/thinreports/generator/pdf/document/parse_color.rb +1 -1
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer/base.rb +5 -7
- data/lib/thinreports/generator/pdf/drawer/list.rb +4 -4
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +8 -3
- data/lib/thinreports/generator/pdf/drawer/page.rb +10 -3
- data/lib/thinreports/generator/pdf/prawn_ext.rb +16 -21
- data/lib/thinreports/layout/format.rb +2 -2
- data/lib/thinreports/layout/version.rb +2 -2
- data/lib/thinreports/report/base.rb +68 -31
- data/tasks/test.rake +48 -4
- data/test/benchmark/basic_estimate.tlf +1 -0
- data/test/benchmark/bench_basic_estimate.rb +95 -0
- data/test/case/character_spacing/character_spacing.rb +7 -0
- data/test/case/character_spacing/character_spacing.tlf +1 -0
- data/test/case/dynamic_image/dynamic_image.rb +41 -0
- data/test/case/dynamic_image/dynamic_image.tlf +1 -0
- data/test/case/dynamic_image/img200x100.png +0 -0
- data/test/case/dynamic_image/img50x50.png +0 -0
- data/test/case/dynamic_style/dynamic_style.rb +154 -0
- data/test/case/dynamic_style/dynamic_style.tlf +1 -0
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/test/case/dynamic_style/image.png +0 -0
- data/test/case/eudc/eudc.rb +20 -0
- data/test/case/eudc/eudc.tlf +1 -0
- data/test/case/eudc/eudc.ttf +0 -0
- data/test/case/helper.rb +27 -0
- data/test/case/hidden_shapes/hidden_shapes.rb +13 -0
- data/test/case/hidden_shapes/hidden_shapes.tlf +1 -0
- data/test/case/list_events/list_events.rb +32 -0
- data/test/case/list_events/list_events.tlf +1 -0
- data/test/case/list_header_inheriting/list_header_inheriting.rb +19 -0
- data/test/case/list_header_inheriting/list_header_inheriting.tlf +1 -0
- data/test/case/list_manual_generation/list_manual_generation.rb +24 -0
- data/test/case/list_manual_generation/list_manual_generation.tlf +1 -0
- data/test/case/single_line_tblock/single_line_tblock.rb +15 -0
- data/test/case/single_line_tblock/single_line_tblock.tlf +1 -0
- data/test/case/tblock_styles/tblock_styles.rb +27 -0
- data/test/case/tblock_styles/tblock_styles.tlf +1 -0
- data/test/case/text_align/text_align.rb +9 -0
- data/test/case/text_align/text_align.tlf +1 -0
- data/test/unit/core/shape/base/test_internal.rb +65 -85
- data/test/unit/core/shape/basic/test_basic_format.rb +30 -0
- data/test/unit/core/shape/basic/test_basic_interface.rb +27 -0
- data/test/unit/core/shape/basic/test_basic_internal.rb +55 -0
- data/test/unit/core/shape/basic/test_interface.rb +84 -36
- data/test/unit/core/shape/basic/test_internal.rb +32 -24
- data/test/unit/core/shape/image_block/test_format.rb +58 -0
- data/test/unit/core/shape/image_block/test_interface.rb +23 -0
- data/test/unit/core/shape/image_block/test_internal.rb +28 -0
- data/test/unit/core/shape/list/test_events.rb +19 -11
- data/test/unit/core/shape/list/test_manager.rb +112 -0
- data/test/unit/core/shape/list/test_page.rb +57 -0
- data/test/unit/core/shape/list/test_section_format.rb +1 -1
- data/test/unit/core/shape/list/test_section_interface.rb +37 -30
- data/test/unit/core/shape/list/test_section_internal.rb +39 -14
- data/test/unit/core/shape/manager/test_format.rb +12 -18
- data/test/unit/core/shape/manager/test_internal.rb +127 -93
- data/test/unit/core/shape/manager/test_target.rb +63 -56
- data/test/unit/core/shape/styles/test_base.rb +219 -0
- data/test/unit/core/shape/styles/test_basic.rb +24 -0
- data/test/unit/core/shape/styles/test_graphic.rb +69 -0
- data/test/unit/core/shape/styles/test_text.rb +318 -0
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_basic.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_datetime.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_number.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_padding.rb +11 -6
- data/test/unit/core/shape/text_block/test_format.rb +160 -0
- data/test/unit/core/shape/{tblock → text_block}/test_formatter.rb +2 -2
- data/test/unit/core/shape/text_block/test_interface.rb +46 -0
- data/test/unit/core/shape/text_block/test_internal.rb +128 -0
- data/test/unit/core/test_shape.rb +31 -6
- data/test/unit/data/basic_layout1.tlf +1 -0
- data/test/unit/data/basic_layout2.tlf +1 -0
- data/test/unit/data/basic_list_layout.tlf +1 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +81 -52
- data/test/unit/generator/pdf/document/graphics/test_text.rb +159 -0
- data/test/unit/generator/pdf/document/test_font.rb +21 -6
- data/test/unit/generator/pdf/document/test_graphics.rb +2 -2
- data/test/unit/generator/pdf/document/test_page.rb +95 -0
- data/test/unit/generator/pdf/document/test_parse_color.rb +2 -2
- data/test/unit/generator/pdf/test_configuration.rb +24 -0
- data/test/unit/generator/pdf/test_document.rb +28 -0
- data/test/unit/generator/test_configuration.rb +25 -0
- data/test/unit/generator/test_pdf.rb +19 -0
- data/test/unit/helper.rb +18 -0
- data/test/unit/layout/test_format.rb +24 -7
- data/test/unit/layout/test_version.rb +61 -27
- data/test/unit/report/test_base.rb +185 -89
- data/test/unit/test_config.rb +22 -0
- data/test/unit/test_report.rb +4 -4
- metadata +94 -43
- data/lib/thinreports/core/shape/tblock.rb +0 -16
- data/lib/thinreports/generator/pxd.rb +0 -75
- data/lib/thinreports/generator/pxd/helper.rb +0 -33
- data/lib/thinreports/generator/pxd/list_renderer.rb +0 -58
- data/lib/thinreports/generator/pxd/page_renderer.rb +0 -75
- data/tasks/clean.rake +0 -6
- data/test/unit/core/shape/tblock/test_format.rb +0 -125
- data/test/unit/core/shape/tblock/test_interface.rb +0 -40
- data/test/unit/core/shape/tblock/test_internal.rb +0 -139
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ThinReports
|
4
|
+
module Core::Shape
|
5
|
+
|
6
|
+
class Style::Basic < Style::Base
|
7
|
+
style_accessible :visible
|
8
|
+
attr_accessor :visible
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
@visible = @format.display?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ThinReports
|
4
|
+
module Core::Shape
|
5
|
+
|
6
|
+
class Style::Graphic < Style::Basic
|
7
|
+
style_accessible :border_color, :border_width, :fill_color, :border,
|
8
|
+
:fill, :stroke
|
9
|
+
|
10
|
+
# @method border_color
|
11
|
+
# @return [String]
|
12
|
+
# @method border_color=(color)
|
13
|
+
# @param [String] color
|
14
|
+
style_accessor :border_color, 'stroke'
|
15
|
+
|
16
|
+
# @method border_width
|
17
|
+
# @return [String, Number]
|
18
|
+
style_reader :border_width, 'stroke-width'
|
19
|
+
|
20
|
+
# @method fill_color
|
21
|
+
# @return [String]
|
22
|
+
# @method fill_color=(color)
|
23
|
+
# @param [String] color
|
24
|
+
style_accessor :fill_color, 'fill'
|
25
|
+
|
26
|
+
# @method fill
|
27
|
+
# @return [String]
|
28
|
+
# @method fill=(color)
|
29
|
+
# @param [String] color
|
30
|
+
# @deprecated Please use the #fill_color method instead.
|
31
|
+
style_accessor :fill, 'fill'
|
32
|
+
|
33
|
+
# @method stroke
|
34
|
+
# @return [String, Number]
|
35
|
+
# @method stroke=(width)
|
36
|
+
# @param [String, Number] width
|
37
|
+
# @deprecated Please use the #stroke_width method instead.
|
38
|
+
style_accessor :stroke, 'stroke-width'
|
39
|
+
|
40
|
+
# @param [String, Number] width
|
41
|
+
def border_width=(width)
|
42
|
+
write_internal_style('stroke-opacity', '1') unless width.to_i.zero?
|
43
|
+
write_internal_style('stroke-width', width)
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Array<String, Number>]
|
47
|
+
def border
|
48
|
+
[self.border_width, self.border_color]
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param [Array<String, Number>]
|
52
|
+
def border=(width_and_color)
|
53
|
+
w, c = width_and_color
|
54
|
+
self.border_width = w
|
55
|
+
self.border_color = c
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ThinReports
|
4
|
+
module Core::Shape
|
5
|
+
|
6
|
+
class Style::Text < Style::Basic
|
7
|
+
TEXT_ALIGN_NAMES = {:left => 'start',
|
8
|
+
:center => 'middle',
|
9
|
+
:right => 'end'}
|
10
|
+
|
11
|
+
style_accessible :bold, :italic, :underline, :linethrough,
|
12
|
+
:align, :valign, :color
|
13
|
+
|
14
|
+
# @method color
|
15
|
+
# @return [String]
|
16
|
+
# @method color=(v)
|
17
|
+
# @param [String] v
|
18
|
+
style_accessor :color, 'fill'
|
19
|
+
|
20
|
+
def initialize(*args)
|
21
|
+
super
|
22
|
+
@valign = default_valign
|
23
|
+
end
|
24
|
+
|
25
|
+
# @override
|
26
|
+
def copy
|
27
|
+
new_style = super
|
28
|
+
new_style.valign = self.valign
|
29
|
+
new_style
|
30
|
+
end
|
31
|
+
|
32
|
+
# @override
|
33
|
+
def identifier
|
34
|
+
super + (@valign == default_valign ? '' : @valign.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Boolean]
|
38
|
+
def bold
|
39
|
+
read_internal_style('font-weight') == 'bold'
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param [Boolean] enable
|
43
|
+
def bold=(enable)
|
44
|
+
write_internal_style('font-weight', enable ? 'bold' : 'normal')
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Boolean]
|
48
|
+
def italic
|
49
|
+
read_internal_style('font-style') == 'italic'
|
50
|
+
end
|
51
|
+
|
52
|
+
# @param [Boolean] enable
|
53
|
+
def italic=(enable)
|
54
|
+
write_internal_style('font-style', enable ? 'italic' : 'normal')
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Boolean]
|
58
|
+
def underline
|
59
|
+
read_internal_style('text-decoration').include?('underline')
|
60
|
+
end
|
61
|
+
|
62
|
+
# @param [Boolean] enable
|
63
|
+
def underline=(enable)
|
64
|
+
text_decoration(enable, linethrough)
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [Boolean]
|
68
|
+
def linethrough
|
69
|
+
read_internal_style('text-decoration').include?('line-through')
|
70
|
+
end
|
71
|
+
|
72
|
+
# @param [Boolean] enable
|
73
|
+
def linethrough=(enable)
|
74
|
+
text_decoration(underline, enable)
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [Symbol]
|
78
|
+
def align
|
79
|
+
interface_text_align(read_internal_style('text-anchor'))
|
80
|
+
end
|
81
|
+
|
82
|
+
# @param [:left, :center, :right] align_name
|
83
|
+
def align=(align_name)
|
84
|
+
verify_style_value(align_name, TEXT_ALIGN_NAMES.keys,
|
85
|
+
'Only :left or :center, :right can be specified as align.')
|
86
|
+
write_internal_style('text-anchor', internal_text_align(align_name))
|
87
|
+
end
|
88
|
+
|
89
|
+
# @return [Symbol]
|
90
|
+
def valign
|
91
|
+
@valign
|
92
|
+
end
|
93
|
+
|
94
|
+
# @param [:top, :center, :bottom] valign_name
|
95
|
+
def valign=(valign_name)
|
96
|
+
verify_style_value(valign_name, [:top, :center, :bottom],
|
97
|
+
'Only :top or :center, :bottom can be specified as valign.')
|
98
|
+
@valign = valign_name
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
# @return [Symbol]
|
104
|
+
def default_valign
|
105
|
+
@format.valign.blank? ? :top : @format.valign.to_sym
|
106
|
+
end
|
107
|
+
|
108
|
+
# @param [Symbol] align The interface align name.
|
109
|
+
# @return [String, nil]
|
110
|
+
def internal_text_align(align)
|
111
|
+
TEXT_ALIGN_NAMES[align]
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param [String] align The internal align name.
|
115
|
+
# @return [Symbol]
|
116
|
+
def interface_text_align(align)
|
117
|
+
TEXT_ALIGN_NAMES.invert[align] || :left
|
118
|
+
end
|
119
|
+
|
120
|
+
# @param [Boolean] u
|
121
|
+
# @param [Boolean] s
|
122
|
+
def text_decoration(u, s)
|
123
|
+
deco = case
|
124
|
+
when u && s
|
125
|
+
'underline line-through'
|
126
|
+
when u && !s
|
127
|
+
'underline'
|
128
|
+
when !u && s
|
129
|
+
'line-through'
|
130
|
+
else
|
131
|
+
'none'
|
132
|
+
end
|
133
|
+
write_internal_style('text-decoration', deco)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ThinReports
|
4
|
+
module Core::Shape
|
5
|
+
|
6
|
+
module TextBlock
|
7
|
+
TYPE_NAME = 's-tblock'
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'thinreports/core/shape/text_block/format'
|
14
|
+
require 'thinreports/core/shape/text_block/internal'
|
15
|
+
require 'thinreports/core/shape/text_block/interface'
|
16
|
+
require 'thinreports/core/shape/text_block/formatter'
|
@@ -4,10 +4,10 @@ module ThinReports
|
|
4
4
|
module Core::Shape
|
5
5
|
|
6
6
|
# @private
|
7
|
-
class
|
8
|
-
config_reader :value
|
7
|
+
class TextBlock::Format < Basic::BlockFormat
|
9
8
|
config_reader :ref_id => %w( ref-id )
|
10
|
-
config_reader :
|
9
|
+
config_reader :valign
|
10
|
+
config_reader :line_height => %w( line-height )
|
11
11
|
config_reader :format_base => %w( format base ),
|
12
12
|
:format_type => %w( format type ),
|
13
13
|
:format_datetime_format => %w( format datetime format ),
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
module ThinReports
|
4
|
-
module Core::Shape::
|
4
|
+
module Core::Shape::TextBlock
|
5
5
|
|
6
6
|
# @private
|
7
7
|
module Formatter
|
8
|
-
# @param [ThinReports::Core::Shape::
|
9
|
-
# @return [ThinReports::Core::Shape::
|
8
|
+
# @param [ThinReports::Core::Shape::TextBlock::Format] format
|
9
|
+
# @return [ThinReports::Core::Shape::TextBlock::Formatter::Base]
|
10
10
|
def self.setup(format)
|
11
11
|
klass = if format.format_type.blank?
|
12
12
|
Basic
|
@@ -26,7 +26,7 @@ module ThinReports
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
require 'thinreports/core/shape/
|
30
|
-
require 'thinreports/core/shape/
|
31
|
-
require 'thinreports/core/shape/
|
32
|
-
require 'thinreports/core/shape/
|
29
|
+
require 'thinreports/core/shape/text_block/formatter/basic'
|
30
|
+
require 'thinreports/core/shape/text_block/formatter/datetime'
|
31
|
+
require 'thinreports/core/shape/text_block/formatter/padding'
|
32
|
+
require 'thinreports/core/shape/text_block/formatter/number'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
module ThinReports
|
4
|
-
module Core::Shape::
|
4
|
+
module Core::Shape::TextBlock
|
5
5
|
|
6
6
|
# @private
|
7
7
|
class Formatter::Padding < Formatter::Basic
|
@@ -10,18 +10,20 @@ module ThinReports
|
|
10
10
|
|
11
11
|
ruby_18 do
|
12
12
|
def apply_format_to(value)
|
13
|
-
|
14
|
-
pad_len = format.format_padding_length
|
13
|
+
value = value.to_s
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
char_length = value.unpack('U*').length
|
16
|
+
pad_length = format.format_padding_length
|
17
|
+
|
18
|
+
if pad_length > char_length
|
19
|
+
pad_strs = format.format_padding_char * (pad_length - char_length)
|
18
20
|
if format.format_padding_rdir?
|
19
|
-
|
21
|
+
value + pad_strs
|
20
22
|
else
|
21
|
-
pad_strs +
|
23
|
+
pad_strs + value
|
22
24
|
end
|
23
25
|
else
|
24
|
-
value
|
26
|
+
value
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ThinReports
|
4
4
|
module Core::Shape
|
5
5
|
|
6
|
-
class
|
6
|
+
class TextBlock::Interface < Basic::BlockInterface
|
7
7
|
internal_delegators :format_enabled?
|
8
8
|
|
9
9
|
# @param [Boolean] enabled
|
@@ -13,25 +13,6 @@ module ThinReports
|
|
13
13
|
self
|
14
14
|
end
|
15
15
|
|
16
|
-
# @overload value(val)
|
17
|
-
# Set a val
|
18
|
-
# @param [Object] val
|
19
|
-
# @return [self]
|
20
|
-
# @overload value
|
21
|
-
# Return the value
|
22
|
-
# @return [Object]
|
23
|
-
def value(*args)
|
24
|
-
case args.size
|
25
|
-
when 0
|
26
|
-
internal.read_value
|
27
|
-
when 1
|
28
|
-
internal.write_value(args.first)
|
29
|
-
self
|
30
|
-
else
|
31
|
-
raise ArgumentError, '#value can take 0 or 1 argument.'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
16
|
# @param [Object] val
|
36
17
|
# @param [Hash<Symbol, Object>] style_settings
|
37
18
|
# @return [self]
|
@@ -44,7 +25,7 @@ module ThinReports
|
|
44
25
|
|
45
26
|
# @see ThinReports::Core::Shape::Base::Interface#init_internal
|
46
27
|
def init_internal(parent, format)
|
47
|
-
|
28
|
+
TextBlock::Internal.new(parent, format)
|
48
29
|
end
|
49
30
|
end
|
50
31
|
|
@@ -4,14 +4,21 @@ module ThinReports
|
|
4
4
|
module Core::Shape
|
5
5
|
|
6
6
|
# @private
|
7
|
-
class
|
8
|
-
format_delegators :multiple
|
7
|
+
class TextBlock::Internal < Basic::BlockInternal
|
8
|
+
format_delegators :multiple?
|
9
9
|
|
10
10
|
def initialize(*args)
|
11
11
|
super(*args)
|
12
12
|
|
13
13
|
@reference = nil
|
14
14
|
@formatter = nil
|
15
|
+
|
16
|
+
@style = Style::Text.new(format)
|
17
|
+
@style.accessible_styles.delete(:valign) unless multiple?
|
18
|
+
end
|
19
|
+
|
20
|
+
def style
|
21
|
+
@style
|
15
22
|
end
|
16
23
|
|
17
24
|
def read_value
|
@@ -19,17 +26,16 @@ module ThinReports
|
|
19
26
|
@reference ||= parent.item(format.ref_id)
|
20
27
|
@reference.value
|
21
28
|
else
|
22
|
-
|
29
|
+
super
|
23
30
|
end
|
24
31
|
end
|
25
|
-
alias_method :value, :read_value
|
26
32
|
|
27
33
|
def write_value(val)
|
28
34
|
if format.has_reference?
|
29
|
-
warn 'The set value
|
35
|
+
warn 'The set value was not saved, ' +
|
30
36
|
"Because '#{format.id}' refers to '#{format.ref_id}'."
|
31
37
|
else
|
32
|
-
|
38
|
+
super
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
@@ -37,7 +43,7 @@ module ThinReports
|
|
37
43
|
if format_enabled?
|
38
44
|
formatter.apply(read_value)
|
39
45
|
else
|
40
|
-
|
46
|
+
super
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
@@ -51,18 +57,18 @@ module ThinReports
|
|
51
57
|
if states.key?(:format_enabled)
|
52
58
|
states[:format_enabled]
|
53
59
|
else
|
54
|
-
format.has_format?
|
60
|
+
!format.format_base.blank? || format.has_format?
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
58
64
|
def type_of?(type_name)
|
59
|
-
type_name == :tblock
|
65
|
+
type_name == :tblock || super
|
60
66
|
end
|
61
67
|
|
62
68
|
private
|
63
69
|
|
64
70
|
def formatter
|
65
|
-
@formatter ||=
|
71
|
+
@formatter ||= TextBlock::Formatter.setup(format)
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|