Class: OoxmlParser::NumberingProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::NumberingProperties
- Defined in:
- lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#ilvls ⇒ Object
Returns the value of attribute ilvls.
-
#multilevel_type ⇒ Object
Returns the value of attribute multilevel_type.
-
#nsid ⇒ Object
Returns the value of attribute nsid.
-
#tmpl ⇒ Object
Returns the value of attribute tmpl.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id = nil, multilevel_type = nil, ilvls = []) ⇒ NumberingProperties
constructor
A new instance of NumberingProperties.
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file
Constructor Details
#initialize(id = nil, multilevel_type = nil, ilvls = []) ⇒ NumberingProperties
Returns a new instance of NumberingProperties.
6 7 8 9 10 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb', line 6 def initialize(id = nil, multilevel_type = nil, ilvls = []) @id = id @multilevel_type = multilevel_type @ilvls = ilvls end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb', line 4 def id @id end |
#ilvls ⇒ Object
Returns the value of attribute ilvls.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb', line 4 def ilvls @ilvls end |
#multilevel_type ⇒ Object
Returns the value of attribute multilevel_type.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb', line 4 def multilevel_type @multilevel_type end |
#nsid ⇒ Object
Returns the value of attribute nsid.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb', line 4 def nsid @nsid end |
#tmpl ⇒ Object
Returns the value of attribute tmpl.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb', line 4 def tmpl @tmpl end |
Class Method Details
.parse(id) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb', line 12 def self.parse(id) doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/numbering.xml'), 'r:UTF-8') numbering = NumberingProperties.new numbering.id = id doc.search('//w:num').each do |num| next unless id == num.attribute('numId').value num.xpath('w:abstractNumId').each do |abstract_num_id| abstract_num_id = abstract_num_id.attribute('val').value doc.search('//w:abstractNum').each do |abstract_num| next unless abstract_num_id == abstract_num.attribute('abstractNumId').value abstract_num.xpath('w:multiLevelType').each do |multilevel_type| numbering.multilevel_type = multilevel_type.attribute('val').value end lvls = [] abstract_num.xpath('w:lvl').each do |lvl| numbering_lvl = NumberingLevel.new numbering_lvl.ilvl = lvl.attribute('ilvl').value lvl.xpath('w:start').each do |start| numbering_lvl.start = start.attribute('val').value end lvl.xpath('w:numFmt').each do |num_format| numbering_lvl.num_format = num_format.attribute('val').value end lvl.xpath('w:lvlText').each do |level_text| numbering_lvl.level_text = level_text.attribute('val').value end lvl.xpath('w:lvlJc').each do |level_jc| numbering_lvl.level_jc = level_jc.attribute('val').value end lvl.xpath('w:pPr').each do |p_pr| p_pr.xpath('w:ind').each do |ind| numbering_lvl.ind = Indents.parse(ind) end lvl.xpath('w:rPr').each do |r_pr| r_pr.xpath('w:rFonts').each do |r_fonts| if !r_fonts.attribute('ascii').nil? numbering_lvl.font = r_fonts.attribute('ascii').value elsif !r_fonts.attribute('hAnsi').nil? numbering_lvl.font = r_fonts.attribute('hAnsi').value elsif !r_fonts.attribute('eastAsia').nil? numbering_lvl.font = r_fonts.attribute('eastAsia').value else numbering_lvl.font = r_fonts.attribute('cs').value unless r_fonts.attribute('cs').nil? end end end end lvls << numbering_lvl end numbering.ilvls = lvls end end end numbering end |