[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
foxr
foxr@source.lon-capa.org
Tue, 17 Nov 2009 11:32:23 -0000
foxr Tue Nov 17 11:32:23 2009 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Truncate the finally formatted user described page header so that it fits
int three lines, BZ 5446
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.564 loncom/interface/lonprintout.pm:1.565
--- loncom/interface/lonprintout.pm:1.564 Mon Nov 16 11:13:24 2009
+++ loncom/interface/lonprintout.pm Tue Nov 17 11:32:23 2009
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.564 2009/11/16 11:13:24 foxr Exp $
+# $Id: lonprintout.pm,v 1.565 2009/11/17 11:32:23 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -499,8 +499,11 @@
sub format_page_header {
my ($width, $format, $assignment, $course, $student, $section) = @_;
-
+
+
$width = &recalcto_mm($width); # Get width in mm.
+ my $chars_per_line = int($width/1.6); # Character/textline.
+
# Default format?
if ($format eq '') {
@@ -514,9 +517,8 @@
# but only truncate the course.
# - Allow the assignment to be 2 lines (wrapped).
#
- my $chars_per_line = $width/2; # Character/textline.
-
+
my $name_length = int($chars_per_line *3 /4);
my $sec_length = int($chars_per_line / 5);
@@ -552,7 +554,19 @@
my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');
$format =~ s/\\\\\s\\\\\s/$testPrintout/;
}
-
+ #
+ # We're going to trust LaTeX to break lines appropriately, but
+ # we'll truncate anything that's more than 3 lines worth of
+ # text. This is also assuming (which will probably end badly)
+ # nobody's going to embed LaTeX control sequences in the title
+ # header or rather that those control sequences won't get broken
+ # by the stuff below.
+ #
+ my $total_length = 3*$chars_per_line;
+ if (length($format) > $total_length) {
+ $format = substr($format, 0, $total_length);
+ }
+
return $format;