ooxml_parser 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.overcommit.yml +35 -0
- data/Changelog.md +25 -0
- data/LICENSE.txt +661 -0
- data/README.md +26 -0
- data/circle.yml +3 -0
- data/lib/ooxml_parser/common_parser/common_data/alingment.rb +56 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb +34 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart.rb +123 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis.rb +34 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_axis_title.rb +38 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_cells_range.rb +23 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_legend.rb +33 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_point.rb +11 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2007_chart_style.rb +17 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/chart_style/office_2010_chart_style.rb +17 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/chart/display_labels_properties.rb +26 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/docx_drawing.rb +49 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_distance_from_text.rb +23 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_position.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb +11 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb +39 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/ooxml_coordinates.rb +32 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb +34 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_group_element.rb +10 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/group/docx_grouped_drawing.rb +34 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_blip.rb +27 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/picture/docx_picture.rb +26 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb +25 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties/preset_text_warp.rb +16 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_body_properties/ooxml_shape_body_properties.rb +30 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb +37 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_pattern_fill.rb +20 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_gradient_color.rb +30 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/gradient_color/docx_single_gradient_color.rb +6 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/solid_color/docx_solid_color.rb +10 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/docx_custom_geometry/docx_shape_line_element.rb +10 -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.rb +44 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/custom_geometry/ooxml_custom_geometry.rb +23 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_color.rb +43 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_line.rb +54 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb +25 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties.rb +40 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb +31 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end/line_size.rb +20 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/line/line_end.rb +21 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_style/docx_shape_style.rb +5 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group.rb +31 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_element.rb +10 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/group/old_docx_group_properties.rb +6 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/old_docx_picture.rb +26 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape.rb +24 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_fill.rb +26 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/picture/shape/old_docx_shape_properties.rb +24 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/common_non_visual_properties.rb +25 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_properties.rb +19 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/non_visual_shape_properties.rb +20 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape.rb +28 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_placeholder.rb +18 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/ooxml_shift.rb +15 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties/transform_effect.rb +28 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/shape_properties.rb +13 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb +26 -0
- data/lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/text_body.rb +23 -0
- data/lib/ooxml_parser/common_parser/common_data/borders_properties.rb +58 -0
- data/lib/ooxml_parser/common_parser/common_data/color.rb +473 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/color_alpha_channel.rb +14 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb +21 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/hsl_color.rb +150 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/image/fill_rectangle.rb +22 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/image/stretching.rb +11 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/image_fill.rb +32 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/image_properties.rb +16 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/gradient_stop.rb +15 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color/linear_gradient.rb +10 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/gradient_color.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb +22 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb +33 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/scheme_color.rb +14 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/theme_colors.rb +22 -0
- data/lib/ooxml_parser/common_parser/common_data/colors/tile.rb +21 -0
- data/lib/ooxml_parser/common_parser/common_data/coordinates.rb +127 -0
- data/lib/ooxml_parser/common_parser/common_data/font_style.rb +101 -0
- data/lib/ooxml_parser/common_parser/common_data/hyperlink.rb +53 -0
- data/lib/ooxml_parser/common_parser/common_data/ooxml_document_object.rb +87 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties.rb +48 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/outline.rb +23 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/strikeout.rb +16 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties.rb +79 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run.rb +24 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties/numbering_level.rb +25 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering/numbering_properties.rb +69 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/numbering.rb +18 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph/paragrpah_properties/spacing.rb +115 -0
- data/lib/ooxml_parser/common_parser/common_data/paragraph.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/table/margins/paragraph_margins.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/table/margins/table_margins.rb +47 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_cell_margin.rb +20 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_element.rb +20 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_look.rb +43 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_position.rb +49 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style.rb +83 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/table_style_elements.rb +21 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/line_join.rb +19 -0
- data/lib/ooxml_parser/common_parser/common_data/table/properties/whole_table/table_cell_style.rb +20 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb +43 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/cell_properties.rb +142 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/merge.rb +18 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/border.rb +25 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/borders.rb +125 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/cell/properties/table_cell_line.rb +35 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/row/table_row_properties.rb +22 -0
- data/lib/ooxml_parser/common_parser/common_data/table/row/row.rb +33 -0
- data/lib/ooxml_parser/common_parser/common_data/table/table_grid.rb +9 -0
- data/lib/ooxml_parser/common_parser/common_data/table/table_properties.rb +77 -0
- data/lib/ooxml_parser/common_parser/common_data/table.rb +41 -0
- data/lib/ooxml_parser/common_parser/common_data/underline.rb +40 -0
- data/lib/ooxml_parser/common_parser/common_document_structure.rb +7 -0
- data/lib/ooxml_parser/configuration.rb +20 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/comment.rb +28 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_properties.rb +21 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/document_style.rb +70 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/accent.rb +11 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/bar.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/box.rb +11 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/delimeter.rb +12 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/fraction.rb +11 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/function.rb +11 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/group_char.rb +13 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/index.rb +12 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/limit.rb +12 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix/matrix_row.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/matrix.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/operator.rb +13 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula/radical.rb +11 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_formula.rb +203 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/offset.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shadow.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_margins.rb +11 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/shape_size.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties/stroke.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape/shape_properties.rb +16 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb +40 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_fill.rb +13 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/text_outline.rb +22 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run.rb +388 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/frame_properties.rb +46 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/indents.rb +87 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/bookmark.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/paragraph_tab.rb +19 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style/style_parametres.rb +35 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/paragraph_style.rb +56 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph.rb +324 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/header_footer.rb +37 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/image.rb +15 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns/column.rb +10 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/columns.rb +37 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/document_grid.rb +29 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/note.rb +49 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb +42 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb +88 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/size.rb +84 -0
- data/lib/ooxml_parser/docx_parser/docx_data/document_structure.rb +232 -0
- data/lib/ooxml_parser/docx_parser/docx_parser.rb +16 -0
- data/lib/ooxml_parser/helpers/string_helper.rb +22 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment/presentation_comment_author.rb +25 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_comment.rb +31 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb +40 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb +44 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/background.rb +19 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb +34 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/presentation_alternate_content.rb +25 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/non_visual_shape_properties/hyperlinks/hyperlink_for_hover.rb +23 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/extents.rb +10 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/shape_properties/offset.rb +10 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/paragraph.rb +10 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shape/text_body/text_field.rb +18 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/shapes_grouping/shapes_grouping.rb +9 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping/grouping_properties.rb +16 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/shapes_grouping.rb +30 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/animation_effect/animation_effect.rb +22 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/behavior.rb +28 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/behavior/target_element.rb +31 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/set_time_node/set_time_node.rb +20 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing/condition.rb +26 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node/common_timing.rb +33 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing/time_node.rb +52 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/slide/timing.rb +23 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound/sound.rb +18 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/sound_action/sound_action.rb +18 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition.rb +43 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/transition/transition_properties/transition_properties.rb +9 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb +110 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide_size.rb +20 -0
- data/lib/ooxml_parser/pptx_parser/pptx_data/presentation.rb +62 -0
- data/lib/ooxml_parser/pptx_parser/pptx_parser.rb +15 -0
- data/lib/ooxml_parser/version.rb +6 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character/excel_comment_character_properties.rb +27 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment/excel_comment_character.rb +25 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments/excel_comment.rb +20 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/excel_comments.rb +43 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_format_properties.rb +21 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view/pane.rb +23 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/sheet_view.rb +18 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb +24 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position/xlsx_drawing_position_parameters.rb +22 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_drawing_position.rb +22 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing/xlsx_shape_grouping.rb +37 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_drawing.rb +49 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/alignment.rb +30 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/foreground_color.rb +25 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb +38 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style.rb +95 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb +47 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row.rb +19 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_table.rb +30 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet.rb +74 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook.rb +108 -0
- data/lib/ooxml_parser/xlsx_parser/xlsx_parser.rb +15 -0
- data/lib/ooxml_parser.rb +35 -0
- data/ooxml_parser.gemspec +30 -0
- metadata +310 -0
@@ -0,0 +1,324 @@
|
|
1
|
+
# noinspection RubyTooManyInstanceVariablesInspection
|
2
|
+
require_relative 'docx_paragraph/docx_paragraph_run'
|
3
|
+
require_relative 'docx_paragraph/indents'
|
4
|
+
require_relative 'docx_paragraph/frame_properties'
|
5
|
+
require_relative 'docx_paragraph/docx_formula'
|
6
|
+
require_relative 'docx_paragraph/paragraph_style'
|
7
|
+
module OoxmlParser
|
8
|
+
class DocxParagraph < OOXMLDocumentObject
|
9
|
+
attr_accessor :number, :bookmark_start, :bookmark_end, :align, :spacing, :background_color, :ind, :numbering,
|
10
|
+
:character_style_array, :horizontal_line, :page_break, :kinoku, :borders, :keep_lines,
|
11
|
+
:contextual_spacing, :sector_properties, :page_numbering, :section_break, :style, :keep_next,
|
12
|
+
:orphan_control, :tabs, :frame_properties
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@number = 0
|
16
|
+
@bookmark_start = []
|
17
|
+
@bookmark_end = []
|
18
|
+
@align = 'left'
|
19
|
+
@spacing = Spacing.new
|
20
|
+
@background_color = nil
|
21
|
+
@ind = Indents.new
|
22
|
+
@kinoku = false
|
23
|
+
@numbering = nil
|
24
|
+
@character_style_array = []
|
25
|
+
@horizontal_line = false
|
26
|
+
@page_break = false
|
27
|
+
@borders = Borders.new
|
28
|
+
@keep_lines = false
|
29
|
+
@contextual_spacing = false
|
30
|
+
@sector_properties = nil
|
31
|
+
@page_numbering = false
|
32
|
+
@section_break = nil
|
33
|
+
@style = nil
|
34
|
+
@keep_next = false
|
35
|
+
@orphan_control = true
|
36
|
+
@tabs = []
|
37
|
+
@frame_properties = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def copy
|
41
|
+
paragraph = DocxParagraph.new
|
42
|
+
paragraph.number = number
|
43
|
+
paragraph.bookmark_start = @bookmark_start.dup
|
44
|
+
paragraph.bookmark_end = @bookmark_end.dup
|
45
|
+
paragraph.align = @align
|
46
|
+
paragraph.spacing = @spacing.copy
|
47
|
+
paragraph.background_color = @background_color
|
48
|
+
paragraph.ind = @ind.copy
|
49
|
+
paragraph.numbering = @numbering
|
50
|
+
paragraph.character_style_array = @character_style_array
|
51
|
+
paragraph.horizontal_line = @horizontal_line
|
52
|
+
paragraph.page_break = @page_break
|
53
|
+
paragraph.kinoku = @kinoku
|
54
|
+
paragraph.borders = @borders
|
55
|
+
paragraph.keep_lines = @keep_lines
|
56
|
+
paragraph.contextual_spacing = @contextual_spacing
|
57
|
+
paragraph.sector_properties = @sector_properties
|
58
|
+
paragraph.page_numbering = @page_numbering
|
59
|
+
paragraph.section_break = @section_break
|
60
|
+
paragraph.style = @style
|
61
|
+
paragraph.keep_next = @keep_next
|
62
|
+
paragraph.orphan_control = @orphan_control
|
63
|
+
paragraph.tabs = @tabs.dup
|
64
|
+
paragraph.frame_properties = @frame_properties
|
65
|
+
paragraph
|
66
|
+
end
|
67
|
+
|
68
|
+
def nonempty_runs
|
69
|
+
@character_style_array.select do |cur_run|
|
70
|
+
if cur_run.is_a?(DocxParagraphRun)
|
71
|
+
(!cur_run.text.empty? || !cur_run.alternate_content.nil? || !cur_run.drawing.nil?)
|
72
|
+
elsif cur_run.is_a?(DocxFormula)
|
73
|
+
true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def remove_empty_runs
|
79
|
+
nonempty = nonempty_runs
|
80
|
+
@character_style_array.each do |cur_run|
|
81
|
+
@character_style_array.delete(cur_run) unless nonempty.include?(cur_run)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def ==(other)
|
86
|
+
character_style_array.each do |current_run|
|
87
|
+
character_style_array.delete(current_run) if current_run.text.empty?
|
88
|
+
end
|
89
|
+
other.character_style_array.each do |current_run|
|
90
|
+
other.character_style_array.delete(current_run) if current_run.text.empty?
|
91
|
+
end
|
92
|
+
ignored_attributes = [:@number]
|
93
|
+
all_instance_variables = instance_variables
|
94
|
+
significan_attribues = all_instance_variables - ignored_attributes
|
95
|
+
significan_attribues.each do |current_attributes|
|
96
|
+
unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.parse(p_tag, par_number = 0, default_paragraph = DocxParagraph.new, default_character = DocxParagraphRun.new)
|
104
|
+
paragraph_style = default_paragraph.copy
|
105
|
+
default_character_style = default_character.copy
|
106
|
+
character_styles_array = []
|
107
|
+
custom_character_style = DocxParagraphRun.new
|
108
|
+
char_number = 0
|
109
|
+
comments = []
|
110
|
+
p_tag.xpath('w:bookmarkStart').each do |bookmark_start|
|
111
|
+
paragraph_style.bookmark_start << Bookmark.new(bookmark_start.attribute('id').value, bookmark_start.attribute('name').value)
|
112
|
+
end
|
113
|
+
p_tag.xpath('w:bookmarkEnd').each do |bookmark_end|
|
114
|
+
paragraph_style.bookmark_end << Bookmark.new(bookmark_end.attribute('id').value)
|
115
|
+
end
|
116
|
+
p_tag.xpath('*').each do |p_element|
|
117
|
+
if p_element.name == 'pPr'
|
118
|
+
p_props = p_tag.xpath('w:pPr')
|
119
|
+
DocxParagraph.parse_paragraph_style(p_props, paragraph_style, custom_character_style)
|
120
|
+
p_tag.xpath('w:pict').each do |pict|
|
121
|
+
pict.xpath('v:rect').each do
|
122
|
+
paragraph_style.horizontal_line = true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
elsif p_element.name == 'commentRangeStart'
|
126
|
+
comments << p_element.attribute('id').value
|
127
|
+
elsif p_element.name == 'fldSimple'
|
128
|
+
instruction = p_element.attribute('instr').to_s
|
129
|
+
paragraph_style.page_numbering = true if instruction.include?('PAGE')
|
130
|
+
p_element.xpath('w:r').each do |r_tag|
|
131
|
+
character_style = DocxParagraphRun.parse_character(r_tag, default_character_style.copy, char_number)
|
132
|
+
character_style.page_number = paragraph_style.page_numbering
|
133
|
+
character_style.instruction = instruction
|
134
|
+
character_styles_array << character_style.copy
|
135
|
+
char_number += 1
|
136
|
+
end
|
137
|
+
elsif p_element.name == 'r'
|
138
|
+
character_style = custom_character_style.copy
|
139
|
+
p_element.xpath('w:instrText').each do |insrt_text|
|
140
|
+
if insrt_text.text.include?('PAGE')
|
141
|
+
paragraph_style.page_numbering = true
|
142
|
+
end
|
143
|
+
end
|
144
|
+
character_style = DocxParagraphRun.parse_character(p_element, character_style, char_number)
|
145
|
+
character_style.comments = comments.dup
|
146
|
+
character_styles_array << character_style.copy
|
147
|
+
unless character_style.shape.nil?
|
148
|
+
character_styles_array.last.shape = character_style.shape
|
149
|
+
end
|
150
|
+
char_number += 1
|
151
|
+
elsif p_element.name == 'hyperlink'
|
152
|
+
character_style = default_character_style.copy
|
153
|
+
if !p_element.attribute('id').nil?
|
154
|
+
character_style.link = Hyperlink.parse(p_element)
|
155
|
+
else
|
156
|
+
unless p_element.attribute('anchor').nil?
|
157
|
+
character_style.link = p_element.attribute('anchor').value
|
158
|
+
end
|
159
|
+
end
|
160
|
+
p_element.xpath('w:r').each do |r_tag|
|
161
|
+
character_style = DocxParagraphRun.parse_character(r_tag, character_style, char_number)
|
162
|
+
character_styles_array << character_style.copy
|
163
|
+
char_number += 1
|
164
|
+
end
|
165
|
+
p_element.xpath('w:fldSimple').each do |simple_field|
|
166
|
+
instruction = simple_field.attribute('instr').to_s
|
167
|
+
paragraph_style.page_numbering = true if instruction.include?('PAGE')
|
168
|
+
simple_field.xpath('w:r').each do |r_tag|
|
169
|
+
character_style = DocxParagraphRun.parse_character(r_tag, character_style.copy, char_number)
|
170
|
+
character_style.page_number = paragraph_style.page_numbering
|
171
|
+
character_style.instruction = instruction
|
172
|
+
character_styles_array << character_style.copy
|
173
|
+
char_number += 1
|
174
|
+
end
|
175
|
+
end
|
176
|
+
elsif p_element.name == 'oMathPara'
|
177
|
+
p_element.xpath('m:oMath').each do |o_math|
|
178
|
+
character_styles_array << DocxFormula.parse(o_math)
|
179
|
+
end
|
180
|
+
elsif p_element.name == 'commentRangeEnd'
|
181
|
+
comments.each_with_index do |comment, index|
|
182
|
+
if comment == p_element.attribute('id').value
|
183
|
+
comments.delete_at(index)
|
184
|
+
break
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
paragraph_style.number = par_number
|
190
|
+
if character_styles_array.last.class == DocxParagraphRun
|
191
|
+
character_styles_array.last.text = character_styles_array.last.text.rstrip
|
192
|
+
end
|
193
|
+
paragraph_style.character_style_array = character_styles_array
|
194
|
+
paragraph_style
|
195
|
+
end
|
196
|
+
|
197
|
+
def self.parse_paragraph_style(paragraph_pr_tag, paragraph_style = DocxParagraph.new, default_char_style = DocxParagraphRun.new)
|
198
|
+
paragraph_pr_tag.xpath('w:tabs').each do |tabs_node|
|
199
|
+
tabs_node.xpath('w:tab').each { |tab_node| paragraph_style.tabs << ParagraphTab.new(tab_node.attribute('val').value.to_sym, (tab_node.attribute('pos').value.to_f / 566.9).round(2)) }
|
200
|
+
end
|
201
|
+
paragraph_pr_tag.xpath('w:pageBreakBefore').each do |page_break_before|
|
202
|
+
if page_break_before.attribute('val').nil? || page_break_before.attribute('val').value != 'false'
|
203
|
+
paragraph_style.page_break = true
|
204
|
+
end
|
205
|
+
end
|
206
|
+
paragraph_pr_tag.xpath('w:pBdr').each do |paragraph_br|
|
207
|
+
paragraph_style.borders = Borders.new
|
208
|
+
paragraph_br.xpath('w:bottom').each do |bottom|
|
209
|
+
paragraph_style.borders.bottom = BordersProperties.parse(bottom)
|
210
|
+
end
|
211
|
+
paragraph_br.xpath('w:left').each do |left|
|
212
|
+
paragraph_style.borders.left = BordersProperties.parse(left)
|
213
|
+
end
|
214
|
+
paragraph_br.xpath('w:top').each do |top|
|
215
|
+
paragraph_style.borders.top = BordersProperties.parse(top)
|
216
|
+
end
|
217
|
+
paragraph_br.xpath('w:right').each do |right|
|
218
|
+
paragraph_style.borders.right = BordersProperties.parse(right)
|
219
|
+
end
|
220
|
+
paragraph_br.xpath('w:between').each do |between|
|
221
|
+
paragraph_style.borders.between = BordersProperties.parse(between)
|
222
|
+
end
|
223
|
+
paragraph_br.xpath('w:bar').each do |bar|
|
224
|
+
paragraph_style.borders.bar = BordersProperties.parse(bar)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
paragraph_pr_tag.xpath('w:keepLines').each do |keep_lines|
|
228
|
+
if keep_lines.attribute('val').nil?
|
229
|
+
paragraph_style.keep_lines = true
|
230
|
+
else
|
231
|
+
unless keep_lines.attribute('val').value == 'false'
|
232
|
+
paragraph_style.keep_lines = true
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
paragraph_pr_tag.xpath('w:widowControl').each do |widow_control_node|
|
237
|
+
paragraph_style.orphan_control = OOXMLDocumentObject.option_enabled?(widow_control_node)
|
238
|
+
end
|
239
|
+
paragraph_pr_tag.xpath('w:keepNext').each do |_|
|
240
|
+
paragraph_style.keep_next = true
|
241
|
+
end
|
242
|
+
paragraph_style.contextual_spacing = true unless paragraph_pr_tag.xpath('w:contextualSpacing').empty?
|
243
|
+
paragraph_pr_tag.xpath('w:shd').each do |shd|
|
244
|
+
background_color_string = shd.attribute('fill').value
|
245
|
+
paragraph_style.background_color = Color.from_int16(background_color_string)
|
246
|
+
unless shd.attribute('val').nil?
|
247
|
+
paragraph_style.background_color.set_style(shd.attribute('val').value)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
paragraph_pr_tag.xpath('w:pStyle').each do |p_style|
|
251
|
+
parse_paragraph_style_xml(p_style.attribute('val').value, paragraph_style, default_char_style)
|
252
|
+
end
|
253
|
+
paragraph_pr_tag.xpath('w:ind').each do |ind|
|
254
|
+
paragraph_style.ind = Indents.parse(ind)
|
255
|
+
end
|
256
|
+
paragraph_pr_tag.xpath('w:kinoku').each do
|
257
|
+
paragraph_style.kinoku = true
|
258
|
+
end
|
259
|
+
paragraph_pr_tag.xpath('w:framePr').each do |frame_pr_node|
|
260
|
+
paragraph_style.frame_properties = FrameProperties.parse(frame_pr_node)
|
261
|
+
end
|
262
|
+
paragraph_pr_tag.xpath('w:numPr').each do |num_pr|
|
263
|
+
numbering = Numbering.new
|
264
|
+
num_pr.xpath('w:ilvl').each do |ilvl|
|
265
|
+
numbering.ilvl = ilvl.attribute('val').value
|
266
|
+
end
|
267
|
+
num_pr.xpath('w:numId').each do |num_id|
|
268
|
+
numbering.numbering_properties = NumberingProperties.parse(num_id.attribute('val').value) if File.exist?(OOXMLDocumentObject.path_to_folder + 'word/numbering.xml')
|
269
|
+
end
|
270
|
+
paragraph_style.numbering = numbering
|
271
|
+
end
|
272
|
+
paragraph_pr_tag.xpath('w:jc').each do |jc|
|
273
|
+
paragraph_style.align = jc.attribute('val').value.to_sym unless jc.attribute('val').nil?
|
274
|
+
paragraph_style.align = :justify if jc.attribute('val').value == 'both'
|
275
|
+
end
|
276
|
+
paragraph_pr_tag.xpath('w:framePr').each do |frame_pr_node|
|
277
|
+
paragraph_style.frame_properties = FrameProperties.parse(frame_pr_node)
|
278
|
+
end
|
279
|
+
paragraph_pr_tag.xpath('w:spacing').each do |spacing|
|
280
|
+
unless spacing.attribute('before').nil?
|
281
|
+
paragraph_style.spacing.before = (spacing.attribute('before').value.to_f / 566.9).round(2)
|
282
|
+
end
|
283
|
+
unless spacing.attribute('after').nil?
|
284
|
+
paragraph_style.spacing.after = (spacing.attribute('after').value.to_f / 566.9).round(2)
|
285
|
+
end
|
286
|
+
unless spacing.attribute('lineRule').nil?
|
287
|
+
paragraph_style.spacing.line_rule = spacing.attribute('lineRule').value.sub('atLeast', 'at_least').to_sym
|
288
|
+
end
|
289
|
+
unless spacing.attribute('line').nil?
|
290
|
+
paragraph_style.spacing.line = (paragraph_style.spacing.line_rule == :auto ? (spacing.attribute('line').value.to_f / 240.0).round(2) : (spacing.attribute('line').value.to_f / 566.9).round(2))
|
291
|
+
end
|
292
|
+
end
|
293
|
+
paragraph_pr_tag.xpath('w:sectPr').each do |sect_pr|
|
294
|
+
paragraph_style.sector_properties = PageProperties.parse(sect_pr, paragraph_style, default_char_style)
|
295
|
+
paragraph_style.section_break = case paragraph_style.sector_properties.type
|
296
|
+
when 'oddPage'
|
297
|
+
'Odd page'
|
298
|
+
when 'evenPage'
|
299
|
+
'Even page'
|
300
|
+
when 'continuous'
|
301
|
+
'Current Page'
|
302
|
+
else
|
303
|
+
'Next Page'
|
304
|
+
end
|
305
|
+
end
|
306
|
+
paragraph_style
|
307
|
+
end
|
308
|
+
|
309
|
+
def self.parse_paragraph_style_xml(id, paragraph_style, character_style)
|
310
|
+
doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/styles.xml'))
|
311
|
+
doc.search('//w:style').each do |style|
|
312
|
+
next unless style.attribute('styleId').value == id
|
313
|
+
style.xpath('w:pPr').each do |p_pr|
|
314
|
+
parse_paragraph_style(p_pr, paragraph_style, character_style)
|
315
|
+
paragraph_style.style = StyleParametres.parse(style)
|
316
|
+
end
|
317
|
+
style.xpath('w:rPr').each do |r_pr|
|
318
|
+
DocxParagraphRun.parse(r_pr, character_style, @default_character)
|
319
|
+
end
|
320
|
+
break
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module OoxmlParser
|
2
|
+
class HeaderFooter < OOXMLDocumentObject
|
3
|
+
attr_accessor :id, :description, :type
|
4
|
+
|
5
|
+
def initialize(type = :header)
|
6
|
+
@type = type
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse(type, id, default_paragraph, default_character)
|
10
|
+
if type == :header
|
11
|
+
doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/footnotes.xml'))
|
12
|
+
doc.search('//w:footnote').each do |footnote|
|
13
|
+
next unless footnote.attribute('id').value == id
|
14
|
+
description = []
|
15
|
+
paragraph_number = 0
|
16
|
+
footnote.xpath('w:p').each do |paragraph|
|
17
|
+
description << DocxParagraph.parse(paragraph, paragraph_number, default_paragraph, default_character)
|
18
|
+
paragraph_number += 1
|
19
|
+
end
|
20
|
+
return description
|
21
|
+
end
|
22
|
+
elsif type == :header
|
23
|
+
doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + 'word/endnotes.xml'))
|
24
|
+
doc.search('//w:endnote').each do |footnote|
|
25
|
+
next unless footnote.attribute('id').value == id
|
26
|
+
description = []
|
27
|
+
paragraph_number = 0
|
28
|
+
footnote.xpath('w:p').each do |paragraph|
|
29
|
+
description << DocxParagraph.parse(paragraph, paragraph_number, default_paragraph, default_character)
|
30
|
+
paragraph_number += 1
|
31
|
+
end
|
32
|
+
return description
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Image Data
|
2
|
+
module OoxmlParser
|
3
|
+
class Image
|
4
|
+
attr_accessor :path, :start_x, :start_y, :end_x, :end_y, :wrap_text
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@path = nil
|
8
|
+
@start_x = 0
|
9
|
+
@start_y = 0
|
10
|
+
@end_x = nil
|
11
|
+
@end_y = nil
|
12
|
+
@wrap_text = 'In text'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'columns/column'
|
2
|
+
module OoxmlParser
|
3
|
+
class Columns < OOXMLDocumentObject
|
4
|
+
attr_accessor :separator
|
5
|
+
attr_accessor :count
|
6
|
+
attr_accessor :equal_width
|
7
|
+
alias equal_width? equal_width
|
8
|
+
attr_accessor :column_array
|
9
|
+
|
10
|
+
def initialize(columns_count)
|
11
|
+
@count = columns_count
|
12
|
+
@column_array = []
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Array, Column] accessor
|
16
|
+
def [](key)
|
17
|
+
@column_array[key]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Parse Columns data
|
21
|
+
# @param [Nokogiri::XML:Element] node with Columns data
|
22
|
+
# @return [DocumentGrid] value of Columns data
|
23
|
+
def self.parse(columns_grid)
|
24
|
+
columns_count = 1
|
25
|
+
columns_count = columns_grid.attribute('num').value.to_i unless columns_grid.attribute('num').nil?
|
26
|
+
columns = Columns.new(columns_count)
|
27
|
+
columns.separator = columns_grid.attribute('sep').value unless columns_grid.attribute('sep').nil?
|
28
|
+
columns.equal_width = option_enabled?(columns_grid, 'equalWidth') unless columns_grid.attribute('equalWidth').nil?
|
29
|
+
columns_grid.xpath('w:col').each do |col|
|
30
|
+
width = (col.attribute('w').value.to_f / OoxmlParser.configuration.units_delimiter).round(2)
|
31
|
+
space = (col.attribute('space').value.to_f / OoxmlParser.configuration.units_delimiter).round(2) unless col.attribute('space').nil?
|
32
|
+
columns.column_array << Column.new(width, space)
|
33
|
+
end
|
34
|
+
columns
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/document_grid.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module OoxmlParser
|
2
|
+
class DocumentGrid
|
3
|
+
attr_accessor :type, :line_pitch, :char_space
|
4
|
+
|
5
|
+
def initialize(type = nil, line_pitch = nil, char_space = nil)
|
6
|
+
@type = type
|
7
|
+
@line_pitch = line_pitch
|
8
|
+
@char_space = char_space
|
9
|
+
end
|
10
|
+
|
11
|
+
# Parse DocumentGrid
|
12
|
+
# @param [Nokogiri::XML:Element] node with DocumentGrid
|
13
|
+
# @return [DocumentGrid] value of DocumentGrid
|
14
|
+
def self.parse(node)
|
15
|
+
document_grid = DocumentGrid.new
|
16
|
+
node.attributes.each do |key, value|
|
17
|
+
case key
|
18
|
+
when 'charSpace'
|
19
|
+
document_grid.char_space = value.value
|
20
|
+
when 'linePitch'
|
21
|
+
document_grid.line_pitch = value.value.to_i
|
22
|
+
when 'type'
|
23
|
+
document_grid.type = value.value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
document_grid
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module OoxmlParser
|
2
|
+
class Note < OOXMLDocumentObject
|
3
|
+
attr_accessor :type, :elements, :assigned_to
|
4
|
+
|
5
|
+
def initialize(type = nil, elements = [], assigned_to = nil)
|
6
|
+
@type = type
|
7
|
+
@elements = elements
|
8
|
+
@assigned_to = assigned_to
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.parse(default_paragraph, default_character, target, assigned_to, type)
|
12
|
+
note = Note.new
|
13
|
+
note.type = type
|
14
|
+
note.assigned_to = assigned_to
|
15
|
+
doc = Nokogiri::XML(File.open(OOXMLDocumentObject.path_to_folder + "word/#{target}"))
|
16
|
+
if type.include?('footer')
|
17
|
+
xpath_note = '//w:ftr'
|
18
|
+
elsif type.include?('header')
|
19
|
+
xpath_note = '//w:hdr'
|
20
|
+
else
|
21
|
+
raise "Cannot parse unknown Note type: #{type}"
|
22
|
+
end
|
23
|
+
doc.search(xpath_note).each do |ftr|
|
24
|
+
number = 0
|
25
|
+
ftr.xpath('*').each do |sub_element|
|
26
|
+
if sub_element.name == 'p'
|
27
|
+
note.elements << DocxParagraph.parse(sub_element, number, default_paragraph, default_character)
|
28
|
+
number += 1
|
29
|
+
elsif sub_element.name == 'tbl'
|
30
|
+
note.elements << Table.parse(sub_element, number)
|
31
|
+
number += 1
|
32
|
+
elsif sub_element.name == 'std'
|
33
|
+
sub_element.xpath('w:p').each do |p|
|
34
|
+
note.elements << DocxParagraph.parse(p, number, default_paragraph, default_character)
|
35
|
+
number += 1
|
36
|
+
end
|
37
|
+
sub_element.xpath('w:sdtContent').each do |sdt_content|
|
38
|
+
sdt_content.xpath('w:p').each do |p|
|
39
|
+
note.elements << DocxParagraph.parse(p, number, default_paragraph, default_character)
|
40
|
+
number += 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
note
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_margins.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module OoxmlParser
|
2
|
+
class PageMargins
|
3
|
+
attr_accessor :top, :bottom, :left, :right, :footer, :gutter, :header
|
4
|
+
|
5
|
+
def initialize(top: nil, bottom: nil, left: nil, right: nil, header: nil, footer: nil, gutter: nil)
|
6
|
+
@top = top
|
7
|
+
@bottom = bottom
|
8
|
+
@left = left
|
9
|
+
@right = right
|
10
|
+
@header = header
|
11
|
+
@footer = footer
|
12
|
+
@gutter = gutter
|
13
|
+
end
|
14
|
+
|
15
|
+
def ==(other)
|
16
|
+
other.class == PageMargins &&
|
17
|
+
@top == other.top &&
|
18
|
+
@bottom == other.bottom &&
|
19
|
+
@left == other.left &&
|
20
|
+
@right == other.right &&
|
21
|
+
@footer == other.footer &&
|
22
|
+
@header == other.header &&
|
23
|
+
@gutter == other.gutter
|
24
|
+
end
|
25
|
+
|
26
|
+
# Parse BordersProperties
|
27
|
+
# @param [Nokogiri::XML:Element] node with PageMargins
|
28
|
+
# @return [PageMargins] value of PageMargins
|
29
|
+
def self.parse(node)
|
30
|
+
margins = PageMargins.new
|
31
|
+
# TODO: implement and understand, why 566.929, but not `unit_delimiter`
|
32
|
+
margins.top = (node.attribute('top').value.to_f / 566.929).round(2)
|
33
|
+
margins.left = (node.attribute('left').value.to_f / 566.929).round(2)
|
34
|
+
margins.right = (node.attribute('right').value.to_f / 566.929).round(2)
|
35
|
+
margins.bottom = (node.attribute('bottom').value.to_f / 566.929).round(2)
|
36
|
+
margins.header = (node.attribute('header').value.to_f / 566.929).round(2) unless node.attribute('header').nil?
|
37
|
+
margins.footer = (node.attribute('footer').value.to_f / 566.929).round(2) unless node.attribute('footer').nil?
|
38
|
+
margins.gutter = (node.attribute('gutter').value.to_f / 566.929).round(2)
|
39
|
+
margins
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/ooxml_parser/docx_parser/docx_data/document_structure/page_properties/page_properties.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative 'document_grid'
|
2
|
+
require_relative 'size'
|
3
|
+
require_relative 'page_margins'
|
4
|
+
require_relative 'columns'
|
5
|
+
require_relative 'note'
|
6
|
+
module OoxmlParser
|
7
|
+
class PageProperties < OOXMLDocumentObject
|
8
|
+
attr_accessor :type, :size, :margins, :document_grid, :num_type, :form_prot, :text_direction, :page_borders, :columns,
|
9
|
+
:notes
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@type = nil
|
13
|
+
@size = nil
|
14
|
+
@margins = nil
|
15
|
+
@document_grid = nil
|
16
|
+
@num_type = nil
|
17
|
+
@form_prot = nil
|
18
|
+
@text_direction = nil
|
19
|
+
@columns = nil
|
20
|
+
@notes = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.parse(sect_pr, default_paragraph, default_character)
|
24
|
+
page_properties = PageProperties.new
|
25
|
+
sect_pr.xpath('w:pgSz').each do |pg_sz|
|
26
|
+
page_properties.size = Size.parse(pg_sz)
|
27
|
+
end
|
28
|
+
sect_pr.xpath('w:pgBorders').each do |pg_borders|
|
29
|
+
page_borders = Borders.new
|
30
|
+
unless pg_borders.attribute('display').nil?
|
31
|
+
page_borders.display = pg_borders.attribute('display').value
|
32
|
+
end
|
33
|
+
unless pg_borders.attribute('offsetFrom').nil?
|
34
|
+
page_borders.offset_from = pg_borders.attribute('offsetFrom').value
|
35
|
+
end
|
36
|
+
pg_borders.xpath('w:bottom').each do |bottom|
|
37
|
+
page_borders.bottom = BordersProperties.parse(bottom)
|
38
|
+
end
|
39
|
+
pg_borders.xpath('w:left').each do |left|
|
40
|
+
page_borders.bottom = BordersProperties.parse(left)
|
41
|
+
end
|
42
|
+
pg_borders.xpath('w:top').each do |top|
|
43
|
+
page_borders.bottom = BordersProperties.parse(top)
|
44
|
+
end
|
45
|
+
pg_borders.xpath('w:right').each do |right|
|
46
|
+
page_borders.bottom = BordersProperties.parse(right)
|
47
|
+
end
|
48
|
+
page_properties.page_border = page_borders
|
49
|
+
end
|
50
|
+
sect_pr.xpath('w:type').each do |type|
|
51
|
+
page_properties.type = type.attribute('val').value
|
52
|
+
end
|
53
|
+
sect_pr.xpath('w:pgMar').each do |pg_mar|
|
54
|
+
page_properties.margins = PageMargins.parse(pg_mar)
|
55
|
+
end
|
56
|
+
sect_pr.xpath('w:pgNumType').each do |pg_num_type|
|
57
|
+
page_properties.num_type = pg_num_type.attribute('fmt').value unless pg_num_type.attribute('fmt').nil?
|
58
|
+
end
|
59
|
+
sect_pr.xpath('w:formProt').each do |form_prot|
|
60
|
+
page_properties.form_prot = form_prot.attribute('val').value
|
61
|
+
end
|
62
|
+
sect_pr.xpath('w:textDirection').each do |text_direction|
|
63
|
+
page_properties.text_direction = text_direction.attribute('val').value
|
64
|
+
end
|
65
|
+
sect_pr.xpath('w:docGrid').each do |doc_grid|
|
66
|
+
page_properties.document_grid = DocumentGrid.parse(doc_grid)
|
67
|
+
end
|
68
|
+
sect_pr.xpath('w:cols').each do |columns_grid|
|
69
|
+
page_properties.columns = Columns.parse(columns_grid)
|
70
|
+
end
|
71
|
+
sect_pr.xpath('w:headerReference').each do |header_reference|
|
72
|
+
target = OOXMLDocumentObject.get_link_from_rels(header_reference.attribute('id').value)
|
73
|
+
OOXMLDocumentObject.add_to_xmls_stack("word/#{target}")
|
74
|
+
note = Note.parse(default_paragraph, default_character, target, header_reference.attribute('type').value, File.basename(target).sub('.xml', ''))
|
75
|
+
page_properties.notes << note
|
76
|
+
OOXMLDocumentObject.xmls_stack.pop
|
77
|
+
end
|
78
|
+
sect_pr.xpath('w:footerReference').each do |footer_reference|
|
79
|
+
target = OOXMLDocumentObject.get_link_from_rels(footer_reference.attribute('id').value)
|
80
|
+
OOXMLDocumentObject.add_to_xmls_stack("word/#{target}")
|
81
|
+
note = Note.parse(default_paragraph, default_character, target, footer_reference.attribute('type').value, File.basename(target).sub('.xml', ''))
|
82
|
+
page_properties.notes << note
|
83
|
+
OOXMLDocumentObject.xmls_stack.pop
|
84
|
+
end
|
85
|
+
page_properties
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|