19f62ea84SAndrew Rist /**************************************************************
2*b4953498Smseidel *
39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
59f62ea84SAndrew Rist * distributed with this work for additional information
69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10*b4953498Smseidel *
119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*b4953498Smseidel *
139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist * software distributed under the License is distributed on an
159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
179f62ea84SAndrew Rist * specific language governing permissions and limitations
189f62ea84SAndrew Rist * under the License.
19*b4953498Smseidel *
209f62ea84SAndrew Rist *************************************************************/
219f62ea84SAndrew Rist
229f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <string.h>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <osl/module.h>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <tools/urlobj.hxx>
32cdf0e10cSrcweir #include <tools/svwin.h>
33cdf0e10cSrcweir #ifdef __MINGW32__
34cdf0e10cSrcweir #include <excpt.h>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <win/wincomp.hxx>
38cdf0e10cSrcweir #include <win/saldata.hxx>
39cdf0e10cSrcweir #include <win/salinst.h>
40cdf0e10cSrcweir #include <win/salgdi.h>
41cdf0e10cSrcweir #include <win/salframe.h>
42cdf0e10cSrcweir #include <win/salprn.h>
43cdf0e10cSrcweir
44cdf0e10cSrcweir #include <salptype.hxx>
45cdf0e10cSrcweir #include <print.h>
46cdf0e10cSrcweir #include <jobset.h>
47cdf0e10cSrcweir
48cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
49cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
50cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
51cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
52cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
54cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
55cdf0e10cSrcweir
56cdf0e10cSrcweir #include <malloc.h>
57cdf0e10cSrcweir
58cdf0e10cSrcweir #ifdef __MINGW32__
59cdf0e10cSrcweir #define CATCH_DRIVER_EX_BEGIN \
60cdf0e10cSrcweir jmp_buf jmpbuf; \
61cdf0e10cSrcweir __SEHandler han; \
62cdf0e10cSrcweir if (__builtin_setjmp(jmpbuf) == 0) \
63cdf0e10cSrcweir { \
64cdf0e10cSrcweir han.Set(jmpbuf, NULL, (__SEHandler::PF)EXCEPTION_EXECUTE_HANDLER)
65*b4953498Smseidel
66cdf0e10cSrcweir #define CATCH_DRIVER_EX_END(mes, p) \
67cdf0e10cSrcweir } \
68cdf0e10cSrcweir han.Reset()
69cdf0e10cSrcweir #define CATCH_DRIVER_EX_END_2(mes) \
70cdf0e10cSrcweir } \
71cdf0e10cSrcweir han.Reset()
72cdf0e10cSrcweir #else
73cdf0e10cSrcweir #define CATCH_DRIVER_EX_BEGIN \
74cdf0e10cSrcweir __try \
75cdf0e10cSrcweir {
76cdf0e10cSrcweir #define CATCH_DRIVER_EX_END(mes, p) \
77cdf0e10cSrcweir } \
78cdf0e10cSrcweir __except(WinSalInstance::WorkaroundExceptionHandlingInUSER32Lib(GetExceptionCode(), GetExceptionInformation()))\
79cdf0e10cSrcweir { \
80cdf0e10cSrcweir DBG_ERROR( mes ); \
81cdf0e10cSrcweir p->markInvalid(); \
82cdf0e10cSrcweir }
83cdf0e10cSrcweir #define CATCH_DRIVER_EX_END_2(mes) \
84cdf0e10cSrcweir } \
85cdf0e10cSrcweir __except(WinSalInstance::WorkaroundExceptionHandlingInUSER32Lib(GetExceptionCode(), GetExceptionInformation()))\
86cdf0e10cSrcweir { \
87cdf0e10cSrcweir DBG_ERROR( mes ); \
88cdf0e10cSrcweir }
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir
91cdf0e10cSrcweir
92cdf0e10cSrcweir using namespace com::sun::star;
93cdf0e10cSrcweir using namespace com::sun::star::uno;
94cdf0e10cSrcweir using namespace com::sun::star::lang;
95cdf0e10cSrcweir using namespace com::sun::star::ui::dialogs;
96cdf0e10cSrcweir using namespace rtl;
97cdf0e10cSrcweir
98cdf0e10cSrcweir // =======================================================================
99cdf0e10cSrcweir
100cdf0e10cSrcweir static char aImplWindows[] = "windows";
101cdf0e10cSrcweir static char aImplDevices[] = "devices";
102cdf0e10cSrcweir static char aImplDevice[] = "device";
103cdf0e10cSrcweir
SAL_DEVMODE_A(const ImplJobSetup * pSetupData)104cdf0e10cSrcweir static LPDEVMODEA SAL_DEVMODE_A( const ImplJobSetup* pSetupData )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir LPDEVMODEA pRet = NULL;
107cdf0e10cSrcweir SalDriverData* pDrv = (SalDriverData*)pSetupData->mpDriverData;
108cdf0e10cSrcweir if( pDrv->mnVersion == SAL_DRIVERDATA_VERSION_A &&
109cdf0e10cSrcweir pSetupData->mnDriverDataLen >= sizeof(DEVMODEA)+sizeof(SalDriverData)-1
110cdf0e10cSrcweir )
111cdf0e10cSrcweir pRet = ((LPDEVMODEA)((pSetupData->mpDriverData) + (pDrv->mnDriverOffset)));
112cdf0e10cSrcweir return pRet;
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
SAL_DEVMODE_W(const ImplJobSetup * pSetupData)115cdf0e10cSrcweir static LPDEVMODEW SAL_DEVMODE_W( const ImplJobSetup* pSetupData )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir LPDEVMODEW pRet = NULL;
118cdf0e10cSrcweir SalDriverData* pDrv = (SalDriverData*)pSetupData->mpDriverData;
119cdf0e10cSrcweir if( pDrv->mnVersion == SAL_DRIVERDATA_VERSION_W &&
120cdf0e10cSrcweir pSetupData->mnDriverDataLen >= sizeof(DEVMODEW)+sizeof(SalDriverData)-1
121cdf0e10cSrcweir )
122cdf0e10cSrcweir pRet = ((LPDEVMODEW)((pSetupData->mpDriverData) + (pDrv->mnDriverOffset)));
123cdf0e10cSrcweir return pRet;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir // =======================================================================
127cdf0e10cSrcweir
ImplWinQueueStatusToSal(DWORD nWinStatus)128cdf0e10cSrcweir static sal_uLong ImplWinQueueStatusToSal( DWORD nWinStatus )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir sal_uLong nStatus = 0;
131cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PAUSED )
132cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PAUSED;
133cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_ERROR )
134cdf0e10cSrcweir nStatus |= QUEUE_STATUS_ERROR;
135cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PENDING_DELETION )
136cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PENDING_DELETION;
137cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PAPER_JAM )
138cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PAPER_JAM;
139cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PAPER_OUT )
140cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PAPER_OUT;
141cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_MANUAL_FEED )
142cdf0e10cSrcweir nStatus |= QUEUE_STATUS_MANUAL_FEED;
143cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PAPER_PROBLEM )
144cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PAPER_PROBLEM;
145cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_OFFLINE )
146cdf0e10cSrcweir nStatus |= QUEUE_STATUS_OFFLINE;
147cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_IO_ACTIVE )
148cdf0e10cSrcweir nStatus |= QUEUE_STATUS_IO_ACTIVE;
149cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_BUSY )
150cdf0e10cSrcweir nStatus |= QUEUE_STATUS_BUSY;
151cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PRINTING )
152cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PRINTING;
153cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_OUTPUT_BIN_FULL )
154cdf0e10cSrcweir nStatus |= QUEUE_STATUS_OUTPUT_BIN_FULL;
155cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_WAITING )
156cdf0e10cSrcweir nStatus |= QUEUE_STATUS_WAITING;
157cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PROCESSING )
158cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PROCESSING;
159cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_INITIALIZING )
160cdf0e10cSrcweir nStatus |= QUEUE_STATUS_INITIALIZING;
161cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_WARMING_UP )
162cdf0e10cSrcweir nStatus |= QUEUE_STATUS_WARMING_UP;
163cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_TONER_LOW )
164cdf0e10cSrcweir nStatus |= QUEUE_STATUS_TONER_LOW;
165cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_NO_TONER )
166cdf0e10cSrcweir nStatus |= QUEUE_STATUS_NO_TONER;
167cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_PAGE_PUNT )
168cdf0e10cSrcweir nStatus |= QUEUE_STATUS_PAGE_PUNT;
169cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_USER_INTERVENTION )
170cdf0e10cSrcweir nStatus |= QUEUE_STATUS_USER_INTERVENTION;
171cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_OUT_OF_MEMORY )
172cdf0e10cSrcweir nStatus |= QUEUE_STATUS_OUT_OF_MEMORY;
173cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_DOOR_OPEN )
174cdf0e10cSrcweir nStatus |= QUEUE_STATUS_DOOR_OPEN;
175cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_SERVER_UNKNOWN )
176cdf0e10cSrcweir nStatus |= QUEUE_STATUS_SERVER_UNKNOWN;
177cdf0e10cSrcweir if ( nWinStatus & PRINTER_STATUS_POWER_SAVE )
178cdf0e10cSrcweir nStatus |= QUEUE_STATUS_POWER_SAVE;
179cdf0e10cSrcweir if ( !nStatus && !(nWinStatus & PRINTER_STATUS_NOT_AVAILABLE) )
180cdf0e10cSrcweir nStatus |= QUEUE_STATUS_READY;
181cdf0e10cSrcweir return nStatus;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir // -----------------------------------------------------------------------
185cdf0e10cSrcweir
getPrinterQueueInfoOldStyle(ImplPrnQueueList * pList)186cdf0e10cSrcweir static void getPrinterQueueInfoOldStyle( ImplPrnQueueList* pList )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir DWORD i;
189cdf0e10cSrcweir DWORD n;
190cdf0e10cSrcweir DWORD nBytes = 0;
191cdf0e10cSrcweir DWORD nInfoPrn2;
192cdf0e10cSrcweir sal_Bool bFound = FALSE;
193cdf0e10cSrcweir PRINTER_INFO_2* pWinInfo2 = NULL;
194cdf0e10cSrcweir PRINTER_INFO_2* pGetInfo2;
195cdf0e10cSrcweir EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &nBytes, &nInfoPrn2 );
196cdf0e10cSrcweir if ( nBytes )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir pWinInfo2 = (PRINTER_INFO_2*) rtl_allocateMemory( nBytes );
199cdf0e10cSrcweir if ( EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pWinInfo2, nBytes, &nBytes, &nInfoPrn2 ) )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir pGetInfo2 = pWinInfo2;
202cdf0e10cSrcweir for ( i = 0; i < nInfoPrn2; i++ )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
205cdf0e10cSrcweir pInfo->maPrinterName = ImplSalGetUniString( pGetInfo2->pPrinterName );
206cdf0e10cSrcweir pInfo->maDriver = ImplSalGetUniString( pGetInfo2->pDriverName );
207cdf0e10cSrcweir XubString aPortName;
208cdf0e10cSrcweir if ( pGetInfo2->pPortName )
209cdf0e10cSrcweir aPortName = ImplSalGetUniString( pGetInfo2->pPortName );
210cdf0e10cSrcweir // pLocation can be 0 (the Windows docu doesn't describe this)
211cdf0e10cSrcweir if ( pGetInfo2->pLocation && strlen( pGetInfo2->pLocation ) )
212cdf0e10cSrcweir pInfo->maLocation = ImplSalGetUniString( pGetInfo2->pLocation );
213cdf0e10cSrcweir else
214cdf0e10cSrcweir pInfo->maLocation = aPortName;
215cdf0e10cSrcweir // pComment can be 0 (the Windows docu doesn't describe this)
216cdf0e10cSrcweir if ( pGetInfo2->pComment )
217cdf0e10cSrcweir pInfo->maComment = ImplSalGetUniString( pGetInfo2->pComment );
218cdf0e10cSrcweir pInfo->mnStatus = ImplWinQueueStatusToSal( pGetInfo2->Status );
219cdf0e10cSrcweir pInfo->mnJobs = pGetInfo2->cJobs;
220cdf0e10cSrcweir pInfo->mpSysData = new XubString( aPortName );
221cdf0e10cSrcweir pList->Add( pInfo );
222cdf0e10cSrcweir pGetInfo2++;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir
225cdf0e10cSrcweir bFound = TRUE;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir // read printers from win.ini
230cdf0e10cSrcweir // TODO: MSDN: GetProfileString() should not be called from server
231cdf0e10cSrcweir // code because it is just there for WIN16 compatibility
232cdf0e10cSrcweir UINT nSize = 4096;
233cdf0e10cSrcweir char* pBuf = new char[nSize];
234cdf0e10cSrcweir UINT nRead = GetProfileStringA( aImplDevices, NULL, "", pBuf, nSize );
235cdf0e10cSrcweir while ( nRead >= nSize-2 )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir nSize += 2048;
238cdf0e10cSrcweir delete []pBuf;
239cdf0e10cSrcweir pBuf = new char[nSize];
240cdf0e10cSrcweir nRead = GetProfileStringA( aImplDevices, NULL, "", pBuf, nSize );
241cdf0e10cSrcweir }
242cdf0e10cSrcweir
243cdf0e10cSrcweir // extract printer names from buffer and fill list
244cdf0e10cSrcweir char* pName = pBuf;
245cdf0e10cSrcweir while ( *pName )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir char* pPortName;
248cdf0e10cSrcweir char* pTmp;
249cdf0e10cSrcweir char aPortBuf[256];
250cdf0e10cSrcweir GetProfileStringA( aImplDevices, pName, "", aPortBuf, sizeof( aPortBuf ) );
251cdf0e10cSrcweir
252cdf0e10cSrcweir pPortName = aPortBuf;
253cdf0e10cSrcweir
254cdf0e10cSrcweir // create name
255cdf0e10cSrcweir xub_StrLen nNameLen = sal::static_int_cast<xub_StrLen>(strlen( pName ));
256cdf0e10cSrcweir XubString aName( ImplSalGetUniString( pName, nNameLen ) );
257cdf0e10cSrcweir
258cdf0e10cSrcweir // get driver name
259cdf0e10cSrcweir pTmp = pPortName;
260cdf0e10cSrcweir while ( *pTmp != ',' )
261cdf0e10cSrcweir pTmp++;
262cdf0e10cSrcweir XubString aDriver( ImplSalGetUniString( pPortName, (sal_uInt16)(pTmp-pPortName) ) );
263cdf0e10cSrcweir pPortName = pTmp;
264cdf0e10cSrcweir
265cdf0e10cSrcweir // get port names
266cdf0e10cSrcweir do
267cdf0e10cSrcweir {
268cdf0e10cSrcweir pPortName++;
269cdf0e10cSrcweir pTmp = pPortName;
270cdf0e10cSrcweir while ( *pTmp && (*pTmp != ',') )
271cdf0e10cSrcweir pTmp++;
272cdf0e10cSrcweir
273cdf0e10cSrcweir String aPortName( ImplSalGetUniString( pPortName, (sal_uInt16)(pTmp-pPortName) ) );
274cdf0e10cSrcweir
275cdf0e10cSrcweir // create new entry
276cdf0e10cSrcweir // look up if printer was already found in first loop
277cdf0e10cSrcweir sal_Bool bAdd = TRUE;
278cdf0e10cSrcweir if ( pWinInfo2 )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir pGetInfo2 = pWinInfo2;
281cdf0e10cSrcweir for ( n = 0; n < nInfoPrn2; n++ )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir if ( aName.EqualsIgnoreCaseAscii( pGetInfo2->pPrinterName ) )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir bAdd = FALSE;
286cdf0e10cSrcweir break;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir pGetInfo2++;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir }
291cdf0e10cSrcweir // if it's a new printer, add it
292cdf0e10cSrcweir if ( bAdd )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
295cdf0e10cSrcweir pInfo->maPrinterName = aName;
296cdf0e10cSrcweir pInfo->maDriver = aDriver;
297cdf0e10cSrcweir pInfo->maLocation = aPortName;
298cdf0e10cSrcweir pInfo->mnStatus = 0;
299cdf0e10cSrcweir pInfo->mnJobs = QUEUE_JOBS_DONTKNOW;
300cdf0e10cSrcweir pInfo->mpSysData = new XubString( aPortName );
301cdf0e10cSrcweir pList->Add( pInfo );
302cdf0e10cSrcweir }
303cdf0e10cSrcweir }
304cdf0e10cSrcweir while ( *pTmp == ',' );
305cdf0e10cSrcweir
306cdf0e10cSrcweir pName += nNameLen + 1;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir
309cdf0e10cSrcweir delete []pBuf;
310cdf0e10cSrcweir rtl_freeMemory( pWinInfo2 );
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
GetPrinterQueueInfo(ImplPrnQueueList * pList)313cdf0e10cSrcweir void WinSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir if( ! aSalShlData.mbWPrinter )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir getPrinterQueueInfoOldStyle( pList );
318cdf0e10cSrcweir return;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir DWORD i;
321cdf0e10cSrcweir DWORD nBytes = 0;
322cdf0e10cSrcweir DWORD nInfoPrn4 = 0;
323cdf0e10cSrcweir PRINTER_INFO_4W* pWinInfo4 = NULL;
324cdf0e10cSrcweir EnumPrintersW( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, NULL, 0, &nBytes, &nInfoPrn4 );
325cdf0e10cSrcweir if ( nBytes )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir pWinInfo4 = (PRINTER_INFO_4W*) rtl_allocateMemory( nBytes );
328cdf0e10cSrcweir if ( EnumPrintersW( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, (LPBYTE)pWinInfo4, nBytes, &nBytes, &nInfoPrn4 ) )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir for ( i = 0; i < nInfoPrn4; i++ )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
333cdf0e10cSrcweir pInfo->maPrinterName = UniString( reinterpret_cast< const sal_Unicode* >(pWinInfo4[i].pPrinterName) );
334cdf0e10cSrcweir pInfo->mnStatus = 0;
335cdf0e10cSrcweir pInfo->mnJobs = 0;
336cdf0e10cSrcweir pInfo->mpSysData = NULL;
337cdf0e10cSrcweir pList->Add( pInfo );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir }
340cdf0e10cSrcweir rtl_freeMemory( pWinInfo4 );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir }
343cdf0e10cSrcweir
344cdf0e10cSrcweir // -----------------------------------------------------------------------
345cdf0e10cSrcweir
getPrinterQueueStateOldStyle(SalPrinterQueueInfo * pInfo)346cdf0e10cSrcweir static void getPrinterQueueStateOldStyle( SalPrinterQueueInfo* pInfo )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir DWORD nBytes = 0;
349cdf0e10cSrcweir DWORD nInfoRet;
350cdf0e10cSrcweir PRINTER_INFO_2* pWinInfo2;
351cdf0e10cSrcweir EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &nBytes, &nInfoRet );
352cdf0e10cSrcweir if ( nBytes )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir pWinInfo2 = (PRINTER_INFO_2*) rtl_allocateMemory( nBytes );
355cdf0e10cSrcweir if ( EnumPrintersA( PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pWinInfo2, nBytes, &nBytes, &nInfoRet ) )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir PRINTER_INFO_2* pGetInfo2 = pWinInfo2;
358cdf0e10cSrcweir for ( DWORD i = 0; i < nInfoRet; i++ )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir if ( pInfo->maPrinterName.EqualsAscii( pGetInfo2->pPrinterName ) &&
361cdf0e10cSrcweir ( pInfo->maDriver.Len() == 0 ||
362cdf0e10cSrcweir pInfo->maDriver.EqualsAscii( pGetInfo2->pDriverName ) )
363cdf0e10cSrcweir )
364cdf0e10cSrcweir {
365cdf0e10cSrcweir XubString aPortName;
366cdf0e10cSrcweir if ( pGetInfo2->pPortName )
367cdf0e10cSrcweir aPortName = ImplSalGetUniString( pGetInfo2->pPortName );
368cdf0e10cSrcweir // pLocation can be 0 (the Windows docu doesn't describe this)
369cdf0e10cSrcweir if ( pGetInfo2->pLocation && strlen( pGetInfo2->pLocation ) )
370cdf0e10cSrcweir pInfo->maLocation = ImplSalGetUniString( pGetInfo2->pLocation );
371cdf0e10cSrcweir else
372cdf0e10cSrcweir pInfo->maLocation = aPortName;
373cdf0e10cSrcweir // pComment can be 0 (the Windows docu doesn't describe this)
374cdf0e10cSrcweir if ( pGetInfo2->pComment )
375cdf0e10cSrcweir pInfo->maComment = ImplSalGetUniString( pGetInfo2->pComment );
376cdf0e10cSrcweir pInfo->mnStatus = ImplWinQueueStatusToSal( pGetInfo2->Status );
377cdf0e10cSrcweir pInfo->mnJobs = pGetInfo2->cJobs;
378cdf0e10cSrcweir if( ! pInfo->mpSysData )
379cdf0e10cSrcweir pInfo->mpSysData = new XubString( aPortName );
380cdf0e10cSrcweir break;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir pGetInfo2++;
384cdf0e10cSrcweir }
385cdf0e10cSrcweir }
386cdf0e10cSrcweir
387cdf0e10cSrcweir rtl_freeMemory( pWinInfo2 );
388cdf0e10cSrcweir }
389cdf0e10cSrcweir }
390cdf0e10cSrcweir
GetPrinterQueueState(SalPrinterQueueInfo * pInfo)391cdf0e10cSrcweir void WinSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir if( ! aSalShlData.mbWPrinter )
394cdf0e10cSrcweir {
395cdf0e10cSrcweir getPrinterQueueStateOldStyle( pInfo );
396cdf0e10cSrcweir return;
397cdf0e10cSrcweir }
398*b4953498Smseidel
399cdf0e10cSrcweir HANDLE hPrinter = 0;
400cdf0e10cSrcweir LPWSTR pPrnName = reinterpret_cast<LPWSTR>(const_cast<sal_Unicode*>(pInfo->maPrinterName.GetBuffer()));
401cdf0e10cSrcweir if( OpenPrinterW( pPrnName, &hPrinter, NULL ) )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir DWORD nBytes = 0;
404cdf0e10cSrcweir GetPrinterW( hPrinter, 2, NULL, 0, &nBytes );
405cdf0e10cSrcweir if( nBytes )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir PRINTER_INFO_2W* pWinInfo2 = (PRINTER_INFO_2W*)rtl_allocateMemory(nBytes);
408cdf0e10cSrcweir if( GetPrinterW( hPrinter, 2, (LPBYTE)pWinInfo2, nBytes, &nBytes ) )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir if( pWinInfo2->pDriverName )
411cdf0e10cSrcweir pInfo->maDriver = String( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pDriverName) );
412cdf0e10cSrcweir XubString aPortName;
413cdf0e10cSrcweir if ( pWinInfo2->pPortName )
414cdf0e10cSrcweir aPortName = String( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pPortName) );
415cdf0e10cSrcweir // pLocation can be 0 (the Windows docu doesn't describe this)
416cdf0e10cSrcweir if ( pWinInfo2->pLocation && *pWinInfo2->pLocation )
417cdf0e10cSrcweir pInfo->maLocation = String( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pLocation) );
418cdf0e10cSrcweir else
419cdf0e10cSrcweir pInfo->maLocation = aPortName;
420cdf0e10cSrcweir // pComment can be 0 (the Windows docu doesn't describe this)
421cdf0e10cSrcweir if ( pWinInfo2->pComment )
422cdf0e10cSrcweir pInfo->maComment = String( reinterpret_cast< const sal_Unicode* >(pWinInfo2->pComment) );
423cdf0e10cSrcweir pInfo->mnStatus = ImplWinQueueStatusToSal( pWinInfo2->Status );
424cdf0e10cSrcweir pInfo->mnJobs = pWinInfo2->cJobs;
425cdf0e10cSrcweir if( ! pInfo->mpSysData )
426cdf0e10cSrcweir pInfo->mpSysData = new XubString( aPortName );
427cdf0e10cSrcweir }
428cdf0e10cSrcweir rtl_freeMemory(pWinInfo2);
429cdf0e10cSrcweir }
430cdf0e10cSrcweir ClosePrinter( hPrinter );
431cdf0e10cSrcweir }
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir // -----------------------------------------------------------------------
435cdf0e10cSrcweir
DeletePrinterQueueInfo(SalPrinterQueueInfo * pInfo)436cdf0e10cSrcweir void WinSalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir delete (String*)(pInfo->mpSysData);
439cdf0e10cSrcweir delete pInfo;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir // -----------------------------------------------------------------------
GetDefaultPrinter()443cdf0e10cSrcweir XubString WinSalInstance::GetDefaultPrinter()
444cdf0e10cSrcweir {
445cdf0e10cSrcweir static bool bGetDefPrtAPI = true;
446cdf0e10cSrcweir static sal_Bool(WINAPI*pGetDefaultPrinter)(LPWSTR,LPDWORD) = NULL;
447cdf0e10cSrcweir // try to use GetDefaultPrinter API (not available prior to W2000)
448cdf0e10cSrcweir if( bGetDefPrtAPI )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir bGetDefPrtAPI = false;
451cdf0e10cSrcweir // check for W2k and XP
452cdf0e10cSrcweir if( aSalShlData.maVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && aSalShlData.maVersionInfo.dwMajorVersion >= 5 )
453cdf0e10cSrcweir {
454aa150a94SHerbert Dürr oslModule pLib = osl_loadAsciiModule( "winspool.drv", SAL_LOADMODULE_DEFAULT );
455cdf0e10cSrcweir oslGenericFunction pFunc = NULL;
456cdf0e10cSrcweir if( pLib )
457aa150a94SHerbert Dürr pFunc = osl_getAsciiFunctionSymbol( pLib, "GetDefaultPrinterW" );
458cdf0e10cSrcweir
459cdf0e10cSrcweir pGetDefaultPrinter = (sal_Bool(WINAPI*)(LPWSTR,LPDWORD)) pFunc;
460cdf0e10cSrcweir }
461cdf0e10cSrcweir }
462cdf0e10cSrcweir if( pGetDefaultPrinter )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir DWORD nChars = 0;
465cdf0e10cSrcweir pGetDefaultPrinter( NULL, &nChars );
466cdf0e10cSrcweir if( nChars )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir LPWSTR pStr = (LPWSTR)rtl_allocateMemory(nChars*sizeof(WCHAR));
469cdf0e10cSrcweir XubString aDefPrt;
470cdf0e10cSrcweir if( pGetDefaultPrinter( pStr, &nChars ) )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir aDefPrt = reinterpret_cast<sal_Unicode* >(pStr);
473cdf0e10cSrcweir }
474cdf0e10cSrcweir rtl_freeMemory( pStr );
475cdf0e10cSrcweir if( aDefPrt.Len() )
476cdf0e10cSrcweir return aDefPrt;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
480cdf0e10cSrcweir // get default printer from win.ini
481cdf0e10cSrcweir char szBuffer[256];
482cdf0e10cSrcweir GetProfileStringA( aImplWindows, aImplDevice, "", szBuffer, sizeof( szBuffer ) );
483cdf0e10cSrcweir if ( szBuffer[0] )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir // Printername suchen
486cdf0e10cSrcweir char* pBuf = szBuffer;
487cdf0e10cSrcweir char* pTmp = pBuf;
488cdf0e10cSrcweir while ( *pTmp && (*pTmp != ',') )
489cdf0e10cSrcweir pTmp++;
490cdf0e10cSrcweir return ImplSalGetUniString( pBuf, (xub_StrLen)(pTmp-pBuf) );
491cdf0e10cSrcweir }
492cdf0e10cSrcweir else
493cdf0e10cSrcweir return XubString();
494cdf0e10cSrcweir }
495cdf0e10cSrcweir
496cdf0e10cSrcweir // =======================================================================
497cdf0e10cSrcweir
ImplDeviceCaps(WinSalInfoPrinter * pPrinter,WORD nCaps,BYTE * pOutput,const ImplJobSetup * pSetupData)498cdf0e10cSrcweir static DWORD ImplDeviceCaps( WinSalInfoPrinter* pPrinter, WORD nCaps,
499cdf0e10cSrcweir BYTE* pOutput, const ImplJobSetup* pSetupData )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir DEVMODEW* pDevMode;
504cdf0e10cSrcweir if ( !pSetupData || !pSetupData->mpDriverData )
505cdf0e10cSrcweir pDevMode = NULL;
506cdf0e10cSrcweir else
507cdf0e10cSrcweir pDevMode = SAL_DEVMODE_W( pSetupData );
508*b4953498Smseidel
509cdf0e10cSrcweir return DeviceCapabilitiesW( reinterpret_cast<LPCWSTR>(pPrinter->maDeviceName.GetBuffer()),
510cdf0e10cSrcweir reinterpret_cast<LPCWSTR>(pPrinter->maPortName.GetBuffer()),
511cdf0e10cSrcweir nCaps, (LPWSTR)pOutput, pDevMode );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir else
514cdf0e10cSrcweir {
515cdf0e10cSrcweir DEVMODEA* pDevMode;
516cdf0e10cSrcweir if ( !pSetupData || !pSetupData->mpDriverData )
517cdf0e10cSrcweir pDevMode = NULL;
518cdf0e10cSrcweir else
519cdf0e10cSrcweir pDevMode = SAL_DEVMODE_A( pSetupData );
520*b4953498Smseidel
521cdf0e10cSrcweir return DeviceCapabilitiesA( ImplSalGetWinAnsiString( pPrinter->maDeviceName, TRUE ).GetBuffer(),
522cdf0e10cSrcweir ImplSalGetWinAnsiString( pPrinter->maPortName, TRUE ).GetBuffer(),
523cdf0e10cSrcweir nCaps, (LPSTR)pOutput, pDevMode );
524cdf0e10cSrcweir }
525cdf0e10cSrcweir }
526cdf0e10cSrcweir
527cdf0e10cSrcweir // -----------------------------------------------------------------------
528cdf0e10cSrcweir
ImplTestSalJobSetup(WinSalInfoPrinter * pPrinter,ImplJobSetup * pSetupData,sal_Bool bDelete)529cdf0e10cSrcweir static sal_Bool ImplTestSalJobSetup( WinSalInfoPrinter* pPrinter,
530cdf0e10cSrcweir ImplJobSetup* pSetupData, sal_Bool bDelete )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir if ( pSetupData && pSetupData->mpDriverData )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir // signature and size must fit to avoid using
535cdf0e10cSrcweir // JobSetups from a wrong system
536cdf0e10cSrcweir
537cdf0e10cSrcweir // initialize versions from jobsetup
538cdf0e10cSrcweir // those will be overwritten with driver's version
539cdf0e10cSrcweir DEVMODEA* pDevModeA = NULL;
540cdf0e10cSrcweir DEVMODEW* pDevModeW = NULL;
541cdf0e10cSrcweir LONG dmSpecVersion = -1;
542cdf0e10cSrcweir LONG dmDriverVersion = -1;
543cdf0e10cSrcweir SalDriverData* pSalDriverData = (SalDriverData*)pSetupData->mpDriverData;
544cdf0e10cSrcweir BYTE* pDriverData = ((BYTE*)pSalDriverData) + pSalDriverData->mnDriverOffset;
545cdf0e10cSrcweir if( pSalDriverData->mnVersion == SAL_DRIVERDATA_VERSION_W )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
548cdf0e10cSrcweir pDevModeW = (DEVMODEW*)pDriverData;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir else if( pSalDriverData->mnVersion == SAL_DRIVERDATA_VERSION_A )
551cdf0e10cSrcweir {
552cdf0e10cSrcweir if( ! aSalShlData.mbWPrinter )
553cdf0e10cSrcweir pDevModeA = (DEVMODEA*)pDriverData;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
556cdf0e10cSrcweir long nSysJobSize = -1;
557cdf0e10cSrcweir if( pPrinter && ( pDevModeA || pDevModeW ) )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir // just too many driver crashes in that area -> check the dmSpecVersion and dmDriverVersion fields always !!!
560cdf0e10cSrcweir // this prevents using the jobsetup between different Windows versions (eg from XP to 9x) but we
561cdf0e10cSrcweir // can avoid potential driver crashes as their jobsetups are often not compatible
562cdf0e10cSrcweir // #110800#, #111151#, #112381#, #i16580#, #i14173# and perhaps #112375#
563cdf0e10cSrcweir ByteString aPrinterNameA= ImplSalGetWinAnsiString( pPrinter->maDeviceName, TRUE );
564cdf0e10cSrcweir HANDLE hPrn;
565cdf0e10cSrcweir LPWSTR pPrinterNameW = reinterpret_cast<LPWSTR>(const_cast<sal_Unicode*>(pPrinter->maDeviceName.GetBuffer()));
566cdf0e10cSrcweir if ( ! aSalShlData.mbWPrinter )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir if ( !OpenPrinterA( (LPSTR)aPrinterNameA.GetBuffer(), &hPrn, NULL ) )
569cdf0e10cSrcweir return FALSE;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir else
572cdf0e10cSrcweir if ( !OpenPrinterW( pPrinterNameW, &hPrn, NULL ) )
573cdf0e10cSrcweir return FALSE;
574cdf0e10cSrcweir
575cdf0e10cSrcweir // #131642# hPrn==HGDI_ERROR even though OpenPrinter() succeeded!
576cdf0e10cSrcweir if( hPrn == HGDI_ERROR )
577cdf0e10cSrcweir return FALSE;
578cdf0e10cSrcweir
579cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
580cdf0e10cSrcweir {
581cdf0e10cSrcweir nSysJobSize = DocumentPropertiesW( 0, hPrn,
582cdf0e10cSrcweir pPrinterNameW,
583cdf0e10cSrcweir NULL, NULL, 0 );
584cdf0e10cSrcweir }
585cdf0e10cSrcweir else
586cdf0e10cSrcweir {
587cdf0e10cSrcweir nSysJobSize = DocumentPropertiesA( 0, hPrn,
588cdf0e10cSrcweir (LPSTR)aPrinterNameA.GetBuffer(),
589cdf0e10cSrcweir NULL, NULL, 0 );
590cdf0e10cSrcweir }
591*b4953498Smseidel
592cdf0e10cSrcweir if( nSysJobSize < 0 )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir ClosePrinter( hPrn );
595cdf0e10cSrcweir return FALSE;
596cdf0e10cSrcweir }
597cdf0e10cSrcweir BYTE *pBuffer = (BYTE*)_alloca( nSysJobSize );
598cdf0e10cSrcweir LONG nRet = -1;
599cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir nRet = DocumentPropertiesW( 0, hPrn,
602cdf0e10cSrcweir pPrinterNameW,
603cdf0e10cSrcweir (LPDEVMODEW)pBuffer, NULL, DM_OUT_BUFFER );
604cdf0e10cSrcweir }
605cdf0e10cSrcweir else
606cdf0e10cSrcweir {
607cdf0e10cSrcweir nRet = DocumentPropertiesA( 0, hPrn,
608cdf0e10cSrcweir (LPSTR)aPrinterNameA.GetBuffer(),
609cdf0e10cSrcweir (LPDEVMODEA)pBuffer, NULL, DM_OUT_BUFFER );
610cdf0e10cSrcweir }
611cdf0e10cSrcweir if( nRet < 0 )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir ClosePrinter( hPrn );
614cdf0e10cSrcweir return FALSE;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir
617*b4953498Smseidel // the spec version differs between the Windows platforms, i.e. 98,NT,2000/XP
618cdf0e10cSrcweir // this allows us to throw away printer settings from other platforms that might crash a buggy driver
619cdf0e10cSrcweir // we check the driver version as well
620cdf0e10cSrcweir dmSpecVersion = aSalShlData.mbWPrinter ? ((DEVMODEW*)pBuffer)->dmSpecVersion : ((DEVMODEA*)pBuffer)->dmSpecVersion;
621cdf0e10cSrcweir dmDriverVersion = aSalShlData.mbWPrinter ? ((DEVMODEW*)pBuffer)->dmDriverVersion : ((DEVMODEA*)pBuffer)->dmDriverVersion;
622cdf0e10cSrcweir
623cdf0e10cSrcweir ClosePrinter( hPrn );
624cdf0e10cSrcweir }
625cdf0e10cSrcweir SalDriverData* pSetupDriverData = (SalDriverData*)(pSetupData->mpDriverData);
626cdf0e10cSrcweir if ( (pSetupData->mnSystem == JOBSETUP_SYSTEM_WINDOWS) &&
627cdf0e10cSrcweir (pPrinter->maDriverName == pSetupData->maDriver) &&
628cdf0e10cSrcweir (pSetupData->mnDriverDataLen > sizeof( SalDriverData )) &&
629cdf0e10cSrcweir (long)(pSetupData->mnDriverDataLen - pSetupDriverData->mnDriverOffset) == nSysJobSize &&
630cdf0e10cSrcweir pSetupDriverData->mnSysSignature == SAL_DRIVERDATA_SYSSIGN )
631cdf0e10cSrcweir {
632cdf0e10cSrcweir if( pDevModeA &&
633cdf0e10cSrcweir (dmSpecVersion == pDevModeA->dmSpecVersion) &&
634cdf0e10cSrcweir (dmDriverVersion == pDevModeA->dmDriverVersion) )
635cdf0e10cSrcweir return TRUE;
636cdf0e10cSrcweir if( pDevModeW &&
637cdf0e10cSrcweir (dmSpecVersion == pDevModeW->dmSpecVersion) &&
638cdf0e10cSrcweir (dmDriverVersion == pDevModeW->dmDriverVersion) )
639cdf0e10cSrcweir return TRUE;
640cdf0e10cSrcweir }
641cdf0e10cSrcweir if ( bDelete )
642cdf0e10cSrcweir {
643cdf0e10cSrcweir rtl_freeMemory( pSetupData->mpDriverData );
644cdf0e10cSrcweir pSetupData->mpDriverData = NULL;
645cdf0e10cSrcweir pSetupData->mnDriverDataLen = 0;
646cdf0e10cSrcweir }
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
649cdf0e10cSrcweir return FALSE;
650cdf0e10cSrcweir }
651cdf0e10cSrcweir
652cdf0e10cSrcweir // -----------------------------------------------------------------------
653cdf0e10cSrcweir
ImplUpdateSalJobSetup(WinSalInfoPrinter * pPrinter,ImplJobSetup * pSetupData,sal_Bool bIn,WinSalFrame * pVisibleDlgParent)654cdf0e10cSrcweir static sal_Bool ImplUpdateSalJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData,
655cdf0e10cSrcweir sal_Bool bIn, WinSalFrame* pVisibleDlgParent )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir ByteString aPrinterNameA = ImplSalGetWinAnsiString( pPrinter->maDeviceName, TRUE );
658cdf0e10cSrcweir HANDLE hPrn;
659cdf0e10cSrcweir LPWSTR pPrinterNameW = reinterpret_cast<LPWSTR>(const_cast<sal_Unicode*>(pPrinter->maDeviceName.GetBuffer()));
660cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir if ( !OpenPrinterW( pPrinterNameW, &hPrn, NULL ) )
663cdf0e10cSrcweir return FALSE;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir else
666cdf0e10cSrcweir {
667cdf0e10cSrcweir if ( !OpenPrinterA( (LPSTR)aPrinterNameA.GetBuffer(), &hPrn, NULL ) )
668cdf0e10cSrcweir return FALSE;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir // #131642# hPrn==HGDI_ERROR even though OpenPrinter() succeeded!
671cdf0e10cSrcweir if( hPrn == HGDI_ERROR )
672cdf0e10cSrcweir return FALSE;
673cdf0e10cSrcweir
674cdf0e10cSrcweir LONG nRet;
675cdf0e10cSrcweir LONG nSysJobSize = -1;
676cdf0e10cSrcweir HWND hWnd = 0;
677cdf0e10cSrcweir DWORD nMode = DM_OUT_BUFFER;
678cdf0e10cSrcweir sal_uLong nDriverDataLen = 0;
679cdf0e10cSrcweir SalDriverData* pOutBuffer = NULL;
680cdf0e10cSrcweir BYTE* pInBuffer = NULL;
681cdf0e10cSrcweir
682cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir nSysJobSize = DocumentPropertiesW( hWnd, hPrn,
685cdf0e10cSrcweir pPrinterNameW,
686cdf0e10cSrcweir NULL, NULL, 0 );
687cdf0e10cSrcweir }
688cdf0e10cSrcweir else
689cdf0e10cSrcweir nSysJobSize = DocumentPropertiesA( hWnd, hPrn,
690cdf0e10cSrcweir (LPSTR)ImplSalGetWinAnsiString( pPrinter->maDeviceName, TRUE ).GetBuffer(),
691cdf0e10cSrcweir NULL, NULL, 0 );
692cdf0e10cSrcweir if ( nSysJobSize < 0 )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir ClosePrinter( hPrn );
695cdf0e10cSrcweir return FALSE;
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir // Outputbuffer anlegen
699cdf0e10cSrcweir nDriverDataLen = sizeof(SalDriverData) + nSysJobSize-1;
700cdf0e10cSrcweir pOutBuffer = (SalDriverData*)rtl_allocateZeroMemory( nDriverDataLen );
701cdf0e10cSrcweir pOutBuffer->mnSysSignature = SAL_DRIVERDATA_SYSSIGN;
702cdf0e10cSrcweir pOutBuffer->mnVersion = aSalShlData.mbWPrinter ? SAL_DRIVERDATA_VERSION_W : SAL_DRIVERDATA_VERSION_A;
703cdf0e10cSrcweir // calculate driver data offset including structure padding
704cdf0e10cSrcweir pOutBuffer->mnDriverOffset = sal::static_int_cast<sal_uInt16>(
705cdf0e10cSrcweir (char*)pOutBuffer->maDriverData -
706cdf0e10cSrcweir (char*)pOutBuffer );
707cdf0e10cSrcweir
708cdf0e10cSrcweir // Testen, ob wir einen geeigneten Inputbuffer haben
709cdf0e10cSrcweir if ( bIn && ImplTestSalJobSetup( pPrinter, pSetupData, FALSE ) )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir pInBuffer = (BYTE*)pSetupData->mpDriverData + ((SalDriverData*)pSetupData->mpDriverData)->mnDriverOffset;
712cdf0e10cSrcweir nMode |= DM_IN_BUFFER;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir
715cdf0e10cSrcweir // Testen, ob Dialog angezeigt werden soll
716cdf0e10cSrcweir if ( pVisibleDlgParent )
717cdf0e10cSrcweir {
718cdf0e10cSrcweir hWnd = pVisibleDlgParent->mhWnd;
719cdf0e10cSrcweir nMode |= DM_IN_PROMPT;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir // Release mutex, in the other case we don't get paints and so on
723cdf0e10cSrcweir sal_uLong nMutexCount=0;
724cdf0e10cSrcweir if ( pVisibleDlgParent )
725cdf0e10cSrcweir nMutexCount = ImplSalReleaseYieldMutex();
726*b4953498Smseidel
727cdf0e10cSrcweir BYTE* pOutDevMode = (((BYTE*)pOutBuffer) + pOutBuffer->mnDriverOffset);
728cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
729cdf0e10cSrcweir {
730cdf0e10cSrcweir nRet = DocumentPropertiesW( hWnd, hPrn,
731cdf0e10cSrcweir pPrinterNameW,
732cdf0e10cSrcweir (LPDEVMODEW)pOutDevMode, (LPDEVMODEW)pInBuffer, nMode );
733cdf0e10cSrcweir }
734cdf0e10cSrcweir else
735cdf0e10cSrcweir {
736cdf0e10cSrcweir nRet = DocumentPropertiesA( hWnd, hPrn,
737cdf0e10cSrcweir (LPSTR)ImplSalGetWinAnsiString( pPrinter->maDeviceName, TRUE ).GetBuffer(),
738cdf0e10cSrcweir (LPDEVMODEA)pOutDevMode, (LPDEVMODEA)pInBuffer, nMode );
739cdf0e10cSrcweir }
740cdf0e10cSrcweir if ( pVisibleDlgParent )
741cdf0e10cSrcweir ImplSalAcquireYieldMutex( nMutexCount );
742cdf0e10cSrcweir ClosePrinter( hPrn );
743cdf0e10cSrcweir
744cdf0e10cSrcweir if( (nRet < 0) || (pVisibleDlgParent && (nRet == IDCANCEL)) )
745cdf0e10cSrcweir {
746cdf0e10cSrcweir rtl_freeMemory( pOutBuffer );
747cdf0e10cSrcweir return FALSE;
748cdf0e10cSrcweir }
749cdf0e10cSrcweir
750cdf0e10cSrcweir // fill up string buffers with 0 so they do not influence a JobSetup's memcmp
751cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
752cdf0e10cSrcweir {
753cdf0e10cSrcweir if( ((LPDEVMODEW)pOutDevMode)->dmSize >= 64 )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir sal_Int32 nLen = rtl_ustr_getLength( (const sal_Unicode*)((LPDEVMODEW)pOutDevMode)->dmDeviceName );
756cdf0e10cSrcweir if ( nLen < sizeof( ((LPDEVMODEW)pOutDevMode)->dmDeviceName )/sizeof(sal_Unicode) )
757cdf0e10cSrcweir memset( ((LPDEVMODEW)pOutDevMode)->dmDeviceName+nLen, 0, sizeof( ((LPDEVMODEW)pOutDevMode)->dmDeviceName )-(nLen*sizeof(sal_Unicode)) );
758cdf0e10cSrcweir }
759cdf0e10cSrcweir if( ((LPDEVMODEW)pOutDevMode)->dmSize >= 166 )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir sal_Int32 nLen = rtl_ustr_getLength( (const sal_Unicode*)((LPDEVMODEW)pOutDevMode)->dmFormName );
762cdf0e10cSrcweir if ( nLen < sizeof( ((LPDEVMODEW)pOutDevMode)->dmFormName )/sizeof(sal_Unicode) )
763cdf0e10cSrcweir memset( ((LPDEVMODEW)pOutDevMode)->dmFormName+nLen, 0, sizeof( ((LPDEVMODEW)pOutDevMode)->dmFormName )-(nLen*sizeof(sal_Unicode)) );
764cdf0e10cSrcweir }
765cdf0e10cSrcweir }
766cdf0e10cSrcweir else
767cdf0e10cSrcweir {
768cdf0e10cSrcweir if( ((LPDEVMODEA)pOutDevMode)->dmSize >= 32 )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir sal_Int32 nLen = strlen( (const char*)((LPDEVMODEA)pOutDevMode)->dmDeviceName );
771cdf0e10cSrcweir if ( nLen < sizeof( ((LPDEVMODEA)pOutDevMode)->dmDeviceName ) )
772cdf0e10cSrcweir memset( ((LPDEVMODEA)pOutDevMode)->dmDeviceName+nLen, 0, sizeof( ((LPDEVMODEA)pOutDevMode)->dmDeviceName )-nLen );
773cdf0e10cSrcweir }
774cdf0e10cSrcweir if( ((LPDEVMODEA)pOutDevMode)->dmSize >= 102 )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir sal_Int32 nLen = strlen( (const char*)((LPDEVMODEA)pOutDevMode)->dmFormName );
777cdf0e10cSrcweir if ( nLen < sizeof( ((LPDEVMODEA)pOutDevMode)->dmFormName ) )
778cdf0e10cSrcweir memset( ((LPDEVMODEA)pOutDevMode)->dmFormName+nLen, 0, sizeof( ((LPDEVMODEA)pOutDevMode)->dmFormName )-nLen );
779cdf0e10cSrcweir }
780cdf0e10cSrcweir }
781cdf0e10cSrcweir
782cdf0e10cSrcweir // update data
783cdf0e10cSrcweir if ( pSetupData->mpDriverData )
784cdf0e10cSrcweir rtl_freeMemory( pSetupData->mpDriverData );
785cdf0e10cSrcweir pSetupData->mnDriverDataLen = nDriverDataLen;
786cdf0e10cSrcweir pSetupData->mpDriverData = (BYTE*)pOutBuffer;
787cdf0e10cSrcweir pSetupData->mnSystem = JOBSETUP_SYSTEM_WINDOWS;
788cdf0e10cSrcweir
789cdf0e10cSrcweir return TRUE;
790cdf0e10cSrcweir }
791cdf0e10cSrcweir
792cdf0e10cSrcweir // -----------------------------------------------------------------------
793cdf0e10cSrcweir
794cdf0e10cSrcweir #define DECLARE_DEVMODE( i )\
795cdf0e10cSrcweir DEVMODEA* pDevModeA = SAL_DEVMODE_A(i);\
796cdf0e10cSrcweir DEVMODEW* pDevModeW = SAL_DEVMODE_W(i);\
797cdf0e10cSrcweir if( pDevModeA == NULL && pDevModeW == NULL )\
798cdf0e10cSrcweir return
799cdf0e10cSrcweir
800cdf0e10cSrcweir #define CHOOSE_DEVMODE(i)\
801cdf0e10cSrcweir (pDevModeW ? pDevModeW->i : pDevModeA->i)
802cdf0e10cSrcweir
ImplDevModeToJobSetup(WinSalInfoPrinter * pPrinter,ImplJobSetup * pSetupData,sal_uLong nFlags)803cdf0e10cSrcweir static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData, sal_uLong nFlags )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir if ( !pSetupData || !pSetupData->mpDriverData )
806cdf0e10cSrcweir return;
807cdf0e10cSrcweir
808cdf0e10cSrcweir DECLARE_DEVMODE( pSetupData );
809cdf0e10cSrcweir
810cdf0e10cSrcweir // Orientation
811cdf0e10cSrcweir if ( nFlags & SAL_JOBSET_ORIENTATION )
812cdf0e10cSrcweir {
813cdf0e10cSrcweir if ( CHOOSE_DEVMODE(dmOrientation) == DMORIENT_PORTRAIT )
814cdf0e10cSrcweir pSetupData->meOrientation = ORIENTATION_PORTRAIT;
815cdf0e10cSrcweir else if ( CHOOSE_DEVMODE(dmOrientation) == DMORIENT_LANDSCAPE )
816cdf0e10cSrcweir pSetupData->meOrientation = ORIENTATION_LANDSCAPE;
817cdf0e10cSrcweir }
818cdf0e10cSrcweir
819cdf0e10cSrcweir // PaperBin
820cdf0e10cSrcweir if ( nFlags & SAL_JOBSET_PAPERBIN )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir sal_uLong nCount = ImplDeviceCaps( pPrinter, DC_BINS, NULL, pSetupData );
823cdf0e10cSrcweir
824cdf0e10cSrcweir if ( nCount && (nCount != GDI_ERROR) )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir WORD* pBins = (WORD*)rtl_allocateZeroMemory( nCount*sizeof(WORD) );
827cdf0e10cSrcweir ImplDeviceCaps( pPrinter, DC_BINS, (BYTE*)pBins, pSetupData );
828cdf0e10cSrcweir pSetupData->mnPaperBin = 0;
829cdf0e10cSrcweir
830cdf0e10cSrcweir // search the right bin and assign index to mnPaperBin
831cdf0e10cSrcweir for( sal_uLong i = 0; i < nCount; i++ )
832cdf0e10cSrcweir {
833cdf0e10cSrcweir if( CHOOSE_DEVMODE(dmDefaultSource) == pBins[ i ] )
834cdf0e10cSrcweir {
835cdf0e10cSrcweir pSetupData->mnPaperBin = (sal_uInt16)i;
836cdf0e10cSrcweir break;
837cdf0e10cSrcweir }
838cdf0e10cSrcweir }
839cdf0e10cSrcweir
840cdf0e10cSrcweir rtl_freeMemory( pBins );
841cdf0e10cSrcweir }
842cdf0e10cSrcweir }
843cdf0e10cSrcweir
844cdf0e10cSrcweir // PaperSize
845cdf0e10cSrcweir if ( nFlags & SAL_JOBSET_PAPERSIZE )
846cdf0e10cSrcweir {
847cdf0e10cSrcweir if( (CHOOSE_DEVMODE(dmFields) & (DM_PAPERWIDTH|DM_PAPERLENGTH)) == (DM_PAPERWIDTH|DM_PAPERLENGTH) )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir pSetupData->mnPaperWidth = CHOOSE_DEVMODE(dmPaperWidth)*10;
850cdf0e10cSrcweir pSetupData->mnPaperHeight = CHOOSE_DEVMODE(dmPaperLength)*10;
851cdf0e10cSrcweir }
852cdf0e10cSrcweir else
853cdf0e10cSrcweir {
854cdf0e10cSrcweir sal_uLong nPaperCount = ImplDeviceCaps( pPrinter, DC_PAPERS, NULL, pSetupData );
855cdf0e10cSrcweir WORD* pPapers = NULL;
856cdf0e10cSrcweir sal_uLong nPaperSizeCount = ImplDeviceCaps( pPrinter, DC_PAPERSIZE, NULL, pSetupData );
857cdf0e10cSrcweir POINT* pPaperSizes = NULL;
858cdf0e10cSrcweir if ( nPaperCount && (nPaperCount != GDI_ERROR) )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir pPapers = (WORD*)rtl_allocateZeroMemory(nPaperCount*sizeof(WORD));
861cdf0e10cSrcweir ImplDeviceCaps( pPrinter, DC_PAPERS, (BYTE*)pPapers, pSetupData );
862cdf0e10cSrcweir }
863cdf0e10cSrcweir if ( nPaperSizeCount && (nPaperSizeCount != GDI_ERROR) )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir pPaperSizes = (POINT*)rtl_allocateZeroMemory(nPaperSizeCount*sizeof(POINT));
866cdf0e10cSrcweir ImplDeviceCaps( pPrinter, DC_PAPERSIZE, (BYTE*)pPaperSizes, pSetupData );
867cdf0e10cSrcweir }
868cdf0e10cSrcweir if( nPaperSizeCount == nPaperCount && pPaperSizes && pPapers )
869cdf0e10cSrcweir {
870cdf0e10cSrcweir for( sal_uLong i = 0; i < nPaperCount; i++ )
871cdf0e10cSrcweir {
872cdf0e10cSrcweir if( pPapers[ i ] == CHOOSE_DEVMODE(dmPaperSize) )
873cdf0e10cSrcweir {
874cdf0e10cSrcweir pSetupData->mnPaperWidth = pPaperSizes[ i ].x*10;
875cdf0e10cSrcweir pSetupData->mnPaperHeight = pPaperSizes[ i ].y*10;
876cdf0e10cSrcweir break;
877cdf0e10cSrcweir }
878cdf0e10cSrcweir }
879cdf0e10cSrcweir }
880cdf0e10cSrcweir if( pPapers )
881cdf0e10cSrcweir rtl_freeMemory( pPapers );
882cdf0e10cSrcweir if( pPaperSizes )
883cdf0e10cSrcweir rtl_freeMemory( pPaperSizes );
884cdf0e10cSrcweir }
885cdf0e10cSrcweir switch( CHOOSE_DEVMODE(dmPaperSize) )
886cdf0e10cSrcweir {
887cdf0e10cSrcweir case( DMPAPER_LETTER ):
888cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_LETTER;
889cdf0e10cSrcweir break;
890cdf0e10cSrcweir case( DMPAPER_TABLOID ):
891cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_TABLOID;
892cdf0e10cSrcweir break;
893cdf0e10cSrcweir case( DMPAPER_LEDGER ):
894cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_LEDGER;
895cdf0e10cSrcweir break;
896cdf0e10cSrcweir case( DMPAPER_LEGAL ):
897cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_LEGAL;
898cdf0e10cSrcweir break;
899cdf0e10cSrcweir case( DMPAPER_STATEMENT ):
900cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_STATEMENT;
901cdf0e10cSrcweir break;
902cdf0e10cSrcweir case( DMPAPER_EXECUTIVE ):
903cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_EXECUTIVE;
904cdf0e10cSrcweir break;
905cdf0e10cSrcweir case( DMPAPER_A3 ):
906cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_A3;
907cdf0e10cSrcweir break;
908cdf0e10cSrcweir case( DMPAPER_A4 ):
909cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_A4;
910cdf0e10cSrcweir break;
911cdf0e10cSrcweir case( DMPAPER_A5 ):
912cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_A5;
913cdf0e10cSrcweir break;
914*b4953498Smseidel //See https://wiki.openoffice.org/wiki/DefaultPaperSize
915cdf0e10cSrcweir //i.e.
916cdf0e10cSrcweir //http://msdn.microsoft.com/en-us/library/dd319099(VS.85).aspx
917cdf0e10cSrcweir //DMPAPER_B4 12 B4 (JIS) 257 x 364 mm
918cdf0e10cSrcweir //http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf
919cdf0e10cSrcweir //also says that the MS DMPAPER_B4 is JIS, which makes most sense. And
920cdf0e10cSrcweir //matches our Excel filter's belief about the matching XlPaperSize
921cdf0e10cSrcweir //enumeration.
922cdf0e10cSrcweir //
923cdf0e10cSrcweir //http://msdn.microsoft.com/en-us/library/ms776398(VS.85).aspx said
924cdf0e10cSrcweir ////"DMPAPER_B4 12 B4 (JIS) 250 x 354"
925cdf0e10cSrcweir //which is bogus as it's either JIS 257 × 364 or ISO 250 × 353
926cdf0e10cSrcweir //(cmc)
927cdf0e10cSrcweir case( DMPAPER_B4 ):
928cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_B4_JIS;
929cdf0e10cSrcweir break;
930cdf0e10cSrcweir case( DMPAPER_B5 ):
931cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_B5_JIS;
932cdf0e10cSrcweir break;
933cdf0e10cSrcweir case( DMPAPER_QUARTO ):
934cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_QUARTO;
935cdf0e10cSrcweir break;
936cdf0e10cSrcweir case( DMPAPER_10X14 ):
937cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_10x14;
938cdf0e10cSrcweir break;
939cdf0e10cSrcweir case( DMPAPER_NOTE ):
940cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_LETTER;
941cdf0e10cSrcweir break;
942cdf0e10cSrcweir case( DMPAPER_ENV_9 ):
943cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_9;
944cdf0e10cSrcweir break;
945cdf0e10cSrcweir case( DMPAPER_ENV_10 ):
946cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_10;
947cdf0e10cSrcweir break;
948cdf0e10cSrcweir case( DMPAPER_ENV_11 ):
949cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_11;
950cdf0e10cSrcweir break;
951cdf0e10cSrcweir case( DMPAPER_ENV_12 ):
952cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_12;
953cdf0e10cSrcweir break;
954cdf0e10cSrcweir case( DMPAPER_ENV_14 ):
955cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_14;
956cdf0e10cSrcweir break;
957cdf0e10cSrcweir case( DMPAPER_CSHEET ):
958cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_C;
959cdf0e10cSrcweir break;
960cdf0e10cSrcweir case( DMPAPER_DSHEET ):
961cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_D;
962cdf0e10cSrcweir break;
963cdf0e10cSrcweir case( DMPAPER_ESHEET ):
964cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_E;
965cdf0e10cSrcweir break;
966cdf0e10cSrcweir case( DMPAPER_ENV_DL):
967cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_DL;
968cdf0e10cSrcweir break;
969cdf0e10cSrcweir case( DMPAPER_ENV_C5):
970cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_C5;
971cdf0e10cSrcweir break;
972cdf0e10cSrcweir case( DMPAPER_ENV_C3):
973cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_C3;
974cdf0e10cSrcweir break;
975cdf0e10cSrcweir case( DMPAPER_ENV_C4):
976cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_C4;
977cdf0e10cSrcweir break;
978cdf0e10cSrcweir case( DMPAPER_ENV_C6):
979cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_C6;
980cdf0e10cSrcweir break;
981cdf0e10cSrcweir case( DMPAPER_ENV_C65):
982cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_C65;
983cdf0e10cSrcweir break;
984cdf0e10cSrcweir case( DMPAPER_ENV_ITALY ):
985cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_ITALY;
986cdf0e10cSrcweir break;
987cdf0e10cSrcweir case( DMPAPER_ENV_MONARCH ):
988cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_MONARCH;
989cdf0e10cSrcweir break;
990cdf0e10cSrcweir case( DMPAPER_ENV_PERSONAL ):
991cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_PERSONAL;
992cdf0e10cSrcweir break;
993cdf0e10cSrcweir case( DMPAPER_FANFOLD_US ):
994cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_FANFOLD_US;
995cdf0e10cSrcweir break;
996cdf0e10cSrcweir case( DMPAPER_FANFOLD_STD_GERMAN ):
997cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_FANFOLD_DE;
998cdf0e10cSrcweir break;
999cdf0e10cSrcweir case( DMPAPER_FANFOLD_LGL_GERMAN ):
1000cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_FANFOLD_LEGAL_DE;
1001cdf0e10cSrcweir break;
1002cdf0e10cSrcweir case( DMPAPER_ISO_B4 ):
1003cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_B4_ISO;
1004cdf0e10cSrcweir break;
1005cdf0e10cSrcweir case( DMPAPER_JAPANESE_POSTCARD ):
1006cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_POSTCARD_JP;
1007cdf0e10cSrcweir break;
1008cdf0e10cSrcweir case( DMPAPER_9X11 ):
1009cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_9x11;
1010cdf0e10cSrcweir break;
1011cdf0e10cSrcweir case( DMPAPER_10X11 ):
1012cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_10x11;
1013cdf0e10cSrcweir break;
1014cdf0e10cSrcweir case( DMPAPER_15X11 ):
1015cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_15x11;
1016cdf0e10cSrcweir break;
1017cdf0e10cSrcweir case( DMPAPER_ENV_INVITE ):
1018cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_ENV_INVITE;
1019cdf0e10cSrcweir break;
1020cdf0e10cSrcweir case( DMPAPER_A_PLUS ):
1021cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_A_PLUS;
1022cdf0e10cSrcweir break;
1023cdf0e10cSrcweir case( DMPAPER_B_PLUS ):
1024cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_B_PLUS;
1025cdf0e10cSrcweir break;
1026cdf0e10cSrcweir case( DMPAPER_LETTER_PLUS ):
1027cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_LETTER_PLUS;
1028cdf0e10cSrcweir break;
1029cdf0e10cSrcweir case( DMPAPER_A4_PLUS ):
1030cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_A4_PLUS;
1031cdf0e10cSrcweir break;
1032cdf0e10cSrcweir case( DMPAPER_A2 ):
1033cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_A2;
1034cdf0e10cSrcweir break;
1035cdf0e10cSrcweir case( DMPAPER_DBL_JAPANESE_POSTCARD ):
1036cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_DOUBLEPOSTCARD_JP;
1037cdf0e10cSrcweir break;
1038cdf0e10cSrcweir case( DMPAPER_A6 ):
1039cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_A6;
1040cdf0e10cSrcweir break;
1041cdf0e10cSrcweir case( DMPAPER_B6_JIS ):
1042cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_B6_JIS;
1043cdf0e10cSrcweir break;
1044cdf0e10cSrcweir case( DMPAPER_12X11 ):
1045cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_12x11;
1046cdf0e10cSrcweir break;
1047cdf0e10cSrcweir default:
1048cdf0e10cSrcweir pSetupData->mePaperFormat = PAPER_USER;
1049cdf0e10cSrcweir break;
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir }
1052*b4953498Smseidel
1053cdf0e10cSrcweir if( nFlags & SAL_JOBSET_DUPLEXMODE )
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir DuplexMode eDuplex = DUPLEX_UNKNOWN;
1056cdf0e10cSrcweir if( (CHOOSE_DEVMODE(dmFields) & DM_DUPLEX) )
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir if( CHOOSE_DEVMODE(dmDuplex) == DMDUP_SIMPLEX )
1059cdf0e10cSrcweir eDuplex = DUPLEX_OFF;
1060cdf0e10cSrcweir else if( CHOOSE_DEVMODE(dmDuplex) == DMDUP_VERTICAL )
1061cdf0e10cSrcweir eDuplex = DUPLEX_LONGEDGE;
1062cdf0e10cSrcweir else if( CHOOSE_DEVMODE(dmDuplex) == DMDUP_HORIZONTAL )
1063cdf0e10cSrcweir eDuplex = DUPLEX_SHORTEDGE;
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir pSetupData->meDuplexMode = eDuplex;
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir // -----------------------------------------------------------------------
1070cdf0e10cSrcweir
ImplJobSetupToDevMode(WinSalInfoPrinter * pPrinter,ImplJobSetup * pSetupData,sal_uLong nFlags)1071cdf0e10cSrcweir static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData, sal_uLong nFlags )
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir if ( !pSetupData || !pSetupData->mpDriverData )
1074cdf0e10cSrcweir return;
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir DECLARE_DEVMODE( pSetupData );
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir // Orientation
1079cdf0e10cSrcweir if ( nFlags & SAL_JOBSET_ORIENTATION )
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir CHOOSE_DEVMODE(dmFields) |= DM_ORIENTATION;
1082cdf0e10cSrcweir if ( pSetupData->meOrientation == ORIENTATION_PORTRAIT )
1083cdf0e10cSrcweir CHOOSE_DEVMODE(dmOrientation) = DMORIENT_PORTRAIT;
1084cdf0e10cSrcweir else
1085cdf0e10cSrcweir CHOOSE_DEVMODE(dmOrientation) = DMORIENT_LANDSCAPE;
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir // PaperBin
1089cdf0e10cSrcweir if ( nFlags & SAL_JOBSET_PAPERBIN )
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir sal_uLong nCount = ImplDeviceCaps( pPrinter, DC_BINS, NULL, pSetupData );
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir if ( nCount && (nCount != GDI_ERROR) )
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir WORD* pBins = (WORD*)rtl_allocateZeroMemory(nCount*sizeof(WORD));
1096cdf0e10cSrcweir ImplDeviceCaps( pPrinter, DC_BINS, (BYTE*)pBins, pSetupData );
1097cdf0e10cSrcweir CHOOSE_DEVMODE(dmFields) |= DM_DEFAULTSOURCE;
1098cdf0e10cSrcweir CHOOSE_DEVMODE(dmDefaultSource) = pBins[ pSetupData->mnPaperBin ];
1099cdf0e10cSrcweir rtl_freeMemory( pBins );
1100cdf0e10cSrcweir }
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir // PaperSize
1104cdf0e10cSrcweir if ( nFlags & SAL_JOBSET_PAPERSIZE )
1105cdf0e10cSrcweir {
1106cdf0e10cSrcweir CHOOSE_DEVMODE(dmFields) |= DM_PAPERSIZE;
1107cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperWidth) = 0;
1108cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperLength) = 0;
1109cdf0e10cSrcweir
1110cdf0e10cSrcweir switch( pSetupData->mePaperFormat )
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir case( PAPER_A2 ):
1113cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A2;
1114cdf0e10cSrcweir break;
1115cdf0e10cSrcweir case( PAPER_A3 ):
1116cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A3;
1117cdf0e10cSrcweir break;
1118cdf0e10cSrcweir case( PAPER_A4 ):
1119cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A4;
1120cdf0e10cSrcweir break;
1121cdf0e10cSrcweir case( PAPER_A5 ):
1122cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A5;
1123cdf0e10cSrcweir break;
1124cdf0e10cSrcweir case( PAPER_B4_ISO):
1125cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ISO_B4;
1126cdf0e10cSrcweir break;
1127cdf0e10cSrcweir case( PAPER_LETTER ):
1128cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_LETTER;
1129cdf0e10cSrcweir break;
1130cdf0e10cSrcweir case( PAPER_LEGAL ):
1131cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_LEGAL;
1132cdf0e10cSrcweir break;
1133cdf0e10cSrcweir case( PAPER_TABLOID ):
1134cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_TABLOID;
1135cdf0e10cSrcweir break;
1136cdf0e10cSrcweir #if 0
1137cdf0e10cSrcweir //http://msdn.microsoft.com/en-us/library/ms776398(VS.85).aspx
1138cdf0e10cSrcweir //DMPAPER_ENV_B6 is documented as:
1139cdf0e10cSrcweir //"DMPAPER_ENV_B6 35 Envelope B6 176 x 125 mm"
1140cdf0e10cSrcweir //which is the wrong way around, it is surely 125 x 176, i.e.
1141cdf0e10cSrcweir //compare DMPAPER_ENV_B4 and DMPAPER_ENV_B4 as
1142cdf0e10cSrcweir //DMPAPER_ENV_B4 33 Envelope B4 250 x 353 mm
1143cdf0e10cSrcweir //DMPAPER_ENV_B5 34 Envelope B5 176 x 250 mm
1144cdf0e10cSrcweir case( PAPER_B6_ISO ):
1145cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_B6;
1146cdf0e10cSrcweir break;
1147cdf0e10cSrcweir #endif
1148cdf0e10cSrcweir case( PAPER_ENV_C4 ):
1149cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_C4;
1150cdf0e10cSrcweir break;
1151cdf0e10cSrcweir case( PAPER_ENV_C5 ):
1152cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_C5;
1153cdf0e10cSrcweir break;
1154cdf0e10cSrcweir case( PAPER_ENV_C6 ):
1155cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_C6;
1156cdf0e10cSrcweir break;
1157cdf0e10cSrcweir case( PAPER_ENV_C65 ):
1158cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_C65;
1159cdf0e10cSrcweir break;
1160cdf0e10cSrcweir case( PAPER_ENV_DL ):
1161cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_DL;
1162cdf0e10cSrcweir break;
1163cdf0e10cSrcweir case( PAPER_C ):
1164cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_CSHEET;
1165cdf0e10cSrcweir break;
1166cdf0e10cSrcweir case( PAPER_D ):
1167cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_DSHEET;
1168cdf0e10cSrcweir break;
1169cdf0e10cSrcweir case( PAPER_E ):
1170cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ESHEET;
1171cdf0e10cSrcweir break;
1172cdf0e10cSrcweir case( PAPER_EXECUTIVE ):
1173cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_EXECUTIVE;
1174cdf0e10cSrcweir break;
1175cdf0e10cSrcweir case( PAPER_FANFOLD_LEGAL_DE ):
1176cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_FANFOLD_LGL_GERMAN;
1177cdf0e10cSrcweir break;
1178cdf0e10cSrcweir case( PAPER_ENV_MONARCH ):
1179cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_MONARCH;
1180cdf0e10cSrcweir break;
1181cdf0e10cSrcweir case( PAPER_ENV_PERSONAL ):
1182cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_PERSONAL;
1183cdf0e10cSrcweir break;
1184cdf0e10cSrcweir case( PAPER_ENV_9 ):
1185cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_9;
1186cdf0e10cSrcweir break;
1187cdf0e10cSrcweir case( PAPER_ENV_10 ):
1188cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_10;
1189cdf0e10cSrcweir break;
1190cdf0e10cSrcweir case( PAPER_ENV_11 ):
1191cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_11;
1192cdf0e10cSrcweir break;
1193cdf0e10cSrcweir case( PAPER_ENV_12 ):
1194cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_12;
1195cdf0e10cSrcweir break;
1196cdf0e10cSrcweir //See the comments on DMPAPER_B4 above
1197cdf0e10cSrcweir case( PAPER_B4_JIS ):
1198cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_B4;
1199cdf0e10cSrcweir break;
1200cdf0e10cSrcweir case( PAPER_B5_JIS ):
1201cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_B5;
1202cdf0e10cSrcweir break;
1203cdf0e10cSrcweir case( PAPER_B6_JIS ):
1204cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_B6_JIS;
1205cdf0e10cSrcweir break;
1206cdf0e10cSrcweir case( PAPER_LEDGER ):
1207cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_LEDGER;
1208cdf0e10cSrcweir break;
1209cdf0e10cSrcweir case( PAPER_STATEMENT ):
1210cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_STATEMENT;
1211cdf0e10cSrcweir break;
1212cdf0e10cSrcweir case( PAPER_10x14 ):
1213cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_10X14;
1214cdf0e10cSrcweir break;
1215cdf0e10cSrcweir case( PAPER_ENV_14 ):
1216cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_14;
1217cdf0e10cSrcweir break;
1218cdf0e10cSrcweir case( PAPER_ENV_C3 ):
1219cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_C3;
1220cdf0e10cSrcweir break;
1221cdf0e10cSrcweir case( PAPER_ENV_ITALY ):
1222cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_ITALY;
1223cdf0e10cSrcweir break;
1224cdf0e10cSrcweir case( PAPER_FANFOLD_US ):
1225cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_FANFOLD_US;
1226cdf0e10cSrcweir break;
1227cdf0e10cSrcweir case( PAPER_FANFOLD_DE ):
1228cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_FANFOLD_STD_GERMAN;
1229cdf0e10cSrcweir break;
1230cdf0e10cSrcweir case( PAPER_POSTCARD_JP ):
1231cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_JAPANESE_POSTCARD;
1232cdf0e10cSrcweir break;
1233cdf0e10cSrcweir case( PAPER_9x11 ):
1234cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_9X11;
1235cdf0e10cSrcweir break;
1236cdf0e10cSrcweir case( PAPER_10x11 ):
1237cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_10X11;
1238cdf0e10cSrcweir break;
1239cdf0e10cSrcweir case( PAPER_15x11 ):
1240cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_15X11;
1241cdf0e10cSrcweir break;
1242cdf0e10cSrcweir case( PAPER_ENV_INVITE ):
1243cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_ENV_INVITE;
1244cdf0e10cSrcweir break;
1245cdf0e10cSrcweir case( PAPER_A_PLUS ):
1246cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A_PLUS;
1247cdf0e10cSrcweir break;
1248cdf0e10cSrcweir case( PAPER_B_PLUS ):
1249cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_B_PLUS;
1250cdf0e10cSrcweir break;
1251cdf0e10cSrcweir case( PAPER_LETTER_PLUS ):
1252cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_LETTER_PLUS;
1253cdf0e10cSrcweir break;
1254cdf0e10cSrcweir case( PAPER_A4_PLUS ):
1255cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A4_PLUS;
1256cdf0e10cSrcweir break;
1257cdf0e10cSrcweir case( PAPER_DOUBLEPOSTCARD_JP ):
1258cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_DBL_JAPANESE_POSTCARD;
1259cdf0e10cSrcweir break;
1260cdf0e10cSrcweir case( PAPER_A6 ):
1261cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A6;
1262cdf0e10cSrcweir break;
1263cdf0e10cSrcweir case( PAPER_12x11 ):
1264cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_12X11;
1265cdf0e10cSrcweir break;
1266cdf0e10cSrcweir default:
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir short nPaper = 0;
1269cdf0e10cSrcweir sal_uLong nPaperCount = ImplDeviceCaps( pPrinter, DC_PAPERS, NULL, pSetupData );
1270cdf0e10cSrcweir WORD* pPapers = NULL;
1271cdf0e10cSrcweir sal_uLong nPaperSizeCount = ImplDeviceCaps( pPrinter, DC_PAPERSIZE, NULL, pSetupData );
1272cdf0e10cSrcweir POINT* pPaperSizes = NULL;
1273cdf0e10cSrcweir DWORD nLandscapeAngle = ImplDeviceCaps( pPrinter, DC_ORIENTATION, NULL, pSetupData );
1274cdf0e10cSrcweir if ( nPaperCount && (nPaperCount != GDI_ERROR) )
1275cdf0e10cSrcweir {
1276cdf0e10cSrcweir pPapers = (WORD*)rtl_allocateZeroMemory(nPaperCount*sizeof(WORD));
1277cdf0e10cSrcweir ImplDeviceCaps( pPrinter, DC_PAPERS, (BYTE*)pPapers, pSetupData );
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir if ( nPaperSizeCount && (nPaperSizeCount != GDI_ERROR) )
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir pPaperSizes = (POINT*)rtl_allocateZeroMemory(nPaperSizeCount*sizeof(POINT));
1282cdf0e10cSrcweir ImplDeviceCaps( pPrinter, DC_PAPERSIZE, (BYTE*)pPaperSizes, pSetupData );
1283cdf0e10cSrcweir }
1284cdf0e10cSrcweir if ( (nPaperSizeCount == nPaperCount) && pPapers && pPaperSizes )
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir PaperInfo aInfo(pSetupData->mnPaperWidth, pSetupData->mnPaperHeight);
1287cdf0e10cSrcweir // compare paper formats and select a good match
1288cdf0e10cSrcweir for ( sal_uLong i = 0; i < nPaperCount; i++ )
1289cdf0e10cSrcweir {
1290cdf0e10cSrcweir if ( aInfo.sloppyEqual(PaperInfo(pPaperSizes[i].x*10, pPaperSizes[i].y*10)))
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir nPaper = pPapers[i];
1293cdf0e10cSrcweir break;
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir
1297cdf0e10cSrcweir // If the printer supports landscape orientation, check paper sizes again
1298cdf0e10cSrcweir // with landscape orientation. This is necessary as a printer driver provides
1299cdf0e10cSrcweir // all paper sizes with portrait orientation only!!
1300cdf0e10cSrcweir if ( !nPaper && nLandscapeAngle != 0 )
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir PaperInfo aRotatedInfo(pSetupData->mnPaperHeight, pSetupData->mnPaperWidth);
1303cdf0e10cSrcweir for ( sal_uLong i = 0; i < nPaperCount; i++ )
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir if ( aRotatedInfo.sloppyEqual(PaperInfo(pPaperSizes[i].x*10, pPaperSizes[i].y*10)) )
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir nPaper = pPapers[i];
1308cdf0e10cSrcweir break;
1309cdf0e10cSrcweir }
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir
1313cdf0e10cSrcweir if ( nPaper )
1314cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = nPaper;
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir
1317cdf0e10cSrcweir if ( !nPaper )
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir CHOOSE_DEVMODE(dmFields) |= DM_PAPERLENGTH | DM_PAPERWIDTH;
1320cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_USER;
1321cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperWidth) = (short)(pSetupData->mnPaperWidth/10);
1322cdf0e10cSrcweir CHOOSE_DEVMODE(dmPaperLength) = (short)(pSetupData->mnPaperHeight/10);
1323cdf0e10cSrcweir }
1324cdf0e10cSrcweir
1325cdf0e10cSrcweir if ( pPapers )
1326cdf0e10cSrcweir rtl_freeMemory(pPapers);
1327cdf0e10cSrcweir if ( pPaperSizes )
1328cdf0e10cSrcweir rtl_freeMemory(pPaperSizes);
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir break;
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir if( (nFlags & SAL_JOBSET_DUPLEXMODE) )
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir switch( pSetupData->meDuplexMode )
1337cdf0e10cSrcweir {
1338cdf0e10cSrcweir case DUPLEX_OFF:
1339cdf0e10cSrcweir CHOOSE_DEVMODE(dmFields) |= DM_DUPLEX;
1340cdf0e10cSrcweir CHOOSE_DEVMODE(dmDuplex) = DMDUP_SIMPLEX;
1341cdf0e10cSrcweir break;
1342cdf0e10cSrcweir case DUPLEX_SHORTEDGE:
1343cdf0e10cSrcweir CHOOSE_DEVMODE(dmFields) |= DM_DUPLEX;
1344cdf0e10cSrcweir CHOOSE_DEVMODE(dmDuplex) = DMDUP_HORIZONTAL;
1345cdf0e10cSrcweir break;
1346cdf0e10cSrcweir case DUPLEX_LONGEDGE:
1347cdf0e10cSrcweir CHOOSE_DEVMODE(dmFields) |= DM_DUPLEX;
1348cdf0e10cSrcweir CHOOSE_DEVMODE(dmDuplex) = DMDUP_VERTICAL;
1349cdf0e10cSrcweir break;
1350cdf0e10cSrcweir case DUPLEX_UNKNOWN:
1351cdf0e10cSrcweir break;
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir // -----------------------------------------------------------------------
1357cdf0e10cSrcweir
ImplCreateICW_WithCatch(LPWSTR pDriver,LPCWSTR pDevice,LPDEVMODEW pDevMode)1358cdf0e10cSrcweir static HDC ImplCreateICW_WithCatch( LPWSTR pDriver,
1359cdf0e10cSrcweir LPCWSTR pDevice,
1360cdf0e10cSrcweir LPDEVMODEW pDevMode )
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir HDC hDC = 0;
1363cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
1364cdf0e10cSrcweir hDC = CreateICW( pDriver, pDevice, 0, pDevMode );
1365cdf0e10cSrcweir CATCH_DRIVER_EX_END_2( "exception in CreateICW" );
1366cdf0e10cSrcweir return hDC;
1367cdf0e10cSrcweir }
1368cdf0e10cSrcweir
ImplCreateICA_WithCatch(char * pDriver,char * pDevice,LPDEVMODEA pDevMode)1369cdf0e10cSrcweir static HDC ImplCreateICA_WithCatch( char* pDriver,
1370cdf0e10cSrcweir char* pDevice,
1371cdf0e10cSrcweir LPDEVMODEA pDevMode )
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir HDC hDC = 0;
1374cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
1375cdf0e10cSrcweir hDC = CreateICA( pDriver, pDevice, 0, pDevMode );
1376cdf0e10cSrcweir CATCH_DRIVER_EX_END_2( "exception in CreateICW" );
1377cdf0e10cSrcweir return hDC;
1378cdf0e10cSrcweir }
1379cdf0e10cSrcweir
1380cdf0e10cSrcweir
ImplCreateSalPrnIC(WinSalInfoPrinter * pPrinter,ImplJobSetup * pSetupData)1381cdf0e10cSrcweir static HDC ImplCreateSalPrnIC( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData )
1382cdf0e10cSrcweir {
1383cdf0e10cSrcweir HDC hDC = 0;
1384cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
1385cdf0e10cSrcweir {
1386cdf0e10cSrcweir LPDEVMODEW pDevMode;
1387cdf0e10cSrcweir if ( pSetupData && pSetupData->mpDriverData )
1388cdf0e10cSrcweir pDevMode = SAL_DEVMODE_W( pSetupData );
1389cdf0e10cSrcweir else
1390cdf0e10cSrcweir pDevMode = NULL;
1391cdf0e10cSrcweir // #95347 some buggy drivers (eg, OKI) write to those buffers in CreateIC, although declared const - so provide some space
1392cdf0e10cSrcweir // pl: does this hold true for Unicode functions ?
1393cdf0e10cSrcweir if( pPrinter->maDriverName.Len() > 2048 || pPrinter->maDeviceName.Len() > 2048 )
1394cdf0e10cSrcweir return 0;
1395cdf0e10cSrcweir sal_Unicode pDriverName[ 4096 ];
1396cdf0e10cSrcweir sal_Unicode pDeviceName[ 4096 ];
1397cdf0e10cSrcweir rtl_copyMemory( pDriverName, pPrinter->maDriverName.GetBuffer(), pPrinter->maDriverName.Len()*sizeof(sal_Unicode));
1398cdf0e10cSrcweir memset( pDriverName+pPrinter->maDriverName.Len(), 0, 32 );
1399cdf0e10cSrcweir rtl_copyMemory( pDeviceName, pPrinter->maDeviceName.GetBuffer(), pPrinter->maDeviceName.Len()*sizeof(sal_Unicode));
1400cdf0e10cSrcweir memset( pDeviceName+pPrinter->maDeviceName.Len(), 0, 32 );
1401cdf0e10cSrcweir hDC = ImplCreateICW_WithCatch( reinterpret_cast< LPWSTR >(pDriverName),
1402cdf0e10cSrcweir reinterpret_cast< LPCWSTR >(pDeviceName),
1403cdf0e10cSrcweir pDevMode );
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir else
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir LPDEVMODEA pDevMode;
1408cdf0e10cSrcweir if ( pSetupData && pSetupData->mpDriverData )
1409cdf0e10cSrcweir pDevMode = SAL_DEVMODE_A( pSetupData );
1410cdf0e10cSrcweir else
1411cdf0e10cSrcweir pDevMode = NULL;
1412cdf0e10cSrcweir // #95347 some buggy drivers (eg, OKI) write to those buffers in CreateIC, although declared const - so provide some space
1413cdf0e10cSrcweir ByteString aDriver ( ImplSalGetWinAnsiString( pPrinter->maDriverName, TRUE ) );
1414cdf0e10cSrcweir ByteString aDevice ( ImplSalGetWinAnsiString( pPrinter->maDeviceName, TRUE ) );
1415cdf0e10cSrcweir int n = aDriver.Len() > aDevice.Len() ? aDriver.Len() : aDevice.Len();
1416cdf0e10cSrcweir // #125813# under some circumstances many printer drivers really
1417cdf0e10cSrcweir // seem to have a problem with the names and their conversions.
1418cdf0e10cSrcweir // We need to get on to of this, but haven't been able to reproduce
1419cdf0e10cSrcweir // the problem yet. Put the names on the stack so we get them
1420cdf0e10cSrcweir // with an eventual crash report.
1421cdf0e10cSrcweir if( n >= 2048 )
1422cdf0e10cSrcweir return 0;
1423cdf0e10cSrcweir n += 2048;
1424cdf0e10cSrcweir char lpszDriverName[ 4096 ];
1425cdf0e10cSrcweir char lpszDeviceName[ 4096 ];
1426cdf0e10cSrcweir strncpy( lpszDriverName, aDriver.GetBuffer(), n );
1427cdf0e10cSrcweir strncpy( lpszDeviceName, aDevice.GetBuffer(), n );
1428cdf0e10cSrcweir // HDU: the crashes usually happen in a MBCS to unicode conversion,
1429cdf0e10cSrcweir // so I suspect the MBCS string's end is not properly recognized.
1430cdf0e10cSrcweir // The longest MBCS encoding I'm aware of has six bytes per code
1431cdf0e10cSrcweir // => add a couple of zeroes...
1432cdf0e10cSrcweir memset( lpszDriverName+aDriver.Len(), 0, 16 );
1433cdf0e10cSrcweir memset( lpszDeviceName+aDevice.Len(), 0, 16 );
1434cdf0e10cSrcweir hDC = ImplCreateICA_WithCatch( lpszDriverName,
1435cdf0e10cSrcweir lpszDeviceName,
1436cdf0e10cSrcweir pDevMode );
1437cdf0e10cSrcweir }
1438cdf0e10cSrcweir return hDC;
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir
1441cdf0e10cSrcweir // -----------------------------------------------------------------------
1442cdf0e10cSrcweir
ImplCreateSalPrnGraphics(HDC hDC)1443cdf0e10cSrcweir static WinSalGraphics* ImplCreateSalPrnGraphics( HDC hDC )
1444cdf0e10cSrcweir {
1445cdf0e10cSrcweir WinSalGraphics* pGraphics = new WinSalGraphics;
1446cdf0e10cSrcweir pGraphics->SetLayout( 0 );
14475f27b83cSArmin Le Grand pGraphics->setHDC(hDC);
1448cdf0e10cSrcweir pGraphics->mhWnd = 0;
1449cdf0e10cSrcweir pGraphics->mbPrinter = TRUE;
1450cdf0e10cSrcweir pGraphics->mbVirDev = FALSE;
1451cdf0e10cSrcweir pGraphics->mbWindow = FALSE;
1452cdf0e10cSrcweir pGraphics->mbScreen = FALSE;
1453cdf0e10cSrcweir ImplSalInitGraphics( pGraphics );
1454cdf0e10cSrcweir return pGraphics;
1455cdf0e10cSrcweir }
1456cdf0e10cSrcweir
1457cdf0e10cSrcweir // -----------------------------------------------------------------------
1458cdf0e10cSrcweir
ImplUpdateSalPrnIC(WinSalInfoPrinter * pPrinter,ImplJobSetup * pSetupData)1459cdf0e10cSrcweir static sal_Bool ImplUpdateSalPrnIC( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData )
1460cdf0e10cSrcweir {
1461cdf0e10cSrcweir HDC hNewDC = ImplCreateSalPrnIC( pPrinter, pSetupData );
1462cdf0e10cSrcweir if ( !hNewDC )
1463cdf0e10cSrcweir return FALSE;
1464cdf0e10cSrcweir
1465cdf0e10cSrcweir if ( pPrinter->mpGraphics )
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir ImplSalDeInitGraphics( pPrinter->mpGraphics );
14685f27b83cSArmin Le Grand DeleteDC( pPrinter->mpGraphics->getHDC() );
1469cdf0e10cSrcweir delete pPrinter->mpGraphics;
1470cdf0e10cSrcweir }
1471cdf0e10cSrcweir
1472cdf0e10cSrcweir pPrinter->mpGraphics = ImplCreateSalPrnGraphics( hNewDC );
1473cdf0e10cSrcweir pPrinter->mhDC = hNewDC;
1474cdf0e10cSrcweir
1475cdf0e10cSrcweir return TRUE;
1476cdf0e10cSrcweir }
1477cdf0e10cSrcweir
1478cdf0e10cSrcweir // =======================================================================
1479cdf0e10cSrcweir
CreateInfoPrinter(SalPrinterQueueInfo * pQueueInfo,ImplJobSetup * pSetupData)1480cdf0e10cSrcweir SalInfoPrinter* WinSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
1481cdf0e10cSrcweir ImplJobSetup* pSetupData )
1482cdf0e10cSrcweir {
1483cdf0e10cSrcweir WinSalInfoPrinter* pPrinter = new WinSalInfoPrinter;
1484cdf0e10cSrcweir if( ! pQueueInfo->mpSysData )
1485cdf0e10cSrcweir GetPrinterQueueState( pQueueInfo );
1486cdf0e10cSrcweir pPrinter->maDriverName = pQueueInfo->maDriver;
1487cdf0e10cSrcweir pPrinter->maDeviceName = pQueueInfo->maPrinterName;
1488*b4953498Smseidel pPrinter->maPortName = pQueueInfo->mpSysData ?
1489cdf0e10cSrcweir *(String*)(pQueueInfo->mpSysData)
1490cdf0e10cSrcweir : String();
1491cdf0e10cSrcweir
1492cdf0e10cSrcweir // check if the provided setup data match the actual printer
1493cdf0e10cSrcweir ImplTestSalJobSetup( pPrinter, pSetupData, TRUE );
1494cdf0e10cSrcweir
1495cdf0e10cSrcweir HDC hDC = ImplCreateSalPrnIC( pPrinter, pSetupData );
1496cdf0e10cSrcweir if ( !hDC )
1497cdf0e10cSrcweir {
1498cdf0e10cSrcweir delete pPrinter;
1499cdf0e10cSrcweir return NULL;
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir
1502cdf0e10cSrcweir pPrinter->mpGraphics = ImplCreateSalPrnGraphics( hDC );
1503cdf0e10cSrcweir pPrinter->mhDC = hDC;
1504cdf0e10cSrcweir if ( !pSetupData->mpDriverData )
1505cdf0e10cSrcweir ImplUpdateSalJobSetup( pPrinter, pSetupData, FALSE, NULL );
1506cdf0e10cSrcweir ImplDevModeToJobSetup( pPrinter, pSetupData, SAL_JOBSET_ALL );
1507cdf0e10cSrcweir pSetupData->mnSystem = JOBSETUP_SYSTEM_WINDOWS;
1508cdf0e10cSrcweir
1509cdf0e10cSrcweir return pPrinter;
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir
1512cdf0e10cSrcweir // -----------------------------------------------------------------------
1513cdf0e10cSrcweir
DestroyInfoPrinter(SalInfoPrinter * pPrinter)1514cdf0e10cSrcweir void WinSalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir delete pPrinter;
1517cdf0e10cSrcweir }
1518cdf0e10cSrcweir
1519cdf0e10cSrcweir // =======================================================================
1520cdf0e10cSrcweir
WinSalInfoPrinter()1521cdf0e10cSrcweir WinSalInfoPrinter::WinSalInfoPrinter() :
1522cdf0e10cSrcweir mpGraphics( NULL ),
1523cdf0e10cSrcweir mhDC( 0 ),
1524cdf0e10cSrcweir mbGraphics( FALSE )
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir m_bPapersInit = FALSE;
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir
1529cdf0e10cSrcweir // -----------------------------------------------------------------------
1530cdf0e10cSrcweir
~WinSalInfoPrinter()1531cdf0e10cSrcweir WinSalInfoPrinter::~WinSalInfoPrinter()
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir if ( mpGraphics )
1534cdf0e10cSrcweir {
1535cdf0e10cSrcweir ImplSalDeInitGraphics( mpGraphics );
15365f27b83cSArmin Le Grand DeleteDC( mpGraphics->getHDC() );
1537cdf0e10cSrcweir delete mpGraphics;
1538cdf0e10cSrcweir }
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir
1541cdf0e10cSrcweir // -----------------------------------------------------------------------
1542cdf0e10cSrcweir
InitPaperFormats(const ImplJobSetup * pSetupData)1543cdf0e10cSrcweir void WinSalInfoPrinter::InitPaperFormats( const ImplJobSetup* pSetupData )
1544cdf0e10cSrcweir {
1545cdf0e10cSrcweir m_aPaperFormats.clear();
1546cdf0e10cSrcweir
1547cdf0e10cSrcweir DWORD nCount = ImplDeviceCaps( this, DC_PAPERSIZE, NULL, pSetupData );
1548cdf0e10cSrcweir if( nCount == GDI_ERROR )
1549cdf0e10cSrcweir nCount = 0;
1550cdf0e10cSrcweir
1551cdf0e10cSrcweir POINT* pPaperSizes = NULL;
1552cdf0e10cSrcweir if( nCount )
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir pPaperSizes = (POINT*)rtl_allocateZeroMemory(nCount*sizeof(POINT));
1555cdf0e10cSrcweir ImplDeviceCaps( this, DC_PAPERSIZE, (BYTE*)pPaperSizes, pSetupData );
1556cdf0e10cSrcweir
1557cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
1558cdf0e10cSrcweir {
1559cdf0e10cSrcweir sal_Unicode* pNamesBuffer = (sal_Unicode*)rtl_allocateMemory(nCount*64*sizeof(sal_Unicode));
1560cdf0e10cSrcweir ImplDeviceCaps( this, DC_PAPERNAMES, (BYTE*)pNamesBuffer, pSetupData );
1561cdf0e10cSrcweir for( DWORD i = 0; i < nCount; ++i )
1562cdf0e10cSrcweir {
1563cdf0e10cSrcweir PaperInfo aInfo(pPaperSizes[i].x * 10, pPaperSizes[i].y * 10);
1564cdf0e10cSrcweir m_aPaperFormats.push_back( aInfo );
1565cdf0e10cSrcweir }
1566cdf0e10cSrcweir rtl_freeMemory( pNamesBuffer );
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir else
1569cdf0e10cSrcweir {
1570cdf0e10cSrcweir char* pNamesBuffer = (char*)rtl_allocateMemory(nCount*64);
1571cdf0e10cSrcweir ImplDeviceCaps( this, DC_PAPERNAMES, (BYTE*)pNamesBuffer, pSetupData );
1572cdf0e10cSrcweir for( DWORD i = 0; i < nCount; ++i )
1573cdf0e10cSrcweir {
1574cdf0e10cSrcweir PaperInfo aInfo(pPaperSizes[i].x * 10, pPaperSizes[i].y * 10);
1575cdf0e10cSrcweir m_aPaperFormats.push_back( aInfo );
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir rtl_freeMemory( pNamesBuffer );
1578cdf0e10cSrcweir }
1579cdf0e10cSrcweir rtl_freeMemory( pPaperSizes );
1580cdf0e10cSrcweir }
1581cdf0e10cSrcweir
1582cdf0e10cSrcweir m_bPapersInit = true;
1583cdf0e10cSrcweir }
1584cdf0e10cSrcweir
1585cdf0e10cSrcweir // -----------------------------------------------------------------------
1586cdf0e10cSrcweir
GetLandscapeAngle(const ImplJobSetup * pSetupData)1587cdf0e10cSrcweir int WinSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* pSetupData )
1588cdf0e10cSrcweir {
1589cdf0e10cSrcweir int nRet = ImplDeviceCaps( this, DC_ORIENTATION, NULL, pSetupData );
1590cdf0e10cSrcweir
1591cdf0e10cSrcweir if( nRet != GDI_ERROR )
1592cdf0e10cSrcweir return nRet * 10;
1593cdf0e10cSrcweir else
1594cdf0e10cSrcweir return 900; // guess
1595cdf0e10cSrcweir }
1596cdf0e10cSrcweir
1597cdf0e10cSrcweir // -----------------------------------------------------------------------
1598cdf0e10cSrcweir
GetGraphics()1599cdf0e10cSrcweir SalGraphics* WinSalInfoPrinter::GetGraphics()
1600cdf0e10cSrcweir {
1601cdf0e10cSrcweir if ( mbGraphics )
1602cdf0e10cSrcweir return NULL;
1603cdf0e10cSrcweir
1604cdf0e10cSrcweir if ( mpGraphics )
1605cdf0e10cSrcweir mbGraphics = TRUE;
1606cdf0e10cSrcweir
1607cdf0e10cSrcweir return mpGraphics;
1608cdf0e10cSrcweir }
1609cdf0e10cSrcweir
1610cdf0e10cSrcweir // -----------------------------------------------------------------------
1611cdf0e10cSrcweir
ReleaseGraphics(SalGraphics *)1612cdf0e10cSrcweir void WinSalInfoPrinter::ReleaseGraphics( SalGraphics* )
1613cdf0e10cSrcweir {
1614cdf0e10cSrcweir mbGraphics = FALSE;
1615cdf0e10cSrcweir }
1616cdf0e10cSrcweir
1617cdf0e10cSrcweir // -----------------------------------------------------------------------
1618cdf0e10cSrcweir
Setup(SalFrame * pFrame,ImplJobSetup * pSetupData)1619cdf0e10cSrcweir sal_Bool WinSalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pSetupData )
1620cdf0e10cSrcweir {
1621cdf0e10cSrcweir if ( ImplUpdateSalJobSetup( this, pSetupData, TRUE, static_cast<WinSalFrame*>(pFrame) ) )
1622cdf0e10cSrcweir {
1623cdf0e10cSrcweir ImplDevModeToJobSetup( this, pSetupData, SAL_JOBSET_ALL );
1624cdf0e10cSrcweir return ImplUpdateSalPrnIC( this, pSetupData );
1625cdf0e10cSrcweir }
1626cdf0e10cSrcweir
1627cdf0e10cSrcweir return FALSE;
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir
1630cdf0e10cSrcweir // -----------------------------------------------------------------------
1631cdf0e10cSrcweir
SetPrinterData(ImplJobSetup * pSetupData)1632cdf0e10cSrcweir sal_Bool WinSalInfoPrinter::SetPrinterData( ImplJobSetup* pSetupData )
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir if ( !ImplTestSalJobSetup( this, pSetupData, FALSE ) )
1635cdf0e10cSrcweir return FALSE;
1636cdf0e10cSrcweir return ImplUpdateSalPrnIC( this, pSetupData );
1637cdf0e10cSrcweir }
1638cdf0e10cSrcweir
1639cdf0e10cSrcweir // -----------------------------------------------------------------------
1640cdf0e10cSrcweir
SetData(sal_uLong nFlags,ImplJobSetup * pSetupData)1641cdf0e10cSrcweir sal_Bool WinSalInfoPrinter::SetData( sal_uLong nFlags, ImplJobSetup* pSetupData )
1642cdf0e10cSrcweir {
1643cdf0e10cSrcweir ImplJobSetupToDevMode( this, pSetupData, nFlags );
1644cdf0e10cSrcweir if ( ImplUpdateSalJobSetup( this, pSetupData, TRUE, NULL ) )
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir ImplDevModeToJobSetup( this, pSetupData, nFlags );
1647cdf0e10cSrcweir return ImplUpdateSalPrnIC( this, pSetupData );
1648cdf0e10cSrcweir }
1649cdf0e10cSrcweir
1650cdf0e10cSrcweir return FALSE;
1651cdf0e10cSrcweir }
1652cdf0e10cSrcweir
1653cdf0e10cSrcweir // -----------------------------------------------------------------------
1654cdf0e10cSrcweir
GetPaperBinCount(const ImplJobSetup * pSetupData)1655cdf0e10cSrcweir sal_uLong WinSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pSetupData )
1656cdf0e10cSrcweir {
1657cdf0e10cSrcweir DWORD nRet = ImplDeviceCaps( this, DC_BINS, NULL, pSetupData );
1658cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1659cdf0e10cSrcweir return nRet;
1660cdf0e10cSrcweir else
1661cdf0e10cSrcweir return 0;
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir
1664cdf0e10cSrcweir // -----------------------------------------------------------------------
1665cdf0e10cSrcweir
GetPaperBinName(const ImplJobSetup * pSetupData,sal_uLong nPaperBin)1666cdf0e10cSrcweir XubString WinSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, sal_uLong nPaperBin )
1667cdf0e10cSrcweir {
1668cdf0e10cSrcweir XubString aPaperBinName;
1669cdf0e10cSrcweir
1670cdf0e10cSrcweir DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, NULL, pSetupData );
1671cdf0e10cSrcweir if ( (nPaperBin < nBins) && (nBins != GDI_ERROR) )
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
1674cdf0e10cSrcweir {
1675cdf0e10cSrcweir sal_Unicode* pBuffer = new sal_Unicode[nBins*24];
1676cdf0e10cSrcweir DWORD nRet = ImplDeviceCaps( this, DC_BINNAMES, (BYTE*)pBuffer, pSetupData );
1677cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1678cdf0e10cSrcweir aPaperBinName = pBuffer + (nPaperBin*24);
1679cdf0e10cSrcweir delete [] pBuffer;
1680cdf0e10cSrcweir }
1681cdf0e10cSrcweir else
1682cdf0e10cSrcweir {
1683cdf0e10cSrcweir char* pBuffer = new char[nBins*24];
1684cdf0e10cSrcweir DWORD nRet = ImplDeviceCaps( this, DC_BINNAMES, (BYTE*)pBuffer, pSetupData );
1685cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1686cdf0e10cSrcweir aPaperBinName = ImplSalGetUniString( (const char*)(pBuffer + (nPaperBin*24)) );
1687cdf0e10cSrcweir delete [] pBuffer;
1688cdf0e10cSrcweir }
1689cdf0e10cSrcweir }
1690cdf0e10cSrcweir
1691cdf0e10cSrcweir return aPaperBinName;
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir
1694cdf0e10cSrcweir // -----------------------------------------------------------------------
1695cdf0e10cSrcweir
GetCapabilities(const ImplJobSetup * pSetupData,sal_uInt16 nType)1696cdf0e10cSrcweir sal_uLong WinSalInfoPrinter::GetCapabilities( const ImplJobSetup* pSetupData, sal_uInt16 nType )
1697cdf0e10cSrcweir {
1698cdf0e10cSrcweir DWORD nRet;
1699cdf0e10cSrcweir
1700cdf0e10cSrcweir switch ( nType )
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir case PRINTER_CAPABILITIES_SUPPORTDIALOG:
1703cdf0e10cSrcweir return TRUE;
1704cdf0e10cSrcweir case PRINTER_CAPABILITIES_COPIES:
1705cdf0e10cSrcweir nRet = ImplDeviceCaps( this, DC_COPIES, NULL, pSetupData );
1706cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1707cdf0e10cSrcweir return nRet;
1708cdf0e10cSrcweir return 0;
1709cdf0e10cSrcweir case PRINTER_CAPABILITIES_COLLATECOPIES:
1710cdf0e10cSrcweir if ( aSalShlData.mbW40 )
1711cdf0e10cSrcweir {
1712cdf0e10cSrcweir nRet = ImplDeviceCaps( this, DC_COLLATE, NULL, pSetupData );
1713cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1714cdf0e10cSrcweir {
1715cdf0e10cSrcweir nRet = ImplDeviceCaps( this, DC_COPIES, NULL, pSetupData );
1716cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1717cdf0e10cSrcweir return nRet;
1718cdf0e10cSrcweir }
1719cdf0e10cSrcweir }
1720cdf0e10cSrcweir return 0;
1721cdf0e10cSrcweir
1722cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETORIENTATION:
1723cdf0e10cSrcweir nRet = ImplDeviceCaps( this, DC_ORIENTATION, NULL, pSetupData );
1724cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1725cdf0e10cSrcweir return TRUE;
1726cdf0e10cSrcweir return FALSE;
1727cdf0e10cSrcweir
1728cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETPAPERBIN:
1729cdf0e10cSrcweir nRet = ImplDeviceCaps( this, DC_BINS, NULL, pSetupData );
1730cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1731cdf0e10cSrcweir return TRUE;
1732cdf0e10cSrcweir return FALSE;
1733cdf0e10cSrcweir
1734cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETPAPERSIZE:
1735cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETPAPER:
1736cdf0e10cSrcweir nRet = ImplDeviceCaps( this, DC_PAPERS, NULL, pSetupData );
1737cdf0e10cSrcweir if ( nRet && (nRet != GDI_ERROR) )
1738cdf0e10cSrcweir return TRUE;
1739cdf0e10cSrcweir return FALSE;
1740cdf0e10cSrcweir }
1741cdf0e10cSrcweir
1742cdf0e10cSrcweir return 0;
1743cdf0e10cSrcweir }
1744cdf0e10cSrcweir
1745cdf0e10cSrcweir // -----------------------------------------------------------------------
1746cdf0e10cSrcweir
GetPageInfo(const ImplJobSetup *,long & rOutWidth,long & rOutHeight,long & rPageOffX,long & rPageOffY,long & rPageWidth,long & rPageHeight)1747cdf0e10cSrcweir void WinSalInfoPrinter::GetPageInfo( const ImplJobSetup*,
1748cdf0e10cSrcweir long& rOutWidth, long& rOutHeight,
1749cdf0e10cSrcweir long& rPageOffX, long& rPageOffY,
1750cdf0e10cSrcweir long& rPageWidth, long& rPageHeight )
1751cdf0e10cSrcweir {
1752cdf0e10cSrcweir HDC hDC = mhDC;
1753cdf0e10cSrcweir
1754cdf0e10cSrcweir rOutWidth = GetDeviceCaps( hDC, HORZRES );
1755cdf0e10cSrcweir rOutHeight = GetDeviceCaps( hDC, VERTRES );
1756cdf0e10cSrcweir
1757cdf0e10cSrcweir rPageOffX = GetDeviceCaps( hDC, PHYSICALOFFSETX );
1758cdf0e10cSrcweir rPageOffY = GetDeviceCaps( hDC, PHYSICALOFFSETY );
1759cdf0e10cSrcweir rPageWidth = GetDeviceCaps( hDC, PHYSICALWIDTH );
1760cdf0e10cSrcweir rPageHeight = GetDeviceCaps( hDC, PHYSICALHEIGHT );
1761cdf0e10cSrcweir }
1762cdf0e10cSrcweir
1763cdf0e10cSrcweir // =======================================================================
1764cdf0e10cSrcweir
CreatePrinter(SalInfoPrinter * pInfoPrinter)1765cdf0e10cSrcweir SalPrinter* WinSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
1766cdf0e10cSrcweir {
1767cdf0e10cSrcweir WinSalPrinter* pPrinter = new WinSalPrinter;
1768cdf0e10cSrcweir pPrinter->mpInfoPrinter = static_cast<WinSalInfoPrinter*>(pInfoPrinter);
1769cdf0e10cSrcweir return pPrinter;
1770cdf0e10cSrcweir }
1771cdf0e10cSrcweir
1772cdf0e10cSrcweir // -----------------------------------------------------------------------
1773cdf0e10cSrcweir
DestroyPrinter(SalPrinter * pPrinter)1774cdf0e10cSrcweir void WinSalInstance::DestroyPrinter( SalPrinter* pPrinter )
1775cdf0e10cSrcweir {
1776cdf0e10cSrcweir delete pPrinter;
1777cdf0e10cSrcweir }
1778cdf0e10cSrcweir
1779cdf0e10cSrcweir // =======================================================================
1780cdf0e10cSrcweir
SalPrintAbortProc(HDC hPrnDC,int)1781cdf0e10cSrcweir BOOL CALLBACK SalPrintAbortProc( HDC hPrnDC, int /* nError */ )
1782cdf0e10cSrcweir {
1783cdf0e10cSrcweir SalData* pSalData = GetSalData();
1784cdf0e10cSrcweir WinSalPrinter* pPrinter;
1785cdf0e10cSrcweir sal_Bool bWhile = TRUE;
1786cdf0e10cSrcweir int i = 0;
1787cdf0e10cSrcweir
1788cdf0e10cSrcweir do
1789cdf0e10cSrcweir {
1790cdf0e10cSrcweir // Messages verarbeiten
1791cdf0e10cSrcweir MSG aMsg;
1792cdf0e10cSrcweir if ( ImplPeekMessage( &aMsg, 0, 0, 0, PM_REMOVE ) )
1793cdf0e10cSrcweir {
1794cdf0e10cSrcweir if ( !ImplInterceptChildWindowKeyDown( aMsg ) )
1795cdf0e10cSrcweir {
1796cdf0e10cSrcweir TranslateMessage( &aMsg );
1797cdf0e10cSrcweir ImplDispatchMessage( &aMsg );
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir i++;
1800cdf0e10cSrcweir if ( i > 15 )
1801cdf0e10cSrcweir bWhile = FALSE;
1802cdf0e10cSrcweir }
1803cdf0e10cSrcweir else
1804cdf0e10cSrcweir bWhile = FALSE;
1805cdf0e10cSrcweir
1806cdf0e10cSrcweir pPrinter = pSalData->mpFirstPrinter;
1807cdf0e10cSrcweir while ( pPrinter )
1808cdf0e10cSrcweir {
1809cdf0e10cSrcweir if( pPrinter->mhDC == hPrnDC )
1810cdf0e10cSrcweir break;
1811cdf0e10cSrcweir
1812cdf0e10cSrcweir pPrinter = pPrinter->mpNextPrinter;
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir
1815cdf0e10cSrcweir if ( !pPrinter || pPrinter->mbAbort )
1816cdf0e10cSrcweir return FALSE;
1817cdf0e10cSrcweir }
1818cdf0e10cSrcweir while ( bWhile );
1819cdf0e10cSrcweir
1820cdf0e10cSrcweir return TRUE;
1821cdf0e10cSrcweir }
1822cdf0e10cSrcweir
1823cdf0e10cSrcweir // -----------------------------------------------------------------------
1824cdf0e10cSrcweir
ImplSalSetCopies(LPDEVMODEA pDevMode,sal_uLong nCopies,sal_Bool bCollate)1825cdf0e10cSrcweir static LPDEVMODEA ImplSalSetCopies( LPDEVMODEA pDevMode, sal_uLong nCopies, sal_Bool bCollate )
1826cdf0e10cSrcweir {
1827cdf0e10cSrcweir LPDEVMODEA pNewDevMode = pDevMode;
1828cdf0e10cSrcweir if ( pDevMode && (nCopies > 1) )
1829cdf0e10cSrcweir {
1830cdf0e10cSrcweir if ( nCopies > 32765 )
1831cdf0e10cSrcweir nCopies = 32765;
1832cdf0e10cSrcweir sal_uLong nDevSize = pDevMode->dmSize+pDevMode->dmDriverExtra;
1833cdf0e10cSrcweir pNewDevMode = (LPDEVMODEA)rtl_allocateMemory( nDevSize );
1834cdf0e10cSrcweir memcpy( pNewDevMode, pDevMode, nDevSize );
1835cdf0e10cSrcweir pDevMode = pNewDevMode;
1836cdf0e10cSrcweir pDevMode->dmFields |= DM_COPIES;
1837cdf0e10cSrcweir pDevMode->dmCopies = (short)(sal_uInt16)nCopies;
1838cdf0e10cSrcweir if ( aSalShlData.mbW40 )
1839cdf0e10cSrcweir {
1840cdf0e10cSrcweir pDevMode->dmFields |= DM_COLLATE;
1841cdf0e10cSrcweir if ( bCollate )
1842cdf0e10cSrcweir pDevMode->dmCollate = DMCOLLATE_TRUE;
1843cdf0e10cSrcweir else
1844cdf0e10cSrcweir pDevMode->dmCollate = DMCOLLATE_FALSE;
1845cdf0e10cSrcweir }
1846cdf0e10cSrcweir }
1847cdf0e10cSrcweir
1848cdf0e10cSrcweir return pNewDevMode;
1849cdf0e10cSrcweir }
1850cdf0e10cSrcweir
ImplSalSetCopies(LPDEVMODEW pDevMode,sal_uLong nCopies,sal_Bool bCollate)1851cdf0e10cSrcweir static LPDEVMODEW ImplSalSetCopies( LPDEVMODEW pDevMode, sal_uLong nCopies, sal_Bool bCollate )
1852cdf0e10cSrcweir {
1853cdf0e10cSrcweir LPDEVMODEW pNewDevMode = pDevMode;
1854cdf0e10cSrcweir if ( pDevMode && (nCopies > 1) )
1855cdf0e10cSrcweir {
1856cdf0e10cSrcweir if ( nCopies > 32765 )
1857cdf0e10cSrcweir nCopies = 32765;
1858cdf0e10cSrcweir sal_uLong nDevSize = pDevMode->dmSize+pDevMode->dmDriverExtra;
1859cdf0e10cSrcweir pNewDevMode = (LPDEVMODEW)rtl_allocateMemory( nDevSize );
1860cdf0e10cSrcweir memcpy( pNewDevMode, pDevMode, nDevSize );
1861cdf0e10cSrcweir pDevMode = pNewDevMode;
1862cdf0e10cSrcweir pDevMode->dmFields |= DM_COPIES;
1863cdf0e10cSrcweir pDevMode->dmCopies = (short)(sal_uInt16)nCopies;
1864cdf0e10cSrcweir if ( aSalShlData.mbW40 )
1865cdf0e10cSrcweir {
1866cdf0e10cSrcweir pDevMode->dmFields |= DM_COLLATE;
1867cdf0e10cSrcweir if ( bCollate )
1868cdf0e10cSrcweir pDevMode->dmCollate = DMCOLLATE_TRUE;
1869cdf0e10cSrcweir else
1870cdf0e10cSrcweir pDevMode->dmCollate = DMCOLLATE_FALSE;
1871cdf0e10cSrcweir }
1872cdf0e10cSrcweir }
1873cdf0e10cSrcweir
1874cdf0e10cSrcweir return pNewDevMode;
1875cdf0e10cSrcweir }
1876cdf0e10cSrcweir
1877cdf0e10cSrcweir // -----------------------------------------------------------------------
1878cdf0e10cSrcweir
WinSalPrinter()1879cdf0e10cSrcweir WinSalPrinter::WinSalPrinter() :
1880cdf0e10cSrcweir mpGraphics( NULL ),
1881cdf0e10cSrcweir mpInfoPrinter( NULL ),
1882cdf0e10cSrcweir mpNextPrinter( NULL ),
1883cdf0e10cSrcweir mhDC( 0 ),
1884cdf0e10cSrcweir mnError( 0 ),
1885cdf0e10cSrcweir mnCopies( 0 ),
1886cdf0e10cSrcweir mbCollate( FALSE ),
1887cdf0e10cSrcweir mbAbort( FALSE ),
1888cdf0e10cSrcweir mbValid( true )
1889cdf0e10cSrcweir {
1890cdf0e10cSrcweir SalData* pSalData = GetSalData();
1891cdf0e10cSrcweir // insert printer in printerlist
1892cdf0e10cSrcweir mpNextPrinter = pSalData->mpFirstPrinter;
1893cdf0e10cSrcweir pSalData->mpFirstPrinter = this;
1894cdf0e10cSrcweir }
1895cdf0e10cSrcweir
1896cdf0e10cSrcweir // -----------------------------------------------------------------------
1897cdf0e10cSrcweir
~WinSalPrinter()1898cdf0e10cSrcweir WinSalPrinter::~WinSalPrinter()
1899cdf0e10cSrcweir {
1900cdf0e10cSrcweir SalData* pSalData = GetSalData();
1901cdf0e10cSrcweir
1902cdf0e10cSrcweir // release DC if there is one still around because of AbortJob
1903cdf0e10cSrcweir HDC hDC = mhDC;
1904cdf0e10cSrcweir if ( hDC )
1905cdf0e10cSrcweir {
1906cdf0e10cSrcweir if ( mpGraphics )
1907cdf0e10cSrcweir {
1908cdf0e10cSrcweir ImplSalDeInitGraphics( mpGraphics );
1909cdf0e10cSrcweir delete mpGraphics;
1910cdf0e10cSrcweir }
1911cdf0e10cSrcweir
1912cdf0e10cSrcweir DeleteDC( hDC );
1913cdf0e10cSrcweir }
1914cdf0e10cSrcweir
1915cdf0e10cSrcweir // remove printer from printerlist
1916cdf0e10cSrcweir if ( this == pSalData->mpFirstPrinter )
1917cdf0e10cSrcweir pSalData->mpFirstPrinter = mpNextPrinter;
1918cdf0e10cSrcweir else
1919cdf0e10cSrcweir {
1920cdf0e10cSrcweir WinSalPrinter* pTempPrinter = pSalData->mpFirstPrinter;
1921cdf0e10cSrcweir
1922cdf0e10cSrcweir while( pTempPrinter->mpNextPrinter != this )
1923cdf0e10cSrcweir pTempPrinter = pTempPrinter->mpNextPrinter;
1924cdf0e10cSrcweir
1925cdf0e10cSrcweir pTempPrinter->mpNextPrinter = mpNextPrinter;
1926cdf0e10cSrcweir }
1927cdf0e10cSrcweir mbValid = false;
1928cdf0e10cSrcweir }
1929cdf0e10cSrcweir
1930cdf0e10cSrcweir // -----------------------------------------------------------------------
1931cdf0e10cSrcweir
markInvalid()1932cdf0e10cSrcweir void WinSalPrinter::markInvalid()
1933cdf0e10cSrcweir {
1934cdf0e10cSrcweir mbValid = false;
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir
1937cdf0e10cSrcweir // -----------------------------------------------------------------------
1938cdf0e10cSrcweir
1939cdf0e10cSrcweir // need wrappers for StarTocW/A to use structured exception handling
1940cdf0e10cSrcweir // since SEH does not mix with standard exception handling's cleanup
lcl_StartDocW(HDC hDC,DOCINFOW * pInfo,WinSalPrinter * pPrt)1941cdf0e10cSrcweir static int lcl_StartDocW( HDC hDC, DOCINFOW* pInfo, WinSalPrinter* pPrt )
1942cdf0e10cSrcweir {
1943cdf0e10cSrcweir int nRet = 0;
1944cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
1945cdf0e10cSrcweir nRet = ::StartDocW( hDC, pInfo );
1946cdf0e10cSrcweir CATCH_DRIVER_EX_END( "exception in StartDocW", pPrt );
1947cdf0e10cSrcweir return nRet;
1948cdf0e10cSrcweir }
1949cdf0e10cSrcweir
lcl_StartDocA(HDC hDC,DOCINFOA * pInfo,WinSalPrinter * pPrt)1950cdf0e10cSrcweir static int lcl_StartDocA( HDC hDC, DOCINFOA* pInfo, WinSalPrinter* pPrt )
1951cdf0e10cSrcweir {
1952cdf0e10cSrcweir int nRet = 0;
1953cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
1954cdf0e10cSrcweir nRet = ::StartDocA( hDC, pInfo );
1955cdf0e10cSrcweir CATCH_DRIVER_EX_END( "exception in StartDocW", pPrt );
1956cdf0e10cSrcweir return nRet;
1957cdf0e10cSrcweir }
1958cdf0e10cSrcweir
StartJob(const XubString * pFileName,const XubString & rJobName,const XubString &,sal_uLong nCopies,bool bCollate,bool,ImplJobSetup * pSetupData)1959cdf0e10cSrcweir sal_Bool WinSalPrinter::StartJob( const XubString* pFileName,
1960cdf0e10cSrcweir const XubString& rJobName,
1961cdf0e10cSrcweir const XubString&,
1962cdf0e10cSrcweir sal_uLong nCopies,
1963cdf0e10cSrcweir bool bCollate,
1964cdf0e10cSrcweir bool /*bDirect*/,
1965cdf0e10cSrcweir ImplJobSetup* pSetupData )
1966cdf0e10cSrcweir {
1967cdf0e10cSrcweir mnError = 0;
1968cdf0e10cSrcweir mbAbort = FALSE;
1969cdf0e10cSrcweir mnCopies = nCopies;
1970cdf0e10cSrcweir mbCollate = bCollate;
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir LPDEVMODEA pOrgDevModeA = NULL;
1973cdf0e10cSrcweir LPDEVMODEA pDevModeA = NULL;
1974cdf0e10cSrcweir LPDEVMODEW pOrgDevModeW = NULL;
1975cdf0e10cSrcweir LPDEVMODEW pDevModeW = NULL;
1976cdf0e10cSrcweir HDC hDC = 0;
1977cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
1978cdf0e10cSrcweir {
1979cdf0e10cSrcweir if ( pSetupData && pSetupData->mpDriverData )
1980cdf0e10cSrcweir {
1981cdf0e10cSrcweir pOrgDevModeW = SAL_DEVMODE_W( pSetupData );
1982cdf0e10cSrcweir pDevModeW = ImplSalSetCopies( pOrgDevModeW, nCopies, bCollate );
1983cdf0e10cSrcweir }
1984cdf0e10cSrcweir else
1985cdf0e10cSrcweir pDevModeW = NULL;
1986*b4953498Smseidel
1987*b4953498Smseidel // #95347 some buggy drivers (e.g. OKI) write to those buffers in CreateDC, although declared const - so provide some space
1988cdf0e10cSrcweir sal_Unicode aDrvBuf[4096];
1989cdf0e10cSrcweir sal_Unicode aDevBuf[4096];
1990cdf0e10cSrcweir rtl_copyMemory( aDrvBuf, mpInfoPrinter->maDriverName.GetBuffer(), (mpInfoPrinter->maDriverName.Len()+1)*sizeof(sal_Unicode));
1991cdf0e10cSrcweir rtl_copyMemory( aDevBuf, mpInfoPrinter->maDeviceName.GetBuffer(), (mpInfoPrinter->maDeviceName.Len()+1)*sizeof(sal_Unicode));
1992cdf0e10cSrcweir hDC = CreateDCW( reinterpret_cast<LPCWSTR>(aDrvBuf),
1993cdf0e10cSrcweir reinterpret_cast<LPCWSTR>(aDevBuf),
1994cdf0e10cSrcweir NULL,
1995cdf0e10cSrcweir pDevModeW );
1996*b4953498Smseidel
1997cdf0e10cSrcweir if ( pDevModeW != pOrgDevModeW )
1998cdf0e10cSrcweir rtl_freeMemory( pDevModeW );
1999cdf0e10cSrcweir }
2000cdf0e10cSrcweir else
2001cdf0e10cSrcweir {
2002cdf0e10cSrcweir if ( pSetupData && pSetupData->mpDriverData )
2003cdf0e10cSrcweir {
2004cdf0e10cSrcweir pOrgDevModeA = SAL_DEVMODE_A( pSetupData );
2005cdf0e10cSrcweir pDevModeA = ImplSalSetCopies( pOrgDevModeA, nCopies, bCollate );
2006cdf0e10cSrcweir }
2007cdf0e10cSrcweir else
2008cdf0e10cSrcweir pDevModeA = NULL;
2009*b4953498Smseidel
2010*b4953498Smseidel // #95347 some buggy drivers (e.g. OKI) write to those buffers in CreateDC, although declared const - so provide some space
2011cdf0e10cSrcweir ByteString aDriver ( ImplSalGetWinAnsiString( mpInfoPrinter->maDriverName, TRUE ) );
2012cdf0e10cSrcweir ByteString aDevice ( ImplSalGetWinAnsiString( mpInfoPrinter->maDeviceName, TRUE ) );
2013cdf0e10cSrcweir int n = aDriver.Len() > aDevice.Len() ? aDriver.Len() : aDevice.Len();
2014cdf0e10cSrcweir n += 2048;
2015cdf0e10cSrcweir char *lpszDriverName = new char[n];
2016cdf0e10cSrcweir char *lpszDeviceName = new char[n];
2017cdf0e10cSrcweir strncpy( lpszDriverName, aDriver.GetBuffer(), n );
2018cdf0e10cSrcweir strncpy( lpszDeviceName, aDevice.GetBuffer(), n );
2019cdf0e10cSrcweir hDC = CreateDCA( lpszDriverName,
2020cdf0e10cSrcweir lpszDeviceName,
2021cdf0e10cSrcweir NULL,
2022cdf0e10cSrcweir pDevModeA );
2023*b4953498Smseidel
2024cdf0e10cSrcweir delete [] lpszDriverName;
2025cdf0e10cSrcweir delete [] lpszDeviceName;
2026*b4953498Smseidel
2027cdf0e10cSrcweir if ( pDevModeA != pOrgDevModeA )
2028cdf0e10cSrcweir rtl_freeMemory( pDevModeA );
2029cdf0e10cSrcweir }
2030cdf0e10cSrcweir
2031cdf0e10cSrcweir if ( !hDC )
2032cdf0e10cSrcweir {
2033cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_GENERALERROR;
2034cdf0e10cSrcweir return FALSE;
2035cdf0e10cSrcweir }
2036cdf0e10cSrcweir
2037cdf0e10cSrcweir // make sure mhDC is set before the printer driver may call our abortproc
2038cdf0e10cSrcweir mhDC = hDC;
2039cdf0e10cSrcweir if ( SetAbortProc( hDC, SalPrintAbortProc ) <= 0 )
2040cdf0e10cSrcweir {
2041cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_GENERALERROR;
2042cdf0e10cSrcweir return FALSE;
2043cdf0e10cSrcweir }
2044cdf0e10cSrcweir
2045cdf0e10cSrcweir mnError = 0;
2046cdf0e10cSrcweir mbAbort = FALSE;
2047cdf0e10cSrcweir
2048cdf0e10cSrcweir // Wegen Telocom Balloon Fax-Treiber, der uns unsere Messages
2049cdf0e10cSrcweir // ansonsten oefters schickt, versuchen wir vorher alle
2050cdf0e10cSrcweir // zu verarbeiten und dann eine Dummy-Message reinstellen
2051cdf0e10cSrcweir sal_Bool bWhile = TRUE;
2052cdf0e10cSrcweir int i = 0;
2053cdf0e10cSrcweir do
2054cdf0e10cSrcweir {
2055cdf0e10cSrcweir // Messages verarbeiten
2056cdf0e10cSrcweir MSG aMsg;
2057cdf0e10cSrcweir if ( ImplPeekMessage( &aMsg, 0, 0, 0, PM_REMOVE ) )
2058cdf0e10cSrcweir {
2059cdf0e10cSrcweir if ( !ImplInterceptChildWindowKeyDown( aMsg ) )
2060cdf0e10cSrcweir {
2061cdf0e10cSrcweir TranslateMessage( &aMsg );
2062cdf0e10cSrcweir ImplDispatchMessage( &aMsg );
2063cdf0e10cSrcweir }
2064cdf0e10cSrcweir
2065cdf0e10cSrcweir i++;
2066cdf0e10cSrcweir if ( i > 15 )
2067cdf0e10cSrcweir bWhile = FALSE;
2068cdf0e10cSrcweir }
2069cdf0e10cSrcweir else
2070cdf0e10cSrcweir bWhile = FALSE;
2071cdf0e10cSrcweir }
2072cdf0e10cSrcweir while ( bWhile );
2073cdf0e10cSrcweir ImplPostMessage( GetSalData()->mpFirstInstance->mhComWnd, SAL_MSG_DUMMY, 0, 0 );
2074cdf0e10cSrcweir
2075*b4953498Smseidel // bring up a file chooser if printing to file port but no file name given
2076cdf0e10cSrcweir OUString aOutFileName;
2077cdf0e10cSrcweir if( mpInfoPrinter->maPortName.EqualsIgnoreCaseAscii( "FILE:" ) && !(pFileName && pFileName->Len()) )
2078cdf0e10cSrcweir {
2079cdf0e10cSrcweir
2080cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
2081cdf0e10cSrcweir if( xFactory.is() )
2082cdf0e10cSrcweir {
2083cdf0e10cSrcweir uno::Reference< XFilePicker > xFilePicker( xFactory->createInstance(
2084cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ) ),
2085cdf0e10cSrcweir UNO_QUERY );
2086cdf0e10cSrcweir DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
2087cdf0e10cSrcweir
2088cdf0e10cSrcweir uno::Reference< XInitialization > xInit( xFilePicker, UNO_QUERY );
2089cdf0e10cSrcweir uno::Reference< XFilterManager > xFilterMgr( xFilePicker, UNO_QUERY );
2090cdf0e10cSrcweir if( xInit.is() && xFilePicker.is() && xFilterMgr.is() )
2091cdf0e10cSrcweir {
2092cdf0e10cSrcweir Sequence< Any > aServiceType( 1 );
2093cdf0e10cSrcweir aServiceType[0] <<= TemplateDescription::FILESAVE_SIMPLE;
2094cdf0e10cSrcweir xInit->initialize( aServiceType );
2095cdf0e10cSrcweir if( xFilePicker->execute() == ExecutableDialogResults::OK )
2096cdf0e10cSrcweir {
2097cdf0e10cSrcweir Sequence< OUString > aPathSeq( xFilePicker->getFiles() );
2098cdf0e10cSrcweir INetURLObject aObj( aPathSeq[0] );
2099cdf0e10cSrcweir // we're using ansi calls (StartDocA) so convert the string
2100cdf0e10cSrcweir aOutFileName = aObj.PathToFileName();
2101cdf0e10cSrcweir }
2102cdf0e10cSrcweir else
2103cdf0e10cSrcweir {
2104cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_ABORT;
2105cdf0e10cSrcweir return FALSE;
2106cdf0e10cSrcweir }
2107cdf0e10cSrcweir }
2108cdf0e10cSrcweir }
2109cdf0e10cSrcweir }
2110cdf0e10cSrcweir
2111cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
2112cdf0e10cSrcweir {
2113cdf0e10cSrcweir DOCINFOW aInfo;
2114cdf0e10cSrcweir memset( &aInfo, 0, sizeof( DOCINFOW ) );
2115cdf0e10cSrcweir aInfo.cbSize = sizeof( aInfo );
2116cdf0e10cSrcweir aInfo.lpszDocName = (LPWSTR)rJobName.GetBuffer();
2117cdf0e10cSrcweir if ( pFileName || aOutFileName.getLength() )
2118cdf0e10cSrcweir {
2119cdf0e10cSrcweir if ( (pFileName && pFileName->Len()) || aOutFileName.getLength() )
2120cdf0e10cSrcweir {
2121cdf0e10cSrcweir aInfo.lpszOutput = (LPWSTR)( (pFileName && pFileName->Len()) ? pFileName->GetBuffer() : aOutFileName.getStr());
2122cdf0e10cSrcweir }
2123cdf0e10cSrcweir else
2124cdf0e10cSrcweir aInfo.lpszOutput = L"FILE:";
2125cdf0e10cSrcweir }
2126cdf0e10cSrcweir else
2127cdf0e10cSrcweir aInfo.lpszOutput = NULL;
2128*b4953498Smseidel
2129cdf0e10cSrcweir // start Job
2130cdf0e10cSrcweir int nRet = lcl_StartDocW( hDC, &aInfo, this );
2131*b4953498Smseidel
2132cdf0e10cSrcweir if ( nRet <= 0 )
2133cdf0e10cSrcweir {
2134cdf0e10cSrcweir long nError = GetLastError();
2135cdf0e10cSrcweir if ( (nRet == SP_USERABORT) || (nRet == SP_APPABORT) || (nError == ERROR_PRINT_CANCELLED) || (nError == ERROR_CANCELLED) )
2136cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_ABORT;
2137cdf0e10cSrcweir else
2138cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_GENERALERROR;
2139*b4953498Smseidel return FALSE;
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir }
2142cdf0e10cSrcweir else
2143cdf0e10cSrcweir {
2144cdf0e10cSrcweir // Both strings must exist, if StartJob() is called
2145cdf0e10cSrcweir ByteString aJobName( ImplSalGetWinAnsiString( rJobName, TRUE ) );
2146cdf0e10cSrcweir ByteString aFileName;
2147*b4953498Smseidel
2148cdf0e10cSrcweir DOCINFOA aInfo;
2149cdf0e10cSrcweir memset( &aInfo, 0, sizeof( DOCINFOA ) );
2150cdf0e10cSrcweir aInfo.cbSize = sizeof( aInfo );
2151cdf0e10cSrcweir aInfo.lpszDocName = (LPCSTR)aJobName.GetBuffer();
2152cdf0e10cSrcweir if ( pFileName || aOutFileName.getLength() )
2153cdf0e10cSrcweir {
2154cdf0e10cSrcweir if ( pFileName->Len() || aOutFileName.getLength() )
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir aFileName = ImplSalGetWinAnsiString( pFileName ? *pFileName : static_cast<const XubString>(aOutFileName), TRUE );
2157cdf0e10cSrcweir aInfo.lpszOutput = (LPCSTR)aFileName.GetBuffer();
2158cdf0e10cSrcweir }
2159cdf0e10cSrcweir else
2160cdf0e10cSrcweir aInfo.lpszOutput = "FILE:";
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir else
2163cdf0e10cSrcweir aInfo.lpszOutput = NULL;
2164*b4953498Smseidel
2165cdf0e10cSrcweir // start Job
2166cdf0e10cSrcweir int nRet = lcl_StartDocA( hDC, &aInfo, this );
2167cdf0e10cSrcweir if ( nRet <= 0 )
2168cdf0e10cSrcweir {
2169cdf0e10cSrcweir long nError = GetLastError();
2170cdf0e10cSrcweir if ( (nRet == SP_USERABORT) || (nRet == SP_APPABORT) || (nError == ERROR_PRINT_CANCELLED) || (nError == ERROR_CANCELLED) )
2171cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_ABORT;
2172cdf0e10cSrcweir else
2173cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_GENERALERROR;
2174cdf0e10cSrcweir return FALSE;
2175cdf0e10cSrcweir }
2176cdf0e10cSrcweir }
2177cdf0e10cSrcweir
2178cdf0e10cSrcweir return TRUE;
2179cdf0e10cSrcweir }
2180cdf0e10cSrcweir
2181cdf0e10cSrcweir // -----------------------------------------------------------------------
2182cdf0e10cSrcweir
EndJob()2183cdf0e10cSrcweir sal_Bool WinSalPrinter::EndJob()
2184cdf0e10cSrcweir {
2185cdf0e10cSrcweir DWORD err = 0;
2186cdf0e10cSrcweir HDC hDC = mhDC;
2187cdf0e10cSrcweir if ( isValid() && hDC )
2188cdf0e10cSrcweir {
2189cdf0e10cSrcweir if ( mpGraphics )
2190cdf0e10cSrcweir {
2191cdf0e10cSrcweir ImplSalDeInitGraphics( mpGraphics );
2192cdf0e10cSrcweir delete mpGraphics;
2193cdf0e10cSrcweir mpGraphics = NULL;
2194cdf0e10cSrcweir }
2195cdf0e10cSrcweir
2196cdf0e10cSrcweir // #i54419# Windows fax printer brings up a dialog in EndDoc
2197cdf0e10cSrcweir // which text previously copied in soffice process can be
2198cdf0e10cSrcweir // pasted to -> deadlock due to mutex not released.
2199cdf0e10cSrcweir // it should be safe to release the yield mutex over the EndDoc
2200cdf0e10cSrcweir // call, however the real solution is supposed to be the threading
2201cdf0e10cSrcweir // framework yet to come.
2202cdf0e10cSrcweir SalData* pSalData = GetSalData();
2203cdf0e10cSrcweir sal_uLong nAcquire = pSalData->mpFirstInstance->ReleaseYieldMutex();
2204cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
2205cdf0e10cSrcweir if( ::EndDoc( hDC ) <= 0 )
2206cdf0e10cSrcweir err = GetLastError();
2207cdf0e10cSrcweir CATCH_DRIVER_EX_END( "exception in EndDoc", this );
2208*b4953498Smseidel
2209cdf0e10cSrcweir pSalData->mpFirstInstance->AcquireYieldMutex( nAcquire );
2210cdf0e10cSrcweir DeleteDC( hDC );
2211cdf0e10cSrcweir mhDC = 0;
2212cdf0e10cSrcweir }
2213cdf0e10cSrcweir
2214cdf0e10cSrcweir return TRUE;
2215cdf0e10cSrcweir }
2216cdf0e10cSrcweir
2217cdf0e10cSrcweir // -----------------------------------------------------------------------
2218cdf0e10cSrcweir
AbortJob()2219cdf0e10cSrcweir sal_Bool WinSalPrinter::AbortJob()
2220cdf0e10cSrcweir {
2221cdf0e10cSrcweir mbAbort = TRUE;
2222cdf0e10cSrcweir
2223cdf0e10cSrcweir // Abort asyncron ausloesen
2224cdf0e10cSrcweir HDC hDC = mhDC;
2225cdf0e10cSrcweir if ( hDC )
2226cdf0e10cSrcweir {
2227cdf0e10cSrcweir SalData* pSalData = GetSalData();
2228cdf0e10cSrcweir ImplPostMessage( pSalData->mpFirstInstance->mhComWnd,
2229cdf0e10cSrcweir SAL_MSG_PRINTABORTJOB, (WPARAM)hDC, 0 );
2230cdf0e10cSrcweir }
2231cdf0e10cSrcweir
2232cdf0e10cSrcweir return TRUE;
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir
2235cdf0e10cSrcweir // -----------------------------------------------------------------------
2236cdf0e10cSrcweir
ImplSalPrinterAbortJobAsync(HDC hPrnDC)2237cdf0e10cSrcweir void ImplSalPrinterAbortJobAsync( HDC hPrnDC )
2238cdf0e10cSrcweir {
2239cdf0e10cSrcweir SalData* pSalData = GetSalData();
2240cdf0e10cSrcweir WinSalPrinter* pPrinter = pSalData->mpFirstPrinter;
2241cdf0e10cSrcweir
2242cdf0e10cSrcweir // Feststellen, ob Printer noch existiert
2243cdf0e10cSrcweir while ( pPrinter )
2244cdf0e10cSrcweir {
2245cdf0e10cSrcweir if ( pPrinter->mhDC == hPrnDC )
2246cdf0e10cSrcweir break;
2247cdf0e10cSrcweir
2248cdf0e10cSrcweir pPrinter = pPrinter->mpNextPrinter;
2249cdf0e10cSrcweir }
2250cdf0e10cSrcweir
2251cdf0e10cSrcweir // Wenn Printer noch existiert, dann den Job abbrechen
2252cdf0e10cSrcweir if ( pPrinter )
2253cdf0e10cSrcweir {
2254cdf0e10cSrcweir HDC hDC = pPrinter->mhDC;
2255cdf0e10cSrcweir if ( hDC )
2256cdf0e10cSrcweir {
2257cdf0e10cSrcweir if ( pPrinter->mpGraphics )
2258cdf0e10cSrcweir {
2259cdf0e10cSrcweir ImplSalDeInitGraphics( pPrinter->mpGraphics );
2260cdf0e10cSrcweir delete pPrinter->mpGraphics;
2261cdf0e10cSrcweir pPrinter->mpGraphics = NULL;
2262cdf0e10cSrcweir }
2263cdf0e10cSrcweir
2264cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
2265cdf0e10cSrcweir ::AbortDoc( hDC );
2266cdf0e10cSrcweir CATCH_DRIVER_EX_END( "exception in AbortDoc", pPrinter );
2267cdf0e10cSrcweir
2268cdf0e10cSrcweir DeleteDC( hDC );
2269cdf0e10cSrcweir pPrinter->mhDC = 0;
2270cdf0e10cSrcweir }
2271cdf0e10cSrcweir }
2272cdf0e10cSrcweir }
2273cdf0e10cSrcweir
2274cdf0e10cSrcweir // -----------------------------------------------------------------------
2275cdf0e10cSrcweir
StartPage(ImplJobSetup * pSetupData,sal_Bool bNewJobData)2276cdf0e10cSrcweir SalGraphics* WinSalPrinter::StartPage( ImplJobSetup* pSetupData, sal_Bool bNewJobData )
2277cdf0e10cSrcweir {
2278cdf0e10cSrcweir if( ! isValid() || mhDC == 0 )
2279cdf0e10cSrcweir return NULL;
2280*b4953498Smseidel
2281cdf0e10cSrcweir HDC hDC = mhDC;
2282cdf0e10cSrcweir if ( pSetupData && pSetupData->mpDriverData && bNewJobData )
2283cdf0e10cSrcweir {
2284cdf0e10cSrcweir if( aSalShlData.mbWPrinter )
2285cdf0e10cSrcweir {
2286cdf0e10cSrcweir LPDEVMODEW pOrgDevModeW;
2287cdf0e10cSrcweir LPDEVMODEW pDevModeW;
2288cdf0e10cSrcweir pOrgDevModeW = SAL_DEVMODE_W( pSetupData );
2289cdf0e10cSrcweir pDevModeW = ImplSalSetCopies( pOrgDevModeW, mnCopies, mbCollate );
2290cdf0e10cSrcweir ResetDCW( hDC, pDevModeW );
2291cdf0e10cSrcweir if ( pDevModeW != pOrgDevModeW )
2292cdf0e10cSrcweir rtl_freeMemory( pDevModeW );
2293cdf0e10cSrcweir }
2294cdf0e10cSrcweir else
2295cdf0e10cSrcweir {
2296cdf0e10cSrcweir LPDEVMODEA pOrgDevModeA;
2297cdf0e10cSrcweir LPDEVMODEA pDevModeA;
2298cdf0e10cSrcweir pOrgDevModeA = SAL_DEVMODE_A( pSetupData );
2299cdf0e10cSrcweir pDevModeA = ImplSalSetCopies( pOrgDevModeA, mnCopies, mbCollate );
2300cdf0e10cSrcweir ResetDCA( hDC, pDevModeA );
2301cdf0e10cSrcweir if ( pDevModeA != pOrgDevModeA )
2302cdf0e10cSrcweir rtl_freeMemory( pDevModeA );
2303cdf0e10cSrcweir }
2304cdf0e10cSrcweir }
2305cdf0e10cSrcweir int nRet = 0;
2306cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
2307cdf0e10cSrcweir nRet = ::StartPage( hDC );
2308cdf0e10cSrcweir CATCH_DRIVER_EX_END( "exception in StartPage", this );
2309*b4953498Smseidel
2310cdf0e10cSrcweir if ( nRet <= 0 )
2311cdf0e10cSrcweir {
2312cdf0e10cSrcweir GetLastError();
2313cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_GENERALERROR;
2314cdf0e10cSrcweir return NULL;
2315cdf0e10cSrcweir }
2316cdf0e10cSrcweir
2317cdf0e10cSrcweir // Hack to work around old PostScript printer drivers optimizing away empty pages
2318cdf0e10cSrcweir // TODO: move into ImplCreateSalPrnGraphics()?
2319cdf0e10cSrcweir HPEN hTempPen = SelectPen( hDC, GetStockPen( NULL_PEN ) );
2320cdf0e10cSrcweir HBRUSH hTempBrush = SelectBrush( hDC, GetStockBrush( NULL_BRUSH ) );
2321cdf0e10cSrcweir WIN_Rectangle( hDC, -8000, -8000, -7999, -7999 );
2322cdf0e10cSrcweir SelectPen( hDC, hTempPen );
2323cdf0e10cSrcweir SelectBrush( hDC, hTempBrush );
2324cdf0e10cSrcweir
2325cdf0e10cSrcweir mpGraphics = ImplCreateSalPrnGraphics( hDC );
2326cdf0e10cSrcweir return mpGraphics;
2327cdf0e10cSrcweir }
2328cdf0e10cSrcweir
2329cdf0e10cSrcweir // -----------------------------------------------------------------------
2330cdf0e10cSrcweir
EndPage()2331cdf0e10cSrcweir sal_Bool WinSalPrinter::EndPage()
2332cdf0e10cSrcweir {
2333cdf0e10cSrcweir HDC hDC = mhDC;
2334cdf0e10cSrcweir if ( hDC && mpGraphics )
2335cdf0e10cSrcweir {
2336cdf0e10cSrcweir ImplSalDeInitGraphics( mpGraphics );
2337cdf0e10cSrcweir delete mpGraphics;
2338cdf0e10cSrcweir mpGraphics = NULL;
2339cdf0e10cSrcweir }
2340cdf0e10cSrcweir
2341cdf0e10cSrcweir if( ! isValid() )
2342cdf0e10cSrcweir return FALSE;
2343*b4953498Smseidel
2344cdf0e10cSrcweir int nRet = 0;
2345cdf0e10cSrcweir CATCH_DRIVER_EX_BEGIN;
2346cdf0e10cSrcweir nRet = ::EndPage( hDC );
2347cdf0e10cSrcweir CATCH_DRIVER_EX_END( "exception in EndPage", this );
2348cdf0e10cSrcweir
2349cdf0e10cSrcweir if ( nRet > 0 )
2350cdf0e10cSrcweir return TRUE;
2351cdf0e10cSrcweir else
2352cdf0e10cSrcweir {
2353cdf0e10cSrcweir GetLastError();
2354cdf0e10cSrcweir mnError = SAL_PRINTER_ERROR_GENERALERROR;
2355cdf0e10cSrcweir return FALSE;
2356cdf0e10cSrcweir }
2357cdf0e10cSrcweir }
2358cdf0e10cSrcweir
2359cdf0e10cSrcweir // -----------------------------------------------------------------------
2360cdf0e10cSrcweir
GetErrorCode()2361cdf0e10cSrcweir sal_uLong WinSalPrinter::GetErrorCode()
2362cdf0e10cSrcweir {
2363cdf0e10cSrcweir return mnError;
2364cdf0e10cSrcweir }
2365