BOOL DrvStartPage( SURFOBJ *pso ) /*++ Routine Description: Function called to process BEGIN_DOC transaction. That is, the start of a document. Thus it is necessary to send the initialisation data to the printer, as well as initialise internal data. Arguments: pso - Pointer to the SURFOBJ which belong to this driver Return Value: TRUE if sucessful FALSE otherwise Author: 15-Feb-1994 Tue 09:58:26 updated -by- Daniel Chou (danielc) Move PhysPosition and AnchorCorner to the SendPageHeader where the commmand is sent. 30-Nov-1993 Tue 23:08:12 created -by- Daniel Chou (danielc) Revision History: --*/ { PPDEV pPDev; if (!(pPDev = SURFOBJ_GETPDEV(pso))) { PLOTERR(("DrvStartPage: invalid pPDev")); return(FALSE); } // // initialize some PDEV values for current plotter state... // pPDev->CurPenSelected = -1; pPDev->LastDevROP = 0xFFFF; pPDev->Rop3CopyBits = 0xCC; pPDev->LastFillTypeIndex = 0xFFFF; pPDev->LastLineType = PLOT_LT_UNDEFINED; pPDev->DevBrushUniq = 0; ResetDBCache(pPDev); return(SendPageHeader(pPDev)); }
BOOL DrvSendPage( SURFOBJ *pso ) /*++ Routine Description: Called when the user has completed the drawing for this page. and we need to start output the remainding data Arguments: pso - Pointer to the SURFOBJ which belong to this driver Return Value: TRUE if sucessful FALSE otherwise Author: 30-Nov-1993 Tue 21:34:53 created -by- Daniel Chou (danielc) Revision History: --*/ { PPDEV pPDev; // // Not a great deal to do - we basically get the surface details and call // the output functions. If this is a surface, then nothing needs to be // done, but journal files require more complex processing. // // TODO we need REPLOT support here if we support multiple copies.... // we also have to determine how much data gets resett after the plot // page.. if (!(pPDev = SURFOBJ_GETPDEV(pso))) { PLOTERR(("DrvSendPage: invalid pPDev")); return(FALSE); } if (pso->iType == STYPE_DEVICE) { return(SendPageTrailer(pPDev)); } else { PLOTRIP(("DrvSendPage: Invalid surface type %ld passed???", (LONG)pso->iType)); return(FALSE); } }
VOID GetDefaultPlotterForm( PPLOTGPC pPlotGPC, PPAPERINFO pPaperInfo ) /*++ Routine Description: This function set the default loaded paper on the plotter to the first form data list in the PCD data file Arguments: pPlotGPC - Pointer to the GPC data pPaperInfo - Pointer to the paper info to be returned Return Value: TRUE if sucessful, false if failed Author: 03-Feb-1994 Thu 11:37:37 created -by- Daniel Chou (danielc) Revision History: --*/ { PFORMSRC pFS; if ((pFS = (PFORMSRC)pPlotGPC->Forms.pData) && (pPlotGPC->Forms.Count)) { str2Wstr(pPaperInfo->Name, pFS->Name); pPaperInfo->Size = pFS->Size; pPaperInfo->ImageArea.left = pFS->Margin.left; pPaperInfo->ImageArea.top = pFS->Margin.top; pPaperInfo->ImageArea.right = pFS->Size.cx - pFS->Margin.right; pPaperInfo->ImageArea.bottom = pFS->Size.cy - pFS->Margin.bottom; } else { PLOTERR(("GetDefaultPlotterForm: No FORM DATA in PCD, used country default")); GetDefaultPaper(pPaperInfo); } }
BOOL DrvEndDoc( SURFOBJ *pso, FLONG Flags ) /*++ Routine Description: This function end the control information on the device for the document Arguments: pso - Pointer to the SURFOBJ for the device Flags - if ED_ABORTDOC bit is set then the document has been aborted Return Value: BOOLLEAN to specified if function sucessful Author: 30-Nov-1993 Tue 21:16:48 created -by- Daniel Chou (danielc) Revision History: --*/ { PPDEV pPDev; if (!(pPDev = SURFOBJ_GETPDEV(pso))) { PLOTERR(("DrvEndDoc: invalid pPDev")); return(FALSE); } // // TODO we should review if we should do anything here... // PLOTDBG(DBG_ENDDOC,("DrvEndDoc called with Flags = %08lx", Flags)); return(TRUE); }
BOOL GetFormSelect( PPRINTERINFO pPI, POPTITEM pOptItem ) /*++ Routine Description: This function retrieve the form selected by the user from the combo box Arguments: pPI - Pointer to the PRINTERINFO pOptItem - Pointer to the FORM's OPTITEM Return Value: TRUE if sucessful and pPI will be set correctly, FALSE if error occurred Author: 09-Dec-1993 Thu 14:44:18 created 18-Dec-1993 Sat 03:55:30 updated Changed dmFields setting for the PAPER, now we will only set the DM_FORMNAME field, this way the returned document properties will be always in known form even user defines many forms in spooler. 06-Nov-1995 Mon 12:56:00 updated Re-write for the New UI Revision History: --*/ { PAPERINFO CurPaper; POPTPARAM pOptParam; pOptParam = pOptItem->pOptType->pOptParam + pOptItem->Sel; if (pOptParam->Style == FS_ROLLPAPER) { PFORMSRC pFS; // // This was added from the GPC data for the roll feed // PLOTASSERT(0, "GetComboBoxSelForm: INTERNAL ERROR, ROLLPAPER In document properties", !(pPI->Flags & PIF_DOCPROP), 0); PLOTASSERT(0, "GetComboBoxSelForm: INTERNAL ERROR, device CANNOT have ROLLPAPER", pPI->pPlotGPC->Flags & PLOTF_ROLLFEED, 0); PLOTDBG(DBG_FORMS, ("Roll Feed Paper is selected, (%ld)", pOptParam->lParam)); if ((pOptParam->lParam >= 0) && ((DWORD)(pOptParam->lParam) < (DWORD)pPI->pPlotGPC->Forms.Count)) { pFS = (PFORMSRC)pPI->pPlotGPC->Forms.pData + pOptParam->lParam; // // Since the RollFeed paper has variable length, and the cy is set // to zero at GPC data, we must take that into account // CurPaper.Size = pFS->Size; CurPaper.ImageArea.left = pFS->Margin.left; CurPaper.ImageArea.top = pFS->Margin.top; CurPaper.ImageArea.right = CurPaper.Size.cx - pFS->Margin.right; CurPaper.ImageArea.bottom = pPI->pPlotGPC->DeviceSize.cy - pFS->Margin.bottom; str2Wstr(CurPaper.Name, CCHOF(CurPaper.Name), pFS->Name); } else { PLOTERR(("GetComboBoxSelForm: Internal Error, Invalid lParam=%ld", pOptParam->lParam)); return(FALSE); } } else { FORM_INFO_1 *pFI1; DWORD cb; // // This form is in the form data base // pFI1 = pPI->pFI1Base + pOptParam->lParam; CurPaper.Size = pFI1->Size; CurPaper.ImageArea = pFI1->ImageableArea; WCPYFIELDNAME(CurPaper.Name, CCHOF(CurPaper.Name), pFI1->pName); } // // Now we have current paper validated // if (pPI->Flags & PIF_DOCPROP) { // // Turn off first, then turn on paper fields as needed // pPI->PlotDM.dm.dmFields &= ~DM_PAPER_FIELDS; pPI->PlotDM.dm.dmFields |= (DM_FORMNAME | DM_PAPERSIZE); // // Copy down the dmFormName, dmPaperSize and set dmPaperWidth/Length, // the fields for PAPER will bb set to DM_FORMNAME so that we always // can find the form also we may set DM_PAPERSIZE if index number is // <= DMPAPER_LAST // WCPYFIELDNAME(pPI->PlotDM.dm.dmFormName, CCHOF(pPI->PlotDM.dm.dmFormName), CurPaper.Name); pPI->PlotDM.dm.dmPaperSize = (SHORT)(pOptParam->lParam + DMPAPER_FIRST); pPI->PlotDM.dm.dmPaperWidth = SPLTODM(CurPaper.Size.cx); pPI->PlotDM.dm.dmPaperLength = SPLTODM(CurPaper.Size.cy); #if DBG *(PRECTL)&pPI->PlotDM.dm.dmBitsPerPel = CurPaper.ImageArea; #endif } else { pPI->CurPaper = CurPaper; } PLOTDBG(DBG_FORMS, ("*** GetComboBoxSelForm from COMBO = '%s'", CurPaper.Name)); PLOTDBG(DBG_FORMS, ("Size=%ld x %ld", CurPaper.Size.cx, CurPaper.Size.cy)); PLOTDBG(DBG_FORMS, ("ImageArea=(%ld, %ld) - (%ld, %ld)", CurPaper.ImageArea.left, CurPaper.ImageArea.top, CurPaper.ImageArea.right, CurPaper.ImageArea.bottom)); return(TRUE); }
BOOL AddFormsToDataBase( PPRINTERINFO pPI, BOOL DeleteFirst ) /*++ Routine Description: This function add driver supports forms to the data base Arguments: pPI - Pointer to the PRINTERINFO Return Value: BOOLEAN Author: 09-Dec-1993 Thu 22:38:27 created 27-Apr-1994 Wed 19:18:58 updated Fixed bug# 13592 which printman/spooler did not call ptrprop first but docprop so let us into unknown form database state, Revision History: --*/ { WCHAR wName[CCHFORMNAME + 2]; BOOL bRet; LONG i; DWORD Type; Type = REG_SZ; if ((GetPrinterData(pPI->hPrinter, wszModel, &Type, (LPBYTE)wName, sizeof(wName), &i) == ERROR_SUCCESS) && (wcscmp(pPI->PlotDM.dm.dmDeviceName, wName))) { PLOTDBG(DBG_FORMS, ("Already added forms to the data base for %s", pPI->PlotDM.dm.dmDeviceName)); return(TRUE); } // // Find out if we have permission to do this // if (SetPrinterData(pPI->hPrinter, wszModel, REG_SZ, (LPBYTE)pPI->PlotDM.dm.dmDeviceName, (wcslen(pPI->PlotDM.dm.dmDeviceName) + 1) * sizeof(WCHAR)) == ERROR_SUCCESS) { PFORMSRC pFS; FORM_INFO_1 FI1; // // We have permission to update the registry so do it now // pPI->Flags |= PIF_UPDATE_PERMISSION; PLOTDBG(DBG_PERMISSION, ("!!! MODEL NAME: '%s' not Match, Re-installed Form Database", pPI->PlotDM.dm.dmDeviceName)); // // Add the driver supportes forms to the system spooler data base if // not yet done so // FI1.pName = wName; for (i = 0, pFS = (PFORMSRC)pPI->pPlotGPC->Forms.pData; i < (LONG)pPI->pPlotGPC->Forms.Count; i++, pFS++) { // // We will only add the non-roll paper forms // if (pFS->Size.cy) { str2Wstr(wName, CCHOF(wName), pFS->Name); // // Firstable we will delete the same name form in the data // base first, this will ensure we have our curent user defined // form can be installed // if (DeleteFirst) { DeleteForm(pPI->hPrinter, wName); } FI1.Size = pFS->Size; FI1.ImageableArea.left = pFS->Margin.left; FI1.ImageableArea.top = pFS->Margin.top; FI1.ImageableArea.right = FI1.Size.cx - pFS->Margin.right; FI1.ImageableArea.bottom = FI1.Size.cy - pFS->Margin.bottom; PLOTDBG(DBG_FORMS, ( "AddForm: %s-[%ld x %ld] (%ld, %ld)-(%ld, %ld)", FI1.pName, FI1.Size.cx, FI1.Size.cy, FI1.ImageableArea.left, FI1.ImageableArea.top, FI1.ImageableArea.right,FI1.ImageableArea.bottom)); FI1.Flags = FORM_PRINTER; if ((!AddForm(pPI->hPrinter, 1, (LPBYTE)&FI1)) && (GetLastError() != ERROR_FILE_EXISTS) && (GetLastError() != ERROR_ALREADY_EXISTS)) { bRet = FALSE; PLOTERR(("AddFormsToDataBase: AddForm(%s) failed, [%ld]", wName, GetLastError())); } } } return(TRUE); } else { pPI->Flags &= ~PIF_UPDATE_PERMISSION; PLOTDBG(DBG_PERMISSION, ("AddFormsToDataBase(): NO UPDATE PERMISSION")); return(FALSE); } }
UINT CreateFormOI( PPRINTERINFO pPI, POPTITEM pOptItem, POIDATA pOIData ) /*++ Routine Description: This function add the available forms to the combo box, it will optionally add the roll feed type of form Arguments: pPI - Pointer to the PRINTERINFO data structure pOptItem - Pointer to the FORM's OPTITEM pOIData - Pointer to the OIDATA structure Return Value: The form selected, a netavie number means error Author: 09-Dec-1993 Thu 14:35:59 created 06-Nov-1995 Mon 12:56:24 updated Re-write for the New UI Revision History: --*/ { LPWSTR pwSelName; POPTPARAM pOptParam; PFORM_INFO_1 pFI1; PFORMSRC pFS; ENUMFORMPARAM EFP; DWORD i; LONG Sel; DWORD cRollPaper; EXTRAINFO EI; if (!pOptItem) { return(1); } pwSelName = (LPWSTR)((pPI->Flags & PIF_DOCPROP) ? pPI->PlotDM.dm.dmFormName : pPI->CurPaper.Name); PLOTDBG(DBG_FORMS, ("Current Form: <%ws>", pwSelName)); EFP.pPlotDM = &(pPI->PlotDM); EFP.pPlotGPC = pPI->pPlotGPC; if (!PlotEnumForms(pPI->hPrinter, NULL, &EFP)) { PLOTERR(("CreateFormOI: PlotEnumForms() failed")); return(0); } cRollPaper = 0; if ((!(pPI->Flags & PIF_DOCPROP)) && (pPI->pPlotGPC->Flags & PLOTF_ROLLFEED)) { // // Add device' roll paper to the combo box too. // PLOTDBG(DBG_FORMS, ("Device support ROLLFEED so add RollPaper if any")); for (i= 0, pFS = (PFORMSRC)pPI->pPlotGPC->Forms.pData; i < (DWORD)pPI->pPlotGPC->Forms.Count; i++, pFS++) { if (!pFS->Size.cy) { ++cRollPaper; } } } PLOTDBG(DBG_FORMS, ("Valid Count is %ld [%ld + %ld] out of %ld", EFP.ValidCount + cRollPaper, EFP.ValidCount, cRollPaper, EFP.Count)); EI.Size = (DWORD)(cRollPaper * (sizeof(WCHAR) * CCHFORMNAME)); if (!CreateOPTTYPE(pPI, pOptItem, pOIData, EFP.ValidCount + cRollPaper, &EI)) { LocalFree((HLOCAL)EFP.pFI1Base); return(0); } pPI->pFI1Base = EFP.pFI1Base; pOptItem->pOptType->Style = OTS_LBCB_SORT; pOptParam = pOptItem->pOptType->pOptParam; for (i = 0, Sel = 0, pFI1 = EFP.pFI1Base; i < EFP.Count; i++, pFI1++) { if (pFI1->Flags & FI1F_VALID_SIZE) { pOptParam->cbSize = sizeof(OPTPARAM); pOptParam->Style = (pPI->pPlotGPC->Flags & PLOTF_PAPERTRAY) ? FS_TRAYPAPER : 0; pOptParam->pData = pFI1->pName; pOptParam->IconID = (pFI1->Flags & FI1F_ENVELOPE) ? IDI_CPSUI_ENVELOPE : IDI_CPSUI_STD_FORM; pOptParam->lParam = (LONG)i; if (!lstrcmp(pwSelName, pOptParam->pData)) { pOptItem->Sel = Sel; } pOptParam++; Sel++; } } if (cRollPaper) { LPWSTR pwStr = (LPWSTR)EI.pData; size_t cchpwStr = EI.Size / sizeof(WCHAR); // // Add device' roll paper to the combo box too. // for (i = 0, pFS = (PFORMSRC)pPI->pPlotGPC->Forms.pData; i < (DWORD)pPI->pPlotGPC->Forms.Count; i++, pFS++) { if (!(pFS->Size.cy)) { // // Got one, we have to translated into the UNICODE first // pOptParam->cbSize = sizeof(OPTPARAM); pOptParam->Style = FS_ROLLPAPER; pOptParam->pData = (LPTSTR)pwStr; pwStr += CCHFORMNAME; cchpwStr -= CCHFORMNAME; pOptParam->IconID = IDI_ROLLPAPER; pOptParam->lParam = (LONG)i; str2Wstr(pOptParam->pData, cchpwStr, pFS->Name); if (!lstrcmp(pwSelName, pOptParam->pData)) { pOptItem->Sel = Sel; } pOptParam++; Sel++; } } } return(1); }
VOID SetDefaultPLOTDM( HANDLE hPrinter, _In_ PPLOTGPC pPlotGPC, _In_opt_ LPCWSTR pwDeviceName, _In_ PPLOTDEVMODE pPlotDM, _Out_opt_ PFORMSIZE pCurForm ) /*++ Routine Description: This function set the default devmode based on the current pPlotGPC Arguments: hPrinter - Handle to the printer pPlotGPC - our loaded/verified GPC data. pwDeviceName - the device name passed in pPlotDM - Pointer to our ExtDevMode pCurForm - Pointer to the FORMSIZE data structure which will be updated if the pointer is not NULL, the final result of the form size/imagable area selected by the user will be written to here. the form name will be in pPlotDM->dmFormName. Return Value: VOID Author: 14-Dec-1993 Tue 20:21:48 updated Update the dmScale based on maximum the device can support 06-Dec-1993 Mon 12:49:52 updated make sure we turn off the DM_xxx bits if one of those is not valid or supported in current plotter 16-Nov-1993 Tue 13:49:27 created Revision History: --*/ { WCHAR *pwchDeviceName = NULL; ULONG ulStrLen = 0; UNREFERENCED_PARAMETER(hPrinter); // // Device name including NULL terminator // must be equal or shorter than CCHDEVICENAME. // PREFIX doesn' take this assumption. Buffer size needs to be flexible and // should not be on stack. // if (pwDeviceName) { ulStrLen = (ULONG)wcslen(pwDeviceName); // // Allocate buffer to hold pwDeviceName including null terminator. // Make sure that pwDeviceName has a device name. // if (0 == ulStrLen || !(pwchDeviceName = (WCHAR*)LocalAlloc(LMEM_FIXED|LMEM_ZEROINIT, (ulStrLen + 1) * sizeof(WCHAR)))) { PLOTERR(("SetDefaultPLOTDM: memory allocaton failed.\n")); // // Make sure that pPlotGPC->DeviceName has a null terminator. // pPlotGPC->DeviceName[0] = (BYTE)'\0'; } else { _WCPYSTR_FILL_TRAIL_WITH_NULL(pwchDeviceName, ulStrLen + 1, pwDeviceName); // // Make sure the PlotGPC's device name is ssync with the pDeviceName // passed. // String length must be equal or shorter than CCHDEVICENAME. // DEVMODE's device name and pPlotGPC->DeviceName can't hold a sting // longer than CCHDEVICENAME. // if (ulStrLen + 1 > CCHDEVICENAME) { PLOTERR(("SetDefaultPLOTDM: DeviceName is longer than buffer size.\n")); } else { WStr2Str(pPlotGPC->DeviceName, CCHOF(pPlotGPC->DeviceName), pwchDeviceName); } } PLOTDBG(DBG_DEFDEVMODE, ("PlotGPC DeviceName=%hs\npwDeviceName=%ls", pPlotGPC->DeviceName, pwDeviceName)); } else { PLOTERR(("No DeviceName passed, using GPC's '%hs'", pPlotGPC->DeviceName)); ulStrLen = (ULONG)strlen(pPlotGPC->DeviceName); // // Allocate buffer to hold pwDeviceName including null terminator. // Make sure that pwDeviceName has a device name. // if (0 == ulStrLen || !(pwchDeviceName = (WCHAR*)LocalAlloc(LMEM_FIXED|LMEM_ZEROINIT, (ulStrLen + 1) * sizeof(WCHAR)))) { PLOTERR(("SetDefaultPLOTDM: memory allocaton failed.\n")); } else { str2Wstr(pwchDeviceName, ulStrLen + 1, pPlotGPC->DeviceName); } } // // Make a default copy first then copy device name down // CopyMemory(pPlotDM, &_DefPlotDM, sizeof(PLOTDEVMODE)); if (pwchDeviceName) { WCPYFIELDNAME(pPlotDM->dm.dmDeviceName, CCHOF(pPlotDM->dm.dmDeviceName), pwchDeviceName); LocalFree(pwchDeviceName); } else { pPlotDM->dm.dmDeviceName[0] = L'\0'; } // // We must turn off the DM_xxx bits in dmFields if we do not support it, // look at default fields we copy down then update it // if (pPlotGPC->MaxScale) { if ((WORD)pPlotDM->dm.dmScale > pPlotGPC->MaxScale) { pPlotDM->dm.dmScale = (SHORT)pPlotGPC->MaxScale; } } else { pPlotDM->dm.dmFields &= ~DM_SCALE; } if (pPlotGPC->MaxCopies <= 1) { pPlotDM->dm.dmFields &= ~DM_COPIES; } if (!(pPlotGPC->MaxQuality)) { pPlotDM->dm.dmFields &= ~DM_PRINTQUALITY; } // // DEFAULT 50% quality for byte align plotter (DJ 600) to do ROP right // if (pPlotGPC->Flags & PLOTF_RASTERBYTEALIGN) { pPlotDM->dm.dmPrintQuality = DMRES_LOW; PLOTWARN(("SetDefaultPLOTDM: Force Default Qaulity = DMRES_LOW")); } if (!(pPlotGPC->Flags & PLOTF_COLOR)) { if (pPlotGPC->Flags & PLOTF_RASTER) { pPlotDM->dm.dmFields &= ~DM_COLOR; pPlotDM->dm.dmColor = DMCOLOR_MONOCHROME; } else { PLOTASSERT(0, "SetDefaultPLOTDM: The Pen Ploter CANNOT be MONO.", (pPlotGPC->Flags & PLOTF_COLOR), 0); pPlotGPC->Flags |= PLOTF_COLOR; } } // // Set default form name based on the country/region // SetDefaultDMForm(pPlotDM, pCurForm); }
BOOL DoMix2( PPDEV pPDev, SURFOBJ *psoDst, SURFOBJ *psoSrc, CLIPOBJ *pco, XLATEOBJ *pxlo, PRECTL prclDst, PRECTL prclSrc, PPOINTL pptlSrcOrg, DWORD Mix2 ) /*++ Routine Description: This function is responsible for doing a device copy of a bitmap with/without tiling and activating the proper Rop2 Arguments: pPDev - Pointer to the PDEV psoDst - pointer to the destination surface object psoSrc - pointer to the source surface object pco - Pointer to the CLIPOBJ pxlo - the translate object from the source to the destination prclDst - the output destination rectangle area prclSrc - the source rectangle area pptlSrcOrg - brush origin for the source rectangle, if this is NULL then prclSrc will not have to be aligned on the destination Mix2 - a rop2 mode 0 - 0x0F Return Value: BOOLEAN Author: 08-Feb-1994 Tue 16:33:41 updated fixed ptlSrcOrg problem, we need to modulate with source size before it get used. 27-Jan-1994 Thu 23:45:46 updated Re-write so that it can handle the tiling more efficient. 13-Jan-1994 Sat 09:34:06 created Revision History: --*/ { RECTL rclSrc; RECTL rclDst; POINTL ptlSrcOrg; LONG cxSrc; LONG cySrc; DWORD OHTFlags = 0; BOOL MemMix2; // // The final ROP is either a ROP3 or a ROP4 (no mask) and it is always // a rop2 operation which deals with the source and destination // // First make it into a Rop3 representation of Rop2 (Mix2) // PLOTASSERT(1, "DoMix2: Passed INVALID psoSrc (%08lx) = STYPE_DEVICE", (psoSrc) && (psoSrc->iType != STYPE_DEVICE), psoSrc); PLOTASSERT(1, "DoMix2: Unexpected Mix2 = %u, SHOULD NOT BE HERE", (Mix2 != MIX2_0) && (Mix2 != MIX2_1) && (Mix2 != MIX2_D) && (Mix2 != MIX2_nD), Mix2); Mix2 &= 0x0F; Mix2 |= (DWORD)(Mix2 << 4); switch (Mix2) { case 0x00: // 0 case 0xFF: // 1 case 0x55: // ~D DoSpecialRop3(psoDst, pco, prclDst, Mix2); case 0xAA: // D return(TRUE); } if (MemMix2 = (BOOL)(psoDst->iType != STYPE_DEVICE)) { // // Now make it into Rop4 representation of Rop2 (Mix2) // Mix2 |= (Mix2 << 8); } else { if (!IsHTCompatibleSurfObj(pPDev, psoSrc, pxlo, ((pxlo) ? ISHTF_ALTFMT : 0) | ISHTF_HTXB | ISHTF_DSTPRIM_OK)) { PLOTERR(("DoMix2: The psoSrc is not HT compatible format (%08lx", psoSrc->iBitmapFormat)); return(FALSE); } } cxSrc = prclSrc->right - prclSrc->left; cySrc = prclSrc->bottom - prclSrc->top; if (pptlSrcOrg) { ptlSrcOrg = *pptlSrcOrg; if ((ptlSrcOrg.x = (LONG)(prclDst->left - ptlSrcOrg.x) % cxSrc) < 0) { ptlSrcOrg.x += cxSrc; } if ((ptlSrcOrg.y = (LONG)(prclDst->top - ptlSrcOrg.y) % cySrc) < 0) { ptlSrcOrg.y += cySrc; } PLOTDBG(DBG_DOMIX2, ("DoMix2: ORG ptlSrcOrg=(%ld, %ld) -> (%ld, %ld)", pptlSrcOrg->x, pptlSrcOrg->y, ptlSrcOrg.x, ptlSrcOrg.y)); } else { ptlSrcOrg.x = ptlSrcOrg.y = 0; PLOTDBG(DBG_DOMIX2, ("DoMix2: >>> DO NOT NEED TO ALIGN SRC on DEST <<<")); } rclSrc.top = prclSrc->top + ptlSrcOrg.y; rclSrc.bottom = prclSrc->bottom; rclDst.top = prclDst->top; rclDst.bottom = rclDst.top + (rclSrc.bottom - rclSrc.top); PLOTDBG(DBG_DOMIX2, ("DoMix2: SrcFormat=%ld, DstFormat=%ld %hs", psoSrc->iBitmapFormat, psoDst->iBitmapFormat, (MemMix2) ? "[MemMix2]" : "")); PLOTDBG(DBG_DOMIX2, ("DoMix2: ORG: Dst=(%ld, %ld)-(%ld,%ld), Src=(%ld, %ld)-(%ld, %ld)", prclDst->left, prclDst->top, prclDst->right, prclDst->bottom, prclSrc->left, prclSrc->top, prclSrc->right, prclSrc->bottom)); while (rclDst.top < prclDst->bottom) { // // check if the destination bottom is overhanging, clip it, // // NOTE: This could happen the first time. // if (rclDst.bottom > prclDst->bottom) { // // Clip the source/destination rectangle, because we may do // EngBitBlt() or OutputHTBitmap() // rclSrc.bottom -= (rclDst.bottom - prclDst->bottom); rclDst.bottom = prclDst->bottom; } rclSrc.left = prclSrc->left + ptlSrcOrg.x; rclSrc.right = prclSrc->right; rclDst.left = prclDst->left; rclDst.right = rclDst.left + (rclSrc.right - rclSrc.left); while (rclDst.left < prclDst->right) { // // check if the destination right edge is overhanging, clip it if // necessary. // // NOTE: This could happen the first time. // if (rclDst.right > prclDst->right) { // // Clip the source/destination rectangle, because we may do a // EngBitBlt() or OutputHTBitmap() // rclSrc.right -= (rclDst.right - prclDst->right); rclDst.right = prclDst->right; } PLOTDBG(DBG_DOMIX2, ("DoMix2: TILE: Dst=(%ld, %ld)-(%ld,%ld), Src=(%ld, %ld)-(%ld, %ld)", rclDst.left, rclDst.top, rclDst.right, rclDst.bottom, rclSrc.left, rclSrc.top, rclSrc.right, rclSrc.bottom)); if (MemMix2) { // // In the memory version we don't have to worry about PCO so // just call EngBitBlt to do the work. // if (!(EngBitBlt(psoDst, // psoDst psoSrc, // psoSrc NULL, // psoMask pco, // pco NULL, // pxlo &rclDst, // prclDst (PPOINTL)&rclSrc, // pptlSrc NULL, // pptlMask NULL, // pbo (PPOINTL)&ptlZeroOrigin, // pptlBrushOrg Mix2))) { PLOTERR(("DoMix2: EngBitBlt(MemMix2=%04lx) Failed!!!",Mix2)); return(FALSE); } } else { if (!OutputHTBitmap(pPDev, psoSrc, pco, (PPOINTL)&rclDst, &rclSrc, Mix2, &OHTFlags)) { PLOTERR(("DoMix2: OutputHTBitmap() Failed!!!")); return(FALSE); } } // // Reset <source left> to the original left margin and move the // destination right to the left for the next destination RECTL. // rclSrc.left = prclSrc->left; rclDst.left = rclDst.right; rclDst.right += cxSrc; } // // Reset <source top> to the original top margin and move the // destination bottom to the top, and set bottom for the next destination // RECTL. // rclSrc.top = prclSrc->top; rclDst.top = rclDst.bottom; rclDst.bottom += cySrc; } if (OHTFlags & OHTF_MASK) { OHTFlags |= OHTF_EXIT_TO_HPGL2; OutputHTBitmap(pPDev, psoSrc, NULL, NULL, NULL, 0xAA, &OHTFlags); } return(TRUE); }
BOOL ValidatePlotGPC( PPLOTGPC pPlotGPC ) /*++ Routine Description: This function validate a PLOTGPC data structure Arguments: pPlotGPC Return Value: BOOL Development History: 15-Feb-1994 Tue 22:49:40 updated Update the pen plotter validation for the bitmap font and color 15-Nov-1993 Mon 10:11:58 created Revision History: 02-Apr-1995 Sun 11:23:46 updated Update the COLORINFO checking so it will make to NT3.51's default and not compute the devpels on the spot. --*/ { if ((pPlotGPC->ID != PLOTGPC_ID) || (pPlotGPC->cjThis != sizeof(PLOTGPC))) { PLOTERR(("ValidatePlotGPC: invalid PLOTGPC data (ID/Size)")); return(FALSE); } pPlotGPC->DeviceName[sizeof(pPlotGPC->DeviceName) - 1] = '\0'; pPlotGPC->Flags &= PLOTF_ALL_FLAGS; // // Validate device size and its margin // if (pPlotGPC->DeviceSize.cx - (pPlotGPC->DeviceMargin.left + pPlotGPC->DeviceMargin.right) < MIN_PLOTGPC_FORM_CX) { PLOTERR(("Invalid Device CX (%ld) set to default", pPlotGPC->DeviceSize.cx)); pPlotGPC->DeviceSize.cx = pPlotGPC->DeviceMargin.left + pPlotGPC->DeviceMargin.right + MIN_PLOTGPC_FORM_CX; } if (pPlotGPC->DeviceSize.cy < MIN_PLOTGPC_FORM_CY) { PLOTERR(("Invalid Device CY (%ld) default to 50' long", pPlotGPC->DeviceSize.cx)); pPlotGPC->DeviceSize.cy = 15240000; } if (pPlotGPC->DeviceSize.cy - (pPlotGPC->DeviceMargin.top + pPlotGPC->DeviceMargin.bottom) < MIN_PLOTGPC_FORM_CY) { PLOTERR(("Invalid Device CY (%ld) set to default", pPlotGPC->DeviceSize.cy)); pPlotGPC->DeviceSize.cx = pPlotGPC->DeviceMargin.top + pPlotGPC->DeviceMargin.bottom + MIN_PLOTGPC_FORM_CY; } // // For now we must have 1:1 ratio // if (pPlotGPC->PlotXDPI != pPlotGPC->PlotYDPI) { pPlotGPC->PlotYDPI = pPlotGPC->PlotXDPI; } if (pPlotGPC->RasterXDPI != pPlotGPC->RasterYDPI) { pPlotGPC->RasterYDPI = pPlotGPC->RasterXDPI; } if (pPlotGPC->ROPLevel > ROP_LEVEL_MAX) { pPlotGPC->ROPLevel = ROP_LEVEL_MAX; } if (pPlotGPC->MaxScale > MAX_SCALE_MAX) { pPlotGPC->MaxScale = MAX_SCALE_MAX; } if ((!(pPlotGPC->Flags & PLOTF_RASTER)) && (pPlotGPC->MaxPens > MAX_PENPLOTTER_PENS)) { pPlotGPC->MaxPens = MAX_PENPLOTTER_PENS; } if (pPlotGPC->MaxPolygonPts < 3) { // minimum 3 points to make up a // region pPlotGPC->MaxPolygonPts = 0; } if (pPlotGPC->MaxQuality > MAX_QUALITY_MAX) { pPlotGPC->MaxQuality = MAX_QUALITY_MAX; } if (pPlotGPC->Flags & PLOTF_PAPERTRAY) { if ((pPlotGPC->PaperTraySize.cx != pPlotGPC->DeviceSize.cx) && (pPlotGPC->PaperTraySize.cy != pPlotGPC->DeviceSize.cx)) { PLOTERR(("Invalid PaperTraySize (%ld x %ld), Make it as DeviceSize", pPlotGPC->PaperTraySize.cx, pPlotGPC->PaperTraySize.cy)); pPlotGPC->PaperTraySize.cx = pPlotGPC->DeviceSize.cx; pPlotGPC->PaperTraySize.cy = pPlotGPC->DeviceSize.cy; } } else { pPlotGPC->PaperTraySize.cx = pPlotGPC->PaperTraySize.cy = 0; } if (!pPlotGPC->ci.Cyan.Y) { // // This is NT3.51 default // pPlotGPC->ci = DefDevHTInfo.ColorInfo; pPlotGPC->DevicePelsDPI = 0; } else if ((pPlotGPC->DevicePelsDPI < 30) || (pPlotGPC->DevicePelsDPI > pPlotGPC->RasterXDPI)) { pPlotGPC->DevicePelsDPI = 0; } if (pPlotGPC->HTPatternSize > HT_PATSIZE_16x16_M) { pPlotGPC->HTPatternSize = PickDefaultHTPatSize(pPlotGPC->RasterXDPI, pPlotGPC->RasterYDPI, FALSE); } if ((pPlotGPC->InitString.Count != 1) || (!pPlotGPC->InitString.SizeEach) || (!pPlotGPC->InitString.pData)) { ZeroMemory(&(pPlotGPC->InitString), sizeof(GPCVARSIZE)); } if ((pPlotGPC->Forms.Count) && (pPlotGPC->Forms.SizeEach == sizeof(FORMSRC)) && (pPlotGPC->Forms.pData)) { ValidateFormSrc(&(pPlotGPC->Forms), pPlotGPC->DeviceSize, (pPlotGPC->Flags & PLOTF_ROLLFEED)); } else { ZeroMemory(&(pPlotGPC->Forms), sizeof(GPCVARSIZE)); } if (!(pPlotGPC->Flags & PLOTF_RASTER)) { // // PEN PLOTTER MUST COLOR and NO_BMP_FONT // pPlotGPC->Flags |= (PLOTF_NO_BMP_FONT | PLOTF_COLOR); } if ((!(pPlotGPC->Flags & PLOTF_RASTER)) && (pPlotGPC->Pens.Count) && (pPlotGPC->Pens.SizeEach == sizeof(PENDATA)) && (pPlotGPC->Pens.pData)) { UINT i; PPENDATA pPD; pPD = (PPENDATA)pPlotGPC->Pens.pData; for (i = 0; i < (UINT)pPlotGPC->MaxPens; i++, pPD++) { if (pPD->ColorIdx > PC_IDX_LAST) { PLOTERR(("Invalid ColorIndex (%ld), set to default", pPD->ColorIdx)); pPD->ColorIdx = PC_IDX_FIRST; } } } else { ZeroMemory(&(pPlotGPC->Pens), sizeof(GPCVARSIZE)); } return(TRUE); }
BOOL CreateOPTTYPE( PPRINTERINFO pPI, POPTITEM pOptItem, POIDATA pOIData, UINT cLBCBItem, PEXTRAINFO pExtraInfo ) /*++ Routine Description: This function allocate memory and initialized field for OPTTYPE/OPTPARAM Arguments: pOptItem - Pointer to OPTITEM data structure pOIData - Pointer to the OIDATA structure Return Value: Author: 03-Nov-1995 Fri 13:25:54 created Revision History: --*/ { LPBYTE pbData = NULL; UINT cOP; DWORD cbOP; DWORD cbECB; DWORD cbExtra; DWORD cbAlloc = 0; BYTE Type; DWORD Flags; BOOL bRetVal = TRUE; Flags = pOIData->Flags; ZeroMemory(pOptItem, sizeof(OPTITEM)); pOptItem->cbSize = sizeof(OPTITEM); pOptItem->Level = pOIData->Level; pOptItem->Flags = (Flags & ODF_CALLBACK) ? OPTIF_CALLBACK : 0; if (Flags & ODF_COLLAPSE) { pOptItem->Flags |= OPTIF_COLLAPSE; } pOptItem->pName = (LPTSTR)pOIData->IDSName; pOptItem->HelpIndex = (DWORD)pOIData->HelpIdx; pOptItem->DMPubID = pOIData->DMPubID; if ((Type = pOIData->Type) >= sizeof(cTVOP)) { pOptItem->Sel = (LONG)pOIData->IconID; cOP = 0; } else if (!(cOP = cTVOP[Type])) { cOP = cLBCBItem; } cbOP = (cOP) ? SIZE_OPTTYPE(cOP) : 0; cbECB = (Flags & ODF_ECB) ? sizeof(EXTCHKBOX) : 0; cbExtra = (pExtraInfo) ? pExtraInfo->Size : 0; if (! SUCCEEDED(DWordAdd(cbOP, cbECB, &cbAlloc)) || ! SUCCEEDED(DWordAdd(cbAlloc, cbExtra, &cbAlloc))) { PLOTERR(("CreateOPTTYPE: Arithmetic Overflow Error")); bRetVal = FALSE; } if (bRetVal && (cbAlloc > 0)) { if (! (pbData = (LPBYTE)LocalAlloc(LPTR, cbAlloc)) ) { PLOTERR(("CreateOPTTYPE: LocalAlloc%ld failed", cbAlloc)); bRetVal = FALSE; } else { POPDATA pOPData; pOPData = (pOIData->Flags & ODF_CALLCREATEOI) ? NULL : pOIData->pOPData; pOptItem->UserData = (DWORD_PTR)pbData; if (cbECB) { PEXTCHKBOX pECB; pOptItem->pExtChkBox = pECB = (PEXTCHKBOX)pbData; pbData += cbECB; pECB->cbSize = sizeof(EXTCHKBOX); if (pOPData) { pECB->Flags = pOPData->Flags; pECB->pTitle = (LPTSTR)pOPData->IDSName; pECB->IconID = (DWORD)pOPData->IconID; pECB->pSeparator = (LPTSTR)pOPData->IDSSeparator; pECB->pCheckedName = (LPTSTR)pOPData->IDSCheckedName; pOPData++; } } if (cbOP) { POPTTYPE pOptType; POPTPARAM pOP; UINT i; pOptType = (POPTTYPE)pbData; pbData += cbOP; // // Initialize the OPTITEM // pOptItem->pOptType = pOptType; // // Initialize the OPTTYPE // pOptType->cbSize = sizeof(OPTTYPE); pOptType->Type = (BYTE)Type; pOptType->Count = (WORD)cOP; pOP = pOptType->pOptParam = (POPTPARAM)(pOptType + 1); pOptType->Style = pOIData->Style; for (i = 0; i < cOP; i++, pOP++) { pOP->cbSize = sizeof(OPTPARAM); if (pOPData) { pOP->Flags = (BYTE)(pOPData->Flags & 0xFF); pOP->Style = (BYTE)(pOPData->Style & 0xFF); pOP->pData = (LPTSTR)pOPData->IDSName; pOP->IconID = (DWORD)pOPData->IconID; pOP->lParam = (LONG)pOPData->sParam; if (Type == TVOT_PUSHBUTTON) { (DWORD_PTR)(pOP->pData) += (DWORD_PTR)pPI; } else { if (Flags & ODF_INC_IDSNAME) { (DWORD_PTR)(pOP->pData) += i; } if (Flags & ODF_INC_ICONID) { (DWORD)(pOP->IconID) += i; } } if (!(Flags & ODF_NO_INC_POPDATA)) { pOPData++; } } } } if (pExtraInfo) { pExtraInfo->pData = (cbExtra) ? pbData : 0; } } } return(bRetVal); }
DWORD MergePLOTDM( HANDLE hPrinter, PPLOTGPC pPlotGPC, PPLOTDEVMODE pPlotDMFrom, PPLOTDEVMODE pPlotDMTo, PFORMSIZE pCurForm ) /*++ Routine Description: This function merge and validate the pPlotDMTo from pPlotDMFrom. The PlotDMOut must valid Arguments: hPrinter - Handle to the printer to be checked pPlotGPC - The plotter's GPC data loaded from the file pPlotDMFrom - pointer to the input PLOTDEVMODE data structure, if can be NULL pPlotDMTo - Pointer to the output PLOTDEVMODE data structure, if pPlotDMFrom is NULL then a default PLOTDEVMODE is returned pCurForm - Pointer to the FORMSIZE data structure which will be updated if the pointer is not NULL, the final result of the form size/imagable area selected by the user will be written to here. the form name will be in pPlotDM->dmFormName. Return Value: the return value is a DWORD dmField error code which specified dmFields are invalid (DM_xxxxx in wingdi.h) if the return value has any DM_INV_xxx bits set then it should raised an error to the user. if return value is 0 then function sucessful Author: 25-Oct-1994 Tue 13:32:18 created -by- Daniel Chou (danielc) Revision History: --*/ { PLOTDEVMODE PlotDMIn; ENUMFORMPARAM EFP; DWORD dmErrFields = 0; SIZEL PaperSize; // // First: set the default PLOTDEVMODE for the output then from there // validate/settting from input devmode, if pwDeviceName passed as // NULL then it assume that pPlotDMTo alreay set and validated // // If we have invalid input devmode then this it is // if ((!pPlotDMFrom) || (!pPlotDMTo) || (!pPlotGPC)) { return(0); } // // Do some conversion here if necessary, first, copy the output one // CopyMemory(&PlotDMIn, pPlotDMTo, sizeof(PLOTDEVMODE)); ConvertDevmode((PDEVMODE) pPlotDMFrom, (PDEVMODE) &PlotDMIn); PLOTDBG(DBG_SHOWDEVMODE, ("--------------- Input DEVMODE Setting -------------------")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmDeviceName = %ls", (DWORD)PlotDMIn.dm.dmDeviceName)); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmSpecVersion = %04lx", (DWORD)PlotDMIn.dm.dmSpecVersion)); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmDriverVersion = %04lx", (DWORD)PlotDMIn.dm.dmDriverVersion)); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmSize = %0ld (%ld)", (DWORD)PlotDMIn.dm.dmSize, sizeof(DEVMODE))); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmDriverExtra = %ld (%ld)", (DWORD)PlotDMIn.dm.dmDriverExtra, PLOTDM_PRIV_SIZE)); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmFields = %08lx", (DWORD)PlotDMIn.dm.dmFields)); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmOrientation = %ld (%hs)", (DWORD)PlotDMIn.dm.dmOrientation, (PlotDMIn.dm.dmFields & DM_ORIENTATION) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmPaperSize = %ld (%hs)", (DWORD)PlotDMIn.dm.dmPaperSize, (PlotDMIn.dm.dmFields & DM_PAPERSIZE) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmPaperLength = %ld (%hs)", (DWORD)PlotDMIn.dm.dmPaperLength, (PlotDMIn.dm.dmFields & DM_PAPERLENGTH) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmPaperWidth = %ld (%hs)", (DWORD)PlotDMIn.dm.dmPaperWidth, (PlotDMIn.dm.dmFields & DM_PAPERWIDTH) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmScale = %ld (%hs)", (DWORD)PlotDMIn.dm.dmScale, (PlotDMIn.dm.dmFields & DM_SCALE) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmCopies = %ld (%hs)", (DWORD)PlotDMIn.dm.dmCopies, (PlotDMIn.dm.dmFields & DM_COPIES) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmPrintQuality = %ld (%hs)", (DWORD)PlotDMIn.dm.dmPrintQuality, (PlotDMIn.dm.dmFields & DM_PRINTQUALITY) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmColor = %ld (%hs)", (DWORD)PlotDMIn.dm.dmColor, (PlotDMIn.dm.dmFields & DM_COLOR) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: dmFormName = %ls (%hs)", (DWORD)PlotDMIn.dm.dmFormName, (PlotDMIn.dm.dmFields & DM_FORMNAME) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: Fill Truetype Font = %hs", (PlotDMIn.Flags & PDMF_FILL_TRUETYPE) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("ValidateSetPLOTDM: Plot On the Fly = %hs", (PlotDMIn.Flags & PDMF_PLOT_ON_THE_FLY) ? "ON" : "OFF")); PLOTDBG(DBG_SHOWDEVMODE, ("---------------------------------------------------------")); // // Statring checking the dmFields, *** REMEMBER: The orientation must // check before the checking the paper/form // if (PlotDMIn.dm.dmFields & DM_ORIENTATION) { switch (PlotDMIn.dm.dmOrientation) { case DMORIENT_PORTRAIT: case DMORIENT_LANDSCAPE: pPlotDMTo->dm.dmOrientation = PlotDMIn.dm.dmOrientation; pPlotDMTo->dm.dmFields |= DM_ORIENTATION; break; default: PLOTERR(("ValidatePLOTDM: Invalid dmOrientation = %ld", (LONG)PlotDMIn.dm.dmOrientation)); dmErrFields |= DM_ORIENTATION; break; } } // // Validate form name so we have correct data, assume error first // dmErrFields |= (DWORD)(PlotDMIn.dm.dmFields & DM_PAPER_FIELDS); if (((PlotDMIn.dm.dmFields & DM_PAPER_CUSTOM) == DM_PAPER_CUSTOM) && ((PlotDMIn.dm.dmPaperSize == DMPAPER_USER) || (PlotDMIn.dm.dmPaperSize == 0)) && (PaperSize.cx = DMTOSPL(PlotDMIn.dm.dmPaperWidth)) && (PaperSize.cy = DMTOSPL(PlotDMIn.dm.dmPaperLength)) && (PaperSize.cx >= MIN_SPL_FORM_CX) && (PaperSize.cy >= MIN_SPL_FORM_CY) && (((PaperSize.cx <= pPlotGPC->DeviceSize.cx) && (PaperSize.cy <= pPlotGPC->DeviceSize.cy)) || ((PaperSize.cy <= pPlotGPC->DeviceSize.cx) && (PaperSize.cx <= pPlotGPC->DeviceSize.cy)))) { // // First choice, this is what the caller wants, we need to validate // for this device, since the size may be larger then device can // handle // pPlotDMTo->dm.dmPaperWidth = PlotDMIn.dm.dmPaperWidth; pPlotDMTo->dm.dmPaperLength = PlotDMIn.dm.dmPaperLength; pPlotDMTo->dm.dmFields &= ~DM_PAPER_FIELDS; pPlotDMTo->dm.dmFields |= DM_PAPER_CUSTOM; pPlotDMTo->dm.dmPaperSize = DMPAPER_USER; pPlotDMTo->dm.dmFormName[0] = L'\0'; if (pCurForm) { // // This one is full imageable area as the widht/height // pCurForm->ImageArea.left = pCurForm->ImageArea.top = 0; pCurForm->Size.cx = pCurForm->ImageArea.right = PaperSize.cx; pCurForm->Size.cy = pCurForm->ImageArea.bottom = PaperSize.cy; } dmErrFields &= ~DM_PAPER_FIELDS; // Fine, no error PLOTDBG(DBG_CURFORM,("ValidateSetPLOTDM: FORM=USER <%ld> (%ld x %ld)", PlotDMIn.dm.dmPaperSize, PaperSize.cx, PaperSize.cy)); } else if ((PlotDMIn.dm.dmFields & (DM_PAPERSIZE | DM_FORMNAME)) && (EFP.pPlotDM = pPlotDMTo) && (EFP.pPlotGPC = pPlotGPC) && (PlotEnumForms(hPrinter, NULL, &EFP))) { FORM_INFO_1 *pFI1; SHORT PaperSize; BOOL Found = FALSE; // // Firstable check PaperSize index and if not found then check formname // if ((PlotDMIn.dm.dmFields & DM_PAPERSIZE) && ((PaperSize = PlotDMIn.dm.dmPaperSize) >= DMPAPER_FIRST) && (PaperSize <= (SHORT)EFP.Count) && (pFI1 = EFP.pFI1Base + (PaperSize - DMPAPER_FIRST)) && (pFI1->Flags & FI1F_VALID_SIZE)) { // // Whu..., this guy really pick a right index // Found = TRUE; PLOTDBG(DBG_CURFORM,("ValidateSetPLOTDM: Fount dmPaperSize=%ld", PlotDMIn.dm.dmPaperSize)); } else if (PlotDMIn.dm.dmFields & DM_FORMNAME) { // // Now go through all the formname trouble // pFI1 = EFP.pFI1Base; PaperSize = DMPAPER_FIRST; while (EFP.Count--) { if ((pFI1->Flags & FI1F_VALID_SIZE) && (!wcscmp(pFI1->pName, PlotDMIn.dm.dmFormName))) { PLOTDBG(DBG_CURFORM,("ValidateSetPLOTDM: Found dmFormName=%s", PlotDMIn.dm.dmFormName)); Found = TRUE; break; } ++PaperSize; ++pFI1; } } if (Found) { pPlotDMTo->dm.dmFields &= ~DM_PAPER_FIELDS; pPlotDMTo->dm.dmFields |= (DM_FORMNAME | DM_PAPERSIZE); pPlotDMTo->dm.dmPaperSize = PaperSize; pPlotDMTo->dm.dmPaperWidth = SPLTODM(pFI1->Size.cx); pPlotDMTo->dm.dmPaperLength = SPLTODM(pFI1->Size.cy); WCPYFIELDNAME(pPlotDMTo->dm.dmFormName, pFI1->pName); PLOTDBG(DBG_CURFORM,("FI1 [%ld]: (%ld x %ld), (%ld, %ld)-(%ld, %ld)", (LONG)pPlotDMTo->dm.dmPaperSize, pFI1->Size.cx, pFI1->Size.cy, pFI1->ImageableArea.left, pFI1->ImageableArea.top, pFI1->ImageableArea.right, pFI1->ImageableArea.bottom)); if (pCurForm) { pCurForm->Size = pFI1->Size; pCurForm->ImageArea = pFI1->ImageableArea; } dmErrFields &= ~DM_PAPER_FIELDS; // Fine, no error } // // Free up the memory used // LocalFree((HLOCAL)EFP.pFI1Base); } if ((PlotDMIn.dm.dmFields & DM_SCALE) && (pPlotGPC->MaxScale)) { if ((PlotDMIn.dm.dmScale > 0) && ((WORD)PlotDMIn.dm.dmScale <= pPlotGPC->MaxScale)) { pPlotDMTo->dm.dmScale = PlotDMIn.dm.dmScale; pPlotDMTo->dm.dmFields |= DM_SCALE; } else { PLOTERR(("ValidatePLOTDM: Invalid dmScale = %ld [%ld]", (LONG)PlotDMIn.dm.dmScale, (LONG)pPlotGPC->MaxScale)); dmErrFields |= DM_SCALE; } } if ((PlotDMIn.dm.dmFields & DM_COPIES) && (pPlotGPC->MaxCopies > 1)) { if ((PlotDMIn.dm.dmCopies > 0) && ((WORD)PlotDMIn.dm.dmCopies <= pPlotGPC->MaxCopies)) { pPlotDMTo->dm.dmCopies = PlotDMIn.dm.dmCopies; pPlotDMTo->dm.dmFields |= DM_COPIES; } else { PLOTERR(("ValidatePLOTDM: Invalid dmCopies = %ld [%ld]", (LONG)PlotDMIn.dm.dmCopies, (LONG)pPlotGPC->MaxCopies)); dmErrFields |= DM_COPIES; } } if (PlotDMIn.dm.dmFields & DM_PRINTQUALITY) { dmErrFields |= DM_PRINTQUALITY; // assume error, proven otherwise if (pPlotGPC->MaxQuality) { switch (PlotDMIn.dm.dmPrintQuality) { case DMRES_DRAFT: case DMRES_LOW: case DMRES_MEDIUM: case DMRES_HIGH: dmErrFields &= ~DM_PRINTQUALITY; pPlotDMTo->dm.dmPrintQuality = PlotDMIn.dm.dmPrintQuality; pPlotDMTo->dm.dmFields |= DM_PRINTQUALITY; break; } } if (dmErrFields & DM_PRINTQUALITY) { PLOTERR(("ValidatePLOTDM: Invalid dmPrintQuality = %ld [%ld]", (LONG)PlotDMIn.dm.dmPrintQuality, (LONG)pPlotGPC->MaxQuality)); } } if (PlotDMIn.dm.dmFields & DM_COLOR) { dmErrFields |= DM_COLOR; // assume error, proven otherwise if (pPlotGPC->Flags & PLOTF_COLOR) { switch (PlotDMIn.dm.dmColor) { case DMCOLOR_MONOCHROME: if (!(pPlotGPC->Flags & PLOTF_RASTER)) { PLOTERR(("ValidatePLOTDM: Cannot Set Pen Plotter to MONO")); break; } case DMCOLOR_COLOR: pPlotDMTo->dm.dmColor = PlotDMIn.dm.dmColor; pPlotDMTo->dm.dmFields |= DM_COLOR; dmErrFields &= ~DM_COLOR; break; } } else if (PlotDMIn.dm.dmColor == DMCOLOR_MONOCHROME) { dmErrFields &= ~DM_COLOR; } if (dmErrFields & DM_COLOR) { PLOTERR(("ValidatePLOTDM: Invalid dmColor = %ld [%hs]", (LONG)PlotDMIn.dm.dmColor, (pPlotGPC->Flags & PLOTF_COLOR) ? "COLOR" : "MONO")); } } // // Any other dmFields we just skip because we do not have that caps, now // check if they have correct EXTDEVMODE stuff // if ((PlotDMIn.dm.dmDriverExtra == PLOTDM_PRIV_SIZE) && (PlotDMIn.PrivID == PLOTDM_PRIV_ID) && (PlotDMIn.PrivVer == PLOTDM_PRIV_VER)) { pPlotDMTo->Flags = (DWORD)(PlotDMIn.Flags & PDMF_ALL_BITS); pPlotDMTo->ca = PlotDMIn.ca; if (pPlotGPC->Flags & PLOTF_RASTER) { pPlotDMTo->Flags |= PDMF_FILL_TRUETYPE; } else { // // Non raster device does not have plot on the fly mode // pPlotDMTo->Flags &= ~PDMF_PLOT_ON_THE_FLY; } if (!ValidateColorAdj(&(pPlotDMTo->ca))) { dmErrFields |= DM_INV_PLOTPRIVATE; PLOTERR(("ValidatePLOTDM: Invalid coloradjusment data")); } } return(dmErrFields); }
VOID SetDefaultPLOTDM( HANDLE hPrinter, PPLOTGPC pPlotGPC, LPWSTR pwDeviceName, PPLOTDEVMODE pPlotDM, PFORMSIZE pCurForm ) /*++ Routine Description: This function set the default devmode based on the current pPlotGPC Arguments: hPrinter - Handle to the printer pPlotGPC - our loaded/verified GPC data. pwDeviceName - the device name passed in pPlotDM - Pointer to our ExtDevMode pCurForm - Pointer to the FORMSIZE data structure which will be updated if the pointer is not NULL, the final result of the form size/imagable area selected by the user will be written to here. the form name will be in pPlotDM->dmFormName. Return Value: VOID Author: 14-Dec-1993 Tue 20:21:48 updated -by- Daniel Chou (danielc) Update the dmScale based on maximum the device can support 06-Dec-1993 Mon 12:49:52 updated -by- Daniel Chou (danielc) make sure we turn off the DM_xxx bits if one of those is not valid or supported in current plotter 16-Nov-1993 Tue 13:49:27 created -by- Daniel Chou (danielc) Revision History: --*/ { WCHAR DeviceName[CCHDEVICENAME]; if (pwDeviceName) { _WCPYSTR(DeviceName, pwDeviceName, CCHDEVICENAME); // // Make sure the PlotGPC's device name is ssync with the pDeviceName // passed // WStr2Str(pPlotGPC->DeviceName, DeviceName); PLOTDBG(DBG_DEFDEVMODE, ("PlotGPC DeviceName=%hs\npwDeviceName=%ls", pPlotGPC->DeviceName, pwDeviceName)); } else { PLOTERR(("No DeviceName passed, using GPC's '%hs'", pPlotGPC->DeviceName)); str2Wstr(DeviceName, pPlotGPC->DeviceName); } // // Make a default copy first then copy device name down // CopyMemory(pPlotDM, &_DefPlotDM, sizeof(PLOTDEVMODE)); WCPYFIELDNAME(pPlotDM->dm.dmDeviceName, DeviceName); // // We must turn off the DM_xxx bits in dmFields if we do not support it, // look at default fields we copy down then update it // if (pPlotGPC->MaxScale) { if ((WORD)pPlotDM->dm.dmScale > pPlotGPC->MaxScale) { pPlotDM->dm.dmScale = (SHORT)pPlotGPC->MaxScale; } } else { pPlotDM->dm.dmFields &= ~DM_SCALE; } if (pPlotGPC->MaxCopies <= 1) { pPlotDM->dm.dmFields &= ~DM_COPIES; } if (!(pPlotGPC->MaxQuality)) { pPlotDM->dm.dmFields &= ~DM_PRINTQUALITY; } // // DEFAULT 50% quality for byte align plotter (DJ 600) to do ROP right // if (pPlotGPC->Flags & PLOTF_RASTERBYTEALIGN) { pPlotDM->dm.dmPrintQuality = DMRES_LOW; PLOTWARN(("SetDefaultPLOTDM: HACK Default Qaulity = DMRES_LOW")); } if (!(pPlotGPC->Flags & PLOTF_COLOR)) { if (pPlotGPC->Flags & PLOTF_RASTER) { pPlotDM->dm.dmFields &= ~DM_COLOR; pPlotDM->dm.dmColor = DMCOLOR_MONOCHROME; } else { PLOTASSERT(0, "SetDefaultPLOTDM: The Pen Ploter CANNOT be MONO.", (pPlotGPC->Flags & PLOTF_COLOR), 0); pPlotGPC->Flags |= PLOTF_COLOR; } } // // Set default form name based on the country // SetDefaultDMForm(pPlotDM, pCurForm); }
BOOL RotatePaper( PSIZEL pSize, PRECTL pImageArea, UINT RotateMode ) /*++ Routine Description: This function rotate a paper left 90 degree, right 90 degree or 180 degree depends on the RotateMode passed Arguments: pSize - Pointer to the size of the paper to be rotated pImageArea - Pointer to the RECTL of Imageable area RotateMode - Must be one of RM_L90, RM_R90, RM_180 Return Value: No return value, but the pSize, and pImageArea pointed to location will be updated. Author: 16-Dec-1993 Thu 09:18:33 created -by- Daniel Chou (danielc) Revision History: --*/ { SIZEL Size; RECTL Margin; // // To be sucessfully rotate the paper to the left 90 degree we must know // all four sides margin before we can do anything // Size = *pSize; Margin.left = pImageArea->left; Margin.top = pImageArea->top; Margin.right = Size.cx - pImageArea->right; Margin.bottom = Size.cy - pImageArea->bottom; PLOTASSERT(0, "RotatePaper: cx size too small (%ld)", (Size.cx - Margin.left - Margin.right) > 0, Size.cx); PLOTASSERT(0, "RotatePaper: cy size too small (%ld)", (Size.cy - Margin.top - Margin.bottom) > 0, Size.cy); PLOTDBG(DBG_ROTPAPER, ("RotatePaper(%ld) FROM (%ld x %ld), (%ld, %ld)-(%ld, %ld)", (LONG)RotateMode, pSize->cx, pSize->cy, pImageArea->left, pImageArea->top, pImageArea->right, pImageArea->bottom)); // // Now we can pick the right margin/corner for the rotation // // cx Rotate Left 90 Rotate Right 90 // +-------+ // | T | cy cy // | | +------------+ +------------+ // c| | | R | | L | // y| | c| | c| | // |L R| x| | x| | // | | |T B| |B T| // | | | | | | // | | | L | | R | // | B | +------------+ +------------+ // +-------+ // switch (RotateMode) { case RM_L90: pSize->cx = Size.cy; pSize->cy = Size.cx; pImageArea->left = Margin.top; pImageArea->top = Margin.right; pImageArea->right = Size.cy - Margin.bottom; pImageArea->bottom = Size.cx - Margin.left; break; case RM_R90: pSize->cx = Size.cy; pSize->cy = Size.cx; pImageArea->left = Margin.bottom; pImageArea->top = Margin.left; pImageArea->right = Size.cy - Margin.top; pImageArea->bottom = Size.cx - Margin.right; break; case RM_180: pImageArea->top = Margin.bottom; pImageArea->bottom = Size.cy - Margin.top; break; default: PLOTERR(("RotatePaper(%ld): Invalid RotateMode passed", RotateMode)); return(FALSE); } PLOTDBG(DBG_ROTPAPER, ("RotatePaper(%ld) - TO (%ld x %ld), (%ld, %ld)-(%ld, %ld)", (LONG)RotateMode, pSize->cx, pSize->cy, pImageArea->left, pImageArea->top, pImageArea->right, pImageArea->bottom)); return(TRUE); }
BOOL IsA4PaperDefault( VOID ) /*++ Routine Description: This function determine if the machine user is using the letter or A4 paper as default based on the country code Arguments: NONE Return Value: BOOL true if the country default paper is A4, else LETTER Author: 23-Nov-1993 Tue 17:50:25 created -by- Daniel Chou (danielc) 02-Feb-1994 Wed 03:01:12 updated -by- Daniel Chou (danielc) re-written so that we do open registry for the international data ourself, and we will make sure we close the all the keys opened by this function, so the system can unload the registry when the user log off. Revision History: --*/ { #if HAS_GETREGDATA HKEY hKey; LONG CountryCode = DEFAULT_COUNTRY; WCHAR wszStr[16]; if (RegOpenKey(HKEY_CURRENT_USER, wszCountryKey, &hKey) == ERROR_SUCCESS) { DWORD Type = REG_SZ; DWORD RetVal = sizeof(wszStr); if (RegQueryValueEx(hKey, (LPTSTR)wszCountryValue, NULL, &Type, (LPBYTE)wszStr, &RetVal) == ERROR_SUCCESS) { LPWSTR pwStop; PLOTDBG(DBG_A4DEFAULT, ("IsA4PaperDefault: Country = %s", wszStr)); CountryCode = wcstoul(wszStr, &pwStop, 10); } else { PLOTERR(("IsA4PaperDefault: RegQueryValue '%s' FAILED", wszCountryValue)); } RegCloseKey(hKey); } else { PLOTERR(("IsA4PaperDefault: RegOpenKey '%s' FAILED", wszCountryKey)); } // // ***** MAKE SURE we have following line to close the CURRENT USER // RegCloseKey(HKEY_CURRENT_USER); if ((CountryCode == CTRY_UNITED_STATES) || (CountryCode == CTRY_CANADA) || ((CountryCode >= 50) && (CountryCode < 60)) || ((CountryCode >= 500) && (CountryCode < 600))) { PLOTDBG(DBG_A4DEFAULT, ("IsA4PaperDefault = No, Use 'LETTER'")); return(FALSE); } else { PLOTDBG(DBG_A4DEFAULT, ("IsA4PaperDefault = Yes")); return(TRUE); } #else // // Use letter size now // return(FALSE); #endif // HAS_GETREGDATA }
BOOL CloneBitBltSURFOBJ( PPDEV pPDev, SURFOBJ *psoDst, SURFOBJ *psoSrc, SURFOBJ *psoMask, XLATEOBJ *pxlo, PRECTL prclDst, PRECTL prclSrc, PRECTL prclPat, BRUSHOBJ *pbo, PCLONESO pCloneSO, DWORD RopBG, DWORD RopFG ) /*++ Routine Description: This function will clone the source/pattern and/or create a temp source buffer if we need one Arguments: pPDev - Pointer to our PDEV psoDst - Pointer to our surfae obj psoSrc - Pointer to source surfae obj psoMask - Pointer to the mask surface object if neeed to be used as pat pxlo - translate object from source to destination prclDst - Pointer to the destination rectangle area for the bitblt prclSrc - Pointer to the source rectangle area prclPat - pointer to the pattern rectangle area pbo - Pointer to the pointer of brush object pCloneSO - Pointer to the CLONSO[3] which stored the clone result RopBG - Background rop3 RopFG - Foreground rop3 Return Value: BOOLEAN Author: 24-Jan-1994 Mon 15:58:27 created Revision History: --*/ { DWORD Index; INT CompPat; BYTE Flags; // // Invert Rop3 if we are out of data range (128-255) and then invert // the final result (by inverting last Mix2 Rop2 code (0-15), all Rop3/Rop2 // codes are symmetric. // if ((Index = RopBG) >= 0x80) { Index ^= 0xFF; } Flags = GET_SDMIX_MIX2F(Rop3ToSDMix[Index]); if ((Index = RopFG) >= 0x80) { Index ^= 0xFF; } Flags |= GET_SDMIX_MIX2F(Rop3ToSDMix[Index]); // // Clone the PATTERN if necessary. // if ((ROP3_NEED_PAT(RopFG)) || (ROP3_NEED_PAT(RopBG))) { // // Only Clone the MASK/PATTERN if it is required // PLOTDBG(DBG_CLONESO, ("CloneBitBltSURFOBJ: NEED PATTERN ")); if (psoMask) { PLOTDBG(DBG_CLONESO, ("CloneBitBltSURFOBJ: Use psoMask as pattern")); if (!(pCloneSO[CSI_PAT].pso = CloneMaskSURFOBJ(pPDev, psoMask, &pCloneSO[CSI_PAT].hBmp, prclPat))) { PLOTERR(("CloneBitBltSURFOBJ:: CloneMaskSURFOBJ(psoPat) failed")); return(FALSE); } } else { // // Firs get the DEVBRUSH out. // if (!(CompPat = (INT)GetColor(pPDev, pbo, NULL, NULL, RopBG))) { PLOTERR(("CloneBitBltSURFOBJ:: GetColor for DEVBRUSH failed")); return(FALSE); } // // If we do not have a device compatible pattern or if we have to // do a SRC/PAT memory operation then we need to clone the pattern // if ((CompPat < 0) || (Flags & MIX2F_NEED_TMP)) { if (!(pCloneSO[CSI_PAT].pso = CloneBrushSURFOBJ(pPDev, psoDst, &pCloneSO[CSI_PAT].hBmp, pbo))) { PLOTERR(("CloneBitBltSURFOBJ:: CloneBrushSURFOBJ(psoPat) failed")); return(FALSE); } prclPat->left = prclPat->top = 0; prclPat->right = pCloneSO[CSI_PAT].pso->sizlBitmap.cx; prclPat->bottom = pCloneSO[CSI_PAT].pso->sizlBitmap.cy; } } } // // Determine if we need to clone the source // if ((ROP3_NEED_SRC(RopFG) || ROP3_NEED_SRC(RopBG))) { if (IsHTCompatibleSurfObj(pPDev, psoSrc, pxlo, (Flags & MIX2F_NEED_TMP) ? 0 : (ISHTF_ALTFMT | ISHTF_DSTPRIM_OK))) { PLOTDBG(DBG_CLONESO, ("CloneBitBltSURFOBJ:: Compatible HT Format, SRC=%ld, DST=%ld [ALT=%ld]", psoSrc->iBitmapFormat, ((PDRVHTINFO)pPDev->pvDrvHTData)->HTBmpFormat, ((PDRVHTINFO)pPDev->pvDrvHTData)->AltBmpFormat)); } else { PLOTDBG(DBG_CLONESO, ("CloneBitBltSURFOBJ:: CLONING SOURCE")); if (!(pCloneSO[CSI_SRC].pso = CloneSURFOBJToHT(pPDev, psoDst, psoSrc, pxlo, &pCloneSO[CSI_SRC].hBmp, prclDst, prclSrc))) { PLOTDBG(DBG_CLONESO, ("CloneBitBltSURFOBJ:: CLONE Source FAILED")); return(FALSE); } } } // // Create a TEMP SURFOBJ for SRC/PAT memory operation if it is required // if (Flags & MIX2F_NEED_TMP) { PLOTDBG(DBG_CLONESO, ("CloneBitbltSURFOBJ: CLONE SRC_TMP (%ld x %ld)", prclSrc->right - prclSrc->left, prclSrc->bottom - prclSrc->top)); if (!(pCloneSO[CSI_TMP].pso = CreateBitmapSURFOBJ(pPDev, &pCloneSO[CSI_TMP].hBmp, prclSrc->right - prclSrc->left, prclSrc->bottom - prclSrc->top, HTBMPFORMAT(pPDev), NULL))) { PLOTDBG(DBG_CLONESO, ("CloneBitBltSURFOBJ:: CLONE SRC_TMP FAILED")); return(FALSE); } } return(TRUE); }
BOOL DoSpecialRop3( SURFOBJ *psoDst, CLIPOBJ *pco, PRECTL prclDst, DWORD Rop3 ) /*++ Routine Description: This function does a white or black fil Arguments: psoDst - The device surface must be DEVICE pco - Clipping object prclDst - RECTL area to be rop'ed Rop3 - a special Rop3, 0x00, 0xFF, 0x55, 0xAA Return Value: BOOLEAN Author: 15-Jan-1994 Sat 07:38:55 created Revision History: --*/ { BRUSHOBJ bo; DEVBRUSH DevBrush; PLOTASSERT(1, "DoSpecialRop3: Passed psoDst (%08lx) != STYPE_DEVICE", psoDst->iType == STYPE_DEVICE, psoDst); PLOTDBG(DBG_SPECIALROP, ("DoSpecialROP[%04lx] (%ld, %ld)-(%ld, %ld)=%ld x %ld", Rop3, prclDst->left, prclDst->top, prclDst->right, prclDst->bottom, prclDst->right - prclDst->left, prclDst->bottom - prclDst->top)); bo.iSolidColor = (DWORD)((Rop3) ? 0x000000000 : 0x00FFFFFF); bo.pvRbrush = (LPVOID)&DevBrush; ZeroMemory(&DevBrush, sizeof(DevBrush)); if (!DoFill(psoDst, // psoDst NULL, // psoSrc pco, // pco NULL, // pxlo prclDst, // prclDst NULL, // prclSrc &bo, // pbo (PPOINTL)&ptlZeroOrigin, // pptlBrushOrg Rop3 | (Rop3 << 8))) { // Rop4 PLOTERR(("DoSpecialRop3: Rop3=%08lx Failed!!!", Rop3)); return(FALSE); } return(TRUE); }
BOOL ValidateFormSrc( PGPCVARSIZE pFormGPC, SIZEL DeviceSize, BOOL DevRollFeed ) /*++ Routine Description: This function validate if FORMSRC has valid filed in it Arguments: pFormGPC - pointer to the GPCVARSIZE for the form data. DeviceSize - Device size to check against, DevRollFeed - TRUE if device can do roll feed Return Value: BOOL return value, the fields already verified and corrected. Development History: 15-Nov-1993 Mon 10:34:29 created --*/ { PFORMSRC pFS; LONG cy; UINT Count; BOOL InvalidFS; BOOL Ok = TRUE; pFS = (PFORMSRC)pFormGPC->pData; Count = (UINT)pFormGPC->Count; while (Count--) { InvalidFS = FALSE; // // Make sure that imageable area is less or eqaul to the size // if (pFS->Size.cy) { if (pFS->Size.cy < MIN_PLOTGPC_FORM_CY) { // // Make it as variable length paper // PLOTERR(("Invalid Form CY, make it as variable length (%ld)", pFS->Size.cy)); pFS->Size.cy = 0; } } if (!(cy = pFS->Size.cy)) { cy = DeviceSize.cy; } if (((pFS->Size.cx <= DeviceSize.cx) && (pFS->Size.cy <= cy)) || ((pFS->Size.cy <= DeviceSize.cx) && (pFS->Size.cx <= cy))) { NULL; } else { PLOTERR(("Invalid Form Size, too big for device to handle")); InvalidFS = TRUE; } if ((pFS->Size.cy) && ((pFS->Size.cy - pFS->Margin.top - pFS->Margin.bottom) < MIN_PLOTGPC_FORM_CY)) { PLOTERR(("Invalid Form CY or top/bottom margins")); InvalidFS = TRUE; } if ((pFS->Size.cx < MIN_PLOTGPC_FORM_CX) || ((pFS->Size.cx - pFS->Margin.left - pFS->Margin.right) < MIN_PLOTGPC_FORM_CX)) { PLOTERR(("Invalid Form CX or left/right margins")); InvalidFS = TRUE; } if ((!DevRollFeed) && (pFS->Size.cy == 0)) { InvalidFS = TRUE; PLOTERR(("The device cannot handle roll paper %hs", pFS->Name)); } if (InvalidFS) { PLOTERR(("ValidateFormSrc: invalid form data, (removed it)")); Ok = FALSE; if (Count) { CopyMemory(pFS, pFS + 1, sizeof(FORMSRC)); } pFormGPC->Count -= 1; } else { // // Make sure ansi ascii end with a NULL // pFS->Name[sizeof(pFS->Name) - 1] = '\0'; ++pFS; } } if (!pFormGPC->Count) { PLOTERR(("ValidateFormSrc: NO form are valid, count = 0")); ZeroMemory(pFormGPC, sizeof(GPCVARSIZE)); } return(Ok); }
BOOL DoRop3( PPDEV pPDev, SURFOBJ *psoDst, SURFOBJ *psoSrc, SURFOBJ *psoPat, SURFOBJ *psoTmp, CLIPOBJ *pco, XLATEOBJ *pxlo, PRECTL prclDst, PRECTL prclSrc, PRECTL prclPat, PPOINTL pptlPatOrg, BRUSHOBJ *pbo, DWORD Rop3 ) /*++ Routine Description: This function performs ROP3 operations (one at a time) Arguments: pPDev - Pointer to the PDEV psoDst - pointer to the destination surface object psoSrc - pointer to the source surface object psoPat - Pointer to the pattern surface object psoTmp - pointer to the temp buffer surface object pco - clip object prclDst - pointer to the destination rectangle prclSrc - pointer to the source rectangle prclPat - pointer to the pattern rectangle pptlPatOrg - Pointer to the brush origin, if this is NULL then its assumed the pattern's prclPat does not have to be aligned on the destination pbo - a Brush object if we need to call DoFill() Rop3 - a ROP3 to be performed Return Value: BOOL Author: 20-Jan-1994 Thu 02:36:00 created 27-Jan-1994 Thu 23:46:28 updated Re-write to take other parameter, also move the cloning surface objects to the caller (ie. DrvBitBlt()) Revision History: --*/ { RECTL rclTmp; DWORD SDMix; DWORD Mix2; BYTE Flags; UINT Count; BOOL InvertMix2; BOOL Ok; PLOTDBG(DBG_ROP3, ("DoRop3: Rop3=%08lx", Rop3)); switch (Rop3 &= 0xFF) { case 0x00: // 0 case 0xFF: // 1 case 0x55: // ~D DoSpecialRop3(psoDst, pco, prclDst, Rop3); case 0xAA: // D // // This is NOP // return(TRUE); } // // Invert Rop3 if we are out of the data range (128-255) and then invert // the final result (by inverting last Mix2 Rop2 code (0-15), all Rop3/Rop2 // codes are symmetric. // if (Rop3 >= 0x80) { InvertMix2 = TRUE; SDMix = (DWORD)Rop3ToSDMix[Rop3 ^ 0xFF]; PLOTDBG(DBG_ROP3, ("DoRop3: Need Invert ROP")); } else { InvertMix2 = FALSE; SDMix = (DWORD)Rop3ToSDMix[Rop3]; } if (psoTmp) { rclTmp.left = rclTmp.top = 0; rclTmp.right = psoTmp->sizlBitmap.cx; rclTmp.bottom = psoTmp->sizlBitmap.cy; } Flags = GET_SDMIX_MIX2F(SDMix); Count = (UINT)GET_MIX2F_COUNT(Flags); Ok = TRUE; PLOTDBG(DBG_ROP3, ("SDMix=%08lx, Flags=%02x, Count=%u", SDMix, Flags, Count)); if (Flags & MIX2F_MUL_DST) { PLOTWARN(("DoRop3: *** Rop3=%08lx Has Multiple DEST, Mix2s NOT complete ***", Rop3)); } while ((Ok) && (Count--)) { Mix2 = (DWORD)(SDMix & MIX2_MASK); if ((!Count) && (InvertMix2)) { PLOTDBG(DBG_ROP3, ("DoRop3: Invert Last MIX2 %02lx -> %02lx", Mix2, Mix2 ^ MIX2_MASK)); Mix2 ^= MIX2_MASK; } PLOTDBG(DBG_ROP3, ("DoRop3: SD=%02lx, Mix2=%02lx", SDMix & MIXSD_MASK, Mix2)); switch (SDMix & MIXSD_MASK) { case MIXSD_SRC_DST: PLOTASSERT(1, "DoRop3: MIXSD_SRC_DST but psoSrc = NULL, Rop3=%08lx", psoSrc, Rop3); Ok = DoMix2(pPDev, psoDst, psoSrc, pco, pxlo, prclDst, prclSrc, NULL, Mix2); break; case MIXSD_PAT_DST: if (psoPat) { Ok = DoMix2(pPDev, psoDst, psoPat, pco, NULL, prclDst, prclPat, pptlPatOrg, Mix2); } else { // // A compatible brush object is passed, use DoFill() to do // the actual work. // Mix2 += 1; Mix2 = MixToRop4(Mix2 | (Mix2 << 8)); PLOTDBG(DBG_ROP3, ("DoRop3: DoFill[%04lx] (%ld, %ld)-(%ld, %ld)=%ld x %ld", Mix2, prclDst->left, prclDst->top, prclDst->right, prclDst->bottom, prclDst->right - prclDst->left, prclDst->bottom - prclDst->top)); Ok = DoFill(psoDst, // psoDst NULL, // psoSrc pco, // pco NULL, // pxlo prclDst, // prclDst NULL, // prclSrc pbo, // pbo pptlPatOrg, // pptlBrushOrg Mix2); // Rop4 } break; case MIXSD_SRC_PAT: PLOTASSERT(1, "DoRop3: MIXSD_SRC_PAT but psoSrc = NULL, Rop3=%08lx", psoSrc, Rop3); PLOTASSERT(1, "DoRop3: MIXSD_SRC_PAT but psoPat = NULL, Rop3=%08lx", psoPat, Rop3); PLOTASSERT(1, "DoRop3: MIXSD_SRC_PAT but psoTmp = NULL, Rop3=%08lx", psoTmp, Rop3); // // Firs tile the pattern onto the temp buffer then do SRC/DST // using SRCCOPY = MIX2_S // if (pptlPatOrg) { // // This is a real pattern we have to tile and align it onto the // desination, but since psoTmp is 0,0 - cx,cy we must alter // the pptlPatOrg to make it align correctly. // pptlPatOrg->x -= prclDst->left; pptlPatOrg->y -= prclDst->top; } Ok = DoMix2(pPDev, psoTmp, psoPat, NULL, NULL, &rclTmp, prclPat, pptlPatOrg, MIX2_S); if (pptlPatOrg) { pptlPatOrg->x += prclDst->left; pptlPatOrg->y += prclDst->top; } // // Now We will do the MIX2 operation between SRC and PAT // if (Ok) { Ok = DoMix2(pPDev, psoTmp, psoSrc, NULL, NULL, &rclTmp, prclSrc, NULL, Mix2); } break; case MIXSD_TMP_DST: PLOTASSERT(1, "DoRop3: MIXSD_TMP_DST but psoTmp = NULL, Rop3=%08lx", psoTmp, Rop3); // // Since we already aligned the pattern on the temp buffer // we can just do the mix2 without aligning it again. // Ok = DoMix2(pPDev, psoDst, psoTmp, pco, NULL, prclDst, &rclTmp, NULL, Mix2); break; } SDMix >>= SDMIX_SHIFT_COUNT; } if (!Ok) { PLOTERR(("DoRop3: FAILED in DoMix2() operations")); } return(Ok); }
PPLOTGPC ReadPlotGPCFromFile( LPCWSTR pwsDataFile ) /*++ Routine Description: This function open/read the PlotGPC data file and validate them also Arguments: pwsDataFile - a pointer to full qualify path for the data file name Return Value: BOOL - to indicate state Development History: 15-Nov-1993 Mon 10:01:17 created Revision History: --*/ { HANDLE hFile; DWORD dwSize; PLOTGPC_PCD PlotGPC_PCD; BOOL bSuccess = TRUE; PPLOTGPC pPlotGPC = NULL; if ((hFile = OpenPlotFile(pwsDataFile)) == (HANDLE)INVALID_HANDLE_VALUE) { PLOTERR(("ReadPlotGPCFromFile: Open data file failed")); return(NULL); } if ((ReadPlotFile(hFile, &PlotGPC_PCD, sizeof(PLOTGPC_PCD), &dwSize)) && (dwSize == sizeof(PLOTGPC_PCD))) { if ((PlotGPC_PCD.ID != PLOTGPC_ID) || (PlotGPC_PCD.cjThis != sizeof(PLOTGPC_PCD))) { bSuccess = FALSE; PLOTERR(("ReadPlotGPCFromFile: invalid data file")); } } else { bSuccess = FALSE; PLOTERR(("ReadPlotGPCFromFile: Read data file failed")); } // // if we have pPlotGPC_PCD == NULL then an error ocurred // if (bSuccess) { dwSize = PlotGPC_PCD.SizeExtra + sizeof(PLOTGPC); if (pPlotGPC = (PPLOTGPC)LocalAlloc(LPTR, dwSize)) { CopyPlotGPCFromPCD(pPlotGPC, &PlotGPC_PCD); if ((PlotGPC_PCD.SizeExtra) && (ReadPlotFile(hFile, (LPBYTE)pPlotGPC + sizeof(PLOTGPC), PlotGPC_PCD.SizeExtra, &dwSize)) && (dwSize == PlotGPC_PCD.SizeExtra)) { if ((pPlotGPC->InitString.Count == 1) && (pPlotGPC->InitString.SizeEach) && (pPlotGPC->InitString.pData)) { (LPBYTE)pPlotGPC->InitString.pData += (ULONG_PTR)pPlotGPC; } else { ZeroMemory(&(pPlotGPC->InitString), sizeof(GPCVARSIZE)); } if ((pPlotGPC->Forms.Count) && (pPlotGPC->Forms.SizeEach == sizeof(FORMSRC)) && (pPlotGPC->Forms.pData)) { (LPBYTE)pPlotGPC->Forms.pData += (ULONG_PTR)pPlotGPC; } else { ZeroMemory(&(pPlotGPC->Forms), sizeof(GPCVARSIZE)); } if ((pPlotGPC->Pens.Count) && (pPlotGPC->Pens.SizeEach == sizeof(PENDATA)) && (pPlotGPC->Pens.pData)) { (LPBYTE)pPlotGPC->Pens.pData += (ULONG_PTR)pPlotGPC; } else { ZeroMemory(&(pPlotGPC->Pens), sizeof(GPCVARSIZE)); } } else { // // Failed to read, free the memory and return NULL // LocalFree((HLOCAL)pPlotGPC); pPlotGPC = NULL; PLOTERR(("ReadPlotGPCFromFile: read variable size data failed")); } } else { PLOTERR(("ReadPlotGPCFromFile: allocate memory (%lu bytes) failed", dwSize)); } } ClosePlotFile(hFile); if (pPlotGPC) { ValidatePlotGPC(pPlotGPC); } return(pPlotGPC); }
BOOL DrvStartDoc( SURFOBJ *pso, PWSTR pwDocName, DWORD JobId ) /*++ Routine Description: This function is called by start page, and is the second highest level initialization call. It initializes the beginning of a document, which is different from the beginning of a page, since multiple pages may exist in a document. Arguments: pso - Pointer to the SURFOBJ which belong to this driver pwDocName - Pointer to the document name to be started JobID - Job's ID Return Value: BOOL Author: 16-Nov-1993 Tue 01:55:15 updated -by- Daniel Chou (danielc) re-write 08-Feb-1994 Tue 13:51:59 updated -by- Daniel Chou (danielc) Move to StartPage for now Revision History: --*/ { PPDEV pPDev; if (!(pPDev = SURFOBJ_GETPDEV(pso))) { PLOTERR(("DrvStartDoc: invalid pPDev")); return(FALSE); } // // TODO we should review if we should do anything here... // PLOTDBG(DBG_STARTDOC,("DrvStartDoc: DocName = %s", pwDocName)); //TODO may need to resett stuff in drvstart page return(TRUE); }
BOOL GetPlotRegData( HANDLE hPrinter, LPBYTE pData, DWORD RegIdx ) /*++ Routine Description: This function retrieve from registry to the pData Arguments: hPrinter - Handle to the printer interested pData - Pointer to the data area buffer, it must large enough RegIdx - One of the PRKI_xxxx in LOWORD(Index), HIWORD(Index) specified total count for the PENDATA set Return Value: TRUE if sucessful, FALSE if failed, Author: 06-Dec-1993 Mon 22:22:47 created -by- Daniel Chou (danielc) 10-Dec-1993 Fri 01:13:14 updated -by- Daniel Chou (danielc) Fixed nesty problem in spooler of GetPrinterData which if we passed a pbData and cb but if it cannot get any data then it will clear all our buffer, this is not we expected (we expected it just return error rather clear our buffer). Now we do extended test before we really go get the data. The other problem is, if we set pbData = NULL then spooler always have excption happened even we pass &cb as NULL also. Revision History: --*/ { PPLOTREGKEY pPRK; LONG lRet; DWORD cb; DWORD Type; WCHAR wBuf[32]; PLOTREGKEY PRK; UINT Index; Index = LOWORD(RegIdx); PLOTASSERT(0, "GetPlotRegData: Invalid PRKI_xxx Index %ld", Index <= PRKI_LAST, Index); if (Index >= PRKI_PENDATA1) { UINT cPenData; if ((cPenData = (UINT)HIWORD(RegIdx)) >= MAX_PENPLOTTER_PENS) { PLOTERR(("GetPlotRegData: cPenData too big %ld (Max=%ld)", cPenData, MAX_PENPLOTTER_PENS)); cPenData = MAX_PENPLOTTER_PENS; } PRK.pwKey = GetPenDataKey(wBuf, (WORD)(Index - PRKI_PENDATA1 + 1)); PRK.Size = (DWORD)sizeof(PENDATA) * (DWORD)cPenData; pPRK = &PRK; } else { pPRK = (PPLOTREGKEY)&PlotRegKey[Index]; } // // We must do following sequence or if an error occurred then the pData // will be filled with ZEROs // // 1. Set Type/cb to invalid value // 1. query the type/size of the keyword, (if more data available) // 2. and If size is exact as we want // 3. and if the type is as we want (REG_BINARY) // 4. assume data valid then query it // Type = 0xffffffff; cb = 0; if ((lRet = xGetPrinterData(hPrinter, pPRK->pwKey, &Type, (LPBYTE)pData, 0, &cb)) != ERROR_MORE_DATA) { if (lRet == ERROR_FILE_NOT_FOUND) { PLOTWARN(("GetPlotRegData: GetPrinterData(%ls) not found", pPRK->pwKey)); } else { PLOTERR(("GetPlotRegData: 1st GetPrinterData(%ls) failed, Error=%ld", pPRK->pwKey, lRet)); } } else if (cb != pPRK->Size) { PLOTERR(("GetPlotRegData: GetPrinterData(%ls) Size != %ld (%ld)", pPRK->pwKey, pPRK->Size, cb)); } else if (Type != REG_BINARY) { PLOTERR(("GetPlotRegData: GetPrinterData(%ls) Type != REG_BINARY (%ld)", pPRK->pwKey, Type)); } else if ((lRet = xGetPrinterData(hPrinter, pPRK->pwKey, &Type, (LPBYTE)pData, pPRK->Size, &cb)) == NO_ERROR) { PLOTDBG(DBG_GETREGDATA, ("READ '%ws' REG Data: Type=%ld, %ld bytes", pPRK->pwKey, Type, cb)); return(TRUE); } else { PLOTERR(("GetPlotRegData: 2nd GetPrinterData(%ls) failed, Error=%ld", pPRK->pwKey, lRet)); } return(FALSE); }
BOOL SetPlotRegData( HANDLE hPrinter, LPBYTE pData, DWORD RegIdx ) /*++ Routine Description: This function save pData to to the registry Arguments: hPrinter - Handle to the printer interested pData - Pointer to the data area buffer, it must large enough RegIdx - One of the PRKI_xxxx in LOWORD(Index), HIWORD(Index) specified total count for the PENDATA set Return Value: TRUE if sucessful, FALSE if failed, Author: 06-Dec-1993 Mon 22:25:55 created -by- Daniel Chou (danielc) Revision History: --*/ { PPLOTREGKEY pPRK; WCHAR wBuf[32]; PLOTREGKEY PRK; UINT Index; Index = (UINT)LOWORD(RegIdx); PLOTASSERT(0, "SetPlotRegData: Invalid PRKI_xxx Index %ld", Index <= PRKI_LAST, Index); if (Index >= PRKI_PENDATA1) { UINT cPenData; if ((cPenData = (UINT)HIWORD(RegIdx)) >= MAX_PENPLOTTER_PENS) { PLOTERR(("GetPlotRegData: cPenData too big %ld (Max=%ld)", cPenData, MAX_PENPLOTTER_PENS)); cPenData = MAX_PENPLOTTER_PENS; } PRK.pwKey = GetPenDataKey(wBuf, (WORD)(Index - PRKI_PENDATA1 + 1)); PRK.Size = (DWORD)sizeof(PENDATA) * (DWORD)cPenData; pPRK = &PRK; } else { pPRK = (PPLOTREGKEY)&PlotRegKey[Index]; } if (xSetPrinterData(hPrinter, pPRK->pwKey, REG_BINARY, pData, pPRK->Size) != NO_ERROR) { PLOTERR(("SetPlotRegData: SetPrinterData(%ls [%ld]) failed", pPRK->pwKey, pPRK->Size)); return(FALSE); } else { PLOTDBG(DBG_SETREGDATA, ("SAVE '%ws' registry data", pPRK->pwKey)); return(TRUE); } }
_Use_decl_annotations_ BOOL WINAPI DrvStrokePath( SURFOBJ *pso, PATHOBJ *ppo, CLIPOBJ *pco, XFORMOBJ *pxo, BRUSHOBJ *pbo, PPOINTL pptlBrushOrg, LINEATTRS *plineattrs, MIX Mix ) /*++ Routine Description: The driver's function for the StrokePath Arguments: same as EngStrokePath Return Value: TRUE if sucessful FALSE if failed Author: 8/18/92 -- t-alip Rewrote it. 30-Nov-1993 Tue 22:21:51 updated updated by DC 04-Aug-1994 Thu 20:00:23 updated bug# 22348 Revision History: 31-Jan-1994 Tue 22:21:51 updated Fixed dopolygon to pass in ROP4 not just MIX --*/ { PPDEV pPDev; BOOL bRetVal; UNREFERENCED_PARAMETER(pxo); PLOTDBG(DBG_STROKEPATH, ("DrvStrokePath: Mix = %x", Mix)); if (!(pPDev = SURFOBJ_GETPDEV(pso))) { PLOTERR(("DrvStrokePath: Invalid pPDev")); return(FALSE); } if (!(bRetVal = DoPolygon(pPDev, NULL, pco, ppo, pptlBrushOrg, NULL, pbo, MixToRop4(Mix), plineattrs, FPOLY_STROKE) )) { // // Since DoPolygon failed, it can only be because we had both a complex // clip and a pathobj, so the thing to here is do the stroke via another // method using some of the engine helpers. // // We will also failed when STYLE LINE + DC_RECT when raster plotter is // used // bRetVal = DoStrokePathByEnumingClipLines( pPDev, pso, pco, ppo, pptlBrushOrg, pbo, MixToRop4(Mix), plineattrs); } return(bRetVal); }