openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1524935 - in /openoffice/branches/AOO401/main: cppuhelper/source/findsofficepath.c odk/source/unoapploader/unx/unoapploader.c odk/source/unoapploader/win/unoapploader.c
Date Fri, 20 Sep 2013 08:12:30 GMT
Author: jsc
Date: Fri Sep 20 08:12:30 2013
New Revision: 1524935

URL: http://svn.apache.org/r1524935
Log:
#123283# merge fix from trunk

Modified:
    openoffice/branches/AOO401/main/cppuhelper/source/findsofficepath.c
    openoffice/branches/AOO401/main/odk/source/unoapploader/unx/unoapploader.c
    openoffice/branches/AOO401/main/odk/source/unoapploader/win/unoapploader.c

Modified: openoffice/branches/AOO401/main/cppuhelper/source/findsofficepath.c
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/cppuhelper/source/findsofficepath.c?rev=1524935&r1=1524934&r2=1524935&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/cppuhelper/source/findsofficepath.c (original)
+++ openoffice/branches/AOO401/main/cppuhelper/source/findsofficepath.c Fri Sep 20 08:12:30
2013
@@ -117,7 +117,7 @@ static char* platformSpecific()
 
 #include <unistd.h>
 #include <limits.h>
-
+#include <stdio.h>
 /*     
  * Gets the installation path from the PATH environment variable.
  *
@@ -145,7 +145,21 @@ static char* platformSpecific()
     char buffer[PATH_MAX];
     int pos;
 
-    /* get the value of the PATH environment variable */
+#ifdef MACOSX
+    /* On MacOS we have no soffice link under /usr/bin but the default office location is
known
+       and we check this only
+     */
+    const char* MACDEFAULTOFFICEPATH = "/Applications/OpenOffice.app/Contents/MacOS";
+    const char* MACDEFAULTSOFFICE = "/Applications/OpenOffice.app/Contents/MacOS/soffice";
+
+    if ( !access( MACDEFAULTSOFFICE, F_OK ) )
+    {
+        path = (char*) malloc( MACDEFAULTOFFICEPATH + 1 );
+        strcpy( path, MACDEFAULTOFFICEPATH);
+    }
+    return path;
+#else
+/* get the value of the PATH environment variable */
     env = getenv( PATHVARNAME );
 	str = (char*) malloc( strlen( env ) + 1 );
 	strcpy( str, env );
@@ -190,6 +204,7 @@ static char* platformSpecific()
 	free( str );
 
     return path;
+#endif
 }
 
 #endif

Modified: openoffice/branches/AOO401/main/odk/source/unoapploader/unx/unoapploader.c
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/odk/source/unoapploader/unx/unoapploader.c?rev=1524935&r1=1524934&r2=1524935&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/odk/source/unoapploader/unx/unoapploader.c (original)
+++ openoffice/branches/AOO401/main/odk/source/unoapploader/unx/unoapploader.c Fri Sep 20
08:12:30 2013
@@ -206,8 +206,6 @@ int main( int argc, char *argv[] )
             strcat( envstr, value );
 		}
         putenv( envstr );
-        fprintf( stderr, "DYLD_LIBRARY_PATH=%s\n", envstr );
- 
     }
     else
     {
@@ -242,8 +240,7 @@ char const* getPath()
 
     if ( path == NULL )
     {
-        fprintf( stderr, "Warning: getting path from PATH environment "
-                 "variable failed!\n" );
+        fprintf( stderr, "Warning: getting path from PATH environment variable failed!\n"
);
         fflush( stderr );
     }
 

Modified: openoffice/branches/AOO401/main/odk/source/unoapploader/win/unoapploader.c
URL: http://svn.apache.org/viewvc/openoffice/branches/AOO401/main/odk/source/unoapploader/win/unoapploader.c?rev=1524935&r1=1524934&r2=1524935&view=diff
==============================================================================
--- openoffice/branches/AOO401/main/odk/source/unoapploader/win/unoapploader.c (original)
+++ openoffice/branches/AOO401/main/odk/source/unoapploader/win/unoapploader.c Fri Sep 20
08:12:30 2013
@@ -72,149 +72,29 @@ int WINAPI WinMain( HINSTANCE hInstance,
     const char* PATHSEPARATOR = ";";
 
     char const* path = NULL;
-    char path2[MAX_PATH];
     char* value = NULL;
     char* envstr = NULL;
     char* cmdline = NULL;
     int size;
     STARTUPINFO startup_info;
     PROCESS_INFORMATION process_info;
-    BOOL bCreate;
-
+    BOOL bCreate; 
+    
     (void) hInstance; /* unused */
     (void) hPrevInstance; /* unused */
     (void) nCmdShow; /* unused */
 
     /* get the path of the UNO installation */
     path = getPath();
-
+    
     if ( path != NULL )
     {
-        wchar_t cmd[
-            MY_LENGTH(L"\"") + MAX_PATH +
-            MY_LENGTH(L"\\unoinfo.exe\" c++")];
-            /* hopefully does not overflow */
-        int pathsize;
-        SECURITY_ATTRIBUTES sec;
-        HANDLE temp;
-        HANDLE stdoutRead;
-        HANDLE stdoutWrite;
-        STARTUPINFOW startinfo;
-        PROCESS_INFORMATION procinfo;
-        int ret;
-        cmd[0] = L'"';
-        pathsize = MultiByteToWideChar(CP_ACP, 0, path, -1, cmd + 1, MAX_PATH);
-        if (pathsize == 0) {
-            writeError("Error: MultiByteToWideChar failed!\n");
-            closeErrorFile();
-            return 1;
-        }
-        if (wcschr(cmd + 1, L'"') != NULL) {
-            writeError("Error: bad characters in UNO installation path!\n");
-            closeErrorFile();
-            return 1;
-        }
-        wcscpy(
-            cmd + pathsize,
-            (L"\\unoinfo.exe\" c++" +
-             (pathsize == 1 || cmd[pathsize - 1] != L'\\' ? 0 : 1)));
-        sec.nLength = sizeof (SECURITY_ATTRIBUTES);
-        sec.lpSecurityDescriptor = NULL;
-        sec.bInheritHandle = TRUE;
-        if (CreatePipe(&temp, &stdoutWrite, &sec, 0) == 0 ||
-            DuplicateHandle(
-                GetCurrentProcess(), temp, GetCurrentProcess(), &stdoutRead, 0,
-                FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS) == 0)
-        {
-            writeError("Error: CreatePipe/DuplicateHandle failed!\n");
-            closeErrorFile();
-            return 1;
-        }
-        memset(&startinfo, 0, sizeof (STARTUPINFOW));
-        startinfo.cb = sizeof (STARTUPINFOW);
-        startinfo.lpDesktop = L"";
-        startinfo.dwFlags = STARTF_USESTDHANDLES;
-        startinfo.hStdOutput = stdoutWrite;
-        ret = CreateProcessW(
-            NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &startinfo, &procinfo);
-        if (ret != 0) {
-            char * buf = NULL;
-            size_t n = 1000;
-            size_t k = 0;
-            DWORD exitcode;
-            int path2size;
-            CloseHandle(stdoutWrite);
-            CloseHandle(procinfo.hThread);
-            for (;;) {
-                DWORD m;
-                buf = realloc(buf, n);
-                if (buf == NULL) {
-                    writeError(
-                        "Error: out of memory reading unoinfo output!\n");
-                    closeErrorFile();
-                    return 1;
-                }
-                if (!ReadFile(stdoutRead, buf + k, n - k, &m, NULL))
-                {
-                    DWORD err = GetLastError();
-                    if (err == ERROR_HANDLE_EOF || err == ERROR_BROKEN_PIPE) {
-                        break;
-                    }
-                    writeError("Error: cannot read unoinfo output!\n");
-                    closeErrorFile();
-                    return 1;
-                }
-                if (m == 0) {
-                    break;
-                }
-                k += m;
-                if (k >= n) {
-                    if (n >= SAL_MAX_SIZE / 2) {
-                        writeError(
-                            "Error: out of memory reading unoinfo output!\n");
-                        closeErrorFile();
-                        return 1;
-                    }
-                    n *= 2;
-                }
-            }
-            if ((k & 1) == 1) {
-                writeError("Error: bad unoinfo output!\n");
-                closeErrorFile();
-                return 1;
-            }
-            CloseHandle(stdoutRead);
-            if (!GetExitCodeProcess(procinfo.hProcess, &exitcode) ||
-                exitcode != 0)
-            {
-                writeError("Error: executing unoinfo failed!\n");
-                closeErrorFile();
-                return 1;
-            }
-            if (k == 0) {
-                path2size = 0;
-            } else {
-                path2size = WideCharToMultiByte(
-                    CP_ACP, 0, (wchar_t *) buf, k / 2, path2, MAX_PATH - 1,
-                    NULL, NULL);
-                if (path2size == 0) {
-                    writeError("Error: converting unoinfo output failed!\n");
-                    closeErrorFile();
-                    return 1;
-                }
-            }
-            path2[path2size] = '\0';
-            path = path2;
-        } else {
-            if (GetLastError() != ERROR_FILE_NOT_FOUND) {
-                writeError("Error: calling unoinfo failed!\n");
-                closeErrorFile();
-                return 1;
-            }
-            CloseHandle(stdoutRead);
-            CloseHandle(stdoutWrite);
-        }
-
+        /* The former code to call unoinfo first is removed because we can use the office
path
+           from the registry or from the UNO_PATH variable directly.
+           Further cleanup can remove unoinfo from the installation when all places where
it is
+           used are checked.
+          */
+        
         /* get the value of the PATH environment variable */
         value = getenv( ENVVARNAME );
 
@@ -280,7 +160,7 @@ int WINAPI WinMain( HINSTANCE hInstance,
 char const* getPath()
 {
     char const* path = cppuhelper_detail_findSofficePath();
-
+ 
     if ( path == NULL )
         writeError( "Warning: getting path from Windows Registry failed!\n" );
 



Mime
View raw message