docxi 0.0.1

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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +119 -0
  4. data/Rakefile +10 -0
  5. data/lib/docxer.rb +29 -0
  6. data/lib/docxer/content_types.rb +68 -0
  7. data/lib/docxer/content_types/default.rb +18 -0
  8. data/lib/docxer/content_types/override.rb +18 -0
  9. data/lib/docxer/document.rb +36 -0
  10. data/lib/docxer/properties.rb +29 -0
  11. data/lib/docxer/properties/app.rb +37 -0
  12. data/lib/docxer/properties/core.rb +32 -0
  13. data/lib/docxer/relationships.rb +49 -0
  14. data/lib/docxer/relationships/relationship.rb +19 -0
  15. data/lib/docxer/version.rb +3 -0
  16. data/lib/docxer/word.rb +16 -0
  17. data/lib/docxer/word/contents.rb +6 -0
  18. data/lib/docxer/word/contents/break.rb +33 -0
  19. data/lib/docxer/word/contents/image.rb +38 -0
  20. data/lib/docxer/word/contents/paragraph.rb +59 -0
  21. data/lib/docxer/word/contents/table.rb +223 -0
  22. data/lib/docxer/word/contents/table_of_content.rb +75 -0
  23. data/lib/docxer/word/contents/text.rb +34 -0
  24. data/lib/docxer/word/document.rb +144 -0
  25. data/lib/docxer/word/effects.rb +210 -0
  26. data/lib/docxer/word/endnotes.rb +39 -0
  27. data/lib/docxer/word/fonts.rb +42 -0
  28. data/lib/docxer/word/fonts/font.rb +25 -0
  29. data/lib/docxer/word/footers.rb +30 -0
  30. data/lib/docxer/word/footers/footer.rb +118 -0
  31. data/lib/docxer/word/footnotes.rb +40 -0
  32. data/lib/docxer/word/headers.rb +30 -0
  33. data/lib/docxer/word/headers/header.rb +142 -0
  34. data/lib/docxer/word/helpers.rb +37 -0
  35. data/lib/docxer/word/medias.rb +31 -0
  36. data/lib/docxer/word/medias/media.rb +37 -0
  37. data/lib/docxer/word/numbering.rb +141 -0
  38. data/lib/docxer/word/relationships.rb +57 -0
  39. data/lib/docxer/word/relationships/relationship.rb +21 -0
  40. data/lib/docxer/word/settings.rb +61 -0
  41. data/lib/docxer/word/styles.rb +235 -0
  42. data/lib/docxer/word/themes.rb +30 -0
  43. data/lib/docxer/word/themes/theme.rb +313 -0
  44. data/lib/docxer/word/web_settings.rb +29 -0
  45. metadata +120 -0
@@ -0,0 +1,34 @@
1
+ module Docxer
2
+ module Word
3
+ module Contents
4
+
5
+ class Text
6
+
7
+ attr_accessor :text, :options
8
+ def initialize(text, options={})
9
+ @text = text
10
+ @options = options
11
+ end
12
+
13
+ def render(xml)
14
+ if !@text.nil?
15
+ xml['w'].r do
16
+ xml['w'].rPr do
17
+ xml['w'].b if @options[:bold]
18
+ xml['w'].i if @options[:italic]
19
+ xml['w'].u( 'w:val' => "single" ) if options[:underline]
20
+ xml['w'].color( 'w:val' => @options[:color] ) if @options[:color]
21
+ xml['w'].sz( 'w:val' => @options[:size].to_i * 2 ) if @options[:size]
22
+ end
23
+ xml['w'].t @text
24
+ end
25
+ if options[:br]
26
+ br = Docxer::Word::Contents::Break.new
27
+ br.render(xml)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,144 @@
1
+ module Docxer
2
+ module Word
3
+ class Document
4
+
5
+ include Helpers
6
+
7
+ attr_accessor :options, :fonts, :setings, :styles, :numbering, :effects, :web_settings, :themes, :relationships, :footnotes, :endnotes, :footers, :headers
8
+
9
+ def initialize(options)
10
+ @options = options
11
+ @content = []
12
+ end
13
+
14
+ def add_media(file, options={})
15
+ media = Medias::Media.new(medias.sequence, file, options)
16
+ rel = relationships.add(media.content_type, media.target)
17
+ media.set_sequence(rel.id)
18
+ medias.add(media)
19
+ end
20
+
21
+ def add_footer(footer, options={})
22
+ footer.id = footers.sequence
23
+ rel = relationships.add(footer.content_type, footer.target)
24
+ footer.sequence = rel.id
25
+ footers.add(footer)
26
+ @footer = footer
27
+ end
28
+
29
+ def add_header(header, options={})
30
+ header.id = headers.sequence
31
+ rel = relationships.add(header.content_type, header.target)
32
+ header.sequence = rel.id
33
+ headers.add(header)
34
+ @header = header
35
+ end
36
+
37
+ def fonts
38
+ @fonts ||= Fonts.new
39
+ end
40
+
41
+ def settings
42
+ @settings ||= Settings.new
43
+ end
44
+
45
+ def styles
46
+ @styles ||= Styles.new
47
+ end
48
+
49
+ def numbering
50
+ @numbering ||= Numbering.new
51
+ end
52
+
53
+ def effects
54
+ @effects ||= Effects.new
55
+ end
56
+
57
+ def web_settings
58
+ @web_settings ||= WebSettings.new({})
59
+ end
60
+
61
+ def themes
62
+ @themes ||= Themes.new
63
+ end
64
+
65
+ def medias
66
+ @medias ||= Medias.new
67
+ end
68
+
69
+ def relationships
70
+ @relationships ||= Relationships.new
71
+ end
72
+
73
+ def footnotes
74
+ @footnotes ||= Footnotes.new
75
+ end
76
+
77
+ def endnotes
78
+ @endnotes ||= Endnotes.new
79
+ end
80
+
81
+ def footers
82
+ @footers ||= Footers.new
83
+ end
84
+
85
+ def headers
86
+ @headers ||= Headers.new
87
+ end
88
+
89
+ def render(zip)
90
+ zip.put_next_entry('word/document.xml')
91
+ zip.write(Docxer.to_xml(document))
92
+
93
+ fonts.render(zip)
94
+ settings.render(zip)
95
+ styles.render(zip)
96
+ effects.render(zip)
97
+ numbering.render(zip)
98
+ web_settings.render(zip)
99
+ themes.render(zip)
100
+ footnotes.render(zip)
101
+ endnotes.render(zip)
102
+ headers.render(zip)
103
+ footers.render(zip)
104
+ medias.render(zip)
105
+ relationships.render(zip)
106
+ end
107
+
108
+ private
109
+ def document
110
+ Nokogiri::XML::Builder.with(Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')) do |xml|
111
+ xml.document('xmlns:wpc' => "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", 'xmlns:mc' => "http://schemas.openxmlformats.org/markup-compatibility/2006", 'xmlns:o' => "urn:schemas-microsoft-com:office:office", 'xmlns:r' => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", 'xmlns:m' => "http://schemas.openxmlformats.org/officeDocument/2006/math", 'xmlns:v' => "urn:schemas-microsoft-com:vml", 'xmlns:wp14' => "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", 'xmlns:wp' => "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", 'xmlns:w10' => "urn:schemas-microsoft-com:office:word", 'xmlns:w' => "http://schemas.openxmlformats.org/wordprocessingml/2006/main", 'xmlns:w14' => "http://schemas.microsoft.com/office/word/2010/wordml", 'xmlns:wpg' => "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", 'xmlns:wpi' => "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", 'xmlns:wne' => "http://schemas.microsoft.com/office/word/2006/wordml", 'xmlns:wps' => "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", 'mc:Ignorable' => "w14 wp14") do
112
+ xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "w" }
113
+
114
+ xml['w'].body do
115
+
116
+ content.each do |element|
117
+ element.render(xml)
118
+ end
119
+
120
+ xml['w'].p do
121
+ xml['w'].bookmarkStart( 'w:id' => "0", 'w:name' => "_GoBack")
122
+ xml['w'].bookmarkEnd('w:id' => "0")
123
+ end
124
+ xml['w'].sectPr do
125
+ xml['w'].footerReference( 'w:type' => "default", 'r:id' => @footer.sequence ) if @footer
126
+ xml['w'].headerReference( 'w:type' => "default", 'r:id' => @header.sequence ) if @header
127
+ xml['w'].titlePg
128
+ xml['w'].pgSz( 'w:w' => 12240, 'w:h' => 15840 )
129
+ xml['w'].pgMar( 'w:top' => 800, 'w:right' => 940, 'w:bottom' => 1000, 'w:left' => 940, 'w:header' => 190, 'w:footer' => 200, 'w:gutter' => 0)
130
+ xml['w'].cols( 'w:space' => 720)
131
+ xml['w'].docGrid( 'w:linePitch' => "360")
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ def content
139
+ @content
140
+ end
141
+
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,210 @@
1
+ module Docxer
2
+ module Word
3
+ class Effects
4
+
5
+ attr_accessor :options
6
+ def initialize(options={})
7
+ @options = options
8
+ end
9
+
10
+ def render(zip)
11
+ zip.put_next_entry('word/stylesWithEffects.xml')
12
+ zip.write(Docxer.to_xml(document))
13
+ end
14
+
15
+ private
16
+ def document
17
+ Nokogiri::XML::Builder.with(Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')) do |xml|
18
+ xml.styles( 'xmlns:wpc' => "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", 'xmlns:mc' => "http://schemas.openxmlformats.org/markup-compatibility/2006", 'xmlns:o' => "urn:schemas-microsoft-com:office:office", 'xmlns:r' => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", 'xmlns:m' => "http://schemas.openxmlformats.org/officeDocument/2006/math", 'xmlns:v' => "urn:schemas-microsoft-com:vml", 'xmlns:wp14' => "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", 'xmlns:wp' => "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", 'xmlns:w10' => "urn:schemas-microsoft-com:office:word", 'xmlns:w' => "http://schemas.openxmlformats.org/wordprocessingml/2006/main", 'xmlns:w14' => "http://schemas.microsoft.com/office/word/2010/wordml", 'xmlns:wpg' => "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", 'xmlns:wpi' => "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", 'xmlns:wne' => "http://schemas.microsoft.com/office/word/2006/wordml", 'xmlns:wps' => "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", 'mc:Ignorable' => "w14 wp14") do
19
+ xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "w" }
20
+ xml['w'].docDefaults do
21
+ xml['w'].rPrDefault do
22
+ xml['w'].rPr do
23
+ xml['w'].rFonts( 'w:asciiTheme' => "minorHAnsi", 'w:eastAsiaTheme' => "minorHAnsi", 'w:hAnsiTheme' => "minorHAnsi", 'w:cstheme' => "minorBidi")
24
+ xml['w'].sz( 'w:val' => "22")
25
+ xml['w'].szCs( 'w:val' => "22" )
26
+ xml['w'].lang( 'w:val' => "en-US", 'w:eastAsia' => "en-US", 'w:bidi' => "ar-SA" )
27
+ end
28
+ end
29
+ xml['w'].pPrDefault do
30
+ xml['w'].pPr do
31
+ xml['w'].spacing( 'w:after' => "200", 'w:line' => "276", 'w:lineRule' => "auto" )
32
+ end
33
+ end
34
+ end
35
+ xml['w'].latentStyles( 'w:defLockedState' => "0", 'w:defUIPriority' => "99", 'w:defSemiHidden' => "1", 'w:defUnhideWhenUsed' => "1", 'w:defQFormat' => "0", 'w:count' => "267") do
36
+ xml['w'].lsdException( 'w:name' => "Normal", 'w:semiHidden' => "0", 'w:uiPriority' => "0", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
37
+ xml['w'].lsdException( 'w:name' => "heading 1", 'w:semiHidden' => "0", 'w:uiPriority' => "9", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
38
+ xml['w'].lsdException( 'w:name' => "heading 2", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
39
+ xml['w'].lsdException( 'w:name' => "heading 3", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
40
+ xml['w'].lsdException( 'w:name' => "heading 4", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
41
+ xml['w'].lsdException( 'w:name' => "heading 5", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
42
+ xml['w'].lsdException( 'w:name' => "heading 6", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
43
+ xml['w'].lsdException( 'w:name' => "heading 7", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
44
+ xml['w'].lsdException( 'w:name' => "heading 8", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
45
+ xml['w'].lsdException( 'w:name' => "heading 9", 'w:uiPriority' => "9", 'w:qFormat' => "1" )
46
+ xml['w'].lsdException( 'w:name' => "toc 1", 'w:uiPriority' => "39" )
47
+ xml['w'].lsdException( 'w:name' => "toc 2", 'w:uiPriority' => "39" )
48
+ xml['w'].lsdException( 'w:name' => "toc 3", 'w:uiPriority' => "39" )
49
+ xml['w'].lsdException( 'w:name' => "toc 4", 'w:uiPriority' => "39" )
50
+ xml['w'].lsdException( 'w:name' => "toc 5", 'w:uiPriority' => "39" )
51
+ xml['w'].lsdException( 'w:name' => "toc 6", 'w:uiPriority' => "39" )
52
+ xml['w'].lsdException( 'w:name' => "toc 7", 'w:uiPriority' => "39" )
53
+ xml['w'].lsdException( 'w:name' => "toc 8", 'w:uiPriority' => "39" )
54
+ xml['w'].lsdException( 'w:name' => "toc 9", 'w:uiPriority' => "39" )
55
+ xml['w'].lsdException( 'w:name' => "caption", 'w:uiPriority' => "35", 'w:qFormat' => "1" )
56
+ xml['w'].lsdException( 'w:name' => "Title", 'w:semiHidden' => "0", 'w:uiPriority' => "10", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
57
+ xml['w'].lsdException( 'w:name' => "Default Paragraph Font", 'w:uiPriority' => "1" )
58
+ xml['w'].lsdException( 'w:name' => "Subtitle", 'w:semiHidden' => "0", 'w:uiPriority' => "11", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
59
+ xml['w'].lsdException( 'w:name' => "Strong", 'w:semiHidden' => "0", 'w:uiPriority' => "22", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
60
+ xml['w'].lsdException( 'w:name' => "Emphasis", 'w:semiHidden' => "0", 'w:uiPriority' => "20", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
61
+ xml['w'].lsdException( 'w:name' => "Table Grid", 'w:semiHidden' => "0", 'w:uiPriority' => "59", 'w:unhideWhenUsed' => "0" )
62
+ xml['w'].lsdException( 'w:name' => "Placeholder Text", 'w:unhideWhenUsed' => "0" )
63
+ xml['w'].lsdException( 'w:name' => "No Spacing", 'w:semiHidden' => "0", 'w:uiPriority' => "1", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
64
+ xml['w'].lsdException( 'w:name' => "Light Shading", 'w:semiHidden' => "0", 'w:uiPriority' => "60", 'w:unhideWhenUsed' => "0" )
65
+ xml['w'].lsdException( 'w:name' => "Light List", 'w:semiHidden' => "0", 'w:uiPriority' => "61", 'w:unhideWhenUsed' => "0" )
66
+ xml['w'].lsdException( 'w:name' => "Light Grid", 'w:semiHidden' => "0", 'w:uiPriority' => "62", 'w:unhideWhenUsed' => "0" )
67
+ xml['w'].lsdException( 'w:name' => "Medium Shading 1", 'w:semiHidden' => "0", 'w:uiPriority' => "63", 'w:unhideWhenUsed' => "0" )
68
+ xml['w'].lsdException( 'w:name' => "Medium Shading 2", 'w:semiHidden' => "0", 'w:uiPriority' => "64", 'w:unhideWhenUsed' => "0" )
69
+ xml['w'].lsdException( 'w:name' => "Medium List 1", 'w:semiHidden' => "0", 'w:uiPriority' => "65", 'w:unhideWhenUsed' => "0" )
70
+ xml['w'].lsdException( 'w:name' => "Medium List 2", 'w:semiHidden' => "0", 'w:uiPriority' => "66", 'w:unhideWhenUsed' => "0" )
71
+ xml['w'].lsdException( 'w:name' => "Medium Grid 1", 'w:semiHidden' => "0", 'w:uiPriority' => "67", 'w:unhideWhenUsed' => "0" )
72
+ xml['w'].lsdException( 'w:name' => "Medium Grid 2", 'w:semiHidden' => "0", 'w:uiPriority' => "68", 'w:unhideWhenUsed' => "0" )
73
+ xml['w'].lsdException( 'w:name' => "Medium Grid 3", 'w:semiHidden' => "0", 'w:uiPriority' => "69", 'w:unhideWhenUsed' => "0" )
74
+ xml['w'].lsdException( 'w:name' => "Dark List", 'w:semiHidden' => "0", 'w:uiPriority' => "70", 'w:unhideWhenUsed' => "0" )
75
+ xml['w'].lsdException( 'w:name' => "Colorful Shading", 'w:semiHidden' => "0", 'w:uiPriority' => "71", 'w:unhideWhenUsed' => "0" )
76
+ xml['w'].lsdException( 'w:name' => "Colorful List", 'w:semiHidden' => "0", 'w:uiPriority' => "72", 'w:unhideWhenUsed' => "0" )
77
+ xml['w'].lsdException( 'w:name' => "Colorful Grid", 'w:semiHidden' => "0", 'w:uiPriority' => "73", 'w:unhideWhenUsed' => "0" )
78
+ xml['w'].lsdException( 'w:name' => "Light Shading Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "60", 'w:unhideWhenUsed' => "0" )
79
+ xml['w'].lsdException( 'w:name' => "Light List Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "61", 'w:unhideWhenUsed' => "0" )
80
+ xml['w'].lsdException( 'w:name' => "Light Grid Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "62", 'w:unhideWhenUsed' => "0" )
81
+ xml['w'].lsdException( 'w:name' => "Medium Shading 1 Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "63", 'w:unhideWhenUsed' => "0" )
82
+ xml['w'].lsdException( 'w:name' => "Medium Shading 2 Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "64", 'w:unhideWhenUsed' => "0" )
83
+ xml['w'].lsdException( 'w:name' => "Medium List 1 Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "65", 'w:unhideWhenUsed' => "0" )
84
+ xml['w'].lsdException( 'w:name' => "Revision", 'w:unhideWhenUsed' => "0" )
85
+ xml['w'].lsdException( 'w:name' => "List Paragraph", 'w:semiHidden' => "0", 'w:uiPriority' => "34", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
86
+ xml['w'].lsdException( 'w:name' => "Quote", 'w:semiHidden' => "0", 'w:uiPriority' => "29", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
87
+ xml['w'].lsdException( 'w:name' => "Intense Quote", 'w:semiHidden' => "0", 'w:uiPriority' => "30", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
88
+ xml['w'].lsdException( 'w:name' => "Medium List 2 Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "66", 'w:unhideWhenUsed' => "0" )
89
+ xml['w'].lsdException( 'w:name' => "Medium Grid 1 Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "67", 'w:unhideWhenUsed' => "0" )
90
+ xml['w'].lsdException( 'w:name' => "Medium Grid 2 Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "68", 'w:unhideWhenUsed' => "0" )
91
+ xml['w'].lsdException( 'w:name' => "Medium Grid 3 Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "69", 'w:unhideWhenUsed' => "0" )
92
+ xml['w'].lsdException( 'w:name' => "Dark List Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "70", 'w:unhideWhenUsed' => "0" )
93
+ xml['w'].lsdException( 'w:name' => "Colorful Shading Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "71", 'w:unhideWhenUsed' => "0" )
94
+ xml['w'].lsdException( 'w:name' => "Colorful List Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "72", 'w:unhideWhenUsed' => "0" )
95
+ xml['w'].lsdException( 'w:name' => "Colorful Grid Accent 1", 'w:semiHidden' => "0", 'w:uiPriority' => "73", 'w:unhideWhenUsed' => "0" )
96
+ xml['w'].lsdException( 'w:name' => "Light Shading Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "60", 'w:unhideWhenUsed' => "0" )
97
+ xml['w'].lsdException( 'w:name' => "Light List Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "61", 'w:unhideWhenUsed' => "0" )
98
+ xml['w'].lsdException( 'w:name' => "Light Grid Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "62", 'w:unhideWhenUsed' => "0" )
99
+ xml['w'].lsdException( 'w:name' => "Medium Shading 1 Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "63", 'w:unhideWhenUsed' => "0" )
100
+ xml['w'].lsdException( 'w:name' => "Medium Shading 2 Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "64", 'w:unhideWhenUsed' => "0" )
101
+ xml['w'].lsdException( 'w:name' => "Medium List 1 Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "65", 'w:unhideWhenUsed' => "0" )
102
+ xml['w'].lsdException( 'w:name' => "Medium List 2 Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "66", 'w:unhideWhenUsed' => "0" )
103
+ xml['w'].lsdException( 'w:name' => "Medium Grid 1 Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "67", 'w:unhideWhenUsed' => "0" )
104
+ xml['w'].lsdException( 'w:name' => "Medium Grid 2 Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "68", 'w:unhideWhenUsed' => "0" )
105
+ xml['w'].lsdException( 'w:name' => "Medium Grid 3 Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "69", 'w:unhideWhenUsed' => "0" )
106
+ xml['w'].lsdException( 'w:name' => "Dark List Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "70", 'w:unhideWhenUsed' => "0" )
107
+ xml['w'].lsdException( 'w:name' => "Colorful Shading Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "71", 'w:unhideWhenUsed' => "0" )
108
+ xml['w'].lsdException( 'w:name' => "Colorful List Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "72", 'w:unhideWhenUsed' => "0" )
109
+ xml['w'].lsdException( 'w:name' => "Colorful Grid Accent 2", 'w:semiHidden' => "0", 'w:uiPriority' => "73", 'w:unhideWhenUsed' => "0" )
110
+ xml['w'].lsdException( 'w:name' => "Light Shading Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "60", 'w:unhideWhenUsed' => "0" )
111
+ xml['w'].lsdException( 'w:name' => "Light List Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "61", 'w:unhideWhenUsed' => "0" )
112
+ xml['w'].lsdException( 'w:name' => "Light Grid Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "62", 'w:unhideWhenUsed' => "0" )
113
+ xml['w'].lsdException( 'w:name' => "Medium Shading 1 Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "63", 'w:unhideWhenUsed' => "0" )
114
+ xml['w'].lsdException( 'w:name' => "Medium Shading 2 Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "64", 'w:unhideWhenUsed' => "0" )
115
+ xml['w'].lsdException( 'w:name' => "Medium List 1 Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "65", 'w:unhideWhenUsed' => "0" )
116
+ xml['w'].lsdException( 'w:name' => "Medium List 2 Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "66", 'w:unhideWhenUsed' => "0" )
117
+ xml['w'].lsdException( 'w:name' => "Medium Grid 1 Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "67", 'w:unhideWhenUsed' => "0" )
118
+ xml['w'].lsdException( 'w:name' => "Medium Grid 2 Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "68", 'w:unhideWhenUsed' => "0" )
119
+ xml['w'].lsdException( 'w:name' => "Medium Grid 3 Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "69", 'w:unhideWhenUsed' => "0" )
120
+ xml['w'].lsdException( 'w:name' => "Dark List Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "70", 'w:unhideWhenUsed' => "0" )
121
+ xml['w'].lsdException( 'w:name' => "Colorful Shading Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "71", 'w:unhideWhenUsed' => "0" )
122
+ xml['w'].lsdException( 'w:name' => "Colorful List Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "72", 'w:unhideWhenUsed' => "0" )
123
+ xml['w'].lsdException( 'w:name' => "Colorful Grid Accent 3", 'w:semiHidden' => "0", 'w:uiPriority' => "73", 'w:unhideWhenUsed' => "0" )
124
+ xml['w'].lsdException( 'w:name' => "Light Shading Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "60", 'w:unhideWhenUsed' => "0" )
125
+ xml['w'].lsdException( 'w:name' => "Light List Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "61", 'w:unhideWhenUsed' => "0" )
126
+ xml['w'].lsdException( 'w:name' => "Light Grid Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "62", 'w:unhideWhenUsed' => "0" )
127
+ xml['w'].lsdException( 'w:name' => "Medium Shading 1 Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "63", 'w:unhideWhenUsed' => "0" )
128
+ xml['w'].lsdException( 'w:name' => "Medium Shading 2 Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "64", 'w:unhideWhenUsed' => "0" )
129
+ xml['w'].lsdException( 'w:name' => "Medium List 1 Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "65", 'w:unhideWhenUsed' => "0" )
130
+ xml['w'].lsdException( 'w:name' => "Medium List 2 Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "66", 'w:unhideWhenUsed' => "0" )
131
+ xml['w'].lsdException( 'w:name' => "Medium Grid 1 Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "67", 'w:unhideWhenUsed' => "0" )
132
+ xml['w'].lsdException( 'w:name' => "Medium Grid 2 Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "68", 'w:unhideWhenUsed' => "0" )
133
+ xml['w'].lsdException( 'w:name' => "Medium Grid 3 Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "69", 'w:unhideWhenUsed' => "0" )
134
+ xml['w'].lsdException( 'w:name' => "Dark List Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "70", 'w:unhideWhenUsed' => "0" )
135
+ xml['w'].lsdException( 'w:name' => "Colorful Shading Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "71", 'w:unhideWhenUsed' => "0" )
136
+ xml['w'].lsdException( 'w:name' => "Colorful List Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "72", 'w:unhideWhenUsed' => "0" )
137
+ xml['w'].lsdException( 'w:name' => "Colorful Grid Accent 4", 'w:semiHidden' => "0", 'w:uiPriority' => "73", 'w:unhideWhenUsed' => "0" )
138
+ xml['w'].lsdException( 'w:name' => "Light Shading Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "60", 'w:unhideWhenUsed' => "0" )
139
+ xml['w'].lsdException( 'w:name' => "Light List Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "61", 'w:unhideWhenUsed' => "0" )
140
+ xml['w'].lsdException( 'w:name' => "Light Grid Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "62", 'w:unhideWhenUsed' => "0" )
141
+ xml['w'].lsdException( 'w:name' => "Medium Shading 1 Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "63", 'w:unhideWhenUsed' => "0" )
142
+ xml['w'].lsdException( 'w:name' => "Medium Shading 2 Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "64", 'w:unhideWhenUsed' => "0" )
143
+ xml['w'].lsdException( 'w:name' => "Medium List 1 Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "65", 'w:unhideWhenUsed' => "0" )
144
+ xml['w'].lsdException( 'w:name' => "Medium List 2 Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "66", 'w:unhideWhenUsed' => "0" )
145
+ xml['w'].lsdException( 'w:name' => "Medium Grid 1 Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "67", 'w:unhideWhenUsed' => "0" )
146
+ xml['w'].lsdException( 'w:name' => "Medium Grid 2 Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "68", 'w:unhideWhenUsed' => "0" )
147
+ xml['w'].lsdException( 'w:name' => "Medium Grid 3 Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "69", 'w:unhideWhenUsed' => "0" )
148
+ xml['w'].lsdException( 'w:name' => "Dark List Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "70", 'w:unhideWhenUsed' => "0" )
149
+ xml['w'].lsdException( 'w:name' => "Colorful Shading Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "71", 'w:unhideWhenUsed' => "0" )
150
+ xml['w'].lsdException( 'w:name' => "Colorful List Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "72", 'w:unhideWhenUsed' => "0" )
151
+ xml['w'].lsdException( 'w:name' => "Colorful Grid Accent 5", 'w:semiHidden' => "0", 'w:uiPriority' => "73", 'w:unhideWhenUsed' => "0" )
152
+ xml['w'].lsdException( 'w:name' => "Light Shading Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "60", 'w:unhideWhenUsed' => "0" )
153
+ xml['w'].lsdException( 'w:name' => "Light List Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "61", 'w:unhideWhenUsed' => "0" )
154
+ xml['w'].lsdException( 'w:name' => "Light Grid Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "62", 'w:unhideWhenUsed' => "0" )
155
+ xml['w'].lsdException( 'w:name' => "Medium Shading 1 Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "63", 'w:unhideWhenUsed' => "0" )
156
+ xml['w'].lsdException( 'w:name' => "Medium Shading 2 Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "64", 'w:unhideWhenUsed' => "0" )
157
+ xml['w'].lsdException( 'w:name' => "Medium List 1 Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "65", 'w:unhideWhenUsed' => "0" )
158
+ xml['w'].lsdException( 'w:name' => "Medium List 2 Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "66", 'w:unhideWhenUsed' => "0" )
159
+ xml['w'].lsdException( 'w:name' => "Medium Grid 1 Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "67", 'w:unhideWhenUsed' => "0" )
160
+ xml['w'].lsdException( 'w:name' => "Medium Grid 2 Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "68", 'w:unhideWhenUsed' => "0" )
161
+ xml['w'].lsdException( 'w:name' => "Medium Grid 3 Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "69", 'w:unhideWhenUsed' => "0" )
162
+ xml['w'].lsdException( 'w:name' => "Dark List Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "70", 'w:unhideWhenUsed' => "0" )
163
+ xml['w'].lsdException( 'w:name' => "Colorful Shading Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "71", 'w:unhideWhenUsed' => "0" )
164
+ xml['w'].lsdException( 'w:name' => "Colorful List Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "72", 'w:unhideWhenUsed' => "0" )
165
+ xml['w'].lsdException( 'w:name' => "Colorful Grid Accent 6", 'w:semiHidden' => "0", 'w:uiPriority' => "73", 'w:unhideWhenUsed' => "0" )
166
+ xml['w'].lsdException( 'w:name' => "Subtle Emphasis", 'w:semiHidden' => "0", 'w:uiPriority' => "19", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
167
+ xml['w'].lsdException( 'w:name' => "Intense Emphasis", 'w:semiHidden' => "0", 'w:uiPriority' => "21", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
168
+ xml['w'].lsdException( 'w:name' => "Subtle Reference", 'w:semiHidden' => "0", 'w:uiPriority' => "31", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
169
+ xml['w'].lsdException( 'w:name' => "Intense Reference", 'w:semiHidden' => "0", 'w:uiPriority' => "32", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
170
+ xml['w'].lsdException( 'w:name' => "Book Title", 'w:semiHidden' => "0", 'w:uiPriority' => "33", 'w:unhideWhenUsed' => "0", 'w:qFormat' => "1" )
171
+ xml['w'].lsdException( 'w:name' => "Bibliography", 'w:uiPriority' => "37" )
172
+ xml['w'].lsdException( 'w:name' => "TOC Heading", 'w:uiPriority' => "39", 'w:qFormat' => "1" )
173
+ end
174
+ xml['w'].style( 'w:type' => "paragraph", 'w:default' => "1", 'w:styleId' => "Normal") do
175
+ xml['w'].name( 'w:val' => "Normal" )
176
+ xml['w'].qFormat
177
+ end
178
+ xml['w'].style( 'w:type' => "character", 'w:default' => "1", 'w:styleId' => "DefaultParagraphFont") do
179
+ xml['w'].name( 'w:val' => "Default Paragraph Font" )
180
+ xml['w'].uiPriority( 'w:val' => "1" )
181
+ xml['w'].semiHidden
182
+ xml['w'].unhideWhenUsed
183
+ end
184
+ xml['w'].style( 'w:type' => "table", 'w:default' => "1", 'w:styleId' => "TableNormal") do
185
+ xml['w'].name( 'w:val' => "Normal Table" )
186
+ xml['w'].uiPriority( 'w:val' => "99" )
187
+ xml['w'].semiHidden
188
+ xml['w'].unhideWhenUsed
189
+ xml['w'].tblPr do
190
+ xml['w'].tblInd( 'w:w' => "0", 'w:type' => "dxa" )
191
+ xml['w'].tblCellMar do
192
+ xml['w'].top( 'w:w' => "0", 'w:type' => "dxa" )
193
+ xml['w'].left( 'w:w' => "108", 'w:type' => "dxa" )
194
+ xml['w'].bottom( 'w:w' => "0", 'w:type' => "dxa" )
195
+ xml['w'].right( 'w:w' => "108", 'w:type' => "dxa" )
196
+ end
197
+ end
198
+ end
199
+ xml['w'].style( 'w:type' => "numbering", 'w:default' => "1", 'w:styleId' => "NoList") do
200
+ xml['w'].name( 'w:val' => "No List" )
201
+ xml['w'].uiPriority( 'w:val' => "99" )
202
+ xml['w'].semiHidden
203
+ xml['w'].unhideWhenUsed
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,39 @@
1
+ module Docxer
2
+ module Word
3
+ class Endnotes
4
+
5
+ attr_accessor :options
6
+ def initialize(options={})
7
+ @options = options
8
+ end
9
+
10
+ def render(zip)
11
+ zip.put_next_entry('word/endnotes.xml')
12
+ zip.write(Docxer.to_xml(document))
13
+ end
14
+
15
+ def document
16
+ Nokogiri::XML::Builder.with(Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')) do |xml|
17
+ xml.endnotes( 'xmlns:wpc' => "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", 'xmlns:mc' => "http://schemas.openxmlformats.org/markup-compatibility/2006", 'xmlns:o' => "urn:schemas-microsoft-com:office:office", 'xmlns:r' => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", 'xmlns:m' => "http://schemas.openxmlformats.org/officeDocument/2006/math", 'xmlns:v' => "urn:schemas-microsoft-com:vml", 'xmlns:wp14' => "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", 'xmlns:wp' => "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", 'xmlns:w10' => "urn:schemas-microsoft-com:office:word", 'xmlns:w' => "http://schemas.openxmlformats.org/wordprocessingml/2006/main", 'xmlns:w14' => "http://schemas.microsoft.com/office/word/2010/wordml", 'xmlns:wpg' => "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", 'xmlns:wpi' => "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", 'xmlns:wne' => "http://schemas.microsoft.com/office/word/2006/wordml", 'xmlns:wps' => "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", 'mc:Ignorable' => "w14 wp14" ) do
18
+ xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix == "w" }
19
+ xml['w'].endnote( 'w:type' => "separator", 'w:id' => "-1") do
20
+ xml['w'].p do
21
+ xml['w'].r do
22
+ xml['w'].separator
23
+ end
24
+ end
25
+ end
26
+ xml['w'].endnote( 'w:type' => "continuationSeparator", 'w:id' => "0" ) do
27
+ xml['w'].p do
28
+ xml['w'].r do
29
+ xml['w'].continuationSeparator
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,42 @@
1
+ require 'docxer/word/fonts/font'
2
+
3
+ module Docxer
4
+ module Word
5
+ class Fonts
6
+
7
+ attr_accessor :fonts
8
+
9
+ def initialize
10
+ @fonts = []
11
+ add('Calibri', :panose => '020F0502020204030204', :charset => '00', :family => 'swiss', :pitch => 'variable', :sig => { 'w:usb0' => "E00002FF", 'w:usb1' => "4000ACFF", 'w:usb2' => "00000001", 'w:usb3' => "00000000", 'w:csb0' => "0000019F", 'w:csb1' => "00000000"})
12
+ add('Times New Roman', :panose => '02020603050405020304', :charset => '00', :family => 'roman', :pitch => 'variable', :sig => { 'w:usb0' => "E0002AFF", 'w:usb1' => "C0007841", 'w:usb2' => "00000009", 'w:usb3' => "00000000", 'w:csb0' => "000001FF", 'w:csb1' => "00000000"})
13
+ add('Cambria', :panose => '02040503050406030204', :charset => '00', :family => 'roman', :pitch => 'variable', :sig => { 'w:usb0' => "E00002FF", 'w:usb1' => "400004FF", 'w:usb2' => "00000000", 'w:usb3' => "00000000", 'w:csb0' => "0000019F", 'w:csb1' => "00000000"})
14
+ end
15
+
16
+ def add(name, options)
17
+ font = Font.new(name, options)
18
+ @fonts << font if font
19
+ font
20
+ end
21
+
22
+ def render(zip)
23
+ zip.put_next_entry('word/fontTable.xml')
24
+ zip.write(Docxer.to_xml(document))
25
+ end
26
+
27
+ private
28
+ def document
29
+ Nokogiri::XML::Builder.with(Nokogiri::XML('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>')) do |xml|
30
+ xml.fonts('xmlns:mc' => "http://schemas.openxmlformats.org/markup-compatibility/2006", 'xmlns:r' => "http://schemas.openxmlformats.org/officeDocument/2006/relationships", 'xmlns:w' => "http://schemas.openxmlformats.org/wordprocessingml/2006/main", 'xmlns:w14' => "http://schemas.microsoft.com/office/word/2010/wordml", 'mc:Ignorable' => "w14") do
31
+ xml.parent.namespace = xml.parent.namespace_definitions.find{|ns| ns.prefix=="w" }
32
+
33
+ @fonts.each do |font|
34
+ font.build(xml)
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end