thinreports 0.7.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -5
- data/.travis.yml +8 -4
- data/CHANGELOG.md +220 -0
- data/Gemfile +2 -9
- data/MIT-LICENSE +1 -1
- data/README.md +286 -0
- data/Rakefile +38 -8
- data/examples/character_spacing/character_spacing.rb +8 -0
- data/examples/character_spacing/character_spacing.tlf +1 -0
- data/examples/dynamic_image/dynamic_image.rb +31 -0
- data/examples/dynamic_image/dynamic_image.tlf +1 -0
- data/examples/dynamic_style/dynamic_style.rb +150 -0
- data/examples/dynamic_style/dynamic_style.tlf +1 -0
- data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/examples/eudc/eudc.rb +20 -0
- data/examples/eudc/eudc.tlf +1 -0
- data/examples/helper.rb +50 -0
- data/examples/hidden_shapes/hidden_shapes.rb +9 -0
- data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
- data/examples/list_events/list_events.rb +59 -0
- data/examples/list_events/list_events_0_7_7.tlf +1 -0
- data/examples/list_events/list_events_0_8.tlf +1 -0
- data/examples/list_manual_generation/list_manual_generation.rb +22 -0
- data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
- data/examples/list_page_number/list_page_number.rb +17 -0
- data/examples/list_page_number/list_page_number.tlf +1 -0
- data/examples/page_number/page_number.rb +33 -0
- data/examples/page_number/page_number.tlf +1 -0
- data/examples/password_setting/password_setting.rb +10 -0
- data/examples/password_setting/password_setting.tlf +1 -0
- data/examples/report_callbacks/report_callbacks.rb +31 -0
- data/examples/report_callbacks/report_callbacks.tlf +1 -0
- data/examples/single_line_tblock/single_line_tblock.rb +13 -0
- data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
- data/examples/tblock_overflow/tblock_overflow.rb +20 -0
- data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
- data/examples/tblock_styles/font_size.tlf +1 -0
- data/examples/tblock_styles/tblock_styles.rb +43 -0
- data/examples/tblock_styles/tblock_styles.tlf +1 -0
- data/examples/text_align/text_align.rb +8 -0
- data/examples/text_align/text_align.tlf +1 -0
- data/examples/typeB_page_size/B4_ISO.tlf +1 -0
- data/examples/typeB_page_size/B4_JIS.tlf +1 -0
- data/examples/typeB_page_size/typeB_page_size.rb +17 -0
- data/examples/word_wrap/word_wrap.rb +26 -0
- data/examples/word_wrap/word_wrap.tlf +1 -0
- data/lib/thinreports/config.rb +30 -10
- data/lib/thinreports/core/errors.rb +23 -20
- data/lib/thinreports/core/events.rb +18 -19
- data/lib/thinreports/core/format/base.rb +20 -25
- data/lib/thinreports/core/format/builder.rb +19 -27
- data/lib/thinreports/core/shape/base/interface.rb +15 -15
- data/lib/thinreports/core/shape/base/internal.rb +15 -20
- data/lib/thinreports/core/shape/base.rb +4 -5
- data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
- data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
- data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
- data/lib/thinreports/core/shape/basic/format.rb +11 -10
- data/lib/thinreports/core/shape/basic/interface.rb +3 -3
- data/lib/thinreports/core/shape/basic/internal.rb +9 -6
- data/lib/thinreports/core/shape/basic.rb +1 -1
- data/lib/thinreports/core/shape/image_block/format.rb +5 -6
- data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
- data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/list/configuration.rb +37 -16
- data/lib/thinreports/core/shape/list/events.rb +11 -11
- data/lib/thinreports/core/shape/list/format.rb +27 -28
- data/lib/thinreports/core/shape/list/manager.rb +135 -95
- data/lib/thinreports/core/shape/list/page.rb +57 -51
- data/lib/thinreports/core/shape/list/page_state.rb +19 -17
- data/lib/thinreports/core/shape/list/section_format.rb +14 -15
- data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
- data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
- data/lib/thinreports/core/shape/list/store.rb +10 -11
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/manager/format.rb +10 -11
- data/lib/thinreports/core/shape/manager/internal.rb +22 -21
- data/lib/thinreports/core/shape/manager/target.rb +63 -34
- data/lib/thinreports/core/shape/manager.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +25 -0
- data/lib/thinreports/core/shape/page_number/interface.rb +27 -0
- data/lib/thinreports/core/shape/page_number/internal.rb +57 -0
- data/lib/thinreports/core/shape/page_number.rb +15 -0
- data/lib/thinreports/core/shape/style/base.rb +29 -29
- data/lib/thinreports/core/shape/style/basic.rb +1 -1
- data/lib/thinreports/core/shape/style/graphic.rb +10 -25
- data/lib/thinreports/core/shape/style/text.rb +41 -31
- data/lib/thinreports/core/shape/style.rb +1 -1
- data/lib/thinreports/core/shape/text/format.rb +8 -9
- data/lib/thinreports/core/shape/text/interface.rb +2 -2
- data/lib/thinreports/core/shape/text/internal.rb +6 -7
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text_block/format.rb +17 -17
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
- data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
- data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
- data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape.rb +11 -13
- data/lib/thinreports/core/utils.rb +33 -32
- data/lib/thinreports/generator/base.rb +15 -24
- data/lib/thinreports/generator/configuration.rb +10 -9
- data/lib/thinreports/generator/pdf/configuration.rb +11 -6
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +41 -32
- data/lib/thinreports/generator/pdf/document/font.rb +53 -44
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +34 -25
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +43 -41
- data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
- data/lib/thinreports/generator/pdf/document/page.rb +37 -23
- data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
- data/lib/thinreports/generator/pdf/document.rb +28 -28
- data/lib/thinreports/generator/pdf/drawer/base.rb +16 -22
- data/lib/thinreports/generator/pdf/drawer/list.rb +39 -21
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +17 -18
- data/lib/thinreports/generator/pdf/drawer/page.rb +37 -26
- data/lib/thinreports/generator/pdf/prawn_ext.rb +18 -17
- data/lib/thinreports/generator/pdf.rb +28 -31
- data/lib/thinreports/generator.rb +6 -8
- data/lib/thinreports/layout/base.rb +24 -36
- data/lib/thinreports/layout/configuration.rb +11 -9
- data/lib/thinreports/layout/format.rb +26 -31
- data/lib/thinreports/layout/version.rb +8 -9
- data/lib/thinreports/layout.rb +2 -2
- data/lib/thinreports/report/base.rb +117 -109
- data/lib/thinreports/report/events.rb +5 -5
- data/lib/thinreports/report/internal.rb +48 -38
- data/lib/thinreports/{core → report}/page.rb +42 -32
- data/lib/thinreports/report.rb +10 -14
- data/lib/thinreports/version.rb +2 -3
- data/lib/thinreports.rb +14 -2
- data/test/data/font.ttf +0 -0
- data/test/data/layout_block.tlf +1 -0
- data/test/data/layout_list.tlf +1 -0
- data/test/data/layout_list_noheader.tlf +1 -0
- data/test/data/layout_text1.tlf +1 -0
- data/test/data/layout_text2.tlf +1 -0
- data/test/test_helper.rb +74 -0
- data/test/tmp/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +14 -14
- data/test/unit/core/format/test_builder.rb +20 -25
- data/test/unit/core/shape/base/test_internal.rb +34 -37
- data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
- data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
- data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
- data/test/unit/core/shape/basic/test_format.rb +4 -4
- data/test/unit/core/shape/basic/test_interface.rb +36 -46
- data/test/unit/core/shape/basic/test_internal.rb +29 -18
- data/test/unit/core/shape/image_block/test_format.rb +5 -5
- data/test/unit/core/shape/image_block/test_interface.rb +17 -16
- data/test/unit/core/shape/image_block/test_internal.rb +19 -16
- data/test/unit/core/shape/list/test_configuration.rb +50 -33
- data/test/unit/core/shape/list/test_events.rb +7 -7
- data/test/unit/core/shape/list/test_format.rb +16 -18
- data/test/unit/core/shape/list/test_manager.rb +15 -5
- data/test/unit/core/shape/list/test_page.rb +80 -22
- data/test/unit/core/shape/list/test_page_state.rb +13 -13
- data/test/unit/core/shape/list/test_section_format.rb +16 -17
- data/test/unit/core/shape/list/test_section_interface.rb +30 -22
- data/test/unit/core/shape/list/test_section_internal.rb +21 -19
- data/test/unit/core/shape/list/test_store.rb +7 -7
- data/test/unit/core/shape/manager/test_format.rb +11 -15
- data/test/unit/core/shape/manager/test_internal.rb +9 -9
- data/test/unit/core/shape/manager/test_target.rb +85 -57
- data/test/unit/core/shape/page_number/test_format.rb +73 -0
- data/test/unit/core/shape/page_number/test_interface.rb +33 -0
- data/test/unit/core/shape/page_number/test_internal.rb +81 -0
- data/test/unit/core/shape/styles/test_base.rb +9 -9
- data/test/unit/core/shape/styles/test_basic.rb +5 -5
- data/test/unit/core/shape/styles/test_graphic.rb +19 -33
- data/test/unit/core/shape/styles/test_text.rb +29 -7
- data/test/unit/core/shape/text/test_format.rb +6 -6
- data/test/unit/core/shape/text/test_internal.rb +11 -12
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +22 -20
- data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
- data/test/unit/core/shape/text_block/test_format.rb +13 -8
- data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
- data/test/unit/core/shape/text_block/test_interface.rb +37 -20
- data/test/unit/core/shape/text_block/test_internal.rb +38 -38
- data/test/unit/core/test_events.rb +10 -8
- data/test/unit/core/test_shape.rb +11 -7
- data/test/unit/core/test_utils.rb +68 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +10 -4
- data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
- data/test/unit/generator/pdf/document/test_draw_shape.rb +14 -6
- data/test/unit/generator/pdf/document/test_font.rb +79 -58
- data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
- data/test/unit/generator/pdf/document/test_page.rb +68 -43
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/pdf/test_configuration.rb +16 -9
- data/test/unit/generator/pdf/test_document.rb +8 -16
- data/test/unit/generator/test_base.rb +31 -42
- data/test/unit/generator/test_configuration.rb +6 -6
- data/test/unit/generator/test_pdf.rb +15 -21
- data/test/unit/layout/test_base.rb +34 -79
- data/test/unit/layout/test_configuration.rb +12 -37
- data/test/unit/layout/test_format.rb +36 -39
- data/test/unit/layout/test_version.rb +4 -4
- data/test/unit/report/test_base.rb +160 -192
- data/test/unit/report/test_events.rb +4 -4
- data/test/unit/report/test_internal.rb +102 -82
- data/test/unit/test_config.rb +31 -12
- data/test/unit/test_layout.rb +7 -7
- data/test/unit/test_report.rb +12 -24
- data/thinreports.gemspec +23 -26
- metadata +118 -181
- data/.yardopts +0 -1
- data/LICENSE +0 -1
- data/README.rdoc +0 -167
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/thinreports/core/ext/array.rb +0 -19
- data/lib/thinreports/core/ext/hash.rb +0 -19
- data/lib/thinreports/core/ext/object.rb +0 -25
- data/lib/thinreports/core/ext.rb +0 -5
- data/lib/thinreports/core/format.rb +0 -14
- data/lib/thinreports/core/ordered_hash.rb +0 -39
- data/lib/thinreports/core.rb +0 -20
- data/lib/thinreports/generator/pdf/drawer.rb +0 -16
- data/tasks/doc.rake +0 -13
- data/tasks/test.rake +0 -56
- data/test/benchmark/basic_estimate.tlf +0 -1
- data/test/benchmark/bench_basic_estimate.rb +0 -95
- data/test/case/character_spacing/character_spacing.rb +0 -7
- data/test/case/character_spacing/character_spacing.tlf +0 -1
- data/test/case/dynamic_image/dynamic_image.rb +0 -41
- data/test/case/dynamic_image/dynamic_image.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style.rb +0 -154
- data/test/case/dynamic_style/dynamic_style.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
- data/test/case/eudc/eudc.rb +0 -20
- data/test/case/eudc/eudc.tlf +0 -1
- data/test/case/helper.rb +0 -29
- data/test/case/hidden_shapes/hidden_shapes.rb +0 -13
- data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
- data/test/case/list_events/list_events.rb +0 -32
- data/test/case/list_events/list_events.tlf +0 -1
- data/test/case/list_header_inheriting/list_header_inheriting.rb +0 -17
- data/test/case/list_header_inheriting/list_header_inheriting.tlf +0 -1
- data/test/case/list_manual_generation/list_manual_generation.rb +0 -22
- data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
- data/test/case/single_line_tblock/single_line_tblock.rb +0 -15
- data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
- data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
- data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
- data/test/case/tblock_styles/tblock_styles.rb +0 -27
- data/test/case/tblock_styles/tblock_styles.tlf +0 -1
- data/test/case/text_align/text_align.rb +0 -9
- data/test/case/text_align/text_align.tlf +0 -1
- data/test/unit/core/ext/array_spec.rb +0 -29
- data/test/unit/core/ext/hash_spec.rb +0 -29
- data/test/unit/core/ext/object_spec.rb +0 -30
- data/test/unit/core/ordered_hash_spec.rb +0 -51
- data/test/unit/core/shape/base/test_interface.rb +0 -52
- data/test/unit/core/utils_spec.rb +0 -56
- data/test/unit/data/basic_layout1.tlf +0 -1
- data/test/unit/data/basic_layout2.tlf +0 -1
- data/test/unit/data/basic_list_layout.tlf +0 -1
- data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
- data/test/unit/helper.rb +0 -65
- /data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
- /data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
- /data/{test/case → examples}/dynamic_style/image.png +0 -0
- /data/{test/case → examples}/eudc/eudc.ttf +0 -0
- /data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
- /data/{resources/fonts → fonts}/ipag.ttf +0 -0
- /data/{resources/fonts → fonts}/ipagp.ttf +0 -0
- /data/{resources/fonts → fonts}/ipam.ttf +0 -0
- /data/{resources/fonts → fonts}/ipamp.ttf +0 -0
@@ -2,23 +2,22 @@
|
|
2
2
|
|
3
3
|
require 'bigdecimal'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Thinreports
|
6
6
|
module Core::Shape::TextBlock
|
7
|
-
|
8
|
-
# @private
|
7
|
+
|
9
8
|
class Formatter::Number < Formatter::Basic
|
10
|
-
|
9
|
+
|
11
10
|
private
|
12
|
-
|
11
|
+
|
13
12
|
def apply_format_to(value)
|
14
13
|
precision = format.format_number_precision
|
15
14
|
delimiter = format.format_number_delimiter
|
16
|
-
|
15
|
+
|
17
16
|
if_applicable value do |val|
|
18
|
-
unless precision
|
17
|
+
unless blank_value?(precision)
|
19
18
|
val = number_with_precision(val, precision)
|
20
19
|
end
|
21
|
-
unless delimiter
|
20
|
+
unless blank_value?(delimiter)
|
22
21
|
val = number_with_delimiter(val, delimiter)
|
23
22
|
end
|
24
23
|
val
|
@@ -34,16 +33,16 @@ module ThinReports
|
|
34
33
|
end
|
35
34
|
val.nil? ? value : block.call(val)
|
36
35
|
end
|
37
|
-
|
36
|
+
|
38
37
|
def number_with_delimiter(value, delimiter = ',')
|
39
38
|
value.to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/){ "#{$1}#{delimiter}" }
|
40
39
|
end
|
41
|
-
|
40
|
+
|
42
41
|
def number_with_precision(value, precision = 3)
|
43
42
|
value = BigDecimal(value.to_s).round(precision)
|
44
43
|
sprintf("%.#{precision}f", value)
|
45
44
|
end
|
46
45
|
end
|
47
|
-
|
46
|
+
|
48
47
|
end
|
49
|
-
end
|
48
|
+
end
|
@@ -1,45 +1,22 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape::TextBlock
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class Formatter::Padding < Formatter::Basic
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ruby_18 do
|
12
|
-
def apply_format_to(value)
|
13
|
-
value = value.to_s
|
14
|
-
|
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)
|
20
|
-
if format.format_padding_rdir?
|
21
|
-
value + pad_strs
|
22
|
-
else
|
23
|
-
pad_strs + value
|
24
|
-
end
|
25
|
-
else
|
26
|
-
value
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
ruby_19 do
|
7
|
+
|
8
|
+
private
|
9
|
+
|
32
10
|
def apply_format_to(value)
|
33
11
|
value.to_s.send(format.format_padding_rdir? ? :ljust : :rjust,
|
34
12
|
format.format_padding_length,
|
35
13
|
format.format_padding_char)
|
36
14
|
end
|
37
|
-
|
38
|
-
|
15
|
+
|
39
16
|
def applicable?(value)
|
40
|
-
!format.format_padding_char
|
17
|
+
!blank_value?(format.format_padding_char) && format.format_padding_length > 0
|
41
18
|
end
|
42
19
|
end
|
43
|
-
|
20
|
+
|
44
21
|
end
|
45
|
-
end
|
22
|
+
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape::TextBlock
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
module Formatter
|
8
|
-
# @param [
|
9
|
-
# @return [
|
7
|
+
# @param [Thinreports::Core::Shape::TextBlock::Format] format
|
8
|
+
# @return [Thinreports::Core::Shape::TextBlock::Formatter::Base]
|
10
9
|
def self.setup(format)
|
11
|
-
klass = if format.format_type
|
10
|
+
klass = if Thinreports.blank_value?(format.format_type)
|
12
11
|
Basic
|
13
12
|
else
|
14
13
|
case format.format_type
|
@@ -16,13 +15,13 @@ module ThinReports
|
|
16
15
|
when 'datetime' then Datetime
|
17
16
|
when 'padding' then Padding
|
18
17
|
else
|
19
|
-
raise
|
18
|
+
raise Thinreports::Errors::UnknownFormatterType
|
20
19
|
end
|
21
20
|
end
|
22
21
|
klass.new(format)
|
23
22
|
end
|
24
23
|
end
|
25
|
-
|
24
|
+
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
5
|
|
6
6
|
class TextBlock::Interface < Basic::BlockInterface
|
@@ -23,7 +23,7 @@ module ThinReports
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
# @see
|
26
|
+
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
27
27
|
def init_internal(parent, format)
|
28
28
|
TextBlock::Internal.new(parent, format)
|
29
29
|
end
|
@@ -1,26 +1,25 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class TextBlock::Internal < Basic::BlockInternal
|
8
7
|
format_delegators :multiple?
|
9
|
-
|
8
|
+
|
10
9
|
def initialize(*args)
|
11
10
|
super(*args)
|
12
|
-
|
11
|
+
|
13
12
|
@reference = nil
|
14
13
|
@formatter = nil
|
15
|
-
|
14
|
+
|
16
15
|
@style = Style::Text.new(format)
|
17
16
|
@style.accessible_styles.delete(:valign) unless multiple?
|
18
17
|
end
|
19
|
-
|
18
|
+
|
20
19
|
def style
|
21
20
|
@style
|
22
21
|
end
|
23
|
-
|
22
|
+
|
24
23
|
def read_value
|
25
24
|
if format.has_reference?
|
26
25
|
@reference ||= parent.item(format.ref_id)
|
@@ -29,16 +28,16 @@ module ThinReports
|
|
29
28
|
super
|
30
29
|
end
|
31
30
|
end
|
32
|
-
|
31
|
+
|
33
32
|
def write_value(val)
|
34
33
|
if format.has_reference?
|
35
34
|
warn 'The set value was not saved, ' +
|
36
|
-
"Because '#{format.id}'
|
35
|
+
"Because '#{format.id}' has reference to '#{format.ref_id}'."
|
37
36
|
else
|
38
37
|
super
|
39
38
|
end
|
40
39
|
end
|
41
|
-
|
40
|
+
|
42
41
|
def real_value
|
43
42
|
if format_enabled?
|
44
43
|
formatter.apply(read_value)
|
@@ -46,31 +45,31 @@ module ThinReports
|
|
46
45
|
super
|
47
46
|
end
|
48
47
|
end
|
49
|
-
|
48
|
+
|
50
49
|
def format_enabled(enabled)
|
51
50
|
states[:format_enabled] = enabled
|
52
51
|
end
|
53
|
-
|
52
|
+
|
54
53
|
def format_enabled?
|
55
54
|
return false if multiple?
|
56
|
-
|
55
|
+
|
57
56
|
if states.key?(:format_enabled)
|
58
57
|
states[:format_enabled]
|
59
58
|
else
|
60
|
-
!format.format_base
|
59
|
+
!blank_value?(format.format_base) || format.has_format?
|
61
60
|
end
|
62
61
|
end
|
63
|
-
|
62
|
+
|
64
63
|
def type_of?(type_name)
|
65
64
|
type_name == :tblock || super
|
66
65
|
end
|
67
|
-
|
66
|
+
|
68
67
|
private
|
69
|
-
|
68
|
+
|
70
69
|
def formatter
|
71
70
|
@formatter ||= TextBlock::Formatter.setup(format)
|
72
71
|
end
|
73
72
|
end
|
74
|
-
|
73
|
+
|
75
74
|
end
|
76
|
-
end
|
75
|
+
end
|
@@ -1,44 +1,41 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core
|
5
|
-
|
5
|
+
|
6
6
|
module Shape
|
7
|
-
# @private
|
8
7
|
def Interface(parent, format)
|
9
8
|
find_by_type(format.type)::Interface.new(parent, format)
|
10
9
|
end
|
11
|
-
|
12
|
-
# @private
|
10
|
+
|
13
11
|
def Format(type)
|
14
12
|
find_by_type(type)::Format
|
15
13
|
end
|
16
|
-
|
17
|
-
# @private
|
14
|
+
|
18
15
|
def Configuration(type)
|
19
16
|
klass = find_by_type(type)
|
20
17
|
unless klass.const_defined?(:Configuration)
|
21
|
-
raise
|
18
|
+
raise Thinreports::Errors::NoConfigurationFound, type
|
22
19
|
end
|
23
20
|
klass.const_get(:Configuration)
|
24
21
|
end
|
25
|
-
|
22
|
+
|
26
23
|
module_function :Interface, :Format, :Configuration
|
27
|
-
|
28
|
-
# @private
|
24
|
+
|
29
25
|
def self.find_by_type(type)
|
30
26
|
case type
|
31
27
|
when TextBlock::TYPE_NAME then TextBlock
|
32
28
|
when ImageBlock::TYPE_NAME then ImageBlock
|
33
29
|
when List::TYPE_NAME then List
|
34
30
|
when Text::TYPE_NAME then Text
|
31
|
+
when PageNumber::TYPE_NAME then PageNumber
|
35
32
|
when *Basic::TYPE_NAMES then Basic
|
36
33
|
else
|
37
|
-
raise
|
34
|
+
raise Thinreports::Errors::UnknownShapeType
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
41
|
-
|
38
|
+
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
@@ -50,3 +47,4 @@ require 'thinreports/core/shape/text'
|
|
50
47
|
require 'thinreports/core/shape/text_block'
|
51
48
|
require 'thinreports/core/shape/image_block'
|
52
49
|
require 'thinreports/core/shape/list'
|
50
|
+
require 'thinreports/core/shape/page_number'
|
@@ -1,40 +1,41 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
module Thinreports
|
4
|
+
module Utils
|
5
|
+
def self.included(klass)
|
6
|
+
klass.extend self
|
7
|
+
end
|
8
|
+
|
9
|
+
def deep_copy(src)
|
10
|
+
case src
|
11
|
+
when Hash
|
12
|
+
src.inject({}) {|h, (k, v)| h[k] = (v.dup rescue v); h }
|
13
|
+
when Array
|
14
|
+
src.map {|a| a.dup rescue a }
|
15
|
+
else
|
16
|
+
raise ArgumentError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def blank_value?(value)
|
21
|
+
case value
|
22
|
+
when String then value.empty?
|
23
|
+
when NilClass then true
|
24
|
+
else false
|
17
25
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def call_block_in(scope, &block)
|
29
|
+
return scope unless block_given?
|
30
|
+
|
31
|
+
if block.arity == 1
|
32
|
+
block.call(scope)
|
26
33
|
else
|
27
|
-
|
28
|
-
false
|
29
|
-
end
|
30
|
-
def ruby_19
|
31
|
-
yield
|
32
|
-
end
|
34
|
+
scope.instance_eval(&block)
|
33
35
|
end
|
36
|
+
scope
|
34
37
|
end
|
35
|
-
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
extend Utils
|
41
|
+
end
|
@@ -1,49 +1,40 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator
|
5
|
-
|
5
|
+
|
6
6
|
# @abstract
|
7
7
|
class Base
|
8
|
-
# @return [
|
9
|
-
# @private
|
8
|
+
# @return [Thinreports::Report::Base]
|
10
9
|
attr_reader :report
|
11
10
|
|
12
11
|
# @return [Hash]
|
13
|
-
# @private
|
14
12
|
attr_reader :options
|
15
|
-
|
16
|
-
# @private
|
13
|
+
|
17
14
|
def self.inherited(g)
|
18
15
|
Generator.register(g.name.split('::').last.downcase.to_sym, g);
|
19
16
|
end
|
20
|
-
|
21
|
-
# @param [
|
17
|
+
|
18
|
+
# @param [Thinreports::Report::Base] report
|
22
19
|
# @param [Hash] options
|
23
20
|
def initialize(report, options = {})
|
24
21
|
report.finalize
|
25
|
-
|
22
|
+
|
26
23
|
@report = report.internal
|
27
24
|
@options = options || {}
|
28
25
|
end
|
29
|
-
|
30
|
-
# @
|
31
|
-
# @
|
32
|
-
def generate
|
33
|
-
raise NotImplementedError
|
34
|
-
end
|
35
|
-
|
36
|
-
# @param [String] filename
|
26
|
+
|
27
|
+
# @param [String, nil] filename
|
28
|
+
# @return [String, nil]
|
37
29
|
# @abstract
|
38
|
-
def
|
30
|
+
def generate(filename = nil)
|
39
31
|
raise NotImplementedError
|
40
32
|
end
|
41
|
-
|
42
|
-
# @private
|
33
|
+
|
43
34
|
def default_layout
|
44
35
|
report.default_layout
|
45
|
-
end
|
36
|
+
end
|
46
37
|
end
|
47
|
-
|
38
|
+
|
48
39
|
end
|
49
|
-
end
|
40
|
+
end
|
@@ -1,30 +1,31 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator
|
5
|
-
|
5
|
+
|
6
|
+
# @deprecated This class will be removed in the next major version.
|
6
7
|
class Configuration
|
7
8
|
# @return [Symbol]
|
8
9
|
attr_reader :default
|
9
|
-
|
10
|
+
|
10
11
|
def initialize
|
11
12
|
@default = :pdf
|
12
13
|
end
|
13
|
-
|
14
|
-
# @return [
|
14
|
+
|
15
|
+
# @return [Thinreports::Generator::PDF::Configuration]
|
15
16
|
def pdf
|
16
17
|
@pdf ||= PDF::Configuration.new
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
# @param [Symbol] type
|
20
21
|
# @return [void]
|
21
22
|
def default=(type)
|
22
23
|
unless Generator.registry.key?(type)
|
23
|
-
raise
|
24
|
+
raise Thinreports::Errors::UnknownGeneratorType.new(type)
|
24
25
|
end
|
25
26
|
@default = type
|
26
27
|
end
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
end
|
30
|
-
end
|
31
|
+
end
|
@@ -1,20 +1,25 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator
|
5
|
-
|
5
|
+
|
6
|
+
# @deprecated This class will be removed in the next major version.
|
6
7
|
class PDF::Configuration
|
7
8
|
# @return [Array]
|
8
9
|
attr_reader :eudc_fonts
|
9
|
-
|
10
|
+
|
10
11
|
def initialize
|
11
12
|
@eudc_fonts = []
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
# @param [String, Array<String>] fonts
|
15
16
|
def eudc_fonts=(fonts)
|
17
|
+
warn '[DEPRECATION] `eudc_fonts=` is deprecated and will be removed in ' +
|
18
|
+
'the next major version of thinreports. ' +
|
19
|
+
'Please use `Thinreports.config.fallback_fonts=` instead.'
|
20
|
+
|
16
21
|
fonts = [fonts] unless fonts.is_a?(::Array)
|
17
|
-
|
22
|
+
|
18
23
|
fonts.each do |f|
|
19
24
|
unless File.extname(f.to_s) == '.ttf'
|
20
25
|
raise ArgumentError, 'The EUDC Fonts can specify only the TTF file.'
|
@@ -23,6 +28,6 @@ module ThinReports
|
|
23
28
|
@eudc_fonts = fonts
|
24
29
|
end
|
25
30
|
end
|
26
|
-
|
31
|
+
|
27
32
|
end
|
28
33
|
end
|
@@ -1,18 +1,17 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Generator
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
module PDF::DrawShape
|
8
|
-
# @param [
|
7
|
+
# @param [Thinreports::Core::Shape::TextBlock::Internal] shape
|
9
8
|
def draw_shape_tblock(shape)
|
10
9
|
x, y, w, h = shape.box.values_at('x', 'y', 'width', 'height')
|
11
|
-
|
10
|
+
|
12
11
|
content = shape.real_value.to_s
|
13
12
|
unless content.empty?
|
14
13
|
attrs = shape_text_attrs(shape)
|
15
|
-
|
14
|
+
|
16
15
|
unless shape.multiple?
|
17
16
|
content = content.gsub(/\n/, ' ')
|
18
17
|
attrs[:single] = true
|
@@ -20,49 +19,56 @@ module ThinReports
|
|
20
19
|
text_box(content, x, y, w, h, attrs)
|
21
20
|
end
|
22
21
|
end
|
23
|
-
|
24
|
-
|
22
|
+
|
23
|
+
def draw_shape_pageno(shape, page_no, page_count)
|
24
|
+
x, y, w, h = shape.box.values_at('x', 'y', 'width', 'height')
|
25
|
+
|
26
|
+
text_box(shape.build_format(page_no, page_count), x, y, w, h,
|
27
|
+
common_text_attrs(shape.style.svg_attrs))
|
28
|
+
end
|
29
|
+
|
30
|
+
# @param [Thinreports::Core::Shape::Basic::Internal] shape
|
25
31
|
def draw_shape_image(shape)
|
26
32
|
x, y, w, h = shape.style.svg_attrs.values_at('x', 'y', 'width', 'height')
|
27
33
|
base64image(extract_base64_string(shape.style.svg_attrs['xlink:href']),
|
28
34
|
x, y, w, h)
|
29
35
|
end
|
30
|
-
|
31
|
-
# @param [
|
36
|
+
|
37
|
+
# @param [Thinreports::Core::Shape::ImageBlock::Internal] shape
|
32
38
|
def draw_shape_iblock(shape)
|
33
39
|
x, y, w, h = shape.box.values_at('x', 'y', 'width', 'height')
|
34
|
-
unless shape.src
|
40
|
+
unless blank_value?(shape.src)
|
35
41
|
posx = shape.format.position_x
|
36
42
|
posy = shape.format.position_y
|
37
|
-
|
43
|
+
|
38
44
|
image_box(shape.src, x, y, w, h,
|
39
|
-
:
|
40
|
-
:
|
45
|
+
position_x: posx ? posx.to_sym : nil,
|
46
|
+
position_y: posy ? posy.to_sym : nil)
|
41
47
|
end
|
42
48
|
end
|
43
|
-
|
44
|
-
# @param [
|
49
|
+
|
50
|
+
# @param [Thinreports::Core::Shape::Text::Internal] shape
|
45
51
|
def draw_shape_text(shape)
|
46
52
|
x, y, w, h = shape.box.values_at('x', 'y', 'width', 'height')
|
47
|
-
text(shape.text.join("\n"), x, y, w, h,
|
53
|
+
text(shape.text.join("\n"), x, y, w, h,
|
48
54
|
shape_text_attrs(shape))
|
49
55
|
end
|
50
|
-
|
51
|
-
# @param [
|
56
|
+
|
57
|
+
# @param [Thinreports::Core::Shape::Basic::Internal] shape
|
52
58
|
def draw_shape_ellipse(shape)
|
53
59
|
args = shape.style.svg_attrs.values_at('cx', 'cy', 'rx', 'ry')
|
54
60
|
args << common_graphic_attrs(shape.style.svg_attrs)
|
55
61
|
ellipse(*args)
|
56
62
|
end
|
57
|
-
|
58
|
-
# @param [
|
63
|
+
|
64
|
+
# @param [Thinreports::Core::Shape::Basic::Internal] shape
|
59
65
|
def draw_shape_line(shape)
|
60
66
|
args = shape.style.svg_attrs.values_at('x1', 'y1', 'x2', 'y2')
|
61
67
|
args << common_graphic_attrs(shape.style.svg_attrs)
|
62
68
|
line(*args)
|
63
69
|
end
|
64
|
-
|
65
|
-
# @param [
|
70
|
+
|
71
|
+
# @param [Thinreports::Core::Shape::Basic::Internal] shape
|
66
72
|
def draw_shape_rect(shape)
|
67
73
|
args = shape.style.svg_attrs.values_at('x', 'y', 'width', 'height')
|
68
74
|
args << common_graphic_attrs(shape.style.svg_attrs) do |attrs|
|
@@ -70,26 +76,29 @@ module ThinReports
|
|
70
76
|
end
|
71
77
|
rect(*args)
|
72
78
|
end
|
73
|
-
|
79
|
+
|
74
80
|
private
|
75
|
-
|
76
|
-
# @param [
|
81
|
+
|
82
|
+
# @param [Thinreports::Core::Shape::Text::Internal, Thinreports::Core::Shape::TextBlock::Internal] shape
|
77
83
|
# @return [Hash]
|
78
84
|
def shape_text_attrs(shape)
|
79
85
|
format = shape.format
|
80
|
-
|
86
|
+
|
81
87
|
common_text_attrs(shape.style.svg_attrs) do |attrs|
|
82
88
|
# Set the :line_height option.
|
83
|
-
attrs[:line_height] = format.line_height unless format.line_height
|
89
|
+
attrs[:line_height] = format.line_height unless blank_value?(format.line_height)
|
84
90
|
# Set the :valign option.
|
85
91
|
attrs[:valign] = shape.style.valign
|
86
92
|
|
87
|
-
|
88
|
-
|
93
|
+
if shape.type_of?(:tblock)
|
94
|
+
# Set the :overflow option.
|
95
|
+
attrs[:overflow] = text_overflow(format.overflow)
|
96
|
+
# Set the :word_wrap option
|
97
|
+
attrs[:word_wrap] = text_word_wrap(format.word_wrap)
|
98
|
+
end
|
89
99
|
end
|
90
100
|
end
|
91
|
-
|
92
101
|
end
|
93
|
-
|
102
|
+
|
94
103
|
end
|
95
104
|
end
|