Example #1
0
BOOL
bAddMiniForms(
    HANDLE  hPrinter,               /* Access to the printer */
    BOOL    bUpgrade,
    PRASDDUIINFO pRasdduiInfo       /* Global Data Access */

)
{

    short    *psPSInd;          /* Scan the PAPERSOURCE selection */

    PAPERSIZE  *pPS;            /* Scanning PAPERSIZE data */

    FORM_INFO_1  fi1;           /* The info the spooler wants! */

    WCHAR       awchForm[ 64 ];     /* The name of the form */

    psPSInd = (short *)((BYTE *)pdh + pdh->loHeap +
                                      pModel->rgoi[ MD_OI_PAPERSIZE ]);

    fi1.Flags = FORM_PRINTER;
    fi1.pName = awchForm;
    fi1.ImageableArea.left = 0;
    fi1.ImageableArea.top = 0;

    for( ; *psPSInd; ++psPSInd )
    {
        pPS = (PAPERSIZE *)GetTableInfoIndex( pdh, HE_PAPERSIZE, *psPSInd - 1 );

        if( !pPS || pPS->sPaperSizeID <= DMPAPER_USER )
            continue;           /* Standard rasdd defined */

        if( iLoadStringW( &WinResData, pPS->sPaperSizeID,
                                       awchForm, sizeof( awchForm ) ) == 0 )
        {
#if  DBG
            DbgPrint( "rasddUI!bAddMiniForms: Could not load form name string for index %d\n", pPS->sPaperSizeID );
#endif

            continue;            /* See if there are others */
        }

        /*
         *     Now have a minidriver specific form size!  This information
         *  needs to be communicated to the spooler.
         */

        fi1.Size.cx = MASTERTOX( (long)pPS->ptSize.x );
        fi1.Size.cy = MASTERTOY( (long)pPS->ptSize.y );

        fi1.ImageableArea.right = fi1.Size.cx;
        fi1.ImageableArea.bottom = fi1.Size.cy;

        //This is the upgrade case

        if (bUpgrade)
        {
            FORM_INFO_1 FormInfo;
            DWORD dw = 0;

            if ( GetForm( hPrinter, awchForm, 1,
                          (LPBYTE)&FormInfo,
                          sizeof(FORM_INFO_1), &dw ) )
            {
                /* This means  NT 351 */
                if ( FormInfo.Flags & FORM_USER )
                    DeleteForm(hPrinter,awchForm);
            }
        }


        AddForm( hPrinter, 1, (BYTE *)&fi1 );

    }

    return   TRUE;
}
Example #2
0
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);
    }
}