update dev300-m58
[ooovba.git] / helpcontent2 / helpers / checkuno.pl
blob68a6768a2b3193d64a28d7bcccf9b8c96c9a4b77
1 #!/usr/bin/perl
3 $uno_hid = "/handbuch/WORKBENCH/helpcontent2/helpers/uno_hid.lst";
4 $uno_cmd = "/handbuch/WORKBENCH/helpcontent2/helpers/unocmds.txt";
5 $startdir = "/handbuch/WORKBENCH/helpcontent2/source/text/";
7 if (open HID, $uno_hid) {
8 while (<HID>) {
9 chomp;
10 ($shid,$nhid,$uno) = split ",";
11 $hid{lc($uno)} = $shid;
13 close HID;
14 } else {
15 die "Cannot open $uno_hid: $!\n";
17 print scalar keys(%hid) . " entries read\n";
19 if (open UNO, $uno_cmd) {
20 while (<UNO>) {
21 chomp;
22 ($uno,$file) = split ";";
23 #print "$file\n";
24 if (defined $hid{lc($uno)}) {
25 if (open XML, "$startdir$file") {
26 undef $/;
27 $xml = <XML>;
28 $/ = "\n";
29 close XML;
30 if ($xml =~ /hid\/$hid{lc($uno)}/ig) {
31 print "OK $startdir$file\n";
32 } else {
33 print "MISS $startdir$file\n";
34 open XML, ">$startdir$file.org";
35 print XML $xml;
36 close XML;
37 open XML, ">$startdir$file";
38 $id = "bm_id" . int(rand(10000000));
39 $xml =~ s/(<bookmark[^>]*branch=\"hid\/$uno\"[^>]*>)/<bookmark xml-lang=\"en-US\" branch=\"hid\/$hid{lc($uno)}\" id=\"$id\" localize=\"false\"\/><!-- HID added by script -->\n$1/ig;
40 print XML $xml;
41 close XML;
43 } else {
44 print "Cannot open $startdir$file: $!\n";
48 } else {
49 die "Cannot open $uno_cmd: $!\n";