File: smpaddF.pl

package info (click to toggle)
libole-storage-lite-perl 0.14-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 148 kB
  • ctags: 66
  • sloc: perl: 1,334; makefile: 41
file content (105 lines) | stat: -rw-r--r-- 2,936 bytes parent folder | download | duplicates (7)
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
# OLE::Storage_Lite Sample
# Name : smpadd.pl
#  by Kawai, Takanori (Hippo2000) 2000.12.21, 2001.1.4, 2001.3.1
#=================================================================
use strict;
use OLE::Storage_Lite;

#0. prepare test file
	open OUT, ">test.tmp";
	print OUT "1234567890";
	close OUT;

#1. Normal
{
	my $oOl = OLE::Storage_Lite->new('test.xls');
	my $oPps = $oOl->getPpsTree(1);
	die( "test.xls must be a OLE file") unless($oPps);

	my $oF = OLE::Storage_Lite::PPS::File->new(
			    OLE::Storage_Lite::Asc2Ucs('Add Strting Len 5'), 
			'12345');
	my $oF2 = OLE::Storage_Lite::PPS::File->new(
			    OLE::Storage_Lite::Asc2Ucs('Length 0'), 
			'');
	push @{$oPps->{Child}}, $oF;
	push @{$oPps->{Child}}, $oF2;
	$oPps->save('add_test.xls');
}
#2. Tempfile
{
	my $oOl = OLE::Storage_Lite->new('test.xls');
	my $oPps = $oOl->getPpsTree(1);
	die( "test.xls must be a OLE file") unless($oPps);

	my $oF = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Add tempfile Len 6'), 
			);
	my $oF2 = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Length 0'), 
			'');
	$oF->append('123456');
	push @{$oPps->{Child}}, $oF;
	push @{$oPps->{Child}}, $oF2;
	$oPps->save('add_tmp.xls');
}
#3. Filename
{
	my $oOl = OLE::Storage_Lite->new('test.xls');
	my $oPps = $oOl->getPpsTree(1);

	die( "test.xls must be a OLE file") unless($oPps);
	my $oF = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Add filename Len b'), 
			'test.tmp');

	my $oF2 = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Length 0'), 
			'');
	$oF->append('a');
	push @{$oPps->{Child}}, $oF;
	push @{$oPps->{Child}}, $oF2;
	$oPps->save('add_name.xls');
}
#4. IO::File
{
	my $oOl = OLE::Storage_Lite->new('test.xls');
	my $oPps = $oOl->getPpsTree(1);
	die( "test.xls must be a OLE file") unless($oPps);

	my $oFile = new IO::File;
	$oFile->open('test.tmp', 'r+');

	my $oF = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Add IO::File Len c'), 
			$oFile);

	my $oF2 = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Length 0'), 
			'');
	$oF->append('b');
	push @{$oPps->{Child}}, $oF;
	push @{$oPps->{Child}}, $oF2;
	$oPps->save('add_io.xls');
}
#4.1 IO::File(r)
{
	my $oOl = OLE::Storage_Lite->new('test.xls');
	my $oPps = $oOl->getPpsTree(1);
	die( "test.xls must be a OLE file") unless($oPps);

	my $oFile = new IO::File;
	$oFile->open('test.tmp', 'r');

	my $oF = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Add IO2::File Len c'), 
			$oFile);

	my $oF2 = OLE::Storage_Lite::PPS::File->newFile(
			    OLE::Storage_Lite::Asc2Ucs('Length 0'), 
			'');
	$oF->append('b'); #No Work
	push @{$oPps->{Child}}, $oF;
	push @{$oPps->{Child}}, $oF2;
	$oPps->save('add_io2.xls');
}