write_xlsx 1.02.0 → 1.04.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes +22 -0
- data/README.md +1 -1
- data/examples/chart_line.rb +85 -10
- data/examples/tables.rb +77 -42
- data/lib/write_xlsx/chart/line.rb +15 -1
- data/lib/write_xlsx/format.rb +5 -5
- data/lib/write_xlsx/package/comments.rb +4 -4
- data/lib/write_xlsx/package/relationships.rb +2 -2
- data/lib/write_xlsx/package/styles.rb +26 -8
- data/lib/write_xlsx/package/table.rb +8 -7
- data/lib/write_xlsx/package/vml.rb +20 -19
- data/lib/write_xlsx/sheets.rb +12 -20
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +53 -35
- data/lib/write_xlsx/worksheet.rb +37 -20
- data/test/perl_output/chart_line.xlsx +0 -0
- data/test/perl_output/comments2.xlsx +0 -0
- data/test/perl_output/tables.xlsx +0 -0
- data/test/regression/images/red2.png +0 -0
- data/test/regression/test_chart_line05.rb +43 -0
- data/test/regression/test_chart_line06.rb +43 -0
- data/test/regression/test_comment15.rb +28 -0
- data/test/regression/test_comment16.rb +34 -0
- data/test/regression/test_header_image15.rb +36 -0
- data/test/regression/test_header_image16.rb +42 -0
- data/test/regression/test_header_image17.rb +46 -0
- data/test/regression/test_header_image18.rb +48 -0
- data/test/regression/test_header_image19.rb +36 -0
- data/test/regression/test_hyperlink48.rb +31 -0
- data/test/regression/test_hyperlink49.rb +29 -0
- data/test/regression/test_image45.rb +2 -1
- data/test/regression/test_image46.rb +1 -1
- data/test/regression/test_image48.rb +32 -0
- data/test/regression/test_image49.rb +38 -0
- data/test/regression/test_image50.rb +24 -0
- data/test/regression/test_image51.rb +30 -0
- data/test/regression/test_object_position12.rb +25 -0
- data/test/regression/test_object_position13.rb +25 -0
- data/test/regression/test_object_position14.rb +25 -0
- data/test/regression/test_object_position15.rb +29 -0
- data/test/regression/test_object_position16.rb +29 -0
- data/test/regression/test_object_position17.rb +29 -0
- data/test/regression/test_object_position18.rb +29 -0
- data/test/regression/test_object_position19.rb +29 -0
- data/test/regression/test_object_position20.rb +29 -0
- data/test/regression/test_table24.rb +27 -0
- data/test/regression/test_table25.rb +27 -0
- data/test/regression/xlsx_files/chart_line05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_line06.xlsx +0 -0
- data/test/regression/xlsx_files/comment15.xlsx +0 -0
- data/test/regression/xlsx_files/comment16.xlsx +0 -0
- data/test/regression/xlsx_files/header_image15.xlsx +0 -0
- data/test/regression/xlsx_files/header_image16.xlsx +0 -0
- data/test/regression/xlsx_files/header_image17.xlsx +0 -0
- data/test/regression/xlsx_files/header_image18.xlsx +0 -0
- data/test/regression/xlsx_files/header_image19.xlsx +0 -0
- data/test/regression/xlsx_files/hyperlink46.xlsx +0 -0
- data/test/regression/xlsx_files/image45.xlsx +0 -0
- data/test/regression/xlsx_files/image46.xlsx +0 -0
- data/test/regression/xlsx_files/image48.xlsx +0 -0
- data/test/regression/xlsx_files/image49.xlsx +0 -0
- data/test/regression/xlsx_files/image50.xlsx +0 -0
- data/test/regression/xlsx_files/image51.xlsx +0 -0
- data/test/regression/xlsx_files/object_position12.xlsx +0 -0
- data/test/regression/xlsx_files/object_position13.xlsx +0 -0
- data/test/regression/xlsx_files/object_position14.xlsx +0 -0
- data/test/regression/xlsx_files/object_position15.xlsx +0 -0
- data/test/regression/xlsx_files/object_position16.xlsx +0 -0
- data/test/regression/xlsx_files/object_position17.xlsx +0 -0
- data/test/regression/xlsx_files/object_position18.xlsx +0 -0
- data/test/regression/xlsx_files/object_position19.xlsx +0 -0
- data/test/regression/xlsx_files/object_position20.xlsx +0 -0
- data/test/regression/xlsx_files/table24.xlsx +0 -0
- data/test/regression/xlsx_files/table25.xlsx +0 -0
- data/test/test_example_match.rb +119 -9
- data/test/workbook/test_check_sheetname.rb +0 -10
- data/write_xlsx.gemspec +1 -0
- metadata +120 -2
@@ -398,13 +398,14 @@ def write_table_column(col_data)
|
|
398
398
|
# Write the <tableStyleInfo> element.
|
399
399
|
#
|
400
400
|
def write_table_style_info
|
401
|
-
attributes = [
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
401
|
+
attributes = []
|
402
|
+
if @style && @style != '' && @style != 'None'
|
403
|
+
attributes << ['name', @style]
|
404
|
+
end
|
405
|
+
attributes << ['showFirstColumn', @show_first_col]
|
406
|
+
attributes << ['showLastColumn', @show_last_col]
|
407
|
+
attributes << ['showRowStripes', @show_row_stripes]
|
408
|
+
attributes << ['showColumnStripes', @show_col_stripes]
|
408
409
|
|
409
410
|
@writer.empty_tag('tableStyleInfo', attributes)
|
410
411
|
end
|
@@ -17,9 +17,9 @@ def set_xml_writer(filename)
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def assemble_xml_file(
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
data_id, vml_shape_id, comments_data,
|
21
|
+
buttons_data, header_images_data = []
|
22
|
+
)
|
23
23
|
return unless @writer
|
24
24
|
|
25
25
|
write_xml_namespace do
|
@@ -29,9 +29,9 @@ def assemble_xml_file(
|
|
29
29
|
z_index = 1
|
30
30
|
unless buttons_data.empty?
|
31
31
|
vml_shape_id, z_index =
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
write_shape_type_and_shape(
|
33
|
+
buttons_data,
|
34
|
+
vml_shape_id, z_index) do
|
35
35
|
write_button_shapetype
|
36
36
|
end
|
37
37
|
end
|
@@ -277,6 +277,7 @@ def write_image_shape(id, index, image_data)
|
|
277
277
|
position = image_data[3]
|
278
278
|
x_dpi = image_data[4]
|
279
279
|
y_dpi = image_data[5]
|
280
|
+
ref_id = image_data[6]
|
280
281
|
|
281
282
|
# Scale the height/width by the resolution, relative to 72dpi.
|
282
283
|
width = width * 72.0 / x_dpi
|
@@ -294,20 +295,20 @@ def write_image_shape(id, index, image_data)
|
|
294
295
|
end
|
295
296
|
|
296
297
|
style = [
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
298
|
+
"position:absolute", "margin-left:0", "margin-top:0",
|
299
|
+
"width:#{width}pt", "height:#{height}pt",
|
300
|
+
"z-index:#{index}"
|
301
|
+
].join(';')
|
301
302
|
attributes = [
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
303
|
+
['id', position],
|
304
|
+
['o:spid', "_x0000_s#{id}"],
|
305
|
+
['type', type],
|
306
|
+
['style', style]
|
307
|
+
]
|
307
308
|
|
308
309
|
@writer.tag_elements('v:shape', attributes) do
|
309
310
|
# Write the v:imagedata element.
|
310
|
-
write_imagedata(
|
311
|
+
write_imagedata(ref_id, name)
|
311
312
|
|
312
313
|
# Write the o:lock element.
|
313
314
|
write_rotation_lock
|
@@ -319,9 +320,9 @@ def write_image_shape(id, index, image_data)
|
|
319
320
|
#
|
320
321
|
def write_imagedata(index, o_title)
|
321
322
|
attributes = [
|
322
|
-
|
323
|
-
|
324
|
-
|
323
|
+
['o:relid', "rId#{index}"],
|
324
|
+
['o:title', o_title]
|
325
|
+
]
|
325
326
|
|
326
327
|
@writer.empty_tag('v:imagedata', attributes)
|
327
328
|
end
|
data/lib/write_xlsx/sheets.rb
CHANGED
@@ -67,18 +67,18 @@ def write_vml_files(package_dir)
|
|
67
67
|
vml = Package::Vml.new
|
68
68
|
vml.set_xml_writer("#{dir}/vmlDrawing#{index}.vml")
|
69
69
|
vml.assemble_xml_file(
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
sheet.vml_data_id, sheet.vml_shape_id,
|
71
|
+
sheet.sorted_comments, sheet.buttons_data
|
72
|
+
)
|
73
73
|
index += 1
|
74
74
|
end
|
75
75
|
if sheet.has_header_vml?
|
76
76
|
vml = Package::Vml.new
|
77
77
|
vml.set_xml_writer("#{dir}/vmlDrawing#{index}.vml")
|
78
78
|
vml.assemble_xml_file(
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
sheet.vml_header_id, sheet.vml_header_id * 1024,
|
80
|
+
[], [], sheet.header_images_data
|
81
|
+
)
|
82
82
|
write_vml_drawing_rels_files(package_dir, sheet, index)
|
83
83
|
index += 1
|
84
84
|
end
|
@@ -106,16 +106,12 @@ def write_table_files(package_dir)
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def write_chartsheet_rels_files(package_dir)
|
109
|
-
write_sheet_rels_files_base(
|
110
|
-
|
109
|
+
write_sheet_rels_files_base(
|
110
|
+
chartsheets, "#{package_dir}/xl/chartsheets/_rels", 'sheet'
|
111
|
+
)
|
111
112
|
end
|
112
113
|
|
113
114
|
def write_drawing_rels_files(package_dir)
|
114
|
-
# write_rels_files_base(
|
115
|
-
# self.reject { |sheet| sheet.drawing_links[0].empty? },
|
116
|
-
# "#{package_dir}/xl/drawings/_rels",
|
117
|
-
|
118
|
-
# )
|
119
115
|
dir = "#{package_dir}/xl/drawings/_rels"
|
120
116
|
|
121
117
|
index = 0
|
@@ -159,8 +155,9 @@ def write_vml_drawing_rels_files(package_dir, worksheet, index)
|
|
159
155
|
end
|
160
156
|
|
161
157
|
def write_worksheet_rels_files(package_dir)
|
162
|
-
write_sheet_rels_files_base(
|
163
|
-
|
158
|
+
write_sheet_rels_files_base(
|
159
|
+
worksheets, "#{package_dir}/xl/worksheets/_rels", 'sheet'
|
160
|
+
)
|
164
161
|
end
|
165
162
|
|
166
163
|
def write_sheet_rels_files_base(sheets, dir, body)
|
@@ -235,11 +232,6 @@ def check_valid_sheetname(name)
|
|
235
232
|
raise "Worksheet name #{name} cannot start or end with an "
|
236
233
|
end
|
237
234
|
|
238
|
-
# Check that sheetname isn't a reserved word.
|
239
|
-
if name =~ /history/i
|
240
|
-
raise "Worksheet name cannot be Excel reserved word 'History'"
|
241
|
-
end
|
242
|
-
|
243
235
|
# Check that the worksheet name doesn't already exist since this is a fatal
|
244
236
|
# error in Excel 97. The check must also exclude case insensitive matches.
|
245
237
|
unless is_sheetname_uniq?(name)
|
data/lib/write_xlsx/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
WriteXLSX_VERSION = "1.
|
1
|
+
WriteXLSX_VERSION = "1.04.0"
|
data/lib/write_xlsx/workbook.rb
CHANGED
@@ -132,6 +132,7 @@ def initialize(file, *option_params)
|
|
132
132
|
@strings_to_urls = (options[:strings_to_urls].nil? || options[:strings_to_urls]) ? true : false
|
133
133
|
|
134
134
|
@max_url_length = 2079
|
135
|
+
@has_comments = false
|
135
136
|
if options[:max_url_length]
|
136
137
|
@max_url_length = options[:max_url_length]
|
137
138
|
|
@@ -1115,7 +1116,8 @@ def style_properties
|
|
1115
1116
|
@border_count,
|
1116
1117
|
@fill_count,
|
1117
1118
|
@custom_colors,
|
1118
|
-
@dxf_formats
|
1119
|
+
@dxf_formats,
|
1120
|
+
@has_comments
|
1119
1121
|
]
|
1120
1122
|
end
|
1121
1123
|
|
@@ -1711,11 +1713,14 @@ def prepare_vml_objects #:nodoc:
|
|
1711
1713
|
if sheet.has_comments?
|
1712
1714
|
comment_files += 1
|
1713
1715
|
comment_id += 1
|
1716
|
+
@has_comments = true
|
1714
1717
|
end
|
1715
1718
|
vml_drawing_id += 1
|
1716
1719
|
|
1717
|
-
sheet.prepare_vml_objects(
|
1718
|
-
|
1720
|
+
sheet.prepare_vml_objects(
|
1721
|
+
vml_data_id, vml_shape_id,
|
1722
|
+
vml_drawing_id, comment_id
|
1723
|
+
)
|
1719
1724
|
|
1720
1725
|
# Each VML file should start with a shape id incremented by 1024.
|
1721
1726
|
vml_data_id += 1 * ( 1 + sheet.num_comments_block )
|
@@ -1738,8 +1743,6 @@ def prepare_vml_objects #:nodoc:
|
|
1738
1743
|
end
|
1739
1744
|
end
|
1740
1745
|
|
1741
|
-
add_font_format_for_cell_comments if num_comment_files > 0
|
1742
|
-
|
1743
1746
|
# Set the workbook vba_codename if one of the sheets has a button and
|
1744
1747
|
# the workbook has a vbaProject binary.
|
1745
1748
|
if has_button && @vba_project && !@vba_codename
|
@@ -1759,19 +1762,6 @@ def prepare_tables
|
|
1759
1762
|
end
|
1760
1763
|
end
|
1761
1764
|
|
1762
|
-
def add_font_format_for_cell_comments
|
1763
|
-
format = Format.new(
|
1764
|
-
@formats,
|
1765
|
-
:font => 'Tahoma',
|
1766
|
-
:size => 8,
|
1767
|
-
:color_indexed => 81,
|
1768
|
-
:font_only => 1
|
1769
|
-
)
|
1770
|
-
|
1771
|
-
format.get_xf_index
|
1772
|
-
@formats.formats << format
|
1773
|
-
end
|
1774
|
-
|
1775
1765
|
#
|
1776
1766
|
# Add "cached" data to charts to provide the numCache and strCache data for
|
1777
1767
|
# series and title/axis ranges.
|
@@ -1922,9 +1912,12 @@ def extract_named_ranges(defined_names) #:nodoc:
|
|
1922
1912
|
# Iterate through the worksheets and set up any chart or image drawings.
|
1923
1913
|
#
|
1924
1914
|
def prepare_drawings #:nodoc:
|
1925
|
-
chart_ref_id
|
1926
|
-
image_ref_id
|
1927
|
-
drawing_id
|
1915
|
+
chart_ref_id = 0
|
1916
|
+
image_ref_id = 0
|
1917
|
+
drawing_id = 0
|
1918
|
+
ref_id = 0
|
1919
|
+
image_ids = {}
|
1920
|
+
header_image_ids = {}
|
1928
1921
|
@worksheets.each do |sheet|
|
1929
1922
|
chart_count = sheet.charts.size
|
1930
1923
|
image_count = sheet.images.size
|
@@ -1944,9 +1937,19 @@ def prepare_drawings #:nodoc:
|
|
1944
1937
|
|
1945
1938
|
# Prepare the worksheet images.
|
1946
1939
|
sheet.images.each_with_index do |image, index|
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1940
|
+
filename = image[2]
|
1941
|
+
type, width, height, name, x_dpi, y_dpi, md5 = get_image_properties(image[2])
|
1942
|
+
if image_ids[md5]
|
1943
|
+
ref_id = image_ids[md5]
|
1944
|
+
else
|
1945
|
+
image_ref_id += 1
|
1946
|
+
image_ids[md5] = ref_id = image_ref_id
|
1947
|
+
@images << [filename, type]
|
1948
|
+
end
|
1949
|
+
sheet.prepare_image(
|
1950
|
+
index, ref_id, drawing_id, width, height,
|
1951
|
+
name, type, x_dpi, y_dpi, md5
|
1952
|
+
)
|
1950
1953
|
end
|
1951
1954
|
|
1952
1955
|
# Prepare the worksheet charts.
|
@@ -1965,13 +1968,21 @@ def prepare_drawings #:nodoc:
|
|
1965
1968
|
filename = sheet.header_images[index][0]
|
1966
1969
|
position = sheet.header_images[index][1]
|
1967
1970
|
|
1968
|
-
type, width, height, name, x_dpi, y_dpi =
|
1971
|
+
type, width, height, name, x_dpi, y_dpi, md5 =
|
1969
1972
|
get_image_properties(filename)
|
1970
1973
|
|
1971
|
-
|
1974
|
+
if header_image_ids[md5]
|
1975
|
+
ref_id = header_image_ids[md5]
|
1976
|
+
else
|
1977
|
+
image_ref_id += 1
|
1978
|
+
header_image_ids[md5] = ref_id = image_ref_id
|
1979
|
+
@images << [filename, type]
|
1980
|
+
end
|
1972
1981
|
|
1973
|
-
sheet.prepare_header_image(
|
1974
|
-
|
1982
|
+
sheet.prepare_header_image(
|
1983
|
+
ref_id, width, height, name, type,
|
1984
|
+
position, x_dpi, y_dpi, md5
|
1985
|
+
)
|
1975
1986
|
end
|
1976
1987
|
|
1977
1988
|
# Prepare the footer images.
|
@@ -1979,13 +1990,21 @@ def prepare_drawings #:nodoc:
|
|
1979
1990
|
filename = sheet.footer_images[index][0]
|
1980
1991
|
position = sheet.footer_images[index][1]
|
1981
1992
|
|
1982
|
-
type, width, height, name, x_dpi, y_dpi =
|
1993
|
+
type, width, height, name, x_dpi, y_dpi, md5 =
|
1983
1994
|
get_image_properties(filename)
|
1984
1995
|
|
1985
|
-
|
1996
|
+
if header_image_ids[md5]
|
1997
|
+
ref_id = header_image_ids[md5]
|
1998
|
+
else
|
1999
|
+
image_ref_id += 1
|
2000
|
+
header_image_ids[md5] = ref_id = image_ref_id
|
2001
|
+
@images << [filename, type]
|
2002
|
+
end
|
1986
2003
|
|
1987
|
-
sheet.prepare_header_image(
|
1988
|
-
|
2004
|
+
sheet.prepare_header_image(
|
2005
|
+
ref_id, width, height, name, type,
|
2006
|
+
position, x_dpi, y_dpi, md5
|
2007
|
+
)
|
1989
2008
|
end
|
1990
2009
|
|
1991
2010
|
if has_drawings
|
@@ -2014,6 +2033,7 @@ def get_image_properties(filename)
|
|
2014
2033
|
|
2015
2034
|
# Open the image file and import the data.
|
2016
2035
|
data = File.binread(filename)
|
2036
|
+
md5 = Digest::MD5.hexdigest(data)
|
2017
2037
|
if data.unpack('x A3')[0] == 'PNG'
|
2018
2038
|
# Test for PNGs.
|
2019
2039
|
type, width, height, x_dpi, y_dpi = process_png(data)
|
@@ -2031,13 +2051,11 @@ def get_image_properties(filename)
|
|
2031
2051
|
raise "Unsupported image format for file: #{filename}\n"
|
2032
2052
|
end
|
2033
2053
|
|
2034
|
-
@images << [filename, type]
|
2035
|
-
|
2036
2054
|
# Set a default dpi for images with 0 dpi.
|
2037
2055
|
x_dpi = 96 if x_dpi == 0
|
2038
2056
|
y_dpi = 96 if y_dpi == 0
|
2039
2057
|
|
2040
|
-
[type, width, height, File.basename(filename), x_dpi, y_dpi]
|
2058
|
+
[type, width, height, File.basename(filename), x_dpi, y_dpi, md5]
|
2041
2059
|
end
|
2042
2060
|
|
2043
2061
|
#
|
data/lib/write_xlsx/worksheet.rb
CHANGED
@@ -359,6 +359,8 @@ def initialize(workbook, index, name) #:nodoc:
|
|
359
359
|
@shape_hash = {}
|
360
360
|
@drawing_rels = {}
|
361
361
|
@drawing_rels_id = 0
|
362
|
+
@vml_drawing_rels = {}
|
363
|
+
@vml_drawing_rels_id = 0
|
362
364
|
@header_images = []
|
363
365
|
@footer_images = []
|
364
366
|
|
@@ -5868,27 +5870,24 @@ def position_object_pixels(col_start, row_start, x1, y1, width, height, anchor =
|
|
5868
5870
|
y_abs += y1
|
5869
5871
|
|
5870
5872
|
# Adjust start column for offsets that are greater than the col width.
|
5871
|
-
|
5872
|
-
|
5873
|
-
|
5874
|
-
col_start += 1
|
5875
|
-
end
|
5873
|
+
while x1 >= size_col(col_start, anchor)
|
5874
|
+
x1 -= size_col(col_start)
|
5875
|
+
col_start += 1
|
5876
5876
|
end
|
5877
5877
|
|
5878
5878
|
# Adjust start row for offsets that are greater than the row height.
|
5879
|
-
|
5880
|
-
|
5881
|
-
|
5882
|
-
row_start += 1
|
5883
|
-
end
|
5879
|
+
while y1 >= size_row(row_start, anchor)
|
5880
|
+
y1 -= size_row(row_start)
|
5881
|
+
row_start += 1
|
5884
5882
|
end
|
5885
5883
|
|
5886
5884
|
# Initialise end cell to the same as the start cell.
|
5887
5885
|
col_end = col_start
|
5888
5886
|
row_end = row_start
|
5889
5887
|
|
5890
|
-
|
5891
|
-
|
5888
|
+
# Only offset the image in the cell if the row/col isn't hidden.
|
5889
|
+
width += x1 if size_col(col_start, anchor) > 0
|
5890
|
+
height += y1 if size_row(row_start, anchor) > 0
|
5892
5891
|
|
5893
5892
|
# Subtract the underlying cell widths to find the end cell of the object.
|
5894
5893
|
while width >= size_col(col_end, anchor)
|
@@ -6100,6 +6099,18 @@ def drawing_rel_index(target = nil)
|
|
6100
6099
|
end
|
6101
6100
|
end
|
6102
6101
|
|
6102
|
+
#
|
6103
|
+
# Get the index used to address a vml_drawing rel link.
|
6104
|
+
#
|
6105
|
+
def get_vml_drawing_rel_index(target)
|
6106
|
+
if @vml_drawing_rels[target]
|
6107
|
+
@vml_drawing_rels[target]
|
6108
|
+
else
|
6109
|
+
@vml_drawing_rels_id += 1
|
6110
|
+
@vml_drawing_rels[target] = @vml_drawing_rels_id
|
6111
|
+
end
|
6112
|
+
end
|
6113
|
+
|
6103
6114
|
def hyperlinks_count
|
6104
6115
|
@hyperlinks.keys.inject(0) { |s, n| s += @hyperlinks[n].keys.size }
|
6105
6116
|
end
|
@@ -6447,7 +6458,7 @@ def size_row(row, anchor = 0) #:nodoc:
|
|
6447
6458
|
#
|
6448
6459
|
# Set up image/drawings.
|
6449
6460
|
#
|
6450
|
-
def prepare_image(index, image_id, drawing_id, width, height, name, image_type, x_dpi = 96, y_dpi = 96) #:nodoc:
|
6461
|
+
def prepare_image(index, image_id, drawing_id, width, height, name, image_type, x_dpi = 96, y_dpi = 96, md5 = nil) #:nodoc:
|
6451
6462
|
x_dpi ||= 96
|
6452
6463
|
y_dpi ||= 96
|
6453
6464
|
drawing_type = 2
|
@@ -6503,24 +6514,30 @@ def prepare_image(index, image_id, drawing_id, width, height, name, image_type,
|
|
6503
6514
|
EOS
|
6504
6515
|
end
|
6505
6516
|
|
6506
|
-
if target
|
6517
|
+
if target && !@drawing_rels[url]
|
6507
6518
|
@drawing_links << [rel_type, target, target_mode]
|
6508
6519
|
end
|
6509
|
-
drawing.url_rel_index = drawing_rel_index
|
6520
|
+
drawing.url_rel_index = drawing_rel_index(url)
|
6510
6521
|
end
|
6511
6522
|
|
6512
|
-
|
6513
|
-
|
6523
|
+
if !@drawing_rels[md5]
|
6524
|
+
@drawing_links << ['/image', "../media/image#{image_id}.#{image_type}"]
|
6525
|
+
end
|
6526
|
+
drawing.rel_index = drawing_rel_index(md5)
|
6514
6527
|
end
|
6515
6528
|
public :prepare_image
|
6516
6529
|
|
6517
|
-
def prepare_header_image(image_id, width, height, name, image_type, position, x_dpi, y_dpi)
|
6530
|
+
def prepare_header_image(image_id, width, height, name, image_type, position, x_dpi, y_dpi, md5)
|
6518
6531
|
# Strip the extension from the filename.
|
6519
6532
|
body = name.dup
|
6520
6533
|
body[/\.[^\.]+$/, 0] = ''
|
6521
6534
|
|
6522
|
-
|
6523
|
-
|
6535
|
+
if !@vml_drawing_rels[md5]
|
6536
|
+
@vml_drawing_links << ['/image', "../media/image#{image_id}.#{image_type}" ]
|
6537
|
+
end
|
6538
|
+
|
6539
|
+
ref_id = get_vml_drawing_rel_index(md5)
|
6540
|
+
@header_images_array << [width, height, body, position, x_dpi, y_dpi, ref_id]
|
6524
6541
|
end
|
6525
6542
|
public :prepare_header_image
|
6526
6543
|
|