| 1 | #============================== PageIterator.pm ============================== | ||||||||||||||||||
| 2 | # Filename: PageIterator.pm | ||||||||||||||||||
| 3 | # Description: Page Iterator Class. | ||||||||||||||||||
| 4 | # Original Author: Dale Amon | ||||||||||||||||||
| 5 | # Revised by: $Author: amon $ | ||||||||||||||||||
| 6 | # Date: $Date: 2008-08-28 23:26:17 $ | ||||||||||||||||||
| 7 | # Version: $Revision: 1.5 $ | ||||||||||||||||||
| 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 Document::PageId; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | package Document::PageIterator; | ||||||||||||||||||
| 15 | 1 | ▶ | use vars qw{@ISA}; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 16 | 1 | @ISA = qw( Document::PageId ); | |||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | #============================================================================= | ||||||||||||||||||
| 19 | # Instance Methods | ||||||||||||||||||
| 20 | #============================================================================= | ||||||||||||||||||
| 21 | # Return undef if the page was not changed. | ||||||||||||||||||
| 22 | # | ||||||||||||||||||
| 23 | sub setpageid | ||||||||||||||||||
| 24 | 0 | ▶ | {my ($self,$pageid) = @_; return $self->_init($pageid);} | ||||||||||||||||
|
Subroutine
setpageid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | #----------------------------------------------------------------------------- | ||||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | 0 | ▶ | sub setfirstpage { | ||||||||||||||||
|
Subroutine
setfirstpage: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||
| 29 | 0 | my ($self,$first) = @_; | |||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | 0 | ▶ | ($first =~ /^\d*$/) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 32 | 0 | ▶ | ((length $first) <= $self->{'pn_digits'}) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 0 | $self->{'firstpage'} = $first; | |||||||||||||||||
| 35 | 0 | return $self; | |||||||||||||||||
| 36 | } | ||||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | #============================================================================= | ||||||||||||||||||
| 39 | # These return undef on page overflow. | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 0 | ▶ | sub advancepage { | ||||||||||||||||
|
Subroutine
advancepage: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||
| 42 | 0 | my ($self,$n) = @_; | |||||||||||||||||
| 43 | 0 | ▶ | (defined $n) || ($n=1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 44 | 0 | ▶ | ($n =~ /^\d*$/) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 45 | SW: { | ||||||||||||||||||
| 46 | 0 | $_ = $self->{'type'}; | |||||||||||||||||
| 47 | 0 | ▶ | if (/1/) { $self->_incpage($n) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 48 | || return undef; | ||||||||||||||||||
| 49 | 0 | last SW;} # 001 | |||||||||||||||||
| 50 | 0 | ▶ | if (/2/) { $self->_incpage($n) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 51 | || return undef; | ||||||||||||||||||
| 52 | 0 | $self->_firstalphapage; | |||||||||||||||||
| 53 | 0 | last SW;} # 001a | |||||||||||||||||
| 54 | 0 | ▶ | if (/3/) { last SW;} # 000.spine | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 55 | 0 | ▶ | if (/4/) { $self->_incpage($n) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 56 | || return undef; | ||||||||||||||||||
| 57 | 0 | $self->_firstsubpage; | |||||||||||||||||
| 58 | 0 | last SW;} # 001.01 | |||||||||||||||||
| 59 | 0 | ▶ | if (/5/) { $self->_incpage($n) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 60 | || return undef; | ||||||||||||||||||
| 61 | 0 | $self->_firstsubpage; | |||||||||||||||||
| 62 | 0 | $self->_firstalphapage; | |||||||||||||||||
| 63 | 0 | last SW;} # 001.01a | |||||||||||||||||
| 64 | } | ||||||||||||||||||
| 65 | 0 | return $self->get; | |||||||||||||||||
| 66 | } | ||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | #----------------------------------------------------------------------------- | ||||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 0 | ▶ | sub advancesubpage { | ||||||||||||||||
|
Subroutine
advancesubpage: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||
| 71 | 0 | my ($self,$n) = @_; | |||||||||||||||||
| 72 | 0 | ▶ | (defined $n) || ($n=1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 73 | 0 | ▶ | ($n =~ /^\d*$/) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 74 | SW: { | ||||||||||||||||||
| 75 | 0 | $_ = $self->{'type'}; | |||||||||||||||||
| 76 | 0 | ▶ | if (/1/) { last SW;} # 001 | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 77 | 0 | ▶ | if (/2/) { last SW;} # 001a | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 78 | 0 | ▶ | if (/3/) { last SW;} # 000.spine | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 79 | 0 | ▶ | if (/4/) { $self->_incsubpage($n) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 80 | || return undef; | ||||||||||||||||||
| 81 | 0 | last SW;} # 001.01 | |||||||||||||||||
| 82 | 0 | ▶ | if (/5/) { $self->_incsubpage($n) | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 83 | || return undef; | ||||||||||||||||||
| 84 | 0 | $self->_firstalphapage; | |||||||||||||||||
| 85 | 0 | last SW;} # 001.01a | |||||||||||||||||
| 86 | } | ||||||||||||||||||
| 87 | 0 | return $self->get; | |||||||||||||||||
| 88 | } | ||||||||||||||||||
| 89 | |||||||||||||||||||
| 90 | #----------------------------------------------------------------------------- | ||||||||||||||||||
| 91 | |||||||||||||||||||
| 92 | 0 | ▶ | sub nextid { | ||||||||||||||||
|
Subroutine
nextid: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||
| 93 | 0 | my ($self,$n) = @_; | |||||||||||||||||
| 94 | 0 | ▶ | (defined $n) || ($n=1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 95 | 0 | ▶ | ($n =~ /^\d*$/) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | 0 | ▶ | if ($self->{'mode'} eq "page") | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 98 | 0 | ▶ | {$self->_incpage($n) || return undef;} | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | elsif ($self->{'mode'} eq "subpage") | ||||||||||||||||||
| 101 | 0 | ▶ | {$self->_incsubpage($n) || return undef;} | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 102 | |||||||||||||||||||
| 103 | elsif ($self->{'mode'} eq "alphapage") | ||||||||||||||||||
| 104 | 0 | ▶ | {$self->_incalphapage($n) || return undef;} | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 105 | |||||||||||||||||||
| 106 | 0 | else {return undef;} | |||||||||||||||||
| 107 | |||||||||||||||||||
| 108 | 0 | return $self->get; | |||||||||||||||||
| 109 | } | ||||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | #============================================================================= | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | 0 | ▶ | sub setPagenumber { | ||||||||||||||||
|
Subroutine
setPagenumber: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||
| 114 | 0 | my ($self,$n) = @_; | |||||||||||||||||
| 115 | 0 | ▶ | (defined $self->{'pagenum'}) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 116 | 0 | ▶ | ($n =~ /^\d*$/) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 117 | 0 | ▶ | ((length $n) <= $self->{'pn_digits'}) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | 0 | @$self{'pagenum','_dirty'} = ($n,1); | |||||||||||||||||
| 120 | 0 | return $self; | |||||||||||||||||
| 121 | } | ||||||||||||||||||
| 122 | |||||||||||||||||||
| 123 | #----------------------------------------------------------------------------- | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | 0 | ▶ | sub setSubpagenumber { | ||||||||||||||||
|
Subroutine
setSubpagenumber: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||
| 126 | 0 | my ($self,$n) = @_; | |||||||||||||||||
| 127 | 0 | ▶ | (defined $self->{'subpagenum'}) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 128 | 0 | ▶ | ($n =~ /^\d*$/) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 129 | 0 | ▶ | ((length $n) <= $self->{'spn_digits'}) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | 0 | @$self{'subpagenum','_dirty'} = ($n,1); | |||||||||||||||||
| 132 | 0 | return $self; | |||||||||||||||||
| 133 | } | ||||||||||||||||||
| 134 | |||||||||||||||||||
| 135 | #----------------------------------------------------------------------------- | ||||||||||||||||||
| 136 | |||||||||||||||||||
| 137 | 0 | ▶ | sub setAlphapage { | ||||||||||||||||
|
Subroutine
setAlphapage: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||
| 138 | 0 | my ($self,$c) = @_; | |||||||||||||||||
| 139 | 0 | ▶ | (defined $self->{'side'}) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 140 | 0 | ▶ | ($c =~ /^[a-z]$/) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 141 | |||||||||||||||||||
| 142 | 0 | @$self{'side','_dirty'} = ($c,1); | |||||||||||||||||
| 143 | 0 | return $self; | |||||||||||||||||
| 144 | } | ||||||||||||||||||
| 145 | |||||||||||||||||||
| 146 | #============================================================================= | ||||||||||||||||||
| 147 | # Internal Methods | ||||||||||||||||||
| 148 | #============================================================================= | ||||||||||||||||||
| 149 | # Increment the various possible elements of a pageid. All return false on | ||||||||||||||||||
| 150 | # page number field overflow. | ||||||||||||||||||
| 151 | |||||||||||||||||||
| 152 | 0 | ▶ | sub _incpage {my ($self,$n) = @_; | ||||||||||||||||
|
Subroutine
_incpage: not called CC=2 SCAR=17.9
| |||||||||||||||||||
| 153 | 0 | ▶ | (defined $n) || ($n=1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 154 | 0 | $self->{'_dirty'} = 1; | |||||||||||||||||
| 155 | 0 | $self->{'pagenum'} += $n; | |||||||||||||||||
| 156 | return | ||||||||||||||||||
| 157 | 0 | ((length $self->{'pagenum'}) <= $self->{'pn_digits'});} | |||||||||||||||||
| 158 | |||||||||||||||||||
| 159 | #----------------------------------------------------------------------------- | ||||||||||||||||||
| 160 | |||||||||||||||||||
| 161 | 0 | ▶ | sub _incsubpage {my ($self,$n) = @_; | ||||||||||||||||
|
Subroutine
_incsubpage: not called CC=2 SCAR=17.9
| |||||||||||||||||||
| 162 | 0 | ▶ | (defined $n) || ($n=1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 163 | 0 | $self->{'_dirty'} = 1; | |||||||||||||||||
| 164 | 0 | $self->{'subpagenum'} += $n; | |||||||||||||||||
| 165 | return | ||||||||||||||||||
| 166 | 0 | ((length $self->{'subpagenum'}) <= $self->{'spn_digits'});} | |||||||||||||||||
| 167 | |||||||||||||||||||
| 168 | #----------------------------------------------------------------------------- | ||||||||||||||||||
| 169 | |||||||||||||||||||
| 170 | 0 | ▶ | sub _incalphapage {my ($self,$n) = @_; | ||||||||||||||||
|
Subroutine
_incalphapage: not called CC=3 SCAR=24.8
| |||||||||||||||||||
| 171 | 0 | ▶ | (defined $n) || ($n=1); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 172 | 0 | ▶ | return 0 if ($self->{'side'} eq "z"); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 173 | 0 | $self->{'_dirty'} = 1; | |||||||||||||||||
| 174 | 0 | $self->{'side'} = chr (ord ($self->{'side'}) + $n); | |||||||||||||||||
| 175 | 0 | return 1;} | |||||||||||||||||
| 176 | |||||||||||||||||||
| 177 | #============================================================================= | ||||||||||||||||||
| 178 | |||||||||||||||||||
| 179 | 0 | ▶ | sub _firstpage {my $self = shift; | ||||||||||||||||
|
Subroutine
_firstpage: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 180 | 0 | $self->{'_dirty'} = 1; | |||||||||||||||||
| 181 | 0 | $self->{'pagenum'} = $self->{'firstpage'};} | |||||||||||||||||
| 182 | |||||||||||||||||||
| 183 | 0 | ▶ | sub _firstsubpage {my $self = shift; | ||||||||||||||||
|
Subroutine
_firstsubpage: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 184 | 0 | $self->{'_dirty'} = 1; | |||||||||||||||||
| 185 | 0 | $self->{'subpagenum'} = 1;} | |||||||||||||||||
| 186 | |||||||||||||||||||
| 187 | 0 | ▶ | sub _firstalphapage{my $self = shift; | ||||||||||||||||
|
Subroutine
_firstalphapage: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 188 | 0 | $self->{'_dirty'} = 1; | |||||||||||||||||
| 189 | 0 | $self->{'side'} = "a";} | |||||||||||||||||
| 190 | |||||||||||||||||||
| 191 | #============================================================================= | ||||||||||||||||||
| 192 | # Mode identifies the rightmost element, the one which will be incremented by | ||||||||||||||||||
| 193 | # a nextid method. Elements to the left of it require specifically being | ||||||||||||||||||
| 194 | # 'advanced'. | ||||||||||||||||||
| 195 | |||||||||||||||||||
| 196 | 0 | ▶ | sub _init { | ||||||||||||||||
|
Subroutine
_init: not called CC=7 SCAR=40.3
| |||||||||||||||||||
| 197 | 0 | my $self = shift; | |||||||||||||||||
| 198 | 0 | ▶ | $self->SUPER::_init (@_) || return undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 199 | |||||||||||||||||||
| 200 | 0 | my $mode; | |||||||||||||||||
| 201 | SW: { | ||||||||||||||||||
| 202 | 0 | $_ = $self->{'type'}; | |||||||||||||||||
| 203 | 0 | ▶ | if (/1/) {$mode = "page"; last SW;} # 001 | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 204 | 0 | ▶ | if (/2/) {$mode = "alphapage"; last SW;} # 001a | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 205 | 0 | ▶ | if (/3/) {$mode = "notpage"; last SW;} # 000.spine | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 206 | 0 | ▶ | if (/4/) {$mode = "subpage"; last SW;} # 001.01 | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 207 | 0 | ▶ | if (/5/) {$mode = "alphapage"; last SW;} # 001.01a | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 208 | 0 | $mode = "notpage"; | |||||||||||||||||
| 209 | } | ||||||||||||||||||
| 210 | 0 | $self->{'mode'} = $mode; | |||||||||||||||||
| 211 | 0 | return $self; | |||||||||||||||||
| 212 | } | ||||||||||||||||||
| 213 | |||||||||||||||||||
| 214 | #============================================================================= | ||||||||||||||||||
| 215 | # Pod Documentation | ||||||||||||||||||
| 216 | #============================================================================= | ||||||||||||||||||
| 217 | # You may extract and format the documention section with the 'perldoc' cmd. | ||||||||||||||||||
| 218 | |||||||||||||||||||
| 219 | =head1 NAME | ||||||||||||||||||
| 220 | |||||||||||||||||||
| 221 | Document::PageIterator - Page Iterator Class. | ||||||||||||||||||
| 222 | |||||||||||||||||||
| 223 | #head1 SYNOPSIS | ||||||||||||||||||
| 224 | |||||||||||||||||||
| 225 | use Document::PageIterator; | ||||||||||||||||||
| 226 | $bool = $pg->setpageid ($pageid); | ||||||||||||||||||
| 227 | $pageid = $pg->nextid; | ||||||||||||||||||
| 228 | $bool = $pg->setfirstpage ($n); | ||||||||||||||||||
| 229 | |||||||||||||||||||
| 230 | $bool = $pg->advancepage ($inc); | ||||||||||||||||||
| 231 | $bool = $pg->advancesubpage ($inc); | ||||||||||||||||||
| 232 | $bool = $pg->SetPagenumber ($n); | ||||||||||||||||||
| 233 | $bool = $pg->SetSubpagenumber ($n); | ||||||||||||||||||
| 234 | $bool = $pg->SetAlphapage ($c); | ||||||||||||||||||
| 235 | |||||||||||||||||||
| 236 | =head1 Inheritance | ||||||||||||||||||
| 237 | |||||||||||||||||||
| 238 | UNIVERSAL | ||||||||||||||||||
| 239 | Document::Page | ||||||||||||||||||
| 240 | Document::PageIterator | ||||||||||||||||||
| 241 | |||||||||||||||||||
| 242 | =head1 Description | ||||||||||||||||||
| 243 | |||||||||||||||||||
| 244 | This subclass of Document::Page adds the ability to increment any of the | ||||||||||||||||||
| 245 | pageid formats. Only the last element of a pageid is incremented. Increments | ||||||||||||||||||
| 246 | may continue until an invalid character (anything past "z") for an alphapage | ||||||||||||||||||
| 247 | or a number exceeding the available field size is produced. | ||||||||||||||||||
| 248 | |||||||||||||||||||
| 249 | =head1 Examples | ||||||||||||||||||
| 250 | |||||||||||||||||||
| 251 | $pg = Document::PageIterator->new ("001") || die ("Invalid page id"); | ||||||||||||||||||
| 252 | $pg->setpageid ("001.01a") || die ("Invalid page id"); | ||||||||||||||||||
| 253 | $pg->setfirstpage (1) || die ("Invalid 1st page num"); | ||||||||||||||||||
| 254 | $pageid = $pg->nextid; | ||||||||||||||||||
| 255 | defined $pageid || die ("Page id overflow"); | ||||||||||||||||||
| 256 | |||||||||||||||||||
| 257 | =head1 Class Variables | ||||||||||||||||||
| 258 | |||||||||||||||||||
| 259 | None. | ||||||||||||||||||
| 260 | |||||||||||||||||||
| 261 | =head1 Instance Variables | ||||||||||||||||||
| 262 | |||||||||||||||||||
| 263 | firstpage The first page number in the document. This | ||||||||||||||||||
| 264 | is used when resetting. Usually this is 1 | ||||||||||||||||||
| 265 | or 0 for the cover page of most publications; | ||||||||||||||||||
| 266 | But it could be any number for publications | ||||||||||||||||||
| 267 | that use page numbering based on volumes rather | ||||||||||||||||||
| 268 | than issues. | ||||||||||||||||||
| 269 | |||||||||||||||||||
| 270 | =head1 Class Methods | ||||||||||||||||||
| 271 | |||||||||||||||||||
| 272 | None. | ||||||||||||||||||
| 273 | |||||||||||||||||||
| 274 | =head1 Instance Methods | ||||||||||||||||||
| 275 | |||||||||||||||||||
| 276 | =over 4 | ||||||||||||||||||
| 277 | |||||||||||||||||||
| 278 | =item B<$bool = $pg-E<gt>advancepage ($inc);> | ||||||||||||||||||
| 279 | |||||||||||||||||||
| 280 | If a page number exists in the current pageid, increment it by | ||||||||||||||||||
| 281 | the specified $inc value. If $inc is not numeric or the result would | ||||||||||||||||||
| 282 | exceed the field size of the subpage, it returns false. | ||||||||||||||||||
| 283 | |||||||||||||||||||
| 284 | This is not a commonly used operator. | ||||||||||||||||||
| 285 | |||||||||||||||||||
| 286 | =item B<$bool = $pg-E<gt>advancesubpage ($inc);> | ||||||||||||||||||
| 287 | |||||||||||||||||||
| 288 | If a subpage number exists in the current pageid, increment it by | ||||||||||||||||||
| 289 | the specified $inc value. If $inc is not numeric or the result would | ||||||||||||||||||
| 290 | exceed the field size of the subpage, it returns false. | ||||||||||||||||||
| 291 | |||||||||||||||||||
| 292 | This is not a commonly used operator. | ||||||||||||||||||
| 293 | |||||||||||||||||||
| 294 | =item B<$pageid = $pg-E<gt>nextid> | ||||||||||||||||||
| 295 | |||||||||||||||||||
| 296 | Increment the pageid. Returns undef if this would cause an overflow. | ||||||||||||||||||
| 297 | Overflows can occur if any field size would be exceeded or an illegal | ||||||||||||||||||
| 298 | value generated. For example, increments of the following would fail: | ||||||||||||||||||
| 299 | |||||||||||||||||||
| 300 | 100z | ||||||||||||||||||
| 301 | 001.01z | ||||||||||||||||||
| 302 | 001.99 | ||||||||||||||||||
| 303 | 999 | ||||||||||||||||||
| 304 | |||||||||||||||||||
| 305 | =item B<$bool = $pg-E<gt>SetAlphapage ($c);> | ||||||||||||||||||
| 306 | |||||||||||||||||||
| 307 | If a page alpha character exists in the current pageid, set it to the | ||||||||||||||||||
| 308 | specified alphabetic character. If $c is not a single alphabetic | ||||||||||||||||||
| 309 | character, it returns false. | ||||||||||||||||||
| 310 | |||||||||||||||||||
| 311 | This is not a commonly used operator. | ||||||||||||||||||
| 312 | |||||||||||||||||||
| 313 | =item B<$bool= $pg-E<gt>setfirstpage ($n);> | ||||||||||||||||||
| 314 | |||||||||||||||||||
| 315 | Set the first page number in the document. This is used when resetting. | ||||||||||||||||||
| 316 | Usually it is 1 or 0 for the cover page of most publications; but it | ||||||||||||||||||
| 317 | could be any number for publications which use page numbering based on | ||||||||||||||||||
| 318 | volumes rather than issues. | ||||||||||||||||||
| 319 | |||||||||||||||||||
| 320 | =item B<$bool= $pg-E<gt>setpageid ($pageid)> | ||||||||||||||||||
| 321 | |||||||||||||||||||
| 322 | Set the page id string and fully reinitialize the object for the implied | ||||||||||||||||||
| 323 | field sizes of that id. Returns undef if the pageid is invalid. | ||||||||||||||||||
| 324 | |||||||||||||||||||
| 325 | For example, "009.10a" would set the pagenumber to 9, with a field size | ||||||||||||||||||
| 326 | of 3; the subpage number to 10 with a field size of 2; and the page alpha | ||||||||||||||||||
| 327 | to "a". Since increments only happen at the end, this page id would be | ||||||||||||||||||
| 328 | incrementable from "009.10a" to "009.10z" before an overflow would occur. | ||||||||||||||||||
| 329 | |||||||||||||||||||
| 330 | Typically such complex page numbers are only used for inserts and such; | ||||||||||||||||||
| 331 | more typical is a plain "009" which would be incrementable to "999" before | ||||||||||||||||||
| 332 | overflow occurred. | ||||||||||||||||||
| 333 | |||||||||||||||||||
| 334 | =item B<$bool = $pg-E<gt>SetPagenumber ($n);> | ||||||||||||||||||
| 335 | |||||||||||||||||||
| 336 | If a page number exists in the current pageid, set it to the | ||||||||||||||||||
| 337 | specified number $n. If $n is not numeric or is too large for | ||||||||||||||||||
| 338 | the page number field, it returns false. | ||||||||||||||||||
| 339 | |||||||||||||||||||
| 340 | This is not a commonly used operator. | ||||||||||||||||||
| 341 | |||||||||||||||||||
| 342 | =item B<$bool = $pg-E<gt>SetSubpagenumber ($n);> | ||||||||||||||||||
| 343 | |||||||||||||||||||
| 344 | If a subpage number exists in the current pageid, set it to the | ||||||||||||||||||
| 345 | specified number $n. If $n is not numeric or is too large for | ||||||||||||||||||
| 346 | the subpage number field, it returns false. | ||||||||||||||||||
| 347 | |||||||||||||||||||
| 348 | This is not a commonly used operator. | ||||||||||||||||||
| 349 | |||||||||||||||||||
| 350 | =back 4 | ||||||||||||||||||
| 351 | |||||||||||||||||||
| 352 | =head1 Private Class Method | ||||||||||||||||||
| 353 | |||||||||||||||||||
| 354 | None. | ||||||||||||||||||
| 355 | |||||||||||||||||||
| 356 | =head1 Private Instance Methods | ||||||||||||||||||
| 357 | |||||||||||||||||||
| 358 | None. | ||||||||||||||||||
| 359 | |||||||||||||||||||
| 360 | =head1 Errors and Warnings | ||||||||||||||||||
| 361 | |||||||||||||||||||
| 362 | None. | ||||||||||||||||||
| 363 | |||||||||||||||||||
| 364 | =head1 KNOWN BUGS | ||||||||||||||||||
| 365 | |||||||||||||||||||
| 366 | See TODO. | ||||||||||||||||||
| 367 | |||||||||||||||||||
| 368 | =head1 SEE ALSO | ||||||||||||||||||
| 369 | |||||||||||||||||||
| 370 | Document::PageId | ||||||||||||||||||
| 371 | |||||||||||||||||||
| 372 | =head1 AUTHOR | ||||||||||||||||||
| 373 | |||||||||||||||||||
| 374 | Dale Amon <amon@vnl.com> | ||||||||||||||||||
| 375 | |||||||||||||||||||
| 376 | =cut | ||||||||||||||||||
| 377 | |||||||||||||||||||
| 378 | #============================================================================= | ||||||||||||||||||
| 379 | # CVS HISTORY | ||||||||||||||||||
| 380 | #============================================================================= | ||||||||||||||||||
| 381 | # $Log: PageIterator.pm,v $ | ||||||||||||||||||
| 382 | # Revision 1.5 2008-08-28 23:26:17 amon | ||||||||||||||||||
| 383 | # perldoc section regularization. | ||||||||||||||||||
| 384 | # | ||||||||||||||||||
| 385 | # Revision 1.4 2008-08-13 21:04:32 amon | ||||||||||||||||||
| 386 | # Third phase of reformatting to current standard. | ||||||||||||||||||
| 387 | # | ||||||||||||||||||
| 388 | # Revision 1.3 2008-08-13 20:56:53 amon | ||||||||||||||||||
| 389 | # Second phase of reformatting to current standard. | ||||||||||||||||||
| 390 | # | ||||||||||||||||||
| 391 | # Revision 1.2 2008-08-13 14:50:02 amon | ||||||||||||||||||
| 392 | # First phase of reformatting to current standard. | ||||||||||||||||||
| 393 | # | ||||||||||||||||||
| 394 | # Revision 1.1.1.1 2006-07-05 12:14:23 amon | ||||||||||||||||||
| 395 | # Manages a Document directory | ||||||||||||||||||
| 396 | # | ||||||||||||||||||
| 397 | # 20050323 Dale Amon <amon@islandone.org> | ||||||||||||||||||
| 398 | # Added support for generalized increment to nextid. | ||||||||||||||||||
| 399 | # | ||||||||||||||||||
| 400 | # 20040904 Dale Amon <amon@islandone.org> | ||||||||||||||||||
| 401 | # Created. | ||||||||||||||||||
| 402 | # | ||||||||||||||||||
| 403 | 1 | 1; | |||||||||||||||||