Class: Rubyword::Writer::Part::Styles
- Inherits:
-
Base
- Object
- Base
- Rubyword::Writer::Part::Styles
show all
- Defined in:
- lib/rubyword/writer/part/styles.rb
Constant Summary
collapse
- DEFAULT_FONT_NAME =
'Arial'
- DEFAULT_FONT_SIZE =
10
- DEFAULT_FONT_COLOR =
'000000'
- DEFAULT_FONT_CONTENT_TYPE =
'default'
Instance Attribute Summary
Attributes inherited from Base
#rubyword, #section
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#default_setting(xml) ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/rubyword/writer/part/styles.rb', line 61
def (xml)
xml.send('w:style', {'w:type' => 'character', 'w:styleId' => 'FootnoteReference'}) {
xml.send('w:name', 'w:val' => 'Footnote Reference')
xml.send('w:semiHidden')
xml.send('w:unhideWhenUsed')
xml.send('w:rPr') {
xml.send('w:verAlign', 'w:val' => 'superscript')
}
}
end
|
#normal_style(xml) ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/rubyword/writer/part/styles.rb', line 50
def normal_style(xml)
attribute = {
'w:type' => 'paragraph',
'w:default' => 1,
'w:styleId' => 'Normal'
}
xml.send('w:style', attribute) {
xml.send('w:name', 'w:val' => 'Normal')
}
end
|
#title_style ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/rubyword/writer/part/styles.rb', line 13
def title_style
[
{'size' => 20, 'color' => '333333', 'bold' => true},
{'size' => 16, 'color' => '333333', 'bold' => true},
{'size' => 14, 'color' => '333333', 'bold' => true},
{'size' => 12, 'color' => '333333', 'bold' => true}
]
end
|
#write ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rubyword/writer/part/styles.rb', line 22
def write
attribute = {
'xmlns:w' => 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'
}
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.send('w:styles', attribute) {
default_setting(xml)
normal_style(xml)
(xml)
write_font_style(xml)
}
end
builder.to_xml
end
|
#write_font_style(xml) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/rubyword/writer/part/styles.rb', line 72
def write_font_style(xml)
title_style.each_with_index do |style, index|
index = index + 1
xml.send('w:style', {'w:type' => 'paragraph', 'w:styleId' => "Heading#{index}"}) {
xml.send('w:link', {'w:val' => "Heading#{index}Char"})
xml.send('w:name', {'w:val' => "heading #{index}"})
xml.send('w:rPr') {
xml.send('w:color', 'w:val' => style['color'])
xml.send('w:sz', 'w:val' => style['size'] * 2)
xml.send('w:szCs', 'w:val' => style['size'] * 2)
xml.send('w:b')
}
}
end
end
|