Skip to content

Commit d79915c

Browse files
committed
Rename AbstractNumber/Number to AbstractNumbering/Numbering
1 parent f84ea37 commit d79915c

6 files changed

Lines changed: 25 additions & 24 deletions

File tree

examples/numbering

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ package.styles << list_style
3333

3434
# Each list needs a numbering within the numbering part of the document.
3535

36-
# Create an abstract number that describes a bulleted list:
37-
abstract_number = AbstractNumber.new(0)
36+
# Create an abstract numbering that describes a bulleted list:
37+
abstract_numbering = AbstractNumbering.new(0)
3838

39-
# Each number can have multiple levels. Define the first level as a bulleted list:
39+
# Each numbering can have multiple levels. Define the first level as a bulleted list:
4040
level_0 = Level.new
4141
level_0.level = 0
4242
level_0.start = 1
@@ -49,27 +49,28 @@ level_0.character_style.font.high_ansi = "Symbol"
4949
level_0.character_style.font.hint = :default
5050
level_0.paragraph_style.indentation.left = 720
5151
level_0.paragraph_style.indentation.hanging = 360
52-
abstract_number << level_0
52+
abstract_numbering << level_0
5353

54-
package.numbering << abstract_number
54+
package.numbering << abstract_numbering
5555

5656
package.document << create_paragraph("Example of adding a list to a document")
5757

5858
list_item = create_paragraph("First list item")
5959
list_item.paragraph_style = 'ListParagraph'
60-
# Say that this list item belongs to our first abstract number:
60+
# Say that this list item belongs to our first abstract numbering:
6161
list_item.numbering.level = 0
6262
list_item.numbering.id = 1
6363
# This ID is NOT the numbering ID we created above. Instead, it is a concrete
6464
# numbering that defines an instance of a list in the document. To link it to
65-
# our existing abstract number, we need to create a concrete number instance:
65+
# our existing abstract numbering, we need to create a concrete numbering
66+
# instance:
6667

67-
number = Number.new(1)
68-
# Setting the abstract number ID here links it to a given abstract number
69-
number.abstract_number_id = 0
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
7071

7172
# And add this number to the numbering
72-
package.numbering << number
73+
package.numbering << numbering
7374

7475
# All that allows us to finally add the item to the document.
7576

@@ -89,7 +90,7 @@ package.document << create_paragraph("Outline Example")
8990
# Lists with numbers are a bit more complicated. The following creates an
9091
# "outline" list:
9192

92-
abstract_number = AbstractNumber.new(1)
93+
abstract_numbering = AbstractNumbering.new(1)
9394

9495
[:upperRoman, :upperLetter, :decimal, :lowerLetter, :lowerRoman, :decimal, :lowerLetter].each.with_index do |number_format, index|
9596
level = Level.new
@@ -102,15 +103,15 @@ abstract_number = AbstractNumber.new(1)
102103
level.alignment = :left
103104
level.paragraph_style.indentation.left = (360 * (index+1))
104105
level.paragraph_style.indentation.hanging = 360
105-
abstract_number << level
106+
abstract_numbering << level
106107
end
107108

108-
package.numbering << abstract_number
109+
package.numbering << abstract_numbering
109110

110-
number = Number.new(2)
111-
number.abstract_number_id = 1
111+
numbering = Numbering.new(2)
112+
numbering.abstract_numbering_id = 1
112113

113-
package.numbering << number
114+
package.numbering << numbering
114115

115116
(0..6).each do |level|
116117
list_item = create_paragraph("Level #{level+1}")

lib/openxml/docx/elements/abstract_number.rb renamed to lib/openxml/docx/elements/abstract_numbering.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 Elements
4-
class AbstractNumber < OpenXml::Docx::Element
4+
class AbstractNumbering < OpenXml::Docx::Element
55
include HasChildren, HasProperties
66
tag :abstractNum
77

lib/openxml/docx/elements/level.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Level < OpenXml::Docx::Element
1616
value_property :start
1717
value_property :number_format
1818
value_property :level_restart
19-
value_property :paragraph_style
19+
value_property :associated_paragraph_style, as: :paragraph_style
2020
value_property :legal_numbering
2121
value_property :suffix
2222
value_property :level_text
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module OpenXml
22
module Docx
33
module Elements
4-
class Number < OpenXml::Docx::Element
4+
class Numbering < OpenXml::Docx::Element
55
include HasChildren, HasProperties
66
tag :num
77

@@ -15,7 +15,7 @@ def initialize(id)
1515
attribute :id, expects: :integer, displays_as: :numId#, required: true
1616
end
1717

18-
value_property :abstract_number_id
18+
value_property :abstract_numbering_id
1919

2020
def property_xml(xml)
2121
props = properties.keys.map(&method(:send)).compact

lib/openxml/docx/parts/numbering.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def initialize
1515
end
1616

1717
def <<(child)
18-
if child.is_a?(OpenXml::Docx::Elements::AbstractNumber)
18+
if child.is_a?(OpenXml::Docx::Elements::AbstractNumbering)
1919
abstractNumbers << child
20-
elsif child.is_a?(OpenXml::Docx::Elements::Number)
20+
elsif child.is_a?(OpenXml::Docx::Elements::Numbering)
2121
numbers << child
2222
end
2323
end

lib/openxml/docx/properties/abstract_number_id.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 AbstractNumberId < IntegerProperty
4+
class AbstractNumberingId < IntegerProperty
55
tag :abstractNumId
66

77
end

0 commit comments

Comments
 (0)