class Xlsxrb::Ooxml::Reader::DrawingShapesListener
SAX2 listener for parsing drawing XML to extract shape elements.
Attributes
Public Class Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 4501 def initialize @shapes = [] @inside_anchor = false @inside_sp = false @current_shape = nil @inside_from = false @inside_to = false @inside_tx_body = false @inside_t = false @current_field = nil @text_buffer = +"" @anchor_from = {} @anchor_to = {} @inside_solid_fill = false @inside_highlight = false @inside_ln = false @inside_rpr_ln = false @inside_rpr_effect_lst = false @inside_cust_dash = false @inside_prst_geom = false @inside_rpr = false @inside_end_para_rpr = false @inside_def_rpr = false @current_text_font = nil @inside_effect_lst = false @inside_outer_shdw = false @inside_inner_shdw = false @inside_glow = false @inside_grad_fill = false @inside_patt_fill = false @inside_fg_clr = false @inside_bg_clr = false @current_gs_pos = nil @inside_spc_bef = false @inside_spc_aft = false @inside_lnspc = false @inside_tab_lst = false @inside_bu_clr = false @current_paragraph = nil @paragraphs_for_shape = nil @inside_r = false @current_run = nil end
Public Instance Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 5073 def characters(text) @text_buffer << text if @current_field || @inside_t end
# File lib/xlsxrb/ooxml/reader.rb, line 5077 def end_element(_uri, local_name, qname) name = element_name(local_name, qname) case name when "sp" if @current_shape && !@current_shape.empty? @anchor_from.each { |k, v| @current_shape[:"from_#{k}"] = v } @anchor_to.each { |k, v| @current_shape[:"to_#{k}"] = v } @current_shape[:edit_as] = @anchor_edit_as if @anchor_edit_as @shapes << @current_shape end @current_shape = nil @inside_sp = false @inside_tx_body = false when "twoCellAnchor", "oneCellAnchor" @shapes.last[:locks_with_sheet] = @anchor_locks_with_sheet == "1" if @anchor_locks_with_sheet && !@shapes.empty? @shapes.last[:prints_with_sheet] = @anchor_prints_with_sheet == "1" if @anchor_prints_with_sheet && !@shapes.empty? @shapes.last[:published] = true if @anchor_published && !@shapes.empty? @inside_anchor = false @anchor_from = {} @anchor_to = {} @anchor_locks_with_sheet = nil @anchor_prints_with_sheet = nil @anchor_published = false when "from" @inside_from = false when "to" @inside_to = false when "solidFill" @inside_solid_fill = false when "highlight" @inside_highlight = false when "ln" @inside_ln = false @inside_rpr_ln = false @inside_cust_dash = false when "effectLst" @inside_effect_lst = false @inside_rpr_effect_lst = false when "outerShdw" @inside_outer_shdw = false when "innerShdw" @inside_inner_shdw = false when "glow" @inside_glow = false when "gradFill" @inside_grad_fill = false when "pattFill" @inside_patt_fill = false when "fgClr" @inside_fg_clr = false when "bgClr" @inside_bg_clr = false when "prstGeom" @inside_prst_geom = false when "spcBef" @inside_spc_bef = false when "spcAft" @inside_spc_aft = false when "lnSpc" @inside_lnspc = false when "tabLst" @inside_tab_lst = false when "buClr" @inside_bu_clr = false when "rPr" if @inside_rpr && !@inside_end_para_rpr && !@inside_def_rpr && @current_text_font&.any? if @current_run @current_run[:font] = @current_text_font elsif @current_paragraph @current_paragraph[:font] = @current_text_font end end @inside_rpr = false @current_text_font = nil when "endParaRPr" @current_paragraph[:end_para_rpr] = @current_text_font if @inside_end_para_rpr && @current_text_font&.any? && @current_paragraph @inside_rpr = false @inside_end_para_rpr = false @current_text_font = nil when "defRPr" @current_paragraph[:def_rpr] = @current_text_font if @inside_def_rpr && @current_text_font&.any? && @current_paragraph @inside_rpr = false @inside_def_rpr = false @current_text_font = nil when "t" if @inside_t && @inside_tx_body if @current_run @current_run[:text] = (@current_run[:text] || +"") << @text_buffer elsif @current_paragraph @current_paragraph[:text] = (@current_paragraph[:text] || +"") << @text_buffer end end @inside_t = false when "r" if @inside_r && @current_run && @current_paragraph @current_paragraph[:runs] ||= [] @current_paragraph[:runs] << @current_run @current_run = nil @inside_r = false end when "p" if @inside_tx_body && @inside_sp && @current_paragraph && @paragraphs_for_shape finalize_paragraph_runs(@current_paragraph) @paragraphs_for_shape << @current_paragraph merge_paragraph_to_shape(@current_paragraph, @current_shape) if @current_shape @current_paragraph = nil end when "txBody" @current_shape[:text_paragraphs] = @paragraphs_for_shape if @inside_tx_body && @inside_sp && @current_shape && @paragraphs_for_shape && @paragraphs_for_shape.size > 1 @inside_tx_body = false @paragraphs_for_shape = nil when "col", "colOff", "row", "rowOff" if @current_field val = @text_buffer.to_i if @inside_from @anchor_from[@current_field] = val elsif @inside_to @anchor_to[@current_field] = val end end @current_field = nil end end
# File lib/xlsxrb/ooxml/reader.rb, line 4545 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) case name when "twoCellAnchor", "oneCellAnchor" @inside_anchor = true @anchor_from = {} @anchor_to = {} @anchor_edit_as = attributes["editAs"] @anchor_published = %w[1 true].include?(attributes["fPublished"]) when "sp" @inside_sp = true @current_shape = {} @current_shape[:macro] = attributes["macro"] if attributes["macro"] && !attributes["macro"].empty? @current_shape[:textlink] = attributes["textlink"] if attributes["textlink"] && !attributes["textlink"].empty? when "cNvPr" if @inside_sp && @current_shape @current_shape[:name] = attributes["name"] if attributes["name"] @current_shape[:id] = attributes["id"]&.to_i @current_shape[:description] = attributes["descr"] if attributes["descr"] @current_shape[:title] = attributes["title"] if attributes["title"] @current_shape[:hidden] = %w[1 true].include?(attributes["hidden"]) if attributes["hidden"] end when "prstGeom" if @inside_sp && @current_shape && attributes["prst"] @current_shape[:preset] = attributes["prst"] @inside_prst_geom = true end when "gd" if @inside_prst_geom && @inside_sp && @current_shape && attributes["name"] && attributes["fmla"] @current_shape[:adjust_values] ||= [] @current_shape[:adjust_values] << { name: attributes["name"], fmla: attributes["fmla"] } end when "xfrm" @current_shape[:rotation] = attributes["rot"].to_i if @inside_sp && @current_shape && attributes["rot"] when "solidFill" @inside_solid_fill = true if @inside_sp when "highlight" @inside_highlight = true if @inside_rpr && @inside_sp when "gradFill" if @inside_sp && @current_shape && !@inside_ln @inside_grad_fill = true gf = { stops: [] } gf[:rot_with_shape] = %w[1 true].include?(attributes["rotWithShape"]) if attributes["rotWithShape"] gf[:flip] = attributes["flip"] if attributes["flip"] @current_shape[:gradient_fill] = gf end when "pattFill" if @inside_sp && @current_shape && !@inside_ln @inside_patt_fill = true @current_shape[:pattern_fill] = { preset: attributes["prst"] } if attributes["prst"] end when "fgClr" @inside_fg_clr = true if @inside_patt_fill when "bgClr" @inside_bg_clr = true if @inside_patt_fill when "gs" @current_gs_pos = attributes["pos"].to_i if @inside_grad_fill && attributes["pos"] when "lin" if @inside_grad_fill && @current_shape @current_shape[:gradient_fill][:angle] = attributes["ang"].to_i if attributes["ang"] @current_shape[:gradient_fill][:scaled] = %w[1 true].include?(attributes["scaled"]) if attributes["scaled"] end when "path" @current_shape[:gradient_fill][:path] = attributes["path"] if @inside_grad_fill && @current_shape && attributes["path"] when "tileRect" if @inside_grad_fill && @current_shape tr = {} %w[l t r b].each { |a| tr[a.to_sym] = attributes[a] if attributes[a] } @current_shape[:gradient_fill][:tile_rect] = tr unless tr.empty? end when "ln" if @inside_rpr && @current_text_font @inside_ln = true @inside_rpr_ln = true @current_text_font[:line_width] = attributes["w"].to_i if attributes["w"] @current_text_font[:line_cap] = attributes["cap"] if attributes["cap"] elsif @inside_sp && @current_shape @inside_ln = true @current_shape[:line_width] = attributes["w"].to_i if attributes["w"] @current_shape[:line_cap] = attributes["cap"] if attributes["cap"] @current_shape[:line_align] = attributes["algn"] if attributes["algn"] @current_shape[:line_compound] = attributes["cmpd"] if attributes["cmpd"] end when "effectLst" if @inside_rpr && @current_text_font @inside_rpr_effect_lst = true elsif @inside_sp @inside_effect_lst = true end when "outerShdw" if @inside_rpr_effect_lst && @current_text_font @inside_outer_shdw = true os = {} os[:blur_rad] = attributes["blurRad"].to_i if attributes["blurRad"] os[:dist] = attributes["dist"].to_i if attributes["dist"] os[:dir] = attributes["dir"].to_i if attributes["dir"] os[:algn] = attributes["algn"] if attributes["algn"] os[:rot_with_shape] = %w[1 true].include?(attributes["rotWithShape"]) if attributes["rotWithShape"] @current_text_font[:outer_shadow] = os elsif @inside_sp && @inside_effect_lst && @current_shape @inside_outer_shdw = true os = {} os[:blur_rad] = attributes["blurRad"].to_i if attributes["blurRad"] os[:dist] = attributes["dist"].to_i if attributes["dist"] os[:dir] = attributes["dir"].to_i if attributes["dir"] os[:algn] = attributes["algn"] if attributes["algn"] os[:rot_with_shape] = %w[1 true].include?(attributes["rotWithShape"]) if attributes["rotWithShape"] @current_shape[:outer_shadow] = os end when "innerShdw" if @inside_rpr_effect_lst && @current_text_font @inside_inner_shdw = true is = {} is[:blur_rad] = attributes["blurRad"].to_i if attributes["blurRad"] is[:dist] = attributes["dist"].to_i if attributes["dist"] is[:dir] = attributes["dir"].to_i if attributes["dir"] @current_text_font[:inner_shadow] = is elsif @inside_sp && @inside_effect_lst && @current_shape @inside_inner_shdw = true is = {} is[:blur_rad] = attributes["blurRad"].to_i if attributes["blurRad"] is[:dist] = attributes["dist"].to_i if attributes["dist"] is[:dir] = attributes["dir"].to_i if attributes["dir"] @current_shape[:inner_shadow] = is end when "glow" if @inside_rpr_effect_lst && @current_text_font @inside_glow = true gl = {} gl[:rad] = attributes["rad"].to_i if attributes["rad"] @current_text_font[:glow] = gl elsif @inside_sp && @inside_effect_lst && @current_shape @inside_glow = true gl = {} gl[:rad] = attributes["rad"].to_i if attributes["rad"] @current_shape[:glow] = gl end when "softEdge" if @inside_rpr_effect_lst && @current_text_font se = {} se[:rad] = attributes["rad"].to_i if attributes["rad"] @current_text_font[:soft_edge] = se elsif @inside_sp && @inside_effect_lst && @current_shape se = {} se[:rad] = attributes["rad"].to_i if attributes["rad"] @current_shape[:soft_edge] = se end when "blur" if @inside_rpr_effect_lst && @current_text_font bl = {} bl[:rad] = attributes["rad"].to_i if attributes["rad"] bl[:grow] = %w[1 true].include?(attributes["grow"]) if attributes["grow"] @current_text_font[:blur] = bl elsif @inside_sp && @inside_effect_lst && @current_shape bl = {} bl[:rad] = attributes["rad"].to_i if attributes["rad"] bl[:grow] = %w[1 true].include?(attributes["grow"]) if attributes["grow"] @current_shape[:blur] = bl end when "reflection" if @inside_rpr_effect_lst && @current_text_font rf = {} rf[:blur_rad] = attributes["blurRad"].to_i if attributes["blurRad"] rf[:st_a] = attributes["stA"].to_i if attributes["stA"] rf[:end_a] = attributes["endA"].to_i if attributes["endA"] rf[:dist] = attributes["dist"].to_i if attributes["dist"] rf[:dir] = attributes["dir"].to_i if attributes["dir"] rf[:fade_dir] = attributes["fadeDir"].to_i if attributes["fadeDir"] rf[:sx] = attributes["sx"].to_i if attributes["sx"] rf[:sy] = attributes["sy"].to_i if attributes["sy"] rf[:kx] = attributes["kx"].to_i if attributes["kx"] rf[:ky] = attributes["ky"].to_i if attributes["ky"] rf[:algn] = attributes["algn"] if attributes["algn"] rf[:rot_with_shape] = %w[1 true].include?(attributes["rotWithShape"]) if attributes["rotWithShape"] @current_text_font[:reflection] = rf elsif @inside_sp && @inside_effect_lst && @current_shape rf = {} rf[:blur_rad] = attributes["blurRad"].to_i if attributes["blurRad"] rf[:st_a] = attributes["stA"].to_i if attributes["stA"] rf[:end_a] = attributes["endA"].to_i if attributes["endA"] rf[:dist] = attributes["dist"].to_i if attributes["dist"] rf[:dir] = attributes["dir"].to_i if attributes["dir"] rf[:fade_dir] = attributes["fadeDir"].to_i if attributes["fadeDir"] rf[:sx] = attributes["sx"].to_i if attributes["sx"] rf[:sy] = attributes["sy"].to_i if attributes["sy"] rf[:kx] = attributes["kx"].to_i if attributes["kx"] rf[:ky] = attributes["ky"].to_i if attributes["ky"] rf[:algn] = attributes["algn"] if attributes["algn"] rf[:rot_with_shape] = %w[1 true].include?(attributes["rotWithShape"]) if attributes["rotWithShape"] @current_shape[:reflection] = rf end when "prstDash" if @inside_rpr_ln && @current_text_font && attributes["val"] @current_text_font[:line_dash] = attributes["val"] elsif @inside_sp && @inside_ln && @current_shape && attributes["val"] @current_shape[:line_dash] = attributes["val"] end when "custDash" @inside_cust_dash = true if @inside_sp && @inside_ln && @current_shape when "ds" if @inside_cust_dash && @inside_sp && @inside_ln && @current_shape ds = {} ds[:d] = attributes["d"].to_i if attributes["d"] ds[:sp] = attributes["sp"].to_i if attributes["sp"] @current_shape[:line_custom_dash] ||= [] @current_shape[:line_custom_dash] << ds end when "round" if @inside_rpr_ln && @current_text_font @current_text_font[:line_join] = "round" elsif @inside_sp && @inside_ln && @current_shape @current_shape[:line_join] = "round" end when "bevel" if @inside_rpr_ln && @current_text_font @current_text_font[:line_join] = "bevel" elsif @inside_sp && @inside_ln && @current_shape @current_shape[:line_join] = "bevel" end when "miter" if @inside_rpr_ln && @current_text_font @current_text_font[:line_join] = "miter" @current_text_font[:line_miter_limit] = attributes["lim"].to_i if attributes["lim"] elsif @inside_sp && @inside_ln && @current_shape @current_shape[:line_join] = "miter" @current_shape[:line_miter_limit] = attributes["lim"].to_i if attributes["lim"] end when "headEnd" if @inside_sp && @inside_ln && @current_shape he = {} he[:type] = attributes["type"] if attributes["type"] he[:w] = attributes["w"] if attributes["w"] he[:len] = attributes["len"] if attributes["len"] @current_shape[:head_end] = he end when "tailEnd" if @inside_sp && @inside_ln && @current_shape te = {} te[:type] = attributes["type"] if attributes["type"] te[:w] = attributes["w"] if attributes["w"] te[:len] = attributes["len"] if attributes["len"] @current_shape[:tail_end] = te end when "spLocks" if @inside_sp && @current_shape @current_shape[:f_locks_text] = true if %w[1 true].include?(attributes["fLocksText"]) @current_shape[:no_grp] = true if %w[1 true].include?(attributes["noGrp"]) @current_shape[:no_rot] = true if %w[1 true].include?(attributes["noRot"]) end when "srgbClr" assign_shape_color(attributes["val"]) if attributes["val"] when "schemeClr" assign_shape_color({ scheme: attributes["val"] }) if attributes["val"] when "noFill" if @inside_sp && @current_shape if @inside_ln @current_shape[:no_line] = true else @current_shape[:no_fill] = true end end when "alpha" if @inside_sp && @current_shape && attributes["val"] alpha_val = attributes["val"].to_i if @inside_outer_shdw && !@inside_rpr_effect_lst @current_shape[:outer_shadow][:alpha] = alpha_val if @current_shape[:outer_shadow] elsif @inside_inner_shdw && !@inside_rpr_effect_lst @current_shape[:inner_shadow][:alpha] = alpha_val if @current_shape[:inner_shadow] elsif @inside_glow && !@inside_rpr_effect_lst @current_shape[:glow][:alpha] = alpha_val if @current_shape[:glow] elsif @inside_ln && @inside_solid_fill && !@inside_rpr @current_shape[:line_alpha] = alpha_val elsif @inside_solid_fill && !@inside_ln && !@inside_rpr @current_shape[:fill_alpha] = alpha_val end end when "tint", "shade", "lumMod", "lumOff", "satMod", "satOff", "hueMod", "hueOff" if @inside_sp && @current_shape && @inside_solid_fill && !@inside_rpr && attributes["val"] t = { type: name, val: attributes["val"].to_i } if @inside_ln (@current_shape[:line_color_transforms] ||= []) << t else (@current_shape[:fill_color_transforms] ||= []) << t end end when "from" @inside_from = true if @inside_anchor when "to" @inside_to = true if @inside_anchor when "txBody" @inside_tx_body = true if @inside_sp @paragraphs_for_shape = [] if @inside_sp when "p" @current_paragraph = {} if @inside_tx_body && @inside_sp when "r" if @inside_tx_body && @inside_sp && @current_paragraph @inside_r = true @current_run = {} end when "rPr" if @inside_tx_body && @inside_sp && @current_shape @inside_rpr = true tf = {} tf[:bold] = true if %w[1 true].include?(attributes["b"]) tf[:italic] = true if %w[1 true].include?(attributes["i"]) tf[:no_proof] = true if %w[1 true].include?(attributes["noProof"]) tf[:normalize_h] = true if %w[1 true].include?(attributes["normalizeH"]) tf[:kumimoji] = true if %w[1 true].include?(attributes["kumimoji"]) tf[:strike] = attributes["strike"] if attributes["strike"] tf[:underline] = attributes["u"] if attributes["u"] tf[:baseline] = attributes["baseline"].to_i if attributes["baseline"] tf[:spacing] = attributes["spc"].to_i if attributes["spc"] tf[:kern] = attributes["kern"].to_i if attributes["kern"] tf[:cap] = attributes["cap"] if attributes["cap"] tf[:lang] = attributes["lang"] if attributes["lang"] tf[:alt_lang] = attributes["altLang"] if attributes["altLang"] tf[:dirty] = true if %w[1 true].include?(attributes["dirty"]) tf[:smt_clean] = true if %w[1 true].include?(attributes["smtClean"]) tf[:err] = true if %w[1 true].include?(attributes["err"]) tf[:bmk] = attributes["bmk"] if attributes["bmk"] tf[:size] = attributes["sz"].to_i if attributes["sz"] @current_text_font = tf end when "endParaRPr" if @inside_tx_body && @inside_sp && @current_shape @inside_rpr = true @inside_end_para_rpr = true tf = {} tf[:bold] = true if %w[1 true].include?(attributes["b"]) tf[:italic] = true if %w[1 true].include?(attributes["i"]) tf[:no_proof] = true if %w[1 true].include?(attributes["noProof"]) tf[:normalize_h] = true if %w[1 true].include?(attributes["normalizeH"]) tf[:kumimoji] = true if %w[1 true].include?(attributes["kumimoji"]) tf[:strike] = attributes["strike"] if attributes["strike"] tf[:underline] = attributes["u"] if attributes["u"] tf[:baseline] = attributes["baseline"].to_i if attributes["baseline"] tf[:spacing] = attributes["spc"].to_i if attributes["spc"] tf[:kern] = attributes["kern"].to_i if attributes["kern"] tf[:cap] = attributes["cap"] if attributes["cap"] tf[:lang] = attributes["lang"] if attributes["lang"] tf[:alt_lang] = attributes["altLang"] if attributes["altLang"] tf[:dirty] = true if %w[1 true].include?(attributes["dirty"]) tf[:smt_clean] = true if %w[1 true].include?(attributes["smtClean"]) tf[:err] = true if %w[1 true].include?(attributes["err"]) tf[:bmk] = attributes["bmk"] if attributes["bmk"] tf[:size] = attributes["sz"].to_i if attributes["sz"] @current_text_font = tf end when "latin" @current_text_font[:name] = attributes["typeface"] if @inside_rpr && @current_text_font && attributes["typeface"] when "ea" @current_text_font[:ea_font] = attributes["typeface"] if @inside_rpr && @current_text_font && attributes["typeface"] when "cs" @current_text_font[:cs_font] = attributes["typeface"] if @inside_rpr && @current_text_font && attributes["typeface"] when "sym" @current_text_font[:sym_font] = attributes["typeface"] if @inside_rpr && @current_text_font && attributes["typeface"] when "uFillTx" @current_text_font[:u_fill_tx] = true if @inside_rpr && @current_text_font when "uLnTx" @current_text_font[:u_ln_tx] = true if @inside_rpr && @current_text_font when "pPr" if @inside_tx_body && @inside_sp && @current_paragraph @current_paragraph[:align] = attributes["algn"] if attributes["algn"] @current_paragraph[:font_align] = attributes["fontAlgn"] if attributes["fontAlgn"] @current_paragraph[:def_tab_sz] = attributes["defTabSz"].to_i if attributes["defTabSz"] @current_paragraph[:rtl] = %w[1 true].include?(attributes["rtl"]) if attributes["rtl"] @current_paragraph[:ea_ln_brk] = %w[1 true].include?(attributes["eaLnBrk"]) if attributes["eaLnBrk"] @current_paragraph[:latin_ln_brk] = %w[1 true].include?(attributes["latinLnBrk"]) if attributes["latinLnBrk"] @current_paragraph[:hanging_punct] = %w[1 true].include?(attributes["hangingPunct"]) if attributes["hangingPunct"] @current_paragraph[:level] = attributes["lvl"].to_i if attributes["lvl"] ti = {} ti[:left] = attributes["marL"].to_i if attributes["marL"] ti[:right] = attributes["marR"].to_i if attributes["marR"] ti[:indent] = attributes["indent"].to_i if attributes["indent"] @current_paragraph[:indent] = ti unless ti.empty? end when "defRPr" if @inside_tx_body && @inside_sp && @current_shape @inside_rpr = true @inside_def_rpr = true tf = {} tf[:bold] = true if %w[1 true].include?(attributes["b"]) tf[:italic] = true if %w[1 true].include?(attributes["i"]) tf[:no_proof] = true if %w[1 true].include?(attributes["noProof"]) tf[:normalize_h] = true if %w[1 true].include?(attributes["normalizeH"]) tf[:kumimoji] = true if %w[1 true].include?(attributes["kumimoji"]) tf[:strike] = attributes["strike"] if attributes["strike"] tf[:underline] = attributes["u"] if attributes["u"] tf[:baseline] = attributes["baseline"].to_i if attributes["baseline"] tf[:spacing] = attributes["spc"].to_i if attributes["spc"] tf[:kern] = attributes["kern"].to_i if attributes["kern"] tf[:cap] = attributes["cap"] if attributes["cap"] tf[:lang] = attributes["lang"] if attributes["lang"] tf[:alt_lang] = attributes["altLang"] if attributes["altLang"] tf[:dirty] = true if %w[1 true].include?(attributes["dirty"]) tf[:smt_clean] = true if %w[1 true].include?(attributes["smtClean"]) tf[:err] = true if %w[1 true].include?(attributes["err"]) tf[:bmk] = attributes["bmk"] if attributes["bmk"] tf[:size] = attributes["sz"].to_i if attributes["sz"] @current_text_font = tf end when "spcBef" @inside_spc_bef = true if @inside_tx_body && @inside_sp when "spcAft" @inside_spc_aft = true if @inside_tx_body && @inside_sp when "lnSpc" @inside_lnspc = true if @inside_tx_body && @inside_sp when "tabLst" @inside_tab_lst = true if @inside_tx_body && @inside_sp when "tab" if @inside_tab_lst && @inside_tx_body && @inside_sp && @current_paragraph && attributes["pos"] tab = { pos: attributes["pos"].to_i } tab[:align] = attributes["algn"] if attributes["algn"] @current_paragraph[:tab_stops] ||= [] @current_paragraph[:tab_stops] << tab end when "buNone" if @inside_tx_body && @inside_sp && @current_paragraph @current_paragraph[:bullet] ||= {} @current_paragraph[:bullet][:type] = "none" end when "buClr" @inside_bu_clr = true if @inside_tx_body && @inside_sp when "buFont" if @inside_tx_body && @inside_sp && @current_paragraph && attributes["typeface"] @current_paragraph[:bullet] ||= {} @current_paragraph[:bullet][:font] = attributes["typeface"] end when "buSzPts" if @inside_tx_body && @inside_sp && @current_paragraph && attributes["val"] @current_paragraph[:bullet] ||= {} @current_paragraph[:bullet][:size_pts] = attributes["val"].to_i end when "buSzPct" if @inside_tx_body && @inside_sp && @current_paragraph && attributes["val"] @current_paragraph[:bullet] ||= {} @current_paragraph[:bullet][:size_pct] = attributes["val"].to_i end when "buChar" if @inside_tx_body && @inside_sp && @current_paragraph && attributes["char"] @current_paragraph[:bullet] ||= {} @current_paragraph[:bullet][:type] = "char" @current_paragraph[:bullet][:char] = attributes["char"] end when "buAutoNum" if @inside_tx_body && @inside_sp && @current_paragraph && attributes["type"] @current_paragraph[:bullet] ||= {} @current_paragraph[:bullet][:type] = "auto" @current_paragraph[:bullet][:auto_type] = attributes["type"] @current_paragraph[:bullet][:start_at] = attributes["startAt"].to_i if attributes["startAt"] end when "spcPts" if @inside_tx_body && @inside_sp && @current_paragraph && attributes["val"] @current_paragraph[:spacing] ||= {} if @inside_spc_bef @current_paragraph[:spacing][:before] = attributes["val"].to_i elsif @inside_spc_aft @current_paragraph[:spacing][:after] = attributes["val"].to_i elsif @inside_lnspc @current_paragraph[:spacing][:line] = attributes["val"].to_i end end when "spcPct" if @inside_tx_body && @inside_sp && @current_paragraph && attributes["val"] @current_paragraph[:spacing] ||= {} if @inside_spc_bef @current_paragraph[:spacing][:before_pct] = attributes["val"].to_i elsif @inside_spc_aft @current_paragraph[:spacing][:after_pct] = attributes["val"].to_i elsif @inside_lnspc @current_paragraph[:spacing][:line_pct] = attributes["val"].to_i end end when "bodyPr" if @inside_sp && @current_shape @current_shape[:text_rot] = attributes["rot"].to_i if attributes["rot"] @current_shape[:text_spc_first_last_para] = %w[1 true].include?(attributes["spcFirstLastPara"]) if attributes["spcFirstLastPara"] @current_shape[:text_wrap] = attributes["wrap"] if attributes["wrap"] @current_shape[:text_anchor] = attributes["anchor"] if attributes["anchor"] @current_shape[:text_anchor_ctr] = %w[1 true].include?(attributes["anchorCtr"]) if attributes["anchorCtr"] @current_shape[:text_vert_overflow] = attributes["vertOverflow"] if attributes["vertOverflow"] @current_shape[:text_horz_overflow] = attributes["horzOverflow"] if attributes["horzOverflow"] @current_shape[:text_num_col] = attributes["numCol"].to_i if attributes["numCol"] @current_shape[:text_spc_col] = attributes["spcCol"].to_i if attributes["spcCol"] @current_shape[:text_rtl_col] = %w[1 true].include?(attributes["rtlCol"]) if attributes["rtlCol"] @current_shape[:text_from_word_art] = %w[1 true].include?(attributes["fromWordArt"]) if attributes["fromWordArt"] @current_shape[:text_upright] = %w[1 true].include?(attributes["upright"]) if attributes["upright"] @current_shape[:text_compat_ln_spc] = %w[1 true].include?(attributes["compatLnSpc"]) if attributes["compatLnSpc"] @current_shape[:text_force_aa] = %w[1 true].include?(attributes["forceAA"]) if attributes["forceAA"] @current_shape[:text_vertical] = attributes["vert"] if attributes["vert"] ins = {} ins[:left] = attributes["lIns"].to_i if attributes["lIns"] ins[:top] = attributes["tIns"].to_i if attributes["tIns"] ins[:right] = attributes["rIns"].to_i if attributes["rIns"] ins[:bottom] = attributes["bIns"].to_i if attributes["bIns"] @current_shape[:text_insets] = ins unless ins.empty? end when "noAutofit" @current_shape[:autofit] = "none" if @inside_sp && @current_shape when "spAutoFit" @current_shape[:autofit] = "shape" if @inside_sp && @current_shape when "normAutofit" if @inside_sp && @current_shape if attributes["fontScale"] || attributes["lnSpcReduction"] af = { type: "normal" } af[:font_scale] = attributes["fontScale"].to_i if attributes["fontScale"] af[:ln_spc_reduction] = attributes["lnSpcReduction"].to_i if attributes["lnSpcReduction"] @current_shape[:autofit] = af else @current_shape[:autofit] = "normal" end end when "prstTxWarp" @current_shape[:text_warp] = { preset: attributes["prst"] } if @inside_sp && @current_shape && attributes["prst"] when "t" @inside_t = true if @inside_tx_body @text_buffer = +"" when "col", "colOff", "row", "rowOff" @current_field = name @text_buffer = +"" when "clientData" if @inside_anchor @anchor_locks_with_sheet = attributes["fLocksWithSheet"] @anchor_prints_with_sheet = attributes["fPrintsWithSheet"] end end end