# -*- coding: utf-8 -*- require 'write_xlsx/utility' module Writexlsx module Package class Button include Writexlsx::Utility attr_accessor :font, :macro, :vertices def v_shape_attributes(id, z_index) attributes = v_shape_attributes_base(id, z_index) attributes << ['o:button', 't'] attributes << ['fillcolor', color] attributes << ['strokecolor', 'windowText [64]'] attributes << ['o:insetmode', 'auto'] attributes end def type '#_x0000_t201' end def color 'buttonFace [67]' end def style_addition ['mso-wrap-style:tight'] end def write_shape(writer, id, z_index) @writer = writer attributes = v_shape_attributes(id, z_index) @writer.tag_elements('v:shape', attributes) do # Write the v:fill element. write_fill # Write the o:lock element. write_rotation_lock # Write the v:textbox element. write_textbox # Write the x:ClientData element. write_client_data end end # attributes for element. def fill_attributes [ ['color2', 'buttonFace [67]'], ['o:detectmouseclick', 't'] ] end # # Write the element. # def write_rotation_lock attributes = [ ['v:ext', 'edit'], ['rotation', 't'] ] @writer.empty_tag('o:lock', attributes) end # # Write the element. # def write_textbox attributes = [ ['style', 'mso-direction-alt:auto'], ['o:singleclick', 'f'] ] @writer.tag_elements('v:textbox', attributes) do # Write the div element. write_div('center', font) end end # # Write the element. # def write_client_data attributes = [ ['ObjectType', 'Button'] ] @writer.tag_elements('x:ClientData', attributes) do # Write the x:Anchor element. write_anchor # Write the x:PrintObject element. write_print_object # Write the x:AutoFill element. write_auto_fill # Write the x:FmlaMacro element. write_fmla_macro # Write the x:TextHAlign element. write_text_halign # Write the x:TextVAlign element. write_text_valign end end # # Write the element. # def write_print_object @writer.data_element('x:PrintObject', 'False') end # # Write the element. # def write_fmla_macro @writer.data_element('x:FmlaMacro', macro) end # # Write the element. # def write_text_halign @writer.data_element('x:TextHAlign', 'Center') end # # Write the element. # def write_text_valign @writer.data_element('x:TextVAlign', 'Center') end end end end