1#!/usr/bin/perl 2 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/"; 6 7if (open HID, $uno_hid) { 8 while (<HID>) { 9 chomp; 10 ($shid,$nhid,$uno) = split ","; 11 $hid{lc($uno)} = $shid; 12 } 13 close HID; 14} else { 15 die "Cannot open $uno_hid: $!\n"; 16} 17print scalar keys(%hid) . " entries read\n"; 18 19if (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; 42 } 43 } else { 44 print "Cannot open $startdir$file: $!\n"; 45 } 46 } 47 } 48} else { 49 die "Cannot open $uno_cmd: $!\n"; 50} 51 52 53 54