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
;
21 use installer
::converter
;
22 use installer
::exiter
;
24 use installer
::globals
;
25 use installer
::windows
::idtglobal
;
27 #################################################################################
28 # Collecting all pairs of features and components from the files collector
29 #################################################################################
31 sub create_featurecomponent_table_from_files_collector
33 my ($featurecomponenttableref, $filesref) = @_;
35 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
37 my $onefile = ${$filesref}[$i];
39 my $filecomponent = $onefile->{'componentname'};
40 my $filemodules = $onefile->{'modules'};
42 if ( $filecomponent eq "" )
44 installer
::exiter
::exit_program
("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
46 if ( $filemodules eq "" )
48 installer
::exiter
::exit_program
("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
51 my $filemodulesarrayref = installer
::converter
::convert_stringlist_into_array
(\
$filemodules, ",");
53 for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ )
55 my %featurecomponent = ();
57 my $onemodule = ${$filemodulesarrayref}[$j];
58 $onemodule =~ s/\s*$//;
59 $featurecomponent{'Feature'} = $onemodule;
60 $featurecomponent{'Component'} = $filecomponent;
62 # Attention: Features are renamed, because the maximum length is 38.
63 # But in the files collector ($filesref), the original names are saved.
65 installer
::windows
::idtglobal
::shorten_feature_gid
(\
$featurecomponent{'Feature'});
67 $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
69 # control of uniqueness
71 if (! grep {$_ eq $oneline} @
{$featurecomponenttableref})
73 push(@
{$featurecomponenttableref}, $oneline);
79 #################################################################################
80 # Collecting all pairs of features and components from the registry collector
81 #################################################################################
83 sub create_featurecomponent_table_from_registry_collector
85 my ($featurecomponenttableref, $registryref) = @_;
87 for ( my $i = 0; $i <= $#{$registryref}; $i++ )
89 my $oneregistry = ${$registryref}[$i];
91 my $registrycomponent = $oneregistry->{'componentname'};
92 my $registrymodule = $oneregistry->{'ModuleID'};
94 if ( $registrycomponent eq "" )
96 installer
::exiter
::exit_program
("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
98 if ( $registrymodule eq "" )
100 installer
::exiter
::exit_program
("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
103 my %featurecomponent = ();
105 $featurecomponent{'Feature'} = $registrymodule;
106 $featurecomponent{'Component'} = $registrycomponent;
108 # Attention: Features are renamed, because the maximum length is 38.
109 # But in the files collector ($filesref), the original names are saved.
111 installer
::windows
::idtglobal
::shorten_feature_gid
(\
$featurecomponent{'Feature'});
113 $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
115 # control of uniqueness
117 if (! grep {$_ eq $oneline} @
{$featurecomponenttableref})
119 push(@
{$featurecomponenttableref}, $oneline);
124 #################################################################################
125 # Creating the file FeatureC.idt dynamically
128 #################################################################################
130 sub create_featurecomponent_table
132 my ($filesref, $registryref, $basedir) = @_;
134 my @featurecomponenttable = ();
137 installer
::windows
::idtglobal
::write_idt_header
(\
@featurecomponenttable, "featurecomponent");
139 # This is the first time, that features and componentes are related
140 # Problem: How about created profiles, configurationfiles, services.rdb
141 # -> simple solution: putting them all to the root module
142 # Otherwise profiles and configurationfiles cannot be created the way, they are now created
143 # -> especially a problem for the configurationfiles! # ToDo
144 # Very good: All ProfileItems belong to the root
145 # services.rdb belongs to the root anyway.
147 # At the moment only the files are related to components (and the files know their modules).
148 # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref
150 create_featurecomponent_table_from_files_collector
(\
@featurecomponenttable, $filesref);
152 create_featurecomponent_table_from_registry_collector
(\
@featurecomponenttable, $registryref);
154 # Additional components have to be added here
158 my $featurecomponenttablename = $basedir . $installer::globals
::separator
. "FeatureC.idt";
159 installer
::files
::save_file
($featurecomponenttablename ,\
@featurecomponenttable);
160 $infoline = "Created idt file: $featurecomponenttablename\n";
161 push(@installer::globals
::logfileinfo
, $infoline);