Ignore:
Timestamp:
Jun 18, 2009, 12:12:33 PM (16 years ago)
Author:
ydario
Message:

Gdi32 updates.

File:
1 edited

Legend:

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

    r10597 r21304  
    1 /* $Id: printer.cpp,v 1.3 2004-05-05 09:19:11 sandervl Exp $ */
     1/* $Id: printer.cpp,v 1.14 2004/05/04 13:49:24 sandervl Exp $ */
    22
    33/*
     
    55 *
    66 * Copyright 2001 Sander van Leeuwen (sandervl@xs4all.nl)
    7  *
     7 * Copyright 2002-2003 InnoTek Systemberatung GmbH (sandervl@innotek.de)
    88 *
    99 * Parts based on Wine code (StartDocW)
     
    1919#include <os2win.h>
    2020#include <stdarg.h>
     21#include <stdio.h>
    2122#include <string.h>
    2223#include <dcdata.h>
     
    2829#include "dbglocal.h"
    2930
     31// Private WGSS escape extensions
     32#define PRIVATE_QUERYORIENTATION        0x99990001
     33#define PRIVATE_QUERYCOPIES             0x99990002
     34#define PRIVATE_QUERYCOLLATE            0x99990003
     35
    3036static char *lpszPassThrough = NULL;
    3137static int   cbPassThrough   = 0;
     
    3339//NOTE: We need to insert this postscript statement into the stream or else
    3440//      the output will be completely inverted (x & y)
    35 static char  szSetupString[] = "%%BeginSetup\n[{\n%%BeginColorModelSetup\n<< /ProcessColorModel /DeviceCMYK >> setpagedevice\n%%EndColorModelSetup\n} stopped cleartomark\n%%EndSetup\n";
    36 
     41static char  szSetupStringPortrait[]  = "%%BeginSetup\n[{\n%%BeginColorModelSetup\n<< /ProcessColorModel /DeviceCMYK >> setpagedevice\n%%EndColorModelSetup\n} stopped cleartomark\n%%EndSetup\n";
     42static char  szSetupStringLandscape[] = "%%BeginSetup\n[{\n%%BeginColorModelSetup\n<< /ProcessColorModel /DeviceCMYK >> setpagedevice\n%%EndColorModelSetup\n} stopped cleartomark\n-90 rotate\n%%EndSetup\n";
     43
     44
     45static BOOL  fPostscriptPassthrough = TRUE;
     46
     47//******************************************************************************
     48//******************************************************************************
     49BOOL WIN32API ODIN_QueryPostscriptPassthrough()
     50{
     51    return fPostscriptPassthrough;
     52}
     53//******************************************************************************
     54//******************************************************************************
     55void WIN32API ODIN_SetPostscriptPassthrough(BOOL fEnabled)
     56{
     57    fPostscriptPassthrough = fEnabled;
     58}
    3759//******************************************************************************
    3860//******************************************************************************
     
    6486        dprintf(("Postscript %s data of size %d", lpszEscape, *(WORD *)lpvInData));
    6587
     88        if(fPostscriptPassthrough == FALSE)
     89        {
     90            return 0;
     91        }
     92        if(lpszPassThrough) {
     93            O32_Escape(hdc, nEscape, cbPassThrough, lpszPassThrough, NULL);
     94            free(lpszPassThrough);
     95            lpszPassThrough = NULL;
     96        }
     97        pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     98        if(pHps && (pHps->Reserved & DC_FLAG_SEND_POSTSCRIPT_SETUP_STRING))
     99        {
     100            DWORD dmOrientation = 0, hdrsize, dmCollate, dmCopies;
     101            char *pvSetupData = NULL;
     102
     103            O32_Escape(hdc, PRIVATE_QUERYORIENTATION, 0, NULL, &dmOrientation);
     104            if(dmOrientation == DMORIENT_LANDSCAPE) {
     105                hdrsize = sizeof(szSetupStringLandscape)-1;
     106                pvSetupData = (char *)alloca(hdrsize+sizeof(WORD));
     107            }
     108            else {//portrait
     109                hdrsize = sizeof(szSetupStringPortrait)-1;
     110                pvSetupData = (char *)alloca(hdrsize+sizeof(WORD));
     111            }
     112            if(pvSetupData) {
     113                *(WORD *)pvSetupData = hdrsize;
     114                memcpy(pvSetupData+sizeof(WORD), (hdrsize == sizeof(szSetupStringPortrait)-1) ? szSetupStringPortrait : szSetupStringLandscape, hdrsize);
     115
     116                O32_Escape(hdc, nEscape, *(WORD *)pvSetupData, pvSetupData, NULL);
     117
     118                dprintf(("Send Postscript setup string %d (%x):\n%s", dmOrientation, pHps->Reserved, pvSetupData+sizeof(WORD)));
     119            }
     120            pHps->Reserved &= ~DC_FLAG_SEND_POSTSCRIPT_SETUP_STRING;
     121        }
     122
    66123        rc = O32_Escape(hdc, nEscape, cbInput, lpvInData, lpvOutData);
    67124        if(rc == 1) rc = *(WORD *)lpvInData;
     
    70127    }
    71128
     129    case PRIVATE_QUERYORIENTATION:
     130        DebugInt3();
     131        return 0;
     132   
    72133    case SPCLPASSTHROUGH2:
    73134    {
     
    76137        dprintf(("SPCLPASSTHROUGH2: pretend success"));
    77138        dprintf(("SPCLPASSTHROUGH2: virt mem %x size %x", *(DWORD *)lpvInData, rawsize));
     139        if(lpszPassThrough == NULL) {
     140            lpszPassThrough = (char *)malloc(rawsize+sizeof(WORD));
     141            if(lpszPassThrough == NULL) {
     142                DebugInt3();
     143                return 0;
     144            }
     145            memcpy(lpszPassThrough+sizeof(WORD), (char *)lpvInData+6, rawsize);
     146            cbPassThrough = rawsize;
     147            *(WORD *)lpszPassThrough = (WORD)cbPassThrough;
     148        }
     149        else {
     150            char *tmp = lpszPassThrough;
     151
     152            lpszPassThrough = (char *)malloc(cbPassThrough+rawsize+sizeof(WORD));
     153            if(lpszPassThrough == NULL) {
     154                DebugInt3();
     155                return 0;
     156            }
     157            memcpy(lpszPassThrough+sizeof(WORD), tmp+sizeof(WORD), cbPassThrough);
     158            free(tmp);
     159            memcpy(lpszPassThrough+sizeof(WORD)+cbPassThrough, (char *)lpvInData+6, rawsize);
     160            cbPassThrough += rawsize;
     161            *(WORD *)lpszPassThrough = (WORD)cbPassThrough;
     162        }
    78163        return 1;
    79164    }
     
    126211            return Escape(hdc, QUERYESCSUPPORT, sizeof(nEscapeSup), (LPCSTR)&nEscapeSup, NULL);
    127212        }
     213        case POSTSCRIPT_PASSTHROUGH:
     214        case POSTSCRIPT_DATA:
     215        case PASSTHROUGH:
     216            if(fPostscriptPassthrough == FALSE)
     217            {
     218                return 0;
     219            }
     220            break;
     221
    128222        default:
    129223            break;
Note: See TracChangeset for help on using the changeset viewer.