ruby_pptx 0.1.0 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +83 -2
- data/lib/ruby_pptx/action.rb +12 -4
- data/lib/ruby_pptx/autoshape_spec.rb +6 -2
- data/lib/ruby_pptx/builder.rb +3 -1
- data/lib/ruby_pptx/chart/categories.rb +45 -15
- data/lib/ruby_pptx/chart/chart.rb +77 -27
- data/lib/ruby_pptx/chart/combo.rb +9 -3
- data/lib/ruby_pptx/chart/data.rb +45 -15
- data/lib/ruby_pptx/chart/format.rb +229 -76
- data/lib/ruby_pptx/chart/workbook_writer.rb +9 -3
- data/lib/ruby_pptx/chart/xml_writer.rb +54 -18
- data/lib/ruby_pptx/chart/xy_data.rb +68 -22
- data/lib/ruby_pptx/dml/color.rb +27 -9
- data/lib/ruby_pptx/dml/effect.rb +6 -2
- data/lib/ruby_pptx/dml/fill.rb +42 -14
- data/lib/ruby_pptx/element_proxy.rb +12 -4
- data/lib/ruby_pptx/enum/base.rb +30 -10
- data/lib/ruby_pptx/enum/prog_id.rb +3 -1
- data/lib/ruby_pptx/geometry.rb +32 -10
- data/lib/ruby_pptx/image.rb +27 -9
- data/lib/ruby_pptx/length.rb +94 -27
- data/lib/ruby_pptx/media.rb +12 -4
- data/lib/ruby_pptx/numeric_lengths.rb +34 -9
- data/lib/ruby_pptx/opc/oxml.rb +7 -5
- data/lib/ruby_pptx/opc/pack_uri.rb +15 -5
- data/lib/ruby_pptx/opc/package.rb +97 -31
- data/lib/ruby_pptx/opc/serialized.rb +15 -5
- data/lib/ruby_pptx/oxml/backend.rb +585 -0
- data/lib/ruby_pptx/oxml/chart.rb +112 -42
- data/lib/ruby_pptx/oxml/content_model.rb +6 -2
- data/lib/ruby_pptx/oxml/dml/color.rb +6 -2
- data/lib/ruby_pptx/oxml/dml/fill.rb +6 -2
- data/lib/ruby_pptx/oxml/element.rb +138 -101
- data/lib/ruby_pptx/oxml/ns.rb +7 -7
- data/lib/ruby_pptx/oxml/presentation.rb +9 -3
- data/lib/ruby_pptx/oxml/section.rb +3 -1
- data/lib/ruby_pptx/oxml/shapes/autoshape.rb +39 -13
- data/lib/ruby_pptx/oxml/shapes/groupshape.rb +15 -7
- data/lib/ruby_pptx/oxml/shapes/other.rb +47 -16
- data/lib/ruby_pptx/oxml/shapes/shared.rb +96 -30
- data/lib/ruby_pptx/oxml/simple_types.rb +169 -52
- data/lib/ruby_pptx/oxml/slide.rb +24 -8
- data/lib/ruby_pptx/oxml/table.rb +39 -13
- data/lib/ruby_pptx/oxml/text.rb +37 -15
- data/lib/ruby_pptx/oxml/theme.rb +13 -4
- data/lib/ruby_pptx/package.rb +9 -3
- data/lib/ruby_pptx/parts/chart.rb +6 -2
- data/lib/ruby_pptx/parts/image.rb +12 -4
- data/lib/ruby_pptx/parts/media.rb +3 -1
- data/lib/ruby_pptx/parts/presentation.rb +15 -5
- data/lib/ruby_pptx/parts/slide.rb +33 -11
- data/lib/ruby_pptx/parts/theme.rb +3 -1
- data/lib/ruby_pptx/pattern_matching.rb +6 -2
- data/lib/ruby_pptx/presentation.rb +24 -8
- data/lib/ruby_pptx/section.rb +30 -10
- data/lib/ruby_pptx/shapes/adjustments.rb +9 -3
- data/lib/ruby_pptx/shapes/authoring.rb +3 -1
- data/lib/ruby_pptx/shapes/base.rb +74 -24
- data/lib/ruby_pptx/shapes/freeform.rb +36 -12
- data/lib/ruby_pptx/shapes/placeholder.rb +44 -15
- data/lib/ruby_pptx/shapes/shape.rb +91 -30
- data/lib/ruby_pptx/shapes/shape_tree.rb +66 -22
- data/lib/ruby_pptx/slide.rb +123 -41
- data/lib/ruby_pptx/table.rb +105 -35
- data/lib/ruby_pptx/text/font_metrics.rb +30 -9
- data/lib/ruby_pptx/text/text.rb +108 -36
- data/lib/ruby_pptx/theme.rb +30 -10
- data/lib/ruby_pptx/version.rb +1 -1
- data/lib/ruby_pptx.rb +8 -1
- metadata +22 -1
data/lib/ruby_pptx/table.rb
CHANGED
|
@@ -22,43 +22,63 @@ module Pptx
|
|
|
22
22
|
@parent = parent
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def part
|
|
25
|
+
def part
|
|
26
|
+
@parent.part
|
|
27
|
+
end
|
|
26
28
|
|
|
27
29
|
# The cell at +row_idx+, +col_idx+.
|
|
28
|
-
def cell(row_idx, col_idx)
|
|
30
|
+
def cell(row_idx, col_idx)
|
|
31
|
+
Cell.new(@element.tc(row_idx, col_idx), self)
|
|
32
|
+
end
|
|
29
33
|
|
|
30
34
|
# `table[0, 1]` reads better than `table.cell(0, 1)` in a loop.
|
|
31
35
|
alias [] cell
|
|
32
36
|
|
|
33
|
-
def rows
|
|
37
|
+
def rows
|
|
38
|
+
@rows ||= TableRows.new(@element, self)
|
|
39
|
+
end
|
|
34
40
|
|
|
35
|
-
def columns
|
|
41
|
+
def columns
|
|
42
|
+
@columns ||= TableColumns.new(@element, self)
|
|
43
|
+
end
|
|
36
44
|
|
|
37
|
-
def row_count
|
|
45
|
+
def row_count
|
|
46
|
+
@element.tr_list.size
|
|
47
|
+
end
|
|
38
48
|
|
|
39
|
-
def column_count
|
|
49
|
+
def column_count
|
|
50
|
+
@element.tblGrid.gridCol_list.size
|
|
51
|
+
end
|
|
40
52
|
|
|
41
53
|
# Whether the first row is styled as a header. The same pattern applies to
|
|
42
54
|
# first_col, last_row, last_col, horz_banding and vert_banding.
|
|
43
|
-
def first_row?
|
|
55
|
+
def first_row?
|
|
56
|
+
@element.firstRow
|
|
57
|
+
end
|
|
44
58
|
|
|
45
59
|
def first_row=(value)
|
|
46
60
|
@element.firstRow = value
|
|
47
61
|
end
|
|
48
62
|
|
|
49
|
-
def first_col?
|
|
63
|
+
def first_col?
|
|
64
|
+
@element.firstCol
|
|
65
|
+
end
|
|
50
66
|
|
|
51
67
|
def first_col=(value)
|
|
52
68
|
@element.firstCol = value
|
|
53
69
|
end
|
|
54
70
|
|
|
55
|
-
def last_row?
|
|
71
|
+
def last_row?
|
|
72
|
+
@element.lastRow
|
|
73
|
+
end
|
|
56
74
|
|
|
57
75
|
def last_row=(value)
|
|
58
76
|
@element.lastRow = value
|
|
59
77
|
end
|
|
60
78
|
|
|
61
|
-
def last_col?
|
|
79
|
+
def last_col?
|
|
80
|
+
@element.lastCol
|
|
81
|
+
end
|
|
62
82
|
|
|
63
83
|
def last_col=(value)
|
|
64
84
|
@element.lastCol = value
|
|
@@ -66,13 +86,17 @@ module Pptx
|
|
|
66
86
|
|
|
67
87
|
# Whether alternate rows are shaded. Spelled out where python-pptx says
|
|
68
88
|
# `horz_banding`.
|
|
69
|
-
def banded_rows?
|
|
89
|
+
def banded_rows?
|
|
90
|
+
@element.bandRow
|
|
91
|
+
end
|
|
70
92
|
|
|
71
93
|
def banded_rows=(value)
|
|
72
94
|
@element.bandRow = value
|
|
73
95
|
end
|
|
74
96
|
|
|
75
|
-
def banded_columns?
|
|
97
|
+
def banded_columns?
|
|
98
|
+
@element.bandCol
|
|
99
|
+
end
|
|
76
100
|
|
|
77
101
|
def banded_columns=(value)
|
|
78
102
|
@element.bandCol = value
|
|
@@ -102,7 +126,9 @@ module Pptx
|
|
|
102
126
|
self
|
|
103
127
|
end
|
|
104
128
|
|
|
105
|
-
def inspect
|
|
129
|
+
def inspect
|
|
130
|
+
"#<Pptx::Table #{row_count}x#{column_count}>"
|
|
131
|
+
end
|
|
106
132
|
end
|
|
107
133
|
|
|
108
134
|
# The rows of a table.
|
|
@@ -124,7 +150,9 @@ module Pptx
|
|
|
124
150
|
self
|
|
125
151
|
end
|
|
126
152
|
|
|
127
|
-
def size
|
|
153
|
+
def size
|
|
154
|
+
@element.tr_list.size
|
|
155
|
+
end
|
|
128
156
|
alias length size
|
|
129
157
|
|
|
130
158
|
def [](index, length = nil)
|
|
@@ -151,7 +179,9 @@ module Pptx
|
|
|
151
179
|
self
|
|
152
180
|
end
|
|
153
181
|
|
|
154
|
-
def size
|
|
182
|
+
def size
|
|
183
|
+
@element.tblGrid.gridCol_list.size
|
|
184
|
+
end
|
|
155
185
|
alias length size
|
|
156
186
|
|
|
157
187
|
def [](index, length = nil)
|
|
@@ -168,16 +198,22 @@ module Pptx
|
|
|
168
198
|
@table = table
|
|
169
199
|
end
|
|
170
200
|
|
|
171
|
-
def height
|
|
201
|
+
def height
|
|
202
|
+
@element.h
|
|
203
|
+
end
|
|
172
204
|
|
|
173
205
|
def height=(value)
|
|
174
206
|
@element.h = value
|
|
175
207
|
@table.notify_height_changed
|
|
176
208
|
end
|
|
177
209
|
|
|
178
|
-
def cells
|
|
210
|
+
def cells
|
|
211
|
+
@element.tc_list.map { |tc| Cell.new(tc, @table) }
|
|
212
|
+
end
|
|
179
213
|
|
|
180
|
-
def inspect
|
|
214
|
+
def inspect
|
|
215
|
+
"#<Pptx::TableRow height=#{height&.inches}in>"
|
|
216
|
+
end
|
|
181
217
|
end
|
|
182
218
|
|
|
183
219
|
# One column of a table.
|
|
@@ -187,14 +223,18 @@ module Pptx
|
|
|
187
223
|
@table = table
|
|
188
224
|
end
|
|
189
225
|
|
|
190
|
-
def width
|
|
226
|
+
def width
|
|
227
|
+
@element.w
|
|
228
|
+
end
|
|
191
229
|
|
|
192
230
|
def width=(value)
|
|
193
231
|
@element.w = value
|
|
194
232
|
@table.notify_width_changed
|
|
195
233
|
end
|
|
196
234
|
|
|
197
|
-
def inspect
|
|
235
|
+
def inspect
|
|
236
|
+
"#<Pptx::TableColumn width=#{width&.inches}in>"
|
|
237
|
+
end
|
|
198
238
|
end
|
|
199
239
|
|
|
200
240
|
# One cell of a table.
|
|
@@ -210,44 +250,62 @@ module Pptx
|
|
|
210
250
|
@parent = parent
|
|
211
251
|
end
|
|
212
252
|
|
|
213
|
-
def part
|
|
253
|
+
def part
|
|
254
|
+
@parent.part
|
|
255
|
+
end
|
|
214
256
|
|
|
215
|
-
def text_frame
|
|
257
|
+
def text_frame
|
|
258
|
+
@text_frame ||= TextFrame.new(@element.get_or_add_txBody, self)
|
|
259
|
+
end
|
|
216
260
|
|
|
217
|
-
def text
|
|
261
|
+
def text
|
|
262
|
+
text_frame.text
|
|
263
|
+
end
|
|
218
264
|
|
|
219
265
|
def text=(value)
|
|
220
266
|
text_frame.text = value
|
|
221
267
|
end
|
|
222
268
|
|
|
223
|
-
def fill
|
|
269
|
+
def fill
|
|
270
|
+
@fill ||= FillFormat.from_fill_parent(cell_properties)
|
|
271
|
+
end
|
|
224
272
|
|
|
225
273
|
# @return [Pptx::Enum::MSO_ANCHOR, nil]
|
|
226
|
-
def vertical_anchor
|
|
274
|
+
def vertical_anchor
|
|
275
|
+
cell_properties.anchor
|
|
276
|
+
end
|
|
227
277
|
|
|
228
278
|
def vertical_anchor=(value)
|
|
229
279
|
cell_properties.anchor = value
|
|
230
280
|
end
|
|
231
281
|
|
|
232
|
-
def margin_left
|
|
282
|
+
def margin_left
|
|
283
|
+
cell_properties.marL
|
|
284
|
+
end
|
|
233
285
|
|
|
234
286
|
def margin_left=(value)
|
|
235
287
|
cell_properties.marL = value
|
|
236
288
|
end
|
|
237
289
|
|
|
238
|
-
def margin_right
|
|
290
|
+
def margin_right
|
|
291
|
+
cell_properties.marR
|
|
292
|
+
end
|
|
239
293
|
|
|
240
294
|
def margin_right=(value)
|
|
241
295
|
cell_properties.marR = value
|
|
242
296
|
end
|
|
243
297
|
|
|
244
|
-
def margin_top
|
|
298
|
+
def margin_top
|
|
299
|
+
cell_properties.marT
|
|
300
|
+
end
|
|
245
301
|
|
|
246
302
|
def margin_top=(value)
|
|
247
303
|
cell_properties.marT = value
|
|
248
304
|
end
|
|
249
305
|
|
|
250
|
-
def margin_bottom
|
|
306
|
+
def margin_bottom
|
|
307
|
+
cell_properties.marB
|
|
308
|
+
end
|
|
251
309
|
|
|
252
310
|
def margin_bottom=(value)
|
|
253
311
|
cell_properties.marB = value
|
|
@@ -257,16 +315,24 @@ module Pptx
|
|
|
257
315
|
#
|
|
258
316
|
# Only a merge origin carries the real span; on any other cell this reads
|
|
259
317
|
# 1 whether or not it is part of a merge. Test {#merge_origin?} first.
|
|
260
|
-
def span_width
|
|
318
|
+
def span_width
|
|
319
|
+
@element.gridSpan
|
|
320
|
+
end
|
|
261
321
|
|
|
262
322
|
# How many rows this cell spans. See {#span_width} on when to trust it.
|
|
263
|
-
def span_height
|
|
323
|
+
def span_height
|
|
324
|
+
@element.rowSpan
|
|
325
|
+
end
|
|
264
326
|
|
|
265
327
|
# True when this cell is the top-left of a merged range.
|
|
266
|
-
def merge_origin?
|
|
328
|
+
def merge_origin?
|
|
329
|
+
@element.merge_origin?
|
|
330
|
+
end
|
|
267
331
|
|
|
268
332
|
# True when this cell is covered by a merge rather than being its origin.
|
|
269
|
-
def spanned?
|
|
333
|
+
def spanned?
|
|
334
|
+
@element.spanned?
|
|
335
|
+
end
|
|
270
336
|
|
|
271
337
|
# Merge this cell with +other+, which is the opposite corner of the range.
|
|
272
338
|
#
|
|
@@ -307,10 +373,14 @@ module Pptx
|
|
|
307
373
|
self
|
|
308
374
|
end
|
|
309
375
|
|
|
310
|
-
def inspect
|
|
376
|
+
def inspect
|
|
377
|
+
"#<Pptx::Cell #{text.inspect}>"
|
|
378
|
+
end
|
|
311
379
|
|
|
312
380
|
private
|
|
313
381
|
|
|
314
|
-
def cell_properties
|
|
382
|
+
def cell_properties
|
|
383
|
+
@element.get_or_add_tcPr
|
|
384
|
+
end
|
|
315
385
|
end
|
|
316
386
|
end
|
|
@@ -23,11 +23,15 @@ module Pptx
|
|
|
23
23
|
cache[real] ||= new(real)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def clear_cache
|
|
26
|
+
def clear_cache
|
|
27
|
+
cache.clear
|
|
28
|
+
end
|
|
27
29
|
|
|
28
30
|
private
|
|
29
31
|
|
|
30
|
-
def cache
|
|
32
|
+
def cache
|
|
33
|
+
@cache ||= {}
|
|
34
|
+
end
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
# @param path [String] a .ttf or .otf file
|
|
@@ -64,7 +68,9 @@ module Pptx
|
|
|
64
68
|
[to_emu(box[2] - left, point_size), to_emu(box[3] - box[1], point_size)]
|
|
65
69
|
end
|
|
66
70
|
|
|
67
|
-
def inspect
|
|
71
|
+
def inspect
|
|
72
|
+
"#<Pptx::FontMetrics #{File.basename(@path)} upem=#{@units_per_em}>"
|
|
73
|
+
end
|
|
68
74
|
|
|
69
75
|
private
|
|
70
76
|
|
|
@@ -87,8 +93,13 @@ module Pptx
|
|
|
87
93
|
left && [left, bottom, right, top]
|
|
88
94
|
end
|
|
89
95
|
|
|
90
|
-
def min(a, b)
|
|
91
|
-
|
|
96
|
+
def min(a, b)
|
|
97
|
+
a.nil? || b < a ? b : a
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def max(a, b)
|
|
101
|
+
a.nil? || b > a ? b : a
|
|
102
|
+
end
|
|
92
103
|
|
|
93
104
|
# Font units are relative to the em square, so scaling by the point size
|
|
94
105
|
# gives points, which are 1/72 inch by definition.
|
|
@@ -96,7 +107,9 @@ module Pptx
|
|
|
96
107
|
(units * point_size / @units_per_em.to_f / POINTS_PER_INCH * EMU_PER_INCH).to_i
|
|
97
108
|
end
|
|
98
109
|
|
|
99
|
-
def glyph_id(codepoint)
|
|
110
|
+
def glyph_id(codepoint)
|
|
111
|
+
@cmap[codepoint] || 0
|
|
112
|
+
end
|
|
100
113
|
|
|
101
114
|
# A font may store one advance for a run of trailing glyphs, in which case
|
|
102
115
|
# hmtx is truncated and the last entry stands for all of them.
|
|
@@ -142,9 +155,17 @@ module Pptx
|
|
|
142
155
|
@index_to_loc_format.zero? ? u16(base + (index * 2)) * 2 : u32(base + (index * 4))
|
|
143
156
|
end
|
|
144
157
|
|
|
145
|
-
def u16(at)
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
def u16(at)
|
|
159
|
+
@data.byteslice(at, 2).unpack1("n")
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def s16(at)
|
|
163
|
+
@data.byteslice(at, 2).unpack1("s>")
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def u32(at)
|
|
167
|
+
@data.byteslice(at, 4).unpack1("N")
|
|
168
|
+
end
|
|
148
169
|
|
|
149
170
|
def read_table_directory
|
|
150
171
|
raise Error, "#{@path} is not a TrueType or OpenType font" unless sfnt_version?
|
data/lib/ruby_pptx/text/text.rb
CHANGED
|
@@ -31,19 +31,27 @@ module Pptx
|
|
|
31
31
|
@parent = parent
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def part
|
|
34
|
+
def part
|
|
35
|
+
@parent.part
|
|
36
|
+
end
|
|
35
37
|
|
|
36
38
|
# The paragraphs of this text frame; there is always at least one.
|
|
37
39
|
#
|
|
38
40
|
# @return [Array<Paragraph>]
|
|
39
|
-
def paragraphs
|
|
41
|
+
def paragraphs
|
|
42
|
+
@element.p_list.map { |p| Paragraph.new(p, self) }
|
|
43
|
+
end
|
|
40
44
|
|
|
41
45
|
# Append an empty paragraph and return it.
|
|
42
|
-
def add_paragraph
|
|
46
|
+
def add_paragraph
|
|
47
|
+
Paragraph.new(@element.add_p, self)
|
|
48
|
+
end
|
|
43
49
|
|
|
44
50
|
# All the text, with "\n" between paragraphs and "\v" for each soft line
|
|
45
51
|
# break.
|
|
46
|
-
def text
|
|
52
|
+
def text
|
|
53
|
+
paragraphs.map(&:text).join("\n")
|
|
54
|
+
end
|
|
47
55
|
|
|
48
56
|
# Replace all text. Each "\n" starts a new paragraph, each "\v" a soft
|
|
49
57
|
# line break within one.
|
|
@@ -62,39 +70,51 @@ module Pptx
|
|
|
62
70
|
self
|
|
63
71
|
end
|
|
64
72
|
|
|
65
|
-
def margin_left
|
|
73
|
+
def margin_left
|
|
74
|
+
body_properties.lIns
|
|
75
|
+
end
|
|
66
76
|
|
|
67
77
|
def margin_left=(value)
|
|
68
78
|
body_properties.lIns = value
|
|
69
79
|
end
|
|
70
80
|
|
|
71
|
-
def margin_right
|
|
81
|
+
def margin_right
|
|
82
|
+
body_properties.rIns
|
|
83
|
+
end
|
|
72
84
|
|
|
73
85
|
def margin_right=(value)
|
|
74
86
|
body_properties.rIns = value
|
|
75
87
|
end
|
|
76
88
|
|
|
77
|
-
def margin_top
|
|
89
|
+
def margin_top
|
|
90
|
+
body_properties.tIns
|
|
91
|
+
end
|
|
78
92
|
|
|
79
93
|
def margin_top=(value)
|
|
80
94
|
body_properties.tIns = value
|
|
81
95
|
end
|
|
82
96
|
|
|
83
|
-
def margin_bottom
|
|
97
|
+
def margin_bottom
|
|
98
|
+
body_properties.bIns
|
|
99
|
+
end
|
|
84
100
|
|
|
85
101
|
def margin_bottom=(value)
|
|
86
102
|
body_properties.bIns = value
|
|
87
103
|
end
|
|
88
104
|
|
|
89
105
|
# @return [Pptx::Enum::MSO_ANCHOR, nil] nil when inherited
|
|
90
|
-
def vertical_anchor
|
|
106
|
+
def vertical_anchor
|
|
107
|
+
body_properties.anchor
|
|
108
|
+
end
|
|
91
109
|
|
|
92
110
|
def vertical_anchor=(value)
|
|
93
111
|
body_properties.anchor = value
|
|
94
112
|
end
|
|
95
113
|
|
|
96
114
|
# @return [Pptx::Enum::MSO_AUTO_SIZE, nil] nil when inherited
|
|
97
|
-
def auto_size
|
|
115
|
+
def auto_size
|
|
116
|
+
body_properties.autofit
|
|
117
|
+
end
|
|
98
118
|
|
|
99
119
|
def auto_size=(value)
|
|
100
120
|
body_properties.autofit = value
|
|
@@ -154,7 +174,9 @@ module Pptx
|
|
|
154
174
|
[@parent.width - margin_left - margin_right, @parent.height - margin_top - margin_bottom]
|
|
155
175
|
end
|
|
156
176
|
|
|
157
|
-
def inspect
|
|
177
|
+
def inspect
|
|
178
|
+
"#<Pptx::TextFrame #{text.inspect}>"
|
|
179
|
+
end
|
|
158
180
|
|
|
159
181
|
private
|
|
160
182
|
|
|
@@ -178,7 +200,9 @@ module Pptx
|
|
|
178
200
|
end
|
|
179
201
|
end
|
|
180
202
|
|
|
181
|
-
def body_properties
|
|
203
|
+
def body_properties
|
|
204
|
+
@element.bodyPr
|
|
205
|
+
end
|
|
182
206
|
end
|
|
183
207
|
|
|
184
208
|
# One paragraph of a text frame.
|
|
@@ -194,12 +218,18 @@ module Pptx
|
|
|
194
218
|
@parent = parent
|
|
195
219
|
end
|
|
196
220
|
|
|
197
|
-
def part
|
|
221
|
+
def part
|
|
222
|
+
@parent.part
|
|
223
|
+
end
|
|
198
224
|
|
|
199
225
|
# @return [Array<Run>]
|
|
200
|
-
def runs
|
|
226
|
+
def runs
|
|
227
|
+
@element.r_list.map { |r| Run.new(r, self) }
|
|
228
|
+
end
|
|
201
229
|
|
|
202
|
-
def add_run(text = nil)
|
|
230
|
+
def add_run(text = nil)
|
|
231
|
+
Run.new(@element.add_run(text), self)
|
|
232
|
+
end
|
|
203
233
|
|
|
204
234
|
def add_line_break
|
|
205
235
|
@element.add_line_break
|
|
@@ -207,7 +237,9 @@ module Pptx
|
|
|
207
237
|
end
|
|
208
238
|
|
|
209
239
|
# The text of this paragraph, with "\v" for each soft line break.
|
|
210
|
-
def text
|
|
240
|
+
def text
|
|
241
|
+
@element.text
|
|
242
|
+
end
|
|
211
243
|
|
|
212
244
|
# Replace this paragraph's text, turning "\v" (or "\n") into line breaks
|
|
213
245
|
# rather than new paragraphs -- a paragraph cannot contain another.
|
|
@@ -223,46 +255,62 @@ module Pptx
|
|
|
223
255
|
end
|
|
224
256
|
|
|
225
257
|
# @return [Pptx::Enum::PP_ALIGN, nil] nil when inherited
|
|
226
|
-
def alignment
|
|
258
|
+
def alignment
|
|
259
|
+
paragraph_properties.algn
|
|
260
|
+
end
|
|
227
261
|
|
|
228
262
|
def alignment=(value)
|
|
229
263
|
paragraph_properties.algn = value
|
|
230
264
|
end
|
|
231
265
|
|
|
232
266
|
# Outline level, 0 for the top level.
|
|
233
|
-
def level
|
|
267
|
+
def level
|
|
268
|
+
paragraph_properties.lvl
|
|
269
|
+
end
|
|
234
270
|
|
|
235
271
|
def level=(value)
|
|
236
272
|
paragraph_properties.lvl = value
|
|
237
273
|
end
|
|
238
274
|
|
|
239
275
|
# A Float is a number of lines; a {Pptx::Length} is a fixed distance.
|
|
240
|
-
def line_spacing
|
|
276
|
+
def line_spacing
|
|
277
|
+
paragraph_properties.line_spacing
|
|
278
|
+
end
|
|
241
279
|
|
|
242
280
|
def line_spacing=(value)
|
|
243
281
|
paragraph_properties.line_spacing = value
|
|
244
282
|
end
|
|
245
283
|
|
|
246
|
-
def space_before
|
|
284
|
+
def space_before
|
|
285
|
+
paragraph_properties.space_before
|
|
286
|
+
end
|
|
247
287
|
|
|
248
288
|
def space_before=(value)
|
|
249
289
|
paragraph_properties.space_before = value
|
|
250
290
|
end
|
|
251
291
|
|
|
252
|
-
def space_after
|
|
292
|
+
def space_after
|
|
293
|
+
paragraph_properties.space_after
|
|
294
|
+
end
|
|
253
295
|
|
|
254
296
|
def space_after=(value)
|
|
255
297
|
paragraph_properties.space_after = value
|
|
256
298
|
end
|
|
257
299
|
|
|
258
300
|
# The default character formatting for runs in this paragraph.
|
|
259
|
-
def font
|
|
301
|
+
def font
|
|
302
|
+
Font.new(paragraph_properties.get_or_add_defRPr)
|
|
303
|
+
end
|
|
260
304
|
|
|
261
|
-
def inspect
|
|
305
|
+
def inspect
|
|
306
|
+
"#<Pptx::Paragraph #{text.inspect}>"
|
|
307
|
+
end
|
|
262
308
|
|
|
263
309
|
private
|
|
264
310
|
|
|
265
|
-
def paragraph_properties
|
|
311
|
+
def paragraph_properties
|
|
312
|
+
@element.get_or_add_pPr
|
|
313
|
+
end
|
|
266
314
|
end
|
|
267
315
|
|
|
268
316
|
# A run: a span of text sharing one set of character properties.
|
|
@@ -278,27 +326,39 @@ module Pptx
|
|
|
278
326
|
@parent = parent
|
|
279
327
|
end
|
|
280
328
|
|
|
281
|
-
def part
|
|
329
|
+
def part
|
|
330
|
+
@parent.part
|
|
331
|
+
end
|
|
282
332
|
|
|
283
|
-
def text
|
|
333
|
+
def text
|
|
334
|
+
@element.text
|
|
335
|
+
end
|
|
284
336
|
|
|
285
337
|
def text=(value)
|
|
286
338
|
@element.text = value
|
|
287
339
|
end
|
|
288
340
|
|
|
289
|
-
def font
|
|
341
|
+
def font
|
|
342
|
+
Font.new(@element.get_or_add_rPr)
|
|
343
|
+
end
|
|
290
344
|
|
|
291
345
|
# What happens when this run of text is clicked.
|
|
292
|
-
def click_action
|
|
346
|
+
def click_action
|
|
347
|
+
@click_action ||= ActionSetting.new(@element.get_or_add_rPr, self)
|
|
348
|
+
end
|
|
293
349
|
|
|
294
350
|
# The URL this run links to, or nil.
|
|
295
|
-
def hyperlink
|
|
351
|
+
def hyperlink
|
|
352
|
+
click_action.url
|
|
353
|
+
end
|
|
296
354
|
|
|
297
355
|
def hyperlink=(url)
|
|
298
356
|
click_action.address = url
|
|
299
357
|
end
|
|
300
358
|
|
|
301
|
-
def inspect
|
|
359
|
+
def inspect
|
|
360
|
+
"#<Pptx::Run #{text.inspect}>"
|
|
361
|
+
end
|
|
302
362
|
end
|
|
303
363
|
|
|
304
364
|
# Character formatting: typeface, size, weight, colour.
|
|
@@ -317,20 +377,26 @@ module Pptx
|
|
|
317
377
|
@element = r_pr
|
|
318
378
|
end
|
|
319
379
|
|
|
320
|
-
def bold
|
|
380
|
+
def bold
|
|
381
|
+
@element.b
|
|
382
|
+
end
|
|
321
383
|
|
|
322
384
|
def bold=(value)
|
|
323
385
|
@element.b = value
|
|
324
386
|
end
|
|
325
387
|
|
|
326
|
-
def italic
|
|
388
|
+
def italic
|
|
389
|
+
@element.i
|
|
390
|
+
end
|
|
327
391
|
|
|
328
392
|
def italic=(value)
|
|
329
393
|
@element.i = value
|
|
330
394
|
end
|
|
331
395
|
|
|
332
396
|
# The typeface name, or nil when inherited from the theme.
|
|
333
|
-
def name
|
|
397
|
+
def name
|
|
398
|
+
@element.latin&.typeface
|
|
399
|
+
end
|
|
334
400
|
|
|
335
401
|
def name=(value)
|
|
336
402
|
if value.nil?
|
|
@@ -372,14 +438,18 @@ module Pptx
|
|
|
372
438
|
end
|
|
373
439
|
|
|
374
440
|
# @return [Pptx::Enum::MSO_LANGUAGE_ID, nil]
|
|
375
|
-
def language
|
|
441
|
+
def language
|
|
442
|
+
@element.lang
|
|
443
|
+
end
|
|
376
444
|
|
|
377
445
|
def language=(value)
|
|
378
446
|
@element.lang = value
|
|
379
447
|
end
|
|
380
448
|
|
|
381
449
|
# The fill of the text itself.
|
|
382
|
-
def fill
|
|
450
|
+
def fill
|
|
451
|
+
@fill ||= FillFormat.from_fill_parent(@element)
|
|
452
|
+
end
|
|
383
453
|
|
|
384
454
|
# The text colour. Accessing it makes the fill solid, since a colour has
|
|
385
455
|
# to live on some fill.
|
|
@@ -388,6 +458,8 @@ module Pptx
|
|
|
388
458
|
fill.fore_color
|
|
389
459
|
end
|
|
390
460
|
|
|
391
|
-
def inspect
|
|
461
|
+
def inspect
|
|
462
|
+
"#<Pptx::Font name=#{name.inspect} size=#{size&.pt} bold=#{bold.inspect}>"
|
|
463
|
+
end
|
|
392
464
|
end
|
|
393
465
|
end
|