This file is indexed.

/usr/share/perl5/GD/Graph/pie3d.pm is in libgd-graph3d-perl 0.63-8.

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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
############################################################
#
# Module: GD::Graph::pie3d
#
# Description: 
# This is merely a wrapper around GD::Graph::pie that forces 
# the 3d option for pie charts.
#
# Created: 2000.Jan.19 by Jeremy Wadsack for Wadsack-Allen Digital Group
# 	Copyright (C) 2000,2001 Wadsack-Allen. All rights reserved.
############################################################
# Date      Modification                               Author
# ----------------------------------------------------------
# 2000APR18 Modified to be compatible w/ GD::Graph 1.30   JW
# 2000APR24 Set default slice label color to black        JW
# 2001Feb16 Added support for a legend                    JW
############################################################
package GD::Graph::pie3d;

use strict;
use GD;
use GD::Graph;
use GD::Graph::pie;
use GD::Graph::utils qw(:all);
use Carp;

@GD::Graph::pie3d::ISA = qw( GD::Graph::pie );
$GD::Graph::pie3d::VERSION = '0.63';

my %Defaults = (
	'3d'         => 1,
	axislabelclr => 'black',	# values on slices. black because default colors use dblue

	# Size of the legend markers
	legend_marker_height	=> 8,
	legend_marker_width	=> 12,
	legend_spacing			=> 4,
	legend_placement		=> 'BC',		# '[BR][LCR]'
	lg_cols					=> undef,
	legend_frame_margin	=> 4,
	legend_frame_size		=> undef,
);

# PRIVATE
# Have to include because this is a different %Defaults hash
sub _has_default { 
	my $self = shift;
	my $attr = shift || return;
	exists $Defaults{$attr} || $self->SUPER::_has_default($attr);
}

sub initialise {
	my $self = shift;
	my $rc = $self->SUPER::initialise();

	while( my($key, $val) = each %Defaults ) { 
		$self->{$key} = $val;
	} # end while

	$self->set_legend_font(GD::gdTinyFont);
	return $rc;
} # end initialise

# Add lengend calc and draw code
sub plot
{
	my $self = shift;
	my $data = shift;

	$self->check_data($data) 		or return;
	$self->init_graph() 			or return;
	$self->setup_text()				or return;
	$self->setup_legend();
	$self->setup_coords() 			or return;
	$self->{b_margin} += 4 if $self->{label};		# Kludge for descenders
	$self->draw_text()				or return;
	$self->draw_pie()				or return;
	$self->draw_data()				or return;
	$self->draw_legend();

	return $self->{graph};
}

# Added legend stuff
sub setup_text 
{
	my $self = shift;

	my $rc = $self->SUPER::setup_text( @_ );
	
	$self->{gdta_legend}->set(colour => $self->{legendci});
	$self->{gdta_legend}->set_align('top', 'left');
	$self->{lgfh} = $self->{gdta_legend}->get('height');
	
	return $rc
} # end setup_text

# Inherit everything else from GD::Graph::pie


# Legend Support. Added 16.Feb.2001 - JW/WADG

sub set_legend # List of legend keys
{
	my $self = shift;
	$self->{legend} = [@_];
}

sub set_legend_font # (font name)
{
	my $self = shift;
	$self->_set_font('gdta_legend', @_);
}



#
# Legend
#
sub setup_legend
{
	my $self = shift;

	return unless defined $self->{legend};

	my $maxlen = 0;
	my $num = 0;

	# Save some variables
	$self->{r_margin_abs} = $self->{r_margin};
	$self->{b_margin_abs} = $self->{b_margin};

	foreach my $legend (@{$self->{legend}})
	{
		if (defined($legend) and $legend ne "")
		{
			$self->{gdta_legend}->set_text($legend);
			my $len = $self->{gdta_legend}->get('width');
			$maxlen = ($maxlen > $len) ? $maxlen : $len;
			$num++;
		}
		# Legend for Pie goes over first set, and all points
		last if $num >= $self->{_data}->num_points;
	}

	$self->{lg_num} = $num;

	# calculate the height and width of each element
	my $legend_height = _max($self->{lgfh}, $self->{legend_marker_height});

	$self->{lg_el_width} = 
		$maxlen + $self->{legend_marker_width} + 3 * $self->{legend_spacing};
	$self->{lg_el_height} = $legend_height + 2 * $self->{legend_spacing};

	my ($lg_pos, $lg_align) = split(//, $self->{legend_placement});

	if ($lg_pos eq 'R')
	{
		# Always work in one column
		$self->{lg_cols} = 1;
		$self->{lg_rows} = $num;

		# Just for completeness, might use this in later versions
		$self->{lg_x_size} = $self->{lg_cols} * $self->{lg_el_width};
		$self->{lg_y_size} = $self->{lg_rows} * $self->{lg_el_height};

		# Adjust the right margin for the rest of the graph
		$self->{r_margin} += $self->{lg_x_size};

		# Adjust for frame if defined
		if( $self->{legend_frame_size} ) {
			$self->{r_margin} += 2 * ($self->{legend_frame_margin} + $self->{legend_frame_size});
		} # end if;

		# Set the x starting point
		$self->{lg_xs} = $self->{width} - $self->{r_margin};

		# Set the y starting point, depending on alignment
		if ($lg_align eq 'T')
		{
			$self->{lg_ys} = $self->{t_margin};
		}
		elsif ($lg_align eq 'B')
		{
			$self->{lg_ys} = $self->{height} - $self->{b_margin} - 
				$self->{lg_y_size};
		}
		else # default 'C'
		{
			my $height = $self->{height} - $self->{t_margin} - 
				$self->{b_margin};

			$self->{lg_ys} = 
				int($self->{t_margin} + $height/2 - $self->{lg_y_size}/2) ;
		}
	}
	else # 'B' is the default
	{
		# What width can we use
		my $width = $self->{width} - $self->{l_margin} - $self->{r_margin};

		(!defined($self->{lg_cols})) and 
			$self->{lg_cols} = int($width/$self->{lg_el_width});
		
		$self->{lg_cols} = _min($self->{lg_cols}, $num);

		$self->{lg_rows} = 
			int($num / $self->{lg_cols}) + (($num % $self->{lg_cols}) ? 1 : 0);

		$self->{lg_x_size} = $self->{lg_cols} * $self->{lg_el_width};
		$self->{lg_y_size} = $self->{lg_rows} * $self->{lg_el_height};

		# Adjust the bottom margin for the rest of the graph
		$self->{b_margin} += $self->{lg_y_size};
		# Adjust for frame if defined
		if( $self->{legend_frame_size} ) {
			$self->{b_margin} += 2 * ($self->{legend_frame_margin} + $self->{legend_frame_size});
		} # end if;

		# Set the y starting point
		$self->{lg_ys} = $self->{height} - $self->{b_margin};

		# Set the x starting point, depending on alignment
		if ($lg_align eq 'R')
		{
			$self->{lg_xs} = $self->{width} - $self->{r_margin} - 
				$self->{lg_x_size};
		}
		elsif ($lg_align eq 'L')
		{
			$self->{lg_xs} = $self->{l_margin};
		}
		else # default 'C'
		{
			$self->{lg_xs} =  
				int($self->{l_margin} + $width/2 - $self->{lg_x_size}/2);
		}
	}
}

sub draw_legend
{
	my $self = shift;

	return unless defined $self->{legend};

	my $xl = $self->{lg_xs} + $self->{legend_spacing};
	my $y  = $self->{lg_ys} + $self->{legend_spacing} - 1;

	# If there's a frame, offset by the size and margin
	$xl += $self->{legend_frame_margin} + $self->{legend_frame_size} if $self->{legend_frame_size};
	$y += $self->{legend_frame_margin} + $self->{legend_frame_size} if $self->{legend_frame_size};

	my $i = 0;
	my $row = 1;
	my $x = $xl;	# start position of current element

	foreach my $legend (@{$self->{legend}})
	{
		$i++;
		# Legend for Pie goes over first set, and all points
		last if $i > $self->{_data}->num_points;

		my $xe = $x;	# position within an element

		next unless defined($legend) && $legend ne "";

		$self->draw_legend_marker($i, $xe, $y);

		$xe += $self->{legend_marker_width} + $self->{legend_spacing};
		my $ys = int($y + $self->{lg_el_height}/2 - $self->{lgfh}/2);

		$self->{gdta_legend}->set_text($legend);
		$self->{gdta_legend}->draw($xe, $ys);

		$x += $self->{lg_el_width};

		if (++$row > $self->{lg_cols})
		{
			$row = 1;
			$y += $self->{lg_el_height};
			$x = $xl;
		}
	}
	
	# If there's a frame, draw it now
	if( $self->{legend_frame_size} ) {
		$x = $self->{lg_xs} + $self->{legend_spacing};
		$y = $self->{lg_ys} + $self->{legend_spacing} - 1;
		
		for $i ( 0 .. $self->{legend_frame_size} - 1 ) {
			$self->{graph}->rectangle(
				$x + $i,
				$y + $i, 
				$x + $self->{lg_x_size} + 2 * $self->{legend_frame_margin} - $i - 1,
				$y + $self->{lg_y_size} + 2 * $self->{legend_frame_margin} - $i - 1,
				$self->{acci},
			);
		} # end for
	} # end if
	
}

sub draw_legend_marker # data_set_number, x, y
{
	my $s = shift;
	my $n = shift;
	my $x = shift;
	my $y = shift;

	my $g = $s->{graph};

	my $ci = $s->set_clr($s->pick_data_clr($n));

	$y += int($s->{lg_el_height}/2 - $s->{legend_marker_height}/2);

	$g->filledRectangle(
		$x, $y, 
		$x + $s->{legend_marker_width}, $y + $s->{legend_marker_height},
		$ci
	);

	$g->rectangle(
		$x, $y, 
		$x + $s->{legend_marker_width}, $y + $s->{legend_marker_height},
		$s->{acci}
	);
}


1;