Added more tests for conditionals. Need to fix linking in POD. - Intermediate commit!
[p5sagit/Excel-Template.git] / lib / Excel / Template / Element / Cell.pm
index 1f5e8d4..3e5bb3c 100755 (executable)
@@ -13,35 +13,29 @@ sub new
 {
     my $class = shift;
     my $self = $class->SUPER::new(@_);
-                                                                                
-    $self->{TXTOBJ} = Excel::Template::Factory->create('TEXTOBJECT');
-                                                                                
+
+    $self->{TXTOBJ} = Excel::Template::Factory->_create('TEXTOBJECT');
+
     return $self;
 }
 
-sub get_text
+sub _get_text
 {
     my $self = shift;
     my ($context) = @_;
-                                                                                
+
     my $txt = $context->get($self, 'TEXT');
     if (defined $txt)
     {
-        my $txt_obj = Excel::Template::Factory->create('TEXTOBJECT');
+        my $txt_obj = Excel::Template::Factory->_create('TEXTOBJECT');
         push @{$txt_obj->{STACK}}, $txt;
         $txt = $txt_obj->resolve($context);
     }
-    elsif ($self->{TXTOBJ})
-    {
-        $txt = $self->{TXTOBJ}->resolve($context)
-    }
     else
     {
-        $txt = $context->use_unicode
-            ? Unicode::String::utf8('')
-            : '';
+        $txt = $self->{TXTOBJ}->resolve($context)
     }
-                                                                                
+
     return $txt;
 }
 
@@ -81,10 +75,10 @@ sub render
 
     my ($row, $col) = map { $context->get($self, $_) } qw(ROW COL);
 
-    my $ref = uc $context->get( $self, 'REF' );
+    my $ref = $context->get( $self, 'REF' );
     if (defined $ref && length $ref)
     {
-        $context->add_reference( $ref, $row, $col );
+        $context->add_reference( uc( $ref ), $row, $col );
     }
 
     # Apply the cell width to the current column
@@ -96,11 +90,11 @@ sub render
         {
             $context->active_worksheet->set_column($col, $col, $width);
         }
-    }                                                                         
+    }
 
     $context->active_worksheet->$method(
         $row, $col,
-        $self->get_text($context),
+        $self->_get_text($context),
         $context->active_format,
     );
 
@@ -131,7 +125,7 @@ CELL
 
 =head1 INHERITANCE
 
-Excel::Template::Element
+L<ELEMENT|Excel::Template::Element>
 
 =head1 ATTRIBUTES
 
@@ -139,20 +133,15 @@ Excel::Template::Element
 
 =item * TEXT
 
-This is the text to write to the cell. This can either be text or a parameter
-with a dollar-sign in front of the parameter name.
+This is the text to write to the cell. This can either be text or a parameter with a dollar-sign in front of the parameter name.
 
 =item * COL
 
-Optionally, you can specify which column you want this cell to be in. It can be
-either a number (zero-based) or an offset. See Excel::Template for more info on
-offset-based numbering.
+Optionally, you can specify which column you want this cell to be in. It can be either a number (zero-based) or an offset. See L<Excel::Template> for more info on offset-based numbering.
 
 =item * REF
 
-Adds the current cell to the a list of cells that can be backreferenced.
-This is useful when the current cell needs to be referenced by a
-formula. See BACKREF and RANGE.
+Adds the current cell to the a list of cells that can be backreferenced.  This is useful when the current cell needs to be referenced by a formula. See L<BACKREF|Excel::Tepmlate::Element::Backref> and L<RANGE|Excel::Tepmlate::Container::Range>.
 
 =item * WIDTH
 
@@ -161,12 +150,9 @@ will win out.
 
 =item * TYPE
 
-This allows you to specify what write_*() method will be used. The default is to
-call write() and let S::WE make the right call. However, you may wish to
-override it. Excel::Template will not do any form of validation on what you
-provide. You are assumed to know what you're doing.
+This allows you to specify what write_*() method will be used. The default is to call write() and let L<Spreadsheet::WriteExcel> make the right call. However, you may wish to override it. L<Excel::Template> will not do any form of validation on what you provide. You are assumed to know what you're doing.
 
-The legal types are:
+The legal types (taken from L<Spreadsheet::WriteExcel>) are:
 
 =over 4
 
@@ -188,11 +174,11 @@ q.v. L<Spreadsheet::WriteExcel> for more info.
 
 =head1 CHILDREN
 
-Excel::Template::Element::Formula
+L<FORMULA|Excel::Template::Element::Formula>
 
 =head1 EFFECTS
 
-This will consume one column on the current row. 
+This will consume one column in the current row.
 
 =head1 DEPENDENCIES
 
@@ -206,13 +192,9 @@ None
   <cell text="$Param2"/>
   <cell>Some <var name="Param"> text here</cell>
 
-In the above example, four cells are written out. The first two have text hard-
-coded. The second two have variables. The third and fourth items have another
-thing that should be noted. If you have text where you want a variable in the
-middle, you have to use the latter form. Variables within parameters are the
-entire parameter's value.
+In the above example, four cells are written out. The first two have text hard-coded. The second two have variables. The third and fourth items have another thing that should be noted. If you have text where you want a variable in the middle, you have to use the latter form. Variables within parameters are the entire parameter's value.
 
-Please see Spreadsheet::WriteExcel for what constitutes a legal formula.
+Please see L<Spreadsheet::WriteExcel> for what constitutes a legal formula.
 
 =head1 AUTHOR
 
@@ -220,6 +202,6 @@ Rob Kinyon (rob.kinyon@gmail.com)
 
 =head1 SEE ALSO
 
-ROW, VAR, FORMULA
+L<ROW|Excel::Template::Container::Row>, L<VAR|Excel::Template::Element::Var>, L<FORMULA|Excel::Template::Element::Formula>
 
 =cut