thinreports 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -6
- data/.travis.yml +4 -10
- data/CHANGELOG.md +220 -0
- data/Gemfile +3 -3
- 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/{test/case → examples}/dynamic_image/img200x100.png +0 -0
- data/{test/case → examples}/dynamic_image/img50x50.png +0 -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/{test/case → examples}/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +20 -0
- data/examples/eudc/eudc.tlf +1 -0
- data/{test/case → examples}/eudc/eudc.ttf +0 -0
- data/{test/case → examples}/helper.rb +14 -12
- 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/{test/case → examples}/list_manual_generation/list_manual_generation.rb +4 -4
- data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
- data/{test/case → examples}/list_page_number/list_page_number.rb +3 -3
- 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/{test/case → examples}/single_line_tblock/single_line_tblock.rb +2 -2
- 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/{test/case → examples}/typeB_page_size/typeB_page_size.rb +3 -3
- data/examples/word_wrap/word_wrap.rb +26 -0
- data/examples/word_wrap/word_wrap.tlf +1 -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
- data/lib/thinreports.rb +14 -2
- 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 -20
- data/lib/thinreports/core/format/builder.rb +14 -22
- data/lib/thinreports/core/shape.rb +9 -13
- data/lib/thinreports/core/shape/base.rb +4 -5
- 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/basic.rb +1 -1
- 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 +4 -5
- data/lib/thinreports/core/shape/image_block.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/list.rb +1 -1
- data/lib/thinreports/core/shape/list/configuration.rb +30 -15
- 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 +128 -95
- data/lib/thinreports/core/shape/list/page.rb +54 -50
- data/lib/thinreports/core/shape/list/page_state.rb +15 -16
- 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/manager.rb +1 -1
- data/lib/thinreports/core/shape/manager/format.rb +10 -11
- data/lib/thinreports/core/shape/manager/internal.rb +21 -20
- data/lib/thinreports/core/shape/manager/target.rb +63 -34
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +3 -3
- data/lib/thinreports/core/shape/page_number/interface.rb +2 -2
- data/lib/thinreports/core/shape/page_number/internal.rb +3 -3
- data/lib/thinreports/core/shape/style.rb +1 -1
- 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 +36 -30
- data/lib/thinreports/core/shape/text.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_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/format.rb +17 -18
- data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
- 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/interface.rb +2 -2
- data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
- data/lib/thinreports/core/utils.rb +33 -32
- data/lib/thinreports/generator.rb +6 -8
- data/lib/thinreports/generator/base.rb +15 -24
- data/lib/thinreports/generator/configuration.rb +10 -9
- data/lib/thinreports/generator/pdf.rb +27 -30
- data/lib/thinreports/generator/pdf/configuration.rb +11 -6
- data/lib/thinreports/generator/pdf/document.rb +28 -28
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +30 -31
- data/lib/thinreports/generator/pdf/document/font.rb +53 -44
- data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +25 -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 +40 -41
- data/lib/thinreports/generator/pdf/document/page.rb +20 -21
- 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/drawer/base.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/page.rb +16 -17
- data/lib/thinreports/generator/pdf/prawn_ext.rb +17 -33
- data/lib/thinreports/layout.rb +2 -2
- data/lib/thinreports/layout/base.rb +22 -36
- data/lib/thinreports/layout/configuration.rb +11 -9
- data/lib/thinreports/layout/format.rb +26 -27
- data/lib/thinreports/layout/version.rb +8 -9
- data/lib/thinreports/report.rb +10 -14
- data/lib/thinreports/report/base.rb +104 -126
- data/lib/thinreports/report/events.rb +5 -5
- data/lib/thinreports/report/internal.rb +41 -33
- data/lib/thinreports/{core → report}/page.rb +38 -30
- data/lib/thinreports/version.rb +2 -3
- 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/{unit/tmp → tmp}/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +14 -14
- data/test/unit/core/format/test_builder.rb +19 -23
- 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 +23 -20
- 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 +45 -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 +5 -5
- data/test/unit/core/shape/list/test_page.rb +80 -22
- data/test/unit/core/shape/list/test_page_state.rb +12 -12
- 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 +4 -4
- data/test/unit/core/shape/page_number/test_interface.rb +11 -8
- data/test/unit/core/shape/page_number/test_internal.rb +5 -5
- 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 +18 -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 +4 -4
- 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 +8 -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 +5 -5
- data/test/unit/core/test_shape.rb +6 -6
- data/test/unit/core/test_utils.rb +68 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +4 -4
- data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
- data/test/unit/generator/pdf/document/test_draw_shape.rb +9 -7
- 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 +44 -45
- 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 +17 -14
- 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 +134 -213
- data/test/unit/report/test_events.rb +4 -4
- data/test/unit/report/test_internal.rb +84 -86
- 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 +18 -22
- metadata +101 -200
- data/LICENSE +0 -1
- data/README.rdoc +0 -166
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/thinreports/core.rb +0 -20
- data/lib/thinreports/core/ext.rb +0 -5
- 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/format.rb +0 -14
- data/lib/thinreports/core/ordered_hash.rb +0 -39
- data/lib/thinreports/generator/pdf/drawer.rb +0 -16
- data/tasks/doc.rake +0 -12
- 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 -8
- 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/hidden_shapes/hidden_shapes.rb +0 -9
- 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_manual_generation/list_manual_generation.tlf +0 -1
- data/test/case/list_page_number/list_page_number.tlf +0 -1
- data/test/case/page_number/page_number.rb +0 -33
- data/test/case/page_number/page_number.tlf +0 -1
- data/test/case/password_setting/password_setting.rb +0 -10
- data/test/case/password_setting/password_setting.tlf +0 -1
- 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 -8
- data/test/case/text_align/text_align.tlf +0 -1
- data/test/case/typeB_page_size/B4_ISO.tlf +0 -1
- data/test/case/typeB_page_size/B4_JIS.tlf +0 -1
- data/test/case/word_wrap/word_wrap.rb +0 -26
- data/test/case/word_wrap/word_wrap.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 -87
@@ -1,16 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
5
|
|
6
6
|
class PageNumber::Format < Basic::Format
|
7
7
|
config_reader :overflow, :target, :box
|
8
|
-
config_reader :
|
8
|
+
config_reader default_format: %w( format )
|
9
9
|
|
10
10
|
def id
|
11
11
|
unless @id
|
12
12
|
@id = read('id')
|
13
|
-
@id = self.class.next_default_id if @id
|
13
|
+
@id = self.class.next_default_id if blank_value?(@id)
|
14
14
|
end
|
15
15
|
@id
|
16
16
|
end
|
@@ -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 PageNumber::Interface < Basic::Interface
|
@@ -17,7 +17,7 @@ module ThinReports
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
# @see
|
20
|
+
# @see Thinreports::Core::Shape::Base::Interface#init_internal
|
21
21
|
def init_internal(parent, format)
|
22
22
|
PageNumber::Internal.new(parent, format)
|
23
23
|
end
|
@@ -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 PageNumber::Internal < Basic::Internal
|
@@ -19,7 +19,7 @@ module ThinReports
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def build_format(page_no, page_count)
|
22
|
-
return '' if read_format
|
22
|
+
return '' if blank_value?(read_format)
|
23
23
|
|
24
24
|
if start_page_number > 1
|
25
25
|
page_no += start_page_number - 1
|
@@ -37,7 +37,7 @@ module ThinReports
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def for_report?
|
40
|
-
format.target
|
40
|
+
blank_value?(format.target)
|
41
41
|
end
|
42
42
|
|
43
43
|
def type_of?(type_name)
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class Style::Base
|
7
|
+
include Utils
|
8
|
+
|
8
9
|
class << self
|
9
10
|
# @param [Symbol] style_method
|
10
11
|
# @param [String] style
|
@@ -13,77 +14,76 @@ module ThinReports
|
|
13
14
|
style_reader(style_method, style)
|
14
15
|
style_writer(style_method, style)
|
15
16
|
end
|
16
|
-
|
17
|
+
|
17
18
|
# @see .style_accessor
|
18
19
|
def style_reader(style_method, style)
|
19
20
|
define_method(style_method) do
|
20
21
|
read_internal_style(style)
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|
24
|
+
|
24
25
|
# @see .style_accessor
|
25
26
|
def style_writer(style_method, style)
|
26
27
|
define_method(:"#{style_method}=") do |value|
|
27
28
|
write_internal_style(style, value)
|
28
29
|
end
|
29
30
|
end
|
30
|
-
|
31
|
+
|
31
32
|
# @param [Array<Symbol>] style_methods
|
32
33
|
def style_accessible(*style_methods)
|
33
34
|
accessible_styles.concat(style_methods)
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
# @return [Array<Symbol>]
|
37
38
|
def accessible_styles
|
38
39
|
@accessible_styles ||= []
|
39
40
|
end
|
40
|
-
|
41
|
-
# @private
|
41
|
+
|
42
42
|
def inherited(s)
|
43
43
|
s.accessible_styles.concat(accessible_styles.dup)
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
# @return [Hash]
|
48
48
|
attr_accessor :styles
|
49
49
|
# @see .accessible_styles
|
50
50
|
attr_reader :accessible_styles
|
51
|
-
|
52
|
-
# @param [
|
51
|
+
|
52
|
+
# @param [Thinreports::Core::Format::Base] format
|
53
53
|
# @param [Hash] default_styles ({})
|
54
54
|
def initialize(format, default_styles = {})
|
55
55
|
@format = format
|
56
56
|
@styles = default_styles
|
57
57
|
@base_styles = format.svg_attrs || {}
|
58
|
-
|
58
|
+
|
59
59
|
@accessible_styles = self.class.accessible_styles.dup
|
60
60
|
@finalized_svg_attributes = nil
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
# @param [Symbol] style_method
|
64
64
|
# @return [Object]
|
65
65
|
def [](style_method)
|
66
66
|
verify_style_method(style_method)
|
67
67
|
send(style_method.to_sym)
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
# @param [Symbol] style_method
|
71
71
|
# @param [String, Number, Array<String, Number>] value
|
72
72
|
def []=(style_method, value)
|
73
73
|
verify_style_method(style_method)
|
74
74
|
send(:"#{style_method}=", value)
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# @return [String]
|
78
78
|
def identifier
|
79
79
|
create_identifier(@styles)
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
# @return [self]
|
83
83
|
def copy
|
84
|
-
self.class.new(@format, @styles.empty? ? {} : @styles
|
84
|
+
self.class.new(@format, @styles.empty? ? {} : deep_copy(@styles))
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
# @return [Hash]
|
88
88
|
def finalized_svg_attributes
|
89
89
|
if @finalized_svg_attributes.nil?
|
@@ -96,44 +96,44 @@ module ThinReports
|
|
96
96
|
@finalized_svg_attributes
|
97
97
|
end
|
98
98
|
alias_method :svg_attrs, :finalized_svg_attributes
|
99
|
-
|
99
|
+
|
100
100
|
# @param [String, Symbol] style
|
101
101
|
# @return [Object]
|
102
102
|
def read_internal_style(style)
|
103
103
|
style = style.to_s
|
104
104
|
@styles.key?(style) ? @styles[style] : @base_styles[style]
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
# @param [String, Symbol] style
|
108
108
|
# @param [Object] value
|
109
109
|
def write_internal_style(style, value)
|
110
110
|
@styles[style.to_s] = value
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
# @param [Symbol] style_method
|
114
114
|
# @return [Boolean]
|
115
115
|
def has_style?(style_method)
|
116
116
|
accessible_styles.include?(style_method)
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
private
|
120
|
-
|
120
|
+
|
121
121
|
# @param [Hash] s
|
122
122
|
# @return [String]
|
123
123
|
def create_identifier(s)
|
124
124
|
s.empty? ? '' : s.hash.to_s
|
125
125
|
end
|
126
|
-
|
126
|
+
|
127
127
|
# @param [Symbol] style_method
|
128
128
|
# @return [Boolean]
|
129
|
-
# @raise
|
129
|
+
# @raise Thinreports::Errors::UnknownShapeStyleName
|
130
130
|
def verify_style_method(style_method)
|
131
131
|
unless has_style?(style_method)
|
132
|
-
raise
|
132
|
+
raise Thinreports::Errors::UnknownShapeStyleName.new(style_method,
|
133
133
|
accessible_styles)
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
# @param [Object] value
|
138
138
|
# @param [Array<Object>] allows
|
139
139
|
# @param [String] msg (nil)
|
@@ -144,6 +144,6 @@ module ThinReports
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
end
|
149
149
|
end
|
@@ -1,53 +1,38 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
5
|
+
|
6
6
|
class Style::Graphic < Style::Basic
|
7
|
-
style_accessible :border_color, :border_width, :fill_color, :border
|
8
|
-
|
9
|
-
|
7
|
+
style_accessible :border_color, :border_width, :fill_color, :border
|
8
|
+
|
10
9
|
# @method border_color
|
11
10
|
# @return [String]
|
12
11
|
# @method border_color=(color)
|
13
12
|
# @param [String] color
|
14
13
|
style_accessor :border_color, 'stroke'
|
15
|
-
|
14
|
+
|
16
15
|
# @method border_width
|
17
16
|
# @return [String, Number]
|
18
17
|
style_reader :border_width, 'stroke-width'
|
19
|
-
|
18
|
+
|
20
19
|
# @method fill_color
|
21
20
|
# @return [String]
|
22
21
|
# @method fill_color=(color)
|
23
22
|
# @param [String] color
|
24
23
|
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
|
-
|
24
|
+
|
40
25
|
# @param [String, Number] width
|
41
26
|
def border_width=(width)
|
42
27
|
write_internal_style('stroke-opacity', '1') unless width.to_i.zero?
|
43
28
|
write_internal_style('stroke-width', width)
|
44
29
|
end
|
45
|
-
|
30
|
+
|
46
31
|
# @return [Array<String, Number>]
|
47
32
|
def border
|
48
33
|
[self.border_width, self.border_color]
|
49
34
|
end
|
50
|
-
|
35
|
+
|
51
36
|
# @param [Array<String, Number>] width_and_color
|
52
37
|
def border=(width_and_color)
|
53
38
|
w, c = width_and_color
|
@@ -55,6 +40,6 @@ module ThinReports
|
|
55
40
|
self.border_color = c
|
56
41
|
end
|
57
42
|
end
|
58
|
-
|
43
|
+
|
59
44
|
end
|
60
45
|
end
|
@@ -1,124 +1,130 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
5
|
+
|
6
6
|
class Style::Text < Style::Basic
|
7
|
-
TEXT_ALIGN_NAMES = {:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
|
7
|
+
TEXT_ALIGN_NAMES = {left: 'start',
|
8
|
+
center: 'middle',
|
9
|
+
right: 'end'}
|
10
|
+
|
11
11
|
style_accessible :bold, :italic, :underline, :linethrough,
|
12
|
-
:align, :valign, :color
|
13
|
-
|
12
|
+
:align, :valign, :color, :font_size
|
13
|
+
|
14
14
|
# @method color
|
15
15
|
# @return [String]
|
16
16
|
# @method color=(v)
|
17
17
|
# @param [String] v
|
18
18
|
style_accessor :color, 'fill'
|
19
|
-
|
19
|
+
|
20
|
+
# @method font_size
|
21
|
+
# @return [Numeric, String]
|
22
|
+
# @method font_size=(v)
|
23
|
+
# @param [Numeric, String]
|
24
|
+
style_accessor :font_size, 'font-size'
|
25
|
+
|
20
26
|
def initialize(*args)
|
21
27
|
super
|
22
28
|
@valign = default_valign
|
23
29
|
end
|
24
|
-
|
30
|
+
|
25
31
|
def copy
|
26
32
|
new_style = super
|
27
33
|
new_style.valign = self.valign
|
28
34
|
new_style
|
29
35
|
end
|
30
|
-
|
36
|
+
|
31
37
|
def identifier
|
32
38
|
super + (@valign == default_valign ? '' : @valign.to_s)
|
33
39
|
end
|
34
|
-
|
40
|
+
|
35
41
|
# @return [Boolean]
|
36
42
|
def bold
|
37
43
|
read_internal_style('font-weight') == 'bold'
|
38
44
|
end
|
39
|
-
|
45
|
+
|
40
46
|
# @param [Boolean] enable
|
41
47
|
def bold=(enable)
|
42
48
|
write_internal_style('font-weight', enable ? 'bold' : 'normal')
|
43
49
|
end
|
44
|
-
|
50
|
+
|
45
51
|
# @return [Boolean]
|
46
52
|
def italic
|
47
53
|
read_internal_style('font-style') == 'italic'
|
48
54
|
end
|
49
|
-
|
55
|
+
|
50
56
|
# @param [Boolean] enable
|
51
57
|
def italic=(enable)
|
52
58
|
write_internal_style('font-style', enable ? 'italic' : 'normal')
|
53
59
|
end
|
54
|
-
|
60
|
+
|
55
61
|
# @return [Boolean]
|
56
62
|
def underline
|
57
63
|
read_internal_style('text-decoration').include?('underline')
|
58
64
|
end
|
59
|
-
|
65
|
+
|
60
66
|
# @param [Boolean] enable
|
61
67
|
def underline=(enable)
|
62
68
|
text_decoration(enable, linethrough)
|
63
69
|
end
|
64
|
-
|
70
|
+
|
65
71
|
# @return [Boolean]
|
66
72
|
def linethrough
|
67
73
|
read_internal_style('text-decoration').include?('line-through')
|
68
74
|
end
|
69
|
-
|
75
|
+
|
70
76
|
# @param [Boolean] enable
|
71
77
|
def linethrough=(enable)
|
72
78
|
text_decoration(underline, enable)
|
73
79
|
end
|
74
|
-
|
80
|
+
|
75
81
|
# @return [Symbol]
|
76
82
|
def align
|
77
83
|
interface_text_align(read_internal_style('text-anchor'))
|
78
84
|
end
|
79
|
-
|
85
|
+
|
80
86
|
# @param [:left, :center, :right] align_name
|
81
87
|
def align=(align_name)
|
82
88
|
verify_style_value(align_name, TEXT_ALIGN_NAMES.keys,
|
83
89
|
'Only :left or :center, :right can be specified as align.')
|
84
90
|
write_internal_style('text-anchor', internal_text_align(align_name))
|
85
91
|
end
|
86
|
-
|
92
|
+
|
87
93
|
# @return [Symbol]
|
88
94
|
def valign
|
89
95
|
@valign
|
90
96
|
end
|
91
|
-
|
97
|
+
|
92
98
|
# @param [:top, :center, :bottom] valign_name
|
93
99
|
def valign=(valign_name)
|
94
100
|
verify_style_value(valign_name, [:top, :center, :bottom],
|
95
101
|
'Only :top or :center, :bottom can be specified as valign.')
|
96
102
|
@valign = valign_name
|
97
103
|
end
|
98
|
-
|
104
|
+
|
99
105
|
private
|
100
|
-
|
106
|
+
|
101
107
|
# @return [Symbol, nil]
|
102
108
|
def default_valign
|
103
109
|
if accessible_styles.include?(:valign)
|
104
|
-
@format.valign
|
110
|
+
blank_value?(@format.valign) ? :top : @format.valign.to_sym
|
105
111
|
else
|
106
112
|
:top
|
107
113
|
end
|
108
114
|
end
|
109
|
-
|
115
|
+
|
110
116
|
# @param [Symbol] align The interface align name.
|
111
117
|
# @return [String, nil]
|
112
118
|
def internal_text_align(align)
|
113
119
|
TEXT_ALIGN_NAMES[align]
|
114
120
|
end
|
115
|
-
|
121
|
+
|
116
122
|
# @param [String] align The internal align name.
|
117
123
|
# @return [Symbol]
|
118
124
|
def interface_text_align(align)
|
119
125
|
TEXT_ALIGN_NAMES.invert[align] || :left
|
120
126
|
end
|
121
|
-
|
127
|
+
|
122
128
|
# @param [Boolean] u
|
123
129
|
# @param [Boolean] s
|
124
130
|
def text_decoration(u, s)
|
@@ -135,6 +141,6 @@ module ThinReports
|
|
135
141
|
write_internal_style('text-decoration', deco)
|
136
142
|
end
|
137
143
|
end
|
138
|
-
|
144
|
+
|
139
145
|
end
|
140
146
|
end
|