28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/spreadsheet_architect/utils/ods.rb', line 28
def self.convert_styles(styles={})
styles = {} unless styles.is_a?(Hash)
styles = SpreadsheetArchitect::Utils.stringify_keys(styles)
property_styles = {}
text_styles = {}
text_styles['font-weight'] = styles.delete('bold') ? 'bold' : styles.delete('font-weight')
text_styles['font-size'] = styles.delete('font_size') || styles.delete('font-size')
text_styles['font-style'] = styles.delete('italic') ? 'italic' : styles.delete('font-style')
if styles['underline']
styles.delete('underline')
text_styles['text-underline-style'] = 'solid'
text_styles['text-underline-type'] = 'single'
end
if styles['align']
text_styles['align'] = true
end
if styles['color'].respond_to?(:sub) && !styles['color'].empty?
text_styles['color'] = "##{styles.delete('color').sub('#','')}"
end
text_styles.delete_if{|_,v| v.nil?}
property_styles['text'] = text_styles
cell_styles = {}
styles['background_color'] ||= styles.delete('background-color')
if styles['background_color'].respond_to?(:sub) && !styles['background_color'].empty?
cell_styles['background-color'] = "##{styles.delete('background_color').sub('#','')}"
end
cell_styles.delete_if{|_,v| v.nil?}
property_styles['cell'] = cell_styles
return property_styles
end
|