Changeset 162 for trunk/Lucide/SOURCE/gui/print.cpp
- Timestamp:
- Nov 20, 2006, 7:50:04 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Lucide/SOURCE/gui/print.cpp
r155 r162 309 309 310 310 char tmpps[ CCHMAXPATH ] = ""; 311 getTmpDir( tmpps ); 312 strcat( tmpps, "TMPLUCID.PS" ); 311 if ( psetup->psToFile ) 312 { 313 strcpy( tmpps, title ); 314 char *pointpos = strrchr( tmpps, '.' ); 315 if ( pointpos != NULL ) { 316 *pointpos = 0; 317 } 318 strcat( tmpps, ".ps" ); 319 320 PFILEDLG fd = new FILEDLG; 321 memset( fd, 0, sizeof( FILEDLG ) ); 322 fd->cbSize = sizeof( FILEDLG ); 323 fd->fl = FDS_CENTER | FDS_SAVEAS_DIALOG; 324 strcpy( fd->szFullFile, tmpps ); 325 WinFileDlg( HWND_DESKTOP, hFrame, fd ); 326 if ( fd->lReturn == DID_OK ) { 327 strcpy( tmpps, fd->szFullFile ); 328 delete fd; 329 } 330 else { 331 delete fd; 332 return true; 333 } 334 } 335 else { 336 getTmpDir( tmpps ); 337 strcat( tmpps, "TMPLUCID.PS" ); 338 } 313 339 314 340 boolean rcexp = doc->exportToPostScript( ev, tmpps, psetup->pgfrom-1, psetup->pgto-1, … … 324 350 } 325 351 326 char *spooling_ps = newstrdupL( PRINT_SPOOLING_POSTSCRIPT ); 327 progressDlg->setText( spooling_ps ); 328 delete spooling_ps; 329 330 // build a devopenstruct for the call to DevOpenDC 331 dos.pszLogAddress = psetup->QueueInfo.pszName; // 1 332 strcpy( achDriverName, psetup->QueueInfo.pszDriverName ); 333 achDriverName[ strcspn( achDriverName, "." ) ] = '\0'; 334 dos.pszDriverName = achDriverName; // 2 335 dos.pdriv = psetup->QueueInfo.pDriverData; // 3 336 dos.pszDataType = "PM_Q_RAW"; // 4 337 dos.pszComment = (PSZ)appName; // 5 338 dos.pszQueueProcName = NULL; // 6 339 snprintf( achQueueProcParams, sizeof( achQueueProcParams ), "COP=%d", psetup->copies ); 340 dos.pszQueueProcParams = achQueueProcParams; // 7 341 342 HDC hdcPrinter = DevOpenDC( lhab, OD_QUEUED, "*", 7L, (PDEVOPENDATA)&dos, NULLHANDLE ); 343 if ( hdcPrinter == DEV_ERROR ) { 352 if ( !psetup->psToFile ) 353 { 354 char *spooling_ps = newstrdupL( PRINT_SPOOLING_POSTSCRIPT ); 355 progressDlg->setText( spooling_ps ); 356 delete spooling_ps; 357 358 // build a devopenstruct for the call to DevOpenDC 359 dos.pszLogAddress = psetup->QueueInfo.pszName; // 1 360 strcpy( achDriverName, psetup->QueueInfo.pszDriverName ); 361 achDriverName[ strcspn( achDriverName, "." ) ] = '\0'; 362 dos.pszDriverName = achDriverName; // 2 363 dos.pdriv = psetup->QueueInfo.pDriverData; // 3 364 dos.pszDataType = "PM_Q_RAW"; // 4 365 dos.pszComment = (PSZ)appName; // 5 366 dos.pszQueueProcName = NULL; // 6 367 snprintf( achQueueProcParams, sizeof( achQueueProcParams ), "COP=%d", psetup->copies ); 368 dos.pszQueueProcParams = achQueueProcParams; // 7 369 370 HDC hdcPrinter = DevOpenDC( lhab, OD_QUEUED, "*", 7L, (PDEVOPENDATA)&dos, NULLHANDLE ); 371 if ( hdcPrinter == DEV_ERROR ) { 372 unlink( tmpps ); 373 return false; 374 } 375 376 // Issue STARTDOC to begin printing 377 LONG rc = DevEscape( hdcPrinter, DEVESC_STARTDOC, strlen(title), (PBYTE)title, NULL, NULL ); 378 if ( rc == DEVESC_ERROR ) { 379 DevCloseDC( hdcPrinter ); 380 unlink( tmpps ); 381 return false; 382 } 383 384 FILE *f = fopen( tmpps, "rb" ); 385 if ( f == NULL ) { 386 DevEscape( hdcPrinter, DEVESC_ABORTDOC, 0L, NULL, NULL, NULL ); 387 DevCloseDC( hdcPrinter ); 388 unlink( tmpps ); 389 return false; 390 } 391 392 bool splerr = false; 393 void *buf = malloc( PS_PRINT_BUF_SIZE ); 394 int rd = 0; 395 while ( ( rc != DEVESC_ERROR ) && ( rd = fread( buf, 1, PS_PRINT_BUF_SIZE, f ) ) != 0 ) 396 { 397 rc = DevEscape( hdcPrinter, DEVESC_RAWDATA, rd, (char *)buf, NULL, NULL ); 398 if ( ( rc == DEVESC_ERROR ) || abortPrinting ) { 399 splerr = true; 400 break; 401 } 402 } 403 free( buf ); 404 fclose( f ); 344 405 unlink( tmpps ); 345 return false; 346 } 347 348 // Issue STARTDOC to begin printing 349 LONG rc = DevEscape( hdcPrinter, DEVESC_STARTDOC, strlen(title), (PBYTE)title, NULL, NULL ); 350 if ( rc == DEVESC_ERROR ) { 406 407 DevEscape( hdcPrinter, splerr ? DEVESC_ABORTDOC : DEVESC_ENDDOC, 408 0L, NULL, NULL, NULL ); 351 409 DevCloseDC( hdcPrinter ); 352 unlink( tmpps ); 353 return false; 354 } 355 356 FILE *f = fopen( tmpps, "rb" ); 357 if ( f == NULL ) { 358 DevEscape( hdcPrinter, DEVESC_ABORTDOC, 0L, NULL, NULL, NULL ); 359 DevCloseDC( hdcPrinter ); 360 unlink( tmpps ); 361 return false; 362 } 363 364 bool splerr = false; 365 void *buf = malloc( PS_PRINT_BUF_SIZE ); 366 int rd = 0; 367 while ( ( rc != DEVESC_ERROR ) && ( rd = fread( buf, 1, PS_PRINT_BUF_SIZE, f ) ) != 0 ) 368 { 369 rc = DevEscape( hdcPrinter, DEVESC_RAWDATA, rd, (char *)buf, NULL, NULL ); 370 if ( ( rc == DEVESC_ERROR ) || abortPrinting ) { 371 splerr = true; 372 break; 373 } 374 } 375 free( buf ); 376 fclose( f ); 377 unlink( tmpps ); 378 379 DevEscape( hdcPrinter, splerr ? DEVESC_ABORTDOC : DEVESC_ENDDOC, 380 0L, NULL, NULL, NULL ); 381 DevCloseDC( hdcPrinter ); 382 383 if ( splerr && !abortPrinting ) { 384 return false; 410 411 if ( splerr && !abortPrinting ) { 412 return false; 413 } 385 414 } 386 415
Note: See TracChangeset
for help on using the changeset viewer.