2008-10-01 18:22:22 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* $RCSfile: printdlg.cxx,v $
|
|
|
|
* $Revision: 1.1.2.7 $
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "precompiled_vcl.hxx"
|
|
|
|
|
|
|
|
#include "vcl/print.hxx"
|
|
|
|
#include "vcl/prndlg.hxx"
|
|
|
|
#include "vcl/dialog.hxx"
|
|
|
|
#include "vcl/button.hxx"
|
|
|
|
#include "vcl/svdata.hxx"
|
|
|
|
#include "vcl/svids.hrc"
|
|
|
|
#include "vcl/wall.hxx"
|
|
|
|
#include "vcl/jobset.h"
|
2009-03-18 14:46:10 +00:00
|
|
|
#include "vcl/status.hxx"
|
2009-03-18 16:16:06 +00:00
|
|
|
#include "vcl/decoview.hxx"
|
2008-10-01 18:22:22 +00:00
|
|
|
|
|
|
|
#include "rtl/ustrbuf.hxx"
|
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
#include "com/sun/star/awt/Size.hpp"
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
using namespace vcl;
|
2008-10-30 14:31:29 +00:00
|
|
|
using namespace com::sun::star;
|
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::beans;
|
2008-10-01 18:22:22 +00:00
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
#define HELPID_PREFIX ".HelpId:vcl:PrintDialog"
|
|
|
|
#define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ) ) )
|
|
|
|
#define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ) ) )
|
2009-04-24 15:39:41 +00:00
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId )
|
2009-04-24 09:43:48 +00:00
|
|
|
: Window( i_pParent, i_rId ),
|
|
|
|
mfScaleX( 1 ),
|
|
|
|
mfScaleY( 1 )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::PrintPreviewWindow::~PrintPreviewWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& i_rRect )
|
|
|
|
{
|
|
|
|
Window::Paint( i_rRect );
|
|
|
|
|
2009-04-24 09:43:48 +00:00
|
|
|
GDIMetaFile aMtf( maMtf );
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
SetFillColor( Color( COL_WHITE ) );
|
|
|
|
SetLineColor();
|
|
|
|
DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ));
|
|
|
|
Push();
|
|
|
|
SetMapMode( MAP_100TH_MM );
|
2009-04-24 09:43:48 +00:00
|
|
|
aMtf.WindStart();
|
|
|
|
aMtf.Scale( mfScaleX, mfScaleY );
|
|
|
|
aMtf.WindStart();
|
|
|
|
aMtf.Play( this, Point( 0, 0 ), PixelToLogic( GetSizePixel() ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview )
|
|
|
|
{
|
|
|
|
maMtf = i_rNewPreview;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2009-04-24 09:43:48 +00:00
|
|
|
void PrintDialog::PrintPreviewWindow::setScale( double fScaleX, double fScaleY )
|
|
|
|
{
|
|
|
|
mfScaleX = fScaleX;
|
|
|
|
mfScaleY = fScaleY;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rResId )
|
|
|
|
: TabPage( i_pParent, rResId )
|
|
|
|
, maPrinters( this, VclResId( SV_PRINT_PRINTERS) )
|
|
|
|
, maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) )
|
|
|
|
, maType( this, VclResId( SV_PRINT_PRT_TYPE ) )
|
|
|
|
, maTypeText( this, VclResId( SV_PRINT_PRT_TYPE_TXT ) )
|
|
|
|
, maStatus( this, VclResId( SV_PRINT_PRT_STATUS ) )
|
|
|
|
, maStatusText(this, VclResId( SV_PRINT_PRT_STATUS_TXT ) )
|
|
|
|
, maLocation( this, VclResId( SV_PRINT_PRT_LOCATION ) )
|
|
|
|
, maLocText( this, VclResId( SV_PRINT_PRT_LOCATION_TXT ) )
|
|
|
|
, maComment( this, VclResId( SV_PRINT_PRT_COMMENT ) )
|
|
|
|
, maCommentText( this, VclResId( SV_PRINT_PRT_COMMENT_TXT ) )
|
2009-03-28 08:52:14 +00:00
|
|
|
, maNupLine( this, VclResId( SV_PRINT_PRT_NUP ) )
|
|
|
|
, maNupRowsTxt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_TXT ) )
|
|
|
|
, maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) )
|
|
|
|
, maNupColTxt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_TXT ) )
|
|
|
|
, maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_EDT ) )
|
|
|
|
, maNupPortrait( this, VclResId( SV_PRINT_PRT_NUP_PORTRAIT ) )
|
|
|
|
, maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
2009-04-27 09:47:17 +00:00
|
|
|
maPrinters.SMHID2( "PrinterPage", "PrinterList" );
|
|
|
|
maSetupButton.SMHID2( "PrinterPage", "Setup" );
|
|
|
|
maType.SMHID2( "PrinterPage", "Type" );
|
|
|
|
maTypeText.SMHID2( "PrinterPage", "TypeText" );
|
|
|
|
maStatus.SMHID2( "PrinterPage", "Status" );
|
|
|
|
maStatusText.SMHID2( "PrinterPage", "StatusText" );
|
|
|
|
maLocation.SMHID2( "PrinterPage", "Locaction" );
|
|
|
|
maLocText.SMHID2( "PrinterPage", "LocactionText" );
|
|
|
|
maComment.SMHID2( "PrinterPage", "Comment" );
|
|
|
|
maCommentText.SMHID2( "PrinterPage", "CommentText" );
|
|
|
|
maNupLine.SMHID2( "PrinterPage", "NUPline" );
|
|
|
|
maNupRowsTxt.SMHID2( "PrinterPage", "NUPRowsText" );
|
|
|
|
maNupRowsEdt.SMHID2( "PrinterPage", "NUPRows" );
|
|
|
|
maNupColTxt.SMHID2( "PrinterPage", "NUPColumnsText" );
|
|
|
|
maNupColEdt.SMHID2( "PrinterPage", "NUPColumns" );
|
|
|
|
maNupPortrait.SMHID2( "PrinterPage", "NUPPortrait" );
|
|
|
|
maNupLandscape.SMHID2( "PrinterPage", "NUPLandscape" );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::PrinterTabPage::~PrinterTabPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId )
|
|
|
|
: TabPage( i_pParent, rResId )
|
2009-03-16 18:11:54 +00:00
|
|
|
, maPrinters( this, VclResId( SV_PRINT_PRINTERS) )
|
|
|
|
, maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, maCopies( this, VclResId( SV_PRINT_COPIES ) )
|
|
|
|
, maCopyCount( this, VclResId( SV_PRINT_COPYCOUNT ) )
|
|
|
|
, maCopyCountField( this, VclResId( SV_PRINT_COPYCOUNT_FIELD ) )
|
|
|
|
, maCollateBox( this, VclResId( SV_PRINT_COLLATE ) )
|
|
|
|
, maCollateImage( this, VclResId( SV_PRINT_COLLATE_IMAGE ) )
|
|
|
|
, maCollateImg( VclResId( SV_PRINT_COLLATE_IMG ) )
|
|
|
|
, maCollateHCImg( VclResId( SV_PRINT_COLLATE_HC_IMG ) )
|
|
|
|
, maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) )
|
|
|
|
, maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) )
|
|
|
|
{
|
|
|
|
FreeResource();
|
2009-04-27 09:47:17 +00:00
|
|
|
maPrinters.SMHID2( "JobPage", "PrinterList" );
|
|
|
|
maToFileBox.SMHID2( "JobPage", "ToFile" );
|
|
|
|
maCopies.SMHID2( "JobPage", "CopiesLine" );
|
|
|
|
maCopyCount.SMHID2( "JobPage", "CopiesText" );
|
|
|
|
maCopyCountField.SMHID2( "JobPage", "Copies" );
|
|
|
|
maCollateBox.SMHID2( "JobPage", "Collate" );
|
|
|
|
maCollateImage.SMHID2( "JobPage", "CollateImage" );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::JobTabPage::~JobTabPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterListener>& i_rListener )
|
|
|
|
: ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) )
|
|
|
|
, maOKButton( this, VclResId( SV_PRINT_OK ) )
|
|
|
|
, maCancelButton( this, VclResId( SV_PRINT_CANCEL ) )
|
|
|
|
, maPreviewWindow( this, VclResId( SV_PRINT_PAGE_PREVIEW ) )
|
|
|
|
, maPageText( this, VclResId( SV_PRINT_PAGE_TXT ) )
|
2009-05-22 07:04:13 +00:00
|
|
|
, maPageSlider( this, VclResId( SV_PRINT_PAGE_SCROLL ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, maTabCtrl( this, VclResId( SV_PRINT_TABCTRL ) )
|
|
|
|
, maPrinterPage( &maTabCtrl, VclResId( SV_PRINT_TAB_PRINTER ) )
|
|
|
|
, maJobPage( &maTabCtrl, VclResId( SV_PRINT_TAB_JOB ) )
|
|
|
|
, maButtonLine( this, VclResId( SV_PRINT_BUTTONLINE ) )
|
|
|
|
, maPListener( i_rListener )
|
2009-03-26 18:00:43 +00:00
|
|
|
, maNoPageStr( String( VclResId( SV_PRINT_NOPAGES ) ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, mnCurPage( 0 )
|
|
|
|
, mnCachedPages( 0 )
|
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
// insert the tab pages
|
|
|
|
maTabCtrl.InsertPage( SV_PRINT_TAB_JOB, maJobPage.GetText() );
|
|
|
|
maTabCtrl.SetTabPage( SV_PRINT_TAB_JOB, &maJobPage );
|
2009-03-16 18:11:54 +00:00
|
|
|
maTabCtrl.InsertPage( SV_PRINT_PAGE_PREVIEW, maPrinterPage.GetText() );
|
|
|
|
maTabCtrl.SetTabPage( SV_PRINT_PAGE_PREVIEW, &maPrinterPage );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
|
|
|
maPageStr = maPageText.GetText();
|
|
|
|
// save space for the preview window
|
|
|
|
maPreviewSpace = Rectangle( maPreviewWindow.GetPosPixel(), maPreviewWindow.GetSizePixel() );
|
|
|
|
// get the first page
|
|
|
|
preparePreview();
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
// set up the slider for the preview pages
|
|
|
|
maPageSlider.SetScrollHdl( LINK( this, PrintDialog, SlideHdl ) );
|
|
|
|
maPageSlider.SetEndScrollHdl( LINK( this, PrintDialog, EndSlideHdl ) );
|
|
|
|
maPageSlider.EnableDrag( TRUE );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
|
|
|
// fill printer listbox
|
|
|
|
const std::vector< rtl::OUString >& rQueues( Printer::GetPrinterQueues() );
|
|
|
|
for( std::vector< rtl::OUString >::const_iterator it = rQueues.begin();
|
|
|
|
it != rQueues.end(); ++it )
|
|
|
|
{
|
|
|
|
maPrinterPage.maPrinters.InsertEntry( *it );
|
2009-03-16 18:11:54 +00:00
|
|
|
maJobPage.maPrinters.InsertEntry( *it );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
// select current printer
|
|
|
|
if( maPrinterPage.maPrinters.GetEntryPos( maPListener->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND )
|
2009-03-16 18:11:54 +00:00
|
|
|
{
|
2008-10-01 18:22:22 +00:00
|
|
|
maPrinterPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() );
|
2009-03-16 18:11:54 +00:00
|
|
|
maJobPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() );
|
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// fall back to default printer
|
|
|
|
maPrinterPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() );
|
2009-03-16 18:11:54 +00:00
|
|
|
maJobPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() );
|
2008-10-01 18:22:22 +00:00
|
|
|
maPListener->setPrinter( boost::shared_ptr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) );
|
|
|
|
}
|
|
|
|
// update the text fields for the printer
|
|
|
|
updatePrinterText();
|
|
|
|
|
|
|
|
// set a select handler
|
|
|
|
maPrinterPage.maPrinters.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
|
2009-03-16 18:11:54 +00:00
|
|
|
maJobPage.maPrinters.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
2009-03-28 08:52:14 +00:00
|
|
|
// setup sizes for N-Up
|
|
|
|
Size aNupSize( maPListener->getPrinter()->PixelToLogic(
|
|
|
|
maPListener->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
|
|
|
|
if( maPListener->getPrinter()->GetOrientation() == ORIENTATION_LANDSCAPE )
|
|
|
|
{
|
|
|
|
maNupLandscapeSize = aNupSize;
|
|
|
|
maNupPortraitSize = Size( aNupSize.Height(), aNupSize.Width() );
|
|
|
|
maPrinterPage.maNupLandscape.Check();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maNupPortraitSize = aNupSize;
|
|
|
|
maNupLandscapeSize = Size( aNupSize.Height(), aNupSize.Width() );
|
|
|
|
maPrinterPage.maNupPortrait.Check();
|
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
// setup click handler on the various buttons
|
|
|
|
maJobPage.maCollateBox.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
|
|
|
maPrinterPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-03-28 08:52:14 +00:00
|
|
|
maPrinterPage.maNupPortrait.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
|
|
|
maPrinterPage.maNupLandscape.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
|
|
|
// setup modify hdl
|
|
|
|
maJobPage.maCopyCountField.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
2009-03-28 08:52:14 +00:00
|
|
|
maPrinterPage.maNupRowsEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
|
|
|
maPrinterPage.maNupColEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
// setup optional UI options set by application
|
|
|
|
setupOptionalUI();
|
|
|
|
|
|
|
|
// set change handler for UI options
|
|
|
|
maPListener->setOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) );
|
|
|
|
|
2009-03-17 12:27:26 +00:00
|
|
|
// set min size pixel to current size
|
|
|
|
SetMinOutputSizePixel( GetOutputSizePixel() );
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
// setup dependencies
|
|
|
|
checkControlDependencies();
|
2009-04-27 09:47:17 +00:00
|
|
|
|
|
|
|
// set HelpIDs
|
|
|
|
maOKButton.SMHID1( "OK" );
|
|
|
|
maCancelButton.SMHID1( "Cancel" );
|
|
|
|
maPreviewWindow.SMHID1( "Preview" );
|
|
|
|
maPageText.SMHID1( "PageText" );
|
2009-05-22 07:04:13 +00:00
|
|
|
maPageSlider.SMHID1( "PageSlider" );
|
2009-04-27 09:47:17 +00:00
|
|
|
maTabCtrl.SMHID1( "TabPages" );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::~PrintDialog()
|
|
|
|
{
|
2008-10-30 14:31:29 +00:00
|
|
|
while( ! maControls.empty() )
|
|
|
|
{
|
|
|
|
delete maControls.front();
|
|
|
|
maControls.pop_front();
|
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PrintDialog::isPrintToFile()
|
|
|
|
{
|
2009-03-16 18:11:54 +00:00
|
|
|
return maJobPage.maToFileBox.IsChecked();
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int PrintDialog::getCopyCount()
|
|
|
|
{
|
2008-11-06 15:54:09 +00:00
|
|
|
return static_cast<int>(maJobPage.maCopyCountField.GetValue());
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PrintDialog::isCollate()
|
|
|
|
{
|
|
|
|
return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : FALSE;
|
|
|
|
}
|
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId = -1, const rtl::OUString& i_rPropName = rtl::OUString() )
|
|
|
|
{
|
|
|
|
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() ) );
|
|
|
|
}
|
|
|
|
|
2009-04-27 16:11:03 +00:00
|
|
|
static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpTexts, sal_Int32 i_nIndex )
|
|
|
|
{
|
|
|
|
if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() )
|
|
|
|
i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] );
|
|
|
|
}
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
// FIXME: this is evil hackery and witchcraft
|
|
|
|
// the automatic controls should be replaced by some kind of row/column widget
|
2008-10-30 14:31:29 +00:00
|
|
|
void PrintDialog::setupOptionalUI()
|
|
|
|
{
|
2009-05-22 07:04:13 +00:00
|
|
|
Window* pCurParent = 0, *pDynamicPageParent = 0;
|
|
|
|
long nCurY = 0, nXPos = 5, nMaxY = 0, nJobPageCurY = 0, nDynamicPageCurY = 0;
|
|
|
|
USHORT nOptPageId = 9, nCurSubGroup = 0, nJobGroups = 0;
|
2008-10-30 14:31:29 +00:00
|
|
|
MapMode aFontMapMode( MAP_APPFONT );
|
2009-05-22 07:04:13 +00:00
|
|
|
bool bOnJobPage = false;
|
|
|
|
|
|
|
|
nJobPageCurY = maJobPage.PixelToLogic( maJobPage.maCollateImage.GetPosPixel(), aFontMapMode ).Y();
|
|
|
|
nJobPageCurY += maJobPage.PixelToLogic( maJobPage.maCollateImage.GetSizePixel(), aFontMapMode ).Height();
|
|
|
|
nJobPageCurY += 5;
|
2008-10-30 14:31:29 +00:00
|
|
|
|
2009-03-26 18:54:45 +00:00
|
|
|
Size aTabSize = maTabCtrl.GetTabPageSizePixel();
|
2008-10-30 14:31:29 +00:00
|
|
|
const Sequence< PropertyValue >& rOptions( maPListener->getUIOptions() );
|
|
|
|
for( int i = 0; i < rOptions.getLength(); i++ )
|
|
|
|
{
|
|
|
|
Sequence< beans::PropertyValue > aOptProp;
|
|
|
|
rOptions[i].Value >>= aOptProp;
|
|
|
|
|
|
|
|
// extract ui element
|
|
|
|
bool bEnabled = true;
|
|
|
|
rtl::OUString aCtrlType;
|
|
|
|
rtl::OUString aText;
|
|
|
|
rtl::OUString aPropertyName;
|
|
|
|
Sequence< rtl::OUString > aChoices;
|
2009-04-27 16:11:03 +00:00
|
|
|
Sequence< rtl::OUString > aHelpTexts;
|
2009-03-16 17:48:45 +00:00
|
|
|
sal_Int64 nMinValue = 0, nMaxValue = 0;
|
2009-03-26 19:13:43 +00:00
|
|
|
long nDependencyIndent = 0;
|
2009-04-27 16:11:03 +00:00
|
|
|
sal_Int32 nCurHelpText = 0;
|
2009-05-22 07:04:13 +00:00
|
|
|
sal_Bool bOnJobPageValue = sal_False;
|
2008-10-30 14:31:29 +00:00
|
|
|
|
|
|
|
for( int n = 0; n < aOptProp.getLength(); n++ )
|
|
|
|
{
|
|
|
|
const beans::PropertyValue& rEntry( aOptProp[ n ] );
|
|
|
|
if( rEntry.Name.equalsAscii( "Text" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= aText;
|
|
|
|
}
|
|
|
|
else if( rEntry.Name.equalsAscii( "ControlType" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= aCtrlType;
|
|
|
|
}
|
|
|
|
else if( rEntry.Name.equalsAscii( "Choices" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= aChoices;
|
|
|
|
}
|
|
|
|
else if( rEntry.Name.equalsAscii( "Property" ) )
|
|
|
|
{
|
|
|
|
PropertyValue aVal;
|
|
|
|
rEntry.Value >>= aVal;
|
|
|
|
aPropertyName = aVal.Name;
|
|
|
|
}
|
|
|
|
else if( rEntry.Name.equalsAscii( "Enabled" ) )
|
|
|
|
{
|
|
|
|
sal_Bool bValue = sal_True;
|
|
|
|
rEntry.Value >>= bValue;
|
|
|
|
bEnabled = bValue;
|
|
|
|
}
|
2009-05-22 07:04:13 +00:00
|
|
|
else if( rEntry.Name.equalsAscii( "PutOnJobPage" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= bOnJobPageValue;
|
|
|
|
}
|
2009-03-16 15:13:59 +00:00
|
|
|
else if( rEntry.Name.equalsAscii( "DependsOnName" ) )
|
|
|
|
{
|
2009-03-26 19:13:43 +00:00
|
|
|
rtl::OUString aDepName;
|
|
|
|
rEntry.Value >>= aDepName;
|
|
|
|
std::map< rtl::OUString, Window* >::iterator it( maPropertyToWindowMap.find( aDepName ) );
|
|
|
|
if( it != maPropertyToWindowMap.end() )
|
|
|
|
{
|
|
|
|
Window* pWin = it->second;
|
|
|
|
// still on the same page ?
|
|
|
|
if( pWin->GetParent() == pCurParent )
|
|
|
|
{
|
|
|
|
// is it a labeled window ?
|
|
|
|
if( dynamic_cast< ListBox* >(pWin) ||
|
|
|
|
dynamic_cast< NumericField* >(pWin) )
|
|
|
|
{
|
|
|
|
Window* pLabelWin = pWin->GetLabeledBy();
|
|
|
|
if( dynamic_cast<FixedText*>(pLabelWin) ) // sanity check
|
|
|
|
pWin = pLabelWin;
|
|
|
|
}
|
|
|
|
long nDependencyXPos = PixelToLogic( pWin->GetPosPixel(), aFontMapMode ).X();
|
|
|
|
if( (nDependencyXPos + 5) > nXPos )
|
|
|
|
nDependencyIndent = nDependencyXPos + 5 - nXPos;
|
|
|
|
}
|
|
|
|
}
|
2009-03-16 15:13:59 +00:00
|
|
|
}
|
2009-03-16 17:48:45 +00:00
|
|
|
else if( rEntry.Name.equalsAscii( "MinValue" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= nMinValue;
|
|
|
|
}
|
|
|
|
else if( rEntry.Name.equalsAscii( "MaxValue" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= nMaxValue;
|
|
|
|
}
|
2009-04-27 16:11:03 +00:00
|
|
|
else if( rEntry.Name.equalsAscii( "HelpText" ) )
|
|
|
|
{
|
|
|
|
if( ! (rEntry.Value >>= aHelpTexts) )
|
|
|
|
{
|
|
|
|
rtl::OUString aHelpText;
|
|
|
|
if( (rEntry.Value >>= aHelpText) )
|
|
|
|
{
|
|
|
|
aHelpTexts.realloc( 1 );
|
|
|
|
*aHelpTexts.getArray() = aHelpText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
2008-11-05 14:54:11 +00:00
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
if( aCtrlType.equalsAscii( "Group" ) ||
|
2008-11-05 15:52:15 +00:00
|
|
|
aCtrlType.equalsAscii( "Subgroup" ) ||
|
2008-10-30 14:31:29 +00:00
|
|
|
aCtrlType.equalsAscii( "Radio" ) ||
|
|
|
|
aCtrlType.equalsAscii( "List" ) ||
|
2009-03-16 17:48:45 +00:00
|
|
|
aCtrlType.equalsAscii( "Range" ) ||
|
2009-05-22 07:04:13 +00:00
|
|
|
aCtrlType.equalsAscii( "Edit" ) ||
|
2008-10-30 14:31:29 +00:00
|
|
|
aCtrlType.equalsAscii( "Bool" ) )
|
|
|
|
{
|
|
|
|
if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent )
|
|
|
|
{
|
2009-03-26 18:54:45 +00:00
|
|
|
if( nCurY > nMaxY )
|
|
|
|
nMaxY = nCurY;
|
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
// add new tab page
|
|
|
|
TabPage* pNewGroup = new TabPage( &maTabCtrl );
|
|
|
|
maControls.push_front( pNewGroup );
|
|
|
|
pCurParent = pNewGroup;
|
|
|
|
nCurY = 5;
|
2009-03-16 15:13:59 +00:00
|
|
|
nXPos = 5;
|
2008-10-30 14:31:29 +00:00
|
|
|
pNewGroup->SetText( aText );
|
|
|
|
maTabCtrl.InsertPage( ++nOptPageId, aText );
|
|
|
|
maTabCtrl.SetTabPage( nOptPageId, pNewGroup );
|
2009-04-27 09:47:17 +00:00
|
|
|
|
|
|
|
// set help id
|
|
|
|
setSmartId( pNewGroup, "TabPage", nOptPageId );
|
2009-04-27 16:11:03 +00:00
|
|
|
// set help text
|
|
|
|
setHelpText( pNewGroup, aHelpTexts, 0 );
|
2009-04-27 09:47:17 +00:00
|
|
|
|
|
|
|
// reset subgroup counter
|
|
|
|
nCurSubGroup = 0;
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
|
2008-11-05 15:52:15 +00:00
|
|
|
if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent )
|
|
|
|
{
|
2009-03-16 15:13:59 +00:00
|
|
|
nXPos = 5;
|
2009-05-22 07:04:13 +00:00
|
|
|
// change to job page or back if necessary
|
|
|
|
if( (bOnJobPage && ! bOnJobPageValue) ||
|
|
|
|
(! bOnJobPage && bOnJobPageValue) )
|
|
|
|
{
|
|
|
|
if( nCurY > nMaxY ) // keep track of maximum Y
|
|
|
|
nMaxY = nCurY;
|
|
|
|
bOnJobPage = bOnJobPageValue;
|
|
|
|
if( bOnJobPage )
|
|
|
|
{
|
|
|
|
nDynamicPageCurY = nCurY; // save nCurY
|
|
|
|
pDynamicPageParent = pCurParent; // save current parent
|
|
|
|
pCurParent = &maJobPage; // set job page as current parent
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nCurY = nDynamicPageCurY; // set dynamic CurY
|
|
|
|
pCurParent = pDynamicPageParent; // set current tab page as parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( bOnJobPage )
|
|
|
|
{
|
|
|
|
nXPos += 100 * nJobGroups++;
|
|
|
|
nCurY = nJobPageCurY;
|
|
|
|
}
|
2008-11-05 15:52:15 +00:00
|
|
|
FixedLine* pNewSub = new FixedLine( pCurParent );
|
|
|
|
maControls.push_front( pNewSub );
|
|
|
|
pNewSub->SetText( aText );
|
|
|
|
nCurY += 4;
|
|
|
|
Size aPixelSize( aTabSize );
|
2009-05-22 07:04:13 +00:00
|
|
|
aPixelSize.Width() /= 3;
|
2008-11-05 15:52:15 +00:00
|
|
|
aPixelSize.Height() = pCurParent->GetTextHeight() + 4;
|
2009-03-16 15:13:59 +00:00
|
|
|
pNewSub->SetPosSizePixel( pNewSub->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ),
|
2008-11-05 15:52:15 +00:00
|
|
|
aPixelSize );
|
|
|
|
pNewSub->Show();
|
|
|
|
nCurY += 12;
|
2009-03-16 15:13:59 +00:00
|
|
|
nXPos += 5;
|
2009-04-27 09:47:17 +00:00
|
|
|
|
|
|
|
// set help id
|
|
|
|
setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) );
|
2009-04-27 16:11:03 +00:00
|
|
|
// set help text
|
|
|
|
setHelpText( pNewSub, aHelpTexts, 0 );
|
2008-11-05 15:52:15 +00:00
|
|
|
}
|
|
|
|
else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent )
|
2008-10-30 14:31:29 +00:00
|
|
|
{
|
|
|
|
// add a check box
|
|
|
|
CheckBox* pNewBox = new CheckBox( pCurParent );
|
|
|
|
maControls.push_front( pNewBox );
|
|
|
|
pNewBox->SetText( aText );
|
|
|
|
|
|
|
|
// FIXME: measure text
|
2009-03-26 19:13:43 +00:00
|
|
|
pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ),
|
2008-10-30 14:31:29 +00:00
|
|
|
pNewBox->LogicToPixel( Size( 100, 10 ), aFontMapMode ) );
|
2008-11-05 15:52:15 +00:00
|
|
|
nCurY += 12;
|
2008-10-30 14:31:29 +00:00
|
|
|
|
|
|
|
pNewBox->Show();
|
|
|
|
sal_Bool bVal = sal_False;
|
|
|
|
PropertyValue* pVal = maPListener->getValue( aPropertyName );
|
|
|
|
if( pVal )
|
|
|
|
pVal->Value >>= bVal;
|
|
|
|
pNewBox->Check( bVal );
|
|
|
|
pNewBox->Enable( maPListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL );
|
2009-03-16 12:27:57 +00:00
|
|
|
pNewBox->SetToggleHdl( LINK( this, PrintDialog, UIOption_CheckHdl ) );
|
2008-10-30 14:31:29 +00:00
|
|
|
|
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) );
|
2009-03-16 12:27:57 +00:00
|
|
|
maControlToPropertyMap[pNewBox] = aPropertyName;
|
2009-03-16 15:13:59 +00:00
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pNewBox, "CheckBox", -1, aPropertyName );
|
2009-04-27 16:11:03 +00:00
|
|
|
// set help text
|
|
|
|
setHelpText( pNewBox, aHelpTexts, 0 );
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent )
|
|
|
|
{
|
2009-03-16 15:13:59 +00:00
|
|
|
long nOldXPos = nXPos;
|
2008-10-30 14:31:29 +00:00
|
|
|
if( aText.getLength() )
|
|
|
|
{
|
|
|
|
// add a FixedText:
|
|
|
|
FixedText* pHeading = new FixedText( pCurParent );
|
|
|
|
maControls.push_front( pHeading );
|
|
|
|
pHeading->SetText( aText );
|
|
|
|
Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) );
|
2009-05-22 07:04:13 +00:00
|
|
|
if( bOnJobPage )
|
|
|
|
aPixelSize.Width() = maJobPage.LogicToPixel( Size( 90, 10 ), aFontMapMode ).Width();
|
|
|
|
else
|
|
|
|
aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width();
|
2009-03-26 19:13:43 +00:00
|
|
|
pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ),
|
2008-10-30 14:31:29 +00:00
|
|
|
aPixelSize );
|
|
|
|
pHeading->Show();
|
|
|
|
|
2009-03-16 15:13:59 +00:00
|
|
|
nXPos += 10;
|
2008-10-30 14:31:29 +00:00
|
|
|
nCurY += 12;
|
2009-04-27 09:47:17 +00:00
|
|
|
|
|
|
|
// set help id
|
|
|
|
setSmartId( pHeading, "FixedText", -1, aPropertyName );
|
2009-04-27 16:11:03 +00:00
|
|
|
// set help text
|
|
|
|
setHelpText( pHeading, aHelpTexts, nCurHelpText++ );
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// iterate options
|
2009-03-16 13:18:23 +00:00
|
|
|
sal_Int32 nSelectVal = 0;
|
2008-10-30 14:31:29 +00:00
|
|
|
PropertyValue* pVal = maPListener->getValue( aPropertyName );
|
2008-11-05 14:54:11 +00:00
|
|
|
if( pVal && pVal->Value.hasValue() )
|
2009-03-16 13:18:23 +00:00
|
|
|
pVal->Value >>= nSelectVal;
|
2008-10-30 14:31:29 +00:00
|
|
|
for( sal_Int32 m = 0; m < aChoices.getLength(); m++ )
|
|
|
|
{
|
|
|
|
RadioButton* pBtn = new RadioButton( pCurParent, m == 0 ? WB_GROUP : 0 );
|
|
|
|
maControls.push_front( pBtn );
|
|
|
|
pBtn->SetText( aChoices[m] );
|
2009-03-16 13:18:23 +00:00
|
|
|
pBtn->Check( m == nSelectVal );
|
2009-03-26 19:13:43 +00:00
|
|
|
Size aPixelSize( pBtn->LogicToPixel( Size( 10 + nXPos + nDependencyIndent, 12 ), aFontMapMode ) );
|
2009-05-22 07:04:13 +00:00
|
|
|
if( bOnJobPage )
|
|
|
|
aPixelSize.Width() = maJobPage.LogicToPixel( Size( 80, 10 ), aFontMapMode ).Width();
|
|
|
|
else
|
|
|
|
aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width();
|
|
|
|
pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ),
|
2008-10-30 14:31:29 +00:00
|
|
|
aPixelSize );
|
|
|
|
pBtn->Enable( maPListener->isUIOptionEnabled( aPropertyName ) );
|
2009-03-16 12:27:57 +00:00
|
|
|
pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) );
|
2008-10-30 14:31:29 +00:00
|
|
|
pBtn->Show();
|
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pBtn ) );
|
2009-03-16 12:27:57 +00:00
|
|
|
maControlToPropertyMap[pBtn] = aPropertyName;
|
2009-03-16 13:18:23 +00:00
|
|
|
maControlToNumValMap[pBtn] = m;
|
2009-03-16 12:27:57 +00:00
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pBtn, "RadioButton", m, aPropertyName );
|
2009-04-27 16:11:03 +00:00
|
|
|
// set help text
|
|
|
|
setHelpText( pBtn, aHelpTexts, nCurHelpText++ );
|
2009-04-27 09:47:17 +00:00
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
nCurY += 12;
|
|
|
|
}
|
2009-05-22 07:04:13 +00:00
|
|
|
nCurY += 2;
|
2009-03-16 15:13:59 +00:00
|
|
|
nXPos = nOldXPos;
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
2008-11-05 14:54:11 +00:00
|
|
|
else if( aCtrlType.equalsAscii( "List" ) && pCurParent )
|
2008-10-30 14:31:29 +00:00
|
|
|
{
|
|
|
|
// add a FixedText:
|
|
|
|
FixedText* pHeading = new FixedText( pCurParent );
|
|
|
|
maControls.push_front( pHeading );
|
|
|
|
pHeading->SetText( aText );
|
|
|
|
Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) );
|
2008-11-05 14:54:11 +00:00
|
|
|
aPixelSize.Width() += pHeading->GetTextWidth( aText );
|
2009-03-26 19:13:43 +00:00
|
|
|
pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ),
|
2008-10-30 14:31:29 +00:00
|
|
|
aPixelSize );
|
|
|
|
pHeading->Show();
|
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pHeading, "FixedText", -1, aPropertyName );
|
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER );
|
|
|
|
maControls.push_front( pList );
|
|
|
|
|
|
|
|
// iterate options
|
2008-11-05 14:54:11 +00:00
|
|
|
long nMaxTextWidth = 0;
|
2008-10-30 14:31:29 +00:00
|
|
|
for( sal_Int32 m = 0; m < aChoices.getLength(); m++ )
|
|
|
|
{
|
|
|
|
pList->InsertEntry( aChoices[m] );
|
2008-11-05 14:54:11 +00:00
|
|
|
long nEntryWidth = pList->GetTextWidth( aChoices[m] );
|
|
|
|
if( nEntryWidth > nMaxTextWidth )
|
|
|
|
nMaxTextWidth = nEntryWidth;
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
2009-03-26 18:54:45 +00:00
|
|
|
nMaxTextWidth += 50;
|
2009-03-16 13:18:23 +00:00
|
|
|
sal_Int32 nSelectVal = 0;
|
2008-10-30 14:31:29 +00:00
|
|
|
PropertyValue* pVal = maPListener->getValue( aPropertyName );
|
2008-11-05 14:54:11 +00:00
|
|
|
if( pVal && pVal->Value.hasValue() )
|
2009-03-16 13:18:23 +00:00
|
|
|
pVal->Value >>= nSelectVal;
|
2009-03-16 13:51:45 +00:00
|
|
|
pList->SelectEntryPos( static_cast<USHORT>(nSelectVal) );
|
2008-11-05 14:54:11 +00:00
|
|
|
|
2008-11-05 15:52:15 +00:00
|
|
|
aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) );
|
|
|
|
aPixelSize.Width() = nMaxTextWidth;
|
|
|
|
aPixelSize.Height() *= aChoices.getLength() > 15 ? 15 : aChoices.getLength();
|
|
|
|
|
2008-11-05 14:54:11 +00:00
|
|
|
Point aListPos;
|
2008-11-05 15:52:15 +00:00
|
|
|
bool bDoAlign = false;
|
2008-11-05 14:54:11 +00:00
|
|
|
if( nMaxTextWidth + aPixelSize.Width() < aTabSize.Width() - 10 )
|
|
|
|
{
|
|
|
|
aListPos = pHeading->GetPosPixel();
|
|
|
|
aListPos.X() += pHeading->GetSizePixel().Width() + 5;
|
2008-11-05 15:52:15 +00:00
|
|
|
|
|
|
|
// align heading and list box
|
|
|
|
bDoAlign = true;
|
2008-11-05 14:54:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nCurY += 12;
|
2009-03-26 19:13:43 +00:00
|
|
|
aListPos = pCurParent->LogicToPixel( Point( 15 + nDependencyIndent, nCurY ), aFontMapMode );
|
2008-11-05 14:54:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pList->SetPosSizePixel( aListPos, aPixelSize );
|
|
|
|
pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) );
|
2009-03-16 12:27:57 +00:00
|
|
|
pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) );
|
2008-11-05 14:54:11 +00:00
|
|
|
pList->Show();
|
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pList, "ListBox", -1, aPropertyName );
|
2009-04-27 16:11:03 +00:00
|
|
|
// set help text
|
|
|
|
setHelpText( pList, aHelpTexts, 0 );
|
2009-04-27 09:47:17 +00:00
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) );
|
2009-03-16 12:27:57 +00:00
|
|
|
maControlToPropertyMap[pList] = aPropertyName;
|
2008-11-05 15:52:15 +00:00
|
|
|
nCurY += 16;
|
|
|
|
|
|
|
|
if( bDoAlign )
|
|
|
|
{
|
|
|
|
Point aPos = pHeading->GetPosPixel();
|
|
|
|
Size aSize = pHeading->GetSizePixel();
|
|
|
|
aPos.Y() += (pList->GetSizePixel().Height() - aSize.Height())/2;
|
|
|
|
pHeading->SetPosSizePixel( aPos, aSize );
|
|
|
|
}
|
2009-03-16 17:48:45 +00:00
|
|
|
}
|
|
|
|
else if( aCtrlType.equalsAscii( "Range" ) && pCurParent )
|
|
|
|
{
|
|
|
|
// add a FixedText:
|
|
|
|
FixedText* pHeading = new FixedText( pCurParent );
|
|
|
|
maControls.push_front( pHeading );
|
|
|
|
pHeading->SetText( aText );
|
|
|
|
Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) );
|
|
|
|
aPixelSize.Width() += pHeading->GetTextWidth( aText );
|
2009-03-26 19:13:43 +00:00
|
|
|
pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ),
|
2009-03-16 17:48:45 +00:00
|
|
|
aPixelSize );
|
|
|
|
pHeading->Show();
|
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pHeading, "FixedText", -1, aPropertyName );
|
|
|
|
|
2009-03-16 17:48:45 +00:00
|
|
|
NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN );
|
|
|
|
maControls.push_front( pField );
|
|
|
|
|
|
|
|
// set min/max and current value
|
|
|
|
if( nMinValue != nMaxValue )
|
|
|
|
{
|
|
|
|
pField->SetMin( nMinValue );
|
|
|
|
pField->SetMax( nMaxValue );
|
|
|
|
}
|
|
|
|
sal_Int64 nCurVal = 0;
|
|
|
|
PropertyValue* pVal = maPListener->getValue( aPropertyName );
|
|
|
|
if( pVal && pVal->Value.hasValue() )
|
|
|
|
pVal->Value >>= nCurVal;
|
|
|
|
pField->SetValue( nCurVal );
|
|
|
|
|
|
|
|
aPixelSize = Size( pField->LogicToPixel( Size( 80, 12 ), aFontMapMode ) );
|
|
|
|
|
|
|
|
Point aFieldPos;
|
|
|
|
bool bDoAlign = false;
|
|
|
|
if( aPixelSize.Width() < aTabSize.Width() - 10 )
|
|
|
|
{
|
|
|
|
aFieldPos = pHeading->GetPosPixel();
|
|
|
|
aFieldPos.X() += pHeading->GetSizePixel().Width() + 5;
|
|
|
|
|
|
|
|
// align heading and list box
|
|
|
|
bDoAlign = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nCurY += 12;
|
2009-03-26 19:13:43 +00:00
|
|
|
aFieldPos = pCurParent->LogicToPixel( Point( 15 + nDependencyIndent, nCurY ), aFontMapMode );
|
2009-03-16 17:48:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pField->SetPosSizePixel( aFieldPos, aPixelSize );
|
|
|
|
pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) );
|
|
|
|
pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) );
|
|
|
|
pField->Show();
|
|
|
|
|
2009-04-27 09:47:17 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pField, "NumericField", -1, aPropertyName );
|
2009-04-27 16:11:03 +00:00
|
|
|
// set help text
|
|
|
|
setHelpText( pField, aHelpTexts, 0 );
|
2009-04-27 09:47:17 +00:00
|
|
|
|
2009-03-16 17:48:45 +00:00
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) );
|
|
|
|
maControlToPropertyMap[pField] = aPropertyName;
|
|
|
|
nCurY += 16;
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
if( bDoAlign )
|
|
|
|
{
|
|
|
|
Point aPos = pHeading->GetPosPixel();
|
|
|
|
Size aSize = pHeading->GetSizePixel();
|
|
|
|
aPos.Y() += (pField->GetSizePixel().Height() - aSize.Height())/2;
|
|
|
|
pHeading->SetPosSizePixel( aPos, aSize );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aCtrlType.equalsAscii( "Edit" ) && pCurParent )
|
|
|
|
{
|
|
|
|
FixedText* pHeading = NULL;
|
|
|
|
Size aPixelSize;
|
|
|
|
if( aText.getLength() )
|
|
|
|
{
|
|
|
|
// add a FixedText:
|
|
|
|
pHeading = new FixedText( pCurParent );
|
|
|
|
maControls.push_front( pHeading );
|
|
|
|
pHeading->SetText( aText );
|
|
|
|
aPixelSize = pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode );
|
|
|
|
aPixelSize.Width() += pHeading->GetTextWidth( aText );
|
|
|
|
pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ),
|
|
|
|
aPixelSize );
|
|
|
|
pHeading->Show();
|
|
|
|
|
|
|
|
// set help id
|
|
|
|
setSmartId( pHeading, "FixedText", -1, aPropertyName );
|
|
|
|
}
|
|
|
|
|
|
|
|
Edit* pField = new Edit( pCurParent, WB_BORDER );
|
|
|
|
maControls.push_front( pField );
|
|
|
|
|
|
|
|
rtl::OUString aCurVal;
|
|
|
|
PropertyValue* pVal = maPListener->getValue( aPropertyName );
|
|
|
|
if( pVal && pVal->Value.hasValue() )
|
|
|
|
pVal->Value >>= aCurVal;
|
|
|
|
pField->SetText( aCurVal );
|
|
|
|
|
|
|
|
aPixelSize = Size( pField->LogicToPixel( Size( 80, 12 ), aFontMapMode ) );
|
|
|
|
|
|
|
|
Point aFieldPos;
|
|
|
|
bool bDoAlign = false;
|
|
|
|
if( pHeading && aPixelSize.Width() < aTabSize.Width() - 10 )
|
|
|
|
{
|
|
|
|
aFieldPos = pHeading->GetPosPixel();
|
|
|
|
aFieldPos.X() += pHeading->GetSizePixel().Width() + 5;
|
|
|
|
|
|
|
|
// align heading and list box
|
|
|
|
bDoAlign = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( pHeading )
|
|
|
|
nCurY += 12;
|
|
|
|
aFieldPos = pCurParent->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
pField->SetPosSizePixel( aFieldPos, aPixelSize );
|
|
|
|
pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) );
|
|
|
|
pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) );
|
|
|
|
pField->Show();
|
|
|
|
|
|
|
|
// set help id
|
|
|
|
setSmartId( pField, "Edit", -1, aPropertyName );
|
|
|
|
// set help text
|
|
|
|
setHelpText( pField, aHelpTexts, 0 );
|
|
|
|
|
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) );
|
|
|
|
maControlToPropertyMap[pField] = aPropertyName;
|
|
|
|
nCurY += 16;
|
|
|
|
|
2009-03-16 17:48:45 +00:00
|
|
|
if( bDoAlign )
|
|
|
|
{
|
|
|
|
Point aPos = pHeading->GetPosPixel();
|
|
|
|
Size aSize = pHeading->GetSizePixel();
|
|
|
|
aPos.Y() += (pField->GetSizePixel().Height() - aSize.Height())/2;
|
|
|
|
pHeading->SetPosSizePixel( aPos, aSize );
|
|
|
|
}
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "Unsupported UI option" );
|
|
|
|
}
|
|
|
|
}
|
2009-03-26 18:54:45 +00:00
|
|
|
|
|
|
|
if( nCurY > nMaxY )
|
|
|
|
nMaxY = nCurY;
|
|
|
|
|
|
|
|
// resize dialog if necessary
|
|
|
|
Size aMaxSize( LogicToPixel( Size( nMaxY, nMaxY ), aFontMapMode ) );
|
|
|
|
if( aMaxSize.Height() > aTabSize.Height() )
|
|
|
|
{
|
|
|
|
Size aCurSize( GetSizePixel() );
|
|
|
|
aCurSize.Height() += aMaxSize.Height() - aTabSize.Height();
|
|
|
|
SetSizePixel( aCurSize );
|
|
|
|
}
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
void PrintDialog::checkControlDependencies()
|
|
|
|
{
|
|
|
|
if( maJobPage.maCopyCountField.GetValue() > 1 )
|
|
|
|
maJobPage.maCollateBox.Enable( TRUE );
|
|
|
|
else
|
|
|
|
maJobPage.maCollateBox.Enable( FALSE );
|
|
|
|
|
|
|
|
Image aImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateImg : maJobPage.maNoCollateImg );
|
|
|
|
if( GetSettings().GetStyleSettings().GetFieldColor().IsDark() )
|
|
|
|
aImg = maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateHCImg : maJobPage.maNoCollateHCImg;
|
|
|
|
|
|
|
|
// adjust position and size of image
|
|
|
|
maJobPage.maCollateImage.SetSizePixel( aImg.GetSizePixel() );
|
|
|
|
Point aPos( maJobPage.maCollateImage.GetPosPixel() );
|
|
|
|
aPos.Y() = maJobPage.maCollateBox.GetPosPixel().Y();
|
|
|
|
aPos.Y() -= (aImg.GetSizePixel().Height() - maJobPage.maCollateBox.GetSizePixel().Height())/2;
|
|
|
|
maJobPage.maCollateImage.SetPosPixel( aPos );
|
|
|
|
maJobPage.maCollateImage.SetImage( aImg );
|
|
|
|
|
|
|
|
// enable setup button only for printers that can be setup
|
|
|
|
maPrinterPage.maSetupButton.Enable( maPListener->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ) );
|
|
|
|
}
|
|
|
|
|
2009-03-16 15:13:59 +00:00
|
|
|
void PrintDialog::checkOptionalControlDependencies()
|
|
|
|
{
|
|
|
|
for( std::map< Window*, rtl::OUString >::iterator it = maControlToPropertyMap.begin();
|
|
|
|
it != maControlToPropertyMap.end(); ++it )
|
|
|
|
{
|
|
|
|
bool bShouldbeEnabled = maPListener->isUIOptionEnabled( 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 )
|
|
|
|
it->first->Enable( bShouldbeEnabled );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
void PrintDialog::updatePrinterText()
|
|
|
|
{
|
|
|
|
const QueueInfo* pInfo = Printer::GetQueueInfo( maPrinterPage.maPrinters.GetSelectEntry(), true );
|
|
|
|
if( pInfo )
|
|
|
|
{
|
|
|
|
maPrinterPage.maTypeText.SetText( pInfo->GetDriver() );
|
|
|
|
// FIXME: status message
|
|
|
|
// maJobPage.maStatusText.SetText();
|
|
|
|
maPrinterPage.maLocText.SetText( pInfo->GetLocation() );
|
|
|
|
maPrinterPage.maCommentText.SetText( pInfo->GetComment() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* i_pRepl, sal_Int32 i_nReplLen, sal_Int32 i_nReplacement )
|
|
|
|
{
|
|
|
|
sal_Int32 nPos = i_rOrig.indexOfAsciiL( i_pRepl, i_nReplLen );
|
|
|
|
if( nPos != -1 )
|
|
|
|
{
|
|
|
|
rtl::OUStringBuffer aBuf( i_rOrig.getLength() );
|
|
|
|
aBuf.append( i_rOrig.getStr(), nPos );
|
|
|
|
aBuf.append( i_nReplacement );
|
|
|
|
if( nPos + i_nReplLen < i_rOrig.getLength() )
|
|
|
|
aBuf.append( i_rOrig.getStr() + nPos + i_nReplLen );
|
|
|
|
return aBuf.makeStringAndClear();
|
|
|
|
}
|
|
|
|
return i_rOrig;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::setPreviewText( sal_Int32 nSetPage )
|
|
|
|
{
|
2009-03-26 18:00:43 +00:00
|
|
|
if( mnCachedPages != 0 )
|
|
|
|
{
|
|
|
|
rtl::OUString aNewText( searchAndReplace( maPageStr, "%p", 2, nSetPage+1 ) );
|
|
|
|
aNewText = searchAndReplace( aNewText, "%n", 2, mnCachedPages );
|
|
|
|
maPageText.SetText( aNewText );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
maPageText.SetText( maNoPageStr );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
2009-04-24 09:43:48 +00:00
|
|
|
void PrintDialog::preparePreview( bool i_bNewPage )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2008-11-05 14:54:11 +00:00
|
|
|
// page range may have changed depending on options
|
2009-03-27 23:46:53 +00:00
|
|
|
sal_Int32 nPages = maPListener->getFilteredPageCount();
|
2008-10-01 18:22:22 +00:00
|
|
|
mnCachedPages = nPages;
|
|
|
|
|
2008-11-05 14:54:11 +00:00
|
|
|
if( mnCurPage >= nPages )
|
|
|
|
mnCurPage = nPages-1;
|
2009-03-26 18:00:43 +00:00
|
|
|
if( mnCurPage < 0 )
|
|
|
|
mnCurPage = 0;
|
2008-11-05 14:54:11 +00:00
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
setPreviewText( mnCurPage );
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
maPageSlider.SetRange( Range( 0, nPages-1 ) );
|
|
|
|
maPageSlider.SetThumbPos( mnCurPage );
|
|
|
|
maPageSlider.SetVisibleSize( 1 );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
|
|
|
boost::shared_ptr<Printer> aPrt( maPListener->getPrinter() );
|
|
|
|
|
|
|
|
|
2009-04-24 09:43:48 +00:00
|
|
|
if( i_bNewPage )
|
|
|
|
{
|
|
|
|
const MapMode aMapMode( MAP_100TH_MM );
|
|
|
|
GDIMetaFile aMtf;
|
2009-05-05 17:16:25 +00:00
|
|
|
if( nPages > 0 )
|
|
|
|
maCurPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf );
|
2009-04-24 09:43:48 +00:00
|
|
|
|
|
|
|
maPreviewWindow.setPreview( aMtf );
|
|
|
|
}
|
2009-05-05 17:16:25 +00:00
|
|
|
// catch corner case of strange page size
|
|
|
|
if( maCurPageSize.Width() == 0 || maCurPageSize.Height() == 0 )
|
|
|
|
maCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
|
|
|
Size aPreviewSize;
|
|
|
|
Point aPreviewPos = maPreviewSpace.TopLeft();
|
|
|
|
const long nW = maPreviewSpace.GetSize().Width();
|
|
|
|
const long nH = maPreviewSpace.GetSize().Height();
|
2009-04-24 09:43:48 +00:00
|
|
|
if( maCurPageSize.Width() > maCurPageSize.Height() )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-04-24 09:43:48 +00:00
|
|
|
aPreviewSize = Size( nW, nW * maCurPageSize.Height() / maCurPageSize.Width() );
|
2008-10-01 18:22:22 +00:00
|
|
|
aPreviewPos.Y() += (maPreviewSpace.GetHeight() - aPreviewSize.Height())/2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-24 09:43:48 +00:00
|
|
|
aPreviewSize = Size( nH * maCurPageSize.Width() / maCurPageSize.Height(), nH );
|
2008-10-01 18:22:22 +00:00
|
|
|
aPreviewPos.X() += (maPreviewSpace.GetWidth() - aPreviewSize.Width())/2;
|
|
|
|
}
|
2009-04-24 09:43:48 +00:00
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
maPreviewWindow.SetPosSizePixel( aPreviewPos, aPreviewSize );
|
|
|
|
const Size aLogicSize( maPreviewWindow.PixelToLogic( maPreviewWindow.GetSizePixel(), MapMode( MAP_100TH_MM ) ) );
|
2009-04-24 09:43:48 +00:00
|
|
|
maPreviewWindow.setScale( double(aLogicSize.Width())/double(maCurPageSize.Width()),
|
|
|
|
double(aLogicSize.Height())/double(maCurPageSize.Height()) );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
2009-03-28 08:52:14 +00:00
|
|
|
void PrintDialog::updateNup()
|
|
|
|
{
|
2009-04-22 08:23:48 +00:00
|
|
|
int nRows = int(maPrinterPage.maNupRowsEdt.GetValue());
|
|
|
|
int nCols = int(maPrinterPage.maNupColEdt.GetValue());
|
2009-03-28 08:52:14 +00:00
|
|
|
|
|
|
|
maPListener->setMultipage( nRows, nCols,
|
|
|
|
maPrinterPage.maNupPortrait.IsChecked()
|
|
|
|
? maNupPortraitSize : maNupLandscapeSize );
|
|
|
|
|
|
|
|
preparePreview();
|
|
|
|
}
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
IMPL_LINK( PrintDialog, SlideHdl, ScrollBar*, pSlider )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-05-22 07:04:13 +00:00
|
|
|
if( pSlider == &maPageSlider )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-05-22 07:04:13 +00:00
|
|
|
sal_Int32 nNewPage = static_cast<sal_Int32>( maPageSlider.GetThumbPos() );
|
2008-10-01 18:22:22 +00:00
|
|
|
setPreviewText( nNewPage );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
IMPL_LINK( PrintDialog, EndSlideHdl, ScrollBar*, pSlider )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-05-22 07:04:13 +00:00
|
|
|
if( pSlider == &maPageSlider )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-05-22 07:04:13 +00:00
|
|
|
sal_Int32 nNewPage = static_cast<sal_Int32>( maPageSlider.GetThumbPos() );
|
2008-10-01 18:22:22 +00:00
|
|
|
if( nNewPage != mnCurPage )
|
|
|
|
{
|
|
|
|
mnCurPage = nNewPage;
|
|
|
|
preparePreview();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox )
|
|
|
|
{
|
2009-03-16 18:11:54 +00:00
|
|
|
if( pBox == &maPrinterPage.maPrinters || pBox == &maJobPage.maPrinters )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-03-16 18:11:54 +00:00
|
|
|
String aNewPrinter( pBox->GetSelectEntry() );
|
|
|
|
maJobPage.maPrinters.SelectEntry( aNewPrinter );
|
|
|
|
maPrinterPage.maPrinters.SelectEntry( aNewPrinter );
|
2008-10-01 18:22:22 +00:00
|
|
|
// set new printer
|
2009-03-16 18:11:54 +00:00
|
|
|
maPListener->setPrinter( boost::shared_ptr<Printer>( new Printer( aNewPrinter ) ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
// update text fields
|
|
|
|
updatePrinterText();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton )
|
|
|
|
{
|
|
|
|
if( pButton == &maPrinterPage.maSetupButton )
|
|
|
|
{
|
|
|
|
maPListener->getPrinter()->Setup( this );
|
|
|
|
}
|
|
|
|
checkControlDependencies();
|
2009-03-28 08:52:14 +00:00
|
|
|
if( pButton == &maPrinterPage.maNupPortrait || pButton == &maPrinterPage.maNupLandscape )
|
|
|
|
updateNup();
|
2008-10-01 18:22:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-26 18:00:43 +00:00
|
|
|
IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
checkControlDependencies();
|
2009-05-22 07:04:13 +00:00
|
|
|
if( pEdit == &maPrinterPage.maNupRowsEdt || pEdit == &maPrinterPage.maNupColEdt )
|
2009-03-28 08:52:14 +00:00
|
|
|
{
|
|
|
|
updateNup();
|
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-18 14:52:24 +00:00
|
|
|
IMPL_LINK( PrintDialog, UIOptionsChanged, void*, EMPTYARG )
|
2008-10-30 14:31:29 +00:00
|
|
|
{
|
2009-03-16 15:13:59 +00:00
|
|
|
checkOptionalControlDependencies();
|
2008-10-30 14:31:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-05 14:54:11 +00:00
|
|
|
PropertyValue* PrintDialog::getValueForWindow( Window* i_pWindow ) const
|
|
|
|
{
|
|
|
|
PropertyValue* pVal = NULL;
|
|
|
|
std::map< Window*, rtl::OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow );
|
|
|
|
if( it != maControlToPropertyMap.end() )
|
|
|
|
{
|
|
|
|
pVal = maPListener->getValue( it->second );
|
|
|
|
DBG_ASSERT( pVal, "property value not found" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "changed control not in property map" );
|
|
|
|
}
|
|
|
|
return pVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox*, i_pBox )
|
|
|
|
{
|
|
|
|
PropertyValue* pVal = getValueForWindow( i_pBox );
|
|
|
|
if( pVal )
|
|
|
|
{
|
|
|
|
sal_Bool bVal = i_pBox->IsChecked();
|
|
|
|
pVal->Value <<= bVal;
|
|
|
|
|
2009-03-16 15:13:59 +00:00
|
|
|
checkOptionalControlDependencies();
|
|
|
|
|
2008-11-05 14:54:11 +00:00
|
|
|
// update preview and page settings
|
|
|
|
preparePreview();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn )
|
|
|
|
{
|
2009-03-16 15:22:03 +00:00
|
|
|
// this handler gets called for all radiobuttons that get unchecked, too
|
|
|
|
// however we only want one notificaction for the new value (that is for
|
|
|
|
// the button that gets checked)
|
|
|
|
if( i_pBtn->IsChecked() )
|
2008-11-05 14:54:11 +00:00
|
|
|
{
|
2009-03-16 15:22:03 +00:00
|
|
|
PropertyValue* pVal = getValueForWindow( i_pBtn );
|
|
|
|
std::map< Window*, sal_Int32 >::const_iterator it = maControlToNumValMap.find( i_pBtn );
|
|
|
|
if( pVal && it != maControlToNumValMap.end() )
|
|
|
|
{
|
2009-03-16 13:18:23 +00:00
|
|
|
|
2009-03-16 15:22:03 +00:00
|
|
|
sal_Int32 nVal = it->second;
|
|
|
|
pVal->Value <<= nVal;
|
2008-11-05 14:54:11 +00:00
|
|
|
|
2009-03-16 15:22:03 +00:00
|
|
|
checkOptionalControlDependencies();
|
2009-03-16 15:13:59 +00:00
|
|
|
|
2009-03-16 15:22:03 +00:00
|
|
|
// update preview and page settings
|
|
|
|
preparePreview();
|
|
|
|
}
|
2008-11-05 14:54:11 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox*, i_pBox )
|
|
|
|
{
|
|
|
|
PropertyValue* pVal = getValueForWindow( i_pBox );
|
|
|
|
if( pVal )
|
|
|
|
{
|
2009-03-16 13:18:23 +00:00
|
|
|
sal_Int32 nVal( i_pBox->GetSelectEntryPos() );
|
|
|
|
pVal->Value <<= nVal;
|
2008-11-05 14:54:11 +00:00
|
|
|
|
2009-03-16 15:13:59 +00:00
|
|
|
checkOptionalControlDependencies();
|
|
|
|
|
2008-11-05 14:54:11 +00:00
|
|
|
// update preview and page settings
|
|
|
|
preparePreview();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-30 14:31:29 +00:00
|
|
|
|
2009-03-16 17:48:45 +00:00
|
|
|
IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit*, i_pBox )
|
|
|
|
{
|
|
|
|
PropertyValue* pVal = getValueForWindow( i_pBox );
|
|
|
|
if( pVal )
|
|
|
|
{
|
|
|
|
NumericField* pNum = dynamic_cast<NumericField*>(i_pBox);
|
|
|
|
MetricField* pMetric = dynamic_cast<MetricField*>(i_pBox);
|
|
|
|
if( pNum )
|
|
|
|
{
|
|
|
|
sal_Int64 nVal = pNum->GetValue();
|
|
|
|
pVal->Value <<= nVal;
|
|
|
|
}
|
|
|
|
else if( pMetric )
|
|
|
|
{
|
|
|
|
sal_Int64 nVal = pMetric->GetValue();
|
|
|
|
pVal->Value <<= nVal;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rtl::OUString aVal( i_pBox->GetText() );
|
|
|
|
pVal->Value <<= aVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkOptionalControlDependencies();
|
|
|
|
|
|
|
|
// update preview and page settings
|
|
|
|
preparePreview();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-17 12:27:26 +00:00
|
|
|
void PrintDialog::Resize()
|
|
|
|
{
|
|
|
|
Size aPixDiff( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
|
|
|
|
Size aWindowSize( GetOutputSizePixel() );
|
|
|
|
|
|
|
|
// position buttons from lower end, right to left
|
|
|
|
Size aBtnSize( maCancelButton.GetSizePixel() );
|
|
|
|
Rectangle aBtnRect( Point( aWindowSize.Width() - aPixDiff.Width() - aBtnSize.Width(),
|
|
|
|
aWindowSize.Height() - aPixDiff.Height() - aBtnSize.Height() ),
|
|
|
|
aBtnSize );
|
|
|
|
maCancelButton.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() );
|
|
|
|
aBtnSize = maOKButton.GetSizePixel();
|
|
|
|
aBtnRect = Rectangle( Point( aBtnRect.Left() - aPixDiff.Width() - aBtnSize.Width(),
|
|
|
|
aWindowSize.Height() - aPixDiff.Height() - aBtnSize.Height() ),
|
|
|
|
aBtnSize );
|
|
|
|
maOKButton.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() );
|
|
|
|
aBtnSize = maButtonLine.GetSizePixel();
|
|
|
|
|
|
|
|
// position fixed line above buttons
|
|
|
|
aBtnRect = Rectangle( Point( 0, aBtnRect.Top() - aPixDiff.Width() - aBtnSize.Height()/2 ),
|
|
|
|
Size( aWindowSize.Width(), aBtnSize.Height() ) );
|
|
|
|
maButtonLine.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() );
|
|
|
|
|
|
|
|
// position tab control on upper right
|
|
|
|
aBtnSize = maTabCtrl.GetSizePixel();
|
|
|
|
aBtnRect = Rectangle( Point( aWindowSize.Width() - aPixDiff.Width() - aBtnSize.Width(),
|
|
|
|
aPixDiff.Height() ),
|
|
|
|
Size( aBtnSize.Width(), maButtonLine.GetPosPixel().Y() - 2*aPixDiff.Height() ) );
|
|
|
|
maTabCtrl.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() );
|
|
|
|
|
|
|
|
// set size for preview
|
|
|
|
long nMaxX = maTabCtrl.GetPosPixel().X() - 2*aPixDiff.Width();
|
|
|
|
long nMaxY = maButtonLine.GetPosPixel().Y()
|
|
|
|
- 2 * aPixDiff.Height()
|
|
|
|
- maPageText.GetSizePixel().Height()
|
2009-05-22 07:04:13 +00:00
|
|
|
- maPageSlider.GetSizePixel().Height();
|
2009-03-17 12:27:26 +00:00
|
|
|
long nPreviewLength = std::min( nMaxX, nMaxY );
|
|
|
|
maPreviewSpace = Rectangle( Point( aPixDiff.Width(), aPixDiff.Height() ),
|
|
|
|
Size( nPreviewLength, nPreviewLength ) );
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
// position text and slider below preview
|
2009-03-17 12:27:26 +00:00
|
|
|
aBtnRect = Rectangle( Point( aPixDiff.Width(), 2*aPixDiff.Height() + nPreviewLength ),
|
2009-05-22 07:04:13 +00:00
|
|
|
Size( nPreviewLength, maPageSlider.GetSizePixel().Height() ) );
|
|
|
|
maPageSlider.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() );
|
2009-03-17 12:27:26 +00:00
|
|
|
|
|
|
|
aBtnRect.Top() = aBtnRect.Bottom() + aPixDiff.Height()/2;
|
|
|
|
aBtnRect.Bottom() = aBtnRect.Top() + maPageText.GetSizePixel().Height() - 1;
|
|
|
|
maPageText.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() );
|
|
|
|
|
2009-04-24 09:43:48 +00:00
|
|
|
// and do the preview; however the metafile does not need to be gotten anew
|
|
|
|
preparePreview( false );
|
2009-03-17 12:27:26 +00:00
|
|
|
}
|
2009-03-18 14:46:10 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// PrintProgressDialog
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
PrintProgressDialog::PrintProgressDialog( Window* i_pParent, int i_nMax ) :
|
|
|
|
ModelessDialog( i_pParent, VclResId( SV_DLG_PRINT_PROGRESS ) ),
|
|
|
|
maText( this, VclResId( SV_PRINT_PROGRESS_TEXT ) ),
|
|
|
|
maButton( this, VclResId( SV_PRINT_PROGRESS_CANCEL ) ),
|
|
|
|
mbCanceled( false ),
|
|
|
|
mnCur( 0 ),
|
2009-03-18 16:16:06 +00:00
|
|
|
mnMax( i_nMax ),
|
|
|
|
mnProgressHeight( 15 ),
|
|
|
|
mbNativeProgress( false )
|
2009-03-18 14:46:10 +00:00
|
|
|
{
|
2009-03-24 14:21:10 +00:00
|
|
|
FreeResource();
|
|
|
|
|
2009-05-05 17:16:25 +00:00
|
|
|
if( mnMax < 1 )
|
|
|
|
mnMax = 1;
|
|
|
|
|
2009-03-18 14:46:10 +00:00
|
|
|
maStr = maText.GetText();
|
|
|
|
|
|
|
|
maButton.SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintProgressDialog::~PrintProgressDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( PrintProgressDialog, ClickHdl, Button*, pButton )
|
|
|
|
{
|
|
|
|
if( pButton == &maButton )
|
|
|
|
mbCanceled = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintProgressDialog::implCalcProgressRect()
|
|
|
|
{
|
|
|
|
if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
|
|
|
|
{
|
|
|
|
ImplControlValue aValue;
|
2009-03-18 16:16:06 +00:00
|
|
|
Region aControlRegion( Rectangle( Point(), Size( 100, mnProgressHeight ) ) );
|
2009-03-18 14:46:10 +00:00
|
|
|
Region aNativeControlRegion, aNativeContentRegion;
|
|
|
|
if( GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
|
|
|
|
CTRL_STATE_ENABLED, aValue, rtl::OUString(),
|
|
|
|
aNativeControlRegion, aNativeContentRegion ) )
|
|
|
|
{
|
2009-03-18 16:16:06 +00:00
|
|
|
mnProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight();
|
2009-03-18 14:46:10 +00:00
|
|
|
}
|
2009-03-18 16:16:06 +00:00
|
|
|
mbNativeProgress = true;
|
2009-03-18 14:46:10 +00:00
|
|
|
}
|
|
|
|
maProgressRect = Rectangle( Point( 10, maText.GetPosPixel().Y() + maText.GetSizePixel().Height() + 8 ),
|
2009-03-18 16:16:06 +00:00
|
|
|
Size( GetSizePixel().Width() - 20, mnProgressHeight ) );
|
2009-03-18 14:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax )
|
|
|
|
{
|
2009-03-18 16:16:06 +00:00
|
|
|
if( maProgressRect.IsEmpty() )
|
|
|
|
implCalcProgressRect();
|
|
|
|
|
2009-03-18 14:46:10 +00:00
|
|
|
mnCur = i_nCurrent;
|
|
|
|
if( i_nMax != -1 )
|
|
|
|
mnMax = i_nMax;
|
|
|
|
|
2009-05-05 17:16:25 +00:00
|
|
|
if( mnMax < 1 )
|
|
|
|
mnMax = 1;
|
|
|
|
|
2009-03-18 16:16:06 +00:00
|
|
|
rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, mnCur ) );
|
2009-03-18 14:46:10 +00:00
|
|
|
aNewText = searchAndReplace( aNewText, "%n", 2, mnMax );
|
|
|
|
maText.SetText( aNewText );
|
|
|
|
|
|
|
|
// update progress
|
2009-03-18 18:04:53 +00:00
|
|
|
Invalidate( maProgressRect, INVALIDATE_UPDATE );
|
2009-03-18 14:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintProgressDialog::tick()
|
|
|
|
{
|
|
|
|
if( mnCur < mnMax )
|
|
|
|
setProgress( ++mnCur );
|
|
|
|
}
|
|
|
|
|
2009-03-18 14:52:24 +00:00
|
|
|
void PrintProgressDialog::Paint( const Rectangle& )
|
2009-03-18 14:46:10 +00:00
|
|
|
{
|
2009-05-05 17:16:25 +00:00
|
|
|
if( maProgressRect.IsEmpty() )
|
|
|
|
implCalcProgressRect();
|
|
|
|
|
2009-03-18 16:16:06 +00:00
|
|
|
Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
Color aPrgsColor = rStyleSettings.GetHighlightColor();
|
|
|
|
if ( aPrgsColor == rStyleSettings.GetFaceColor() )
|
|
|
|
aPrgsColor = rStyleSettings.GetDarkShadowColor();
|
|
|
|
SetLineColor();
|
|
|
|
SetFillColor( aPrgsColor );
|
|
|
|
|
2009-03-18 18:05:51 +00:00
|
|
|
const long nOffset = 3;
|
2009-03-18 16:16:06 +00:00
|
|
|
const long nWidth = 3*mnProgressHeight/2;
|
|
|
|
const long nFullWidth = nWidth + nOffset;
|
|
|
|
const long nMaxCount = maProgressRect.GetWidth() / nFullWidth;
|
2009-03-18 14:46:10 +00:00
|
|
|
DrawProgress( this, maProgressRect.TopLeft(),
|
2009-03-18 16:16:06 +00:00
|
|
|
nOffset,
|
|
|
|
nWidth,
|
|
|
|
mnProgressHeight,
|
2009-03-18 14:46:10 +00:00
|
|
|
static_cast<USHORT>(0),
|
2009-03-18 16:16:06 +00:00
|
|
|
static_cast<USHORT>(10000*mnCur/mnMax),
|
|
|
|
static_cast<USHORT>(10000/nMaxCount),
|
2009-03-18 14:46:10 +00:00
|
|
|
maProgressRect
|
|
|
|
);
|
2009-03-18 16:16:06 +00:00
|
|
|
Pop();
|
2009-03-18 14:46:10 +00:00
|
|
|
|
2009-03-18 16:16:06 +00:00
|
|
|
if( ! mbNativeProgress )
|
|
|
|
{
|
|
|
|
DecorationView aDecoView( this );
|
|
|
|
Rectangle aFrameRect( maProgressRect );
|
|
|
|
aFrameRect.Left() -= nOffset;
|
|
|
|
aFrameRect.Right() += nOffset;
|
|
|
|
aFrameRect.Top() -= nOffset;
|
|
|
|
aFrameRect.Bottom() += nOffset;
|
|
|
|
aDecoView.DrawFrame( aFrameRect );
|
|
|
|
}
|
2009-03-18 14:46:10 +00:00
|
|
|
}
|