--- loncom/xml/londefdef.pm 2002/05/22 21:07:45 1.62 +++ 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.62 2002/05/22 21:07:45 sakharuk Exp $ +# $Id: londefdef.pm,v 1.69 2002/07/11 14:40:14 sakharuk Exp $ # # # Copyright Michigan State University Board of Trustees @@ -52,7 +51,7 @@ use Apache::File(); BEGIN { - &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','allow','frameset','pre','insert','externallink','table','tr','th','td')); + &Apache::lonxml::register('Apache::londefdef',('m','html','head','map','select','option','input','textarea','form','meta','title','body','center','b','strong','dt','h1','h2','h3','h4','h5','h6','cite','i','address','dd','dl','dir','ol','ul','menu','dfn','kbd','tt','code','em','q','p','br','big','small','basefont','font','s','sub','strike','sup','hr','a','li','u','output','param','applet','img','embed','allow','frameset','pre','insert','externallink','table','tr','th','td','blankspace','bubble','bubbles','bubbleline')); } @@ -122,7 +121,7 @@ sub end_m { $currentstring .= '\documentclass[letterpaper]{article} \newcommand{\keephidden}[1]{} \usepackage[dvips]{graphicx} - \usepackage{epsfig}'; + \usepackage{epsfig}\usepackage{calc}'; } return $currentstring; } @@ -840,7 +839,7 @@ EDITBUTTON if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '\\\\'; + $currentstring .= '\vskip 0 mm'; } elsif ($target eq 'latexsource') { $currentstring .= '\\'; } @@ -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= 9.0 cm]'; - } - } - } 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; @@ -1481,18 +1476,30 @@ EDITBUTTON $path = $1.'/'; } my $newsrc = $src; - $newsrc =~ s/(\.gif|\.jpg|\.GIF|\.JPG)$/\.eps/; - $file=~s/(\.gif|\.jpg|\.GIF|\.JPG)$/\.eps/; + $newsrc =~ 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 .= '\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'}temp$ENV{'user.login.time'}.dat"; + 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; @@ -1679,5 +1686,24 @@ sub start_embed { } return $currentstring; } +#-- + sub start_blankspace { + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; + my $currentstring = ''; + if ($target eq 'tex') { + my $howmuch = &Apache::lonxml::get_param('heigth',$parstack,$safeeval); + $currentstring .= '\vskip '.$howmuch.' '; + } + return $currentstring; + } + sub end_blankspace { + my ($target,$token) = @_; + my $currentstring = ''; + if ($target eq 'tex') { + $currentstring .= ''; + } + return $currentstring; + } + 1; __END__