--- loncom/xml/londefdef.pm 2002/07/03 15:37:10 1.68 +++ loncom/xml/londefdef.pm 2002/07/11 14:40:14 1.69 @@ -1,8 +1,7 @@ - # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.68 2002/07/03 15:37:10 sakharuk Exp $ +# $Id: londefdef.pm,v 1.69 2002/07/11 14:40:14 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -1286,7 +1285,7 @@ EDITBUTTON $Apache::londefdef::table[-1]{'vvinc'} = '|'; } else { $Apache::londefdef::table[-1]{'hinc'} = ''; - $Apache::londefdef::table[-1]{'vinc'} = ''; + $Apache::londefdef::table[-1]{'vinc'} = '&'; $Apache::londefdef::table[-1]{'vvinc'} = ''; } } @@ -1336,7 +1335,7 @@ EDITBUTTON if ($alignchar ne '') { push @ {$Apache::londefdef::table[-1]{'rows'} }, $alignchar; } else { - push @ {$Apache::londefdef::table[-1]{'rows'} }, 'c'; + push @ {$Apache::londefdef::table[-1]{'rows'} }, 'l'; } push ( @{ $Apache::londefdef::table[-1]{'rowdata'} }, $Apache::londefdef::table[-1]{'hinc'}); $Apache::londefdef::table[-1]{'counter_columns'} = -1; @@ -1421,31 +1420,28 @@ EDITBUTTON $token->[2]->{'src'}; my $currentstring = ''; my $width_param = ''; + my $height_param = ''; + my $scaling = .3; if ($target eq 'web') { $currentstring = $token->[4]; } elsif ($target eq 'tex') { - my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval); - my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval); - my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval); - if ($TeXwidth ne '') { - $width_param = $TeXwidth; - } elsif ($TeXheight ne '') { - $width_param = $TeXheight; - } else { - if ($width ne '') { - $width_param = $width*.3; - if ($width_param <= 900) { - $width_param = '[width='.$width_param.'mm]'; - } else { - $width_param = '[width= \textwidth]'; - } - } - } my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval); $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); + if ($src=~m/\.(gif|GIF)$/) { + my $gif_file = Apache::File->new($src); + binmode ($gif_file); + my ($buff,$imagesize); + read ($gif_file,$buff,6); + read ($gif_file,$imagesize,4); + my ($xlsb,$xmsb,$ylsb,$ymsb) = split(//,$imagesize); + my $image_width=ord($xlsb)+ord($xmsb)*256; + my $image_height=ord($ylsb)+ord($ymsb)*256; + $width_param = $image_width * $scaling; #default value of the picture's width + $height_param = $image_height * $scaling; #default value of the picture's height + } my $epssrc = $src; - $epssrc =~ s/(\.gif|\.jpg|\.GIF|\.JPG)$/\.eps/; + $epssrc =~ s/(\.gif|\.jpg)$/\.eps/i; if (not -e $epssrc) { my $localfile = $epssrc; $localfile =~ s/.*(\/res)/$1/; @@ -1470,8 +1466,7 @@ EDITBUTTON } else { $localfile = $src; $localfile =~ s/.*(\/res)/$1/; - my $as = &Apache::lonnet::getfile($src); - + my $as = &Apache::lonnet::getfile($src); } } my $file; @@ -1482,17 +1477,29 @@ EDITBUTTON } my $newsrc = $src; $newsrc =~ s/(\.gif|\.jpg)$/\.eps/i; - $file=~s/(\.gif|\.jpg)$/\.eps/i; + $file=~s/(\.gif|\.jpg)$/\.eps/i; + #do we have any specified size of the picture? + my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval); + my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval); + my $width = &Apache::lonxml::get_param('width',$parstack,$safeeval); + if ($TeXwidth ne '') { + $width_param = $TeXwidth; + } elsif ($TeXheight ne '') { + $width_param = $TeXheight/$height_param*$width_param; + } elsif ($width ne '') { + $width_param = $width*$scaling; + } + #where can we find the picture? if (-e $newsrc) { if ($path) { - $currentstring .= '\noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics'.$width_param.'{'.$file.'}}'; + $currentstring .= '\noindent\graphicspath{{'.$path.'}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; } } else { my $temp_file; my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat"; $temp_file = Apache::File->new('>>'.$filename); print $temp_file "$src\n"; - $currentstring .= '\graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics'.$width_param.'{'.$file.'}}'; + $currentstring .= '\graphicspath{{/home/httpd/prtspool/}}\fbox{\includegraphics[width='.$width_param.' mm]{'.$file.'}} '; } } return $currentstring;