ooxml_parser 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +17 -1
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/chart_style.rb +4 -0
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +1 -0
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +9 -0
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis/scaling.rb +20 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +1 -1
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +3 -2
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties.rb +8 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +1 -1
  11. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +2 -2
  12. data/lib/ooxml_parser/common_parser/common_data/color.rb +11 -20
  13. data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +1 -1
  14. data/lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb +57 -0
  15. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +3 -6
  16. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +17 -1
  17. data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +12 -1
  18. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +4 -4
  19. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_document_object_helper.rb +30 -1
  20. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +5 -2
  21. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +9 -1
  22. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +1 -1
  23. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/text.rb +23 -0
  24. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +2 -2
  25. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +0 -1
  26. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs.rb +2 -2
  27. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/{tab_list/presentation_tab.rb → tabs/tab.rb} +17 -4
  28. data/lib/ooxml_parser/common_parser/common_data/table.rb +1 -1
  29. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +1 -3
  30. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb +31 -37
  31. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +4 -0
  32. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +2 -2
  33. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +4 -4
  34. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/border.rb +1 -1
  35. data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +1 -16
  36. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +14 -7
  37. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb +2 -2
  38. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended.rb +39 -0
  39. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments_extended/comment_extended.rb +24 -0
  40. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +9 -12
  41. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +1 -1
  42. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +51 -73
  43. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +2 -2
  44. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_helper.rb +8 -0
  45. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +8 -56
  46. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +2 -12
  47. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/inserted.rb +15 -1
  48. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_content.rb +30 -0
  49. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/sdt/sdt_properties.rb +28 -0
  50. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/structured_document_tag.rb +26 -0
  51. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +1 -1
  52. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +10 -10
  53. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +9 -16
  54. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +11 -9
  55. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +5 -2
  56. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +1 -3
  57. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +35 -24
  58. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data.rb +26 -0
  59. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb +33 -0
  60. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/connection_shape.rb +5 -0
  61. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +2 -0
  62. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_notes.rb +21 -0
  63. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +2 -0
  64. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +3 -3
  65. data/lib/ooxml_parser/version.rb +1 -1
  66. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +1 -1
  67. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +20 -0
  68. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill/pattern_fill.rb +2 -2
  69. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +5 -1
  70. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +10 -1
  71. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/ole_objects.rb +18 -0
  72. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +1 -1
  73. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part.rb +7 -1
  74. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter.rb +34 -0
  75. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/autofilter/filter_column.rb +28 -0
  76. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension.rb +5 -0
  77. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups.rb +31 -0
  78. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/extension_list/extension/sparkline_groups/sparkline_group.rb +113 -0
  79. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/table_part/table_style_info.rb +41 -0
  80. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +5 -11
  81. metadata +31 -14
  82. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tab_list.rb +0 -36
  83. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/tabs/paragraph_tab.rb +0 -26
@@ -0,0 +1,24 @@
1
+ module OoxmlParser
2
+ # Class for parsing `w15:commentEx` tag
3
+ class CommentExtended < OOXMLDocumentObject
4
+ # @return [Integer] id of paragraph
5
+ attr_accessor :paragraph_id
6
+ # @return [True, False] is done?
7
+ attr_accessor :done
8
+
9
+ # Parse CommentExtended object
10
+ # @param node [Nokogiri::XML:Element] node to parse
11
+ # @return [CommentExtended] result of parsing
12
+ def parse(node)
13
+ node.attributes.each do |key, value|
14
+ case key
15
+ when 'paraId'
16
+ @paragraph_id = value.value.to_i
17
+ when 'done'
18
+ @done = attribute_enabled?(value.value)
19
+ end
20
+ end
21
+ self
22
+ end
23
+ end
24
+ end
@@ -1,9 +1,11 @@
1
1
  module OoxmlParser
2
2
  # Class for describing Document Background `w:background`
3
3
  class DocumentBackground < OOXMLDocumentObject
4
- attr_accessor :color1, :size, :color2, :type
4
+ attr_reader :color1, :size, :color2, :type
5
5
  # @return [FileReference] image structure
6
- attr_accessor :file_reference
6
+ attr_reader :file_reference
7
+ # @return [Fill] fill data
8
+ attr_reader :fill
7
9
 
8
10
  def initialize(parent: nil)
9
11
  @color1 = nil
@@ -17,16 +19,11 @@ module OoxmlParser
17
19
  def parse(node)
18
20
  @color1 = Color.new(parent: self).parse_hex_string(node.attribute('color').value)
19
21
  node.xpath('v:background').each do |second_color|
20
- unless second_color.attribute('targetscreensize').nil?
21
- @size = second_color.attribute('targetscreensize').value.sub(',', 'x')
22
- end
23
- second_color.xpath('v:fill').each do |fill|
24
- if !fill.attribute('color2').nil?
25
- @color2 = Color.new(parent: self).parse_hex_string(fill.attribute('color2').value.split(' ').first.delete('#'))
26
- @type = fill.attribute('type').value
27
- elsif !fill.attribute('id').nil?
28
- @file_reference = FileReference.new(parent: self).parse(fill)
29
- @type = 'image'
22
+ @size = second_color.attribute('targetscreensize').value.sub(',', 'x') unless second_color.attribute('targetscreensize').nil?
23
+ second_color.xpath('*').each do |node_child|
24
+ case node_child.name
25
+ when 'fill'
26
+ @fill = Fill.new(parent: self).parse(node_child)
30
27
  end
31
28
  end
32
29
  end
@@ -68,7 +68,7 @@ module OoxmlParser
68
68
  when 'rPr'
69
69
  @run_properties = DocxParagraphRun.new.parse_properties(subnode)
70
70
  when 'pPr'
71
- @paragraph_properties = DocxParagraph.new(parent: self).parse_paragraph_style(subnode)
71
+ @paragraph_properties = ParagraphProperties.new(parent: self).parse(subnode)
72
72
  when 'tblPr'
73
73
  @table_properties = TableProperties.new(parent: self).parse(subnode)
74
74
  when 'trPr'
@@ -1,21 +1,32 @@
1
1
  # noinspection RubyTooManyInstanceVariablesInspection
2
2
  require_relative 'docx_paragraph/bookmark'
3
+ require_relative 'docx_paragraph/docx_paragraph_helper'
3
4
  require_relative 'docx_paragraph/docx_paragraph_run'
4
5
  require_relative 'docx_paragraph/indents'
5
6
  require_relative 'docx_paragraph/inserted'
7
+ require_relative 'docx_paragraph/structured_document_tag'
6
8
  require_relative 'docx_paragraph/frame_properties'
7
9
  require_relative 'docx_paragraph/docx_formula'
8
10
  require_relative 'docx_paragraph/style_parametres'
9
11
  module OoxmlParser
10
12
  class DocxParagraph < OOXMLDocumentObject
13
+ include DocxParagraphHelper
11
14
  attr_accessor :number, :bookmark_start, :bookmark_end, :align, :spacing, :background_color, :ind, :numbering,
12
15
  :character_style_array, :horizontal_line, :page_break, :kinoku, :borders, :keep_lines,
13
16
  :contextual_spacing, :sector_properties, :page_numbering, :section_break, :style, :keep_next,
14
17
  :orphan_control, :frame_properties
18
+ # @return [Hyperlink] hyperlink in paragraph
19
+ attr_reader :hyperlink
15
20
  # @return [ParagraphProperties] Properties of current paragraph
16
21
  attr_accessor :paragraph_properties
17
22
  # @return [Inserted] data inserted by review
18
23
  attr_accessor :inserted
24
+ # @return [Integer] id of paragraph (for comment)
25
+ attr_accessor :paragraph_id
26
+ # @return [Integer] id of text (for comment)
27
+ attr_accessor :text_id
28
+ # @return [StructuredDocumentTag] structured document tag data
29
+ attr_accessor :sdt
19
30
 
20
31
  def initialize(parent: nil)
21
32
  @number = 0
@@ -23,53 +34,26 @@ module OoxmlParser
23
34
  @bookmark_end = []
24
35
  @align = 'left'
25
36
  @spacing = Spacing.new
26
- @background_color = nil
27
37
  @ind = Indents.new
28
38
  @kinoku = false
29
- @numbering = nil
30
39
  @character_style_array = []
31
40
  @horizontal_line = false
32
41
  @page_break = false
33
42
  @borders = Borders.new
34
43
  @keep_lines = false
35
44
  @contextual_spacing = false
36
- @sector_properties = nil
37
45
  @page_numbering = false
38
- @section_break = nil
39
- @style = nil
40
46
  @keep_next = false
41
47
  @orphan_control = true
42
- @frame_properties = nil
43
48
  @parent = parent
44
49
  end
45
50
 
46
- def copy
47
- paragraph = DocxParagraph.new
48
- paragraph.number = number
49
- paragraph.bookmark_start = @bookmark_start.dup
50
- paragraph.bookmark_end = @bookmark_end.dup
51
- paragraph.align = @align
52
- paragraph.spacing = @spacing.copy
53
- paragraph.background_color = @background_color
54
- paragraph.ind = @ind.dup
55
- paragraph.numbering = @numbering
56
- paragraph.character_style_array = @character_style_array
57
- paragraph.horizontal_line = @horizontal_line
58
- paragraph.page_break = @page_break
59
- paragraph.kinoku = @kinoku
60
- paragraph.borders = @borders
61
- paragraph.keep_lines = @keep_lines
62
- paragraph.contextual_spacing = @contextual_spacing
63
- paragraph.sector_properties = @sector_properties
64
- paragraph.page_numbering = @page_numbering
65
- paragraph.section_break = @section_break
66
- paragraph.style = @style
67
- paragraph.keep_next = @keep_next
68
- paragraph.orphan_control = @orphan_control
69
- paragraph.frame_properties = @frame_properties
70
- paragraph.paragraph_properties = @paragraph_properties
71
- paragraph.inserted = @inserted
72
- paragraph
51
+ def initialize_copy(source)
52
+ super
53
+ @bookmark_start = source.bookmark_start.clone
54
+ @bookmark_end = source.bookmark_end.clone
55
+ @character_style_array = source.character_style_array.clone
56
+ @spacing = source.spacing.clone
73
57
  end
74
58
 
75
59
  def nonempty_runs
@@ -79,6 +63,7 @@ module OoxmlParser
79
63
  !cur_run.alternate_content.nil? ||
80
64
  !cur_run.drawing.nil? ||
81
65
  !cur_run.object.nil? ||
66
+ !cur_run.shape.nil? ||
82
67
  !cur_run.footnote.nil? ||
83
68
  !cur_run.endnote.nil?
84
69
  )
@@ -88,6 +73,8 @@ module OoxmlParser
88
73
  end
89
74
  end
90
75
 
76
+ alias runs character_style_array
77
+
91
78
  # @return [True, false] if structure contain any user data
92
79
  def with_data?
93
80
  !nonempty_runs.empty?
@@ -101,24 +88,30 @@ module OoxmlParser
101
88
  end
102
89
 
103
90
  def ==(other)
104
- ignored_attributes = [:@number, :@parent]
91
+ ignored_attributes = %i[@number @parent]
105
92
  all_instance_variables = instance_variables
106
93
  significan_attribues = all_instance_variables - ignored_attributes
107
94
  significan_attribues.each do |current_attributes|
108
- unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
109
- return false
110
- end
95
+ return false unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
111
96
  end
112
97
  true
113
98
  end
114
99
 
115
100
  def parse(node, par_number = 0, default_character = DocxParagraphRun.new, parent: nil)
116
101
  @parent = parent
117
- default_character_style = default_character.copy
102
+ default_character_style = default_character.dup
118
103
  character_styles_array = []
119
- custom_character_style = default_character_style.copy
104
+ custom_character_style = default_character_style.dup
120
105
  char_number = 0
121
106
  comments = []
107
+ node.attributes.each do |key, value|
108
+ case key
109
+ when 'paraId'
110
+ @paragraph_id = value.value.to_i
111
+ when 'textId'
112
+ @text_id = value.value.to_i
113
+ end
114
+ end
122
115
  node.xpath('*').each do |node_child|
123
116
  case node_child.name
124
117
  when 'bookmarkStart'
@@ -139,37 +132,34 @@ module OoxmlParser
139
132
  instruction = node_child.attribute('instr').to_s
140
133
  @page_numbering = true if instruction.include?('PAGE')
141
134
  node_child.xpath('w:r').each do |r_tag|
142
- character_style = default_character_style.copy
135
+ character_style = default_character_style.dup
143
136
  character_style.parse(r_tag, char_number, parent: parent)
144
137
  character_style.page_number = @page_numbering
145
138
  character_style.instruction = instruction
146
- character_styles_array << character_style.copy
139
+ character_styles_array << character_style.dup
147
140
  char_number += 1
148
141
  end
149
142
  when 'r'
150
- character_style = custom_character_style.copy
143
+ character_style = custom_character_style.dup
151
144
  node_child.xpath('w:instrText').each do |insrt_text|
152
145
  @page_numbering = true if insrt_text.text.include?('PAGE')
153
146
  end
154
147
  character_style.parse(node_child, char_number, parent: self)
155
148
  character_style.comments = comments.dup
156
- character_styles_array << character_style.copy
157
- unless character_style.shape.nil?
158
- character_styles_array.last.shape = character_style.shape
159
- end
149
+ character_styles_array << character_style.dup
150
+ character_styles_array.last.shape = character_style.shape unless character_style.shape.nil?
160
151
  char_number += 1
161
152
  when 'hyperlink'
162
- character_style = default_character_style.copy
153
+ @hyperlink = Hyperlink.new(parent: self).parse(node_child)
154
+ character_style = default_character_style.dup
163
155
  if !node_child.attribute('id').nil?
164
156
  character_style.link = Hyperlink.new(parent: character_style).parse(node_child)
165
157
  else
166
- unless node_child.attribute('anchor').nil?
167
- character_style.link = node_child.attribute('anchor').value
168
- end
158
+ character_style.link = node_child.attribute('anchor').value unless node_child.attribute('anchor').nil?
169
159
  end
170
160
  node_child.xpath('w:r').each do |r_tag|
171
161
  character_style.parse(r_tag, char_number, parent: parent)
172
- character_styles_array << character_style.copy
162
+ character_styles_array << character_style.dup
173
163
  char_number += 1
174
164
  end
175
165
  node_child.xpath('w:fldSimple').each do |simple_field|
@@ -179,7 +169,7 @@ module OoxmlParser
179
169
  character_style.parse(r_tag, char_number, parent: self)
180
170
  character_style.page_number = @page_numbering
181
171
  character_style.instruction = instruction
182
- character_styles_array << character_style.copy
172
+ character_styles_array << character_style.dup
183
173
  char_number += 1
184
174
  end
185
175
  end
@@ -196,12 +186,12 @@ module OoxmlParser
196
186
  end
197
187
  when 'ins'
198
188
  @inserted = Inserted.new(parent: self).parse(node_child)
189
+ when 'sdt'
190
+ @sdt = StructuredDocumentTag.new(parent: self).parse(node_child)
199
191
  end
200
192
  end
201
193
  @number = par_number
202
- if character_styles_array.last.class == DocxParagraphRun
203
- character_styles_array.last.text = character_styles_array.last.text.rstrip
204
- end
194
+ character_styles_array.last.text = character_styles_array.last.text.rstrip if character_styles_array.last.class == DocxParagraphRun
205
195
  @character_style_array = character_styles_array
206
196
  @parent = parent
207
197
  self
@@ -211,18 +201,14 @@ module OoxmlParser
211
201
  node.xpath('*').each do |node_child|
212
202
  case node_child.name
213
203
  when 'pageBreakBefore'
214
- if node_child.attribute('val').nil? || node_child.attribute('val').value != 'false'
215
- @page_break = true
216
- end
204
+ @page_break = true if node_child.attribute('val').nil? || node_child.attribute('val').value != 'false'
217
205
  when 'pBdr'
218
206
  @borders = ParagraphBorders.new(parent: self).parse(node_child)
219
207
  when 'keepLines'
220
208
  if node_child.attribute('val').nil?
221
209
  @keep_lines = true
222
210
  else
223
- unless node_child.attribute('val').value == 'false'
224
- @keep_lines = true
225
- end
211
+ @keep_lines = true unless node_child.attribute('val').value == 'false'
226
212
  end
227
213
  when 'widowControl'
228
214
  @orphan_control = option_enabled?(node_child)
@@ -233,9 +219,7 @@ module OoxmlParser
233
219
  when 'shd'
234
220
  background_color_string = node_child.attribute('fill').value
235
221
  @background_color = Color.new(parent: self).parse_hex_string(background_color_string)
236
- unless node_child.attribute('val').nil?
237
- @background_color.set_style(node_child.attribute('val').value)
238
- end
222
+ @background_color.set_style(node_child.attribute('val').value.to_sym) unless node_child.attribute('val').nil?
239
223
  when 'pStyle'
240
224
  DocxParagraph.parse_paragraph_style_xml(node_child.attribute('val').value, self, default_char_style)
241
225
  when 'ind'
@@ -250,15 +234,9 @@ module OoxmlParser
250
234
  @align = node_child.attribute('val').value.to_sym unless node_child.attribute('val').nil?
251
235
  @align = :justify if node_child.attribute('val').value == 'both'
252
236
  when 'spacing'
253
- unless node_child.attribute('before').nil?
254
- @spacing.before = (node_child.attribute('before').value.to_f / 566.9).round(2)
255
- end
256
- unless node_child.attribute('after').nil?
257
- @spacing.after = (node_child.attribute('after').value.to_f / 566.9).round(2)
258
- end
259
- unless node_child.attribute('lineRule').nil?
260
- @spacing.line_rule = node_child.attribute('lineRule').value.sub('atLeast', 'at_least').to_sym
261
- end
237
+ @spacing.before = (node_child.attribute('before').value.to_f / 566.9).round(2) unless node_child.attribute('before').nil?
238
+ @spacing.after = (node_child.attribute('after').value.to_f / 566.9).round(2) unless node_child.attribute('after').nil?
239
+ @spacing.line_rule = node_child.attribute('lineRule').value.sub('atLeast', 'at_least').to_sym unless node_child.attribute('lineRule').nil?
262
240
  unless node_child.attribute('line').nil?
263
241
  @spacing.line = (@spacing.line_rule == :auto ? (node_child.attribute('line').value.to_f / 240.0).round(2) : (node_child.attribute('line').value.to_f / 566.9).round(2))
264
242
  end
@@ -19,9 +19,9 @@ module OoxmlParser
19
19
  node_child.xpath('*').each do |node_child_child|
20
20
  case node_child_child.name
21
21
  when 'begChr'
22
- @begin_character = node_child_child.attribute('val').value
22
+ @begin_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
23
23
  when 'endChr'
24
- @end_character = node_child_child.attribute('val').value
24
+ @end_character = ValuedChild.new(:string, parent: self).parse(node_child_child)
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,8 @@
1
+ # Stuff for help working with paragraph
2
+ module DocxParagraphHelper
3
+ # @return [Nil, CommentExtended] extended data for this comment
4
+ def comment_extend_data
5
+ return if @paragraph_id.nil?
6
+ root_object.comments_extended.by_id(@paragraph_id)
7
+ end
8
+ end
@@ -26,31 +26,21 @@ module OoxmlParser
26
26
  @vertical_align = :baseline
27
27
  @size = 11
28
28
  @font_color = Color.new
29
- @background_color = nil
30
29
  @font_style = FontStyle.new
31
30
  @text = ''
32
31
  @drawings = []
33
- @link = nil
34
- @highlight = nil
35
- @effect = nil
36
- @caps = nil
37
32
  @w = false
38
33
  @position = 0.0
39
- @em = nil
40
34
  @spacing = 0.0
41
35
  @break = false
42
- @touch = nil
43
- @footnote = nil
44
- @endnote = nil
45
- @fld_char = nil
46
- @style = nil
47
36
  @comments = []
48
- @alternate_content = nil
49
37
  @page_number = false
50
- @text_outline = nil
51
- @text_fill = nil
52
- @instruction = nil
53
- @object = nil
38
+ end
39
+
40
+ def initialize_copy(source)
41
+ super
42
+ @drawings = source.drawings.clone
43
+ @comments = source.comments.clone
54
44
  end
55
45
 
56
46
  def drawing
@@ -58,50 +48,12 @@ module OoxmlParser
58
48
  @drawings.empty? ? nil : drawings.first
59
49
  end
60
50
 
61
- def copy
62
- character = DocxParagraphRun.new
63
- character.number = number
64
- character.font = font
65
- character.vertical_align = vertical_align
66
- character.size = size
67
- character.font_color = font_color
68
- character.background_color = @background_color
69
- character.font_style = @font_style
70
- character.text = @text
71
- character.drawings = @drawings.clone
72
- character.link = @link
73
- character.highlight = @highlight
74
- character.effect = @effect
75
- character.caps = @caps
76
- character.w = @w
77
- character.position = @position
78
- character.em = @em
79
- character.spacing = @spacing
80
- character.break = @break
81
- character.touch = @touch
82
- character.footnote = @footnote
83
- character.endnote = @endnote
84
- character.fld_char = @fld_char
85
- character.style = @style
86
- character.comments = @comments.clone
87
- character.alternate_content = @alternate_content
88
- character.page_number = @page_number
89
- character.text_outline = @text_outline
90
- character.text_fill = @text_fill
91
- character.instruction = @instruction
92
- character.run_properties = @run_properties
93
- character.object = @object
94
- character
95
- end
96
-
97
51
  def ==(other)
98
- ignored_attributes = [:@number]
52
+ ignored_attributes = %i[@number @parent]
99
53
  all_instance_variables = instance_variables
100
54
  significan_attribues = all_instance_variables - ignored_attributes
101
55
  significan_attribues.each do |current_attributes|
102
- unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
103
- return false
104
- end
56
+ return false unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
105
57
  end
106
58
  true
107
59
  end