1# 2# This file is part of the LibreOffice project. 3# 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/. 7# 8# This file incorporates work covered by the following license notice: 9# 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 . 17# 18 19package installer::windows::property; 20 21use installer::exiter; 22use installer::files; 23use installer::globals; 24use installer::windows::idtglobal; 25use installer::windows::language; 26 27############################################# 28# Setting the properties dynamically 29# for the table Property.idt 30############################################# 31 32sub get_arpcomments_for_property_table 33{ 34 my ( $allvariables, $languagestringref ) = @_; 35 36 my $name = $allvariables->{'PRODUCTNAME'}; 37 my $version = $allvariables->{'PRODUCTVERSION'}; 38 my $comment = $name . " " . $version; 39 40 my $postversionextension = ""; 41 if ( $allvariables->{'POSTVERSIONEXTENSION'} ) 42 { 43 $postversionextension = $allvariables->{'POSTVERSIONEXTENSION'}; 44 $comment = $comment . " " . $postversionextension; 45 } 46 47 if ( $installer::globals::languagepack ) { $comment = $comment . " " . "Language Pack"; } 48 elsif ( $installer::globals::helppack ) { $comment = $comment . " " . "Help Pack"; } 49 50 my $languagestring = $$languagestringref; 51 $languagestring =~ s/\_/\,/g; 52 if ( length($languagestring) > 30 ) { $languagestring = "multilanguage"; } # fdo#64053 53 54 $comment = $comment . " ($languagestring)"; 55 56 return $comment; 57} 58 59sub get_installlevel_for_property_table 60{ 61 my $installlevel = "100"; 62 return $installlevel; 63} 64 65sub get_ischeckforproductupdates_for_property_table 66{ 67 my $ischeckforproductupdates = "1"; 68 return $ischeckforproductupdates; 69} 70 71sub get_manufacturer_for_property_table 72{ 73 return $installer::globals::manufacturer; 74} 75 76sub get_productlanguage_for_property_table 77{ 78 my ($language) = @_; 79 my $windowslanguage = installer::windows::language::get_windows_language($language); 80 return $windowslanguage; 81} 82 83sub get_language_string 84{ 85 my $langstring = ""; 86 87 for ( my $i = 0; $i <= $#installer::globals::languagenames; $i++ ) 88 { 89 $langstring = $langstring . $installer::globals::languagenames[$i] . ", "; 90 } 91 92 $langstring =~ s/\,\s*$//; 93 $langstring = "(" . $langstring . ")"; 94 95 return $langstring; 96} 97 98sub get_english_language_string 99{ 100 my $langstring = ""; 101 102 # Sorting value not keys, therefore collecting all values 103 my %helper = (); 104 foreach my $lang ( keys %installer::globals::all_required_english_languagestrings ) 105 { 106 $helper{$installer::globals::all_required_english_languagestrings{$lang}} = 1; 107 } 108 109 foreach my $lang ( sort keys %helper ) 110 { 111 $langstring = $langstring . $lang . ", "; 112 } 113 114 $langstring =~ s/\,\s*$//; 115 $langstring = "(" . $langstring . ")"; 116 117 return $langstring; 118} 119 120sub get_productname($$) 121{ 122 my ( $language, $allvariables ) = @_; 123 124 my $name = $allvariables->{'PRODUCTNAME'}; 125 126 return $name; 127} 128 129sub get_productname_for_property_table($$) 130{ 131 my ( $language, $allvariables ) = @_; 132 133 my $name = get_productname ($language, $allvariables); 134 my $version = $allvariables->{'PRODUCTVERSION'}; 135 my $productname = $name . " " . $version; 136 137 my $productextension = ""; 138 if ( $allvariables->{'PRODUCTEXTENSION'} ) 139 { 140 $productextension = $allvariables->{'PRODUCTEXTENSION'}; 141 $productname = $productname . $productextension; 142 } 143 144 my $postversionextension = ""; 145 if ( $allvariables->{'POSTVERSIONEXTENSION'} ) 146 { 147 $postversionextension = $allvariables->{'POSTVERSIONEXTENSION'}; 148 $productname = $productname . " " . $postversionextension; 149 } 150 151 if ( $installer::globals::languagepack ) 152 { 153 my $langstring = get_english_language_string(); # Example: (English, German) 154 $productname = $name . " " . $version . " Language Pack" . " " . $langstring; 155 } 156 elsif ( $installer::globals::helppack ) 157 { 158 my $langstring = get_english_language_string(); # New: (English, German) 159 $productname = $name . " " . $version . " Help Pack" . " " . $langstring; 160 } 161 162 # Saving this name in hash $allvariables for further usage 163 $allvariables->{'PROPERTYTABLEPRODUCTNAME'} = $productname; 164 my $infoline = "Defined variable PROPERTYTABLEPRODUCTNAME: $productname\n"; 165 push(@installer::globals::logfileinfo, $infoline); 166 167 return $productname; 168} 169 170sub get_quickstarterlinkname_for_property_table($$) 171{ 172 my ( $language, $allvariables ) = @_; 173 174 # no usage of POSTVERSIONEXTENSION for Quickstarter link name! 175 my $name = get_productname ($language, $allvariables); 176 my $version = $allvariables->{'PRODUCTVERSION'}; 177 my $quickstartername = $name . " " . $version; 178 179 my $infoline = "Defined Quickstarter Link name: $quickstartername\n"; 180 push(@installer::globals::logfileinfo, $infoline); 181 182 return $quickstartername; 183} 184 185sub get_productversion_for_property_table 186{ 187 return $installer::globals::msiproductversion; 188} 189 190####################################################### 191# Setting some important properties 192# (for finding the product in deinstallation process) 193####################################################### 194 195sub set_important_properties 196{ 197 my ($propertyfile, $allvariables, $languagestringref) = @_; 198 199 # Setting new variables with the content of %PRODUCTNAME and %PRODUCTVERSION 200 if ( $allvariables->{'PRODUCTNAME'} ) 201 { 202 my $onepropertyline = "DEFINEDPRODUCT" . "\t" . $allvariables->{'PRODUCTNAME'} . "\n"; 203 push(@{$propertyfile}, $onepropertyline); 204 } 205 206 if ( $allvariables->{'PRODUCTVERSION'} ) 207 { 208 my $onepropertyline = "DEFINEDVERSION" . "\t" . $allvariables->{'PRODUCTVERSION'} . "\n"; 209 push(@{$propertyfile}, $onepropertyline); 210 } 211 212 if (( $allvariables->{'PRODUCTNAME'} ) && ( $allvariables->{'PRODUCTVERSION'} ) && ( $allvariables->{'REGISTRYLAYERNAME'} )) 213 { 214 my $onepropertyline = "FINDPRODUCT" . "\t" . "Software\\LibreOffice" . "\\" . $allvariables->{'REGISTRYLAYERNAME'} . "\\" . $allvariables->{'PRODUCTNAME'} . "\\" . $allvariables->{'PRODUCTVERSION'} . "\n"; 215 push(@{$propertyfile}, $onepropertyline); 216 } 217 218 if ( $allvariables->{'PRODUCTMAJOR'} ) 219 { 220 my $onepropertyline = "PRODUCTMAJOR" . "\t" . $allvariables->{'PRODUCTMAJOR'} . "\n"; 221 push(@{$propertyfile}, $onepropertyline); 222 } 223 224 if ( $allvariables->{'PRODUCTBUILDID'} ) 225 { 226 my $onepropertyline = "PRODUCTBUILDID" . "\t" . $allvariables->{'PRODUCTBUILDID'} . "\n"; 227 push(@{$propertyfile}, $onepropertyline); 228 } 229 230 if ( $allvariables->{'URELAYERVERSION'} ) 231 { 232 my $onepropertyline = "URELAYERVERSION" . "\t" . $allvariables->{'URELAYERVERSION'} . "\n"; 233 push(@{$propertyfile}, $onepropertyline); 234 } 235 236 if ( $allvariables->{'BRANDPACKAGEVERSION'} ) 237 { 238 my $onepropertyline = "BRANDPACKAGEVERSION" . "\t" . $allvariables->{'BRANDPACKAGEVERSION'} . "\n"; 239 push(@{$propertyfile}, $onepropertyline); 240 } 241 242 if ( $allvariables->{'EXCLUDE_FROM_REBASE'} ) 243 { 244 my $onepropertyline = "EXCLUDE_FROM_REBASE" . "\t" . $allvariables->{'EXCLUDE_FROM_REBASE'} . "\n"; 245 push(@{$propertyfile}, $onepropertyline); 246 } 247 248 if ( $allvariables->{'PREREQUIREDPATCH'} ) 249 { 250 my $onepropertyline = "PREREQUIREDPATCH" . "\t" . $allvariables->{'PREREQUIREDPATCH'} . "\n"; 251 push(@{$propertyfile}, $onepropertyline); 252 } 253 254 my $onepropertyline = "IGNOREPREREQUIREDPATCH" . "\t" . "1" . "\n"; 255 push(@{$propertyfile}, $onepropertyline); 256 257 $onepropertyline = "DONTOPTIMIZELIBS" . "\t" . "0" . "\n"; 258 push(@{$propertyfile}, $onepropertyline); 259 260 if ( $installer::globals::officedirhostname ) 261 { 262 my $onepropertyline = "OFFICEDIRHOSTNAME" . "\t" . $installer::globals::officedirhostname . "\n"; 263 push(@{$propertyfile}, $onepropertyline); 264 265 my $localofficedirhostname = $installer::globals::officedirhostname; 266 $localofficedirhostname =~ s/\//\\/g; 267 $onepropertyline = "OFFICEDIRHOSTNAME_" . "\t" . $localofficedirhostname . "\n"; 268 push(@{$propertyfile}, $onepropertyline); 269 } 270 271 if ( $installer::globals::desktoplinkexists ) 272 { 273 my $onepropertyline = "DESKTOPLINKEXISTS" . "\t" . "1" . "\n"; 274 push(@{$propertyfile}, $onepropertyline); 275 276 $onepropertyline = "CREATEDESKTOPLINK" . "\t" . "1" . "\n"; # Setting the default 277 push(@{$propertyfile}, $onepropertyline); 278 } 279 280 if ( $installer::globals::languagepack ) 281 { 282 my $onepropertyline = "ISLANGUAGEPACK" . "\t" . "1" . "\n"; 283 push(@{$propertyfile}, $onepropertyline); 284 } 285 elsif ( $installer::globals::helppack ) 286 { 287 my $onepropertyline = "ISHELPPACK" . "\t" . "1" . "\n"; 288 push(@{$propertyfile}, $onepropertyline); 289 } 290 291 my $languagesline = "PRODUCTALLLANGUAGES" . "\t" . $$languagestringref . "\n"; 292 push(@{$propertyfile}, $languagesline); 293 294 if (( $allvariables->{'PRODUCTEXTENSION'} ) && ( $allvariables->{'PRODUCTEXTENSION'} eq "Beta" )) 295 { 296 # my $registryline = "WRITE_REGISTRY" . "\t" . "0" . "\n"; 297 # push(@{$propertyfile}, $registryline); 298 my $betainfoline = "BETAPRODUCT" . "\t" . "1" . "\n"; 299 push(@{$propertyfile}, $betainfoline); 300 } 301 elsif ( $allvariables->{'DEVELOPMENTPRODUCT'} ) 302 { 303 my $registryline = "WRITE_REGISTRY" . "\t" . "0" . "\n"; 304 push(@{$propertyfile}, $registryline); 305 } 306 else 307 { 308 my $registryline = "WRITE_REGISTRY" . "\t" . "1" . "\n"; # Default: Write complete registry 309 push(@{$propertyfile}, $registryline); 310 } 311 312 # Adding also used tree conditions for multilayer products. 313 # These are saved in %installer::globals::usedtreeconditions 314 foreach my $treecondition (keys %installer::globals::usedtreeconditions) 315 { 316 my $onepropertyline = $treecondition . "\t" . "1" . "\n"; 317 push(@{$propertyfile}, $onepropertyline); 318 } 319 320 # No more license dialog for selected products 321 if ( $allvariables->{'HIDELICENSEDIALOG'} ) 322 { 323 my $onepropertyline = "HIDEEULA" . "\t" . "1" . "\n"; 324 325 my $already_defined = 0; 326 327 for ( my $i = 0; $i <= $#{$propertyfile}; $i++ ) 328 { 329 if ( ${$propertyfile}[$i] =~ /^\s*HIDEEULA\t/ ) 330 { 331 ${$propertyfile}[$i] = $onepropertyline; 332 $already_defined = 1; 333 last; 334 } 335 } 336 337 if ( ! $already_defined ) 338 { 339 push(@{$propertyfile}, $onepropertyline); 340 } 341 } 342} 343 344####################################################### 345# Setting properties needed for ms file type registration 346####################################################### 347 348sub set_ms_file_types_properties 349{ 350 my ($propertyfile) = @_; 351 352# we do not register PPSM, PPAM, and XLAM file types in 353# setup_native\source\win32\customactions\reg4allmsdoc\reg4allmsi.cxx 354# (probably because LibreOffice can't deal with them properly (?) 355 356 push(@{$propertyfile}, "REGISTER_PPS" . "\t" . "0" . "\n"); 357 push(@{$propertyfile}, "REGISTER_PPSX" . "\t" . "0" . "\n"); 358# push(@{$propertyfile}, "REGISTER_PPSM" . "\t" . "0" . "\n"); 359# push(@{$propertyfile}, "REGISTER_PPAM" . "\t" . "0" . "\n"); 360 push(@{$propertyfile}, "REGISTER_PPT" . "\t" . "0" . "\n"); 361 push(@{$propertyfile}, "REGISTER_PPTX" . "\t" . "0" . "\n"); 362 push(@{$propertyfile}, "REGISTER_PPTM" . "\t" . "0" . "\n"); 363 push(@{$propertyfile}, "REGISTER_POT" . "\t" . "0" . "\n"); 364 push(@{$propertyfile}, "REGISTER_POTX" . "\t" . "0" . "\n"); 365 push(@{$propertyfile}, "REGISTER_POTM" . "\t" . "0" . "\n"); 366 367 push(@{$propertyfile}, "REGISTER_DOC" . "\t" . "0" . "\n"); 368 push(@{$propertyfile}, "REGISTER_DOCX" . "\t" . "0" . "\n"); 369 push(@{$propertyfile}, "REGISTER_DOCM" . "\t" . "0" . "\n"); 370 push(@{$propertyfile}, "REGISTER_DOT" . "\t" . "0" . "\n"); 371 push(@{$propertyfile}, "REGISTER_DOTX" . "\t" . "0" . "\n"); 372 push(@{$propertyfile}, "REGISTER_DOTM" . "\t" . "0" . "\n"); 373 push(@{$propertyfile}, "REGISTER_RTF" . "\t" . "0" . "\n"); 374 375 push(@{$propertyfile}, "REGISTER_XLS" . "\t" . "0" . "\n"); 376 push(@{$propertyfile}, "REGISTER_XLSX" . "\t" . "0" . "\n"); 377 push(@{$propertyfile}, "REGISTER_XLSM" . "\t" . "0" . "\n"); 378 push(@{$propertyfile}, "REGISTER_XLSB" . "\t" . "0" . "\n"); 379# push(@{$propertyfile}, "REGISTER_XLAM" . "\t" . "0" . "\n"); 380 push(@{$propertyfile}, "REGISTER_XLT" . "\t" . "0" . "\n"); 381 push(@{$propertyfile}, "REGISTER_XLTX" . "\t" . "0" . "\n"); 382 push(@{$propertyfile}, "REGISTER_XLTM" . "\t" . "0" . "\n"); 383 push(@{$propertyfile}, "REGISTER_IQY" . "\t" . "0" . "\n"); 384 385 push(@{$propertyfile}, "REGISTER_NO_MSO_TYPES" . "\t" . "0" . "\n"); 386 push(@{$propertyfile}, "REGISTER_ALL_MSO_TYPES" . "\t" . "0" . "\n"); 387} 388 389#################################################################################### 390# Updating the file Property.idt dynamically 391# Content: 392# Property Value 393#################################################################################### 394 395sub update_property_table 396{ 397 my ($basedir, $language, $allvariables, $languagestringref) = @_; 398 399 my $properyfilename = $basedir . $installer::globals::separator . "Property.idt"; 400 401 my $propertyfile = installer::files::read_file($properyfilename); 402 403 my $hasarpnomodify = 0; 404 405 # Getting the new values 406 # Some values (arpcomments, arpcontacts, ...) are inserted from the Property.mlf 407 408 my $arpcomments = get_arpcomments_for_property_table($allvariables, $languagestringref); 409 my $installlevel = get_installlevel_for_property_table(); 410 my $ischeckforproductupdates = get_ischeckforproductupdates_for_property_table(); 411 my $manufacturer = get_manufacturer_for_property_table(); 412 my $productlanguage = get_productlanguage_for_property_table($language); 413 my $productname = get_productname_for_property_table($language, $allvariables); 414 my $productversion = get_productversion_for_property_table(); 415 my $quickstarterlinkname = get_quickstarterlinkname_for_property_table($language, $allvariables); 416 my $windowsminversiontext = "Windows 7 SP1"; 417 my $windowsminversionnumber = "601"; 418 my $windowsminspnumber = "1"; 419 420 # Updating the values 421 422 for ( my $i = 0; $i <= $#{$propertyfile}; $i++ ) 423 { 424 ${$propertyfile}[$i] =~ s/\bARPCOMMENTSTEMPLATE\b/$arpcomments/; 425 ${$propertyfile}[$i] =~ s/\bINSTALLLEVELTEMPLATE\b/$installlevel/; 426 ${$propertyfile}[$i] =~ s/\bISCHECKFORPRODUCTUPDATESTEMPLATE\b/$ischeckforproductupdates/; 427 ${$propertyfile}[$i] =~ s/\bMANUFACTURERTEMPLATE\b/$manufacturer/; 428 ${$propertyfile}[$i] =~ s/\bPRODUCTLANGUAGETEMPLATE\b/$productlanguage/; 429 ${$propertyfile}[$i] =~ s/\bPRODUCTNAMETEMPLATE\b/$productname/; 430 ${$propertyfile}[$i] =~ s/\bPRODUCTVERSIONTEMPLATE\b/$productversion/; 431 ${$propertyfile}[$i] =~ s/\bQUICKSTARTERLINKNAMETEMPLATE\b/$quickstarterlinkname/; 432 ${$propertyfile}[$i] =~ s/\bWINDOWSMINVERSIONTEXTTEMPLATE\b/$windowsminversiontext/; 433 ${$propertyfile}[$i] =~ s/\bWINDOWSMINVERSIONNUMBERTEMPLATE\b/$windowsminversionnumber/; 434 ${$propertyfile}[$i] =~ s/\bWINDOWSMINSPNUMBERTEMPLATE\b/$windowsminspnumber/; 435 if ( ${$propertyfile}[$i] =~ m/\bARPNOMODIFY\b/ ) { $hasarpnomodify = 1; } 436 } 437 438 # Check if are building silent MSI 439 if ( $ENV{ENABLE_SILENT_MSI} eq "TRUE" ) 440 { 441 push(@{$propertyfile}, "LIMITUI" . "\t" . "1" . "\n"); 442 if ( !($hasarpnomodify) ) 443 { 444 push(@{$propertyfile}, "ARPNOMODIFY" . "\t" . "1" . "\n"); 445 } 446 } 447 448 # Setting variables into propertytable 449 set_important_properties($propertyfile, $allvariables, $languagestringref); 450 451 # Setting variables for register for ms file types 452 set_ms_file_types_properties($propertyfile); 453 454 # Saving the file 455 456 installer::files::save_file($properyfilename ,$propertyfile); 457 my $infoline = "Updated idt file: $properyfilename\n"; 458 push(@installer::globals::logfileinfo, $infoline); 459 460} 461 462#################################################################################### 463# Setting language specific Properties in file Property.idt dynamically 464# Adding: 465# isMulti = 1 466#################################################################################### 467 468sub set_languages_in_property_table 469{ 470 my ($basedir, $languagesarrayref) = @_; 471 472 my $properyfilename = $basedir . $installer::globals::separator . "Property.idt"; 473 my $propertyfile = installer::files::read_file($properyfilename); 474 475 # Setting the info about multilingual installation in property "isMulti" 476 477 my $propertyname = "isMulti"; 478 my $ismultivalue = 0; 479 480 if ( $installer::globals::ismultilingual ) { $ismultivalue = 1; } 481 482 my $onepropertyline = $propertyname . "\t" . $ismultivalue . "\n"; 483 push(@{$propertyfile}, $onepropertyline); 484 485 # setting the ARPPRODUCTICON 486 487 if ($installer::globals::sofficeiconadded) # set in shortcut.pm 488 { 489 $onepropertyline = "ARPPRODUCTICON" . "\t" . "soffice.ico" . "\n"; 490 push(@{$propertyfile}, $onepropertyline); 491 } 492 493 # Saving the file 494 495 installer::files::save_file($properyfilename ,$propertyfile); 496 my $infoline = "Added language content into idt file: $properyfilename\n"; 497 push(@installer::globals::logfileinfo, $infoline); 498 499} 500 501############################################################ 502# Setting the ProductCode and the UpgradeCode 503# into the Property table. Both have to be stored 504# in the global file $installer::globals::codefilename 505############################################################ 506 507sub set_codes_in_property_table 508{ 509 my ($basedir) = @_; 510 511 # Reading the property file 512 513 my $properyfilename = $basedir . $installer::globals::separator . "Property.idt"; 514 my $propertyfile = installer::files::read_file($properyfilename); 515 516 # Updating the values 517 518 for ( my $i = 0; $i <= $#{$propertyfile}; $i++ ) 519 { 520 ${$propertyfile}[$i] =~ s/\bPRODUCTCODETEMPLATE\b/$installer::globals::productcode/; 521 ${$propertyfile}[$i] =~ s/\bUPGRADECODETEMPLATE\b/$installer::globals::upgradecode/; 522 } 523 524 # Saving the property file 525 526 installer::files::save_file($properyfilename ,$propertyfile); 527 my $infoline = "Added language content into idt file: $properyfilename\n"; 528 push(@installer::globals::logfileinfo, $infoline); 529 530} 531 532############################################################ 533# Changing default for MS file type registration 534# in Beta products. 535############################################################ 536 537sub update_checkbox_table 538{ 539 my ($basedir, $allvariables) = @_; 540 541 if (( $allvariables->{'PRODUCTEXTENSION'} ) && ( $allvariables->{'PRODUCTEXTENSION'} eq "Beta" )) 542 { 543 my $checkboxfilename = $basedir . $installer::globals::separator . "CheckBox.idt"; 544 545 if ( -f $checkboxfilename ) 546 { 547 my $checkboxfile = installer::files::read_file($checkboxfilename); 548 549 my $checkboxline = "SELECT_WORD" . "\t" . "0" . "\n"; 550 push(@{$checkboxfile}, $checkboxline); 551 $checkboxline = "SELECT_EXCEL" . "\t" . "0" . "\n"; 552 push(@{$checkboxfile}, $checkboxline); 553 $checkboxline = "SELECT_POWERPOINT" . "\t" . "0" . "\n"; 554 push(@{$checkboxfile}, $checkboxline); 555 $checkboxline = "SELECT_VISIO" . "\t" . "0" . "\n"; 556 push(@{$checkboxfile}, $checkboxline); 557 558 # Saving the property file 559 installer::files::save_file($checkboxfilename ,$checkboxfile); 560 my $infoline = "Added ms file type defaults into idt file: $checkboxfilename\n"; 561 push(@installer::globals::logfileinfo, $infoline); 562 } 563 } 564} 565 5661; 567
