Class: Writexlsx::Package::Button

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/write_xlsx/package/button.rb

Constant Summary

Constants included from Utility

Utility::CHAR_WIDTHS, Utility::COL_MAX, Utility::PERL_TRUE_VALUES, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility

#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, #convert_font_args, #dash_types, delete_files, #escape_url, #fill_properties, #float_to_str, #get_font_latin_attributes, #get_font_style_attributes, #get_image_properties, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #palette_color, #params_to_font, #pattern_properties, #pixels_to_points, #process_bmp, #process_gif, #process_jpg, #process_png, #process_workbook_options, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_a_body_pr, #write_a_def_rpr, #write_a_end_para_rpr, #write_a_lst_style, #write_a_p_formula, #write_a_p_pr_formula, #write_a_solid_fill, #write_a_srgb_clr, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_def_rpr_r_pr_common, #write_div, #write_fill, #write_font, #write_stroke, #write_tx_pr, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xl_string_pixel_width, #xml_str

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/write_xlsx/package/button.rb', line 11

def description
  @description
end

#fontObject

Returns the value of attribute font.



11
12
13
# File 'lib/write_xlsx/package/button.rb', line 11

def font
  @font
end

#macroObject

Returns the value of attribute macro.



11
12
13
# File 'lib/write_xlsx/package/button.rb', line 11

def macro
  @macro
end

#verticesObject

Returns the value of attribute vertices.



11
12
13
# File 'lib/write_xlsx/package/button.rb', line 11

def vertices
  @vertices
end

Instance Method Details

#colorObject



29
30
31
# File 'lib/write_xlsx/package/button.rb', line 29

def color
  'buttonFace [67]'
end

#fill_attributesObject

attributes for <v:fill> element.



55
56
57
58
59
60
# File 'lib/write_xlsx/package/button.rb', line 55

def fill_attributes
  [
    ['color2',             'buttonFace [67]'],
    ['o:detectmouseclick', 't']
  ]
end

#style_additionObject



33
34
35
# File 'lib/write_xlsx/package/button.rb', line 33

def style_addition
  ['mso-wrap-style:tight']
end

#typeObject



25
26
27
# File 'lib/write_xlsx/package/button.rb', line 25

def type
  '#_x0000_t201'
end

#v_shape_attributes(id, z_index) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/write_xlsx/package/button.rb', line 13

def v_shape_attributes(id, z_index)
  attributes = v_shape_attributes_base(id)
  attributes << ['alt', description] if description

  attributes << ['style', (v_shape_style_base(z_index, vertices) + style_addition).join]
  attributes << ['o:button',    't']
  attributes << ['fillcolor',   color]
  attributes << ['strokecolor', 'windowText [64]']
  attributes << ['o:insetmode', 'auto']
  attributes
end

#write_client_dataObject

Write the <x:ClientData> element.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/write_xlsx/package/button.rb', line 91

def write_client_data
  attributes = [%w[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_fmla_macroObject

Write the <x:FmlaMacro> element.



120
121
122
# File 'lib/write_xlsx/package/button.rb', line 120

def write_fmla_macro
  @writer.data_element('x:FmlaMacro', macro)
end

#write_print_objectObject

Write the <x:PrintObject> element.



113
114
115
# File 'lib/write_xlsx/package/button.rb', line 113

def write_print_object
  @writer.data_element('x:PrintObject', 'False')
end

#write_rotation_lockObject

Write the <o:lock> element.



65
66
67
68
69
70
71
# File 'lib/write_xlsx/package/button.rb', line 65

def write_rotation_lock
  attributes = [
    ['v:ext',    'edit'],
    %w[rotation t]
  ]
  @writer.empty_tag('o:lock', attributes)
end

#write_shape(writer, id, z_index) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/write_xlsx/package/button.rb', line 37

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

#write_text_halignObject

Write the <x:TextHAlign> element.



127
128
129
# File 'lib/write_xlsx/package/button.rb', line 127

def write_text_halign
  @writer.data_element('x:TextHAlign', 'Center')
end

#write_text_valignObject

Write the <x:TextVAlign> element.



134
135
136
# File 'lib/write_xlsx/package/button.rb', line 134

def write_text_valign
  @writer.data_element('x:TextVAlign', 'Center')
end

#write_textboxObject

Write the <v:textbox> element.



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/write_xlsx/package/button.rb', line 76

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