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"
|
2009-05-22 10:06:06 +00:00
|
|
|
#include "vcl/arrange.hxx"
|
2009-06-02 11:37:36 +00:00
|
|
|
#include "vcl/configsettings.hxx"
|
2009-06-03 18:51:46 +00:00
|
|
|
#include "vcl/help.hxx"
|
2009-06-08 12:43:56 +00:00
|
|
|
#include "vcl/decoview.hxx"
|
2009-08-03 15:51:37 +00:00
|
|
|
#include "vcl/svapp.hxx"
|
2008-10-01 18:22:22 +00:00
|
|
|
|
2009-06-10 12:10:29 +00:00
|
|
|
#include "unotools/localedatawrapper.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"
|
2009-08-17 14:40:01 +00:00
|
|
|
#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 ) )
|
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-07-24 13:15:45 +00:00
|
|
|
: Window( i_pParent, i_rId )
|
|
|
|
, maOrigSize( 10, 10 )
|
|
|
|
, maPageVDev( *this )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-07-24 13:15:45 +00:00
|
|
|
SetPaintTransparent( TRUE );
|
|
|
|
SetBackground();
|
|
|
|
maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::PrintPreviewWindow::~PrintPreviewWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-07-24 13:15:45 +00:00
|
|
|
void PrintDialog::PrintPreviewWindow::Resize()
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-07-24 13:15:45 +00:00
|
|
|
Size aNewSize( GetSizePixel() );
|
2009-08-01 12:02:23 +00:00
|
|
|
// leave small space for decoration
|
|
|
|
aNewSize.Width() -= 2;
|
|
|
|
aNewSize.Height() -= 2;
|
2009-07-24 13:15:45 +00:00
|
|
|
Size aScaledSize;
|
|
|
|
double fScale = 1.0;
|
|
|
|
if( maOrigSize.Width() > maOrigSize.Height() )
|
|
|
|
{
|
|
|
|
aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * maOrigSize.Height() / maOrigSize.Width() );
|
|
|
|
if( aScaledSize.Height() > aNewSize.Height() )
|
|
|
|
fScale = double(aNewSize.Height())/double(aScaledSize.Height());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aScaledSize = Size( aNewSize.Height() * maOrigSize.Width() / maOrigSize.Height(), aNewSize.Height() );
|
|
|
|
if( aScaledSize.Width() > aNewSize.Width() )
|
|
|
|
fScale = double(aNewSize.Width())/double(aScaledSize.Width());
|
|
|
|
}
|
|
|
|
aScaledSize.Width() = long(aScaledSize.Width()*fScale);
|
|
|
|
aScaledSize.Height() = long(aScaledSize.Height()*fScale);
|
|
|
|
maPageVDev.SetOutputSizePixel( aScaledSize, FALSE );
|
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
|
2009-07-25 01:56:38 +00:00
|
|
|
void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& )
|
2009-07-24 13:15:45 +00:00
|
|
|
{
|
|
|
|
Size aSize( GetSizePixel() );
|
2009-08-11 15:50:07 +00:00
|
|
|
if( maReplacementString.getLength() != 0 )
|
|
|
|
{
|
|
|
|
// replacement is active
|
|
|
|
Push();
|
|
|
|
Rectangle aTextRect( Point( 0, 0 ), aSize );
|
|
|
|
Font aFont( GetSettings().GetStyleSettings().GetFieldFont() );
|
|
|
|
aFont.SetSize( Size( 0, aSize.Height()/12 ) );
|
|
|
|
SetFont( aFont );
|
|
|
|
DrawText( aTextRect, maReplacementString,
|
|
|
|
TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE
|
|
|
|
);
|
|
|
|
Pop();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GDIMetaFile aMtf( maMtf );
|
2009-07-24 13:15:45 +00:00
|
|
|
|
2009-08-11 15:50:07 +00:00
|
|
|
Size aPreviewSize = maPageVDev.GetOutputSizePixel();
|
|
|
|
Point aOffset( (aSize.Width() - aPreviewSize.Width()) / 2,
|
|
|
|
(aSize.Height() - aPreviewSize.Height()) / 2 );
|
2009-07-24 13:15:45 +00:00
|
|
|
|
2009-08-11 15:50:07 +00:00
|
|
|
const Size aLogicSize( maPageVDev.PixelToLogic( aPreviewSize, MapMode( MAP_100TH_MM ) ) );
|
|
|
|
double fScale = double(aLogicSize.Width())/double(maOrigSize.Width());
|
2009-07-24 13:15:45 +00:00
|
|
|
|
|
|
|
|
2009-08-11 15:50:07 +00:00
|
|
|
maPageVDev.Erase();
|
|
|
|
maPageVDev.Push();
|
|
|
|
maPageVDev.SetMapMode( MAP_100TH_MM );
|
|
|
|
aMtf.WindStart();
|
|
|
|
aMtf.Scale( fScale, fScale );
|
|
|
|
aMtf.WindStart();
|
|
|
|
aMtf.Play( &maPageVDev, Point( 0, 0 ), aLogicSize );
|
|
|
|
maPageVDev.Pop();
|
2009-08-01 12:02:23 +00:00
|
|
|
|
2009-08-11 15:50:07 +00:00
|
|
|
SetMapMode( MAP_PIXEL );
|
|
|
|
maPageVDev.SetMapMode( MAP_PIXEL );
|
|
|
|
DrawOutDev( aOffset, aPreviewSize, Point( 0, 0 ), aPreviewSize, maPageVDev );
|
|
|
|
|
|
|
|
DecorationView aVw( this );
|
|
|
|
aOffset.X() -= 1; aOffset.Y() -=1; aPreviewSize.Width() += 2; aPreviewSize.Height() += 2;
|
|
|
|
aVw.DrawFrame( Rectangle( aOffset, aPreviewSize ), FRAME_DRAW_GROUP );
|
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
2009-07-16 08:50:32 +00:00
|
|
|
void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt )
|
|
|
|
{
|
|
|
|
if( rEvt.GetCommand() == COMMAND_WHEEL )
|
|
|
|
{
|
|
|
|
const CommandWheelData* pWheelData = rEvt.GetWheelData();
|
|
|
|
PrintDialog* pDlg = dynamic_cast<PrintDialog*>(GetParent());
|
|
|
|
if( pDlg )
|
|
|
|
{
|
|
|
|
if( pWheelData->GetDelta() > 0 )
|
|
|
|
pDlg->previewForward();
|
|
|
|
else if( pWheelData->GetDelta() < 0 )
|
|
|
|
pDlg->previewBackward();
|
|
|
|
/*
|
|
|
|
else
|
|
|
|
huh ?
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-11 15:50:07 +00:00
|
|
|
void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview,
|
|
|
|
const Size& i_rOrigSize,
|
2009-08-13 15:10:43 +00:00
|
|
|
const rtl::OUString& i_rReplacement,
|
|
|
|
sal_Int32 i_nDPIX,
|
|
|
|
sal_Int32 i_nDPIY
|
2009-08-11 15:50:07 +00:00
|
|
|
)
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
maMtf = i_rNewPreview;
|
2009-07-24 13:15:45 +00:00
|
|
|
maOrigSize = i_rOrigSize;
|
2009-08-11 15:50:07 +00:00
|
|
|
maReplacementString = i_rReplacement;
|
2009-08-13 15:10:43 +00:00
|
|
|
maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY );
|
|
|
|
maPageVDev.EnableOutput( TRUE );
|
2009-07-27 17:10:15 +00:00
|
|
|
Resize();
|
2009-04-24 09:43:48 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2009-07-30 13:52:50 +00:00
|
|
|
PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( Window* i_pParent )
|
2009-08-10 18:44:52 +00:00
|
|
|
: Window( i_pParent, WB_NOBORDER )
|
2009-07-30 13:52:50 +00:00
|
|
|
, mnOrderMode( 0 )
|
|
|
|
, mnRows( 1 )
|
|
|
|
, mnColumns( 1 )
|
|
|
|
{
|
|
|
|
ImplInitSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::ShowNupOrderWindow::~ShowNupOrderWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::ShowNupOrderWindow::ImplInitSettings()
|
|
|
|
{
|
|
|
|
SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect )
|
|
|
|
{
|
|
|
|
Window::Paint( i_rRect );
|
|
|
|
SetMapMode( MAP_PIXEL );
|
|
|
|
SetTextColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
|
|
|
|
|
|
|
|
int nPages = mnRows * mnColumns;
|
|
|
|
Font aFont( GetSettings().GetStyleSettings().GetFieldFont() );
|
|
|
|
aFont.SetSize( Size( 0, 24 ) );
|
|
|
|
SetFont( aFont );
|
2009-07-30 18:05:46 +00:00
|
|
|
Size aSampleTextSize( GetTextWidth( rtl::OUString::valueOf( sal_Int32(nPages+1) ) ), GetTextHeight() );
|
2009-07-30 13:52:50 +00:00
|
|
|
|
|
|
|
Size aOutSize( GetOutputSizePixel() );
|
|
|
|
Size aSubSize( aOutSize.Width() / mnColumns, aOutSize.Height() / mnRows );
|
|
|
|
// calculate font size: shrink the sample text so it fits
|
2009-07-30 18:05:46 +00:00
|
|
|
double fX = double(aSubSize.Width())/double(aSampleTextSize.Width());
|
|
|
|
double fY = double(aSubSize.Height())/double(aSampleTextSize.Height());
|
2009-07-30 13:52:50 +00:00
|
|
|
double fScale = (fX < fY) ? fX : fY;
|
|
|
|
long nFontHeight = long(24.0*fScale) - 3;
|
|
|
|
if( nFontHeight < 5 )
|
|
|
|
nFontHeight = 5;
|
|
|
|
aFont.SetSize( Size( 0, nFontHeight ) );
|
|
|
|
SetFont( aFont );
|
|
|
|
long nTextHeight = GetTextHeight();
|
|
|
|
for( int i = 0; i < nPages; i++ )
|
|
|
|
{
|
|
|
|
rtl::OUString aPageText( rtl::OUString::valueOf( sal_Int32(i+1) ) );
|
|
|
|
int nX = 0, nY = 0;
|
|
|
|
switch( mnOrderMode )
|
|
|
|
{
|
|
|
|
case SV_PRINT_PRT_NUP_ORDER_LRTD:
|
|
|
|
nX = (i % mnColumns); nY = (i / mnColumns);
|
|
|
|
break;
|
|
|
|
case SV_PRINT_PRT_NUP_ORDER_TDLR:
|
|
|
|
nX = (i / mnRows); nY = (i % mnRows);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Size aTextSize( GetTextWidth( aPageText ), nTextHeight );
|
|
|
|
int nDeltaX = (aSubSize.Width() - aTextSize.Width()) / 2;
|
|
|
|
int nDeltaY = (aSubSize.Height() - aTextSize.Height()) / 2;
|
|
|
|
DrawText( Point( nX * aSubSize.Width() + nDeltaX,
|
|
|
|
nY * aSubSize.Height() + nDeltaY ),
|
|
|
|
aPageText );
|
|
|
|
}
|
2009-08-10 18:44:52 +00:00
|
|
|
DecorationView aVw( this );
|
|
|
|
aVw.DrawFrame( Rectangle( Point( 0, 0), aOutSize ), FRAME_DRAW_GROUP );
|
2009-07-30 13:52:50 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId )
|
2008-10-01 18:22:22 +00:00
|
|
|
: TabPage( i_pParent, rResId )
|
2009-07-27 17:10:15 +00:00
|
|
|
, maNupLine( this, VclResId( SV_PRINT_PRT_NUP_LAYOUT_FL ) )
|
2009-08-01 15:16:11 +00:00
|
|
|
, maPagesBtn( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BTN ) )
|
2009-08-03 11:26:33 +00:00
|
|
|
, maBrochureBtn( this, VclResId( SV_PRINT_PRT_NUP_BROCHURE_BTN ) )
|
2009-07-27 17:10:15 +00:00
|
|
|
, maNupPagesBox( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BOX ) )
|
|
|
|
, maNupNumPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_NUM_PAGES_TXT ) )
|
|
|
|
, maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLS_EDT ) )
|
|
|
|
, maNupTimesTxt( this, VclResId( SV_PRINT_PRT_NUP_TIMES_TXT ) )
|
2009-03-28 08:52:14 +00:00
|
|
|
, maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) )
|
2009-08-10 16:48:53 +00:00
|
|
|
, maPageMarginTxt1( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_1_TXT ) )
|
2009-07-27 17:10:15 +00:00
|
|
|
, maPageMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT ) )
|
2009-08-10 16:48:53 +00:00
|
|
|
, maPageMarginTxt2( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_2_TXT ) )
|
|
|
|
, maSheetMarginTxt1( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_1_TXT ) )
|
2009-07-27 17:10:15 +00:00
|
|
|
, maSheetMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT ) )
|
2009-08-10 16:48:53 +00:00
|
|
|
, maSheetMarginTxt2( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_2_TXT ) )
|
2009-07-27 17:10:15 +00:00
|
|
|
, maNupOrientationTxt( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_TXT ) )
|
|
|
|
, maNupOrientationBox( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_BOX ) )
|
|
|
|
, maNupOrderTxt( this, VclResId( SV_PRINT_PRT_NUP_ORDER_TXT ) )
|
|
|
|
, maNupOrderBox( this, VclResId( SV_PRINT_PRT_NUP_ORDER_BOX ) )
|
2009-07-30 13:52:50 +00:00
|
|
|
, maNupOrderWin( this )
|
2009-06-09 18:58:38 +00:00
|
|
|
, maBorderCB( this, VclResId( SV_PRINT_PRT_NUP_BORDER_CB ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
2009-06-10 12:10:29 +00:00
|
|
|
|
2009-07-30 13:52:50 +00:00
|
|
|
maNupOrderWin.Show();
|
2009-08-03 11:26:33 +00:00
|
|
|
maPagesBtn.Check( TRUE );
|
2009-08-01 15:16:11 +00:00
|
|
|
maBrochureBtn.Show( FALSE );
|
2009-07-30 13:52:50 +00:00
|
|
|
|
2009-06-10 12:10:29 +00:00
|
|
|
// setup field units for metric fields
|
2009-07-27 17:10:15 +00:00
|
|
|
const LocaleDataWrapper& rLocWrap( maPageMarginEdt.GetLocaleDataWrapper() );
|
2009-06-10 12:10:29 +00:00
|
|
|
FieldUnit eUnit = FUNIT_MM;
|
|
|
|
USHORT nDigits = 0;
|
|
|
|
if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US )
|
|
|
|
{
|
|
|
|
eUnit = FUNIT_INCH;
|
|
|
|
nDigits = 2;
|
|
|
|
}
|
|
|
|
// set units
|
2009-07-27 17:10:15 +00:00
|
|
|
maPageMarginEdt.SetUnit( eUnit );
|
|
|
|
maSheetMarginEdt.SetUnit( eUnit );
|
2009-06-10 12:10:29 +00:00
|
|
|
|
|
|
|
// set precision
|
2009-07-27 17:10:15 +00:00
|
|
|
maPageMarginEdt.SetDecimalDigits( nDigits );
|
|
|
|
maSheetMarginEdt.SetDecimalDigits( nDigits );
|
|
|
|
|
2009-08-12 09:46:09 +00:00
|
|
|
SMHID1( "NUpPage" );
|
2009-07-27 17:10:15 +00:00
|
|
|
maNupLine.SMHID2("NUpPage", "Layout");
|
2009-08-01 15:16:11 +00:00
|
|
|
maBrochureBtn.SMHID2("NUpPage", "Brochure" );
|
|
|
|
maPagesBtn.SMHID2( "NUpPage", "PagesPerSheet" );
|
2009-07-27 17:10:15 +00:00
|
|
|
maNupPagesBox.SMHID2( "NUpPage", "PagesPerSheetBox" );
|
|
|
|
maNupNumPagesTxt.SMHID2( "NUpPage", "Columns" );
|
|
|
|
maNupColEdt.SMHID2( "NUpPage", "ColumnsBox" );
|
|
|
|
maNupTimesTxt.SMHID2( "NUpPage", "Rows" );
|
|
|
|
maNupRowsEdt.SMHID2( "NUpPage", "RowsBox" );
|
2009-08-10 16:48:53 +00:00
|
|
|
maPageMarginTxt1.SMHID2( "NUpPage", "PageMargin" );
|
2009-07-27 17:10:15 +00:00
|
|
|
maPageMarginEdt.SMHID2( "NUpPage", "PageMarginBox" );
|
2009-08-10 16:48:53 +00:00
|
|
|
maPageMarginTxt2.SMHID2( "NUpPage", "PageMarginCont" );
|
|
|
|
maSheetMarginTxt1.SMHID2( "NUpPage", "SheetMargin" );
|
2009-07-27 17:10:15 +00:00
|
|
|
maSheetMarginEdt.SMHID2( "NUpPage", "SheetMarginBox" );
|
2009-08-10 16:48:53 +00:00
|
|
|
maSheetMarginTxt2.SMHID2( "NUpPage", "SheetMarginCont" );
|
2009-07-27 17:10:15 +00:00
|
|
|
maNupOrientationTxt.SMHID2( "NUpPage", "Orientation" );
|
|
|
|
maNupOrientationBox.SMHID2( "NUpPage", "OrientationBox" );
|
|
|
|
maNupOrderTxt.SMHID2( "NUpPage", "Order" );
|
|
|
|
maNupOrderBox.SMHID2( "NUpPage", "OrderBox" );
|
|
|
|
maBorderCB.SMHID2( "NUpPage", "BorderBox" );
|
|
|
|
|
|
|
|
setupLayout();
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
PrintDialog::NUpTabPage::~NUpTabPage()
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-08-01 15:16:11 +00:00
|
|
|
void PrintDialog::NUpTabPage::enableNupControls( bool bEnable )
|
|
|
|
{
|
|
|
|
maNupPagesBox.Enable( bEnable );
|
|
|
|
maNupNumPagesTxt.Enable( bEnable );
|
|
|
|
maNupColEdt.Enable( bEnable );
|
|
|
|
maNupTimesTxt.Enable( bEnable );
|
|
|
|
maNupRowsEdt.Enable( bEnable );
|
2009-08-10 16:48:53 +00:00
|
|
|
maPageMarginTxt1.Enable( bEnable );
|
2009-08-01 15:16:11 +00:00
|
|
|
maPageMarginEdt.Enable( bEnable );
|
2009-08-10 16:48:53 +00:00
|
|
|
maPageMarginTxt2.Enable( bEnable );
|
|
|
|
maSheetMarginTxt1.Enable( bEnable );
|
2009-08-01 15:16:11 +00:00
|
|
|
maSheetMarginEdt.Enable( bEnable );
|
2009-08-10 16:48:53 +00:00
|
|
|
maSheetMarginTxt2.Enable( bEnable );
|
2009-08-01 15:16:11 +00:00
|
|
|
maNupOrientationTxt.Enable( bEnable );
|
|
|
|
maNupOrientationBox.Enable( bEnable );
|
|
|
|
maNupOrderTxt.Enable( bEnable );
|
|
|
|
maNupOrderBox.Enable( bEnable );
|
|
|
|
maNupOrderWin.Enable( bEnable );
|
|
|
|
maBorderCB.Enable( bEnable );
|
|
|
|
}
|
|
|
|
|
2009-08-10 16:48:53 +00:00
|
|
|
void PrintDialog::NUpTabPage::showAdvancedControls( bool i_bShow )
|
|
|
|
{
|
|
|
|
maNupNumPagesTxt.Show( i_bShow );
|
|
|
|
maNupColEdt.Show( i_bShow );
|
|
|
|
maNupTimesTxt.Show( i_bShow );
|
|
|
|
maNupRowsEdt.Show( i_bShow );
|
|
|
|
maPageMarginTxt1.Show( i_bShow );
|
|
|
|
maPageMarginEdt.Show( i_bShow );
|
|
|
|
maPageMarginTxt2.Show( i_bShow );
|
|
|
|
maSheetMarginTxt1.Show( i_bShow );
|
|
|
|
maSheetMarginEdt.Show( i_bShow );
|
|
|
|
maSheetMarginTxt2.Show( i_bShow );
|
|
|
|
maNupOrientationTxt.Show( i_bShow );
|
|
|
|
maNupOrientationBox.Show( i_bShow );
|
|
|
|
maLayout.resize();
|
|
|
|
}
|
|
|
|
|
2009-07-27 17:10:15 +00:00
|
|
|
void PrintDialog::NUpTabPage::setupLayout()
|
2009-06-18 18:26:15 +00:00
|
|
|
{
|
|
|
|
Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
|
2009-08-10 16:48:53 +00:00
|
|
|
long nIndent = 3*aBorder.Width();
|
2009-06-18 18:26:15 +00:00
|
|
|
|
2009-07-27 17:10:15 +00:00
|
|
|
maLayout.setParentWindow( this );
|
|
|
|
maLayout.setOuterBorder( aBorder.Width() );
|
|
|
|
|
|
|
|
maLayout.addWindow( &maNupLine );
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &maLayout, false ) );
|
|
|
|
maLayout.addChild( xRow );
|
2009-08-03 15:15:39 +00:00
|
|
|
boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get() ) );
|
2009-07-30 13:52:50 +00:00
|
|
|
xRow->addChild( xIndent );
|
|
|
|
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xShowNupCol( new vcl::RowOrColumn( xRow.get() ) );
|
|
|
|
xRow->addChild( xShowNupCol, -1 );
|
|
|
|
xShowNupCol->setMinimumSize( xShowNupCol->addWindow( &maNupOrderWin ), Size( 70, 70 ) );
|
|
|
|
boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xShowNupCol.get() ) );
|
|
|
|
xShowNupCol->addChild( xSpacer );
|
|
|
|
|
2009-08-10 16:48:53 +00:00
|
|
|
boost::shared_ptr< vcl::LabelColumn > xMainCol( new vcl::LabelColumn( xIndent.get() ) );
|
2009-08-03 11:26:33 +00:00
|
|
|
xIndent->setChild( xMainCol );
|
|
|
|
|
2009-08-10 16:48:53 +00:00
|
|
|
xMainCol->addRow( &maPagesBtn, &maNupPagesBox );
|
|
|
|
|
|
|
|
xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) );
|
|
|
|
xMainCol->addRow( &maNupNumPagesTxt, xRow, nIndent );
|
|
|
|
xRow->addWindow( &maNupColEdt );
|
|
|
|
xRow->addWindow( &maNupTimesTxt );
|
|
|
|
xRow->addWindow( &maNupRowsEdt );
|
2009-07-27 17:10:15 +00:00
|
|
|
|
2009-08-10 16:48:53 +00:00
|
|
|
boost::shared_ptr< vcl::LabeledElement > xLab( new vcl::LabeledElement( xMainCol.get(), 2 ) );
|
|
|
|
xLab->setLabel( &maPageMarginEdt );
|
|
|
|
xLab->setElement( &maPageMarginTxt2 );
|
|
|
|
xMainCol->addRow( &maPageMarginTxt1, xLab, nIndent );
|
2009-07-27 18:42:13 +00:00
|
|
|
|
2009-08-10 16:48:53 +00:00
|
|
|
xLab.reset( new vcl::LabeledElement( xMainCol.get(), 2 ) );
|
|
|
|
xLab->setLabel( &maSheetMarginEdt );
|
|
|
|
xLab->setElement( &maSheetMarginTxt2 );
|
|
|
|
xMainCol->addRow( &maSheetMarginTxt1, xLab, nIndent );
|
2009-07-27 17:10:15 +00:00
|
|
|
|
2009-08-10 16:48:53 +00:00
|
|
|
xMainCol->addRow( &maNupOrientationTxt, &maNupOrientationBox, nIndent );
|
|
|
|
xMainCol->addRow( &maNupOrderTxt, &maNupOrderBox, nIndent );
|
|
|
|
xMainCol->setBorders( xMainCol->addWindow( &maBorderCB ), nIndent, 0, 0, 0 );
|
2009-07-27 17:10:15 +00:00
|
|
|
|
2009-08-03 15:15:39 +00:00
|
|
|
xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, aBorder.Width() ) ) );
|
|
|
|
xMainCol->addChild( xSpacer );
|
|
|
|
|
2009-08-03 11:26:33 +00:00
|
|
|
xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) );
|
2009-08-10 16:48:53 +00:00
|
|
|
xMainCol->addRow( &maBrochureBtn, xRow );
|
2009-08-03 11:26:33 +00:00
|
|
|
// remember brochure row for dependencies
|
|
|
|
mxBrochureDep = xRow;
|
|
|
|
|
2009-08-03 15:51:37 +00:00
|
|
|
// initially advanced controls are not shown, rows=columns=1
|
2009-08-10 16:48:53 +00:00
|
|
|
showAdvancedControls( false );
|
2009-07-27 17:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::NUpTabPage::Resize()
|
|
|
|
{
|
|
|
|
maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
|
2009-06-18 18:26:15 +00:00
|
|
|
}
|
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& i_rMPS )
|
2009-06-09 18:58:38 +00:00
|
|
|
{
|
2009-07-27 17:10:15 +00:00
|
|
|
maSheetMarginEdt.SetValue( maSheetMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM );
|
|
|
|
maPageMarginEdt.SetValue( maPageMarginEdt.Normalize( i_rMPS.nHorizontalSpacing ), FUNIT_100TH_MM );
|
2009-06-09 18:58:38 +00:00
|
|
|
maBorderCB.Check( i_rMPS.bDrawBorder );
|
|
|
|
maNupRowsEdt.SetValue( i_rMPS.nRows );
|
|
|
|
maNupColEdt.SetValue( i_rMPS.nColumns );
|
|
|
|
}
|
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
void PrintDialog::NUpTabPage::readFromSettings()
|
2009-06-02 11:37:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
void PrintDialog::NUpTabPage::storeToSettings()
|
2009-06-02 11:37:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId )
|
|
|
|
: TabPage( i_pParent, rResId )
|
2009-07-22 17:16:34 +00:00
|
|
|
, maPrinterFL( this, VclResId( SV_PRINT_PRINTERS_FL ) )
|
|
|
|
, maPrinters( this, VclResId( SV_PRINT_PRINTERS ) )
|
2009-07-27 18:42:13 +00:00
|
|
|
, maDetailsBtn( this, VclResId( SV_PRINT_DETAILS_BTN ) )
|
|
|
|
, maDetailsTxt( this, VclResId( SV_PRINT_DETAILS_TXT ) )
|
2009-07-22 17:16:34 +00:00
|
|
|
, maStatusLabel( this, VclResId( SV_PRINT_STATUS_TXT ) )
|
|
|
|
, maStatusTxt( this, 0 )
|
|
|
|
, maLocationLabel( this, VclResId( SV_PRINT_LOCATION_TXT ) )
|
|
|
|
, maLocationTxt( this, 0 )
|
|
|
|
, maCommentLabel( this, VclResId( SV_PRINT_COMMENT_TXT ) )
|
|
|
|
, maCommentTxt( this, 0 )
|
2009-06-03 18:51:46 +00:00
|
|
|
, maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, maCopies( this, VclResId( SV_PRINT_COPIES ) )
|
2009-07-22 17:16:34 +00:00
|
|
|
, maCopySpacer( this, WB_VERT )
|
2008-10-01 18:22:22 +00:00
|
|
|
, 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 ) )
|
2009-07-16 12:41:37 +00:00
|
|
|
, mnCollateUIMode( 0 )
|
2009-08-03 11:26:33 +00:00
|
|
|
, maLayout( NULL, true )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
2009-08-12 09:46:09 +00:00
|
|
|
|
|
|
|
SMHID1( "JobPage" );
|
2009-07-22 17:16:34 +00:00
|
|
|
maPrinterFL.SMHID2( "JobPage", "Printer" );
|
2009-04-27 09:47:17 +00:00
|
|
|
maPrinters.SMHID2( "JobPage", "PrinterList" );
|
2009-08-24 17:27:29 +00:00
|
|
|
maDetailsBtn.SMHID2( "JobPage", "DetailsBtn" );
|
2009-07-22 17:16:34 +00:00
|
|
|
maStatusLabel.SMHID2( "JobPage", "StatusLabel" );
|
|
|
|
maStatusTxt.SMHID2( "JobPage", "StatusText" );
|
|
|
|
maLocationLabel.SMHID2( "JobPage", "LocationLabel" );
|
|
|
|
maLocationTxt.SMHID2( "JobPage", "LocationText" );
|
|
|
|
maCommentLabel.SMHID2( "JobPage", "CommentLabel" );
|
|
|
|
maCommentTxt.SMHID2( "JobPage", "CommentText" );
|
2009-08-17 14:40:01 +00:00
|
|
|
maSetupButton.SMHID2( "JobPage", "Properties" );
|
2009-04-27 09:47:17 +00:00
|
|
|
maCopies.SMHID2( "JobPage", "CopiesLine" );
|
2009-07-22 17:16:34 +00:00
|
|
|
maCopySpacer.SMHID2( "JobPage", "CopySpacer" );
|
2009-04-27 09:47:17 +00:00
|
|
|
maCopyCount.SMHID2( "JobPage", "CopiesText" );
|
|
|
|
maCopyCountField.SMHID2( "JobPage", "Copies" );
|
|
|
|
maCollateBox.SMHID2( "JobPage", "Collate" );
|
|
|
|
maCollateImage.SMHID2( "JobPage", "CollateImage" );
|
2009-07-22 17:16:34 +00:00
|
|
|
|
|
|
|
maCopySpacer.Show();
|
|
|
|
maStatusTxt.Show();
|
|
|
|
maCommentTxt.Show();
|
|
|
|
maLocationTxt.Show();
|
|
|
|
|
|
|
|
setupLayout();
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::JobTabPage::~JobTabPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-07-22 17:16:34 +00:00
|
|
|
void PrintDialog::JobTabPage::setupLayout()
|
|
|
|
{
|
|
|
|
// HACK: this is not a dropdown box, but the dropdown line count
|
|
|
|
// 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() );
|
|
|
|
|
|
|
|
// add printer fixed line
|
|
|
|
maLayout.addWindow( &maPrinterFL );
|
|
|
|
// add print LB
|
|
|
|
maLayout.addWindow( &maPrinters );
|
|
|
|
|
2009-07-27 18:42:13 +00:00
|
|
|
// create a row for details button/text and properties button
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( &maLayout, false ) );
|
|
|
|
maLayout.addChild( xDetRow );
|
2009-08-10 18:44:52 +00:00
|
|
|
boost::shared_ptr< vcl::LabeledElement > xDetLbl( new vcl::LabeledElement( xDetRow.get() ) );
|
|
|
|
xDetRow->addChild( xDetLbl );
|
|
|
|
xDetLbl->setLabel( &maDetailsBtn );
|
|
|
|
xDetLbl->setElement( &maDetailsTxt );
|
2009-07-27 18:42:13 +00:00
|
|
|
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 );
|
|
|
|
// remember details controls
|
|
|
|
mxDetails = xIndent;
|
|
|
|
// create a column for the details
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xDetCol( new vcl::RowOrColumn( xIndent.get() ) );
|
|
|
|
xIndent->setChild( xDetCol );
|
2009-07-22 17:16:34 +00:00
|
|
|
// create a row for stati and properties button
|
2009-07-27 18:42:13 +00:00
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xStateRow( new vcl::RowOrColumn( xDetCol.get(), false ) );
|
|
|
|
xDetCol->addChild( xStateRow );
|
2009-07-22 17:16:34 +00:00
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xLabelCol( new vcl::RowOrColumn( xStateRow.get(), true, aBorder.Height() ) );
|
|
|
|
xStateRow->addChild( xLabelCol );
|
|
|
|
xLabelCol->addWindow( &maStatusLabel );
|
|
|
|
xLabelCol->addWindow( &maLocationLabel );
|
|
|
|
xLabelCol->addWindow( &maCommentLabel );
|
|
|
|
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xStatusCol( new vcl::RowOrColumn( xStateRow.get(), true, aBorder.Height() ) );
|
|
|
|
xStateRow->addChild( xStatusCol );
|
|
|
|
xStatusCol->addWindow( &maStatusTxt );
|
|
|
|
xStatusCol->addWindow( &maLocationTxt );
|
|
|
|
xStatusCol->addWindow( &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 );
|
|
|
|
|
|
|
|
// create print range and add to range row
|
|
|
|
mxPrintRange.reset( new vcl::RowOrColumn( xRangeRow.get() ) );
|
|
|
|
xRangeRow->addChild( mxPrintRange );
|
|
|
|
xRangeRow->addWindow( &maCopySpacer );
|
|
|
|
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xCopyCollateCol( new vcl::RowOrColumn( xRangeRow.get() ) );
|
|
|
|
xRangeRow->addChild( xCopyCollateCol );
|
|
|
|
|
|
|
|
// add copies row to copy/collate column
|
2009-07-30 17:31:08 +00:00
|
|
|
boost::shared_ptr< vcl::LabeledElement > xCopiesRow( new vcl::LabeledElement( xCopyCollateCol.get() ) );
|
2009-07-22 17:16:34 +00:00
|
|
|
xCopyCollateCol->addChild( xCopiesRow );
|
2009-07-30 17:31:08 +00:00
|
|
|
xCopiesRow->setLabel( &maCopyCount );
|
|
|
|
xCopiesRow->setElement( &maCopyCountField );
|
|
|
|
boost::shared_ptr< vcl::LabeledElement > xCollateRow( new vcl::LabeledElement( xCopyCollateCol.get() ) );
|
2009-07-22 17:16:34 +00:00
|
|
|
xCopyCollateCol->addChild( xCollateRow );
|
2009-07-30 17:31:08 +00:00
|
|
|
xCollateRow->setLabel( &maCollateBox );
|
|
|
|
xCollateRow->setElement( &maCollateImage );
|
2009-07-27 18:42:13 +00:00
|
|
|
|
|
|
|
maDetailsBtn.SetSymbol( SYMBOL_SPIN_DOWN );
|
|
|
|
maDetailsBtn.SetSmallSymbol();
|
|
|
|
maDetailsBtn.SetStyle( maDetailsBtn.GetStyle() | (WB_SMALLSTYLE | WB_BEVELBUTTON) );
|
|
|
|
mxDetails->show( false, false );
|
2009-07-22 17:16:34 +00:00
|
|
|
}
|
|
|
|
|
2009-06-02 11:37:36 +00:00
|
|
|
void PrintDialog::JobTabPage::readFromSettings()
|
|
|
|
{
|
|
|
|
SettingsConfigItem* pItem = SettingsConfigItem::get();
|
|
|
|
rtl::OUString aValue;
|
|
|
|
|
2009-06-09 18:58:38 +00:00
|
|
|
#if 0
|
|
|
|
// do not actually make copy count persistent
|
|
|
|
// the assumption is that this would lead to a lot of unwanted copies
|
2009-07-16 12:41:37 +00:00
|
|
|
aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
2009-06-24 17:37:07 +00:00
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ) );
|
2009-06-02 11:37:36 +00:00
|
|
|
sal_Int32 nVal = aValue.toInt32();
|
|
|
|
maCopyCountField.SetValue( sal_Int64(nVal > 1 ? nVal : 1) );
|
2009-06-09 18:58:38 +00:00
|
|
|
#endif
|
2009-06-02 11:37:36 +00:00
|
|
|
|
2009-07-16 12:41:37 +00:00
|
|
|
aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CollateBox" ) ) );
|
|
|
|
if( aValue.equalsIgnoreAsciiCaseAscii( "alwaysoff" ) )
|
|
|
|
{
|
|
|
|
mnCollateUIMode = 1;
|
|
|
|
maCollateBox.Check( FALSE );
|
|
|
|
maCollateBox.Enable( FALSE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mnCollateUIMode = 0;
|
|
|
|
aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) );
|
|
|
|
maCollateBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) );
|
|
|
|
}
|
2009-08-06 09:00:23 +00:00
|
|
|
Resize();
|
2009-06-02 11:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::JobTabPage::storeToSettings()
|
|
|
|
{
|
|
|
|
SettingsConfigItem* pItem = SettingsConfigItem::get();
|
2009-07-16 12:41:37 +00:00
|
|
|
pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
2009-06-24 17:37:07 +00:00
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ),
|
2009-06-02 11:37:36 +00:00
|
|
|
maCopyCountField.GetText() );
|
2009-07-16 12:41:37 +00:00
|
|
|
pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
2009-06-02 11:37:36 +00:00
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ),
|
|
|
|
rtl::OUString::createFromAscii( maCollateBox.IsChecked() ? "true" : "false" ) );
|
|
|
|
}
|
|
|
|
|
2009-07-22 17:16:34 +00:00
|
|
|
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 ) )
|
|
|
|
{
|
2009-07-24 13:15:45 +00:00
|
|
|
FreeResource();
|
2009-08-12 09:46:09 +00:00
|
|
|
SMHID1( "OptPage" );
|
2009-07-22 17:16:34 +00:00
|
|
|
maOptionsLine.SMHID2( "OptPage", "Options" );
|
|
|
|
maToFileBox.SMHID2( "OptPage", "ToFile" );
|
|
|
|
maCollateSingleJobsBox.SMHID2( "OptPage", "SingleJobs" );
|
|
|
|
maReverseOrderBox.SMHID2( "OptPage", "Reverse" );
|
2009-07-23 17:22:34 +00:00
|
|
|
|
|
|
|
setupLayout();
|
2009-07-22 17:16:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintDialog::OutputOptPage::~OutputOptPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-07-23 17:22:34 +00:00
|
|
|
void PrintDialog::OutputOptPage::setupLayout()
|
|
|
|
{
|
|
|
|
Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
|
|
|
|
|
|
|
|
maLayout.setParentWindow( this );
|
|
|
|
maLayout.setOuterBorder( aBorder.Width() );
|
|
|
|
|
|
|
|
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() ) );
|
|
|
|
xIndent->setChild( xCol );
|
2009-07-28 19:01:04 +00:00
|
|
|
mxOptGroup = xCol;
|
2009-07-23 17:22:34 +00:00
|
|
|
xCol->addWindow( &maToFileBox );
|
|
|
|
xCol->addWindow( &maCollateSingleJobsBox );
|
|
|
|
xCol->addWindow( &maReverseOrderBox );
|
|
|
|
}
|
|
|
|
|
2009-07-22 17:16:34 +00:00
|
|
|
void PrintDialog::OutputOptPage::readFromSettings()
|
|
|
|
{
|
|
|
|
SettingsConfigItem* pItem = SettingsConfigItem::get();
|
|
|
|
rtl::OUString aValue;
|
|
|
|
|
|
|
|
aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) );
|
|
|
|
maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::OutputOptPage::storeToSettings()
|
|
|
|
{
|
|
|
|
SettingsConfigItem* pItem = SettingsConfigItem::get();
|
|
|
|
pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ),
|
|
|
|
rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) );
|
|
|
|
}
|
|
|
|
|
2009-07-23 17:22:34 +00:00
|
|
|
void PrintDialog::OutputOptPage::Resize()
|
|
|
|
{
|
|
|
|
maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
|
|
|
|
}
|
|
|
|
|
2009-07-22 17:16:34 +00:00
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterController>& i_rController )
|
2008-10-01 18:22:22 +00:00
|
|
|
: ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) )
|
|
|
|
, maOKButton( this, VclResId( SV_PRINT_OK ) )
|
|
|
|
, maCancelButton( this, VclResId( SV_PRINT_CANCEL ) )
|
2009-08-03 15:51:37 +00:00
|
|
|
, maHelpButton( this, VclResId( SV_PRINT_HELP ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, maPreviewWindow( this, VclResId( SV_PRINT_PAGE_PREVIEW ) )
|
2009-06-03 18:51:46 +00:00
|
|
|
, maPageEdit( this, VclResId( SV_PRINT_PAGE_EDIT ) )
|
|
|
|
, maNumPagesText( this, VclResId( SV_PRINT_PAGE_TXT ) )
|
|
|
|
, maForwardBtn( this, VclResId( SV_PRINT_PAGE_FORWARD ) )
|
|
|
|
, maBackwardBtn( this, VclResId( SV_PRINT_PAGE_BACKWARD ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, maTabCtrl( this, VclResId( SV_PRINT_TABCTRL ) )
|
2009-06-03 18:51:46 +00:00
|
|
|
, maNUpPage( &maTabCtrl, VclResId( SV_PRINT_TAB_NUP ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, maJobPage( &maTabCtrl, VclResId( SV_PRINT_TAB_JOB ) )
|
2009-07-22 17:16:34 +00:00
|
|
|
, maOptionsPage( &maTabCtrl, VclResId( SV_PRINT_TAB_OPT ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
, maButtonLine( this, VclResId( SV_PRINT_BUTTONLINE ) )
|
2009-07-06 10:54:21 +00:00
|
|
|
, maPController( i_rController )
|
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 )
|
2009-07-24 13:15:45 +00:00
|
|
|
, maPrintToFileText( String( VclResId( SV_PRINT_TOFILE_TXT ) ) )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
2009-07-24 13:15:45 +00:00
|
|
|
// save printbutton text, gets exchanged occasionally with print to file
|
|
|
|
maPrintText = maOKButton.GetText();
|
|
|
|
|
2009-06-05 15:01:27 +00:00
|
|
|
// setup preview controls
|
|
|
|
maForwardBtn.SetStyle( maForwardBtn.GetStyle() | WB_BEVELBUTTON );
|
|
|
|
maBackwardBtn.SetStyle( maBackwardBtn.GetStyle() | WB_BEVELBUTTON );
|
|
|
|
|
2009-07-23 17:22:34 +00:00
|
|
|
// insert the job (general) tab page first
|
2008-10-01 18:22:22 +00:00
|
|
|
maTabCtrl.InsertPage( SV_PRINT_TAB_JOB, maJobPage.GetText() );
|
|
|
|
maTabCtrl.SetTabPage( SV_PRINT_TAB_JOB, &maJobPage );
|
2009-06-03 18:51:46 +00:00
|
|
|
|
|
|
|
// set symbols on forward and backward button
|
|
|
|
maBackwardBtn.SetSymbol( SYMBOL_PREV );
|
|
|
|
maForwardBtn.SetSymbol( SYMBOL_NEXT );
|
|
|
|
maBackwardBtn.ImplSetSmallSymbol( TRUE );
|
|
|
|
maForwardBtn.ImplSetSmallSymbol( TRUE );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
maPageStr = maNumPagesText.GetText();
|
2009-07-24 13:15:45 +00:00
|
|
|
|
2009-07-30 15:11:07 +00:00
|
|
|
// init reverse print
|
|
|
|
maOptionsPage.maReverseOrderBox.Check( maPController->getReversePrint() );
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
// get the first page
|
2009-06-10 17:21:10 +00:00
|
|
|
preparePreview( true, 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 )
|
|
|
|
{
|
2009-03-16 18:11:54 +00:00
|
|
|
maJobPage.maPrinters.InsertEntry( *it );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
// select current printer
|
2009-07-06 10:54:21 +00:00
|
|
|
if( maJobPage.maPrinters.GetEntryPos( maPController->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND )
|
2009-03-16 18:11:54 +00:00
|
|
|
{
|
2009-07-06 10:54:21 +00:00
|
|
|
maJobPage.maPrinters.SelectEntry( maPController->getPrinter()->GetName() );
|
2009-03-16 18:11:54 +00:00
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
else
|
|
|
|
{
|
2009-06-02 11:37:36 +00:00
|
|
|
// fall back to last printer
|
|
|
|
SettingsConfigItem* pItem = SettingsConfigItem::get();
|
|
|
|
String aValue( pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinter" ) ) ) );
|
2009-06-03 18:51:46 +00:00
|
|
|
if( maJobPage.maPrinters.GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND )
|
2009-06-02 11:37:36 +00:00
|
|
|
{
|
|
|
|
maJobPage.maPrinters.SelectEntry( aValue );
|
2009-07-06 10:54:21 +00:00
|
|
|
maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( aValue ) ) );
|
2009-06-02 11:37:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fall back to default printer
|
|
|
|
maJobPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() );
|
2009-07-06 10:54:21 +00:00
|
|
|
maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) );
|
2009-06-02 11:37:36 +00:00
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
// update the text fields for the printer
|
|
|
|
updatePrinterText();
|
|
|
|
|
|
|
|
// set a select handler
|
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
|
2009-07-06 10:54:21 +00:00
|
|
|
Size aNupSize( maPController->getPrinter()->PixelToLogic(
|
|
|
|
maPController->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
|
|
|
|
if( maPController->getPrinter()->GetOrientation() == ORIENTATION_LANDSCAPE )
|
2009-03-28 08:52:14 +00:00
|
|
|
{
|
|
|
|
maNupLandscapeSize = aNupSize;
|
|
|
|
maNupPortraitSize = Size( aNupSize.Height(), aNupSize.Width() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maNupPortraitSize = aNupSize;
|
|
|
|
maNupLandscapeSize = Size( aNupSize.Height(), aNupSize.Width() );
|
|
|
|
}
|
2009-07-06 10:54:21 +00:00
|
|
|
maNUpPage.initFromMultiPageSetup( maPController->getMultipage() );
|
2009-06-09 18:58:38 +00:00
|
|
|
|
2009-03-28 08:52:14 +00:00
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
// setup click handler on the various buttons
|
2009-06-02 11:37:36 +00:00
|
|
|
maOKButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
|
|
|
maCancelButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
|
|
|
#endif
|
2009-08-03 15:51:37 +00:00
|
|
|
maHelpButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-06-03 18:51:46 +00:00
|
|
|
maForwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
|
|
|
maBackwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-07-16 11:37:53 +00:00
|
|
|
maJobPage.maCollateBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-06-03 18:51:46 +00:00
|
|
|
maJobPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-07-27 18:42:13 +00:00
|
|
|
maJobPage.maDetailsBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-06-09 18:58:38 +00:00
|
|
|
maNUpPage.maBorderCB.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-07-24 13:15:45 +00:00
|
|
|
maOptionsPage.maToFileBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-07-30 15:11:07 +00:00
|
|
|
maOptionsPage.maReverseOrderBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2009-08-01 15:16:11 +00:00
|
|
|
maNUpPage.maPagesBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
|
|
|
// setup modify hdl
|
2009-06-03 18:51:46 +00:00
|
|
|
maPageEdit.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
maJobPage.maCopyCountField.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
2009-06-03 18:51:46 +00:00
|
|
|
maNUpPage.maNupRowsEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
|
|
|
maNUpPage.maNupColEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
2009-07-27 17:10:15 +00:00
|
|
|
maNUpPage.maPageMarginEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
|
|
|
maNUpPage.maSheetMarginEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
|
|
|
|
|
|
|
|
// setup select hdl
|
|
|
|
maNUpPage.maNupPagesBox.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
|
|
|
|
maNUpPage.maNupOrientationBox.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
|
|
|
|
maNUpPage.maNupOrderBox.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
2009-07-24 13:15:45 +00:00
|
|
|
// setup the layout
|
|
|
|
setupLayout();
|
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
// setup optional UI options set by application
|
|
|
|
setupOptionalUI();
|
|
|
|
|
|
|
|
// set change handler for UI options
|
2009-07-06 10:54:21 +00:00
|
|
|
maPController->setOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) );
|
2008-10-30 14:31:29 +00:00
|
|
|
|
2009-03-17 12:27:26 +00:00
|
|
|
// set min size pixel to current size
|
|
|
|
SetMinOutputSizePixel( GetOutputSizePixel() );
|
|
|
|
|
2009-06-02 11:37:36 +00:00
|
|
|
// restore settings from last run
|
|
|
|
readFromSettings();
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
// setup dependencies
|
|
|
|
checkControlDependencies();
|
2009-04-27 09:47:17 +00:00
|
|
|
|
|
|
|
// set HelpIDs
|
2009-08-12 09:46:09 +00:00
|
|
|
SMHID1( "Dialog" );
|
2009-04-27 09:47:17 +00:00
|
|
|
maOKButton.SMHID1( "OK" );
|
|
|
|
maCancelButton.SMHID1( "Cancel" );
|
2009-08-24 17:27:29 +00:00
|
|
|
maHelpButton.SMHID1( "Help" );
|
2009-04-27 09:47:17 +00:00
|
|
|
maPreviewWindow.SMHID1( "Preview" );
|
2009-06-03 18:51:46 +00:00
|
|
|
maNumPagesText.SMHID1( "NumPagesText" );
|
|
|
|
maPageEdit.SMHID1( "PageEdit" );
|
|
|
|
maForwardBtn.SMHID1( "ForwardBtn" );
|
|
|
|
maBackwardBtn.SMHID1( "BackwardBtn" );
|
2009-04-27 09:47:17 +00:00
|
|
|
maTabCtrl.SMHID1( "TabPages" );
|
2009-07-22 17:16:34 +00:00
|
|
|
|
2009-07-23 17:22:34 +00:00
|
|
|
// append further tab pages
|
|
|
|
maTabCtrl.InsertPage( SV_PRINT_TAB_NUP, maNUpPage.GetText() );
|
|
|
|
maTabCtrl.SetTabPage( SV_PRINT_TAB_NUP, &maNUpPage );
|
2009-07-22 17:16:34 +00:00
|
|
|
maTabCtrl.InsertPage( SV_PRINT_TAB_OPT, maOptionsPage.GetText() );
|
|
|
|
maTabCtrl.SetTabPage( SV_PRINT_TAB_OPT, &maOptionsPage );
|
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
|
|
|
}
|
|
|
|
|
2009-07-24 13:15:45 +00:00
|
|
|
void PrintDialog::setupLayout()
|
|
|
|
{
|
|
|
|
Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
|
|
|
|
|
|
|
|
maLayout.setParentWindow( this );
|
|
|
|
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xPreviewAndTab( new vcl::RowOrColumn( &maLayout, false ) );
|
2009-08-01 11:38:53 +00:00
|
|
|
size_t nIndex = maLayout.addChild( xPreviewAndTab, 5 );
|
|
|
|
maLayout.setBorders( nIndex, aBorder.Width(), aBorder.Width(), aBorder.Width(), 0 );
|
2009-07-24 13:15:45 +00:00
|
|
|
|
|
|
|
// setup column for preview and sub controls
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xPreview( new vcl::RowOrColumn( xPreviewAndTab.get() ) );
|
|
|
|
xPreviewAndTab->addChild( xPreview, 5 );
|
|
|
|
xPreview->addWindow( &maPreviewWindow, 5 );
|
|
|
|
// get a row for the preview controls
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xPreviewCtrls( new vcl::RowOrColumn( xPreview.get(), false ) );
|
2009-08-01 12:39:45 +00:00
|
|
|
nIndex = xPreview->addChild( xPreviewCtrls );
|
2009-08-25 08:52:05 +00:00
|
|
|
boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xPreviewCtrls.get(), 2 ) );
|
|
|
|
xPreviewCtrls->addChild( xSpacer );
|
2009-07-24 13:15:45 +00:00
|
|
|
xPreviewCtrls->addWindow( &maPageEdit );
|
|
|
|
xPreviewCtrls->addWindow( &maNumPagesText );
|
2009-08-25 08:52:05 +00:00
|
|
|
xSpacer.reset( new vcl::Spacer( xPreviewCtrls.get(), 2 ) );
|
2009-07-24 13:15:45 +00:00
|
|
|
xPreviewCtrls->addChild( xSpacer );
|
|
|
|
xPreviewCtrls->addWindow( &maBackwardBtn );
|
|
|
|
xPreviewCtrls->addWindow( &maForwardBtn );
|
2009-08-25 08:52:05 +00:00
|
|
|
xSpacer.reset( new vcl::Spacer( xPreviewCtrls.get(), 2 ) );
|
|
|
|
xPreviewCtrls->addChild( xSpacer );
|
2009-07-24 13:15:45 +00:00
|
|
|
|
|
|
|
// continue with the tab ctrl
|
|
|
|
xPreviewAndTab->addWindow( &maTabCtrl );
|
|
|
|
|
|
|
|
// add the button line
|
|
|
|
maLayout.addWindow( &maButtonLine );
|
|
|
|
|
|
|
|
// add the row for the buttons
|
|
|
|
boost::shared_ptr< vcl::RowOrColumn > xButtons( new vcl::RowOrColumn( &maLayout, false ) );
|
2009-08-01 11:38:53 +00:00
|
|
|
nIndex = maLayout.addChild( xButtons );
|
|
|
|
maLayout.setBorders( nIndex, aBorder.Width(), 0, aBorder.Width(), aBorder.Width() );
|
2009-07-24 13:15:45 +00:00
|
|
|
|
2009-08-03 15:51:37 +00:00
|
|
|
Size aMinSize( maCancelButton.GetSizePixel() );
|
|
|
|
// insert help button
|
|
|
|
xButtons->setMinimumSize( xButtons->addWindow( &maHelpButton ), aMinSize );
|
|
|
|
// insert a spacer, cancel and OK buttons are right aligned
|
2009-07-24 13:15:45 +00:00
|
|
|
xSpacer.reset( new vcl::Spacer( xButtons.get(), 2 ) );
|
|
|
|
xButtons->addChild( xSpacer );
|
|
|
|
xButtons->setMinimumSize( xButtons->addWindow( &maOKButton ), aMinSize );
|
|
|
|
xButtons->setMinimumSize( xButtons->addWindow( &maCancelButton ), aMinSize );
|
|
|
|
}
|
|
|
|
|
2009-06-02 11:37:36 +00:00
|
|
|
void PrintDialog::readFromSettings()
|
|
|
|
{
|
|
|
|
maJobPage.readFromSettings();
|
2009-06-03 18:51:46 +00:00
|
|
|
maNUpPage.readFromSettings();
|
2009-07-22 17:16:34 +00:00
|
|
|
maOptionsPage.readFromSettings();
|
2009-06-02 11:37:36 +00:00
|
|
|
|
|
|
|
// read last selected tab page; if it exists, actiavte it
|
|
|
|
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++ )
|
|
|
|
{
|
|
|
|
USHORT nPageId = maTabCtrl.GetPageId( i );
|
|
|
|
if( aValue.equals( maTabCtrl.GetPageText( nPageId ) ) )
|
|
|
|
{
|
|
|
|
maTabCtrl.SelectTabPage( nPageId );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 13:15:45 +00:00
|
|
|
maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText );
|
2009-06-02 11:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::storeToSettings()
|
|
|
|
{
|
|
|
|
maJobPage.storeToSettings();
|
2009-06-03 18:51:46 +00:00
|
|
|
maNUpPage.storeToSettings();
|
2009-07-22 17:16:34 +00:00
|
|
|
maOptionsPage.storeToSettings();
|
2009-06-02 11:37:36 +00:00
|
|
|
|
|
|
|
// store last selected printer
|
|
|
|
SettingsConfigItem* pItem = SettingsConfigItem::get();
|
|
|
|
pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinter" ) ),
|
|
|
|
maJobPage.maPrinters.GetSelectEntry() );
|
|
|
|
|
|
|
|
pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ),
|
|
|
|
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPage" ) ),
|
|
|
|
maTabCtrl.GetPageText( maTabCtrl.GetCurPageId() ) );
|
|
|
|
pItem->Commit();
|
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
bool PrintDialog::isPrintToFile()
|
|
|
|
{
|
2009-07-22 17:16:34 +00:00
|
|
|
return maOptionsPage.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 );
|
|
|
|
}
|
2009-08-17 14:40:01 +00:00
|
|
|
i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear(), HID_PRINTDLG ) );
|
2009-04-27 09:47:17 +00:00
|
|
|
}
|
|
|
|
|
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-08-03 15:51:37 +00:00
|
|
|
void updateMaxSize( const Size& i_rCheckSize, Size& o_rMaxSize )
|
|
|
|
{
|
|
|
|
if( i_rCheckSize.Width() > o_rMaxSize.Width() )
|
|
|
|
o_rMaxSize.Width() = i_rCheckSize.Width();
|
|
|
|
if( i_rCheckSize.Height() > o_rMaxSize.Height() )
|
|
|
|
o_rMaxSize.Height() = i_rCheckSize.Height();
|
|
|
|
}
|
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
void PrintDialog::setupOptionalUI()
|
|
|
|
{
|
2009-07-23 17:22:34 +00:00
|
|
|
Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) );
|
2009-05-22 10:06:06 +00:00
|
|
|
|
|
|
|
std::vector<vcl::RowOrColumn*> aDynamicColumns;
|
|
|
|
vcl::RowOrColumn* pCurColumn = 0;
|
|
|
|
|
2009-05-22 07:04:13 +00:00
|
|
|
Window* pCurParent = 0, *pDynamicPageParent = 0;
|
2009-05-22 10:06:06 +00:00
|
|
|
USHORT nOptPageId = 9, nCurSubGroup = 0;
|
2009-07-23 17:22:34 +00:00
|
|
|
bool bOnStaticPage = false;
|
2009-07-28 19:01:04 +00:00
|
|
|
bool bSubgroupOnStaticPage = false;
|
2009-05-22 07:04:13 +00:00
|
|
|
|
2009-05-27 17:40:24 +00:00
|
|
|
std::multimap< rtl::OUString, vcl::RowOrColumn* > aPropertyToDependencyRowMap;
|
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
const Sequence< PropertyValue >& rOptions( maPController->getUIOptions() );
|
2008-10-30 14:31:29 +00:00
|
|
|
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-04-27 16:11:03 +00:00
|
|
|
sal_Int32 nCurHelpText = 0;
|
2009-07-22 17:16:34 +00:00
|
|
|
rtl::OUString aGroupingHint;
|
2009-05-27 17:40:24 +00:00
|
|
|
rtl::OUString aDependsOnName;
|
|
|
|
sal_Int32 nDependsOnValue = 0;
|
|
|
|
sal_Bool bUseDependencyRow = 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-07-22 17:16:34 +00:00
|
|
|
else if( rEntry.Name.equalsAscii( "GroupingHint" ) )
|
2009-05-22 07:04:13 +00:00
|
|
|
{
|
2009-07-22 17:16:34 +00:00
|
|
|
rEntry.Value >>= aGroupingHint;
|
2009-05-22 07:04:13 +00:00
|
|
|
}
|
2009-03-16 15:13:59 +00:00
|
|
|
else if( rEntry.Name.equalsAscii( "DependsOnName" ) )
|
|
|
|
{
|
2009-05-27 17:40:24 +00:00
|
|
|
rEntry.Value >>= aDependsOnName;
|
|
|
|
}
|
|
|
|
else if( rEntry.Name.equalsAscii( "DependsOnEntry" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= nDependsOnValue;
|
|
|
|
}
|
|
|
|
else if( rEntry.Name.equalsAscii( "AttachToDependency" ) )
|
|
|
|
{
|
|
|
|
rEntry.Value >>= bUseDependencyRow;
|
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
|
|
|
|
2009-07-28 19:01:04 +00:00
|
|
|
// is it necessary to switch between static and dynamic pages ?
|
|
|
|
bool bSwitchPage = false;
|
|
|
|
if( aGroupingHint.getLength() )
|
|
|
|
bSwitchPage = true;
|
|
|
|
else if( aCtrlType.equalsAscii( "Subgroup" ) || (bOnStaticPage && ! bSubgroupOnStaticPage ) )
|
|
|
|
bSwitchPage = true;
|
|
|
|
if( bSwitchPage )
|
|
|
|
{
|
|
|
|
// restore to dynamic
|
|
|
|
pCurParent = pDynamicPageParent;
|
|
|
|
pCurColumn = aDynamicColumns.empty() ? NULL : aDynamicColumns.back();
|
|
|
|
bOnStaticPage = false;
|
|
|
|
bSubgroupOnStaticPage = false;
|
|
|
|
|
|
|
|
if( aGroupingHint.equalsAscii( "PrintRange" ) )
|
|
|
|
{
|
|
|
|
pCurColumn = maJobPage.mxPrintRange.get();
|
|
|
|
pCurParent = &maJobPage; // set job page as current parent
|
|
|
|
bOnStaticPage = true;
|
|
|
|
}
|
|
|
|
else if( aGroupingHint.equalsAscii( "OptionsPage" ) )
|
|
|
|
{
|
|
|
|
pCurColumn = &maOptionsPage.maLayout;
|
|
|
|
pCurParent = &maOptionsPage; // set options page as current parent
|
|
|
|
bOnStaticPage = true;
|
|
|
|
}
|
|
|
|
else if( aGroupingHint.equalsAscii( "OptionsPageOptGroup" ) )
|
|
|
|
{
|
|
|
|
pCurColumn = maOptionsPage.mxOptGroup.get();
|
|
|
|
pCurParent = &maOptionsPage; // set options page as current parent
|
|
|
|
bOnStaticPage = true;
|
|
|
|
}
|
|
|
|
else if( aGroupingHint.equalsAscii( "LayoutPage" ) )
|
|
|
|
{
|
2009-08-10 16:48:53 +00:00
|
|
|
pCurColumn = &maNUpPage.maLayout;
|
2009-07-28 19:01:04 +00:00
|
|
|
pCurParent = &maNUpPage; // set layout page as current parent
|
|
|
|
bOnStaticPage = true;
|
|
|
|
}
|
|
|
|
else if( aGroupingHint.getLength() )
|
|
|
|
{
|
|
|
|
pCurColumn = &maJobPage.maLayout;
|
|
|
|
pCurParent = &maJobPage; // set job page as current parent
|
|
|
|
bOnStaticPage = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-27 18:53:40 +00:00
|
|
|
if( aCtrlType.equalsAscii( "Group" ) ||
|
2009-07-23 17:22:34 +00:00
|
|
|
( ! pCurParent && ! (bOnStaticPage || aGroupingHint.getLength() ) ) )
|
2009-05-27 17:40:24 +00:00
|
|
|
{
|
|
|
|
// add new tab page
|
|
|
|
TabPage* pNewGroup = new TabPage( &maTabCtrl );
|
|
|
|
maControls.push_front( pNewGroup );
|
2009-07-23 17:22:34 +00:00
|
|
|
pDynamicPageParent = pCurParent = pNewGroup;
|
2009-05-27 17:40:24 +00:00
|
|
|
pNewGroup->SetText( aText );
|
|
|
|
maTabCtrl.InsertPage( ++nOptPageId, aText );
|
|
|
|
maTabCtrl.SetTabPage( nOptPageId, pNewGroup );
|
|
|
|
|
|
|
|
// set help id
|
|
|
|
setSmartId( pNewGroup, "TabPage", nOptPageId );
|
|
|
|
// set help text
|
|
|
|
setHelpText( pNewGroup, aHelpTexts, 0 );
|
|
|
|
|
|
|
|
// reset subgroup counter
|
|
|
|
nCurSubGroup = 0;
|
|
|
|
|
2009-07-23 17:22:34 +00:00
|
|
|
aDynamicColumns.push_back( new vcl::RowOrColumn( NULL, true, aBorder.Width() ) );
|
2009-05-27 17:40:24 +00:00
|
|
|
pCurColumn = aDynamicColumns.back();
|
|
|
|
pCurColumn->setParentWindow( pNewGroup );
|
2009-07-23 17:22:34 +00:00
|
|
|
pCurColumn->setOuterBorder( aBorder.Width() );
|
2009-07-28 19:01:04 +00:00
|
|
|
bSubgroupOnStaticPage = false;
|
|
|
|
bOnStaticPage = false;
|
2009-05-27 17:40:24 +00:00
|
|
|
}
|
2009-07-22 17:16:34 +00:00
|
|
|
else if( aCtrlType.equalsAscii( "Subgroup" ) && (pCurParent || aGroupingHint.getLength() ) )
|
2008-10-30 14:31:29 +00:00
|
|
|
{
|
2009-07-28 19:01:04 +00:00
|
|
|
bSubgroupOnStaticPage = (aGroupingHint.getLength() != 0);
|
2009-05-27 17:40:24 +00:00
|
|
|
// create group FixedLine
|
2009-07-22 17:16:34 +00:00
|
|
|
if( ! aGroupingHint.equalsAscii( "PrintRange" ) ||
|
|
|
|
! pCurColumn->countElements() == 0
|
|
|
|
)
|
|
|
|
{
|
2009-08-01 12:39:45 +00:00
|
|
|
Window* pNewSub = NULL;
|
|
|
|
if( aGroupingHint.equalsAscii( "PrintRange" ) )
|
|
|
|
pNewSub = new FixedText( pCurParent, WB_VCENTER );
|
|
|
|
else
|
|
|
|
pNewSub = new FixedLine( pCurParent );
|
2009-07-22 17:16:34 +00:00
|
|
|
maControls.push_front( pNewSub );
|
|
|
|
pNewSub->SetText( aText );
|
|
|
|
pNewSub->Show();
|
2008-10-30 14:31:29 +00:00
|
|
|
|
2009-07-22 17:16:34 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) );
|
|
|
|
// set help text
|
|
|
|
setHelpText( pNewSub, aHelpTexts, 0 );
|
|
|
|
// add group to current column
|
|
|
|
pCurColumn->addWindow( pNewSub );
|
|
|
|
}
|
2009-07-23 17:22:34 +00:00
|
|
|
|
|
|
|
// add an indent to the current column
|
|
|
|
vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn, aBorder.Width() );
|
|
|
|
pCurColumn->addChild( pIndent );
|
|
|
|
// and create a column inside the indent
|
|
|
|
pCurColumn = new vcl::RowOrColumn( pIndent );
|
|
|
|
pIndent->setChild( pCurColumn );
|
2009-05-27 17:40:24 +00:00
|
|
|
}
|
2009-08-01 15:16:11 +00:00
|
|
|
// EVIL
|
|
|
|
else if( aCtrlType.equalsAscii( "Bool" ) &&
|
|
|
|
aGroupingHint.equalsAscii( "LayoutPage" ) &&
|
2009-08-17 14:40:01 +00:00
|
|
|
aPropertyName.equalsAscii( "PrintProspect" )
|
2009-08-01 15:16:11 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
maNUpPage.maBrochureBtn.SetText( aText );
|
|
|
|
maNUpPage.maBrochureBtn.Show();
|
|
|
|
setHelpText( &maNUpPage.maBrochureBtn, aHelpTexts, 0 );
|
|
|
|
|
|
|
|
sal_Bool bVal = sal_False;
|
|
|
|
PropertyValue* pVal = maPController->getValue( aPropertyName );
|
|
|
|
if( pVal )
|
|
|
|
pVal->Value >>= bVal;
|
|
|
|
maNUpPage.maBrochureBtn.Check( bVal );
|
|
|
|
maNUpPage.maBrochureBtn.Enable( maPController->isUIOptionEnabled( aPropertyName ) && pVal != NULL );
|
|
|
|
maNUpPage.maBrochureBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) );
|
|
|
|
|
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, &maNUpPage.maBrochureBtn ) );
|
|
|
|
maControlToPropertyMap[&maNUpPage.maBrochureBtn] = aPropertyName;
|
|
|
|
|
|
|
|
aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, maNUpPage.mxBrochureDep.get() ) );
|
|
|
|
}
|
2009-05-27 17:40:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
vcl::RowOrColumn* pSaveCurColumn = pCurColumn;
|
|
|
|
|
|
|
|
if( bUseDependencyRow && aDependsOnName.getLength() )
|
2008-11-05 15:52:15 +00:00
|
|
|
{
|
2009-05-27 17:40:24 +00:00
|
|
|
// find the correct dependency row (if any)
|
|
|
|
std::pair< std::multimap< rtl::OUString, vcl::RowOrColumn* >::iterator,
|
|
|
|
std::multimap< rtl::OUString, vcl::RowOrColumn* >::iterator > aDepRange;
|
|
|
|
aDepRange = aPropertyToDependencyRowMap.equal_range( aDependsOnName );
|
|
|
|
if( aDepRange.first != aDepRange.second )
|
2009-05-22 07:04:13 +00:00
|
|
|
{
|
2009-05-27 17:40:24 +00:00
|
|
|
while( nDependsOnValue && aDepRange.first != aDepRange.second )
|
2009-05-22 07:04:13 +00:00
|
|
|
{
|
2009-05-27 17:40:24 +00:00
|
|
|
nDependsOnValue--;
|
|
|
|
++aDepRange.first;
|
2009-05-22 07:04:13 +00:00
|
|
|
}
|
2009-05-27 17:40:24 +00:00
|
|
|
if( aDepRange.first != aPropertyToDependencyRowMap.end() )
|
2009-05-22 07:04:13 +00:00
|
|
|
{
|
2009-05-27 17:40:24 +00:00
|
|
|
pCurColumn = aDepRange.first->second;
|
2009-05-22 07:04:13 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-05 15:52:15 +00:00
|
|
|
}
|
2009-05-27 17:40:24 +00:00
|
|
|
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 );
|
|
|
|
pNewBox->Show();
|
2009-05-22 10:06:06 +00:00
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
sal_Bool bVal = sal_False;
|
2009-07-06 10:54:21 +00:00
|
|
|
PropertyValue* pVal = maPController->getValue( aPropertyName );
|
2008-10-30 14:31:29 +00:00
|
|
|
if( pVal )
|
|
|
|
pVal->Value >>= bVal;
|
|
|
|
pNewBox->Check( bVal );
|
2009-07-06 10:54:21 +00:00
|
|
|
pNewBox->Enable( maPController->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 );
|
2009-05-22 10:06:06 +00:00
|
|
|
|
2009-05-27 17:40:24 +00:00
|
|
|
vcl::RowOrColumn* pDependencyRow = new vcl::RowOrColumn( pCurColumn, false );
|
|
|
|
pCurColumn->addChild( pDependencyRow );
|
|
|
|
aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pDependencyRow ) );
|
|
|
|
|
2009-05-22 10:06:06 +00:00
|
|
|
// add checkbox to current column
|
2009-05-27 17:40:24 +00:00
|
|
|
pDependencyRow->addWindow( pNewBox );
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent )
|
|
|
|
{
|
2009-05-22 10:06:06 +00:00
|
|
|
vcl::RowOrColumn* pRadioColumn = pCurColumn;
|
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 );
|
|
|
|
pHeading->Show();
|
|
|
|
|
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++ );
|
2009-05-22 10:06:06 +00:00
|
|
|
// add fixed text to current column
|
|
|
|
pCurColumn->addWindow( pHeading );
|
|
|
|
// add an indent to the current column
|
|
|
|
vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn, 15 );
|
|
|
|
pCurColumn->addChild( pIndent );
|
|
|
|
// and create a column inside the indent
|
|
|
|
pRadioColumn = new vcl::RowOrColumn( pIndent );
|
|
|
|
pIndent->setChild( pRadioColumn );
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
// iterate options
|
2009-03-16 13:18:23 +00:00
|
|
|
sal_Int32 nSelectVal = 0;
|
2009-07-06 10:54:21 +00:00
|
|
|
PropertyValue* pVal = maPController->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++ )
|
|
|
|
{
|
2009-08-18 16:07:05 +00:00
|
|
|
boost::shared_ptr<vcl::LabeledElement> pLabel( new vcl::LabeledElement( pRadioColumn, 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() ) );
|
2009-05-27 17:40:24 +00:00
|
|
|
|
2008-10-30 14:31:29 +00:00
|
|
|
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-07-06 10:54:21 +00:00
|
|
|
pBtn->Enable( maPController->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-05-22 10:06:06 +00:00
|
|
|
// add the radio button to the column
|
2009-08-18 16:07:05 +00:00
|
|
|
pLabel->setLabel( pBtn );
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-22 10:19:01 +00:00
|
|
|
else if( ( aCtrlType.equalsAscii( "List" ) ||
|
|
|
|
aCtrlType.equalsAscii( "Range" ) ||
|
|
|
|
aCtrlType.equalsAscii( "Edit" )
|
|
|
|
) && pCurParent )
|
2008-10-30 14:31:29 +00:00
|
|
|
{
|
2009-05-27 17:40:24 +00:00
|
|
|
// create a row in the current column
|
|
|
|
vcl::RowOrColumn* pFieldColumn = new vcl::RowOrColumn( pCurColumn, false );
|
|
|
|
pCurColumn->addChild( pFieldColumn );
|
|
|
|
aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pFieldColumn ) );
|
|
|
|
|
2009-07-30 17:31:08 +00:00
|
|
|
vcl::LabeledElement* pLabel = NULL;
|
2009-05-22 10:19:01 +00:00
|
|
|
if( aText.getLength() )
|
2008-10-30 14:31:29 +00:00
|
|
|
{
|
2009-05-22 10:19:01 +00:00
|
|
|
// add a FixedText:
|
|
|
|
FixedText* pHeading = new FixedText( pCurParent, WB_VCENTER );
|
|
|
|
maControls.push_front( pHeading );
|
|
|
|
pHeading->SetText( aText );
|
|
|
|
pHeading->Show();
|
2009-04-27 09:47:17 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pHeading, "FixedText", -1, aPropertyName );
|
2009-05-22 10:06:06 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// add to row
|
2009-08-10 16:48:53 +00:00
|
|
|
pLabel = new vcl::LabeledElement( pFieldColumn, 2 );
|
2009-07-30 17:31:08 +00:00
|
|
|
pFieldColumn->addChild( pLabel );
|
|
|
|
pLabel->setLabel( pHeading );
|
2009-05-22 10:19:01 +00:00
|
|
|
}
|
2009-03-16 17:48:45 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
if( aCtrlType.equalsAscii( "List" ) )
|
2009-03-16 17:48:45 +00:00
|
|
|
{
|
2009-05-22 10:19:01 +00:00
|
|
|
ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER );
|
|
|
|
maControls.push_front( pList );
|
2009-03-16 17:48:45 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// iterate options
|
|
|
|
for( sal_Int32 m = 0; m < aChoices.getLength(); m++ )
|
|
|
|
{
|
|
|
|
pList->InsertEntry( aChoices[m] );
|
|
|
|
}
|
|
|
|
sal_Int32 nSelectVal = 0;
|
2009-07-06 10:54:21 +00:00
|
|
|
PropertyValue* pVal = maPController->getValue( aPropertyName );
|
2009-05-22 10:19:01 +00:00
|
|
|
if( pVal && pVal->Value.hasValue() )
|
|
|
|
pVal->Value >>= nSelectVal;
|
|
|
|
pList->SelectEntryPos( static_cast<USHORT>(nSelectVal) );
|
2009-07-06 10:54:21 +00:00
|
|
|
pList->Enable( maPController->isUIOptionEnabled( aPropertyName ) );
|
2009-05-22 10:19:01 +00:00
|
|
|
pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) );
|
2009-05-25 15:12:27 +00:00
|
|
|
pList->SetDropDownLineCount( static_cast<USHORT>(aChoices.getLength()) );
|
2009-05-22 10:19:01 +00:00
|
|
|
pList->Show();
|
2009-03-16 17:48:45 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pList, "ListBox", -1, aPropertyName );
|
|
|
|
// set help text
|
|
|
|
setHelpText( pList, aHelpTexts, 0 );
|
2009-04-27 09:47:17 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) );
|
|
|
|
maControlToPropertyMap[pList] = aPropertyName;
|
2009-03-16 17:48:45 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// finish the pair
|
2009-07-30 17:31:08 +00:00
|
|
|
if( pLabel )
|
|
|
|
pLabel->setElement( pList );
|
|
|
|
else
|
|
|
|
pFieldColumn->addWindow( pList );
|
2009-05-22 10:19:01 +00:00
|
|
|
}
|
|
|
|
else if( aCtrlType.equalsAscii( "Range" ) )
|
2009-05-22 07:04:13 +00:00
|
|
|
{
|
2009-05-22 10:19:01 +00:00
|
|
|
NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN );
|
|
|
|
maControls.push_front( pField );
|
2009-05-22 10:06:06 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// set min/max and current value
|
|
|
|
if( nMinValue != nMaxValue )
|
|
|
|
{
|
|
|
|
pField->SetMin( nMinValue );
|
|
|
|
pField->SetMax( nMaxValue );
|
|
|
|
}
|
|
|
|
sal_Int64 nCurVal = 0;
|
2009-07-06 10:54:21 +00:00
|
|
|
PropertyValue* pVal = maPController->getValue( aPropertyName );
|
2009-05-22 10:19:01 +00:00
|
|
|
if( pVal && pVal->Value.hasValue() )
|
|
|
|
pVal->Value >>= nCurVal;
|
|
|
|
pField->SetValue( nCurVal );
|
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
pField->Enable( maPController->isUIOptionEnabled( aPropertyName ) );
|
2009-05-22 10:19:01 +00:00
|
|
|
pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) );
|
|
|
|
pField->Show();
|
2009-05-22 07:04:13 +00:00
|
|
|
|
|
|
|
// set help id
|
2009-05-22 10:19:01 +00:00
|
|
|
setSmartId( pField, "NumericField", -1, aPropertyName );
|
|
|
|
// set help text
|
|
|
|
setHelpText( pField, aHelpTexts, 0 );
|
2009-05-22 07:04:13 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) );
|
|
|
|
maControlToPropertyMap[pField] = aPropertyName;
|
2009-05-22 07:04:13 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// add to row
|
2009-07-30 17:31:08 +00:00
|
|
|
if( pLabel )
|
|
|
|
pLabel->setElement( pField );
|
|
|
|
else
|
|
|
|
pFieldColumn->addWindow( pField );
|
2009-05-22 10:19:01 +00:00
|
|
|
}
|
|
|
|
else if( aCtrlType.equalsAscii( "Edit" ) )
|
|
|
|
{
|
|
|
|
Edit* pField = new Edit( pCurParent, WB_BORDER );
|
|
|
|
maControls.push_front( pField );
|
|
|
|
|
|
|
|
rtl::OUString aCurVal;
|
2009-07-06 10:54:21 +00:00
|
|
|
PropertyValue* pVal = maPController->getValue( aPropertyName );
|
2009-05-22 10:19:01 +00:00
|
|
|
if( pVal && pVal->Value.hasValue() )
|
|
|
|
pVal->Value >>= aCurVal;
|
|
|
|
pField->SetText( aCurVal );
|
2009-07-06 10:54:21 +00:00
|
|
|
pField->Enable( maPController->isUIOptionEnabled( aPropertyName ) );
|
2009-05-22 10:19:01 +00:00
|
|
|
pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) );
|
|
|
|
pField->Show();
|
2009-05-22 07:04:13 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// set help id
|
|
|
|
setSmartId( pField, "Edit", -1, aPropertyName );
|
|
|
|
// set help text
|
|
|
|
setHelpText( pField, aHelpTexts, 0 );
|
2009-05-22 07:04:13 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) );
|
|
|
|
maControlToPropertyMap[pField] = aPropertyName;
|
2009-05-22 07:04:13 +00:00
|
|
|
|
2009-05-22 10:19:01 +00:00
|
|
|
// add to row
|
2009-07-30 17:31:08 +00:00
|
|
|
if( pLabel )
|
|
|
|
pLabel->setElement( pField );
|
|
|
|
else
|
|
|
|
pFieldColumn->addWindow( pField, 2 );
|
2009-05-22 10:19:01 +00:00
|
|
|
}
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
2009-05-27 17:40:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ERROR( "Unsupported UI option" );
|
|
|
|
}
|
|
|
|
|
|
|
|
pCurColumn = pSaveCurColumn;
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-26 18:54:45 +00:00
|
|
|
|
2009-07-28 19:01:04 +00:00
|
|
|
// print range empty (currently math only) -> hide print range and spacer line
|
|
|
|
if( maJobPage.mxPrintRange->countElements() == 0 )
|
|
|
|
{
|
|
|
|
maJobPage.mxPrintRange->show( false, false );
|
|
|
|
maJobPage.maCopySpacer.Show( FALSE );
|
|
|
|
}
|
|
|
|
|
2009-08-07 12:32:48 +00:00
|
|
|
#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
|
|
|
|
// at some point. For now simply add some space at the lowest element
|
|
|
|
size_t nIndex = maJobPage.maLayout.countElements();
|
|
|
|
if( nIndex > 0 ) // sanity check
|
|
|
|
maJobPage.maLayout.setBorders( nIndex-1, 0, 0, 0, aBorder.Width() );
|
|
|
|
#endif
|
|
|
|
|
2009-05-22 10:06:06 +00:00
|
|
|
// calculate job page
|
2009-07-22 17:16:34 +00:00
|
|
|
Size aMaxSize = maJobPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED );
|
2009-08-03 15:51:37 +00:00
|
|
|
// and layout page
|
|
|
|
updateMaxSize( maNUpPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize );
|
|
|
|
// and options page
|
|
|
|
updateMaxSize( maOptionsPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize );
|
2009-05-22 10:06:06 +00:00
|
|
|
|
|
|
|
for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin();
|
|
|
|
it != aDynamicColumns.end(); ++it )
|
|
|
|
{
|
|
|
|
Size aPageSize( (*it)->getOptimalSize( WINDOWSIZE_PREFERRED ) );
|
2009-08-03 15:51:37 +00:00
|
|
|
updateMaxSize( aPageSize, aMaxSize );
|
2009-05-22 10:06:06 +00:00
|
|
|
}
|
2009-03-26 18:54:45 +00:00
|
|
|
|
|
|
|
// resize dialog if necessary
|
2009-05-22 10:06:06 +00:00
|
|
|
Size aTabSize = maTabCtrl.GetTabPageSizePixel();
|
2009-07-24 13:15:45 +00:00
|
|
|
maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() );
|
2009-05-22 10:06:06 +00:00
|
|
|
if( aMaxSize.Height() > aTabSize.Height() || aMaxSize.Width() > aTabSize.Width() )
|
2009-03-26 18:54:45 +00:00
|
|
|
{
|
2009-08-06 18:36:51 +00:00
|
|
|
Size aCurSize( GetOutputSizePixel() );
|
2009-05-22 10:06:06 +00:00
|
|
|
if( aMaxSize.Height() > aTabSize.Height() )
|
2009-08-06 18:36:51 +00:00
|
|
|
{
|
2009-05-22 10:06:06 +00:00
|
|
|
aCurSize.Height() += aMaxSize.Height() - aTabSize.Height();
|
2009-08-06 18:36:51 +00:00
|
|
|
aTabSize.Height() = aMaxSize.Height();
|
|
|
|
}
|
2009-05-22 10:06:06 +00:00
|
|
|
if( aMaxSize.Width() > aTabSize.Width() )
|
|
|
|
{
|
|
|
|
aCurSize.Width() += aMaxSize.Width() - aTabSize.Width();
|
|
|
|
// and the tab ctrl needs more space, too
|
|
|
|
aTabSize.Width() = aMaxSize.Width();
|
|
|
|
}
|
2009-08-06 18:36:51 +00:00
|
|
|
maTabCtrl.SetTabPageSizePixel( aTabSize );
|
|
|
|
maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() );
|
2009-03-26 18:54:45 +00:00
|
|
|
}
|
2009-05-22 10:06:06 +00:00
|
|
|
|
|
|
|
// and finally arrange controls
|
|
|
|
for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin();
|
|
|
|
it != aDynamicColumns.end(); ++it )
|
|
|
|
{
|
2009-08-01 12:23:00 +00:00
|
|
|
(*it)->setManagedArea( Rectangle( Point(), aTabSize ) );
|
2009-05-22 10:06:06 +00:00
|
|
|
delete *it;
|
|
|
|
*it = NULL;
|
|
|
|
}
|
2009-08-06 09:00:23 +00:00
|
|
|
maJobPage.Resize();
|
|
|
|
maNUpPage.Resize();
|
|
|
|
maOptionsPage.Resize();
|
2009-08-06 18:36:51 +00:00
|
|
|
|
|
|
|
Size aSz = maLayout.getOptimalSize( WINDOWSIZE_PREFERRED );
|
|
|
|
SetOutputSizePixel( aSz );
|
2008-10-30 14:31:29 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
void PrintDialog::checkControlDependencies()
|
|
|
|
{
|
|
|
|
if( maJobPage.maCopyCountField.GetValue() > 1 )
|
2009-07-16 12:41:37 +00:00
|
|
|
maJobPage.maCollateBox.Enable( maJobPage.mnCollateUIMode == 0 );
|
2008-10-01 18:22:22 +00:00
|
|
|
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;
|
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
// adjust size of image
|
2008-10-01 18:22:22 +00:00
|
|
|
maJobPage.maCollateImage.SetSizePixel( aImg.GetSizePixel() );
|
|
|
|
maJobPage.maCollateImage.SetImage( aImg );
|
|
|
|
|
|
|
|
// enable setup button only for printers that can be setup
|
2009-07-06 10:54:21 +00:00
|
|
|
bool bHaveSetup = maPController->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG );
|
2009-06-03 18:51:46 +00:00
|
|
|
maJobPage.maSetupButton.Enable( bHaveSetup );
|
|
|
|
if( bHaveSetup )
|
|
|
|
{
|
|
|
|
if( ! maJobPage.maSetupButton.IsVisible() )
|
|
|
|
{
|
|
|
|
Point aPrinterPos( maJobPage.maPrinters.GetPosPixel() );
|
|
|
|
Point aSetupPos( maJobPage.maSetupButton.GetPosPixel() );
|
|
|
|
Size aPrinterSize( maJobPage.maPrinters.GetSizePixel() );
|
|
|
|
aPrinterSize.Width() = aSetupPos.X() - aPrinterPos.X() - LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ).Width();
|
|
|
|
maJobPage.maPrinters.SetSizePixel( aPrinterSize );
|
|
|
|
maJobPage.maSetupButton.Show();
|
2009-07-27 18:42:13 +00:00
|
|
|
maLayout.resize();
|
2009-06-03 18:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( maJobPage.maSetupButton.IsVisible() )
|
|
|
|
{
|
|
|
|
Point aPrinterPos( maJobPage.maPrinters.GetPosPixel() );
|
|
|
|
Point aSetupPos( maJobPage.maSetupButton.GetPosPixel() );
|
|
|
|
Size aPrinterSize( maJobPage.maPrinters.GetSizePixel() );
|
|
|
|
Size aSetupSize( maJobPage.maSetupButton.GetSizePixel() );
|
|
|
|
aPrinterSize.Width() = aSetupPos.X() + aSetupSize.Width() - aPrinterPos.X();
|
|
|
|
maJobPage.maPrinters.SetSizePixel( aPrinterSize );
|
|
|
|
maJobPage.maSetupButton.Hide();
|
2009-07-27 18:42:13 +00:00
|
|
|
maLayout.resize();
|
2009-06-03 18:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
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 )
|
|
|
|
{
|
2009-07-06 10:54:21 +00:00
|
|
|
bool bShouldbeEnabled = maPController->isUIOptionEnabled( it->second );
|
2009-03-16 15:13:59 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* i_pRepl, sal_Int32 i_nReplLen, const rtl::OUString& i_rRepl )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
|
|
|
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 );
|
2009-06-03 18:51:46 +00:00
|
|
|
aBuf.append( i_rRepl );
|
2008-10-01 18:22:22 +00:00
|
|
|
if( nPos + i_nReplLen < i_rOrig.getLength() )
|
|
|
|
aBuf.append( i_rOrig.getStr() + nPos + i_nReplLen );
|
|
|
|
return aBuf.makeStringAndClear();
|
|
|
|
}
|
|
|
|
return i_rOrig;
|
|
|
|
}
|
|
|
|
|
2009-06-03 18:51:46 +00:00
|
|
|
void PrintDialog::updatePrinterText()
|
|
|
|
{
|
|
|
|
const QueueInfo* pInfo = Printer::GetQueueInfo( maJobPage.maPrinters.GetSelectEntry(), true );
|
|
|
|
if( pInfo )
|
|
|
|
{
|
2009-07-22 17:16:34 +00:00
|
|
|
maJobPage.maLocationTxt.SetText( pInfo->GetLocation() );
|
|
|
|
maJobPage.maCommentTxt.SetText( pInfo->GetComment() );
|
|
|
|
// FIXME: status text
|
|
|
|
maJobPage.maStatusTxt.SetText( String() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maJobPage.maLocationTxt.SetText( String() );
|
|
|
|
maJobPage.maCommentTxt.SetText( String() );
|
|
|
|
maJobPage.maStatusTxt.SetText( String() );
|
2009-06-03 18:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-03 19:22:35 +00:00
|
|
|
void PrintDialog::setPreviewText( sal_Int32 )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-08-11 15:50:07 +00:00
|
|
|
rtl::OUString aNewText( searchAndReplace( maPageStr, "%n", 2, rtl::OUString::valueOf( mnCachedPages ) ) );
|
|
|
|
maNumPagesText.SetText( aNewText );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
2009-06-10 17:21:10 +00:00
|
|
|
void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
|
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-07-06 10:54:21 +00:00
|
|
|
sal_Int32 nPages = maPController->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-06-03 18:51:46 +00:00
|
|
|
maPageEdit.SetMin( 1 );
|
|
|
|
maPageEdit.SetMax( nPages );
|
2008-10-01 18:22:22 +00:00
|
|
|
|
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 )
|
2009-08-12 16:37:34 +00:00
|
|
|
maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache );
|
2009-04-24 09:43:48 +00:00
|
|
|
|
2009-08-12 16:37:34 +00:00
|
|
|
boost::shared_ptr<Printer> aPrt( maPController->getPrinter() );
|
|
|
|
Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) );
|
2009-08-13 15:10:43 +00:00
|
|
|
maPreviewWindow.setPreview( aMtf, aCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr,
|
|
|
|
aPrt->ImplGetDPIX(), aPrt->ImplGetDPIY()
|
|
|
|
);
|
2009-08-10 18:44:52 +00:00
|
|
|
|
|
|
|
maForwardBtn.Enable( mnCurPage < nPages-1 );
|
|
|
|
maBackwardBtn.Enable( mnCurPage != 0 );
|
|
|
|
maPageEdit.Enable( nPages > 1 );
|
2008-10-01 18:22:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-27 17:10:15 +00:00
|
|
|
Size PrintDialog::getJobPageSize()
|
|
|
|
{
|
|
|
|
if( maFirstPageSize.Width() == 0 && maFirstPageSize.Height() == 0)
|
|
|
|
{
|
|
|
|
maFirstPageSize = maNupPortraitSize;
|
|
|
|
GDIMetaFile aMtf;
|
2009-08-10 16:48:53 +00:00
|
|
|
if( maPController->getPageCountProtected() > 0 )
|
2009-08-17 17:34:09 +00:00
|
|
|
{
|
|
|
|
PrinterController::PageSize aPageSize = maPController->getPageFile( 0, aMtf, true );
|
|
|
|
maFirstPageSize = aPageSize.aSize;
|
|
|
|
}
|
2009-07-27 17:10:15 +00:00
|
|
|
}
|
|
|
|
return maFirstPageSize;
|
|
|
|
}
|
|
|
|
|
2009-08-03 11:26:33 +00:00
|
|
|
void PrintDialog::updateNupFromPages()
|
|
|
|
{
|
|
|
|
long nPages = long(maNUpPage.maNupPagesBox.GetEntryData(maNUpPage.maNupPagesBox.GetSelectEntryPos()));
|
|
|
|
int nRows = int(maNUpPage.maNupRowsEdt.GetValue());
|
|
|
|
int nCols = int(maNUpPage.maNupColEdt.GetValue());
|
|
|
|
long nPageMargin = long(maNUpPage.maPageMarginEdt.Denormalize(maNUpPage.maPageMarginEdt.GetValue( FUNIT_100TH_MM )));
|
|
|
|
long nSheetMargin = long(maNUpPage.maSheetMarginEdt.Denormalize(maNUpPage.maSheetMarginEdt.GetValue( FUNIT_100TH_MM )));
|
|
|
|
bool bCustom = false;
|
|
|
|
|
|
|
|
if( nPages == 1 )
|
|
|
|
{
|
|
|
|
nRows = nCols = 1;
|
|
|
|
nSheetMargin = 0;
|
|
|
|
}
|
|
|
|
else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 )
|
|
|
|
{
|
|
|
|
Size aJobPageSize( getJobPageSize() );
|
|
|
|
bool bPortrait = aJobPageSize.Width() < aJobPageSize.Height();
|
|
|
|
if( nPages == 2 )
|
|
|
|
{
|
|
|
|
if( bPortrait )
|
|
|
|
nRows = 1, nCols = 2;
|
|
|
|
else
|
|
|
|
nRows = 2, nCols = 1;
|
|
|
|
}
|
|
|
|
else if( nPages == 4 )
|
|
|
|
nRows = nCols = 2;
|
|
|
|
else if( nPages == 6 )
|
|
|
|
{
|
|
|
|
if( bPortrait )
|
|
|
|
nRows = 2, nCols = 3;
|
|
|
|
else
|
|
|
|
nRows = 3, nCols = 2;
|
|
|
|
}
|
|
|
|
else if( nPages == 9 )
|
|
|
|
nRows = nCols = 3;
|
|
|
|
else if( nPages == 16 )
|
|
|
|
nRows = nCols = 4;
|
2009-08-25 08:52:05 +00:00
|
|
|
nPageMargin = 0;
|
|
|
|
nSheetMargin = 0;
|
2009-08-03 11:26:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
bCustom = true;
|
|
|
|
|
|
|
|
maNUpPage.maNupRowsEdt.SetValue( nRows );
|
|
|
|
maNUpPage.maNupColEdt.SetValue( nCols );
|
|
|
|
maNUpPage.maPageMarginEdt.SetValue( maNUpPage.maPageMarginEdt.Normalize( nPageMargin ), FUNIT_100TH_MM );
|
|
|
|
maNUpPage.maSheetMarginEdt.SetValue( maNUpPage.maSheetMarginEdt.Normalize( nSheetMargin ), FUNIT_100TH_MM );
|
|
|
|
|
2009-08-10 16:48:53 +00:00
|
|
|
maNUpPage.showAdvancedControls( bCustom );
|
2009-08-03 15:51:37 +00:00
|
|
|
if( bCustom )
|
|
|
|
{
|
|
|
|
// see if we have to enlarge the dialog to make the tab page fit
|
|
|
|
Size aCurSize( maNUpPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ) );
|
|
|
|
Size aTabSize( maTabCtrl.GetTabPageSizePixel() );
|
|
|
|
if( aTabSize.Height() < aCurSize.Height() )
|
|
|
|
{
|
|
|
|
Size aDlgSize( GetSizePixel() );
|
|
|
|
aDlgSize.Height() += aCurSize.Height() - aTabSize.Height();
|
|
|
|
SetSizePixel( aDlgSize );
|
|
|
|
}
|
|
|
|
}
|
2009-08-03 11:26:33 +00:00
|
|
|
|
|
|
|
updateNup();
|
|
|
|
}
|
|
|
|
|
2009-03-28 08:52:14 +00:00
|
|
|
void PrintDialog::updateNup()
|
|
|
|
{
|
2009-07-27 17:10:15 +00:00
|
|
|
int nRows = int(maNUpPage.maNupRowsEdt.GetValue());
|
|
|
|
int nCols = int(maNUpPage.maNupColEdt.GetValue());
|
|
|
|
long nPageMargin = long(maNUpPage.maPageMarginEdt.Denormalize(maNUpPage.maPageMarginEdt.GetValue( FUNIT_100TH_MM )));
|
|
|
|
long nSheetMargin = long(maNUpPage.maSheetMarginEdt.Denormalize(maNUpPage.maSheetMarginEdt.GetValue( FUNIT_100TH_MM )));
|
2009-03-28 08:52:14 +00:00
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
PrinterController::MultiPageSetup aMPS;
|
2009-06-09 18:58:38 +00:00
|
|
|
aMPS.nRows = nRows;
|
|
|
|
aMPS.nColumns = nCols;
|
2009-07-27 17:10:15 +00:00
|
|
|
aMPS.nRepeat = 1;
|
|
|
|
aMPS.nLeftMargin =
|
|
|
|
aMPS.nTopMargin =
|
|
|
|
aMPS.nRightMargin =
|
|
|
|
aMPS.nBottomMargin = nSheetMargin;
|
2009-06-09 18:58:38 +00:00
|
|
|
|
2009-07-27 17:10:15 +00:00
|
|
|
aMPS.nHorizontalSpacing =
|
|
|
|
aMPS.nVerticalSpacing = nPageMargin;
|
2009-06-09 18:58:38 +00:00
|
|
|
|
|
|
|
aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked();
|
|
|
|
|
2009-08-01 07:34:21 +00:00
|
|
|
int nOrderMode = int(sal_IntPtr(maNUpPage.maNupOrderBox.GetEntryData(
|
|
|
|
maNUpPage.maNupOrderBox.GetSelectEntryPos() )));
|
2009-07-30 13:52:50 +00:00
|
|
|
if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTD )
|
|
|
|
aMPS.nOrder = PrinterController::LRTB;
|
|
|
|
else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TDLR )
|
|
|
|
aMPS.nOrder = PrinterController::TBLR;
|
|
|
|
|
2009-08-01 07:34:21 +00:00
|
|
|
int nOrientationMode = int(sal_IntPtr(maNUpPage.maNupOrientationBox.GetEntryData(
|
|
|
|
maNUpPage.maNupOrientationBox.GetSelectEntryPos() )));
|
2009-07-27 17:10:15 +00:00
|
|
|
if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE )
|
|
|
|
aMPS.aPaperSize = maNupLandscapeSize;
|
|
|
|
else if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT )
|
|
|
|
aMPS.aPaperSize = maNupPortraitSize;
|
|
|
|
else // automatic mode
|
|
|
|
{
|
|
|
|
// get size of first real page to see if it is portrait or landscape
|
|
|
|
// we assume same page sizes for all the pages for this
|
|
|
|
Size aPageSize = getJobPageSize();
|
|
|
|
|
|
|
|
Size aMultiSize( aPageSize.Width() * nCols, aPageSize.Height() * nRows );
|
|
|
|
if( aMultiSize.Width() > aMultiSize.Height() ) // fits better on landscape
|
|
|
|
aMPS.aPaperSize = maNupLandscapeSize;
|
|
|
|
else
|
|
|
|
aMPS.aPaperSize = maNupPortraitSize;
|
|
|
|
}
|
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
maPController->setMultipage( aMPS );
|
2009-03-28 08:52:14 +00:00
|
|
|
|
2009-07-30 13:52:50 +00:00
|
|
|
maNUpPage.maNupOrderWin.setValues( nOrderMode, nCols, nRows );
|
|
|
|
|
2009-06-10 17:21:10 +00:00
|
|
|
preparePreview( true, true );
|
2009-03-28 08:52:14 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox )
|
|
|
|
{
|
2009-06-03 18:51:46 +00:00
|
|
|
if( pBox == &maJobPage.maPrinters )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-03-16 18:11:54 +00:00
|
|
|
String aNewPrinter( pBox->GetSelectEntry() );
|
2008-10-01 18:22:22 +00:00
|
|
|
// set new printer
|
2009-07-06 10:54:21 +00:00
|
|
|
maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( aNewPrinter ) ) );
|
2008-10-01 18:22:22 +00:00
|
|
|
// update text fields
|
|
|
|
updatePrinterText();
|
|
|
|
}
|
2009-07-30 13:52:50 +00:00
|
|
|
else if( pBox == &maNUpPage.maNupOrientationBox || pBox == &maNUpPage.maNupOrderBox )
|
2009-07-27 17:10:15 +00:00
|
|
|
{
|
|
|
|
updateNup();
|
|
|
|
}
|
|
|
|
else if( pBox == &maNUpPage.maNupPagesBox )
|
|
|
|
{
|
2009-08-03 11:26:33 +00:00
|
|
|
updateNupFromPages();
|
2009-07-27 17:10:15 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton )
|
|
|
|
{
|
2009-06-02 11:37:36 +00:00
|
|
|
if( pButton == &maOKButton || pButton == &maCancelButton )
|
2008-10-01 18:22:22 +00:00
|
|
|
{
|
2009-06-02 11:37:36 +00:00
|
|
|
storeToSettings();
|
|
|
|
EndDialog( pButton == &maOKButton );
|
|
|
|
}
|
2009-08-03 15:51:37 +00:00
|
|
|
else if( pButton == &maHelpButton )
|
|
|
|
{
|
|
|
|
// start help system
|
|
|
|
Help* pHelp = Application::GetHelp();
|
|
|
|
if( pHelp )
|
|
|
|
{
|
|
|
|
// FIXME: find out proper help URL and use here
|
2009-08-17 15:41:35 +00:00
|
|
|
pHelp->Start( HID_PRINTDLG, GetParent() );
|
2009-08-03 15:51:37 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-03 18:51:46 +00:00
|
|
|
else if( pButton == &maForwardBtn )
|
|
|
|
{
|
2009-07-16 08:50:32 +00:00
|
|
|
previewForward();
|
2009-06-03 18:51:46 +00:00
|
|
|
}
|
|
|
|
else if( pButton == &maBackwardBtn )
|
|
|
|
{
|
2009-07-16 08:50:32 +00:00
|
|
|
previewBackward();
|
2009-06-03 18:51:46 +00:00
|
|
|
}
|
2009-07-24 13:15:45 +00:00
|
|
|
else if( pButton == &maOptionsPage.maToFileBox )
|
|
|
|
{
|
|
|
|
maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText );
|
|
|
|
maLayout.resize();
|
|
|
|
}
|
2009-08-01 15:16:11 +00:00
|
|
|
else if( pButton == &maNUpPage.maBrochureBtn )
|
|
|
|
{
|
|
|
|
PropertyValue* pVal = getValueForWindow( pButton );
|
|
|
|
if( pVal )
|
|
|
|
{
|
|
|
|
sal_Bool bVal = maNUpPage.maBrochureBtn.IsChecked();
|
|
|
|
pVal->Value <<= bVal;
|
|
|
|
|
|
|
|
checkOptionalControlDependencies();
|
|
|
|
|
|
|
|
// update preview and page settings
|
|
|
|
preparePreview();
|
|
|
|
}
|
|
|
|
if( maNUpPage.maBrochureBtn.IsChecked() )
|
2009-08-03 11:26:33 +00:00
|
|
|
{
|
|
|
|
maNUpPage.maNupPagesBox.SelectEntryPos( 0 );
|
|
|
|
updateNupFromPages();
|
2009-08-10 16:48:53 +00:00
|
|
|
maNUpPage.showAdvancedControls( false );
|
2009-08-01 15:16:11 +00:00
|
|
|
maNUpPage.enableNupControls( false );
|
2009-08-03 11:26:33 +00:00
|
|
|
}
|
2009-08-01 15:16:11 +00:00
|
|
|
}
|
|
|
|
else if( pButton == &maNUpPage.maPagesBtn )
|
|
|
|
{
|
|
|
|
maNUpPage.enableNupControls( true );
|
2009-08-03 11:26:33 +00:00
|
|
|
updateNupFromPages();
|
2009-08-01 15:16:11 +00:00
|
|
|
}
|
2009-07-27 18:42:13 +00:00
|
|
|
else if( pButton == &maJobPage.maDetailsBtn )
|
|
|
|
{
|
|
|
|
bool bShow = ! maJobPage.maStatusTxt.IsVisible();
|
|
|
|
maJobPage.maDetailsBtn.SetSymbol( bShow ? SYMBOL_SPIN_UP : SYMBOL_SPIN_DOWN );
|
|
|
|
maJobPage.mxDetails->show( bShow );
|
2009-07-29 11:48:58 +00:00
|
|
|
// enlarge dialog if necessary
|
|
|
|
Size aMinSize( maJobPage.maLayout.getOptimalSize( WINDOWSIZE_MINIMUM ) );
|
|
|
|
Size aCurSize( maJobPage.GetSizePixel() );
|
|
|
|
if( aCurSize.Height() < aMinSize.Height() )
|
|
|
|
{
|
|
|
|
Size aDlgSize( GetOutputSizePixel() );
|
|
|
|
aDlgSize.Height() += aMinSize.Height() - aCurSize.Height();
|
|
|
|
SetOutputSizePixel( aDlgSize );
|
|
|
|
}
|
2009-07-27 18:42:13 +00:00
|
|
|
}
|
2009-07-16 11:37:53 +00:00
|
|
|
else if( pButton == &maJobPage.maCollateBox )
|
|
|
|
{
|
|
|
|
maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ),
|
|
|
|
makeAny( sal_Bool(isCollate()) ) );
|
2009-07-22 17:16:34 +00:00
|
|
|
checkControlDependencies();
|
2009-07-16 11:37:53 +00:00
|
|
|
}
|
2009-07-30 15:11:07 +00:00
|
|
|
else if( pButton == &maOptionsPage.maReverseOrderBox )
|
|
|
|
{
|
|
|
|
sal_Bool bChecked = maOptionsPage.maReverseOrderBox.IsChecked();
|
|
|
|
maPController->setReversePrint( bChecked );
|
|
|
|
maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverse" ) ),
|
|
|
|
makeAny( bChecked ) );
|
|
|
|
preparePreview( true, true );
|
|
|
|
}
|
2009-08-07 14:27:26 +00:00
|
|
|
else if( pButton == &maNUpPage.maBorderCB )
|
|
|
|
{
|
|
|
|
updateNup();
|
|
|
|
}
|
2009-06-02 11:37:36 +00:00
|
|
|
else
|
|
|
|
{
|
2009-06-03 18:51:46 +00:00
|
|
|
if( pButton == &maJobPage.maSetupButton )
|
2009-06-02 11:37:36 +00:00
|
|
|
{
|
2009-08-07 14:27:26 +00:00
|
|
|
maPController->setupPrinter( this );
|
|
|
|
preparePreview( true, true );
|
2009-06-02 11:37:36 +00:00
|
|
|
}
|
|
|
|
checkControlDependencies();
|
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-07-27 17:10:15 +00:00
|
|
|
if( pEdit == &maNUpPage.maNupRowsEdt || pEdit == &maNUpPage.maNupColEdt ||
|
|
|
|
pEdit == &maNUpPage.maSheetMarginEdt || pEdit == &maNUpPage.maPageMarginEdt
|
2009-06-09 18:58:38 +00:00
|
|
|
)
|
2009-03-28 08:52:14 +00:00
|
|
|
{
|
|
|
|
updateNup();
|
|
|
|
}
|
2009-06-03 18:51:46 +00:00
|
|
|
else if( pEdit == &maPageEdit )
|
|
|
|
{
|
|
|
|
mnCurPage = sal_Int32( maPageEdit.GetValue() - 1 );
|
2009-06-10 17:21:10 +00:00
|
|
|
preparePreview( true, true );
|
2009-06-03 18:51:46 +00:00
|
|
|
}
|
2009-06-24 17:37:07 +00:00
|
|
|
else if( pEdit == &maJobPage.maCopyCountField )
|
|
|
|
{
|
2009-07-06 10:54:21 +00:00
|
|
|
maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ),
|
2009-06-24 17:37:07 +00:00
|
|
|
makeAny( sal_Int32(maJobPage.maCopyCountField.GetValue()) ) );
|
2009-07-16 11:37:53 +00:00
|
|
|
maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ),
|
|
|
|
makeAny( sal_Bool(isCollate()) ) );
|
2009-06-24 17:37:07 +00:00
|
|
|
}
|
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() )
|
|
|
|
{
|
2009-07-06 10:54:21 +00:00
|
|
|
pVal = maPController->getValue( it->second );
|
2008-11-05 14:54:11 +00:00
|
|
|
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-07-16 08:50:32 +00:00
|
|
|
void PrintDialog::Command( const CommandEvent& rEvt )
|
|
|
|
{
|
|
|
|
if( rEvt.GetCommand() == COMMAND_WHEEL )
|
|
|
|
{
|
|
|
|
const CommandWheelData* pWheelData = rEvt.GetWheelData();
|
|
|
|
if( pWheelData->GetDelta() > 0 )
|
|
|
|
previewForward();
|
|
|
|
else if( pWheelData->GetDelta() < 0 )
|
|
|
|
previewBackward();
|
|
|
|
/*
|
|
|
|
else
|
|
|
|
huh ?
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-17 12:27:26 +00:00
|
|
|
void PrintDialog::Resize()
|
|
|
|
{
|
2009-07-24 13:15:45 +00:00
|
|
|
maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
|
2009-06-08 12:43:56 +00:00
|
|
|
// and do the preview; however the metafile does not need to be gotten anew
|
|
|
|
preparePreview( false );
|
|
|
|
|
2009-07-14 13:26:46 +00:00
|
|
|
// do an invalidate for the benefit of the grouping elements
|
|
|
|
Invalidate();
|
2009-03-17 12:27:26 +00:00
|
|
|
}
|
2009-03-18 14:46:10 +00:00
|
|
|
|
2009-07-16 08:50:32 +00:00
|
|
|
void PrintDialog::previewForward()
|
|
|
|
{
|
|
|
|
maPageEdit.Up();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintDialog::previewBackward()
|
|
|
|
{
|
|
|
|
maPageEdit.Down();
|
|
|
|
}
|
|
|
|
|
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-06-03 18:51:46 +00:00
|
|
|
rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, rtl::OUString::valueOf( mnCur ) ) );
|
|
|
|
aNewText = searchAndReplace( aNewText, "%n", 2, rtl::OUString::valueOf( mnMax ) );
|
2009-03-18 14:46:10 +00:00
|
|
|
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
|
|
|
}
|
2009-07-16 08:50:32 +00:00
|
|
|
|