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 +4 -4
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb +4 -2
- data/lib/ooxml_parser/common_parser/common_data/valued_child.rb +7 -2
- data/lib/ooxml_parser/docx_parser/document_structure/default_style_helper.rb +9 -4
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph.rb +22 -3
- data/lib/ooxml_parser/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb6ab2462b53e26803ec7441c3f9b4a5217003952535f1f8578824d310c3aa78
|
4
|
+
data.tar.gz: 90610d1f3650f86f70f096060f3a5b20a2b54de950c36bc4cd7ef42bcc55ca77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
@
|
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 ==
|
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
|
-
|
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
|
-
|
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, :
|
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]
|
data/lib/ooxml_parser/version.rb
CHANGED
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.
|
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-
|
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.
|
628
|
+
rubygems_version: 3.3.26
|
629
629
|
signing_key:
|
630
630
|
specification_version: 4
|
631
631
|
summary: OoxmlParser Gem
|