* Sync up to trunk r55544.
[reactos.git] / dll / win32 / mscms / profile.c
index c9a5b42..c4eae9d 100644 (file)
@@ -30,6 +30,7 @@
 #include "wingdi.h"
 #include "winuser.h"
 #include "winreg.h"
+#include "shlwapi.h"
 #include "icm.h"
 
 #include "mscms_priv.h"
@@ -497,7 +498,7 @@ BOOL WINAPI GetColorProfileFromHandle( HPROFILE handle, PBYTE buffer, PDWORD siz
  *  Failure: FALSE
  *
  * NOTES
- *  The profile header returned will be adjusted for endianess.
+ *  The profile header returned will be adjusted for endianness.
  */
 BOOL WINAPI GetColorProfileHeader( HPROFILE handle, PPROFILEHEADER header )
 {
@@ -660,9 +661,9 @@ BOOL WINAPI GetStandardColorSpaceProfileW( PCWSTR machine, DWORD id, PWSTR profi
     GetColorDirectoryW( machine, rgbprofile, &len );
 
     switch (id)
+    {
         case LCS_sRGB:
         case LCS_WINDOWS_COLOR_SPACE: /* FIXME */
-        {
             lstrcatW( rgbprofile, rgbprofilefile );
             len = lstrlenW( rgbprofile ) * sizeof(WCHAR);
 
@@ -1470,7 +1471,25 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
         if (!flags) return NULL;
         if (!sharing) sharing = FILE_SHARE_READ;
 
-        handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
+        if (!PathIsRelativeW( profile->pProfileData ))
+            handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
+        else
+        {
+            DWORD size;
+            WCHAR *path;
+
+            if (!GetColorDirectoryW( NULL, NULL, &size ) && GetLastError() == ERROR_MORE_DATA)
+            {
+                size += (strlenW( profile->pProfileData ) + 2) * sizeof(WCHAR);
+                if (!(path = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL;
+                GetColorDirectoryW( NULL, path, &size );
+                PathAddBackslashW( path );
+                strcatW( path, profile->pProfileData );
+            }
+            else return NULL;
+            handle = CreateFileW( path, flags, sharing, NULL, creation, 0, NULL );
+            HeapFree( GetProcessHeap(), 0, path );
+        }
         if (handle == INVALID_HANDLE_VALUE)
         {
             WARN( "Unable to open color profile %u\n", GetLastError() );