ooxml_parser 0.24.0 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7709109a298642b27297b3646d9b94c2dd73dd5ba6d52468dfe7c90c221d4809
4
- data.tar.gz: '09db15c81f7f0c31d2a0bd7f5afcb7606c8455baa7140b1d0a340234ec34e74f'
3
+ metadata.gz: 409ce77d24b38512604d5215a2bd6a54f887685db71cd9942c81935ef678f3b0
4
+ data.tar.gz: 4f7edddf4bab2d5d6ab9485754b333a2943d2df96fdcc933d671e820cd9dc70d
5
5
  SHA512:
6
- metadata.gz: 515a28a6d616cb0bd272645ab0ec4d8c5365fcbb96f58141552a70eec3a34dd3e22ff207f997f1baa4624216b3452a351e803f5b93c6edbb73f12ad344b07448
7
- data.tar.gz: e81fc4ad01b4fc326eea90a3a8758b95b9f7fe56cb4c6c46d53c2b50d0ba472007ee6c7412d0510d9550632c1ff6ff52202b6519ea8f92adb66c443137bef52c
6
+ metadata.gz: aad06b0a4dd775d5efe4411d43b87ebda68fe05a5a15924fb6773d77169141284baaf8047eee042634a2e6145649ac0fce2e9aa143d401587434598eeff5f73d
7
+ data.tar.gz: c2ab404a2ab3f559a312da5953da7a668b4ae1c359ff790bc4b4d577ccbd453e4314844125cc64e144c884f9e187389586c98f085c4d27ca5837d8a1b9e61f9d
@@ -22,8 +22,8 @@ module OoxmlParser
22
22
 
23
23
  # @return [String] text representation
24
24
  def to_s
25
- "Value: `#{value}`, "\
26
- "Color: `#{color}`, "\
25
+ "Value: `#{value}`, " \
26
+ "Color: `#{color}`, " \
27
27
  "Fill: `#{fill}`"
28
28
  end
29
29
 
@@ -38,8 +38,8 @@ module OoxmlParser
38
38
  private
39
39
 
40
40
  # This is dirty workaround for situations
41
- # Then @line_rule parsed after @line so getting
42
- # @line value is totally screwed up
41
+ # Then `@line_rule` parsed after `@line` so getting
42
+ # `@line` value is totally screwed up
43
43
  # @param [Nokogiri::XML:Node] node with ParagraphSpacing
44
44
  # @return [Hash] hash with sorted values
45
45
  # TODO: Totally redone parsing of spacing to remove this workaround
@@ -8,11 +8,11 @@ module OoxmlParser
8
8
 
9
9
  # @return [String] result of convert of object to string
10
10
  def to_s
11
- "Table position left: #{left}, "\
12
- "right: #{right}, "\
13
- "top: #{top}, "\
14
- "bottom #{bottom}, "\
15
- "position x: #{position_x}, "\
11
+ "Table position left: #{left}, " \
12
+ "right: #{right}, " \
13
+ "top: #{top}, " \
14
+ "bottom #{bottom}, " \
15
+ "position x: #{position_x}, " \
16
16
  "position y: #{position_y}"
17
17
  end
18
18
 
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `w:instrText` object
5
+ class InstructionText < TextValue
6
+ # @return [Boolean] is current object for hyperlink
7
+ def hyperlink?
8
+ value.include?('HYPERLINK')
9
+ end
10
+
11
+ # @return [Boolean] is current object for page number
12
+ def page_number?
13
+ value.match?(/PAGE\s+\\\*/)
14
+ end
15
+
16
+ # @return [Hyperlink] convert InstructionText to Hyperlink
17
+ def to_hyperlink
18
+ Hyperlink.new(value.sub('HYPERLINK ', '').split(' \\o ').first,
19
+ value.sub('HYPERLINK', '').split(' \\o ').last)
20
+ end
21
+ end
22
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # noinspection RubyTooManyInstanceVariablesInspection
4
4
  require_relative 'docx_paragraph_run/docx_paragraph_run_helpers'
5
+ require_relative 'docx_paragraph_run/instruction_text'
5
6
  require_relative 'docx_paragraph_run/object'
6
7
  require_relative 'docx_paragraph_run/text_outline'
7
8
  require_relative 'docx_paragraph_run/text_fill'
@@ -15,9 +16,9 @@ module OoxmlParser
15
16
  :link, :highlight, :effect, :caps, :w,
16
17
  :position, :em, :spacing, :break, :touch, :shape, :footnote, :endnote, :fld_char, :style,
17
18
  :comments, :alternate_content, :page_number, :text_outline, :text_fill
18
- # @return [String] type of instruction used for upper level of run
19
- # http://officeopenxml.com/WPfieldInstructions.php
20
- attr_accessor :instruction
19
+ # @return [InstructionText] text of instruction
20
+ # See ECMA-376, 17.16.23 instrText (Field Code)
21
+ attr_reader :instruction_text
21
22
  # @return [RunProperties] properties of run
22
23
  attr_accessor :run_properties
23
24
  # @return [RunObject] object of run
@@ -96,10 +97,10 @@ module OoxmlParser
96
97
  parse_properties(node_child)
97
98
  @run_properties = RunProperties.new(parent: self).parse(node_child)
98
99
  when 'instrText'
99
- if node_child.text.include?('HYPERLINK')
100
- hyperlink = Hyperlink.new(node_child.text.sub('HYPERLINK ', '').split(' \\o ').first, node_child.text.sub('HYPERLINK', '').split(' \\o ').last)
101
- @link = hyperlink
102
- elsif node_child.text[/PAGE\s+\\\*/]
100
+ @instruction_text = InstructionText.new(parent: self).parse(node_child)
101
+ if @instruction_text.hyperlink?
102
+ @link = @instruction_text.to_hyperlink
103
+ elsif @instruction_text.page_number?
103
104
  @text = '*PAGE NUMBER*'
104
105
  end
105
106
  when 'fldChar'
@@ -25,7 +25,7 @@ module OoxmlParser
25
25
  # Convert to string
26
26
  # @return [String] result of conversion
27
27
  def to_s
28
- "first line indent: #{@first_line_indent}, left indent: #{@left_indent}, "\
28
+ "first line indent: #{@first_line_indent}, left indent: #{@left_indent}, " \
29
29
  "right indent: #{@right_indent}, hanging indent: #{@hanging_indent}"
30
30
  end
31
31
 
@@ -18,7 +18,7 @@ module OoxmlParser
18
18
  # Class for data of DocxParagraph
19
19
  class DocxParagraph < OOXMLDocumentObject
20
20
  include DocxParagraphHelper
21
- attr_accessor :number, :bookmark_start, :bookmark_end, :align, :spacing, :ind, :numbering,
21
+ attr_accessor :number, :align, :spacing, :ind, :numbering,
22
22
  :character_style_array, :page_break, :borders, :keep_lines,
23
23
  :contextual_spacing, :sector_properties, :page_numbering, :section_break, :style, :keep_next,
24
24
  :orphan_control
@@ -39,8 +39,6 @@ module OoxmlParser
39
39
 
40
40
  def initialize(parent: nil)
41
41
  @number = 0
42
- @bookmark_start = []
43
- @bookmark_end = []
44
42
  @align = :left
45
43
  @spacing = Spacing.new
46
44
  @ind = Indents.new
@@ -62,8 +60,6 @@ module OoxmlParser
62
60
  # @return [void]
63
61
  def initialize_copy(source)
64
62
  super
65
- @bookmark_start = source.bookmark_start.clone
66
- @bookmark_end = source.bookmark_end.clone
67
63
  @character_style_array = source.character_style_array.clone
68
64
  @spacing = source.spacing.clone
69
65
  end
@@ -58,10 +58,9 @@ module OoxmlParser
58
58
  @slide_size = SlideSize.new(parent: self).parse(presentation_node_child)
59
59
  when 'sldIdLst'
60
60
  presentation_node_child.xpath('p:sldId').each do |silde_id_node|
61
- id = nil
62
- silde_id_node.attribute_nodes.select { |node| id = node.to_s if node.namespace && node.namespace.prefix == 'r' }
61
+ slide_id = silde_id_node.attr('r:id')
63
62
  @slides << Slide.new(parent: self,
64
- xml_path: "#{OOXMLDocumentObject.root_subfolder}/#{OOXMLDocumentObject.get_link_from_rels(id)}")
63
+ xml_path: "#{OOXMLDocumentObject.root_subfolder}/#{OOXMLDocumentObject.get_link_from_rels(slide_id)}")
65
64
  .parse
66
65
  end
67
66
  end
@@ -4,6 +4,6 @@ module OoxmlParser
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
6
  # [String] Version of Gem
7
- STRING = '0.24.0'
7
+ STRING = '0.25.0'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ooxml_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-06-10 00:00:00.000000000 Z
13
+ date: 2022-07-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -403,6 +403,7 @@ files:
403
403
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_helper.rb
404
404
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run.rb
405
405
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb
406
+ - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/instruction_text.rb
406
407
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/object.rb
407
408
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/object/ole_object.rb
408
409
  - lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/docx_paragraph_run/shape.rb
@@ -604,7 +605,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
604
605
  - !ruby/object:Gem::Version
605
606
  version: '0'
606
607
  requirements: []
607
- rubygems_version: 3.3.7
608
+ rubygems_version: 3.3.19
608
609
  signing_key:
609
610
  specification_version: 4
610
611
  summary: OoxmlParser Gem