< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 679         BOOL samePrinter = FALSE;
 680 
 681         // check if given printername is same as the currently saved printer
 682         if (pd.hDevNames != NULL ) {
 683 
 684             DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(pd.hDevNames);
 685             if (devnames != NULL) {
 686                 LPTSTR lpdevnames = (LPTSTR)devnames;
 687                 printName = lpdevnames+devnames->wDeviceOffset;
 688 
 689                 if (!_tcscmp(printName, getName)) {
 690 
 691                     samePrinter = TRUE;
 692                     printName = _tcsdup(lpdevnames+devnames->wDeviceOffset);
 693                     portName = _tcsdup(lpdevnames+devnames->wOutputOffset);
 694 
 695                 }
 696             }
 697             ::GlobalUnlock(pd.hDevNames);
 698         }

 699 
 700         if (!samePrinter) {
 701             LPTSTR foundPrinter = NULL;
 702             LPTSTR foundPort = NULL;
 703             DWORD cbBuf = 0;
 704             VERIFY(AwtPrintControl::FindPrinter(NULL, NULL, &cbBuf,
 705                                                 NULL, NULL));
 706             LPBYTE buffer = new BYTE[cbBuf];
 707 
 708             if (AwtPrintControl::FindPrinter(printerName, buffer, &cbBuf,
 709                                              &foundPrinter, &foundPort) &&
 710                 (foundPrinter != NULL) && (foundPort != NULL)) {
 711 
 712                 printName = _tcsdup(foundPrinter);
 713                 portName = _tcsdup(foundPort);
 714 
 715                 if (!AwtPrintControl::CreateDevModeAndDevNames(&pd,
 716                                                    foundPrinter, foundPort)) {
 717                     delete [] buffer;
 718                     if (printName != NULL) {


   1 /*
   2  * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 679         BOOL samePrinter = FALSE;
 680 
 681         // check if given printername is same as the currently saved printer
 682         if (pd.hDevNames != NULL ) {
 683 
 684             DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(pd.hDevNames);
 685             if (devnames != NULL) {
 686                 LPTSTR lpdevnames = (LPTSTR)devnames;
 687                 printName = lpdevnames+devnames->wDeviceOffset;
 688 
 689                 if (!_tcscmp(printName, getName)) {
 690 
 691                     samePrinter = TRUE;
 692                     printName = _tcsdup(lpdevnames+devnames->wDeviceOffset);
 693                     portName = _tcsdup(lpdevnames+devnames->wOutputOffset);
 694 
 695                 }
 696             }
 697             ::GlobalUnlock(pd.hDevNames);
 698         }
 699         JNU_ReleaseStringPlatformChars(env, printerName, getName);
 700 
 701         if (!samePrinter) {
 702             LPTSTR foundPrinter = NULL;
 703             LPTSTR foundPort = NULL;
 704             DWORD cbBuf = 0;
 705             VERIFY(AwtPrintControl::FindPrinter(NULL, NULL, &cbBuf,
 706                                                 NULL, NULL));
 707             LPBYTE buffer = new BYTE[cbBuf];
 708 
 709             if (AwtPrintControl::FindPrinter(printerName, buffer, &cbBuf,
 710                                              &foundPrinter, &foundPort) &&
 711                 (foundPrinter != NULL) && (foundPort != NULL)) {
 712 
 713                 printName = _tcsdup(foundPrinter);
 714                 portName = _tcsdup(foundPort);
 715 
 716                 if (!AwtPrintControl::CreateDevModeAndDevNames(&pd,
 717                                                    foundPrinter, foundPort)) {
 718                     delete [] buffer;
 719                     if (printName != NULL) {


< prev index next >