Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / windows / idtglobal.pm
blob81f6130ac581e6a687e73f556204396b5627360b
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: idtglobal.pm,v $
11 # $Revision: 1.45 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::windows::idtglobal;
34 use Cwd;
35 use installer::converter;
36 use installer::existence;
37 use installer::exiter;
38 use installer::files;
39 use installer::globals;
40 use installer::pathanalyzer;
41 use installer::remover;
42 use installer::scriptitems;
43 use installer::systemactions;
44 use installer::windows::language;
46 ##############################################################
47 # Shorten the gid for a feature.
48 # Attention: Maximum length is 38
49 ##############################################################
51 sub shorten_feature_gid
53 my ($stringref) = @_;
55 $$stringref =~ s/gid_Module_/gm_/;
56 $$stringref =~ s/_Root_/_r_/;
57 $$stringref =~ s/_Prg_/_p_/;
58 $$stringref =~ s/_Optional_/_o_/;
59 $$stringref =~ s/_Wrt_Flt_/_w_f_/;
60 $$stringref =~ s/_Javafilter_/_jf_/;
63 ############################################
64 # Getting the next free number, that
65 # can be added.
66 # Sample: 01-44-~1.DAT, 01-44-~2.DAT, ...
67 ############################################
69 sub get_next_free_number
71 my ($name, $shortnamesref) = @_;
73 my $counter = 0;
74 my $dontsave = 0;
75 my $alreadyexists;
76 my ($newname, $shortname);
80 $alreadyexists = 0;
81 $counter++;
82 $newname = $name . $counter;
84 for ( my $i = 0; $i <= $#{$shortnamesref}; $i++ )
86 $shortname = ${$shortnamesref}[$i];
88 if ( uc($shortname) eq uc($newname) ) # case insensitive
90 $alreadyexists = 1;
91 last;
95 until (!($alreadyexists));
97 if (( $counter > 9 ) && ( length($name) > 6 ))
99 $dontsave = 1;
102 if (!($dontsave))
104 push(@{$shortnamesref}, $newname); # adding the new shortname to the array of shortnames
107 return $counter
110 ############################################
111 # Getting the next free number, that
112 # can be added.
113 # Sample: 01-44-~1.DAT, 01-44-~2.DAT, ...
114 ############################################
116 sub get_next_free_number_with_hash
118 my ($name, $shortnamesref, $ext) = @_;
120 my $counter = 0;
121 my $dontsave = 0;
122 my $saved = 0;
123 my $alreadyexists;
124 my ($newname, $shortname);
128 $alreadyexists = 0;
129 $counter++;
130 $newname = $name . $counter;
131 $newname = uc($newname); # case insensitive, always upper case
132 if ( exists($shortnamesref->{$newname}) ||
133 exists($installer::globals::savedrev83mapping{$newname.$ext}) )
135 $alreadyexists = 1;
138 until (!($alreadyexists));
140 if (( $counter > 9 ) && ( length($name) > 6 )) { $dontsave = 1; }
141 if (( $counter > 99 ) && ( length($name) > 5 )) { $dontsave = 1; }
143 if (!($dontsave))
145 # push(@{$shortnamesref}, $newname); # adding the new shortname to the array of shortnames
146 $shortnamesref->{$newname} = 1; # adding the new shortname to the array of shortnames, always uppercase
147 $saved = 1;
150 return ( $counter, $saved )
153 #########################################
154 # 8.3 for filenames and directories
155 #########################################
157 sub make_eight_three_conform
159 my ($inputstring, $pattern, $shortnamesref) = @_;
161 # all shortnames are collected in $shortnamesref, because of uniqueness
163 my ($name, $namelength, $number);
164 my $conformstring = "";
165 my $changed = 0;
167 if (( $inputstring =~ /^\s*(.*?)\.(.*?)\s*$/ ) && ( $pattern eq "file" )) # files with a dot
169 $name = $1;
170 my $extension = $2;
172 $namelength = length($name);
173 my $extensionlength = length($extension);
175 if ( $extensionlength > 3 )
177 # simply taking the first three letters
178 $extension = substr($extension, 0, 3); # name, offset, length
181 # Attention: readme.html -> README~1.HTM
183 if (( $namelength > 8 ) || ( $extensionlength > 3 ))
185 # taking the first six letters
186 $name = substr($name, 0, 6); # name, offset, length
187 $name =~ s/\s*$//; # removing ending whitespaces
188 $name = $name . "\~";
189 $number = get_next_free_number($name, $shortnamesref);
191 # if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
193 if ( $number > 9 )
195 $name = substr($name, 0, 5); # name, offset, length
196 $name =~ s/\s*$//; # removing ending whitespaces
197 $name = $name . "\~";
198 $number = get_next_free_number($name, $shortnamesref);
201 $name = $name . "$number";
203 $changed = 1;
206 $conformstring = $name . "\." . $extension;
208 if ( $changed ) { $conformstring= uc($conformstring); }
210 else # no dot in filename or directory (also used for shortcuts)
212 $name = $inputstring;
213 $namelength = length($name);
215 if ( $namelength > 8 )
217 # taking the first six letters
218 $name = substr($name, 0, 6); # name, offset, length
219 $name =~ s/\s*$//; # removing ending whitespaces
220 $name = $name . "\~";
221 $number = get_next_free_number($name, $shortnamesref);
223 # if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
225 if ( $number > 9 )
227 $name = substr($name, 0, 5); # name, offset, length
228 $name =~ s/\s*$//; # removing ending whitespaces
229 $name = $name . "\~";
230 $number = get_next_free_number($name, $shortnamesref);
233 $name = $name . "$number";
234 $changed = 1;
235 if ( $pattern eq "dir" ) { $name =~ s/\./\_/g; } # in directories replacing "." with "_"
238 $conformstring = $name;
240 if ( $changed ) { $conformstring = uc($name); }
243 return $conformstring;
246 #########################################
247 # 8.3 for filenames and directories
248 # $shortnamesref is a hash in this case
249 # -> performance reasons
250 #########################################
252 sub make_eight_three_conform_with_hash
254 my ($inputstring, $pattern, $shortnamesref) = @_;
256 # all shortnames are collected in $shortnamesref, because of uniqueness (a hash!)
258 my ($name, $namelength, $number);
259 my $conformstring = "";
260 my $changed = 0;
261 my $saved;
263 # if (( $inputstring =~ /^\s*(.*?)\.(.*?)\s*$/ ) && ( $pattern eq "file" )) # files with a dot
264 if (( $inputstring =~ /^\s*(.*)\.(.*?)\s*$/ ) && ( $pattern eq "file" )) # files with a dot
266 # extension has to be non-greedy, but name is. This is important to find the last dot in the filename
267 $name = $1;
268 my $extension = $2;
270 if ( $name =~ /^\s*(.*?)\s*$/ ) { $name = $1; } # now the name is also non-greedy
271 $name =~ s/\.//g; # no dots in 8+3 conform filename
273 $namelength = length($name);
274 my $extensionlength = length($extension);
276 if ( $extensionlength > 3 )
278 # simply taking the first three letters
279 $extension = substr($extension, 0, 3); # name, offset, length
280 $changed = 1;
283 # Attention: readme.html -> README~1.HTM
285 if (( $namelength > 8 ) || ( $extensionlength > 3 ))
287 # taking the first six letters, if filename is longer than 6 characters
288 if ( $namelength > 6 )
290 $name = substr($name, 0, 6); # name, offset, length
291 $name =~ s/\s*$//; # removing ending whitespaces
292 $name = $name . "\~";
293 ($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
295 # if $number>9 the new name would be "abcdef~10.xyz", which is 9+3, and therefore not allowed
297 if ( ! $saved )
299 $name = substr($name, 0, 5); # name, offset, length
300 $name =~ s/\s*$//; # removing ending whitespaces
301 $name = $name . "\~";
302 ($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
304 # if $number>99 the new name would be "abcde~100.xyz", which is 9+3, and therefore not allowed
306 if ( ! $saved )
308 $name = substr($name, 0, 4); # name, offset, length
309 $name =~ s/\s*$//; # removing ending whitespaces
310 $name = $name . "\~";
311 ($number, $saved) = get_next_free_number_with_hash($name, $shortnamesref, '.'.uc($extension));
313 if ( ! $saved )
315 installer::exiter::exit_program("ERROR: Could not set 8+3 conform name for $inputstring !", "make_eight_three_conform_with_hash");
320 $name = $name . "$number";
321 $changed = 1;
325 $conformstring = $name . "\." . $extension;
327 if ( $changed ) { $conformstring= uc($conformstring); }
329 else # no dot in filename or directory (also used for shortcuts)
331 $name = $inputstring;
332 $namelength = length($name);
334 if ( $namelength > 8 )
336 # taking the first six letters
337 $name = substr($name, 0, 6); # name, offset, length
338 $name =~ s/\s*$//; # removing ending whitespaces
339 $name = $name . "\~";
340 ( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
342 # if $number>9 the new name would be "abcdef~10", which is 9+0, and therefore not allowed
344 if ( ! $saved )
346 $name = substr($name, 0, 5); # name, offset, length
347 $name =~ s/\s*$//; # removing ending whitespaces
348 $name = $name . "\~";
349 ( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
351 # if $number>99 the new name would be "abcde~100", which is 9+0, and therefore not allowed
353 if ( ! $saved )
355 $name = substr($name, 0, 4); # name, offset, length
356 $name =~ s/\s*$//; # removing ending whitespaces
357 $name = $name . "\~";
358 ( $number, $saved ) = get_next_free_number_with_hash($name, $shortnamesref, '');
360 if ( ! $saved ) { installer::exiter::exit_program("ERROR: Could not set 8+3 conform name for $inputstring !", "make_eight_three_conform_with_hash"); }
364 $name = $name . "$number";
365 $changed = 1;
366 if ( $pattern eq "dir" ) { $name =~ s/\./\_/g; } # in directories replacing "." with "_"
369 $conformstring = $name;
371 if ( $changed ) { $conformstring = uc($name); }
374 return $conformstring;
377 #########################################
378 # Writing the header for idt files
379 #########################################
381 sub write_idt_header
383 my ($idtref, $definestring) = @_;
385 my $oneline;
387 if ( $definestring eq "file" )
389 $oneline = "File\tComponent_\tFileName\tFileSize\tVersion\tLanguage\tAttributes\tSequence\n";
390 push(@{$idtref}, $oneline);
391 $oneline = "s72\ts72\tl255\ti4\tS72\tS20\tI2\ti2\n";
392 push(@{$idtref}, $oneline);
393 $oneline = "File\tFile\n";
394 push(@{$idtref}, $oneline);
397 if ( $definestring eq "filehash" )
399 $oneline = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n";
400 push(@{$idtref}, $oneline);
401 $oneline = "s72\ti2\ti4\ti4\ti4\ti4\n";
402 push(@{$idtref}, $oneline);
403 $oneline = "MsiFileHash\tFile_\n";
404 push(@{$idtref}, $oneline);
407 if ( $definestring eq "directory" )
409 $oneline = "Directory\tDirectory_Parent\tDefaultDir\n";
410 push(@{$idtref}, $oneline);
411 $oneline = "s72\tS72\tl255\n";
412 push(@{$idtref}, $oneline);
413 $oneline = "Directory\tDirectory\n";
414 push(@{$idtref}, $oneline);
417 if ( $definestring eq "component" )
419 $oneline = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n";
420 push(@{$idtref}, $oneline);
421 $oneline = "s72\tS38\ts72\ti2\tS255\tS72\n";
422 push(@{$idtref}, $oneline);
423 $oneline = "Component\tComponent\n";
424 push(@{$idtref}, $oneline);
427 if ( $definestring eq "feature" )
429 $oneline = "Feature\tFeature_Parent\tTitle\tDescription\tDisplay\tLevel\tDirectory_\tAttributes\n";
430 push(@{$idtref}, $oneline);
431 $oneline = "s38\tS38\tL64\tL255\tI2\ti2\tS72\ti2\n";
432 push(@{$idtref}, $oneline);
433 $oneline = "WINDOWSENCODINGTEMPLATE\tFeature\tFeature\n";
434 push(@{$idtref}, $oneline);
437 if ( $definestring eq "featurecomponent" )
439 $oneline = "Feature_\tComponent_\n";
440 push(@{$idtref}, $oneline);
441 $oneline = "s38\ts72\n";
442 push(@{$idtref}, $oneline);
443 $oneline = "FeatureComponents\tFeature_\tComponent_\n";
444 push(@{$idtref}, $oneline);
447 if ( $definestring eq "media" )
449 $oneline = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tVolumeLabel\tSource\n";
450 push(@{$idtref}, $oneline);
451 $oneline = "i2\ti2\tL64\tS255\tS32\tS72\n";
452 push(@{$idtref}, $oneline);
453 $oneline = "Media\tDiskId\n";
454 push(@{$idtref}, $oneline);
457 if ( $definestring eq "font" )
459 $oneline = "File_\tFontTitle\n";
460 push(@{$idtref}, $oneline);
461 $oneline = "s72\tS128\n";
462 push(@{$idtref}, $oneline);
463 $oneline = "Font\tFile_\n";
464 push(@{$idtref}, $oneline);
467 if ( $definestring eq "shortcut" )
469 $oneline = "Shortcut\tDirectory_\tName\tComponent_\tTarget\tArguments\tDescription\tHotkey\tIcon_\tIconIndex\tShowCmd\tWkDir\n";
470 push(@{$idtref}, $oneline);
471 $oneline = "s72\ts72\tl128\ts72\ts72\tS255\tL255\tI2\tS72\tI2\tI2\tS72\n";
472 push(@{$idtref}, $oneline);
473 $oneline = "WINDOWSENCODINGTEMPLATE\tShortcut\tShortcut\n";
474 push(@{$idtref}, $oneline);
477 if ( $definestring eq "registry" )
479 $oneline = "Registry\tRoot\tKey\tName\tValue\tComponent_\n";
480 push(@{$idtref}, $oneline);
481 $oneline = "s72\ti2\tl255\tL255\tL0\ts72\n";
482 push(@{$idtref}, $oneline);
483 $oneline = "Registry\tRegistry\n";
484 push(@{$idtref}, $oneline);
487 if ( $definestring eq "createfolder" )
489 $oneline = "Directory_\tComponent_\n";
490 push(@{$idtref}, $oneline);
491 $oneline = "s72\ts72\n";
492 push(@{$idtref}, $oneline);
493 $oneline = "CreateFolder\tDirectory_\tComponent_\n";
494 push(@{$idtref}, $oneline);
497 if ( $definestring eq "removefile" )
499 $oneline = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n";
500 push(@{$idtref}, $oneline);
501 $oneline = "s72\ts72\tL255\ts72\ti2\n";
502 push(@{$idtref}, $oneline);
503 $oneline = "RemoveFile\tFileKey\n";
504 push(@{$idtref}, $oneline);
507 if ( $definestring eq "upgrade" )
509 $oneline = "UpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\tRemove\tActionProperty\n";
510 push(@{$idtref}, $oneline);
511 $oneline = "s38\tS20\tS20\tS255\ti4\tS255\ts72\n";
512 push(@{$idtref}, $oneline);
513 $oneline = "Upgrade\tUpgradeCode\tVersionMin\tVersionMax\tLanguage\tAttributes\n";
514 push(@{$idtref}, $oneline);
517 if ( $definestring eq "icon" )
519 $oneline = "Name\tData\n";
520 push(@{$idtref}, $oneline);
521 $oneline = "s72\tv0\n";
522 push(@{$idtref}, $oneline);
523 $oneline = "Icon\tName\n";
524 push(@{$idtref}, $oneline);
527 if ( $definestring eq "inifile" )
529 $oneline = "IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_\n";
530 push(@{$idtref}, $oneline);
531 $oneline = "s72\tl255\tS72\tl96\tl128\tl255\ti2\ts72\n";
532 push(@{$idtref}, $oneline);
533 $oneline = "IniFile\tIniFile\n";
534 push(@{$idtref}, $oneline);
537 if ( $definestring eq "selfreg" )
539 $oneline = "File_\tCost\n";
540 push(@{$idtref}, $oneline);
541 $oneline = "s72\tI2\n";
542 push(@{$idtref}, $oneline);
543 $oneline = "SelfReg\tFile_\n";
544 push(@{$idtref}, $oneline);
547 if ( $definestring eq "msiassembly" )
549 $oneline = "Component_\tFeature_\tFile_Manifest\tFile_Application\tAttributes\n";
550 push(@{$idtref}, $oneline);
551 $oneline = "s72\ts38\tS72\tS72\tI2\n";
552 push(@{$idtref}, $oneline);
553 $oneline = "MsiAssembly\tComponent_\n";
554 push(@{$idtref}, $oneline);
557 if ( $definestring eq "msiassemblyname" )
559 $oneline = "Component_\tName\tValue\n";
560 push(@{$idtref}, $oneline);
561 $oneline = "s72\ts255\ts255\n";
562 push(@{$idtref}, $oneline);
563 $oneline = "MsiAssemblyName\tComponent_\tName\n";
564 push(@{$idtref}, $oneline);
567 if ( $definestring eq "appsearch" )
569 $oneline = "Property\tSignature_\n";
570 push(@{$idtref}, $oneline);
571 $oneline = "s72\ts72\n";
572 push(@{$idtref}, $oneline);
573 $oneline = "AppSearch\tProperty\tSignature_\n";
574 push(@{$idtref}, $oneline);
577 if ( $definestring eq "reglocat" )
579 $oneline = "Signature_\tRoot\tKey\tName\tType\n";
580 push(@{$idtref}, $oneline);
581 $oneline = "s72\ti2\ts255\tS255\tI2\n";
582 push(@{$idtref}, $oneline);
583 $oneline = "RegLocator\tSignature_\n";
584 push(@{$idtref}, $oneline);
587 if ( $definestring eq "signatur" )
589 $oneline = "Signature\tFileName\tMinVersion\tMaxVersion\tMinSize\tMaxSize\tMinDate\tMaxDate\tLanguages\n";
590 push(@{$idtref}, $oneline);
591 $oneline = "s72\ts255\tS20\tS20\tI4\tI4\tI4\tI4\tS255\n";
592 push(@{$idtref}, $oneline);
593 $oneline = "Signature\tSignature\n";
594 push(@{$idtref}, $oneline);
599 ##############################################################
600 # Returning the name of the rranslation file for a
601 # given language.
602 # Sample: "01" oder "en-US" -> "1033.txt"
603 ##############################################################
605 sub get_languagefilename
607 my ($idtfilename, $basedir) = @_;
609 # $idtfilename =~ s/\.idt/\.ulf/;
610 $idtfilename =~ s/\.idt/\.mlf/;
612 my $languagefilename = $basedir . $installer::globals::separator . $idtfilename;
614 return $languagefilename;
617 ##############################################################
618 # Returning the complete block in all languages
619 # for a specified string
620 ##############################################################
622 sub get_language_block_from_language_file
624 my ($searchstring, $languagefile) = @_;
626 my @language_block = ();
628 for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
630 if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
632 my $counter = $i;
634 push(@language_block, ${$languagefile}[$counter]);
635 $counter++;
637 while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
639 push(@language_block, ${$languagefile}[$counter]);
640 $counter++;
643 last;
647 return \@language_block;
650 ##############################################################
651 # Returning a specific language string from the block
652 # of all translations
653 ##############################################################
655 sub get_language_string_from_language_block
657 my ($language_block, $language, $oldstring) = @_;
659 my $newstring = "";
661 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
663 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
665 $newstring = $1;
666 last;
670 if ( $newstring eq "" )
672 $language = "en-US"; # defaulting to english
674 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
676 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
678 $newstring = $1;
679 last;
684 return $newstring;
687 ##############################################################
688 # Returning a specific code from the block
689 # of all codes. No defaulting to english!
690 ##############################################################
692 sub get_code_from_code_block
694 my ($codeblock, $language) = @_;
696 my $newstring = "";
698 for ( my $i = 0; $i <= $#{$codeblock}; $i++ )
700 if ( ${$codeblock}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
702 $newstring = $1;
703 last;
707 return $newstring;
710 ##############################################################
711 # Translating an idt file
712 ##############################################################
714 sub translate_idtfile
716 my ($idtfile, $languagefile, $onelanguage) = @_;
718 for ( my $i = 0; $i <= $#{$idtfile}; $i++ )
720 my @allstrings = ();
722 my $oneline = ${$idtfile}[$i];
724 while ( $oneline =~ /\b(OOO_\w+)\b/ )
726 my $replacestring = $1;
727 push(@allstrings, $replacestring);
728 $oneline =~ s/$replacestring//;
731 my $oldstring;
733 foreach $oldstring (@allstrings)
735 my $language_block = get_language_block_from_language_file($oldstring, $languagefile);
736 my $newstring = get_language_string_from_language_block($language_block, $onelanguage, $oldstring);
738 # if (!( $newstring eq "" )) { ${$idtfile}[$i] =~ s/$oldstring/$newstring/; }
739 ${$idtfile}[$i] =~ s/$oldstring/$newstring/; # always substitute, even if $newstring eq "" (there are empty strings for control.idt)
744 ##############################################################
745 # Copying all needed files to create a msi database
746 # into one language specific directory
747 ##############################################################
749 sub prepare_language_idt_directory
751 my ($destinationdir, $newidtdir, $onelanguage, $filesref, $iconfilecollector, $binarytablefiles, $allvariables) = @_;
753 # Copying all idt-files from the source $installer::globals::idttemplatepath to the destination $destinationdir
754 # Copying all files in the subdirectory "Binary"
755 # Copying all files in the subdirectory "Icon"
757 my $infoline = "";
759 installer::systemactions::copy_directory($installer::globals::idttemplatepath, $destinationdir);
761 if ( -d $installer::globals::idttemplatepath . $installer::globals::separator . "Binary")
763 installer::systemactions::create_directory($destinationdir . $installer::globals::separator . "Binary");
764 installer::systemactions::copy_directory($installer::globals::idttemplatepath . $installer::globals::separator . "Binary", $destinationdir . $installer::globals::separator . "Binary");
766 if (( $installer::globals::patch ) && ( $allvariables->{'WINDOWSPATCHBITMAPDIRECTORY'} ))
768 my $newsourcedir = $installer::globals::unpackpath . $installer::globals::separator . $allvariables->{'WINDOWSPATCHBITMAPDIRECTORY'}; # path setting in list file dependent from unpackpath !?
769 $infoline = "\nOverwriting files in directory \"" . $destinationdir . $installer::globals::separator . "Binary" . "\" with files from directory \"" . $newsourcedir . "\".\n";
770 push( @installer::globals::logfileinfo, $infoline);
771 if ( ! -d $newsourcedir )
773 my $currentdir = cwd();
774 installer::exiter::exit_program("ERROR: Directory $newsourcedir does not exist! Current directory is: $currentdir", "prepare_language_idt_directory");
776 installer::systemactions::copy_directory($newsourcedir, $destinationdir . $installer::globals::separator . "Binary");
780 installer::systemactions::create_directory($destinationdir . $installer::globals::separator . "Icon");
782 if ( -d $installer::globals::idttemplatepath . $installer::globals::separator . "Icon")
784 installer::systemactions::copy_directory($installer::globals::idttemplatepath . $installer::globals::separator . "Icon", $destinationdir . $installer::globals::separator . "Icon");
787 # Copying all files in $iconfilecollector, that describe icons of folderitems
789 for ( my $i = 0; $i <= $#{$iconfilecollector}; $i++ )
791 my $iconfilename = ${$iconfilecollector}[$i];
792 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$iconfilename);
793 installer::systemactions::copy_one_file(${$iconfilecollector}[$i], $destinationdir . $installer::globals::separator . "Icon" . $installer::globals::separator . $iconfilename);
796 # Copying all files in $binarytablefiles in the binary directory
798 for ( my $i = 0; $i <= $#{$binarytablefiles}; $i++ )
800 my $binaryfile = ${$binarytablefiles}[$i];
801 my $binaryfilepath = $binaryfile->{'sourcepath'};
802 my $binaryfilename = $binaryfilepath;
803 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$binaryfilename);
804 installer::systemactions::copy_one_file($binaryfilepath, $destinationdir . $installer::globals::separator . "Binary" . $installer::globals::separator . $binaryfilename);
807 # Copying all new created and language independent idt-files to the destination $destinationdir.
808 # Example: "File.idt"
810 installer::systemactions::copy_directory_with_fileextension($newidtdir, $destinationdir, "idt");
812 # Copying all new created and language dependent idt-files to the destination $destinationdir.
813 # Example: "Feature.idt.01"
815 installer::systemactions::copy_directory_with_fileextension($newidtdir, $destinationdir, $onelanguage);
816 installer::systemactions::rename_files_with_fileextension($destinationdir, $onelanguage);
820 ##############################################################
821 # Returning the source path of the rtf licensefile for
822 # a specified language
823 ##############################################################
825 sub get_rtflicensefilesource
827 my ($language, $includepatharrayref) = @_;
829 my $licensefilename = "license_" . $language . ".rtf";
831 my $sourcefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $includepatharrayref, 1);
833 if ($$sourcefileref eq "") { installer::exiter::exit_program("ERROR: Could not find $licensefilename!", "get_rtflicensefilesource"); }
835 my $infoline = "Using licensefile: $$sourcefileref\n";
836 push( @installer::globals::logfileinfo, $infoline);
838 return $$sourcefileref;
841 ##############################################################
842 # Returning the source path of the licensefile for
843 # a specified language
844 ##############################################################
846 sub get_licensefilesource
848 my ($language, $filesref) = @_;
850 my $licensefilename = "license_" . $language . ".txt";
851 my $sourcepath = "";
852 my $foundlicensefile = 0;
854 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
856 my $onefile = ${$filesref}[$i];
857 my $filename = $onefile->{'Name'};
859 if ($filename eq $licensefilename)
861 $sourcepath = $onefile->{'sourcepath'};
862 $foundlicensefile = 1;
863 last;
867 if ( ! $foundlicensefile ) { installer::exiter::exit_program("ERROR: Did not find file $licensefilename in file collector!", "get_licensefilesource"); }
869 return $sourcepath;
872 ##############################################################
873 # A simple converter to create the license text
874 # in rtf format
875 ##############################################################
877 sub get_rtf_licensetext
879 my ($licensefile) = @_;
881 # A very simple rtf converter
883 # The static header
885 my $rtf_licensetext = '{\rtf1\ansi\deff0';
886 $rtf_licensetext = $rtf_licensetext . '{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}';
887 $rtf_licensetext = $rtf_licensetext . '{\colortbl\red0\green0\blue0;\red255\green255\blue255;\red128\green128\blue128;}';
888 $rtf_licensetext = $rtf_licensetext . '{\stylesheet{\s1\snext1 Standard;}}';
889 $rtf_licensetext = $rtf_licensetext . '{\info{\comment StarWriter}{\vern5690}}\deftab709';
890 $rtf_licensetext = $rtf_licensetext . '{\*\pgdsctbl';
891 $rtf_licensetext = $rtf_licensetext . '{\pgdsc0\pgdscuse195\pgwsxn11905\pghsxn16837\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}}';
892 $rtf_licensetext = $rtf_licensetext . '\paperh16837\paperw11905\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\pgwsxn11905\pghsxn16837\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc';
893 $rtf_licensetext = $rtf_licensetext . '\pard\plain \s1';
895 for ( my $i = 0; $i <= $#{$licensefile}; $i++ )
897 my $oneline = ${$licensefile}[$i];
898 # if ( $oneline =~ /^\s*$/ ) { $oneline = '\par'; } # empty lines
900 if ( $i == 0 ) { $oneline =~ s/^\W*//; }
902 $oneline =~ s/\t/ /g; # no tabs allowed, converting to four spaces
903 $oneline =~ s/\n$//g; # no newline at line end
905 # $oneline =~ s/ä/\\\'e4/g; # converting "ä"
906 # $oneline =~ s/ö/\\\'f6/g; # converting "ö"
907 # $oneline =~ s/ü/\\\'fc/g; # converting "ü"
908 # $oneline =~ s/ß/\\\'df/g; # converting "ß"
910 # german replacements
912 $oneline =~ s/\Ã\„/\\\'c4/g; # converting "Ä"
913 $oneline =~ s/\Ã\–/\\\'d6/g; # converting "Ö"
914 $oneline =~ s/\Ã\œ/\\\'dc/g; # converting "Ü"
915 $oneline =~ s/\Ã\¤/\\\'e4/g; # converting "ä"
916 $oneline =~ s/\Ã\¶/\\\'f6/g; # converting "ö"
917 $oneline =~ s/\Ã\¼/\\\'fc/g; # converting "ü"
918 $oneline =~ s/\Ã\Ÿ/\\\'df/g; # converting "ß"
920 # french replacements
922 $oneline =~ s/\Ã\‰/\\\'c9/g;
923 $oneline =~ s/\Ã\€/\\\'c0/g;
924 $oneline =~ s/\Â\«/\\\'ab/g;
925 $oneline =~ s/\Â\»/\\\'bb/g;
926 $oneline =~ s/\Ã\©/\\\'e9/g;
927 $oneline =~ s/\Ã\¨/\\\'e8/g;
928 $oneline =~ s/\Ã\ /\\\'e0/g;
929 $oneline =~ s/\Ã\´/\\\'f4/g;
930 $oneline =~ s/\Ã\§/\\\'e7/g;
931 $oneline =~ s/\Ã\ª/\\\'ea/g;
932 $oneline =~ s/\Ã\Š/\\\'ca/g;
933 $oneline =~ s/\Ã\»/\\\'fb/g;
934 $oneline =~ s/\Ã\¹/\\\'f9/g;
935 $oneline =~ s/\Ã\®/\\\'ee/g;
937 # quotation marks
939 $oneline =~ s/\â\€\ž/\\\'84/g;
940 $oneline =~ s/\â\€\œ/\\ldblquote/g;
941 $oneline =~ s/\â\€\™/\\rquote/g;
944 $oneline =~ s/\Â\ /\\\~/g;
946 $oneline = '\par ' . $oneline;
948 $rtf_licensetext = $rtf_licensetext . $oneline;
951 # and the end
953 $rtf_licensetext = $rtf_licensetext . '\par \par }';
955 return $rtf_licensetext;
958 ##############################################################
959 # A simple converter to create a license txt string from
960 # the rtf format
961 ##############################################################
963 sub make_string_licensetext
965 my ($licensefile) = @_;
967 my $rtf_licensetext = "";
969 for ( my $i = 0; $i <= $#{$licensefile}; $i++ )
971 my $oneline = ${$licensefile}[$i];
972 $oneline =~ s/\s*$//g; # no whitespace at line end
974 $rtf_licensetext = $rtf_licensetext . $oneline . " ";
977 return $rtf_licensetext;
980 ##############################################################
981 # Setting the path, where the soffice.exe is installed, into
982 # the CustomAction table
983 ##############################################################
985 sub add_officedir_to_database
987 my ($basedir, $allvariables) = @_;
989 my $customactionfilename = $basedir . $installer::globals::separator . "CustomAc.idt";
991 my $customacfile = installer::files::read_file($customactionfilename);
993 my $found = 0;
995 # Updating the values
997 if ( $installer::globals::officeinstalldirectoryset )
999 $found = 0;
1001 for ( my $i = 0; $i <= $#{$customacfile}; $i++ )
1003 if ( ${$customacfile}[$i] =~ /\bOFFICEDIRECTORYGID\b/ )
1005 ${$customacfile}[$i] =~ s/\bOFFICEDIRECTORYGID\b/$installer::globals::officeinstalldirectory/;
1006 $found = 1;
1010 if (( ! $found ) && ( ! $allvariables->{'IGNOREDIRECTORYLAYER'} ))
1012 installer::exiter::exit_program("ERROR: \"OFFICEDIRECTORYGID\" not found in \"$customactionfilename\" !", "add_officedir_to_database");
1016 if ( $installer::globals::basisinstalldirectoryset )
1018 $found = 0;
1020 for ( my $i = 0; $i <= $#{$customacfile}; $i++ )
1022 if ( ${$customacfile}[$i] =~ /\bBASISDIRECTORYGID\b/ )
1024 ${$customacfile}[$i] =~ s/\bBASISDIRECTORYGID\b/$installer::globals::basisinstalldirectory/;
1025 $found = 1;
1029 if (( ! $found ) && ( ! $allvariables->{'IGNOREDIRECTORYLAYER'} ))
1031 installer::exiter::exit_program("ERROR: \"BASISDIRECTORYGID\" not found in \"$customactionfilename\" !", "add_officedir_to_database");
1035 if ( $installer::globals::ureinstalldirectoryset )
1037 $found = 0;
1039 for ( my $i = 0; $i <= $#{$customacfile}; $i++ )
1041 if ( ${$customacfile}[$i] =~ /\bUREDIRECTORYGID\b/ )
1043 ${$customacfile}[$i] =~ s/\bUREDIRECTORYGID\b/$installer::globals::ureinstalldirectory/;
1044 $found = 1;
1048 if (( ! $found ) && ( ! $allvariables->{'IGNOREDIRECTORYLAYER'} ))
1050 installer::exiter::exit_program("ERROR: \"UREDIRECTORYGID\" not found in \"$customactionfilename\" !", "add_officedir_to_database");
1054 # Saving the file
1056 installer::files::save_file($customactionfilename ,$customacfile);
1057 my $infoline = "Updated idt file: $customactionfilename\n";
1058 push(@installer::globals::logfileinfo, $infoline);
1062 ##############################################################
1063 # Including the license text into the table control.idt
1064 ##############################################################
1066 sub add_licensefile_to_database
1068 my ($licensefile, $controltable) = @_;
1070 # Nine tabs before the license text and two tabs after it
1071 # The license text has to be included into the dialog
1072 # LicenseAgreement into the control Memo.
1074 my $foundlicenseline = 0;
1075 my ($number, $line);
1077 for ( my $i = 0; $i <= $#{$controltable}; $i++ )
1079 $line = ${$controltable}[$i];
1081 if ( $line =~ /^\s*\bLicenseAgreement\b\t\bMemo\t/ )
1083 $foundlicenseline = 1;
1084 $number = $i;
1085 last;
1089 if (!($foundlicenseline))
1091 installer::exiter::exit_program("ERROR: Line for license file in Control.idt not found!", "add_licensefile_to_database");
1093 else
1095 my %control = ();
1097 if ( $line =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
1099 $control{'Dialog_'} = $1;
1100 $control{'Control'} = $2;
1101 $control{'Type'} = $3;
1102 $control{'X'} = $4;
1103 $control{'Y'} = $5;
1104 $control{'Width'} = $6;
1105 $control{'Height'} = $7;
1106 $control{'Attributes'} = $8;
1107 $control{'Property'} = $9;
1108 $control{'Text'} = $10;
1109 $control{'Control_Next'} = $11;
1110 $control{'Help'} = $12;
1112 else
1114 installer::exiter::exit_program("ERROR: Could not split line correctly!", "add_licensefile_to_database");
1117 # my $licensetext = get_rtf_licensetext($licensefile);
1118 my $licensetext = make_string_licensetext($licensefile);
1120 $control{'Text'} = $licensetext;
1122 my $newline = $control{'Dialog_'} . "\t" . $control{'Control'} . "\t" . $control{'Type'} . "\t" .
1123 $control{'X'} . "\t" . $control{'Y'} . "\t" . $control{'Width'} . "\t" .
1124 $control{'Height'} . "\t" . $control{'Attributes'} . "\t" . $control{'Property'} . "\t" .
1125 $control{'Text'} . "\t" . $control{'Control_Next'} . "\t" . $control{'Help'} . "\n";
1127 ${$controltable}[$number] = $newline
1131 ################################################################################################
1132 # Including the checkboxes for the language selection dialog
1133 # into the table control.idt . This is only relevant for
1134 # multilingual installation sets.
1136 # old:
1137 # LanguageSelection CheckBox1 CheckBox 22 60 15 24 3 IS1033 CheckBox2
1138 # LanguageSelection Text1 Text 40 60 70 15 65539 OOO_CONTROL_LANG_1033
1139 # LanguageSelection CheckBox2 CheckBox 22 90 15 24 3 IS1031 Next
1140 # LanguageSelection Text2 Text 40 90 70 15 65539 OOO_CONTROL_LANG_1031
1141 # new:
1142 # LanguageSelection CheckBox1 CheckBox 22 60 15 24 3 IS1033 Text CheckBox2
1143 # LanguageSelection CheckBox2 CheckBox 22 90 15 24 3 IS1031 Text Next
1144 ################################################################################################
1146 sub add_language_checkboxes_to_database
1148 my ($controltable, $languagesarrayref) = @_;
1150 # for each language, two lines have to be inserted
1152 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1154 my $last = 0;
1155 if ( $i == $#{$languagesarrayref} ) { $last = 1; } # special handling for the last
1157 my $onelanguage = ${$languagesarrayref}[$i];
1158 my $windowslanguage = installer::windows::language::get_windows_language($onelanguage);
1160 # my $is_english = 0;
1161 # if ( $windowslanguage eq "1033" ) { $is_english = 1; }
1163 my $checkboxattribute = "3";
1164 # if ( $is_english ) { $checkboxattribute = "1"; } # english is not deselectable
1166 my $count = $i + 1;
1167 my $nextcount = $i + 2;
1168 my $checkboxcount = "CheckBox" . $count;
1170 my $multiplier = 20;
1171 my $offset = 60;
1172 if ( $#{$languagesarrayref} > 7 )
1174 $multiplier = 15; # smaller differences for more than 7 languages
1175 $offset = 50; # smaller offset for more than 7 languages
1178 my $yvalue = $offset + $i * $multiplier;
1180 my $property = "IS" . $windowslanguage;
1181 # if ( ! exists($installer::globals::languageproperties{$property}) ) { installer::exiter::exit_program("ERROR: Could not find property \"$property\" in the list of language properties!", "add_language_checkboxes_to_database"); }
1183 my $controlnext = "";
1184 if ( $last ) { $controlnext = "Next"; }
1185 else { $controlnext = "CheckBox" . $nextcount; }
1187 my $stringname = "OOO_CONTROL_LANG_" . $windowslanguage;
1189 my $line1 = "LanguageSelection" . "\t" . $checkboxcount . "\t" . "CheckBox" . "\t" .
1190 "22" . "\t" . $yvalue . "\t" . "200" . "\t" . "15" . "\t" . $checkboxattribute . "\t" .
1191 $property . "\t" . $stringname . "\t" . $controlnext . "\t" . "\n";
1193 push(@{$controltable}, $line1);
1195 # my $textcount = "Text" . $count;
1196 # my $stringname = "OOO_CONTROL_LANG_" . $windowslanguage;
1198 # $yvalue = $yvalue + 2; # text 2 pixel lower than checkbox
1200 # my $line2 = "LanguageSelection" . "\t" . $textcount . "\t" . "Text" . "\t" .
1201 # "40" . "\t" . $yvalue . "\t" . "70" . "\t" . "15" . "\t" . "65539" . "\t" .
1202 # "\t" . $stringname . "\t" . "\t" . "\n";
1204 # push(@{$controltable}, $line2);
1208 ###################################################################
1209 # Determining the last position in a sequencetable
1210 # into the tables CustomAc.idt and InstallE.idt.
1211 ###################################################################
1213 sub get_last_position_in_sequencetable
1215 my ($sequencetable) = @_;
1217 my $position = 0;
1219 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1221 my $line = ${$sequencetable}[$i];
1223 if ( $line =~ /^\s*\w+\t.*\t\s*(\d+)\s$/ )
1225 my $newposition = $1;
1226 if ( $newposition > $position ) { $position = $newposition; }
1230 return $position;
1233 #########################################################################
1234 # Determining the position of a specified Action in the sequencetable
1235 #########################################################################
1237 sub get_position_in_sequencetable
1239 my ($action, $sequencetable) = @_;
1241 my $position = 0;
1243 $action =~ s/^\s*behind_//;
1245 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
1247 my $line = ${$sequencetable}[$i];
1249 if ( $line =~ /^\s*(\w+)\t.*\t\s*(\d+)\s$/ )
1251 my $compareaction = $1;
1252 $position = $2;
1253 if ( $compareaction eq $action ) { last; }
1257 return $position;
1260 ################################################################################################
1261 # Including the CustomAction for the configuration
1262 # into the tables CustomAc.idt and InstallE.idt.
1264 # CustomAc.idt: ExecutePkgchk 82 pkgchk.exe -s
1265 # InstallE.idt: ExecutePkgchk Not REMOVE="ALL" 3175
1267 # CustomAc.idt: ExecuteQuickstart 82 install_quickstart.exe
1268 # InstallE.idt: ExecuteQuickstart &gm_o_Quickstart=3 3200
1270 # CustomAc.idt: ExecuteInstallRegsvrex 82 regsvrex.exe shlxthdl.dll
1271 # InstallE.idt: ExecuteInstallRegsvrex Not REMOVE="ALL" 3225
1273 # CustomAc.idt: ExecuteUninstallRegsvrex 82 regsvrex.exe /u shlxthdl.dll
1274 # InstallE.idt: ExecuteUninstallRegsvrex REMOVE="ALL" 690
1276 # CustomAc.idt: Regmsdocmsidll1 1 reg4msdocmsidll Reg4MsDocEntry
1277 # InstallU.idt: Regmsdocmsidll1 Not REMOVE="ALL" 610
1279 # CustomAc.idt: Regmsdocmsidll2 1 reg4msdocmsidll Reg4MsDocEntry
1280 # InstallE.idt: Regmsdocmsidll2 Not REMOVE="ALL" 3160
1281 ################################################################################################
1283 sub set_custom_action
1285 my ($customactionidttable, $actionname, $actionflags, $exefilename, $actionparameter, $inbinarytable, $filesref, $customactionidttablename, $styles) = @_;
1287 my $included_customaction = 0;
1288 my $infoline = "";
1289 my $customaction_exefilename = $exefilename;
1290 my $uniquename = "";
1292 # when the style NO_FILE is set, no searching for the file is needed, no filtering is done, we can add that custom action
1293 if ( $styles =~ /\bNO_FILE\b/ )
1295 my $line = $actionname . "\t" . $actionflags . "\t" . $customaction_exefilename . "\t" . $actionparameter . "\n";
1296 push(@{$customactionidttable}, $line);
1298 $infoline = "Added $actionname CustomAction into table $customactionidttablename (NO_FILE has been set)\n";
1299 push(@installer::globals::logfileinfo, $infoline);
1301 $included_customaction = 1;
1302 return $included_customaction;
1305 # is the $exefilename a library that is included into the binary table
1307 if ( $inbinarytable ) { $customaction_exefilename =~ s/\.//; } # this is the entry in the binary table ("abc.dll" -> "abcdll")
1309 # is the $exefilename included into the product?
1311 my $contains_file = 0;
1313 # All files are located in $filesref and in @installer::globals::binarytableonlyfiles.
1314 # Both must be added together
1315 my $localfilesref = installer::converter::combine_arrays_from_references(\@installer::globals::binarytableonlyfiles, $filesref);
1317 for ( my $i = 0; $i <= $#{$localfilesref}; $i++ )
1319 my $onefile = ${$localfilesref}[$i];
1320 my $filename = "";
1321 if ( exists($onefile->{'Name'}) )
1323 $filename = $onefile->{'Name'};
1325 if ( $filename eq $exefilename )
1327 $contains_file = 1;
1328 $uniquename = ${$localfilesref}[$i]->{'uniquename'};
1329 last;
1332 else
1334 installer::exiter::exit_program("ERROR: Did not find \"Name\" for file \"$onefile->{'uniquename'}\" ($onefile->{'gid'})!", "set_custom_action");
1338 if ( $contains_file )
1340 # Now the CustomAction can be included into the CustomAc.idt
1342 if ( ! $inbinarytable ) { $customaction_exefilename = $uniquename; } # the unique file name has to be added to the custom action table
1344 my $line = $actionname . "\t" . $actionflags . "\t" . $customaction_exefilename . "\t" . $actionparameter . "\n";
1345 push(@{$customactionidttable}, $line);
1347 $included_customaction = 1;
1350 if ( $included_customaction ) { $infoline = "Added $actionname CustomAction into table $customactionidttablename\n"; }
1351 else { $infoline = "Did not add $actionname CustomAction into table $customactionidttablename\n"; }
1352 push(@installer::globals::logfileinfo, $infoline);
1354 return $included_customaction;
1357 ####################################################################
1358 # Adding a Custom Action to InstallExecuteTable or InstallUITable
1359 ####################################################################
1361 sub add_custom_action_to_install_table
1363 my ($installtable, $exefilename, $actionname, $actioncondition, $position, $filesref, $installtablename, $styles) = @_;
1365 my $included_customaction = 0;
1366 my $feature = "";
1367 my $infoline = "";
1369 # when the style NO_FILE is set, no searching for the file is needed, no filtering is done, we can add that custom action
1370 if ( $styles =~ /\bNO_FILE\b/ )
1372 # then the InstallE.idt.idt or InstallU.idt.idt
1373 $actioncondition =~ s/FEATURETEMPLATE/$feature/g; # only execute Custom Action, if feature of the file is installed
1375 my $actionposition = 0;
1377 if ( $position eq "end" ) { $actionposition = get_last_position_in_sequencetable($installtable) + 25; }
1378 elsif ( $position =~ /^\s*behind_/ ) { $actionposition = get_position_in_sequencetable($position, $installtable) + 2; }
1379 else { $actionposition = get_position_in_sequencetable($position, $installtable) - 2; }
1381 my $line = $actionname . "\t" . $actioncondition . "\t" . $actionposition . "\n";
1382 push(@{$installtable}, $line);
1384 $infoline = "Added $actionname CustomAction into table $installtablename (NO_FILE has been set)\n";
1385 push(@installer::globals::logfileinfo, $infoline);
1386 return;
1389 my $contains_file = 0;
1391 # All files are located in $filesref and in @installer::globals::binarytableonlyfiles.
1392 # Both must be added together
1393 my $localfilesref = installer::converter::combine_arrays_from_references(\@installer::globals::binarytableonlyfiles, $filesref);
1395 for ( my $i = 0; $i <= $#{$localfilesref}; $i++ )
1397 my $filename = ${$localfilesref}[$i]->{'Name'};
1399 if ( $filename eq $exefilename )
1401 $contains_file = 1;
1403 # Determining the feature of the file
1405 if ( ${$localfilesref}[$i] ) { $feature = ${$localfilesref}[$i]->{'modules'}; }
1407 # If modules contains a list of modules, only taking the first one.
1408 if ( $feature =~ /^\s*(.*?)\,/ ) { $feature = $1; }
1409 # Attention: Maximum feature length is 38!
1410 shorten_feature_gid(\$feature);
1412 last;
1416 if ( $contains_file )
1418 # then the InstallE.idt.idt or InstallU.idt.idt
1420 $actioncondition =~ s/FEATURETEMPLATE/$feature/g; # only execute Custom Action, if feature of the file is installed
1422 # my $actionposition = 0;
1423 # if ( $position eq "end" ) { $actionposition = get_last_position_in_sequencetable($installtable) + 25; }
1424 # elsif ( $position =~ /^\s*behind_/ ) { $actionposition = get_position_in_sequencetable($position, $installtable) + 2; }
1425 # else { $actionposition = get_position_in_sequencetable($position, $installtable) - 2; }
1426 # my $line = $actionname . "\t" . $actioncondition . "\t" . $actionposition . "\n";
1428 my $positiontemplate = "";
1429 if ( $position =~ /^\s*\d+\s*$/ ) { $positiontemplate = $position; } # setting the position directly, number defined in scp2
1430 else { $positiontemplate = "POSITIONTEMPLATE_" . $position; }
1432 my $line = $actionname . "\t" . $actioncondition . "\t" . $positiontemplate . "\n";
1433 push(@{$installtable}, $line);
1435 $included_customaction = 1;
1438 if ( $included_customaction ) { $infoline = "Added $actionname CustomAction into table $installtablename\n"; }
1439 else { $infoline = "Did not add $actionname CustomAction into table $installtablename\n"; }
1440 push(@installer::globals::logfileinfo, $infoline);
1444 ##################################################################
1445 # A line in the table ControlEvent connects a Control
1446 # with a Custom Action
1447 #################################################################
1449 sub connect_custom_action_to_control
1451 my ( $table, $tablename, $dialog, $control, $event, $argument, $condition, $ordering) = @_;
1453 my $line = $dialog . "\t" . $control. "\t" . $event. "\t" . $argument. "\t" . $condition. "\t" . $ordering . "\n";
1455 push(@{$table}, $line);
1457 $line =~ s/\s*$//g;
1459 $infoline = "Added line \"$line\" into table $tablename\n";
1460 push(@installer::globals::logfileinfo, $infoline);
1463 ##################################################################
1464 # A line in the table ControlCondition connects a Control state
1465 # with a condition
1466 ##################################################################
1468 sub connect_condition_to_control
1470 my ( $table, $tablename, $dialog, $control, $event, $condition) = @_;
1472 my $line = $dialog . "\t" . $control. "\t" . $event. "\t" . $condition. "\n";
1474 push(@{$table}, $line);
1476 $line =~ s/\s*$//g;
1478 $infoline = "Added line \"$line\" into table $tablename\n";
1479 push(@installer::globals::logfileinfo, $infoline);
1482 ##################################################################
1483 # Searching for a sequencenumber in InstallUISequence table
1484 # "ExecuteAction" must be the last action
1485 ##################################################################
1487 sub get_free_number_in_uisequence_table
1489 my ( $installuitable ) = @_;
1491 # determining the sequence of "ExecuteAction"
1493 my $executeactionnumber = 0;
1495 for ( my $i = 0; $i <= $#{$installuitable}; $i++ )
1497 if ( ${$installuitable}[$i] =~ /^\s*(\w+)\t\w*\t(\d+)\s*$/ )
1499 my $actionname = $1;
1500 my $actionnumber = $2;
1502 if ( $actionname eq "ExecuteAction" )
1504 $executeactionnumber = $actionnumber;
1505 last;
1510 if ( $executeactionnumber == 0 ) { installer::exiter::exit_program("ERROR: Did not find \"ExecuteAction\" in InstallUISequence table!", "get_free_number_in_uisequence_table"); }
1512 # determining the sequence of the action before "ExecuteAction"
1514 my $lastactionnumber = 0;
1516 for ( my $i = 0; $i <= $#{$installuitable}; $i++ )
1518 if ( ${$installuitable}[$i] =~ /^\s*\w+\t\w*\t(\d+)\s*$/ )
1520 my $actionnumber = $1;
1522 if (( $actionnumber > $lastactionnumber ) && ( $actionnumber != $executeactionnumber ))
1524 $lastactionnumber = $actionnumber;
1529 # the new number can now be calculated
1531 my $newnumber = 0;
1533 if ((( $lastactionnumber + $executeactionnumber ) % 2 ) == 0 ) { $newnumber = ( $lastactionnumber + $executeactionnumber ) / 2; }
1534 else { $newnumber = ( $lastactionnumber + $executeactionnumber -1 ) / 2; }
1536 return $newnumber;
1539 ##################################################################
1540 # Searching for a specified string in the feature table
1541 ##################################################################
1543 sub get_feature_name
1545 my ( $string, $featuretable ) = @_;
1547 my $featurename = "";
1549 for ( my $i = 0; $i <= $#{$featuretable}; $i++ )
1551 if ( ${$featuretable}[$i] =~ /^\s*(\w+$string)\t/ )
1553 $featurename = $1;
1554 last;
1558 return $featurename;
1561 ######################################################################
1562 # Returning the toplevel directory name of one specific file
1563 ######################################################################
1565 sub get_directory_name_from_file
1567 my ($onefile) = @_;
1569 my $destination = $onefile->{'destination'};
1570 my $name = $onefile->{'Name'};
1572 $destination =~ s/\Q$name\E\s*$//;
1573 $destination =~ s/\Q$installer::globals::separator\E\s*$//;
1575 my $path = "";
1577 if ( $destination =~ /\Q$installer::globals::separator\E/ )
1579 if ( $destination =~ /^\s*(\S.*\S\Q$installer::globals::separator\E)(\S.+\S?)/ )
1581 $path = $2;
1584 else
1586 $path = $destination;
1589 return $path;
1592 #############################################################
1593 # Including the new subdir into the directory table
1594 #############################################################
1596 sub include_subdirname_into_directory_table
1598 my ($dirname, $directorytable, $directorytablename, $onefile) = @_;
1600 my $subdir = "";
1601 if ( $onefile->{'Subdir'} ) { $subdir = $onefile->{'Subdir'}; }
1602 if ( $subdir eq "" ) { installer::exiter::exit_program("ERROR: No \"Subdir\" defined for $onefile->{'Name'}", "include_subdirname_into_directory_table"); }
1604 # program INSTALLLOCATION program -> subjava INSTALLLOCATION program:java
1606 my $uniquename = "";
1607 my $parent = "";
1608 my $name = "";
1610 my $includedline = 0;
1612 my $newdir = "";
1614 for ( my $i = 0; $i <= $#{$directorytable}; $i++ )
1617 if ( ${$directorytable}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\s*$/ )
1619 $uniquename = $1;
1620 $parent = $2;
1621 $name = $3;
1623 if ( $dirname eq $name )
1625 my $newuniquename = "sub" . $subdir;
1626 $newdir = $newuniquename;
1627 my $newparent = $parent;
1628 my $newname = $name . "\:" . $subdir;
1629 my $newline =
1630 $line = "$newuniquename\t$newparent\t$newname\n";
1631 push(@{$directorytable}, $line);
1632 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1633 $infoline = "Added $line into directory table $directorytablename\n";
1634 push(@installer::globals::logfileinfo, $infoline);
1636 $includedline = 1;
1637 last;
1642 if ( ! $includedline ) { installer::exiter::exit_program("ERROR: Could not include new subdirectory into directory table for file $onefile->{'Name'}!", "include_subdirname_into_directory_table"); }
1644 return $newdir;
1647 ##################################################################
1648 # Including the new sub directory into the component table
1649 ##################################################################
1651 sub include_subdir_into_componenttable
1653 my ($subdir, $onefile, $componenttable) = @_;
1655 my $componentname = $onefile->{'componentname'};
1657 my $changeddirectory = 0;
1659 for ( my $i = 0; $i <= $#{$componenttable}; $i++ )
1661 if ( ${$componenttable}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
1663 my $localcomponentname = $1;
1664 my $directory = $3;
1666 if ( $componentname eq $localcomponentname )
1668 my $oldvalue = ${$componenttable}[$i];
1669 ${$componenttable}[$i] =~ s/\b\Q$directory\E\b/$subdir/;
1670 my $newvalue = ${$componenttable}[$i];
1672 installer::remover::remove_leading_and_ending_whitespaces(\$oldvalue);
1673 installer::remover::remove_leading_and_ending_whitespaces(\$newvalue);
1674 $infoline = "Change in Component table: From \"$oldvalue\" to \"$newvalue\"\n";
1675 push(@installer::globals::logfileinfo, $infoline);
1677 $changeddirectory = 1;
1678 last;
1683 if ( ! $changeddirectory ) { installer::exiter::exit_program("ERROR: Could not change directory for component: $onefile->{'Name'}!", "include_subdir_into_componenttable"); }
1687 ################################################################################################
1688 # Including the content for the child installations
1689 # into the tables:
1690 # CustomAc.idt, InstallU.idt, Feature.idt
1691 ################################################################################################
1693 sub add_childprojects
1695 my ($languageidtdir, $filesref, $allvariables) = @_;
1697 my $customactiontablename = $languageidtdir . $installer::globals::separator . "CustomAc.idt";
1698 my $customactiontable = installer::files::read_file($customactiontablename);
1699 my $installuitablename = $languageidtdir . $installer::globals::separator . "InstallU.idt";
1700 my $installuitable = installer::files::read_file($installuitablename);
1701 my $featuretablename = $languageidtdir . $installer::globals::separator . "Feature.idt";
1702 my $featuretable = installer::files::read_file($featuretablename);
1703 my $directorytablename = $languageidtdir . $installer::globals::separator . "Director.idt";
1704 my $directorytable = installer::files::read_file($directorytablename);
1705 my $componenttablename = $languageidtdir . $installer::globals::separator . "Componen.idt";
1706 my $componenttable = installer::files::read_file($componenttablename);
1708 my $infoline = "";
1709 my $line = "";
1711 $installer::globals::javafile = installer::worker::return_first_item_with_special_flag($filesref ,"JAVAFILE");
1712 $installer::globals::urefile = installer::worker::return_first_item_with_special_flag($filesref ,"UREFILE");
1714 if (( $installer::globals::javafile eq "" ) && ( $allvariables->{'JAVAPRODUCT'} )) { installer::exiter::exit_program("ERROR: No JAVAFILE found in files collector!", "add_childprojects"); }
1715 if (( $installer::globals::urefile eq "" ) && ( $allvariables->{'UREPRODUCT'} )) { installer::exiter::exit_program("ERROR: No UREFILE found in files collector!", "add_childprojects"); }
1717 # Content for Directory table
1718 # SystemFolder TARGETDIR .
1720 my $contains_systemfolder = 0;
1722 for ( my $i = 0; $i <= $#{$directorytable}; $i++ )
1724 if ( ${$directorytable}[$i] =~ /^\s*SystemFolder\t/ )
1726 $contains_systemfolder = 1;
1727 last;
1731 if ( ! $contains_systemfolder )
1733 $line = "SystemFolder\tTARGETDIR\t\.\n";
1734 push(@{$directorytable}, $line);
1735 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1736 $infoline = "Added $line into table $directorytablename\n";
1738 else
1740 $infoline = "SystemFolder already exists in table $directorytablename\n";
1743 push(@installer::globals::logfileinfo, $infoline);
1745 # Additional content for the directory table
1746 # subjava INSTALLLOCATION program:java
1747 # subure INSTALLLOCATION program:ure
1749 my $dirname = "";
1750 my $subjavadir = "";
1751 my $suburedir = "";
1753 if ( $allvariables->{'JAVAPRODUCT'} )
1755 $dirname = get_directory_name_from_file($installer::globals::javafile);
1756 $subjavadir = include_subdirname_into_directory_table($dirname, $directorytable, $directorytablename, $installer::globals::javafile);
1759 if ( $allvariables->{'UREPRODUCT'} )
1761 $dirname = get_directory_name_from_file($installer::globals::urefile);
1762 $suburedir = include_subdirname_into_directory_table($dirname, $directorytable, $directorytablename, $installer::globals::urefile);
1765 # Content for the Component table
1766 # The Java and Ada components have new directories
1768 if ( $allvariables->{'JAVAPRODUCT'} ) { include_subdir_into_componenttable($subjavadir, $installer::globals::javafile, $componenttable); }
1769 if ( $allvariables->{'UREPRODUCT'} ) { include_subdir_into_componenttable($suburedir, $installer::globals::urefile, $componenttable); }
1771 # Content for CustomAction table
1773 if ( $allvariables->{'JAVAPRODUCT'} )
1775 $line = "InstallJava\t98\tSystemFolder\t[SourceDir]$installer::globals::javafile->{'Subdir'}\\$installer::globals::javafile->{'Name'} \/qb REBOOT=Suppress SPONSORS=0 DISABLEAD=1\n";
1776 push(@{$customactiontable} ,$line);
1777 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1778 $infoline = "Added $line into table $customactiontablename\n";
1779 push(@installer::globals::logfileinfo, $infoline);
1782 if ( $allvariables->{'UREPRODUCT'} )
1784 $line = "InstallUre\t98\tSystemFolder\t$installer::globals::urefile->{'Subdir'}\\$installer::globals::urefile->{'Name'} /S\n";
1785 push(@{$customactiontable} ,$line);
1786 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1787 $infoline = "Added $line into table $customactiontablename\n";
1788 push(@installer::globals::logfileinfo, $infoline);
1791 if ( $allvariables->{'JAVAPRODUCT'} )
1793 $line = "MaintenanceJava\t82\t$installer::globals::javafile->{'uniquename'}\t\/qb REBOOT=Suppress SPONSORS=0 DISABLEAD=1\n";
1794 push(@{$customactiontable} ,$line);
1795 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1796 $infoline = "Added $line into table $customactiontablename\n";
1797 push(@installer::globals::logfileinfo, $infoline);
1800 if ( $allvariables->{'UREPRODUCT'} )
1802 $line = "MaintenanceUre\t82\t$installer::globals::urefile->{'uniquename'}\t\/S\n";
1803 push(@{$customactiontable} ,$line);
1804 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1805 $infoline = "Added $line into table $customactiontablename\n";
1806 push(@installer::globals::logfileinfo, $infoline);
1809 # Content for InstallUISequence table
1810 # InstallAdabas &gm_o_Adabas=3 825
1811 # InstallJava &gm_o_Java=3 827
1813 my $number = "";
1814 my $featurename = "";
1816 if ( $allvariables->{'ADAPRODUCT'} )
1818 $number = get_free_number_in_uisequence_table($installuitable);
1819 $featurename = get_feature_name("_Adabas", $featuretable);
1820 $line = "InstallAdabas\t\&$featurename\=3 And Not Installed And Not PATCH\t$number\n";
1821 push(@{$installuitable} ,$line);
1822 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1823 $infoline = "Added $line into table $installuitablename\n";
1824 push(@installer::globals::logfileinfo, $infoline);
1827 if ( $allvariables->{'JAVAPRODUCT'} )
1829 $number = get_free_number_in_uisequence_table($installuitable) + 2;
1830 $featurename = get_feature_name("_Java", $featuretable);
1831 if ( $featurename ) { $line = "InstallJava\t\&$featurename\=3 And Not Installed And JAVAPATH\=\"\" And Not PATCH\t$number\n"; }
1832 else { $line = "InstallJava\tNot Installed And JAVAPATH\=\"\" And Not PATCH\t$number\n"; } # feature belongs to root
1833 push(@{$installuitable} ,$line);
1834 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1835 $infoline = "Added $line into table $installuitablename\n";
1836 push(@installer::globals::logfileinfo, $infoline);
1839 if ( $allvariables->{'ADAPRODUCT'} )
1841 $number = get_free_number_in_uisequence_table($installuitable) + 4;
1842 $featurename = get_feature_name("_Adabas", $featuretable);
1843 $line = "MaintenanceAdabas\t\&$featurename\=3 And Installed And Not PATCH\t$number\n";
1844 push(@{$installuitable} ,$line);
1845 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1846 $infoline = "Added $line into table $installuitablename\n";
1847 push(@installer::globals::logfileinfo, $infoline);
1850 if ( $allvariables->{'JAVAPRODUCT'} )
1852 $number = get_free_number_in_uisequence_table($installuitable) + 6;
1853 $featurename = get_feature_name("_Java", $featuretable);
1854 if ( $featurename ) { $line = "MaintenanceJava\t\&$featurename\=3 And Installed And JAVAPATH\=\"\" And Not PATCH\t$number\n"; }
1855 else { $line = "MaintenanceJava\tInstalled And JAVAPATH\=\"\" And Not PATCH\t$number\n"; } # feature belongs to root
1856 push(@{$installuitable} ,$line);
1857 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1858 $infoline = "Added $line into table $installuitablename\n";
1859 push(@installer::globals::logfileinfo, $infoline);
1862 if ( $allvariables->{'UREPRODUCT'} )
1864 $number = get_free_number_in_uisequence_table($installuitable) + 8;
1865 $featurename = get_feature_name("_Ure", $featuretable);
1866 if ( $featurename ) { $line = "InstallUre\t\&$featurename\=3 And Not Installed\t$number\n"; }
1867 else { $line = "InstallUre\tNot Installed\t$number\n"; } # feature belongs to root
1868 push(@{$installuitable} ,$line);
1869 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1870 $infoline = "Added $line into table $installuitablename\n";
1871 push(@installer::globals::logfileinfo, $infoline);
1874 if ( $allvariables->{'UREPRODUCT'} )
1876 $number = get_free_number_in_uisequence_table($installuitable) + 10;
1877 $featurename = get_feature_name("_Ure", $featuretable);
1878 if ( $featurename ) { $line = "MaintenanceUre\t\&$featurename\=3 And Installed\t$number\n"; }
1879 else { $line = "MaintenanceUre\tInstalled\t$number\n"; } # feature belongs to root
1880 push(@{$installuitable} ,$line);
1881 installer::remover::remove_leading_and_ending_whitespaces(\$line);
1882 $infoline = "Added $line into table $installuitablename\n";
1883 push(@installer::globals::logfileinfo, $infoline);
1886 # Content for Feature table, better from scp (translation)
1887 # gm_o_java gm_optional Java 1.4.2 Description 2 200
1889 installer::files::save_file($customactiontablename, $customactiontable);
1890 installer::files::save_file($installuitablename, $installuitable);
1891 installer::files::save_file($featuretablename, $featuretable);
1892 installer::files::save_file($directorytablename, $directorytable);
1893 installer::files::save_file($componenttablename, $componenttable);
1896 ##################################################################
1897 # Setting the encoding in all idt files. Replacing the
1898 # variable WINDOWSENCODINGTEMPLATE
1899 ##################################################################
1901 sub setencoding
1903 my ( $languageidtdir, $onelanguage ) = @_;
1905 my $encoding = installer::windows::language::get_windows_encoding($onelanguage);
1907 # collecting all idt files in the directory $languageidtdir and substituting the string
1909 my $idtfiles = installer::systemactions::find_file_with_file_extension("idt", $languageidtdir);
1911 for ( my $i = 0; $i <= $#{$idtfiles}; $i++ )
1913 my $onefilename = $languageidtdir . $installer::globals::separator . ${$idtfiles}[$i];
1914 my $onefile = installer::files::read_file($onefilename);
1916 for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1918 ${$onefile}[$j] =~ s/WINDOWSENCODINGTEMPLATE/$encoding/g;
1921 installer::files::save_file($onefilename, $onefile);
1925 ##################################################################
1926 # Setting the condition, that at least one module is selected.
1927 # All modules with flag SHOW_MULTILINGUAL_ONLY were already
1928 # collected. In table ControlE.idt, the string
1929 # LANGUAGECONDITIONINSTALL needs to be replaced.
1930 # Also for APPLICATIONCONDITIONINSTALL for the applications
1931 # with flag APPLICATIONMODULE.
1932 ##################################################################
1934 sub set_multilanguageonly_condition
1936 my ( $languageidtdir ) = @_;
1938 my $onefilename = $languageidtdir . $installer::globals::separator . "ControlE.idt";
1939 my $onefile = installer::files::read_file($onefilename);
1941 # Language modules
1943 my $condition = "";
1945 foreach my $module ( sort keys %installer::globals::multilingual_only_modules )
1947 $condition = $condition . " &$module=3 Or";
1950 $condition =~ s/^\s*//;
1951 $condition =~ s/\s*Or\s*$//; # removing the ending "Or"
1953 if ( $condition eq "" ) { $condition = "1"; }
1955 for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1957 ${$onefile}[$j] =~ s/LANGUAGECONDITIONINSTALL/$condition/;
1960 # Application modules
1962 $condition = "";
1964 foreach my $module ( sort keys %installer::globals::application_modules )
1966 $condition = $condition . " &$module=3 Or";
1969 $condition =~ s/^\s*//;
1970 $condition =~ s/\s*Or\s*$//; # removing the ending "Or"
1972 if ( $condition eq "" ) { $condition = "1"; }
1974 for ( my $j = 0; $j <= $#{$onefile}; $j++ )
1976 ${$onefile}[$j] =~ s/APPLICATIONCONDITIONINSTALL/$condition/;
1979 installer::files::save_file($onefilename, $onefile);
1982 #############################################
1983 # Putting array values into hash
1984 #############################################
1986 sub fill_assignment_hash
1988 my ($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray) = @_;
1990 my $max = $parameter - 1;
1992 if ( $max != $#{$assignmentarray} )
1994 my $definedparameter = $#{$assignmentarray} + 1;
1995 installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Wrong parameter in scp. For table $tablename $parameter parameter are required ! You defined: $definedparameter", "fill_assignment_hash");
1998 for ( my $i = 0; $i <= $#{$assignmentarray}; $i++ )
2000 my $counter = $i + 1;
2001 my $key = "parameter". $counter;
2003 my $localvalue = ${$assignmentarray}[$i];
2004 installer::remover::remove_leading_and_ending_quotationmarks(\$localvalue);
2005 $localvalue =~ s/\\\"/\"/g;
2006 $localvalue =~ s/\\\!/\!/g;
2007 $localvalue =~ s/\\\&/\&/g;
2008 $localvalue =~ s/\\\</\</g;
2009 $localvalue =~ s/\\\>/\>/g;
2010 $assignmenthashref->{$key} = $localvalue;
2014 ##########################################################################
2015 # Checking the assignment of a Windows CustomAction and putting it
2016 # into a hash
2017 ##########################################################################
2019 sub create_customaction_assignment_hash
2021 my ($gid, $name, $key, $assignmentarray) = @_;
2023 my %assignment = ();
2024 my $assignmenthashref = \%assignment;
2026 my $tablename = ${$assignmentarray}[0];
2027 installer::remover::remove_leading_and_ending_quotationmarks(\$tablename);
2029 my $tablename_defined = 0;
2030 my $parameter = 0;
2032 if ( $tablename eq "InstallUISequence" )
2034 $tablename_defined = 1;
2035 $parameter = 3;
2036 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2039 if ( $tablename eq "InstallExecuteSequence" )
2041 $tablename_defined = 1;
2042 $parameter = 3;
2043 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2046 if ( $tablename eq "AdminExecuteSequence" )
2048 $tablename_defined = 1;
2049 $parameter = 3;
2050 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2053 if ( $tablename eq "ControlEvent" )
2055 $tablename_defined = 1;
2056 $parameter = 7;
2057 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2060 if ( $tablename eq "ControlCondition" )
2062 $tablename_defined = 1;
2063 $parameter = 5;
2064 fill_assignment_hash($gid, $name, $key, $assignmenthashref, $parameter, $tablename, $assignmentarray);
2067 if ( ! $tablename_defined )
2069 installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Unknown Windows CustomAction table: $tablename ! Currently supported: InstallUISequence, InstallExecuteSequence, ControlEvent, ControlCondition", "create_customaction_assignment_hash");
2072 return $assignmenthashref;
2075 ##########################################################################
2076 # Finding the position of a specified CustomAction.
2077 # If the CustomAction is not found, the return value is "-1".
2078 # If the CustomAction position is not defined yet,
2079 # the return value is also "-1".
2080 ##########################################################################
2082 sub get_customaction_position
2084 my ($action, $sequencetable) = @_;
2086 my $position = -1;
2088 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2090 my $line = ${$sequencetable}[$i];
2092 if ( $line =~ /^\s*([\w\.]+)\t.*\t\s*(\d+)\s$/ ) # matching only, if position is a number!
2094 my $compareaction = $1;
2095 my $localposition = $2;
2097 if ( $compareaction eq $action )
2099 $position = $localposition;
2100 last;
2105 return $position;
2108 ##########################################################################
2109 # Setting the position of CustomActions in sequence tables.
2110 # Replacing all occurences of "POSITIONTEMPLATE_"
2111 ##########################################################################
2113 sub set_positions_in_table
2115 my ( $sequencetable, $tablename ) = @_;
2117 my $infoline = "\nSetting positions in table \"$tablename\".\n";
2118 push(@installer::globals::logfileinfo, $infoline);
2120 # Step 1: Resolving all occurences of "POSITIONTEMPLATE_end"
2122 my $lastposition = get_last_position_in_sequencetable($sequencetable);
2124 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2126 if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*POSITIONTEMPLATE_end\s*$/ )
2128 my $customaction = $1;
2129 $lastposition = $lastposition + 25;
2130 ${$sequencetable}[$i] =~ s/POSITIONTEMPLATE_end/$lastposition/;
2131 $infoline = "Setting position \"$lastposition\" for custom action \"$customaction\".\n";
2132 push(@installer::globals::logfileinfo, $infoline);
2136 # Step 2: Resolving all occurences of "POSITIONTEMPLATE_abc" or "POSITIONTEMPLATE_behind_abc"
2137 # where abc is the name of the reference Custom Action.
2138 # This has to be done, until there is no more occurence of POSITIONTEMPLATE (success)
2139 # or there is no replacement in one circle (failure).
2141 my $template_exists = 0;
2142 my $template_replaced = 0;
2143 my $counter = 0;
2147 $template_exists = 0;
2148 $template_replaced = 0;
2149 $counter++;
2151 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2153 if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*(POSITIONTEMPLATE_.*?)\s*$/ )
2155 my $onename = $1;
2156 my $templatename = $2;
2157 my $positionname = $templatename;
2158 my $customaction = $templatename;
2159 $customaction =~ s/POSITIONTEMPLATE_//;
2160 $template_exists = 1;
2162 # Trying to find the correct number.
2163 # This can fail, if the custom action has no number
2165 my $setbehind = 0;
2166 if ( $customaction =~ /^\s*behind_(.*?)\s*$/ )
2168 $customaction = $1;
2169 $setbehind = 1;
2172 my $position = get_customaction_position($customaction, $sequencetable);
2174 if ( $position >= 0 ) # Found CustomAction and is has a position. Otherwise return value is "-1".
2176 my $newposition = 0;
2177 if ( $setbehind ) { $newposition = $position + 2; }
2178 else { $newposition = $position - 2; }
2179 ${$sequencetable}[$i] =~ s/$templatename/$newposition/;
2180 $template_replaced = 1;
2181 $infoline = "Setting position \"$newposition\" for custom action \"$onename\" (scp: \"$positionname\" at position $position).\n";
2182 push(@installer::globals::logfileinfo, $infoline);
2184 else
2186 $infoline = "Could not assign position for custom action \"$onename\" yet (scp: \"$positionname\").\n";
2187 push(@installer::globals::logfileinfo, $infoline);
2191 } while (( $template_exists ) && ( $template_replaced ));
2193 # An error occured, because templates still exist, but could not be replaced.
2194 # Reason:
2195 # 1. Wrong name of CustomAction in scp2 (typo?)
2196 # 2. Circular dependencies of CustomActions (A after B and B after A)
2198 # Problem: It is allowed, that a CustomAction is defined in scp2 in a library that is
2199 # part of product ABC, but this CustomAction is not used in this product
2200 # and the reference CustomAction is not part of this product.
2201 # Therefore this cannot be an error, but only produce a warning. The assigned number
2202 # must be the last sequence number.
2204 if (( $template_exists ) && ( ! $template_replaced ))
2206 # Giving a precise error message, collecting all unresolved templates
2207 # my $templatestring = "";
2209 for ( my $i = 0; $i <= $#{$sequencetable}; $i++ )
2211 if ( ${$sequencetable}[$i] =~ /^\s*([\w\.]+)\t.*\t\s*(POSITIONTEMPLATE_.*?)\s*$/ )
2213 my $customactionname = $1;
2214 my $fulltemplate = $2;
2215 my $template = $fulltemplate;
2216 $template =~ s/POSITIONTEMPLATE_//;
2217 # my $newstring = $customactionname . " (" . $template . ")";
2218 # $templatestring = $templatestring . $newstring . ", ";
2219 # Setting at the end!
2220 $lastposition = $lastposition + 25;
2221 ${$sequencetable}[$i] =~ s/$fulltemplate/$lastposition/;
2222 $infoline = "WARNING: Setting position \"$lastposition\" for custom action \"$customactionname\". Could not find CustomAction \"$template\".\n";
2223 push(@installer::globals::logfileinfo, $infoline);
2226 # $templatestring =~ s/,\s*$//;
2228 # $infoline = "Error: Saving table \"$tablename\"\n";
2229 # push(@installer::globals::logfileinfo, $infoline);
2230 # print $infoline;
2231 # installer::files::save_file($tablename, $sequencetable);
2232 # installer::exiter::exit_program("ERROR: Unresolved positions in CustomActions in scp2: $templatestring", "set_positions_in_table");
2236 ##########################################################################
2237 # Setting the Windows custom actions into different tables
2238 # CustomAc.idt, InstallE.idt, InstallU.idt, ControlE.idt, ControlC.idt
2239 ##########################################################################
2241 sub addcustomactions
2243 my ($languageidtdir, $customactions, $filesarray) = @_;
2245 installer::logger::include_timestamp_into_logfile("\nPerformance Info: addcustomactions start\n");
2247 my $customactionidttablename = $languageidtdir . $installer::globals::separator . "CustomAc.idt";
2248 my $customactionidttable = installer::files::read_file($customactionidttablename);
2249 my $installexecutetablename = $languageidtdir . $installer::globals::separator . "InstallE.idt";
2250 my $installexecutetable = installer::files::read_file($installexecutetablename);
2251 my $adminexecutetablename = $languageidtdir . $installer::globals::separator . "AdminExe.idt";
2252 my $adminexecutetable = installer::files::read_file($adminexecutetablename);
2253 my $installuitablename = $languageidtdir . $installer::globals::separator . "InstallU.idt";
2254 my $installuitable = installer::files::read_file($installuitablename);
2255 my $controleventtablename = $languageidtdir . $installer::globals::separator . "ControlE.idt";
2256 my $controleventtable = installer::files::read_file($controleventtablename);
2257 my $controlconditiontablename = $languageidtdir . $installer::globals::separator . "ControlC.idt";
2258 my $controlconditiontable = installer::files::read_file($controlconditiontablename);
2260 # Iterating over all Windows custom actions
2262 for ( my $i = 0; $i <= $#{$customactions}; $i++ )
2264 my $customaction = ${$customactions}[$i];
2265 my $name = $customaction->{'Name'};
2266 my $typ = $customaction->{'Typ'};
2267 my $source = $customaction->{'Source'};
2268 my $target = $customaction->{'Target'};
2269 my $inbinarytable = $customaction->{'Inbinarytable'};
2270 my $gid = $customaction->{'gid'};
2272 my $styles = "";
2273 if ( $customaction->{'Styles'} ) { $styles = $customaction->{'Styles'}; }
2275 my $added_customaction = set_custom_action($customactionidttable, $name, $typ, $source, $target, $inbinarytable, $filesarray, $customactionidttablename, $styles);
2277 if ( $added_customaction )
2279 # If the CustomAction was added into the CustomAc.idt, it can be connected to the installation.
2280 # There are currently two different ways for doing this:
2281 # 1. Using "add_custom_action_to_install_table", which adds the CustomAction to the install sequences,
2282 # which are saved in InstallE.idt and InstallU.idt
2283 # 2. Using "connect_custom_action_to_control" and "connect_custom_action_to_control". The first method
2284 # connects a CustomAction to a control in ControlE.idt. The second method sets a condition for a control,
2285 # which might be influenced by the CustomAction. This happens in ControlC.idt.
2287 # Any Windows CustomAction can have a lot of different assignments.
2289 for ( my $j = 1; $j <= 50; $j++ )
2291 my $key = "Assignment" . $j;
2292 my $value = "";
2293 if ( $customaction->{$key} )
2295 $value = $customaction->{$key};
2297 # in a patch the Assignment can be overwritten by a PatchAssignment
2298 if ( $installer::globals::patch )
2300 $patchkey = "PatchAssignment" . $j;
2301 if ( $customaction->{$patchkey} )
2303 $value = $customaction->{$patchkey};
2304 $key = $patchkey;
2309 else { last; }
2311 # $value is now a comma separated list
2312 if ( $value =~ /^\s*\(\s*(.*)\s*\);?\s*$/ ) { $value = $1; }
2313 my $assignmentarray = installer::converter::convert_stringlist_into_array(\$value, ",");
2314 my $assignment = create_customaction_assignment_hash($gid, $name, $key, $assignmentarray);
2316 if ( $assignment->{'parameter1'} eq "InstallExecuteSequence" )
2318 add_custom_action_to_install_table($installexecutetable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $installexecutetablename, $styles);
2320 elsif ( $assignment->{'parameter1'} eq "AdminExecuteSequence" )
2322 add_custom_action_to_install_table($adminexecutetable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $adminexecutetablename, $styles);
2324 elsif ( $assignment->{'parameter1'} eq "InstallUISequence" )
2326 add_custom_action_to_install_table($installuitable, $source, $name, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $filesarray, $installuitablename, $styles);
2328 elsif ( $assignment->{'parameter1'} eq "ControlEvent" )
2330 connect_custom_action_to_control($controleventtable, $controleventtablename, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $assignment->{'parameter4'}, $assignment->{'parameter5'}, $assignment->{'parameter6'}, $assignment->{'parameter7'});
2332 elsif ( $assignment->{'parameter1'} eq "ControlCondition" )
2334 connect_condition_to_control($controlconditiontable, $controlconditiontablename, $assignment->{'parameter2'}, $assignment->{'parameter3'}, $assignment->{'parameter4'}, $assignment->{'parameter5'});
2336 else
2338 installer::exiter::exit_program("ERROR: gid: $gid, key: $key ! Unknown Windows CustomAction table: $assignmenthashref->{'parameter1'} ! Currently supported: InstallUISequence, InstallESequence, ControlEvent, ControlCondition", "addcustomactions");
2344 # Setting the positions in the tables
2346 set_positions_in_table($installexecutetable, $installexecutetablename);
2347 set_positions_in_table($installuitable, $installuitablename);
2348 set_positions_in_table($adminexecutetable, $adminexecutetablename);
2350 # Saving the files
2352 installer::files::save_file($customactionidttablename, $customactionidttable);
2353 installer::files::save_file($installexecutetablename, $installexecutetable);
2354 installer::files::save_file($adminexecutetablename, $adminexecutetable);
2355 installer::files::save_file($installuitablename, $installuitable);
2356 installer::files::save_file($controleventtablename, $controleventtable);
2357 installer::files::save_file($controlconditiontablename, $controlconditiontable);
2359 my $infoline = "Updated idt file: $customactionidttablename\n";
2360 push(@installer::globals::logfileinfo, $infoline);
2361 $infoline = "Updated idt file: $installexecutetablename\n";
2362 push(@installer::globals::logfileinfo, $infoline);
2363 $infoline = "Updated idt file: $adminexecutetablename\n";
2364 push(@installer::globals::logfileinfo, $infoline);
2365 $infoline = "Updated idt file: $installuitablename\n";
2366 push(@installer::globals::logfileinfo, $infoline);
2367 $infoline = "Updated idt file: $controleventtablename\n";
2368 push(@installer::globals::logfileinfo, $infoline);
2369 $infoline = "Updated idt file: $controlconditiontablename\n";
2370 push(@installer::globals::logfileinfo, $infoline);
2372 installer::logger::include_timestamp_into_logfile("\nPerformance Info: addcustomactions end\n");
2375 ##########################################################################
2376 # Setting bidi attributes in idt tables
2377 ##########################################################################
2379 sub setbidiattributes
2381 my ($languageidtdir, $onelanguage) = @_;
2383 # Editing the files Dialog.idt and Control.idt
2385 my $dialogfilename = $languageidtdir . $installer::globals::separator . "Dialog.idt";
2386 my $controlfilename = $languageidtdir . $installer::globals::separator . "Control.idt";
2388 my $dialogfile = installer::files::read_file($dialogfilename);
2389 my $controlfile = installer::files::read_file($controlfilename);
2391 # Searching attributes in Dialog.idt and adding "896".
2392 # Attributes are in column 6 (from 10).
2394 my $bidiattribute = 896;
2395 for ( my $i = 0; $i <= $#{$dialogfile}; $i++ )
2397 if ( $i < 3 ) { next; }
2398 if ( ${$dialogfile}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
2400 my $one = $1;
2401 my $two = $2;
2402 my $three = $3;
2403 my $four = $4;
2404 my $five = $5;
2405 my $attribute = $6;
2406 my $seven = $7;
2407 my $eight = $8;
2408 $attribute = $attribute + $bidiattribute;
2409 ${$dialogfile}[$i] = "$one\t$two\t$three\t$four\t$five\t$attribute\t$seven\t$eight\n";
2413 # Searching attributes in Control.idt and adding "224".
2414 # Attributes are in column 8 (from 12).
2416 $bidiattribute = 224;
2417 for ( my $i = 0; $i <= $#{$controlfile}; $i++ )
2419 if ( $i < 3 ) { next; }
2420 if ( ${$controlfile}[$i] =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\t(.*?)\s*$/ )
2422 my $one = $1;
2423 my $two = $2;
2424 my $three = $3;
2425 my $four = $4;
2426 my $five = $5;
2427 my $six = $6;
2428 my $seven = $7;
2429 my $attribute = $8;
2430 my $nine = $9;
2431 my $ten = $10;
2432 my $eleven = $11;
2433 my $twelve = $12;
2434 $attribute = $attribute + $bidiattribute;
2435 ${$controlfile}[$i] = "$one\t$two\t$three\t$four\t$five\t$six\t$seven\t$attribute\t$nine\t$ten\t$eleven\t$twelve\n";
2439 # Saving the file
2441 installer::files::save_file($dialogfilename, $dialogfile);
2442 $infoline = "Set bidi support in idt file \"$dialogfilename\" for language $onelanguage\n";
2443 push(@installer::globals::logfileinfo, $infoline);
2445 installer::files::save_file($controlfilename, $controlfile);
2446 $infoline = "Set bidi support in idt file \"$controlfilename\" for language $onelanguage\n";
2447 push(@installer::globals::logfileinfo, $infoline);