Class: OoxmlParser::PageProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::PageProperties
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb
Overview
Class for data of PageProperties
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#document_grid ⇒ Object
Returns the value of attribute document_grid.
-
#footnote_properties ⇒ FootnoteProperties
Properties of footnote.
-
#form_prot ⇒ Object
Returns the value of attribute form_prot.
-
#margins ⇒ Object
Returns the value of attribute margins.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#num_type ⇒ Object
Returns the value of attribute num_type.
-
#page_borders ⇒ Object
Returns the value of attribute page_borders.
-
#size ⇒ Object
Returns the value of attribute size.
-
#text_direction ⇒ Object
Returns the value of attribute text_direction.
-
#title_page ⇒ True, False
readonly
Specifies whether the section should have a different header and footer for its first page.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil, type: nil) ⇒ PageProperties
constructor
A new instance of PageProperties.
-
#parse(node, default_paragraph, default_character) ⇒ PageProperties
Parse PageProperties data.
-
#section_break ⇒ String
Type of section break.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil, type: nil) ⇒ PageProperties
Returns a new instance of PageProperties.
22 23 24 25 26 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 22 def initialize(parent: nil, type: nil) @notes = [] @type = type super(parent: parent) end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def columns @columns end |
#document_grid ⇒ Object
Returns the value of attribute document_grid.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def document_grid @document_grid end |
#footnote_properties ⇒ FootnoteProperties
Returns properties of footnote.
18 19 20 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 18 def footnote_properties @footnote_properties end |
#form_prot ⇒ Object
Returns the value of attribute form_prot.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def form_prot @form_prot end |
#margins ⇒ Object
Returns the value of attribute margins.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def margins @margins end |
#notes ⇒ Object
Returns the value of attribute notes.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def notes @notes end |
#num_type ⇒ Object
Returns the value of attribute num_type.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def num_type @num_type end |
#page_borders ⇒ Object
Returns the value of attribute page_borders.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def page_borders @page_borders end |
#size ⇒ Object
Returns the value of attribute size.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def size @size end |
#text_direction ⇒ Object
Returns the value of attribute text_direction.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def text_direction @text_direction end |
#title_page ⇒ True, False (readonly)
Returns Specifies whether the section should have a different header and footer for its first page.
20 21 22 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 20 def title_page @title_page end |
#type ⇒ Object
Returns the value of attribute type.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 15 def type @type end |
Instance Method Details
#parse(node, default_paragraph, default_character) ⇒ PageProperties
Parse PageProperties data
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 31 def parse(node, default_paragraph, default_character) node.xpath('*').each do |pg_size_subnode| case pg_size_subnode.name when 'pgSz' @size = PageSize.new.parse(pg_size_subnode) when 'pgBorders' page_borders_object = PageBorders.new(parent: self).parse(pg_size_subnode) page_borders = Borders.new page_borders.display = page_borders_object.display if page_borders_object.display page_borders.offset_from = page_borders_object.offset_from if page_borders_object.offset_from pg_size_subnode.xpath('w:bottom').each do |bottom| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(bottom) end pg_size_subnode.xpath('w:left').each do |left| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(left) end pg_size_subnode.xpath('w:top').each do |top| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(top) end pg_size_subnode.xpath('w:right').each do |right| page_borders.bottom = BordersProperties.new(parent: page_borders).parse(right) end @page_borders = page_borders when 'type' @type_object = ValuedChild.new(:string, parent: self).parse(pg_size_subnode) @type = @type_object.value when 'pgMar' @margins = PageMargins.new(parent: self).parse(pg_size_subnode) when 'pgNumType' @num_type = pg_size_subnode.attribute('fmt').value unless pg_size_subnode.attribute('fmt').nil? when 'formProt' form_prot_object = ValuedChild.new(:string, parent: self).parse(pg_size_subnode) @form_prot = form_prot_object.value when 'textDirection' text_directon_object = ValuedChild.new(:string, parent: self).parse(pg_size_subnode) @text_direction = text_directon_object.value when 'docGrid' @document_grid = DocumentGrid.new(parent: self).parse(pg_size_subnode) when 'titlePg' @title_page = option_enabled?(pg_size_subnode) when 'cols' @columns = Columns.new.parse(pg_size_subnode) when 'headerReference', 'footerReference' reference = HeaderFooterReference.new(parent: self).parse(pg_size_subnode) target = root_object.get_link_from_rels(reference.id) root_object.add_to_xmls_stack("word/#{target}") note = Note.new.parse(default_paragraph: default_paragraph, default_character: default_character, target: target, assigned_to: reference.type, type: File.basename(target).sub('.xml', ''), parent: self) @notes << note root_object.xmls_stack.pop when 'footnotePr' @footnote_properties = FootnoteProperties.new(parent: self).parse(pg_size_subnode) end end self end |
#section_break ⇒ String
Returns type of section break.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ooxml_parser/docx_parser/document_structure/page_properties/page_properties.rb', line 93 def section_break @section_break ||= case type when 'oddPage' 'Odd page' when 'continuous' 'Current Page' else 'Next Page' end end |