openxml-docx 0.11.0.rc → 0.11.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5237f91a84828cf674cdc2ba93b7f3ccca7500db
4
- data.tar.gz: 0507dab47e9edbb7648fb994909d68bb24e3599a
2
+ SHA256:
3
+ metadata.gz: aef7247561ac85ebf59ce97f8a4c3de2b74e03d29881cb00257d44462adb395e
4
+ data.tar.gz: 71d28458c33a4f75f61231e235d9cc956c8b6f70e1cd7473ca7b3ea1bbfeb1b5
5
5
  SHA512:
6
- metadata.gz: 3a1a8423874b848f4173c4ca1f02208b403c2e25cc53d3570d3b3313dc55cf8daea7890549c7f9228528356d8b63059b73ca57efb1f48d1724e97573a9df84de
7
- data.tar.gz: 22f6bc385345e85ef2229b3166f14e282128fe972e0503f32fb0a0c29dc2dca6252b5a26d694c1724987cc6015b94014ccd0c3ce3b859647631f8c25bbcd07b4
6
+ metadata.gz: ceb9ea15cc3af14d25fbfd44aed3146701f8914f7b17ccb82303b32dbba2837d02de3e14326533ba0b92183c365e35b767ef7a681efd3de234f1f24aa721f540
7
+ data.tar.gz: d2458309c0b8f36154ab0e8a6992d90b58a5d8bd66438db45081a8f385337808fa0de0e8c5adfe98254127d6fe4685b066cb056835ea9ebed81500df5b384d72
@@ -0,0 +1,21 @@
1
+ name: Tests
2
+ on: [push]
3
+
4
+ jobs:
5
+ ruby:
6
+ name: Ruby Tests
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version: [ "2.6", "2.7" ]
11
+
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+ - name: Setup Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ bundler-cache: true
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ - name: Run Tests
21
+ run: bundle exec rake spec
data/Gemfile.lock CHANGED
@@ -1,58 +1,56 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openxml-docx (0.11.0.rc)
4
+ openxml-docx (0.11.3)
5
5
  nokogiri
6
6
  openxml-drawingml
7
7
  openxml-package (>= 0.2.2)
8
- ox (~> 2.4.3, < 2.4.10)
8
+ ox (~> 2.9)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- coderay (1.1.1)
13
+ coderay (1.1.2)
14
14
  diff-lcs (1.3)
15
- docile (1.1.5)
16
- json (2.1.0)
17
- method_source (0.8.2)
18
- mini_portile2 (2.2.0)
19
- nokogiri (1.8.0)
20
- mini_portile2 (~> 2.2.0)
21
- openxml-drawingml (0.1.0)
15
+ docile (1.3.2)
16
+ method_source (1.0.0)
17
+ mini_portile2 (2.6.1)
18
+ nokogiri (1.12.5)
19
+ mini_portile2 (~> 2.6.1)
20
+ racc (~> 1.4)
21
+ openxml-drawingml (0.2.0)
22
22
  nokogiri
23
- openxml-package (~> 0.2.9)
24
- openxml-package (0.2.9)
23
+ openxml-package (~> 0.3.2)
24
+ openxml-package (0.3.4)
25
25
  nokogiri
26
26
  ox
27
- rubyzip (~> 1.2.1)
28
- ox (2.4.9)
29
- pry (0.10.4)
30
- coderay (~> 1.1.0)
31
- method_source (~> 0.8.1)
32
- slop (~> 3.4)
33
- rake (12.0.0)
34
- rr (1.2.0)
35
- rspec (3.6.0)
36
- rspec-core (~> 3.6.0)
37
- rspec-expectations (~> 3.6.0)
38
- rspec-mocks (~> 3.6.0)
39
- rspec-core (3.6.0)
40
- rspec-support (~> 3.6.0)
41
- rspec-expectations (3.6.0)
27
+ rubyzip
28
+ ox (2.14.5)
29
+ pry (0.13.1)
30
+ coderay (~> 1.1)
31
+ method_source (~> 1.0)
32
+ racc (1.6.0)
33
+ rake (13.0.1)
34
+ rr (1.2.1)
35
+ rspec (3.9.0)
36
+ rspec-core (~> 3.9.0)
37
+ rspec-expectations (~> 3.9.0)
38
+ rspec-mocks (~> 3.9.0)
39
+ rspec-core (3.9.2)
40
+ rspec-support (~> 3.9.3)
41
+ rspec-expectations (3.9.2)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.6.0)
44
- rspec-mocks (3.6.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-mocks (3.9.1)
45
45
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.6.0)
47
- rspec-support (3.6.0)
48
- rubyzip (1.2.1)
49
- simplecov (0.14.1)
50
- docile (~> 1.1.0)
51
- json (>= 1.8, < 3)
52
- simplecov-html (~> 0.10.0)
53
- simplecov-html (0.10.1)
54
- slop (3.6.0)
55
- timecop (0.8.1)
46
+ rspec-support (~> 3.9.0)
47
+ rspec-support (3.9.3)
48
+ rubyzip (2.3.2)
49
+ simplecov (0.18.5)
50
+ docile (~> 1.1)
51
+ simplecov-html (~> 0.11)
52
+ simplecov-html (0.12.2)
53
+ timecop (0.9.1)
56
54
 
57
55
  PLATFORMS
58
56
  ruby
@@ -67,4 +65,4 @@ DEPENDENCIES
67
65
  timecop
68
66
 
69
67
  BUNDLED WITH
70
- 1.14.6
68
+ 2.1.4
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This example shows how to use the "numbering" system to describe how a list
4
+ # should be numbered within a document.
5
+
6
+ # require "rails" # workaround: openxml-package uses `extract_options!`
7
+ $:.push Dir.pwd + "/lib"
8
+ require "openxml/docx"
9
+
10
+ package = OpenXml::Docx::Package.new
11
+
12
+ include OpenXml::Docx::Elements
13
+
14
+ # Each list item is a paragraph. A helper function to create paragraphs in the
15
+ # final document:
16
+ def create_paragraph(content)
17
+ text = Text.new(content)
18
+ run = Run.new
19
+ run << text
20
+ paragraph = Paragraph.new
21
+ paragraph << run
22
+ paragraph
23
+ end
24
+
25
+ # First up, create a style for the list paragraph
26
+ list_style = OpenXml::Docx::Style.new :paragraph
27
+ list_style.id = 'ListParagraph'
28
+ list_style.style_name = 'List Paragraph'
29
+ list_style.paragraph.indentation.left = 720
30
+ list_style.paragraph.contextual_spacing = true
31
+
32
+ package.styles << list_style
33
+
34
+ # Each list needs a numbering within the numbering part of the document.
35
+
36
+ # Create an abstract numbering that describes a bulleted list:
37
+ abstract_numbering = AbstractNumbering.new(0)
38
+
39
+ # Each numbering can have multiple levels. Define the first level as a bulleted list:
40
+ level_0 = Level.new
41
+ level_0.level = 0
42
+ level_0.start = 1
43
+ level_0.number_format = :bullet
44
+ # This is the default bullet Word uses
45
+ level_0.level_text = "\u00B7".encode("UTF-8")
46
+ level_0.alignment = :left
47
+ level_0.character_style.font.ascii = "Symbol"
48
+ level_0.character_style.font.high_ansi = "Symbol"
49
+ level_0.character_style.font.hint = :default
50
+ level_0.paragraph_style.indentation.left = 720
51
+ level_0.paragraph_style.indentation.hanging = 360
52
+ abstract_numbering << level_0
53
+
54
+ package.numbering << abstract_numbering
55
+
56
+ package.document << create_paragraph("Example of adding a list to a document")
57
+
58
+ list_item = create_paragraph("First list item")
59
+ list_item.paragraph_style = 'ListParagraph'
60
+ # Say that this list item belongs to our first abstract numbering:
61
+ list_item.numbering.level = 0
62
+ list_item.numbering.id = 1
63
+ # This ID is NOT the numbering ID we created above. Instead, it is a concrete
64
+ # numbering that defines an instance of a list in the document. To link it to
65
+ # our existing abstract numbering, we need to create a concrete numbering
66
+ # instance:
67
+
68
+ numbering = Numbering.new(1)
69
+ # Setting the abstract numbering ID here links it to a given abstract numbering
70
+ numbering.abstract_numbering_id = 0
71
+
72
+ # And add this number to the numbering
73
+ package.numbering << numbering
74
+
75
+ # All that allows us to finally add the item to the document.
76
+
77
+ package.document << list_item
78
+
79
+ list_item = create_paragraph("Second list item")
80
+ list_item.paragraph_style = 'ListParagraph'
81
+
82
+ # The second list item is simpler: we can reuse the numbering we used above.
83
+ list_item.numbering.level = 0
84
+ list_item.numbering.id = 1
85
+
86
+ package.document << list_item
87
+
88
+ package.document << create_paragraph("Outline Example")
89
+
90
+ # Lists with numbers are a bit more complicated. The following creates an
91
+ # "outline" list:
92
+
93
+ abstract_numbering = AbstractNumbering.new(1)
94
+
95
+ [:upperRoman, :upperLetter, :decimal, :lowerLetter, :lowerRoman, :decimal, :lowerLetter].each.with_index do |number_format, index|
96
+ level = Level.new
97
+ level.level = index
98
+ level.start = 1
99
+ level.number_format = number_format
100
+ # Level text replacement tokens are always 1-based, while the levels
101
+ # themselves are 0-based
102
+ level.level_text = index < 4 ? "%#{index+1}." : "(%#{index+1})"
103
+ level.alignment = :left
104
+ level.paragraph_style.indentation.left = (360 * (index+1))
105
+ level.paragraph_style.indentation.hanging = 360
106
+ abstract_numbering << level
107
+ end
108
+
109
+ package.numbering << abstract_numbering
110
+
111
+ numbering = Numbering.new(2)
112
+ numbering.abstract_numbering_id = 1
113
+
114
+ package.numbering << numbering
115
+
116
+ (0..6).each do |level|
117
+ list_item = create_paragraph("Level #{level+1}")
118
+ list_item.paragraph_style = 'ListParagraph'
119
+ list_item.numbering.level = level
120
+ list_item.numbering.id = 2
121
+ package.document << list_item
122
+ end
123
+
124
+ filename = "numbering_example.docx"
125
+ package.save File.expand_path("#{filename}")
@@ -0,0 +1,34 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class AbstractNumbering < OpenXml::Docx::Element
5
+ include HasChildren, HasProperties
6
+ tag :abstractNum
7
+
8
+ def initialize(id)
9
+ super()
10
+ self.id = id
11
+ end
12
+ # TODO: child levels is limited to a max of 9
13
+
14
+ with_namespace :w do
15
+ attribute :id, expects: :integer, displays_as: :abstractNumId#, required: true
16
+ end
17
+
18
+ # value_property :nsid - this is a UI property and likely not worth implementing
19
+ value_property :multi_level_type
20
+ # value_property :tmpl - this is a UI property and likely not worth implementing
21
+ # value_property :name
22
+ # value_property :style_link
23
+ # value_property :num_style_link
24
+
25
+ def property_xml(xml)
26
+ props = properties.keys.map(&method(:send)).compact
27
+ return if props.none?(&:render?)
28
+
29
+ props.each { |prop| prop.to_xml(xml) }
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,53 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class Level < OpenXml::Docx::Element
5
+ include HasChildren, HasProperties
6
+ tag :lvl
7
+
8
+ with_namespace :w do
9
+ attribute :level, expects: :integer, displays_as: :ilvl # required
10
+ # tplc is an entirely opaque "Word template code" and is
11
+ # "application-specific" according to the spec
12
+ attribute :template_code, expects: :long_hex_number, displays_as: :tplc
13
+ attribute :tentative, expects: :boolean
14
+ end
15
+
16
+ value_property :start
17
+ value_property :number_format
18
+ value_property :level_restart
19
+ value_property :associated_paragraph_style, as: :paragraph_style
20
+ value_property :legal_numbering
21
+ value_property :suffix
22
+ value_property :level_text
23
+ # TODO: Add pic_bullet support (this refers to an element that isn't
24
+ # implemented in the Numbering part)
25
+ # value_property :lvl_pic_bullet_id
26
+ value_property :alignment, as: :level_alignment
27
+
28
+ def paragraph_style
29
+ @paragraph_style ||= Paragraph.new
30
+ end
31
+
32
+ def character_style
33
+ @character_style ||= Run.new
34
+ end
35
+
36
+ def property_xml(xml)
37
+ props = properties.keys.map(&method(:send)).compact
38
+ return if props.none?(&:render?)
39
+
40
+ props.each { |prop| prop.to_xml(xml) }
41
+ end
42
+
43
+ def to_xml(xml)
44
+ xml["w"].public_send(tag, xml_attributes) {
45
+ property_xml(xml)
46
+ @paragraph_style.property_xml(xml) unless @paragraph_style.nil?
47
+ @character_style.property_xml(xml) unless @character_style.nil?
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,27 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class LevelOverride < OpenXml::Docx::Element
5
+ include HasChildren, HasProperties
6
+ tag :lvlOverride
7
+
8
+ with_namespace :w do
9
+ attribute :level, expects: :integer, displays_as: :ilvl # required
10
+ end
11
+
12
+ value_property :start_override
13
+
14
+ def override
15
+ @override ||= Level.new
16
+ end
17
+
18
+ def to_xml(xml)
19
+ xml["w"].public_send(tag, xml_attributes) {
20
+ start_override.to_xml(xml)
21
+ @override.to_xml(xml) unless @override.nil?
22
+ }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Elements
4
+ class Numbering < OpenXml::Docx::Element
5
+ include HasChildren, HasProperties
6
+ tag :num
7
+
8
+ def initialize(id)
9
+ super()
10
+ self.id = id
11
+ end
12
+ # TODO: child lvlOverride is limited to 9
13
+
14
+ with_namespace :w do
15
+ attribute :id, expects: :integer, displays_as: :numId#, required: true
16
+ end
17
+
18
+ value_property :abstract_numbering_id
19
+
20
+ def property_xml(xml)
21
+ props = properties.keys.map(&method(:send)).compact
22
+ return if props.none?(&:render?)
23
+
24
+ props.each { |prop| prop.to_xml(xml) }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -10,6 +10,7 @@ module OpenXml
10
10
  :footers,
11
11
  :styles,
12
12
  :fonts,
13
+ :numbering,
13
14
  :image_names
14
15
 
15
16
  content_types do
@@ -23,6 +24,7 @@ module OpenXml
23
24
  override "/word/styles.xml", TYPE_STYLES
24
25
  override "/word/settings.xml", TYPE_SETTINGS
25
26
  override "/word/fontTable.xml", TYPE_FONT_TABLE
27
+ override "/word/numbering.xml", TYPE_NUMBERING
26
28
  end
27
29
 
28
30
  def initialize
@@ -32,6 +34,7 @@ module OpenXml
32
34
  @settings = OpenXml::Docx::Parts::Settings.new
33
35
  @styles = OpenXml::Docx::Parts::Styles.new
34
36
  @fonts = OpenXml::Docx::Parts::Fonts.new
37
+ @numbering = OpenXml::Docx::Parts::Numbering.new
35
38
  @document = OpenXml::Docx::Parts::Document.new
36
39
  @headers = []
37
40
  @footers = []
@@ -40,6 +43,7 @@ module OpenXml
40
43
  document.relationships.add_relationship REL_STYLES, "styles.xml"
41
44
  document.relationships.add_relationship REL_SETTINGS, "settings.xml"
42
45
  document.relationships.add_relationship REL_FONT_TABLE, "fontTable.xml"
46
+ document.relationships.add_relationship REL_NUMBERING, "numbering.xml"
43
47
 
44
48
  add_part "word/_rels/document.xml.rels", document.relationships
45
49
  add_part "word/_rels/fontTable.xml.rels", fonts.relationships
@@ -47,6 +51,7 @@ module OpenXml
47
51
  add_part "word/settings.xml", settings
48
52
  add_part "word/styles.xml", styles
49
53
  add_part "word/fontTable.xml", fonts
54
+ add_part "word/numbering.xml", numbering
50
55
  end
51
56
 
52
57
  def embed_truetype_font(path: nil, name: nil)
@@ -97,7 +102,7 @@ module OpenXml
97
102
  def add_header(header)
98
103
  headers << header
99
104
  header_name = "header#{headers.count}.xml"
100
- Package.content_types { override "/word/#{header_name}", TYPE_HEADER }
105
+ content_types.add_override "/word/#{header_name}", TYPE_HEADER
101
106
  add_part "word/#{header_name}", header
102
107
  add_part "word/_rels/#{header_name}.rels", header.relationships
103
108
  relationship = document.relationships.add_relationship REL_HEADER, header_name
@@ -107,7 +112,7 @@ module OpenXml
107
112
  def add_footer(footer)
108
113
  footers << footer
109
114
  footer_name = "footer#{footers.count}.xml"
110
- Package.content_types { override "/word/#{footer_name}", TYPE_FOOTER }
115
+ content_types.add_override "/word/#{footer_name}", TYPE_FOOTER
111
116
  add_part "word/#{footer_name}", footer
112
117
  add_part "word/_rels/#{footer_name}.rels", footer.relationships
113
118
  relationship = document.relationships.add_relationship REL_FOOTER, footer_name
@@ -0,0 +1,42 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Parts
4
+ class Numbering < OpenXml::Part
5
+ include RootNamespaces
6
+
7
+ attr_reader :abstractNumbers, :numbers
8
+
9
+ use_namespaces :w
10
+
11
+ def initialize
12
+ @abstractNumbers = []
13
+ @numbers = []
14
+ @relationships = OpenXml::Parts::Rels.new
15
+ end
16
+
17
+ def <<(child)
18
+ if child.is_a?(OpenXml::Docx::Elements::AbstractNumbering)
19
+ abstractNumbers << child
20
+ elsif child.is_a?(OpenXml::Docx::Elements::Numbering)
21
+ numbers << child
22
+ end
23
+ end
24
+
25
+ def count
26
+ abstractNums.count
27
+ end
28
+
29
+ def to_xml
30
+ build_standalone_xml do |xml|
31
+ xml.numbering(root_namespaces) {
32
+ xml.parent.namespace = :w
33
+ abstractNumbers.each { |num| num.to_xml(xml) }
34
+ numbers.each { |number| number.to_xml(xml) }
35
+ }
36
+ end
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class AbstractNumberingId < IntegerProperty
5
+ tag :abstractNumId
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class LegalNumbering < OnOffProperty
5
+ tag :isLgl
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class LevelAlignment < ValueProperty
5
+ tag :lvlJc
6
+
7
+ def ok_values
8
+ %i(both center distribute end highKashida lowKashida mediumKashida numTab start thaiDistribute left right)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class LevelRestart < IntegerProperty
5
+ tag :lvlRestart
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class LevelText < StringProperty
5
+ include HasAttributes
6
+ tag :lvlText
7
+
8
+ with_namespace :w do
9
+ attribute :null, expects: :boolean
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class MultiLevelType < ValueProperty
5
+ tag :multiLevelType
6
+
7
+ def ok_values
8
+ %i(singleLevel multilevel hybridMultilevel)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,46 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class NumberFormat < ValueProperty
5
+ tag :numFmt
6
+
7
+ # TODO: Also allow "format" when "custom" is the number format
8
+
9
+ def ok_values
10
+ %i(decimal upperRoman lowerRoman upperLetter lowerLetter ordinal
11
+ cardinalText ordinalText hex chicago ideographDigital japaneseCounting
12
+ aiueo iroha decimalFullWidth decimalHalfWidth japaneseLegal
13
+ japaneseDigitalTenThousand decimalEnclosedCircle decimalFullWidth2
14
+ aiueoFullWidth irohaFullWidth decimalZero bullet ganada chosung
15
+ decimalEnclosedFullstop
16
+ decimalEnclosedParen
17
+ decimalEnclosedCircleChinese
18
+ ideographEnclosedCircle
19
+ ideographTraditional
20
+ ideographZodiac
21
+ ideographZodiacTraditional
22
+ taiwaneseCounting
23
+ ideographLegalTraditional
24
+ taiwaneseCountingThousand
25
+ taiwaneseDigital
26
+ chineseCounting
27
+ chineseLegalSimplified
28
+ chineseCountingThousand
29
+ koreanDigital
30
+ koreanCounting
31
+ koreanLegal
32
+ koreanDigital2
33
+ vietnameseCounting
34
+ russianLower russianUpper
35
+ none numberInDash
36
+ hebrew1 hebrew2
37
+ arabicAlpha arabicAbjad
38
+ hindiVowels hindiConsonants hindiNumbers hindiCounting
39
+ thaiLetters thaiNumbers thaiCounting
40
+ bahtText
41
+ dollarText custom)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,10 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class Start < IntegerProperty
5
+ tag :start
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class StartOverride < IntegerProperty
5
+ tag :startOverride
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module OpenXml
2
+ module Docx
3
+ module Properties
4
+ class Suffix < ValueProperty
5
+ tag :suff
6
+
7
+ def ok_values
8
+ %i(tab space nothing)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -4,7 +4,7 @@ module OpenXml
4
4
  class Tab < BaseProperty
5
5
  attr_reader :position, :type, :leader
6
6
 
7
- VALID_TYPES = %i(bar center clear decimal end num start)
7
+ VALID_TYPES = %i(bar center clear decimal end num start left right)
8
8
  VALID_LEADERS = [nil, :dot, :heavy, :hyphen, :middleDot, :none, :underscore]
9
9
 
10
10
  def initialize(position, type, leader=nil)
@@ -1,5 +1,5 @@
1
1
  module OpenXml
2
2
  module Docx
3
- VERSION = "0.11.0.rc"
3
+ VERSION = "0.11.3"
4
4
  end
5
5
  end
data/lib/openxml/docx.rb CHANGED
@@ -7,6 +7,7 @@ module OpenXml
7
7
  REL_FOOTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer".freeze
8
8
  REL_FONT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable".freeze
9
9
  REL_FONT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font".freeze
10
+ REL_NUMBERING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering".freeze
10
11
  REL_IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image".freeze
11
12
 
12
13
  TYPE_STYLES = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml".freeze
@@ -14,6 +15,7 @@ module OpenXml
14
15
  TYPE_HEADER = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml".freeze
15
16
  TYPE_FOOTER = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml".freeze
16
17
  TYPE_FONT_TABLE = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml".freeze
18
+ TYPE_NUMBERING = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml".freeze
17
19
  TYPE_XML = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml".freeze
18
20
  TYPE_OBSCURED_FONT = "application/vnd.openxmlformats-officedocument.obfuscatedFont".freeze
19
21
  TYPE_IMAGE = {
@@ -61,7 +61,7 @@ module OpenXml
61
61
 
62
62
  def valid_diagram_layout(value)
63
63
  message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
64
- raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
64
+ raise ArgumentError, message unless (value.is_a?(Integer) && (0..3).include?(value)) || value =~ /^[0-3]$/
65
65
  end
66
66
 
67
67
  end
@@ -76,7 +76,7 @@ module OpenXml
76
76
 
77
77
  def valid_diagram_layout(value)
78
78
  message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
79
- raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
79
+ raise ArgumentError, message unless (value.is_a?(Integer) && (0..3).include?(value)) || value =~ /^[0-3]$/
80
80
  end
81
81
  end
82
82
  end
@@ -82,7 +82,7 @@ module OpenXml
82
82
 
83
83
  def valid_diagram_layout(value)
84
84
  message = "Invalid diagram layout. Must be a single digit between 0 and 3 inclusive"
85
- raise ArgumentError, message unless (value.is_a?(Fixnum) && (0..3).include?(value)) || value =~ /^[0-3]$/
85
+ raise ArgumentError, message unless (value.is_a?(Integer) && (0..3).include?(value)) || value =~ /^[0-3]$/
86
86
  end
87
87
 
88
88
  end
data/openxml-docx.gemspec CHANGED
@@ -19,16 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.required_ruby_version = "~> 2.0"
22
+ spec.required_ruby_version = ">= 2.0"
23
23
 
24
24
  spec.add_dependency "nokogiri"
25
25
  spec.add_dependency "openxml-package", ">= 0.2.2"
26
26
  spec.add_dependency "openxml-drawingml"
27
-
28
- # Ox 2.4.10 changed how special characters are encoded,
29
- # but a few of openxml-docx's tests rely on the previous
30
- # behavior. Remove this line after refactoring those tests.
31
- spec.add_dependency "ox", "~> 2.4.3", "< 2.4.10"
27
+ spec.add_dependency "ox", "~> 2.9"
32
28
 
33
29
  spec.add_development_dependency "pry"
34
30
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openxml-docx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0.rc
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene Doyel
8
8
  - Bob Lail
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-06-13 00:00:00.000000000 Z
12
+ date: 2021-10-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -59,20 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 2.4.3
63
- - - "<"
64
- - !ruby/object:Gem::Version
65
- version: 2.4.10
62
+ version: '2.9'
66
63
  type: :runtime
67
64
  prerelease: false
68
65
  version_requirements: !ruby/object:Gem::Requirement
69
66
  requirements:
70
67
  - - "~>"
71
68
  - !ruby/object:Gem::Version
72
- version: 2.4.3
73
- - - "<"
74
- - !ruby/object:Gem::Version
75
- version: 2.4.10
69
+ version: '2.9'
76
70
  - !ruby/object:Gem::Dependency
77
71
  name: pry
78
72
  requirement: !ruby/object:Gem::Requirement
@@ -165,8 +159,8 @@ executables: []
165
159
  extensions: []
166
160
  extra_rdoc_files: []
167
161
  files:
162
+ - ".github/workflows/ci.yml"
168
163
  - ".gitignore"
169
- - ".travis.yml"
170
164
  - Gemfile
171
165
  - Gemfile.lock
172
166
  - LICENSE.txt
@@ -178,6 +172,7 @@ files:
178
172
  - examples/booklet-printing
179
173
  - examples/drawing-ml
180
174
  - examples/image-embedding
175
+ - examples/numbering
181
176
  - examples/ochanomizu.jpg
182
177
  - examples/table
183
178
  - lib/openxml-docx.rb
@@ -185,6 +180,7 @@ files:
185
180
  - lib/openxml/docx/element.rb
186
181
  - lib/openxml/docx/elements.rb
187
182
  - lib/openxml/docx/elements/absolute_position_tab.rb
183
+ - lib/openxml/docx/elements/abstract_numbering.rb
188
184
  - lib/openxml/docx/elements/background.rb
189
185
  - lib/openxml/docx/elements/bidi_embed.rb
190
186
  - lib/openxml/docx/elements/bidi_override.rb
@@ -217,6 +213,8 @@ files:
217
213
  - lib/openxml/docx/elements/grid_column.rb
218
214
  - lib/openxml/docx/elements/group_shape.rb
219
215
  - lib/openxml/docx/elements/last_rendered_page_break.rb
216
+ - lib/openxml/docx/elements/level.rb
217
+ - lib/openxml/docx/elements/level_override.rb
220
218
  - lib/openxml/docx/elements/long_day.rb
221
219
  - lib/openxml/docx/elements/long_month.rb
222
220
  - lib/openxml/docx/elements/long_year.rb
@@ -224,6 +222,7 @@ files:
224
222
  - lib/openxml/docx/elements/markup_compatibility_choice.rb
225
223
  - lib/openxml/docx/elements/markup_compatibility_fallback.rb
226
224
  - lib/openxml/docx/elements/nonbreaking_hyphen.rb
225
+ - lib/openxml/docx/elements/numbering.rb
227
226
  - lib/openxml/docx/elements/optional_hyphen.rb
228
227
  - lib/openxml/docx/elements/page_number.rb
229
228
  - lib/openxml/docx/elements/paper_source.rb
@@ -277,9 +276,11 @@ files:
277
276
  - lib/openxml/docx/parts/fonts.rb
278
277
  - lib/openxml/docx/parts/footer.rb
279
278
  - lib/openxml/docx/parts/header.rb
279
+ - lib/openxml/docx/parts/numbering.rb
280
280
  - lib/openxml/docx/parts/settings.rb
281
281
  - lib/openxml/docx/parts/styles.rb
282
282
  - lib/openxml/docx/properties.rb
283
+ - lib/openxml/docx/properties/abstract_number_id.rb
283
284
  - lib/openxml/docx/properties/alignment.rb
284
285
  - lib/openxml/docx/properties/auto_adjust_right_indent.rb
285
286
  - lib/openxml/docx/properties/auto_space_de.rb
@@ -342,14 +343,20 @@ files:
342
343
  - lib/openxml/docx/properties/language.rb
343
344
  - lib/openxml/docx/properties/latent_styles.rb
344
345
  - lib/openxml/docx/properties/latent_styles_exception.rb
346
+ - lib/openxml/docx/properties/legal_numbering.rb
347
+ - lib/openxml/docx/properties/level_alignment.rb
348
+ - lib/openxml/docx/properties/level_restart.rb
349
+ - lib/openxml/docx/properties/level_text.rb
345
350
  - lib/openxml/docx/properties/line_numbering.rb
346
351
  - lib/openxml/docx/properties/linked_style.rb
347
352
  - lib/openxml/docx/properties/manual_width.rb
348
353
  - lib/openxml/docx/properties/math.rb
349
354
  - lib/openxml/docx/properties/mirror_indent.rb
355
+ - lib/openxml/docx/properties/multi_level_type.rb
350
356
  - lib/openxml/docx/properties/next_style.rb
351
357
  - lib/openxml/docx/properties/no_proof.rb
352
358
  - lib/openxml/docx/properties/no_wrap.rb
359
+ - lib/openxml/docx/properties/number_format.rb
353
360
  - lib/openxml/docx/properties/numbering.rb
354
361
  - lib/openxml/docx/properties/on_off_property.rb
355
362
  - lib/openxml/docx/properties/outline.rb
@@ -386,6 +393,8 @@ files:
386
393
  - lib/openxml/docx/properties/snap_to_grid.rb
387
394
  - lib/openxml/docx/properties/spacing.rb
388
395
  - lib/openxml/docx/properties/spec_vanish.rb
396
+ - lib/openxml/docx/properties/start.rb
397
+ - lib/openxml/docx/properties/start_override.rb
389
398
  - lib/openxml/docx/properties/strikethrough.rb
390
399
  - lib/openxml/docx/properties/string_property.rb
391
400
  - lib/openxml/docx/properties/style.rb
@@ -393,6 +402,7 @@ files:
393
402
  - lib/openxml/docx/properties/style_auto_redefinition.rb
394
403
  - lib/openxml/docx/properties/style_lock.rb
395
404
  - lib/openxml/docx/properties/style_name.rb
405
+ - lib/openxml/docx/properties/suffix.rb
396
406
  - lib/openxml/docx/properties/supress_auto_hyphens.rb
397
407
  - lib/openxml/docx/properties/supress_line_numbers.rb
398
408
  - lib/openxml/docx/properties/supress_overlap.rb
@@ -452,24 +462,23 @@ homepage: https://github.com/openxml/openxml-docx
452
462
  licenses:
453
463
  - MIT
454
464
  metadata: {}
455
- post_install_message:
465
+ post_install_message:
456
466
  rdoc_options: []
457
467
  require_paths:
458
468
  - lib
459
469
  required_ruby_version: !ruby/object:Gem::Requirement
460
470
  requirements:
461
- - - "~>"
471
+ - - ">="
462
472
  - !ruby/object:Gem::Version
463
473
  version: '2.0'
464
474
  required_rubygems_version: !ruby/object:Gem::Requirement
465
475
  requirements:
466
- - - ">"
476
+ - - ">="
467
477
  - !ruby/object:Gem::Version
468
- version: 1.3.1
478
+ version: '0'
469
479
  requirements: []
470
- rubyforge_project:
471
- rubygems_version: 2.6.11
472
- signing_key:
480
+ rubygems_version: 3.1.6
481
+ signing_key:
473
482
  specification_version: 4
474
483
  summary: Implements the Office Open XML spec for creating WordprocessingML documents
475
484
  test_files: []
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- # .travis.yml
2
- language: ruby
3
- rvm:
4
- - 2.3.0
5
- script:
6
- - bundle exec rake spec