Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / configuration.pm
blob09bc9cb262489b1e2925effef1d9bb981e7beda5
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: configuration.pm,v $
11 # $Revision: 1.7 $
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::configuration;
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::logger;
41 use installer::remover;
42 use installer::systemactions;
44 ################################################################################
45 # Getting package from configurationitem (for instance: org.openoffice.Office)
46 # Getting name from configurationitem (for instance: Common)
47 ################################################################################
49 sub analyze_path_of_configurationitem
51 my ($configurationitemsref) = @_;
53 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::analyze_path_of_configurationitem : $#{$configurationitemsref}"); }
55 my ($startpath, $nodes, $name, $packagename, $onenode, $first, $second, $third, $bracketnode);
57 for ( my $i = 0; $i <= $#{$configurationitemsref}; $i++ )
59 my $oneconfig = ${$configurationitemsref}[$i];
60 my $path = $oneconfig->{'Path'};
62 installer::remover::remove_leading_and_ending_slashes(\$path); # in scp are some path beginning with "/"
64 if ( $path =~ /^\s*(.*?)\/(.*)\s*$/ )
66 $startpath = $1;
67 $nodes = $2;
69 else
71 installer::exiter::exit_program("ERROR: Unknown format of ConfigurationItem path: $path", "analyze_path_of_configurationitem");
74 # Startpath is now: org.openoffice.Setup
75 # Nodes is now: Office/Factories/com.sun.star.chart.ChartDocument
77 # Dividing the startpath into package (org.openoffic) and name (Setup).
79 $oneconfig->{'startpath'} = $startpath; # saving the startpath into the hash
81 if ( $startpath =~ /^\s*(\S*)\.(\S*?)\s*$/ )
83 $packagename = $1;
84 $name = $2;
85 $oneconfig->{'name'} = $name;
86 $oneconfig->{'packagename'} = $packagename;
88 else
90 installer::exiter::exit_program("ERROR: Unknown format of ConfigurationItem startpath: $startpath", "analyze_path_of_configurationitem");
93 # Collecting all nodes
95 installer::remover::remove_leading_and_ending_slashes(\$nodes);
97 my $counter = 1;
99 # Attention: Do not trust the slash
100 # Filters/Filter['StarWriter 5.0 Vorlage/Template']
101 # Menus/New/*['m10']/Title
103 if ( $nodes =~ /^(.*\[\')(.*\/.*)(\'\].*)$/ )
105 $first = $1;
106 $second = $2;
107 $third = $3;
109 $second =~ s/\//SUBSTITUTEDSLASH/g; # substituting "/" to "SUBSTITUTEDSLASH"
110 $nodes = $first . $second . $third;
113 while ( $nodes =~ /\// )
115 if ($nodes =~ /^\s*(.*?)\/(.*)\s*$/ )
117 $onenode = $1;
118 $nodes = $2;
119 $nodename = "node". $counter;
121 # Special handling for filters. Difference between:
122 # Filter['StarWriter 5.0 Vorlage/Template'] without oor:op="replace"
123 # *['m10'] with oor:op="replace"
125 if ( $onenode =~ /^\s*Filter\[\'(.*)\'\].*$/ ) { $oneconfig->{'isfilter'} = 1; }
127 # Changing the nodes with brackets:
128 # Filter['StarWriter 5.0 Vorlage/Template']
129 # *['m10']
131 if ( $onenode =~ /^.*\[\'(.*)\'\].*$/ )
133 $onenode = $1;
134 $bracketnode = "bracket_" . $nodename;
135 $oneconfig->{$bracketnode} = 1;
138 $onenode =~ s/SUBSTITUTEDSLASH/\//g; # substituting "SUBSTITUTEDSLASH" to "/"
139 $oneconfig->{$nodename} = $onenode;
141 # special handling for nodes "Factories"
143 if ( $onenode eq "Factories" ) { $oneconfig->{'factoriesnode'} = $counter; }
144 else { $oneconfig->{'factoriesnode'} = -99; }
147 $counter++
150 # and the final node
152 if ( $nodes =~ /^\s*Filter\[\'(.*)\'\].*$/ ) { $oneconfig->{'isfilter'} = 1; }
154 $nodename = "node". $counter;
156 if ( $nodes =~ /^.*\[\'(.*)\'\].*$/ )
158 $nodes = $1;
159 $bracketnode = "bracket_" . $nodename;
160 $oneconfig->{$bracketnode} = 1;
163 $nodes =~ s/SUBSTITUTEDSLASH/\//g; # substituting "SUBSTITUTEDSLASH" to "/"
165 if (($nodes eq "Name") || ($nodes eq "Title")) # isocodes below "Name" or "Title"
167 # if the last node $nodes is "Name" or "Title", it is a Property, not a name! See Common.xcu
169 $oneconfig->{'isisocode'} = 1;
171 if ( $nodes eq "Name" ) { $oneconfig->{'isname'} = 1; }
172 if ( $nodes eq "Title" ) { $oneconfig->{'istitle'} = 1; }
173 $counter--; # decreasing the counter, because "Name" and "Title" are no nodes
175 else
177 $oneconfig->{$nodename} = $nodes;
178 $oneconfig->{'isisocode'} = 0;
181 # special handling for nodes "Factories"
183 if ( $onenode eq "Factories" ) { $oneconfig->{'factoriesnode'} = $counter; }
184 else { $oneconfig->{'factoriesnode'} = -99; }
186 # saving the number of nodes
188 $oneconfig->{'nodenumber'} = $counter;
192 ####################################################################
193 # Inserting the start block into a configuration file
194 ####################################################################
196 sub insert_start_block_into_configfile
198 my ($configfileref, $oneconfig) = @_;
200 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_start_block_into_configfile : $#{$configfileref} : $oneconfig->{'name'}"); }
202 my $line = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
203 push( @{$configfileref}, $line);
205 $line = '<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:install="http://openoffice.org/2004/installation" oor:name="FILENAME" oor:package="PACKAGENAME">' . "\n";
206 my $packagename = $oneconfig->{'packagename'};
207 my $name = $oneconfig->{'name'};
208 $line =~ s/PACKAGENAME/$packagename/g;
209 $line =~ s/FILENAME/$name/g;
210 push( @{$configfileref}, $line);
212 $line = "\n";
213 push( @{$configfileref}, $line);
216 ####################################################################
217 # Inserting the end block into a configuration file
218 ####################################################################
220 sub insert_end_block_into_configfile
222 my ($configfileref) = @_;
224 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_end_block_into_configfile : $#{$configfileref}"); }
226 my $line = "\n" . '</oor:component-data>' . "\n";
227 push( @{$configfileref}, $line);
230 ##############################################################
231 # Getting the content of a node
232 ##############################################################
234 sub get_node_content
236 my ($nodeline) = @_;
238 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::get_node_content : $nodeline"); }
240 my $content = "";
242 if ( $nodeline =~ /name\=\"(.*?)\"/ )
244 $content = $1;
246 else
248 installer::exiter::exit_program("ERROR: Impossible error in function get_node_content!", "get_node_content");
251 return \$content;
254 ##############################################################
255 # Getting the line number of an existing node
256 # Return "-1" if node does not exist
257 ##############################################################
259 sub get_node_line_number
261 my ($nodecount, $oneconfig, $oneconfigfileref) = @_;
263 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::get_node_line_number : $nodecount : $oneconfig->{'name'} : $#{$oneconfigfileref}"); }
265 my $linenumber = -1; # the node does not exists, if returnvalue is "-1"
267 # Attention: Take care of the two title nodes:
268 # Path=org.openoffice.Office.Common/Menus/Wizard/*['m14']/Title
269 # Path=org.openoffice.Office.Common/Menus/Wizard/*['m15']/Title
270 # -> every subnode has to be identical
272 # creating the allnodes string from $oneconfig
274 my $allnodes = "";
276 for ( my $i = 1; $i <= $nodecount; $i++ )
278 my $nodename = "node" . $i;
279 $allnodes .= $oneconfig->{$nodename} . "/";
282 installer::remover::remove_leading_and_ending_slashes(\$allnodes); # exactly this string has to be found in the following iteration
284 # Iterating over the already built configuration file
286 my @allnodes = ();
288 for ( my $i = 0; $i <= $#{$oneconfigfileref}; $i++ )
290 my $line = ${$oneconfigfileref}[$i];
291 installer::remover::remove_leading_and_ending_whitespaces(\$line);
292 my $nodechanged = 0;
294 if ( $line =~ /^\s*\<node/ ) # opening node
296 $nodechanged = 1;
297 my $nodecontentref = get_node_content($line);
298 push(@allnodes, $$nodecontentref); # collecting all nodes in an array
301 if ( $line =~ /^\s*\<\/node/ ) # ending node
303 $nodechanged = 1;
304 pop(@allnodes); # removing the last node from the array
307 if (( $nodechanged ) && ($#allnodes > -1)) # a node was found and the node array is not empty
309 # creating the string to compare with the string $allnodes
311 my $nodestring = "";
313 for ( my $j = 0; $j <= $#allnodes; $j++ )
315 $nodestring .= $allnodes[$j] . "/";
318 installer::remover::remove_leading_and_ending_slashes(\$nodestring);
320 if ( $nodestring eq $allnodes )
322 # that is exactly the same node
324 $linenumber = $i;
325 $linenumber++; # increasing the linenumber
326 last;
332 return $linenumber;
335 ##############################################################
336 # Inserting one configurationitem into the configurationfile
337 ##############################################################
339 sub insert_into_config_file
341 my ($oneconfig, $oneconfigfileref) = @_;
343 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_into_config_file : $oneconfig->{'nodenumber'} : $#{$oneconfigfileref}"); }
345 my ($nodename, $nodecontent, $newnodeline, $bracketkey, $line, $insertline);
347 # interpreting the nodes, keys and values
349 my $nodeline = '<node oor:name="NODECONTENT" REPLACEPART >' . "\n";
350 my $propline = '<prop oor:name="KEYCONTENT" REPLACEPART TYPEPART>' . "\n";
351 my $valueline = '<value SEPARATORPART>VALUECONTENT</value>' . "\n";
352 my $langvalueline = '<value xml:lang="SAVEDLANGUAGE">VALUECONTENT</value>' . "\n";
353 my $propendline = '</prop>' . "\n";
354 my $nodeendline = '</node>' . "\n";
356 my $replacepart = 'oor:op="replace"';
357 my $typepart = 'oor:type="xs:VALUETYPE"'; # VALUETYPE can be "string", "boolean", ...
359 my $nodecount = $oneconfig->{'nodenumber'};
360 my $styles = $oneconfig->{'Styles'};
362 for ( my $i = 1; $i <= $nodecount; $i++ )
364 $insertline = get_node_line_number($i, $oneconfig, $oneconfigfileref);
366 if ( $insertline == -1) # if true, the node does not exist
368 $nodename = "node" . $i;
369 $nodecontent = $oneconfig->{$nodename};
370 $newnodeline = $nodeline;
372 $newnodeline =~ s/NODECONTENT/$nodecontent/g;
374 # Case1:
375 # Nodes with brackets, need the replacepart 'oor:op="replace"'
376 # Bracket node is set for each node with: bracket_node1=1, bracket_node2=1, ...
377 # Case a: <node oor:name="m0" oor:op="replace"> (Common.xcu needs oor:op="replace")
378 # Case b: <node oor:name="Ami Pro 1.x-3.1 (W4W)"> (TypeDetection.xcu does not need oor:op="replace")
379 # For case b introducting a special case for Filters
381 $bracketkey = "bracket_" . $nodename;
383 my $localbracketkey = 0;
385 if ( $oneconfig->{$bracketkey} ) { $localbracketkey = $oneconfig->{$bracketkey}; }
387 if ( $localbracketkey == 1 ) # 'oor:op="replace"' is needed
389 my $isfilter = 0;
390 if ( $oneconfig->{'isfilter'} ) { $isfilter = $oneconfig->{'isfilter'}; }
392 if ( $isfilter == 1 ) # this is a filter
394 $newnodeline =~ s/REPLACEPART//;
396 else
398 $newnodeline =~ s/REPLACEPART/$replacepart/;
401 $newnodeline =~ s/\s*\>/\>/; # removing resulting whitespaces
404 # Case2:
405 # Nodes below a Node "Factories", also need the replacepart 'oor:op="replace"'
406 # This is saved in $oneconfig->{'factoriesnode'}. If not set, the value is "-99"
408 if ( $i == $oneconfig->{'factoriesnode'} )
410 $newnodeline =~ s/REPLACEPART/$replacepart/;
411 $newnodeline =~ s/\s*\>/\>/; # removing resulting whitespaces
414 # Case3:
415 # In all other cases, REPLACEPART in nodes can be removed
417 $newnodeline =~ s/REPLACEPART//;
418 $newnodeline =~ s/\s*\>/\>/; # removing resulting whitespaces
420 # Finding the correct place for inserting the node
422 if ( $i == 1 ) # this is a toplevel node
424 push(@{$oneconfigfileref}, $newnodeline);
425 push(@{$oneconfigfileref}, $nodeendline);
427 else
429 # searching for the parent node
431 my $parentnumber = $i-1;
432 $insertline = get_node_line_number($parentnumber, $oneconfig, $oneconfigfileref);
433 splice(@{$oneconfigfileref}, $insertline, 0, ($newnodeline, $nodeendline));
438 # Setting variables $isbracketnode and $isfactorynode for the properties
441 my $isbracketnode = 0;
442 my $isfactorynode = 0;
444 for ( my $i = 1; $i <= $nodecount; $i++ )
446 $nodename = "node" . $i;
447 $bracketkey = "bracket_" . $nodename;
449 my $localbracketkey = 0;
450 if ( $oneconfig->{$bracketkey} ) { $localbracketkey = $oneconfig->{$bracketkey}; }
452 if ( $localbracketkey == 1 ) { $isbracketnode = 1; }
453 if ( $i == $oneconfig->{'factoriesnode'} ) { $isfactorynode = 1; }
456 # now all nodes exist, and the key and value can be inserted into the configfile
457 # the next line contains the key, for instance: <prop oor:name="UseDefaultMailer" oor:type="xs:boolean">
458 # my $propline = '<prop oor:name="KEYCONTENT" REPLACEPART TYPEPART>' . "\n";
459 # The type is only needed, if a replace is set.
461 my $newpropline = $propline;
463 # Replacement of KEYCONTENT, REPLACEPART and TYPEPART
465 # Case 1:
466 # Properties with oor:name="Name" (Common.xcu) are simply <prop oor:name="Name">
467 # The information about such a property is stored in $oneconfig->{'isisocode'}
469 if ( $oneconfig->{'isisocode'} )
471 if ( $oneconfig->{'isname'} ) { $newpropline =~ s/KEYCONTENT/Name/; } # The property name is always "Name"
472 if ( $oneconfig->{'istitle'} ) { $newpropline =~ s/KEYCONTENT/Title/; } # The property name is always "Title"
473 $newpropline =~ s/REPLACEPART//;
474 $newpropline =~ s/TYPEPART//;
475 $newpropline =~ s/\s*\>/\>/; # removing resulting whitespaces
478 # Begin of all other cases
480 my $key = $oneconfig->{'Key'};
481 $newpropline =~ s/KEYCONTENT/$key/;
483 my $valuetype;
485 if ( $styles =~ /CFG_STRING\b/ ) { $valuetype = "string"; }
486 elsif ( $styles =~ /CFG_NUMERIC/ ) { $valuetype = "int"; }
487 elsif ( $styles =~ /CFG_BOOLEAN/ ) { $valuetype = "boolean"; }
488 elsif ( $styles =~ /CFG_STRINGLIST/ ) { $valuetype = "string-list"; }
489 # elsif ( $styles =~ /CFG_STRINGLIST/ ) { $valuetype = "string-list oor:separator=\"\|\""; }
490 else
492 installer::exiter::exit_program("ERROR: Unknown configuration value type: $styles", "insert_into_config_file");
495 # Case 2:
496 # Properties below a node "Factories" do not need a 'oor:op="replace"' and a 'oor:type="xs:VALUETYPE"'
498 if ( $isfactorynode )
500 $newpropline =~ s/REPLACEPART//;
501 $newpropline =~ s/TYPEPART//;
502 $newpropline =~ s/\s*\>/\>/; # removing resulting whitespaces
505 # Case 3:
506 # Properties below a "bracket" node do not need a 'oor:op="replace"', except they are iso-codes
507 # Assumption here: They are multilingual
509 if ( $isbracketnode )
511 my $localtypepart = $typepart;
512 $localtypepart =~ s/VALUETYPE/$valuetype/;
513 $newpropline =~ s/TYPEPART/$localtypepart/;
515 if ( $oneconfig->{'ismultilingual'} ) # This is solved by "Name" and "Title"
517 $newpropline =~ s/REPLACEPART/$replacepart/;
519 else
521 $newpropline =~ s/REPLACEPART//;
524 $newpropline =~ s/\s*\>/\>/; # removing resulting whitespaces
527 # Case 4:
528 # if the flag CREATE is set, the properties get 'oor:op="replace"' and 'oor:type="xs:VALUETYPE"'
530 if (( $styles =~ /\bCREATE\b/ ) && (!($isbracketnode)))
532 # my $typepart = 'oor:type="xs:VALUETYPE"'; # VALUETYPE can be "string", "boolean", ...
534 my $localtypepart = $typepart;
535 $localtypepart =~ s/VALUETYPE/$valuetype/;
537 $newpropline =~ s/TYPEPART/$localtypepart/;
538 $newpropline =~ s/REPLACEPART/$replacepart/;
539 $newpropline =~ s/\s*\>/\>/; # removing resulting whitespaces
542 # Case 5:
543 # all other ConfigurationItems do not need 'oor:op="replace"' and 'oor:type="xs:VALUETYPE"'
545 $newpropline =~ s/REPLACEPART//;
546 $newpropline =~ s/TYPEPART//;
547 $newpropline =~ s/\s*\>/\>/; # removing resulting whitespaces
549 # finally the value can be set
551 my $value = $oneconfig->{'Value'};
553 # Some values in setup script are written during installation process by the setup. These
554 # have values like "<title>". This will lead to an error, because of the brackets. Therefore the
555 # brackets have to be removed.
557 # ToDo: Substituting the setup replace variables
559 # replace_setting_variables();
561 $value =~ s/^\s*\<//;
562 $value =~ s/\>\s*$//;
564 # Deal with list separators
565 my $separatorpart = '';
566 if ( ($valuetype eq "string-list") && ($value =~ /\|/) )
568 $separatorpart = 'oor:separator="|"';
571 # Fake: substituting german umlauts
573 $value =~ s/\ä/ae/;
574 $value =~ s/\ö/oe/;
575 $value =~ s/\ü/ue/;
576 $value =~ s/\Ä/AE/;
577 $value =~ s/\Ö/OE/;
578 $value =~ s/\Ü/UE/;
580 my $newvalueline;
582 if (!($oneconfig->{'isisocode'} )) # this is the simpe case
584 # my $valueline = '<value SEPARATORPART>VALUECONTENT</value>' . "\n";
585 $newvalueline = $valueline;
586 $newvalueline =~ s/VALUECONTENT/$value/g;
587 $newvalueline =~ s/SEPARATORPART/$separatorpart/;
589 else
591 # my $langvalueline = '<value xml:lang="SAVEDLANGUAGE">VALUECONTENT</value>' . "\n";
592 $newvalueline = $langvalueline;
593 $newvalueline =~ s/VALUECONTENT/$value/;
594 my $savedlanguage = $oneconfig->{'Key'};
595 $newvalueline =~ s/SAVEDLANGUAGE/$savedlanguage/;
598 # For language dependent values, it is possible, that the property already exist.
599 # In this case the prop must not be created again and only the value has to be included:
600 # <prop oor:name="Name">
601 # <value xml:lang="de">OpenOffice.org 2.0 Diagramm</value>
602 # <value xml:lang="en-US">OpenOffice.org 2.0 Chart</value>
603 # </prop>
605 # The key has to be written after the line, containing the complete node
607 $insertline = get_node_line_number($nodecount, $oneconfig, $oneconfigfileref);
609 if ( $oneconfig->{'ismultilingual'} )
611 if ( $newpropline eq ${$oneconfigfileref}[$insertline] )
613 if (!($newvalueline eq ${$oneconfigfileref}[$insertline+1])) # only include, if the value not already exists (example: value="FALSE" for many languages)
615 splice(@{$oneconfigfileref}, $insertline+1, 0, ($newvalueline)); # only the value needs to be added
618 else
620 splice(@{$oneconfigfileref}, $insertline, 0, ($newpropline, $newvalueline, $propendline));
623 else
625 splice(@{$oneconfigfileref}, $insertline, 0, ($newpropline, $newvalueline, $propendline));
628 return $oneconfigfileref;
631 ##########################################################
632 # Inserting tabs for better view into configuration file
633 ##########################################################
635 sub insert_tabs_into_configfile
637 my ($configfileref) = @_;
639 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_tabs_into_configfile : $#{$configfileref}"); }
641 my $counter = 0;
643 for ( my $i = 0; $i <= $#{$configfileref}; $i++ )
645 my $line = ${$configfileref}[$i];
646 my $linebefore = ${$configfileref}[$i-1];
648 if (( $line =~ /^\s*\<node/ ) || ( $line =~ /^\s*\<prop/ ))
650 if ((!( $linebefore =~ /^\s*\<\/node/ )) && (!( $linebefore =~ /^\s*\<\/prop/ ))) # do not increase after "</node" and after "</prop"
652 $counter++;
656 if ( $line =~ /^\s*\<value/ )
658 if (!($linebefore =~ /^\s*\<value/ )) # do not increase counter with "<value>" after "<value>" (multilingual configitems)
660 $counter++;
664 if (( $line =~ /^\s*\<\/node\>/ ) || ( $line =~ /^\s*\<\/prop\>/ ))
666 if ((!( $linebefore =~ /^\s*\<node/ )) && (!( $linebefore =~ /^\s*\<prop/ ))) # do not decrease after "<node" and after "<prop"
668 $counter--;
672 if ($counter > 0)
674 for ( my $j = 0; $j < $counter; $j++ )
676 $line = "\t" . $line;
680 ${$configfileref}[$i] = $line;
684 ######################################################################
685 # Collecting all different configuration items (Files and Modules)
686 ######################################################################
688 sub collect_all_configuration_items
690 my ($configurationitemsref, $item) = @_;
692 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::collect_all_configuration_items : $#{$configurationitemsref} : $item"); }
694 my @allitems = ();
696 for ( my $i = 0; $i <= $#{$configurationitemsref}; $i++ )
698 my $oneconfig = ${$configurationitemsref}[$i];
700 if (! installer::existence::exists_in_array($oneconfig->{$item}, \@allitems))
702 push(@allitems, $oneconfig->{$item});
706 return \@allitems;
709 ######################################################################
710 # Collecting all module specific configuration items
711 ######################################################################
713 sub get_all_configitems_at_module
715 my ($moduleid, $configurationitemsref) = @_;
717 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::get_all_configitems_at_module : $moduleid : $#{$configurationitemsref}"); }
719 my @moduleconfigurationitems = ();
721 for ( my $i = 0; $i <= $#{$configurationitemsref}; $i++ )
723 my $oneconfig = ${$configurationitemsref}[$i];
725 if ( $oneconfig->{'ModuleID'} eq $moduleid )
727 push(@moduleconfigurationitems, $oneconfig);
731 return \@moduleconfigurationitems;
734 #######################################################
735 # Saving and zipping the created configurationfile
736 #######################################################
738 sub save_and_zip_configfile
740 my ($oneconfigfileref, $onefile, $onemodule, $configdir) = @_;
742 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::save_and_zip_configfile : $#{$oneconfigfileref} : $onefile : $onemodule : $configdir"); }
744 my $savefilename = $onefile;
745 $savefilename =~ s/\./\_/g;
746 $savefilename = $savefilename . "_" . $onemodule;
747 $savefilename = $savefilename . ".xcu";
748 my $shortsavefilename = $savefilename;
750 $savefilename = $configdir . $installer::globals::separator . $savefilename;
752 installer::files::save_file($savefilename, $oneconfigfileref);
754 # zipping the configfile
756 my $returnvalue = 1;
758 my $zipfilename = $shortsavefilename;
759 $zipfilename =~ s/\.xcu/\.zip/;
761 my $currentdir = cwd();
762 if ( $installer::globals::iswin ) { $currentdir =~ s/\//\\/g; }
764 chdir($configdir);
766 my $systemcall = "$installer::globals::zippath -q -m $zipfilename $shortsavefilename";
767 $returnvalue = system($systemcall);
769 chdir($currentdir);
771 my $infoline = "Systemcall: $systemcall\n";
772 push( @installer::globals::logfileinfo, $infoline);
774 if ($returnvalue)
776 $infoline = "ERROR: Could not zip $savefilename to $zipfilename\n";
778 else
780 $infoline = "SUCCESS: Zipped file $savefilename to $zipfilename\n";
782 push( @installer::globals::logfileinfo, $infoline);
784 return $zipfilename;
787 #####################################################################
788 # Adding the newly created configuration file into the file list
789 #####################################################################
791 sub add_zipfile_into_filelist
793 my ($zipfilename, $configdir, $filesarrayref, $onemodule) = @_;
795 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::add_zipfile_into_filelist: $zipfilename : $configdir : $#{$filesarrayref} : $onemodule"); }
797 my $longzipfilename = $configdir . $installer::globals::separator . $zipfilename;
798 my $gid = "gid_" . $zipfilename;
799 $gid =~ s/\./\_/g;
801 my %configfile = ();
803 # Taking the base data from the "gid_File_Lib_Vcl"
805 my $vclgid = "gid_File_Lib_Vcl";
806 my $vclfile = installer::existence::get_specified_file($filesarrayref, $vclgid);
808 # copying all base data
809 installer::converter::copy_item_object($vclfile, \%configfile);
811 # and overriding all new data
812 $configfile{'ismultilingual'} = 0;
813 $configfile{'sourcepath'} = $longzipfilename;
814 $configfile{'Name'} = $zipfilename;
815 $configfile{'UnixRights'} = "644";
816 $configfile{'gid'} = $gid;
817 $configfile{'Dir'} = "gid_Dir_Share_Uno_Packages";
818 $configfile{'destination'} = "share" . $installer::globals::separator . "uno_packages" . $installer::globals::separator . $zipfilename;
819 $configfile{'modules'} = $onemodule; # assigning the file to the correct module!
821 push(@{$filesarrayref}, \%configfile);
824 #######################################################
825 # Creating configuration files from configurationitems
826 #######################################################
828 sub create_configuration_files
830 my ($configurationitemsref, $filesarrayref, $languagestringref) = @_;
832 if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::create_configuration_files: $#{$configurationitemsref} : $#{$filesarrayref} : $$languagestringref"); }
834 installer::logger::include_header_into_logfile("Creating configuration files:");
836 # creating the directory
838 my $configdir = installer::systemactions::create_directories("configfiles", $languagestringref);
840 $configdir = installer::converter::make_path_conform($configdir);
842 # collecting an array of all modules
843 my $allmodules = collect_all_configuration_items($configurationitemsref, "ModuleID");
845 # iterating over all modules
847 for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
849 my $onemodule = ${$allmodules}[$i];
851 my $moduleconfigitems = get_all_configitems_at_module($onemodule, $configurationitemsref);
853 # collecting an array of all "startpath". This are all different files (org.openoffice.Office.Common).
854 my $allfiles = collect_all_configuration_items($moduleconfigitems, "startpath");
856 # iteration over all files
858 for ( my $j = 0; $j <= $#{$allfiles}; $j++ )
860 my $onefile = ${$allfiles}[$j];
862 my @oneconfigfile = ();
863 my $oneconfigfileref = \@oneconfigfile;
865 my $startblockwritten = 0;
867 for ( my $k = 0; $k <= $#{$moduleconfigitems}; $k++ )
869 my $oneconfig = ${$moduleconfigitems}[$k];
871 my $startpath = $oneconfig->{'startpath'};
873 if ($startpath eq $onefile)
875 if (!($startblockwritten)) # writing some global lines into the xcu file
877 insert_start_block_into_configfile($oneconfigfileref, $oneconfig);
878 $startblockwritten = 1;
881 $oneconfigfileref = insert_into_config_file($oneconfig, $oneconfigfileref);
885 insert_end_block_into_configfile($oneconfigfileref);
887 # inserting tabs for nice appearance
888 insert_tabs_into_configfile($oneconfigfileref);
890 # saving the configfile
891 my $zipfilename = save_and_zip_configfile($oneconfigfileref, $onefile, $onemodule, $configdir);
893 # adding the zipped configfile to the list of installed files
894 # Some data are set now, others are taken from the file "soffice.exe" ("soffice.bin")
896 add_zipfile_into_filelist($zipfilename, $configdir, $filesarrayref, $onemodule);
900 my $infoline = "\n";
901 push( @installer::globals::logfileinfo, $infoline);