line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::IE::SlideShow;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
43241
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
16932
|
use Win32::OLE;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Win32::API;
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.03';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new {
|
11
|
|
|
|
|
|
|
my ($class, %options) = @_;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $invoked;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# IE requires special treatment to get an active object.
|
16
|
|
|
|
|
|
|
# Simple GetActiveObject('...') doesn't work.
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $shell = Win32::OLE->new('Shell.Application')
|
19
|
|
|
|
|
|
|
or die Win32::OLE->LastError;
|
20
|
|
|
|
|
|
|
my $ie;
|
21
|
|
|
|
|
|
|
if ( $shell->Windows->Count ) {
|
22
|
|
|
|
|
|
|
$ie = $shell->Windows->Item(0);
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
else {
|
25
|
|
|
|
|
|
|
$ie = Win32::OLE->new('InternetExplorer.Application')
|
26
|
|
|
|
|
|
|
or die Win32::OLE->LastError;
|
27
|
|
|
|
|
|
|
$invoked = 1;
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# $ie->{Visible} = 0;
|
31
|
|
|
|
|
|
|
my @keys = qw( FullScreen TheaterMode Top Left Height Width );
|
32
|
|
|
|
|
|
|
foreach my $key ( @keys ) {
|
33
|
|
|
|
|
|
|
$ie->{$key} = $options{$key} if exists $options{$key};
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
$ie->Navigate('about:blank');
|
36
|
|
|
|
|
|
|
if ( $options{TopMost} ) {
|
37
|
|
|
|
|
|
|
my $wndTopMost = -1;
|
38
|
|
|
|
|
|
|
my $SWP_NOMOVE = 2;
|
39
|
|
|
|
|
|
|
my $SWP_NOSIZE = 1;
|
40
|
|
|
|
|
|
|
my $SetWindowPos = Win32::API->new('user32', 'SetWindowPos', 'NNNNNNN', 'N');
|
41
|
|
|
|
|
|
|
$SetWindowPos->Call( $ie->{HWND}, $wndTopMost, 0, 0, 0, 0, $SWP_NOMOVE|$SWP_NOSIZE );
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
$ie->{Visible} = 1;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $self = bless { ie => $ie, invoked => $invoked }, $class;
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$self;
|
48
|
|
|
|
|
|
|
}
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub set {
|
51
|
|
|
|
|
|
|
my ($self, @slides) = @_;
|
52
|
|
|
|
|
|
|
$self->{slides} = \@slides;
|
53
|
|
|
|
|
|
|
$self->{total} = scalar @slides;
|
54
|
|
|
|
|
|
|
$self->{index} = 0;
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub set_callback {
|
58
|
|
|
|
|
|
|
my ($self, $callback) = @_;
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->{converter} = $callback;
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub total { shift->{total} }
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub start { shift->goto(1) }
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub goto {
|
68
|
|
|
|
|
|
|
my ($self, $page) = @_;
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# "page" (which viewers may see) should start from 1,
|
71
|
|
|
|
|
|
|
# but "index" (used internally) should start from 0.
|
72
|
|
|
|
|
|
|
$self->{index} = $page - 1;
|
73
|
|
|
|
|
|
|
$self->next;
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub next {
|
77
|
|
|
|
|
|
|
my $self = shift;
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $slide = $self->{slides}->[$self->{index}++];
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
if ( $self->{converter} ) {
|
82
|
|
|
|
|
|
|
$slide = $self->{converter}->( $slide );
|
83
|
|
|
|
|
|
|
}
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $document = $self->{ie}->{Document};
|
86
|
|
|
|
|
|
|
$document->open( "text/html", "replace" );
|
87
|
|
|
|
|
|
|
$document->write( $slide );
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# actually this "index" points to the next slide,
|
90
|
|
|
|
|
|
|
# however, "index" + 1 happens to be the same as the "page".
|
91
|
|
|
|
|
|
|
return $self->{index};
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub has_next {
|
95
|
|
|
|
|
|
|
my $self = shift;
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return $self->{index} < $self->{total} ? 1 : 0;
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub back {
|
101
|
|
|
|
|
|
|
my $self = shift;
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
if ( $self->page > 1 ) {
|
104
|
|
|
|
|
|
|
$self->goto( $self->page - 1 );
|
105
|
|
|
|
|
|
|
}
|
106
|
|
|
|
|
|
|
}
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub page {
|
109
|
|
|
|
|
|
|
my $self = shift;
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
return ( $self->{index} + 1 );
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub quit {
|
115
|
|
|
|
|
|
|
my $self = shift;
|
116
|
|
|
|
|
|
|
if ( $self->{ie} && $self->{invoked} ) {
|
117
|
|
|
|
|
|
|
$self->{ie}->Quit;
|
118
|
|
|
|
|
|
|
delete $self->{ie};
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
}
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub DESTROY { shift->quit }
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1;
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__
|