Changeset 5760 for trunk/src


Ignore:
Timestamp:
May 19, 2001, 9:43:54 PM (24 years ago)
Author:
sandervl
Message:

LPtoDP/DPtoLP: check input because GpiConvert doesn't like illegal values

Location:
trunk/src/gdi32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/gdi32.cpp

    r5709 r5760  
    1 /* $Id: gdi32.cpp,v 1.69 2001-05-15 10:34:01 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.70 2001-05-19 19:43:53 sandervl Exp $ */
    22
    33/*
     
    517517//******************************************************************************
    518518//******************************************************************************
    519 BOOL WIN32API DPtoLP( HDC arg1, PPOINT arg2, int  arg3)
    520 {
    521     dprintf(("GDI32: DPtoLP\n"));
    522     return O32_DPtoLP(arg1, arg2, arg3);
    523 }
    524 //******************************************************************************
    525 //******************************************************************************
    526519BOOL WIN32API Ellipse(HDC hdc, int nLeftRect, int nTopRect, int nRightRect,
    527520                      int nBottomRect)
     
    984977//******************************************************************************
    985978//******************************************************************************
    986 BOOL WIN32API LPtoDP(HDC hdc, PPOINT lpPoints, int nCount)
    987 {
    988  BOOL ret;
    989 
    990     dprintf(("LPtoDP %x %x %d", hdc, lpPoints, nCount));
    991 #ifdef DEBUG
    992     if(nCount && lpPoints) {
    993         for(int i=0;i<nCount;i++) {
    994             dprintf(("LPtoDP in (%d,%d)", lpPoints[i].x, lpPoints[i].y));
    995         }
    996     }
    997 #endif
    998     ret = O32_LPtoDP(hdc, lpPoints, nCount);
    999 #ifdef DEBUG
    1000     if(nCount && lpPoints) {
    1001         for(int i=0;i<nCount;i++) {
    1002             dprintf(("LPtoDP out (%d,%d)", lpPoints[i].x, lpPoints[i].y));
    1003         }
    1004     }
    1005 #endif
    1006     return ret;
    1007 }
    1008 //******************************************************************************
    1009 //******************************************************************************
    1010979BOOL WIN32API Pie(HDC hdc, int nLeftRect, int nTopRect, int nRightRect,
    1011980                  int nBottomRect, int nXRadial1, int nYRadial1, int nXRadial2,
  • trunk/src/gdi32/oslibgpi.h

    r4602 r5760  
    1 /* $Id: oslibgpi.h,v 1.9 2000-11-16 16:34:49 sandervl Exp $ */
     1/* $Id: oslibgpi.h,v 1.10 2001-05-19 19:43:54 sandervl Exp $ */
    22
    33/*
     
    309309   #define GreIntersectClipRectangle(a,b) (INT) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PRECTL)(b),0L,0x00004075L)
    310310
     311#ifndef _OS2WIN_H
     312#define OPEN32API       _System
     313
     314BOOL    OPEN32API _O32_LPtoDP( HDC, PPOINT, int );
     315
     316inline BOOL O32_LPtoDP(HDC a, PPOINT b, int c)
     317{
     318 BOOL yyrc;
     319 USHORT sel = RestoreOS2FS();
     320
     321    yyrc = _O32_LPtoDP(a, b, c);
     322    SetFS(sel);
     323
     324    return yyrc;
     325}
     326BOOL    OPEN32API _O32_DPtoLP( HDC, PPOINT, int );
     327
     328inline BOOL O32_DPtoLP(HDC a, PPOINT b, int c)
     329{
     330 BOOL yyrc;
     331 USHORT sel = RestoreOS2FS();
     332
     333    yyrc = _O32_DPtoLP(a, b, c);
     334    SetFS(sel);
     335
     336    return yyrc;
     337}
     338
    311339#endif
     340#endif
  • trunk/src/gdi32/region.cpp

    r5607 r5760  
    1 /* $Id: region.cpp,v 1.20 2001-04-27 17:37:23 sandervl Exp $ */
     1/* $Id: region.cpp,v 1.21 2001-05-19 19:43:54 sandervl Exp $ */
    22
    33/*
     
    6666//******************************************************************************
    6767//******************************************************************************
    68 static LONG hdcHeight(HWND hwnd, pDCData pHps)
     68LONG hdcHeight(HWND hwnd, pDCData pHps)
    6969{
    7070    if(hwnd == 0 && pHps != 0)
     
    111111//******************************************************************************
    112112//******************************************************************************
    113 static LONG hdcWidth(HWND hwnd, pDCData pHps)
     113LONG hdcWidth(HWND hwnd, pDCData pHps)
    114114{
    115115    if(hwnd == 0 && pHps != 0)
  • trunk/src/gdi32/transform.cpp

    r5709 r5760  
    1 /* $Id: transform.cpp,v 1.3 2001-05-15 10:34:02 sandervl Exp $ */
     1/* $Id: transform.cpp,v 1.4 2001-05-19 19:43:54 sandervl Exp $ */
    22
    33/*
    4  * GDI32 coordinate & translformation code
     4 * GDI32 coordinate & transformation code
    55 *
    66 * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
     
    3434static const XFORM_W  XFORMIdentity    = { 1.0, 0.0, 0.0, 1.0, 0, 0 };
    3535
     36//region.cpp (todo; move to header)
     37LONG hdcHeight(HWND hwnd, pDCData pHps);
     38LONG hdcWidth(HWND hwnd, pDCData pHps);
     39
     40//******************************************************************************
     41//******************************************************************************
     42BOOL WIN32API LPtoDP(HDC hdc, PPOINT lpPoints, int nCount)
     43{
     44 BOOL ret;
     45 DWORD hdcwidth, hdcheight;
     46 pDCData pHps;
     47
     48    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     49    if(!pHps)
     50    {
     51        dprintf(("WARNING: LPtoDP %x invalid handle!!", hdc));
     52        SetLastError(ERROR_INVALID_HANDLE_W);
     53        return FALSE;
     54    }
     55
     56    dprintf(("LPtoDP %x %x %d", hdc, lpPoints, nCount));
     57
     58    //GpiConvert doesn't like illegal values; TODO: check what NT does
     59    if(nCount && lpPoints) {
     60        hdcwidth  = hdcWidth(0, pHps);
     61        hdcheight = hdcHeight(0, pHps);
     62        for(int i=0;i<nCount;i++) {
     63            dprintf(("LPtoDP in (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     64            if(lpPoints[i].x > hdcwidth) {
     65                dprintf(("WARNING: LPtoDP correcting x value; hdcwidth = %d", hdcwidth));
     66                lpPoints[i].x = 0;
     67            }
     68            if(lpPoints[i].y > hdcwidth) {
     69                dprintf(("WARNING: LPtoDP correcting y value; hdcheight = %d", hdcheight));
     70                lpPoints[i].y = 0;
     71            }
     72        }
     73    }
     74    ret = O32_LPtoDP(hdc, lpPoints, nCount);
     75#ifdef DEBUG
     76    if(nCount && lpPoints) {
     77        for(int i=0;i<nCount;i++) {
     78            dprintf(("LPtoDP out (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     79        }
     80    }
     81#endif
     82    return ret;
     83}
     84//******************************************************************************
     85//******************************************************************************
     86BOOL WIN32API DPtoLP(HDC hdc, PPOINT lpPoints, int nCount)
     87{
     88    BOOL ret;
     89    DWORD hdcwidth, hdcheight;
     90    pDCData pHps;
     91
     92    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     93    if(!pHps)
     94    {
     95        dprintf(("WARNING: DPtoLP %x invalid handle!!", hdc));
     96        SetLastError(ERROR_INVALID_HANDLE_W);
     97        return FALSE;
     98    }
     99
     100    dprintf(("GDI32: DPtoLP %x %x %d", hdc, lpPoints, nCount));
     101
     102    //GpiConvert doesn't like illegal values; TODO: check what NT does
     103    if(nCount && lpPoints) {
     104        hdcwidth  = hdcWidth(0, pHps);
     105        hdcheight = hdcHeight(0, pHps);
     106        for(int i=0;i<nCount;i++) {
     107            dprintf(("DPtoLP in (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     108            if(lpPoints[i].x > hdcwidth) {
     109                dprintf(("WARNING: DPtoLP correcting x value; hdcwidth = %d", hdcwidth));
     110                lpPoints[i].x = 0;
     111            }
     112            if(lpPoints[i].y > hdcwidth) {
     113                dprintf(("WARNING: DPtoLP correcting y value; hdcheight = %d", hdcheight));
     114                lpPoints[i].y = 0;
     115            }
     116        }
     117    }
     118
     119    ret = O32_DPtoLP(hdc, lpPoints, nCount);
     120#ifdef DEBUG
     121    if(nCount && lpPoints) {
     122        for(int i=0;i<nCount;i++) {
     123            dprintf(("DPtoLP out (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     124        }
     125    }
     126#endif
     127    return ret;
     128}
    36129//******************************************************************************
    37130//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.