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
|
@@ -87,7 +87,9 @@ module Pptx
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# A group counts as one shape, whatever it contains.
|
|
90
|
-
def size
|
|
90
|
+
def size
|
|
91
|
+
member_elements.size
|
|
92
|
+
end
|
|
91
93
|
alias length size
|
|
92
94
|
|
|
93
95
|
def [](index, length = nil)
|
|
@@ -158,15 +160,23 @@ module Pptx
|
|
|
158
160
|
|
|
159
161
|
# Which shape elements belong to this collection; placeholder collections
|
|
160
162
|
# narrow this.
|
|
161
|
-
def member?(_shape_element)
|
|
163
|
+
def member?(_shape_element)
|
|
164
|
+
true
|
|
165
|
+
end
|
|
162
166
|
|
|
163
|
-
def member_elements
|
|
167
|
+
def member_elements
|
|
168
|
+
@sp_tree.shape_elements.select { |e| member?(e) }
|
|
169
|
+
end
|
|
164
170
|
|
|
165
|
-
def shape_factory(shape_element)
|
|
171
|
+
def shape_factory(shape_element)
|
|
172
|
+
ShapeFactory.build(shape_element, self)
|
|
173
|
+
end
|
|
166
174
|
|
|
167
175
|
# One more than the highest id in use. Note the shape tree's own allocator
|
|
168
176
|
# fills gaps instead; both behaviours are inherited from python-pptx.
|
|
169
|
-
def next_shape_id
|
|
177
|
+
def next_shape_id
|
|
178
|
+
@sp_tree.max_shape_id + 1
|
|
179
|
+
end
|
|
170
180
|
|
|
171
181
|
# Office's icon for an Office document, a generic one for anything else.
|
|
172
182
|
def default_ole_icon(prog_id)
|
|
@@ -477,9 +487,13 @@ module Pptx
|
|
|
477
487
|
private
|
|
478
488
|
|
|
479
489
|
# A group resizes itself around its contents; a slide does not move.
|
|
480
|
-
def recalculate_extents
|
|
490
|
+
def recalculate_extents
|
|
491
|
+
nil
|
|
492
|
+
end
|
|
481
493
|
|
|
482
|
-
def shape_factory(shape_element)
|
|
494
|
+
def shape_factory(shape_element)
|
|
495
|
+
ShapeFactory.build_for_slide(shape_element, self)
|
|
496
|
+
end
|
|
483
497
|
end
|
|
484
498
|
|
|
485
499
|
# The shapes on a slide.
|
|
@@ -502,11 +516,15 @@ module Pptx
|
|
|
502
516
|
element && shape_factory(element)
|
|
503
517
|
end
|
|
504
518
|
|
|
505
|
-
def placeholders
|
|
519
|
+
def placeholders
|
|
520
|
+
parent.placeholders
|
|
521
|
+
end
|
|
506
522
|
|
|
507
523
|
private
|
|
508
524
|
|
|
509
|
-
def shape_factory(shape_element)
|
|
525
|
+
def shape_factory(shape_element)
|
|
526
|
+
ShapeFactory.build_for_slide(shape_element, self)
|
|
527
|
+
end
|
|
510
528
|
end
|
|
511
529
|
|
|
512
530
|
# The shapes inside a `p:grpSp`.
|
|
@@ -524,14 +542,18 @@ module Pptx
|
|
|
524
542
|
class LayoutShapes < BaseShapes
|
|
525
543
|
private
|
|
526
544
|
|
|
527
|
-
def shape_factory(shape_element)
|
|
545
|
+
def shape_factory(shape_element)
|
|
546
|
+
ShapeFactory.build_for_layout(shape_element, self)
|
|
547
|
+
end
|
|
528
548
|
end
|
|
529
549
|
|
|
530
550
|
# The shapes on a slide master.
|
|
531
551
|
class MasterShapes < BaseShapes
|
|
532
552
|
private
|
|
533
553
|
|
|
534
|
-
def shape_factory(shape_element)
|
|
554
|
+
def shape_factory(shape_element)
|
|
555
|
+
ShapeFactory.build_for_master(shape_element, self)
|
|
556
|
+
end
|
|
535
557
|
end
|
|
536
558
|
|
|
537
559
|
# The shapes on a notes page.
|
|
@@ -554,17 +576,23 @@ module Pptx
|
|
|
554
576
|
|
|
555
577
|
private
|
|
556
578
|
|
|
557
|
-
def shape_factory(shape_element)
|
|
579
|
+
def shape_factory(shape_element)
|
|
580
|
+
ShapeFactory.build_for_notes_slide(shape_element, self)
|
|
581
|
+
end
|
|
558
582
|
end
|
|
559
583
|
|
|
560
584
|
# The placeholders on a notes page.
|
|
561
585
|
class NotesSlidePlaceholders < NotesSlideShapes
|
|
562
586
|
# @return [NotesSlidePlaceholder, nil]
|
|
563
|
-
def by_type(ph_type)
|
|
587
|
+
def by_type(ph_type)
|
|
588
|
+
find { |ph| ph.element.ph_type == ph_type }
|
|
589
|
+
end
|
|
564
590
|
|
|
565
591
|
private
|
|
566
592
|
|
|
567
|
-
def member?(shape_element)
|
|
593
|
+
def member?(shape_element)
|
|
594
|
+
shape_element.placeholder?
|
|
595
|
+
end
|
|
568
596
|
end
|
|
569
597
|
|
|
570
598
|
# The placeholders of a slide layout, in `idx` order.
|
|
@@ -572,13 +600,19 @@ module Pptx
|
|
|
572
600
|
include PlaceholderAuthoring
|
|
573
601
|
|
|
574
602
|
# @return [LayoutPlaceholder, nil]
|
|
575
|
-
def by_idx(idx)
|
|
603
|
+
def by_idx(idx)
|
|
604
|
+
find { |ph| ph.element.ph_idx == idx }
|
|
605
|
+
end
|
|
576
606
|
|
|
577
607
|
private
|
|
578
608
|
|
|
579
|
-
def member?(shape_element)
|
|
609
|
+
def member?(shape_element)
|
|
610
|
+
shape_element.placeholder?
|
|
611
|
+
end
|
|
580
612
|
|
|
581
|
-
def member_elements
|
|
613
|
+
def member_elements
|
|
614
|
+
super.sort_by(&:ph_idx)
|
|
615
|
+
end
|
|
582
616
|
end
|
|
583
617
|
|
|
584
618
|
# The placeholders of a slide master, in `idx` order.
|
|
@@ -586,13 +620,19 @@ module Pptx
|
|
|
586
620
|
include PlaceholderAuthoring
|
|
587
621
|
|
|
588
622
|
# @return [MasterPlaceholder, nil]
|
|
589
|
-
def by_type(ph_type)
|
|
623
|
+
def by_type(ph_type)
|
|
624
|
+
find { |ph| ph.element.ph_type == ph_type }
|
|
625
|
+
end
|
|
590
626
|
|
|
591
627
|
private
|
|
592
628
|
|
|
593
|
-
def member?(shape_element)
|
|
629
|
+
def member?(shape_element)
|
|
630
|
+
shape_element.placeholder?
|
|
631
|
+
end
|
|
594
632
|
|
|
595
|
-
def member_elements
|
|
633
|
+
def member_elements
|
|
634
|
+
super.sort_by(&:ph_idx)
|
|
635
|
+
end
|
|
596
636
|
end
|
|
597
637
|
|
|
598
638
|
# The placeholders of a slide.
|
|
@@ -614,7 +654,9 @@ module Pptx
|
|
|
614
654
|
self
|
|
615
655
|
end
|
|
616
656
|
|
|
617
|
-
def size
|
|
657
|
+
def size
|
|
658
|
+
@sp_tree.placeholder_elements.count
|
|
659
|
+
end
|
|
618
660
|
alias length size
|
|
619
661
|
|
|
620
662
|
# The placeholder whose `idx` is +idx+, or nil.
|
|
@@ -629,6 +671,8 @@ module Pptx
|
|
|
629
671
|
|
|
630
672
|
private
|
|
631
673
|
|
|
632
|
-
def placeholder_elements
|
|
674
|
+
def placeholder_elements
|
|
675
|
+
@sp_tree.placeholder_elements.sort_by(&:ph_idx)
|
|
676
|
+
end
|
|
633
677
|
end
|
|
634
678
|
end
|
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,12 +218,16 @@ 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
|
#
|
|
@@ -193,9 +243,13 @@ module Pptx
|
|
|
193
243
|
# The zero-based position of +slide+.
|
|
194
244
|
#
|
|
195
245
|
# @return [Integer, nil] nil when the slide is not in this collection
|
|
196
|
-
def index(slide)
|
|
246
|
+
def index(slide)
|
|
247
|
+
each_with_index.find { |s, _| s == slide }&.last
|
|
248
|
+
end
|
|
197
249
|
|
|
198
|
-
def inspect
|
|
250
|
+
def inspect
|
|
251
|
+
"#<Pptx::Slides size=#{size}>"
|
|
252
|
+
end
|
|
199
253
|
end
|
|
200
254
|
|
|
201
255
|
# A slide layout: the arrangement a slide inherits from.
|
|
@@ -213,10 +267,14 @@ module Pptx
|
|
|
213
267
|
].freeze
|
|
214
268
|
|
|
215
269
|
# The shapes on this layout.
|
|
216
|
-
def shapes
|
|
270
|
+
def shapes
|
|
271
|
+
@shapes ||= LayoutShapes.new(@element.spTree, self)
|
|
272
|
+
end
|
|
217
273
|
|
|
218
274
|
# The placeholders on this layout, in `idx` order.
|
|
219
|
-
def placeholders
|
|
275
|
+
def placeholders
|
|
276
|
+
@placeholders ||= LayoutPlaceholders.new(@element.spTree, self)
|
|
277
|
+
end
|
|
220
278
|
|
|
221
279
|
# The placeholders a new slide based on this layout should receive.
|
|
222
280
|
def cloneable_placeholders
|
|
@@ -224,11 +282,15 @@ module Pptx
|
|
|
224
282
|
end
|
|
225
283
|
|
|
226
284
|
# The master this layout inherits from.
|
|
227
|
-
def slide_master
|
|
285
|
+
def slide_master
|
|
286
|
+
part.slide_master
|
|
287
|
+
end
|
|
228
288
|
|
|
229
289
|
# The kind of layout this is, e.g. "title" or "obj". PowerPoint uses it to
|
|
230
290
|
# decide which layout to offer for a given command.
|
|
231
|
-
def type
|
|
291
|
+
def type
|
|
292
|
+
@element.type
|
|
293
|
+
end
|
|
232
294
|
|
|
233
295
|
def type=(value)
|
|
234
296
|
@element.type = value&.to_s
|
|
@@ -239,7 +301,9 @@ module Pptx
|
|
|
239
301
|
part.package.presentation_part.presentation.slides.select { |s| s.layout == self }
|
|
240
302
|
end
|
|
241
303
|
|
|
242
|
-
def inspect
|
|
304
|
+
def inspect
|
|
305
|
+
"#<Pptx::SlideLayout #{name.inspect}>"
|
|
306
|
+
end
|
|
243
307
|
end
|
|
244
308
|
|
|
245
309
|
# The layouts belonging to one slide master.
|
|
@@ -262,7 +326,9 @@ module Pptx
|
|
|
262
326
|
self
|
|
263
327
|
end
|
|
264
328
|
|
|
265
|
-
def size
|
|
329
|
+
def size
|
|
330
|
+
@sld_layout_id_list.size
|
|
331
|
+
end
|
|
266
332
|
alias length size
|
|
267
333
|
|
|
268
334
|
# Indexed by position, or looked up by layout name.
|
|
@@ -282,10 +348,14 @@ module Pptx
|
|
|
282
348
|
end
|
|
283
349
|
|
|
284
350
|
# @return [SlideLayout, nil]
|
|
285
|
-
def by_name(name)
|
|
351
|
+
def by_name(name)
|
|
352
|
+
find { |layout| layout.name == name }
|
|
353
|
+
end
|
|
286
354
|
|
|
287
355
|
# @return [Integer, nil]
|
|
288
|
-
def index(slide_layout)
|
|
356
|
+
def index(slide_layout)
|
|
357
|
+
each_with_index.find { |l, _| l == slide_layout }&.last
|
|
358
|
+
end
|
|
289
359
|
|
|
290
360
|
# Remove +slide_layout+ from this collection and from the package.
|
|
291
361
|
#
|
|
@@ -329,7 +399,9 @@ module Pptx
|
|
|
329
399
|
layout
|
|
330
400
|
end
|
|
331
401
|
|
|
332
|
-
def inspect
|
|
402
|
+
def inspect
|
|
403
|
+
"#<Pptx::SlideLayouts size=#{size}>"
|
|
404
|
+
end
|
|
333
405
|
end
|
|
334
406
|
|
|
335
407
|
# A slide master.
|
|
@@ -342,14 +414,20 @@ module Pptx
|
|
|
342
414
|
# The colours and fonts this master draws from.
|
|
343
415
|
#
|
|
344
416
|
# @return [Pptx::Theme]
|
|
345
|
-
def theme
|
|
417
|
+
def theme
|
|
418
|
+
part.theme_part.theme
|
|
419
|
+
end
|
|
346
420
|
|
|
347
421
|
# The placeholders every layout and slide under this master inherits from.
|
|
348
422
|
#
|
|
349
423
|
# @return [MasterPlaceholders]
|
|
350
|
-
def placeholders
|
|
424
|
+
def placeholders
|
|
425
|
+
@placeholders ||= MasterPlaceholders.new(@element.spTree, self)
|
|
426
|
+
end
|
|
351
427
|
|
|
352
|
-
def inspect
|
|
428
|
+
def inspect
|
|
429
|
+
"#<Pptx::SlideMaster #{part.partname}>"
|
|
430
|
+
end
|
|
353
431
|
end
|
|
354
432
|
|
|
355
433
|
# The slide masters of a presentation.
|
|
@@ -372,7 +450,9 @@ module Pptx
|
|
|
372
450
|
self
|
|
373
451
|
end
|
|
374
452
|
|
|
375
|
-
def size
|
|
453
|
+
def size
|
|
454
|
+
@sld_master_id_list.size
|
|
455
|
+
end
|
|
376
456
|
alias length size
|
|
377
457
|
|
|
378
458
|
def [](index, length = nil)
|
|
@@ -408,7 +488,9 @@ module Pptx
|
|
|
408
488
|
master
|
|
409
489
|
end
|
|
410
490
|
|
|
411
|
-
def inspect
|
|
491
|
+
def inspect
|
|
492
|
+
"#<Pptx::SlideMasters size=#{size}>"
|
|
493
|
+
end
|
|
412
494
|
|
|
413
495
|
private
|
|
414
496
|
|