File Coverage

blib/lib/SMIL/Head.pm
Criterion Covered Total %
statement 40 70 57.1
branch 5 24 20.8
condition 2 9 22.2
subroutine 10 15 66.6
pod 0 10 0.0
total 57 128 44.5


line stmt bran cond sub pod time code
1             package SMIL::Head;
2              
3             my $debug = 0;
4              
5             $VERSION = "0.898";
6              
7 1     1   6 use SMIL::XMLContainer;
  1         2  
  1         35  
8 1     1   6 use SMIL::XMLTag;
  1         3  
  1         21  
9 1     1   891 use SMIL::Layout;
  1         3  
  1         47  
10 1     1   1000 use SMIL::Meta;
  1         4  
  1         33  
11 1     1   618 use SMIL::Transition;
  1         3  
  1         1494  
12              
13             @ISA = qw( SMIL::XMLContainer );
14              
15             my $layout = "layout";
16             my $metas = "metas";
17             my $transitions = 'transitions';
18             my $meta = "meta";
19              
20             sub init {
21 1     1 0 3 my $self = shift;
22 1         5 my %hash = @_;
23 1         9 $self->SUPER::init( "head" );
24 1 50 33     10 if( $hash{ 'height' } && $hash{ 'width' } ) {
25 1         5 $self->initLayout( @_ ) ;
26             # print "Setting layout" if $debug;
27             }
28 1 50       8 $self->initMetas( @_ ) if( $hash{ 'meta' } );
29             }
30              
31             sub getRootHeight {
32 0     0 0 0 my $self = shift;
33 0         0 my $ly = $self->getContentObjectByName( $layout );
34 0 0       0 return $ly ? $ly->getRootHeight() : 0;
35             }
36              
37             sub getRootWidth {
38 0     0 0 0 my $self = shift;
39 0         0 my $ly = $self->getContentObjectByName( $layout );
40 0 0       0 return $ly ? $ly->getRootWidth() : 0;
41             }
42              
43             sub initLayout {
44 1     1 0 2 my $self = shift;
45 1         14 $self->{$layout} = new SMIL::Layout( @_ );
46 1         10 $self->setTagContents( $layout => $self->{$layout} );
47             }
48              
49             sub getRegionAttribute
50             {
51 0     0 0 0 my $self = shift;
52 0         0 my $region_name = shift;
53 0         0 my $attr = shift;
54 0         0 my $return_value;
55             my $ly;
56 0         0 my $found_region;
57 0 0       0 if( $self ) {
58 0 0       0 if( $ly = $self->getContentObjectByName( $layout ) ) {
59            
60 0 0       0 if( $found_region = $ly->getRegion( $region_name ) ) {
61 0 0       0 if( $found_region ) {
62             # extract the attribute value, send it back
63 0         0 $return_value = $found_region->getAttributeValue( $attr );
64             }
65             else {
66             #print "No region found.\n";
67             }
68             }
69             else {
70             #print "No found region?";
71             }
72             }
73             else {
74             #print "No layout?";
75             }
76             }
77             else {
78             #print "No object.\n";
79             }
80 0         0 return $return_value;
81             }
82              
83             sub initMetas {
84 1     1 0 2 my $self = shift;
85 1         3 my %hash = @_;
86              
87 1 50       7 if( $hash{ $meta } ) {
88 1         4 $self->setMeta( $hash{ $meta } );
89             }
90             }
91              
92             sub setMeta {
93              
94 1     1 0 2 my $self = shift;
95 1         9 my $hash_ref = shift;
96 1         13 my $meta_tags_ref = $self->getContentObjectByName( $metas );
97              
98 1 50 33     5 if( !( $meta_tags_ref && @$meta_tags_ref ) ) {
99 1         3 $meta_tags_ref = [];
100             }
101            
102             # Extract the meta tags
103 1         5 foreach $name ( keys %$hash_ref ) {
104 3         17 my $meta = new SMIL::Meta( $name, $$hash_ref{ $name } );
105             # Now, push it on the stack of meta tags
106 3         83 push @$meta_tags_ref, $meta;
107             }
108            
109             # $self->{$metas} = $meta_tags_ref;
110 1         6 $self->setTagContents( $metas => $meta_tags_ref );
111             }
112              
113             sub addTransition {
114 0     0 0 0 my $self = shift;
115 0         0 my $transitions_ref = $self->getContentObjectByName( $transitions );
116 0 0 0     0 if( !( $transitions_ref && @$transitions_ref ) ) {
117 0         0 $transitions_ref = [];
118             }
119            
120 0         0 my $transition = new SMIL::Transition( @_ );
121 0         0 push @$transitions_ref, $transition;
122             # $self->{ $transitions } = $transitions_ref;
123 0         0 $self->setTagContents( $transitions => $transitions_ref );
124             }
125              
126             sub addRegion {
127 2     2 0 4 my $self = shift;
128 2 50       6 $self->{$layout} = new SMIL::Layout( @_ )
129             unless $self->getContentObjectByName( $layout );
130 2         12 $self->getContentObjectByName( $layout )->addRegion( @_ );
131             }
132              
133             my $switch = 'switch';
134             my $layouts = 'layouts';
135              
136             sub setSwitchedLayout {
137 0     0 0   my $self = shift;
138 0           my %hash = @_;
139            
140             # Extract the switch attribute
141 0           my $switch_attribute = $hash{ $switch };
142 0           my $thelayout = $hash{ $layouts };
143            
144 0           my $switch_obj = new SMIL::Switch( $switch_attribute, $thelayout );
145 0           $self->setTagContents( $layout => $switch_obj );
146             }