Skip to content

Commit 9529856

Browse files
authored
Merge pull request #63 from openxml/explicit-false
Turn off the bold!
2 parents e3a4d4d + ae30d3e commit 9529856

6 files changed

Lines changed: 20 additions & 4 deletions

File tree

lib/openxml/docx/properties.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Properties
1414
require "openxml/docx/properties/string_property"
1515
require "openxml/docx/properties/on_off_property"
1616
require "openxml/docx/properties/toggle_property"
17+
require "openxml/docx/properties/explicit_toggle_property"
1718
require "openxml/docx/properties/string_property"
1819
require "openxml/docx/properties/container_property"
1920
require "openxml/docx/properties/transparent_container_property"

lib/openxml/docx/properties/bold.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module OpenXml
22
module Docx
33
module Properties
4-
class Bold < ToggleProperty
4+
class Bold < ExplicitToggleProperty
55
tag :b
66

77
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module OpenXml
2+
module Docx
3+
module Properties
4+
class ExplicitToggleProperty < ToggleProperty
5+
6+
def to_xml(xml)
7+
return if value.nil?
8+
return xml["w"].public_send(tag, "w:val" => value) if value == false
9+
xml["w"].public_send(tag)
10+
end
11+
12+
end
13+
end
14+
end
15+
end

lib/openxml/docx/properties/italics.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module OpenXml
22
module Docx
33
module Properties
4-
class Italics < ToggleProperty
4+
class Italics < ExplicitToggleProperty
55
tag :i
66

77
end

spec/properties/bold_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
with_value(false) do
1414
it_should_work
15-
it_should_output ""
15+
it_should_output "<w:b w:val=\"false\"/>"
1616
end
1717

1818
with_value(nil) do

spec/properties/italics_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
with_value(false) do
1414
it_should_work
15-
it_should_output ""
15+
it_should_output "<w:i w:val=\"false\"/>"
1616
end
1717

1818
with_value(nil) do

0 commit comments

Comments
 (0)