xref: /trunk/main/svtools/source/dialogs/prnsetup.cxx (revision 5900e8ec)
1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5900e8ecSAndrew Rist  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19*5900e8ecSAndrew Rist  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <tools/debug.hxx>
27cdf0e10cSrcweir #ifndef _VCL_PRINT_HXX
28cdf0e10cSrcweir #include <vcl/print.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef GCC
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <svtools/svtdata.hxx>
35cdf0e10cSrcweir #include "prnsetup.hrc"
36cdf0e10cSrcweir #include <svtools/prnsetup.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir // =======================================================================
39cdf0e10cSrcweir 
ImplFillPrnDlgListBox(const Printer * pPrinter,ListBox * pBox,PushButton * pPropBtn)40cdf0e10cSrcweir void ImplFillPrnDlgListBox( const Printer* pPrinter,
41cdf0e10cSrcweir 							ListBox* pBox, PushButton* pPropBtn )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	ImplFreePrnDlgListBox( pBox );
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     const std::vector<rtl::OUString>& rPrinters = Printer::GetPrinterQueues();
46cdf0e10cSrcweir 	unsigned int nCount = rPrinters.size();
47cdf0e10cSrcweir 	if ( nCount )
48cdf0e10cSrcweir 	{
49cdf0e10cSrcweir 		for( unsigned int i = 0; i < nCount; i++ )
50cdf0e10cSrcweir 			pBox->InsertEntry( rPrinters[i] );
51cdf0e10cSrcweir 		pBox->SelectEntry( pPrinter->GetName() );
52cdf0e10cSrcweir 	}
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	pBox->Enable( nCount != 0 );
55cdf0e10cSrcweir 	pPropBtn->Show( pPrinter->HasSupport( SUPPORT_SETUPDIALOG ) );
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir // -----------------------------------------------------------------------
59cdf0e10cSrcweir 
ImplFreePrnDlgListBox(ListBox * pBox,sal_Bool bClear)60cdf0e10cSrcweir void ImplFreePrnDlgListBox( ListBox* pBox, sal_Bool bClear )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	if ( bClear )
63cdf0e10cSrcweir 		pBox->Clear();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // -----------------------------------------------------------------------
67cdf0e10cSrcweir 
ImplPrnDlgListBoxSelect(ListBox * pBox,PushButton * pPropBtn,Printer * pPrinter,Printer * pTempPrinter)68cdf0e10cSrcweir Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
69cdf0e10cSrcweir 								  Printer* pPrinter, Printer* pTempPrinter )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	if ( pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
72cdf0e10cSrcweir 	{
73cdf0e10cSrcweir 		const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), true );
74cdf0e10cSrcweir         if( pInfo)
75cdf0e10cSrcweir         {
76cdf0e10cSrcweir             if ( !pTempPrinter )
77cdf0e10cSrcweir             {
78cdf0e10cSrcweir                 if ( (pPrinter->GetName() == pInfo->GetPrinterName()) &&
79cdf0e10cSrcweir                      (pPrinter->GetDriverName() == pInfo->GetDriver()) )
80cdf0e10cSrcweir                     pTempPrinter = new Printer( pPrinter->GetJobSetup() );
81cdf0e10cSrcweir                 else
82cdf0e10cSrcweir                     pTempPrinter = new Printer( *pInfo );
83cdf0e10cSrcweir             }
84cdf0e10cSrcweir             else
85cdf0e10cSrcweir             {
86cdf0e10cSrcweir                 if ( (pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
87cdf0e10cSrcweir                      (pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
88cdf0e10cSrcweir                 {
89cdf0e10cSrcweir                     delete pTempPrinter;
90cdf0e10cSrcweir                     pTempPrinter = new Printer( *pInfo );
91cdf0e10cSrcweir                 }
92cdf0e10cSrcweir             }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir             pPropBtn->Enable( pTempPrinter->HasSupport( SUPPORT_SETUPDIALOG ) );
95cdf0e10cSrcweir         }
96cdf0e10cSrcweir         else
97cdf0e10cSrcweir             pPropBtn->Disable();
98cdf0e10cSrcweir 	}
99cdf0e10cSrcweir 	else
100cdf0e10cSrcweir 		pPropBtn->Disable();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	return pTempPrinter;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir // -----------------------------------------------------------------------
106cdf0e10cSrcweir 
ImplPrnDlgUpdatePrinter(Printer * pPrinter,Printer * pTempPrinter)107cdf0e10cSrcweir Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	XubString aPrnName;
110cdf0e10cSrcweir 	if ( pTempPrinter )
111cdf0e10cSrcweir 		aPrnName = pTempPrinter->GetName();
112cdf0e10cSrcweir 	else
113cdf0e10cSrcweir 		aPrnName = pPrinter->GetName();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	if ( ! Printer::GetQueueInfo( aPrnName, false ) )
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		if ( pTempPrinter )
118cdf0e10cSrcweir 			delete pTempPrinter;
119cdf0e10cSrcweir 		pTempPrinter = new Printer;
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	return pTempPrinter;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir // -----------------------------------------------------------------------
126cdf0e10cSrcweir 
ImplPrnDlgUpdateQueueInfo(ListBox * pBox,QueueInfo & rInfo)127cdf0e10cSrcweir void ImplPrnDlgUpdateQueueInfo( ListBox* pBox, QueueInfo& rInfo )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	if ( pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir         const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), true );
132cdf0e10cSrcweir         if( pInfo )
133cdf0e10cSrcweir 			rInfo = *pInfo;
134cdf0e10cSrcweir 	}
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // -----------------------------------------------------------------------
138cdf0e10cSrcweir 
ImplPrnDlgAddString(XubString & rStr,const XubString & rAddStr)139cdf0e10cSrcweir static void ImplPrnDlgAddString( XubString& rStr, const XubString& rAddStr )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	if ( rStr.Len() )
142cdf0e10cSrcweir 		rStr.AppendAscii( "; " );
143cdf0e10cSrcweir 	rStr += rAddStr;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir // -----------------------------------------------------------------------
147cdf0e10cSrcweir 
ImplPrnDlgAddResString(XubString & rStr,sal_uInt16 nResId)148cdf0e10cSrcweir static void ImplPrnDlgAddResString( XubString& rStr, sal_uInt16 nResId )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	SvtResId aResId( nResId );
151cdf0e10cSrcweir 	XubString aAddStr( aResId );
152cdf0e10cSrcweir 	ImplPrnDlgAddString( rStr, aAddStr );
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir // -----------------------------------------------------------------------
156cdf0e10cSrcweir 
ImplPrnDlgGetStatusText(const QueueInfo & rInfo)157cdf0e10cSrcweir XubString ImplPrnDlgGetStatusText( const QueueInfo& rInfo )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir 	XubString	aStr;
160cdf0e10cSrcweir 	sal_uLong		nStatus = rInfo.GetStatus();
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	// Default-Printer
163cdf0e10cSrcweir 	if ( rInfo.GetPrinterName().Len() &&
164cdf0e10cSrcweir 		 (rInfo.GetPrinterName() == Printer::GetDefaultPrinterName()) )
165cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_DEFPRINTER );
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	// Status
168cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_READY )
169cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_READY );
170cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PAUSED )
171cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAUSED );
172cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PENDING_DELETION )
173cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PENDING );
174cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_BUSY )
175cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_BUSY );
176cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_INITIALIZING )
177cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_INITIALIZING );
178cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_WAITING )
179cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_WAITING );
180cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_WARMING_UP )
181cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_WARMING_UP );
182cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PROCESSING )
183cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PROCESSING );
184cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PRINTING )
185cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PRINTING );
186cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_OFFLINE )
187cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_OFFLINE );
188cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_ERROR )
189cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_ERROR );
190cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_SERVER_UNKNOWN )
191cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_SERVER_UNKNOWN );
192cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PAPER_JAM )
193cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAPER_JAM );
194cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PAPER_OUT )
195cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAPER_OUT );
196cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_MANUAL_FEED )
197cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_MANUAL_FEED );
198cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PAPER_PROBLEM )
199cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAPER_PROBLEM );
200cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_IO_ACTIVE )
201cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_IO_ACTIVE );
202cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_OUTPUT_BIN_FULL )
203cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_OUTPUT_BIN_FULL );
204cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_TONER_LOW )
205cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_TONER_LOW );
206cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_NO_TONER )
207cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_NO_TONER );
208cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_PAGE_PUNT )
209cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAGE_PUNT );
210cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_USER_INTERVENTION )
211cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_USER_INTERVENTION );
212cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_OUT_OF_MEMORY )
213cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_OUT_OF_MEMORY );
214cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_DOOR_OPEN )
215cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_DOOR_OPEN );
216cdf0e10cSrcweir 	if ( nStatus & QUEUE_STATUS_POWER_SAVE )
217cdf0e10cSrcweir 		ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_POWER_SAVE );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	// Anzahl Jobs
220cdf0e10cSrcweir 	sal_uLong nJobs = rInfo.GetJobs();
221cdf0e10cSrcweir 	if ( nJobs && (nJobs != QUEUE_JOBS_DONTKNOW) )
222cdf0e10cSrcweir 	{
223cdf0e10cSrcweir 		XubString aJobStr( SvtResId( STR_SVT_PRNDLG_JOBCOUNT ) );
224cdf0e10cSrcweir 		XubString aJobs( XubString::CreateFromInt32( nJobs ) );
225cdf0e10cSrcweir 		aJobStr.SearchAndReplaceAscii( "%d", aJobs );
226cdf0e10cSrcweir 		ImplPrnDlgAddString( aStr, aJobStr );
227cdf0e10cSrcweir 	}
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	return aStr;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
232cdf0e10cSrcweir // =======================================================================
233cdf0e10cSrcweir 
PrinterSetupDialog(Window * pWindow)234cdf0e10cSrcweir PrinterSetupDialog::PrinterSetupDialog( Window* pWindow ) :
235cdf0e10cSrcweir 	ModalDialog 	( pWindow, SvtResId( DLG_SVT_PRNDLG_PRNSETUPDLG ) ),
236cdf0e10cSrcweir 	maFlPrinter		( this, SvtResId( FL_PRINTER ) ),
237cdf0e10cSrcweir 	maFtName		( this, SvtResId( FT_NAME ) ),
238cdf0e10cSrcweir 	maLbName		( this, SvtResId( LB_NAMES ) ),
239cdf0e10cSrcweir 	maBtnProperties ( this, SvtResId( BTN_PROPERTIES ) ),
240cdf0e10cSrcweir 	maBtnOptions    ( this, SvtResId( BTN_OPTIONS ) ),
241cdf0e10cSrcweir 	maFtStatus		( this, SvtResId( FT_STATUS ) ),
242cdf0e10cSrcweir 	maFiStatus		( this, SvtResId( FI_STATUS ) ),
243cdf0e10cSrcweir 	maFtType		( this, SvtResId( FT_TYPE ) ),
244cdf0e10cSrcweir 	maFiType		( this, SvtResId( FI_TYPE ) ),
245cdf0e10cSrcweir 	maFtLocation	( this, SvtResId( FT_LOCATION ) ),
246cdf0e10cSrcweir 	maFiLocation	( this, SvtResId( FI_LOCATION ) ),
247cdf0e10cSrcweir 	maFtComment 	( this, SvtResId( FT_COMMENT ) ),
248cdf0e10cSrcweir 	maFiComment 	( this, SvtResId( FI_COMMENT ) ),
249cdf0e10cSrcweir     maFlSepButton	( this, SvtResId( FL_SEPBUTTON ) ),
250cdf0e10cSrcweir 	maBtnOK 		( this, SvtResId( BTN_OK ) ),
251cdf0e10cSrcweir 	maBtnCancel 	( this, SvtResId( BTN_CANCEL ) ),
252cdf0e10cSrcweir 	maBtnHelp		( this, SvtResId( BTN_HELP ) )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir 	FreeResource();
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     // show options button only if link is set
257cdf0e10cSrcweir     maBtnOptions.Hide();
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	mpPrinter		= NULL;
260cdf0e10cSrcweir 	mpTempPrinter	= NULL;
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 	maStatusTimer.SetTimeout( IMPL_PRINTDLG_STATUS_UPDATE );
263cdf0e10cSrcweir 	maStatusTimer.SetTimeoutHdl( LINK( this, PrinterSetupDialog, ImplStatusHdl ) );
264cdf0e10cSrcweir 	maBtnProperties.SetClickHdl( LINK( this, PrinterSetupDialog, ImplPropertiesHdl ) );
265cdf0e10cSrcweir 	maLbName.SetSelectHdl( LINK( this, PrinterSetupDialog, ImplChangePrinterHdl ) );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir // -----------------------------------------------------------------------
269cdf0e10cSrcweir 
~PrinterSetupDialog()270cdf0e10cSrcweir PrinterSetupDialog::~PrinterSetupDialog()
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	ImplFreePrnDlgListBox( &maLbName, sal_False );
273cdf0e10cSrcweir 	delete mpTempPrinter;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir 
276cdf0e10cSrcweir // -----------------------------------------------------------------------
277cdf0e10cSrcweir 
SetOptionsHdl(const Link & rLink)278cdf0e10cSrcweir void PrinterSetupDialog::SetOptionsHdl( const Link& rLink )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir     maBtnOptions.SetClickHdl( rLink );
281cdf0e10cSrcweir     maBtnOptions.Show( rLink.IsSet() );
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
GetOptionsHdl() const284cdf0e10cSrcweir const Link& PrinterSetupDialog::GetOptionsHdl() const
285cdf0e10cSrcweir {
286cdf0e10cSrcweir     return maBtnOptions.GetClickHdl();
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
ImplSetInfo()289cdf0e10cSrcweir void PrinterSetupDialog::ImplSetInfo()
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	const QueueInfo* pInfo = Printer::GetQueueInfo(maLbName.GetSelectEntry(), true);
292cdf0e10cSrcweir 	if ( pInfo )
293cdf0e10cSrcweir 	{
294cdf0e10cSrcweir 		maFiType.SetText( pInfo->GetDriver() );
295cdf0e10cSrcweir 		maFiLocation.SetText( pInfo->GetLocation() );
296cdf0e10cSrcweir 		maFiComment.SetText( pInfo->GetComment() );
297cdf0e10cSrcweir 		maFiStatus.SetText( ImplPrnDlgGetStatusText( *pInfo ) );
298cdf0e10cSrcweir 	}
299cdf0e10cSrcweir 	else
300cdf0e10cSrcweir 	{
301cdf0e10cSrcweir 		XubString aTempStr;
302cdf0e10cSrcweir 		maFiType.SetText( aTempStr );
303cdf0e10cSrcweir 		maFiLocation.SetText( aTempStr );
304cdf0e10cSrcweir 		maFiComment.SetText( aTempStr );
305cdf0e10cSrcweir 		maFiStatus.SetText( aTempStr );
306cdf0e10cSrcweir 	}
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir // -----------------------------------------------------------------------
310cdf0e10cSrcweir 
IMPL_LINK(PrinterSetupDialog,ImplStatusHdl,Timer *,EMPTYARG)311cdf0e10cSrcweir IMPL_LINK( PrinterSetupDialog, ImplStatusHdl, Timer*, EMPTYARG )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	QueueInfo aInfo;
314cdf0e10cSrcweir 	ImplPrnDlgUpdateQueueInfo( &maLbName, aInfo );
315cdf0e10cSrcweir 	maFiStatus.SetText( ImplPrnDlgGetStatusText( aInfo ) );
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 	return 0;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir // -----------------------------------------------------------------------
321cdf0e10cSrcweir 
IMPL_LINK(PrinterSetupDialog,ImplPropertiesHdl,void *,EMPTYARG)322cdf0e10cSrcweir IMPL_LINK( PrinterSetupDialog, ImplPropertiesHdl, void*, EMPTYARG )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir 	if ( !mpTempPrinter )
325cdf0e10cSrcweir 		mpTempPrinter = new Printer( mpPrinter->GetJobSetup() );
326cdf0e10cSrcweir 	mpTempPrinter->Setup( this );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 	return 0;
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir // -----------------------------------------------------------------------
332cdf0e10cSrcweir 
IMPL_LINK(PrinterSetupDialog,ImplChangePrinterHdl,void *,EMPTYARG)333cdf0e10cSrcweir IMPL_LINK( PrinterSetupDialog, ImplChangePrinterHdl, void*, EMPTYARG )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir 	mpTempPrinter = ImplPrnDlgListBoxSelect( &maLbName, &maBtnProperties,
336cdf0e10cSrcweir 											 mpPrinter, mpTempPrinter );
337cdf0e10cSrcweir 	ImplSetInfo();
338cdf0e10cSrcweir 	return 0;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir // -----------------------------------------------------------------------
342cdf0e10cSrcweir 
Notify(NotifyEvent & rNEvt)343cdf0e10cSrcweir long PrinterSetupDialog::Notify( NotifyEvent& rNEvt )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir 	if ( (rNEvt.GetType() == EVENT_GETFOCUS) && IsReallyVisible() )
346cdf0e10cSrcweir 		ImplStatusHdl( &maStatusTimer );
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	return ModalDialog::Notify( rNEvt );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir // -----------------------------------------------------------------------
352cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)353cdf0e10cSrcweir void PrinterSetupDialog::DataChanged( const DataChangedEvent& rDCEvt )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir 	if ( rDCEvt.GetType() == DATACHANGED_PRINTER )
356cdf0e10cSrcweir 	{
357cdf0e10cSrcweir 		mpTempPrinter = ImplPrnDlgUpdatePrinter( mpPrinter, mpTempPrinter );
358cdf0e10cSrcweir 		Printer* pPrn;
359cdf0e10cSrcweir 		if ( mpTempPrinter )
360cdf0e10cSrcweir 			pPrn = mpTempPrinter;
361cdf0e10cSrcweir 		else
362cdf0e10cSrcweir 			pPrn = mpPrinter;
363cdf0e10cSrcweir 		ImplFillPrnDlgListBox( pPrn, &maLbName, &maBtnProperties );
364cdf0e10cSrcweir 		ImplSetInfo();
365cdf0e10cSrcweir 	}
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 	ModalDialog::DataChanged( rDCEvt );
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir // -----------------------------------------------------------------------
371cdf0e10cSrcweir 
Execute()372cdf0e10cSrcweir short PrinterSetupDialog::Execute()
373cdf0e10cSrcweir {
374cdf0e10cSrcweir 	if ( !mpPrinter || mpPrinter->IsPrinting() || mpPrinter->IsJobActive() )
375cdf0e10cSrcweir 	{
376cdf0e10cSrcweir 		DBG_ERRORFILE( "PrinterSetupDialog::Execute() - No Printer or printer is printing" );
377cdf0e10cSrcweir 		return sal_False;
378cdf0e10cSrcweir 	}
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     Printer::updatePrinters();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 	ImplFillPrnDlgListBox( mpPrinter, &maLbName, &maBtnProperties );
383cdf0e10cSrcweir 	ImplSetInfo();
384cdf0e10cSrcweir 	maStatusTimer.Start();
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	// Dialog starten
387cdf0e10cSrcweir 	short nRet = ModalDialog::Execute();
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	// Wenn Dialog mit OK beendet wurde, dann die Daten updaten
390cdf0e10cSrcweir 	if ( nRet == sal_True )
391cdf0e10cSrcweir 	{
392cdf0e10cSrcweir 		if ( mpTempPrinter )
393cdf0e10cSrcweir 			mpPrinter->SetPrinterProps( mpTempPrinter );
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	maStatusTimer.Stop();
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 	return nRet;
399cdf0e10cSrcweir }
400