亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? text.cpp

?? Separator Print Processor Sample
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*++

Copyright (c) 1990-2003  Microsoft Corporation
All Rights Reserved

Abstract:

    Routines to facilitate printing of text jobs.

--*/

#include "local.h"

#define FLAG_CR_STATE         0x1
#define FLAG_TAB_STATE        0x2
#define FLAG_DBCS_SPLIT       0x8
#define FLAG_FF               0x10
#define FLAG_LF               0x20
#define FLAG_CR               0x40
#define FLAG_TRANSLATE_LF     0x80
#define FLAG_TRANSLATE_CR     0x100

const WCHAR gszNoTranslateCRLF[] = L"Winprint_TextNoTranslation";
const WCHAR gszNoTranslateCR[]   = L"Winprint_TextNoCRTranslation";
const WCHAR gszTransparency[]    = L"Transparency";

/** Prototypes for functions in this file **/

PBYTE
GetTabbedLineFromBuffer(
    IN      PBYTE   pSrcBuffer,
    IN      PBYTE   pSrcBufferEnd,
    IN      PBYTE   pDestBuffer,
    IN      ULONG   CharsPerLine,
    IN      ULONG   TabExpansionSize,
    IN      ULONG   Encoding,
    IN OUT  PULONG  pLength,
    IN OUT  PULONG  pTabBase,
    IN OUT  PDWORD  pfdwFlags
    );


/*++
*******************************************************************
    P r i n t T e x t J o b

    Routine Description:
        Prints a text data job.

    Arguments:
        pData           => Data structure for this job
        pDocumentName   => Name of this document

    Return Value:
        TRUE  if successful
        FALSE if failed - GetLastError() will return reason.
*******************************************************************
--*/
BOOL
PrintTextJob(
    IN PPRINTPROCESSORDATA pData,
    IN LPWSTR pDocumentName)
{
    DOCINFO     DocInfo;
    LOGFONT     LogFont;
    CHARSETINFO CharSetInfo;
    HFONT       hOldFont, hFont;
    DWORD       Copies;
    BOOL        rc;
    DWORD       NoRead;
    DWORD       CurrentLine;
    DWORD       CurrentCol;
    HANDLE      hPrinter = NULL;
    BYTE        *ReadBufferStart = NULL;
    PBYTE       pLineBuffer = NULL;
    PBYTE       pReadBuffer = NULL;
    PBYTE       pReadBufferEnd = NULL;
    ULONG       CharHeight, CharWidth, CharsPerLine, LinesPerPage;
    ULONG       PageWidth, PageHeight;
    ULONG       Length, TabBase;
    BOOL        ReadAll;
    TEXTMETRIC  tm;
    DWORD       fdwFlags;
    DWORD       Encoding;
    DWORD       SplitSize;
    BOOL        ReturnValue = FALSE;
    BOOL        bAbortDoc   = FALSE;

    DWORD       dwNeeded;
    DWORD       dwNoTranslate = 0;
    DWORD       dwNoTranslateCR = 0;
    DWORD       dwTransparent = 0;
    INT         iBkMode;

    DocInfo.lpszDocName = pData->pDocument;  /* Document name */
    DocInfo.lpszOutput  = NULL;              /* Output file */
    DocInfo.lpszDatatype = NULL;             /* Datatype */
    DocInfo.cbSize = sizeof(DOCINFO);        /* Size of the structure */



    //
    // Go figure out the size of the form on the printer.  We do this
    // by calling GetTextMetrics, which gives us the font size of the
    // printer font, then getting the form size and calculating the
    // number of characters that will fit. In other cases we treat it as ANSI text.
    // Currently the codepage context is fixed to the system default codepage.
    //

    Encoding = GetACP();

    //
    // Create FIXED PITCH font and select
    //

    hOldFont = 0;
    ZeroMemory(&CharSetInfo, sizeof(CHARSETINFO));
    if (TranslateCharsetInfo((PDWORD)UIntToPtr(Encoding), &CharSetInfo, TCI_SRCCODEPAGE))
    {
        ZeroMemory(&LogFont, sizeof(LOGFONT));

        LogFont.lfWeight = 400;
        LogFont.lfCharSet = (BYTE)CharSetInfo.ciCharset;
        LogFont.lfPitchAndFamily = FIXED_PITCH;

        hFont = CreateFontIndirect(&LogFont);
        hOldFont = (HFONT)SelectObject(pData->hDC, hFont);
    }

    if (!GetTextMetrics(pData->hDC, &tm)) {
        // Essential text processing computation failed
        goto Done;
    }

    CharHeight = tm.tmHeight + tm.tmExternalLeading;
    CharWidth  = tm.tmAveCharWidth;

    if (!CharWidth || !CharHeight) {
        // Essential text processing computation failed
        goto Done;
    }

    //
    // Calculate most fittable characters' number to one line.
    //

    PageWidth = GetDeviceCaps(pData->hDC, DESKTOPHORZRES);
    PageHeight = GetDeviceCaps(pData->hDC, DESKTOPVERTRES);

    CharsPerLine = PageWidth / CharWidth;
    LinesPerPage = PageHeight / CharHeight;

    if (!CharsPerLine || !LinesPerPage) {
        // Essential text processing computation failed
        goto Done;
    }

    /** Allocate a buffer for one line of text **/

    pLineBuffer = (PBYTE)AllocSplMem(CharsPerLine + 5);

    if (!pLineBuffer) {
        goto Done;
    }

    /** Let the printer know we are starting a new document **/

    if (!StartDoc(pData->hDC, (LPDOCINFO)&DocInfo)) {

        goto Done;
    }

    ReadBufferStart = (PBYTE)AllocSplMem(READ_BUFFER_SIZE);

    if (!ReadBufferStart) {

        goto Done;
    }

    /** Print the data pData->Copies times **/

    Copies = pData->Copies;

    while (Copies--) {

        /**
            Loop, getting data and sending it to the printer.  This also
            takes care of pausing and cancelling print jobs by checking
            the processor's status flags while printing.  The way we do
            this is to read in some data from the printer.  We will then
            pull data, one tabbed line at a time from there and print
            it.  If the last bit of data in the buffer does not make up
            a whole line, we call GetTabbedLineFromBuffer() with a non-
            zero Length, which indicates that there are chars left
            from the previous read.
        **/

        TabBase = 0;
        Length = 0;
        fdwFlags = FLAG_TRANSLATE_CR | FLAG_TRANSLATE_LF;

        CurrentLine = 0;
        CurrentCol = 0;

        /**
            Open the printer.  If it fails, return.  This also sets up the
            pointer for the ReadPrinter calls.
        **/

        if (!OpenPrinter(pDocumentName, &hPrinter, NULL)) {

            hPrinter = NULL;
            bAbortDoc = TRUE;
            goto Done;
        }

        //
        // Call GetPrinterData to see if the queue wants no LF/CR processing.
        //
        if( GetPrinterData( hPrinter,
                            (LPWSTR)gszNoTranslateCRLF,
                            NULL,
                            (PBYTE)&dwNoTranslate,
                            sizeof( dwNoTranslate ),
                            &dwNeeded ) == ERROR_SUCCESS ){

            if( dwNoTranslate ){
                fdwFlags &= ~( FLAG_TRANSLATE_CR | FLAG_TRANSLATE_LF );
            }
        }

        //
        // Call GetPrinterData to see if the queue wants no CR processing.
        //
        if( GetPrinterData( hPrinter,
                            (LPWSTR)gszNoTranslateCR,
                            NULL,
                            (PBYTE)&dwNoTranslateCR,
                            sizeof( dwNoTranslateCR ),
                            &dwNeeded ) == ERROR_SUCCESS ){

            if( dwNoTranslateCR ){

                fdwFlags &= ~FLAG_TRANSLATE_CR;

                if( GetPrinterData( hPrinter,
                                (LPWSTR)gszTransparency,
                                NULL,
                                (PBYTE)&dwTransparent,
                                sizeof( dwTransparent ),
                                &dwNeeded ) == ERROR_SUCCESS ){

                    if( dwTransparent ){
                        iBkMode = SetBkMode( pData->hDC, TRANSPARENT );
                    }
                }
            }
        }

        if (StartPage(pData->hDC) == SP_ERROR) {

            bAbortDoc = TRUE;
            goto Done;
        }

        /** ReadAll indicates if we are on the last line of the file **/

        ReadAll = FALSE;

        /**
            This next do loop continues until we have read all of the
            data for the print job.
        **/

        do {

            if (fdwFlags & FLAG_DBCS_SPLIT) {
                SplitSize = (DWORD)(pReadBufferEnd - pReadBuffer);
                memcpy(ReadBufferStart, pReadBuffer, SplitSize);
                fdwFlags &= ~FLAG_DBCS_SPLIT;
            }
            else {
                SplitSize = 0;
            }

            rc = ReadPrinter(hPrinter,
                             (ReadBufferStart + SplitSize),
                             (READ_BUFFER_SIZE - SplitSize),
                             &NoRead);

            if (!rc || !NoRead) {

                ReadAll = TRUE;

            } else {

                /** Pick up a pointer to the end of the data **/

                pReadBuffer    = ReadBufferStart;
                pReadBufferEnd = ReadBufferStart + SplitSize + NoRead;
            }

            /**
                This loop will process all the data that we have
                just read from the printer.
            **/

            do {

                if (!ReadAll) {

                    /**
                        Length on entry holds the length of any
                        residual chars from the last line that we couldn't
                        print out because we ran out of characters on
                        the ReadPrinter buffer.
                    **/

                    pReadBuffer = GetTabbedLineFromBuffer(
                                      pReadBuffer,
                                      pReadBufferEnd,
                                      pLineBuffer,
                                      CharsPerLine - CurrentCol,
                                      pData->TabSize,
                                      Encoding,
                                      &Length,
                                      &TabBase,
                                      &fdwFlags );

                    /**

                        If pReadBuffer == NULL, then we have
                        exhausted the read buffer and we need to ReadPrinter
                        again and save the last line chars.  Length holds
                        the number of characters on this partial line,
                        so the next time we call ReadPrinter we will
                        pickup where we left off.

                        The only time we'll get residual chars is if:

                        1. The last line ends w/o ff/lf/cr ("Hello\EOF")
                           In this case we should TextOutA the last line
                           and then quit.

                           (In this case, don't break here; go ahead and
                           print, then we'll break out below in the do..while.)


                        2. The ReadPrinter last byte is in the middle of a line.
                           Here we should read the next chunk and add the
                           new characters at the end of the chars we just read.

                           (In this case, we should break and leave Length
                           as it is so we will read again and append to the
                           buffer, beginning at Length.)
                    **/

                    if (!pReadBuffer || (fdwFlags & FLAG_DBCS_SPLIT))
                        break;
                }


                /** If the print processor is paused, wait for it to be resumed **/

                if (pData->fsStatus & PRINTPROCESSOR_PAUSED) {
                    WaitForSingleObject(pData->semPaused, INFINITE);
                }

                /** If the job has been aborted, clean up and leave **/

                if (pData->fsStatus & PRINTPROCESSOR_ABORTED) {

                    ReturnValue = TRUE;

                    bAbortDoc = TRUE;
                    goto Done;
                }

                /** Write the data to the printer **/

                /** Make sure Length is not zero  **/
                /** TextOut will fail if Length == 0 **/

                if (Length) {

                    /**
                        We may have a number of newlines pending, that
                        may push us to the next page (or even next-next
                        page).
                    **/

                    while (CurrentLine >= LinesPerPage) {

                        /**
                            We need a new page; always defer this to the
                            last second to prevent extra pages from coming out.
                        **/

                        if (EndPage(pData->hDC) == SP_ERROR ||
                            StartPage(pData->hDC) == SP_ERROR) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一级视频免费观看在线| 亚洲国产精品尤物yw在线观看| 暴力调教一区二区三区| 亚洲欧美日韩人成在线播放| 色悠悠久久综合| 美国欧美日韩国产在线播放| 国产精品国产成人国产三级 | 国产一区二区成人久久免费影院 | 蜜臀va亚洲va欧美va天堂| 欧美高清在线一区| 欧美日产在线观看| 成人黄色在线网站| 亚洲综合自拍偷拍| 日韩一区二区三区在线观看| 99久久综合色| 国产一区二区三区四区五区入口| 亚洲乱码国产乱码精品精98午夜| 欧美一级片在线看| fc2成人免费人成在线观看播放 | 欧美美女一区二区在线观看| 国产91丝袜在线播放九色| 美国三级日本三级久久99 | 亚洲免费高清视频在线| av资源站一区| 韩国三级在线一区| 日韩高清欧美激情| 亚洲三级在线看| 国产精品大尺度| 国产精品白丝在线| 国产精品久久久久永久免费观看 | 欧美精品一区二区三区在线| 欧美一区二区视频免费观看| 欧美一区二区三区的| 欧美日韩精品免费观看视频 | 欧美图片一区二区三区| 欧美自拍丝袜亚洲| 欧美人动与zoxxxx乱| 欧美伦理电影网| 日韩美女天天操| 国产精品久久久久久亚洲伦| 亚洲欧洲日韩一区二区三区| 亚洲伦理在线精品| 亚洲一二三区在线观看| 蜜桃一区二区三区在线| 国产盗摄一区二区三区| 一本色道a无线码一区v| 91精品国产入口在线| 国产精品福利在线播放| 免费成人你懂的| 成人永久看片免费视频天堂| 91久久国产最好的精华液| 91麻豆精品国产综合久久久久久| 日韩精品一区二区在线观看| 国产亲近乱来精品视频| 国产在线精品一区二区夜色| 欧美一级日韩不卡播放免费| 久久精品72免费观看| 国产精品第四页| 99视频精品免费视频| 亚洲一区二区在线播放相泽| www.久久久久久久久| 欧美日韩视频专区在线播放| 亚洲女人小视频在线观看| 国产伦精品一区二区三区免费| 欧美日韩在线直播| 亚洲美女免费视频| 成人免费三级在线| 国产亚洲一区字幕| 国产伦精品一区二区三区视频青涩| 制服丝袜一区二区三区| 亚洲国产欧美在线人成| 欧美系列在线观看| 亚洲一区免费在线观看| 在线观看日韩一区| 亚洲成a人片综合在线| 欧美色网一区二区| 青青草视频一区| 欧美精品一区二| 成人av中文字幕| 一区二区三区四区五区视频在线观看 | 91美女片黄在线| 亚洲精品乱码久久久久久黑人| 欧美欧美欧美欧美| 亚洲一区中文日韩| av在线播放一区二区三区| 国产成都精品91一区二区三| 色综合天天在线| 欧美精品一区二区三区在线播放| 亚洲一区免费视频| 欧美在线视频全部完| 亚洲精品美腿丝袜| 欧美一区二区在线不卡| 国产乱色国产精品免费视频| 国产精品久久久久久久午夜片| 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美日韩激情在线| 国产精品色噜噜| 91高清视频免费看| 日本不卡在线视频| 国产精品网站在线播放| 色欧美片视频在线观看在线视频| 亚洲地区一二三色| 国产亚洲精品aa| 91麻豆精品国产91久久久资源速度| 久久99久久精品欧美| 亚洲你懂的在线视频| 制服.丝袜.亚洲.另类.中文| 99re在线精品| 国产成人精品三级麻豆| 日本女人一区二区三区| 亚洲欧美综合色| 久久精品视频免费观看| 91精品国产综合久久香蕉的特点| 97久久超碰精品国产| 国产精品一区二区久激情瑜伽| 亚洲超碰精品一区二区| 国产精品精品国产色婷婷| 日韩视频一区在线观看| 在线免费观看日本欧美| 成人h动漫精品一区二| 国产最新精品免费| 极品瑜伽女神91| 美女脱光内衣内裤视频久久影院| 亚洲乱码国产乱码精品精98午夜 | 欧美激情一区二区三区全黄 | 亚洲乱码国产乱码精品精98午夜| 久久久精品欧美丰满| 久久影院午夜片一区| 久久久久久97三级| 国产日韩欧美精品在线| 国产日韩视频一区二区三区| 欧美日韩午夜在线| 日韩一区二区三区在线| 在线影院国内精品| 日韩欧美一二三区| 欧美一个色资源| 国产精品久久久久久一区二区三区| 亚洲v精品v日韩v欧美v专区| 国产高清亚洲一区| 日韩欧美国产一区二区在线播放| 国产精品麻豆欧美日韩ww| 亚洲理论在线观看| 五月天激情综合网| 爽爽淫人综合网网站| 一区二区在线观看免费| 亚洲综合色婷婷| 亚洲激情欧美激情| 国产三级三级三级精品8ⅰ区| 欧美疯狂做受xxxx富婆| 在线播放一区二区三区| 国产精品午夜在线| 色偷偷久久人人79超碰人人澡| 国产女人水真多18毛片18精品视频 | 国产亚洲精品超碰| 欧美在线免费视屏| 国产在线不卡一卡二卡三卡四卡| 国产精品久久久久永久免费观看| 欧美日韩美少妇| 国产精品1区二区.| 亚洲成人免费在线| 中文一区二区完整视频在线观看| 欧美视频在线一区二区三区| 久久99九九99精品| 亚洲永久免费视频| 国产欧美一区二区精品性| 欧美日韩国产一级二级| 成人午夜精品一区二区三区| 婷婷国产在线综合| 国产精品日产欧美久久久久| 日韩一级片在线播放| 色综合天天综合给合国产| 国产一区二区毛片| 日本视频一区二区三区| 亚洲精品中文字幕乱码三区| 久久综合九色综合97婷婷| 欧美日本一区二区三区四区| 成人午夜又粗又硬又大| 美国av一区二区| 五月激情综合婷婷| 亚洲精品国产a久久久久久| 国产欧美日本一区视频| 日韩视频免费直播| 欧美日韩国产综合久久| 一本大道久久精品懂色aⅴ| 国产91精品在线观看| 美女脱光内衣内裤视频久久网站| 亚洲一区在线电影| 亚洲欧美中日韩| 国产欧美一区二区在线| 久久亚洲一区二区三区四区| 这里是久久伊人| 欧美精品乱码久久久久久| 色拍拍在线精品视频8848| av成人老司机| 91视频一区二区| 成人精品国产福利| 国产成人精品亚洲午夜麻豆| 国产一区二区三区免费播放| 麻豆成人综合网| 美日韩一区二区|