home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / bin / ooo-wrapper < prev    next >
Encoding:
Text File  |  2006-08-01  |  2.9 KB  |  109 lines

  1. #!/usr/bin/perl -w
  2. #
  3. # ooffice - Wrapper script for OpenOffice.org
  4. #
  5.  
  6. # Define system installation directory
  7. my $SystemInstallDir = '/usr/lib/openoffice';
  8. # Suffix for parallel installable versioning
  9. my $BinSuffix = '';
  10. # ooo-build version
  11. my $OOO_BUILDVERSION = 'ooc680-m7';
  12.  
  13. if ($SystemInstallDir =~ /^@/) {
  14.     $SystemInstallDir = '/usr/lib/ooo-2.0';
  15.     $BinSuffix = '';
  16. }
  17.  
  18. my $Binary = 'soffice';
  19. if (-x "$SystemInstallDir/program/ooqstart") {
  20.     $Binary = 'ooqstart';
  21.     $ENV{OOO_EXTRA_ARG} ||= '';
  22. }
  23.  
  24. my @ooo_argv;
  25. my $widgets_set;
  26. while ($ARGV[0]) {
  27.     $_ = shift;
  28.     if (m/^--widgets-set/) {
  29.     $widgets_set = shift;
  30.     (defined $widgets_set) || die "Error: The option --widgets-set requires a value\n" .
  31.                                 "For example: --widgets-set gtk\n";
  32.     } elsif (m/^--version/) {
  33.     print "This is OpenOffice.org built with ooo-build-$OOO_BUILDVERSION\n";
  34.     exit 0;
  35.     } elsif (m/^-(base|calc|draw|impress|math|web|writer)$/ && $Binary eq "ooqstart") {
  36.         $ENV{OOO_EXTRA_ARG} = $_;
  37.     } elsif (m/^-fromtemplate$/ && $Binary eq "ooqstart") {
  38.         $ENV{OOO_EXTRA_ARG} = "slot:5500";
  39.     } elsif (m/^system:\//) {
  40.     s/^system:/file:\/\//;
  41.         push @ooo_argv, $_;
  42.     } elsif (m/^system:/) {
  43.     use Cwd;
  44.     my $dir = getcwd;
  45.     s/^system:/file:\/\/$dir\//;
  46.         push @ooo_argv, $_;
  47.     } else {
  48.         push @ooo_argv, $_;
  49.     }
  50. }
  51.  
  52. if (!@ooo_argv) {
  53.     my $arg;
  54.     if ($0 =~ m/\/oo(calc|draw|impress|math|web|writer|base)$BinSuffix$/) {
  55.         $arg = "-$1";
  56.     } elsif ($0 =~ m/\/oofromtemplate$BinSuffix$/) {
  57.         $arg = "slot:5500";
  58.     }
  59.  
  60.     if ($arg) {
  61.         if ($Binary eq "soffice") {
  62.             push @ooo_argv, "$arg";
  63.     } else {
  64.         $ENV{OOO_EXTRA_ARG} = $arg;
  65.     }
  66.     }
  67. }
  68.  
  69. if (defined $widgets_set) {
  70.     $ENV{SAL_USE_VCLPLUGIN} = $widgets_set;
  71. }
  72.  
  73. # FIXME: the following two fixes should be done by OOo itself
  74. # create the user config directory  with safe rights 700 if it we find
  75. # the right path and the directory does not exist
  76. if (open BOOTSTRAPRC, "$SystemInstallDir/program/bootstraprc") {
  77.     while (my $line = <BOOTSTRAPRC>) {
  78.     chomp $line;
  79.         if (($line =~ m/^\s*UserInstallation\s*=\s*([^\s]*)\s*$/) && ($1)) {
  80.         my $userConfDir=$1;
  81.         $userConfDir =~ s|\$SYSUSERCONFIG|$ENV{HOME}|;
  82.         $userConfDir =~ s|file://||;
  83.         mkdir ($userConfDir,0700) unless (-d $userConfDir);
  84.         last;
  85.     }
  86.     }
  87.     close BOOTSTRAPRC;
  88. }
  89. # touch ~/.recently-used with safe rights 700 if it does not exist
  90. if (! -f "$ENV{HOME}/.recently-used") {
  91.     open (RECENTLY_USED, ">$ENV{HOME}/.recently-used") &&
  92.     close RECENTLY_USED &&
  93.     chmod 0600, "$ENV{HOME}/.recently-used";
  94. }
  95.     
  96. if (!(-f '/proc/version')) {
  97.     print STDERR "\n\n --- Warning - OO.o will not work without a mounted /proc filesystem --- \n\n\n";
  98. }
  99.  
  100. if (defined $ENV{LANG}) {
  101.     if ($ENV{LANG} =~ /^th/) {
  102.     # turn off autohinting for thai (Ubuntu #35305).
  103.     $ENV{SAL_AUTOHINTING_PRIORITY} = "0";
  104.     }
  105. }
  106.  
  107. # And here we go.
  108. exec "$SystemInstallDir/program/$Binary", @ooo_argv
  109.