2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer
::windows
::featurecomponent
;
24 use installer
::converter
;
25 use installer
::exiter
;
27 use installer
::globals
;
28 use installer
::windows
::idtglobal
;
30 #################################################################################
31 # Collecting all pairs of features and components from the files collector
32 #################################################################################
34 sub create_featurecomponent_table_from_files_collector
36 my ($featurecomponenttableref, $filesref) = @_;
38 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
40 my $onefile = ${$filesref}[$i];
42 my $filecomponent = $onefile->{'componentname'};
43 my $filemodules = $onefile->{'modules'};
45 if ( $filecomponent eq "" )
47 installer
::exiter
::exit_program
("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
49 if ( $filemodules eq "" )
51 installer
::exiter
::exit_program
("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
54 my $filemodulesarrayref = installer
::converter
::convert_stringlist_into_array
(\
$filemodules, ",");
56 for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ )
58 my %featurecomponent = ();
60 my $onemodule = ${$filemodulesarrayref}[$j];
61 $onemodule =~ s/\s*$//;
62 $featurecomponent{'Feature'} = $onemodule;
63 $featurecomponent{'Component'} = $filecomponent;
65 # Attention: Features are renamed, because the maximum length is 38.
66 # But in the files collector ($filesref), the original names are saved.
68 installer
::windows
::idtglobal
::shorten_feature_gid
(\
$featurecomponent{'Feature'});
70 my $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
72 # control of uniqueness
74 if (! grep {$_ eq $oneline} @
{$featurecomponenttableref})
76 push(@
{$featurecomponenttableref}, $oneline);
82 #################################################################################
83 # Collecting all pairs of features and components from the registry collector
84 #################################################################################
86 sub create_featurecomponent_table_from_registry_collector
88 my ($featurecomponenttableref, $registryref) = @_;
90 for ( my $i = 0; $i <= $#{$registryref}; $i++ )
92 my $oneregistry = ${$registryref}[$i];
94 my $registrycomponent = $oneregistry->{'componentname'};
95 my $registrymodule = $oneregistry->{'ModuleID'};
97 if ( $registrycomponent eq "" )
99 installer
::exiter
::exit_program
("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
101 if ( $registrymodule eq "" )
103 installer
::exiter
::exit_program
("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
106 my %featurecomponent = ();
108 $featurecomponent{'Feature'} = $registrymodule;
109 $featurecomponent{'Component'} = $registrycomponent;
111 # Attention: Features are renamed, because the maximum length is 38.
112 # But in the files collector ($filesref), the original names are saved.
114 installer
::windows
::idtglobal
::shorten_feature_gid
(\
$featurecomponent{'Feature'});
116 my $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
118 # control of uniqueness
120 if (! grep {$_ eq $oneline} @
{$featurecomponenttableref})
122 push(@
{$featurecomponenttableref}, $oneline);
127 #################################################################################
128 # Creating the file FeatureC.idt dynamically
131 #################################################################################
133 sub create_featurecomponent_table
135 my ($filesref, $registryref, $basedir) = @_;
137 my @featurecomponenttable = ();
140 installer
::windows
::idtglobal
::write_idt_header
(\
@featurecomponenttable, "featurecomponent");
142 # This is the first time, that features and components are related
143 # Problem: How about created profiles, configurationfiles, services.rdb
144 # -> simple solution: putting them all to the root module
145 # Otherwise profiles and configurationfiles cannot be created the way, they are now created
146 # -> especially a problem for the configurationfiles! # ToDo
147 # Very good: All ProfileItems belong to the root
148 # services.rdb belongs to the root anyway.
150 # At the moment only the files are related to components (and the files know their modules).
151 # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref
153 create_featurecomponent_table_from_files_collector
(\
@featurecomponenttable, $filesref);
155 create_featurecomponent_table_from_registry_collector
(\
@featurecomponenttable, $registryref);
157 # Additional components have to be added here
161 my $featurecomponenttablename = $basedir . $installer::globals
::separator
. "FeatureC.idt";
162 installer
::files
::save_file
($featurecomponenttablename ,\
@featurecomponenttable);
163 $infoline = "Created idt file: $featurecomponenttablename\n";
164 push(@installer::globals
::logfileinfo
, $infoline);