require 'rubyXL/objects/ooxml_object' require 'rubyXL/objects/extensions' module RubyXL # http://www.schemacentral.com/sc/ooxml/e-a_ext-1.html class AExtension < OOXMLObject define_attribute(:uri, :string) define_element_name 'a:ext' attr_accessor :raw_xml def self.parse(node) obj = new obj.raw_xml = node.to_xml obj end def write_xml(xml, node_name_override = nil) self.raw_xml end end class AExtensionStorageArea < OOXMLObject #FIXME# define_child_node(RubyXL::AExtension, :collection => true) define_element_name 'a:extLst' end class ColorScheme < OOXMLObject #FIXME# define_element_name 'a:clrScheme' end class FontScheme < OOXMLObject #FIXME# define_element_name 'a:fontScheme' end class FormatScheme < OOXMLObject #FIXME# define_element_name 'a:fmtScheme' end # http://www.schemacentral.com/sc/ooxml/e-a_themeElements-1.html class ThemeElements < OOXMLObject define_child_node(RubyXL::ColorScheme) define_child_node(RubyXL::FontScheme) define_child_node(RubyXL::FormatScheme) define_child_node(RubyXL::AExtensionStorageArea) define_element_name 'a:themeElements' end # http://www.schemacentral.com/sc/ooxml/e-a_off-1.html class Offset < OOXMLObject define_attribute(:x, :int, :required => true) define_attribute(:y, :int, :required => true) define_element_name 'a:off' end # http://www.schemacentral.com/sc/ooxml/e-a_ext-2.html class Extents < OOXMLObject define_attribute(:cx, :int, :required => true) define_attribute(:cy, :int, :required => true) define_element_name 'a:ext' end # http://www.schemacentral.com/sc/ooxml/e-a_xfrm-4.html class TwoDTransform < OOXMLObject define_attribute(:rot, :int, :default => 0) define_attribute(:flipH, :bool, :default => false) define_attribute(:flipV, :bool, :default => false) define_child_node(RubyXL::Offset) define_child_node(RubyXL::Extents) define_element_name 'a:xfrm' end # http://www.schemacentral.com/sc/ooxml/e-a_custGeom-1.html class CustomGeometry < OOXMLObject # a:avLst [0..1] Adjust Value List # a:gdLst [0..1] List of Shape Guides # a:ahLst [0..1] List of Shape Adjust Handles # a:cxnLst [0..1] List of Shape Connection Sites # a:rect [0..1] Shape Text Rectangle # a:pathLst [1..1] List of Shape Paths define_element_name 'a:custGeom' end # http://www.schemacentral.com/sc/ooxml/e-a_prstGeom-1.html class PresetGeometry < OOXMLObject # a:avLst [0..1] Adjust Value List define_attribute(:prst, RubyXL::ST_ShapeType, :required => true) define_element_name 'a:prstGeom' end # http://www.schemacentral.com/sc/ooxml/e-a_spPr-1.html class VisualProperties < OOXMLObject define_child_node(RubyXL::TwoDTransform) define_child_node(RubyXL::CustomGeometry) define_child_node(RubyXL::PresetGeometry) # a:noFill No Fill # a:solidFill Solid Fill # a:gradFill Gradient Fill # a:blipFill Picture Fill # a:pattFill Pattern Fill # a:grpFill Group Fill # a:ln [0..1] # a:effectLst Effect Container # a:effectDag Effect Container # a:scene3d [0..1] 3-D Scene # a:sp3d [0..1] 3-D Shape Properties # a:extLst [0..1] Extension List define_attribute(:bwMode, RubyXL::ST_BlackWhiteMode) define_child_node(RubyXL::AExtensionStorageArea) define_element_name 'a:spPr' end # http://www.schemacentral.com/sc/ooxml/e-a_spDef-1.html class ShapeDefault < OOXMLObject define_child_node(RubyXL::VisualProperties) # a:bodyPr [1..1] BodyProperties # a:lstStyle [1..1] TextListStyles # a:style [0..1] Shape Style define_child_node(RubyXL::AExtensionStorageArea) define_element_name 'a:spDef' end # http://www.schemacentral.com/sc/ooxml/e-a_objectDefaults-1.html class ObjectDefaults < OOXMLObject define_child_node(RubyXL::ShapeDefault) # a:spDef [0..1] # a:lnDef [0..1] LineDefault # a:txDef [0..1] TextDefault define_child_node(RubyXL::AExtensionStorageArea) define_element_name 'a:objectDefaults' end # http://www.schemacentral.com/sc/ooxml/e-a_extraClrScheme-1.html class ExtraColorScheme < OOXMLObject # a:clrScheme [1..1] ColorScheme # a:clrMap [0..1] ColorMap define_element_name 'a:extraClrScheme' end # http://www.schemacentral.com/sc/ooxml/e-a_extraClrSchemeLst-1.html class ExtraColorSchemeList < OOXMLContainerObject define_child_node(RubyXL::ExtraColorScheme, :collection => true) define_element_name 'a:extraClrSchemeLst' end # http://www.schemacentral.com/sc/ooxml/e-a_custClr-1.html class CustomColor < OOXMLObject # a:scrgbClr RGB Color Model - Percentage Variant # a:srgbClr RGB Color Model - Hex Variant # a:hslClr Hue, Saturation, Luminance Color Model # a:sysClr System Color # a:schemeClr Scheme Color # a:prstClr Preset Color define_attribute(:name, :string, :default => '') define_element_name 'a:custClr' end # http://www.schemacentral.com/sc/ooxml/e-a_custClrLst-1.html class CustomColorList < OOXMLContainerObject define_child_node(RubyXL::CustomColor, :collection => true) define_element_name 'a:custClrLst' end # http://www.schemacentral.com/sc/ooxml/e-a_theme.html class Theme < OOXMLTopLevelObject define_attribute(:name, :string, :default => '') define_child_node(RubyXL::ThemeElements) define_child_node(RubyXL::ObjectDefaults) define_child_node(RubyXL::ExtraColorSchemeList) define_child_node(RubyXL::CustomColorList) define_child_node(RubyXL::AExtensionStorageArea) define_element_name 'a:theme' set_namespaces('xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main') def self.xlsx_path File.join('xl', 'theme', 'theme1.xml') end def self.content_type 'application/vnd.openxmlformats-officedocument.theme+xml' end ###### Temporary storage of the theme until I'm done with fully implementing ###### all of its intricacies attr_accessor :raw_xml def self.parse_file(dirpath) full_path = File.join(dirpath, xlsx_path) return nil unless File.exist?(full_path) obj = self.new obj.raw_xml = File.open(full_path, 'r').read obj end def write_xml raw_xml || # Use fallback theme. ' ' end ###### end end