File: OLE.pm

package info (click to toggle)
libhtml-display-perl 0.40-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 244 kB
  • sloc: perl: 1,166; makefile: 2
file content (81 lines) | stat: -rw-r--r-- 1,525 bytes parent folder | download | duplicates (4)
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
package HTML::Display::Win32::OLE;
use strict;
use parent 'HTML::Display::Common';
use vars qw($VERSION);
$VERSION='0.40';

=head1 NAME

HTML::Display::Win32::OLE - use an OLE object to display HTML

=head1 SYNOPSIS

=for example begin

  package HTML::Display::Win32::OleControl;
  use parent 'HTML::Display::Win32::OLE';

  sub new {
    my $class = shift;
    $class->SUPER::new( app_string => "FooBrowser.Application", @_ );
    $self;
  };

  my $browser = HTML::Display->new(
    class => 'HTML::Display::Win32::OleControl',
  );
  $browser->display("<html><body><h1>Hello world!</h1></body></html>");

=for example end

=cut

sub new {
  my ($class) = shift;
  my %args = @_;

  my $self = $class->SUPER::new( %args );
  $self;
};

=head2 setup

C<setup> is a method you can override to provide initial
setup of your OLE control. It is called after the control
is instantiated for the first time.

=cut

sub setup {};

=head2 control

This initializes the OLE control and returns it. Only one
control is initialized for each object instance. You don't need
to store it separately.

=cut

sub control {
  my $self = shift;
  unless ($self->{control}) {
    eval "use Win32::OLE";
    die $@ if $@;
    my $control = Win32::OLE->CreateObject($self->{app_string});
    $self->{control} = $control;
    $self->setup($control);
  };
  $self->{control};
};

=head1 AUTHOR

Copyright (c) 2004-2007 Max Maischein C<< <corion@cpan.org> >>

=head1 LICENSE

This module is released under the same terms as Perl itself.

=cut

1;