Author: jimtabor
Date: Mon Oct 27 12:56:35 2008
New Revision: 37026
URL: 
http://svn.reactos.org/svn/reactos?rev=37026&view=rev
Log:
- Cleanup and fix OffsetViewport/WindowOrgEx.
Modified:
    trunk/reactos/dll/win32/gdi32/misc/hacks.c
    trunk/reactos/dll/win32/gdi32/objects/coord.c
    trunk/reactos/subsystems/win32/win32k/objects/coord.c
Modified: trunk/reactos/dll/win32/gdi32/misc/hacks.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/misc/hacks…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/misc/hacks.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/misc/hacks.c [iso-8859-1] Mon Oct 27 12:56:35 2008
@@ -10,33 +10,6 @@
  *
  */
-/*
- * @implemented
- *
- */
-BOOL
-STDCALL
-OffsetViewportOrgEx(HDC hdc,
-                    int nXOffset,
-                    int nYOffset,
-                    LPPOINT lpPoint)
-{
-    return  NtGdiOffsetViewportOrgEx(hdc, nXOffset, nYOffset, lpPoint);
-}
-
-/*
- * @implemented
- *
- */
-BOOL
-STDCALL
-OffsetWindowOrgEx(HDC hdc,
-                  int nXOffset,
-                  int nYOffset,
-                  LPPOINT lpPoint)
-{
-    return NtGdiOffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
-}
Modified: trunk/reactos/dll/win32/gdi32/objects/coord.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/gdi32/objects/co…
==============================================================================
--- trunk/reactos/dll/win32/gdi32/objects/coord.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/gdi32/objects/coord.c [iso-8859-1] Mon Oct 27 12:56:35 2008
@@ -701,4 +701,125 @@
   return NtGdiSetLayout( hdc, wox, dwLayout);
 }
-
+/*
+ * @implemented
+ *
+ */
+BOOL
+STDCALL
+OffsetViewportOrgEx(HDC hdc,
+                    int nXOffset,
+                    int nYOffset,
+                    LPPOINT lpPoint)
+{
+#if 0
+  PDC_ATTR Dc_Attr;
+#if 0
+  if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
+  {
+    if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
+      return MFDRV_OffsetViewportOrgEx(hdc, nXOffset, nYOffset, lpPoint);
+    else
+    {
+      PLDC pLDC = GdiGetLDC(hdc);
+      if ( !pLDC )
+      {
+         SetLastError(ERROR_INVALID_HANDLE);
+         return FALSE;
+      }
+      if (pLDC->iType == LDC_EMFLDC)
+      {
+        return EMFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
+      }
+    }
+  }
+#endif
+  if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr))
return FALSE;
+
+  if ( lpPoint )
+  {
+     *lpPoint = (POINT)Dc_Attr->ptlViewportOrg;
+     if ( Dc_Attr->dwLayout & LAYOUT_RTL) lpPoint->x = -lpPoint->x;
+  }
+
+  if ( nXOffset || nYOffset != nXOffset )
+  {
+     if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc)
+     {
+        if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY)
+        {
+           NtGdiFlush();
+           Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY;
+        }
+     }
+     Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID);
+     if ( Dc_Attr->dwLayout & LAYOUT_RTL) nXOffset = -nXOffset;
+     Dc_Attr->ptlViewportOrg.x += nXOffset;
+     Dc_Attr->ptlViewportOrg.y += nYOffset;
+  }
+  return TRUE;
+#endif
+    return  NtGdiOffsetViewportOrgEx(hdc, nXOffset, nYOffset, lpPoint);
+}
+
+/*
+ * @implemented
+ *
+ */
+BOOL
+STDCALL
+OffsetWindowOrgEx(HDC hdc,
+                  int nXOffset,
+                  int nYOffset,
+                  LPPOINT lpPoint)
+{
+#if 0
+  PDC_ATTR Dc_Attr;
+#if 0
+  if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
+  {
+    if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
+      return MFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
+    else
+    {
+      PLDC pLDC = GdiGetLDC(hdc);
+      if ( !pLDC )
+      {
+         SetLastError(ERROR_INVALID_HANDLE);
+         return FALSE;
+      }
+      if (pLDC->iType == LDC_EMFLDC)
+      {
+        return EMFDRV_OffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
+      }
+    }
+  }
+#endif
+  if (!GdiGetHandleUserData((HGDIOBJ) hdc, GDI_OBJECT_TYPE_DC, (PVOID) &Dc_Attr))
return FALSE;
+
+  if ( lpPoint )
+  {
+     *lpPoint   = (POINT)Dc_Attr->ptlWindowOrg;
+     lpPoint->x = Dc_Attr->lWindowOrgx;
+  }
+
+  if ( nXOffset || nYOffset != nXOffset )
+  {
+     if (NtCurrentTeb()->GdiTebBatch.HDC == (ULONG)hdc)
+     {
+        if (Dc_Attr->ulDirty_ & DC_MODE_DIRTY)
+        {
+           NtGdiFlush();
+           Dc_Attr->ulDirty_ &= ~DC_MODE_DIRTY;
+        }
+     }
+     Dc_Attr->flXform |= (PAGE_XLATE_CHANGED|DEVICE_TO_WORLD_INVALID);
+     Dc_Attr->ptlWindowOrg.x += nXOffset;
+     Dc_Attr->ptlWindowOrg.y += nYOffset;
+     Dc_Attr->lWindowOrgx += nXOffset;
+  }
+  return TRUE;
+#endif
+    return NtGdiOffsetWindowOrgEx(hdc, nXOffset, nYOffset, lpPoint);
+}
+
Modified: trunk/reactos/subsystems/win32/win32k/objects/coord.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/coord.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/coord.c [iso-8859-1] Mon Oct 27 12:56:35
2008
@@ -404,6 +404,7 @@
                           1);
             UnsafePoint->x = Dc_Attr->ptlViewportOrg.x;
             UnsafePoint->y = Dc_Attr->ptlViewportOrg.y;
+            if ( Dc_Attr->dwLayout & LAYOUT_RTL ) UnsafePoint->x =
-UnsafePoint->x;
         }
         _SEH_HANDLE
         {
@@ -419,6 +420,7 @@
          }
     }
+  if ( Dc_Attr->dwLayout & LAYOUT_RTL ) XOffset = -XOffset;
   Dc_Attr->ptlViewportOrg.x += XOffset;
   Dc_Attr->ptlViewportOrg.y += YOffset;
   DC_UpdateXforms(dc);