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/theme.rb
CHANGED
|
@@ -17,7 +17,9 @@ module Pptx
|
|
|
17
17
|
# are inherited from the base theme and not editable here; writing a
|
|
18
18
|
# coherent set by hand is a design exercise, not a configuration one.
|
|
19
19
|
class Theme < PartElementProxy
|
|
20
|
-
def name
|
|
20
|
+
def name
|
|
21
|
+
@element.name
|
|
22
|
+
end
|
|
21
23
|
|
|
22
24
|
def name=(value)
|
|
23
25
|
# PowerPoint shows the theme name in three places and expects them to
|
|
@@ -28,12 +30,18 @@ module Pptx
|
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
# @return [ThemeColors]
|
|
31
|
-
def colors
|
|
33
|
+
def colors
|
|
34
|
+
@colors ||= ThemeColors.new(@element.clrScheme, self)
|
|
35
|
+
end
|
|
32
36
|
|
|
33
37
|
# @return [ThemeFonts]
|
|
34
|
-
def fonts
|
|
38
|
+
def fonts
|
|
39
|
+
@fonts ||= ThemeFonts.new(@element.fontScheme, self)
|
|
40
|
+
end
|
|
35
41
|
|
|
36
|
-
def inspect
|
|
42
|
+
def inspect
|
|
43
|
+
"#<Pptx::Theme #{name.inspect}>"
|
|
44
|
+
end
|
|
37
45
|
end
|
|
38
46
|
|
|
39
47
|
# The twelve theme colours, addressed by name.
|
|
@@ -50,7 +58,9 @@ module Pptx
|
|
|
50
58
|
NAMES = Oxml::CT_ColorScheme::SLOTS.map(&:to_sym).freeze
|
|
51
59
|
|
|
52
60
|
# @return [Pptx::ColorFormat]
|
|
53
|
-
def [](name)
|
|
61
|
+
def [](name)
|
|
62
|
+
ColorFormat.from_color_choice_parent(@element.slot(name))
|
|
63
|
+
end
|
|
54
64
|
|
|
55
65
|
def each
|
|
56
66
|
return enum_for(:each) { NAMES.size } unless block_given?
|
|
@@ -71,9 +81,13 @@ module Pptx
|
|
|
71
81
|
self
|
|
72
82
|
end
|
|
73
83
|
|
|
74
|
-
def names
|
|
84
|
+
def names
|
|
85
|
+
NAMES
|
|
86
|
+
end
|
|
75
87
|
|
|
76
|
-
def inspect
|
|
88
|
+
def inspect
|
|
89
|
+
"#<Pptx::ThemeColors #{NAMES.size} colours>"
|
|
90
|
+
end
|
|
77
91
|
end
|
|
78
92
|
|
|
79
93
|
# The heading and body typefaces of a theme.
|
|
@@ -81,18 +95,24 @@ module Pptx
|
|
|
81
95
|
# PowerPoint calls these "major" and "minor"; they are what `+mj-lt` and
|
|
82
96
|
# `+mn-lt` resolve to in placeholder text.
|
|
83
97
|
class ThemeFonts < ParentedElementProxy
|
|
84
|
-
def major
|
|
98
|
+
def major
|
|
99
|
+
@element.majorFont.typeface
|
|
100
|
+
end
|
|
85
101
|
|
|
86
102
|
def major=(value)
|
|
87
103
|
@element.majorFont.typeface = value
|
|
88
104
|
end
|
|
89
105
|
|
|
90
|
-
def minor
|
|
106
|
+
def minor
|
|
107
|
+
@element.minorFont.typeface
|
|
108
|
+
end
|
|
91
109
|
|
|
92
110
|
def minor=(value)
|
|
93
111
|
@element.minorFont.typeface = value
|
|
94
112
|
end
|
|
95
113
|
|
|
96
|
-
def inspect
|
|
114
|
+
def inspect
|
|
115
|
+
"#<Pptx::ThemeFonts major=#{major.inspect} minor=#{minor.inspect}>"
|
|
116
|
+
end
|
|
97
117
|
end
|
|
98
118
|
end
|
data/lib/ruby_pptx/version.rb
CHANGED
data/lib/ruby_pptx.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Nokogiri is not required here: Pptx::Oxml::Backend loads it when it can
|
|
4
|
+
# and falls back to REXML when it cannot, as under ruby.wasm.
|
|
4
5
|
require "zip"
|
|
5
6
|
|
|
6
7
|
require "ruby_pptx/version"
|
|
@@ -87,4 +88,10 @@ require "ruby_pptx/enum/prog_id"
|
|
|
87
88
|
|
|
88
89
|
# A Ruby object model for PowerPoint (.pptx) files, ported from python-pptx.
|
|
89
90
|
module Pptx
|
|
91
|
+
# The XML library in use: :nokogiri, or :rexml where Nokogiri cannot be
|
|
92
|
+
# loaded (ruby.wasm) or RUBY_PPTX_XML_BACKEND=rexml asks for it. Output is
|
|
93
|
+
# the same either way; Nokogiri is several times faster.
|
|
94
|
+
def self.xml_backend
|
|
95
|
+
Oxml::BACKEND.name
|
|
96
|
+
end
|
|
90
97
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_pptx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andi
|
|
@@ -24,6 +24,26 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.18'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rexml
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 3.3.9
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '4'
|
|
37
|
+
type: :runtime
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 3.3.9
|
|
44
|
+
- - "<"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '4'
|
|
27
47
|
- !ruby/object:Gem::Dependency
|
|
28
48
|
name: rubyzip
|
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -88,6 +108,7 @@ files:
|
|
|
88
108
|
- lib/ruby_pptx/opc/serialized.rb
|
|
89
109
|
- lib/ruby_pptx/opc/spec.rb
|
|
90
110
|
- lib/ruby_pptx/oxml/action.rb
|
|
111
|
+
- lib/ruby_pptx/oxml/backend.rb
|
|
91
112
|
- lib/ruby_pptx/oxml/chart.rb
|
|
92
113
|
- lib/ruby_pptx/oxml/content_model.rb
|
|
93
114
|
- lib/ruby_pptx/oxml/core_properties.rb
|