Finished changes for v0.21 - including documentation fixes and a new renderer
[p5sagit/Excel-Template.git] / lib / Excel / Template / Context.pm
index 7a66225..d7218af 100644 (file)
@@ -15,7 +15,7 @@ use Excel::Template::Format;
 # represent an XML object. Rather, every container will use this object to
 # maintain the context for its children.
 
-my %isAbsolute = map { $_ => !!1 } qw(
+my %isAbsolute = map { $_ => ~~1 } qw(
     ROW
     COL
 );
@@ -29,14 +29,19 @@ sub new
     $self->{ACTIVE_FORMAT}    = Excel::Template::Format->blank_format($self);
     $self->{WORKSHEET_NAMES}  = undef;
 
-    UNIVERSAL::isa($self->{$_}, 'ARRAY') || ($self->{$_} = [])
-        for qw( STACK PARAM_MAP NAME_MAP );
+    for (qw( STACK PARAM_MAP NAME_MAP ))
+    {
+        next if defined $self->{$_} && UNIVERSAL::isa($self->{$_}, 'ARRAY');
+        $self->{$_} = [];
+    }
 
     $self->{$_} = 0 for keys %isAbsolute;
 
     return $self;
 }
 
+sub use_unicode { $_[0]->{UNICODE} && 1 }
+
 sub _find_param_in_map
 {
     my $self = shift;
@@ -50,7 +55,7 @@ sub _find_param_in_map
         next unless exists $map->{$param};
         $depth--, next if $depth;
 
-        $found = !!1;
+        $found = ~~1;
         $val = $map->{$param};
         last;
     }
@@ -144,7 +149,7 @@ sub enter_scope
         $self->{$key} = $self->resolve($obj, $key);
     }
 
-    return !!1;
+    return ~~1;
 }
 
 sub exit_scope
@@ -160,7 +165,7 @@ sub exit_scope
 
     pop @{$self->{STACK}};
 
-    return !!1;
+    return ~~1;
 }
 
 sub get
@@ -255,7 +260,7 @@ sub add_reference
 
     push @{$self->{REFERENCES}{$ref}}, [ $row, $col ];
 
-    return !!1;
+    return ~~1;
 }
 
 sub get_all_references
@@ -287,19 +292,55 @@ Excel::Template::Context
 
 =head1 PURPOSE
 
+This is a helper node that provides the global context for the nodes do their processing within. It provides attribute scoping, parameter resolution, and other very nice things.
+
+Documentation is provided for if you wish to subclass another node.
+
 =head1 NODE NAME
 
+None
+
 =head1 INHERITANCE
 
+None
+
 =head1 ATTRIBUTES
 
+None
+
 =head1 CHILDREN
 
+None
+
 =head1 AFFECTS
 
+Everything
+
 =head1 DEPENDENCIES
 
-=head1 USAGE
+None
+
+=head1 METHODS
+
+=head2 active_format
+
+=head2 active_worksheet
+
+=head2 add_reference
+
+=head2 get
+
+=head2 get_all_references
+
+=head2 get_last_reference
+
+=head2 named_param
+
+=head2 new_worksheet
+
+=head2 param
+
+=head2 use_unicode
 
 =head1 AUTHOR