openxml-docx 0.8.0 → 0.9.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/Gemfile.lock +1 -1
- data/{example → examples/base} +1 -1
- data/examples/table +68 -0
- data/lib/openxml/docx/elements/grid_column.rb +12 -0
- data/lib/openxml/docx/elements/table.rb +30 -0
- data/lib/openxml/docx/elements/table_cell.rb +26 -0
- data/lib/openxml/docx/elements/table_grid.rb +10 -0
- data/lib/openxml/docx/elements/table_row.rb +36 -0
- data/lib/openxml/docx/package.rb +3 -0
- data/lib/openxml/docx/properties.rb +2 -0
- data/lib/openxml/docx/properties/base_property.rb +14 -0
- data/lib/openxml/docx/properties/cant_split.rb +8 -0
- data/lib/openxml/docx/properties/columns.rb +2 -0
- data/lib/openxml/docx/properties/grid_after.rb +8 -0
- data/lib/openxml/docx/properties/grid_before.rb +8 -0
- data/lib/openxml/docx/properties/grid_span.rb +8 -0
- data/lib/openxml/docx/properties/header.rb +8 -0
- data/lib/openxml/docx/properties/headers.rb +12 -0
- data/lib/openxml/docx/properties/hidden.rb +8 -0
- data/lib/openxml/docx/properties/hide_mark.rb +8 -0
- data/lib/openxml/docx/properties/no_wrap.rb +8 -0
- data/lib/openxml/docx/properties/table_border.rb +25 -0
- data/lib/openxml/docx/properties/table_borders.rb +13 -0
- data/lib/openxml/docx/properties/table_caption.rb +10 -0
- data/lib/openxml/docx/properties/table_cell_border.rb +25 -0
- data/lib/openxml/docx/properties/table_cell_borders.rb +13 -0
- data/lib/openxml/docx/properties/table_cell_cell_margin.rb +13 -0
- data/lib/openxml/docx/properties/table_cell_fit_text.rb +9 -0
- data/lib/openxml/docx/properties/table_cell_margin.rb +13 -0
- data/lib/openxml/docx/properties/table_cell_margins.rb +13 -0
- data/lib/openxml/docx/properties/table_cell_spacing.rb +13 -0
- data/lib/openxml/docx/properties/table_cell_width.rb +13 -0
- data/lib/openxml/docx/properties/table_description.rb +10 -0
- data/lib/openxml/docx/properties/table_header.rb +10 -0
- data/lib/openxml/docx/properties/table_indent.rb +13 -0
- data/lib/openxml/docx/properties/table_layout.rb +14 -0
- data/lib/openxml/docx/properties/table_look.rb +17 -0
- data/lib/openxml/docx/properties/table_overlap.rb +14 -0
- data/lib/openxml/docx/properties/table_p_pr.rb +41 -0
- data/lib/openxml/docx/properties/table_style.rb +10 -0
- data/lib/openxml/docx/properties/table_width.rb +13 -0
- data/lib/openxml/docx/properties/tr_height.rb +19 -0
- data/lib/openxml/docx/properties/valign.rb +13 -0
- data/lib/openxml/docx/properties/wafter.rb +12 -0
- data/lib/openxml/docx/properties/wbefore.rb +12 -0
- data/lib/openxml/docx/properties/width_property.rb +17 -0
- data/lib/openxml/docx/style.rb +17 -7
- data/lib/openxml/docx/version.rb +1 -1
- data/spec/elements/grid_column_spec.rb +15 -0
- data/spec/elements/table_cell_spec.rb +15 -0
- data/spec/elements/table_grid_spec.rb +17 -0
- data/spec/elements/table_row_spec.rb +18 -0
- data/spec/elements/table_spec.rb +21 -0
- data/spec/properties/border_spec.rb +21 -95
- data/spec/properties/cant_split_spec.rb +23 -0
- data/spec/properties/color_spec.rb +9 -29
- data/spec/properties/column_spec.rb +6 -22
- data/spec/properties/columns_spec.rb +4 -14
- data/spec/properties/conditional_formatting_spec.rb +12 -108
- data/spec/properties/document_grid_spec.rb +12 -53
- data/spec/properties/east_asian_layout_spec.rb +14 -74
- data/spec/properties/font_spec.rb +35 -238
- data/spec/properties/frame_spec.rb +48 -285
- data/spec/properties/grid_after_spec.rb +26 -0
- data/spec/properties/grid_before_spec.rb +26 -0
- data/spec/properties/grid_span_spec.rb +24 -0
- data/spec/properties/header_spec.rb +17 -0
- data/spec/properties/headers_spec.rb +39 -0
- data/spec/properties/hidden_spec.rb +23 -0
- data/spec/properties/hide_mark_spec.rb +23 -0
- data/spec/properties/indentation_spec.rb +32 -136
- data/spec/properties/language_spec.rb +3 -12
- data/spec/properties/latent_styles_exception_spec.rb +7 -22
- data/spec/properties/latent_styles_spec.rb +5 -18
- data/spec/properties/line_numbering_spec.rb +15 -68
- data/spec/properties/manual_width_spec.rb +8 -33
- data/spec/properties/no_wrap_spec.rb +23 -0
- data/spec/properties/numbering_spec.rb +4 -13
- data/spec/properties/page_margins_spec.rb +28 -114
- data/spec/properties/page_numbering_spec.rb +26 -367
- data/spec/properties/page_size_spec.rb +15 -62
- data/spec/properties/paper_source_spec.rb +8 -34
- data/spec/properties/shading_spec.rb +21 -92
- data/spec/properties/spacing_spec.rb +27 -119
- data/spec/properties/table_border_spec.rb +119 -0
- data/spec/properties/table_borders_spec.rb +41 -0
- data/spec/properties/table_caption_spec.rb +17 -0
- data/spec/properties/table_cell_border_spec.rb +119 -0
- data/spec/properties/table_cell_borders_spec.rb +40 -0
- data/spec/properties/table_cell_cell_margin_spec.rb +46 -0
- data/spec/properties/table_cell_fit_text.rb +23 -0
- data/spec/properties/table_cell_margin_spec.rb +40 -0
- data/spec/properties/table_cell_margins_spec.rb +46 -0
- data/spec/properties/table_cell_spacing_spec.rb +21 -0
- data/spec/properties/table_cell_width.rb +21 -0
- data/spec/properties/table_description_spec.rb +17 -0
- data/spec/properties/table_header_spec.rb +23 -0
- data/spec/properties/table_indent_spec.rb +43 -0
- data/spec/properties/table_layout_spec.rb +22 -0
- data/spec/properties/table_look_spec.rb +38 -0
- data/spec/properties/table_overlap_spec.rb +22 -0
- data/spec/properties/table_p_pr_spec.rb +68 -0
- data/spec/properties/table_row_height.rb +20 -0
- data/spec/properties/table_style_spec.rb +17 -0
- data/spec/properties/table_width_spec.rb +21 -0
- data/spec/properties/underline_spec.rb +14 -130
- data/spec/properties/valign_spec.rb +19 -0
- data/spec/properties/wafter_spec.rb +21 -0
- data/spec/properties/wbefore_spec.rb +21 -0
- data/spec/support/data/elements/grid_column_element.xml +4 -0
- data/spec/support/data/elements/table_cell_element.xml +8 -0
- data/spec/support/data/elements/table_element.xml +18 -0
- data/spec/support/data/elements/table_grid_element.xml +6 -0
- data/spec/support/data/elements/table_row_element.xml +13 -0
- data/spec/support/property_test_macros.rb +61 -0
- metadata +86 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableCellMargins do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblCellMar, name: "table_cell_margins"
|
|
7
|
+
|
|
8
|
+
context "when trying to add table cell margins, it" do
|
|
9
|
+
before(:each) do
|
|
10
|
+
@instance = described_class.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should raise an exception if the margin to be added isn't a margin at all" do
|
|
14
|
+
expect { instance << [] }.to raise_error(ArgumentError)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context "when there are no margins" do
|
|
19
|
+
before(:each) do
|
|
20
|
+
@instance = described_class.new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should not output any XML" do
|
|
24
|
+
expect(xml(instance)).to eq("")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "when there are margins" do
|
|
29
|
+
before(:each) do
|
|
30
|
+
@instance = described_class.new
|
|
31
|
+
start_margin = OpenXml::Docx::Properties::TableCellMargin.new(:start)
|
|
32
|
+
end_margin = OpenXml::Docx::Properties::TableCellMargin.new(:end)
|
|
33
|
+
start_margin.type = :dxa
|
|
34
|
+
start_margin.width = 1
|
|
35
|
+
end_margin.type = :dxa
|
|
36
|
+
end_margin.width = 1
|
|
37
|
+
instance << start_margin
|
|
38
|
+
instance << end_margin
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should output the correct XML" do
|
|
42
|
+
expect(xml(instance)).to eq("<w:tblCellMar>\n <w:start w:type=\"dxa\" w:w=\"1\"/>\n <w:end w:type=\"dxa\" w:w=\"1\"/>\n </w:tblCellMar>")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableCellSpacing do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblCellSpacing, name: "table_cell_spacing"
|
|
7
|
+
|
|
8
|
+
for_attribute(:type) do
|
|
9
|
+
values = %i(dxa pct)
|
|
10
|
+
it_should_assign_and_output_xml values
|
|
11
|
+
it_should_not_allow_invalid_value
|
|
12
|
+
it_should_not_allow_integers
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
for_attribute(:width) do
|
|
16
|
+
it_should_assign_and_output_xml 2
|
|
17
|
+
it_should_not_allow_invalid_value
|
|
18
|
+
it_should_not_allow_floats
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableCellWidth do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tcW, name: "table_cell_width"
|
|
7
|
+
|
|
8
|
+
for_attribute(:type) do
|
|
9
|
+
values = %i(dxa pct)
|
|
10
|
+
it_should_assign_and_output_xml values
|
|
11
|
+
it_should_not_allow_invalid_value
|
|
12
|
+
it_should_not_allow_integers
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
for_attribute(:width) do
|
|
16
|
+
it_should_assign_and_output_xml 2
|
|
17
|
+
it_should_not_allow_invalid_value
|
|
18
|
+
it_should_not_allow_floats
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableDescription do
|
|
4
|
+
include ValuePropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblDescription, name: "table_description", value: "Something"
|
|
7
|
+
|
|
8
|
+
with_value("Something Else") do
|
|
9
|
+
it_should_work
|
|
10
|
+
it_should_output "<w:tblDescription w:val=\"Something Else\"/>"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
with_value("") do
|
|
14
|
+
it_should_not_work
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableHeader do
|
|
4
|
+
include ValuePropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblHeader, name: "table_header"
|
|
7
|
+
|
|
8
|
+
with_value(true) do
|
|
9
|
+
it_should_work
|
|
10
|
+
it_should_output "<w:tblHeader/>"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
with_value(false) do
|
|
14
|
+
it_should_work
|
|
15
|
+
it_should_output ""
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
with_value(nil) do
|
|
19
|
+
it_should_work
|
|
20
|
+
it_should_output ""
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableIndent do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblInd, name: "table_indent"
|
|
7
|
+
|
|
8
|
+
for_attribute(:type) do
|
|
9
|
+
with_value(:dxa) do
|
|
10
|
+
it_should_assign_successfully
|
|
11
|
+
it_should_output "<w:tblInd w:type=\"dxa\"/>"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
with_value(:pct) do
|
|
15
|
+
it_should_assign_successfully
|
|
16
|
+
it_should_output "<w:tblInd w:type=\"pct\"/>"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
with_value(:pixels) do
|
|
20
|
+
it_should_raise_an_exception
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
with_value(5) do
|
|
24
|
+
it_should_raise_an_exception
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
for_attribute(:width) do
|
|
29
|
+
with_value(2) do
|
|
30
|
+
it_should_assign_successfully
|
|
31
|
+
it_should_output "<w:tblInd w:w=\"2\"/>"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
with_value(12.1) do
|
|
35
|
+
it_should_raise_an_exception
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
with_value(:big) do
|
|
39
|
+
it_should_raise_an_exception
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableLayout do
|
|
4
|
+
include ValuePropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblLayout, name: "table_layout", value: :autofit
|
|
7
|
+
|
|
8
|
+
with_value(:autofit) do
|
|
9
|
+
it_should_work
|
|
10
|
+
it_should_output "<w:tblLayout w:val=\"autofit\"/>"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
with_value(:fixed) do
|
|
14
|
+
it_should_work
|
|
15
|
+
it_should_output "<w:tblLayout w:val=\"fixed\"/>"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
with_value(:nope) do
|
|
19
|
+
it_should_not_work
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableLook do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblLook, name: "table_look"
|
|
7
|
+
|
|
8
|
+
for_attribute(:firstColumn) do
|
|
9
|
+
it_should_assign_and_output_xml true
|
|
10
|
+
it_should_not_allow_invalid_value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
for_attribute(:firstRow) do
|
|
14
|
+
it_should_assign_and_output_xml true
|
|
15
|
+
it_should_not_allow_invalid_value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
for_attribute(:lastColumn) do
|
|
19
|
+
it_should_assign_and_output_xml true
|
|
20
|
+
it_should_not_allow_invalid_value
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
for_attribute(:lastRow) do
|
|
24
|
+
it_should_assign_and_output_xml true
|
|
25
|
+
it_should_not_allow_invalid_value
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
for_attribute(:noHBand) do
|
|
29
|
+
it_should_assign_and_output_xml true
|
|
30
|
+
it_should_not_allow_invalid_value
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
for_attribute(:noVBand) do
|
|
34
|
+
it_should_assign_and_output_xml true
|
|
35
|
+
it_should_not_allow_invalid_value
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableOverlap do
|
|
4
|
+
include ValuePropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblOverlap, name: "table_overlap", value: :never
|
|
7
|
+
|
|
8
|
+
with_value(:never) do
|
|
9
|
+
it_should_work
|
|
10
|
+
it_should_output "<w:tblOverlap w:val=\"never\"/>"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
with_value(:overlap) do
|
|
14
|
+
it_should_work
|
|
15
|
+
it_should_output "<w:tblOverlap w:val=\"overlap\"/>"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
with_value(:nope) do
|
|
19
|
+
it_should_not_work
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TablePPr do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblpPr, name: "table_ppr"
|
|
7
|
+
|
|
8
|
+
for_attribute(:bottomFromText) do
|
|
9
|
+
it_should_assign_and_output_xml 1
|
|
10
|
+
it_should_not_allow_negative_numbers
|
|
11
|
+
it_should_not_allow_invalid_value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
for_attribute(:horizAnchor) do
|
|
15
|
+
values = %i(margin page text)
|
|
16
|
+
it_should_assign_and_output_xml values
|
|
17
|
+
it_should_not_allow_invalid_value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
for_attribute(:leftFromText) do
|
|
21
|
+
it_should_assign_and_output_xml 1
|
|
22
|
+
it_should_not_allow_negative_numbers
|
|
23
|
+
it_should_not_allow_invalid_value
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
for_attribute(:rightFromText) do
|
|
27
|
+
it_should_assign_and_output_xml 1
|
|
28
|
+
it_should_not_allow_negative_numbers
|
|
29
|
+
it_should_not_allow_invalid_value
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
for_attribute(:tblpX) do
|
|
33
|
+
values = [1, -1]
|
|
34
|
+
it_should_assign_and_output_xml values
|
|
35
|
+
it_should_not_allow_invalid_value
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
for_attribute(:tblpXSpec) do
|
|
39
|
+
values = %i(center inside left outside right)
|
|
40
|
+
it_should_assign_and_output_xml values
|
|
41
|
+
it_should_not_allow_invalid_value
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
for_attribute(:tblpY) do
|
|
45
|
+
values = [1, -1]
|
|
46
|
+
it_should_assign_and_output_xml values
|
|
47
|
+
it_should_not_allow_invalid_value
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
for_attribute(:tblpYSpec) do
|
|
51
|
+
values = %i(bottom center inline inside outside top)
|
|
52
|
+
it_should_assign_and_output_xml values
|
|
53
|
+
it_should_not_allow_invalid_value
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
for_attribute(:topFromText) do
|
|
57
|
+
it_should_assign_and_output_xml 1
|
|
58
|
+
it_should_not_allow_negative_numbers
|
|
59
|
+
it_should_not_allow_invalid_value
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
for_attribute(:vertAnchor) do
|
|
63
|
+
values = %i(margin page text)
|
|
64
|
+
it_should_assign_and_output_xml values
|
|
65
|
+
it_should_not_allow_invalid_value
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableRowHeight do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :trHeight, name: "table_row_height"
|
|
7
|
+
|
|
8
|
+
for_attribute(:hRule) do
|
|
9
|
+
values = %i(auto atLeast exact)
|
|
10
|
+
it_should_assign_and_output_xml values
|
|
11
|
+
it_should_not_allow_invalid_value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
for_attribute(:val) do
|
|
15
|
+
it_should_assign_and_output_xml 2
|
|
16
|
+
it_should_not_allow_floats
|
|
17
|
+
it_should_not_allow_invalid_value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableStyle do
|
|
4
|
+
include ValuePropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblStyle, name: "table_style", value: "Something"
|
|
7
|
+
|
|
8
|
+
with_value("Something Else") do
|
|
9
|
+
it_should_work
|
|
10
|
+
it_should_output "<w:tblStyle w:val=\"Something Else\"/>"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
with_value("") do
|
|
14
|
+
it_should_not_work
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe OpenXml::Docx::Properties::TableWidth do
|
|
4
|
+
include PropertyTestMacros
|
|
5
|
+
|
|
6
|
+
it_should_use tag: :tblW, name: "table_width"
|
|
7
|
+
|
|
8
|
+
for_attribute(:type) do
|
|
9
|
+
values = %i(dxa pct)
|
|
10
|
+
it_should_assign_and_output_xml values
|
|
11
|
+
it_should_not_allow_invalid_value
|
|
12
|
+
it_should_not_allow_integers
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
for_attribute(:width) do
|
|
16
|
+
it_should_assign_and_output_xml 2
|
|
17
|
+
it_should_not_allow_floats
|
|
18
|
+
it_should_not_allow_invalid_value
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -6,148 +6,32 @@ describe OpenXml::Docx::Properties::Underline do
|
|
|
6
6
|
it_should_use tag: :u, name: "underline"
|
|
7
7
|
|
|
8
8
|
for_attribute(:color) do
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
with_value(:auto) do
|
|
15
|
-
it_should_assign_successfully
|
|
16
|
-
it_should_output "<w:u w:color=\"auto\"/>"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
with_value(:nope) do
|
|
20
|
-
it_should_raise_an_exception
|
|
21
|
-
end
|
|
9
|
+
values = ["FF34E1", :auto]
|
|
10
|
+
it_should_assign_and_output_xml values
|
|
11
|
+
it_should_not_allow_invalid_value
|
|
22
12
|
end
|
|
23
13
|
|
|
24
14
|
for_attribute(:theme_color) do
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
it_should_output "<w:u w:themeColor=\"accent3\"/>"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
with_value(:nope) do
|
|
31
|
-
it_should_raise_an_exception
|
|
32
|
-
end
|
|
15
|
+
it_should_assign_and_output_xml :accent3
|
|
16
|
+
it_should_not_allow_invalid_value
|
|
33
17
|
end
|
|
34
18
|
|
|
35
19
|
for_attribute(:theme_shade) do
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
it_should_output "<w:u w:themeShade=\"BF\"/>"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
with_value(:nope) do
|
|
42
|
-
it_should_raise_an_exception
|
|
43
|
-
end
|
|
20
|
+
it_should_assign_and_output_xml "BF"
|
|
21
|
+
it_should_not_allow_invalid_value
|
|
44
22
|
end
|
|
45
23
|
|
|
46
24
|
for_attribute(:theme_tint) do
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
it_should_output "<w:u w:themeTint=\"BF\"/>"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
with_value(:nope) do
|
|
53
|
-
it_should_raise_an_exception
|
|
54
|
-
end
|
|
25
|
+
it_should_assign_and_output_xml "BF"
|
|
26
|
+
it_should_not_allow_invalid_value
|
|
55
27
|
end
|
|
56
28
|
|
|
57
29
|
for_attribute(:type) do
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
with_value(:dashDotDotHeavy) do
|
|
64
|
-
it_should_assign_successfully
|
|
65
|
-
it_should_output "<w:u w:val=\"dashDotDotHeavy\"/>"
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
with_value(:dashDotHeavy) do
|
|
69
|
-
it_should_assign_successfully
|
|
70
|
-
it_should_output "<w:u w:val=\"dashDotHeavy\"/>"
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
with_value(:dashedHeavy) do
|
|
74
|
-
it_should_assign_successfully
|
|
75
|
-
it_should_output "<w:u w:val=\"dashedHeavy\"/>"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
with_value(:dashLong) do
|
|
79
|
-
it_should_assign_successfully
|
|
80
|
-
it_should_output "<w:u w:val=\"dashLong\"/>"
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
with_value(:dashLongHeavy) do
|
|
84
|
-
it_should_assign_successfully
|
|
85
|
-
it_should_output "<w:u w:val=\"dashLongHeavy\"/>"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
with_value(:dotDash) do
|
|
89
|
-
it_should_assign_successfully
|
|
90
|
-
it_should_output "<w:u w:val=\"dotDash\"/>"
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
with_value(:dotDotDash) do
|
|
94
|
-
it_should_assign_successfully
|
|
95
|
-
it_should_output "<w:u w:val=\"dotDotDash\"/>"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
with_value(:dotted) do
|
|
99
|
-
it_should_assign_successfully
|
|
100
|
-
it_should_output "<w:u w:val=\"dotted\"/>"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
with_value(:dottedHeavy) do
|
|
104
|
-
it_should_assign_successfully
|
|
105
|
-
it_should_output "<w:u w:val=\"dottedHeavy\"/>"
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
with_value(:double) do
|
|
109
|
-
it_should_assign_successfully
|
|
110
|
-
it_should_output "<w:u w:val=\"double\"/>"
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
with_value(:none) do
|
|
114
|
-
it_should_assign_successfully
|
|
115
|
-
it_should_output "<w:u w:val=\"none\"/>"
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
with_value(:single) do
|
|
119
|
-
it_should_assign_successfully
|
|
120
|
-
it_should_output "<w:u w:val=\"single\"/>"
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
with_value(:thick) do
|
|
124
|
-
it_should_assign_successfully
|
|
125
|
-
it_should_output "<w:u w:val=\"thick\"/>"
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
with_value(:wave) do
|
|
129
|
-
it_should_assign_successfully
|
|
130
|
-
it_should_output "<w:u w:val=\"wave\"/>"
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
with_value(:wavyDouble) do
|
|
134
|
-
it_should_assign_successfully
|
|
135
|
-
it_should_output "<w:u w:val=\"wavyDouble\"/>"
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
with_value(:wavyHeavy) do
|
|
139
|
-
it_should_assign_successfully
|
|
140
|
-
it_should_output "<w:u w:val=\"wavyHeavy\"/>"
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
with_value(:words) do
|
|
144
|
-
it_should_assign_successfully
|
|
145
|
-
it_should_output "<w:u w:val=\"words\"/>"
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
with_value(:triple) do
|
|
149
|
-
it_should_raise_an_exception
|
|
150
|
-
end
|
|
30
|
+
values = %i(dash dashDotDotHeavy dashDotDotHeavy dashedHeavy dashLong dashLongHeavy
|
|
31
|
+
dotDash dotDotDash dotted dottedHeavy double none single thick wave
|
|
32
|
+
wavyDouble wavyHeavy words)
|
|
33
|
+
it_should_assign_and_output_xml values
|
|
34
|
+
it_should_not_allow_invalid_value
|
|
151
35
|
end
|
|
152
36
|
|
|
153
37
|
with_no_attributes_set do
|