summaryrefslogtreecommitdiff
path: root/solenv/bin/modules/pre2par
diff options
context:
space:
mode:
Diffstat (limited to 'solenv/bin/modules/pre2par')
-rw-r--r--solenv/bin/modules/pre2par/directory.pm54
-rw-r--r--solenv/bin/modules/pre2par/existence.pm74
-rw-r--r--solenv/bin/modules/pre2par/exiter.pm70
-rw-r--r--solenv/bin/modules/pre2par/files.pm125
-rw-r--r--solenv/bin/modules/pre2par/globals.pm68
-rw-r--r--solenv/bin/modules/pre2par/language.pm172
-rw-r--r--solenv/bin/modules/pre2par/parameter.pm178
-rw-r--r--solenv/bin/modules/pre2par/pathanalyzer.pm75
-rw-r--r--solenv/bin/modules/pre2par/remover.pm67
-rw-r--r--solenv/bin/modules/pre2par/systemactions.pm206
-rw-r--r--solenv/bin/modules/pre2par/work.pm363
11 files changed, 1452 insertions, 0 deletions
diff --git a/solenv/bin/modules/pre2par/directory.pm b/solenv/bin/modules/pre2par/directory.pm
new file mode 100644
index 000000000000..2253c54bc47a
--- /dev/null
+++ b/solenv/bin/modules/pre2par/directory.pm
@@ -0,0 +1,54 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+package pre2par::directory;
+
+use pre2par::pathanalyzer;
+use pre2par::systemactions;
+
+############################################
+# Checking, whether the output directories
+# exist. If not, they are created.
+############################################
+
+sub check_directory
+{
+ my ($parfilename) = @_;
+
+ my $productdirectory = $parfilename;
+ pre2par::pathanalyzer::get_path_from_fullqualifiedname(\$productdirectory);
+ $productdirectory =~ s/\Q$pre2par::globals::separator\E\s*$//;
+
+ my $pardirectory = $productdirectory;
+ pre2par::pathanalyzer::get_path_from_fullqualifiedname(\$pardirectory);
+ $pardirectory =~ s/\Q$pre2par::globals::separator\E\s*$//;
+
+ if ( ! -d $pardirectory ) { pre2par::systemactions::create_directory($pardirectory); }
+ if ( ! -d $productdirectory ) { pre2par::systemactions::create_directory($productdirectory); }
+}
+
+1; \ No newline at end of file
diff --git a/solenv/bin/modules/pre2par/existence.pm b/solenv/bin/modules/pre2par/existence.pm
new file mode 100644
index 000000000000..1775f1d9394c
--- /dev/null
+++ b/solenv/bin/modules/pre2par/existence.pm
@@ -0,0 +1,74 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+package pre2par::existence;
+
+#############################
+# Test of existence
+#############################
+
+sub exists_in_array
+{
+ my ($searchstring, $arrayref) = @_;
+
+ my $alreadyexists = 0;
+
+ for ( my $i = 0; $i <= $#{$arrayref}; $i++ )
+ {
+ if ( ${$arrayref}[$i] eq $searchstring)
+ {
+ $alreadyexists = 1;
+ last;
+ }
+ }
+
+ return $alreadyexists;
+}
+
+sub exists_in_array_of_hashes
+{
+ my ($searchkey, $searchvalue, $arrayref) = @_;
+
+ my $hashref;
+ my $valueexists = 0;
+
+ for ( my $i = 0; $i <= $#{$arrayref}; $i++ )
+ {
+ $hashref = ${$arrayref}[$i];
+
+ if ( $hashref->{$searchkey} eq $searchvalue )
+ {
+ $valueexists = 1;
+ last;
+ }
+ }
+
+ return $valueexists;
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/exiter.pm b/solenv/bin/modules/pre2par/exiter.pm
new file mode 100644
index 000000000000..fe992aad4253
--- /dev/null
+++ b/solenv/bin/modules/pre2par/exiter.pm
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+package pre2par::exiter;
+
+use pre2par::files;
+use pre2par::globals;
+
+############################################
+# Exiting the program with an error
+# This function is used instead of "die"
+############################################
+
+sub exit_program
+{
+ my ($message, $function) = @_;
+
+ my $infoline;
+
+ $infoline = "\n***************************************************************\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+ print("$infoline");
+
+ $infoline = "$message\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+ print("$infoline");
+
+ $infoline = "in function: $function\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+ print("$infoline");
+
+ $infoline = "***************************************************************\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+
+ if ($pre2par::globals::logging)
+ {
+ pre2par::files::save_file($pre2par::globals::logfilename ,\@pre2par::globals::logfileinfo);
+ print("Saved logfile: $pre2par::globals::logfilename\n");
+ }
+
+ print("$infoline");
+
+ exit(-1);
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/files.pm b/solenv/bin/modules/pre2par/files.pm
new file mode 100644
index 000000000000..e3de88b6dd4e
--- /dev/null
+++ b/solenv/bin/modules/pre2par/files.pm
@@ -0,0 +1,125 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+package pre2par::files;
+
+use pre2par::exiter;
+
+############################################
+# File Operations
+############################################
+
+sub check_file
+{
+ my ($arg) = @_;
+
+ if(!( -f $arg ))
+ {
+ pre2par::exiter::exit_program("ERROR: Cannot find file $arg", "check_file");
+ }
+}
+
+sub read_file
+{
+ my ($localfile) = @_;
+
+ my @localfile = ();
+
+ open( IN, "<$localfile" ) || pre2par::exiter::exit_program("ERROR: Cannot open file: $localfile", "read_file");
+ while ( <IN> ) { push(@localfile, $_); }
+ close( IN );
+
+ return \@localfile;
+}
+
+###########################################
+# Saving files, arrays and hashes
+###########################################
+
+sub save_file
+{
+ my ($savefile, $savecontent) = @_;
+ if (-f $savefile) { unlink $savefile };
+ if (-f $savefile) { pre2par::exiter::exit_program("ERROR: Cannot delete existing file: $savefile", "save_file"); };
+ open( OUT, ">$savefile" );
+ print OUT @{$savecontent};
+ close( OUT);
+ if (! -f $savefile) { pre2par::exiter::exit_program("ERROR: Cannot write file: $savefile", "save_file"); }
+}
+
+sub save_hash
+{
+ my ($savefile, $hashref) = @_;
+
+ my @printcontent = ();
+
+ my ($itemkey, $itemvalue, $line);
+
+ foreach $itemkey ( keys %{$hashref} )
+ {
+ $line = "";
+ $itemvalue = $hashref->{$itemkey};
+ $line = $itemkey . "=" . $itemvalue . "\n";
+ push(@printcontent, $line);
+ }
+
+ open( OUT, ">$savefile" );
+ print OUT @printcontent;
+ close( OUT);
+}
+
+sub save_array_of_hashes
+{
+ my ($savefile, $arrayref) = @_;
+
+ my @printcontent = ();
+
+ my ($itemkey, $itemvalue, $line, $hashref);
+
+ for ( my $i = 0; $i <= $#{$arrayref}; $i++ )
+ {
+ $line = "";
+ $hashref = ${$arrayref}[$i];
+
+ foreach $itemkey ( keys %{$hashref} )
+ {
+ $itemvalue = $hashref->{$itemkey};
+
+ $line = $line . $itemkey . "=" . $itemvalue . "\t";
+ }
+
+ $line = $line . "\n";
+
+ push(@printcontent, $line);
+ }
+
+ open( OUT, ">$savefile" );
+ print OUT @printcontent;
+ close( OUT);
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/globals.pm b/solenv/bin/modules/pre2par/globals.pm
new file mode 100644
index 000000000000..a0a50dc11958
--- /dev/null
+++ b/solenv/bin/modules/pre2par/globals.pm
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+package pre2par::globals;
+
+############################################
+# Global settings
+############################################
+
+BEGIN
+{
+ $prog="pre2par";
+
+ $prefilename = "";
+ $parfilename = "";
+ $langfilename = "";
+
+ @allitems = ("Installation", "ScpAction", "HelpText", "Directory", "DataCarrier", "StarRegistry", "File",
+ "Shortcut", "Custom", "Unixlink", "Procedure", "Module", "Profile", "ProfileItem",
+ "Folder", "FolderItem", "RegistryItem", "StarRegistryItem", "WindowsCustomAction",
+ "MergeModule");
+
+ $logging = 0;
+ $logfilename = "logfile.log"; # the default logfile name for global errors
+ @logfileinfo = ();
+
+ $plat = $^O;
+
+ $separator = "/";
+ $pathseparator = "\:";
+ $isunix = 1;
+ $iswin = 0;
+
+ $islinux = 0;
+ $issolaris = 0;
+
+ if ( $plat =~ /linux/i ) { $islinux = 1; }
+ if ( $plat =~ /kfreebsd/i ) { $islinux = 1; }
+ if ( $plat =~ /solaris/i ) { $issolaris = 1; }
+
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/language.pm b/solenv/bin/modules/pre2par/language.pm
new file mode 100644
index 000000000000..b5dc336ba847
--- /dev/null
+++ b/solenv/bin/modules/pre2par/language.pm
@@ -0,0 +1,172 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+package pre2par::language;
+
+use pre2par::existence;
+
+##############################################################
+# Returning a specific language string from the block
+# of all translations
+##############################################################
+
+sub get_language_string_from_language_block
+{
+ my ($language_block, $language) = @_;
+
+ my $newstring = "";
+
+ for ( my $i = 0; $i <= $#{$language_block}; $i++ )
+ {
+
+ if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
+ {
+ $newstring = $1;
+ $newstring =~ s/\"/\\\"/g; # masquerading all '"' in the string
+ $newstring = "\"" . $newstring . "\"";
+ last;
+ }
+ }
+
+ # defaulting to english!
+
+ if ( $newstring eq "" )
+ {
+ $language = "en-US"; # defaulting to english
+
+ for ( my $i = 0; $i <= $#{$language_block}; $i++ )
+ {
+ if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*(\".*\")\s*$/ )
+ {
+ $newstring = $1;
+ last;
+ }
+ }
+ }
+
+ return $newstring;
+}
+
+##############################################################
+# Returning the complete block in all languages
+# for a specified string
+##############################################################
+
+sub get_language_block_from_language_file
+{
+ my ($searchstring, $langfile) = @_;
+
+ my @language_block = ();
+
+ for ( my $i = 0; $i <= $#{$langfile}; $i++ )
+ {
+ if ( ${$langfile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
+ {
+ my $counter = $i;
+
+ push(@language_block, ${$langfile}[$counter]);
+ $counter++;
+
+ while (( $counter <= $#{$langfile} ) && (!( ${$langfile}[$counter] =~ /^\s*\[/ )))
+ {
+ push(@language_block, ${$langfile}[$counter]);
+ $counter++;
+ }
+
+ last;
+ }
+ }
+
+ return \@language_block;
+}
+
+############################################
+# collecting all replace strings
+# in a language file
+############################################
+
+sub get_all_replace_strings
+{
+ my ($langfile) = @_;
+
+ my @allstrings = ();
+
+ for ( my $i = 0; $i <= $#{$langfile}; $i++ )
+ {
+ if ( ${$langfile}[$i] =~ /^\s*\[\s*(.*?)\s*\]\s*$/ )
+ {
+ my $replacestring = $1;
+ if (! pre2par::existence::exists_in_array($replacestring, \@allstrings))
+ {
+ push(@allstrings, $replacestring);
+ }
+ }
+ }
+
+ return \@allstrings;
+}
+
+############################################
+# localizing the par file with the
+# corresponding language file
+############################################
+
+sub localize
+{
+ my ($parfile, $langfile) = @_;
+
+ my $allreplacestrings = get_all_replace_strings($langfile);
+
+ for ( my $i = 0; $i <= $#{$parfile}; $i++ )
+ {
+ my $oneline = ${$parfile}[$i];
+
+ for ( my $j = 0; $j <= $#{$allreplacestrings}; $j++ )
+ {
+ if ( $oneline =~ /\b${$allreplacestrings}[$j]\b/ ) # Not for basic scripts
+ {
+ my $oldstring = ${$allreplacestrings}[$j];
+
+ if ( $oneline =~ /^\s*\w+\s*\(([\w-]+)\)\s*\=/ )
+ {
+ my $language = $1; # can be "01" or "en" or "en-US" or ...
+
+ my $languageblock = get_language_block_from_language_file($oldstring, $langfile);
+ my $newstring = get_language_string_from_language_block($languageblock, $language);
+
+ if ( $newstring eq "" ) { $newstring = "\"" . $oldstring . "\""; }
+
+ $oneline =~ s/$oldstring/$newstring/g;
+
+ ${$parfile}[$i] = $oneline;
+ }
+ }
+ }
+ }
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/parameter.pm b/solenv/bin/modules/pre2par/parameter.pm
new file mode 100644
index 000000000000..763f1963051c
--- /dev/null
+++ b/solenv/bin/modules/pre2par/parameter.pm
@@ -0,0 +1,178 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+package pre2par::parameter;
+
+use Cwd;
+use pre2par::files;
+use pre2par::globals;
+use pre2par::systemactions;
+
+############################################
+# Parameter Operations
+############################################
+
+sub usage
+{
+ print <<Ende;
+---------------------------------------------------------
+$pre2par::globals::prog
+The following parameter are needed:
+-s: path to the pre file
+-o: path to the par file
+-l: path to the ulf file (mlf or jlf file)
+-v: log process (optional)
+
+Example:
+
+perl pre2par.pl -l test.mlf -s readme.pre -o readme.par -v
+
+---------------------------------------------------------
+Ende
+ exit(-1);
+}
+
+#####################################
+# Reading parameter
+#####################################
+
+sub getparameter
+{
+ while ( $#ARGV >= 0 )
+ {
+ my $param = shift(@ARGV);
+
+ if ($param eq "-s") { $pre2par::globals::prefilename = shift(@ARGV); }
+ elsif ($param eq "-o") { $pre2par::globals::parfilename = shift(@ARGV); }
+ elsif ($param eq "-l") { $pre2par::globals::langfilename = shift(@ARGV); }
+ elsif ($param eq "-v") { $pre2par::globals::logging = 1; }
+ else
+ {
+ print("\n*************************************\n");
+ print("Sorry, unknown parameter: $param");
+ print("\n*************************************\n");
+ usage();
+ exit(-1);
+ }
+ }
+}
+
+############################################
+# Controlling the fundamental parameter
+# (required for every process)
+############################################
+
+sub control_parameter
+{
+ if ($pre2par::globals::prefilename eq "")
+ {
+ print "\n************************************************\n";
+ print "Error: Name of the input file not set (-s)!";
+ print "\n************************************************\n";
+ usage();
+ exit(-1);
+ }
+
+ if ($pre2par::globals::parfilename eq "")
+ {
+ print "\n************************************************\n";
+ print "Error: Name of the output file not set (-o)!";
+ print "\n************************************************\n";
+ usage();
+ exit(-1);
+ }
+
+ if (!($pre2par::globals::prefilename =~ /\.pre\s*$/))
+ {
+ print "\n************************************************\n";
+ print "Error: Input file is no .pre file!";
+ print "\n************************************************\n";
+ usage();
+ exit(-1);
+ }
+
+ if (!($pre2par::globals::parfilename =~ /\.par\s*$/))
+ {
+ print "\n************************************************\n";
+ print "Error: Output file is no .par file!";
+ print "\n************************************************\n";
+ usage();
+ exit(-1);
+ }
+
+ # The input file has to exist
+
+ pre2par::files::check_file($pre2par::globals::prefilename);
+}
+
+##########################################################
+# The path parameters can be relative or absolute.
+# This function creates absolute pathes.
+##########################################################
+
+sub make_path_absolute
+{
+ my ($pathref) = @_;
+
+ if ( $pre2par::globals::isunix )
+ {
+ if (!($$pathref =~ /^\s*\//)) # this is a relative unix path
+ {
+ $$pathref = cwd() . $pre2par::globals::separator . $$pathref;
+ }
+ }
+
+ if ( $pre2par::globals::iswin )
+ {
+ if (!($$pathref =~ /^\s*\w\:/)) # this is a relative windows path
+ {
+ $$pathref = cwd() . $pre2par::globals::separator . $$pathref;
+ $$pathref =~ s/\//\\/g;
+ }
+ }
+
+ $$pathref =~ s/\Q$pre2par::globals::separator\E\s*$//; # removing ending slashes
+}
+
+#####################################
+# Writing parameter to shell
+#####################################
+
+sub outputparameter
+{
+ $pre2par::globals::logging ? ($logoption = " -v") : ($logoption = "");
+ print "\n$pre2par::globals::prog -l $pre2par::globals::langfilename -s $pre2par::globals::prefilename -o $pre2par::globals::parfilename$logoption\n";
+
+# print "\n********************************************************\n";
+# print "This is $pre2par::globals::prog, version 1.0\n";
+# print "Input file: $pre2par::globals::prefilename\n";
+# print "Output file: $pre2par::globals::parfilename\n";
+# print "********************************************************\n";
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/pathanalyzer.pm b/solenv/bin/modules/pre2par/pathanalyzer.pm
new file mode 100644
index 000000000000..f45a0808d53a
--- /dev/null
+++ b/solenv/bin/modules/pre2par/pathanalyzer.pm
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+package pre2par::pathanalyzer;
+
+use pre2par::globals;
+
+###########################################
+# Path analyzer
+###########################################
+
+sub get_path_from_fullqualifiedname
+{
+ my ($longfilenameref) = @_;
+
+ if ( $$longfilenameref =~ /\Q$pre2par::globals::separator\E/ ) # Is there a separator in the path? Otherwise the path is empty.
+ {
+ if ( $$longfilenameref =~ /^\s*(\S.*\S\Q$pre2par::globals::separator\E)(\S.+?\S)/ )
+ {
+ $$longfilenameref = $1;
+ }
+ }
+ else
+ {
+ $$longfilenameref = ""; # there is no path
+ }
+}
+
+sub make_absolute_filename_to_relative_filename
+{
+ my ($longfilenameref) = @_;
+
+ if ( $pre2par::globals::isunix )
+ {
+ if ( $$longfilenameref =~ /^.*\/(\S.+\S?)/ )
+ {
+ $$longfilenameref = $1;
+ }
+ }
+
+ if ( $pre2par::globals::iswin )
+ {
+ if ( $$longfilenameref =~ /^.*\\(\S.+\S?)/ )
+ {
+ $$longfilenameref = $1;
+ }
+ }
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/remover.pm b/solenv/bin/modules/pre2par/remover.pm
new file mode 100644
index 000000000000..4efe6ea0610c
--- /dev/null
+++ b/solenv/bin/modules/pre2par/remover.pm
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+package pre2par::remover;
+
+############################################
+# Remover
+############################################
+
+sub remove_leading_and_ending_whitespaces
+{
+ my ( $stringref ) = @_;
+
+ $$stringref =~ s/^\s*//g;
+ $$stringref =~ s/\s*$//g;
+}
+
+sub remove_leading_and_ending_quotationmarks
+{
+ my ( $stringref ) = @_;
+
+ $$stringref =~ s/^\s*\"//g;
+ $$stringref =~ s/\"\s*$//g;
+}
+
+sub remove_leading_and_ending_slashes
+{
+ my ( $stringref ) = @_;
+
+ $$stringref =~ s/^\s*\///g;
+ $$stringref =~ s/\/\s*$//g;
+}
+
+sub remove_leading_and_ending_backslashes
+{
+ my ( $stringref ) = @_;
+
+ $$stringref =~ s/^\s*\\//g;
+ $$stringref =~ s/\\\s*$//g;
+}
+
+1;
diff --git a/solenv/bin/modules/pre2par/systemactions.pm b/solenv/bin/modules/pre2par/systemactions.pm
new file mode 100644
index 000000000000..e084d7753f48
--- /dev/null
+++ b/solenv/bin/modules/pre2par/systemactions.pm
@@ -0,0 +1,206 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+package pre2par::systemactions;
+
+use File::Copy;
+use pre2par::exiter;
+use pre2par::globals;
+
+######################################################
+# Creating a new direcotory
+######################################################
+
+sub create_directory
+{
+ my ($directory) = @_;
+
+ my $returnvalue = 1;
+ my $infoline = "";
+
+ if ($directory eq "" )
+ {
+ return 0;
+ }
+
+ if (!(-d $directory))
+ {
+ $returnvalue = mkdir($directory, 0775);
+
+ if ($returnvalue)
+ {
+ $infoline = "Created directory: $directory\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+
+ if ($pre2par::globals::isunix)
+ {
+ my $localcall = "chmod 775 $directory \>\/dev\/null 2\>\&1";
+ system($localcall);
+ }
+ }
+ else
+ {
+ # New solution in parallel packing: It is possible, that the directory now exists, although it
+ # was not created in this process. There is only an important error, if the directory does not
+ # exist now.
+
+ if (!(-d $directory))
+ {
+ pre2par::exiter::exit_program("Error: Could not create directory: $directory", "create_directory");
+ }
+ else
+ {
+ $infoline = "\nAnother process created this directory in exactly this moment :-) : $directory\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+ }
+ }
+ }
+ else
+ {
+ $infoline = "\nAlready existing directory, did not create: $directory\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+ }
+}
+
+#######################################################################
+# Creating the directories, in which files are generated or unzipped
+#######################################################################
+
+sub create_directories
+{
+ my ($directory, $languagesref) =@_;
+
+ $pre2par::globals::unpackpath =~ s/\Q$pre2par::globals::separator\E\s*$//; # removing ending slashes and backslashes
+
+ my $path = $pre2par::globals::unpackpath; # this path already exists
+
+ $path = $path . $pre2par::globals::separator . $pre2par::globals::build . $pre2par::globals::separator;
+ create_directory($path);
+
+ $path = $path . $pre2par::globals::minor . $pre2par::globals::separator;
+ create_directory($path);
+
+ if ($directory eq "unzip" )
+ {
+ $path = $path . "common" . $pre2par::globals::productextension . $pre2par::globals::separator;
+ create_directory($path);
+
+ $path = $path . $directory . $pre2par::globals::separator;
+ create_directory($path);
+ }
+ else
+ {
+ $path = $path . $pre2par::globals::compiler . $pre2par::globals::productextension . $pre2par::globals::separator;
+ create_directory($path);
+
+ $path = $path . $pre2par::globals::product . $pre2par::globals::separator;
+ create_directory($path);
+
+ $path = $path . $directory . $pre2par::globals::separator;
+ create_directory($path);
+
+ if (!($$languagesref eq "" )) # this will be a path like "01_49", for Profiles and ConfigurationFiles, idt-Files
+ {
+ $path = $path . $$languagesref . $pre2par::globals::separator;
+ create_directory($path);
+ }
+ }
+
+ $path =~ s/\Q$pre2par::globals::separator\E\s*$//;
+
+ return $path;
+}
+
+########################
+# Copying one file
+########################
+
+sub copy_one_file
+{
+ my ($source, $dest) = @_;
+
+ my ($copyreturn, $returnvalue, $infoline);
+
+ $copyreturn = copy($source, $dest);
+
+ if ($copyreturn)
+ {
+ $infoline = "Copy: $source to $dest\n";
+ $returnvalue = 1;
+ }
+ else
+ {
+ $infoline = "Error: Could not copy $source to $dest\n";
+ $returnvalue = 0;
+ }
+
+ push(@pre2par::globals::logfileinfo, $infoline);
+
+ return $returnvalue;
+}
+
+##########################################
+# Copying all files from one directory
+# to another directory
+##########################################
+
+sub copy_directory
+{
+ my ($sourcedir, $destdir) = @_;
+
+ my ($onefile, $sourcefile, $destfile);
+ my @sourcefiles = ();
+
+ $sourcedir =~ s/\Q$pre2par::globals::separator\E\s*$//;
+ $destdir =~ s/\Q$pre2par::globals::separator\E\s*$//;
+
+ $infoline = "\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+ $infoline = "Copying files from directory $sourcedir to directory $destdir\n";
+ push(@pre2par::globals::logfileinfo, $infoline);
+
+ opendir(DIR, $sourcedir);
+ @sourcefiles = readdir(DIR);
+ closedir(DIR);
+
+ foreach $onefile (@sourcefiles)
+ {
+ if ((!($onefile eq ".")) && (!($onefile eq "..")))
+ {
+ $sourcefile = $sourcedir . $pre2par::globals::separator . $onefile;
+ $destfile = $destdir . $pre2par::globals::separator . $onefile;
+ if ( -f $sourcefile ) # only files, no directories
+ {
+ copy_one_file($sourcefile, $destfile);
+ }
+ }
+ }
+}
+
+
+1;
diff --git a/solenv/bin/modules/pre2par/work.pm b/solenv/bin/modules/pre2par/work.pm
new file mode 100644
index 000000000000..d70f75e80b2e
--- /dev/null
+++ b/solenv/bin/modules/pre2par/work.pm
@@ -0,0 +1,363 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+package pre2par::work;
+
+use pre2par::exiter;
+use pre2par::remover;
+use pre2par::pathanalyzer;
+
+############################################
+# pre2par working module
+############################################
+
+############################################
+# procedure to split a line, that contains
+# more than one par file lines
+############################################
+
+sub split_line
+{
+ my ($line, $parfile) = @_;
+
+ while ( $line =~ /^((?:[^"]|\"(?:[^"\\]|\\.)*\")*?\;\s+)\s*(.*)$/ )
+ {
+ my $oneline = $1;
+ $line = $2;
+ pre2par::remover::remove_leading_and_ending_whitespaces(\$oneline);
+ $oneline = $oneline . "\n";
+ push(@{$parfile}, $oneline);
+
+ if ( $line =~ /^\s*End\s+(\w+.*$)/i )
+ {
+ $line = $1;
+ push(@{$parfile}, "End\n\n");
+ }
+ }
+
+ # the last line
+
+ pre2par::remover::remove_leading_and_ending_whitespaces(\$line);
+ $line = $line . "\n";
+ push(@{$parfile}, $line);
+
+ if ( $line =~ /^\s*End\s*$/i ) { push(@{$parfile}, "\n"); }
+}
+
+###################################################################
+# Preprocessing the pre file to split all lines with semicolon
+###################################################################
+
+sub preprocess_macros
+{
+ my ($prefile) = @_;
+
+ my @newprefile = ();
+
+ for ( my $i = 0; $i <= $#{$prefile}; $i++ )
+ {
+ my $oneline = ${$prefile}[$i];
+ if ( $oneline =~ /\;\s*\w+/ )
+ {
+ split_line($oneline, \@newprefile);
+ }
+ else
+ {
+ push(@newprefile, $oneline);
+ }
+ }
+
+ return \@newprefile;
+}
+
+############################################
+# main working procedure
+############################################
+
+sub convert
+{
+ my ($prefile) = @_;
+
+ my @parfile = ();
+
+ my $iscodesection = 0;
+ my $ismultiliner = 0;
+ my $globalline = "";
+
+ # Preprocessing the pre file to split all lines with semicolon
+ $prefile = preprocess_macros($prefile);
+
+ for ( my $i = 0; $i <= $#{$prefile}; $i++ )
+ {
+ my $oneline = ${$prefile}[$i];
+
+ if ($iscodesection)
+ {
+ if ( $oneline =~ /^\s*\}\;\s*$/ )
+ {
+ $iscodesection = 0;
+ }
+ else # nothing to do for code inside a code section
+ {
+ push(@parfile, $oneline);
+ next;
+ }
+ }
+
+ if ( $oneline =~ /^\s*$/ ) { next; }
+
+ if ( $oneline =~ /^\s*Code\s+\=\s+\{/ )
+ {
+ $iscodesection = 1;
+ }
+
+ pre2par::remover::remove_leading_and_ending_whitespaces(\$oneline);
+
+ my $insertemptyline = 0;
+
+ if ( $oneline =~ /^\s*End\s*$/i ) { $insertemptyline = 1; }
+
+ # Sometimes the complete file is in one line, then the gid line has to be separated
+
+ if ( $oneline =~ /^\s*(\w+\s+\w+)\s+(\w+\s+\=.*$)/ ) # three words before the equal sign
+ {
+ my $gidline = $1;
+ $oneline = $2;
+ $gidline = $gidline . "\n";
+
+ push(@parfile, $gidline);
+ }
+
+ if ( $oneline =~ /\;\s*\w+/ )
+ {
+ split_line($oneline, \@parfile);
+ next;
+ }
+
+ # searching for lines with brackets, like Customs = { ..., which can be parted above several lines
+
+ if ( $oneline =~ /^\s*\w+\s+\=\s*\(.*\)\s*\;\s*$/ ) # only one line
+ {
+ if (( ! ( $oneline =~ /^\s*Assignment\d+\s*\=/ )) && ( ! ( $oneline =~ /^\s*PatchAssignment\d+\s*\=/ )))
+ {
+ $oneline =~ s/\s//g; # removing whitespaces in lists
+ $oneline =~ s/\=/\ \=\ /; # adding whitespace around equals sign
+ }
+ }
+
+ if ( $oneline =~ /^\s*\w+\s+\=\s*$/ )
+ {
+ $oneline =~ s/\s*$//;
+ pre2par::exiter::exit_program("Error: Illegal syntax, no line break after eqals sign allowed. Line: \"$oneline\"", "convert");
+ }
+
+ if (( $oneline =~ /^\s*\w+\s+\=\s*\(/ ) && (!( $oneline =~ /\)\s*\;\s*$/ ))) # several lines
+ {
+ $ismultiliner = 1;
+ $oneline =~ s/\s//g;
+ $globalline .= $oneline;
+ next; # not including yet
+ }
+
+ if ( $ismultiliner )
+ {
+ $oneline =~ s/\s//g;
+ $globalline .= $oneline;
+
+ if ( $oneline =~ /\)\s*\;\s*$/ ) { $ismultiliner = 0; }
+
+ if (! ( $ismultiliner ))
+ {
+ $globalline =~ s/\=/\ \=\ /; # adding whitespace around equals sign
+ $globalline .= "\n";
+ push(@parfile, $globalline);
+ $globalline = "";
+ }
+
+ next;
+ }
+
+ $oneline = $oneline . "\n";
+
+ $oneline =~ s/\s*\=\s*/ \= /; # nice, to have only one whitespace around equal signs
+
+ # Concatenate adjacent string literals:
+ while ($oneline =~
+ s/^((?:[^"]*
+ \"(?:[^\\"]|\\.)*\"
+ (?:[^"]*[^[:blank:]"][^"]*\"(?:[^\\"]|\\.)*\")*)*
+ [^"]*
+ \"(?:[^\\"]|\\.)*)
+ \"[[:blank:]]*\"
+ ((?:[^\\"]|\\.)*\")
+ /\1\2/x)
+ {}
+
+ push(@parfile, $oneline);
+
+ if ($insertemptyline) { push(@parfile, "\n"); }
+
+ }
+
+ return \@parfile;
+}
+
+############################################
+# formatting the par file
+############################################
+
+sub formatter
+{
+ my ($parfile) = @_;
+
+ my $iscodesection = 0;
+
+ my $tabcounter = 0;
+ my $isinsideitem = 0;
+ my $currentitem;
+
+ for ( my $i = 0; $i <= $#{$parfile}; $i++ )
+ {
+ my $oneline = ${$parfile}[$i];
+ my $isitemline = 0;
+
+ if (! $isinsideitem )
+ {
+ for ( my $j = 0; $j <= $#pre2par::globals::allitems; $j++ )
+ {
+ if ( $oneline =~ /^\s*$pre2par::globals::allitems[$j]\s+\w+\s*$/ )
+ {
+ $currentitem = $pre2par::globals::allitems[$j];
+ $isitemline = 1;
+ $isinsideitem = 1;
+ $tabcounter = 0;
+ last;
+ }
+ }
+ }
+
+ if ( $isitemline )
+ {
+ next; # nothing to do
+ }
+
+ if ( $oneline =~ /^\s*end\s*$/i )
+ {
+ $isinsideitem = 0;
+ $tabcounter--;
+ }
+
+ if ( $isinsideitem )
+ {
+ $oneline = "\t" . $oneline;
+ ${$parfile}[$i] = $oneline;
+ }
+ }
+}
+
+###################################################
+# Returning the language file name
+###################################################
+
+sub getlangfilename
+{
+ return $pre2par::globals::langfilename;
+}
+
+###################################################
+# Creating the ulf file name from the
+# corresponding pre file name
+###################################################
+
+sub getulffilename
+{
+ my ($prefilename) = @_;
+
+ my $ulffilename = $prefilename;
+ $ulffilename =~ s/\.pre\s*$/\.ulf/;
+ pre2par::pathanalyzer::make_absolute_filename_to_relative_filename(\$ulffilename);
+
+ return $ulffilename;
+}
+
+############################################
+# Checking if a file exists
+############################################
+
+sub fileexists
+{
+ my ($langfilename) = @_;
+
+ my $fileexists = 0;
+
+ if( -f $langfilename ) { $fileexists = 1; }
+
+ return $fileexists;
+}
+
+############################################
+# Checking the existence of ulf and
+# jlf/mlf files
+############################################
+
+sub check_existence_of_langfiles
+{
+ my ($langfilename, $ulffilename) = @_;
+
+ my $do_localize = 0;
+
+ if (( fileexists($ulffilename) ) && ( ! fileexists($langfilename) )) { pre2par::exiter::exit_program("Error: Did not find language file $langfilename", "check_existence_of_langfiles"); }
+ if (( fileexists($ulffilename) ) && ( fileexists($langfilename) )) { $do_localize = 1; }
+
+ return $do_localize;
+}
+
+############################################
+# Checking that the pre file has content
+############################################
+
+sub check_content
+{
+ my ($filecontent, $filename) = @_;
+
+ if ( $#{$filecontent} < 0 ) { pre2par::exiter::exit_program("Error: $filename has no content!", "check_content"); }
+}
+
+############################################
+# Checking content of par files.
+# Currently only size.
+############################################
+
+sub diff_content
+{
+ my ($content1, $content2, $filename) = @_;
+
+ if ( $#{$content1} != $#{$content2} ) { pre2par::exiter::exit_program("Error: $filename was not saved correctly!", "diff_content"); }
+}
+
+1;