comparison dwt/printing/Printer.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents af0e7b559478
children 36f5cb12e1a2
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
89 * @return the list of available printers 89 * @return the list of available printers
90 */ 90 */
91 public static PrinterData[] getPrinterList() { 91 public static PrinterData[] getPrinterList() {
92 int length = 1024; 92 int length = 1024;
93 /* Use the character encoding for the default locale */ 93 /* Use the character encoding for the default locale */
94 char[] buf = new char[](length); 94 String buf = new String(length);
95 int n = OS.GetProfileString( TCHARsToStr(profile), null, null, buf, length); 95 int n = OS.GetProfileString( TCHARsToStr(profile), null, null, buf, length);
96 if (n is 0) return null; 96 if (n is 0) return null;
97 char[][] deviceNames = new char[][](5); 97 String[] deviceNames = new String[](5);
98 int nameCount = 0; 98 int nameCount = 0;
99 int index = 0; 99 int index = 0;
100 for (int i = 0; i < n; i++) { 100 for (int i = 0; i < n; i++) {
101 if (buf[i] is 0) { 101 if (buf[i] is 0) {
102 if (nameCount is deviceNames.length) { 102 if (nameCount is deviceNames.length) {
103 char[][] newNames = new char[][](deviceNames.length + 5); 103 String[] newNames = new String[](deviceNames.length + 5);
104 System.arraycopy(deviceNames, 0, newNames, 0, deviceNames.length); 104 System.arraycopy(deviceNames, 0, newNames, 0, deviceNames.length);
105 deviceNames = newNames; 105 deviceNames = newNames;
106 } 106 }
107 deviceNames[nameCount] = buf[index .. i ].dup; 107 deviceNames[nameCount] = buf[index .. i ].dup;
108 nameCount++; 108 nameCount++;
109 index = i + 1; 109 index = i + 1;
110 } 110 }
111 } 111 }
112 PrinterData printerList[] = new PrinterData[nameCount]; 112 PrinterData printerList[] = new PrinterData[nameCount];
113 for (int p = 0; p < nameCount; p++) { 113 for (int p = 0; p < nameCount; p++) {
114 char[] device = deviceNames[p]; 114 String device = deviceNames[p];
115 char[] driver = ""; //$NON-NLS-1$ 115 String driver = ""; //$NON-NLS-1$
116 if (OS.GetProfileString(TCHARsToStr(profile), device, null, buf, length) > 0) { 116 if (OS.GetProfileString(TCHARsToStr(profile), device, null, buf, length) > 0) {
117 int commaIndex = 0; 117 int commaIndex = 0;
118 while (buf[commaIndex] !is ',' && commaIndex < length) commaIndex++; 118 while (buf[commaIndex] !is ',' && commaIndex < length) commaIndex++;
119 if (commaIndex < length) { 119 if (commaIndex < length) {
120 driver = buf[0 .. commaIndex].dup; 120 driver = buf[0 .. commaIndex].dup;
133 * @return the default printer data or null 133 * @return the default printer data or null
134 * 134 *
135 * @since 2.1 135 * @since 2.1
136 */ 136 */
137 public static PrinterData getDefaultPrinterData() { 137 public static PrinterData getDefaultPrinterData() {
138 char[] deviceName = null; 138 String deviceName = null;
139 int length = 1024; 139 int length = 1024;
140 /* Use the character encoding for the default locale */ 140 /* Use the character encoding for the default locale */
141 char[] buf = new char[](length); 141 String buf = new String(length);
142 int n = OS.GetProfileString(TCHARsToStr(appName), TCHARsToStr(keyName), null, buf, length); 142 int n = OS.GetProfileString(TCHARsToStr(appName), TCHARsToStr(keyName), null, buf, length);
143 if (n is 0) return null; 143 if (n is 0) return null;
144 int commaIndex = 0; 144 int commaIndex = 0;
145 while(buf[commaIndex] !is ',' && commaIndex < length) commaIndex++; 145 while(buf[commaIndex] !is ',' && commaIndex < length) commaIndex++;
146 if (commaIndex < length) { 146 if (commaIndex < length) {
147 deviceName = buf[0 .. commaIndex].dup; 147 deviceName = buf[0 .. commaIndex].dup;
148 } 148 }
149 char[] driver = ""; //$NON-NLS-1$ 149 String driver = ""; //$NON-NLS-1$
150 if (OS.GetProfileString(TCHARsToStr(profile), deviceName, null, buf, length) > 0) { 150 if (OS.GetProfileString(TCHARsToStr(profile), deviceName, null, buf, length) > 0) {
151 commaIndex = 0; 151 commaIndex = 0;
152 while (buf[commaIndex] !is ',' && commaIndex < length) commaIndex++; 152 while (buf[commaIndex] !is ',' && commaIndex < length) commaIndex++;
153 if (commaIndex < length) { 153 if (commaIndex < length) {
154 driver = buf[0 .. commaIndex].dup; 154 driver = buf[0 .. commaIndex].dup;
296 * 296 *
297 * @see #startPage 297 * @see #startPage
298 * @see #endPage 298 * @see #endPage
299 * @see #endJob 299 * @see #endJob
300 */ 300 */
301 public bool startJob(char[] jobName) { 301 public bool startJob(String jobName) {
302 checkDevice(); 302 checkDevice();
303 DOCINFO di; 303 DOCINFO di;
304 di.cbSize = DOCINFO.sizeof; 304 di.cbSize = DOCINFO.sizeof;
305 auto hHeap = OS.GetProcessHeap(); 305 auto hHeap = OS.GetProcessHeap();
306 TCHAR* lpszDocName; 306 TCHAR* lpszDocName;