/[webpac2]/trunk/lib/WebPAC/Input/PDF.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input/PDF.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1056 by dpavlin, Tue Nov 20 09:30:56 2007 UTC revision 1057 by dpavlin, Tue Nov 20 10:08:02 2007 UTC
# Line 69  sub new { Line 69  sub new {
69    
70          $log->info("opend $file with $pages pages");          $log->info("opend $file with $pages pages");
71    
72          my @lines;          my @lines = ();
73    
74          foreach my $p ( 1 .. $pages ) {          foreach my $p ( 1 .. $pages ) {
75                  my $tree = $doc->getPageContentTree($p);                  my $tree = $doc->getPageContentTree($p);
# Line 123  sub new { Line 123  sub new {
123                  }                  }
124          }          }
125    
126          $self->size( $#lines );          $self->{_lines} = \@lines;
127    
128          $log->debug("loaded ", $self->size, " records", sub { dump( @lines ) });          $log->debug("loaded ", $self->size, " records", sub { dump( @lines ) });
129    
# Line 136  Return record with ID C<$mfn> from datab Line 136  Return record with ID C<$mfn> from datab
136    
137    my $rec = $input->fetch_rec( $mfn, $filter_coderef );    my $rec = $input->fetch_rec( $mfn, $filter_coderef );
138    
139    Records are returned as field C<A>, C<B> and so on...
140    
141    Last supported column is C<ZZ>.
142    
143  =cut  =cut
144    
145  sub fetch_rec {  sub fetch_rec {
# Line 143  sub fetch_rec { Line 147  sub fetch_rec {
147    
148          my ( $mfn, $filter_coderef ) = @_;          my ( $mfn, $filter_coderef ) = @_;
149    
150          return $self->{_rec}->[$mfn-1];          my $rec = {
151                    '000' => [ $mfn ],
152            };
153    
154            my $line = $self->{_lines}->[ $mfn - 1 ] || return;
155            confess "expected ARRAY for _lines $mfn" unless ref($line) eq 'ARRAY';
156    
157    #       warn "## line = ",dump( $line );
158    
159            my $col = 'A';
160            my $c = 0;
161            foreach my $e ( @$line ) {
162                    $rec->{$col} = $e;
163                    $c++;
164                    # FIXME what about columns > ZZ
165                    if ( $col eq 'Z' ) {
166                            $col .= 'AA';
167                    } elsif ( $col eq 'ZZ' ) {
168                            $self->_get_logger()->logwarn("ignoring colums above ZZ (original ", $#$line + 1, " > $c max columns)");
169                            last;
170                    } elsif ( $col =~ m/([A-Z])Z$/ ) {
171                            $col .= $1++ . 'A';
172                    } else {
173                            $col++;
174                    }
175            }
176    
177    #       warn "## rec = ",dump( $rec );
178    
179            return $rec;
180  }  }
181    
182    
# Line 157  Return number of records in database Line 190  Return number of records in database
190    
191  sub size {  sub size {
192          my $self = shift;          my $self = shift;
193          return $#{$self->{_rec}} + 1;          return $#{$self->{_lines}} + 1;
194  }  }
195    
196  =head1 SEE ALSO  =head1 SEE ALSO

Legend:
Removed from v.1056  
changed lines
  Added in v.1057

  ViewVC Help
Powered by ViewVC 1.1.26