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
|
@@ -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.
|