1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: printdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <tools/debug.hxx>
35 #include <vcl/svapp.hxx>
37 #ifndef _VCL_PRINT_HXX
38 #include <vcl/print.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/jobset.hxx>
42 #include <tools/urlobj.hxx>
44 #include "printdlg.hrc"
45 #include "controldims.hrc"
46 #include <svtools/prnsetup.hxx>
47 #include <svtools/printdlg.hxx>
48 #include <svtools/svtdata.hxx>
49 #include <filedlg.hxx>
50 #include "pickerhelper.hxx"
51 #ifndef _SVT_HELPID_HRC
52 #include <svtools/helpid.hrc>
54 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
55 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
56 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
57 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
58 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
59 #include <comphelper/processfactory.hxx>
62 using namespace com::sun::star
;
66 Printer
* m_pTempPrinter
;
67 sal_Bool m_bHelpDisabled
;
68 PrintSheetRange m_eSheetRange
;
71 m_pTempPrinter( NULL
), m_bHelpDisabled( sal_False
), m_eSheetRange( PRINTSHEETS_ALL
) {}
72 ~SvtPrinterImpl() { delete m_pTempPrinter
; }
75 #define TEMPPRINTER() mpPrinterImpl->m_pTempPrinter
77 // =======================================================================
79 PrintDialog::PrintDialog( Window
* pWindow
, bool bWithSheetsAndCells
) :
80 ModalDialog ( pWindow
, SvtResId( DLG_SVT_PRNDLG_PRINTDLG
) ),
81 maFlPrinter ( this, SvtResId( FL_PRINTER
) ),
82 maFtName ( this, SvtResId( FT_NAME
) ),
83 maLbName ( this, SvtResId( LB_NAMES
) ),
84 maBtnProperties ( this, SvtResId( BTN_PROPERTIES
) ),
85 maFtStatus ( this, SvtResId( FT_STATUS
) ),
86 maFiStatus ( this, SvtResId( FI_STATUS
) ),
87 maFtType ( this, SvtResId( FT_TYPE
) ),
88 maFiType ( this, SvtResId( FI_TYPE
) ),
89 maFtLocation ( this, SvtResId( FT_LOCATION
) ),
90 maFiLocation ( this, SvtResId( FI_LOCATION
) ),
91 maFtComment ( this, SvtResId( FT_COMMENT
) ),
92 maFiComment ( this, SvtResId( FI_COMMENT
) ),
93 maCbxFilePrint ( this, SvtResId( CBX_FILEPRINT
) ),
94 maFiPrintFile ( this, SvtResId( FI_PRINTFILE
) ),
95 maFiFaxNo ( this, SvtResId( FI_FAXNO
) ),
96 maEdtFaxNo ( this, SvtResId( EDT_FAXNO
) ),
97 maFlPrint ( this, SvtResId( FL_PRINT
) ),
98 maRbtAllSheets ( this, SvtResId( RBT_ALL_SHEETS
) ),
99 maRbtSelectedSheets ( this, SvtResId( RBT_SELECTED_SHEETS
) ),
100 maRbtSelectedCells ( this, SvtResId( RBT_SELECTED_CELLS
) ),
101 maFlPrintRange ( this, SvtResId( FL_PRINTRANGE
) ),
102 maRbtAll ( this, SvtResId( RBT_ALL
) ),
103 maRbtPages ( this, SvtResId( RBT_PAGES
) ),
104 maRbtSelection ( this, SvtResId( RBT_SELECTION
) ),
105 maEdtPages ( this, SvtResId( EDT_PAGES
) ),
106 maFlSepCopiesRange ( this, SvtResId( FL_SEPCOPIESRANGE
) ),
107 maFlCopies ( this, SvtResId( FL_COPIES
) ),
108 maFtCopies ( this, SvtResId( FT_COPIES
) ),
109 maNumCopies ( this, SvtResId( NUM_COPIES
) ),
110 maImgCollate ( this, SvtResId( IMG_COLLATE
) ),
111 maImgNotCollate ( this, SvtResId( IMG_NOT_COLLATE
) ),
112 maCbxCollate ( this, SvtResId( CBX_COLLATE
) ),
113 maFlSepButtonLine ( this, SvtResId( FL_SEPBUTTONLINE
) ),
114 maBtnOptions ( this, SvtResId( BTN_OPTIONS
) ),
115 maBtnOK ( this, SvtResId( BTN_OK
) ),
116 maBtnCancel ( this, SvtResId( BTN_CANCEL
) ),
117 maBtnHelp ( this, SvtResId( BTN_HELP
) ),
118 mbWithSheetsAndCells( bWithSheetsAndCells
),
119 maAllFilterStr ( SvtResId( STR_ALLFILTER
) )
125 mpPrinterImpl
= new SvtPrinterImpl
;
131 meCheckRange
= PRINTDIALOG_ALL
;
137 mbCollateCheck
= TRUE
;
140 maStatusTimer
.SetTimeout( IMPL_PRINTDLG_STATUS_UPDATE
);
141 maStatusTimer
.SetTimeoutHdl( LINK( this, PrintDialog
, ImplStatusHdl
) );
142 maBtnProperties
.SetClickHdl( LINK( this, PrintDialog
, ImplPropertiesHdl
) );
143 maLbName
.SetSelectHdl( LINK( this, PrintDialog
, ImplChangePrinterHdl
) );
145 maFiPrintFile
.SetStyle( maFiPrintFile
.GetStyle() | WB_PATHELLIPSIS
);
147 Link
aLink( LINK( this, PrintDialog
, ImplModifyControlHdl
) );
148 maCbxFilePrint
.SetClickHdl( aLink
);
149 maRbtAll
.SetClickHdl( aLink
);
150 maRbtPages
.SetClickHdl( aLink
);
151 maRbtSelection
.SetClickHdl( aLink
);
152 maEdtPages
.SetModifyHdl( aLink
);
153 maNumCopies
.SetModifyHdl( aLink
);
154 maCbxCollate
.SetClickHdl( aLink
);
155 maBtnOptions
.SetClickHdl( aLink
);
156 maEdtFaxNo
.SetModifyHdl( aLink
);
157 maBtnOK
.SetClickHdl( aLink
);
163 // -----------------------------------------------------------------------
165 PrintDialog::~PrintDialog()
167 ImplFreePrnDlgListBox( &maLbName
, FALSE
);
168 delete mpPrinterImpl
;
171 // -----------------------------------------------------------------------
173 void PrintDialog::ImplSetImages()
175 if( ! GetSettings().GetStyleSettings().GetDialogColor().IsDark() )
177 maImgCollate
.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_COLLATE
) ), BMP_COLOR_NORMAL
);
178 maImgNotCollate
.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_NOCOLLATE
) ), BMP_COLOR_NORMAL
);
182 maImgCollate
.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_COLLATE_HC
) ), BMP_COLOR_HIGHCONTRAST
);
183 maImgNotCollate
.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_NOCOLLATE_HC
) ), BMP_COLOR_HIGHCONTRAST
);
187 // -----------------------------------------------------------------------
189 void PrintDialog::ImplSetInfo()
191 const QueueInfo
* pInfo
= Printer::GetQueueInfo( maLbName
.GetSelectEntry(), true );
194 maFiType
.SetText( pInfo
->GetDriver() );
195 maFiLocation
.SetText( pInfo
->GetLocation() );
196 maFiComment
.SetText( pInfo
->GetComment() );
197 maFiStatus
.SetText( ImplPrnDlgGetStatusText( *pInfo
) );
202 maFiType
.SetText( aTempStr
);
203 maFiLocation
.SetText( aTempStr
);
204 maFiComment
.SetText( aTempStr
);
205 maFiStatus
.SetText( aTempStr
);
209 if( pInfo
&& pInfo
->GetLocation().EqualsAscii( "fax_queue" ) )
211 maFiPrintFile
.Show( FALSE
);
212 maCbxFilePrint
.Show( FALSE
);
213 maFiFaxNo
.Show( TRUE
);
214 maEdtFaxNo
.Show( TRUE
);
215 Printer
* pPrinter
= TEMPPRINTER() ? TEMPPRINTER() : mpPrinter
;
216 maEdtFaxNo
.SetText( pPrinter
->GetJobValue( String::CreateFromAscii( "FAX#" ) ) );
218 Size aFTSize
= maFiFaxNo
.GetSizePixel();
219 long nTextWidth
= maFiFaxNo
.GetCtrlTextWidth( maFiFaxNo
.GetText() ) + 10;
220 if ( aFTSize
.Width() < nTextWidth
)
222 long nDelta
= nTextWidth
- aFTSize
.Width();
223 aFTSize
.Width() = aFTSize
.Width() + nDelta
;
224 maFiFaxNo
.SetSizePixel( aFTSize
);
225 Size aEdtSize
= maEdtFaxNo
.GetSizePixel();
226 aEdtSize
.Width() = aEdtSize
.Width() - nDelta
;
227 Point aEdtPos
= maEdtFaxNo
.GetPosPixel();
228 aEdtPos
.X() = aEdtPos
.X() + nDelta
;
229 maEdtFaxNo
.SetPosSizePixel( aEdtPos
, aEdtSize
);
235 maFiPrintFile
.Show( TRUE
);
236 maCbxFilePrint
.Show( TRUE
);
237 maFiFaxNo
.Show( FALSE
);
238 maEdtFaxNo
.Show( FALSE
);
243 // -----------------------------------------------------------------------
245 void PrintDialog::ImplCheckOK()
247 // Ueberprueft, ob der OK-Button enabled ist
250 if ( bEnable
&& maRbtPages
.IsChecked() )
251 bEnable
= maEdtPages
.GetText().Len() > 0;
256 bEnable
= TEMPPRINTER()->IsValid();
258 bEnable
= mpPrinter
->IsValid();
261 maBtnOK
.Enable( bEnable
);
264 // -----------------------------------------------------------------------
266 void PrintDialog::ImplInitControls()
272 if( meCheckRange
== PRINTDIALOG_ALL
)
273 maRbtAll
.Check( TRUE
);
276 maRbtAll
.Enable( FALSE
);
281 maRbtSelection
.Enable();
282 if ( meCheckRange
== PRINTDIALOG_SELECTION
)
283 maRbtSelection
.Check( TRUE
);
286 maRbtSelection
.Enable( FALSE
);
293 maEdtPages
.SetText( maRangeText
);
295 if( ( meCheckRange
== PRINTDIALOG_FROMTO
) ||
296 ( meCheckRange
== PRINTDIALOG_RANGE
) )
298 maRbtPages
.Check( TRUE
);
302 maEdtPages
.Enable( FALSE
);
306 maRbtPages
.Enable( FALSE
);
311 maNumCopies
.SetValue( mnCopyCount
);
314 maCbxCollate
.Enable( mbCollate
);
315 maCbxCollate
.Check( mbCollateCheck
);
321 if ( !mbWithSheetsAndCells
)
324 LogicToPixel( Size( RSC_SP_CTRL_GROUP_X
, RSC_SP_CTRL_GROUP_Y
), MAP_APPFONT
);
325 long nTempPos
= maImgCollate
.GetPosPixel().Y() +
326 maImgCollate
.GetSizePixel().Height() + aMarginSize
.Height();
327 long nDelta1
= maFlPrintRange
.GetPosPixel().Y() - maFlPrint
.GetPosPixel().Y();
328 long nDelta2
= maFlSepButtonLine
.GetPosPixel().Y() - nTempPos
;
331 maRbtAllSheets
.Hide();
332 maRbtSelectedSheets
.Hide();
333 maRbtSelectedCells
.Hide();
334 maRbtSelection
.Show();
336 Size aNewSize
= GetSizePixel();
337 aNewSize
.Height() -= nDelta2
;
338 SetSizePixel( aNewSize
);
339 aNewSize
= maFlSepCopiesRange
.GetSizePixel();
340 aNewSize
.Height() -= nDelta2
;
341 maFlSepCopiesRange
.SetSizePixel( aNewSize
);
343 long nDelta
= nDelta1
;
344 Window
* pControls
[] = { &maFlPrintRange
, &maRbtAll
,
345 &maRbtPages
, &maEdtPages
, &maRbtSelection
, NULL
,
346 &maFlSepButtonLine
, &maBtnOptions
, &maBtnOK
,
347 &maBtnCancel
, &maBtnHelp
};
348 Window
** pCtrl
= pControls
;
349 const sal_Int32 nCount
= sizeof( pControls
) / sizeof( pControls
[0] );
350 for ( sal_Int32 i
= 0; i
< nCount
; ++i
, ++pCtrl
)
352 if ( NULL
== *pCtrl
)
357 Point aNewPos
= (*pCtrl
)->GetPosPixel();
358 aNewPos
.Y() -= nDelta
;
359 (*pCtrl
)->SetPosPixel( aNewPos
);
364 // -----------------------------------------------------------------------
366 void PrintDialog::ImplFillDialogData()
368 if ( maRbtAll
.IsChecked() )
369 meCheckRange
= PRINTDIALOG_ALL
;
370 else if( maRbtSelection
.IsChecked() )
371 meCheckRange
= PRINTDIALOG_SELECTION
;
374 meCheckRange
= PRINTDIALOG_RANGE
;
375 maRangeText
= maEdtPages
.GetText();
378 mnCopyCount
= (USHORT
) maNumCopies
.GetValue();
379 mbCollateCheck
= maCbxCollate
.IsChecked();
382 if ( maCbxFilePrint
.IsChecked() )
383 mpPrinter
->SetPrintFile( maFiPrintFile
.GetText() );
384 mpPrinter
->EnablePrintFile( maCbxFilePrint
.IsChecked() );
387 // -----------------------------------------------------------------------
389 IMPL_LINK( PrintDialog
, ImplStatusHdl
, Timer
*, EMPTYARG
)
392 ImplPrnDlgUpdateQueueInfo( &maLbName
, aInfo
);
393 maFiStatus
.SetText( ImplPrnDlgGetStatusText( aInfo
) );
398 // -----------------------------------------------------------------------
400 IMPL_LINK( PrintDialog
, ImplPropertiesHdl
, void*, EMPTYARG
)
402 if ( !TEMPPRINTER() )
403 TEMPPRINTER() = new Printer( mpPrinter
->GetJobSetup() );
404 TEMPPRINTER()->Setup( this );
409 // -----------------------------------------------------------------------
411 IMPL_LINK( PrintDialog
, ImplChangePrinterHdl
, void*, EMPTYARG
)
413 TEMPPRINTER() = ImplPrnDlgListBoxSelect( &maLbName
, &maBtnProperties
,
414 mpPrinter
, TEMPPRINTER() );
416 ImplCheckOK(); // Check if "OK" button can be enabled now!
421 // -----------------------------------------------------------------------
423 bool PrintDialog::ImplGetFilename()
425 uno::Reference
< lang::XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
426 static ::rtl::OUString aOldFile
;
429 uno::Sequence
< uno::Any
> aTempl( 1 );
430 aTempl
.getArray()[0] <<= ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
;
431 uno::Reference
< ui::dialogs::XFilePicker
> xFilePicker(
432 xFactory
->createInstanceWithArguments(
433 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ),
434 aTempl
), uno::UNO_QUERY
);
435 DBG_ASSERT( xFilePicker
.is(), "could not get FilePicker service" );
437 uno::Reference
< ui::dialogs::XFilterManager
> xFilterMgr( xFilePicker
, uno::UNO_QUERY
);
438 if( xFilePicker
.is() && xFilterMgr
.is() )
443 // add PostScript and PDF
444 Printer
* pPrinter
= TEMPPRINTER() ? TEMPPRINTER() : mpPrinter
;
445 bool bPS
= true, bPDF
= true;
448 if( pPrinter
->GetCapabilities( PRINTER_CAPABILITIES_PDF
) )
454 xFilterMgr
->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PostScript" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.ps" ) ) );
456 xFilterMgr
->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Portable Document Format" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.pdf" ) ) );
458 xFilterMgr
->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.PRN" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ) );
460 // add arbitrary files
461 xFilterMgr
->appendFilter( maAllFilterStr
, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) );
463 catch( lang::IllegalArgumentException rExc
)
465 DBG_ERRORFILE( "caught IllegalArgumentException when registering filter\n" );
468 if( aOldFile
.getLength() )
470 INetURLObject
aUrl( aOldFile
, INET_PROT_FILE
);
471 xFilePicker
->setDefaultName( aUrl
.GetLastName() );
473 xFilePicker
->setDisplayDirectory( aUrl
.GetMainURL( INetURLObject::DECODE_TO_IURI
) );
476 if( xFilePicker
->execute() == ui::dialogs::ExecutableDialogResults::OK
)
478 uno::Sequence
< ::rtl::OUString
> aPathSeq( xFilePicker
->getFiles() );
479 INetURLObject
aObj( aPathSeq
[0] );
480 maFiPrintFile
.SetText( aOldFile
= aObj
.PathToFileName() );
487 // something went awry, lets try the old fashioned dialogue
488 Window
* pDlgParent
= IsReallyVisible() ? this : GetParent();
489 FileDialog
aDlg( pDlgParent
, WB_STDDIALOG
| WB_SAVEAS
);
491 aDlg
.AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ) );
492 aDlg
.SetDefaultExt( String( RTL_CONSTASCII_USTRINGPARAM( "prn" ) ) );
494 aDlg
.AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "PostScript" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.ps" ) ) );
495 aDlg
.SetDefaultExt( String( RTL_CONSTASCII_USTRINGPARAM( "ps" ) ) );
498 if( aOldFile
.getLength() )
499 aDlg
.SetPath( aOldFile
);
503 String aTargetFile
= aDlg
.GetPath();
504 maFiPrintFile
.SetText( aOldFile
= aTargetFile
);
511 // -----------------------------------------------------------------------
513 IMPL_LINK( PrintDialog
, ImplModifyControlHdl
, void*, p
)
515 // Radiobuttons (Umfang)
516 if ( !p
|| (p
== &maRbtAll
) || (p
== &maRbtPages
) || (p
== &maRbtSelection
) )
518 BOOL bCheck
= maRbtPages
.IsChecked();
519 maEdtPages
.Enable( bCheck
);
520 if ( p
== &maRbtPages
)
521 maEdtPages
.GrabFocus();
525 // Edit-Felder (Seiten)
526 if ( p
== &maEdtPages
)
529 if( p
== &maEdtFaxNo
)
531 Printer
* pPrinter
= TEMPPRINTER() ? TEMPPRINTER() : mpPrinter
;
532 pPrinter
->SetJobValue( String::CreateFromAscii( "FAX#" ), maEdtFaxNo
.GetText() );
536 BOOL bNumCopies
= FALSE
;
538 if ( !p
|| p
== &maNumCopies
)
542 //BOOL bCopies = maNumCopies.GetValue() > 1;
543 maCbxCollate
.Enable( mbCollate
);
546 maCbxCollate.Check( FALSE );
548 if ( mbCollateCheck
)
549 maCbxCollate
.Check( TRUE
);
553 if ( !p
|| p
== &maCbxCollate
|| bNumCopies
)
555 BOOL bCheck
= maCbxCollate
.IsChecked();
558 mbCollateCheck
= maCbxCollate
.IsChecked();
563 maImgNotCollate
.Hide();
568 maImgNotCollate
.Show();
573 if ( p
== &maBtnOptions
)
578 EndDialog( maCbxFilePrint
.IsChecked() ? ImplGetFilename() : TRUE
);
584 // -----------------------------------------------------------------------
586 long PrintDialog::ClickOptionsHdl()
588 if ( maOptionsHdlLink
.IsSet() )
589 return maOptionsHdlLink
.Call( this );
594 // -----------------------------------------------------------------------
596 long PrintDialog::OK()
598 if ( maOKHdlLink
.IsSet() )
599 return maOKHdlLink
.Call( this );
604 // -----------------------------------------------------------------------
606 void PrintDialog::EnableSheetRange( bool bEnable
, PrintSheetRange eRange
)
608 if ( mbWithSheetsAndCells
)
612 case PRINTSHEETS_ALL
:
613 maRbtAllSheets
.Enable( bEnable
!= false );
615 case PRINTSHEETS_SELECTED_SHEETS
:
616 maRbtSelectedSheets
.Enable( bEnable
!= false );
618 case PRINTSHEETS_SELECTED_CELLS
:
619 maRbtSelectedCells
.Enable( bEnable
!= false );
622 DBG_ERRORFILE( "PrintDialog::EnableSheetRange(): invalid range" );
627 // -----------------------------------------------------------------------
629 bool PrintDialog::IsSheetRangeEnabled( PrintSheetRange eRange
) const
631 if ( !mbWithSheetsAndCells
)
637 case PRINTSHEETS_ALL
:
638 bRet
= maRbtAllSheets
.IsEnabled() != FALSE
;
640 case PRINTSHEETS_SELECTED_SHEETS
:
641 bRet
= maRbtSelectedSheets
.IsEnabled() != FALSE
;
643 case PRINTSHEETS_SELECTED_CELLS
:
644 bRet
= maRbtSelectedCells
.IsEnabled() != FALSE
;
647 DBG_ERRORFILE( "PrintDialog::IsSheetRangeEnabled(): invalid range" );
652 // -----------------------------------------------------------------------
654 void PrintDialog::CheckSheetRange( PrintSheetRange eRange
)
656 if ( mbWithSheetsAndCells
)
660 case PRINTSHEETS_ALL
:
661 maRbtAllSheets
.Check();
663 case PRINTSHEETS_SELECTED_SHEETS
:
664 maRbtSelectedSheets
.Check();
666 case PRINTSHEETS_SELECTED_CELLS
:
667 maRbtSelectedCells
.Check();
670 DBG_ERRORFILE( "PrintDialog::CheckSheetRange(): invalid range" );
675 // -----------------------------------------------------------------------
677 PrintSheetRange
PrintDialog::GetCheckedSheetRange() const
679 PrintSheetRange eRange
= PRINTSHEETS_ALL
;
680 if ( mbWithSheetsAndCells
)
682 if ( maRbtSelectedSheets
.IsChecked() )
683 eRange
= PRINTSHEETS_SELECTED_SHEETS
;
684 else if ( maRbtSelectedCells
.IsChecked() )
685 eRange
= PRINTSHEETS_SELECTED_CELLS
;
690 // -----------------------------------------------------------------------
692 bool PrintDialog::IsSheetRangeChecked( PrintSheetRange eRange
) const
694 if ( !mbWithSheetsAndCells
)
700 case PRINTSHEETS_ALL
:
701 bRet
= maRbtAllSheets
.IsChecked() != FALSE
;
703 case PRINTSHEETS_SELECTED_SHEETS
:
704 bRet
= maRbtSelectedSheets
.IsChecked() != FALSE
;
706 case PRINTSHEETS_SELECTED_CELLS
:
707 bRet
= maRbtSelectedCells
.IsChecked() != FALSE
;
710 DBG_ERRORFILE( "PrintDialog::IsSheetRangeChecked(): invalid range" );
715 // -----------------------------------------------------------------------
717 long PrintDialog::Notify( NotifyEvent
& rNEvt
)
719 if ( (rNEvt
.GetType() == EVENT_GETFOCUS
) && IsReallyVisible() )
720 ImplStatusHdl( &maStatusTimer
);
721 else if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
723 if ( rNEvt
.GetKeyEvent()->GetKeyCode().GetCode() == KEY_F1
&& mpPrinterImpl
->m_bHelpDisabled
)
724 return 1; // do nothing
727 return ModalDialog::Notify( rNEvt
);
730 // -----------------------------------------------------------------------
732 void PrintDialog::DataChanged( const DataChangedEvent
& rDCEvt
)
734 if ( rDCEvt
.GetType() == DATACHANGED_PRINTER
)
736 TEMPPRINTER() = ImplPrnDlgUpdatePrinter( mpPrinter
, TEMPPRINTER() );
739 pPrn
= TEMPPRINTER();
742 ImplFillPrnDlgListBox( pPrn
, &maLbName
, &maBtnProperties
);
746 else if ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
)
749 ModalDialog::DataChanged( rDCEvt
);
752 // -----------------------------------------------------------------------
754 short PrintDialog::Execute()
756 if ( !mpPrinter
|| mpPrinter
->IsPrinting() || mpPrinter
->IsJobActive() )
758 DBG_ERRORFILE( "PrinterSetupDialog::Execute() - No Printer or printer is printing" );
762 // check if the printer brings up its own dialog
763 // in that case leave the work to that dialog
764 if( mpPrinter
->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG
) )
767 Printer::updatePrinters();
769 // Controls initialisieren
770 ImplFillPrnDlgListBox( mpPrinter
, &maLbName
, &maBtnProperties
);
772 maStatusTimer
.Start();
774 maNumCopies
.GrabFocus();
775 maNumCopies
.SetSelection( Selection( 0, maNumCopies
.GetText().Len() ) );
776 ImplModifyControlHdl( NULL
);
779 short nRet
= ModalDialog::Execute();
781 // Wenn Dialog mit OK beendet wurde, dann die Daten updaten
785 mpPrinter
->SetPrinterProps( TEMPPRINTER() );
786 ImplFillDialogData();
789 maStatusTimer
.Stop();
794 // -----------------------------------------------------------------------
796 void PrintDialog::DisableHelp()
798 mpPrinterImpl
->m_bHelpDisabled
= sal_True
;