releasing/cbrtools/perl/TableFormatter/Html.pm
author kelvzhu
Mon, 18 Oct 2010 16:16:46 +0800
changeset 655 3f65fd25dfd4
parent 602 3145852acc89
permissions -rw-r--r--
sync up SVN codes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
# TableFormatter/Html.pm
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
package TableFormatter::Html;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
use Utils;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
use TableFormatter;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
use vars qw/@ISA/;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
@ISA = qw(TableFormatter);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
sub PrintTable {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
  my $data = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
  my $hasHeader = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
  my $location = Utils::PrependEpocRoot("\\epoc32\\relinfo\\temp-table.html");
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
  open(HTML, ">$location") or die "Couldn't open \"$location\" for writing because $!";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
  print HTML <<ENDHEAD;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
<html>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
<head>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
  <title>Release tools command output</title>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
</head>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
<body>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
<table border>
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
ENDHEAD
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
  foreach my $row (@$data) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
    print HTML "  <tr>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
    my $celltype = "td";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
    if ($hasHeader) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
      $celltype = "th";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
      $hasHeader = 0; # only first row gets header cells
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
    foreach my $cell (@$row) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
      $cell =~ s/\&/\&amp;/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
      $cell =~ s/\</\&lt;/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
      $cell =~ s/\>/\&gt;/g;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
      print HTML "  <$celltype>$cell</$celltype>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
    print HTML "  </tr>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
  print HTML "</table>\n</body>\n</html>\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
  close HTML;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
  system ($location);
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
__END__
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
TableFormatter/Html.pm - Formats tables in HTML format
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
=head2 New
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
Creates a formatter.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
=head2 PrintTable 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
Prints the table. Two arguments: firstly, a 2D array of the data. Secondly, a Boolean specifying whether the first row is a header row.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
The name of this file (i.e. Html.pm) must be in that capitalisation, for IniData.pm to be able to find it.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
No actual bugs.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
 Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
=cut