summaryrefslogtreecommitdiff
path: root/solenv/bin/modules/installer/configuration.pm
blob: ed6a5b4b270784ea6c91e4145ed483c47c138fe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2008 by Sun Microsystems, Inc.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: configuration.pm,v $
#
# $Revision: 1.7 $
#
# This file is part of OpenOffice.org.
#
# OpenOffice.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenOffice.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenOffice.org.  If not, see
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
#*************************************************************************

package installer::configuration;

use Cwd;
use installer::converter;
use installer::existence;
use installer::exiter;
use installer::files;
use installer::globals;
use installer::logger;
use installer::remover;
use installer::systemactions;

################################################################################
# Getting package from configurationitem (for instance: org.openoffice.Office)
# Getting name from configurationitem (for instance: Common)
################################################################################

sub analyze_path_of_configurationitem
{
    my ($configurationitemsref) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::analyze_path_of_configurationitem : $#{$configurationitemsref}"); }

    my ($startpath, $nodes, $name, $packagename, $onenode, $first, $second, $third, $bracketnode);

    for ( my $i = 0; $i <= $#{$configurationitemsref}; $i++ )
    {
        my $oneconfig = ${$configurationitemsref}[$i];
        my $path = $oneconfig->{'Path'};

        installer::remover::remove_leading_and_ending_slashes(\$path);  # in scp are some path beginning with "/"

        if ( $path =~ /^\s*(.*?)\/(.*)\s*$/ )
        {
            $startpath = $1;
            $nodes = $2;
        }
        else
        {
            installer::exiter::exit_program("ERROR: Unknown format of ConfigurationItem path: $path", "analyze_path_of_configurationitem");
        }

        # Startpath is now: org.openoffice.Setup
        # Nodes is now: Office/Factories/com.sun.star.chart.ChartDocument

        # Dividing the startpath into package (org.openoffic) and name (Setup).

        $oneconfig->{'startpath'} = $startpath; # saving the startpath into the hash

        if ( $startpath =~ /^\s*(\S*)\.(\S*?)\s*$/ )
        {
            $packagename = $1;
            $name = $2;
            $oneconfig->{'name'} = $name;
            $oneconfig->{'packagename'} = $packagename;
        }
        else
        {
            installer::exiter::exit_program("ERROR: Unknown format of ConfigurationItem startpath: $startpath", "analyze_path_of_configurationitem");
        }

        # Collecting all nodes

        installer::remover::remove_leading_and_ending_slashes(\$nodes);

        my $counter = 1;

        # Attention: Do not trust the slash
        # Filters/Filter['StarWriter 5.0 Vorlage/Template']
        # Menus/New/*['m10']/Title

        if ( $nodes =~ /^(.*\[\')(.*\/.*)(\'\].*)$/ )
        {
            $first = $1;
            $second = $2;
            $third = $3;

            $second =~ s/\//SUBSTITUTEDSLASH/g; # substituting "/" to "SUBSTITUTEDSLASH"
            $nodes = $first . $second . $third;
        }

        while ( $nodes =~ /\// )
        {
            if ($nodes =~ /^\s*(.*?)\/(.*)\s*$/ )
            {
                $onenode = $1;
                $nodes = $2;
                $nodename = "node". $counter;

                # Special handling for filters. Difference between:
                # Filter['StarWriter 5.0 Vorlage/Template'] without oor:op="replace"
                # *['m10'] with oor:op="replace"

                if ( $onenode =~ /^\s*Filter\[\'(.*)\'\].*$/ ) { $oneconfig->{'isfilter'} = 1; }

                # Changing the nodes with brackets:
                # Filter['StarWriter 5.0 Vorlage/Template']
                # *['m10']

                if ( $onenode =~ /^.*\[\'(.*)\'\].*$/ )
                {
                    $onenode = $1;
                    $bracketnode = "bracket_" . $nodename;
                    $oneconfig->{$bracketnode} = 1;
                }

                $onenode =~ s/SUBSTITUTEDSLASH/\//g;    # substituting "SUBSTITUTEDSLASH" to "/"
                $oneconfig->{$nodename} = $onenode;

                # special handling for nodes "Factories"

                if ( $onenode eq "Factories" ) { $oneconfig->{'factoriesnode'} = $counter; }
                else { $oneconfig->{'factoriesnode'} = -99; }
            }

            $counter++
        }

        # and the final node

        if ( $nodes =~ /^\s*Filter\[\'(.*)\'\].*$/ ) { $oneconfig->{'isfilter'} = 1; }

        $nodename = "node". $counter;

        if ( $nodes =~ /^.*\[\'(.*)\'\].*$/ )
        {
            $nodes = $1;
            $bracketnode = "bracket_" . $nodename;
            $oneconfig->{$bracketnode} = 1;
        }

        $nodes =~ s/SUBSTITUTEDSLASH/\//g;  # substituting "SUBSTITUTEDSLASH" to "/"

        if (($nodes eq "Name") || ($nodes eq "Title"))  # isocodes below "Name" or "Title"
        {
            # if the last node $nodes is "Name" or "Title", it is a Property, not a name! See Common.xcu

            $oneconfig->{'isisocode'} = 1;

            if ( $nodes eq "Name" ) { $oneconfig->{'isname'} = 1; }
            if ( $nodes eq "Title" ) { $oneconfig->{'istitle'} = 1; }
            $counter--;     # decreasing the counter, because "Name" and "Title" are no nodes
        }
        else
        {
            $oneconfig->{$nodename} = $nodes;
            $oneconfig->{'isisocode'} = 0;
        }

        # special handling for nodes "Factories"

        if ( $onenode eq "Factories" ) { $oneconfig->{'factoriesnode'} = $counter; }
        else { $oneconfig->{'factoriesnode'} = -99; }

        # saving the number of nodes

        $oneconfig->{'nodenumber'} = $counter;
    }
}

####################################################################
# Inserting the start block into a configuration file
####################################################################

sub insert_start_block_into_configfile
{
    my ($configfileref, $oneconfig) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_start_block_into_configfile : $#{$configfileref} : $oneconfig->{'name'}"); }

    my $line = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    push( @{$configfileref}, $line);

    $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";
    my $packagename = $oneconfig->{'packagename'};
    my $name = $oneconfig->{'name'};
    $line =~ s/PACKAGENAME/$packagename/g;
    $line =~ s/FILENAME/$name/g;
    push( @{$configfileref}, $line);

    $line = "\n";
    push( @{$configfileref}, $line);
}

####################################################################
# Inserting the end block into a configuration file
####################################################################

sub insert_end_block_into_configfile
{
    my ($configfileref) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_end_block_into_configfile : $#{$configfileref}"); }

    my $line = "\n" . '</oor:component-data>' . "\n";
    push( @{$configfileref}, $line);
}

##############################################################
# Getting the content of a node
##############################################################

sub get_node_content
{
    my ($nodeline) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::get_node_content : $nodeline"); }

    my $content = "";

    if ( $nodeline =~ /name\=\"(.*?)\"/ )
    {
        $content = $1;
    }
    else
    {
        installer::exiter::exit_program("ERROR: Impossible error in function get_node_content!", "get_node_content");
    }

    return \$content;
}

##############################################################
# Getting the line number of an existing node
# Return "-1" if node does not exist
##############################################################

sub get_node_line_number
{
    my ($nodecount, $oneconfig, $oneconfigfileref) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::get_node_line_number : $nodecount : $oneconfig->{'name'} : $#{$oneconfigfileref}"); }

    my $linenumber = -1;    # the node does not exists, if returnvalue is "-1"

    # Attention: Take care of the two title nodes:
    # Path=org.openoffice.Office.Common/Menus/Wizard/*['m14']/Title
    # Path=org.openoffice.Office.Common/Menus/Wizard/*['m15']/Title
    # -> every subnode has to be identical

    # creating the allnodes string from $oneconfig

    my $allnodes = "";

    for ( my $i = 1; $i <= $nodecount; $i++ )
    {
        my $nodename = "node" . $i;
        $allnodes .= $oneconfig->{$nodename} . "/";
    }

    installer::remover::remove_leading_and_ending_slashes(\$allnodes);  # exactly this string has to be found  in the following iteration

    # Iterating over the already built configuration file

    my @allnodes = ();

    for ( my $i = 0; $i <= $#{$oneconfigfileref}; $i++ )
    {
        my $line = ${$oneconfigfileref}[$i];
        installer::remover::remove_leading_and_ending_whitespaces(\$line);
        my $nodechanged = 0;

        if ( $line =~ /^\s*\<node/ )    # opening node
        {
            $nodechanged = 1;
            my $nodecontentref = get_node_content($line);
            push(@allnodes, $$nodecontentref);  # collecting all nodes in an array
        }

        if ( $line =~ /^\s*\<\/node/ )  # ending node
        {
            $nodechanged = 1;
            pop(@allnodes);     # removing the last node from the array
        }

        if (( $nodechanged ) && ($#allnodes > -1))  # a node was found and the node array is not empty
        {
            # creating the string to compare with the string $allnodes

            my $nodestring = "";

            for ( my $j = 0; $j <= $#allnodes; $j++ )
            {
                $nodestring .= $allnodes[$j] . "/";
            }

            installer::remover::remove_leading_and_ending_slashes(\$nodestring);

            if ( $nodestring eq $allnodes )
            {
                # that is exactly the same node

                $linenumber = $i;
                $linenumber++;  # increasing the linenumber
                last;

            }
        }
    }

    return $linenumber;
}

##############################################################
# Inserting one configurationitem into the configurationfile
##############################################################

sub insert_into_config_file
{
    my ($oneconfig, $oneconfigfileref) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_into_config_file : $oneconfig->{'nodenumber'} : $#{$oneconfigfileref}"); }

    my ($nodename, $nodecontent, $newnodeline, $bracketkey, $line, $insertline);

    # interpreting the nodes, keys and values

    my $nodeline = '<node oor:name="NODECONTENT" REPLACEPART >' . "\n";
    my $propline = '<prop oor:name="KEYCONTENT" REPLACEPART TYPEPART>' . "\n";
    my $valueline = '<value SEPARATORPART>VALUECONTENT</value>' . "\n";
    my $langvalueline = '<value xml:lang="SAVEDLANGUAGE">VALUECONTENT</value>' . "\n";
    my $propendline = '</prop>' . "\n";
    my $nodeendline = '</node>' . "\n";

    my $replacepart = 'oor:op="replace"';
    my $typepart = 'oor:type="xs:VALUETYPE"';   # VALUETYPE can be "string", "boolean", ...

    my $nodecount = $oneconfig->{'nodenumber'};
    my $styles = $oneconfig->{'Styles'};

    for ( my $i = 1; $i <= $nodecount; $i++ )
    {
        $insertline = get_node_line_number($i, $oneconfig, $oneconfigfileref);

        if ( $insertline == -1) # if true, the node does not exist
        {
            $nodename = "node" . $i;
            $nodecontent = $oneconfig->{$nodename};
            $newnodeline = $nodeline;

            $newnodeline =~ s/NODECONTENT/$nodecontent/g;

            # Case1:
            # Nodes with brackets, need the replacepart 'oor:op="replace"'
            # Bracket node is set for each node with: bracket_node1=1, bracket_node2=1, ...
            # Case a: <node oor:name="m0" oor:op="replace">     (Common.xcu needs oor:op="replace")
            # Case b: <node oor:name="Ami Pro 1.x-3.1 (W4W)">   (TypeDetection.xcu does not need oor:op="replace")
            # For case b introducting a special case for Filters

            $bracketkey = "bracket_" . $nodename;

            my $localbracketkey = 0;

            if ( $oneconfig->{$bracketkey} ) { $localbracketkey = $oneconfig->{$bracketkey}; }

            if ( $localbracketkey == 1 )    # 'oor:op="replace"' is needed
            {
                my $isfilter = 0;
                if ( $oneconfig->{'isfilter'} ) { $isfilter = $oneconfig->{'isfilter'}; }

                if ( $isfilter == 1 )   # this is a filter
                {
                    $newnodeline =~ s/REPLACEPART//;
                }
                else
                {
                    $newnodeline =~ s/REPLACEPART/$replacepart/;
                }

                $newnodeline =~ s/\s*\>/\>/;    # removing resulting whitespaces
            }

            # Case2:
            # Nodes below a Node "Factories", also need the replacepart 'oor:op="replace"'
            # This is saved in $oneconfig->{'factoriesnode'}. If not set, the value is "-99"

            if ( $i == $oneconfig->{'factoriesnode'} )
            {
                $newnodeline =~ s/REPLACEPART/$replacepart/;
                $newnodeline =~ s/\s*\>/\>/;    # removing resulting whitespaces
            }

            # Case3:
            # In all other cases, REPLACEPART in nodes can be removed

            $newnodeline =~ s/REPLACEPART//;
            $newnodeline =~ s/\s*\>/\>/;    # removing resulting whitespaces

            # Finding the correct place for inserting the node

            if ( $i == 1 )  # this is a toplevel node
            {
                push(@{$oneconfigfileref}, $newnodeline);
                push(@{$oneconfigfileref}, $nodeendline);
            }
            else
            {
                # searching for the parent node

                my $parentnumber = $i-1;
                $insertline = get_node_line_number($parentnumber, $oneconfig, $oneconfigfileref);
                splice(@{$oneconfigfileref}, $insertline, 0, ($newnodeline, $nodeendline));
            }
        }
    }

    # Setting variables $isbracketnode and $isfactorynode for the properties


    my $isbracketnode = 0;
    my $isfactorynode = 0;

    for ( my $i = 1; $i <= $nodecount; $i++ )
    {
        $nodename = "node" . $i;
        $bracketkey = "bracket_" . $nodename;

        my $localbracketkey = 0;
        if ( $oneconfig->{$bracketkey} ) { $localbracketkey = $oneconfig->{$bracketkey}; }

        if ( $localbracketkey == 1 ) { $isbracketnode = 1;  }
        if ( $i == $oneconfig->{'factoriesnode'} ) { $isfactorynode = 1; }
    }

    # now all nodes exist, and the key and value can be inserted into the configfile
    # the next line contains the key, for instance: <prop oor:name="UseDefaultMailer" oor:type="xs:boolean">
    # my $propline = '<prop oor:name="KEYCONTENT" REPLACEPART TYPEPART>' . "\n";
    # The type is only needed, if a replace is set.

    my $newpropline = $propline;

    # Replacement of KEYCONTENT, REPLACEPART and TYPEPART

    # Case 1:
    # Properties with oor:name="Name" (Common.xcu) are simply <prop oor:name="Name">
    # The information about such a property is stored in $oneconfig->{'isisocode'}

    if ( $oneconfig->{'isisocode'} )
    {
        if ( $oneconfig->{'isname'} ) { $newpropline =~ s/KEYCONTENT/Name/; }       # The property name is always "Name"
        if ( $oneconfig->{'istitle'} ) { $newpropline =~ s/KEYCONTENT/Title/; }     # The property name is always "Title"
        $newpropline =~ s/REPLACEPART//;
        $newpropline =~ s/TYPEPART//;
        $newpropline =~ s/\s*\>/\>/;    # removing resulting whitespaces
    }

    # Begin of all other cases

    my $key = $oneconfig->{'Key'};
    $newpropline =~ s/KEYCONTENT/$key/;

    my $valuetype;

    if ( $styles =~ /CFG_STRING\b/ ) { $valuetype = "string"; }
    elsif ( $styles =~ /CFG_NUMERIC/ ) { $valuetype = "int"; }
    elsif ( $styles =~ /CFG_BOOLEAN/ ) { $valuetype = "boolean"; }
    elsif ( $styles =~ /CFG_STRINGLIST/ ) { $valuetype = "string-list"; }
#   elsif ( $styles =~ /CFG_STRINGLIST/ ) { $valuetype = "string-list oor:separator=\"\|\""; }
    else
    {
        installer::exiter::exit_program("ERROR: Unknown configuration value type: $styles", "insert_into_config_file");
    }

    # Case 2:
    # Properties below a node "Factories" do not need a 'oor:op="replace"' and a 'oor:type="xs:VALUETYPE"'

    if ( $isfactorynode )
    {
        $newpropline =~ s/REPLACEPART//;
        $newpropline =~ s/TYPEPART//;
        $newpropline =~ s/\s*\>/\>/;    # removing resulting whitespaces
    }

    # Case 3:
    # Properties below a "bracket" node do not need a 'oor:op="replace"', except they are iso-codes
    # Assumption here: They are multilingual

    if ( $isbracketnode )
    {
        my $localtypepart = $typepart;
        $localtypepart =~ s/VALUETYPE/$valuetype/;
        $newpropline =~ s/TYPEPART/$localtypepart/;

        if ( $oneconfig->{'ismultilingual'} )   # This is solved by "Name" and "Title"
        {
            $newpropline =~ s/REPLACEPART/$replacepart/;
        }
        else
        {
            $newpropline =~ s/REPLACEPART//;
        }

        $newpropline =~ s/\s*\>/\>/;    # removing resulting whitespaces
    }

    # Case 4:
    # if the flag CREATE is set, the properties get 'oor:op="replace"' and 'oor:type="xs:VALUETYPE"'

    if (( $styles =~ /\bCREATE\b/ ) && (!($isbracketnode)))
    {
        # my $typepart = 'oor:type="xs:VALUETYPE"'; # VALUETYPE can be "string", "boolean", ...

        my $localtypepart = $typepart;
        $localtypepart =~ s/VALUETYPE/$valuetype/;

        $newpropline =~ s/TYPEPART/$localtypepart/;
        $newpropline =~ s/REPLACEPART/$replacepart/;
        $newpropline =~ s/\s*\>/\>/;    # removing resulting whitespaces
    }

    # Case 5:
    # all other ConfigurationItems do not need 'oor:op="replace"' and 'oor:type="xs:VALUETYPE"'

    $newpropline =~ s/REPLACEPART//;
    $newpropline =~ s/TYPEPART//;
    $newpropline =~ s/\s*\>/\>/;    # removing resulting whitespaces

    # finally the value can be set

    my $value = $oneconfig->{'Value'};

    # Some values in setup script are written during installation process by the setup. These
    # have values like "<title>". This will lead to an error, because of the brackets. Therefore the
    # brackets have to be removed.

    # ToDo: Substituting the setup replace variables

    # replace_setting_variables();

    $value =~ s/^\s*\<//;
    $value =~ s/\>\s*$//;

    # Deal with list separators
    my $separatorpart = '';
    if ( ($valuetype eq "string-list") && ($value =~ /\|/) )
    {
        $separatorpart = 'oor:separator="|"';
    }

    # Fake: substituting german umlauts

    $value =~ s/\ä/ae/;
    $value =~ s/\ö/oe/;
    $value =~ s/\ü/ue/;
    $value =~ s/\Ä/AE/;
    $value =~ s/\Ö/OE/;
    $value =~ s/\Ü/UE/;

    my $newvalueline;

    if (!($oneconfig->{'isisocode'} ))  # this is the simpe case
    {
        # my $valueline = '<value SEPARATORPART>VALUECONTENT</value>' . "\n";
        $newvalueline = $valueline;
        $newvalueline =~ s/VALUECONTENT/$value/g;
        $newvalueline =~ s/SEPARATORPART/$separatorpart/;
    }
    else
    {
        # my $langvalueline = '<value xml:lang="SAVEDLANGUAGE">VALUECONTENT</value>' . "\n";
        $newvalueline = $langvalueline;
        $newvalueline =~ s/VALUECONTENT/$value/;
        my $savedlanguage = $oneconfig->{'Key'};
        $newvalueline =~ s/SAVEDLANGUAGE/$savedlanguage/;
    }

    # For language dependent values, it is possible, that the property already exist.
    # In this case the prop must not be created again and only the value has to be included:
    # <prop oor:name="Name">
    #  <value xml:lang="de">OpenOffice.org 2.0 Diagramm</value>
    #  <value xml:lang="en-US">OpenOffice.org 2.0 Chart</value>
    # </prop>

    # The key has to be written after the line, containing the complete node

    $insertline = get_node_line_number($nodecount, $oneconfig, $oneconfigfileref);

    if ( $oneconfig->{'ismultilingual'} )
    {
        if ( $newpropline eq ${$oneconfigfileref}[$insertline] )
        {
            if (!($newvalueline eq ${$oneconfigfileref}[$insertline+1]))    # only include, if the value not already exists (example: value="FALSE" for many languages)
            {
                splice(@{$oneconfigfileref}, $insertline+1, 0, ($newvalueline));    # only the value needs to be added
            }
        }
        else
        {
            splice(@{$oneconfigfileref}, $insertline, 0, ($newpropline, $newvalueline, $propendline));
        }
    }
    else
    {
        splice(@{$oneconfigfileref}, $insertline, 0, ($newpropline, $newvalueline, $propendline));
    }

    return $oneconfigfileref;
}

##########################################################
# Inserting tabs for better view into configuration file
##########################################################

sub insert_tabs_into_configfile
{
    my ($configfileref) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::insert_tabs_into_configfile : $#{$configfileref}"); }

    my $counter = 0;

    for ( my $i = 0; $i <= $#{$configfileref}; $i++ )
    {
        my $line = ${$configfileref}[$i];
        my $linebefore = ${$configfileref}[$i-1];

        if (( $line =~ /^\s*\<node/ ) || ( $line =~ /^\s*\<prop/ ))
        {
            if ((!( $linebefore =~ /^\s*\<\/node/ )) && (!( $linebefore =~ /^\s*\<\/prop/ )))       # do not increase after "</node" and after "</prop"
            {
                $counter++;
            }
        }

        if ( $line =~ /^\s*\<value/ )
        {
            if (!($linebefore =~ /^\s*\<value/ ))       # do not increase counter with "<value>" after "<value>" (multilingual configitems)
            {
                $counter++;
            }
        }

        if (( $line =~ /^\s*\<\/node\>/ ) || ( $line =~ /^\s*\<\/prop\>/ ))
        {
            if ((!( $linebefore =~ /^\s*\<node/ )) && (!( $linebefore =~ /^\s*\<prop/ )))       # do not decrease after "<node" and after "<prop"
            {
                $counter--;
            }
        }

        if ($counter > 0)
        {
            for ( my $j = 0; $j < $counter; $j++ )
            {
                $line = "\t" . $line;
            }
        }

        ${$configfileref}[$i] = $line;
    }
}

######################################################################
# Collecting all different configuration items (Files and Modules)
######################################################################

sub collect_all_configuration_items
{
    my ($configurationitemsref, $item) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::collect_all_configuration_items : $#{$configurationitemsref} : $item"); }

    my @allitems = ();

    for ( my $i = 0; $i <= $#{$configurationitemsref}; $i++ )
    {
        my $oneconfig = ${$configurationitemsref}[$i];

        if (! installer::existence::exists_in_array($oneconfig->{$item}, \@allitems))
        {
            push(@allitems, $oneconfig->{$item});
        }
    }

    return \@allitems;
}

######################################################################
# Collecting all module specific configuration items
######################################################################

sub get_all_configitems_at_module
{
    my ($moduleid, $configurationitemsref) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::get_all_configitems_at_module : $moduleid : $#{$configurationitemsref}"); }

    my @moduleconfigurationitems = ();

    for ( my $i = 0; $i <= $#{$configurationitemsref}; $i++ )
    {
        my $oneconfig = ${$configurationitemsref}[$i];

        if ( $oneconfig->{'ModuleID'} eq $moduleid )
        {
            push(@moduleconfigurationitems, $oneconfig);
        }
    }

    return \@moduleconfigurationitems;
}

#######################################################
# Saving and zipping the created configurationfile
#######################################################

sub save_and_zip_configfile
{
    my ($oneconfigfileref, $onefile, $onemodule, $configdir) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::save_and_zip_configfile : $#{$oneconfigfileref} : $onefile : $onemodule : $configdir"); }

    my $savefilename = $onefile;
    $savefilename =~ s/\./\_/g;
    $savefilename = $savefilename . "_" . $onemodule;
    $savefilename = $savefilename . ".xcu";
    my $shortsavefilename = $savefilename;

    $savefilename = $configdir . $installer::globals::separator . $savefilename;

    installer::files::save_file($savefilename, $oneconfigfileref);

    # zipping the configfile

    my $returnvalue = 1;

    my $zipfilename = $shortsavefilename;
    $zipfilename =~ s/\.xcu/\.zip/;

    my $currentdir = cwd();
    if ( $installer::globals::iswin ) { $currentdir =~ s/\//\\/g; }

    chdir($configdir);

     my $systemcall = "$installer::globals::zippath -q -m $zipfilename $shortsavefilename";
    $returnvalue = system($systemcall);

    chdir($currentdir);

    my $infoline = "Systemcall: $systemcall\n";
    push( @installer::globals::logfileinfo, $infoline);

    if ($returnvalue)
    {
        $infoline = "ERROR: Could not zip $savefilename to $zipfilename\n";
    }
    else
    {
        $infoline = "SUCCESS: Zipped file $savefilename to $zipfilename\n";
    }
    push( @installer::globals::logfileinfo, $infoline);

    return $zipfilename;
}

#####################################################################
# Adding the newly created configuration file into the file list
#####################################################################

sub add_zipfile_into_filelist
{
    my ($zipfilename, $configdir, $filesarrayref, $onemodule) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::add_zipfile_into_filelist: $zipfilename : $configdir : $#{$filesarrayref} : $onemodule"); }

    my $longzipfilename = $configdir . $installer::globals::separator . $zipfilename;
    my $gid = "gid_" . $zipfilename;
    $gid =~ s/\./\_/g;

    my %configfile = ();

    # Taking the base data from the "gid_File_Lib_Vcl"

    my $vclgid = "gid_File_Lib_Vcl";
    my $vclfile = installer::existence::get_specified_file($filesarrayref, $vclgid);

    # copying all base data
    installer::converter::copy_item_object($vclfile, \%configfile);

    # and overriding all new data
    $configfile{'ismultilingual'} = 0;
    $configfile{'sourcepath'} = $longzipfilename;
    $configfile{'Name'} = $zipfilename;
    $configfile{'UnixRights'} = "644";
    $configfile{'gid'} = $gid;
    $configfile{'Dir'} = "gid_Dir_Share_Uno_Packages";
    $configfile{'destination'} = "share" . $installer::globals::separator . "uno_packages" . $installer::globals::separator . $zipfilename;
    $configfile{'modules'} = $onemodule;    # assigning the file to the correct module!

    push(@{$filesarrayref}, \%configfile);
}

#######################################################
# Creating configuration files from configurationitems
#######################################################

sub create_configuration_files
{
    my ($configurationitemsref, $filesarrayref, $languagestringref) = @_;

    if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::configuration::create_configuration_files: $#{$configurationitemsref} : $#{$filesarrayref} : $$languagestringref"); }

    installer::logger::include_header_into_logfile("Creating configuration files:");

    # creating the directory

    my $configdir = installer::systemactions::create_directories("configfiles", $languagestringref);

    $configdir = installer::converter::make_path_conform($configdir);

    # collecting an array of all modules
    my $allmodules = collect_all_configuration_items($configurationitemsref, "ModuleID");

    # iterating over all modules

    for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
    {
        my $onemodule = ${$allmodules}[$i];

        my $moduleconfigitems = get_all_configitems_at_module($onemodule, $configurationitemsref);

        # collecting an array of all "startpath". This are all different files (org.openoffice.Office.Common).
        my $allfiles = collect_all_configuration_items($moduleconfigitems, "startpath");

        # iteration over all files

        for ( my $j = 0; $j <= $#{$allfiles}; $j++ )
        {
            my $onefile = ${$allfiles}[$j];

            my @oneconfigfile = ();
            my $oneconfigfileref = \@oneconfigfile;

            my $startblockwritten = 0;

            for ( my $k = 0; $k <= $#{$moduleconfigitems}; $k++ )
            {
                my $oneconfig = ${$moduleconfigitems}[$k];

                my $startpath = $oneconfig->{'startpath'};

                if ($startpath eq $onefile)
                {
                    if (!($startblockwritten))  # writing some global lines into the xcu file
                    {
                        insert_start_block_into_configfile($oneconfigfileref, $oneconfig);
                        $startblockwritten = 1;
                    }

                    $oneconfigfileref = insert_into_config_file($oneconfig, $oneconfigfileref);
                }
            }

            insert_end_block_into_configfile($oneconfigfileref);

            # inserting tabs for nice appearance
            insert_tabs_into_configfile($oneconfigfileref);

            # saving the configfile
            my $zipfilename = save_and_zip_configfile($oneconfigfileref, $onefile, $onemodule, $configdir);

            # adding the zipped configfile to the list of installed files
            # Some data are set now, others are taken from the file "soffice.exe" ("soffice.bin")

            add_zipfile_into_filelist($zipfilename, $configdir, $filesarrayref, $onemodule);
        }
    }

    my $infoline = "\n";
    push( @installer::globals::logfileinfo, $infoline);

}

1;