ooxml_parser 0.34.0 → 0.34.1

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: 9dc34421044dd53e46d0d5c355dac61acfe6bbb825381cb4c1d0aca2b5b78daf
4
+ data.tar.gz: d7ef26c1cdc5d94a7c355ae64437f23663d5c1579d651427bbac0bf83a03964e
5
5
  SHA512:
6
- metadata.gz: 124354363a41cda9a479196831b71d5e0459e3247f8b4968b46da0aebb2e22d9672263fcee5722db253b748232a5120e56fc8bda5a6b33b40d3727de1f1f8fa2
7
- data.tar.gz: f7558e9d79eadde76d2609b270579e573490dcb2d36ddaf7be0af06468113ae480c141857bbf0fbd6cfb41df15b549c7520f51b0cb088d75c092f402d4e6aad5
6
+ metadata.gz: 358fb82db492d965faeb84fcb356d18db1e04c759bd17e2cb76398abe20b353e76fb7f4359c7235f2004f4acdc440c0b1fb8bddc8b0075c65f5832caca0d8c16
7
+ data.tar.gz: e1d817d32dc5de38bb6ae960a50300068405fc079eb63f14c266a4cf472840f706e54586996b45ba80cb4af16c6615a05eafc56889a55f1289ea32fa1a551c66
@@ -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)
@@ -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,20 @@ 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
+ root_object.styles&.default_style(:paragraph)&.paragraph_properties&.indent
247
+ end
248
+
233
249
  # Fill data from styles
234
250
  # @param character_style [DocxParagraphRun] style to parse
235
251
  # @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.1'
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.1
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-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri