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 +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 +8 -3
- data/lib/ooxml_parser/docx_parser/document_structure/docx_paragraph.rb +19 -3
- data/lib/ooxml_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dc34421044dd53e46d0d5c355dac61acfe6bbb825381cb4c1d0aca2b5b78daf
|
4
|
+
data.tar.gz: d7ef26c1cdc5d94a7c355ae64437f23663d5c1579d651427bbac0bf83a03964e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
@
|
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)
|
@@ -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,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]
|
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.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-
|
13
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|