1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2010 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 11# OpenOffice.org is free software: you can redistribute it and/or modify 12# it under the terms of the GNU Lesser General Public License version 3 13# only, as published by the Free Software Foundation. 14# 15# OpenOffice.org is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU Lesser General Public License version 3 for more details 19# (a copy is included in the LICENSE file that accompanied this code). 20# 21# You should have received a copy of the GNU Lesser General Public License 22# version 3 along with OpenOffice.org. If not, see 23# <http://www.openoffice.org/license.html> 24# for a copy of the LGPLv3 License. 25# 26#************************************************************************* 27 28package installer::windows::createfolder; 29 30use installer::existence; 31use installer::exiter; 32use installer::files; 33use installer::globals; 34use installer::windows::idtglobal; 35 36############################################################## 37# Returning directory for createfolder table. 38############################################################## 39 40sub get_createfolder_directory 41{ 42 my ($onedir) = @_; 43 44 my $uniquename = $onedir->{'uniquename'}; 45 46 return $uniquename; 47} 48 49############################################################## 50# Searching the correct file for language pack directories. 51############################################################## 52 53sub get_languagepack_file 54{ 55 my ($filesref, $onedir) = @_; 56 57 my $language = $onedir->{'specificlanguage'}; 58 my $foundfile = 0; 59 my $onefile = ""; 60 61 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 62 { 63 $onefile = ${$filesref}[$i]; 64 65 if ( $onefile->{'specificlanguage'} eq $onedir->{'specificlanguage'} ) 66 { 67 $foundfile = 1; 68 last; 69 } 70 } 71 72 if ( ! $foundfile ) { installer::exiter::exit_program("ERROR: No file with correct language found (language pack build)!", "get_languagepack_file"); } 73 74 return $onefile; 75} 76 77############################################################## 78# Returning component for createfolder table. 79############################################################## 80 81sub get_createfolder_component 82{ 83 my ($onedir, $filesref, $allvariableshashref) = @_; 84 85 # Directories do not belong to a module. 86 # Therefore they can only belong to the root module and 87 # will be added to a component at the root module. 88 # All directories will be added to the component 89 # containing the file $allvariableshashref->{'GLOBALFILEGID'} 90 91 if ( ! $allvariableshashref->{'GLOBALFILEGID'} ) { installer::exiter::exit_program("ERROR: GLOBALFILEGID must be defined in list file!", "get_createfolder_component"); } 92 if (( $installer::globals::patch ) && ( ! $allvariableshashref->{'GLOBALFILEGID'} )) { installer::exiter::exit_program("ERROR: GLOBALPATCHFILEGID must be defined in list file!", "get_createfolder_component"); } 93 94 my $globalfilegid = $allvariableshashref->{'GLOBALFILEGID'}; 95 if ( $installer::globals::patch ) { $globalfilegid = $allvariableshashref->{'GLOBALPATCHFILEGID'}; } 96 97 my $onefile = ""; 98 if ( $installer::globals::languagepack ) { $onefile = get_languagepack_file($filesref, $onedir); } 99 else { $onefile = installer::existence::get_specified_file($filesref, $globalfilegid); } 100 101 return $onefile->{'componentname'}; 102} 103 104#################################################################################### 105# Creating the file CreateFo.idt dynamically for creation of empty directories 106# Content: 107# Directory_ Component_ 108#################################################################################### 109 110sub create_createfolder_table 111{ 112 my ($dirref, $filesref, $basedir, $allvariableshashref) = @_; 113 114 my @createfoldertable = (); 115 116 my $infoline; 117 118 installer::windows::idtglobal::write_idt_header(\@createfoldertable, "createfolder"); 119 120 for ( my $i = 0; $i <= $#{$dirref}; $i++ ) 121 { 122 my $onedir = ${$dirref}[$i]; 123 124 # language packs get only language dependent directories 125 if (( $installer::globals::languagepack ) && ( $onedir->{'specificlanguage'} eq "" )) { next }; 126 127 my $styles = ""; 128 129 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } 130 131 if ( $styles =~ /\bCREATE\b/ ) 132 { 133 my %directory = (); 134 135 $directory{'Directory_'} = get_createfolder_directory($onedir); 136 $directory{'Component_'} = get_createfolder_component($onedir, $filesref, $allvariableshashref); 137 138 my $oneline = $directory{'Directory_'} . "\t" . $directory{'Component_'} . "\n"; 139 140 push(@createfoldertable, $oneline); 141 } 142 } 143 144 # Saving the file 145 146 my $createfoldertablename = $basedir . $installer::globals::separator . "CreateFo.idt"; 147 installer::files::save_file($createfoldertablename ,\@createfoldertable); 148 $infoline = "Created idt file: $createfoldertablename\n"; 149 push(@installer::globals::logfileinfo, $infoline); 150 151} 152 1531;