1*cdf0e10cSrcweir#!/usr/bin/perl
2*cdf0e10cSrcweir
3*cdf0e10cSrcweir$uno_hid = "/handbuch/WORKBENCH/helpcontent2/helpers/uno_hid.lst";
4*cdf0e10cSrcweir$uno_cmd = "/handbuch/WORKBENCH/helpcontent2/helpers/unocmds.txt";
5*cdf0e10cSrcweir$startdir = "/handbuch/WORKBENCH/helpcontent2/source/text/";
6*cdf0e10cSrcweir
7*cdf0e10cSrcweirif (open HID, $uno_hid) {
8*cdf0e10cSrcweir	while (<HID>) {
9*cdf0e10cSrcweir		chomp;
10*cdf0e10cSrcweir		($shid,$nhid,$uno) = split ",";
11*cdf0e10cSrcweir		$hid{lc($uno)} = $shid;
12*cdf0e10cSrcweir	}
13*cdf0e10cSrcweir	close HID;
14*cdf0e10cSrcweir} else {
15*cdf0e10cSrcweir	die "Cannot open $uno_hid: $!\n";
16*cdf0e10cSrcweir}
17*cdf0e10cSrcweirprint scalar keys(%hid) . " entries read\n";
18*cdf0e10cSrcweir
19*cdf0e10cSrcweirif (open UNO, $uno_cmd) {
20*cdf0e10cSrcweir	while (<UNO>) {
21*cdf0e10cSrcweir		chomp;
22*cdf0e10cSrcweir		($uno,$file) = split ";";
23*cdf0e10cSrcweir		#print "$file\n";
24*cdf0e10cSrcweir		if (defined $hid{lc($uno)}) {
25*cdf0e10cSrcweir			if (open XML, "$startdir$file") {
26*cdf0e10cSrcweir				undef $/;
27*cdf0e10cSrcweir				$xml = <XML>;
28*cdf0e10cSrcweir				$/ = "\n";
29*cdf0e10cSrcweir				close XML;
30*cdf0e10cSrcweir				if ($xml =~ /hid\/$hid{lc($uno)}/ig) {
31*cdf0e10cSrcweir					print "OK    $startdir$file\n";
32*cdf0e10cSrcweir				} else {
33*cdf0e10cSrcweir					print "MISS  $startdir$file\n";
34*cdf0e10cSrcweir					open XML, ">$startdir$file.org";
35*cdf0e10cSrcweir					print XML $xml;
36*cdf0e10cSrcweir					close XML;
37*cdf0e10cSrcweir					open XML, ">$startdir$file";
38*cdf0e10cSrcweir					$id = "bm_id" . int(rand(10000000));
39*cdf0e10cSrcweir					$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*cdf0e10cSrcweir					print XML $xml;
41*cdf0e10cSrcweir					close XML;
42*cdf0e10cSrcweir				}
43*cdf0e10cSrcweir			} else {
44*cdf0e10cSrcweir				print "Cannot open $startdir$file: $!\n";
45*cdf0e10cSrcweir			}
46*cdf0e10cSrcweir		}
47*cdf0e10cSrcweir	}
48*cdf0e10cSrcweir} else {
49*cdf0e10cSrcweir	die "Cannot open $uno_cmd: $!\n";
50*cdf0e10cSrcweir}
51*cdf0e10cSrcweir
52*cdf0e10cSrcweir
53*cdf0e10cSrcweir
54