1package PDF::FromHTML::Template::Container::Margin;
2
3use strict;
4
5BEGIN {
6    use vars qw(@ISA);
7    @ISA = qw(PDF::FromHTML::Template::Container::Always);
8
9    use PDF::FromHTML::Template::Container::Always;
10}
11
12# This is the common parent for <header> and <footer>. It exists so that
13# common code can be factored out. The code here is used for redefining
14# Context::should_render(). Normally, it restricts display only to
15# between the top and bottom margins. However, footers and headers are
16# supposed to write in those margins, so the children of this type of
17# node need to be allowed anywhere on the page.
18
19sub enter_scope
20{
21    my $self = shift;
22    my ($context) = @_;
23
24    $self->SUPER::enter_scope($context);
25
26    {
27        no strict 'refs';
28
29        my $class = ref $context;
30        $self->{OLD_CHECK_EOP} = \&{"${class}::check_end_of_page"};
31        *{"${class}::check_end_of_page"} = sub { return 1 };
32    }
33
34    return 1;
35}
36
37sub exit_scope
38{
39    my $self = shift;
40    my ($context) = @_;
41
42    {
43        no strict 'refs';
44
45        my $class = ref $context;
46        *{"${class}::check_end_of_page"} = delete $self->{OLD_CHECK_EOP};
47    }
48
49    @{$context}{qw/X Y/} = @{$self}{qw/OLD_X OLD_Y/};
50
51    return $self->SUPER::exit_scope($context);
52}
53
541;
55__END__
56
57=head1 NAME
58
59PDF::FromHTML::Template::Container::Margin
60
61=head1 PURPOSE
62
63A base class for HEADER and FOOTER
64
65=head1 NODE NAME
66
67None (This is not a rendering class)
68
69=head1 INHERITANCE
70
71PDF::FromHTML::Template::Container::Always
72
73=head1 ATTRIBUTES
74
75None
76
77=head1 CHILDREN
78
79PDF::FromHTML::Template::Container::Footer
80PDF::FromHTML::Template::Container::Header
81
82=head1 AFFECTS
83
84Nothing
85
86=head1 DEPENDENCIES
87
88None
89
90=head1 USAGE
91
92None
93
94=head1 AUTHOR
95
96Rob Kinyon (rkinyon@columbus.rr.com)
97
98=head1 SEE ALSO
99
100ALWAYS, HEADER, FOOTER
101
102=cut
103