xref: /trunk/main/helpcontent2/helpers/checkuno.pl (revision c667dd47)
1#!/usr/bin/env perl
2# *************************************************************
3#
4#  Licensed to the Apache Software Foundation (ASF) under one
5#  or more contributor license agreements.  See the NOTICE file
6#  distributed with this work for additional information
7#  regarding copyright ownership.  The ASF licenses this file
8#  to you under the Apache License, Version 2.0 (the
9#  "License"); you may not use this file except in compliance
10#  with the License.  You may obtain a copy of the License at
11#
12#    http://www.apache.org/licenses/LICENSE-2.0
13#
14#  Unless required by applicable law or agreed to in writing,
15#  software distributed under the License is distributed on an
16#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17#  KIND, either express or implied.  See the License for the
18#  specific language governing permissions and limitations
19#  under the License.
20#
21# *************************************************************
22
23$uno_hid = "/handbuch/WORKBENCH/helpcontent2/helpers/uno_hid.lst";
24$uno_cmd = "/handbuch/WORKBENCH/helpcontent2/helpers/unocmds.txt";
25$startdir = "/handbuch/WORKBENCH/helpcontent2/source/text/";
26
27if (open HID, $uno_hid) {
28	while (<HID>) {
29		chomp;
30		($shid,$nhid,$uno) = split ",";
31		$hid{lc($uno)} = $shid;
32	}
33	close HID;
34} else {
35	die "Cannot open $uno_hid: $!\n";
36}
37print scalar keys(%hid) . " entries read\n";
38
39if (open UNO, $uno_cmd) {
40	while (<UNO>) {
41		chomp;
42		($uno,$file) = split ";";
43		#print "$file\n";
44		if (defined $hid{lc($uno)}) {
45			if (open XML, "$startdir$file") {
46				undef $/;
47				$xml = <XML>;
48				$/ = "\n";
49				close XML;
50				if ($xml =~ /hid\/$hid{lc($uno)}/ig) {
51					print "OK    $startdir$file\n";
52				} else {
53					print "MISS  $startdir$file\n";
54					open XML, ">$startdir$file.org";
55					print XML $xml;
56					close XML;
57					open XML, ">$startdir$file";
58					$id = "bm_id" . int(rand(10000000));
59					$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;
60					print XML $xml;
61					close XML;
62				}
63			} else {
64				print "Cannot open $startdir$file: $!\n";
65			}
66		}
67	}
68} else {
69	die "Cannot open $uno_cmd: $!\n";
70}
71
72
73
74