diff options
Diffstat (limited to 'vcl/source/window/printdlg.cxx')
-rw-r--r-- | vcl/source/window/printdlg.cxx | 529 |
1 files changed, 267 insertions, 262 deletions
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 4932b689a9c2..40b80e234ff3 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -47,7 +47,7 @@ #include "unotools/localedatawrapper.hxx" -#include "rtl/ustrbuf.hxx" +#include "rtl/strbuf.hxx" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/container/XNameAccess.hpp" @@ -61,19 +61,23 @@ using namespace com::sun::star::lang; using namespace com::sun::star::container; using namespace com::sun::star::beans; -#define HELPID_PREFIX ".HelpId:vcl:PrintDialog" -#define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ), HID_PRINTDLG ) ) -#define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ), HID_PRINTDLG ) ) - PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ) , maOrigSize( 10, 10 ) , maPageVDev( *this ) , maToolTipString( String( VclResId( SV_PRINT_PRINTPREVIEW_TXT ) ) ) + , mbGreyscale( false ) + , maHorzDim( this, WB_HORZ | WB_CENTER ) + , maVertDim( this, WB_VERT | WB_VCENTER ) { - SetPaintTransparent( TRUE ); + SetPaintTransparent( sal_True ); SetBackground(); maPageVDev.SetBackground( Color( COL_WHITE ) ); + maHorzDim.Show(); + maVertDim.Show(); + + maHorzDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) ); + maVertDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) ); } PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() @@ -93,9 +97,10 @@ void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDC void PrintDialog::PrintPreviewWindow::Resize() { Size aNewSize( GetSizePixel() ); + long nTextHeight = maHorzDim.GetTextHeight(); // leave small space for decoration - aNewSize.Width() -= 2; - aNewSize.Height() -= 2; + aNewSize.Width() -= nTextHeight + 2; + aNewSize.Height() -= nTextHeight + 2; Size aScaledSize; double fScale = 1.0; @@ -136,17 +141,29 @@ void PrintDialog::PrintPreviewWindow::Resize() fZoom /= 2.0; } - maPageVDev.SetOutputSizePixel( aScaledSize, FALSE ); + maPageVDev.SetOutputSizePixel( aScaledSize, sal_False ); + + // position dimension lines + Point aRef( nTextHeight + (aNewSize.Width() - maPreviewSize.Width())/2, + nTextHeight + (aNewSize.Height() - maPreviewSize.Height())/2 ); + maHorzDim.SetPosSizePixel( Point( aRef.X(), aRef.Y() - nTextHeight ), + Size( maPreviewSize.Width(), nTextHeight ) ); + maVertDim.SetPosSizePixel( Point( aRef.X() - nTextHeight, aRef.Y() ), + Size( nTextHeight, maPreviewSize.Height() ) ); + } void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) { + long nTextHeight = maHorzDim.GetTextHeight(); Size aSize( GetSizePixel() ); + aSize.Width() -= nTextHeight; + aSize.Height() -= nTextHeight; if( maReplacementString.getLength() != 0 ) { // replacement is active Push(); - Rectangle aTextRect( Point( 0, 0 ), aSize ); + Rectangle aTextRect( Point( nTextHeight, nTextHeight ), aSize ); DecorationView aVw( this ); aVw.DrawFrame( aTextRect, FRAME_DRAW_GROUP ); aTextRect.Left() += 2; @@ -164,8 +181,8 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) { GDIMetaFile aMtf( maMtf ); - Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2, - (aSize.Height() - maPreviewSize.Height()) / 2 ); + Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2 + nTextHeight, + (aSize.Height() - maPreviewSize.Height()) / 2 + nTextHeight ); Size aVDevSize( maPageVDev.GetOutputSizePixel() ); const Size aLogicSize( maPageVDev.PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) ); @@ -180,6 +197,11 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) maPageVDev.Erase(); maPageVDev.Push(); maPageVDev.SetMapMode( MAP_100TH_MM ); + sal_uLong nOldDrawMode = maPageVDev.GetDrawMode(); + if( mbGreyscale ) + maPageVDev.SetDrawMode( maPageVDev.GetDrawMode() | + ( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT | + DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) ); aMtf.WindStart(); aMtf.Scale( fScale, fScale ); aMtf.WindStart(); @@ -189,6 +211,7 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) SetMapMode( MAP_PIXEL ); maPageVDev.SetMapMode( MAP_PIXEL ); DrawOutDev( aOffset, maPreviewSize, Point( 0, 0 ), aVDevSize, maPageVDev ); + maPageVDev.SetDrawMode( nOldDrawMode ); DecorationView aVw( this ); Rectangle aFrame( aOffset + Point( -1, -1 ), Size( maPreviewSize.Width() + 2, maPreviewSize.Height() + 2 ) ); @@ -218,27 +241,50 @@ void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, const Size& i_rOrigSize, + const rtl::OUString& i_rPaperName, const rtl::OUString& i_rReplacement, sal_Int32 i_nDPIX, - sal_Int32 i_nDPIY + sal_Int32 i_nDPIY, + bool i_bGreyscale ) { rtl::OUStringBuffer aBuf( 256 ); aBuf.append( maToolTipString ); - #if OSL_DEBUG_LEVEL > 0 - aBuf.appendAscii( "\n---\nPageSize: " ); - aBuf.append( sal_Int32( i_rOrigSize.Width()/100) ); - aBuf.appendAscii( "mm x " ); - aBuf.append( sal_Int32( i_rOrigSize.Height()/100) ); - aBuf.appendAscii( "mm" ); - #endif SetQuickHelpText( aBuf.makeStringAndClear() ); maMtf = i_rNewPreview; maOrigSize = i_rOrigSize; maReplacementString = i_rReplacement; + mbGreyscale = i_bGreyscale; maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY ); - maPageVDev.EnableOutput( TRUE ); + maPageVDev.EnableOutput( sal_True ); + + // use correct measurements + const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() ); + MapUnit eUnit = MAP_MM; + int nDigits = 0; + if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US ) + { + eUnit = MAP_100TH_INCH; + nDigits = 2; + } + Size aLogicPaperSize( LogicToLogic( i_rOrigSize, MapMode( MAP_100TH_MM ), MapMode( eUnit ) ) ); + String aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) ); + aBuf.append( aNumText ); + aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" ); + if( i_rPaperName.getLength() ) + { + aBuf.appendAscii( " (" ); + aBuf.append( i_rPaperName ); + aBuf.append( sal_Unicode(')') ); + } + maHorzDim.SetText( aBuf.makeStringAndClear() ); + + aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ); + aBuf.append( aNumText ); + aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" ); + maVertDim.SetText( aBuf.makeStringAndClear() ); + Resize(); Invalidate(); } @@ -291,12 +337,18 @@ void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) int nX = 0, nY = 0; switch( mnOrderMode ) { - case SV_PRINT_PRT_NUP_ORDER_LRTD: + case SV_PRINT_PRT_NUP_ORDER_LRTB: nX = (i % mnColumns); nY = (i / mnColumns); break; - case SV_PRINT_PRT_NUP_ORDER_TDLR: + case SV_PRINT_PRT_NUP_ORDER_TBLR: nX = (i / mnRows); nY = (i % mnRows); break; + case SV_PRINT_PRT_NUP_ORDER_RLTB: + nX = mnColumns - 1 - (i % mnColumns); nY = (i / mnColumns); + break; + case SV_PRINT_PRT_NUP_ORDER_TBRL: + nX = mnColumns - 1 - (i / mnRows); nY = (i % mnRows); + break; } Size aTextSize( GetTextWidth( aPageText ), nTextHeight ); int nDeltaX = (aSubSize.Width() - aTextSize.Width()) / 2; @@ -336,13 +388,13 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) FreeResource(); maNupOrderWin.Show(); - maPagesBtn.Check( TRUE ); - maBrochureBtn.Show( FALSE ); + maPagesBtn.Check( sal_True ); + maBrochureBtn.Show( sal_False ); // setup field units for metric fields const LocaleDataWrapper& rLocWrap( maPageMarginEdt.GetLocaleDataWrapper() ); FieldUnit eUnit = FUNIT_MM; - USHORT nDigits = 0; + sal_uInt16 nDigits = 0; if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US ) { eUnit = FUNIT_INCH; @@ -356,28 +408,6 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maPageMarginEdt.SetDecimalDigits( nDigits ); maSheetMarginEdt.SetDecimalDigits( nDigits ); - SMHID1( "NUpPage" ); - maNupLine.SMHID2("NUpPage", "Layout"); - maBrochureBtn.SMHID2("NUpPage", "Brochure" ); - maPagesBtn.SMHID2( "NUpPage", "PagesPerSheet" ); - maPagesBoxTitleTxt.SMHID2( "NUpPage", "PagesPerSheetLabel" ); - maNupPagesBox.SMHID2( "NUpPage", "PagesPerSheetBox" ); - maNupNumPagesTxt.SMHID2( "NUpPage", "Columns" ); - maNupColEdt.SMHID2( "NUpPage", "ColumnsBox" ); - maNupTimesTxt.SMHID2( "NUpPage", "Rows" ); - maNupRowsEdt.SMHID2( "NUpPage", "RowsBox" ); - maPageMarginTxt1.SMHID2( "NUpPage", "PageMargin" ); - maPageMarginEdt.SMHID2( "NUpPage", "PageMarginBox" ); - maPageMarginTxt2.SMHID2( "NUpPage", "PageMarginCont" ); - maSheetMarginTxt1.SMHID2( "NUpPage", "SheetMargin" ); - maSheetMarginEdt.SMHID2( "NUpPage", "SheetMarginBox" ); - maSheetMarginTxt2.SMHID2( "NUpPage", "SheetMarginCont" ); - maNupOrientationTxt.SMHID2( "NUpPage", "Orientation" ); - maNupOrientationBox.SMHID2( "NUpPage", "OrientationBox" ); - maNupOrderTxt.SMHID2( "NUpPage", "Order" ); - maNupOrderBox.SMHID2( "NUpPage", "OrderBox" ); - maBorderCB.SMHID2( "NUpPage", "BorderBox" ); - setupLayout(); } @@ -387,7 +417,7 @@ PrintDialog::NUpTabPage::~NUpTabPage() void PrintDialog::NUpTabPage::enableNupControls( bool bEnable ) { - maNupPagesBox.Enable( TRUE ); + maNupPagesBox.Enable( sal_True ); maNupNumPagesTxt.Enable( bEnable ); maNupColEdt.Enable( bEnable ); maNupTimesTxt.Enable( bEnable ); @@ -420,22 +450,21 @@ void PrintDialog::NUpTabPage::showAdvancedControls( bool i_bShow ) maSheetMarginTxt2.Show( i_bShow ); maNupOrientationTxt.Show( i_bShow ); maNupOrientationBox.Show( i_bShow ); - maLayout.resize(); + getLayout()->resize(); } void PrintDialog::NUpTabPage::setupLayout() { + boost::shared_ptr<vcl::RowOrColumn> xLayout = + boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); Size aBorder( LogicToPixel( Size( 6, 6 ), MapMode( MAP_APPFONT ) ) ); /* According to OOo style guide, the horizontal indentation of child elements to their parent element should always be 6 map units. */ long nIndent = aBorder.Width(); - maLayout.setParentWindow( this ); - maLayout.setOuterBorder( aBorder.Width() ); - - maLayout.addWindow( &maNupLine ); - boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &maLayout, false ) ); - maLayout.addChild( xRow ); + xLayout->addWindow( &maNupLine ); + boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( xLayout.get(), false ) ); + xLayout->addChild( xRow ); boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get() ) ); xRow->addChild( xIndent ); @@ -471,7 +500,7 @@ void PrintDialog::NUpTabPage::setupLayout() xMainCol->addRow( &maNupOrderTxt, &maNupOrderBox, nIndent ); xMainCol->setBorders( xMainCol->addWindow( &maBorderCB ), nIndent, 0, 0, 0 ); - xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, aBorder.Width() ) ) ); + xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, WindowArranger::getDefaultBorder() ) ) ); xMainCol->addChild( xSpacer ); xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); @@ -483,11 +512,6 @@ void PrintDialog::NUpTabPage::setupLayout() showAdvancedControls( false ); } -void PrintDialog::NUpTabPage::Resize() -{ - maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) ); -} - void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& i_rMPS ) { maSheetMarginEdt.SetValue( maSheetMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM ); @@ -523,30 +547,13 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maCopyCountField( this, VclResId( SV_PRINT_COPYCOUNT_FIELD ) ) , maCollateBox( this, VclResId( SV_PRINT_COLLATE ) ) , maCollateImage( this, VclResId( SV_PRINT_COLLATE_IMAGE ) ) + , maReverseOrderBox( this, VclResId( SV_PRINT_OPT_REVERSE ) ) , maCollateImg( VclResId( SV_PRINT_COLLATE_IMG ) ) , maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) ) , mnCollateUIMode( 0 ) - , maLayout( NULL, true ) { FreeResource(); - SMHID1( "JobPage" ); - maPrinterFL.SMHID2( "JobPage", "Printer" ); - maPrinters.SMHID2( "JobPage", "PrinterList" ); - maDetailsBtn.SMHID2( "JobPage", "DetailsBtn" ); - maStatusLabel.SMHID2( "JobPage", "StatusLabel" ); - maStatusTxt.SMHID2( "JobPage", "StatusText" ); - maLocationLabel.SMHID2( "JobPage", "LocationLabel" ); - maLocationTxt.SMHID2( "JobPage", "LocationText" ); - maCommentLabel.SMHID2( "JobPage", "CommentLabel" ); - maCommentTxt.SMHID2( "JobPage", "CommentText" ); - maSetupButton.SMHID2( "JobPage", "Properties" ); - maCopies.SMHID2( "JobPage", "CopiesLine" ); - maCopySpacer.SMHID2( "JobPage", "CopySpacer" ); - maCopyCount.SMHID2( "JobPage", "CopiesText" ); - maCopyCountField.SMHID2( "JobPage", "Copies" ); - maCollateBox.SMHID2( "JobPage", "Collate" ); - maCollateImage.SMHID2( "JobPage", "CollateImage" ); maCopySpacer.Show(); maStatusTxt.Show(); @@ -566,39 +573,37 @@ void PrintDialog::JobTabPage::setupLayout() // sets the results of GetOptimalSize in a normal ListBox maPrinters.SetDropDownLineCount( 4 ); - Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); - - maLayout.setParentWindow( this ); - maLayout.setOuterBorder( aBorder.Width() ); + boost::shared_ptr<vcl::RowOrColumn> xLayout = + boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); // add printer fixed line - maLayout.addWindow( &maPrinterFL ); + xLayout->addWindow( &maPrinterFL ); // add print LB - maLayout.addWindow( &maPrinters, 3 ); + xLayout->addWindow( &maPrinters, 3 ); // create a row for details button/text and properties button - boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( &maLayout, false ) ); - maLayout.addChild( xDetRow ); + boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( xLayout.get(), false ) ); + xLayout->addChild( xDetRow ); xDetRow->addWindow( &maDetailsBtn ); xDetRow->addChild( new vcl::Spacer( xDetRow.get(), 2 ) ); xDetRow->addWindow( &maSetupButton ); // create an indent for details - boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( &maLayout ) ); - maLayout.addChild( xIndent ); + boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xLayout.get() ) ); + xLayout->addChild( xIndent ); // remember details controls mxDetails = xIndent; // create a column for the details - boost::shared_ptr< vcl::LabelColumn > xLabelCol( new vcl::LabelColumn( xIndent.get(), aBorder.Height() ) ); + boost::shared_ptr< vcl::LabelColumn > xLabelCol( new vcl::LabelColumn( xIndent.get() ) ); xIndent->setChild( xLabelCol ); xLabelCol->addRow( &maStatusLabel, &maStatusTxt ); xLabelCol->addRow( &maLocationLabel, &maLocationTxt ); xLabelCol->addRow( &maCommentLabel, &maCommentTxt ); // add print range and copies columns - maLayout.addWindow( &maCopies ); - boost::shared_ptr< vcl::RowOrColumn > xRangeRow( new vcl::RowOrColumn( &maLayout, false, aBorder.Width() ) ); - maLayout.addChild( xRangeRow ); + xLayout->addWindow( &maCopies ); + boost::shared_ptr< vcl::RowOrColumn > xRangeRow( new vcl::RowOrColumn( xLayout.get(), false ) ); + xLayout->addChild( xRangeRow ); // create print range and add to range row mxPrintRange.reset( new vcl::RowOrColumn( xRangeRow.get() ) ); @@ -632,8 +637,8 @@ void PrintDialog::JobTabPage::readFromSettings() if( aValue.equalsIgnoreAsciiCaseAscii( "alwaysoff" ) ) { mnCollateUIMode = 1; - maCollateBox.Check( FALSE ); - maCollateBox.Enable( FALSE ); + maCollateBox.Check( sal_False ); + maCollateBox.Enable( sal_False ); } else { @@ -657,24 +662,13 @@ void PrintDialog::JobTabPage::storeToSettings() rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("false")) ); } -void PrintDialog::JobTabPage::Resize() -{ - maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); -} - PrintDialog::OutputOptPage::OutputOptPage( Window* i_pParent, const ResId& i_rResId ) : TabPage( i_pParent, i_rResId ) , maOptionsLine( this, VclResId( SV_PRINT_OPT_PRINT_FL ) ) , maToFileBox( this, VclResId( SV_PRINT_OPT_TOFILE ) ) , maCollateSingleJobsBox( this, VclResId( SV_PRINT_OPT_SINGLEJOBS ) ) - , maReverseOrderBox( this, VclResId( SV_PRINT_OPT_REVERSE ) ) { FreeResource(); - SMHID1( "OptPage" ); - maOptionsLine.SMHID2( "OptPage", "Options" ); - maToFileBox.SMHID2( "OptPage", "ToFile" ); - maCollateSingleJobsBox.SMHID2( "OptPage", "SingleJobs" ); - maReverseOrderBox.SMHID2( "OptPage", "Reverse" ); setupLayout(); } @@ -685,20 +679,17 @@ PrintDialog::OutputOptPage::~OutputOptPage() void PrintDialog::OutputOptPage::setupLayout() { - Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); - - maLayout.setParentWindow( this ); - maLayout.setOuterBorder( aBorder.Width() ); + boost::shared_ptr<vcl::RowOrColumn> xLayout = + boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); - maLayout.addWindow( &maOptionsLine ); - boost::shared_ptr<vcl::Indenter> xIndent( new vcl::Indenter( &maLayout, aBorder.Width() ) ); - maLayout.addChild( xIndent ); - boost::shared_ptr<vcl::RowOrColumn> xCol( new vcl::RowOrColumn( xIndent.get(), aBorder.Height() ) ); + xLayout->addWindow( &maOptionsLine ); + boost::shared_ptr<vcl::Indenter> xIndent( new vcl::Indenter( xLayout.get(), -1 ) ); + xLayout->addChild( xIndent ); + boost::shared_ptr<vcl::RowOrColumn> xCol( new vcl::RowOrColumn( xIndent.get() ) ); xIndent->setChild( xCol ); mxOptGroup = xCol; xCol->addWindow( &maToFileBox ); xCol->addWindow( &maCollateSingleJobsBox ); - xCol->addWindow( &maReverseOrderBox ); } void PrintDialog::OutputOptPage::readFromSettings() @@ -714,12 +705,6 @@ void PrintDialog::OutputOptPage::storeToSettings() : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("false")) ); } -void PrintDialog::OutputOptPage::Resize() -{ - maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); -} - - PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterController>& i_rController ) : ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) ) , maOKButton( this, VclResId( SV_PRINT_OK ) ) @@ -759,16 +744,14 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterCont // set symbols on forward and backward button maBackwardBtn.SetSymbol( SYMBOL_PREV ); maForwardBtn.SetSymbol( SYMBOL_NEXT ); - maBackwardBtn.ImplSetSmallSymbol( TRUE ); - maForwardBtn.ImplSetSmallSymbol( TRUE ); + maBackwardBtn.ImplSetSmallSymbol( sal_True ); + maForwardBtn.ImplSetSmallSymbol( sal_True ); maPageStr = maNumPagesText.GetText(); // init reverse print - maOptionsPage.maReverseOrderBox.Check( maPController->getReversePrint() ); + maJobPage.maReverseOrderBox.Check( maPController->getReversePrint() ); - // get the first page - preparePreview( true, true ); // fill printer listbox const std::vector< rtl::OUString >& rQueues( Printer::GetPrinterQueues() ); @@ -800,6 +783,12 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterCont maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) ); } } + // not printing to file + maPController->resetPrinterOptions( false ); + + // get the first page + preparePreview( true, true ); + // update the text fields for the printer updatePrinterText(); @@ -835,7 +824,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterCont maJobPage.maDetailsBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maNUpPage.maBorderCB.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maOptionsPage.maToFileBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); - maOptionsPage.maReverseOrderBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); + maJobPage.maReverseOrderBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maOptionsPage.maCollateSingleJobsBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); maNUpPage.maPagesBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); @@ -887,18 +876,6 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterCont } } - // set HelpIDs - SMHID1( "Dialog" ); - maOKButton.SMHID1( "OK" ); - maCancelButton.SMHID1( "Cancel" ); - maHelpButton.SMHID1( "Help" ); - maPreviewWindow.SMHID1( "Preview" ); - maNumPagesText.SMHID1( "NumPagesText" ); - maPageEdit.SMHID1( "PageEdit" ); - maForwardBtn.SMHID1( "ForwardBtn" ); - maBackwardBtn.SMHID1( "BackwardBtn" ); - maTabCtrl.SMHID1( "TabPages" ); - // append further tab pages if( mbShowLayoutPage ) { @@ -927,13 +904,14 @@ PrintDialog::~PrintDialog() void PrintDialog::setupLayout() { - Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); + boost::shared_ptr<vcl::RowOrColumn> xLayout = + boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); + xLayout->setOuterBorder( 0 ); - maLayout.setParentWindow( this ); - boost::shared_ptr< vcl::RowOrColumn > xPreviewAndTab( new vcl::RowOrColumn( &maLayout, false ) ); - size_t nIndex = maLayout.addChild( xPreviewAndTab, 5 ); - maLayout.setBorders( nIndex, aBorder.Width(), aBorder.Width(), aBorder.Width(), 0 ); + boost::shared_ptr< vcl::RowOrColumn > xPreviewAndTab( new vcl::RowOrColumn( xLayout.get(), false ) ); + size_t nIndex = xLayout->addChild( xPreviewAndTab, 5 ); + xLayout->setBorders( nIndex, -1, -1, -1, 0 ); // setup column for preview and sub controls boost::shared_ptr< vcl::RowOrColumn > xPreview( new vcl::RowOrColumn( xPreviewAndTab.get() ) ); @@ -957,12 +935,12 @@ void PrintDialog::setupLayout() xPreviewAndTab->addWindow( &maTabCtrl ); // add the button line - maLayout.addWindow( &maButtonLine ); + xLayout->addWindow( &maButtonLine ); // add the row for the buttons - boost::shared_ptr< vcl::RowOrColumn > xButtons( new vcl::RowOrColumn( &maLayout, false ) ); - nIndex = maLayout.addChild( xButtons ); - maLayout.setBorders( nIndex, aBorder.Width(), 0, aBorder.Width(), aBorder.Width() ); + boost::shared_ptr< vcl::RowOrColumn > xButtons( new vcl::RowOrColumn( xLayout.get(), false ) ); + nIndex = xLayout->addChild( xButtons ); + xLayout->setBorders( nIndex, -1, 0, -1, -1 ); Size aMinSize( maCancelButton.GetSizePixel() ); // insert help button @@ -984,10 +962,10 @@ void PrintDialog::readFromSettings() SettingsConfigItem* pItem = SettingsConfigItem::get(); rtl::OUString aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPage" ) ) ); - USHORT nCount = maTabCtrl.GetPageCount(); - for( USHORT i = 0; i < nCount; i++ ) + sal_uInt16 nCount = maTabCtrl.GetPageCount(); + for( sal_uInt16 i = 0; i < nCount; i++ ) { - USHORT nPageId = maTabCtrl.GetPageId( i ); + sal_uInt16 nPageId = maTabCtrl.GetPageId( i ); if( aValue.equals( maTabCtrl.GetPageText( nPageId ) ) ) { maTabCtrl.SelectTabPage( nPageId ); @@ -995,6 +973,11 @@ void PrintDialog::readFromSettings() } } maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); + if( maOptionsPage.maToFileBox.IsChecked() ) + { + maPController->resetPrinterOptions( true ); + preparePreview( true, true ); + } } void PrintDialog::storeToSettings() @@ -1027,7 +1010,7 @@ int PrintDialog::getCopyCount() bool PrintDialog::isCollate() { - return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : FALSE; + return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : sal_False; } bool PrintDialog::isSingleJobs() @@ -1035,35 +1018,18 @@ bool PrintDialog::isSingleJobs() return maOptionsPage.maCollateSingleJobsBox.IsChecked(); } -static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId = -1, const rtl::OUString& i_rPropName = rtl::OUString() ) +void setHelpId( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpIds, sal_Int32 i_nIndex ) { - rtl::OUStringBuffer aBuf( 256 ); - aBuf.appendAscii( HELPID_PREFIX ); - if( i_rPropName.getLength() ) - { - aBuf.append( sal_Unicode( ':' ) ); - aBuf.append( i_rPropName ); - } - if( i_pType ) - { - aBuf.append( sal_Unicode( ':' ) ); - aBuf.appendAscii( i_pType ); - } - if( i_nId >= 0 ) - { - aBuf.append( sal_Unicode( ':' ) ); - aBuf.append( i_nId ); - } - i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear(), HID_PRINTDLG ) ); + if( i_nIndex >= 0 && i_nIndex < i_rHelpIds.getLength() ) + i_pWindow->SetHelpId( rtl::OUStringToOString( i_rHelpIds.getConstArray()[i_nIndex], RTL_TEXTENCODING_UTF8 ) ); } -static void setHelpText( Window* /*i_pWindow*/, const Sequence< rtl::OUString >& /*i_rHelpTexts*/, sal_Int32 /*i_nIndex*/ ) +static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpTexts, sal_Int32 i_nIndex ) { // without a help text set and the correct smartID, // help texts will be retrieved from the online help system - - // passed help texts for optional UI is used only for native dialogs which currently - // cannot access the same (rather implicit) mechanism + if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() ) + i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] ); } void updateMaxSize( const Size& i_rCheckSize, Size& o_rMaxSize ) @@ -1076,17 +1042,15 @@ void updateMaxSize( const Size& i_rCheckSize, Size& o_rMaxSize ) void PrintDialog::setupOptionalUI() { - Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); - - std::vector<vcl::RowOrColumn*> aDynamicColumns; - vcl::RowOrColumn* pCurColumn = 0; + std::vector< boost::shared_ptr<vcl::RowOrColumn> > aDynamicColumns; + boost::shared_ptr< vcl::RowOrColumn > pCurColumn; Window* pCurParent = 0, *pDynamicPageParent = 0; - USHORT nOptPageId = 9, nCurSubGroup = 0; + sal_uInt16 nOptPageId = 9, nCurSubGroup = 0; bool bOnStaticPage = false; bool bSubgroupOnStaticPage = false; - std::multimap< rtl::OUString, vcl::RowOrColumn* > aPropertyToDependencyRowMap; + std::multimap< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> > aPropertyToDependencyRowMap; const Sequence< PropertyValue >& rOptions( maPController->getUIOptions() ); for( int i = 0; i < rOptions.getLength(); i++ ) @@ -1099,7 +1063,9 @@ void PrintDialog::setupOptionalUI() rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + Sequence< sal_Bool > aChoicesDisabled; Sequence< rtl::OUString > aHelpTexts; + Sequence< rtl::OUString > aHelpIds; sal_Int64 nMinValue = 0, nMaxValue = 0; sal_Int32 nCurHelpText = 0; rtl::OUString aGroupingHint; @@ -1122,6 +1088,10 @@ void PrintDialog::setupOptionalUI() { rEntry.Value >>= aChoices; } + else if( rEntry.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ChoicesDisabled" ) ) ) + { + rEntry.Value >>= aChoicesDisabled; + } else if( rEntry.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Property" ) ) ) { PropertyValue aVal; @@ -1169,6 +1139,18 @@ void PrintDialog::setupOptionalUI() } } } + else if( rEntry.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "HelpId" ) ) ) + { + if( ! (rEntry.Value >>= aHelpIds ) ) + { + rtl::OUString aHelpId; + if( (rEntry.Value >>= aHelpId) ) + { + aHelpIds.realloc( 1 ); + *aHelpIds.getArray() = aHelpId; + } + } + } else if( rEntry.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "HintNoLayoutPage" ) ) ) { sal_Bool bNoLayoutPage = sal_False; @@ -1190,37 +1172,40 @@ void PrintDialog::setupOptionalUI() { // restore to dynamic pCurParent = pDynamicPageParent; - pCurColumn = aDynamicColumns.empty() ? NULL : aDynamicColumns.back(); + if( ! aDynamicColumns.empty() ) + pCurColumn = aDynamicColumns.back(); + else + pCurColumn.reset(); bOnStaticPage = false; bSubgroupOnStaticPage = false; if( aGroupingHint.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PrintRange" ) ) ) { - pCurColumn = maJobPage.mxPrintRange.get(); + pCurColumn = maJobPage.mxPrintRange; pCurParent = &maJobPage; // set job page as current parent bOnStaticPage = true; } else if( aGroupingHint.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OptionsPage" ) ) ) { - pCurColumn = &maOptionsPage.maLayout; + pCurColumn = boost::dynamic_pointer_cast<vcl::RowOrColumn>(maOptionsPage.getLayout()); pCurParent = &maOptionsPage; // set options page as current parent bOnStaticPage = true; } else if( aGroupingHint.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OptionsPageOptGroup" ) ) ) { - pCurColumn = maOptionsPage.mxOptGroup.get(); + pCurColumn = maOptionsPage.mxOptGroup; pCurParent = &maOptionsPage; // set options page as current parent bOnStaticPage = true; } else if( aGroupingHint.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "LayoutPage" ) ) ) { - pCurColumn = &maNUpPage.maLayout; + pCurColumn = boost::dynamic_pointer_cast<vcl::RowOrColumn>(maNUpPage.getLayout()); pCurParent = &maNUpPage; // set layout page as current parent bOnStaticPage = true; } else if( aGroupingHint.getLength() ) { - pCurColumn = &maJobPage.maLayout; + pCurColumn = boost::dynamic_pointer_cast<vcl::RowOrColumn>(maJobPage.getLayout()); pCurParent = &maJobPage; // set job page as current parent bOnStaticPage = true; } @@ -1238,17 +1223,16 @@ void PrintDialog::setupOptionalUI() maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); // set help id - setSmartId( pNewGroup, "TabPage", nOptPageId ); + setHelpId( pNewGroup, aHelpIds, 0 ); // set help text setHelpText( pNewGroup, aHelpTexts, 0 ); // reset subgroup counter nCurSubGroup = 0; - aDynamicColumns.push_back( new vcl::RowOrColumn( NULL, true, aBorder.Width() ) ); + aDynamicColumns.push_back( boost::dynamic_pointer_cast<vcl::RowOrColumn>(pNewGroup->getLayout()) ); pCurColumn = aDynamicColumns.back(); pCurColumn->setParentWindow( pNewGroup ); - pCurColumn->setOuterBorder( aBorder.Width() ); bSubgroupOnStaticPage = false; bOnStaticPage = false; } @@ -1270,7 +1254,7 @@ void PrintDialog::setupOptionalUI() pNewSub->Show(); // set help id - setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); + setHelpId( pNewSub, aHelpIds, 0 ); // set help text setHelpText( pNewSub, aHelpTexts, 0 ); // add group to current column @@ -1278,10 +1262,10 @@ void PrintDialog::setupOptionalUI() } // add an indent to the current column - vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn, aBorder.Width() ); + vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn.get(), -1 ); pCurColumn->addChild( pIndent ); // and create a column inside the indent - pCurColumn = new vcl::RowOrColumn( pIndent ); + pCurColumn.reset( new vcl::RowOrColumn( pIndent ) ); pIndent->setChild( pCurColumn ); } // EVIL @@ -1305,17 +1289,17 @@ void PrintDialog::setupOptionalUI() maPropertyToWindowMap[ aPropertyName ].push_back( &maNUpPage.maBrochureBtn ); maControlToPropertyMap[&maNUpPage.maBrochureBtn] = aPropertyName; - aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, maNUpPage.mxBrochureDep.get() ) ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, maNUpPage.mxBrochureDep ) ); } else { - vcl::RowOrColumn* pSaveCurColumn = pCurColumn; + boost::shared_ptr<vcl::RowOrColumn> pSaveCurColumn( pCurColumn ); if( bUseDependencyRow ) { // find the correct dependency row (if any) - std::pair< std::multimap< rtl::OUString, vcl::RowOrColumn* >::iterator, - std::multimap< rtl::OUString, vcl::RowOrColumn* >::iterator > aDepRange; + std::pair< std::multimap< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >::iterator, + std::multimap< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >::iterator > aDepRange; aDepRange = aPropertyToDependencyRowMap.equal_range( aDependsOnName ); if( aDepRange.first != aDepRange.second ) { @@ -1350,20 +1334,20 @@ void PrintDialog::setupOptionalUI() maControlToPropertyMap[pNewBox] = aPropertyName; // set help id - setSmartId( pNewBox, "CheckBox", -1, aPropertyName ); + setHelpId( pNewBox, aHelpIds, 0 ); // set help text setHelpText( pNewBox, aHelpTexts, 0 ); - vcl::RowOrColumn* pDependencyRow = new vcl::RowOrColumn( pCurColumn, false ); + boost::shared_ptr<vcl::RowOrColumn> pDependencyRow( new vcl::RowOrColumn( pCurColumn.get(), false ) ); pCurColumn->addChild( pDependencyRow ); - aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pDependencyRow ) ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, pDependencyRow ) ); // add checkbox to current column pDependencyRow->addWindow( pNewBox ); } else if( aCtrlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Radio" ) ) && pCurParent ) { - vcl::RowOrColumn* pRadioColumn = pCurColumn; + boost::shared_ptr<vcl::RowOrColumn> pRadioColumn( pCurColumn ); if( aText.getLength() ) { // add a FixedText: @@ -1373,16 +1357,17 @@ void PrintDialog::setupOptionalUI() pHeading->Show(); // set help id - setSmartId( pHeading, "FixedText", -1, aPropertyName ); + setHelpId( pHeading, aHelpIds, nCurHelpText ); // set help text - setHelpText( pHeading, aHelpTexts, nCurHelpText++ ); + setHelpText( pHeading, aHelpTexts, nCurHelpText ); + nCurHelpText++; // add fixed text to current column pCurColumn->addWindow( pHeading ); // add an indent to the current column - vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn, 15 ); + vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn.get(), 15 ); pCurColumn->addChild( pIndent ); // and create a column inside the indent - pRadioColumn = new vcl::RowOrColumn( pIndent ); + pRadioColumn.reset( new vcl::RowOrColumn( pIndent ) ); pIndent->setChild( pRadioColumn ); } // iterate options @@ -1392,26 +1377,29 @@ void PrintDialog::setupOptionalUI() pVal->Value >>= nSelectVal; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { - boost::shared_ptr<vcl::LabeledElement> pLabel( new vcl::LabeledElement( pRadioColumn, 1 ) ); + boost::shared_ptr<vcl::LabeledElement> pLabel( new vcl::LabeledElement( pRadioColumn.get(), 1 ) ); pRadioColumn->addChild( pLabel ); boost::shared_ptr<vcl::RowOrColumn> pDependencyRow( new vcl::RowOrColumn( pLabel.get(), false ) ); pLabel->setElement( pDependencyRow ); - aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pDependencyRow.get() ) ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, pDependencyRow ) ); RadioButton* pBtn = new RadioButton( pCurParent, m == 0 ? WB_GROUP : 0 ); maControls.push_front( pBtn ); pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); + if( aChoicesDisabled.getLength() > m && aChoicesDisabled[m] == sal_True ) + pBtn->Enable( sal_False ); pBtn->Show(); maPropertyToWindowMap[ aPropertyName ].push_back( pBtn ); maControlToPropertyMap[pBtn] = aPropertyName; maControlToNumValMap[pBtn] = m; // set help id - setSmartId( pBtn, "RadioButton", m, aPropertyName ); + setHelpId( pBtn, aHelpIds, nCurHelpText ); // set help text - setHelpText( pBtn, aHelpTexts, nCurHelpText++ ); + setHelpText( pBtn, aHelpTexts, nCurHelpText ); + nCurHelpText++; // add the radio button to the column pLabel->setLabel( pBtn ); } @@ -1422,9 +1410,9 @@ void PrintDialog::setupOptionalUI() ) && pCurParent ) { // create a row in the current column - vcl::RowOrColumn* pFieldColumn = new vcl::RowOrColumn( pCurColumn, false ); + boost::shared_ptr<vcl::RowOrColumn> pFieldColumn( new vcl::RowOrColumn( pCurColumn.get(), false ) ); pCurColumn->addChild( pFieldColumn ); - aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pFieldColumn ) ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, pFieldColumn ) ); vcl::LabeledElement* pLabel = NULL; if( aText.getLength() ) @@ -1435,11 +1423,9 @@ void PrintDialog::setupOptionalUI() pHeading->SetText( aText ); pHeading->Show(); - // set help id - setSmartId( pHeading, "FixedText", -1, aPropertyName ); // add to row - pLabel = new vcl::LabeledElement( pFieldColumn, 2 ); + pLabel = new vcl::LabeledElement( pFieldColumn.get(), 2 ); pFieldColumn->addChild( pLabel ); pLabel->setLabel( pHeading ); } @@ -1458,13 +1444,13 @@ void PrintDialog::setupOptionalUI() PropertyValue* pVal = maPController->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; - pList->SelectEntryPos( static_cast<USHORT>(nSelectVal) ); + pList->SelectEntryPos( static_cast<sal_uInt16>(nSelectVal) ); pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); - pList->SetDropDownLineCount( static_cast<USHORT>(aChoices.getLength()) ); + pList->SetDropDownLineCount( static_cast<sal_uInt16>(aChoices.getLength()) ); pList->Show(); // set help id - setSmartId( pList, "ListBox", -1, aPropertyName ); + setHelpId( pList, aHelpIds, 0 ); // set help text setHelpText( pList, aHelpTexts, 0 ); @@ -1497,7 +1483,7 @@ void PrintDialog::setupOptionalUI() pField->Show(); // set help id - setSmartId( pField, "NumericField", -1, aPropertyName ); + setHelpId( pField, aHelpIds, 0 ); // set help text setHelpText( pField, aHelpTexts, 0 ); @@ -1524,7 +1510,7 @@ void PrintDialog::setupOptionalUI() pField->Show(); // set help id - setSmartId( pField, "Edit", -1, aPropertyName ); + setHelpId( pField, aHelpIds, 0 ); // set help text setHelpText( pField, aHelpTexts, 0 ); @@ -1554,9 +1540,9 @@ void PrintDialog::setupOptionalUI() if( maNUpPage.mxPagesBtnLabel.get() ) { maNUpPage.maPagesBoxTitleTxt.SetText( maNUpPage.maPagesBtn.GetText() ); - maNUpPage.maPagesBoxTitleTxt.Show( TRUE ); + maNUpPage.maPagesBoxTitleTxt.Show( sal_True ); maNUpPage.mxPagesBtnLabel->setLabel( &maNUpPage.maPagesBoxTitleTxt ); - maNUpPage.maPagesBtn.Show( FALSE ); + maNUpPage.maPagesBtn.Show( sal_False ); } } @@ -1567,18 +1553,28 @@ void PrintDialog::setupOptionalUI() if( maJobPage.mxPrintRange->countElements() == 0 ) { maJobPage.mxPrintRange->show( false, false ); - maJobPage.maCopySpacer.Show( FALSE ); + maJobPage.maCopySpacer.Show( sal_False ); + maJobPage.maReverseOrderBox.Show( sal_False ); + } + else + { + // add an indent to the current column + vcl::Indenter* pIndent = new vcl::Indenter( maJobPage.mxPrintRange.get(), -1 ); + maJobPage.mxPrintRange->addChild( pIndent ); + // and create a column inside the indent + pIndent->setWindow( &maJobPage.maReverseOrderBox ); + maJobPage.maReverseOrderBox.Show( sal_True ); } #ifdef WNT // FIXME: the GetNativeControlRegion call on Windows has some issues // (which skew the results of GetOptimalSize()) // however fixing this thoroughly needs to take interaction with paint into - // acoount, making the right fix less simple. Fix this the right way + // account, making the right fix less simple. Fix this the right way // at some point. For now simply add some space at the lowest element - size_t nIndex = maJobPage.maLayout.countElements(); + size_t nIndex = maJobPage.getLayout()->countElements(); if( nIndex > 0 ) // sanity check - maJobPage.maLayout.setBorders( nIndex-1, 0, 0, 0, aBorder.Width() ); + maJobPage.getLayout()->setBorders( nIndex-1, 0, 0, 0, -1 ); #endif // create auto mnemomnics now so they can be calculated in layout @@ -1588,13 +1584,13 @@ void PrintDialog::setupOptionalUI() ImplWindowAutoMnemonic( this ); // calculate job page - Size aMaxSize = maJobPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); + Size aMaxSize = maJobPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ); // and layout page - updateMaxSize( maNUpPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); + updateMaxSize( maNUpPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); // and options page - updateMaxSize( maOptionsPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); + updateMaxSize( maOptionsPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); - for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); + for( std::vector< boost::shared_ptr<vcl::RowOrColumn> >::iterator it = aDynamicColumns.begin(); it != aDynamicColumns.end(); ++it ) { Size aPageSize( (*it)->getOptimalSize( WINDOWSIZE_PREFERRED ) ); @@ -1622,19 +1618,8 @@ void PrintDialog::setupOptionalUI() maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); } - // and finally arrange controls - for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); - it != aDynamicColumns.end(); ++it ) - { - (*it)->setManagedArea( Rectangle( Point(), aTabSize ) ); - delete *it; - *it = NULL; - } - maJobPage.Resize(); - maNUpPage.Resize(); - maOptionsPage.Resize(); + Size aSz = getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ); - Size aSz = maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); SetOutputSizePixel( aSz ); } @@ -1651,7 +1636,7 @@ void PrintDialog::checkControlDependencies() if( maJobPage.maCopyCountField.GetValue() > 1 ) maJobPage.maCollateBox.Enable( maJobPage.mnCollateUIMode == 0 ); else - maJobPage.maCollateBox.Enable( FALSE ); + maJobPage.maCollateBox.Enable( sal_False ); Image aImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateImg : maJobPage.maNoCollateImg ); @@ -1660,7 +1645,7 @@ void PrintDialog::checkControlDependencies() // adjust size of image maJobPage.maCollateImage.SetSizePixel( aImgSize ); maJobPage.maCollateImage.SetImage( aImg ); - maJobPage.maLayout.resize(); + maJobPage.getLayout()->resize(); // enable setup button only for printers that can be setup bool bHaveSetup = maPController->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ); @@ -1675,7 +1660,7 @@ void PrintDialog::checkControlDependencies() aPrinterSize.Width() = aSetupPos.X() - aPrinterPos.X() - LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ).Width(); maJobPage.maPrinters.SetSizePixel( aPrinterSize ); maJobPage.maSetupButton.Show(); - maLayout.resize(); + getLayout()->resize(); } } else @@ -1689,7 +1674,7 @@ void PrintDialog::checkControlDependencies() aPrinterSize.Width() = aSetupPos.X() + aSetupSize.Width() - aPrinterPos.X(); maJobPage.maPrinters.SetSizePixel( aPrinterSize ); maJobPage.maSetupButton.Hide(); - maLayout.resize(); + getLayout()->resize(); } } } @@ -1718,6 +1703,16 @@ void PrintDialog::checkOptionalControlDependencies() } } + if( bShouldbeEnabled && dynamic_cast<RadioButton*>(it->first) ) + { + std::map< Window*, sal_Int32 >::const_iterator r_it = maControlToNumValMap.find( it->first ); + if( r_it != maControlToNumValMap.end() ) + { + bShouldbeEnabled = maPController->isUIChoiceEnabled( it->second, r_it->second ); + } + } + + bool bIsEnabled = it->first->IsEnabled(); // Enable does not do a change check first, so can be less cheap than expected if( bShouldbeEnabled != bIsEnabled ) @@ -1806,8 +1801,11 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) } Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); - maPreviewWindow.setPreview( aMtf, aCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr, - aPrt->ImplGetDPIX(), aPrt->ImplGetDPIY() + maPreviewWindow.setPreview( aMtf, aCurPageSize, + aPrt->GetPaperName( false ), + nPages > 0 ? rtl::OUString() : maNoPageStr, + aPrt->ImplGetDPIX(), aPrt->ImplGetDPIY(), + aPrt->GetPrinterOptions().IsConvertToGreyscales() ); maForwardBtn.Enable( mnCurPage < nPages-1 ); @@ -1920,7 +1918,7 @@ void PrintDialog::updateNupFromPages() if( bCustom ) { // see if we have to enlarge the dialog to make the tab page fit - Size aCurSize( maNUpPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ) ); + Size aCurSize( maNUpPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ) ); Size aTabSize( maTabCtrl.GetTabPageSizePixel() ); if( aTabSize.Height() < aCurSize.Height() ) { @@ -1956,10 +1954,14 @@ void PrintDialog::updateNup() int nOrderMode = int(sal_IntPtr(maNUpPage.maNupOrderBox.GetEntryData( maNUpPage.maNupOrderBox.GetSelectEntryPos() ))); - if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTD ) + if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTB ) aMPS.nOrder = PrinterController::LRTB; - else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TDLR ) + else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TBLR ) aMPS.nOrder = PrinterController::TBLR; + else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_RLTB ) + aMPS.nOrder = PrinterController::RLTB; + else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TBRL ) + aMPS.nOrder = PrinterController::TBRL; int nOrientationMode = int(sal_IntPtr(maNUpPage.maNupOrientationBox.GetEntryData( maNUpPage.maNupOrientationBox.GetSelectEntryPos() ))); @@ -1994,6 +1996,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) String aNewPrinter( pBox->GetSelectEntry() ); // set new printer maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( aNewPrinter ) ) ); + maPController->resetPrinterOptions( maOptionsPage.maToFileBox.IsChecked() ); // update text fields updatePrinterText(); } @@ -2024,8 +2027,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) Help* pHelp = Application::GetHelp(); if( pHelp ) { - // FIXME: find out proper help URL and use here - pHelp->Start( HID_PRINTDLG, GetParent() ); + pHelp->Start( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:OK" ) ), &maOKButton ); } } else if( pButton == &maForwardBtn ) @@ -2039,7 +2041,9 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) else if( pButton == &maOptionsPage.maToFileBox ) { maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); - maLayout.resize(); + maPController->resetPrinterOptions( maOptionsPage.maToFileBox.IsChecked() ); + getLayout()->resize(); + preparePreview( true, true ); } else if( pButton == &maNUpPage.maBrochureBtn ) { @@ -2075,7 +2079,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) { maDetailsCollapsedSize = GetOutputSizePixel(); // enlarge dialog if necessary - Size aMinSize( maJobPage.maLayout.getOptimalSize( WINDOWSIZE_MINIMUM ) ); + Size aMinSize( maJobPage.getLayout()->getOptimalSize( WINDOWSIZE_MINIMUM ) ); Size aCurSize( maJobPage.GetSizePixel() ); if( aCurSize.Height() < aMinSize.Height() ) { @@ -2104,9 +2108,9 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) makeAny( sal_Bool(isCollate()) ) ); checkControlDependencies(); } - else if( pButton == &maOptionsPage.maReverseOrderBox ) + else if( pButton == &maJobPage.maReverseOrderBox ) { - sal_Bool bChecked = maOptionsPage.maReverseOrderBox.IsChecked(); + sal_Bool bChecked = maJobPage.maReverseOrderBox.IsChecked(); maPController->setReversePrint( bChecked ); maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverse" ) ), makeAny( bChecked ) ); @@ -2212,7 +2216,7 @@ void PrintDialog::updateWindowFromProperty( const rtl::OUString& i_rProperty ) ListBox* pList = dynamic_cast< ListBox* >( rWindows.front() ); if( pList ) { - pList->SelectEntryPos( static_cast< USHORT >(nVal) ); + pList->SelectEntryPos( static_cast< sal_uInt16 >(nVal) ); } else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) ) { @@ -2349,7 +2353,7 @@ void PrintDialog::Command( const CommandEvent& rEvt ) void PrintDialog::Resize() { - maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); + // maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); // and do the preview; however the metafile does not need to be gotten anew preparePreview( false ); @@ -2453,6 +2457,7 @@ void PrintProgressDialog::tick() void PrintProgressDialog::reset() { + mbCanceled = false; setProgress( 0 ); } @@ -2477,9 +2482,9 @@ void PrintProgressDialog::Paint( const Rectangle& ) nOffset, nWidth, mnProgressHeight, - static_cast<USHORT>(0), - static_cast<USHORT>(10000*mnCur/mnMax), - static_cast<USHORT>(10000/nMaxCount), + static_cast<sal_uInt16>(0), + static_cast<sal_uInt16>(10000*mnCur/mnMax), + static_cast<sal_uInt16>(10000/nMaxCount), maProgressRect ); Pop(); |