Ignore:
Timestamp:
Jan 21, 2007, 5:34:28 PM (14 years ago)
Author:
Eugene Romanenko
Message:

Odd/Even? printing for 'As Image' printing, pdf plugin: fix document title

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/gui/print.cpp

    r179 r183  
    125125}
    126126
     127static bool isPrintPageNum( PrintOddEven oddeven, long page )
     128{
     129    if ( oddeven == OEOdd ) {
     130        return ( ( page % 2 ) != 0 );
     131    }
     132    else if ( oddeven == OEEven ) {
     133        return ( ( page % 2 ) == 0 );
     134    }
     135    return true;
     136}
     137
     138static long countPagesToPrint( PrintOddEven oddeven, long pgfrom, long pgto )
     139{
     140    long r = 0;
     141    for ( long i = pgfrom; i <= pgto; i++ ) {
     142        if ( isPrintPageNum( oddeven, i ) ) {
     143            r++;
     144        }
     145    }
     146    return r;
     147}
     148
    127149bool LucidePrinting::doPmPrint( HAB lhab )
    128150{
     
    164186    DevEscape( hdcPrinter, DEVESC_STARTDOC, strlen(title), (PBYTE)title, NULL, NULL );
    165187
    166 
    167     long totalpages = abs( psetup->pgto - psetup->pgfrom ) + 1;
     188    long pgfrom = psetup->pgfrom;
     189    long pgto = psetup->pgto;
     190    if ( pgfrom > pgto ) {
     191        long tmp = pgfrom;
     192        pgfrom = pgto;
     193        pgto = tmp;
     194    }
     195
     196    long pagestoprint = countPagesToPrint( psetup->oddeven, pgfrom, pgto );
    168197    long pg = psetup->pgfrom;
    169     for ( long i = 0; i < totalpages; i++ )
     198    for ( long i = pgfrom, j = 1; i <= pgto; i++ )
    170199    {
    171         char *fmt = newstrdupL( PRINT_PRINTING_PAGE_OF );
    172         char *buf = new char[ 255 ];
    173         snprintf( buf, 255, fmt, pg, i + 1, totalpages );
    174         progressDlg->setText( buf );
    175         delete fmt;
    176         delete buf;
    177 
    178         printPagePm( pg - 1, hpsPrinter, &curForm );
    179 
    180         if ( pg != psetup->pgto ) {
    181             DevEscape( hdcPrinter, DEVESC_NEWFRAME, 0L, NULL, NULL, NULL );
     200        if ( isPrintPageNum( psetup->oddeven, pg ) )
     201        {
     202            char *fmt = newstrdupL( PRINT_PRINTING_PAGE_OF );
     203            char *buf = new char[ 255 ];
     204            snprintf( buf, 255, fmt, pg, j++, pagestoprint );
     205            progressDlg->setText( buf );
     206            delete fmt;
     207            delete buf;
     208
     209            printPagePm( pg - 1, hpsPrinter, &curForm );
     210
     211            if ( pg != psetup->pgto ) {
     212                DevEscape( hdcPrinter, DEVESC_NEWFRAME, 0L, NULL, NULL, NULL );
     213            }
    182214        }
    183215
Note: See TracChangeset for help on using the changeset viewer.