Permalink
Browse files

Some pictures are not properly scaled without \picwgoal and \pichgoal

  • Loading branch information...
1 parent 1f91b59 commit 09d40f2f9624bf5b7548f639314460c060a30873 @murbanski murbanski committed Nov 17, 2011
Showing with 14 additions and 2 deletions.
  1. +5 −2 lib/rtf/node.rb
  2. +9 −0 test/image_node_test.rb
View
@@ -1109,11 +1109,11 @@ class ImageNode < Node
# Attribute accessor.
attr_reader :x_scaling, :y_scaling, :top_crop, :right_crop, :bottom_crop,
- :left_crop, :width, :height
+ :left_crop, :width, :height, :displayed_width, :displayed_height
# Attribute mutator.
attr_writer :x_scaling, :y_scaling, :top_crop, :right_crop, :bottom_crop,
- :left_crop
+ :left_crop, :displayed_width, :displayed_height
# This is the constructor for the ImageNode class.
@@ -1138,6 +1138,7 @@ def initialize(parent, source, id)
@x_scaling = @y_scaling = nil
@top_crop = @right_crop = @bottom_crop = @left_crop = nil
@width = @height = nil
+ @displayed_width = @displayed_height = nil
# Check what we were given.
src = source
@@ -1208,6 +1209,8 @@ def to_rtf
text << "\\piccropr#{@right_crop}" if @right_crop != nil
text << "\\piccropt#{@top_crop}" if @top_crop != nil
text << "\\piccropb#{@bottom_crop}" if @bottom_crop != nil
+ text << "\\picwgoal#{@displayed_width}" if @displayed_width != nil
+ text << "\\pichgoal#{@displayed_height}" if @displayed_height != nil
text << "\\picw#{@width}\\pich#{@height}\\bliptag#{@id}"
text << "\\#{@type.id2name}\n"
@source.each_byte {|byte| @read << byte} if @source.eof? == false
View
@@ -40,6 +40,12 @@ def test_mutators
image.left_crop = 50
assert(image.left_crop == 50)
+
+ image.displayed_width = 5000
+ assert(image.displayed_width == 5000)
+
+ image.displayed_height = 9000
+ assert(image.displayed_height == 9000)
end
def test_image_reading
@@ -73,10 +79,13 @@ def test_rtf
image.right_crop = 15
image.left_crop = 20
image.bottom_crop = 25
+ image.displayed_width = 5000
+ image.displayed_height = 9000
rtf = image.to_rtf
assert(rtf == "{\\*\\shppict{\\pict\\picscalex100\\picscaley75"\
"\\piccropl20\\piccropr15\\piccropt10\\piccropb25"\
+ "\\picwgoal5000\\pichgoal9000"\
"\\picw20\\pich20\\bliptag1\\pngblip\n"\
"89504e470d0a1a0a0000000d494844520000001400000014080200000002eb8a5a00000001735247\n"\
"4200aece1ce90000000467414d410000b18f0bfc6105000000206348524d00007a26000080840000\n"\

0 comments on commit 09d40f2

Please sign in to comment.