ooxml_parser 0.5.1 → 0.8.0
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.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content/choice/math_text/math_paragraph.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +6 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series.rb +2 -2
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart/series/series_text.rb +0 -2
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +1 -20
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +51 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_size.rb +4 -1
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip/file_reference.rb +4 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +0 -2
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb +1 -3
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style.rb +42 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/effect_reference.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/fill_reference.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/font_reference.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/shape_style/line_reference.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +1 -0
- 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
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +12 -4
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +10 -3
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +1 -3
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +1 -3
- data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/color.rb +48 -82
- data/lib/ooxml_parser/common_parser/common_data/color/color_helper.rb +4 -3
- data/lib/ooxml_parser/common_parser/common_data/color/color_indexes.list +66 -0
- data/lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb +5 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +8 -2
- data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +11 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +4 -0
- data/lib/ooxml_parser/common_parser/common_data/content_types.rb +2 -0
- data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_default.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/content_types/content_type_override.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +7 -0
- data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +14 -3
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +28 -2
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +28 -12
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +4 -2
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering_properties.rb +2 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/paragraph_borders.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +16 -13
- data/lib/ooxml_parser/common_parser/common_data/table.rb +2 -0
- data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +7 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties.rb +1 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_properties/table_style_properties_helper.rb +4 -4
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +4 -5
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +6 -0
- data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +3 -0
- data/lib/ooxml_parser/common_parser/common_data/underline.rb +7 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +41 -9
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comments/comment.rb +3 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +3 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +25 -8
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/bookmark_end.rb +1 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/comment_range_start.rb +1 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/pre_sub_superscript.rb +3 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +13 -3
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/docx_paragraph_run_helpers.rb +4 -1
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +0 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +3 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +4 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +8 -4
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/numbering.rb +5 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +3 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +6 -2
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_size.rb +1 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/styles.rb +2 -0
- data/lib/ooxml_parser/docx_parser/docx_parser.rb +3 -0
- data/lib/ooxml_parser/name.rb +1 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +2 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +3 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +3 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +5 -2
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +3 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide_helper.rb +15 -1
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +3 -0
- data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +4 -1
- data/lib/ooxml_parser/version.rb +2 -1
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +21 -2
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/chartsheet.rb +3 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache.rb +41 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb +37 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source.rb +33 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition/cache_source/worksheet_source.rb +26 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet.rb +2 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb +5 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills/fill.rb +2 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb +3 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +5 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +4 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +4 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +3 -0
- metadata +70 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bff9ef732546243f5b751041e9fb41602a4e0ca823f93a83f671975e881cf6fd
|
4
|
+
data.tar.gz: 3e5bc500fb572b0fa43297f6d85a0f47e1d35365caed9803441b81785808e83d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a6648cf7f5ce6a088d3c654c2c50b04afb363507e20ef8f2198ba35265310dfc44205819b32d635b997c589656bb87514fc5ab2007d2b898accf4d8fcb2b4b
|
7
|
+
data.tar.gz: 3e3f6e9c0a70516a176f5614294f8aecb02be45219c9a9c6799d3b3e75e7a2d7b6ff0a3680e6a8f18d8bbd6d8658740cac1157447b94659bd082a07ec9025a5e
|
data/lib/ooxml_parser.rb
CHANGED
@@ -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 [
|
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 =
|
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'
|
@@ -30,34 +30,15 @@ module OoxmlParser
|
|
30
30
|
when 'inline'
|
31
31
|
@type = :inline
|
32
32
|
end
|
33
|
-
@properties.distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
|
34
|
-
@properties.wrap = DocxWrapDrawing.new(parent: self).parse(node_child)
|
35
|
-
node_child.attributes.each do |key, value|
|
36
|
-
case key
|
37
|
-
when 'relativeHeight'
|
38
|
-
@properties.relative_height = value.value.to_i
|
39
|
-
end
|
40
|
-
end
|
41
33
|
node_child.xpath('*').each do |content_node_child|
|
42
34
|
case content_node_child.name
|
43
|
-
when 'simplePos'
|
44
|
-
@properties.simple_position = OOXMLCoordinates.parse(content_node_child)
|
45
|
-
when 'extent'
|
46
|
-
@properties.object_size = OOXMLCoordinates.parse(content_node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
|
47
35
|
when 'graphic'
|
48
36
|
@graphic = DocxGraphic.new(parent: self).parse(content_node_child)
|
49
|
-
when 'positionV'
|
50
|
-
@properties.vertical_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
|
51
|
-
when 'positionH'
|
52
|
-
@properties.horizontal_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
|
53
|
-
when 'sizeRelH'
|
54
|
-
@properties.size_relative_horizontal = SizeRelativeHorizontal.new(parent: self).parse(content_node_child)
|
55
|
-
when 'sizeRelV'
|
56
|
-
@properties.size_relative_vertical = SizeRelativeVertical.new(parent: self).parse(content_node_child)
|
57
37
|
when 'docPr'
|
58
38
|
@doc_properties = DocProperties.new(parent: self).parse(content_node_child)
|
59
39
|
end
|
60
40
|
end
|
41
|
+
@properties.parse(node_child)
|
61
42
|
end
|
62
43
|
self
|
63
44
|
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
|
@@ -8,9 +8,56 @@ require_relative 'docx_wrap_drawing'
|
|
8
8
|
module OoxmlParser
|
9
9
|
# Docx Drawing Properties
|
10
10
|
class DocxDrawingProperties < OOXMLDocumentObject
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# @return [DocxDrawingDistanceFromText] distance from text
|
12
|
+
attr_reader :distance_from_text
|
13
|
+
# @return [DocxWrapDrawing] wrap of drawing
|
14
|
+
attr_reader :wrap
|
15
|
+
# @return [Integer] relative height of object
|
16
|
+
attr_reader :relative_height
|
17
|
+
# @return [OOXMLCoordinates] simple position of object
|
18
|
+
attr_reader :simple_position
|
19
|
+
# @return [OOXMLCoordinates] size of object
|
20
|
+
attr_reader :object_size
|
21
|
+
# @return [DocxDrawingPosition] vertical position
|
22
|
+
attr_reader :vertical_position
|
23
|
+
# @return [DocxDrawingPosition] horizontal position
|
24
|
+
attr_reader :horizontal_position
|
25
|
+
# @return [SizeRelativeHorizontal] size of drawing relative to horizontal
|
26
|
+
attr_reader :size_relative_horizontal
|
27
|
+
# @return [SizeRelativeVertical] size of drawing relative to vertical
|
28
|
+
attr_reader :size_relative_vertical
|
29
|
+
|
30
|
+
# Parse DocxDrawingProperties
|
31
|
+
# @param [Nokogiri::XML:Node] node with DocxDrawingProperties
|
32
|
+
# @return [DocxDrawingProperties] result of parsing
|
33
|
+
def parse(node)
|
34
|
+
@distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node)
|
35
|
+
@wrap = DocxWrapDrawing.new(parent: self).parse(node)
|
36
|
+
|
37
|
+
node.attributes.each do |key, value|
|
38
|
+
case key
|
39
|
+
when 'relativeHeight'
|
40
|
+
@relative_height = value.value.to_i
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
node.xpath('*').each do |content_node_child|
|
45
|
+
case content_node_child.name
|
46
|
+
when 'simplePos'
|
47
|
+
@simple_position = OOXMLCoordinates.parse(content_node_child)
|
48
|
+
when 'extent'
|
49
|
+
@object_size = OOXMLCoordinates.parse(content_node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
|
50
|
+
when 'positionV'
|
51
|
+
@vertical_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
|
52
|
+
when 'positionH'
|
53
|
+
@horizontal_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
|
54
|
+
when 'sizeRelH'
|
55
|
+
@size_relative_horizontal = SizeRelativeHorizontal.new(parent: self).parse(content_node_child)
|
56
|
+
when 'sizeRelV'
|
57
|
+
@size_relative_vertical = SizeRelativeVertical.new(parent: self).parse(content_node_child)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
self
|
61
|
+
end
|
15
62
|
end
|
16
63
|
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,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)
|
@@ -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 :
|
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
|