ooxml_parser 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ooxml_parser.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/drawing_properties/docx_drawing_distance_from_text.rb +3 -0
- 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/ooxml_text_box.rb +1 -3
- 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 +1 -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 +36 -4
- data/lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb +5 -0
- 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/ooxml_document_object.rb +24 -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 +0 -8
- 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/table_style_properties_helper.rb +4 -4
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +4 -7
- 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 +4 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +27 -3
- 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 +2 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +22 -1
- 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 +2 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +0 -2
- 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/note.rb +3 -0
- 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 +3 -0
- 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 +3 -0
- 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 +64 -4
|
@@ -44,6 +44,9 @@ module OoxmlParser
|
|
|
44
44
|
|
|
45
45
|
alias theme_colors theme
|
|
46
46
|
|
|
47
|
+
# Compare this object to other
|
|
48
|
+
# @param other [Object] any other object
|
|
49
|
+
# @return [True, False] result of comparision
|
|
47
50
|
def ==(other)
|
|
48
51
|
@elements == other.elements &&
|
|
49
52
|
@page_properties == other.page_properties &&
|
|
@@ -53,6 +56,10 @@ module OoxmlParser
|
|
|
53
56
|
@comments == other.comments
|
|
54
57
|
end
|
|
55
58
|
|
|
59
|
+
# Get element by it's type
|
|
60
|
+
# @param location [Symbol] location of object
|
|
61
|
+
# @param type [Symbol] type of object
|
|
62
|
+
# @return [OOXMLDocumentObject]
|
|
56
63
|
def element_by_description(location: :canvas, type: :docx_paragraph)
|
|
57
64
|
case location
|
|
58
65
|
when :canvas
|
|
@@ -95,6 +102,9 @@ module OoxmlParser
|
|
|
95
102
|
end
|
|
96
103
|
end
|
|
97
104
|
|
|
105
|
+
# Get note by it's description
|
|
106
|
+
# @param type [Symbol] note type
|
|
107
|
+
# @return [Note]
|
|
98
108
|
def note_by_description(type)
|
|
99
109
|
notes.each do |note|
|
|
100
110
|
return note if note.type.to_sym == type
|
|
@@ -102,6 +112,11 @@ module OoxmlParser
|
|
|
102
112
|
raise 'There isn\'t this type of the note'
|
|
103
113
|
end
|
|
104
114
|
|
|
115
|
+
# Detect numbering type
|
|
116
|
+
# @param location [Symbol] location of object
|
|
117
|
+
# @param type [Symbol] type of object
|
|
118
|
+
# @param paragraph_number [Integer] number of object
|
|
119
|
+
# @return [Array<String,String>] type of numbering
|
|
105
120
|
def recognize_numbering(location: :canvas, type: :simple, paragraph_number: 0)
|
|
106
121
|
elements = element_by_description(location: location, type: type)
|
|
107
122
|
lvl_text = elements[paragraph_number].numbering.abstruct_numbering.level_list[0].text.value
|
|
@@ -109,6 +124,11 @@ module OoxmlParser
|
|
|
109
124
|
[num_format, lvl_text]
|
|
110
125
|
end
|
|
111
126
|
|
|
127
|
+
# Return outline type
|
|
128
|
+
# @param location [Symbol] location of object
|
|
129
|
+
# @param type [Symbol] type of object
|
|
130
|
+
# @param levels_count [Integer] count of levels to detect
|
|
131
|
+
# @return [Array<String,String>] type of outline
|
|
112
132
|
def outline(location: :canvas, type: :simple, levels_count: 1)
|
|
113
133
|
elements = element_by_description(location: location, type: type)
|
|
114
134
|
set = []
|
|
@@ -124,6 +144,8 @@ module OoxmlParser
|
|
|
124
144
|
styles.styles
|
|
125
145
|
end
|
|
126
146
|
|
|
147
|
+
# Parse docx file
|
|
148
|
+
# @return [DocumentStructure] parsed structure
|
|
127
149
|
def self.parse
|
|
128
150
|
doc_structure = DocumentStructure.new
|
|
129
151
|
doc_structure.content_types = ContentTypes.new(parent: doc_structure).parse
|
|
@@ -181,6 +203,8 @@ module OoxmlParser
|
|
|
181
203
|
doc_structure
|
|
182
204
|
end
|
|
183
205
|
|
|
206
|
+
# Parse default style
|
|
207
|
+
# @return [void]
|
|
184
208
|
def parse_default_style
|
|
185
209
|
doc = parse_xml(OOXMLDocumentObject.path_to_folder + 'word/styles.xml')
|
|
186
210
|
doc.search('//w:style').each do |style|
|
|
@@ -194,14 +218,14 @@ module OoxmlParser
|
|
|
194
218
|
DocumentStructure.default_paragraph_style = DocxParagraph.new.parse_paragraph_style(paragraph_pr_tag, DocumentStructure.default_run_style)
|
|
195
219
|
end
|
|
196
220
|
style.xpath('w:rPr').each do |character_pr_tag|
|
|
197
|
-
DocumentStructure.default_run_style.parse_properties(character_pr_tag
|
|
221
|
+
DocumentStructure.default_run_style.parse_properties(character_pr_tag)
|
|
198
222
|
end
|
|
199
223
|
elsif (style.attribute('default').value == '1' ||
|
|
200
224
|
style.attribute('default').value == 'on' ||
|
|
201
225
|
style.attribute('default').value == 'true') &&
|
|
202
226
|
style.attribute('type').value == 'character'
|
|
203
227
|
style.xpath('w:rPr').each do |character_pr_tag|
|
|
204
|
-
DocumentStructure.default_run_style.parse_properties(character_pr_tag
|
|
228
|
+
DocumentStructure.default_run_style.parse_properties(character_pr_tag)
|
|
205
229
|
end
|
|
206
230
|
end
|
|
207
231
|
end
|
|
@@ -216,7 +240,7 @@ module OoxmlParser
|
|
|
216
240
|
style.attribute('type').value == 'table'
|
|
217
241
|
|
|
218
242
|
style.xpath('w:rPr').each do |table_character_pr_tag|
|
|
219
|
-
DocumentStructure.default_table_run_style.parse_properties(table_character_pr_tag
|
|
243
|
+
DocumentStructure.default_table_run_style.parse_properties(table_character_pr_tag)
|
|
220
244
|
end
|
|
221
245
|
end
|
|
222
246
|
end
|
|
@@ -44,10 +44,12 @@ module OoxmlParser
|
|
|
44
44
|
@parent = parent
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
# @return [String] result of convert of object to string
|
|
47
48
|
def to_s
|
|
48
49
|
"Table style properties list: #{@table_style_properties_list.join(',')}"
|
|
49
50
|
end
|
|
50
51
|
|
|
52
|
+
# @return [String] inspect of object for debug means
|
|
51
53
|
def inspect
|
|
52
54
|
to_s
|
|
53
55
|
end
|
|
@@ -57,6 +57,9 @@ module OoxmlParser
|
|
|
57
57
|
|
|
58
58
|
alias elements character_style_array
|
|
59
59
|
|
|
60
|
+
# Constructor for copy of object
|
|
61
|
+
# @param source [DocxParagraph] original object
|
|
62
|
+
# @return [void]
|
|
60
63
|
def initialize_copy(source)
|
|
61
64
|
super
|
|
62
65
|
@bookmark_start = source.bookmark_start.clone
|
|
@@ -65,6 +68,7 @@ module OoxmlParser
|
|
|
65
68
|
@spacing = source.spacing.clone
|
|
66
69
|
end
|
|
67
70
|
|
|
71
|
+
# @return [Array<OOXMLDocumentObject>] array of child objects that contains data
|
|
68
72
|
def nonempty_runs
|
|
69
73
|
@character_style_array.select do |cur_run|
|
|
70
74
|
if cur_run.is_a?(DocxParagraphRun) || cur_run.is_a?(ParagraphRun)
|
|
@@ -87,6 +91,9 @@ module OoxmlParser
|
|
|
87
91
|
!nonempty_runs.empty? || paragraph_properties.section_properties
|
|
88
92
|
end
|
|
89
93
|
|
|
94
|
+
# Compare this object to other
|
|
95
|
+
# @param other [Object] any other object
|
|
96
|
+
# @return [True, False] result of comparision
|
|
90
97
|
def ==(other)
|
|
91
98
|
ignored_attributes = %i[@number @parent]
|
|
92
99
|
all_instance_variables = instance_variables
|
|
@@ -97,6 +104,12 @@ module OoxmlParser
|
|
|
97
104
|
true
|
|
98
105
|
end
|
|
99
106
|
|
|
107
|
+
# Parse object
|
|
108
|
+
# @param node [Nokogiri::XML:Node] node with DocxParagraph
|
|
109
|
+
# @param par_number [Integer] number of paragraph
|
|
110
|
+
# @param default_character [DocxParagraphRun] style for paragraph
|
|
111
|
+
# @param parent [OOXMLDocumentObject] parent of run
|
|
112
|
+
# @return [DocxParagraph] result of parse
|
|
100
113
|
def parse(node, par_number = 0, default_character = DocxParagraphRun.new, parent: nil)
|
|
101
114
|
@parent ||= parent
|
|
102
115
|
default_character_style = default_character.dup
|
|
@@ -174,6 +187,10 @@ module OoxmlParser
|
|
|
174
187
|
self
|
|
175
188
|
end
|
|
176
189
|
|
|
190
|
+
# Parse style
|
|
191
|
+
# @param node [Nokogiri::XML:Node] node with style
|
|
192
|
+
# @param default_char_style [DocxParagraphRun] style for paragraph
|
|
193
|
+
# @return [DocxParagraph] result of parse
|
|
177
194
|
def parse_paragraph_style(node, default_char_style = DocxParagraphRun.new(parent: self))
|
|
178
195
|
node.xpath('*').each do |node_child|
|
|
179
196
|
case node_child.name
|
|
@@ -229,6 +246,10 @@ module OoxmlParser
|
|
|
229
246
|
self
|
|
230
247
|
end
|
|
231
248
|
|
|
249
|
+
# Parse style xml
|
|
250
|
+
# @param id [String] id of style to parse
|
|
251
|
+
# @param character_style [DocxParagraphRun] style to parse
|
|
252
|
+
# @return [void]
|
|
232
253
|
def parse_paragraph_style_xml(id, character_style)
|
|
233
254
|
doc = parse_xml(OOXMLDocumentObject.path_to_folder + 'word/styles.xml')
|
|
234
255
|
doc.search('//w:style').each do |style|
|
|
@@ -239,7 +260,7 @@ module OoxmlParser
|
|
|
239
260
|
@style = StyleParametres.new(parent: self).parse(style)
|
|
240
261
|
end
|
|
241
262
|
style.xpath('w:rPr').each do |r_pr|
|
|
242
|
-
character_style.parse_properties(r_pr
|
|
263
|
+
character_style.parse_properties(r_pr)
|
|
243
264
|
end
|
|
244
265
|
break
|
|
245
266
|
end
|
|
@@ -12,6 +12,9 @@ module OoxmlParser
|
|
|
12
12
|
# @return [DocxFormula] base
|
|
13
13
|
attr_accessor :base
|
|
14
14
|
|
|
15
|
+
# Parse PreSubSuperscript
|
|
16
|
+
# @param [Nokogiri::XML:Node] node with PreSubSuperscript
|
|
17
|
+
# @return [PreSubSuperscript] result of parsing
|
|
15
18
|
def parse(node)
|
|
16
19
|
node.xpath('*').each do |node_child|
|
|
17
20
|
case node_child.name
|
data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb
CHANGED
|
@@ -41,12 +41,16 @@ module OoxmlParser
|
|
|
41
41
|
@parent = parent
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
# Constructor for copy of object
|
|
45
|
+
# @param source [DocxParagraphRun] original object
|
|
46
|
+
# @return [void]
|
|
44
47
|
def initialize_copy(source)
|
|
45
48
|
super
|
|
46
49
|
@drawings = source.drawings.clone
|
|
47
50
|
@comments = source.comments.clone
|
|
48
51
|
end
|
|
49
52
|
|
|
53
|
+
# @return [Array, nil] Drawings of Run
|
|
50
54
|
def drawing
|
|
51
55
|
# TODO: Rewrite all tests without this methos
|
|
52
56
|
@drawings.empty? ? nil : drawings.first
|
|
@@ -64,6 +68,9 @@ module OoxmlParser
|
|
|
64
68
|
!@break
|
|
65
69
|
end
|
|
66
70
|
|
|
71
|
+
# Compare this object to other
|
|
72
|
+
# @param other [Object] any other object
|
|
73
|
+
# @return [True, False] result of comparision
|
|
67
74
|
def ==(other)
|
|
68
75
|
ignored_attributes = %i[@number @parent]
|
|
69
76
|
all_instance_variables = instance_variables
|
|
@@ -74,12 +81,17 @@ module OoxmlParser
|
|
|
74
81
|
true
|
|
75
82
|
end
|
|
76
83
|
|
|
84
|
+
# Parse object
|
|
85
|
+
# @param r_tag [Nokogiri::XML:Node] node with DocxParagraphRun
|
|
86
|
+
# @param char_number [Integer] number of run
|
|
87
|
+
# @param parent [OOXMLDocumentObject] parent of run
|
|
88
|
+
# @return [void]
|
|
77
89
|
def parse(r_tag, char_number, parent: nil)
|
|
78
90
|
@parent = parent
|
|
79
91
|
r_tag.xpath('*').each do |node_child|
|
|
80
92
|
case node_child.name
|
|
81
93
|
when 'rPr'
|
|
82
|
-
parse_properties(node_child
|
|
94
|
+
parse_properties(node_child)
|
|
83
95
|
@run_properties = RunProperties.new(parent: self).parse(node_child)
|
|
84
96
|
when 'instrText'
|
|
85
97
|
if node_child.text.include?('HYPERLINK')
|
|
@@ -121,8 +133,6 @@ module OoxmlParser
|
|
|
121
133
|
@shape = Shape.new(parent: self).parse(pict_node_child, :shape)
|
|
122
134
|
when 'rect'
|
|
123
135
|
@shape = Shape.new(parent: self).parse(pict_node_child, :rectangle)
|
|
124
|
-
when 'oval'
|
|
125
|
-
@shape = Shape.new(parent: self).parse(pict_node_child, :oval)
|
|
126
136
|
end
|
|
127
137
|
end
|
|
128
138
|
when 'object'
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
module OoxmlParser
|
|
4
4
|
# Module for some helpers for ParagraphRun
|
|
5
5
|
module DocxParagraphRunHelpers
|
|
6
|
-
|
|
6
|
+
# Parse other properties
|
|
7
|
+
# @param node [Nokogiri::XML:Element] node to parse
|
|
8
|
+
# @return [DocxParagraphRun] result of parse
|
|
9
|
+
def parse_properties(node)
|
|
7
10
|
self.font_style = FontStyle.new
|
|
8
11
|
node.xpath('*').each do |node_child|
|
|
9
12
|
case node_child.name
|
|
@@ -53,8 +53,6 @@ module OoxmlParser
|
|
|
53
53
|
@properties.margins.top = property.split(':').last
|
|
54
54
|
elsif property.include?('margin-left')
|
|
55
55
|
@properties.margins.left = property.split(':').last
|
|
56
|
-
elsif property.include?('margin-right')
|
|
57
|
-
@properties.margins.right = property.split(':').last
|
|
58
56
|
elsif property.include?('width')
|
|
59
57
|
@properties.size.width = property.split(':').last
|
|
60
58
|
elsif property.include?('height')
|
data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb
CHANGED
|
@@ -7,6 +7,9 @@ module OoxmlParser
|
|
|
7
7
|
:horizontal_align, :vertical_align, :anchor_lock, :vertical_space, :horizontal_space,
|
|
8
8
|
:horizontal_position, :vertical_position
|
|
9
9
|
|
|
10
|
+
# Parse FrameProperties
|
|
11
|
+
# @param node [Nokogiri::XML:Element] with FrameProperties
|
|
12
|
+
# @return [FrameProperties] parsed result
|
|
10
13
|
def parse(node)
|
|
11
14
|
node.attributes.each do |key, value|
|
|
12
15
|
case key
|
|
@@ -22,6 +22,8 @@ module OoxmlParser
|
|
|
22
22
|
alias right right_indent
|
|
23
23
|
alias hanging hanging_indent
|
|
24
24
|
|
|
25
|
+
# Convert to string
|
|
26
|
+
# @return [String] result of conversion
|
|
25
27
|
def to_s
|
|
26
28
|
"first line indent: #{@first_line_indent}, left indent: #{@left_indent},
|
|
27
29
|
right indent: #{@right_indent}, hanging indent: #{@hanging_indent}"
|
|
@@ -17,6 +17,9 @@ module OoxmlParser
|
|
|
17
17
|
@parent = parent
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
# Get properties by number id
|
|
21
|
+
# @param num_id [Integer] index of number id
|
|
22
|
+
# @return [nil, AbstractNumbering] result of search
|
|
20
23
|
def properties_by_num_id(num_id)
|
|
21
24
|
abstract_num_id = nil
|
|
22
25
|
@numbering_definition_list.each do |num_def|
|
|
@@ -32,6 +35,8 @@ module OoxmlParser
|
|
|
32
35
|
end
|
|
33
36
|
end
|
|
34
37
|
|
|
38
|
+
# Parse Numbering data
|
|
39
|
+
# @return [Numbering] result of parse
|
|
35
40
|
def parse
|
|
36
41
|
numbering_xml = OOXMLDocumentObject.path_to_folder + 'word/numbering.xml'
|
|
37
42
|
return nil unless File.exist?(numbering_xml)
|
|
@@ -7,6 +7,9 @@ require_relative 'docx_data/document_structure'
|
|
|
7
7
|
module OoxmlParser
|
|
8
8
|
# Basic class for DocxParser
|
|
9
9
|
class DocxParser
|
|
10
|
+
# Parse docx file
|
|
11
|
+
# @param path_to_file [String] file path
|
|
12
|
+
# @return [DocumentStructure] result of parse
|
|
10
13
|
def self.parse_docx(path_to_file)
|
|
11
14
|
Parser.parse_format(path_to_file) do
|
|
12
15
|
DocumentStructure.parse
|
data/lib/ooxml_parser/name.rb
CHANGED
|
@@ -14,6 +14,9 @@ module OoxmlParser
|
|
|
14
14
|
@color_scheme = color_scheme
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# Parse PresentationTheme
|
|
18
|
+
# @param file [String] path to file to parse
|
|
19
|
+
# @return [PresentationTheme] result of parsing
|
|
17
20
|
def self.parse(file)
|
|
18
21
|
OOXMLDocumentObject.theme = PresentationTheme.new
|
|
19
22
|
OOXMLDocumentObject.add_to_xmls_stack(file)
|
|
@@ -28,6 +28,7 @@ module OoxmlParser
|
|
|
28
28
|
@xml_path = xml_path
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
# @return [True, False] is slide with data
|
|
31
32
|
def with_data?
|
|
32
33
|
return true unless background.nil?
|
|
33
34
|
|
|
@@ -37,10 +38,12 @@ module OoxmlParser
|
|
|
37
38
|
false
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
# @return <Array> List of elements on slide
|
|
40
42
|
def elements
|
|
41
43
|
@common_slide_data.shape_tree.elements
|
|
42
44
|
end
|
|
43
45
|
|
|
46
|
+
# @return [Background] background of slide
|
|
44
47
|
def background
|
|
45
48
|
@common_slide_data.background
|
|
46
49
|
end
|