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
|
@@ -24,64 +24,90 @@ module Pptx
|
|
|
24
24
|
@parent = parent
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def ==(other)
|
|
27
|
+
def ==(other)
|
|
28
|
+
other.is_a?(BaseShape) && other.element == @element
|
|
29
|
+
end
|
|
28
30
|
alias eql? ==
|
|
29
31
|
|
|
30
|
-
def hash
|
|
32
|
+
def hash
|
|
33
|
+
@element.hash
|
|
34
|
+
end
|
|
31
35
|
|
|
32
36
|
# The package part containing this shape.
|
|
33
|
-
def part
|
|
37
|
+
def part
|
|
38
|
+
@parent.part
|
|
39
|
+
end
|
|
34
40
|
|
|
35
41
|
# The drawing-object id, unique within the slide.
|
|
36
|
-
def shape_id
|
|
42
|
+
def shape_id
|
|
43
|
+
@element.shape_id
|
|
44
|
+
end
|
|
37
45
|
|
|
38
|
-
def name
|
|
46
|
+
def name
|
|
47
|
+
@element.shape_name
|
|
48
|
+
end
|
|
39
49
|
|
|
40
50
|
def name=(value)
|
|
41
51
|
@element.nvXxPr.cNvPr.name = value.to_s
|
|
42
52
|
end
|
|
43
53
|
|
|
44
54
|
# @return [Length, nil] nil when the shape inherits its position
|
|
45
|
-
def left
|
|
55
|
+
def left
|
|
56
|
+
@element.x
|
|
57
|
+
end
|
|
46
58
|
|
|
47
59
|
def left=(value)
|
|
48
60
|
@element.x = value
|
|
49
61
|
end
|
|
50
62
|
|
|
51
|
-
def top
|
|
63
|
+
def top
|
|
64
|
+
@element.y
|
|
65
|
+
end
|
|
52
66
|
|
|
53
67
|
def top=(value)
|
|
54
68
|
@element.y = value
|
|
55
69
|
end
|
|
56
70
|
|
|
57
|
-
def width
|
|
71
|
+
def width
|
|
72
|
+
@element.cx
|
|
73
|
+
end
|
|
58
74
|
|
|
59
75
|
def width=(value)
|
|
60
76
|
@element.cx = value
|
|
61
77
|
end
|
|
62
78
|
|
|
63
|
-
def height
|
|
79
|
+
def height
|
|
80
|
+
@element.cy
|
|
81
|
+
end
|
|
64
82
|
|
|
65
83
|
def height=(value)
|
|
66
84
|
@element.cy = value
|
|
67
85
|
end
|
|
68
86
|
|
|
69
87
|
# Clockwise rotation in degrees.
|
|
70
|
-
def rotation
|
|
88
|
+
def rotation
|
|
89
|
+
@element.rot
|
|
90
|
+
end
|
|
71
91
|
|
|
72
92
|
def rotation=(value)
|
|
73
93
|
@element.rot = value
|
|
74
94
|
end
|
|
75
95
|
|
|
76
|
-
def placeholder?
|
|
96
|
+
def placeholder?
|
|
97
|
+
@element.placeholder?
|
|
98
|
+
end
|
|
77
99
|
|
|
78
100
|
# This shape's shadow. Always returned, even when the shadow is inherited.
|
|
79
101
|
#
|
|
80
102
|
# @return [ShadowFormat]
|
|
81
|
-
def shadow
|
|
103
|
+
def shadow
|
|
104
|
+
@shadow ||= ShadowFormat.new(@element.spPr)
|
|
105
|
+
end
|
|
82
106
|
|
|
83
107
|
# What happens when this shape is clicked during a slide show.
|
|
84
|
-
def click_action
|
|
108
|
+
def click_action
|
|
109
|
+
@click_action ||= ActionSetting.new(@element.nvXxPr.cNvPr, self)
|
|
110
|
+
end
|
|
85
111
|
|
|
86
112
|
# What happens when the pointer rests on this shape.
|
|
87
113
|
def hover_action
|
|
@@ -93,7 +119,9 @@ module Pptx
|
|
|
93
119
|
# A shortcut for `click_action.url`, which is the common case; reach for
|
|
94
120
|
# {#click_action} when the click does something else. Nil when the click
|
|
95
121
|
# is not a hyperlink -- a slide jump reports nil here, not a partname.
|
|
96
|
-
def hyperlink
|
|
122
|
+
def hyperlink
|
|
123
|
+
click_action.url
|
|
124
|
+
end
|
|
97
125
|
|
|
98
126
|
def hyperlink=(url)
|
|
99
127
|
click_action.address = url
|
|
@@ -105,14 +133,26 @@ module Pptx
|
|
|
105
133
|
end
|
|
106
134
|
|
|
107
135
|
# Overridden by the subclasses that can actually hold these.
|
|
108
|
-
def text_frame?
|
|
109
|
-
|
|
110
|
-
|
|
136
|
+
def text_frame?
|
|
137
|
+
false
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def chart?
|
|
141
|
+
false
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def table?
|
|
145
|
+
false
|
|
146
|
+
end
|
|
111
147
|
|
|
112
148
|
# @return [Pptx::Enum::MSO_SHAPE_TYPE]
|
|
113
|
-
def shape_type
|
|
149
|
+
def shape_type
|
|
150
|
+
raise(NotImplementedError, "#{self.class} must implement #shape_type")
|
|
151
|
+
end
|
|
114
152
|
|
|
115
|
-
def inspect
|
|
153
|
+
def inspect
|
|
154
|
+
"#<#{self.class.name} id=#{shape_id} #{name.inspect}>"
|
|
155
|
+
end
|
|
116
156
|
end
|
|
117
157
|
|
|
118
158
|
# The placeholder-specific properties of a shape: which placeholder it is
|
|
@@ -124,15 +164,25 @@ module Pptx
|
|
|
124
164
|
|
|
125
165
|
# The `idx` that ties a slide placeholder to the layout one it inherits
|
|
126
166
|
# from. The title placeholder is always 0.
|
|
127
|
-
def idx
|
|
167
|
+
def idx
|
|
168
|
+
@element.idx
|
|
169
|
+
end
|
|
128
170
|
|
|
129
171
|
# @return [Pptx::Enum::PP_PLACEHOLDER]
|
|
130
|
-
def type
|
|
172
|
+
def type
|
|
173
|
+
@element.type
|
|
174
|
+
end
|
|
131
175
|
|
|
132
|
-
def orientation
|
|
176
|
+
def orientation
|
|
177
|
+
@element.orient
|
|
178
|
+
end
|
|
133
179
|
|
|
134
|
-
def size
|
|
180
|
+
def size
|
|
181
|
+
@element.sz
|
|
182
|
+
end
|
|
135
183
|
|
|
136
|
-
def inspect
|
|
184
|
+
def inspect
|
|
185
|
+
"#<Pptx::PlaceholderFormat idx=#{idx} type=#{type}>"
|
|
186
|
+
end
|
|
137
187
|
end
|
|
138
188
|
end
|
|
@@ -36,9 +36,13 @@ module Pptx
|
|
|
36
36
|
new(shapes, start_x, start_y, x_scale, y_scale)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
def each(&)
|
|
39
|
+
def each(&)
|
|
40
|
+
@operations.each(&)
|
|
41
|
+
end
|
|
40
42
|
|
|
41
|
-
def size
|
|
43
|
+
def size
|
|
44
|
+
@operations.size
|
|
45
|
+
end
|
|
42
46
|
|
|
43
47
|
# Draw a straight line to (x, y).
|
|
44
48
|
#
|
|
@@ -89,11 +93,17 @@ module Pptx
|
|
|
89
93
|
#
|
|
90
94
|
# The bounding box need not start at the local origin, so this is what the
|
|
91
95
|
# points are measured from.
|
|
92
|
-
def offset_x
|
|
96
|
+
def offset_x
|
|
97
|
+
drawn.map(&:x).push(@start_x).min
|
|
98
|
+
end
|
|
93
99
|
|
|
94
|
-
def offset_y
|
|
100
|
+
def offset_y
|
|
101
|
+
drawn.map(&:y).push(@start_y).min
|
|
102
|
+
end
|
|
95
103
|
|
|
96
|
-
def inspect
|
|
104
|
+
def inspect
|
|
105
|
+
"#<Pptx::FreeformBuilder #{size} operations>"
|
|
106
|
+
end
|
|
97
107
|
|
|
98
108
|
private
|
|
99
109
|
|
|
@@ -103,10 +113,14 @@ module Pptx
|
|
|
103
113
|
# Rounded half-to-even, because Python rounds that way and Ruby rounds
|
|
104
114
|
# half-up: a coordinate of 100.5 would otherwise land a unit away from
|
|
105
115
|
# where the reference implementation puts it.
|
|
106
|
-
def round(value)
|
|
116
|
+
def round(value)
|
|
117
|
+
value.round(half: :even)
|
|
118
|
+
end
|
|
107
119
|
|
|
108
120
|
# Operations that have a position; a close does not.
|
|
109
|
-
def drawn
|
|
121
|
+
def drawn
|
|
122
|
+
@operations.reject { |operation| operation.kind == :close }
|
|
123
|
+
end
|
|
110
124
|
|
|
111
125
|
def local_width
|
|
112
126
|
xs = drawn.map(&:x).push(@start_x)
|
|
@@ -118,17 +132,27 @@ module Pptx
|
|
|
118
132
|
ys.max - ys.min
|
|
119
133
|
end
|
|
120
134
|
|
|
121
|
-
def width
|
|
135
|
+
def width
|
|
136
|
+
(local_width * @x_scale).round
|
|
137
|
+
end
|
|
122
138
|
|
|
123
|
-
def height
|
|
139
|
+
def height
|
|
140
|
+
(local_height * @y_scale).round
|
|
141
|
+
end
|
|
124
142
|
|
|
125
|
-
def left
|
|
143
|
+
def left
|
|
144
|
+
(offset_x * @x_scale).round
|
|
145
|
+
end
|
|
126
146
|
|
|
127
|
-
def top
|
|
147
|
+
def top
|
|
148
|
+
(offset_y * @y_scale).round
|
|
149
|
+
end
|
|
128
150
|
|
|
129
151
|
# Points inside a path are relative to the shape's top-left corner, not to
|
|
130
152
|
# the local origin.
|
|
131
|
-
def to_shape_space(x, y)
|
|
153
|
+
def to_shape_space(x, y)
|
|
154
|
+
[x - offset_x, y - offset_y]
|
|
155
|
+
end
|
|
132
156
|
|
|
133
157
|
def apply(operation, path)
|
|
134
158
|
case operation.kind
|
|
@@ -13,13 +13,26 @@ module Pptx
|
|
|
13
13
|
# Writing is not inherited -- setting a value applies it to this shape, which
|
|
14
14
|
# is what stops it tracking the layout from then on.
|
|
15
15
|
module InheritsDimensions
|
|
16
|
-
def left
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
def left
|
|
17
|
+
effective(:left)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def top
|
|
21
|
+
effective(:top)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def width
|
|
25
|
+
effective(:width)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def height
|
|
29
|
+
effective(:height)
|
|
30
|
+
end
|
|
20
31
|
|
|
21
32
|
# The placeholder one level up that this one inherits from, or nil.
|
|
22
|
-
def base_placeholder
|
|
33
|
+
def base_placeholder
|
|
34
|
+
raise(NotImplementedError, "#{self.class} must define base_placeholder")
|
|
35
|
+
end
|
|
23
36
|
|
|
24
37
|
private
|
|
25
38
|
|
|
@@ -42,7 +55,9 @@ module Pptx
|
|
|
42
55
|
class SlidePlaceholder < Shape
|
|
43
56
|
include InheritsDimensions
|
|
44
57
|
|
|
45
|
-
def shape_type
|
|
58
|
+
def shape_type
|
|
59
|
+
Enum::MSO_SHAPE_TYPE::PLACEHOLDER
|
|
60
|
+
end
|
|
46
61
|
|
|
47
62
|
# Matched to the layout by `idx`, which is what ties the two together.
|
|
48
63
|
def base_placeholder
|
|
@@ -63,9 +78,9 @@ module Pptx
|
|
|
63
78
|
# Put +new_element+ where this placeholder is and move the `p:ph` onto
|
|
64
79
|
# it. The original element leaves the tree; this object is spent.
|
|
65
80
|
def replace_placeholder_with(new_element)
|
|
66
|
-
adopted = @element.
|
|
81
|
+
adopted = @element.import(new_element)
|
|
67
82
|
adopted.nvXxPr.nvPr.insert_ph(@element.ph)
|
|
68
|
-
@element.
|
|
83
|
+
@element.add_previous_sibling(adopted)
|
|
69
84
|
@element.parent.remove(@element)
|
|
70
85
|
ShapeFactory.build_for_slide(adopted, @parent)
|
|
71
86
|
end
|
|
@@ -129,14 +144,20 @@ module Pptx
|
|
|
129
144
|
class PlaceholderPicture < Picture
|
|
130
145
|
include InheritsDimensions
|
|
131
146
|
|
|
132
|
-
def shape_type
|
|
147
|
+
def shape_type
|
|
148
|
+
Enum::MSO_SHAPE_TYPE::PLACEHOLDER
|
|
149
|
+
end
|
|
133
150
|
|
|
134
|
-
def base_placeholder
|
|
151
|
+
def base_placeholder
|
|
152
|
+
part.slide_layout.placeholders.by_idx(element.ph_idx)
|
|
153
|
+
end
|
|
135
154
|
end
|
|
136
155
|
|
|
137
156
|
# A table or chart that fills a placeholder.
|
|
138
157
|
class PlaceholderGraphicFrame < GraphicFrame
|
|
139
|
-
def placeholder?
|
|
158
|
+
def placeholder?
|
|
159
|
+
true
|
|
160
|
+
end
|
|
140
161
|
end
|
|
141
162
|
|
|
142
163
|
# A placeholder on a slide layout.
|
|
@@ -153,7 +174,9 @@ module Pptx
|
|
|
153
174
|
DATE: :DATE, FOOTER: :FOOTER, SLIDE_NUMBER: :SLIDE_NUMBER
|
|
154
175
|
}.freeze
|
|
155
176
|
|
|
156
|
-
def shape_type
|
|
177
|
+
def shape_type
|
|
178
|
+
Enum::MSO_SHAPE_TYPE::PLACEHOLDER
|
|
179
|
+
end
|
|
157
180
|
|
|
158
181
|
def base_placeholder
|
|
159
182
|
base_type = BASE_TYPES[element.ph_type&.name]
|
|
@@ -169,9 +192,13 @@ module Pptx
|
|
|
169
192
|
class NotesSlidePlaceholder < Shape
|
|
170
193
|
include InheritsDimensions
|
|
171
194
|
|
|
172
|
-
def shape_type
|
|
195
|
+
def shape_type
|
|
196
|
+
Enum::MSO_SHAPE_TYPE::PLACEHOLDER
|
|
197
|
+
end
|
|
173
198
|
|
|
174
|
-
def base_placeholder
|
|
199
|
+
def base_placeholder
|
|
200
|
+
part.notes_master.placeholders.by_type(element.ph_type)
|
|
201
|
+
end
|
|
175
202
|
end
|
|
176
203
|
|
|
177
204
|
# A placeholder on a slide master.
|
|
@@ -179,6 +206,8 @@ module Pptx
|
|
|
179
206
|
# There is nothing above a master to inherit from, so its geometry is
|
|
180
207
|
# whatever it carries itself.
|
|
181
208
|
class MasterPlaceholder < Shape
|
|
182
|
-
def shape_type
|
|
209
|
+
def shape_type
|
|
210
|
+
Enum::MSO_SHAPE_TYPE::PLACEHOLDER
|
|
211
|
+
end
|
|
183
212
|
end
|
|
184
213
|
end
|
|
@@ -8,7 +8,9 @@ require "ruby_pptx/table"
|
|
|
8
8
|
module Pptx
|
|
9
9
|
# A `p:sp`: an auto shape, a text box, or a placeholder.
|
|
10
10
|
class Shape < BaseShape
|
|
11
|
-
def text_frame?
|
|
11
|
+
def text_frame?
|
|
12
|
+
true
|
|
13
|
+
end
|
|
12
14
|
|
|
13
15
|
# The text inside this shape, creating an empty text body if it has none.
|
|
14
16
|
def text_frame
|
|
@@ -16,27 +18,37 @@ module Pptx
|
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
# Shortcut for `text_frame.text`.
|
|
19
|
-
def text
|
|
21
|
+
def text
|
|
22
|
+
text_frame.text
|
|
23
|
+
end
|
|
20
24
|
|
|
21
25
|
def text=(value)
|
|
22
26
|
text_frame.text = value
|
|
23
27
|
end
|
|
24
28
|
|
|
25
29
|
# The shape's fill.
|
|
26
|
-
def fill
|
|
30
|
+
def fill
|
|
31
|
+
@fill ||= FillFormat.from_fill_parent(@element.spPr)
|
|
32
|
+
end
|
|
27
33
|
|
|
28
34
|
# The shape's outline.
|
|
29
|
-
def line
|
|
35
|
+
def line
|
|
36
|
+
@line ||= LineFormat.new(@element.spPr)
|
|
37
|
+
end
|
|
30
38
|
|
|
31
39
|
# The adjustment handles of this shape's geometry; empty for a freeform.
|
|
32
40
|
#
|
|
33
41
|
# @return [Adjustments]
|
|
34
|
-
def adjustments
|
|
42
|
+
def adjustments
|
|
43
|
+
@adjustments ||= Adjustments.new(@element.spPr.prstGeom)
|
|
44
|
+
end
|
|
35
45
|
|
|
36
46
|
# The preset geometry of an auto shape.
|
|
37
47
|
#
|
|
38
48
|
# @return [Pptx::Enum::MSO_SHAPE, nil] nil unless this is an auto shape
|
|
39
|
-
def auto_shape_type
|
|
49
|
+
def auto_shape_type
|
|
50
|
+
@element.autoshape? ? @element.prst : nil
|
|
51
|
+
end
|
|
40
52
|
|
|
41
53
|
def shape_type
|
|
42
54
|
return Enum::MSO_SHAPE_TYPE::PLACEHOLDER if placeholder?
|
|
@@ -60,12 +72,16 @@ module Pptx
|
|
|
60
72
|
end
|
|
61
73
|
|
|
62
74
|
# The outline drawn around the picture.
|
|
63
|
-
def line
|
|
75
|
+
def line
|
|
76
|
+
@line ||= LineFormat.new(@element.spPr)
|
|
77
|
+
end
|
|
64
78
|
end
|
|
65
79
|
|
|
66
80
|
# A `p:pic` showing a still image.
|
|
67
81
|
class Picture < BasePicture
|
|
68
|
-
def shape_type
|
|
82
|
+
def shape_type
|
|
83
|
+
Enum::MSO_SHAPE_TYPE::PICTURE
|
|
84
|
+
end
|
|
69
85
|
|
|
70
86
|
# The image this picture shows: its bytes, format, size and resolution.
|
|
71
87
|
#
|
|
@@ -82,7 +98,9 @@ module Pptx
|
|
|
82
98
|
# which crops nothing; an ellipse shows it through an oval.
|
|
83
99
|
#
|
|
84
100
|
# @return [Pptx::Enum::Member, nil] nil for a freeform mask, or no geometry
|
|
85
|
-
def auto_shape_type
|
|
101
|
+
def auto_shape_type
|
|
102
|
+
@element.spPr.prstGeom&.prst
|
|
103
|
+
end
|
|
86
104
|
|
|
87
105
|
def auto_shape_type=(value)
|
|
88
106
|
member = Enum::MSO_AUTO_SHAPE_TYPE.fetch(value)
|
|
@@ -101,9 +119,13 @@ module Pptx
|
|
|
101
119
|
# Not a {Picture}: the image a movie holds is its poster frame, which is
|
|
102
120
|
# what {#poster_frame} returns, and a movie cannot be masked by a shape.
|
|
103
121
|
class Movie < BasePicture
|
|
104
|
-
def shape_type
|
|
122
|
+
def shape_type
|
|
123
|
+
Enum::MSO_SHAPE_TYPE::MEDIA
|
|
124
|
+
end
|
|
105
125
|
|
|
106
|
-
def media_type
|
|
126
|
+
def media_type
|
|
127
|
+
Enum::PP_MEDIA_TYPE::MOVIE
|
|
128
|
+
end
|
|
107
129
|
|
|
108
130
|
# The still shown before the movie plays, or nil if there is none.
|
|
109
131
|
#
|
|
@@ -116,7 +138,9 @@ module Pptx
|
|
|
116
138
|
# Playback settings. PowerPoint keeps these in the timing tree and
|
|
117
139
|
# python-pptx exposes none of them yet; the object exists so code written
|
|
118
140
|
# against either library finds it.
|
|
119
|
-
def media_format
|
|
141
|
+
def media_format
|
|
142
|
+
@media_format ||= MediaFormat.new(@element)
|
|
143
|
+
end
|
|
120
144
|
end
|
|
121
145
|
|
|
122
146
|
# Playback formatting for a movie. Deliberately empty; see {Movie#media_format}.
|
|
@@ -128,29 +152,41 @@ module Pptx
|
|
|
128
152
|
# points, so moving an end point may flip the box rather than move it. The
|
|
129
153
|
# accessors here hide that.
|
|
130
154
|
class Connector < BaseShape
|
|
131
|
-
def shape_type
|
|
155
|
+
def shape_type
|
|
156
|
+
Enum::MSO_SHAPE_TYPE::LINE
|
|
157
|
+
end
|
|
132
158
|
|
|
133
|
-
def line
|
|
159
|
+
def line
|
|
160
|
+
@line ||= LineFormat.new(@element.spPr)
|
|
161
|
+
end
|
|
134
162
|
|
|
135
|
-
def begin_x
|
|
163
|
+
def begin_x
|
|
164
|
+
Length.emu(@element.flipH ? left.to_i + width.to_i : left.to_i)
|
|
165
|
+
end
|
|
136
166
|
|
|
137
167
|
def begin_x=(value)
|
|
138
168
|
move_x(Length.coerce(value).emu, begin_point: true)
|
|
139
169
|
end
|
|
140
170
|
|
|
141
|
-
def begin_y
|
|
171
|
+
def begin_y
|
|
172
|
+
Length.emu(@element.flipV ? top.to_i + height.to_i : top.to_i)
|
|
173
|
+
end
|
|
142
174
|
|
|
143
175
|
def begin_y=(value)
|
|
144
176
|
move_y(Length.coerce(value).emu, begin_point: true)
|
|
145
177
|
end
|
|
146
178
|
|
|
147
|
-
def end_x
|
|
179
|
+
def end_x
|
|
180
|
+
Length.emu(@element.flipH ? left.to_i : left.to_i + width.to_i)
|
|
181
|
+
end
|
|
148
182
|
|
|
149
183
|
def end_x=(value)
|
|
150
184
|
move_x(Length.coerce(value).emu, begin_point: false)
|
|
151
185
|
end
|
|
152
186
|
|
|
153
|
-
def end_y
|
|
187
|
+
def end_y
|
|
188
|
+
Length.emu(@element.flipV ? top.to_i : top.to_i + height.to_i)
|
|
189
|
+
end
|
|
154
190
|
|
|
155
191
|
def end_y=(value)
|
|
156
192
|
move_y(Length.coerce(value).emu, begin_point: false)
|
|
@@ -183,9 +219,13 @@ module Pptx
|
|
|
183
219
|
self
|
|
184
220
|
end
|
|
185
221
|
|
|
186
|
-
def begin_connected?
|
|
222
|
+
def begin_connected?
|
|
223
|
+
!@element.nvCxnSpPr.cNvCxnSpPr.stCxn.nil?
|
|
224
|
+
end
|
|
187
225
|
|
|
188
|
-
def end_connected?
|
|
226
|
+
def end_connected?
|
|
227
|
+
!@element.nvCxnSpPr.cNvCxnSpPr.endCxn.nil?
|
|
228
|
+
end
|
|
189
229
|
|
|
190
230
|
def inspect
|
|
191
231
|
"#<Pptx::Connector (#{begin_x.inches.round(2)}, #{begin_y.inches.round(2)}) -> " \
|
|
@@ -238,8 +278,13 @@ module Pptx
|
|
|
238
278
|
raise Error, "a graphic frame has no shadow of its own; format the chart or table instead"
|
|
239
279
|
end
|
|
240
280
|
|
|
241
|
-
def table?
|
|
242
|
-
|
|
281
|
+
def table?
|
|
282
|
+
@element.table?
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def chart?
|
|
286
|
+
@element.chart?
|
|
287
|
+
end
|
|
243
288
|
|
|
244
289
|
# The table inside this frame.
|
|
245
290
|
#
|
|
@@ -274,7 +319,9 @@ module Pptx
|
|
|
274
319
|
end
|
|
275
320
|
end
|
|
276
321
|
|
|
277
|
-
def ole_object?
|
|
322
|
+
def ole_object?
|
|
323
|
+
@element.ole_object?
|
|
324
|
+
end
|
|
278
325
|
|
|
279
326
|
# The OLE object this frame holds.
|
|
280
327
|
#
|
|
@@ -300,12 +347,18 @@ module Pptx
|
|
|
300
347
|
end
|
|
301
348
|
|
|
302
349
|
# The ProgID naming the program that opens the object, e.g. "Excel.Sheet.12".
|
|
303
|
-
def prog_id
|
|
350
|
+
def prog_id
|
|
351
|
+
@element.progId
|
|
352
|
+
end
|
|
304
353
|
|
|
305
354
|
# Whether it appears as an icon rather than as a picture of its content.
|
|
306
|
-
def show_as_icon?
|
|
355
|
+
def show_as_icon?
|
|
356
|
+
@element.showAsIcon
|
|
357
|
+
end
|
|
307
358
|
|
|
308
|
-
def inspect
|
|
359
|
+
def inspect
|
|
360
|
+
"#<Pptx::OleFormat #{prog_id.inspect}>"
|
|
361
|
+
end
|
|
309
362
|
end
|
|
310
363
|
|
|
311
364
|
# A `p:grpSp` containing other shapes.
|
|
@@ -314,15 +367,23 @@ module Pptx
|
|
|
314
367
|
# contains, and are recomputed whenever its contents change.
|
|
315
368
|
class GroupShape < BaseShape
|
|
316
369
|
# A group keeps its effects in `p:grpSpPr` rather than `p:spPr`.
|
|
317
|
-
def shadow
|
|
370
|
+
def shadow
|
|
371
|
+
@shadow ||= ShadowFormat.new(@element.grpSpPr)
|
|
372
|
+
end
|
|
318
373
|
|
|
319
|
-
def shape_type
|
|
374
|
+
def shape_type
|
|
375
|
+
Enum::MSO_SHAPE_TYPE::GROUP
|
|
376
|
+
end
|
|
320
377
|
|
|
321
378
|
# The shapes inside this group.
|
|
322
|
-
def shapes
|
|
379
|
+
def shapes
|
|
380
|
+
@shapes ||= GroupShapes.new(@element, self)
|
|
381
|
+
end
|
|
323
382
|
|
|
324
383
|
# A group holds no text of its own, though the shapes in it may.
|
|
325
|
-
def text_frame?
|
|
384
|
+
def text_frame?
|
|
385
|
+
false
|
|
386
|
+
end
|
|
326
387
|
|
|
327
388
|
# PowerPoint offers no click behaviour on a group; the shapes inside carry
|
|
328
389
|
# their own.
|