Sha256: 45783b9de9ecc822d00c7814290cfcdf73fbed41929d7983879fa0b34d2532e1
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module Goldendocx module Documents class Styles include Goldendocx::Document XML_PATH = 'word/styles.xml' TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles' CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' tag :styles namespace :w concern_namespaces :mc, :r, :w, :w14, :w15 ignore_namespaces :w14, :w15 embeds_one :defaults, class_name: 'Goldendocx::Documents::Properties::DefaultStyleProperty', auto_build: true embeds_one :latentStyles, class_name: 'Goldendocx::Documents::LatentStyles' embeds_many :styles, class_name: 'Goldendocx::Documents::Style' def size styles.size end def write_to(zos) zos.put_next_entry XML_PATH zos.write to_document_xml end def find_text_style(style_name) return if style_name.nil? styles.find { |s| s.type == 'paragraph' && s.name == style_name } end def find_table_style(style_name) return if style_name.nil? styles.find { |s| s.type == 'table' && s.name == style_name } end def add_style(fragment) style = Goldendocx::Documents::Style.parse(fragment) style.id = (styles.size + 1).to_s # Rearrange id to prevent duplicates styles << style style.id end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
goldendocx-0.3.0 | lib/goldendocx/documents/styles.rb |
goldendocx-0.2.3 | lib/goldendocx/documents/styles.rb |