Changeset 24569

Show
Ignore:
Timestamp:
07.09.2011 18:52:02 (8 years ago)
Author:
ak19
Message:

1. Thanks to Diego, a bug was identified which prevented the openoffice extension from working on Ubuntu: there was reference to the Win32 package even when we're not on Windows. 2. The code now does a better job of working out the default location for SOFFICE_HOME if this is not set. 3. The code changes allow the extension to work successfully with LibreOffice?, since that is also launched with soffice and because jodjar is able to work with it in the same way as it works with openoffice.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/open-office/trunk/src/perllib/plugins/OpenOfficeConverter.pm

    r24104 r24569  
    232232#    into the command to launch jodconverter so that, when using the remote GS server 
    233233#    on Windows, jodconverter can find the openoffice installation:  
    234     my $office_short_path = Win32::GetShortPathName($ENV{'SOFFICE_HOME'}); 
    235     my $convert_cmd = "java -Doffice.home=\"".$office_short_path."\" -jar \"$jodjar\" --port $ENV{'JODCONVERTER_PORT'}";  
    236  
    237     # commented out the following line since jodjar always assumes that soffice  
    238     # is in C:\Prog Files\OpenOffice org 3 rather than checking for any SOFFICE var 
    239     # the user may have set. So need to run with the -Doffice.home flag that's set above 
    240     # rather than run without it as was being done below. 
    241 #    my $convert_cmd = "java -jar \"$jodjar\" --port $ENV{'JODCONVERTER_PORT'}"; 
     234 
     235    my $office_short_path; 
     236    if(defined $ENV{'SOFFICE_HOME'}) { # points to libreoffice or openoffice, since soffice launches both 
     237    if ($ENV{'GSDLOS'} =~ m/^windows$/) { 
     238        $office_short_path = Win32::GetShortPathName($ENV{'SOFFICE_HOME'}); 
     239    } else { 
     240        $office_short_path = $ENV{'SOFFICE_HOME'}; 
     241    } 
     242    }  
     243    else { # SOFFICE_HOME not user-defined, try defaults 
     244    if ($ENV{'GSDLOS'} =~ m/^windows$/) { 
     245        $office_short_path = "C:\\PROGRA~1\\OPENOF~1.ORG"; 
     246    } else { 
     247        if (-d "/usr/lib/libreoffice") { # try libreoffice first 
     248        $office_short_path = "/usr/lib/libreoffice"; 
     249        } elsif (-d "/usr/lib/openoffice") { # perhaps it's more likely that openoffice exists (fallback) 
     250        $office_short_path = "/usr/lib/openoffice"; 
     251        } else { # set to default linux officeHome which jodconverter tries for 
     252        $office_short_path = "/opt/openoffice.org3"; 
     253        } 
     254    } 
     255    } 
     256 
     257    # jodjar always assumes that soffice (officeHome) is in "C:\Prog Files\OpenOffice org 3" 
     258    # or "/opt/openoffice.org3" rather than checking for any user-defined SOFFICE_HOME var.  
     259    # Therefore, we run jodjar with the -Doffice.home flag explicitly set, instead of without. 
     260    # my $convert_cmd = "java -jar \"$jodjar\" --port $ENV{'JODCONVERTER_PORT'}"; 
     261    my $convert_cmd = "java -Doffice.home=\"".$office_short_path."\" -jar \"$jodjar\" --port $ENV{'JODCONVERTER_PORT'}"; 
    242262    $convert_cmd .= " \"$source_file_full_path\" \"$target_file_path\""; 
    243263