This file is indexed.

/usr/share/perl5/Spreadsheet/Wright/XHTML.pm is in libspreadsheet-wright-perl 0.105-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package Spreadsheet::Wright::XHTML;

use 5.010;
use strict;
use warnings;
no warnings qw( uninitialized numeric );

BEGIN {
	$Spreadsheet::Wright::XHTML::VERSION   = '0.105';
	$Spreadsheet::Wright::XHTML::AUTHORITY = 'cpan:TOBYINK';
}

use Carp;
use XML::LibXML;

use parent qw(Spreadsheet::Wright);
use constant XHTML_NS => 'http://www.w3.org/1999/xhtml';

sub new
{
	my ($class, %args) = @_;
	
	$args{'title'} //= 'Data';
	
	my $self = bless { 'options' => \%args }, $class;
	
	$self->{'_FILENAME'} = $args{'file'} // $args{'filename'}
		or croak "Need filename.";

	return $self;
}

sub _prepare
{
	my $self = shift;
	
	return $self if $self->{'document'};
	
	$self->{'document'} = XML::LibXML->createDocument;
	$self->{'document'}->setDocumentElement(
		$self->{'document'}->createElementNS(XHTML_NS,'html')
		);
	$self->{'document'}->documentElement
		->addNewChild(XHTML_NS, 'head')
		->addNewChild(XHTML_NS, 'title')
		->appendText($self->{'options'}->{'title'});
	$self->{'body'} = $self->{'document'}->documentElement
		->addNewChild(XHTML_NS, 'body');
	$self->{'body'}->addNewChild(XHTML_NS, 'h1')
		->appendText($self->{'options'}->{'title'});
	$self->addsheet($self->{'options'}->{'sheet'});
	
	return $self;
}

sub addsheet
{
	my ($self, $caption) = @_;

	$self->{'worksheet'} = $self->{'body'}->addNewChild(XHTML_NS, 'table');

	if (defined $caption)
	{
		$self->{'worksheet'}->addNewChild(XHTML_NS, 'caption')->appendText($caption);
	}

	$self->{'tbody'}     = $self->{'worksheet'}->addNewChild(XHTML_NS, 'tbody');

	return $self;
}

sub _add_prepared_row
{
	my $self = shift;

	my $tr   = $self->{'tbody'}->addNewChild(XHTML_NS, 'tr');
	
	foreach my $cell (@_)
	{
		my $td;
		if ($cell->{'header'})
		{
			$td = $tr->addNewChild(XHTML_NS, 'th');
		}
		else
		{
			$td = $tr->addNewChild(XHTML_NS, 'td');
		}
		
		my $content = $cell->{'content'};
		$content = sprintf($cell->{'sprintf'}, $content)
			if defined $cell->{'sprintf'};
		
		$td->appendText($content);
		
		if (defined $cell->{'style'} && defined $self->{'options'}->{'styles'}->{ $cell->{'style'} })
		{
			while (my ($k, $v) = each %{ $self->{'options'}->{'styles'}->{ $cell->{'style'} } })
			{
				$cell->{$k} = $v
					unless defined $cell->{$k};
			}
		}
		
		my %styles;
		if ($cell->{'font_weight'} eq 'bold')
		{
			$styles{'font-weight'} = 'bold';
		}
		if ($cell->{'font_style'} eq 'italic')
		{
			$styles{'font-style'} = 'italics';
		}
		if ($cell->{'font_decoration'} =~ m'underline')
		{
			$styles{'text-decoration'} = 'underline';
		}
		if ($cell->{'font_decoration'} =~ m'strikeout')
		{
			$styles{'text-decoration'} = 'line-through';
		}
		if (defined $cell->{'font_color'})
		{
			$styles{'color'} = $cell->{'font_color'};
		}
		if (defined $cell->{'font_face'})
		{
			$styles{'font-family'}=sprintf('"%s"', $cell->{'font_face'});
		}
		if (defined $cell->{'font_size'})
		{
			$styles{'font-size'}=$cell->{'font_size'}.'pt';
		}
		if (defined $cell->{'align'})
		{
			$styles{'text-align'}=$cell->{'align'};
		}
		if (defined $cell->{'valign'})
		{
			$styles{'valign'}=$cell->{'valign'};
		}

		my $style;
		while (my ($k, $v) = each %styles)
		{
			$style .= sprintf('%s: %s; ', $k, $v);
		}
		$style =~ s/; $//;
		
		$td->setAttribute('style', $style) if length $style;
	}
	
	return $self;
}

sub close
{
	my $self=shift;
	return if $self->{'_CLOSED'};
	$self->{'_FH'}->print( $self->_make_output );
	$self->{'_FH'}->close;
	$self->{'_CLOSED'}=1;
	return $self;
}

sub _make_output
{
	my $self = shift;
	return $self->{'document'}->toString;
}

1;