ooxml_parser 0.5.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ooxml_parser.rb +1 -0
  3. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice.rb +1 -0
  4. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text.rb +1 -0
  5. data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text/math_paragraph.rb +1 -0
  6. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +6 -0
  7. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series.rb +2 -2
  8. data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +0 -2
  9. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +3 -0
  10. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -0
  11. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +4 -1
  12. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +1 -0
  13. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +4 -0
  14. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +0 -2
  15. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +3 -0
  16. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -3
  17. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style.rb +42 -0
  18. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/effect_reference.rb +35 -0
  19. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/fill_reference.rb +35 -0
  20. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/font_reference.rb +35 -0
  21. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/line_reference.rb +35 -0
  22. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -0
  23. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_path/docx_shape_line_element.rb +0 -2
  24. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -0
  25. data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +1 -3
  26. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +1 -3
  27. data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +1 -3
  28. data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +3 -0
  29. data/lib/ooxml_parser/common_parser/common_data/color.rb +39 -7
  30. data/lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb +5 -0
  31. data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +11 -0
  32. data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +1 -0
  33. data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +4 -0
  34. data/lib/ooxml_parser/common_parser/common_data/content_types.rb +2 -0
  35. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_default.rb +3 -0
  36. data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_override.rb +3 -0
  37. data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +7 -0
  38. data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +24 -2
  39. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +3 -0
  40. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +0 -6
  41. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +2 -0
  42. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +1 -0
  43. data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +16 -13
  44. data/lib/ooxml_parser/common_parser/common_data/table.rb +2 -0
  45. data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +3 -0
  46. data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +7 -0
  47. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +1 -0
  48. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +1 -0
  49. data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +4 -4
  50. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +4 -5
  51. data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +6 -0
  52. data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +3 -0
  53. data/lib/ooxml_parser/common_parser/common_data/underline.rb +4 -0
  54. data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +27 -3
  55. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +3 -0
  56. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +3 -0
  57. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +22 -1
  58. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark_end.rb +1 -1
  59. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/comment_range_start.rb +1 -0
  60. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/pre_sub_superscript.rb +3 -0
  61. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +13 -3
  62. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +4 -1
  63. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +0 -2
  64. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +3 -0
  65. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +2 -0
  66. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +0 -2
  67. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +5 -0
  68. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +1 -0
  69. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +3 -0
  70. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +1 -0
  71. data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -0
  72. data/lib/ooxml_parser/docx_parser/docx_parser.rb +3 -0
  73. data/lib/ooxml_parser/name.rb +1 -0
  74. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +2 -0
  75. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +3 -0
  76. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +3 -0
  77. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +3 -0
  78. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +3 -0
  79. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +15 -1
  80. data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +3 -0
  81. data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +3 -0
  82. data/lib/ooxml_parser/version.rb +2 -1
  83. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +21 -2
  84. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +3 -0
  85. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache.rb +41 -0
  86. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +37 -0
  87. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source.rb +33 -0
  88. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source/worksheet_source.rb +26 -0
  89. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +2 -0
  90. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +5 -0
  91. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +2 -0
  92. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +3 -0
  93. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +5 -0
  94. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +4 -0
  95. data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +4 -0
  96. data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +3 -0
  97. metadata +69 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc51b71e9f6946af4aebd3df5e9343a3f1a2ce016ca2d164c8f7a233dbfcbb17
4
- data.tar.gz: b9e008e9e4bde76b5136ee2cb0841d3c74bad4fc493991128e534a4bf18401dd
3
+ metadata.gz: a6c4527d0b7792aa56cbbebb6bd824ae102ef05ebd34cf5c254d237b4db91649
4
+ data.tar.gz: 2ec7cc8db0789617c92def28654e0beac19cbc5197348cb440097a0e911a6542
5
5
  SHA512:
6
- metadata.gz: 74b8eb6a6a4b61f77c5451617b640e2108c78f302ac2cfd8ee2332edfbb0085fcb5faee64b3417d3a9eb76f824d1fe6f841afa404328ceda6c584618db06a275
7
- data.tar.gz: 373108844b1ba342fe75e053cdf14af096b974957523e470ce44b6d6f1f2b0a492581b18781557d789500edae1294f885c3ce8975606ad2dea98c8bc0a81c83e
6
+ metadata.gz: d5b906924c2cd8fdfb0c199d3de2070964875bd514bfa4090160e3aec18d712d6f5a91159c9a1961d7a76569ba04aef40baedcf5127f1315fc0e628ae50c73fe
7
+ data.tar.gz: 06eb55cf4eb895dc896721e796f97e12e973af1f27fde9e463fcc74ba8994ae6d8ffe3f7d03e64c0a72283a735e9e044f68fa0e93ee0808e0457cf6a67d40100
@@ -29,6 +29,7 @@ module OoxmlParser
29
29
  @configuration ||= Configuration.new
30
30
  end
31
31
 
32
+ # Reset settings to default
32
33
  def self.reset
33
34
  @configuration = Configuration.new
34
35
  end
@@ -6,6 +6,7 @@ module OoxmlParser
6
6
  # graphic data
7
7
  class Choice < OOXMLDocumentObject
8
8
  attr_accessor :math_text
9
+
9
10
  # Parse Choice object
10
11
  # @param node [Nokogiri::XML:Element] node to parse
11
12
  # @return [Choice] result of parsing
@@ -5,6 +5,7 @@ module OoxmlParser
5
5
  # Class for storing math text
6
6
  class MathText < OOXMLDocumentObject
7
7
  attr_accessor :math_paragraph
8
+
8
9
  # Parse MathText object
9
10
  # @param node [Nokogiri::XML:Element] node to parse
10
11
  # @return [MathText] result of parsing
@@ -4,6 +4,7 @@ module OoxmlParser
4
4
  # Class for storing math paragraph
5
5
  class MathParagraph < OOXMLDocumentObject
6
6
  attr_accessor :math
7
+
7
8
  # Parse MathParagraph object
8
9
  # @param node [Nokogiri::XML:Element] node to parse
9
10
  # @return [MathParagraph] result of parsing
@@ -41,6 +41,9 @@ module OoxmlParser
41
41
  @parent = parent
42
42
  end
43
43
 
44
+ # Parse properties of Chart
45
+ # @param chart_prop_node [Nokogiri::XML:Element] node to parse
46
+ # @return [void]
44
47
  def parse_properties(chart_prop_node)
45
48
  chart_prop_node.xpath('*').each do |chart_props_node_child|
46
49
  case chart_props_node_child.name
@@ -71,6 +74,9 @@ module OoxmlParser
71
74
  extend Gem::Deprecate
72
75
  deprecate :data, 'series points interface', 2020, 1
73
76
 
77
+ # Parse Chart
78
+ # @param parent [OOOXMLDocumentObject] parent of chart
79
+ # @return [Chart] result of parsing
74
80
  def self.parse(parent: nil)
75
81
  chart = Chart.new(parent: parent)
76
82
  chart_xml = chart.parse_xml(OOXMLDocumentObject.current_xml)
@@ -11,7 +11,7 @@ module OoxmlParser
11
11
  attr_reader :order
12
12
  # @return [SeriesText] text of series
13
13
  attr_accessor :text
14
- # @return [Categories] categories of chart
14
+ # @return [SeriesText] categories of chart
15
15
  attr_accessor :categories
16
16
  # @return [DisplayLabelsProperties]
17
17
  attr_accessor :display_labels
@@ -35,7 +35,7 @@ module OoxmlParser
35
35
  when 'tx'
36
36
  @text = SeriesText.new(parent: self).parse(node_child)
37
37
  when 'cat'
38
- @categories = Categories.new(parent: self).parse(node_child)
38
+ @categories = SeriesText.new(parent: self).parse(node_child)
39
39
  when 'dLbls'
40
40
  @display_labels = DisplayLabelsProperties.new(parent: self).parse(node_child)
41
41
  when 'val'
@@ -20,6 +20,4 @@ module OoxmlParser
20
20
  self
21
21
  end
22
22
  end
23
-
24
- Categories = SeriesText
25
23
  end
@@ -5,6 +5,9 @@ module OoxmlParser
5
5
  class DocxDrawingDistanceFromText < OOXMLDocumentObject
6
6
  attr_accessor :top, :bottom, :left, :right
7
7
 
8
+ # Parse DocxDrawingDistanceFromText object
9
+ # @param node [Nokogiri::XML:Element] node to parse
10
+ # @return [DocxDrawingDistanceFromText] result of parsing
8
11
  def parse(node)
9
12
  node.attributes.each do |key, value|
10
13
  case key
@@ -18,6 +18,7 @@ module OoxmlParser
18
18
  end
19
19
  end
20
20
 
21
+ # @return [String] result of convert of object to string
21
22
  def to_s
22
23
  '(' + @x.to_s + '; ' + @y.to_s + ')'
23
24
  end
@@ -28,6 +28,9 @@ module OoxmlParser
28
28
  self
29
29
  end
30
30
 
31
+ # Compare this object to other
32
+ # @param other [Object] any other object
33
+ # @return [True, False] result of comparision
31
34
  def ==(other)
32
35
  (to_base_unit.value - other.to_base_unit.value).abs < 10**(OoxmlParser.configuration.accuracy + 2)
33
36
  end
@@ -40,7 +43,7 @@ module OoxmlParser
40
43
  # @return [String] string representation of size
41
44
  def to_s(unit = :centimeter)
42
45
  converted = to_unit(unit)
43
- "#{converted.value} #{converted.unit}"
46
+ "#{converted.value.to_f} #{converted.unit}"
44
47
  end
45
48
 
46
49
  # Convert all values to one same base unit
@@ -10,6 +10,7 @@ module OoxmlParser
10
10
 
11
11
  alias path path_to_media_file
12
12
 
13
+ # @return [String] result of convert of object to string
13
14
  def to_str
14
15
  path_to_media_file
15
16
  end
@@ -10,6 +10,9 @@ module OoxmlParser
10
10
  # @return [String] content of file
11
11
  attr_accessor :content
12
12
 
13
+ # Parse FileReference object
14
+ # @param node [Nokogiri::XML:Element] node to parse
15
+ # @return [FileReference] result of parsing
13
16
  def parse(node)
14
17
  node.attributes.each do |key, value|
15
18
  case key
@@ -26,6 +29,7 @@ module OoxmlParser
26
29
  return self
27
30
  end
28
31
  return self if @path == 'NULL'
32
+ return self if @path.match?(URI::DEFAULT_PARSER.make_regexp)
29
33
 
30
34
  full_path_to_file = OOXMLDocumentObject.path_to_folder + OOXMLDocumentObject.root_subfolder + @path.gsub('..', '')
31
35
  if File.exist?(full_path_to_file)
@@ -28,6 +28,4 @@ module OoxmlParser
28
28
  self
29
29
  end
30
30
  end
31
-
32
- Picture = DocxPicture
33
31
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'docx_shape/ooxml_text_box'
4
4
  require_relative 'docx_shape/non_visual_shape_properties'
5
+ require_relative 'docx_shape/shape_style'
5
6
  require_relative 'docx_shape/text_body'
6
7
  require_relative 'shape_properties/docx_shape_properties'
7
8
  require_relative 'shape_body_properties/ooxml_shape_body_properties'
@@ -32,6 +33,8 @@ module OoxmlParser
32
33
  @non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
33
34
  when 'spPr'
34
35
  @properties = DocxShapeProperties.new(parent: self).parse(node_child)
36
+ when 'style'
37
+ @style = ShapeStyle.new(parent: self).parse(node_child)
35
38
  when 'txbx'
36
39
  @text_body = OOXMLTextBox.new(parent: self).parse(node_child)
37
40
  when 'txBody'
@@ -3,7 +3,7 @@
3
3
  module OoxmlParser
4
4
  # Class for parsing `txbx` tags
5
5
  class OOXMLTextBox < OOXMLDocumentObject
6
- attr_accessor :properties, :elements
6
+ attr_accessor :elements
7
7
 
8
8
  def initialize(parent: nil)
9
9
  @elements = []
@@ -21,8 +21,6 @@ module OoxmlParser
21
21
  @elements << DocxParagraph.new(parent: self).parse(node_child, index)
22
22
  when 'tbl'
23
23
  @elements << Table.new(parent: self).parse(node_child, index)
24
- when 'bodyPr'
25
- @properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
26
24
  end
27
25
  end
28
26
  self
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'shape_style/effect_reference'
4
+ require_relative 'shape_style/fill_reference'
5
+ require_relative 'shape_style/font_reference'
6
+ require_relative 'shape_style/line_reference'
7
+ module OoxmlParser
8
+ # Class for parsing `wps:style` tags
9
+ class ShapeStyle < OOXMLDocumentObject
10
+ # @return [FillReference] effect reference
11
+ attr_reader :effect_reference
12
+ # @return [FillReference] fill reference
13
+ attr_reader :fill_reference
14
+ # @return [FontReference] font reference
15
+ attr_reader :font_reference
16
+ # @return [LineReference] line reference
17
+ attr_reader :line_reference
18
+
19
+ def initialize(parent: nil)
20
+ @parent = parent
21
+ end
22
+
23
+ # Parse ShapeStyle object
24
+ # @param node [Nokogiri::XML:Element] node to parse
25
+ # @return [ShapeStyle] result of parsing
26
+ def parse(node)
27
+ node.xpath('*').each do |node_child|
28
+ case node_child.name
29
+ when 'effectRef'
30
+ @effect_reference = EffectReference.new(parent: self).parse(node_child)
31
+ when 'fillRef'
32
+ @fill_reference = FillReference.new(parent: self).parse(node_child)
33
+ when 'fontRef'
34
+ @font_reference = FontReference.new(parent: self).parse(node_child)
35
+ when 'lnRef'
36
+ @line_reference = LineReference.new(parent: self).parse(node_child)
37
+ end
38
+ end
39
+ self
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `a:effectRef` tags
5
+ class EffectReference < OOXMLDocumentObject
6
+ # @return [Integer] Style Matrix Index
7
+ attr_reader :index
8
+ # @return [Color] scheme color of EffectReference
9
+ attr_reader :scheme_color
10
+
11
+ def initialize(parent: nil)
12
+ @parent = parent
13
+ end
14
+
15
+ # Parse EffectReference object
16
+ # @param node [Nokogiri::XML:Element] node to parse
17
+ # @return [EffectReference] result of parsing
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'idx'
22
+ @index = value.value.to_f
23
+ end
24
+ end
25
+
26
+ node.xpath('*').each do |node_child|
27
+ case node_child.name
28
+ when 'schemeClr'
29
+ @scheme_color = Color.new(parent: self).parse_scheme_color(node_child)
30
+ end
31
+ end
32
+ self
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `a:fillRef` tags
5
+ class FillReference < OOXMLDocumentObject
6
+ # @return [Integer] Style Matrix Index
7
+ attr_reader :index
8
+ # @return [Color] scheme color of FillReference
9
+ attr_reader :scheme_color
10
+
11
+ def initialize(parent: nil)
12
+ @parent = parent
13
+ end
14
+
15
+ # Parse FillReference object
16
+ # @param node [Nokogiri::XML:Element] node to parse
17
+ # @return [FillReference] result of parsing
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'idx'
22
+ @index = value.value.to_f
23
+ end
24
+ end
25
+
26
+ node.xpath('*').each do |node_child|
27
+ case node_child.name
28
+ when 'schemeClr'
29
+ @scheme_color = Color.new(parent: self).parse_scheme_color(node_child)
30
+ end
31
+ end
32
+ self
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `a:fontRef` tags
5
+ class FontReference < OOXMLDocumentObject
6
+ # @return [String] Font Collection Index
7
+ attr_reader :index
8
+ # @return [Color] scheme color of FontReference
9
+ attr_reader :scheme_color
10
+
11
+ def initialize(parent: nil)
12
+ @parent = parent
13
+ end
14
+
15
+ # Parse FontReference object
16
+ # @param node [Nokogiri::XML:Element] node to parse
17
+ # @return [FontReference] result of parsing
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'idx'
22
+ @index = value.value.to_s
23
+ end
24
+ end
25
+
26
+ node.xpath('*').each do |node_child|
27
+ case node_child.name
28
+ when 'schemeClr'
29
+ @scheme_color = Color.new(parent: self).parse_scheme_color(node_child)
30
+ end
31
+ end
32
+ self
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OoxmlParser
4
+ # Class for parsing `a:lnRef` tags
5
+ class LineReference < OOXMLDocumentObject
6
+ # @return [Integer] Style Matrix Index
7
+ attr_reader :index
8
+ # @return [Color] scheme color of LineReference
9
+ attr_reader :scheme_color
10
+
11
+ def initialize(parent: nil)
12
+ @parent = parent
13
+ end
14
+
15
+ # Parse LineReference object
16
+ # @param node [Nokogiri::XML:Element] node to parse
17
+ # @return [LineReference] result of parsing
18
+ def parse(node)
19
+ node.attributes.each do |key, value|
20
+ case key
21
+ when 'idx'
22
+ @index = value.value.to_f
23
+ end
24
+ end
25
+
26
+ node.xpath('*').each do |node_child|
27
+ case node_child.name
28
+ when 'schemeClr'
29
+ @scheme_color = Color.new(parent: self).parse_scheme_color(node_child)
30
+ end
31
+ end
32
+ self
33
+ end
34
+ end
35
+ end
@@ -35,6 +35,7 @@ module OoxmlParser
35
35
  self
36
36
  end
37
37
 
38
+ # @return [String] result of convert of object to string
38
39
  def to_s
39
40
  "Color: #{@color}, type: #{type}"
40
41
  end
@@ -23,8 +23,6 @@ module OoxmlParser
23
23
  @type = :arc
24
24
  when 'cubicBezTo'
25
25
  @type = :cubic_bezier
26
- when 'quadBezTo'
27
- @type = :quadratic_bezier
28
26
  when 'close'
29
27
  @type = :close
30
28
  end
@@ -16,6 +16,7 @@ module OoxmlParser
16
16
  @parent = parent
17
17
  end
18
18
 
19
+ # @return [Integer] stroke size of object
19
20
  def stroke_size
20
21
  if @color_scheme.nil? || @color_scheme.color == :none
21
22
  0
@@ -10,7 +10,7 @@ require_relative 'custom_geometry/ooxml_custom_geometry'
10
10
  module OoxmlParser
11
11
  # DOCX Shape Properties
12
12
  class DocxShapeProperties < OOXMLDocumentObject
13
- attr_accessor :shape_size, :preset_geometry, :fill_color, :text_box, :line, :custom_geometry
13
+ attr_accessor :shape_size, :preset_geometry, :fill_color, :line, :custom_geometry
14
14
  attr_accessor :blip_fill
15
15
 
16
16
  alias transform shape_size
@@ -33,8 +33,6 @@ module OoxmlParser
33
33
  @shape_size = DocxShapeSize.new(parent: self).parse(node_child)
34
34
  when 'prstGeom'
35
35
  @preset_geometry = PresetGeometry.new(parent: self).parse(node_child)
36
- when 'txbx'
37
- @text_box = TextBox.parse_list(node_child)
38
36
  when 'ln'
39
37
  @line = DocxShapeLine.new(parent: self).parse(node_child)
40
38
  when 'blipFill'
@@ -6,7 +6,7 @@ require_relative 'group/old_docx_group'
6
6
  module OoxmlParser
7
7
  # Fallback DOCX Picture
8
8
  class OldDocxPicture < OOXMLDocumentObject
9
- attr_accessor :data, :type, :style_number
9
+ attr_accessor :data, :type
10
10
 
11
11
  # Parse OldDocxPicture object
12
12
  # @param node [Nokogiri::XML:Element] node to parse
@@ -20,8 +20,6 @@ module OoxmlParser
20
20
  when 'group'
21
21
  @type = :group
22
22
  @data = OldDocxGroup.new(parent: self).parse(node_child)
23
- when 'style'
24
- @style_number = node_child.attribute('val').value.to_i
25
23
  end
26
24
  end
27
25
  self