merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / modules / installer / windows / featurecomponent.pm
blob584d8df698c1e8430b84661f2b35d759b49d65b1
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: featurecomponent.pm,v $
11 # $Revision: 1.5 $
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::featurecomponent;
34 use installer::converter;
35 use installer::existence;
36 use installer::exiter;
37 use installer::files;
38 use installer::globals;
39 use installer::windows::idtglobal;
41 #################################################################################
42 # Collecting all pairs of features and components from the files collector
43 #################################################################################
45 sub create_featurecomponent_table_from_files_collector
47 my ($featurecomponenttableref, $filesref) = @_;
49 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
51 my $onefile = ${$filesref}[$i];
53 my $filecomponent = $onefile->{'componentname'};
54 my $filemodules = $onefile->{'modules'};
56 if ( $filecomponent eq "" )
58 installer::exiter::exit_program("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
60 if ( $filemodules eq "" )
62 installer::exiter::exit_program("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
65 my $filemodulesarrayref = installer::converter::convert_stringlist_into_array(\$filemodules, ",");
67 for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ )
69 my %featurecomponent = ();
71 my $onemodule = ${$filemodulesarrayref}[$j];
72 $onemodule =~ s/\s*$//;
73 $featurecomponent{'Feature'} = $onemodule;
74 $featurecomponent{'Component'} = $filecomponent;
76 # Attention: Features are renamed, because the maximum length is 38.
77 # But in the files collector ($filesref), the original names are saved.
79 installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'});
81 $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
83 # control of uniqueness
85 if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref))
87 push(@{$featurecomponenttableref}, $oneline);
93 #################################################################################
94 # Collecting all pairs of features and components from the registry collector
95 #################################################################################
97 sub create_featurecomponent_table_from_registry_collector
99 my ($featurecomponenttableref, $registryref) = @_;
101 for ( my $i = 0; $i <= $#{$registryref}; $i++ )
103 my $oneregistry = ${$registryref}[$i];
105 my $registrycomponent = $oneregistry->{'componentname'};
106 my $registrymodule = $oneregistry->{'ModuleID'};
108 if ( $registrycomponent eq "" )
110 installer::exiter::exit_program("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
112 if ( $registrymodule eq "" )
114 installer::exiter::exit_program("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
117 my %featurecomponent = ();
119 $featurecomponent{'Feature'} = $registrymodule;
120 $featurecomponent{'Component'} = $registrycomponent;
122 # Attention: Features are renamed, because the maximum length is 38.
123 # But in the files collector ($filesref), the original names are saved.
125 installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'});
127 $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
129 # control of uniqueness
131 if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref))
133 push(@{$featurecomponenttableref}, $oneline);
138 #################################################################################
139 # Collecting all feature that are listed in the featurecomponent table.
140 #################################################################################
142 sub collect_all_feature
144 my ($featurecomponenttable) = @_;
146 my @allfeature = ();
148 for ( my $i = 3; $i <= $#{$featurecomponenttable}; $i++ ) # beginning in line 4
150 my $oneline = ${$featurecomponenttable}[$i];
152 if ( $oneline =~ /^\s*(\S+)\s+(\S+)\s*$/ )
154 my $feature = $1;
156 if (! installer::existence::exists_in_array($feature, \@allfeature)) { push(@allfeature, $feature); }
160 return \@allfeature;
163 #################################################################################
164 # On Win98 and Win Me there seems to be the problem, that maximum 817
165 # components can be added to a feature. Even if Windows Installer 2.0
166 # is used.
167 #################################################################################
169 sub check_number_of_components_at_feature
171 my ($featurecomponenttable) = @_;
173 my $infoline = "\nChecking number of components at features. Maximum is 817 (for Win 98 and Win Me)\n";
174 push(@installer::globals::logfileinfo, $infoline);
176 my $allfeature = collect_all_feature($featurecomponenttable);
178 for ( my $i = 0; $i <= $#{$allfeature}; $i++ )
180 my $onefeature = ${$allfeature}[$i];
181 my $featurecomponents = 0;
183 for ( my $j = 0; $j <= $#{$featurecomponenttable}; $j++ )
185 if ( ${$featurecomponenttable}[$j] =~ /^\s*\Q$onefeature\E\s+(\S+)\s*$/ ) { $featurecomponents++; }
188 if ( $featurecomponents > 816 )
190 installer::exiter::exit_program("ERROR: More than 816 components ($featurecomponents) at feature $onefeature. This causes problems on Win 98 and Win Me!", "check_number_of_components_at_feature");
193 # Logging the result
195 $infoline = "Number of components at feature $onefeature : $featurecomponents\n";
196 push(@installer::globals::logfileinfo, $infoline);
199 $infoline = "\n";
200 push(@installer::globals::logfileinfo, $infoline);
203 #################################################################################
204 # Creating the file FeatureC.idt dynamically
205 # Content:
206 # Feature Component
207 #################################################################################
209 sub create_featurecomponent_table
211 my ($filesref, $registryref, $basedir) = @_;
213 my @featurecomponenttable = ();
214 my $infoline;
216 installer::windows::idtglobal::write_idt_header(\@featurecomponenttable, "featurecomponent");
218 # This is the first time, that features and componentes are related
219 # Problem: How about created profiles, configurationfiles, services.rdb
220 # -> simple solution: putting them all to the root module
221 # Otherwise profiles and configurationfiles cannot be created the way, they are now created
222 # -> especially a problem for the configurationfiles! # ToDo
223 # Very good: All ProfileItems belong to the root
224 # services.rdb belongs to the root anyway.
226 # At the moment only the files are related to components (and the files know their modules).
227 # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref
229 create_featurecomponent_table_from_files_collector(\@featurecomponenttable, $filesref);
231 create_featurecomponent_table_from_registry_collector(\@featurecomponenttable, $registryref);
233 # Additional components have to be added here
235 # Checking, whether there are more than 817 components at a feature
237 check_number_of_components_at_feature(\@featurecomponenttable);
239 # Saving the file
241 my $featurecomponenttablename = $basedir . $installer::globals::separator . "FeatureC.idt";
242 installer::files::save_file($featurecomponenttablename ,\@featurecomponenttable);
243 $infoline = "Created idt file: $featurecomponenttablename\n";
244 push(@installer::globals::logfileinfo, $infoline);