thinreports 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +11 -1
- data/Gemfile +2 -9
- data/MIT-LICENSE +1 -1
- data/README.rdoc +25 -26
- data/lib/thinreports/core/format/base.rb +0 -5
- data/lib/thinreports/core/format/builder.rb +5 -5
- data/lib/thinreports/core/page.rb +5 -3
- data/lib/thinreports/core/shape.rb +2 -0
- data/lib/thinreports/core/shape/basic/internal.rb +5 -1
- data/lib/thinreports/core/shape/list/configuration.rb +9 -3
- data/lib/thinreports/core/shape/list/manager.rb +11 -4
- data/lib/thinreports/core/shape/list/page.rb +3 -1
- data/lib/thinreports/core/shape/list/page_state.rb +4 -1
- data/lib/thinreports/core/shape/manager/internal.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +15 -0
- 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/style/text.rb +6 -2
- data/lib/thinreports/core/shape/text_block/format.rb +1 -0
- data/lib/thinreports/generator/pdf.rb +1 -1
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +14 -4
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +9 -0
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +4 -1
- data/lib/thinreports/generator/pdf/document/page.rb +18 -3
- data/lib/thinreports/generator/pdf/drawer/base.rb +3 -8
- data/lib/thinreports/generator/pdf/drawer/list.rb +31 -12
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +5 -5
- data/lib/thinreports/generator/pdf/drawer/page.rb +22 -10
- data/lib/thinreports/generator/pdf/prawn_ext.rb +18 -1
- data/lib/thinreports/layout/base.rb +4 -2
- data/lib/thinreports/layout/format.rb +1 -5
- data/lib/thinreports/report/base.rb +36 -6
- data/lib/thinreports/report/internal.rb +7 -5
- data/lib/thinreports/version.rb +1 -1
- data/tasks/doc.rake +0 -1
- data/test/case/character_spacing/character_spacing.rb +4 -3
- data/test/case/dynamic_image/dynamic_image.rb +34 -34
- data/test/case/dynamic_style/dynamic_style.rb +141 -141
- data/test/case/eudc/eudc.rb +16 -16
- data/test/case/helper.rb +39 -20
- data/test/case/hidden_shapes/hidden_shapes.rb +4 -8
- data/test/case/list_events/list_events.rb +26 -26
- data/test/case/list_manual_generation/list_manual_generation.rb +16 -16
- data/test/case/list_page_number/list_page_number.rb +17 -0
- data/test/case/list_page_number/list_page_number.tlf +1 -0
- data/test/case/page_number/page_number.rb +33 -0
- data/test/case/page_number/page_number.tlf +1 -0
- data/test/case/password_setting/password_setting.rb +10 -0
- data/test/case/password_setting/password_setting.tlf +1 -0
- data/test/case/single_line_tblock/single_line_tblock.rb +10 -12
- data/test/case/tblock_overflow/tblock_overflow.rb +16 -16
- data/test/case/tblock_styles/tblock_styles.rb +24 -24
- data/test/case/text_align/text_align.rb +5 -6
- data/test/case/typeB_page_size/B4_ISO.tlf +1 -0
- data/test/case/typeB_page_size/B4_JIS.tlf +1 -0
- data/test/case/typeB_page_size/typeB_page_size.rb +17 -0
- data/test/case/word_wrap/word_wrap.rb +26 -0
- data/test/case/word_wrap/word_wrap.tlf +1 -0
- data/test/unit/core/format/test_builder.rb +1 -2
- data/test/unit/core/shape/basic/test_internal.rb +9 -1
- data/test/unit/core/shape/list/test_configuration.rb +6 -1
- data/test/unit/core/shape/list/test_manager.rb +10 -0
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/page_number/test_format.rb +73 -0
- data/test/unit/core/shape/page_number/test_interface.rb +30 -0
- data/test/unit/core/shape/page_number/test_internal.rb +81 -0
- data/test/unit/core/shape/styles/test_text.rb +12 -1
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +19 -17
- data/test/unit/core/shape/text_block/test_format.rb +5 -0
- data/test/unit/core/test_events.rb +5 -3
- data/test/unit/core/test_shape.rb +5 -1
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +6 -0
- data/test/unit/generator/pdf/document/test_draw_shape.rb +6 -0
- data/test/unit/generator/pdf/document/test_page.rb +29 -3
- data/test/unit/generator/test_pdf.rb +1 -10
- data/test/unit/helper.rb +33 -11
- data/test/unit/layout/test_base.rb +1 -1
- data/test/unit/report/test_base.rb +47 -0
- data/test/unit/report/test_internal.rb +22 -0
- data/test/unit/tmp/.gitkeep +0 -0
- data/thinreports.gemspec +14 -13
- metadata +89 -53
- data/.yardopts +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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8bd5e81c97f873dec7aea631b5ee9a3f2194bdad
|
|
4
|
+
data.tar.gz: 8e84d4b9e83f60c98293305d2f4f937ae65697a3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: db8ff91414f3f2826c6dc4d58b2dfc77fd824075a363da23d7bdbeb0049cca5b72f4fdf2c04cc7b33641baf6ed383705ad791d28376cc152e648cf5cf7950349
|
|
7
|
+
data.tar.gz: f6198bc83cc5eb2566c20e50223a1c74a9d09a04b47b06e4c78111efafbe1f8ae2394026378909d57090acefaa8ed8681b8488f2815b3e8942ebf69a384f0975
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -2,13 +2,6 @@ source 'http://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
unless RUBY_VERSION > '1.9'
|
|
7
|
-
gem 'json', '>= 1.4.6'
|
|
8
|
-
gem 'minitest', '>= 0'
|
|
9
|
-
gem 'turn', '>=0'
|
|
10
|
-
end
|
|
5
|
+
# For 1.8.7
|
|
6
|
+
gem 'json', '>= 1.4.6' unless RUBY_VERSION > '1.9'
|
|
11
7
|
|
|
12
|
-
platforms :mswin, :mingw do
|
|
13
|
-
gem 'win32console'
|
|
14
|
-
end
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
= ThinReports Generator
|
|
2
2
|
|
|
3
|
-
{<img src="https://secure.travis-ci.org/thinreports/thinreports-generator.png" />}[http://travis-ci.org/thinreports/thinreports-generator] {<img src="https://codeclimate.com/
|
|
3
|
+
{<img src="https://secure.travis-ci.org/thinreports/thinreports-generator.png" />}[http://travis-ci.org/thinreports/thinreports-generator] {<img src="https://codeclimate.com/github/thinreports/thinreports-generator.png" />}[https://codeclimate.com/github/thinreports/thinreports-generator] {<img src="https://gemnasium.com/thinreports/thinreports-generator.png" />}[https://gemnasium.com/thinreports/thinreports-generator]
|
|
4
4
|
|
|
5
5
|
{ThinReports}[http://www.thinreports.org/] is Open Source Reporting Solution for Ruby.
|
|
6
6
|
|
|
@@ -34,8 +34,8 @@ Generator can be dynamically operated ...
|
|
|
34
34
|
|
|
35
35
|
== Supported Versions
|
|
36
36
|
|
|
37
|
-
* Ruby 1.8.7,
|
|
38
|
-
* JRuby 1.6.
|
|
37
|
+
* Ruby 1.8.7,1.9.3, 2.0.0, 2.1.0
|
|
38
|
+
* JRuby 1.6, 1.7.0 (Only 1.8 mode)
|
|
39
39
|
|
|
40
40
|
== Install
|
|
41
41
|
|
|
@@ -71,11 +71,11 @@ Or:
|
|
|
71
71
|
page.item(:title).style(:color, 'red')
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
report.
|
|
74
|
+
report.generate(:filename => 'report.pdf')
|
|
75
75
|
|
|
76
76
|
Or,
|
|
77
77
|
|
|
78
|
-
ThinReports::Report.
|
|
78
|
+
ThinReports::Report.generate(:filename => 'report.pdf', :layout => 'report.tlf') do
|
|
79
79
|
start_new_page
|
|
80
80
|
|
|
81
81
|
page.item(:title).value('ThinReports')
|
|
@@ -91,45 +91,43 @@ Or,
|
|
|
91
91
|
report.start_new_page
|
|
92
92
|
|
|
93
93
|
10.times do |n|
|
|
94
|
-
report.
|
|
94
|
+
report.list.add_row do |row|
|
|
95
95
|
row.item(:no).value(n)
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
report.
|
|
99
|
+
report.generate(:filename => 'list.tlf')
|
|
100
100
|
|
|
101
101
|
Or,
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
10.times do |n|
|
|
104
|
+
report.list.add_row :no => n
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
Or,
|
|
108
|
+
|
|
109
|
+
report.list(:other_list_id) do |list|
|
|
104
110
|
10.times do |n|
|
|
105
111
|
list.add_row :no => n
|
|
106
112
|
end
|
|
107
113
|
end
|
|
108
114
|
|
|
109
|
-
|
|
115
|
+
* +#start_new_page+ can be omitted because it is created new page automatically when +#list+ is called
|
|
116
|
+
* id argument of +#list+ can be omitted if is +:default+
|
|
117
|
+
|
|
118
|
+
0.7.0 and earlier:
|
|
110
119
|
|
|
111
120
|
report = ThinReports::Report.new :layout => 'list.tlf'
|
|
112
121
|
|
|
113
122
|
10.times do |n|
|
|
114
|
-
report.list.add_row do |row|
|
|
123
|
+
report.page.list(:default).add_row do |row|
|
|
115
124
|
row.item(:no).value(n)
|
|
116
125
|
end
|
|
117
126
|
end
|
|
118
127
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
report.list do |list|
|
|
122
|
-
10.times do |n|
|
|
123
|
-
list.add_row :title => n
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
* +#start_new_page+ can be omitted because it is created new page automatically when +#list+ is called
|
|
128
|
-
* id argument of +#list+ can be omitted if is :default
|
|
129
|
-
|
|
130
|
-
{Learn more}[http://osc.matsukei.net/projects/thinreports/wiki/Getting_Started].
|
|
128
|
+
{Learn more}[http://osc.matsukei.net/projects/thinreports/wiki/En_Getting_Started].
|
|
131
129
|
|
|
132
|
-
=== Rails3
|
|
130
|
+
=== Rails3, 4
|
|
133
131
|
|
|
134
132
|
* Rails Template handler for ThinReports DSL: {thinreports-rails}[https://github.com/takeshinoda/thinreports-rails]
|
|
135
133
|
|
|
@@ -142,9 +140,10 @@ More simply,
|
|
|
142
140
|
|
|
143
141
|
=== Documentation
|
|
144
142
|
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
{
|
|
143
|
+
* Getting Started [{en}[http://osc.matsukei.net/projects/thinreports/wiki/En_Getting_Started] / {ja}[http://osc.matsukei.net/projects/thinreports/wiki/Getting_Started]]
|
|
144
|
+
* Examples [{en}[http://osc.matsukei.net/projects/thinreports/wiki/En_Examples] / {ja}[http://osc.matsukei.net/projects/thinreports/wiki/Examples]]
|
|
145
|
+
* HowTos [{en}[http://osc.matsukei.net/projects/thinreports/wiki/En_HowTos] / {ja}[http://osc.matsukei.net/projects/thinreports/wiki/HowTos]]
|
|
146
|
+
* Tutorial [{en}[http://osc.matsukei.net/projects/thinreports/wiki/En_Tutorial] / {ja}[http://osc.matsukei.net/projects/thinreports/wiki/Tutorial]]
|
|
148
147
|
|
|
149
148
|
=== Support
|
|
150
149
|
|
|
@@ -15,7 +15,7 @@ module ThinReports
|
|
|
15
15
|
def build(*args)
|
|
16
16
|
build_internal(*args)
|
|
17
17
|
rescue ThinReports::Errors::Basic => e
|
|
18
|
-
raise
|
|
18
|
+
raise
|
|
19
19
|
rescue => e
|
|
20
20
|
raise ThinReports::Errors::InvalidLayoutFormat
|
|
21
21
|
end
|
|
@@ -31,13 +31,13 @@ module ThinReports
|
|
|
31
31
|
# @param [Hash] options
|
|
32
32
|
def build_layout(format, options = {}, &block)
|
|
33
33
|
level = '-' * ((options[:level] || 1 ) - 1)
|
|
34
|
+
pattern = /<!--#{level}SHAPE(.*?)SHAPE#{level}-->/
|
|
34
35
|
|
|
35
|
-
format.layout.
|
|
36
|
-
shape_format = block.call(*parsed_format_and_shape_type(
|
|
37
|
-
|
|
36
|
+
format.layout.scan(pattern) do |m|
|
|
37
|
+
shape_format = block.call(*parsed_format_and_shape_type(m.first))
|
|
38
38
|
format.shapes[shape_format.id.to_sym] = shape_format
|
|
39
|
-
shape_tag(shape_format)
|
|
40
39
|
end
|
|
40
|
+
format.layout.gsub!(pattern, '')
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# @param [String] svg
|
|
@@ -35,8 +35,10 @@ module ThinReports
|
|
|
35
35
|
|
|
36
36
|
# @param [ThinReports::Report::Base] report
|
|
37
37
|
# @param [ThinReports::Layout::Base] layout
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
# @param [Hash] options ({})
|
|
39
|
+
# @option options [Boolean] :count (true)
|
|
40
|
+
def initialize(report, layout, options = {})
|
|
41
|
+
super(options.key?(:count) ? options[:count] : true)
|
|
40
42
|
|
|
41
43
|
@report = report
|
|
42
44
|
@layout = layout
|
|
@@ -54,7 +56,7 @@ module ThinReports
|
|
|
54
56
|
|
|
55
57
|
# @private
|
|
56
58
|
def copy
|
|
57
|
-
new_page = self.class.new(report, layout)
|
|
59
|
+
new_page = self.class.new(report, layout, :count => count?)
|
|
58
60
|
|
|
59
61
|
manager.shapes.each do |id, shape|
|
|
60
62
|
new_shape = shape.copy(new_page)
|
|
@@ -32,6 +32,7 @@ module ThinReports
|
|
|
32
32
|
when ImageBlock::TYPE_NAME then ImageBlock
|
|
33
33
|
when List::TYPE_NAME then List
|
|
34
34
|
when Text::TYPE_NAME then Text
|
|
35
|
+
when PageNumber::TYPE_NAME then PageNumber
|
|
35
36
|
when *Basic::TYPE_NAMES then Basic
|
|
36
37
|
else
|
|
37
38
|
raise ThinReports::Errors::UnknownShapeType
|
|
@@ -50,3 +51,4 @@ require 'thinreports/core/shape/text'
|
|
|
50
51
|
require 'thinreports/core/shape/text_block'
|
|
51
52
|
require 'thinreports/core/shape/image_block'
|
|
52
53
|
require 'thinreports/core/shape/list'
|
|
54
|
+
require 'thinreports/core/shape/page_number'
|
|
@@ -6,10 +6,10 @@ module ThinReports
|
|
|
6
6
|
class List::Configuration
|
|
7
7
|
# @return [ThinReports::Core::Shape::List::Events]
|
|
8
8
|
attr_reader :events
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
# @return [ThinReports::Core::Shape::List::Store]
|
|
11
11
|
attr_reader :store
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
# @param [ThinReports::Core::Shape::List::Events, nil] events (nil)
|
|
14
14
|
# @param [ThinReports::Core::Shape::List::Store, nil] store (nil)
|
|
15
15
|
def initialize(events = nil, store = nil)
|
|
@@ -27,7 +27,13 @@ module ThinReports
|
|
|
27
27
|
def copy
|
|
28
28
|
self.class.new(@events.copy, @store && @store.copy)
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
# @return [String]
|
|
32
|
+
def type
|
|
33
|
+
List::TYPE_NAME
|
|
34
|
+
end
|
|
30
35
|
end
|
|
31
36
|
|
|
32
37
|
end
|
|
33
|
-
end
|
|
38
|
+
end
|
|
39
|
+
|
|
@@ -5,6 +5,7 @@ module ThinReports
|
|
|
5
5
|
|
|
6
6
|
# @private
|
|
7
7
|
class List::Manager
|
|
8
|
+
# @return [ThinReports::Core::Shape::List::Configuration]
|
|
8
9
|
attr_reader :config
|
|
9
10
|
|
|
10
11
|
# @return [ThinReports::Core::Shape:::List::Page]
|
|
@@ -12,13 +13,17 @@ module ThinReports
|
|
|
12
13
|
|
|
13
14
|
# @return [ThinReports::Core::Shape::List::PageState]
|
|
14
15
|
attr_reader :current_page_state
|
|
16
|
+
|
|
17
|
+
# @return [Integer]
|
|
18
|
+
attr_accessor :page_count
|
|
15
19
|
|
|
16
20
|
# @param [ThinReports::Core::Shape::List::Page] page
|
|
17
21
|
def initialize(page)
|
|
18
22
|
switch_current!(page)
|
|
19
23
|
|
|
20
|
-
@config
|
|
21
|
-
@finalized
|
|
24
|
+
@config = init_config
|
|
25
|
+
@finalized = false
|
|
26
|
+
@page_count = 0
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
# @param [ThinReports::Core::Shape::List::Page] page
|
|
@@ -137,7 +142,7 @@ module ThinReports
|
|
|
137
142
|
def auto_page_break?
|
|
138
143
|
format.auto_page_break?
|
|
139
144
|
end
|
|
140
|
-
|
|
145
|
+
|
|
141
146
|
# @param [Hash] options
|
|
142
147
|
# @option [Boolean] :ignore_page_footer (false)
|
|
143
148
|
# When the switch of the page is generated by #finalize, it is used.
|
|
@@ -163,7 +168,9 @@ module ThinReports
|
|
|
163
168
|
dispatch(List::Events::PageEvent.new(:page_finalize,
|
|
164
169
|
current_page,
|
|
165
170
|
current_page_state.parent))
|
|
166
|
-
|
|
171
|
+
@page_count += 1
|
|
172
|
+
current_page_state.no = @page_count
|
|
173
|
+
end
|
|
167
174
|
|
|
168
175
|
# @private
|
|
169
176
|
def finalize
|
|
@@ -4,7 +4,6 @@ module ThinReports
|
|
|
4
4
|
module Core::Shape
|
|
5
5
|
|
|
6
6
|
class List::Page < Basic::Interface
|
|
7
|
-
|
|
8
7
|
# @param [ThinReports::Core::Page] parent
|
|
9
8
|
# @param [ThinReports::Core::Shape::Basic::Format] format
|
|
10
9
|
# @param [ThinReports::Core::Shape::List::PageState] internal (nil)
|
|
@@ -17,6 +16,9 @@ module ThinReports
|
|
|
17
16
|
else
|
|
18
17
|
List::Manager.new(self)
|
|
19
18
|
end
|
|
19
|
+
|
|
20
|
+
# Set a reference to List::PageState List::Manager
|
|
21
|
+
self.internal.manager = self.manager
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
# @param [Hash] values ({})
|
|
@@ -6,8 +6,11 @@ module ThinReports
|
|
|
6
6
|
# @private
|
|
7
7
|
class List::PageState < Basic::Internal
|
|
8
8
|
attr_reader :rows
|
|
9
|
+
|
|
9
10
|
attr_accessor :height
|
|
10
11
|
attr_accessor :header
|
|
12
|
+
attr_accessor :no
|
|
13
|
+
attr_accessor :manager
|
|
11
14
|
|
|
12
15
|
def initialize(*args)
|
|
13
16
|
super(*args)
|
|
@@ -41,4 +44,4 @@ module ThinReports
|
|
|
41
44
|
List::Internal = List::PageState
|
|
42
45
|
|
|
43
46
|
end
|
|
44
|
-
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
module PageNumber
|
|
7
|
+
TYPE_NAME = 's-pageno'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require 'thinreports/core/shape/page_number/format'
|
|
14
|
+
require 'thinreports/core/shape/page_number/internal'
|
|
15
|
+
require 'thinreports/core/shape/page_number/interface'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
class PageNumber::Format < Basic::Format
|
|
7
|
+
config_reader :overflow, :target, :box
|
|
8
|
+
config_reader :default_format => %w( format )
|
|
9
|
+
|
|
10
|
+
def id
|
|
11
|
+
unless @id
|
|
12
|
+
@id = read('id')
|
|
13
|
+
@id = self.class.next_default_id if @id.blank?
|
|
14
|
+
end
|
|
15
|
+
@id
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.next_default_id
|
|
19
|
+
@id_counter ||= 0
|
|
20
|
+
"__pageno#{@id_counter += 1}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
class PageNumber::Interface < Basic::Interface
|
|
7
|
+
internal_delegators :reset_format
|
|
8
|
+
|
|
9
|
+
def format(*args)
|
|
10
|
+
if args.empty?
|
|
11
|
+
internal.read_format
|
|
12
|
+
else
|
|
13
|
+
internal.write_format(args.first)
|
|
14
|
+
self
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
# @see ThinReports::Core::Shape::Base::Interface#init_internal
|
|
21
|
+
def init_internal(parent, format)
|
|
22
|
+
PageNumber::Internal.new(parent, format)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
class PageNumber::Internal < Basic::Internal
|
|
7
|
+
format_delegators :box
|
|
8
|
+
|
|
9
|
+
def read_format
|
|
10
|
+
states.key?(:format) ? states[:format] : format.default_format.dup
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def reset_format
|
|
14
|
+
states.delete(:format)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def write_format(format)
|
|
18
|
+
states[:format] = format.to_s
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def build_format(page_no, page_count)
|
|
22
|
+
return '' if read_format.blank?
|
|
23
|
+
|
|
24
|
+
if start_page_number > 1
|
|
25
|
+
page_no += start_page_number - 1
|
|
26
|
+
page_count += start_page_number - 1
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
read_format.dup.tap do |f|
|
|
30
|
+
f.gsub! '{page}', page_no.to_s
|
|
31
|
+
f.gsub! '{total}', page_count.to_s
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def style
|
|
36
|
+
@style ||= PageNumber::Style.new(format)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def for_report?
|
|
40
|
+
format.target.blank?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def type_of?(type_name)
|
|
44
|
+
type_name == :pageno
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def start_page_number
|
|
48
|
+
for_report? ? parent.report.start_page_number : 1
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class PageNumber::Style < Style::Text
|
|
53
|
+
accessible_styles.delete :valign
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|