| 1 | #================================= Job.pm ==================================== | ||||||||||||||||||||||||||||
| 2 | # Filename: Job.pm | ||||||||||||||||||||||||||||
| 3 | # Description: Handle a scanning job, where job is usually a document. | ||||||||||||||||||||||||||||
| 4 | # Original Author: Dale M. Amon | ||||||||||||||||||||||||||||
| 5 | # Revised by: $Author: amon $ | ||||||||||||||||||||||||||||
| 6 | # Date: $Date: 2008-08-28 23:31:44 $ | ||||||||||||||||||||||||||||
| 7 | # Version: $Revision: 1.3 $ | ||||||||||||||||||||||||||||
| 8 | # License: LGPL 2.1, Perl Artistic or BSD | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | #============================================================================= | ||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Fault::DebugPrinter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Fault::ErrorHandler; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Fault::Logger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Document::Directory; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Document::PageIterator; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Document::PageId; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Scanner::Device; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Scanner::Format; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Scanner::Page; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | package Scanner::Job; | ||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use vars qw{@ISA}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 1 | @ISA = qw( UNIVERSAL ); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | #============================================================================= | ||||||||||||||||||||||||||||
| 30 | # CLASS METHODS | ||||||||||||||||||||||||||||
| 31 | #============================================================================= | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 0 | my ($class,$scanner,$firstpage,$format,$Spine_Width_Inches,$Total_Sheets, | |||||||||||||||||||||||||||
| 35 | $path,$date,$publication) = @_; | ||||||||||||||||||||||||||||
| 36 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my $pgformat = Scanner::Format->new ('format' => $format); | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | if (!defined $pgformat) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | Fault::ErrorHandler->warn ("Invalid page format"); | |||||||||||||||||||||||||||
| 41 | 0 | return undef; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($Total_Sheets <= 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | Fault::ErrorHandler->warn ("Total Sheets cannot be zero!"); | |||||||||||||||||||||||||||
| 46 | 0 | return undef; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($Spine_Width_Inches <= 0.0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | Fault::ErrorHandler->warn ("Spine Width cannot be 0.0 inches!"); | |||||||||||||||||||||||||||
| 51 | 0 | return undef; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | my ($w,$h) = $pgformat->UserDimensions; | |||||||||||||||||||||||||||
| 55 | 0 | my $so = $pgformat->orientation; | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | my $sw = ($pgformat->portrait) ? $Spine_Width_Inches : $w; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $sh = ($pgformat->landscape) ? $Spine_Width_Inches : $h; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | my $spine = Scanner::Format->new ('format' => "${so}:${sw}x${sh}"); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | my @parse = Document::PageId->parse ($firstpage); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( !($parse[0] and !$parse[1])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parse[0] and not $parse[1]
MC/DC0%0/2
$parse[0] and not $parse[1]
$parse[0]
not $parse[1]
Truth table0%0/3
A and not(B)
A= $parse[0]B= not $parse[1]
| |||||||||||||||||||||||||||||
| 63 | 0 | Fault::ErrorHandler->warn | |||||||||||||||||||||||||||
| 64 | ("First page is not in a recognizable format: \"$firstpage\""); | ||||||||||||||||||||||||||||
| 65 | 0 | return undef; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | $self->{'scanner'} = $scanner; | |||||||||||||||||||||||||||
| 69 | 0 | $self->{'FirstPage'} = $firstpage; | |||||||||||||||||||||||||||
| 70 | 0 | $self->{'PageFormat'} = $pgformat; | |||||||||||||||||||||||||||
| 71 | 0 | $self->{'SpineFormat'} = $spine; | |||||||||||||||||||||||||||
| 72 | 0 | $self->{'Total_Sheets'} = $Total_Sheets; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | $self->{'pgspersheet'} = 1; | |||||||||||||||||||||||||||
| 75 | 0 | $self->{'batchlen'} = 1; | |||||||||||||||||||||||||||
| 76 | 0 | $self->{'batchcnt'} = 0; | |||||||||||||||||||||||||||
| 77 | 0 | $self->{'PageTitle'} = "cover"; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | $self->{'FirstPageId'} = ($firstpage == 0) ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | "000a" : sprintf "%03d",$firstpage; | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | $self->{'curpgobj1'} = Document::PageIterator->new ($self->{'FirstPageId'}); | |||||||||||||||||||||||||||
| 82 | 0 | $self->{'curpgobj2'} = Document::PageIterator->new ($self->{'FirstPageId'}); | |||||||||||||||||||||||||||
| 83 | 0 | $self->{'document'} = Document::Directory->open ($path,$date,$publication); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | return $self; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | #============================================================================= | ||||||||||||||||||||||||||||
| 89 | # INSTANCE METHODS | ||||||||||||||||||||||||||||
| 90 | #============================================================================= | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub scan ($) { | ||||||||||||||||||||||||||
|
Subroutine
scan: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | 0 | my $fs = $self->{'document'}->filespec; | |||||||||||||||||||||||||||
| 95 | 0 | my ($pageid, $format, $title); | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($self->isSpine) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | $pageid = "000.spine"; | |||||||||||||||||||||||||||
| 99 | 0 | $format = $self->{'SpineFormat'}; | |||||||||||||||||||||||||||
| 100 | 0 | $title = "spine"; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||||||||||
| 103 | 0 | $pageid = $self->pageid; | |||||||||||||||||||||||||||
| 104 | 0 | $format = $self->{'PageFormat'}; | |||||||||||||||||||||||||||
| 105 | 0 | $title = $self->{'PageTitle'}; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | my $curpage = Scanner::Page->new | |||||||||||||||||||||||||||
| 109 | ( 'date' => $fs->dates, | ||||||||||||||||||||||||||||
| 110 | 'title' => $fs->undated_filename, | ||||||||||||||||||||||||||||
| 111 | 'pageid' => $pageid, | ||||||||||||||||||||||||||||
| 112 | 'format' => $format | ||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||
| 114 | 0 | $self->{'scanner'}->scan ($curpage, $fs->pathname); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | Fault::DebugPrinter->dbg (2, "Scan page " . $pageid); | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | $self->{'document'}->add ($pageid,($title) ); | |||||||||||||||||||||||||||
| 119 | 0 | return $self; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub nextPageNumbers { | ||||||||||||||||||||||||||
|
Subroutine
nextPageNumbers: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 126 | 0 | my ($curpgobj1,$curpgobj2) = @$self{'curpgobj1','curpgobj2'}; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ($self->{'pgspersheet'} == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | $curpgobj1->nextid(1); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | else { | ||||||||||||||||||||||||||||
| 132 | 0 | $curpgobj1->setpageid ($curpgobj2->get); | |||||||||||||||||||||||||||
| 133 | 0 | $curpgobj1->nextid (1); | |||||||||||||||||||||||||||
| 134 | 0 | $curpgobj2->setpageid ($curpgobj1->get); | |||||||||||||||||||||||||||
| 135 | 0 | $curpgobj2->nextid (1); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 0 | return $self; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub pageid { | ||||||||||||||||||||||||||
|
Subroutine
pageid: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 0 | my ($self) = shift; | |||||||||||||||||||||||||||
| 144 | 0 | my ($pgobj1,$pgobj2) = @$self{'curpgobj1','curpgobj2'}; | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $pg1 = (defined $pgobj1) ? $pgobj1->get : "UNDEF"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $pg2 = (defined $pgobj2) ? $pgobj2->get : "UNDEF"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return ($self->{'pgspersheet'} == 1) ? $pg1 : "$pg1-$pg2"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub guessPageTitle { | ||||||||||||||||||||||||||
|
Subroutine
guessPageTitle: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 154 | 0 | my ($self) = shift; | |||||||||||||||||||||||||||
| 155 | 0 | my ($pgobj1,$pgobj2) = @$self{'curpgobj1','curpgobj2'}; | |||||||||||||||||||||||||||
| 156 | 0 | my $str; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( $pgobj1->get eq "000.spine") {$str = "spine";} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | else {$str = ($pgobj1->get eq $self->{'FirstPageId'}) ? "cover" : "";} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | $self->{'PageTitle'} = $str; | |||||||||||||||||||||||||||
| 162 | 0 | return $str; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub setPagesPerSheet { | ||||||||||||||||||||||||||
|
Subroutine
setPagesPerSheet: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 168 | 0 | my ($self,$pgs) = (shift,shift); | |||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ($pgs < 0 or $pgs > 2) {return undef;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pgs < 0 or $pgs > 2
MC/DC0%0/2
$pgs < 0 or $pgs > 2
$pgs < 0
$pgs > 2
Truth table0%0/3
A or B
A= $pgs < 0B= $pgs > 2
| |||||||||||||||||||||||||||||
| 170 | 0 | $self->{'pgspersheet'} = $pgs; | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ($pgs == 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | $self->{'curpgobj2'}->setpageid ($self->{'curpgobj1'}->get); | |||||||||||||||||||||||||||
| 173 | 0 | $self->{'curpgobj2'}->nextid (1); | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | 0 | return $self->{'pgspersheet'}; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub setPagesPerSheetAsIn { | ||||||||||||||||||||||||||
|
Subroutine
setPagesPerSheetAsIn: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 181 | 0 | my ($self,$line) = (shift,shift); | |||||||||||||||||||||||||||
| 182 | 0 | my ($pgobj1,$pgobj2) = @$self{'curpgobj1','curpgobj2'}; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | my ($one,$two) = split (/-/, $line, 2); | |||||||||||||||||||||||||||
| 185 | 0 | ▶ | if (defined $one) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 0 | $pgobj1->setpageid ($one); | |||||||||||||||||||||||||||
| 187 | 0 | $self->setPagesPerSheet (1); | |||||||||||||||||||||||||||
| 188 | 0 | ▶ | if (defined $two) {$pgobj2->setpageid ($two);} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 0 | else {$pgobj2->setpageid ($one);} | |||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | $self->{'pgspersheet'} = ($pgobj1->get eq $pgobj2->get) ? 1 : 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | 0 | return $self->{'pgspersheet'}; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | ▶ | sub setBatchLength { | ||||||||||||||||||||||||||
|
Subroutine
setBatchLength: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 199 | 0 | my ($self,$n) = (shift,shift); | |||||||||||||||||||||||||||
| 200 | 0 | ▶ | $n=1 if ($n == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | $self->{'batchlen'}=$n; | |||||||||||||||||||||||||||
| 203 | 0 | return $n; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub info ($) { | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 209 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | printf "[Job]\n" . | ||||||||||||||||||||||||||||
| 212 | "First page: %s\n" . | ||||||||||||||||||||||||||||
| 213 | "Pages Per Sheet: %d\n" . | ||||||||||||||||||||||||||||
| 214 | "Total Sheets: %d\n" . | ||||||||||||||||||||||||||||
| 215 | "Batch Length: %d\n" . | ||||||||||||||||||||||||||||
| 216 | "Batch Down Counter: %d\n", | ||||||||||||||||||||||||||||
| 217 | 0 | @$self{'FirstPage', 'pgspersheet', | |||||||||||||||||||||||||||
| 218 | 'Total_Sheets', 'batchlen', 'batchcnt'}; | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | printf ("\n"); $self->{'scanner'}->info; | |||||||||||||||||||||||||||
| 221 | 0 | printf ("\n"); $self->{'document'}->info; | |||||||||||||||||||||||||||
| 222 | 0 | printf ("\n"); $self->{'PageFormat'}->info ("Page"); | |||||||||||||||||||||||||||
| 223 | 0 | printf ("\n"); $self->{'SpineFormat'}->info ("Spine"); | |||||||||||||||||||||||||||
| 224 | 0 | printf ("\n"); | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | return $self; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub isSpine {my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
isSpine: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 232 | 0 | return ($self->{'PageTitle'} eq "spine");} | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub setPageTitle {my $self = shift; $self->{'PageTitle'} = shift; | ||||||||||||||||||||||||||
|
Subroutine
setPageTitle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 235 | 0 | return $self->{'PageTitle'};} | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub initBatchCnt {my $self=shift; $self->{'batchcnt'}=$self->{'batchlen'}; | ||||||||||||||||||||||||||
|
Subroutine
initBatchCnt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 238 | 0 | return $self->{'batchcnt'};} | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub decBatchCnt {my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
decBatchCnt: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if (--$self->{'batchcnt'} < 0) {$self->{'batchcnt'}=0;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | return $self->{'batchcnt'};} | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub pageTitle {return shift->{'PageTitle'};} | ||||||||||||||||||||||||||
|
Subroutine
pageTitle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub totalSheets {return shift->{'Total_Sheets'};} | ||||||||||||||||||||||||||
|
Subroutine
totalSheets: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub batchLength {return shift->{'batchlen'};} | ||||||||||||||||||||||||||
|
Subroutine
batchLength: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub pagesPerSheet {return shift->{'pgspersheet'};} | ||||||||||||||||||||||||||
|
Subroutine
pagesPerSheet: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | #============================================================================= | ||||||||||||||||||||||||||||
| 250 | # POD DOCUMENTATION | ||||||||||||||||||||||||||||
| 251 | #============================================================================= | ||||||||||||||||||||||||||||
| 252 | # You may extract and format the documention section with the 'perldoc' cmd. | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | =head1 NAME | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | Scanner::Job - Handle a scanning job, where job is usually a document. | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | use Scanner::Job; | ||||||||||||||||||||||||||||
| 261 | $obj = Scanner::Job->new($scanner,$firstpage,$format,$spine_width_inches,$total_sheets,$path,$date,$publication); | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | $obj = $obj->scan; | ||||||||||||||||||||||||||||
| 264 | $obj = $obj->nextPageNumbers; | ||||||||||||||||||||||||||||
| 265 | $str = $obj->pageid; | ||||||||||||||||||||||||||||
| 266 | $str = $obj->guessPageTitle; | ||||||||||||||||||||||||||||
| 267 | $num = $obj->setPagesPerSheet ($pgs); | ||||||||||||||||||||||||||||
| 268 | $num = $obj->setPagesPerSheetAsIn ($line); | ||||||||||||||||||||||||||||
| 269 | $num = $obj->setBatchLength ($num); | ||||||||||||||||||||||||||||
| 270 | $flg = $obj->isSpine; | ||||||||||||||||||||||||||||
| 271 | $str = $obj->setPageTitle; | ||||||||||||||||||||||||||||
| 272 | $num = $obj->initBatchCnt; | ||||||||||||||||||||||||||||
| 273 | $num = $obj->decBatchCnt; | ||||||||||||||||||||||||||||
| 274 | $str = $obj->pageTitle; | ||||||||||||||||||||||||||||
| 275 | $num = $obj->totalSheets; | ||||||||||||||||||||||||||||
| 276 | $num = $obj->batchLength; | ||||||||||||||||||||||||||||
| 277 | $num = $obj->pagesPerSheet; | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =head1 Inheritance | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | UNIVERSAL | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | =head1 Description | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | Handle a scanning job, where job is usually a document. | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | =head1 Examples | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | None. | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | =head1 Class Variables | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | None. | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | =head1 Instance Variables | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | FirstPage String identifying the number portion of the first | ||||||||||||||||||||||||||||
| 298 | page scanned. eg "000" | ||||||||||||||||||||||||||||
| 299 | FirstPageId String identifying the the first page scanned, including | ||||||||||||||||||||||||||||
| 300 | subpage numbers and such. eg "000a" | ||||||||||||||||||||||||||||
| 301 | FormatPage Scanner::Format object for pages | ||||||||||||||||||||||||||||
| 302 | SpineFormat Scanner::Format object for spine. | ||||||||||||||||||||||||||||
| 303 | scanner Scanner object. | ||||||||||||||||||||||||||||
| 304 | Total_Sheets Total sheets in document. Not really used yet. | ||||||||||||||||||||||||||||
| 305 | pgspersheet Pages per scanned sheet. Usually 1 or 2. | ||||||||||||||||||||||||||||
| 306 | batchlen Number of pages in ADF scan batch. | ||||||||||||||||||||||||||||
| 307 | batchcnt Page count of ADF scan batch. | ||||||||||||||||||||||||||||
| 308 | PageTitle Type of page. cover, backcover, contents... | ||||||||||||||||||||||||||||
| 309 | curpgobj1 Document::PageIterator for the page, or of the left | ||||||||||||||||||||||||||||
| 310 | hand page if there are two. | ||||||||||||||||||||||||||||
| 311 | curpgobj2 Document::PageIterator for the page, or of the right | ||||||||||||||||||||||||||||
| 312 | hand page if there are two. | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =head1 Class Methods | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | =over 4 | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | =item B<$obj = Scanner::Job-E<gt>new ($scanner,$firstpage,$format,$spine_width_inches,$total_sheets,$path,$date,$publication)> | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | Create and initialize instances of Scanner::Job. | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | scanner A Scanner object. | ||||||||||||||||||||||||||||
| 323 | firstpage Page number to begin scanning at. | ||||||||||||||||||||||||||||
| 324 | format A page format string, ie "L:10x12" | ||||||||||||||||||||||||||||
| 325 | spine_width_inches Width of the document spine. | ||||||||||||||||||||||||||||
| 326 | total_sheets Total sheets in the document. Not really used yet. | ||||||||||||||||||||||||||||
| 327 | path Where to put the document. | ||||||||||||||||||||||||||||
| 328 | date Date of the document. | ||||||||||||||||||||||||||||
| 329 | publication Name of the publication, title and author of book or | ||||||||||||||||||||||||||||
| 330 | paper, etc. | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | =head1 Instance Methods | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | =over 4 | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | =item B<$obj = $obj-E<gt>scan> | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | Set up the information for the next page of the document and scan it. The | ||||||||||||||||||||||||||||
| 339 | page will be named, placed in its document directory and logged and added | ||||||||||||||||||||||||||||
| 340 | to the table of contents file there. | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | If the page name is the special token 'spine', then the special pageid of | ||||||||||||||||||||||||||||
| 343 | "000.spine" is used instead of the current pageid and the document scan | ||||||||||||||||||||||||||||
| 344 | format is set for the width of the spine in whichever dimension on the | ||||||||||||||||||||||||||||
| 345 | scanbed is appropriate: scanner height if landscape; scanner width if | ||||||||||||||||||||||||||||
| 346 | portrait. | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | Returns self. | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | =item B<$num = $obj-E<gt>nextPageNumbers> | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | Increment the page number or numbers. | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | Returns self. | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =item B<$str = $obj-E<gt>pageid> | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | Return a pageid string made up from info from one or two pageid objects. | ||||||||||||||||||||||||||||
| 359 | Returns <pageid1> or <pageid1>-<pageid2> | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =item B<$str = $obj-E<gt>guessPageTitle> | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | Make our best guess at what the user is going to want for the title. | ||||||||||||||||||||||||||||
| 364 | Returns PageTitle. | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | =item B<$num = $obj-E<gt>setPagesPerSheet ($pgs)> | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | Set the number of pages per sheet and return the value when done. | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | =item B<$num = $obj-E<gt>setPagesPerSheetAsIn ($line)> | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | Set the pages per sheet to match $line and return the result of doing so. | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =item B<$num = $obj-E<gt>setBatchLength ($n)> | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | Set the batch length and return the result of doing so. | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =item B<$flg = $obj-E<gt>isSpine> | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | Return true if the page is the document spine, ie the page number is 000.spine. | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =item B<$str = $obj-E<gt>setPageTitle> | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | Set the page title and return the result of doing so. | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | =item B<$num = $obj-E<gt>initBatchCnt> | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | Set the batch count to the batch length and return the result. | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | =item B<$num = $obj-E<gt>decBatchCnt> | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | Decrement the batch count until it reaches 0. Returns the value | ||||||||||||||||||||||||||||
| 393 | after the decrement. | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | =item B<$str = $obj-E<gt>pageTitle> | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | Returns the page title. | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | =item B<$num = $obj-E<gt>totalSheets> | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | Returns the total sheets. | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | =item B<$num = $obj-E<gt>batchLength> | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | Returns the batch length. | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | =item B<$num = $obj-E<gt>pagesPerSheet> | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | Returns the pages per sheet. | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | =back 4 | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | =head1 Private Class Method | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | None. | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | =head1 Private Instance Methods | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | None. | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =head1 Errors and Warnings | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | None. | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =head1 KNOWN BUGS | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | See TODO. | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | Document::LogFile, Document::TocFile, Document::Toc, Document::PageIterator, | ||||||||||||||||||||||||||||
| 432 | Scanner, Scanner::Page | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | Dale Amon <amon@vnl.com> | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | =cut | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | #============================================================================= | ||||||||||||||||||||||||||||
| 441 | # CVS HISTORY | ||||||||||||||||||||||||||||
| 442 | #============================================================================= | ||||||||||||||||||||||||||||
| 443 | # $Log: Job.pm,v $ | ||||||||||||||||||||||||||||
| 444 | # Revision 1.3 2008-08-28 23:31:44 amon | ||||||||||||||||||||||||||||
| 445 | # Major rewrite. Shuffled code between classes and add lots of features. | ||||||||||||||||||||||||||||
| 446 | # | ||||||||||||||||||||||||||||
| 447 | # Revision 1.2 2008-08-07 19:52:48 amon | ||||||||||||||||||||||||||||
| 448 | # Upgrade source format to current standard. | ||||||||||||||||||||||||||||
| 449 | # | ||||||||||||||||||||||||||||
| 450 | # Revision 1.1.1.1 2008-08-06 21:36:11 amon | ||||||||||||||||||||||||||||
| 451 | # Classes for scanner use abstractions. | ||||||||||||||||||||||||||||
| 452 | # | ||||||||||||||||||||||||||||
| 453 | # 20070511 Dale Amon <amon@islandone.org> | ||||||||||||||||||||||||||||
| 454 | # Created. | ||||||||||||||||||||||||||||
| 455 | 1 | 1; | |||||||||||||||||||||||||||