r13925@rob-kinyons-powerbook58: rob | 2006-06-02 14:29:05 -0400
[p5sagit/Excel-Template.git] / lib / Excel / Template / Factory.pm
index c2321f9..ed87510 100644 (file)
@@ -2,11 +2,7 @@ package Excel::Template::Factory;
 
 use strict;
 
-BEGIN {
-    use vars qw(%Manifest %isBuildable);
-}
-
-%Manifest = (
+my %Manifest = (
 
 # These are the instantiable nodes
     'IF'        => 'Excel::Template::Container::Conditional',
@@ -16,11 +12,13 @@ BEGIN {
     'WORKBOOK'  => 'Excel::Template::Container::Workbook',
     'WORKSHEET' => 'Excel::Template::Container::Worksheet',
 
-    'BACKREF'   => 'Excel::Template::Element::Backref',
-    'CELL'      => 'Excel::Template::Element::Cell',
-    'FORMULA'   => 'Excel::Template::Element::Formula',
-    'RANGE'     => 'Excel::Template::Element::Range',
-    'VAR'       => 'Excel::Template::Element::Var',
+    'BACKREF'     => 'Excel::Template::Element::Backref',
+    'CELL'        => 'Excel::Template::Element::Cell',
+    'FORMULA'     => 'Excel::Template::Element::Formula',
+    'FREEZEPANES' => 'Excel::Template::Element::FreezePanes',
+    'IMAGE'       => 'Excel::Template::Element::Image',
+    'RANGE'       => 'Excel::Template::Element::Range',
+    'VAR'         => 'Excel::Template::Element::Var',
 
     'FORMAT'    => 'Excel::Template::Container::Format',
 
@@ -34,6 +32,8 @@ BEGIN {
     'SHADOW'    => 'Excel::Template::Container::Shadow',
     'STRIKEOUT' => 'Excel::Template::Container::Strikeout',
 
+    'KEEP_LEADING_ZEROS' => 'Excel::Template::Container::KeepLeadingZeros',
+
 # These are the helper objects
 # They are also in here to make E::T::Factory::isa() work.
     'CONTEXT'    => 'Excel::Template::Context',
@@ -46,41 +46,35 @@ BEGIN {
     'BASE'       => 'Excel::Template::Base',
 );
 
-%isBuildable = map { $_ => ~~1 } qw(
-    BOLD
-    CELL
-    FORMAT
-    FORMULA
-    IF
-    HIDDEN
-    ITALIC
-    LOCKED
-    OUTLINE
-    LOOP
-    BACKREF
-    RANGE
-    ROW
-    SCOPE
-    SHADOW
-    STRIKEOUT
-    VAR
-    WORKBOOK
-    WORKSHEET
+my %isBuildable = map { $_ => ~~1 } qw(
+    WORKBOOK WORKSHEET
+    FORMAT BOLD HIDDEN ITALIC LOCKED OUTLINE SHADOW STRIKEOUT
+    IF ROW LOOP SCOPE KEEP_LEADING_ZEROS
+    CELL FORMULA FREEZEPANES IMAGE
+    VAR BACKREF RANGE
 );
 
-sub _load_class
 {
-    my $self = shift;
-    my ($class) = @_;
+    my %Loaded;
+    sub _load_class
+    {
+        my $self = shift;
+        my ($class) = @_;
 
-    (my $filename = $class) =~ s!::!/!g;
-    eval {
-        require "$filename.pm";
-    }; if ($@) {
-        die "Cannot find or compile PM file for '$class' ($filename)\n";
-    }
+        unless ( exists $Loaded{$class} )
+        {
+            (my $filename = $class) =~ s!::!/!g;
+            eval {
+                require "$filename.pm";
+            }; if ($@) {
+                die "Cannot find or compile PM file for '$class' ($filename)\n";
+            }
+
+            $Loaded{$class} = ~~1;
+        }
 
-    return ~~1;
+        return ~~1;
+    }
 }
 
 {