line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenOffice::OOSheets; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
48630
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
345
|
use XML::Parser; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#use Data::Dumper; |
6
|
|
|
|
|
|
|
#use utf8; |
7
|
|
|
|
|
|
|
our $VERSION = '0.70'; |
8
|
|
|
|
|
|
|
#========= |
9
|
|
|
|
|
|
|
#use: |
10
|
|
|
|
|
|
|
#GetData( text=><>,ref=>[ |
11
|
|
|
|
|
|
|
# { |
12
|
|
|
|
|
|
|
# table=>'sheet1', |
13
|
|
|
|
|
|
|
# cells=>['B2','AA2','A1','E6','B4','C10','C11'] |
14
|
|
|
|
|
|
|
# } |
15
|
|
|
|
|
|
|
# ] |
16
|
|
|
|
|
|
|
# ) |
17
|
|
|
|
|
|
|
#========== |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub GetData { |
20
|
|
|
|
|
|
|
my (%arg)=@_; |
21
|
|
|
|
|
|
|
our ($ref,$text)=@arg{qw/ref text/}; |
22
|
|
|
|
|
|
|
#Levels,Flags,Variabels |
23
|
|
|
|
|
|
|
our $number; |
24
|
|
|
|
|
|
|
our $curr_rec; |
25
|
|
|
|
|
|
|
our %sonar_cells; |
26
|
|
|
|
|
|
|
our ($c_row,$c_cell); |
27
|
|
|
|
|
|
|
our %current; |
28
|
|
|
|
|
|
|
our $par_text=0; |
29
|
|
|
|
|
|
|
our %res; |
30
|
|
|
|
|
|
|
our $n=0; |
31
|
|
|
|
|
|
|
our %map; |
32
|
|
|
|
|
|
|
map {$map{$_}=++$n} ('A'..'Z'); |
33
|
|
|
|
|
|
|
our %enumeration_map; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub A1_2_11 { |
36
|
|
|
|
|
|
|
my $addr=shift; |
37
|
|
|
|
|
|
|
my ($X,$Y)=$addr=~m/(\D+)(\d+)/; |
38
|
|
|
|
|
|
|
my @sym=split("",$X); |
39
|
|
|
|
|
|
|
my $cell; |
40
|
|
|
|
|
|
|
while(my $symbol = shift(@sym)){ |
41
|
|
|
|
|
|
|
my $sym_cod = $map{$symbol}; |
42
|
|
|
|
|
|
|
$cell += $sym_cod * (26 ** scalar(@sym)); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
my $res="$Y:$cell"; |
45
|
|
|
|
|
|
|
$enumeration_map{$res}=$addr; |
46
|
|
|
|
|
|
|
return $res; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _11_2_A1 { |
50
|
|
|
|
|
|
|
my $addr=shift; |
51
|
|
|
|
|
|
|
return $enumeration_map{$addr}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub handle_start { |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my ($ref_Ex,$name,%attr)=@_; |
58
|
|
|
|
|
|
|
next unless $name; |
59
|
|
|
|
|
|
|
for ($name) { |
60
|
|
|
|
|
|
|
/table:table$/ && ( |
61
|
|
|
|
|
|
|
($curr_rec=(grep { |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# my $conv=new Text::Iconv ("utf-8","koi8-r"); |
64
|
|
|
|
|
|
|
# my $koi_curr=$conv->convert($attr{'table:name'}); |
65
|
|
|
|
|
|
|
# my $koi_need=$conv->convert($_->{table}); |
66
|
|
|
|
|
|
|
my $koi_curr=$attr{'table:name'}; |
67
|
|
|
|
|
|
|
my $koi_need=$_->{table}; |
68
|
|
|
|
|
|
|
$koi_need =~/$koi_curr$/ ; |
69
|
|
|
|
|
|
|
} @$ref )[0]) |
70
|
|
|
|
|
|
|
&& |
71
|
|
|
|
|
|
|
do { |
72
|
|
|
|
|
|
|
$c_row=0; |
73
|
|
|
|
|
|
|
@sonar_cells{map {A1_2_11($_)} @{$curr_rec->{cells}}}=(); |
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
) |
77
|
|
|
|
|
|
|
|| |
78
|
|
|
|
|
|
|
!(ref $curr_rec) && do {return} |
79
|
|
|
|
|
|
|
|| |
80
|
|
|
|
|
|
|
/table:table-row$/ && do { |
81
|
|
|
|
|
|
|
$c_row++;$c_cell=0; |
82
|
|
|
|
|
|
|
%current=("$c_row:$c_cell",1); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|| |
85
|
|
|
|
|
|
|
/table:table-cell$/ && do { |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$c_cell++; |
88
|
|
|
|
|
|
|
%current=("$c_row:$c_cell",1); |
89
|
|
|
|
|
|
|
my $repeat=$attr{'table:number-columns-repeated'}; |
90
|
|
|
|
|
|
|
if ($repeat){ |
91
|
|
|
|
|
|
|
map {$current{$_}=1} |
92
|
|
|
|
|
|
|
map {"$c_row:".++$c_cell} @{[1..$repeat-1]}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
$c_cell += $attr{'table:number-columns-spanned'}-1 if $attr{'table:number-columns-spanned'}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|| |
97
|
|
|
|
|
|
|
/text:p$/ && do {$par_text=1} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub handle_end { |
102
|
|
|
|
|
|
|
my ($ref_Ex,$name)=@_; |
103
|
|
|
|
|
|
|
$_=$name; |
104
|
|
|
|
|
|
|
$curr_rec=undef if /table:table$/; |
105
|
|
|
|
|
|
|
$par_text=0 if /text:p$/; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub handle_char { |
109
|
|
|
|
|
|
|
my ($ref_Ex,$data)=@_; |
110
|
|
|
|
|
|
|
if ($par_text) { |
111
|
|
|
|
|
|
|
@{$res{$curr_rec->{table}}}{ map {_11_2_A1($_)} grep {exists $sonar_cells{$_}} keys %current}.=$data ; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $parser=new XML::Parser(Handlers => { |
116
|
|
|
|
|
|
|
Start => sub {&handle_start(@_)}, |
117
|
|
|
|
|
|
|
End => sub {&handle_end(@_)}, |
118
|
|
|
|
|
|
|
Char => sub {&handle_char(@_)} |
119
|
|
|
|
|
|
|
}); |
120
|
|
|
|
|
|
|
$parser->parse ($text); |
121
|
|
|
|
|
|
|
return \%res; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Preloaded methods go here. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
__END__ |