1c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file
5c82f2877SAndrew Rist * distributed with this work for additional information
6c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the
8c82f2877SAndrew Rist * "License"); you may not use this file except in compliance
9c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at
10c82f2877SAndrew Rist *
11c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12c82f2877SAndrew Rist *
13c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing,
14c82f2877SAndrew Rist * software distributed under the License is distributed on an
15c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c82f2877SAndrew Rist * KIND, either express or implied. See the License for the
17c82f2877SAndrew Rist * specific language governing permissions and limitations
18c82f2877SAndrew Rist * under the License.
19c82f2877SAndrew Rist *
20c82f2877SAndrew Rist *************************************************************/
21c82f2877SAndrew Rist
22c82f2877SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir /**
28cdf0e10cSrcweir this file implements the sal printer interface ( SalPrinter, SalInfoPrinter
29cdf0e10cSrcweir and some printer relevant methods of SalInstance and SalGraphicsData )
30cdf0e10cSrcweir
31cdf0e10cSrcweir as aunderlying library the printer features of psprint are used.
32cdf0e10cSrcweir
33cdf0e10cSrcweir The query methods of a SalInfoPrinter are implemented by querying psprint
34cdf0e10cSrcweir
35cdf0e10cSrcweir The job methods of a SalPrinter are implemented by calling psprint
36cdf0e10cSrcweir printer job functions.
37cdf0e10cSrcweir */
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include <unistd.h>
40cdf0e10cSrcweir #include <sys/wait.h>
41cdf0e10cSrcweir #include <sys/stat.h>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include "rtl/ustring.hxx"
44cdf0e10cSrcweir
45cdf0e10cSrcweir #include "osl/module.h"
46cdf0e10cSrcweir
47cdf0e10cSrcweir #include "vcl/svapp.hxx"
48cdf0e10cSrcweir #include "vcl/print.hxx"
49cdf0e10cSrcweir #include "vcl/pdfwriter.hxx"
50cdf0e10cSrcweir #include "vcl/printerinfomanager.hxx"
51cdf0e10cSrcweir
52cdf0e10cSrcweir #include <unx/salunx.h>
53cdf0e10cSrcweir #include "unx/saldisp.hxx"
54cdf0e10cSrcweir #include "unx/salinst.h"
55cdf0e10cSrcweir #include "unx/salprn.h"
56cdf0e10cSrcweir #include "unx/salframe.h"
57cdf0e10cSrcweir #include "unx/pspgraphics.h"
58cdf0e10cSrcweir #include "unx/saldata.hxx"
59cdf0e10cSrcweir
60cdf0e10cSrcweir #include "jobset.h"
61cdf0e10cSrcweir #include "print.h"
62cdf0e10cSrcweir #include "salptype.hxx"
63cdf0e10cSrcweir
64cdf0e10cSrcweir using namespace psp;
65cdf0e10cSrcweir using namespace rtl;
66cdf0e10cSrcweir using namespace com::sun::star;
67cdf0e10cSrcweir
68cdf0e10cSrcweir /*
69cdf0e10cSrcweir * static helpers
70cdf0e10cSrcweir */
71cdf0e10cSrcweir
72cdf0e10cSrcweir static oslModule driverLib = NULL;
73cdf0e10cSrcweir extern "C"
74cdf0e10cSrcweir {
75cdf0e10cSrcweir typedef int(*setupFunction)(PrinterInfo&);
76cdf0e10cSrcweir static setupFunction pSetupFunction = NULL;
77cdf0e10cSrcweir typedef int(*faxFunction)(String&);
78cdf0e10cSrcweir static faxFunction pFaxNrFunction = NULL;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
getPdfDir(const PrinterInfo & rInfo)81cdf0e10cSrcweir static String getPdfDir( const PrinterInfo& rInfo )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir String aDir;
84cdf0e10cSrcweir sal_Int32 nIndex = 0;
85cdf0e10cSrcweir while( nIndex != -1 )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
88cdf0e10cSrcweir if( ! aToken.compareToAscii( "pdf=", 4 ) )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir sal_Int32 nPos = 0;
91cdf0e10cSrcweir aDir = aToken.getToken( 1, '=', nPos );
92cdf0e10cSrcweir if( ! aDir.Len() )
93cdf0e10cSrcweir aDir = String( ByteString( getenv( "HOME" ) ), osl_getThreadTextEncoding() );
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir }
97cdf0e10cSrcweir return aDir;
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
getPaLib()100cdf0e10cSrcweir static void getPaLib()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir if( ! driverLib )
103cdf0e10cSrcweir {
104*aa150a94SHerbert Dürr driverLib = osl_loadAsciiModuleRelative( (oslGenericFunction)getPaLib, _XSALSET_LIBNAME, SAL_LOADMODULE_DEFAULT );
105cdf0e10cSrcweir if ( !driverLib )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir return;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
110cdf0e10cSrcweir pSetupFunction = (setupFunction)osl_getAsciiFunctionSymbol( driverLib, "Sal_SetupPrinterDriver" );
111cdf0e10cSrcweir if ( !pSetupFunction )
112cdf0e10cSrcweir fprintf( stderr, "could not resolve Sal_SetupPrinterDriver\n" );
113cdf0e10cSrcweir
114cdf0e10cSrcweir pFaxNrFunction = (faxFunction)osl_getAsciiFunctionSymbol( driverLib, "Sal_queryFaxNumber" );
115cdf0e10cSrcweir if ( !pFaxNrFunction )
116cdf0e10cSrcweir fprintf( stderr, "could not resolve Sal_queryFaxNumber\n" );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
PtTo10Mu(int nPoints)120cdf0e10cSrcweir inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778)+0.5); }
121cdf0e10cSrcweir
TenMuToPt(int nUnits)122cdf0e10cSrcweir inline int TenMuToPt( int nUnits ) { return (int)((((double)nUnits)/35.27777778)+0.5); }
123cdf0e10cSrcweir
copyJobDataToJobSetup(ImplJobSetup * pJobSetup,JobData & rData)124cdf0e10cSrcweir static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir pJobSetup->meOrientation = (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
127cdf0e10cSrcweir
128cdf0e10cSrcweir // copy page size
129cdf0e10cSrcweir String aPaper;
130cdf0e10cSrcweir int width, height;
131cdf0e10cSrcweir
132cdf0e10cSrcweir rData.m_aContext.getPageSize( aPaper, width, height );
133cdf0e10cSrcweir pJobSetup->mePaperFormat = PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 ));
134cdf0e10cSrcweir
135cdf0e10cSrcweir pJobSetup->mnPaperWidth = 0;
136cdf0e10cSrcweir pJobSetup->mnPaperHeight = 0;
137cdf0e10cSrcweir if( pJobSetup->mePaperFormat == PAPER_USER )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir // transform to 100dth mm
140cdf0e10cSrcweir width = PtTo10Mu( width );
141cdf0e10cSrcweir height = PtTo10Mu( height );
142cdf0e10cSrcweir
143cdf0e10cSrcweir if( rData.m_eOrientation == psp::orientation::Portrait )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir pJobSetup->mnPaperWidth = width;
146cdf0e10cSrcweir pJobSetup->mnPaperHeight= height;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir else
149cdf0e10cSrcweir {
150cdf0e10cSrcweir pJobSetup->mnPaperWidth = height;
151cdf0e10cSrcweir pJobSetup->mnPaperHeight= width;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir // copy input slot
156cdf0e10cSrcweir const PPDKey* pKey = NULL;
157cdf0e10cSrcweir const PPDValue* pValue = NULL;
158cdf0e10cSrcweir
159cdf0e10cSrcweir pJobSetup->mnPaperBin = 0;
160cdf0e10cSrcweir if( rData.m_pParser )
161cdf0e10cSrcweir pKey = rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
162cdf0e10cSrcweir if( pKey )
163cdf0e10cSrcweir pValue = rData.m_aContext.getValue( pKey );
164cdf0e10cSrcweir if( pKey && pValue )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir for( pJobSetup->mnPaperBin = 0;
167cdf0e10cSrcweir pValue != pKey->getValue( pJobSetup->mnPaperBin ) &&
168cdf0e10cSrcweir pJobSetup->mnPaperBin < pKey->countValues();
169cdf0e10cSrcweir pJobSetup->mnPaperBin++ )
170cdf0e10cSrcweir ;
171cdf0e10cSrcweir if( pJobSetup->mnPaperBin >= pKey->countValues() )
172cdf0e10cSrcweir pJobSetup->mnPaperBin = 0;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir // copy duplex
176cdf0e10cSrcweir pKey = NULL;
177cdf0e10cSrcweir pValue = NULL;
178cdf0e10cSrcweir
179cdf0e10cSrcweir pJobSetup->meDuplexMode = DUPLEX_UNKNOWN;
180cdf0e10cSrcweir if( rData.m_pParser )
181cdf0e10cSrcweir pKey = rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
182cdf0e10cSrcweir if( pKey )
183cdf0e10cSrcweir pValue = rData.m_aContext.getValue( pKey );
184cdf0e10cSrcweir if( pKey && pValue )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir if( pValue->m_aOption.EqualsIgnoreCaseAscii( "None" ) ||
187cdf0e10cSrcweir pValue->m_aOption.EqualsIgnoreCaseAscii( "Simplex", 0, 7 )
188cdf0e10cSrcweir )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir pJobSetup->meDuplexMode = DUPLEX_OFF;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir else if( pValue->m_aOption.EqualsIgnoreCaseAscii( "DuplexNoTumble" ) )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir pJobSetup->meDuplexMode = DUPLEX_LONGEDGE;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir else if( pValue->m_aOption.EqualsIgnoreCaseAscii( "DuplexTumble" ) )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir pJobSetup->meDuplexMode = DUPLEX_SHORTEDGE;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir // copy the whole context
203cdf0e10cSrcweir if( pJobSetup->mpDriverData )
204cdf0e10cSrcweir rtl_freeMemory( pJobSetup->mpDriverData );
205cdf0e10cSrcweir
206cdf0e10cSrcweir int nBytes;
207cdf0e10cSrcweir void* pBuffer = NULL;
208cdf0e10cSrcweir if( rData.getStreamBuffer( pBuffer, nBytes ) )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir pJobSetup->mnDriverDataLen = nBytes;
211cdf0e10cSrcweir pJobSetup->mpDriverData = (sal_uInt8*)pBuffer;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir else
214cdf0e10cSrcweir {
215cdf0e10cSrcweir pJobSetup->mnDriverDataLen = 0;
216cdf0e10cSrcweir pJobSetup->mpDriverData = NULL;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
passFileToCommandLine(const String & rFilename,const String & rCommandLine,bool bRemoveFile=true)220cdf0e10cSrcweir static bool passFileToCommandLine( const String& rFilename, const String& rCommandLine, bool bRemoveFile = true )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir bool bSuccess = false;
223cdf0e10cSrcweir
224cdf0e10cSrcweir rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
225cdf0e10cSrcweir ByteString aCmdLine( rCommandLine, aEncoding );
226cdf0e10cSrcweir ByteString aFilename( rFilename, aEncoding );
227cdf0e10cSrcweir
228cdf0e10cSrcweir bool bPipe = aCmdLine.Search( "(TMP)" ) != STRING_NOTFOUND ? false : true;
229cdf0e10cSrcweir
230cdf0e10cSrcweir // setup command line for exec
231cdf0e10cSrcweir if( ! bPipe )
232cdf0e10cSrcweir while( aCmdLine.SearchAndReplace( "(TMP)", aFilename ) != STRING_NOTFOUND )
233cdf0e10cSrcweir ;
234cdf0e10cSrcweir
235cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
236cdf0e10cSrcweir fprintf( stderr, "%s commandline: \"%s\"\n",
237cdf0e10cSrcweir bPipe ? "piping to" : "executing",
238cdf0e10cSrcweir aCmdLine.GetBuffer() );
239cdf0e10cSrcweir struct stat aStat;
240cdf0e10cSrcweir if( stat( aFilename.GetBuffer(), &aStat ) )
241cdf0e10cSrcweir fprintf( stderr, "stat( %s ) failed\n", aFilename.GetBuffer() );
242cdf0e10cSrcweir fprintf( stderr, "Tmp file %s has modes: 0%03lo\n", aFilename.GetBuffer(), (long)aStat.st_mode );
243cdf0e10cSrcweir #endif
244cdf0e10cSrcweir const char* argv[4];
245cdf0e10cSrcweir if( ! ( argv[ 0 ] = getenv( "SHELL" ) ) )
246cdf0e10cSrcweir argv[ 0 ] = "/bin/sh";
247cdf0e10cSrcweir argv[ 1 ] = "-c";
248cdf0e10cSrcweir argv[ 2 ] = aCmdLine.GetBuffer();
249cdf0e10cSrcweir argv[ 3 ] = 0;
250cdf0e10cSrcweir
251cdf0e10cSrcweir bool bHavePipes = false;
252cdf0e10cSrcweir int pid, fd[2];
253cdf0e10cSrcweir
254cdf0e10cSrcweir if( bPipe )
255cdf0e10cSrcweir bHavePipes = pipe( fd ) ? false : true;
256cdf0e10cSrcweir if( ( pid = fork() ) > 0 )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir if( bPipe && bHavePipes )
259cdf0e10cSrcweir {
260cdf0e10cSrcweir close( fd[0] );
261cdf0e10cSrcweir char aBuffer[ 2048 ];
262cdf0e10cSrcweir FILE* fp = fopen( aFilename.GetBuffer(), "r" );
263cdf0e10cSrcweir while( fp && ! feof( fp ) )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir int nBytes = fread( aBuffer, 1, sizeof( aBuffer ), fp );
266cdf0e10cSrcweir if( nBytes )
267cdf0e10cSrcweir write( fd[ 1 ], aBuffer, nBytes );
268cdf0e10cSrcweir }
269cdf0e10cSrcweir fclose( fp );
270cdf0e10cSrcweir close( fd[ 1 ] );
271cdf0e10cSrcweir }
272cdf0e10cSrcweir int status = 0;
273cdf0e10cSrcweir waitpid( pid, &status, 0 );
274cdf0e10cSrcweir if( ! status )
275cdf0e10cSrcweir bSuccess = true;
276cdf0e10cSrcweir }
277cdf0e10cSrcweir else if( ! pid )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir if( bPipe && bHavePipes )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir close( fd[1] );
282cdf0e10cSrcweir if( fd[0] != STDIN_FILENO ) // not probable, but who knows :)
283cdf0e10cSrcweir dup2( fd[0], STDIN_FILENO );
284cdf0e10cSrcweir }
285cdf0e10cSrcweir execv( argv[0], const_cast<char**>(argv) );
286cdf0e10cSrcweir fprintf( stderr, "failed to execute \"%s\"\n", aCmdLine.GetBuffer() );
287cdf0e10cSrcweir _exit( 1 );
288cdf0e10cSrcweir }
289cdf0e10cSrcweir else
290cdf0e10cSrcweir fprintf( stderr, "failed to fork\n" );
291cdf0e10cSrcweir
292cdf0e10cSrcweir // clean up the mess
293cdf0e10cSrcweir if( bRemoveFile )
294cdf0e10cSrcweir unlink( aFilename.GetBuffer() );
295cdf0e10cSrcweir
296cdf0e10cSrcweir return bSuccess;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
sendAFax(const String & rFaxNumber,const String & rFileName,const String & rCommand)299cdf0e10cSrcweir static bool sendAFax( const String& rFaxNumber, const String& rFileName, const String& rCommand )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir std::list< OUString > aFaxNumbers;
302cdf0e10cSrcweir
303cdf0e10cSrcweir if( ! rFaxNumber.Len() )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir getPaLib();
306cdf0e10cSrcweir if( pFaxNrFunction )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir String aNewNr;
309cdf0e10cSrcweir if( pFaxNrFunction( aNewNr ) )
310cdf0e10cSrcweir aFaxNumbers.push_back( OUString( aNewNr ) );
311cdf0e10cSrcweir }
312cdf0e10cSrcweir }
313cdf0e10cSrcweir else
314cdf0e10cSrcweir {
315cdf0e10cSrcweir sal_Int32 nIndex = 0;
316cdf0e10cSrcweir OUString aFaxes( rFaxNumber );
317cdf0e10cSrcweir OUString aBeginToken( RTL_CONSTASCII_USTRINGPARAM("<Fax#>") );
318cdf0e10cSrcweir OUString aEndToken( RTL_CONSTASCII_USTRINGPARAM("</Fax#>") );
319cdf0e10cSrcweir while( nIndex != -1 )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir nIndex = aFaxes.indexOf( aBeginToken, nIndex );
322cdf0e10cSrcweir if( nIndex != -1 )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir sal_Int32 nBegin = nIndex + aBeginToken.getLength();
325cdf0e10cSrcweir nIndex = aFaxes.indexOf( aEndToken, nIndex );
326cdf0e10cSrcweir if( nIndex != -1 )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir aFaxNumbers.push_back( aFaxes.copy( nBegin, nIndex-nBegin ) );
329cdf0e10cSrcweir nIndex += aEndToken.getLength();
330cdf0e10cSrcweir }
331cdf0e10cSrcweir }
332cdf0e10cSrcweir }
333cdf0e10cSrcweir }
334cdf0e10cSrcweir
335cdf0e10cSrcweir bool bSuccess = true;
336cdf0e10cSrcweir if( aFaxNumbers.begin() != aFaxNumbers.end() )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir while( aFaxNumbers.begin() != aFaxNumbers.end() && bSuccess )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir String aCmdLine( rCommand );
341cdf0e10cSrcweir String aFaxNumber( aFaxNumbers.front() );
342cdf0e10cSrcweir aFaxNumbers.pop_front();
343cdf0e10cSrcweir while( aCmdLine.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "(PHONE)" ) ), aFaxNumber ) != STRING_NOTFOUND )
344cdf0e10cSrcweir ;
345cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
346cdf0e10cSrcweir fprintf( stderr, "sending fax to \"%s\"\n", OUStringToOString( aFaxNumber, osl_getThreadTextEncoding() ).getStr() );
347cdf0e10cSrcweir #endif
348cdf0e10cSrcweir bSuccess = passFileToCommandLine( rFileName, aCmdLine, false );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir }
351cdf0e10cSrcweir else
352cdf0e10cSrcweir bSuccess = false;
353cdf0e10cSrcweir
354cdf0e10cSrcweir // clean up temp file
355cdf0e10cSrcweir unlink( ByteString( rFileName, osl_getThreadTextEncoding() ).GetBuffer() );
356cdf0e10cSrcweir
357cdf0e10cSrcweir return bSuccess;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
createPdf(const String & rToFile,const String & rFromFile,const String & rCommandLine)360cdf0e10cSrcweir static bool createPdf( const String& rToFile, const String& rFromFile, const String& rCommandLine )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir String aCommandLine( rCommandLine );
363cdf0e10cSrcweir while( aCommandLine.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "(OUTFILE)" ) ), rToFile ) != STRING_NOTFOUND )
364cdf0e10cSrcweir ;
365cdf0e10cSrcweir return passFileToCommandLine( rFromFile, aCommandLine );
366cdf0e10cSrcweir }
367cdf0e10cSrcweir
368cdf0e10cSrcweir /*
369cdf0e10cSrcweir * SalInstance
370cdf0e10cSrcweir */
371cdf0e10cSrcweir
372cdf0e10cSrcweir // -----------------------------------------------------------------------
373cdf0e10cSrcweir
CreateInfoPrinter(SalPrinterQueueInfo * pQueueInfo,ImplJobSetup * pJobSetup)374cdf0e10cSrcweir SalInfoPrinter* X11SalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
375cdf0e10cSrcweir ImplJobSetup* pJobSetup )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir mbPrinterInit = true;
378cdf0e10cSrcweir // create and initialize SalInfoPrinter
379cdf0e10cSrcweir PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter;
380cdf0e10cSrcweir
381cdf0e10cSrcweir if( pJobSetup )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir PrinterInfoManager& rManager( PrinterInfoManager::get() );
384cdf0e10cSrcweir PrinterInfo aInfo( rManager.getPrinterInfo( pQueueInfo->maPrinterName ) );
385cdf0e10cSrcweir pPrinter->m_aJobData = aInfo;
386cdf0e10cSrcweir pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData );
387cdf0e10cSrcweir
388cdf0e10cSrcweir if( pJobSetup->mpDriverData )
389cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo );
390cdf0e10cSrcweir
391cdf0e10cSrcweir pJobSetup->mnSystem = JOBSETUP_SYSTEM_UNIX;
392cdf0e10cSrcweir pJobSetup->maPrinterName = pQueueInfo->maPrinterName;
393cdf0e10cSrcweir pJobSetup->maDriver = aInfo.m_aDriverName;
394cdf0e10cSrcweir copyJobDataToJobSetup( pJobSetup, aInfo );
395cdf0e10cSrcweir
396cdf0e10cSrcweir // set/clear backwards compatibility flag
397cdf0e10cSrcweir bool bStrictSO52Compatibility = false;
398cdf0e10cSrcweir std::hash_map<rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator compat_it =
399cdf0e10cSrcweir pJobSetup->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StrictSO52Compatibility" ) ) );
400cdf0e10cSrcweir
401cdf0e10cSrcweir if( compat_it != pJobSetup->maValueMap.end() )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir if( compat_it->second.equalsIgnoreAsciiCaseAscii( "true" ) )
404cdf0e10cSrcweir bStrictSO52Compatibility = true;
405cdf0e10cSrcweir }
406cdf0e10cSrcweir pPrinter->m_aPrinterGfx.setStrictSO52Compatibility( bStrictSO52Compatibility );
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
409cdf0e10cSrcweir
410cdf0e10cSrcweir return pPrinter;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir // -----------------------------------------------------------------------
414cdf0e10cSrcweir
DestroyInfoPrinter(SalInfoPrinter * pPrinter)415cdf0e10cSrcweir void X11SalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir delete pPrinter;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir // -----------------------------------------------------------------------
421cdf0e10cSrcweir
CreatePrinter(SalInfoPrinter * pInfoPrinter)422cdf0e10cSrcweir SalPrinter* X11SalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir mbPrinterInit = true;
425cdf0e10cSrcweir // create and initialize SalPrinter
426cdf0e10cSrcweir PspSalPrinter* pPrinter = new PspSalPrinter( pInfoPrinter );
427cdf0e10cSrcweir pPrinter->m_aJobData = static_cast<PspSalInfoPrinter*>(pInfoPrinter)->m_aJobData;
428cdf0e10cSrcweir
429cdf0e10cSrcweir return pPrinter;
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
432cdf0e10cSrcweir // -----------------------------------------------------------------------
433cdf0e10cSrcweir
DestroyPrinter(SalPrinter * pPrinter)434cdf0e10cSrcweir void X11SalInstance::DestroyPrinter( SalPrinter* pPrinter )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir delete pPrinter;
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
439cdf0e10cSrcweir // -----------------------------------------------------------------------
440cdf0e10cSrcweir
GetPrinterQueueInfo(ImplPrnQueueList * pList)441cdf0e10cSrcweir void X11SalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir mbPrinterInit = true;
444cdf0e10cSrcweir PrinterInfoManager& rManager( PrinterInfoManager::get() );
445cdf0e10cSrcweir static const char* pNoSyncDetection = getenv( "SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION" );
446cdf0e10cSrcweir if( ! pNoSyncDetection || ! *pNoSyncDetection )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir // #i62663# synchronize possible asynchronouse printer detection now
449cdf0e10cSrcweir rManager.checkPrintersChanged( true );
450cdf0e10cSrcweir }
451cdf0e10cSrcweir ::std::list< OUString > aPrinters;
452cdf0e10cSrcweir rManager.listPrinters( aPrinters );
453cdf0e10cSrcweir
454cdf0e10cSrcweir for( ::std::list< OUString >::iterator it = aPrinters.begin(); it != aPrinters.end(); ++it )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir const PrinterInfo& rInfo( rManager.getPrinterInfo( *it ) );
457cdf0e10cSrcweir // Neuen Eintrag anlegen
458cdf0e10cSrcweir SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
459cdf0e10cSrcweir pInfo->maPrinterName = *it;
460cdf0e10cSrcweir pInfo->maDriver = rInfo.m_aDriverName;
461cdf0e10cSrcweir pInfo->maLocation = rInfo.m_aLocation;
462cdf0e10cSrcweir pInfo->maComment = rInfo.m_aComment;
463cdf0e10cSrcweir pInfo->mpSysData = NULL;
464cdf0e10cSrcweir
465cdf0e10cSrcweir sal_Int32 nIndex = 0;
466cdf0e10cSrcweir while( nIndex != -1 )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir String aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
469cdf0e10cSrcweir if( aToken.CompareToAscii( "pdf=", 4 ) == COMPARE_EQUAL )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir pInfo->maLocation = getPdfDir( rInfo );
472cdf0e10cSrcweir break;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir }
475cdf0e10cSrcweir
476cdf0e10cSrcweir pList->Add( pInfo );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
480cdf0e10cSrcweir // -----------------------------------------------------------------------
481cdf0e10cSrcweir
DeletePrinterQueueInfo(SalPrinterQueueInfo * pInfo)482cdf0e10cSrcweir void X11SalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir delete pInfo;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir
487cdf0e10cSrcweir // -----------------------------------------------------------------------
488cdf0e10cSrcweir
GetPrinterQueueState(SalPrinterQueueInfo *)489cdf0e10cSrcweir void X11SalInstance::GetPrinterQueueState( SalPrinterQueueInfo* )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir mbPrinterInit = true;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
494cdf0e10cSrcweir // -----------------------------------------------------------------------
495cdf0e10cSrcweir
GetDefaultPrinter()496cdf0e10cSrcweir String X11SalInstance::GetDefaultPrinter()
497cdf0e10cSrcweir {
498cdf0e10cSrcweir mbPrinterInit = true;
499cdf0e10cSrcweir PrinterInfoManager& rManager( PrinterInfoManager::get() );
500cdf0e10cSrcweir return rManager.getDefaultPrinter();
501cdf0e10cSrcweir }
502cdf0e10cSrcweir
503cdf0e10cSrcweir // =======================================================================
504cdf0e10cSrcweir
PspSalInfoPrinter()505cdf0e10cSrcweir PspSalInfoPrinter::PspSalInfoPrinter()
506cdf0e10cSrcweir {
507cdf0e10cSrcweir m_pGraphics = NULL;
508cdf0e10cSrcweir m_bPapersInit = false;
509cdf0e10cSrcweir }
510cdf0e10cSrcweir
511cdf0e10cSrcweir // -----------------------------------------------------------------------
512cdf0e10cSrcweir
~PspSalInfoPrinter()513cdf0e10cSrcweir PspSalInfoPrinter::~PspSalInfoPrinter()
514cdf0e10cSrcweir {
515cdf0e10cSrcweir if( m_pGraphics )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir delete m_pGraphics;
518cdf0e10cSrcweir m_pGraphics = NULL;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir }
521cdf0e10cSrcweir
522cdf0e10cSrcweir // -----------------------------------------------------------------------
523cdf0e10cSrcweir
InitPaperFormats(const ImplJobSetup *)524cdf0e10cSrcweir void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir m_aPaperFormats.clear();
527cdf0e10cSrcweir m_bPapersInit = true;
528cdf0e10cSrcweir
529cdf0e10cSrcweir if( m_aJobData.m_pParser )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir const PPDKey* pKey = m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
532cdf0e10cSrcweir if( pKey )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir int nValues = pKey->countValues();
535cdf0e10cSrcweir for( int i = 0; i < nValues; i++ )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir const PPDValue* pValue = pKey->getValue( i );
538cdf0e10cSrcweir int nWidth = 0, nHeight = 0;
539cdf0e10cSrcweir m_aJobData.m_pParser->getPaperDimension( pValue->m_aOption, nWidth, nHeight );
540cdf0e10cSrcweir PaperInfo aInfo(PtTo10Mu( nWidth ), PtTo10Mu( nHeight ));
541cdf0e10cSrcweir m_aPaperFormats.push_back( aInfo );
542cdf0e10cSrcweir }
543cdf0e10cSrcweir }
544cdf0e10cSrcweir }
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir // -----------------------------------------------------------------------
548cdf0e10cSrcweir
GetLandscapeAngle(const ImplJobSetup *)549cdf0e10cSrcweir int PspSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir return 900;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
554cdf0e10cSrcweir // -----------------------------------------------------------------------
555cdf0e10cSrcweir
GetGraphics()556cdf0e10cSrcweir SalGraphics* PspSalInfoPrinter::GetGraphics()
557cdf0e10cSrcweir {
558cdf0e10cSrcweir // return a valid pointer only once
559cdf0e10cSrcweir // the reasoning behind this is that we could have different
560cdf0e10cSrcweir // SalGraphics that can run in multiple threads
561cdf0e10cSrcweir // (future plans)
562cdf0e10cSrcweir SalGraphics* pRet = NULL;
563cdf0e10cSrcweir if( ! m_pGraphics )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir m_pGraphics = new PspGraphics( &m_aJobData, &m_aPrinterGfx, NULL, false, this );
566cdf0e10cSrcweir m_pGraphics->SetLayout( 0 );
567cdf0e10cSrcweir pRet = m_pGraphics;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir return pRet;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
572cdf0e10cSrcweir // -----------------------------------------------------------------------
573cdf0e10cSrcweir
ReleaseGraphics(SalGraphics * pGraphics)574cdf0e10cSrcweir void PspSalInfoPrinter::ReleaseGraphics( SalGraphics* pGraphics )
575cdf0e10cSrcweir {
576cdf0e10cSrcweir if( pGraphics == m_pGraphics )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir delete pGraphics;
579cdf0e10cSrcweir m_pGraphics = NULL;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir return;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
584cdf0e10cSrcweir // -----------------------------------------------------------------------
585cdf0e10cSrcweir
Setup(SalFrame * pFrame,ImplJobSetup * pJobSetup)586cdf0e10cSrcweir sal_Bool PspSalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pJobSetup )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir if( ! pFrame || ! pJobSetup )
589cdf0e10cSrcweir return sal_False;
590cdf0e10cSrcweir
591cdf0e10cSrcweir getPaLib();
592cdf0e10cSrcweir
593cdf0e10cSrcweir if( ! pSetupFunction )
594cdf0e10cSrcweir return sal_False;
595cdf0e10cSrcweir
596cdf0e10cSrcweir PrinterInfoManager& rManager = PrinterInfoManager::get();
597cdf0e10cSrcweir
598cdf0e10cSrcweir PrinterInfo aInfo( rManager.getPrinterInfo( pJobSetup->maPrinterName ) );
599cdf0e10cSrcweir if ( pJobSetup->mpDriverData )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir SetData( ~0, pJobSetup );
602cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo );
603cdf0e10cSrcweir }
604cdf0e10cSrcweir
605cdf0e10cSrcweir if( pSetupFunction( aInfo ) )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir rtl_freeMemory( pJobSetup->mpDriverData );
608cdf0e10cSrcweir pJobSetup->mpDriverData = NULL;
609cdf0e10cSrcweir
610cdf0e10cSrcweir int nBytes;
611cdf0e10cSrcweir void* pBuffer = NULL;
612cdf0e10cSrcweir aInfo.getStreamBuffer( pBuffer, nBytes );
613cdf0e10cSrcweir pJobSetup->mnDriverDataLen = nBytes;
614cdf0e10cSrcweir pJobSetup->mpDriverData = (sal_uInt8*)pBuffer;
615cdf0e10cSrcweir
616cdf0e10cSrcweir // copy everything to job setup
617cdf0e10cSrcweir copyJobDataToJobSetup( pJobSetup, aInfo );
618cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData );
619cdf0e10cSrcweir return sal_True;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir return sal_False;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir // -----------------------------------------------------------------------
625cdf0e10cSrcweir
626cdf0e10cSrcweir // This function gets the driver data and puts it into pJobSetup
627cdf0e10cSrcweir // If pJobSetup->mpDriverData is NOT NULL, then the independend
628cdf0e10cSrcweir // data should be merged into the driver data
629cdf0e10cSrcweir // If pJobSetup->mpDriverData IS NULL, then the driver defaults
630cdf0e10cSrcweir // should be merged into the independent data
SetPrinterData(ImplJobSetup * pJobSetup)631cdf0e10cSrcweir sal_Bool PspSalInfoPrinter::SetPrinterData( ImplJobSetup* pJobSetup )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir // set/clear backwards compatibility flag
634cdf0e10cSrcweir bool bStrictSO52Compatibility = false;
635cdf0e10cSrcweir std::hash_map<rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator compat_it =
636cdf0e10cSrcweir pJobSetup->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StrictSO52Compatibility" ) ) );
637cdf0e10cSrcweir
638cdf0e10cSrcweir if( compat_it != pJobSetup->maValueMap.end() )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir if( compat_it->second.equalsIgnoreAsciiCaseAscii( "true" ) )
641cdf0e10cSrcweir bStrictSO52Compatibility = true;
642cdf0e10cSrcweir }
643cdf0e10cSrcweir m_aPrinterGfx.setStrictSO52Compatibility( bStrictSO52Compatibility );
644cdf0e10cSrcweir
645cdf0e10cSrcweir if( pJobSetup->mpDriverData )
646cdf0e10cSrcweir return SetData( ~0, pJobSetup );
647cdf0e10cSrcweir
648cdf0e10cSrcweir copyJobDataToJobSetup( pJobSetup, m_aJobData );
649cdf0e10cSrcweir
650cdf0e10cSrcweir return sal_True;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir
653cdf0e10cSrcweir // -----------------------------------------------------------------------
654cdf0e10cSrcweir
655cdf0e10cSrcweir // This function merges the independ driver data
656cdf0e10cSrcweir // and sets the new independ data in pJobSetup
657cdf0e10cSrcweir // Only the data must be changed, where the bit
658cdf0e10cSrcweir // in nGetDataFlags is set
SetData(sal_uLong nSetDataFlags,ImplJobSetup * pJobSetup)659cdf0e10cSrcweir sal_Bool PspSalInfoPrinter::SetData(
660cdf0e10cSrcweir sal_uLong nSetDataFlags,
661cdf0e10cSrcweir ImplJobSetup* pJobSetup )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir JobData aData;
664cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
665cdf0e10cSrcweir
666cdf0e10cSrcweir if( aData.m_pParser )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir const PPDKey* pKey;
669cdf0e10cSrcweir const PPDValue* pValue;
670cdf0e10cSrcweir
671cdf0e10cSrcweir // merge papersize if necessary
672cdf0e10cSrcweir if( nSetDataFlags & SAL_JOBSET_PAPERSIZE )
673cdf0e10cSrcweir {
674cdf0e10cSrcweir int nWidth, nHeight;
675cdf0e10cSrcweir if( pJobSetup->meOrientation == ORIENTATION_PORTRAIT )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir nWidth = pJobSetup->mnPaperWidth;
678cdf0e10cSrcweir nHeight = pJobSetup->mnPaperHeight;
679cdf0e10cSrcweir }
680cdf0e10cSrcweir else
681cdf0e10cSrcweir {
682cdf0e10cSrcweir nWidth = pJobSetup->mnPaperHeight;
683cdf0e10cSrcweir nHeight = pJobSetup->mnPaperWidth;
684cdf0e10cSrcweir }
685cdf0e10cSrcweir String aPaper;
686cdf0e10cSrcweir
687cdf0e10cSrcweir if( pJobSetup->mePaperFormat == PAPER_USER )
688cdf0e10cSrcweir aPaper = aData.m_pParser->matchPaper(
689cdf0e10cSrcweir TenMuToPt( pJobSetup->mnPaperWidth ),
690cdf0e10cSrcweir TenMuToPt( pJobSetup->mnPaperHeight ) );
691cdf0e10cSrcweir else
692cdf0e10cSrcweir aPaper = rtl::OStringToOUString(PaperInfo::toPSName(pJobSetup->mePaperFormat), RTL_TEXTENCODING_ISO_8859_1);
693cdf0e10cSrcweir
694cdf0e10cSrcweir pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
695cdf0e10cSrcweir pValue = pKey ? pKey->getValueCaseInsensitive( aPaper ) : NULL;
696cdf0e10cSrcweir
697cdf0e10cSrcweir // some PPD files do not specify the standard paper names (e.g. C5 instead of EnvC5)
698cdf0e10cSrcweir // try to find the correct paper anyway using the size
699cdf0e10cSrcweir if( pKey && ! pValue && pJobSetup->mePaperFormat != PAPER_USER )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir PaperInfo aInfo( pJobSetup->mePaperFormat );
702cdf0e10cSrcweir aPaper = aData.m_pParser->matchPaper(
703cdf0e10cSrcweir TenMuToPt( aInfo.getWidth() ),
704cdf0e10cSrcweir TenMuToPt( aInfo.getHeight() ) );
705cdf0e10cSrcweir pValue = pKey->getValueCaseInsensitive( aPaper );
706cdf0e10cSrcweir }
707cdf0e10cSrcweir
708cdf0e10cSrcweir if( ! ( pKey && pValue && aData.m_aContext.setValue( pKey, pValue, false ) == pValue ) )
709cdf0e10cSrcweir return sal_False;
710cdf0e10cSrcweir }
711cdf0e10cSrcweir
712cdf0e10cSrcweir // merge paperbin if necessary
713cdf0e10cSrcweir if( nSetDataFlags & SAL_JOBSET_PAPERBIN )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
716cdf0e10cSrcweir if( pKey )
717cdf0e10cSrcweir {
718cdf0e10cSrcweir int nPaperBin = pJobSetup->mnPaperBin;
719cdf0e10cSrcweir if( nPaperBin >= pKey->countValues() )
720cdf0e10cSrcweir pValue = pKey->getDefaultValue();
721cdf0e10cSrcweir else
722cdf0e10cSrcweir pValue = pKey->getValue( pJobSetup->mnPaperBin );
723cdf0e10cSrcweir
724cdf0e10cSrcweir // may fail due to constraints;
725cdf0e10cSrcweir // real paper bin is copied back to jobsetup in that case
726cdf0e10cSrcweir aData.m_aContext.setValue( pKey, pValue );
727cdf0e10cSrcweir }
728cdf0e10cSrcweir // if printer has no InputSlot key simply ignore this setting
729cdf0e10cSrcweir // (e.g. SGENPRT has no InputSlot)
730cdf0e10cSrcweir }
731cdf0e10cSrcweir
732cdf0e10cSrcweir // merge orientation if necessary
733cdf0e10cSrcweir if( nSetDataFlags & SAL_JOBSET_ORIENTATION )
734cdf0e10cSrcweir aData.m_eOrientation = pJobSetup->meOrientation == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait;
735cdf0e10cSrcweir
736cdf0e10cSrcweir // merge duplex if necessary
737cdf0e10cSrcweir if( nSetDataFlags & SAL_JOBSET_DUPLEXMODE )
738cdf0e10cSrcweir {
739cdf0e10cSrcweir pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
740cdf0e10cSrcweir if( pKey )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir pValue = NULL;
743cdf0e10cSrcweir switch( pJobSetup->meDuplexMode )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir case DUPLEX_OFF:
746cdf0e10cSrcweir pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "None" ) ) );
747cdf0e10cSrcweir if( pValue == NULL )
748cdf0e10cSrcweir pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "SimplexNoTumble" ) ) );
749cdf0e10cSrcweir break;
750cdf0e10cSrcweir case DUPLEX_SHORTEDGE:
751cdf0e10cSrcweir pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexTumble" ) ) );
752cdf0e10cSrcweir break;
753cdf0e10cSrcweir case DUPLEX_LONGEDGE:
754cdf0e10cSrcweir pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexNoTumble" ) ) );
755cdf0e10cSrcweir break;
756cdf0e10cSrcweir case DUPLEX_UNKNOWN:
757cdf0e10cSrcweir default:
758cdf0e10cSrcweir pValue = 0;
759cdf0e10cSrcweir break;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir if( ! pValue )
762cdf0e10cSrcweir pValue = pKey->getDefaultValue();
763cdf0e10cSrcweir aData.m_aContext.setValue( pKey, pValue );
764cdf0e10cSrcweir }
765cdf0e10cSrcweir }
766cdf0e10cSrcweir
767cdf0e10cSrcweir m_aJobData = aData;
768cdf0e10cSrcweir copyJobDataToJobSetup( pJobSetup, aData );
769cdf0e10cSrcweir return sal_True;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir
772cdf0e10cSrcweir return sal_False;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
775cdf0e10cSrcweir // -----------------------------------------------------------------------
776cdf0e10cSrcweir
GetPageInfo(const ImplJobSetup * pJobSetup,long & rOutWidth,long & rOutHeight,long & rPageOffX,long & rPageOffY,long & rPageWidth,long & rPageHeight)777cdf0e10cSrcweir void PspSalInfoPrinter::GetPageInfo(
778cdf0e10cSrcweir const ImplJobSetup* pJobSetup,
779cdf0e10cSrcweir long& rOutWidth, long& rOutHeight,
780cdf0e10cSrcweir long& rPageOffX, long& rPageOffY,
781cdf0e10cSrcweir long& rPageWidth, long& rPageHeight )
782cdf0e10cSrcweir {
783cdf0e10cSrcweir if( ! pJobSetup )
784cdf0e10cSrcweir return;
785cdf0e10cSrcweir
786cdf0e10cSrcweir JobData aData;
787cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
788cdf0e10cSrcweir
789cdf0e10cSrcweir // get the selected page size
790cdf0e10cSrcweir if( aData.m_pParser )
791cdf0e10cSrcweir {
792cdf0e10cSrcweir
793cdf0e10cSrcweir String aPaper;
794cdf0e10cSrcweir int width, height;
795cdf0e10cSrcweir int left = 0, top = 0, right = 0, bottom = 0;
796cdf0e10cSrcweir int nDPI = aData.m_aContext.getRenderResolution();
797cdf0e10cSrcweir
798cdf0e10cSrcweir
799cdf0e10cSrcweir if( aData.m_eOrientation == psp::orientation::Portrait )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir aData.m_aContext.getPageSize( aPaper, width, height );
802cdf0e10cSrcweir aData.m_pParser->getMargins( aPaper, left, right, top, bottom );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir else
805cdf0e10cSrcweir {
806cdf0e10cSrcweir aData.m_aContext.getPageSize( aPaper, height, width );
807cdf0e10cSrcweir aData.m_pParser->getMargins( aPaper, top, bottom, right, left );
808cdf0e10cSrcweir }
809cdf0e10cSrcweir
810cdf0e10cSrcweir rPageWidth = width * nDPI / 72;
811cdf0e10cSrcweir rPageHeight = height * nDPI / 72;
812cdf0e10cSrcweir rPageOffX = left * nDPI / 72;
813cdf0e10cSrcweir rPageOffY = top * nDPI / 72;
814cdf0e10cSrcweir rOutWidth = ( width - left - right ) * nDPI / 72;
815cdf0e10cSrcweir rOutHeight = ( height - top - bottom ) * nDPI / 72;
816cdf0e10cSrcweir }
817cdf0e10cSrcweir }
818cdf0e10cSrcweir
819cdf0e10cSrcweir // -----------------------------------------------------------------------
820cdf0e10cSrcweir
GetPaperBinCount(const ImplJobSetup * pJobSetup)821cdf0e10cSrcweir sal_uLong PspSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir if( ! pJobSetup )
824cdf0e10cSrcweir return 0;
825cdf0e10cSrcweir
826cdf0e10cSrcweir JobData aData;
827cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
828cdf0e10cSrcweir
829cdf0e10cSrcweir const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) ): NULL;
830cdf0e10cSrcweir return pKey ? pKey->countValues() : 0;
831cdf0e10cSrcweir }
832cdf0e10cSrcweir
833cdf0e10cSrcweir // -----------------------------------------------------------------------
834cdf0e10cSrcweir
GetPaperBinName(const ImplJobSetup * pJobSetup,sal_uLong nPaperBin)835cdf0e10cSrcweir String PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, sal_uLong nPaperBin )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir JobData aData;
838cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
839cdf0e10cSrcweir
840cdf0e10cSrcweir String aRet;
841cdf0e10cSrcweir if( aData.m_pParser )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) ): NULL;
844cdf0e10cSrcweir if( ! pKey || nPaperBin >= (sal_uLong)pKey->countValues() )
845cdf0e10cSrcweir aRet = aData.m_pParser->getDefaultInputSlot();
846cdf0e10cSrcweir else
847cdf0e10cSrcweir {
848cdf0e10cSrcweir const PPDValue* pValue = pKey->getValue( nPaperBin );
849cdf0e10cSrcweir if( pValue )
850cdf0e10cSrcweir aRet = aData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption );
851cdf0e10cSrcweir }
852cdf0e10cSrcweir }
853cdf0e10cSrcweir
854cdf0e10cSrcweir return aRet;
855cdf0e10cSrcweir }
856cdf0e10cSrcweir
857cdf0e10cSrcweir // -----------------------------------------------------------------------
858cdf0e10cSrcweir
GetCapabilities(const ImplJobSetup * pJobSetup,sal_uInt16 nType)859cdf0e10cSrcweir sal_uLong PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, sal_uInt16 nType )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir switch( nType )
862cdf0e10cSrcweir {
863cdf0e10cSrcweir case PRINTER_CAPABILITIES_SUPPORTDIALOG:
864cdf0e10cSrcweir return 1;
865cdf0e10cSrcweir case PRINTER_CAPABILITIES_COPIES:
866cdf0e10cSrcweir return 0xffff;
867cdf0e10cSrcweir case PRINTER_CAPABILITIES_COLLATECOPIES:
868cdf0e10cSrcweir {
869cdf0e10cSrcweir // see if the PPD contains a value to set Collate to True
870cdf0e10cSrcweir JobData aData;
871cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
872cdf0e10cSrcweir
873cdf0e10cSrcweir const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ) : NULL;
874cdf0e10cSrcweir const PPDValue* pVal = pKey ? pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "True" ) ) ) : NULL;
875cdf0e10cSrcweir
876cdf0e10cSrcweir // PPDs don't mention the number of possible collated copies.
877cdf0e10cSrcweir // so let's guess as many as we want ?
878cdf0e10cSrcweir return pVal ? 0xffff : 0;
879cdf0e10cSrcweir }
880cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETORIENTATION:
881cdf0e10cSrcweir return 1;
882cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETDUPLEX:
883cdf0e10cSrcweir return 1;
884cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETPAPERBIN:
885cdf0e10cSrcweir return 1;
886cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETPAPERSIZE:
887cdf0e10cSrcweir return 1;
888cdf0e10cSrcweir case PRINTER_CAPABILITIES_SETPAPER:
889cdf0e10cSrcweir return 0;
890cdf0e10cSrcweir case PRINTER_CAPABILITIES_FAX:
891cdf0e10cSrcweir return PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "fax" ) ? 1 : 0;
892cdf0e10cSrcweir case PRINTER_CAPABILITIES_PDF:
893cdf0e10cSrcweir if( PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "pdf" ) )
894cdf0e10cSrcweir return 1;
895cdf0e10cSrcweir else
896cdf0e10cSrcweir {
897cdf0e10cSrcweir // see if the PPD contains a value to set Collate to True
898cdf0e10cSrcweir JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName );
899cdf0e10cSrcweir if( pJobSetup->mpDriverData )
900cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
901cdf0e10cSrcweir return aData.m_nPDFDevice > 0 ? 1 : 0;
902cdf0e10cSrcweir }
903cdf0e10cSrcweir case PRINTER_CAPABILITIES_EXTERNALDIALOG:
904cdf0e10cSrcweir return PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "external_dialog" ) ? 1 : 0;
905cdf0e10cSrcweir case PRINTER_CAPABILITIES_USEPULLMODEL:
906cdf0e10cSrcweir {
907cdf0e10cSrcweir // see if the PPD contains a value to set Collate to True
908cdf0e10cSrcweir JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName );
909cdf0e10cSrcweir if( pJobSetup->mpDriverData )
910cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
911cdf0e10cSrcweir return aData.m_nPDFDevice > 0 ? 1 : 0;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir default: break;
914cdf0e10cSrcweir };
915cdf0e10cSrcweir return 0;
916cdf0e10cSrcweir }
917cdf0e10cSrcweir
918cdf0e10cSrcweir // =======================================================================
919cdf0e10cSrcweir
920cdf0e10cSrcweir /*
921cdf0e10cSrcweir * SalPrinter
922cdf0e10cSrcweir */
923cdf0e10cSrcweir
PspSalPrinter(SalInfoPrinter * pInfoPrinter)924cdf0e10cSrcweir PspSalPrinter::PspSalPrinter( SalInfoPrinter* pInfoPrinter )
925cdf0e10cSrcweir : m_bFax( false ),
926cdf0e10cSrcweir m_bPdf( false ),
927cdf0e10cSrcweir m_bSwallowFaxNo( false ),
928cdf0e10cSrcweir m_bIsPDFWriterJob( false ),
929cdf0e10cSrcweir m_pGraphics( NULL ),
930cdf0e10cSrcweir m_nCopies( 1 ),
931cdf0e10cSrcweir m_bCollate( false ),
932cdf0e10cSrcweir m_pInfoPrinter( pInfoPrinter )
933cdf0e10cSrcweir {
934cdf0e10cSrcweir }
935cdf0e10cSrcweir
936cdf0e10cSrcweir // -----------------------------------------------------------------------
937cdf0e10cSrcweir
~PspSalPrinter()938cdf0e10cSrcweir PspSalPrinter::~PspSalPrinter()
939cdf0e10cSrcweir {
940cdf0e10cSrcweir }
941cdf0e10cSrcweir
942cdf0e10cSrcweir // -----------------------------------------------------------------------
943cdf0e10cSrcweir
getTmpName()944cdf0e10cSrcweir static String getTmpName()
945cdf0e10cSrcweir {
946cdf0e10cSrcweir rtl::OUString aTmp, aSys;
947cdf0e10cSrcweir osl_createTempFile( NULL, NULL, &aTmp.pData );
948cdf0e10cSrcweir osl_getSystemPathFromFileURL( aTmp.pData, &aSys.pData );
949cdf0e10cSrcweir
950cdf0e10cSrcweir return aSys;
951cdf0e10cSrcweir }
952cdf0e10cSrcweir
StartJob(const XubString * pFileName,const XubString & rJobName,const XubString & rAppName,sal_uLong nCopies,bool bCollate,bool bDirect,ImplJobSetup * pJobSetup)953cdf0e10cSrcweir sal_Bool PspSalPrinter::StartJob(
954cdf0e10cSrcweir const XubString* pFileName,
955cdf0e10cSrcweir const XubString& rJobName,
956cdf0e10cSrcweir const XubString& rAppName,
957cdf0e10cSrcweir sal_uLong nCopies,
958cdf0e10cSrcweir bool bCollate,
959cdf0e10cSrcweir bool bDirect,
960cdf0e10cSrcweir ImplJobSetup* pJobSetup )
961cdf0e10cSrcweir {
962cdf0e10cSrcweir vcl_sal::PrinterUpdate::jobStarted();
963cdf0e10cSrcweir
964cdf0e10cSrcweir m_bFax = false;
965cdf0e10cSrcweir m_bPdf = false;
966cdf0e10cSrcweir m_aFileName = pFileName ? *pFileName : String();
967cdf0e10cSrcweir m_aTmpFile = String();
968cdf0e10cSrcweir m_nCopies = nCopies;
969cdf0e10cSrcweir m_bCollate = bCollate;
970cdf0e10cSrcweir
971cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData );
972cdf0e10cSrcweir if( m_nCopies > 1 )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir // in case user did not do anything (m_nCopies=1)
975cdf0e10cSrcweir // take the default from jobsetup
976cdf0e10cSrcweir m_aJobData.m_nCopies = m_nCopies;
977cdf0e10cSrcweir m_aJobData.setCollate( bCollate );
978cdf0e10cSrcweir }
979cdf0e10cSrcweir
980cdf0e10cSrcweir // check wether this printer is configured as fax
981cdf0e10cSrcweir int nMode = 0;
982cdf0e10cSrcweir const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) );
983cdf0e10cSrcweir sal_Int32 nIndex = 0;
984cdf0e10cSrcweir while( nIndex != -1 )
985cdf0e10cSrcweir {
986cdf0e10cSrcweir OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
987cdf0e10cSrcweir if( ! aToken.compareToAscii( "fax", 3 ) )
988cdf0e10cSrcweir {
989cdf0e10cSrcweir m_bFax = true;
990cdf0e10cSrcweir m_aTmpFile = getTmpName();
991cdf0e10cSrcweir nMode = S_IRUSR | S_IWUSR;
992cdf0e10cSrcweir
993cdf0e10cSrcweir ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash >::const_iterator it;
994cdf0e10cSrcweir it = pJobSetup->maValueMap.find( ::rtl::OUString::createFromAscii( "FAX#" ) );
995cdf0e10cSrcweir if( it != pJobSetup->maValueMap.end() )
996cdf0e10cSrcweir m_aFaxNr = it->second;
997cdf0e10cSrcweir
998cdf0e10cSrcweir sal_Int32 nPos = 0;
999cdf0e10cSrcweir m_bSwallowFaxNo = ! aToken.getToken( 1, '=', nPos ).compareToAscii( "swallow", 7 ) ? true : false;
1000cdf0e10cSrcweir
1001cdf0e10cSrcweir break;
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir if( ! aToken.compareToAscii( "pdf=", 4 ) )
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir m_bPdf = true;
1006cdf0e10cSrcweir m_aTmpFile = getTmpName();
1007cdf0e10cSrcweir nMode = S_IRUSR | S_IWUSR;
1008cdf0e10cSrcweir
1009cdf0e10cSrcweir if( ! m_aFileName.Len() )
1010cdf0e10cSrcweir {
1011cdf0e10cSrcweir m_aFileName = getPdfDir( rInfo );
1012cdf0e10cSrcweir m_aFileName.Append( '/' );
1013cdf0e10cSrcweir m_aFileName.Append( rJobName );
1014cdf0e10cSrcweir m_aFileName.AppendAscii( ".pdf" );
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir break;
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir m_aPrinterGfx.Init( m_aJobData );
1020cdf0e10cSrcweir
1021cdf0e10cSrcweir // set/clear backwards compatibility flag
1022cdf0e10cSrcweir bool bStrictSO52Compatibility = false;
1023cdf0e10cSrcweir std::hash_map<rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator compat_it =
1024cdf0e10cSrcweir pJobSetup->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StrictSO52Compatibility" ) ) );
1025cdf0e10cSrcweir
1026cdf0e10cSrcweir if( compat_it != pJobSetup->maValueMap.end() )
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir if( compat_it->second.equalsIgnoreAsciiCaseAscii( "true" ) )
1029cdf0e10cSrcweir bStrictSO52Compatibility = true;
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir m_aPrinterGfx.setStrictSO52Compatibility( bStrictSO52Compatibility );
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir return m_aPrintJob.StartJob( m_aTmpFile.Len() ? m_aTmpFile : m_aFileName, nMode, rJobName, rAppName, m_aJobData, &m_aPrinterGfx, bDirect ) ? sal_True : sal_False;
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir
1036cdf0e10cSrcweir // -----------------------------------------------------------------------
1037cdf0e10cSrcweir
EndJob()1038cdf0e10cSrcweir sal_Bool PspSalPrinter::EndJob()
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir sal_Bool bSuccess = sal_False;
1041cdf0e10cSrcweir if( m_bIsPDFWriterJob )
1042cdf0e10cSrcweir bSuccess = sal_True;
1043cdf0e10cSrcweir else
1044cdf0e10cSrcweir {
1045cdf0e10cSrcweir bSuccess = m_aPrintJob.EndJob();
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir if( bSuccess )
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir // check for fax
1050cdf0e10cSrcweir if( m_bFax )
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir
1053cdf0e10cSrcweir const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) );
1054cdf0e10cSrcweir // sendAFax removes the file after use
1055cdf0e10cSrcweir bSuccess = sendAFax( m_aFaxNr, m_aTmpFile, rInfo.m_aCommand );
1056cdf0e10cSrcweir }
1057cdf0e10cSrcweir else if( m_bPdf )
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) );
1060cdf0e10cSrcweir bSuccess = createPdf( m_aFileName, m_aTmpFile, rInfo.m_aCommand );
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir }
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir vcl_sal::PrinterUpdate::jobEnded();
1065cdf0e10cSrcweir return bSuccess;
1066cdf0e10cSrcweir }
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir // -----------------------------------------------------------------------
1069cdf0e10cSrcweir
AbortJob()1070cdf0e10cSrcweir sal_Bool PspSalPrinter::AbortJob()
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir sal_Bool bAbort = m_aPrintJob.AbortJob() ? sal_True : sal_False;
1073cdf0e10cSrcweir vcl_sal::PrinterUpdate::jobEnded();
1074cdf0e10cSrcweir return bAbort;
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir // -----------------------------------------------------------------------
1078cdf0e10cSrcweir
StartPage(ImplJobSetup * pJobSetup,sal_Bool)1079cdf0e10cSrcweir SalGraphics* PspSalPrinter::StartPage( ImplJobSetup* pJobSetup, sal_Bool )
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData );
1082cdf0e10cSrcweir m_pGraphics = new PspGraphics( &m_aJobData, &m_aPrinterGfx, m_bFax ? &m_aFaxNr : NULL, m_bSwallowFaxNo, m_pInfoPrinter );
1083cdf0e10cSrcweir m_pGraphics->SetLayout( 0 );
1084cdf0e10cSrcweir if( m_nCopies > 1 )
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir // in case user did not do anything (m_nCopies=1)
1087cdf0e10cSrcweir // take the default from jobsetup
1088cdf0e10cSrcweir m_aJobData.m_nCopies = m_nCopies;
1089cdf0e10cSrcweir m_aJobData.setCollate( m_nCopies > 1 && m_bCollate );
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir m_aPrintJob.StartPage( m_aJobData );
1093cdf0e10cSrcweir m_aPrinterGfx.Init( m_aPrintJob );
1094cdf0e10cSrcweir
1095cdf0e10cSrcweir return m_pGraphics;
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir
1098cdf0e10cSrcweir // -----------------------------------------------------------------------
1099cdf0e10cSrcweir
EndPage()1100cdf0e10cSrcweir sal_Bool PspSalPrinter::EndPage()
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir sal_Bool bResult = m_aPrintJob.EndPage();
1103cdf0e10cSrcweir m_aPrinterGfx.Clear();
1104cdf0e10cSrcweir return bResult ? sal_True : sal_False;
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir
1107cdf0e10cSrcweir // -----------------------------------------------------------------------
1108cdf0e10cSrcweir
GetErrorCode()1109cdf0e10cSrcweir sal_uLong PspSalPrinter::GetErrorCode()
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir return 0;
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir
1114cdf0e10cSrcweir // -----------------------------------------------------------------------
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir struct PDFNewJobParameters
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir Size maPageSize;
1119cdf0e10cSrcweir sal_uInt16 mnPaperBin;
1120cdf0e10cSrcweir
PDFNewJobParametersPDFNewJobParameters1121cdf0e10cSrcweir PDFNewJobParameters( const Size& i_rSize = Size(),
1122cdf0e10cSrcweir sal_uInt16 i_nPaperBin = 0xffff )
1123cdf0e10cSrcweir : maPageSize( i_rSize ), mnPaperBin( i_nPaperBin ) {}
1124cdf0e10cSrcweir
operator !=PDFNewJobParameters1125cdf0e10cSrcweir bool operator!=(const PDFNewJobParameters& rComp ) const
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir Size aCompLSSize( rComp.maPageSize.Height(), rComp.maPageSize.Width() );
1128cdf0e10cSrcweir return
1129cdf0e10cSrcweir (maPageSize != rComp.maPageSize && maPageSize != aCompLSSize)
1130cdf0e10cSrcweir || mnPaperBin != rComp.mnPaperBin
1131cdf0e10cSrcweir ;
1132cdf0e10cSrcweir }
1133cdf0e10cSrcweir
operator ==PDFNewJobParameters1134cdf0e10cSrcweir bool operator==(const PDFNewJobParameters& rComp) const
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir return ! this->operator!=(rComp);
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir };
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir struct PDFPrintFile
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir rtl::OUString maTmpURL;
1143cdf0e10cSrcweir PDFNewJobParameters maParameters;
1144cdf0e10cSrcweir
PDFPrintFilePDFPrintFile1145cdf0e10cSrcweir PDFPrintFile( const rtl::OUString& i_rURL, const PDFNewJobParameters& i_rNewParameters )
1146cdf0e10cSrcweir : maTmpURL( i_rURL )
1147cdf0e10cSrcweir , maParameters( i_rNewParameters ) {}
1148cdf0e10cSrcweir };
1149cdf0e10cSrcweir
StartJob(const String * i_pFileName,const String & i_rJobName,const String & i_rAppName,ImplJobSetup * i_pSetupData,vcl::PrinterController & i_rController)1150cdf0e10cSrcweir sal_Bool PspSalPrinter::StartJob( const String* i_pFileName, const String& i_rJobName, const String& i_rAppName,
1151cdf0e10cSrcweir ImplJobSetup* i_pSetupData, vcl::PrinterController& i_rController )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir OSL_TRACE( "StartJob with controller: pFilename = %s", i_pFileName ? rtl::OUStringToOString( *i_pFileName, RTL_TEXTENCODING_UTF8 ).getStr() : "<nil>" );
1154cdf0e10cSrcweir // mark for endjob
1155cdf0e10cSrcweir m_bIsPDFWriterJob = true;
1156cdf0e10cSrcweir // reset IsLastPage
1157cdf0e10cSrcweir i_rController.setLastPage( sal_False );
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir // update job data
1160cdf0e10cSrcweir if( i_pSetupData )
1161cdf0e10cSrcweir JobData::constructFromStreamBuffer( i_pSetupData->mpDriverData, i_pSetupData->mnDriverDataLen, m_aJobData );
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir OSL_ASSERT( m_aJobData.m_nPDFDevice > 0 );
1164cdf0e10cSrcweir m_aJobData.m_nPDFDevice = 1;
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir // possibly create one job for collated output
1167cdf0e10cSrcweir sal_Bool bSinglePrintJobs = sal_False;
1168cdf0e10cSrcweir beans::PropertyValue* pSingleValue = i_rController.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintCollateAsSingleJobs" ) ) );
1169cdf0e10cSrcweir if( pSingleValue )
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir pSingleValue->Value >>= bSinglePrintJobs;
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir int nCopies = i_rController.getPrinter()->GetCopyCount();
1175cdf0e10cSrcweir bool bCollate = i_rController.getPrinter()->IsCollateCopy();
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir // notify start of real print job
1178cdf0e10cSrcweir i_rController.jobStarted();
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir // setup PDFWriter context
1181cdf0e10cSrcweir vcl::PDFWriter::PDFWriterContext aContext;
1182cdf0e10cSrcweir aContext.Version = vcl::PDFWriter::PDF_1_4;
1183cdf0e10cSrcweir aContext.Tagged = false;
1184cdf0e10cSrcweir aContext.EmbedStandardFonts = true;
1185cdf0e10cSrcweir aContext.DocumentLocale = Application::GetSettings().GetLocale();
1186cdf0e10cSrcweir aContext.ColorMode = i_rController.getPrinter()->GetPrinterOptions().IsConvertToGreyscales()
1187cdf0e10cSrcweir ? vcl::PDFWriter::DrawGreyscale : vcl::PDFWriter::DrawColor;
1188cdf0e10cSrcweir
1189cdf0e10cSrcweir // prepare doc info
1190cdf0e10cSrcweir aContext.DocumentInfo.Title = i_rJobName;
1191cdf0e10cSrcweir aContext.DocumentInfo.Creator = i_rAppName;
1192cdf0e10cSrcweir aContext.DocumentInfo.Producer = i_rAppName;
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir // define how we handle metafiles in PDFWriter
1195cdf0e10cSrcweir vcl::PDFWriter::PlayMetafileContext aMtfContext;
1196cdf0e10cSrcweir aMtfContext.m_bOnlyLosslessCompression = true;
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir boost::shared_ptr<vcl::PDFWriter> pWriter;
1199cdf0e10cSrcweir std::vector< PDFPrintFile > aPDFFiles;
1200cdf0e10cSrcweir boost::shared_ptr<Printer> pPrinter( i_rController.getPrinter() );
1201cdf0e10cSrcweir int nAllPages = i_rController.getFilteredPageCount();
1202cdf0e10cSrcweir i_rController.createProgressDialog();
1203cdf0e10cSrcweir bool bAborted = false;
1204cdf0e10cSrcweir PDFNewJobParameters aLastParm;
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir aContext.DPIx = pPrinter->ImplGetDPIX();
1207cdf0e10cSrcweir aContext.DPIy = pPrinter->ImplGetDPIY();
1208cdf0e10cSrcweir for( int nPage = 0; nPage < nAllPages && ! bAborted; nPage++ )
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir if( nPage == nAllPages-1 )
1211cdf0e10cSrcweir i_rController.setLastPage( sal_True );
1212cdf0e10cSrcweir
1213cdf0e10cSrcweir // get the page's metafile
1214cdf0e10cSrcweir GDIMetaFile aPageFile;
1215cdf0e10cSrcweir vcl::PrinterController::PageSize aPageSize = i_rController.getFilteredPageFile( nPage, aPageFile );
1216cdf0e10cSrcweir if( i_rController.isProgressCanceled() )
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir bAborted = true;
1219cdf0e10cSrcweir if( nPage != nAllPages-1 )
1220cdf0e10cSrcweir {
1221cdf0e10cSrcweir i_rController.createProgressDialog();
1222cdf0e10cSrcweir i_rController.setLastPage( sal_True );
1223cdf0e10cSrcweir i_rController.getFilteredPageFile( nPage, aPageFile );
1224cdf0e10cSrcweir }
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir else
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir pPrinter->SetMapMode( MapMode( MAP_100TH_MM ) );
1229cdf0e10cSrcweir pPrinter->SetPaperSizeUser( aPageSize.aSize, true );
1230cdf0e10cSrcweir PDFNewJobParameters aNewParm( pPrinter->GetPaperSize(), pPrinter->GetPaperBin() );
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir // create PDF writer on demand
1233cdf0e10cSrcweir // either on first page
1234cdf0e10cSrcweir // or on paper format change - cups does not support multiple paper formats per job (yet?)
1235cdf0e10cSrcweir // so we need to start a new job to get a new paper format from the printer
1236cdf0e10cSrcweir // orientation switches (that is switch of height and width) is handled transparently by CUPS
1237cdf0e10cSrcweir if( ! pWriter ||
1238cdf0e10cSrcweir (aNewParm != aLastParm && ! i_pFileName ) )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir if( pWriter )
1241cdf0e10cSrcweir {
1242cdf0e10cSrcweir pWriter->Emit();
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir // produce PDF file
1245cdf0e10cSrcweir OUString aPDFUrl;
1246cdf0e10cSrcweir if( i_pFileName )
1247cdf0e10cSrcweir aPDFUrl = *i_pFileName;
1248cdf0e10cSrcweir else
1249cdf0e10cSrcweir osl_createTempFile( NULL, NULL, &aPDFUrl.pData );
1250cdf0e10cSrcweir // normalize to file URL
1251cdf0e10cSrcweir if( aPDFUrl.compareToAscii( "file:", 5 ) != 0 )
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir // this is not a file URL, but it should
1254cdf0e10cSrcweir // form it into a osl friendly file URL
1255cdf0e10cSrcweir rtl::OUString aTmp;
1256cdf0e10cSrcweir osl_getFileURLFromSystemPath( aPDFUrl.pData, &aTmp.pData );
1257cdf0e10cSrcweir aPDFUrl = aTmp;
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir // save current file and paper format
1260cdf0e10cSrcweir aLastParm = aNewParm;
1261cdf0e10cSrcweir aPDFFiles.push_back( PDFPrintFile( aPDFUrl, aNewParm ) );
1262cdf0e10cSrcweir // update context
1263cdf0e10cSrcweir aContext.URL = aPDFUrl;
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir // create and initialize PDFWriter
1266cdf0e10cSrcweir #if defined __SUNPRO_CC
1267cdf0e10cSrcweir #pragma disable_warn
1268cdf0e10cSrcweir #endif
1269cdf0e10cSrcweir pWriter.reset( new vcl::PDFWriter( aContext, uno::Reference< beans::XMaterialHolder >() ) );
1270cdf0e10cSrcweir #if defined __SUNPRO_CC
1271cdf0e10cSrcweir #pragma enable_warn
1272cdf0e10cSrcweir #endif
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir pWriter->NewPage( TenMuToPt( aNewParm.maPageSize.Width() ),
1276cdf0e10cSrcweir TenMuToPt( aNewParm.maPageSize.Height() ),
1277cdf0e10cSrcweir vcl::PDFWriter::Portrait );
1278cdf0e10cSrcweir
1279cdf0e10cSrcweir pWriter->PlayMetafile( aPageFile, aMtfContext, NULL );
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir // emit the last file
1284cdf0e10cSrcweir if( pWriter )
1285cdf0e10cSrcweir pWriter->Emit();
1286cdf0e10cSrcweir
1287cdf0e10cSrcweir // handle collate, copy count and multiple jobs correctly
1288cdf0e10cSrcweir int nOuterJobs = 1;
1289cdf0e10cSrcweir if( bSinglePrintJobs )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir nOuterJobs = nCopies;
1292cdf0e10cSrcweir m_aJobData.m_nCopies = 1;
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir else
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir if( bCollate )
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir if( aPDFFiles.size() == 1 && pPrinter->HasSupport( SUPPORT_COLLATECOPY ) )
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir m_aJobData.setCollate( true );
1301cdf0e10cSrcweir m_aJobData.m_nCopies = nCopies;
1302cdf0e10cSrcweir }
1303cdf0e10cSrcweir else
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir nOuterJobs = nCopies;
1306cdf0e10cSrcweir m_aJobData.m_nCopies = 1;
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir else
1310cdf0e10cSrcweir {
1311cdf0e10cSrcweir m_aJobData.setCollate( false );
1312cdf0e10cSrcweir m_aJobData.m_nCopies = nCopies;
1313cdf0e10cSrcweir }
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir
1316cdf0e10cSrcweir // spool files
1317cdf0e10cSrcweir if( ! i_pFileName && ! bAborted )
1318cdf0e10cSrcweir {
1319cdf0e10cSrcweir bool bFirstJob = true;
1320cdf0e10cSrcweir for( int nCurJob = 0; nCurJob < nOuterJobs; nCurJob++ )
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir for( size_t i = 0; i < aPDFFiles.size(); i++ )
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir oslFileHandle pFile = NULL;
1325cdf0e10cSrcweir osl_openFile( aPDFFiles[i].maTmpURL.pData, &pFile, osl_File_OpenFlag_Read );
1326cdf0e10cSrcweir if( pFile )
1327cdf0e10cSrcweir {
1328cdf0e10cSrcweir osl_setFilePos( pFile, osl_Pos_Absolut, 0 );
1329cdf0e10cSrcweir std::vector< char > buffer( 0x10000, 0 );
1330cdf0e10cSrcweir // update job data with current page size
1331cdf0e10cSrcweir Size aPageSize( aPDFFiles[i].maParameters.maPageSize );
1332cdf0e10cSrcweir m_aJobData.setPaper( TenMuToPt( aPageSize.Width() ), TenMuToPt( aPageSize.Height() ) );
1333cdf0e10cSrcweir // update job data with current paperbin
1334cdf0e10cSrcweir m_aJobData.setPaperBin( aPDFFiles[i].maParameters.mnPaperBin );
1335cdf0e10cSrcweir
1336cdf0e10cSrcweir // spool current file
1337cdf0e10cSrcweir FILE* fp = PrinterInfoManager::get().startSpool( pPrinter->GetName(), i_rController.isDirectPrint() );
1338cdf0e10cSrcweir if( fp )
1339cdf0e10cSrcweir {
1340cdf0e10cSrcweir sal_uInt64 nBytesRead = 0;
1341cdf0e10cSrcweir do
1342cdf0e10cSrcweir {
1343cdf0e10cSrcweir osl_readFile( pFile, &buffer[0], buffer.size(), &nBytesRead );
1344cdf0e10cSrcweir if( nBytesRead > 0 )
1345cdf0e10cSrcweir fwrite( &buffer[0], 1, nBytesRead, fp );
1346cdf0e10cSrcweir } while( nBytesRead == buffer.size() );
1347cdf0e10cSrcweir rtl::OUStringBuffer aBuf( i_rJobName.Len() + 8 );
1348cdf0e10cSrcweir aBuf.append( i_rJobName );
1349cdf0e10cSrcweir if( i > 0 || nCurJob > 0 )
1350cdf0e10cSrcweir {
1351cdf0e10cSrcweir aBuf.append( sal_Unicode(' ') );
1352cdf0e10cSrcweir aBuf.append( sal_Int32( i + nCurJob * aPDFFiles.size() ) );
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir PrinterInfoManager::get().endSpool( pPrinter->GetName(), aBuf.makeStringAndClear(), fp, m_aJobData, bFirstJob );
1355cdf0e10cSrcweir bFirstJob = false;
1356cdf0e10cSrcweir }
1357cdf0e10cSrcweir }
1358cdf0e10cSrcweir osl_closeFile( pFile );
1359cdf0e10cSrcweir }
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir
1363cdf0e10cSrcweir // job has been spooled
1364cdf0e10cSrcweir i_rController.setJobState( bAborted ? view::PrintableState_JOB_ABORTED : view::PrintableState_JOB_SPOOLED );
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir // clean up the temporary PDF files
1367cdf0e10cSrcweir if( ! i_pFileName || bAborted )
1368cdf0e10cSrcweir {
1369cdf0e10cSrcweir for( size_t i = 0; i < aPDFFiles.size(); i++ )
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir osl_removeFile( aPDFFiles[i].maTmpURL.pData );
1372cdf0e10cSrcweir OSL_TRACE( "removed print PDF file %s\n", rtl::OUStringToOString( aPDFFiles[i].maTmpURL, RTL_TEXTENCODING_UTF8 ).getStr() );
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir }
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir return sal_True;
1377cdf0e10cSrcweir }
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir
1380cdf0e10cSrcweir
1381cdf0e10cSrcweir /*
1382cdf0e10cSrcweir * vcl::PrinterUpdate
1383cdf0e10cSrcweir */
1384cdf0e10cSrcweir
1385cdf0e10cSrcweir Timer* vcl_sal::PrinterUpdate::pPrinterUpdateTimer = NULL;
1386cdf0e10cSrcweir int vcl_sal::PrinterUpdate::nActiveJobs = 0;
1387cdf0e10cSrcweir
doUpdate()1388cdf0e10cSrcweir void vcl_sal::PrinterUpdate::doUpdate()
1389cdf0e10cSrcweir {
1390cdf0e10cSrcweir ::psp::PrinterInfoManager& rManager( ::psp::PrinterInfoManager::get() );
1391cdf0e10cSrcweir if( rManager.checkPrintersChanged( false ) )
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir SalDisplay* pDisp = GetX11SalData()->GetDisplay();
1394cdf0e10cSrcweir const std::list< SalFrame* >& rList = pDisp->getFrames();
1395cdf0e10cSrcweir for( std::list< SalFrame* >::const_iterator it = rList.begin();
1396cdf0e10cSrcweir it != rList.end(); ++it )
1397cdf0e10cSrcweir pDisp->SendInternalEvent( *it, NULL, SALEVENT_PRINTERCHANGED );
1398cdf0e10cSrcweir }
1399cdf0e10cSrcweir }
1400cdf0e10cSrcweir
1401cdf0e10cSrcweir // -----------------------------------------------------------------------
1402cdf0e10cSrcweir
IMPL_STATIC_LINK_NOINSTANCE(vcl_sal::PrinterUpdate,UpdateTimerHdl,void *,EMPTYARG)1403cdf0e10cSrcweir IMPL_STATIC_LINK_NOINSTANCE( vcl_sal::PrinterUpdate, UpdateTimerHdl, void*, EMPTYARG )
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir if( nActiveJobs < 1 )
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir doUpdate();
1408cdf0e10cSrcweir delete pPrinterUpdateTimer;
1409cdf0e10cSrcweir pPrinterUpdateTimer = NULL;
1410cdf0e10cSrcweir }
1411cdf0e10cSrcweir else
1412cdf0e10cSrcweir pPrinterUpdateTimer->Start();
1413cdf0e10cSrcweir
1414cdf0e10cSrcweir return 0;
1415cdf0e10cSrcweir }
1416cdf0e10cSrcweir
1417cdf0e10cSrcweir // -----------------------------------------------------------------------
1418cdf0e10cSrcweir
update()1419cdf0e10cSrcweir void vcl_sal::PrinterUpdate::update()
1420cdf0e10cSrcweir {
1421cdf0e10cSrcweir if( Application::GetSettings().GetMiscSettings().GetDisablePrinting() )
1422cdf0e10cSrcweir return;
1423cdf0e10cSrcweir
1424cdf0e10cSrcweir if( ! static_cast< X11SalInstance* >(GetSalData()->m_pInstance)->isPrinterInit() )
1425cdf0e10cSrcweir {
1426cdf0e10cSrcweir // #i45389# start background printer detection
1427cdf0e10cSrcweir psp::PrinterInfoManager::get();
1428cdf0e10cSrcweir return;
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir if( nActiveJobs < 1 )
1432cdf0e10cSrcweir doUpdate();
1433cdf0e10cSrcweir else if( ! pPrinterUpdateTimer )
1434cdf0e10cSrcweir {
1435cdf0e10cSrcweir pPrinterUpdateTimer = new Timer();
1436cdf0e10cSrcweir pPrinterUpdateTimer->SetTimeout( 500 );
1437cdf0e10cSrcweir pPrinterUpdateTimer->SetTimeoutHdl( STATIC_LINK( NULL, vcl_sal::PrinterUpdate, UpdateTimerHdl ) );
1438cdf0e10cSrcweir pPrinterUpdateTimer->Start();
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir }
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir // -----------------------------------------------------------------------
1443cdf0e10cSrcweir
jobEnded()1444cdf0e10cSrcweir void vcl_sal::PrinterUpdate::jobEnded()
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir nActiveJobs--;
1447cdf0e10cSrcweir if( nActiveJobs < 1 )
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir if( pPrinterUpdateTimer )
1450cdf0e10cSrcweir {
1451cdf0e10cSrcweir pPrinterUpdateTimer->Stop();
1452cdf0e10cSrcweir delete pPrinterUpdateTimer;
1453cdf0e10cSrcweir pPrinterUpdateTimer = NULL;
1454cdf0e10cSrcweir doUpdate();
1455cdf0e10cSrcweir }
1456cdf0e10cSrcweir }
1457cdf0e10cSrcweir }
1458