ruby_pptx 0.1.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 +7 -0
- data/CHANGELOG.md +83 -0
- data/LICENSE +21 -0
- data/NOTICE +48 -0
- data/README.md +272 -0
- data/lib/ruby_pptx/action.rb +120 -0
- data/lib/ruby_pptx/autoshape_spec.rb +337 -0
- data/lib/ruby_pptx/builder.rb +228 -0
- data/lib/ruby_pptx/chart/categories.rb +208 -0
- data/lib/ruby_pptx/chart/chart.rb +443 -0
- data/lib/ruby_pptx/chart/combo.rb +230 -0
- data/lib/ruby_pptx/chart/data.rb +147 -0
- data/lib/ruby_pptx/chart/format.rb +647 -0
- data/lib/ruby_pptx/chart/workbook_writer.rb +212 -0
- data/lib/ruby_pptx/chart/xml_writer.rb +953 -0
- data/lib/ruby_pptx/chart/xy_data.rb +182 -0
- data/lib/ruby_pptx/core_ext.rb +12 -0
- data/lib/ruby_pptx/dml/color.rb +155 -0
- data/lib/ruby_pptx/dml/effect.rb +33 -0
- data/lib/ruby_pptx/dml/fill.rb +234 -0
- data/lib/ruby_pptx/element_proxy.rb +53 -0
- data/lib/ruby_pptx/enum/action.rb +46 -0
- data/lib/ruby_pptx/enum/base.rb +139 -0
- data/lib/ruby_pptx/enum/chart.rb +278 -0
- data/lib/ruby_pptx/enum/dml.rb +237 -0
- data/lib/ruby_pptx/enum/lang.rb +441 -0
- data/lib/ruby_pptx/enum/prog_id.rb +38 -0
- data/lib/ruby_pptx/enum/shapes.rb +514 -0
- data/lib/ruby_pptx/enum/text.rb +108 -0
- data/lib/ruby_pptx/errors.rb +15 -0
- data/lib/ruby_pptx/geometry.rb +89 -0
- data/lib/ruby_pptx/image.rb +347 -0
- data/lib/ruby_pptx/length.rb +120 -0
- data/lib/ruby_pptx/media.rb +64 -0
- data/lib/ruby_pptx/numeric_lengths.rb +30 -0
- data/lib/ruby_pptx/opc/constants.rb +205 -0
- data/lib/ruby_pptx/opc/oxml.rb +99 -0
- data/lib/ruby_pptx/opc/pack_uri.rb +146 -0
- data/lib/ruby_pptx/opc/package.rb +482 -0
- data/lib/ruby_pptx/opc/serialized.rb +229 -0
- data/lib/ruby_pptx/opc/spec.rb +37 -0
- data/lib/ruby_pptx/oxml/action.rb +43 -0
- data/lib/ruby_pptx/oxml/chart.rb +785 -0
- data/lib/ruby_pptx/oxml/content_model.rb +186 -0
- data/lib/ruby_pptx/oxml/core_properties.rb +145 -0
- data/lib/ruby_pptx/oxml/dml/color.rb +115 -0
- data/lib/ruby_pptx/oxml/dml/fill.rb +137 -0
- data/lib/ruby_pptx/oxml/element.rb +329 -0
- data/lib/ruby_pptx/oxml/ns.rb +115 -0
- data/lib/ruby_pptx/oxml/presentation.rb +110 -0
- data/lib/ruby_pptx/oxml/section.rb +65 -0
- data/lib/ruby_pptx/oxml/shapes/autoshape.rb +310 -0
- data/lib/ruby_pptx/oxml/shapes/groupshape.rb +217 -0
- data/lib/ruby_pptx/oxml/shapes/other.rb +405 -0
- data/lib/ruby_pptx/oxml/shapes/shared.rb +292 -0
- data/lib/ruby_pptx/oxml/simple_types.rb +563 -0
- data/lib/ruby_pptx/oxml/slide.rb +290 -0
- data/lib/ruby_pptx/oxml/table.rb +253 -0
- data/lib/ruby_pptx/oxml/text.rb +324 -0
- data/lib/ruby_pptx/oxml/theme.rb +93 -0
- data/lib/ruby_pptx/package.rb +139 -0
- data/lib/ruby_pptx/parts/chart.rb +75 -0
- data/lib/ruby_pptx/parts/core_properties.rb +40 -0
- data/lib/ruby_pptx/parts/embedded_package.rb +43 -0
- data/lib/ruby_pptx/parts/image.rb +55 -0
- data/lib/ruby_pptx/parts/media.rb +17 -0
- data/lib/ruby_pptx/parts/presentation.rb +79 -0
- data/lib/ruby_pptx/parts/slide.rb +221 -0
- data/lib/ruby_pptx/parts/theme.rb +26 -0
- data/lib/ruby_pptx/pattern_matching.rb +50 -0
- data/lib/ruby_pptx/presentation.rb +128 -0
- data/lib/ruby_pptx/refinements.rb +21 -0
- data/lib/ruby_pptx/section.rb +130 -0
- data/lib/ruby_pptx/shapes/adjustments.rb +83 -0
- data/lib/ruby_pptx/shapes/authoring.rb +110 -0
- data/lib/ruby_pptx/shapes/base.rb +138 -0
- data/lib/ruby_pptx/shapes/freeform.rb +141 -0
- data/lib/ruby_pptx/shapes/placeholder.rb +184 -0
- data/lib/ruby_pptx/shapes/shape.rb +337 -0
- data/lib/ruby_pptx/shapes/shape_tree.rb +634 -0
- data/lib/ruby_pptx/sliceable.rb +34 -0
- data/lib/ruby_pptx/slide.rb +430 -0
- data/lib/ruby_pptx/table.rb +316 -0
- data/lib/ruby_pptx/table_paging.rb +91 -0
- data/lib/ruby_pptx/templates/default.pptx +0 -0
- data/lib/ruby_pptx/templates/docx-icon.emf +0 -0
- data/lib/ruby_pptx/templates/generic-icon.emf +0 -0
- data/lib/ruby_pptx/templates/media-speaker.png +0 -0
- data/lib/ruby_pptx/templates/notes.xml +23 -0
- data/lib/ruby_pptx/templates/notesMaster.xml +352 -0
- data/lib/ruby_pptx/templates/pptx-icon.emf +0 -0
- data/lib/ruby_pptx/templates/slideMaster.xml +277 -0
- data/lib/ruby_pptx/templates/theme.xml +321 -0
- data/lib/ruby_pptx/templates/xlsx-icon.emf +0 -0
- data/lib/ruby_pptx/text/fitter.rb +72 -0
- data/lib/ruby_pptx/text/font_metrics.rb +221 -0
- data/lib/ruby_pptx/text/text.rb +393 -0
- data/lib/ruby_pptx/theme.rb +98 -0
- data/lib/ruby_pptx/version.rb +5 -0
- data/lib/ruby_pptx.rb +90 -0
- metadata +174 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by tools/generate_opc_constants.py from python-pptx. Do not edit by hand.
|
|
4
|
+
|
|
5
|
+
module Pptx
|
|
6
|
+
module Opc
|
|
7
|
+
module CONTENT_TYPE
|
|
8
|
+
ASF = "video/x-ms-asf"
|
|
9
|
+
AVI = "video/avi"
|
|
10
|
+
BMP = "image/bmp"
|
|
11
|
+
DML_CHART = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
|
|
12
|
+
DML_CHARTSHAPES = "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml"
|
|
13
|
+
DML_DIAGRAM_COLORS = "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml"
|
|
14
|
+
DML_DIAGRAM_DATA = "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml"
|
|
15
|
+
DML_DIAGRAM_DRAWING = "application/vnd.ms-office.drawingml.diagramDrawing+xml"
|
|
16
|
+
DML_DIAGRAM_LAYOUT = "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml"
|
|
17
|
+
DML_DIAGRAM_STYLE = "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml"
|
|
18
|
+
GIF = "image/gif"
|
|
19
|
+
INK = "application/inkml+xml"
|
|
20
|
+
JPEG = "image/jpeg"
|
|
21
|
+
MOV = "video/quicktime"
|
|
22
|
+
MP4 = "video/mp4"
|
|
23
|
+
MPG = "video/mpeg"
|
|
24
|
+
MS_PHOTO = "image/vnd.ms-photo"
|
|
25
|
+
MS_VIDEO = "video/msvideo"
|
|
26
|
+
OFC_CHART_COLORS = "application/vnd.ms-office.chartcolorstyle+xml"
|
|
27
|
+
OFC_CHART_EX = "application/vnd.ms-office.chartex+xml"
|
|
28
|
+
OFC_CHART_STYLE = "application/vnd.ms-office.chartstyle+xml"
|
|
29
|
+
OFC_CUSTOM_PROPERTIES = "application/vnd.openxmlformats-officedocument.custom-properties+xml"
|
|
30
|
+
OFC_CUSTOM_XML_PROPERTIES = "application/vnd.openxmlformats-officedocument.customXmlProperties+xml"
|
|
31
|
+
OFC_DRAWING = "application/vnd.openxmlformats-officedocument.drawing+xml"
|
|
32
|
+
OFC_EXTENDED_PROPERTIES = "application/vnd.openxmlformats-officedocument.extended-properties+xml"
|
|
33
|
+
OFC_OLE_OBJECT = "application/vnd.openxmlformats-officedocument.oleObject"
|
|
34
|
+
OFC_PACKAGE = "application/vnd.openxmlformats-officedocument.package"
|
|
35
|
+
OFC_THEME = "application/vnd.openxmlformats-officedocument.theme+xml"
|
|
36
|
+
OFC_THEME_OVERRIDE = "application/vnd.openxmlformats-officedocument.themeOverride+xml"
|
|
37
|
+
OFC_VML_DRAWING = "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
38
|
+
OPC_CORE_PROPERTIES = "application/vnd.openxmlformats-package.core-properties+xml"
|
|
39
|
+
OPC_DIGITAL_SIGNATURE_CERTIFICATE = "application/vnd.openxmlformats-package.digital-signature-certificate"
|
|
40
|
+
OPC_DIGITAL_SIGNATURE_ORIGIN = "application/vnd.openxmlformats-package.digital-signature-origin"
|
|
41
|
+
OPC_DIGITAL_SIGNATURE_XMLSIGNATURE = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
|
|
42
|
+
OPC_RELATIONSHIPS = "application/vnd.openxmlformats-package.relationships+xml"
|
|
43
|
+
PML_COMMENTS = "application/vnd.openxmlformats-officedocument.presentationml.comments+xml"
|
|
44
|
+
PML_COMMENT_AUTHORS = "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml"
|
|
45
|
+
PML_HANDOUT_MASTER = "application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml"
|
|
46
|
+
PML_NOTES_MASTER = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml"
|
|
47
|
+
PML_NOTES_SLIDE = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml"
|
|
48
|
+
PML_PRESENTATION = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
49
|
+
PML_PRESENTATION_MAIN = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"
|
|
50
|
+
PML_PRES_MACRO_MAIN = "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml"
|
|
51
|
+
PML_PRES_PROPS = "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"
|
|
52
|
+
PML_PRINTER_SETTINGS = "application/vnd.openxmlformats-officedocument.presentationml.printerSettings"
|
|
53
|
+
PML_SLIDE = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml"
|
|
54
|
+
PML_SLIDESHOW_MAIN = "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"
|
|
55
|
+
PML_SLIDE_LAYOUT = "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"
|
|
56
|
+
PML_SLIDE_MASTER = "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"
|
|
57
|
+
PML_SLIDE_UPDATE_INFO = "application/vnd.openxmlformats-officedocument.presentationml.slideUpdateInfo+xml"
|
|
58
|
+
PML_TABLE_STYLES = "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml"
|
|
59
|
+
PML_TAGS = "application/vnd.openxmlformats-officedocument.presentationml.tags+xml"
|
|
60
|
+
PML_TEMPLATE_MAIN = "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml"
|
|
61
|
+
PML_VIEW_PROPS = "application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml"
|
|
62
|
+
PNG = "image/png"
|
|
63
|
+
SML_CALC_CHAIN = "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml"
|
|
64
|
+
SML_CHARTSHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml"
|
|
65
|
+
SML_COMMENTS = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
66
|
+
SML_CONNECTIONS = "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml"
|
|
67
|
+
SML_CUSTOM_PROPERTY = "application/vnd.openxmlformats-officedocument.spreadsheetml.customProperty"
|
|
68
|
+
SML_DIALOGSHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml"
|
|
69
|
+
SML_EXTERNAL_LINK = "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"
|
|
70
|
+
SML_PIVOT_CACHE_DEFINITION = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
|
|
71
|
+
SML_PIVOT_CACHE_RECORDS = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"
|
|
72
|
+
SML_PIVOT_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
|
|
73
|
+
SML_PRINTER_SETTINGS = "application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings"
|
|
74
|
+
SML_QUERY_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml"
|
|
75
|
+
SML_REVISION_HEADERS = "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml"
|
|
76
|
+
SML_REVISION_LOG = "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml"
|
|
77
|
+
SML_SHARED_STRINGS = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
|
|
78
|
+
SML_SHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
79
|
+
SML_SHEET_MAIN = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
|
|
80
|
+
SML_SHEET_METADATA = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml"
|
|
81
|
+
SML_STYLES = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
|
|
82
|
+
SML_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
|
|
83
|
+
SML_TABLE_SINGLE_CELLS = "application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml"
|
|
84
|
+
SML_TEMPLATE_MAIN = "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
|
|
85
|
+
SML_USER_NAMES = "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml"
|
|
86
|
+
SML_VOLATILE_DEPENDENCIES = "application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml"
|
|
87
|
+
SML_WORKSHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
|
|
88
|
+
SWF = "application/x-shockwave-flash"
|
|
89
|
+
TIFF = "image/tiff"
|
|
90
|
+
VIDEO = "video/unknown"
|
|
91
|
+
WML_COMMENTS = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"
|
|
92
|
+
WML_DOCUMENT = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
93
|
+
WML_DOCUMENT_GLOSSARY = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml"
|
|
94
|
+
WML_DOCUMENT_MAIN = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
|
|
95
|
+
WML_ENDNOTES = "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"
|
|
96
|
+
WML_FONT_TABLE = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"
|
|
97
|
+
WML_FOOTER = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"
|
|
98
|
+
WML_FOOTNOTES = "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"
|
|
99
|
+
WML_HEADER = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml"
|
|
100
|
+
WML_NUMBERING = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"
|
|
101
|
+
WML_PRINTER_SETTINGS = "application/vnd.openxmlformats-officedocument.wordprocessingml.printerSettings"
|
|
102
|
+
WML_SETTINGS = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"
|
|
103
|
+
WML_STYLES = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"
|
|
104
|
+
WML_WEB_SETTINGS = "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"
|
|
105
|
+
WMV = "video/x-ms-wmv"
|
|
106
|
+
XML = "application/xml"
|
|
107
|
+
X_EMF = "image/x-emf"
|
|
108
|
+
X_FONTDATA = "application/x-fontdata"
|
|
109
|
+
X_FONT_TTF = "application/x-font-ttf"
|
|
110
|
+
X_MS_VIDEO = "video/x-msvideo"
|
|
111
|
+
X_WMF = "image/x-wmf"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
module NAMESPACE
|
|
115
|
+
DML_WORDPROCESSING_DRAWING = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
|
|
116
|
+
OFC_RELATIONSHIPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
117
|
+
OPC_CONTENT_TYPES = "http://schemas.openxmlformats.org/package/2006/content-types"
|
|
118
|
+
OPC_RELATIONSHIPS = "http://schemas.openxmlformats.org/package/2006/relationships"
|
|
119
|
+
WML_MAIN = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
module RELATIONSHIP_TARGET_MODE
|
|
123
|
+
EXTERNAL = "External"
|
|
124
|
+
INTERNAL = "Internal"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
module RELATIONSHIP_TYPE
|
|
128
|
+
AUDIO = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio"
|
|
129
|
+
A_F_CHUNK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk"
|
|
130
|
+
CALC_CHAIN = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain"
|
|
131
|
+
CERTIFICATE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate"
|
|
132
|
+
CHART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
|
|
133
|
+
CHARTSHEET = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"
|
|
134
|
+
CHART_COLOR_STYLE = "http://schemas.microsoft.com/office/2011/relationships/chartColorStyle"
|
|
135
|
+
CHART_USER_SHAPES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes"
|
|
136
|
+
COMMENTS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
|
|
137
|
+
COMMENT_AUTHORS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"
|
|
138
|
+
CONNECTIONS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections"
|
|
139
|
+
CONTROL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/control"
|
|
140
|
+
CORE_PROPERTIES = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
|
|
141
|
+
CUSTOM_PROPERTIES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"
|
|
142
|
+
CUSTOM_PROPERTY = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customProperty"
|
|
143
|
+
CUSTOM_XML = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"
|
|
144
|
+
CUSTOM_XML_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps"
|
|
145
|
+
DIAGRAM_COLORS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors"
|
|
146
|
+
DIAGRAM_DATA = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData"
|
|
147
|
+
DIAGRAM_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout"
|
|
148
|
+
DIAGRAM_QUICK_STYLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"
|
|
149
|
+
DIALOGSHEET = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet"
|
|
150
|
+
DRAWING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
|
|
151
|
+
ENDNOTES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"
|
|
152
|
+
EXTENDED_PROPERTIES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
|
|
153
|
+
EXTERNAL_LINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink"
|
|
154
|
+
FONT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font"
|
|
155
|
+
FONT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
|
|
156
|
+
FOOTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
|
|
157
|
+
FOOTNOTES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
|
|
158
|
+
GLOSSARY_DOCUMENT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"
|
|
159
|
+
HANDOUT_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster"
|
|
160
|
+
HEADER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
|
|
161
|
+
HYPERLINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
|
|
162
|
+
IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
|
|
163
|
+
MEDIA = "http://schemas.microsoft.com/office/2007/relationships/media"
|
|
164
|
+
NOTES_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"
|
|
165
|
+
NOTES_SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"
|
|
166
|
+
NUMBERING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"
|
|
167
|
+
OFFICE_DOCUMENT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
|
|
168
|
+
OLE_OBJECT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"
|
|
169
|
+
ORIGIN = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin"
|
|
170
|
+
PACKAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"
|
|
171
|
+
PIVOT_CACHE_DEFINITION = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
|
|
172
|
+
PIVOT_CACHE_RECORDS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/spreadsheetml/pivotCacheRecords"
|
|
173
|
+
PIVOT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
|
|
174
|
+
PRES_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps"
|
|
175
|
+
PRINTER_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings"
|
|
176
|
+
QUERY_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/queryTable"
|
|
177
|
+
REVISION_HEADERS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionHeaders"
|
|
178
|
+
REVISION_LOG = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionLog"
|
|
179
|
+
SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"
|
|
180
|
+
SHARED_STRINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
|
|
181
|
+
SHEET_METADATA = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata"
|
|
182
|
+
SIGNATURE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature"
|
|
183
|
+
SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
|
|
184
|
+
SLIDE_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout"
|
|
185
|
+
SLIDE_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"
|
|
186
|
+
SLIDE_UPDATE_INFO = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideUpdateInfo"
|
|
187
|
+
STYLES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
|
|
188
|
+
TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
|
|
189
|
+
TABLE_SINGLE_CELLS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells"
|
|
190
|
+
TABLE_STYLES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles"
|
|
191
|
+
TAGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tags"
|
|
192
|
+
THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
|
|
193
|
+
THEME_OVERRIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride"
|
|
194
|
+
THUMBNAIL = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"
|
|
195
|
+
USERNAMES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/usernames"
|
|
196
|
+
VIDEO = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"
|
|
197
|
+
VIEW_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps"
|
|
198
|
+
VML_DRAWING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"
|
|
199
|
+
VOLATILE_DEPENDENCIES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/volatileDependencies"
|
|
200
|
+
WEB_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"
|
|
201
|
+
WORKSHEET_SOURCE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheetSource"
|
|
202
|
+
XML_MAPS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/xmlMaps"
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ruby_pptx/oxml/element"
|
|
4
|
+
require "ruby_pptx/oxml/content_model"
|
|
5
|
+
require "ruby_pptx/oxml/simple_types"
|
|
6
|
+
require "ruby_pptx/opc/constants"
|
|
7
|
+
|
|
8
|
+
module Pptx
|
|
9
|
+
module Opc
|
|
10
|
+
# Element classes for the two XML formats the packaging layer owns:
|
|
11
|
+
# `[Content_Types].xml` and the `.rels` items.
|
|
12
|
+
module Oxml
|
|
13
|
+
ST = Pptx::Oxml::SimpleTypes
|
|
14
|
+
Element = Pptx::Oxml::Element
|
|
15
|
+
|
|
16
|
+
# Serialize a part's root element as the bytes of a `.xml` file,
|
|
17
|
+
# including the XML declaration Office expects.
|
|
18
|
+
#
|
|
19
|
+
# The declaration is written with single quotes and `standalone="yes"`
|
|
20
|
+
# to match what python-pptx (and lxml) produce, so packages compare
|
|
21
|
+
# byte-for-byte.
|
|
22
|
+
def self.serialize_part_xml(element)
|
|
23
|
+
node = element.is_a?(Element) ? element.node : element
|
|
24
|
+
body = node.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML |
|
|
25
|
+
Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
|
|
26
|
+
%(<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n#{body})
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# `<Default>`: the content type for every part with a given extension.
|
|
30
|
+
class CT_Default < Element
|
|
31
|
+
tag "ct:Default"
|
|
32
|
+
required_attr "Extension", type: ST::ST_Extension, as: :extension
|
|
33
|
+
required_attr "ContentType", type: ST::ST_ContentType, as: :contentType
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# `<Override>`: the content type for one specific part.
|
|
37
|
+
class CT_Override < Element
|
|
38
|
+
tag "ct:Override"
|
|
39
|
+
required_attr "PartName", type: ST::XsdAnyUri, as: :partName
|
|
40
|
+
required_attr "ContentType", type: ST::ST_ContentType, as: :contentType
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# `<Types>`, the root of `[Content_Types].xml`.
|
|
44
|
+
class CT_Types < Element
|
|
45
|
+
tag "ct:Types"
|
|
46
|
+
zero_or_more "ct:Default", as: :default
|
|
47
|
+
zero_or_more "ct:Override", as: :override
|
|
48
|
+
|
|
49
|
+
def self.new_element
|
|
50
|
+
Element.parse(%(<Types xmlns="#{NAMESPACE::OPC_CONTENT_TYPES}"/>))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Named `*_for` rather than `add_default` / `add_override`: those names
|
|
54
|
+
# belong to the accessors the content-model macros generate.
|
|
55
|
+
def add_default_for(ext, content_type)
|
|
56
|
+
add_default(extension: ext, contentType: content_type)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def add_override_for(partname, content_type)
|
|
60
|
+
add_override(partName: partname.to_s, contentType: content_type)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# `<Relationship>`: one link from a part (or the package) to a target.
|
|
65
|
+
class CT_Relationship < Element
|
|
66
|
+
tag "pr:Relationship"
|
|
67
|
+
required_attr "Id", type: ST::XsdId, as: :rId
|
|
68
|
+
required_attr "Type", type: ST::XsdAnyUri, as: :reltype
|
|
69
|
+
required_attr "Target", type: ST::XsdAnyUri, as: :target_ref
|
|
70
|
+
optional_attr "TargetMode", type: ST::ST_TargetMode,
|
|
71
|
+
default: RELATIONSHIP_TARGET_MODE::INTERNAL, as: :targetMode
|
|
72
|
+
|
|
73
|
+
def external? = targetMode == RELATIONSHIP_TARGET_MODE::EXTERNAL
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# `<Relationships>`, the root of a `.rels` item.
|
|
77
|
+
class CT_Relationships < Element
|
|
78
|
+
tag "pr:Relationships"
|
|
79
|
+
zero_or_more "pr:Relationship", as: :relationship
|
|
80
|
+
|
|
81
|
+
def self.new_element
|
|
82
|
+
Element.parse(%(<Relationships xmlns="#{NAMESPACE::OPC_RELATIONSHIPS}"/>))
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def add_rel(r_id, reltype, target, is_external: false)
|
|
86
|
+
target_mode = if is_external
|
|
87
|
+
RELATIONSHIP_TARGET_MODE::EXTERNAL
|
|
88
|
+
else
|
|
89
|
+
RELATIONSHIP_TARGET_MODE::INTERNAL
|
|
90
|
+
end
|
|
91
|
+
add_relationship(rId: r_id, reltype: reltype, target_ref: target, targetMode: target_mode)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Bytes for a `.rels` item, with the XML declaration.
|
|
95
|
+
def xml_file_bytes = Oxml.serialize_part_xml(self)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pptx
|
|
4
|
+
module Opc
|
|
5
|
+
# An absolute part name within an OPC package, e.g. "/ppt/slides/slide1.xml".
|
|
6
|
+
#
|
|
7
|
+
# Part names are always rooted at "/" and are *not* filesystem paths: they
|
|
8
|
+
# are normalised purely lexically, with no reference to the working
|
|
9
|
+
# directory or to `~`. The package itself has the pseudo part name "/".
|
|
10
|
+
class PackURI
|
|
11
|
+
include Comparable
|
|
12
|
+
|
|
13
|
+
# Splits a filename stem into its name and optional trailing index, e.g.
|
|
14
|
+
# "slide21" => ["slide", "21"].
|
|
15
|
+
FILENAME_RE = /\A([a-zA-Z]+)([0-9]+)?/
|
|
16
|
+
|
|
17
|
+
# Resolve +relative_ref+ (as found in a .rels part) against +base_uri+.
|
|
18
|
+
#
|
|
19
|
+
# PackURI.from_rel_ref("/ppt", "slides/slide1.xml") #=> "/ppt/slides/slide1.xml"
|
|
20
|
+
# PackURI.from_rel_ref("/ppt/slides", "../media/image1.png") #=> "/ppt/media/image1.png"
|
|
21
|
+
def self.from_rel_ref(base_uri, relative_ref)
|
|
22
|
+
new(normalize(join(base_uri, relative_ref)))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Lexically join path segments with "/", ignoring a leading "/" on later
|
|
26
|
+
# segments the way posixpath.join does not -- we only ever join a base
|
|
27
|
+
# with a genuinely relative reference.
|
|
28
|
+
def self.join(*parts)
|
|
29
|
+
parts.reject { |p| p.nil? || p.empty? }
|
|
30
|
+
.each_with_index
|
|
31
|
+
.map { |p, i| i.zero? ? p.chomp("/") : p }
|
|
32
|
+
.join("/")
|
|
33
|
+
end
|
|
34
|
+
private_class_method :join
|
|
35
|
+
|
|
36
|
+
# Collapse "." and ".." segments. Leading ".." on an absolute path are
|
|
37
|
+
# dropped, matching posixpath.abspath.
|
|
38
|
+
def self.normalize(path)
|
|
39
|
+
absolute = path.start_with?("/")
|
|
40
|
+
segments = path.split("/").each_with_object([]) do |seg, acc|
|
|
41
|
+
case seg
|
|
42
|
+
when "", "." then next
|
|
43
|
+
when ".."
|
|
44
|
+
if acc.empty? || acc.last == ".."
|
|
45
|
+
acc.push(seg) unless absolute
|
|
46
|
+
else
|
|
47
|
+
acc.pop
|
|
48
|
+
end
|
|
49
|
+
else acc.push(seg)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
absolute ? "/#{segments.join("/")}" : segments.join("/")
|
|
53
|
+
end
|
|
54
|
+
private_class_method :normalize
|
|
55
|
+
|
|
56
|
+
# @return [String] the full part name, e.g. "/ppt/slides/slide1.xml"
|
|
57
|
+
attr_reader :to_s
|
|
58
|
+
|
|
59
|
+
def initialize(pack_uri_str)
|
|
60
|
+
pack_uri_str = pack_uri_str.to_s
|
|
61
|
+
unless pack_uri_str.start_with?("/")
|
|
62
|
+
raise ArgumentError, "PackURI must begin with a slash, got #{pack_uri_str.inspect}"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
@to_s = pack_uri_str.freeze
|
|
66
|
+
freeze
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# The directory portion, e.g. "/ppt/slides" for "/ppt/slides/slide1.xml".
|
|
70
|
+
# The package pseudo part name "/" has itself as its base URI.
|
|
71
|
+
def base_uri
|
|
72
|
+
idx = @to_s.rindex("/")
|
|
73
|
+
idx.zero? ? "/" : @to_s[0...idx]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# The extension without its leading period, e.g. "xml". Empty when there
|
|
77
|
+
# is none.
|
|
78
|
+
def ext
|
|
79
|
+
File.extname(filename).delete_prefix(".")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# The last segment, e.g. "slide1.xml". Empty for the package itself.
|
|
83
|
+
def filename
|
|
84
|
+
@to_s[(@to_s.rindex("/") + 1)..]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# The integer suffix of an "array" part name, e.g. 21 for
|
|
88
|
+
# "/ppt/slides/slide21.xml"; nil for a singleton such as
|
|
89
|
+
# "/ppt/presentation.xml".
|
|
90
|
+
#
|
|
91
|
+
# @return [Integer, nil]
|
|
92
|
+
def idx
|
|
93
|
+
stem = File.basename(filename, ".*")
|
|
94
|
+
return nil if stem.empty?
|
|
95
|
+
|
|
96
|
+
match = FILENAME_RE.match(stem)
|
|
97
|
+
match && match[2] && Integer(match[2], 10)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# The part name without its leading slash -- the form used as the Zip
|
|
101
|
+
# entry name.
|
|
102
|
+
def member_name = @to_s[1..]
|
|
103
|
+
|
|
104
|
+
# A reference to this part relative to +base_uri+, as written into a
|
|
105
|
+
# .rels part.
|
|
106
|
+
#
|
|
107
|
+
# PackURI.new("/ppt/slideLayouts/slideLayout1.xml").relative_ref("/ppt/slides")
|
|
108
|
+
# #=> "../slideLayouts/slideLayout1.xml"
|
|
109
|
+
def relative_ref(base_uri)
|
|
110
|
+
return member_name if base_uri == "/"
|
|
111
|
+
|
|
112
|
+
from = base_uri.split("/").reject(&:empty?)
|
|
113
|
+
to = @to_s.split("/").reject(&:empty?)
|
|
114
|
+
common = 0
|
|
115
|
+
common += 1 while common < from.length && common < to.length && from[common] == to[common]
|
|
116
|
+
(([".."] * (from.length - common)) + to[common..]).join("/")
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# The part name of the .rels part describing this part's relationships.
|
|
120
|
+
#
|
|
121
|
+
# PackURI.new("/ppt/presentation.xml").rels_uri #=> "/ppt/_rels/presentation.xml.rels"
|
|
122
|
+
def rels_uri
|
|
123
|
+
PackURI.new(self.class.send(:join, base_uri, "_rels", "#{filename}.rels"))
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def <=>(other)
|
|
127
|
+
other = PackURI.new(other) if other.is_a?(String)
|
|
128
|
+
return nil unless other.is_a?(PackURI)
|
|
129
|
+
|
|
130
|
+
@to_s <=> other.to_s
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def ==(other) = (self <=> other)&.zero? || false
|
|
134
|
+
alias eql? ==
|
|
135
|
+
|
|
136
|
+
def hash = @to_s.hash
|
|
137
|
+
|
|
138
|
+
def to_str = @to_s
|
|
139
|
+
|
|
140
|
+
def inspect = "#<Pptx::Opc::PackURI #{@to_s.inspect}>"
|
|
141
|
+
|
|
142
|
+
PACKAGE = new("/")
|
|
143
|
+
CONTENT_TYPES = new("/[Content_Types].xml")
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|