From 7faa2f58b00f20e08457a44bd5ac9285001151ea Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Fri, 18 Apr 2008 07:06:23 -0400 Subject: [PATCH] Adding back text wrap funcionality for lines exceeding $text_wrap_cols; also adding use of C4::Debug Signed-off-by: Joshua Ferraro --- C4/Labels.pm | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/C4/Labels.pm b/C4/Labels.pm index 6365c568f1..536fdaf92c 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -21,11 +21,12 @@ use strict; use vars qw($VERSION @ISA @EXPORT); use PDF::Reuse; -use Text::Wrap; +#use Text::Wrap; use Algorithm::CheckDigits; use C4::Members; use C4::Branch; - use Data::Dumper; +use C4::Debug; +#use Data::Dumper; # use Smart::Comments; BEGIN { @@ -60,7 +61,6 @@ BEGIN { ); } -my $DEBUG = 0; =head1 NAME @@ -417,7 +417,7 @@ sub GetTextWrapCols { my $strwidth; my $count = 0; # my $textlimit = $label_width - ($left_text_margin); - my $textlimit = $label_width - ( 2* $left_text_margin); + my $textlimit = $label_width - ( 3 * $left_text_margin); while ( $strwidth < $textlimit ) { $strwidth = prStrWidth( $string, $font, $fontsize ); @@ -929,9 +929,6 @@ sub DrawSpineText { $$item->{'itemtype'} = $data->{'description'} if ($$item->{'itemtype'} eq $data->{'itemtype'}); } - $Text::Wrap::columns = $text_wrap_cols; - $Text::Wrap::separator = "\n"; - my $str; my $top_text_margin = ( $fontsize + 3 ); #FIXME: This should be a template parameter and passed in... @@ -972,11 +969,17 @@ sub DrawSpineText { } unshift @strings, $str; } else { - push @strings, $str; # or if we are not wrapping the call number just send it along as we found it... + push @strings, $str; # if $nowrap == 1 do not wrap or remove segmentation markers... + } + } else { + $str =~ s/\/$//g; # Here we will strip out all trailing '/' in fields other than the call number... + if ( length($str) > $text_wrap_cols ) { # wrap lines greater than $text_wrap_cols width... + my $wrap = substr($str, ($text_wrap_cols - length($str)), $text_wrap_cols, ""); + push @strings, $str; + push @strings, $wrap; + } else { + push @strings, $str; } - } else { # Here we will strip out all trailing '/' in fields other than the call number... - $str =~ s/\/$//g; - push @strings, $str; } # loop for each string line foreach my $str (@strings) { @@ -1163,8 +1166,8 @@ sub DrawBarcode { my $moo2 = $tot_bar_length * $xsize_ratio; - warn "$x_pos, $y_pos, $barcode, $barcodetype" if $DEBUG; - warn "BAR_WDTH = $bar_width, TOT.BAR.LGHT=$tot_bar_length R*TOT.BAR =$moo2" if $DEBUG; + warn "$x_pos, $y_pos, $barcode, $barcodetype" if $debug; + warn "BAR_WDTH = $bar_width, TOT.BAR.LGHT=$tot_bar_length R*TOT.BAR =$moo2" if $debug; } =item build_circ_barcode; -- 2.39.5