Class: OoxmlParser::DocumentStyle
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::DocumentStyle
- Includes:
- DocumentStyleHelper, TableStylePropertiesHelper
- Defined in:
- lib/ooxml_parser/docx_parser/document_structure/document_style.rb
Overview
Class for describing styles containing in styles.xml
Constant Summary
Constants included from TableStylePropertiesHelper
TableStylePropertiesHelper::TABLE_STYLES_NAMES_HASH
Instance Attribute Summary collapse
-
#based_on ⇒ FixNum
Id of style on which this style is based.
-
#default ⇒ True, False
readonly
Is style default.
-
#name ⇒ String
Name of style.
-
#next_style ⇒ FixNum
Id of next style.
-
#paragraph_properties ⇒ DocxParagraph
Run properties.
-
#paragraph_properties_node ⇒ Nokogiri::XML:Node
Paragraph properties node.
-
#q_format ⇒ True, False
(also: #visible?)
Used to determine if current style is visible in style list in editors According to www.wordarticles.com/Articles/WordStyles/LatentStyles.php.
-
#raw_node ⇒ Nokogiri::XML:Element
readonly
Raw node value.
-
#run_properties ⇒ DocxParagraphRun
Run properties.
-
#run_properties_node ⇒ Nokogiri::XML:Node
Run properties node.
-
#style_id ⇒ FixNum
Number of style.
-
#table_cell_properties ⇒ CellProperties
Properties of table cell.
-
#table_properties ⇒ TableProperties
Properties of table.
-
#table_row_properties ⇒ TableRowProperties
Properties of table row.
-
#table_style_properties_list ⇒ Array, TableStyleProperties
List of table style properties.
-
#type ⇒ Symbol
Type of style (
:paragraph
or:table
).
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil) ⇒ DocumentStyle
constructor
A new instance of DocumentStyle.
-
#inspect ⇒ String
Inspect of object for debug means.
-
#parse(node) ⇒ DocumentStyle
Parse single document style.
-
#to_s ⇒ String
Result of convert of object to string.
Methods included from DocumentStyleHelper
#based_on_style, #document_style_by_id, #document_style_by_name, #style_exist?
Methods included from TableStylePropertiesHelper
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) ⇒ DocumentStyle
Returns a new instance of DocumentStyle.
47 48 49 50 51 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 47 def initialize(parent: nil) @q_format = false @table_style_properties_list = [] super end |
Instance Attribute Details
#based_on ⇒ FixNum
Returns id of style on which this style is based.
19 20 21 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 19 def based_on @based_on end |
#default ⇒ True, False (readonly)
Returns is style default.
11 12 13 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 11 def default @default end |
#name ⇒ String
Returns name of style.
17 18 19 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 17 def name @name end |
#next_style ⇒ FixNum
Returns id of next style.
21 22 23 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 21 def next_style @next_style end |
#paragraph_properties ⇒ DocxParagraph
Returns run properties.
27 28 29 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 27 def paragraph_properties @paragraph_properties end |
#paragraph_properties_node ⇒ Nokogiri::XML:Node
Returns paragraph properties node.
29 30 31 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 29 def paragraph_properties_node @paragraph_properties_node end |
#q_format ⇒ True, False Also known as: visible?
Used to determine if current style is visible in style list in editors According to www.wordarticles.com/Articles/WordStyles/LatentStyles.php
41 42 43 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 41 def q_format @q_format end |
#raw_node ⇒ Nokogiri::XML:Element (readonly)
Returns raw node value.
43 44 45 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 43 def raw_node @raw_node end |
#run_properties ⇒ DocxParagraphRun
Returns run properties.
23 24 25 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 23 def run_properties @run_properties end |
#run_properties_node ⇒ Nokogiri::XML:Node
Returns run properties node.
25 26 27 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 25 def run_properties_node @run_properties_node end |
#style_id ⇒ FixNum
Returns number of style.
15 16 17 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 15 def style_id @style_id end |
#table_cell_properties ⇒ CellProperties
Returns properties of table cell.
37 38 39 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 37 def table_cell_properties @table_cell_properties end |
#table_properties ⇒ TableProperties
Returns properties of table.
31 32 33 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 31 def table_properties @table_properties end |
#table_row_properties ⇒ TableRowProperties
Returns properties of table row.
35 36 37 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 35 def table_row_properties @table_row_properties end |
#table_style_properties_list ⇒ Array, TableStyleProperties
Returns list of table style properties.
33 34 35 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 33 def table_style_properties_list @table_style_properties_list end |
#type ⇒ Symbol
Returns Type of style (:paragraph
or :table
).
13 14 15 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 13 def type @type end |
Instance Method Details
#inspect ⇒ String
Returns inspect of object for debug means.
59 60 61 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 59 def inspect to_s end |
#parse(node) ⇒ DocumentStyle
Parse single document style
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 65 def parse(node) @raw_node = node node.attributes.each do |key, value| case key when 'type' @type = value.value.to_sym when 'styleId' @style_id = value.value when 'default' @default = attribute_enabled?(value.value) end end node.xpath('*').each do |subnode| case subnode.name when 'name' @name_object = ValuedChild.new(:string, parent: self).parse(subnode) @name = @name_object.value when 'basedOn' @based_on_object = ValuedChild.new(:string, parent: self).parse(subnode) @based_on = @based_on_object.value when 'next' @next_style_object = ValuedChild.new(:string, parent: self).parse(subnode) @next_style = @next_style_object.value when 'rPr' @run_properties_node = subnode @run_properties = DocxParagraphRun.new(parent: self).parse_properties(@run_properties_node) when 'pPr' @paragraph_properties_node = subnode @paragraph_properties = ParagraphProperties.new(parent: self).parse(@paragraph_properties_node) when 'tblPr' @table_properties = TableProperties.new(parent: self).parse(subnode) when 'trPr' @table_row_properties = TableRowProperties.new(parent: self).parse(subnode) when 'tcPr' @table_cell_properties = CellProperties.new(parent: self).parse(subnode) when 'tblStylePr' @table_style_properties_list << TableStyleProperties.new(parent: self).parse(subnode) when 'qFormat' @q_format = true end end fill_empty_table_styles self end |
#to_s ⇒ String
Returns result of convert of object to string.
54 55 56 |
# File 'lib/ooxml_parser/docx_parser/document_structure/document_style.rb', line 54 def to_s "Table style properties list: #{@table_style_properties_list.join(',')}" end |