lib/write_xlsx/drawing.rb in write_xlsx-0.75.0 vs lib/write_xlsx/drawing.rb in write_xlsx-0.76.0

- old
+ new

@@ -79,11 +79,11 @@ # Add attribute for images. attributes << [:editAs, 'oneCell'] if type == 2 # Add attribute for shapes. - attributes << [:editAs, shape.edit_as] if shape && !shape.edit_as.nil? + attributes << [:editAs, shape.edit_as] if shape && shape.edit_as @writer.tag_elements('xdr:twoCellAnchor', attributes) do # Write the xdr:from element. write_from(col_from, row_from, col_from_offset, row_from_offset) # Write the xdr:from element. @@ -109,35 +109,33 @@ # # Write the <xdr:absoluteAnchor> element. # def write_absolute_anchor(index) - @writer.start_tag('xdr:absoluteAnchor') + @writer.tag_elements('xdr:absoluteAnchor') do + # Different co-ordinates for horizonatal (= 0) and vertical (= 1). + if !ptrue?(@orientation) - # Different co-ordinates for horizonatal (= 0) and vertical (= 1). - if !ptrue?(@orientation) + # Write the xdr:pos element. + write_pos(0, 0) - # Write the xdr:pos element. - write_pos(0, 0) + # Write the xdr:ext element. + write_ext(9308969, 6078325) + else + # Write the xdr:pos element. + write_pos(0, -47625) - # Write the xdr:ext element. - write_ext(9308969, 6078325) - else - # Write the xdr:pos element. - write_pos(0, -47625) + # Write the xdr:ext element. + write_ext(6162675, 6124575) + end - # Write the xdr:ext element. - write_ext(6162675, 6124575) - end + # Write the xdr:graphicFrame element. + write_graphic_frame(index) - # Write the xdr:graphicFrame element. - write_graphic_frame(index) - - # Write the xdr:clientData element. - write_client_data - - @writer.end_tag('xdr:absoluteAnchor') + # Write the xdr:clientData element. + write_client_data + end end # # Write the <xdr:from> element. # @@ -244,11 +242,11 @@ # # Write the <xdr:nvGraphicFramePr> element. # def write_nv_graphic_frame_pr(index, name = nil) - name = "Chart #{index}" if name.nil? || name.empty? + name = "Chart #{index}" unless ptrue?(name) @writer.tag_elements('xdr:nvGraphicFramePr') do # Write the xdr:cNvPr element. write_c_nv_pr( index + 1, name) # Write the xdr:cNvGraphicFramePr element. @@ -398,11 +396,11 @@ # Write the xdr:nvCxnSpPr element. write_nv_cxn_sp_pr(index, shape) # Write the xdr:spPr element. - write_xdr_sp_pr(index, col_absolute, row_absolute, width, height, shape) + write_xdr_sp_pr(col_absolute, row_absolute, width, height, shape) end else # Add attribute for shapes. attributes = [ [:macro, ''], @@ -412,15 +410,15 @@ # Write the xdr:nvSpPr element. write_nv_sp_pr(index, shape) # Write the xdr:spPr element. - write_xdr_sp_pr(index, col_absolute, row_absolute, width, height, shape) + write_xdr_sp_pr(col_absolute, row_absolute, width, height, shape) # Write the xdr:txBody element. if shape.text != 0 - write_txBody(col_absolute, row_absolute, width, height, shape) + write_tx_body(shape) end end end end @@ -583,11 +581,11 @@ end # # Write the <xdr:spPr> element for shapes. # - def write_xdr_sp_pr(index, col_absolute, row_absolute, width, height, shape) + def write_xdr_sp_pr(col_absolute, row_absolute, width, height, shape) attributes = [ ['bwMode', 'auto'] ] @writer.tag_elements('xdr:spPr', attributes) do # Write the a:xfrm element. @@ -746,11 +744,11 @@ end # # Write the <xdr:txBody> element. # - def write_txBody(col_absolute, row_absolute, width, height, shape) + def write_tx_body(shape) attributes = [ [:vertOverflow, "clip"], [:wrap, "square"], [:lIns, "27432"], [:tIns, "22860"], @@ -795,10 +793,10 @@ [:baseline, 0] ] @writer.tag_elements('a:rPr', attributes) do color = shape.format[:color] if color - color = shape.get_palette_color(color) + color = shape.palette_color(color) color = color.sub(/^FF/, '') # Remove leading FF from rgb for shape color. else color = '000000' end