File: Margin.pm

package info (click to toggle)
libpdf-fromhtml-perl 0.34-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 576 kB
  • sloc: perl: 4,876; makefile: 15
file content (98 lines) | stat: -rw-r--r-- 1,782 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package PDF::FromHTML::Template::Container::Margin;

use strict;

BEGIN {
    use vars qw(@ISA);
    @ISA = qw(PDF::FromHTML::Template::Container::Always);

    use PDF::FromHTML::Template::Container::Always;
}

# This is the common parent for <header> and <footer>. It exists so that
# common code can be factored out. The code here is used for redefining
# Context::should_render(). Normally, it restricts display only to
# between the top and bottom margins. However, footers and headers are
# supposed to write in those margins, so the children of this type of
# node need to be allowed anywhere on the page.

sub enter_scope
{
    my $self = shift;
    my ($context) = @_;

    $self->SUPER::enter_scope($context);

    {
        no strict 'refs';

        my $class = ref $context;
        $self->{OLD_CHECK_EOP} = \&{"${class}::check_end_of_page"};
        *{"${class}::check_end_of_page"} = sub { return 1 };
    }

    return 1;
}

sub exit_scope
{
    my $self = shift;
    my ($context) = @_;

    {
        no strict 'refs';

        my $class = ref $context;
        *{"${class}::check_end_of_page"} = delete $self->{OLD_CHECK_EOP};
    }

    @{$context}{qw/X Y/} = @{$self}{qw/OLD_X OLD_Y/};

    return $self->SUPER::exit_scope($context);
}

1;
__END__

=head1 NAME

PDF::FromHTML::Template::Container::Margin - Base class for HEADER and FOOTER

=head1 NODE NAME

None (This is not a rendering class)

=head1 INHERITANCE

PDF::FromHTML::Template::Container::Always

=head1 ATTRIBUTES

None

=head1 CHILDREN

PDF::FromHTML::Template::Container::Footer
PDF::FromHTML::Template::Container::Header

=head1 AFFECTS

Nothing

=head1 DEPENDENCIES

None

=head1 USAGE

None

=head1 AUTHOR

Rob Kinyon (rkinyon@columbus.rr.com)

=head1 SEE ALSO

ALWAYS, HEADER, FOOTER

=cut