From: Rob Kinyon Date: Thu, 4 Nov 2004 18:09:16 +0000 (+0000) Subject: Fixed email address to gmail address X-Git-Tag: v0.16~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c09684ff93144b943ad8786931bc51752e29bec3;p=p5sagit%2FExcel-Template.git Fixed email address to gmail address Added new format handling + POD --- diff --git a/lib/Excel/Template/Container.pm b/lib/Excel/Template/Container.pm index 97d6972..51ed783 100644 --- a/lib/Excel/Template/Container.pm +++ b/lib/Excel/Template/Container.pm @@ -140,7 +140,7 @@ Excel::Template::Container =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Bold.pm b/lib/Excel/Template/Container/Bold.pm index f4b345f..6e53931 100644 --- a/lib/Excel/Template/Container/Bold.pm +++ b/lib/Excel/Template/Container/Bold.pm @@ -66,7 +66,7 @@ elements) in a bold format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Conditional.pm b/lib/Excel/Template/Container/Conditional.pm index cd7ec75..89cf668 100644 --- a/lib/Excel/Template/Container/Conditional.pm +++ b/lib/Excel/Template/Container/Conditional.pm @@ -180,7 +180,7 @@ In the above example, the children will be executed if the value of __ODD__ =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Format.pm b/lib/Excel/Template/Container/Format.pm index 3574362..c272e15 100644 --- a/lib/Excel/Template/Container/Format.pm +++ b/lib/Excel/Template/Container/Format.pm @@ -27,6 +27,8 @@ sub render my $child_success = $self->iterate_over_children($context); $context->active_format($old_format); + + return $child_success; } 1; @@ -52,19 +54,55 @@ Excel::Template::Container =over 4 +Boolean attributes should be set to 1, 0, true, or false. + +Color values can be the color name or the color index. See http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.11/lib/Spreadsheet/WriteExcel.pm#COLOURS_IN_EXCEL + + +=item * align + +Set to either left, center, right, fill, or justify. Default is left. See also valign. + +=item * bg_color + +Set to a color value. Default is none. + =item * bold This will set bold to on or off, depending on the boolean value. -=item * hidden +=item * border -This will set whether the cell is hidden to on or off, depending on the boolean -value. (q.v. BOLD tag) +Set the border for all for edges of a cell. Also see bottom, top, left, and right. +Valid values are 0 - 7. -=item * italic +http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.11/lib/Spreadsheet/WriteExcel.pm#set_border() -This will set italic to on or off, depending on the boolean value. (q.v. ITALIC -tag) +=item * border_color + +Sets the color value for the border. See also border, top_color, bottom_color, left_color +and right_color. + +=item * bottom + +See border. + +=item * bottom_color + +See border_color + +=item * color + +This will set the color of the text, depending on color value. Default is black. + +=item * fg_color + +Set to a color value. This color will be used in foreground of some patterns. See color +to change the color of text. Also see bg_color and pattern. + +=item * font + +This will sent the font face. Default is Arial. =item * font_outline @@ -74,13 +112,87 @@ OUTLINE tag) =item * font_shadow This will set font_shadow to on or off, depending on the boolean value. (q.v. -SHADOW tag) +SHADOW tag). This only applies to Excel for Macintosh. =item * font_strikeout This will set font_strikeout to on or off, depending on the boolean value. (q.v. STRIKEOUT tag) +=item * hidden + +This will set whether the cell is hidden to on or off, depending on the boolean +value. + +=item * indent + +Set the indentation level for a cell. Positive integers are allowed. + +=item * italic + +This will set italic to on or off, depending on the boolean value. (q.v. ITALIC +tag) + +=item * left + +See border. + +=item * left_color + +See border_color. + +=item * num_format + +Set to the index of one of Excel's built-in number formats. See http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.11/lib/Spreadsheet/WriteExcel.pm#set_num_format() + +=item * pattern + +Set to an integer, 0 - 18. Sets the background fill pattern of a ell. Default is 1, solid. + +=item * right + +See border. + +=item * right_color + +See border color. + +=item * rotation + +Set the rotation of the text in a cell. The rotation can be any angle in the range -90 to 90 degrees. +The angle 270 is also supported. This indicates text where the letters run from top to bottom. + +=item * shrink + +A boolean value. If true, text will shrink to fit a cell. + +=item * size + +This will set the size of the font. Default is 10. Unless a row height is +specifically set, the row will grow taller as necessary. + +=item * text_justlast + +A boolean value to justify the last line. Only applies to Far Eastern versions of Excel. + +=item * text_wrap + +A boolean value. When set to true, text will wrap in a cell instead of crossing over +into empty cells. If the row height is not set, the row will grow taller to accomodate +the wrapping text. + +=item * top + +See border. + +=item * top_color + +See border_color + +=item * valign + +Set to top, vcenter, bottom, or vjustify. Default is vcenter. See also align. + =back 4 =head1 CHILDREN @@ -107,7 +219,7 @@ elements) in a bold format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Hidden.pm b/lib/Excel/Template/Container/Hidden.pm index 97f8f08..9b18489 100644 --- a/lib/Excel/Template/Container/Hidden.pm +++ b/lib/Excel/Template/Container/Hidden.pm @@ -66,7 +66,7 @@ elements) in a hidden format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Italic.pm b/lib/Excel/Template/Container/Italic.pm index f4f4e00..e74439b 100644 --- a/lib/Excel/Template/Container/Italic.pm +++ b/lib/Excel/Template/Container/Italic.pm @@ -66,7 +66,7 @@ elements) in a italic format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Locked.pm b/lib/Excel/Template/Container/Locked.pm index 55cab43..4ad52d9 100644 --- a/lib/Excel/Template/Container/Locked.pm +++ b/lib/Excel/Template/Container/Locked.pm @@ -66,7 +66,7 @@ elements) in a locked format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Loop.pm b/lib/Excel/Template/Container/Loop.pm index 574ca5f..16e0cbc 100644 --- a/lib/Excel/Template/Container/Loop.pm +++ b/lib/Excel/Template/Container/Loop.pm @@ -172,7 +172,7 @@ also hide outside variables with inner values, if you desire, just like Perl. =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Outline.pm b/lib/Excel/Template/Container/Outline.pm index a13447b..d2551e6 100644 --- a/lib/Excel/Template/Container/Outline.pm +++ b/lib/Excel/Template/Container/Outline.pm @@ -66,7 +66,7 @@ elements) in a outline format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Row.pm b/lib/Excel/Template/Container/Row.pm index cc5c3d1..fc0323f 100644 --- a/lib/Excel/Template/Container/Row.pm +++ b/lib/Excel/Template/Container/Row.pm @@ -72,7 +72,7 @@ Generally, you will have CELL and/or FORMULA tags within a ROW. =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Scope.pm b/lib/Excel/Template/Container/Scope.pm index 97c4124..700e720 100644 --- a/lib/Excel/Template/Container/Scope.pm +++ b/lib/Excel/Template/Container/Scope.pm @@ -59,7 +59,7 @@ all has the same set of parameter values, but don't have a common parent. =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Shadow.pm b/lib/Excel/Template/Container/Shadow.pm index 8597218..bd7502e 100644 --- a/lib/Excel/Template/Container/Shadow.pm +++ b/lib/Excel/Template/Container/Shadow.pm @@ -66,7 +66,7 @@ elements) in a shadow format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Strikeout.pm b/lib/Excel/Template/Container/Strikeout.pm index bc6b96b..3630831 100644 --- a/lib/Excel/Template/Container/Strikeout.pm +++ b/lib/Excel/Template/Container/Strikeout.pm @@ -66,7 +66,7 @@ elements) in a bold format. All other formatting will remain the same and the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Workbook.pm b/lib/Excel/Template/Container/Workbook.pm index 2defd37..cbc9f3b 100644 --- a/lib/Excel/Template/Container/Workbook.pm +++ b/lib/Excel/Template/Container/Workbook.pm @@ -53,7 +53,7 @@ None =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Container/Worksheet.pm b/lib/Excel/Template/Container/Worksheet.pm index c707779..4b96638 100644 --- a/lib/Excel/Template/Container/Worksheet.pm +++ b/lib/Excel/Template/Container/Worksheet.pm @@ -71,7 +71,7 @@ In the above example, the children will be executed in the context of the =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Context.pm b/lib/Excel/Template/Context.pm index 79c5415..ea5d8f3 100644 --- a/lib/Excel/Template/Context.pm +++ b/lib/Excel/Template/Context.pm @@ -255,7 +255,7 @@ Excel::Template::Context =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Element.pm b/lib/Excel/Template/Element.pm index 4ca8284..16d4d9c 100644 --- a/lib/Excel/Template/Element.pm +++ b/lib/Excel/Template/Element.pm @@ -34,7 +34,7 @@ Excel::Template::Element =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Element/Cell.pm_ b/lib/Excel/Template/Element/Cell.pm_ index 6db119c..f291c4b 100755 --- a/lib/Excel/Template/Element/Cell.pm_ +++ b/lib/Excel/Template/Element/Cell.pm_ @@ -138,7 +138,7 @@ capability to have a formula reference other nodes in the template dynamically. =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Element/Formula.pm b/lib/Excel/Template/Element/Formula.pm index 094326e..3de93b0 100644 --- a/lib/Excel/Template/Element/Formula.pm +++ b/lib/Excel/Template/Element/Formula.pm @@ -100,7 +100,7 @@ parameters are the entire parameter's value. =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Element/Var.pm b/lib/Excel/Template/Element/Var.pm index b4eac2f..74bfede 100644 --- a/lib/Excel/Template/Element/Var.pm +++ b/lib/Excel/Template/Element/Var.pm @@ -66,7 +66,7 @@ Where the actual name to be substituted is, itself, a parameter. =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Factory.pm b/lib/Excel/Template/Factory.pm index 6b806c9..1fc9cd3 100644 --- a/lib/Excel/Template/Factory.pm +++ b/lib/Excel/Template/Factory.pm @@ -160,7 +160,7 @@ Excel::Template::Factory =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/Format.pm b/lib/Excel/Template/Format.pm index dcd2a1f..77c0056 100644 --- a/lib/Excel/Template/Format.pm +++ b/lib/Excel/Template/Format.pm @@ -10,132 +10,134 @@ use strict; # formats and making new formats based on old ones. { - # %_Parameters is a hash with the key being the format name and the value - # being the index/length of the format in the bit-vector. - my %_Formats = ( - bold => [ 0, 1 ], - italic => [ 1, 1 ], - locked => [ 2, 1 ], - hidden => [ 3, 1 ], - font_outline => [ 4, 1 ], - font_shadow => [ 5, 1 ], - font_strikeout => [ 6, 1 ], + my %_Formats; + + sub _assign { $_Formats{$_[0]} = $_[1]; $_Formats{$_[1]} = $_[0] } +# my $key = shift; +# my $format = shift; +# $_Formats{$key} = $format; +# $_Formats{$format} = $key; +# } + + sub _retrieve_key { $_Formats{ $_[0] } } +# my $format = shift; +# return $_Formats{$format}; +# } + + *_retrieve_format = \&_retrieve_key; +# sub _retrieve_format { +# my $key = shift; +# return $_Formats{$key}; +# } +} + +{ + my @_boolean_formats = qw( + bold italic locked hidden font_outline font_shadow font_strikeout + text_wrap text_justlast shrink ); - - sub _params_to_vec + + my @_integer_formats = qw( + size num_format underline rotation indent pattern border + bottom top left right + ); + + my @_string_formats = qw( + font color align valign bg_color fg_color border_color + bottom_color top_color left_color right_color + ); + + sub _params_to_key { my %params = @_; $params{lc $_} = delete $params{$_} for keys %params; - - my $vec = ''; - vec( $vec, $_Formats{$_}[0], $_Formats{$_}[1] ) = ($params{$_} && 1) - for grep { exists $_Formats{$_} } - map { lc } keys %params; - - $vec; + + my @parts = ( + (map { !! $params{$_} } @_boolean_formats), + (map { $params{$_} ? $params{$_} + 0 : '' } @_integer_formats), + (map { $params{$_} || '' } @_string_formats), + ); + + return join( "\n", @parts ); } - - sub _vec_to_params + + sub _key_to_params { - my ($vec) = @_; - + my ($key) = @_; + + my @key_parts = split /\n/, $key; + + my @boolean_parts = splice @key_parts, 0, scalar( @_boolean_formats ); + my @integer_parts = splice @key_parts, 0, scalar( @_integer_formats ); + my @string_parts = splice @key_parts, 0, scalar( @_string_formats ); + my %params; - while (my ($k, $v) = each %_Formats) - { - next unless vec( $vec, $v->[0], $v->[1] ); - $params{$k} = 1; - } - - %params; - } -} + $params{ $_boolean_formats[$_] } = !!1 + for grep { $boolean_parts[$_] } 0 .. $#_boolean_formats; -{ - my %_Formats; + $params{ $_integer_formats[$_] } = $integer_parts[$_] + for grep { length $integer_parts[$_] } 0 .. $#_integer_formats; + + $params{ $_string_formats[$_] } = $string_parts[$_] + for grep { $string_parts[$_] } 0 .. $#_string_formats; - sub _assign { - $_Formats{$_[0]} = $_[1] unless exists $_Formats{$_[0]}; - $_Formats{$_[1]} = $_[0] unless exists $_Formats{$_[1]}; + return %params; } - sub _retrieve_vec { ref($_[0]) ? ($_Formats{$_[0]}) : ($_[0]); } - sub _retrieve_format { ref($_[0]) ? ($_[0]) : ($_Formats{$_[0]}); } -} + sub copy + { + shift; + my ($context, $old_fmt, %properties) = @_; -sub blank_format -{ - shift; - my ($context) = @_; + defined(my $key = _retrieve_key($old_fmt)) + || die "Internal Error: Cannot find key for format '$old_fmt'!\n"; + + my %params = _key_to_params($key); + PROPERTY: + while ( my ($prop, $value) = each %properties ) + { + $prop = lc $prop; + foreach (@_boolean_formats) + { + if ($prop eq $_) { + $params{$_} = ($value && $value !~ /false/i); + next PROPERTY; + } + } + foreach (@_integer_formats, @_string_formats) + { + if ($prop eq $_) { + $params{$_} = $value; + next PROPERTY; + } + } + } - my $blank_vec = _params_to_vec(); + my $new_key = _params_to_key(%params); - my $format = _retrieve_format($blank_vec); - return $format if $format; + my $format = _retrieve_format($new_key); + return $format if $format; - $format = $context->{XLS}->add_format; - _assign($blank_vec, $format); - $format; + $format = $context->{XLS}->add_format(%params); + _assign($new_key, $format); + return $format; + } } -sub copy +sub blank_format { shift; - my ($context, $old_format, %properties) = @_; - - defined(my $vec = _retrieve_vec($old_format)) - || die "Internal Error: Cannot find vector for format '$old_format'!\n"; - - my $new_vec = _params_to_vec(%properties); + my ($context) = @_; - $new_vec |= $vec; + my $blank_key = _params_to_key(); - my $format = _retrieve_format($new_vec); + my $format = _retrieve_format($blank_key); return $format if $format; - $format = $context->{XLS}->add_format(_vec_to_params($new_vec)); - _assign($new_vec, $format); - $format; + $format = $context->{XLS}->add_format; + _assign($blank_key, $format); + return $format; } 1; __END__ - -Category Description Property Method Name Implemented --------- ----------- -------- ----------- ----------- -Font Font type font set_font() - Font size size set_size() - Font color color set_color() - Bold bold set_bold() YES - Italic italic set_italic() YES - Underline underline set_underline() - Strikeout font_strikeout set_font_strikeout() YES - Super/Subscript font_script set_font_script() - Outline font_outline set_font_outline() YES - Shadow font_shadow set_font_shadow() YES - -Number Numeric format num_format set_num_format() - -Protection Lock cells locked set_locked() YES - Hide formulas hidden set_hidden() YES - -Alignment Horizontal align align set_align() - Vertical align valign set_align() - Rotation rotation set_rotation() - Text wrap text_wrap set_text_wrap() - Justify last text_justlast set_text_justlast() - Merge merge set_merge() - -Pattern Cell pattern pattern set_pattern() - Background color bg_color set_bg_color() - Foreground color fg_color set_fg_color() - -Border Cell border border set_border() - Bottom border bottom set_bottom() - Top border top set_top() - Left border left set_left() - Right border right set_right() - Border color border_color set_border_color() - Bottom color bottom_color set_bottom_color() - Top color top_color set_top_color() - Left color left_color set_left_color() - Right color right_color set_right_color() diff --git a/lib/Excel/Template/Iterator.pm b/lib/Excel/Template/Iterator.pm index bdd74e2..ccdc8b1 100644 --- a/lib/Excel/Template/Iterator.pm +++ b/lib/Excel/Template/Iterator.pm @@ -204,7 +204,7 @@ Excel::Template::Iterator =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO diff --git a/lib/Excel/Template/TextObject.pm_ b/lib/Excel/Template/TextObject.pm_ index 3597af5..db555d5 100755 --- a/lib/Excel/Template/TextObject.pm_ +++ b/lib/Excel/Template/TextObject.pm_ @@ -72,7 +72,7 @@ Excel::Template::TextObject =head1 AUTHOR -Rob Kinyon (rkinyon@columbus.rr.com) +Rob Kinyon (rob.kinyon@gmail.com) =head1 SEE ALSO