Class: OoxmlParser::PresentationTheme
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::PresentationTheme
- Defined in:
- lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb
Instance Attribute Summary collapse
-
#color_scheme ⇒ Object
Returns the value of attribute color_scheme.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from OOXMLDocumentObject
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = '', color_scheme = {}) ⇒ PresentationTheme
constructor
A new instance of PresentationTheme.
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(name = '', color_scheme = {}) ⇒ PresentationTheme
Returns a new instance of PresentationTheme.
6 7 8 9 |
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb', line 6 def initialize(name = '', color_scheme = {}) @name = name @color_scheme = color_scheme end |
Instance Attribute Details
#color_scheme ⇒ Object
Returns the value of attribute color_scheme.
4 5 6 |
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb', line 4 def color_scheme @color_scheme end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb', line 4 def name @name end |
Class Method Details
.parse(file) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme.rb', line 11 def self.parse(file) OOXMLDocumentObject.theme = PresentationTheme.new OOXMLDocumentObject.add_to_xmls_stack(file) unless File.exist?(OOXMLDocumentObject.current_xml) OOXMLDocumentObject.xmls_stack.pop return end doc = Nokogiri::XML(File.open(OOXMLDocumentObject.current_xml)) doc.xpath('a:theme').each do |theme_node| OOXMLDocumentObject.theme.name = theme_node.attribute('name').value if theme_node.attribute('name') theme_node.xpath('a:themeElements/*').each do |theme_element_node| case theme_element_node.name when 'clrScheme' theme_element_node.xpath('*').each do |color_scheme_element| OOXMLDocumentObject.theme.color_scheme[color_scheme_element.name.to_sym] = ThemeColor.new.parse(color_scheme_element) end OOXMLDocumentObject.theme.color_scheme[:background1] = OOXMLDocumentObject.theme.color_scheme[:lt1] OOXMLDocumentObject.theme.color_scheme[:background2] = OOXMLDocumentObject.theme.color_scheme[:lt2] OOXMLDocumentObject.theme.color_scheme[:bg1] = OOXMLDocumentObject.theme.color_scheme[:lt1] OOXMLDocumentObject.theme.color_scheme[:bg2] = OOXMLDocumentObject.theme.color_scheme[:lt2] OOXMLDocumentObject.theme.color_scheme[:text1] = OOXMLDocumentObject.theme.color_scheme[:dk1] OOXMLDocumentObject.theme.color_scheme[:text2] = OOXMLDocumentObject.theme.color_scheme[:dk2] OOXMLDocumentObject.theme.color_scheme[:tx1] = OOXMLDocumentObject.theme.color_scheme[:dk1] OOXMLDocumentObject.theme.color_scheme[:tx2] = OOXMLDocumentObject.theme.color_scheme[:dk2] end end end OOXMLDocumentObject.xmls_stack.pop ThemeColors.list = {} OOXMLDocumentObject.theme.color_scheme.each { |key, value| ThemeColors.list[key] = value.color } OOXMLDocumentObject.theme end |