ooxml_parser 0.34.0 → 0.34.2

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: 0e89bbef1bb5d024074a4c344543e90b00a87f12699c65c43fb43b2dbcc9cd55
4
- data.tar.gz: 34d0c7a756143e4d9eee8f5276c369f2d55e8776cba0f9c018f6ad7d54d40b2a
3
+ metadata.gz: eb6ab2462b53e26803ec7441c3f9b4a5217003952535f1f8578824d310c3aa78
4
+ data.tar.gz: 90610d1f3650f86f70f096060f3a5b20a2b54de950c36bc4cd7ef42bcc55ca77
5
5
  SHA512:
6
- metadata.gz: 124354363a41cda9a479196831b71d5e0459e3247f8b4968b46da0aebb2e22d9672263fcee5722db253b748232a5120e56fc8bda5a6b33b40d3727de1f1f8fa2
7
- data.tar.gz: f7558e9d79eadde76d2609b270579e573490dcb2d36ddaf7be0af06468113ae480c141857bbf0fbd6cfb41df15b549c7520f51b0cb088d75c092f402d4e6aad5
6
+ metadata.gz: f71b9fd4e5156a6dd60335587a1164cddf107f2e99bdfbd413acaa59e1b55ed696ab63944254ad283860547710fe6a8346f56161fe503c61197388d11d7cff7b
7
+ data.tar.gz: 263fb808264d65c0ff6dfee7e8d1d3f88f9fe7f49233ac426a8447abbc57902d9fbe73ca29816b1e1e297cdd34e738449535a46fb4a63bfdbb2e32e0396de87e
@@ -10,7 +10,7 @@ module OoxmlParser
10
10
  attr_reader :num_id
11
11
 
12
12
  def initialize(ilvl = 0, parent: nil)
13
- @ilvl = ilvl
13
+ @default_i_level = ilvl
14
14
  super(parent: parent)
15
15
  end
16
16
 
@@ -41,13 +41,15 @@ module OoxmlParser
41
41
 
42
42
  # @return [Integer] i-level value
43
43
  def ilvl
44
+ return @default_i_level unless @i_level
45
+
44
46
  @i_level.value
45
47
  end
46
48
 
47
49
  # @return [AbstractNumbering] level list of current numbering
48
50
  def numbering_level_current
49
51
  abstruct_numbering.level_list.each do |current_ilvl|
50
- return current_ilvl if current_ilvl.ilvl == @ilvl
52
+ return current_ilvl if current_ilvl.ilvl == ilvl
51
53
  end
52
54
  nil
53
55
  end
@@ -3,8 +3,6 @@
3
3
  module OoxmlParser
4
4
  # Class for working with any tag contained only value
5
5
  class ValuedChild < OOXMLDocumentObject
6
- # @return [String] value of tag
7
- attr_accessor :value
8
6
  # @return [String] type of value
9
7
  attr_reader :type
10
8
 
@@ -30,6 +28,13 @@ module OoxmlParser
30
28
  self
31
29
  end
32
30
 
31
+ # @return [Object] value of parameter
32
+ def value
33
+ return true if type == :boolean && @value.nil?
34
+
35
+ @value
36
+ end
37
+
33
38
  private
34
39
 
35
40
  # Handle boolean value
@@ -6,7 +6,8 @@ module OoxmlParser
6
6
  # Parse default style
7
7
  # @return [void]
8
8
  def parse_default_style
9
- parse_default_paragraph_style
9
+ parse_default_style_paragraph_properties
10
+ parse_default_style_run_properties
10
11
  parse_default_character_style
11
12
  DocumentStructure.default_table_paragraph_style = DocumentStructure.default_paragraph_style.dup
12
13
  DocumentStructure.default_table_paragraph_style.spacing = Spacing.new(0, 0, 1, :auto)
@@ -33,7 +34,7 @@ module OoxmlParser
33
34
  .paragraph_properties_default
34
35
  .raw_node, 0)
35
36
  end
36
- if @styles&.document_defaults&.run_properties_default
37
+ if @styles&.document_defaults&.run_properties_default&.run_properties
37
38
  DocumentStructure.default_run_style = DocxParagraphRun.new(parent: self)
38
39
  .parse_properties(@styles
39
40
  .document_defaults
@@ -46,13 +47,17 @@ module OoxmlParser
46
47
 
47
48
  private
48
49
 
49
- # Parse default paragraph style
50
- def parse_default_paragraph_style
50
+ def parse_default_style_paragraph_properties
51
51
  return unless @styles&.default_style(:paragraph)&.paragraph_properties_node
52
52
 
53
53
  DocxParagraph.new.parse_paragraph_style(@styles.default_style(:paragraph)
54
54
  .paragraph_properties_node,
55
55
  DocumentStructure.default_run_style)
56
+ end
57
+
58
+ def parse_default_style_run_properties
59
+ return unless @styles&.default_style(:paragraph)&.run_properties_node
60
+
56
61
  DocumentStructure.default_run_style
57
62
  .parse_properties(@styles.default_style(:paragraph)
58
63
  .run_properties_node)
@@ -16,7 +16,7 @@ module OoxmlParser
16
16
  # Class for data of DocxParagraph
17
17
  class DocxParagraph < OOXMLDocumentObject
18
18
  include DocxParagraphHelper
19
- attr_accessor :number, :align, :spacing, :ind, :numbering,
19
+ attr_accessor :number, :align, :numbering,
20
20
  :character_style_array, :page_break, :borders, :keep_lines,
21
21
  :contextual_spacing, :sector_properties, :page_numbering, :section_break, :style, :keep_next,
22
22
  :orphan_control
@@ -32,6 +32,8 @@ module OoxmlParser
32
32
  attr_accessor :paragraph_id
33
33
  # @return [MathParagraph] math paragraph
34
34
  attr_reader :math_paragraph
35
+ # Set spacing value
36
+ attr_writer :spacing
35
37
  # @return [Integer] id of text (for comment)
36
38
  attr_accessor :text_id
37
39
 
@@ -59,7 +61,7 @@ module OoxmlParser
59
61
  def initialize_copy(source)
60
62
  super
61
63
  @character_style_array = source.character_style_array.clone
62
- @spacing = source.spacing.clone
64
+ @spacing = source.instance_variable_get(:@spacing).clone
63
65
  end
64
66
 
65
67
  # @return [Array<OOXMLDocumentObject>] array of child objects that contains data
@@ -204,7 +206,7 @@ module OoxmlParser
204
206
  @paragraph_style_ref = ParagraphStyleRef.new(parent: self).parse(node_child)
205
207
  fill_style_data(default_char_style)
206
208
  when 'ind'
207
- @ind = DocumentStructure.default_paragraph_style.ind.dup.parse(node_child)
209
+ @ind = DocumentStructure.default_paragraph_style.instance_variable_get(:@ind).dup.parse(node_child)
208
210
  when 'numPr'
209
211
  @numbering = NumberingProperties.new(parent: self).parse(node_child)
210
212
  when 'jc'
@@ -230,6 +232,23 @@ module OoxmlParser
230
232
  self
231
233
  end
232
234
 
235
+ def spacing
236
+ style_spacing = root_object.styles&.default_style(:paragraph)&.paragraph_properties&.spacing
237
+ return Spacing.new.fetch_from_valued_spacing(style_spacing) if style_spacing
238
+
239
+ @spacing
240
+ end
241
+
242
+ # @return [Indents] value of indents
243
+ def ind
244
+ return @ind if @ind != Indents.new
245
+
246
+ indents_from_styles = root_object.styles&.default_style(:paragraph)&.paragraph_properties&.indent
247
+ return indents_from_styles if indents_from_styles
248
+
249
+ Indents.new
250
+ end
251
+
233
252
  # Fill data from styles
234
253
  # @param character_style [DocxParagraphRun] style to parse
235
254
  # @return [void]
@@ -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.34.0'
7
+ STRING = '0.34.2'
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.34.0
4
+ version: 0.34.2
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-11-09 00:00:00.000000000 Z
13
+ date: 2022-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -625,7 +625,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
625
625
  - !ruby/object:Gem::Version
626
626
  version: '0'
627
627
  requirements: []
628
- rubygems_version: 3.3.25
628
+ rubygems_version: 3.3.26
629
629
  signing_key:
630
630
  specification_version: 4
631
631
  summary: OoxmlParser Gem