ruby_pptx 0.1.0 → 0.3.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 +98 -0
- data/README.md +94 -4
- 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 +168 -31
- data/lib/ruby_pptx/chart/combo.rb +19 -4
- 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 +25 -8
- data/lib/ruby_pptx/oxml/table.rb +39 -13
- data/lib/ruby_pptx/oxml/text.rb +122 -16
- 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 +235 -121
- data/lib/ruby_pptx/slide.rb +137 -46
- data/lib/ruby_pptx/table.rb +105 -35
- data/lib/ruby_pptx/text/font_metrics.rb +30 -9
- data/lib/ruby_pptx/text/list_style.rb +88 -0
- data/lib/ruby_pptx/text/text.rb +241 -59
- data/lib/ruby_pptx/theme.rb +30 -10
- data/lib/ruby_pptx/version.rb +1 -1
- data/lib/ruby_pptx.rb +9 -1
- metadata +24 -2
data/lib/ruby_pptx/slide.rb
CHANGED
|
@@ -10,34 +10,46 @@ module Pptx
|
|
|
10
10
|
# Behaviour common to slides, layouts, masters and notes slides.
|
|
11
11
|
class BaseSlide < PartElementProxy
|
|
12
12
|
# The internal name of this slide; an empty string when unnamed.
|
|
13
|
-
def name
|
|
13
|
+
def name
|
|
14
|
+
@element.cSld.name
|
|
15
|
+
end
|
|
14
16
|
|
|
15
17
|
def name=(value)
|
|
16
18
|
@element.cSld.name = value.to_s
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def shape_tree
|
|
21
|
+
def shape_tree
|
|
22
|
+
@element.spTree
|
|
23
|
+
end
|
|
20
24
|
|
|
21
25
|
# The slide background.
|
|
22
26
|
#
|
|
23
27
|
# Note that merely reading this is destructive: a background given by a
|
|
24
28
|
# style reference, or inherited, is replaced with an explicit no-fill so
|
|
25
29
|
# there is something to interrogate. python-pptx behaves the same way.
|
|
26
|
-
def background
|
|
30
|
+
def background
|
|
31
|
+
@background ||= Background.new(@element.cSld)
|
|
32
|
+
end
|
|
27
33
|
end
|
|
28
34
|
|
|
29
35
|
# The background of a slide, layout or master.
|
|
30
36
|
class Background < ElementProxy
|
|
31
|
-
def fill
|
|
37
|
+
def fill
|
|
38
|
+
@fill ||= FillFormat.from_fill_parent(@element.get_or_add_bgPr)
|
|
39
|
+
end
|
|
32
40
|
end
|
|
33
41
|
|
|
34
42
|
# Common to slide masters and the notes master.
|
|
35
43
|
class BaseMaster < BaseSlide
|
|
36
44
|
# The shapes on this master.
|
|
37
|
-
def shapes
|
|
45
|
+
def shapes
|
|
46
|
+
@shapes ||= MasterShapes.new(@element.spTree, self)
|
|
47
|
+
end
|
|
38
48
|
|
|
39
49
|
# The placeholders on this master, in `idx` order.
|
|
40
|
-
def placeholders
|
|
50
|
+
def placeholders
|
|
51
|
+
@placeholders ||= MasterPlaceholders.new(@element.spTree, self)
|
|
52
|
+
end
|
|
41
53
|
end
|
|
42
54
|
|
|
43
55
|
# The master every notes page in a presentation inherits from.
|
|
@@ -46,7 +58,9 @@ module Pptx
|
|
|
46
58
|
# the first time a slide is given speaker notes, or {Presentation#notes_master}
|
|
47
59
|
# is asked for.
|
|
48
60
|
class NotesMaster < BaseMaster
|
|
49
|
-
def inspect
|
|
61
|
+
def inspect
|
|
62
|
+
"#<Pptx::NotesMaster #{part.partname}>"
|
|
63
|
+
end
|
|
50
64
|
end
|
|
51
65
|
|
|
52
66
|
# The speaker notes page belonging to one slide.
|
|
@@ -58,17 +72,25 @@ module Pptx
|
|
|
58
72
|
# The header, date and footer stay on the master, as they do in PowerPoint.
|
|
59
73
|
CLONEABLE = %i[SLIDE_IMAGE BODY SLIDE_NUMBER].freeze
|
|
60
74
|
|
|
61
|
-
def shapes
|
|
75
|
+
def shapes
|
|
76
|
+
@shapes ||= NotesSlideShapes.new(@element.spTree, self)
|
|
77
|
+
end
|
|
62
78
|
|
|
63
|
-
def placeholders
|
|
79
|
+
def placeholders
|
|
80
|
+
@placeholders ||= NotesSlidePlaceholders.new(@element.spTree, self)
|
|
81
|
+
end
|
|
64
82
|
|
|
65
83
|
# The body placeholder that holds the notes text, or nil if it was removed.
|
|
66
|
-
def notes_placeholder
|
|
84
|
+
def notes_placeholder
|
|
85
|
+
placeholders.find { |ph| ph.placeholder_format.type.name == :BODY }
|
|
86
|
+
end
|
|
67
87
|
|
|
68
88
|
# The text frame of the notes placeholder, or nil when there is none.
|
|
69
89
|
#
|
|
70
90
|
# @return [TextFrame, nil]
|
|
71
|
-
def notes_text_frame
|
|
91
|
+
def notes_text_frame
|
|
92
|
+
notes_placeholder&.text_frame
|
|
93
|
+
end
|
|
72
94
|
|
|
73
95
|
# Copy the cloneable placeholders from +notes_master+, keeping their order.
|
|
74
96
|
# Called once, when the notes slide is created.
|
|
@@ -82,7 +104,9 @@ module Pptx
|
|
|
82
104
|
self
|
|
83
105
|
end
|
|
84
106
|
|
|
85
|
-
def inspect
|
|
107
|
+
def inspect
|
|
108
|
+
"#<Pptx::NotesSlide #{part.partname}>"
|
|
109
|
+
end
|
|
86
110
|
end
|
|
87
111
|
|
|
88
112
|
# One slide in a presentation.
|
|
@@ -93,15 +117,23 @@ module Pptx
|
|
|
93
117
|
|
|
94
118
|
# The id that identifies this slide within the presentation, stable across
|
|
95
119
|
# reordering.
|
|
96
|
-
def slide_id
|
|
120
|
+
def slide_id
|
|
121
|
+
part.slide_id
|
|
122
|
+
end
|
|
97
123
|
|
|
98
124
|
# The layout this slide takes its appearance from.
|
|
99
|
-
def layout
|
|
125
|
+
def layout
|
|
126
|
+
part.slide_layout
|
|
127
|
+
end
|
|
100
128
|
|
|
101
129
|
# True when this slide inherits the master's background.
|
|
102
|
-
def follows_master_background?
|
|
130
|
+
def follows_master_background?
|
|
131
|
+
@element.bg.nil?
|
|
132
|
+
end
|
|
103
133
|
|
|
104
|
-
def notes_slide?
|
|
134
|
+
def notes_slide?
|
|
135
|
+
part.notes_slide?
|
|
136
|
+
end
|
|
105
137
|
|
|
106
138
|
# This slide's speaker notes page, created on first use.
|
|
107
139
|
#
|
|
@@ -109,13 +141,17 @@ module Pptx
|
|
|
109
141
|
# {#notes} and {#notes=} for the common case of just the text.
|
|
110
142
|
#
|
|
111
143
|
# @return [NotesSlide]
|
|
112
|
-
def notes_slide
|
|
144
|
+
def notes_slide
|
|
145
|
+
part.notes_slide
|
|
146
|
+
end
|
|
113
147
|
|
|
114
148
|
# The speaker notes as plain text, or nil when the slide has none.
|
|
115
149
|
#
|
|
116
150
|
# Reading never creates a notes slide; that would add parts to a file
|
|
117
151
|
# merely by looking at it.
|
|
118
|
-
def notes
|
|
152
|
+
def notes
|
|
153
|
+
notes_slide? ? notes_slide.notes_text_frame&.text : nil
|
|
154
|
+
end
|
|
119
155
|
|
|
120
156
|
# Replace the speaker notes, creating the notes slide if need be.
|
|
121
157
|
def notes=(text)
|
|
@@ -126,12 +162,18 @@ module Pptx
|
|
|
126
162
|
end
|
|
127
163
|
|
|
128
164
|
# The shapes on this slide, in z-order.
|
|
129
|
-
def shapes
|
|
165
|
+
def shapes
|
|
166
|
+
@shapes ||= SlideShapes.new(@element.spTree, self)
|
|
167
|
+
end
|
|
130
168
|
|
|
131
169
|
# The placeholders on this slide, keyed by `idx`.
|
|
132
|
-
def placeholders
|
|
170
|
+
def placeholders
|
|
171
|
+
@placeholders ||= SlidePlaceholders.new(@element.spTree, self)
|
|
172
|
+
end
|
|
133
173
|
|
|
134
|
-
def inspect
|
|
174
|
+
def inspect
|
|
175
|
+
"#<Pptx::Slide id=#{slide_id} #{part.partname}>"
|
|
176
|
+
end
|
|
135
177
|
end
|
|
136
178
|
|
|
137
179
|
# The slides of a presentation, in order.
|
|
@@ -154,10 +196,14 @@ module Pptx
|
|
|
154
196
|
self
|
|
155
197
|
end
|
|
156
198
|
|
|
157
|
-
def size
|
|
199
|
+
def size
|
|
200
|
+
@sld_id_list.size
|
|
201
|
+
end
|
|
158
202
|
alias length size
|
|
159
203
|
|
|
160
|
-
def empty?
|
|
204
|
+
def empty?
|
|
205
|
+
size.zero?
|
|
206
|
+
end
|
|
161
207
|
|
|
162
208
|
# Indexed access, supporting a negative index as Ruby arrays do.
|
|
163
209
|
#
|
|
@@ -172,20 +218,25 @@ module Pptx
|
|
|
172
218
|
end
|
|
173
219
|
|
|
174
220
|
# Enumerable gives us #first but not #last.
|
|
175
|
-
def last
|
|
221
|
+
def last
|
|
222
|
+
self[-1]
|
|
223
|
+
end
|
|
176
224
|
|
|
177
225
|
# The slide with the given slide id.
|
|
178
226
|
#
|
|
179
227
|
# @return [Slide, nil]
|
|
180
|
-
def by_id(slide_id)
|
|
228
|
+
def by_id(slide_id)
|
|
229
|
+
part.slide_by_id(slide_id)
|
|
230
|
+
end
|
|
181
231
|
|
|
182
232
|
# Add a slide inheriting from +slide_layout+, and return it.
|
|
183
233
|
#
|
|
184
234
|
# The layout's placeholders are copied onto the new slide, preserving
|
|
185
|
-
# z-order
|
|
186
|
-
|
|
235
|
+
# z-order. Date, footer and slide number come along only with
|
|
236
|
+
# +footers: true+, which is what PowerPoint needs to show them.
|
|
237
|
+
def add(slide_layout, footers: false)
|
|
187
238
|
r_id, slide = part.add_slide(slide_layout)
|
|
188
|
-
slide.shapes.clone_layout_placeholders(slide_layout)
|
|
239
|
+
slide.shapes.clone_layout_placeholders(slide_layout, footers: footers)
|
|
189
240
|
@sld_id_list.add_slide_id(r_id)
|
|
190
241
|
slide
|
|
191
242
|
end
|
|
@@ -193,9 +244,13 @@ module Pptx
|
|
|
193
244
|
# The zero-based position of +slide+.
|
|
194
245
|
#
|
|
195
246
|
# @return [Integer, nil] nil when the slide is not in this collection
|
|
196
|
-
def index(slide)
|
|
247
|
+
def index(slide)
|
|
248
|
+
each_with_index.find { |s, _| s == slide }&.last
|
|
249
|
+
end
|
|
197
250
|
|
|
198
|
-
def inspect
|
|
251
|
+
def inspect
|
|
252
|
+
"#<Pptx::Slides size=#{size}>"
|
|
253
|
+
end
|
|
199
254
|
end
|
|
200
255
|
|
|
201
256
|
# A slide layout: the arrangement a slide inherits from.
|
|
@@ -204,8 +259,8 @@ module Pptx
|
|
|
204
259
|
|
|
205
260
|
pattern_keys :name, :type, :slide_master, :shapes, :placeholders
|
|
206
261
|
|
|
207
|
-
# Placeholders
|
|
208
|
-
#
|
|
262
|
+
# Placeholders a new slide leaves out unless asked: PowerPoint shows them
|
|
263
|
+
# only where the slide carries them, which is its Header & Footer switch.
|
|
209
264
|
LATENT_PLACEHOLDER_TYPES = [
|
|
210
265
|
Enum::PP_PLACEHOLDER::DATE,
|
|
211
266
|
Enum::PP_PLACEHOLDER::FOOTER,
|
|
@@ -213,10 +268,14 @@ module Pptx
|
|
|
213
268
|
].freeze
|
|
214
269
|
|
|
215
270
|
# The shapes on this layout.
|
|
216
|
-
def shapes
|
|
271
|
+
def shapes
|
|
272
|
+
@shapes ||= LayoutShapes.new(@element.spTree, self)
|
|
273
|
+
end
|
|
217
274
|
|
|
218
275
|
# The placeholders on this layout, in `idx` order.
|
|
219
|
-
def placeholders
|
|
276
|
+
def placeholders
|
|
277
|
+
@placeholders ||= LayoutPlaceholders.new(@element.spTree, self)
|
|
278
|
+
end
|
|
220
279
|
|
|
221
280
|
# The placeholders a new slide based on this layout should receive.
|
|
222
281
|
def cloneable_placeholders
|
|
@@ -224,11 +283,15 @@ module Pptx
|
|
|
224
283
|
end
|
|
225
284
|
|
|
226
285
|
# The master this layout inherits from.
|
|
227
|
-
def slide_master
|
|
286
|
+
def slide_master
|
|
287
|
+
part.slide_master
|
|
288
|
+
end
|
|
228
289
|
|
|
229
290
|
# The kind of layout this is, e.g. "title" or "obj". PowerPoint uses it to
|
|
230
291
|
# decide which layout to offer for a given command.
|
|
231
|
-
def type
|
|
292
|
+
def type
|
|
293
|
+
@element.type
|
|
294
|
+
end
|
|
232
295
|
|
|
233
296
|
def type=(value)
|
|
234
297
|
@element.type = value&.to_s
|
|
@@ -239,7 +302,9 @@ module Pptx
|
|
|
239
302
|
part.package.presentation_part.presentation.slides.select { |s| s.layout == self }
|
|
240
303
|
end
|
|
241
304
|
|
|
242
|
-
def inspect
|
|
305
|
+
def inspect
|
|
306
|
+
"#<Pptx::SlideLayout #{name.inspect}>"
|
|
307
|
+
end
|
|
243
308
|
end
|
|
244
309
|
|
|
245
310
|
# The layouts belonging to one slide master.
|
|
@@ -262,7 +327,9 @@ module Pptx
|
|
|
262
327
|
self
|
|
263
328
|
end
|
|
264
329
|
|
|
265
|
-
def size
|
|
330
|
+
def size
|
|
331
|
+
@sld_layout_id_list.size
|
|
332
|
+
end
|
|
266
333
|
alias length size
|
|
267
334
|
|
|
268
335
|
# Indexed by position, or looked up by layout name.
|
|
@@ -282,10 +349,14 @@ module Pptx
|
|
|
282
349
|
end
|
|
283
350
|
|
|
284
351
|
# @return [SlideLayout, nil]
|
|
285
|
-
def by_name(name)
|
|
352
|
+
def by_name(name)
|
|
353
|
+
find { |layout| layout.name == name }
|
|
354
|
+
end
|
|
286
355
|
|
|
287
356
|
# @return [Integer, nil]
|
|
288
|
-
def index(slide_layout)
|
|
357
|
+
def index(slide_layout)
|
|
358
|
+
each_with_index.find { |l, _| l == slide_layout }&.last
|
|
359
|
+
end
|
|
289
360
|
|
|
290
361
|
# Remove +slide_layout+ from this collection and from the package.
|
|
291
362
|
#
|
|
@@ -329,7 +400,9 @@ module Pptx
|
|
|
329
400
|
layout
|
|
330
401
|
end
|
|
331
402
|
|
|
332
|
-
def inspect
|
|
403
|
+
def inspect
|
|
404
|
+
"#<Pptx::SlideLayouts size=#{size}>"
|
|
405
|
+
end
|
|
333
406
|
end
|
|
334
407
|
|
|
335
408
|
# A slide master.
|
|
@@ -342,14 +415,28 @@ module Pptx
|
|
|
342
415
|
# The colours and fonts this master draws from.
|
|
343
416
|
#
|
|
344
417
|
# @return [Pptx::Theme]
|
|
345
|
-
def theme
|
|
418
|
+
def theme
|
|
419
|
+
part.theme_part.theme
|
|
420
|
+
end
|
|
346
421
|
|
|
347
422
|
# The placeholders every layout and slide under this master inherits from.
|
|
348
423
|
#
|
|
349
424
|
# @return [MasterPlaceholders]
|
|
350
|
-
def placeholders
|
|
425
|
+
def placeholders
|
|
426
|
+
@placeholders ||= MasterPlaceholders.new(@element.spTree, self)
|
|
427
|
+
end
|
|
351
428
|
|
|
352
|
-
|
|
429
|
+
# The default text formatting per outline level for titles, body text and
|
|
430
|
+
# everything else, which every layout and slide under this master inherits.
|
|
431
|
+
#
|
|
432
|
+
# @return [TextStyles]
|
|
433
|
+
def text_styles
|
|
434
|
+
TextStyles.new(@element.get_or_add_txStyles)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def inspect
|
|
438
|
+
"#<Pptx::SlideMaster #{part.partname}>"
|
|
439
|
+
end
|
|
353
440
|
end
|
|
354
441
|
|
|
355
442
|
# The slide masters of a presentation.
|
|
@@ -372,7 +459,9 @@ module Pptx
|
|
|
372
459
|
self
|
|
373
460
|
end
|
|
374
461
|
|
|
375
|
-
def size
|
|
462
|
+
def size
|
|
463
|
+
@sld_master_id_list.size
|
|
464
|
+
end
|
|
376
465
|
alias length size
|
|
377
466
|
|
|
378
467
|
def [](index, length = nil)
|
|
@@ -408,7 +497,9 @@ module Pptx
|
|
|
408
497
|
master
|
|
409
498
|
end
|
|
410
499
|
|
|
411
|
-
def inspect
|
|
500
|
+
def inspect
|
|
501
|
+
"#<Pptx::SlideMasters size=#{size}>"
|
|
502
|
+
end
|
|
412
503
|
|
|
413
504
|
private
|
|
414
505
|
|
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
|