1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_vcl.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "printdlg.hxx" 27cdf0e10cSrcweir #include "svdata.hxx" 28cdf0e10cSrcweir #include "svids.hrc" 29cdf0e10cSrcweir #include "jobset.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "vcl/print.hxx" 32cdf0e10cSrcweir #include "vcl/dialog.hxx" 33cdf0e10cSrcweir #include "vcl/button.hxx" 34cdf0e10cSrcweir #include "vcl/wall.hxx" 35cdf0e10cSrcweir #include "vcl/status.hxx" 36cdf0e10cSrcweir #include "vcl/decoview.hxx" 37cdf0e10cSrcweir #include "vcl/arrange.hxx" 38cdf0e10cSrcweir #include "vcl/configsettings.hxx" 39cdf0e10cSrcweir #include "vcl/help.hxx" 40cdf0e10cSrcweir #include "vcl/decoview.hxx" 41cdf0e10cSrcweir #include "vcl/svapp.hxx" 42cdf0e10cSrcweir #include "vcl/unohelp.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include "unotools/localedatawrapper.hxx" 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include "rtl/strbuf.hxx" 47cdf0e10cSrcweir 48cdf0e10cSrcweir #include "com/sun/star/lang/XMultiServiceFactory.hpp" 49cdf0e10cSrcweir #include "com/sun/star/container/XNameAccess.hpp" 50cdf0e10cSrcweir #include "com/sun/star/beans/PropertyValue.hpp" 51cdf0e10cSrcweir #include "com/sun/star/awt/Size.hpp" 52cdf0e10cSrcweir 53cdf0e10cSrcweir using namespace vcl; 54cdf0e10cSrcweir using namespace com::sun::star; 55cdf0e10cSrcweir using namespace com::sun::star::uno; 56cdf0e10cSrcweir using namespace com::sun::star::lang; 57cdf0e10cSrcweir using namespace com::sun::star::container; 58cdf0e10cSrcweir using namespace com::sun::star::beans; 59cdf0e10cSrcweir 60cdf0e10cSrcweir PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) 61cdf0e10cSrcweir : Window( i_pParent, i_rId ) 62cdf0e10cSrcweir , maOrigSize( 10, 10 ) 63cdf0e10cSrcweir , maPageVDev( *this ) 64cdf0e10cSrcweir , maToolTipString( String( VclResId( SV_PRINT_PRINTPREVIEW_TXT ) ) ) 65cdf0e10cSrcweir , mbGreyscale( false ) 66cdf0e10cSrcweir , maHorzDim( this, WB_HORZ | WB_CENTER ) 67cdf0e10cSrcweir , maVertDim( this, WB_VERT | WB_VCENTER ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir SetPaintTransparent( sal_True ); 70cdf0e10cSrcweir SetBackground(); 71cdf0e10cSrcweir if( useHCColorReplacement() ) 72cdf0e10cSrcweir maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); 73cdf0e10cSrcweir else 74cdf0e10cSrcweir maPageVDev.SetBackground( Color( COL_WHITE ) ); 75cdf0e10cSrcweir maHorzDim.Show(); 76cdf0e10cSrcweir maVertDim.Show(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir maHorzDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) ); 79cdf0e10cSrcweir maVertDim.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "2.0in" ) ) ); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() 83cdf0e10cSrcweir { 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir bool PrintDialog::PrintPreviewWindow::useHCColorReplacement() const 87cdf0e10cSrcweir { 88cdf0e10cSrcweir bool bRet = false; 89cdf0e10cSrcweir if( GetSettings().GetStyleSettings().GetHighContrastMode() ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir try 92cdf0e10cSrcweir { 93cdf0e10cSrcweir // get service provider 94cdf0e10cSrcweir Reference< XMultiServiceFactory > xSMgr( unohelper::GetMultiServiceFactory() ); 95cdf0e10cSrcweir // create configuration hierachical access name 96cdf0e10cSrcweir if( xSMgr.is() ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir try 99cdf0e10cSrcweir { 100cdf0e10cSrcweir Reference< XMultiServiceFactory > xConfigProvider( 101cdf0e10cSrcweir Reference< XMultiServiceFactory >( 102cdf0e10cSrcweir xSMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 103cdf0e10cSrcweir "com.sun.star.configuration.ConfigurationProvider" ))), 104cdf0e10cSrcweir UNO_QUERY ) 105cdf0e10cSrcweir ); 106cdf0e10cSrcweir if( xConfigProvider.is() ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir Sequence< Any > aArgs(1); 109cdf0e10cSrcweir PropertyValue aVal; 110cdf0e10cSrcweir aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); 111cdf0e10cSrcweir aVal.Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Accessibility" ) ); 112cdf0e10cSrcweir aArgs.getArray()[0] <<= aVal; 113cdf0e10cSrcweir Reference< XNameAccess > xConfigAccess( 114cdf0e10cSrcweir Reference< XNameAccess >( 115cdf0e10cSrcweir xConfigProvider->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 116cdf0e10cSrcweir "com.sun.star.configuration.ConfigurationAccess" )), 117cdf0e10cSrcweir aArgs ), 118cdf0e10cSrcweir UNO_QUERY ) 119cdf0e10cSrcweir ); 120cdf0e10cSrcweir if( xConfigAccess.is() ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir try 123cdf0e10cSrcweir { 124cdf0e10cSrcweir sal_Bool bValue = sal_False; 125cdf0e10cSrcweir Any aAny = xConfigAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsForPagePreviews" ) ) ); 126cdf0e10cSrcweir if( aAny >>= bValue ) 127cdf0e10cSrcweir bRet = bool(bValue); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir catch( NoSuchElementException& ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir } 132cdf0e10cSrcweir catch( WrappedTargetException& ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir } 135cdf0e10cSrcweir } 136cdf0e10cSrcweir } 137cdf0e10cSrcweir } 138cdf0e10cSrcweir catch( Exception& ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir } 141cdf0e10cSrcweir } 142cdf0e10cSrcweir } 143cdf0e10cSrcweir catch( WrappedTargetException& ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir return bRet; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDCEvt ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir // react on settings changed 153cdf0e10cSrcweir if( i_rDCEvt.GetType() == DATACHANGED_SETTINGS ) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir if( useHCColorReplacement() ) 156cdf0e10cSrcweir maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); 157cdf0e10cSrcweir else 158cdf0e10cSrcweir maPageVDev.SetBackground( Color( COL_WHITE ) ); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir Window::DataChanged( i_rDCEvt ); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir void PrintDialog::PrintPreviewWindow::Resize() 164cdf0e10cSrcweir { 165cdf0e10cSrcweir Size aNewSize( GetSizePixel() ); 166cdf0e10cSrcweir long nTextHeight = maHorzDim.GetTextHeight(); 167cdf0e10cSrcweir // leave small space for decoration 168cdf0e10cSrcweir aNewSize.Width() -= nTextHeight + 2; 169cdf0e10cSrcweir aNewSize.Height() -= nTextHeight + 2; 170cdf0e10cSrcweir Size aScaledSize; 171cdf0e10cSrcweir double fScale = 1.0; 172cdf0e10cSrcweir 173cdf0e10cSrcweir // #i106435# catch corner case of Size(0,0) 174cdf0e10cSrcweir Size aOrigSize( maOrigSize ); 175cdf0e10cSrcweir if( aOrigSize.Width() < 1 ) 176cdf0e10cSrcweir aOrigSize.Width() = aNewSize.Width(); 177cdf0e10cSrcweir if( aOrigSize.Height() < 1 ) 178cdf0e10cSrcweir aOrigSize.Height() = aNewSize.Height(); 179cdf0e10cSrcweir if( aOrigSize.Width() > aOrigSize.Height() ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * aOrigSize.Height() / aOrigSize.Width() ); 182cdf0e10cSrcweir if( aScaledSize.Height() > aNewSize.Height() ) 183cdf0e10cSrcweir fScale = double(aNewSize.Height())/double(aScaledSize.Height()); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir else 186cdf0e10cSrcweir { 187cdf0e10cSrcweir aScaledSize = Size( aNewSize.Height() * aOrigSize.Width() / aOrigSize.Height(), aNewSize.Height() ); 188cdf0e10cSrcweir if( aScaledSize.Width() > aNewSize.Width() ) 189cdf0e10cSrcweir fScale = double(aNewSize.Width())/double(aScaledSize.Width()); 190cdf0e10cSrcweir } 191cdf0e10cSrcweir aScaledSize.Width() = long(aScaledSize.Width()*fScale); 192cdf0e10cSrcweir aScaledSize.Height() = long(aScaledSize.Height()*fScale); 193cdf0e10cSrcweir 194cdf0e10cSrcweir maPreviewSize = aScaledSize; 195cdf0e10cSrcweir 196cdf0e10cSrcweir // #i104784# if we render the page too small then rounding issues result in 197cdf0e10cSrcweir // layout artifacts looking really bad. So scale the page unto a device that is not 198cdf0e10cSrcweir // full page size but not too small either. This also results in much better visual 199cdf0e10cSrcweir // quality of the preview, e.g. when its height approaches the number of text lines 200cdf0e10cSrcweir // find a good scaling factor 201cdf0e10cSrcweir Size aPreviewMMSize( maPageVDev.PixelToLogic( aScaledSize, MapMode( MAP_100TH_MM ) ) ); 202cdf0e10cSrcweir double fZoom = double(maOrigSize.Height())/double(aPreviewMMSize.Height()); 203cdf0e10cSrcweir while( fZoom > 10 ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir aScaledSize.Width() *= 2; 206cdf0e10cSrcweir aScaledSize.Height() *= 2; 207cdf0e10cSrcweir fZoom /= 2.0; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir maPageVDev.SetOutputSizePixel( aScaledSize, sal_False ); 211cdf0e10cSrcweir 212cdf0e10cSrcweir // position dimension lines 213cdf0e10cSrcweir Point aRef( nTextHeight + (aNewSize.Width() - maPreviewSize.Width())/2, 214cdf0e10cSrcweir nTextHeight + (aNewSize.Height() - maPreviewSize.Height())/2 ); 215cdf0e10cSrcweir maHorzDim.SetPosSizePixel( Point( aRef.X(), aRef.Y() - nTextHeight ), 216cdf0e10cSrcweir Size( maPreviewSize.Width(), nTextHeight ) ); 217cdf0e10cSrcweir maVertDim.SetPosSizePixel( Point( aRef.X() - nTextHeight, aRef.Y() ), 218cdf0e10cSrcweir Size( nTextHeight, maPreviewSize.Height() ) ); 219cdf0e10cSrcweir 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir long nTextHeight = maHorzDim.GetTextHeight(); 225cdf0e10cSrcweir Size aSize( GetSizePixel() ); 226cdf0e10cSrcweir aSize.Width() -= nTextHeight; 227cdf0e10cSrcweir aSize.Height() -= nTextHeight; 228cdf0e10cSrcweir if( maReplacementString.getLength() != 0 ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir // replacement is active 231cdf0e10cSrcweir Push(); 232cdf0e10cSrcweir Rectangle aTextRect( Point( nTextHeight, nTextHeight ), aSize ); 233cdf0e10cSrcweir DecorationView aVw( this ); 234cdf0e10cSrcweir aVw.DrawFrame( aTextRect, FRAME_DRAW_GROUP ); 235cdf0e10cSrcweir aTextRect.Left() += 2; 236cdf0e10cSrcweir aTextRect.Top() += 2; 237cdf0e10cSrcweir aTextRect.Right() -= 2; 238cdf0e10cSrcweir aTextRect.Bottom() -= 2; 239cdf0e10cSrcweir Font aFont( GetSettings().GetStyleSettings().GetLabelFont() ); 240cdf0e10cSrcweir SetZoomedPointFont( aFont ); 241cdf0e10cSrcweir DrawText( aTextRect, maReplacementString, 242cdf0e10cSrcweir TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE 243cdf0e10cSrcweir ); 244cdf0e10cSrcweir Pop(); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir else 247cdf0e10cSrcweir { 248cdf0e10cSrcweir GDIMetaFile aMtf( maMtf ); 249cdf0e10cSrcweir 250cdf0e10cSrcweir Point aOffset( (aSize.Width() - maPreviewSize.Width()) / 2 + nTextHeight, 251cdf0e10cSrcweir (aSize.Height() - maPreviewSize.Height()) / 2 + nTextHeight ); 252cdf0e10cSrcweir 253cdf0e10cSrcweir Size aVDevSize( maPageVDev.GetOutputSizePixel() ); 254cdf0e10cSrcweir const Size aLogicSize( maPageVDev.PixelToLogic( aVDevSize, MapMode( MAP_100TH_MM ) ) ); 255cdf0e10cSrcweir Size aOrigSize( maOrigSize ); 256cdf0e10cSrcweir if( aOrigSize.Width() < 1 ) 257cdf0e10cSrcweir aOrigSize.Width() = aLogicSize.Width(); 258cdf0e10cSrcweir if( aOrigSize.Height() < 1 ) 259cdf0e10cSrcweir aOrigSize.Height() = aLogicSize.Height(); 260cdf0e10cSrcweir double fScale = double(aLogicSize.Width())/double(aOrigSize.Width()); 261cdf0e10cSrcweir 262cdf0e10cSrcweir 263cdf0e10cSrcweir maPageVDev.Erase(); 264cdf0e10cSrcweir maPageVDev.Push(); 265cdf0e10cSrcweir maPageVDev.SetMapMode( MAP_100TH_MM ); 266cdf0e10cSrcweir sal_uLong nOldDrawMode = maPageVDev.GetDrawMode(); 267cdf0e10cSrcweir if( mbGreyscale ) 268cdf0e10cSrcweir maPageVDev.SetDrawMode( maPageVDev.GetDrawMode() | 269cdf0e10cSrcweir ( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT | 270cdf0e10cSrcweir DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) ); 271cdf0e10cSrcweir aMtf.WindStart(); 272cdf0e10cSrcweir aMtf.Scale( fScale, fScale ); 273cdf0e10cSrcweir aMtf.WindStart(); 274cdf0e10cSrcweir aMtf.Play( &maPageVDev, Point( 0, 0 ), aLogicSize ); 275cdf0e10cSrcweir maPageVDev.Pop(); 276cdf0e10cSrcweir 277cdf0e10cSrcweir SetMapMode( MAP_PIXEL ); 278cdf0e10cSrcweir maPageVDev.SetMapMode( MAP_PIXEL ); 279cdf0e10cSrcweir DrawOutDev( aOffset, maPreviewSize, Point( 0, 0 ), aVDevSize, maPageVDev ); 280cdf0e10cSrcweir maPageVDev.SetDrawMode( nOldDrawMode ); 281cdf0e10cSrcweir 282cdf0e10cSrcweir DecorationView aVw( this ); 283cdf0e10cSrcweir Rectangle aFrame( aOffset + Point( -1, -1 ), Size( maPreviewSize.Width() + 2, maPreviewSize.Height() + 2 ) ); 284cdf0e10cSrcweir aVw.DrawFrame( aFrame, FRAME_DRAW_GROUP ); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir if( rEvt.GetCommand() == COMMAND_WHEEL ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir const CommandWheelData* pWheelData = rEvt.GetWheelData(); 293cdf0e10cSrcweir PrintDialog* pDlg = dynamic_cast<PrintDialog*>(GetParent()); 294cdf0e10cSrcweir if( pDlg ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir if( pWheelData->GetDelta() > 0 ) 297cdf0e10cSrcweir pDlg->previewForward(); 298cdf0e10cSrcweir else if( pWheelData->GetDelta() < 0 ) 299cdf0e10cSrcweir pDlg->previewBackward(); 300cdf0e10cSrcweir /* 301cdf0e10cSrcweir else 302cdf0e10cSrcweir huh ? 303cdf0e10cSrcweir */ 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, 309cdf0e10cSrcweir const Size& i_rOrigSize, 310cdf0e10cSrcweir const rtl::OUString& i_rPaperName, 311cdf0e10cSrcweir const rtl::OUString& i_rReplacement, 312cdf0e10cSrcweir sal_Int32 i_nDPIX, 313cdf0e10cSrcweir sal_Int32 i_nDPIY, 314cdf0e10cSrcweir bool i_bGreyscale 315cdf0e10cSrcweir ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir rtl::OUStringBuffer aBuf( 256 ); 318cdf0e10cSrcweir aBuf.append( maToolTipString ); 319cdf0e10cSrcweir SetQuickHelpText( aBuf.makeStringAndClear() ); 320cdf0e10cSrcweir maMtf = i_rNewPreview; 321cdf0e10cSrcweir if( useHCColorReplacement() ) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir maMtf.ReplaceColors( Color( COL_BLACK ), Color( COL_WHITE ), 30 ); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir maOrigSize = i_rOrigSize; 327cdf0e10cSrcweir maReplacementString = i_rReplacement; 328cdf0e10cSrcweir mbGreyscale = i_bGreyscale; 329cdf0e10cSrcweir maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY ); 330cdf0e10cSrcweir maPageVDev.EnableOutput( sal_True ); 331cdf0e10cSrcweir 332cdf0e10cSrcweir // use correct measurements 333cdf0e10cSrcweir const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() ); 334cdf0e10cSrcweir MapUnit eUnit = MAP_MM; 335cdf0e10cSrcweir int nDigits = 0; 336cdf0e10cSrcweir if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir eUnit = MAP_100TH_INCH; 339cdf0e10cSrcweir nDigits = 2; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir Size aLogicPaperSize( LogicToLogic( i_rOrigSize, MapMode( MAP_100TH_MM ), MapMode( eUnit ) ) ); 342cdf0e10cSrcweir String aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) ); 343cdf0e10cSrcweir aBuf.append( aNumText ); 344cdf0e10cSrcweir aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" ); 345cdf0e10cSrcweir if( i_rPaperName.getLength() ) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir aBuf.appendAscii( " (" ); 348cdf0e10cSrcweir aBuf.append( i_rPaperName ); 349cdf0e10cSrcweir aBuf.append( sal_Unicode(')') ); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir maHorzDim.SetText( aBuf.makeStringAndClear() ); 352cdf0e10cSrcweir 353cdf0e10cSrcweir aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ); 354cdf0e10cSrcweir aBuf.append( aNumText ); 355cdf0e10cSrcweir aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" ); 356cdf0e10cSrcweir maVertDim.SetText( aBuf.makeStringAndClear() ); 357cdf0e10cSrcweir 358cdf0e10cSrcweir Resize(); 359cdf0e10cSrcweir Invalidate(); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( Window* i_pParent ) 363cdf0e10cSrcweir : Window( i_pParent, WB_NOBORDER ) 364cdf0e10cSrcweir , mnOrderMode( 0 ) 365cdf0e10cSrcweir , mnRows( 1 ) 366cdf0e10cSrcweir , mnColumns( 1 ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir ImplInitSettings(); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir PrintDialog::ShowNupOrderWindow::~ShowNupOrderWindow() 372cdf0e10cSrcweir { 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir void PrintDialog::ShowNupOrderWindow::ImplInitSettings() 376cdf0e10cSrcweir { 377cdf0e10cSrcweir SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir Window::Paint( i_rRect ); 383cdf0e10cSrcweir SetMapMode( MAP_PIXEL ); 384cdf0e10cSrcweir SetTextColor( GetSettings().GetStyleSettings().GetFieldTextColor() ); 385cdf0e10cSrcweir 386cdf0e10cSrcweir int nPages = mnRows * mnColumns; 387cdf0e10cSrcweir Font aFont( GetSettings().GetStyleSettings().GetFieldFont() ); 388cdf0e10cSrcweir aFont.SetSize( Size( 0, 24 ) ); 389cdf0e10cSrcweir SetFont( aFont ); 390cdf0e10cSrcweir Size aSampleTextSize( GetTextWidth( rtl::OUString::valueOf( sal_Int32(nPages+1) ) ), GetTextHeight() ); 391cdf0e10cSrcweir 392cdf0e10cSrcweir Size aOutSize( GetOutputSizePixel() ); 393cdf0e10cSrcweir Size aSubSize( aOutSize.Width() / mnColumns, aOutSize.Height() / mnRows ); 394cdf0e10cSrcweir // calculate font size: shrink the sample text so it fits 395cdf0e10cSrcweir double fX = double(aSubSize.Width())/double(aSampleTextSize.Width()); 396cdf0e10cSrcweir double fY = double(aSubSize.Height())/double(aSampleTextSize.Height()); 397cdf0e10cSrcweir double fScale = (fX < fY) ? fX : fY; 398cdf0e10cSrcweir long nFontHeight = long(24.0*fScale) - 3; 399cdf0e10cSrcweir if( nFontHeight < 5 ) 400cdf0e10cSrcweir nFontHeight = 5; 401cdf0e10cSrcweir aFont.SetSize( Size( 0, nFontHeight ) ); 402cdf0e10cSrcweir SetFont( aFont ); 403cdf0e10cSrcweir long nTextHeight = GetTextHeight(); 404cdf0e10cSrcweir for( int i = 0; i < nPages; i++ ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir rtl::OUString aPageText( rtl::OUString::valueOf( sal_Int32(i+1) ) ); 407cdf0e10cSrcweir int nX = 0, nY = 0; 408cdf0e10cSrcweir switch( mnOrderMode ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir case SV_PRINT_PRT_NUP_ORDER_LRTB: 411cdf0e10cSrcweir nX = (i % mnColumns); nY = (i / mnColumns); 412cdf0e10cSrcweir break; 413cdf0e10cSrcweir case SV_PRINT_PRT_NUP_ORDER_TBLR: 414cdf0e10cSrcweir nX = (i / mnRows); nY = (i % mnRows); 415cdf0e10cSrcweir break; 416cdf0e10cSrcweir case SV_PRINT_PRT_NUP_ORDER_RLTB: 417cdf0e10cSrcweir nX = mnColumns - 1 - (i % mnColumns); nY = (i / mnColumns); 418cdf0e10cSrcweir break; 419cdf0e10cSrcweir case SV_PRINT_PRT_NUP_ORDER_TBRL: 420cdf0e10cSrcweir nX = mnColumns - 1 - (i / mnRows); nY = (i % mnRows); 421cdf0e10cSrcweir break; 422cdf0e10cSrcweir } 423cdf0e10cSrcweir Size aTextSize( GetTextWidth( aPageText ), nTextHeight ); 424cdf0e10cSrcweir int nDeltaX = (aSubSize.Width() - aTextSize.Width()) / 2; 425cdf0e10cSrcweir int nDeltaY = (aSubSize.Height() - aTextSize.Height()) / 2; 426cdf0e10cSrcweir DrawText( Point( nX * aSubSize.Width() + nDeltaX, 427cdf0e10cSrcweir nY * aSubSize.Height() + nDeltaY ), 428cdf0e10cSrcweir aPageText ); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir DecorationView aVw( this ); 431cdf0e10cSrcweir aVw.DrawFrame( Rectangle( Point( 0, 0), aOutSize ), FRAME_DRAW_GROUP ); 432cdf0e10cSrcweir } 433cdf0e10cSrcweir 434cdf0e10cSrcweir PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) 435cdf0e10cSrcweir : TabPage( i_pParent, rResId ) 436cdf0e10cSrcweir , maNupLine( this, VclResId( SV_PRINT_PRT_NUP_LAYOUT_FL ) ) 437cdf0e10cSrcweir , maPagesBtn( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BTN ) ) 438cdf0e10cSrcweir , maBrochureBtn( this, VclResId( SV_PRINT_PRT_NUP_BROCHURE_BTN ) ) 439cdf0e10cSrcweir , maPagesBoxTitleTxt( this, 0 ) 440cdf0e10cSrcweir , maNupPagesBox( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BOX ) ) 441cdf0e10cSrcweir , maNupNumPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_NUM_PAGES_TXT ) ) 442cdf0e10cSrcweir , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLS_EDT ) ) 443cdf0e10cSrcweir , maNupTimesTxt( this, VclResId( SV_PRINT_PRT_NUP_TIMES_TXT ) ) 444cdf0e10cSrcweir , maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) ) 445cdf0e10cSrcweir , maPageMarginTxt1( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_1_TXT ) ) 446cdf0e10cSrcweir , maPageMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT ) ) 447cdf0e10cSrcweir , maPageMarginTxt2( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_2_TXT ) ) 448cdf0e10cSrcweir , maSheetMarginTxt1( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_1_TXT ) ) 449cdf0e10cSrcweir , maSheetMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT ) ) 450cdf0e10cSrcweir , maSheetMarginTxt2( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_2_TXT ) ) 451cdf0e10cSrcweir , maNupOrientationTxt( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_TXT ) ) 452cdf0e10cSrcweir , maNupOrientationBox( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_BOX ) ) 453cdf0e10cSrcweir , maNupOrderTxt( this, VclResId( SV_PRINT_PRT_NUP_ORDER_TXT ) ) 454cdf0e10cSrcweir , maNupOrderBox( this, VclResId( SV_PRINT_PRT_NUP_ORDER_BOX ) ) 455cdf0e10cSrcweir , maNupOrderWin( this ) 456cdf0e10cSrcweir , maBorderCB( this, VclResId( SV_PRINT_PRT_NUP_BORDER_CB ) ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir FreeResource(); 459cdf0e10cSrcweir 460cdf0e10cSrcweir maNupOrderWin.Show(); 461cdf0e10cSrcweir maPagesBtn.Check( sal_True ); 462cdf0e10cSrcweir maBrochureBtn.Show( sal_False ); 463cdf0e10cSrcweir 464cdf0e10cSrcweir // setup field units for metric fields 465cdf0e10cSrcweir const LocaleDataWrapper& rLocWrap( maPageMarginEdt.GetLocaleDataWrapper() ); 466cdf0e10cSrcweir FieldUnit eUnit = FUNIT_MM; 467cdf0e10cSrcweir sal_uInt16 nDigits = 0; 468cdf0e10cSrcweir if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US ) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir eUnit = FUNIT_INCH; 471cdf0e10cSrcweir nDigits = 2; 472cdf0e10cSrcweir } 473cdf0e10cSrcweir // set units 474cdf0e10cSrcweir maPageMarginEdt.SetUnit( eUnit ); 475cdf0e10cSrcweir maSheetMarginEdt.SetUnit( eUnit ); 476cdf0e10cSrcweir 477cdf0e10cSrcweir // set precision 478cdf0e10cSrcweir maPageMarginEdt.SetDecimalDigits( nDigits ); 479cdf0e10cSrcweir maSheetMarginEdt.SetDecimalDigits( nDigits ); 480cdf0e10cSrcweir 481cdf0e10cSrcweir setupLayout(); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir PrintDialog::NUpTabPage::~NUpTabPage() 485cdf0e10cSrcweir { 486cdf0e10cSrcweir } 487cdf0e10cSrcweir 488cdf0e10cSrcweir void PrintDialog::NUpTabPage::enableNupControls( bool bEnable ) 489cdf0e10cSrcweir { 490cdf0e10cSrcweir maNupPagesBox.Enable( sal_True ); 491cdf0e10cSrcweir maNupNumPagesTxt.Enable( bEnable ); 492cdf0e10cSrcweir maNupColEdt.Enable( bEnable ); 493cdf0e10cSrcweir maNupTimesTxt.Enable( bEnable ); 494cdf0e10cSrcweir maNupRowsEdt.Enable( bEnable ); 495cdf0e10cSrcweir maPageMarginTxt1.Enable( bEnable ); 496cdf0e10cSrcweir maPageMarginEdt.Enable( bEnable ); 497cdf0e10cSrcweir maPageMarginTxt2.Enable( bEnable ); 498cdf0e10cSrcweir maSheetMarginTxt1.Enable( bEnable ); 499cdf0e10cSrcweir maSheetMarginEdt.Enable( bEnable ); 500cdf0e10cSrcweir maSheetMarginTxt2.Enable( bEnable ); 501cdf0e10cSrcweir maNupOrientationTxt.Enable( bEnable ); 502cdf0e10cSrcweir maNupOrientationBox.Enable( bEnable ); 503cdf0e10cSrcweir maNupOrderTxt.Enable( bEnable ); 504cdf0e10cSrcweir maNupOrderBox.Enable( bEnable ); 505cdf0e10cSrcweir maNupOrderWin.Enable( bEnable ); 506cdf0e10cSrcweir maBorderCB.Enable( bEnable ); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir void PrintDialog::NUpTabPage::showAdvancedControls( bool i_bShow ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir maNupNumPagesTxt.Show( i_bShow ); 512cdf0e10cSrcweir maNupColEdt.Show( i_bShow ); 513cdf0e10cSrcweir maNupTimesTxt.Show( i_bShow ); 514cdf0e10cSrcweir maNupRowsEdt.Show( i_bShow ); 515cdf0e10cSrcweir maPageMarginTxt1.Show( i_bShow ); 516cdf0e10cSrcweir maPageMarginEdt.Show( i_bShow ); 517cdf0e10cSrcweir maPageMarginTxt2.Show( i_bShow ); 518cdf0e10cSrcweir maSheetMarginTxt1.Show( i_bShow ); 519cdf0e10cSrcweir maSheetMarginEdt.Show( i_bShow ); 520cdf0e10cSrcweir maSheetMarginTxt2.Show( i_bShow ); 521cdf0e10cSrcweir maNupOrientationTxt.Show( i_bShow ); 522cdf0e10cSrcweir maNupOrientationBox.Show( i_bShow ); 523cdf0e10cSrcweir getLayout()->resize(); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir void PrintDialog::NUpTabPage::setupLayout() 527cdf0e10cSrcweir { 528cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> xLayout = 529cdf0e10cSrcweir boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); 530cdf0e10cSrcweir Size aBorder( LogicToPixel( Size( 6, 6 ), MapMode( MAP_APPFONT ) ) ); 531cdf0e10cSrcweir /* According to OOo style guide, the horizontal indentation of child 532cdf0e10cSrcweir elements to their parent element should always be 6 map units. */ 533cdf0e10cSrcweir long nIndent = aBorder.Width(); 534cdf0e10cSrcweir 535cdf0e10cSrcweir xLayout->addWindow( &maNupLine ); 536cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( xLayout.get(), false ) ); 537cdf0e10cSrcweir xLayout->addChild( xRow ); 538cdf0e10cSrcweir boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get() ) ); 539cdf0e10cSrcweir xRow->addChild( xIndent ); 540cdf0e10cSrcweir 541cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xShowNupCol( new vcl::RowOrColumn( xRow.get() ) ); 542cdf0e10cSrcweir xRow->addChild( xShowNupCol, -1 ); 543cdf0e10cSrcweir xShowNupCol->setMinimumSize( xShowNupCol->addWindow( &maNupOrderWin ), Size( 70, 70 ) ); 544cdf0e10cSrcweir boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xShowNupCol.get() ) ); 545cdf0e10cSrcweir xShowNupCol->addChild( xSpacer ); 546cdf0e10cSrcweir 547cdf0e10cSrcweir boost::shared_ptr< vcl::LabelColumn > xMainCol( new vcl::LabelColumn( xIndent.get() ) ); 548cdf0e10cSrcweir xIndent->setChild( xMainCol ); 549cdf0e10cSrcweir 550cdf0e10cSrcweir size_t nPagesIndex = xMainCol->addRow( &maPagesBtn, &maNupPagesBox ); 551cdf0e10cSrcweir mxPagesBtnLabel = boost::dynamic_pointer_cast<vcl::LabeledElement>( xMainCol->getChild( nPagesIndex ) ); 552cdf0e10cSrcweir 553cdf0e10cSrcweir xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); 554cdf0e10cSrcweir xMainCol->addRow( &maNupNumPagesTxt, xRow, nIndent ); 555cdf0e10cSrcweir xRow->addWindow( &maNupColEdt ); 556cdf0e10cSrcweir xRow->addWindow( &maNupTimesTxt ); 557cdf0e10cSrcweir xRow->addWindow( &maNupRowsEdt ); 558cdf0e10cSrcweir 559cdf0e10cSrcweir boost::shared_ptr< vcl::LabeledElement > xLab( new vcl::LabeledElement( xMainCol.get(), 2 ) ); 560cdf0e10cSrcweir xLab->setLabel( &maPageMarginEdt ); 561cdf0e10cSrcweir xLab->setElement( &maPageMarginTxt2 ); 562cdf0e10cSrcweir xMainCol->addRow( &maPageMarginTxt1, xLab, nIndent ); 563cdf0e10cSrcweir 564cdf0e10cSrcweir xLab.reset( new vcl::LabeledElement( xMainCol.get(), 2 ) ); 565cdf0e10cSrcweir xLab->setLabel( &maSheetMarginEdt ); 566cdf0e10cSrcweir xLab->setElement( &maSheetMarginTxt2 ); 567cdf0e10cSrcweir xMainCol->addRow( &maSheetMarginTxt1, xLab, nIndent ); 568cdf0e10cSrcweir 569cdf0e10cSrcweir xMainCol->addRow( &maNupOrientationTxt, &maNupOrientationBox, nIndent ); 570cdf0e10cSrcweir xMainCol->addRow( &maNupOrderTxt, &maNupOrderBox, nIndent ); 571cdf0e10cSrcweir xMainCol->setBorders( xMainCol->addWindow( &maBorderCB ), nIndent, 0, 0, 0 ); 572cdf0e10cSrcweir 573cdf0e10cSrcweir xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, WindowArranger::getDefaultBorder() ) ) ); 574cdf0e10cSrcweir xMainCol->addChild( xSpacer ); 575cdf0e10cSrcweir 576cdf0e10cSrcweir xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); 577cdf0e10cSrcweir xMainCol->addRow( &maBrochureBtn, xRow ); 578cdf0e10cSrcweir // remember brochure row for dependencies 579cdf0e10cSrcweir mxBrochureDep = xRow; 580cdf0e10cSrcweir 581cdf0e10cSrcweir // initially advanced controls are not shown, rows=columns=1 582cdf0e10cSrcweir showAdvancedControls( false ); 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585cdf0e10cSrcweir void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& i_rMPS ) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir maSheetMarginEdt.SetValue( maSheetMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM ); 588cdf0e10cSrcweir maPageMarginEdt.SetValue( maPageMarginEdt.Normalize( i_rMPS.nHorizontalSpacing ), FUNIT_100TH_MM ); 589cdf0e10cSrcweir maBorderCB.Check( i_rMPS.bDrawBorder ); 590cdf0e10cSrcweir maNupRowsEdt.SetValue( i_rMPS.nRows ); 591cdf0e10cSrcweir maNupColEdt.SetValue( i_rMPS.nColumns ); 5920dccdc5dSMichael Stahl maBorderCB.Check( i_rMPS.bDrawBorder ); 5930dccdc5dSMichael Stahl for( sal_uInt16 i = 0; i < maNupOrderBox.GetEntryCount(); i++ ) 5940dccdc5dSMichael Stahl { 5950dccdc5dSMichael Stahl if( int(sal_IntPtr(maNupOrderBox.GetEntryData( i ))) == i_rMPS.nOrder ) 5960dccdc5dSMichael Stahl maNupOrderBox.SelectEntryPos( i ); 5970dccdc5dSMichael Stahl } 5980dccdc5dSMichael Stahl if( i_rMPS.nRows != 1 || i_rMPS.nColumns != 1 ) 5990dccdc5dSMichael Stahl { 6000dccdc5dSMichael Stahl maNupPagesBox.SelectEntryPos( maNupPagesBox.GetEntryCount()-1 ); 6010dccdc5dSMichael Stahl showAdvancedControls( true ); 6020dccdc5dSMichael Stahl maNupOrderWin.setValues( i_rMPS.nOrder, i_rMPS.nColumns, i_rMPS.nRows ); 6030dccdc5dSMichael Stahl } 604cdf0e10cSrcweir } 605cdf0e10cSrcweir 606cdf0e10cSrcweir void PrintDialog::NUpTabPage::readFromSettings() 607cdf0e10cSrcweir { 608cdf0e10cSrcweir } 609cdf0e10cSrcweir 610cdf0e10cSrcweir void PrintDialog::NUpTabPage::storeToSettings() 611cdf0e10cSrcweir { 612cdf0e10cSrcweir } 613cdf0e10cSrcweir 614cdf0e10cSrcweir PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) 615cdf0e10cSrcweir : TabPage( i_pParent, rResId ) 616cdf0e10cSrcweir , maPrinterFL( this, VclResId( SV_PRINT_PRINTERS_FL ) ) 617cdf0e10cSrcweir , maPrinters( this, VclResId( SV_PRINT_PRINTERS ) ) 618cdf0e10cSrcweir , maDetailsBtn( this, VclResId( SV_PRINT_DETAILS_BTN ) ) 619cdf0e10cSrcweir , maStatusLabel( this, VclResId( SV_PRINT_STATUS_TXT ) ) 620cdf0e10cSrcweir , maStatusTxt( this, 0 ) 621cdf0e10cSrcweir , maLocationLabel( this, VclResId( SV_PRINT_LOCATION_TXT ) ) 622cdf0e10cSrcweir , maLocationTxt( this, 0 ) 623cdf0e10cSrcweir , maCommentLabel( this, VclResId( SV_PRINT_COMMENT_TXT ) ) 624cdf0e10cSrcweir , maCommentTxt( this, 0 ) 625cdf0e10cSrcweir , maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) ) 626cdf0e10cSrcweir , maCopies( this, VclResId( SV_PRINT_COPIES ) ) 627cdf0e10cSrcweir , maCopySpacer( this, WB_VERT ) 628cdf0e10cSrcweir , maCopyCount( this, VclResId( SV_PRINT_COPYCOUNT ) ) 629cdf0e10cSrcweir , maCopyCountField( this, VclResId( SV_PRINT_COPYCOUNT_FIELD ) ) 630cdf0e10cSrcweir , maCollateBox( this, VclResId( SV_PRINT_COLLATE ) ) 631cdf0e10cSrcweir , maCollateImage( this, VclResId( SV_PRINT_COLLATE_IMAGE ) ) 632cdf0e10cSrcweir , maReverseOrderBox( this, VclResId( SV_PRINT_OPT_REVERSE ) ) 633cdf0e10cSrcweir , maCollateImg( VclResId( SV_PRINT_COLLATE_IMG ) ) 634cdf0e10cSrcweir , maCollateHCImg( VclResId( SV_PRINT_COLLATE_HC_IMG ) ) 635cdf0e10cSrcweir , maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) ) 636cdf0e10cSrcweir , maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) ) 637cdf0e10cSrcweir , mnCollateUIMode( 0 ) 638cdf0e10cSrcweir { 639cdf0e10cSrcweir FreeResource(); 640cdf0e10cSrcweir 641cdf0e10cSrcweir maCopySpacer.Show(); 642cdf0e10cSrcweir maStatusTxt.Show(); 643cdf0e10cSrcweir maCommentTxt.Show(); 644cdf0e10cSrcweir maLocationTxt.Show(); 645cdf0e10cSrcweir 646cdf0e10cSrcweir setupLayout(); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir PrintDialog::JobTabPage::~JobTabPage() 650cdf0e10cSrcweir { 651cdf0e10cSrcweir } 652cdf0e10cSrcweir 653cdf0e10cSrcweir void PrintDialog::JobTabPage::setupLayout() 654cdf0e10cSrcweir { 655cdf0e10cSrcweir // HACK: this is not a dropdown box, but the dropdown line count 656cdf0e10cSrcweir // sets the results of GetOptimalSize in a normal ListBox 657cdf0e10cSrcweir maPrinters.SetDropDownLineCount( 4 ); 658cdf0e10cSrcweir 659cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> xLayout = 660cdf0e10cSrcweir boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); 661cdf0e10cSrcweir 662cdf0e10cSrcweir // add printer fixed line 663cdf0e10cSrcweir xLayout->addWindow( &maPrinterFL ); 664cdf0e10cSrcweir // add print LB 665cdf0e10cSrcweir xLayout->addWindow( &maPrinters, 3 ); 666cdf0e10cSrcweir 667cdf0e10cSrcweir // create a row for details button/text and properties button 668cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( xLayout.get(), false ) ); 669cdf0e10cSrcweir xLayout->addChild( xDetRow ); 670cdf0e10cSrcweir xDetRow->addWindow( &maDetailsBtn ); 671cdf0e10cSrcweir xDetRow->addChild( new vcl::Spacer( xDetRow.get(), 2 ) ); 672cdf0e10cSrcweir xDetRow->addWindow( &maSetupButton ); 673cdf0e10cSrcweir 674cdf0e10cSrcweir // create an indent for details 675cdf0e10cSrcweir boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xLayout.get() ) ); 676cdf0e10cSrcweir xLayout->addChild( xIndent ); 677cdf0e10cSrcweir // remember details controls 678cdf0e10cSrcweir mxDetails = xIndent; 679cdf0e10cSrcweir // create a column for the details 680cdf0e10cSrcweir boost::shared_ptr< vcl::LabelColumn > xLabelCol( new vcl::LabelColumn( xIndent.get() ) ); 681cdf0e10cSrcweir xIndent->setChild( xLabelCol ); 682cdf0e10cSrcweir xLabelCol->addRow( &maStatusLabel, &maStatusTxt ); 683cdf0e10cSrcweir xLabelCol->addRow( &maLocationLabel, &maLocationTxt ); 684cdf0e10cSrcweir xLabelCol->addRow( &maCommentLabel, &maCommentTxt ); 685cdf0e10cSrcweir 686cdf0e10cSrcweir // add print range and copies columns 687cdf0e10cSrcweir xLayout->addWindow( &maCopies ); 688cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xRangeRow( new vcl::RowOrColumn( xLayout.get(), false ) ); 689cdf0e10cSrcweir xLayout->addChild( xRangeRow ); 690cdf0e10cSrcweir 691cdf0e10cSrcweir // create print range and add to range row 692cdf0e10cSrcweir mxPrintRange.reset( new vcl::RowOrColumn( xRangeRow.get() ) ); 693cdf0e10cSrcweir xRangeRow->addChild( mxPrintRange ); 694cdf0e10cSrcweir xRangeRow->addWindow( &maCopySpacer ); 695cdf0e10cSrcweir 696cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xCopyCollateCol( new vcl::RowOrColumn( xRangeRow.get() ) ); 697cdf0e10cSrcweir xRangeRow->addChild( xCopyCollateCol ); 698cdf0e10cSrcweir 699cdf0e10cSrcweir // add copies row to copy/collate column 700cdf0e10cSrcweir boost::shared_ptr< vcl::LabeledElement > xCopiesRow( new vcl::LabeledElement( xCopyCollateCol.get(), 2 ) ); 701cdf0e10cSrcweir xCopyCollateCol->addChild( xCopiesRow ); 702cdf0e10cSrcweir xCopiesRow->setLabel( &maCopyCount ); 703cdf0e10cSrcweir xCopiesRow->setElement( &maCopyCountField ); 704cdf0e10cSrcweir boost::shared_ptr< vcl::LabeledElement > xCollateRow( new vcl::LabeledElement( xCopyCollateCol.get(), 2 ) ); 705cdf0e10cSrcweir xCopyCollateCol->addChild( xCollateRow ); 706cdf0e10cSrcweir xCollateRow->setLabel( &maCollateBox ); 707cdf0e10cSrcweir xCollateRow->setElement( &maCollateImage ); 708cdf0e10cSrcweir 709cdf0e10cSrcweir // maDetailsBtn.SetStyle( maDetailsBtn.GetStyle() | (WB_SMALLSTYLE | WB_BEVELBUTTON) ); 710cdf0e10cSrcweir mxDetails->show( false, false ); 711cdf0e10cSrcweir } 712cdf0e10cSrcweir 713cdf0e10cSrcweir void PrintDialog::JobTabPage::readFromSettings() 714cdf0e10cSrcweir { 715cdf0e10cSrcweir SettingsConfigItem* pItem = SettingsConfigItem::get(); 716cdf0e10cSrcweir rtl::OUString aValue; 717cdf0e10cSrcweir 718cdf0e10cSrcweir #if 0 719cdf0e10cSrcweir // do not actually make copy count persistent 720cdf0e10cSrcweir // the assumption is that this would lead to a lot of unwanted copies 721cdf0e10cSrcweir aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 722cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ) ); 723cdf0e10cSrcweir sal_Int32 nVal = aValue.toInt32(); 724cdf0e10cSrcweir maCopyCountField.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); 725cdf0e10cSrcweir #endif 726cdf0e10cSrcweir 727cdf0e10cSrcweir aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 728cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CollateBox" ) ) ); 729cdf0e10cSrcweir if( aValue.equalsIgnoreAsciiCaseAscii( "alwaysoff" ) ) 730cdf0e10cSrcweir { 731cdf0e10cSrcweir mnCollateUIMode = 1; 732cdf0e10cSrcweir maCollateBox.Check( sal_False ); 733cdf0e10cSrcweir maCollateBox.Enable( sal_False ); 734cdf0e10cSrcweir } 735cdf0e10cSrcweir else 736cdf0e10cSrcweir { 737cdf0e10cSrcweir mnCollateUIMode = 0; 738cdf0e10cSrcweir aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 739cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); 740cdf0e10cSrcweir maCollateBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); 741cdf0e10cSrcweir } 742cdf0e10cSrcweir Resize(); 743cdf0e10cSrcweir } 744cdf0e10cSrcweir 745cdf0e10cSrcweir void PrintDialog::JobTabPage::storeToSettings() 746cdf0e10cSrcweir { 747cdf0e10cSrcweir SettingsConfigItem* pItem = SettingsConfigItem::get(); 748cdf0e10cSrcweir pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 749cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), 750cdf0e10cSrcweir maCopyCountField.GetText() ); 751cdf0e10cSrcweir pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 752cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), 753cdf0e10cSrcweir rtl::OUString::createFromAscii( maCollateBox.IsChecked() ? "true" : "false" ) ); 754cdf0e10cSrcweir } 755cdf0e10cSrcweir 756cdf0e10cSrcweir PrintDialog::OutputOptPage::OutputOptPage( Window* i_pParent, const ResId& i_rResId ) 757cdf0e10cSrcweir : TabPage( i_pParent, i_rResId ) 758cdf0e10cSrcweir , maOptionsLine( this, VclResId( SV_PRINT_OPT_PRINT_FL ) ) 759cdf0e10cSrcweir , maToFileBox( this, VclResId( SV_PRINT_OPT_TOFILE ) ) 760cdf0e10cSrcweir , maCollateSingleJobsBox( this, VclResId( SV_PRINT_OPT_SINGLEJOBS ) ) 761cdf0e10cSrcweir { 762cdf0e10cSrcweir FreeResource(); 763cdf0e10cSrcweir 764cdf0e10cSrcweir setupLayout(); 765cdf0e10cSrcweir } 766cdf0e10cSrcweir 767cdf0e10cSrcweir PrintDialog::OutputOptPage::~OutputOptPage() 768cdf0e10cSrcweir { 769cdf0e10cSrcweir } 770cdf0e10cSrcweir 771cdf0e10cSrcweir void PrintDialog::OutputOptPage::setupLayout() 772cdf0e10cSrcweir { 773cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> xLayout = 774cdf0e10cSrcweir boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); 775cdf0e10cSrcweir 776cdf0e10cSrcweir xLayout->addWindow( &maOptionsLine ); 777cdf0e10cSrcweir boost::shared_ptr<vcl::Indenter> xIndent( new vcl::Indenter( xLayout.get(), -1 ) ); 778cdf0e10cSrcweir xLayout->addChild( xIndent ); 779cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> xCol( new vcl::RowOrColumn( xIndent.get() ) ); 780cdf0e10cSrcweir xIndent->setChild( xCol ); 781cdf0e10cSrcweir mxOptGroup = xCol; 782cdf0e10cSrcweir xCol->addWindow( &maToFileBox ); 783cdf0e10cSrcweir xCol->addWindow( &maCollateSingleJobsBox ); 784cdf0e10cSrcweir } 785cdf0e10cSrcweir 786cdf0e10cSrcweir void PrintDialog::OutputOptPage::readFromSettings() 787cdf0e10cSrcweir { 788cdf0e10cSrcweir #if 0 789cdf0e10cSrcweir SettingsConfigItem* pItem = SettingsConfigItem::get(); 790cdf0e10cSrcweir rtl::OUString aValue; 791cdf0e10cSrcweir 792cdf0e10cSrcweir aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 793cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) ); 794cdf0e10cSrcweir maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); 795cdf0e10cSrcweir #endif 796cdf0e10cSrcweir } 797cdf0e10cSrcweir 798cdf0e10cSrcweir void PrintDialog::OutputOptPage::storeToSettings() 799cdf0e10cSrcweir { 800cdf0e10cSrcweir SettingsConfigItem* pItem = SettingsConfigItem::get(); 801cdf0e10cSrcweir pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 802cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ), 803cdf0e10cSrcweir rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) ); 804cdf0e10cSrcweir } 805cdf0e10cSrcweir 806cdf0e10cSrcweir PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterController>& i_rController ) 807cdf0e10cSrcweir : ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) ) 808cdf0e10cSrcweir , maOKButton( this, VclResId( SV_PRINT_OK ) ) 809cdf0e10cSrcweir , maCancelButton( this, VclResId( SV_PRINT_CANCEL ) ) 810cdf0e10cSrcweir , maHelpButton( this, VclResId( SV_PRINT_HELP ) ) 811cdf0e10cSrcweir , maPreviewWindow( this, VclResId( SV_PRINT_PAGE_PREVIEW ) ) 812cdf0e10cSrcweir , maPageEdit( this, VclResId( SV_PRINT_PAGE_EDIT ) ) 813cdf0e10cSrcweir , maNumPagesText( this, VclResId( SV_PRINT_PAGE_TXT ) ) 814cdf0e10cSrcweir , maBackwardBtn( this, VclResId( SV_PRINT_PAGE_BACKWARD ) ) 815cdf0e10cSrcweir , maForwardBtn( this, VclResId( SV_PRINT_PAGE_FORWARD ) ) 816cdf0e10cSrcweir , maTabCtrl( this, VclResId( SV_PRINT_TABCTRL ) ) 817cdf0e10cSrcweir , maNUpPage( &maTabCtrl, VclResId( SV_PRINT_TAB_NUP ) ) 818cdf0e10cSrcweir , maJobPage( &maTabCtrl, VclResId( SV_PRINT_TAB_JOB ) ) 819cdf0e10cSrcweir , maOptionsPage( &maTabCtrl, VclResId( SV_PRINT_TAB_OPT ) ) 820cdf0e10cSrcweir , maButtonLine( this, VclResId( SV_PRINT_BUTTONLINE ) ) 821cdf0e10cSrcweir , maPController( i_rController ) 822cdf0e10cSrcweir , maNoPageStr( String( VclResId( SV_PRINT_NOPAGES ) ) ) 823cdf0e10cSrcweir , mnCurPage( 0 ) 824cdf0e10cSrcweir , mnCachedPages( 0 ) 825cdf0e10cSrcweir , maPrintToFileText( String( VclResId( SV_PRINT_TOFILE_TXT ) ) ) 826cdf0e10cSrcweir , maDefPrtText( String( VclResId( SV_PRINT_DEFPRT_TXT ) ) ) 827cdf0e10cSrcweir , mbShowLayoutPage( sal_True ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir FreeResource(); 830cdf0e10cSrcweir 831cdf0e10cSrcweir // save printbutton text, gets exchanged occasionally with print to file 832cdf0e10cSrcweir maPrintText = maOKButton.GetText(); 833cdf0e10cSrcweir 834cdf0e10cSrcweir // setup preview controls 835cdf0e10cSrcweir maForwardBtn.SetStyle( maForwardBtn.GetStyle() | WB_BEVELBUTTON ); 836cdf0e10cSrcweir maBackwardBtn.SetStyle( maBackwardBtn.GetStyle() | WB_BEVELBUTTON ); 837cdf0e10cSrcweir 838cdf0e10cSrcweir // insert the job (general) tab page first 839cdf0e10cSrcweir maTabCtrl.InsertPage( SV_PRINT_TAB_JOB, maJobPage.GetText() ); 840cdf0e10cSrcweir maTabCtrl.SetTabPage( SV_PRINT_TAB_JOB, &maJobPage ); 841cdf0e10cSrcweir 842cdf0e10cSrcweir // set symbols on forward and backward button 843cdf0e10cSrcweir maBackwardBtn.SetSymbol( SYMBOL_PREV ); 844cdf0e10cSrcweir maForwardBtn.SetSymbol( SYMBOL_NEXT ); 845cdf0e10cSrcweir maBackwardBtn.ImplSetSmallSymbol( sal_True ); 846cdf0e10cSrcweir maForwardBtn.ImplSetSmallSymbol( sal_True ); 847cdf0e10cSrcweir 848cdf0e10cSrcweir maPageStr = maNumPagesText.GetText(); 849cdf0e10cSrcweir 850cdf0e10cSrcweir // init reverse print 851cdf0e10cSrcweir maJobPage.maReverseOrderBox.Check( maPController->getReversePrint() ); 852cdf0e10cSrcweir 853cdf0e10cSrcweir // fill printer listbox 854cdf0e10cSrcweir const std::vector< rtl::OUString >& rQueues( Printer::GetPrinterQueues() ); 855cdf0e10cSrcweir for( std::vector< rtl::OUString >::const_iterator it = rQueues.begin(); 856cdf0e10cSrcweir it != rQueues.end(); ++it ) 857cdf0e10cSrcweir { 858cdf0e10cSrcweir maJobPage.maPrinters.InsertEntry( *it ); 859cdf0e10cSrcweir } 860cdf0e10cSrcweir // select current printer 861cdf0e10cSrcweir if( maJobPage.maPrinters.GetEntryPos( maPController->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND ) 862cdf0e10cSrcweir { 863cdf0e10cSrcweir maJobPage.maPrinters.SelectEntry( maPController->getPrinter()->GetName() ); 864cdf0e10cSrcweir } 865cdf0e10cSrcweir else 866cdf0e10cSrcweir { 867cdf0e10cSrcweir // fall back to last printer 868cdf0e10cSrcweir SettingsConfigItem* pItem = SettingsConfigItem::get(); 869cdf0e10cSrcweir String aValue( pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 870cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinter" ) ) ) ); 871cdf0e10cSrcweir if( maJobPage.maPrinters.GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND ) 872cdf0e10cSrcweir { 873cdf0e10cSrcweir maJobPage.maPrinters.SelectEntry( aValue ); 874cdf0e10cSrcweir maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( aValue ) ) ); 875cdf0e10cSrcweir } 876cdf0e10cSrcweir else 877cdf0e10cSrcweir { 878cdf0e10cSrcweir // fall back to default printer 879cdf0e10cSrcweir maJobPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); 880cdf0e10cSrcweir maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) ); 881cdf0e10cSrcweir } 882cdf0e10cSrcweir } 883cdf0e10cSrcweir // not printing to file 884cdf0e10cSrcweir maPController->resetPrinterOptions( false ); 885cdf0e10cSrcweir 886cdf0e10cSrcweir // get the first page 887cdf0e10cSrcweir preparePreview( true, true ); 888cdf0e10cSrcweir 889cdf0e10cSrcweir // update the text fields for the printer 890cdf0e10cSrcweir updatePrinterText(); 891cdf0e10cSrcweir 892cdf0e10cSrcweir // set a select handler 893cdf0e10cSrcweir maJobPage.maPrinters.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); 894cdf0e10cSrcweir 895cdf0e10cSrcweir // setup sizes for N-Up 896cdf0e10cSrcweir Size aNupSize( maPController->getPrinter()->PixelToLogic( 897cdf0e10cSrcweir maPController->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); 898cdf0e10cSrcweir if( maPController->getPrinter()->GetOrientation() == ORIENTATION_LANDSCAPE ) 899cdf0e10cSrcweir { 900cdf0e10cSrcweir maNupLandscapeSize = aNupSize; 901cdf0e10cSrcweir maNupPortraitSize = Size( aNupSize.Height(), aNupSize.Width() ); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir else 904cdf0e10cSrcweir { 905cdf0e10cSrcweir maNupPortraitSize = aNupSize; 906cdf0e10cSrcweir maNupLandscapeSize = Size( aNupSize.Height(), aNupSize.Width() ); 907cdf0e10cSrcweir } 908cdf0e10cSrcweir maNUpPage.initFromMultiPageSetup( maPController->getMultipage() ); 909cdf0e10cSrcweir 910cdf0e10cSrcweir 911cdf0e10cSrcweir // setup click handler on the various buttons 912cdf0e10cSrcweir maOKButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); 913cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 914cdf0e10cSrcweir maCancelButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); 915cdf0e10cSrcweir #endif 916cdf0e10cSrcweir maHelpButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); 917cdf0e10cSrcweir maForwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); 918cdf0e10cSrcweir maBackwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); 919cdf0e10cSrcweir maJobPage.maCollateBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); 920cdf0e10cSrcweir maJobPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); 921cdf0e10cSrcweir maJobPage.maDetailsBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); 922cdf0e10cSrcweir maNUpPage.maBorderCB.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); 923cdf0e10cSrcweir maOptionsPage.maToFileBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); 924cdf0e10cSrcweir maJobPage.maReverseOrderBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); 925cdf0e10cSrcweir maOptionsPage.maCollateSingleJobsBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); 926cdf0e10cSrcweir maNUpPage.maPagesBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); 927cdf0e10cSrcweir 928cdf0e10cSrcweir // setup modify hdl 929cdf0e10cSrcweir maPageEdit.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); 930cdf0e10cSrcweir maJobPage.maCopyCountField.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); 931cdf0e10cSrcweir maNUpPage.maNupRowsEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); 932cdf0e10cSrcweir maNUpPage.maNupColEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); 933cdf0e10cSrcweir maNUpPage.maPageMarginEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); 934cdf0e10cSrcweir maNUpPage.maSheetMarginEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); 935cdf0e10cSrcweir 936cdf0e10cSrcweir // setup select hdl 937cdf0e10cSrcweir maNUpPage.maNupPagesBox.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); 938cdf0e10cSrcweir maNUpPage.maNupOrientationBox.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); 939cdf0e10cSrcweir maNUpPage.maNupOrderBox.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); 940cdf0e10cSrcweir 941cdf0e10cSrcweir // setup the layout 942cdf0e10cSrcweir setupLayout(); 943cdf0e10cSrcweir 944cdf0e10cSrcweir // setup optional UI options set by application 945cdf0e10cSrcweir setupOptionalUI(); 946cdf0e10cSrcweir 947cdf0e10cSrcweir // set change handler for UI options 948cdf0e10cSrcweir maPController->setOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) ); 949cdf0e10cSrcweir 950cdf0e10cSrcweir // set min size pixel to current size 951cdf0e10cSrcweir Size aOutSize( GetOutputSizePixel() ); 952cdf0e10cSrcweir SetMinOutputSizePixel( aOutSize ); 953cdf0e10cSrcweir 954cdf0e10cSrcweir // if there is space enough, enlarge the preview so it gets roughly as 955cdf0e10cSrcweir // high as the tab control 956cdf0e10cSrcweir if( aOutSize.Width() < 768 ) 957cdf0e10cSrcweir { 958cdf0e10cSrcweir Size aJobPageSize( getJobPageSize() ); 959cdf0e10cSrcweir Size aTabSize( maTabCtrl.GetSizePixel() ); 960cdf0e10cSrcweir if( aJobPageSize.Width() < 1 ) 961cdf0e10cSrcweir aJobPageSize.Width() = aTabSize.Width(); 962cdf0e10cSrcweir if( aJobPageSize.Height() < 1 ) 963cdf0e10cSrcweir aJobPageSize.Height() = aTabSize.Height(); 964cdf0e10cSrcweir long nOptPreviewWidth = aTabSize.Height() * aJobPageSize.Width() / aJobPageSize.Height(); 965cdf0e10cSrcweir // add space for borders 966cdf0e10cSrcweir nOptPreviewWidth += 15; 967cdf0e10cSrcweir if( aOutSize.Width() - aTabSize.Width() < nOptPreviewWidth ) 968cdf0e10cSrcweir { 969cdf0e10cSrcweir aOutSize.Width() = aTabSize.Width() + nOptPreviewWidth; 970cdf0e10cSrcweir if( aOutSize.Width() > 768 ) // don't enlarge the dialog too much 971cdf0e10cSrcweir aOutSize.Width() = 768; 972cdf0e10cSrcweir SetOutputSizePixel( aOutSize ); 973cdf0e10cSrcweir } 974cdf0e10cSrcweir } 975cdf0e10cSrcweir 976cdf0e10cSrcweir // append further tab pages 977cdf0e10cSrcweir if( mbShowLayoutPage ) 978cdf0e10cSrcweir { 979cdf0e10cSrcweir maTabCtrl.InsertPage( SV_PRINT_TAB_NUP, maNUpPage.GetText() ); 980cdf0e10cSrcweir maTabCtrl.SetTabPage( SV_PRINT_TAB_NUP, &maNUpPage ); 981cdf0e10cSrcweir } 982cdf0e10cSrcweir maTabCtrl.InsertPage( SV_PRINT_TAB_OPT, maOptionsPage.GetText() ); 983cdf0e10cSrcweir maTabCtrl.SetTabPage( SV_PRINT_TAB_OPT, &maOptionsPage ); 984cdf0e10cSrcweir 985cdf0e10cSrcweir // restore settings from last run 986cdf0e10cSrcweir readFromSettings(); 987cdf0e10cSrcweir 988cdf0e10cSrcweir // setup dependencies 989cdf0e10cSrcweir checkControlDependencies(); 990cdf0e10cSrcweir 991cdf0e10cSrcweir } 992cdf0e10cSrcweir 993cdf0e10cSrcweir PrintDialog::~PrintDialog() 994cdf0e10cSrcweir { 995cdf0e10cSrcweir while( ! maControls.empty() ) 996cdf0e10cSrcweir { 997cdf0e10cSrcweir delete maControls.front(); 998cdf0e10cSrcweir maControls.pop_front(); 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir void PrintDialog::setupLayout() 1003cdf0e10cSrcweir { 1004cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> xLayout = 1005cdf0e10cSrcweir boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); 1006cdf0e10cSrcweir xLayout->setOuterBorder( 0 ); 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir 1009cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xPreviewAndTab( new vcl::RowOrColumn( xLayout.get(), false ) ); 1010cdf0e10cSrcweir size_t nIndex = xLayout->addChild( xPreviewAndTab, 5 ); 1011cdf0e10cSrcweir xLayout->setBorders( nIndex, -1, -1, -1, 0 ); 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir // setup column for preview and sub controls 1014cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xPreview( new vcl::RowOrColumn( xPreviewAndTab.get() ) ); 1015cdf0e10cSrcweir xPreviewAndTab->addChild( xPreview, 5 ); 1016cdf0e10cSrcweir xPreview->addWindow( &maPreviewWindow, 5 ); 1017cdf0e10cSrcweir // get a row for the preview controls 1018cdf0e10cSrcweir mxPreviewCtrls.reset( new vcl::RowOrColumn( xPreview.get(), false ) ); 1019cdf0e10cSrcweir nIndex = xPreview->addChild( mxPreviewCtrls ); 1020cdf0e10cSrcweir boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( mxPreviewCtrls.get(), 2 ) ); 1021cdf0e10cSrcweir mxPreviewCtrls->addChild( xSpacer ); 1022cdf0e10cSrcweir mxPreviewCtrls->addWindow( &maPageEdit ); 1023cdf0e10cSrcweir mxPreviewCtrls->addWindow( &maNumPagesText ); 1024cdf0e10cSrcweir xSpacer.reset( new vcl::Spacer( mxPreviewCtrls.get(), 2 ) ); 1025cdf0e10cSrcweir mxPreviewCtrls->addChild( xSpacer ); 1026cdf0e10cSrcweir mxPreviewCtrls->addWindow( &maBackwardBtn ); 1027cdf0e10cSrcweir mxPreviewCtrls->addWindow( &maForwardBtn ); 1028cdf0e10cSrcweir xSpacer.reset( new vcl::Spacer( mxPreviewCtrls.get(), 2 ) ); 1029cdf0e10cSrcweir mxPreviewCtrls->addChild( xSpacer ); 1030cdf0e10cSrcweir 1031cdf0e10cSrcweir // continue with the tab ctrl 1032cdf0e10cSrcweir xPreviewAndTab->addWindow( &maTabCtrl ); 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir // add the button line 1035cdf0e10cSrcweir xLayout->addWindow( &maButtonLine ); 1036cdf0e10cSrcweir 1037cdf0e10cSrcweir // add the row for the buttons 1038cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > xButtons( new vcl::RowOrColumn( xLayout.get(), false ) ); 1039cdf0e10cSrcweir nIndex = xLayout->addChild( xButtons ); 1040cdf0e10cSrcweir xLayout->setBorders( nIndex, -1, 0, -1, -1 ); 1041cdf0e10cSrcweir 1042cdf0e10cSrcweir Size aMinSize( maCancelButton.GetSizePixel() ); 1043cdf0e10cSrcweir // insert help button 1044cdf0e10cSrcweir xButtons->setMinimumSize( xButtons->addWindow( &maHelpButton ), aMinSize ); 1045cdf0e10cSrcweir // insert a spacer, cancel and OK buttons are right aligned 1046cdf0e10cSrcweir xSpacer.reset( new vcl::Spacer( xButtons.get(), 2 ) ); 1047cdf0e10cSrcweir xButtons->addChild( xSpacer ); 1048cdf0e10cSrcweir xButtons->setMinimumSize( xButtons->addWindow( &maOKButton ), aMinSize ); 1049cdf0e10cSrcweir xButtons->setMinimumSize( xButtons->addWindow( &maCancelButton ), aMinSize ); 1050cdf0e10cSrcweir } 1051cdf0e10cSrcweir 1052cdf0e10cSrcweir void PrintDialog::readFromSettings() 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir maJobPage.readFromSettings(); 1055cdf0e10cSrcweir maNUpPage.readFromSettings(); 1056cdf0e10cSrcweir maOptionsPage.readFromSettings(); 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir // read last selected tab page; if it exists, actiavte it 1059cdf0e10cSrcweir SettingsConfigItem* pItem = SettingsConfigItem::get(); 1060cdf0e10cSrcweir rtl::OUString aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 1061cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPage" ) ) ); 1062cdf0e10cSrcweir sal_uInt16 nCount = maTabCtrl.GetPageCount(); 1063cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCount; i++ ) 1064cdf0e10cSrcweir { 1065cdf0e10cSrcweir sal_uInt16 nPageId = maTabCtrl.GetPageId( i ); 1066cdf0e10cSrcweir if( aValue.equals( maTabCtrl.GetPageText( nPageId ) ) ) 1067cdf0e10cSrcweir { 1068cdf0e10cSrcweir maTabCtrl.SelectTabPage( nPageId ); 1069cdf0e10cSrcweir break; 1070cdf0e10cSrcweir } 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir // persistent window state 1075cdf0e10cSrcweir rtl::OUString aWinState( pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 1076cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WindowState" ) ) ) ); 1077cdf0e10cSrcweir if( aWinState.getLength() ) 1078cdf0e10cSrcweir SetWindowState( rtl::OUStringToOString( aWinState, RTL_TEXTENCODING_UTF8 ) ); 1079cdf0e10cSrcweir 1080cdf0e10cSrcweir if( maOptionsPage.maToFileBox.IsChecked() ) 1081cdf0e10cSrcweir { 1082cdf0e10cSrcweir maPController->resetPrinterOptions( true ); 1083cdf0e10cSrcweir preparePreview( true, true ); 1084cdf0e10cSrcweir } 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir void PrintDialog::storeToSettings() 1088cdf0e10cSrcweir { 1089cdf0e10cSrcweir maJobPage.storeToSettings(); 1090cdf0e10cSrcweir maNUpPage.storeToSettings(); 1091cdf0e10cSrcweir maOptionsPage.storeToSettings(); 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir // store last selected printer 1094cdf0e10cSrcweir SettingsConfigItem* pItem = SettingsConfigItem::get(); 1095cdf0e10cSrcweir pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 1096cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinter" ) ), 1097cdf0e10cSrcweir maJobPage.maPrinters.GetSelectEntry() ); 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 1100cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPage" ) ), 1101cdf0e10cSrcweir maTabCtrl.GetPageText( maTabCtrl.GetCurPageId() ) ); 1102cdf0e10cSrcweir pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), 1103cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WindowState" ) ), 1104cdf0e10cSrcweir rtl::OStringToOUString( GetWindowState(), RTL_TEXTENCODING_UTF8 ) 1105cdf0e10cSrcweir ); 1106cdf0e10cSrcweir pItem->Commit(); 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir bool PrintDialog::isPrintToFile() 1110cdf0e10cSrcweir { 1111cdf0e10cSrcweir return maOptionsPage.maToFileBox.IsChecked(); 1112cdf0e10cSrcweir } 1113cdf0e10cSrcweir 1114cdf0e10cSrcweir int PrintDialog::getCopyCount() 1115cdf0e10cSrcweir { 1116cdf0e10cSrcweir return static_cast<int>(maJobPage.maCopyCountField.GetValue()); 1117cdf0e10cSrcweir } 1118cdf0e10cSrcweir 1119cdf0e10cSrcweir bool PrintDialog::isCollate() 1120cdf0e10cSrcweir { 1121cdf0e10cSrcweir return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : sal_False; 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir 1124cdf0e10cSrcweir bool PrintDialog::isSingleJobs() 1125cdf0e10cSrcweir { 1126cdf0e10cSrcweir return maOptionsPage.maCollateSingleJobsBox.IsChecked(); 1127cdf0e10cSrcweir } 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir void setHelpId( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpIds, sal_Int32 i_nIndex ) 1130cdf0e10cSrcweir { 1131cdf0e10cSrcweir if( i_nIndex >= 0 && i_nIndex < i_rHelpIds.getLength() ) 1132cdf0e10cSrcweir i_pWindow->SetHelpId( rtl::OUStringToOString( i_rHelpIds.getConstArray()[i_nIndex], RTL_TEXTENCODING_UTF8 ) ); 1133cdf0e10cSrcweir } 1134cdf0e10cSrcweir 1135cdf0e10cSrcweir static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpTexts, sal_Int32 i_nIndex ) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir // without a help text set and the correct smartID, 1138cdf0e10cSrcweir // help texts will be retrieved from the online help system 1139cdf0e10cSrcweir if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() ) 1140cdf0e10cSrcweir i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] ); 1141cdf0e10cSrcweir } 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir void updateMaxSize( const Size& i_rCheckSize, Size& o_rMaxSize ) 1144cdf0e10cSrcweir { 1145cdf0e10cSrcweir if( i_rCheckSize.Width() > o_rMaxSize.Width() ) 1146cdf0e10cSrcweir o_rMaxSize.Width() = i_rCheckSize.Width(); 1147cdf0e10cSrcweir if( i_rCheckSize.Height() > o_rMaxSize.Height() ) 1148cdf0e10cSrcweir o_rMaxSize.Height() = i_rCheckSize.Height(); 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir void PrintDialog::setupOptionalUI() 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir std::vector< boost::shared_ptr<vcl::RowOrColumn> > aDynamicColumns; 1154cdf0e10cSrcweir boost::shared_ptr< vcl::RowOrColumn > pCurColumn; 1155cdf0e10cSrcweir 1156cdf0e10cSrcweir Window* pCurParent = 0, *pDynamicPageParent = 0; 1157cdf0e10cSrcweir sal_uInt16 nOptPageId = 9, nCurSubGroup = 0; 1158cdf0e10cSrcweir bool bOnStaticPage = false; 1159cdf0e10cSrcweir bool bSubgroupOnStaticPage = false; 1160cdf0e10cSrcweir 1161cdf0e10cSrcweir std::multimap< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> > aPropertyToDependencyRowMap; 1162cdf0e10cSrcweir 1163cdf0e10cSrcweir const Sequence< PropertyValue >& rOptions( maPController->getUIOptions() ); 1164cdf0e10cSrcweir for( int i = 0; i < rOptions.getLength(); i++ ) 1165cdf0e10cSrcweir { 1166cdf0e10cSrcweir Sequence< beans::PropertyValue > aOptProp; 1167cdf0e10cSrcweir rOptions[i].Value >>= aOptProp; 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir // extract ui element 1170cdf0e10cSrcweir bool bEnabled = true; 1171cdf0e10cSrcweir rtl::OUString aCtrlType; 1172cdf0e10cSrcweir rtl::OUString aText; 1173cdf0e10cSrcweir rtl::OUString aPropertyName; 1174cdf0e10cSrcweir Sequence< rtl::OUString > aChoices; 1175cdf0e10cSrcweir Sequence< sal_Bool > aChoicesDisabled; 1176cdf0e10cSrcweir Sequence< rtl::OUString > aHelpTexts; 1177cdf0e10cSrcweir Sequence< rtl::OUString > aHelpIds; 1178cdf0e10cSrcweir sal_Int64 nMinValue = 0, nMaxValue = 0; 1179cdf0e10cSrcweir sal_Int32 nCurHelpText = 0; 1180cdf0e10cSrcweir rtl::OUString aGroupingHint; 1181cdf0e10cSrcweir rtl::OUString aDependsOnName; 1182cdf0e10cSrcweir sal_Int32 nDependsOnValue = 0; 1183cdf0e10cSrcweir sal_Bool bUseDependencyRow = sal_False; 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir for( int n = 0; n < aOptProp.getLength(); n++ ) 1186cdf0e10cSrcweir { 1187cdf0e10cSrcweir const beans::PropertyValue& rEntry( aOptProp[ n ] ); 1188cdf0e10cSrcweir if( rEntry.Name.equalsAscii( "Text" ) ) 1189cdf0e10cSrcweir { 1190cdf0e10cSrcweir rEntry.Value >>= aText; 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "ControlType" ) ) 1193cdf0e10cSrcweir { 1194cdf0e10cSrcweir rEntry.Value >>= aCtrlType; 1195cdf0e10cSrcweir } 1196cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "Choices" ) ) 1197cdf0e10cSrcweir { 1198cdf0e10cSrcweir rEntry.Value >>= aChoices; 1199cdf0e10cSrcweir } 1200cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "ChoicesDisabled" ) ) 1201cdf0e10cSrcweir { 1202cdf0e10cSrcweir rEntry.Value >>= aChoicesDisabled; 1203cdf0e10cSrcweir } 1204cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "Property" ) ) 1205cdf0e10cSrcweir { 1206cdf0e10cSrcweir PropertyValue aVal; 1207cdf0e10cSrcweir rEntry.Value >>= aVal; 1208cdf0e10cSrcweir aPropertyName = aVal.Name; 1209cdf0e10cSrcweir } 1210cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "Enabled" ) ) 1211cdf0e10cSrcweir { 1212cdf0e10cSrcweir sal_Bool bValue = sal_True; 1213cdf0e10cSrcweir rEntry.Value >>= bValue; 1214cdf0e10cSrcweir bEnabled = bValue; 1215cdf0e10cSrcweir } 1216cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "GroupingHint" ) ) 1217cdf0e10cSrcweir { 1218cdf0e10cSrcweir rEntry.Value >>= aGroupingHint; 1219cdf0e10cSrcweir } 1220cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "DependsOnName" ) ) 1221cdf0e10cSrcweir { 1222cdf0e10cSrcweir rEntry.Value >>= aDependsOnName; 1223cdf0e10cSrcweir } 1224cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "DependsOnEntry" ) ) 1225cdf0e10cSrcweir { 1226cdf0e10cSrcweir rEntry.Value >>= nDependsOnValue; 1227cdf0e10cSrcweir } 1228cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "AttachToDependency" ) ) 1229cdf0e10cSrcweir { 1230cdf0e10cSrcweir rEntry.Value >>= bUseDependencyRow; 1231cdf0e10cSrcweir } 1232cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "MinValue" ) ) 1233cdf0e10cSrcweir { 1234cdf0e10cSrcweir rEntry.Value >>= nMinValue; 1235cdf0e10cSrcweir } 1236cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "MaxValue" ) ) 1237cdf0e10cSrcweir { 1238cdf0e10cSrcweir rEntry.Value >>= nMaxValue; 1239cdf0e10cSrcweir } 1240cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "HelpText" ) ) 1241cdf0e10cSrcweir { 1242cdf0e10cSrcweir if( ! (rEntry.Value >>= aHelpTexts) ) 1243cdf0e10cSrcweir { 1244cdf0e10cSrcweir rtl::OUString aHelpText; 1245cdf0e10cSrcweir if( (rEntry.Value >>= aHelpText) ) 1246cdf0e10cSrcweir { 1247cdf0e10cSrcweir aHelpTexts.realloc( 1 ); 1248cdf0e10cSrcweir *aHelpTexts.getArray() = aHelpText; 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir } 1251cdf0e10cSrcweir } 1252cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "HelpId" ) ) 1253cdf0e10cSrcweir { 1254cdf0e10cSrcweir if( ! (rEntry.Value >>= aHelpIds ) ) 1255cdf0e10cSrcweir { 1256cdf0e10cSrcweir rtl::OUString aHelpId; 1257cdf0e10cSrcweir if( (rEntry.Value >>= aHelpId) ) 1258cdf0e10cSrcweir { 1259cdf0e10cSrcweir aHelpIds.realloc( 1 ); 1260cdf0e10cSrcweir *aHelpIds.getArray() = aHelpId; 1261cdf0e10cSrcweir } 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir } 1264cdf0e10cSrcweir else if( rEntry.Name.equalsAscii( "HintNoLayoutPage" ) ) 1265cdf0e10cSrcweir { 1266cdf0e10cSrcweir sal_Bool bNoLayoutPage = sal_False; 1267cdf0e10cSrcweir rEntry.Value >>= bNoLayoutPage; 1268cdf0e10cSrcweir mbShowLayoutPage = ! bNoLayoutPage; 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir } 1271cdf0e10cSrcweir 1272cdf0e10cSrcweir // bUseDependencyRow should only be true if a dependency exists 1273cdf0e10cSrcweir bUseDependencyRow = bUseDependencyRow && (aDependsOnName.getLength() != 0); 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir // is it necessary to switch between static and dynamic pages ? 1276cdf0e10cSrcweir bool bSwitchPage = false; 1277cdf0e10cSrcweir if( aGroupingHint.getLength() ) 1278cdf0e10cSrcweir bSwitchPage = true; 1279cdf0e10cSrcweir else if( aCtrlType.equalsAscii( "Subgroup" ) || (bOnStaticPage && ! bSubgroupOnStaticPage ) ) 1280cdf0e10cSrcweir bSwitchPage = true; 1281cdf0e10cSrcweir if( bSwitchPage ) 1282cdf0e10cSrcweir { 1283cdf0e10cSrcweir // restore to dynamic 1284cdf0e10cSrcweir pCurParent = pDynamicPageParent; 1285cdf0e10cSrcweir if( ! aDynamicColumns.empty() ) 1286cdf0e10cSrcweir pCurColumn = aDynamicColumns.back(); 1287cdf0e10cSrcweir else 1288cdf0e10cSrcweir pCurColumn.reset(); 1289cdf0e10cSrcweir bOnStaticPage = false; 1290cdf0e10cSrcweir bSubgroupOnStaticPage = false; 1291cdf0e10cSrcweir 1292cdf0e10cSrcweir if( aGroupingHint.equalsAscii( "PrintRange" ) ) 1293cdf0e10cSrcweir { 1294cdf0e10cSrcweir pCurColumn = maJobPage.mxPrintRange; 1295cdf0e10cSrcweir pCurParent = &maJobPage; // set job page as current parent 1296cdf0e10cSrcweir bOnStaticPage = true; 1297cdf0e10cSrcweir } 1298cdf0e10cSrcweir else if( aGroupingHint.equalsAscii( "OptionsPage" ) ) 1299cdf0e10cSrcweir { 1300cdf0e10cSrcweir pCurColumn = boost::dynamic_pointer_cast<vcl::RowOrColumn>(maOptionsPage.getLayout()); 1301cdf0e10cSrcweir pCurParent = &maOptionsPage; // set options page as current parent 1302cdf0e10cSrcweir bOnStaticPage = true; 1303cdf0e10cSrcweir } 1304cdf0e10cSrcweir else if( aGroupingHint.equalsAscii( "OptionsPageOptGroup" ) ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir pCurColumn = maOptionsPage.mxOptGroup; 1307cdf0e10cSrcweir pCurParent = &maOptionsPage; // set options page as current parent 1308cdf0e10cSrcweir bOnStaticPage = true; 1309cdf0e10cSrcweir } 1310cdf0e10cSrcweir else if( aGroupingHint.equalsAscii( "LayoutPage" ) ) 1311cdf0e10cSrcweir { 1312cdf0e10cSrcweir pCurColumn = boost::dynamic_pointer_cast<vcl::RowOrColumn>(maNUpPage.getLayout()); 1313cdf0e10cSrcweir pCurParent = &maNUpPage; // set layout page as current parent 1314cdf0e10cSrcweir bOnStaticPage = true; 1315cdf0e10cSrcweir } 1316cdf0e10cSrcweir else if( aGroupingHint.getLength() ) 1317cdf0e10cSrcweir { 1318cdf0e10cSrcweir pCurColumn = boost::dynamic_pointer_cast<vcl::RowOrColumn>(maJobPage.getLayout()); 1319cdf0e10cSrcweir pCurParent = &maJobPage; // set job page as current parent 1320cdf0e10cSrcweir bOnStaticPage = true; 1321cdf0e10cSrcweir } 1322cdf0e10cSrcweir } 1323cdf0e10cSrcweir 1324cdf0e10cSrcweir if( aCtrlType.equalsAscii( "Group" ) || 1325cdf0e10cSrcweir ( ! pCurParent && ! (bOnStaticPage || aGroupingHint.getLength() ) ) ) 1326cdf0e10cSrcweir { 1327cdf0e10cSrcweir // add new tab page 1328cdf0e10cSrcweir TabPage* pNewGroup = new TabPage( &maTabCtrl ); 1329cdf0e10cSrcweir maControls.push_front( pNewGroup ); 1330cdf0e10cSrcweir pDynamicPageParent = pCurParent = pNewGroup; 1331cdf0e10cSrcweir pNewGroup->SetText( aText ); 1332cdf0e10cSrcweir maTabCtrl.InsertPage( ++nOptPageId, aText ); 1333cdf0e10cSrcweir maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir // set help id 1336cdf0e10cSrcweir setHelpId( pNewGroup, aHelpIds, 0 ); 1337cdf0e10cSrcweir // set help text 1338cdf0e10cSrcweir setHelpText( pNewGroup, aHelpTexts, 0 ); 1339cdf0e10cSrcweir 1340cdf0e10cSrcweir // reset subgroup counter 1341cdf0e10cSrcweir nCurSubGroup = 0; 1342cdf0e10cSrcweir 1343cdf0e10cSrcweir aDynamicColumns.push_back( boost::dynamic_pointer_cast<vcl::RowOrColumn>(pNewGroup->getLayout()) ); 1344cdf0e10cSrcweir pCurColumn = aDynamicColumns.back(); 1345cdf0e10cSrcweir pCurColumn->setParentWindow( pNewGroup ); 1346cdf0e10cSrcweir bSubgroupOnStaticPage = false; 1347cdf0e10cSrcweir bOnStaticPage = false; 1348cdf0e10cSrcweir } 1349cdf0e10cSrcweir else if( aCtrlType.equalsAscii( "Subgroup" ) && (pCurParent || aGroupingHint.getLength() ) ) 1350cdf0e10cSrcweir { 1351cdf0e10cSrcweir bSubgroupOnStaticPage = (aGroupingHint.getLength() != 0); 1352cdf0e10cSrcweir // create group FixedLine 1353cdf0e10cSrcweir if( ! aGroupingHint.equalsAscii( "PrintRange" ) || 1354cdf0e10cSrcweir ! pCurColumn->countElements() == 0 1355cdf0e10cSrcweir ) 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir Window* pNewSub = NULL; 1358cdf0e10cSrcweir if( aGroupingHint.equalsAscii( "PrintRange" ) ) 1359cdf0e10cSrcweir pNewSub = new FixedText( pCurParent, WB_VCENTER ); 1360cdf0e10cSrcweir else 1361cdf0e10cSrcweir pNewSub = new FixedLine( pCurParent ); 1362cdf0e10cSrcweir maControls.push_front( pNewSub ); 1363cdf0e10cSrcweir pNewSub->SetText( aText ); 1364cdf0e10cSrcweir pNewSub->Show(); 1365cdf0e10cSrcweir 1366cdf0e10cSrcweir // set help id 1367cdf0e10cSrcweir setHelpId( pNewSub, aHelpIds, 0 ); 1368cdf0e10cSrcweir // set help text 1369cdf0e10cSrcweir setHelpText( pNewSub, aHelpTexts, 0 ); 1370cdf0e10cSrcweir // add group to current column 1371cdf0e10cSrcweir pCurColumn->addWindow( pNewSub ); 1372cdf0e10cSrcweir } 1373cdf0e10cSrcweir 1374cdf0e10cSrcweir // add an indent to the current column 1375cdf0e10cSrcweir vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn.get(), -1 ); 1376cdf0e10cSrcweir pCurColumn->addChild( pIndent ); 1377cdf0e10cSrcweir // and create a column inside the indent 1378cdf0e10cSrcweir pCurColumn.reset( new vcl::RowOrColumn( pIndent ) ); 1379cdf0e10cSrcweir pIndent->setChild( pCurColumn ); 1380cdf0e10cSrcweir } 1381cdf0e10cSrcweir // EVIL 1382cdf0e10cSrcweir else if( aCtrlType.equalsAscii( "Bool" ) && 1383cdf0e10cSrcweir aGroupingHint.equalsAscii( "LayoutPage" ) && 1384cdf0e10cSrcweir aPropertyName.equalsAscii( "PrintProspect" ) 1385cdf0e10cSrcweir ) 1386cdf0e10cSrcweir { 1387cdf0e10cSrcweir maNUpPage.maBrochureBtn.SetText( aText ); 1388cdf0e10cSrcweir maNUpPage.maBrochureBtn.Show(); 1389cdf0e10cSrcweir setHelpText( &maNUpPage.maBrochureBtn, aHelpTexts, 0 ); 1390cdf0e10cSrcweir 1391cdf0e10cSrcweir sal_Bool bVal = sal_False; 1392cdf0e10cSrcweir PropertyValue* pVal = maPController->getValue( aPropertyName ); 1393cdf0e10cSrcweir if( pVal ) 1394cdf0e10cSrcweir pVal->Value >>= bVal; 1395cdf0e10cSrcweir maNUpPage.maBrochureBtn.Check( bVal ); 1396cdf0e10cSrcweir maNUpPage.maBrochureBtn.Enable( maPController->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); 1397cdf0e10cSrcweir maNUpPage.maBrochureBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); 1398cdf0e10cSrcweir 1399cdf0e10cSrcweir maPropertyToWindowMap[ aPropertyName ].push_back( &maNUpPage.maBrochureBtn ); 1400cdf0e10cSrcweir maControlToPropertyMap[&maNUpPage.maBrochureBtn] = aPropertyName; 1401cdf0e10cSrcweir 1402cdf0e10cSrcweir aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, maNUpPage.mxBrochureDep ) ); 1403cdf0e10cSrcweir } 1404cdf0e10cSrcweir else 1405cdf0e10cSrcweir { 1406cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> pSaveCurColumn( pCurColumn ); 1407cdf0e10cSrcweir 1408cdf0e10cSrcweir if( bUseDependencyRow ) 1409cdf0e10cSrcweir { 1410cdf0e10cSrcweir // find the correct dependency row (if any) 1411cdf0e10cSrcweir std::pair< std::multimap< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >::iterator, 1412cdf0e10cSrcweir std::multimap< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >::iterator > aDepRange; 1413cdf0e10cSrcweir aDepRange = aPropertyToDependencyRowMap.equal_range( aDependsOnName ); 1414cdf0e10cSrcweir if( aDepRange.first != aDepRange.second ) 1415cdf0e10cSrcweir { 1416cdf0e10cSrcweir while( nDependsOnValue && aDepRange.first != aDepRange.second ) 1417cdf0e10cSrcweir { 1418cdf0e10cSrcweir nDependsOnValue--; 1419cdf0e10cSrcweir ++aDepRange.first; 1420cdf0e10cSrcweir } 1421cdf0e10cSrcweir if( aDepRange.first != aPropertyToDependencyRowMap.end() ) 1422cdf0e10cSrcweir { 1423cdf0e10cSrcweir pCurColumn = aDepRange.first->second; 1424cdf0e10cSrcweir maReverseDependencySet.insert( aPropertyName ); 1425cdf0e10cSrcweir } 1426cdf0e10cSrcweir } 1427cdf0e10cSrcweir } 1428cdf0e10cSrcweir if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) 1429cdf0e10cSrcweir { 1430cdf0e10cSrcweir // add a check box 1431cdf0e10cSrcweir CheckBox* pNewBox = new CheckBox( pCurParent ); 1432cdf0e10cSrcweir maControls.push_front( pNewBox ); 1433cdf0e10cSrcweir pNewBox->SetText( aText ); 1434cdf0e10cSrcweir pNewBox->Show(); 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir sal_Bool bVal = sal_False; 1437cdf0e10cSrcweir PropertyValue* pVal = maPController->getValue( aPropertyName ); 1438cdf0e10cSrcweir if( pVal ) 1439cdf0e10cSrcweir pVal->Value >>= bVal; 1440cdf0e10cSrcweir pNewBox->Check( bVal ); 1441cdf0e10cSrcweir pNewBox->SetToggleHdl( LINK( this, PrintDialog, UIOption_CheckHdl ) ); 1442cdf0e10cSrcweir 1443cdf0e10cSrcweir maPropertyToWindowMap[ aPropertyName ].push_back( pNewBox ); 1444cdf0e10cSrcweir maControlToPropertyMap[pNewBox] = aPropertyName; 1445cdf0e10cSrcweir 1446cdf0e10cSrcweir // set help id 1447cdf0e10cSrcweir setHelpId( pNewBox, aHelpIds, 0 ); 1448cdf0e10cSrcweir // set help text 1449cdf0e10cSrcweir setHelpText( pNewBox, aHelpTexts, 0 ); 1450cdf0e10cSrcweir 1451cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> pDependencyRow( new vcl::RowOrColumn( pCurColumn.get(), false ) ); 1452cdf0e10cSrcweir pCurColumn->addChild( pDependencyRow ); 1453cdf0e10cSrcweir aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, pDependencyRow ) ); 1454cdf0e10cSrcweir 1455cdf0e10cSrcweir // add checkbox to current column 1456cdf0e10cSrcweir pDependencyRow->addWindow( pNewBox ); 1457cdf0e10cSrcweir } 1458cdf0e10cSrcweir else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) 1459cdf0e10cSrcweir { 1460cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> pRadioColumn( pCurColumn ); 1461cdf0e10cSrcweir if( aText.getLength() ) 1462cdf0e10cSrcweir { 1463cdf0e10cSrcweir // add a FixedText: 1464cdf0e10cSrcweir FixedText* pHeading = new FixedText( pCurParent ); 1465cdf0e10cSrcweir maControls.push_front( pHeading ); 1466cdf0e10cSrcweir pHeading->SetText( aText ); 1467cdf0e10cSrcweir pHeading->Show(); 1468cdf0e10cSrcweir 1469cdf0e10cSrcweir // set help id 1470cdf0e10cSrcweir setHelpId( pHeading, aHelpIds, nCurHelpText ); 1471cdf0e10cSrcweir // set help text 1472cdf0e10cSrcweir setHelpText( pHeading, aHelpTexts, nCurHelpText ); 1473cdf0e10cSrcweir nCurHelpText++; 1474cdf0e10cSrcweir // add fixed text to current column 1475cdf0e10cSrcweir pCurColumn->addWindow( pHeading ); 1476cdf0e10cSrcweir // add an indent to the current column 1477cdf0e10cSrcweir vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn.get(), 15 ); 1478cdf0e10cSrcweir pCurColumn->addChild( pIndent ); 1479cdf0e10cSrcweir // and create a column inside the indent 1480cdf0e10cSrcweir pRadioColumn.reset( new vcl::RowOrColumn( pIndent ) ); 1481cdf0e10cSrcweir pIndent->setChild( pRadioColumn ); 1482cdf0e10cSrcweir } 1483cdf0e10cSrcweir // iterate options 1484cdf0e10cSrcweir sal_Int32 nSelectVal = 0; 1485cdf0e10cSrcweir PropertyValue* pVal = maPController->getValue( aPropertyName ); 1486cdf0e10cSrcweir if( pVal && pVal->Value.hasValue() ) 1487cdf0e10cSrcweir pVal->Value >>= nSelectVal; 1488cdf0e10cSrcweir for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) 1489cdf0e10cSrcweir { 1490cdf0e10cSrcweir boost::shared_ptr<vcl::LabeledElement> pLabel( new vcl::LabeledElement( pRadioColumn.get(), 1 ) ); 1491cdf0e10cSrcweir pRadioColumn->addChild( pLabel ); 1492cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> pDependencyRow( new vcl::RowOrColumn( pLabel.get(), false ) ); 1493cdf0e10cSrcweir pLabel->setElement( pDependencyRow ); 1494cdf0e10cSrcweir aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, pDependencyRow ) ); 1495cdf0e10cSrcweir 1496cdf0e10cSrcweir RadioButton* pBtn = new RadioButton( pCurParent, m == 0 ? WB_GROUP : 0 ); 1497cdf0e10cSrcweir maControls.push_front( pBtn ); 1498cdf0e10cSrcweir pBtn->SetText( aChoices[m] ); 1499cdf0e10cSrcweir pBtn->Check( m == nSelectVal ); 1500cdf0e10cSrcweir pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); 1501cdf0e10cSrcweir if( aChoicesDisabled.getLength() > m && aChoicesDisabled[m] == sal_True ) 1502cdf0e10cSrcweir pBtn->Enable( sal_False ); 1503cdf0e10cSrcweir pBtn->Show(); 1504cdf0e10cSrcweir maPropertyToWindowMap[ aPropertyName ].push_back( pBtn ); 1505cdf0e10cSrcweir maControlToPropertyMap[pBtn] = aPropertyName; 1506cdf0e10cSrcweir maControlToNumValMap[pBtn] = m; 1507cdf0e10cSrcweir 1508cdf0e10cSrcweir // set help id 1509cdf0e10cSrcweir setHelpId( pBtn, aHelpIds, nCurHelpText ); 1510cdf0e10cSrcweir // set help text 1511cdf0e10cSrcweir setHelpText( pBtn, aHelpTexts, nCurHelpText ); 1512cdf0e10cSrcweir nCurHelpText++; 1513cdf0e10cSrcweir // add the radio button to the column 1514cdf0e10cSrcweir pLabel->setLabel( pBtn ); 1515cdf0e10cSrcweir } 1516cdf0e10cSrcweir } 1517cdf0e10cSrcweir else if( ( aCtrlType.equalsAscii( "List" ) || 1518cdf0e10cSrcweir aCtrlType.equalsAscii( "Range" ) || 1519cdf0e10cSrcweir aCtrlType.equalsAscii( "Edit" ) 1520cdf0e10cSrcweir ) && pCurParent ) 1521cdf0e10cSrcweir { 1522cdf0e10cSrcweir // create a row in the current column 1523cdf0e10cSrcweir boost::shared_ptr<vcl::RowOrColumn> pFieldColumn( new vcl::RowOrColumn( pCurColumn.get(), false ) ); 1524cdf0e10cSrcweir pCurColumn->addChild( pFieldColumn ); 1525cdf0e10cSrcweir aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, boost::shared_ptr<vcl::RowOrColumn> >( aPropertyName, pFieldColumn ) ); 1526cdf0e10cSrcweir 1527cdf0e10cSrcweir vcl::LabeledElement* pLabel = NULL; 1528cdf0e10cSrcweir if( aText.getLength() ) 1529cdf0e10cSrcweir { 1530cdf0e10cSrcweir // add a FixedText: 1531cdf0e10cSrcweir FixedText* pHeading = new FixedText( pCurParent, WB_VCENTER ); 1532cdf0e10cSrcweir maControls.push_front( pHeading ); 1533cdf0e10cSrcweir pHeading->SetText( aText ); 1534cdf0e10cSrcweir pHeading->Show(); 1535cdf0e10cSrcweir 1536cdf0e10cSrcweir // add to row 1537cdf0e10cSrcweir pLabel = new vcl::LabeledElement( pFieldColumn.get(), 2 ); 1538cdf0e10cSrcweir pFieldColumn->addChild( pLabel ); 1539cdf0e10cSrcweir pLabel->setLabel( pHeading ); 1540cdf0e10cSrcweir } 1541cdf0e10cSrcweir 1542cdf0e10cSrcweir if( aCtrlType.equalsAscii( "List" ) ) 1543cdf0e10cSrcweir { 1544cdf0e10cSrcweir ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER ); 1545cdf0e10cSrcweir maControls.push_front( pList ); 1546cdf0e10cSrcweir 1547cdf0e10cSrcweir // iterate options 1548cdf0e10cSrcweir for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) 1549cdf0e10cSrcweir { 1550cdf0e10cSrcweir pList->InsertEntry( aChoices[m] ); 1551cdf0e10cSrcweir } 1552cdf0e10cSrcweir sal_Int32 nSelectVal = 0; 1553cdf0e10cSrcweir PropertyValue* pVal = maPController->getValue( aPropertyName ); 1554cdf0e10cSrcweir if( pVal && pVal->Value.hasValue() ) 1555cdf0e10cSrcweir pVal->Value >>= nSelectVal; 1556cdf0e10cSrcweir pList->SelectEntryPos( static_cast<sal_uInt16>(nSelectVal) ); 1557cdf0e10cSrcweir pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); 1558cdf0e10cSrcweir pList->SetDropDownLineCount( static_cast<sal_uInt16>(aChoices.getLength()) ); 1559cdf0e10cSrcweir pList->Show(); 1560cdf0e10cSrcweir 1561cdf0e10cSrcweir // set help id 1562cdf0e10cSrcweir setHelpId( pList, aHelpIds, 0 ); 1563cdf0e10cSrcweir // set help text 1564cdf0e10cSrcweir setHelpText( pList, aHelpTexts, 0 ); 1565cdf0e10cSrcweir 1566cdf0e10cSrcweir maPropertyToWindowMap[ aPropertyName ].push_back( pList ); 1567cdf0e10cSrcweir maControlToPropertyMap[pList] = aPropertyName; 1568cdf0e10cSrcweir 1569cdf0e10cSrcweir // finish the pair 1570cdf0e10cSrcweir if( pLabel ) 1571cdf0e10cSrcweir pLabel->setElement( pList ); 1572cdf0e10cSrcweir else 1573cdf0e10cSrcweir pFieldColumn->addWindow( pList ); 1574cdf0e10cSrcweir } 1575cdf0e10cSrcweir else if( aCtrlType.equalsAscii( "Range" ) ) 1576cdf0e10cSrcweir { 1577cdf0e10cSrcweir NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN ); 1578cdf0e10cSrcweir maControls.push_front( pField ); 1579cdf0e10cSrcweir 1580cdf0e10cSrcweir // set min/max and current value 1581cdf0e10cSrcweir if( nMinValue != nMaxValue ) 1582cdf0e10cSrcweir { 1583cdf0e10cSrcweir pField->SetMin( nMinValue ); 1584cdf0e10cSrcweir pField->SetMax( nMaxValue ); 1585cdf0e10cSrcweir } 1586cdf0e10cSrcweir sal_Int64 nCurVal = 0; 1587cdf0e10cSrcweir PropertyValue* pVal = maPController->getValue( aPropertyName ); 1588cdf0e10cSrcweir if( pVal && pVal->Value.hasValue() ) 1589cdf0e10cSrcweir pVal->Value >>= nCurVal; 1590cdf0e10cSrcweir pField->SetValue( nCurVal ); 1591cdf0e10cSrcweir pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); 1592cdf0e10cSrcweir pField->Show(); 1593cdf0e10cSrcweir 1594cdf0e10cSrcweir // set help id 1595cdf0e10cSrcweir setHelpId( pField, aHelpIds, 0 ); 1596cdf0e10cSrcweir // set help text 1597cdf0e10cSrcweir setHelpText( pField, aHelpTexts, 0 ); 1598cdf0e10cSrcweir 1599cdf0e10cSrcweir maPropertyToWindowMap[ aPropertyName ].push_back( pField ); 1600cdf0e10cSrcweir maControlToPropertyMap[pField] = aPropertyName; 1601cdf0e10cSrcweir 1602cdf0e10cSrcweir // add to row 1603cdf0e10cSrcweir if( pLabel ) 1604cdf0e10cSrcweir pLabel->setElement( pField ); 1605cdf0e10cSrcweir else 1606cdf0e10cSrcweir pFieldColumn->addWindow( pField ); 1607cdf0e10cSrcweir } 1608cdf0e10cSrcweir else if( aCtrlType.equalsAscii( "Edit" ) ) 1609cdf0e10cSrcweir { 1610cdf0e10cSrcweir Edit* pField = new Edit( pCurParent, WB_BORDER ); 1611cdf0e10cSrcweir maControls.push_front( pField ); 1612cdf0e10cSrcweir 1613cdf0e10cSrcweir rtl::OUString aCurVal; 1614cdf0e10cSrcweir PropertyValue* pVal = maPController->getValue( aPropertyName ); 1615cdf0e10cSrcweir if( pVal && pVal->Value.hasValue() ) 1616cdf0e10cSrcweir pVal->Value >>= aCurVal; 1617cdf0e10cSrcweir pField->SetText( aCurVal ); 1618cdf0e10cSrcweir pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); 1619cdf0e10cSrcweir pField->Show(); 1620cdf0e10cSrcweir 1621cdf0e10cSrcweir // set help id 1622cdf0e10cSrcweir setHelpId( pField, aHelpIds, 0 ); 1623cdf0e10cSrcweir // set help text 1624cdf0e10cSrcweir setHelpText( pField, aHelpTexts, 0 ); 1625cdf0e10cSrcweir 1626cdf0e10cSrcweir maPropertyToWindowMap[ aPropertyName ].push_back( pField ); 1627cdf0e10cSrcweir maControlToPropertyMap[pField] = aPropertyName; 1628cdf0e10cSrcweir 1629cdf0e10cSrcweir // add to row 1630cdf0e10cSrcweir if( pLabel ) 1631cdf0e10cSrcweir pLabel->setElement( pField ); 1632cdf0e10cSrcweir else 1633cdf0e10cSrcweir pFieldColumn->addWindow( pField, 2 ); 1634cdf0e10cSrcweir } 1635cdf0e10cSrcweir } 1636cdf0e10cSrcweir else 1637cdf0e10cSrcweir { 1638cdf0e10cSrcweir DBG_ERROR( "Unsupported UI option" ); 1639cdf0e10cSrcweir } 1640cdf0e10cSrcweir 1641cdf0e10cSrcweir pCurColumn = pSaveCurColumn; 1642cdf0e10cSrcweir } 1643cdf0e10cSrcweir } 1644cdf0e10cSrcweir 1645cdf0e10cSrcweir // #i106506# if no brochure button, then the singular Pages radio button 1646cdf0e10cSrcweir // makes no sense, so replace it by a FixedText label 1647cdf0e10cSrcweir if( ! maNUpPage.maBrochureBtn.IsVisible() ) 1648cdf0e10cSrcweir { 1649cdf0e10cSrcweir if( maNUpPage.mxPagesBtnLabel.get() ) 1650cdf0e10cSrcweir { 1651cdf0e10cSrcweir maNUpPage.maPagesBoxTitleTxt.SetText( maNUpPage.maPagesBtn.GetText() ); 1652cdf0e10cSrcweir maNUpPage.maPagesBoxTitleTxt.Show( sal_True ); 1653cdf0e10cSrcweir maNUpPage.mxPagesBtnLabel->setLabel( &maNUpPage.maPagesBoxTitleTxt ); 1654cdf0e10cSrcweir maNUpPage.maPagesBtn.Show( sal_False ); 1655cdf0e10cSrcweir } 1656cdf0e10cSrcweir } 1657cdf0e10cSrcweir 1658cdf0e10cSrcweir // update enable states 1659cdf0e10cSrcweir checkOptionalControlDependencies(); 1660cdf0e10cSrcweir 1661cdf0e10cSrcweir // print range empty (currently math only) -> hide print range and spacer line 1662cdf0e10cSrcweir if( maJobPage.mxPrintRange->countElements() == 0 ) 1663cdf0e10cSrcweir { 1664cdf0e10cSrcweir maJobPage.mxPrintRange->show( false, false ); 1665cdf0e10cSrcweir maJobPage.maCopySpacer.Show( sal_False ); 1666cdf0e10cSrcweir maJobPage.maReverseOrderBox.Show( sal_False ); 1667cdf0e10cSrcweir } 1668cdf0e10cSrcweir else 1669cdf0e10cSrcweir { 1670cdf0e10cSrcweir // add an indent to the current column 1671cdf0e10cSrcweir vcl::Indenter* pIndent = new vcl::Indenter( maJobPage.mxPrintRange.get(), -1 ); 1672cdf0e10cSrcweir maJobPage.mxPrintRange->addChild( pIndent ); 1673cdf0e10cSrcweir // and create a column inside the indent 1674cdf0e10cSrcweir pIndent->setWindow( &maJobPage.maReverseOrderBox ); 1675cdf0e10cSrcweir maJobPage.maReverseOrderBox.Show( sal_True ); 1676cdf0e10cSrcweir } 1677cdf0e10cSrcweir 1678cdf0e10cSrcweir #ifdef WNT 1679cdf0e10cSrcweir // FIXME: the GetNativeControlRegion call on Windows has some issues 1680cdf0e10cSrcweir // (which skew the results of GetOptimalSize()) 1681cdf0e10cSrcweir // however fixing this thoroughly needs to take interaction with paint into 1682cdf0e10cSrcweir // account, making the right fix less simple. Fix this the right way 1683cdf0e10cSrcweir // at some point. For now simply add some space at the lowest element 1684cdf0e10cSrcweir size_t nIndex = maJobPage.getLayout()->countElements(); 1685cdf0e10cSrcweir if( nIndex > 0 ) // sanity check 1686cdf0e10cSrcweir maJobPage.getLayout()->setBorders( nIndex-1, 0, 0, 0, -1 ); 1687cdf0e10cSrcweir #endif 1688cdf0e10cSrcweir 1689cdf0e10cSrcweir // create auto mnemomnics now so they can be calculated in layout 1690cdf0e10cSrcweir ImplWindowAutoMnemonic( &maJobPage ); 1691cdf0e10cSrcweir ImplWindowAutoMnemonic( &maNUpPage ); 1692cdf0e10cSrcweir ImplWindowAutoMnemonic( &maOptionsPage ); 1693cdf0e10cSrcweir ImplWindowAutoMnemonic( this ); 1694cdf0e10cSrcweir 1695cdf0e10cSrcweir // calculate job page 1696cdf0e10cSrcweir Size aMaxSize = maJobPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ); 1697cdf0e10cSrcweir // and layout page 1698cdf0e10cSrcweir updateMaxSize( maNUpPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); 1699cdf0e10cSrcweir // and options page 1700cdf0e10cSrcweir updateMaxSize( maOptionsPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); 1701cdf0e10cSrcweir 1702cdf0e10cSrcweir for( std::vector< boost::shared_ptr<vcl::RowOrColumn> >::iterator it = aDynamicColumns.begin(); 1703cdf0e10cSrcweir it != aDynamicColumns.end(); ++it ) 1704cdf0e10cSrcweir { 1705cdf0e10cSrcweir Size aPageSize( (*it)->getOptimalSize( WINDOWSIZE_PREFERRED ) ); 1706cdf0e10cSrcweir updateMaxSize( aPageSize, aMaxSize ); 1707cdf0e10cSrcweir } 1708cdf0e10cSrcweir 1709cdf0e10cSrcweir // resize dialog if necessary 1710cdf0e10cSrcweir Size aTabSize = maTabCtrl.GetTabPageSizePixel(); 1711cdf0e10cSrcweir maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); 1712cdf0e10cSrcweir if( aMaxSize.Height() > aTabSize.Height() || aMaxSize.Width() > aTabSize.Width() ) 1713cdf0e10cSrcweir { 1714cdf0e10cSrcweir Size aCurSize( GetOutputSizePixel() ); 1715cdf0e10cSrcweir if( aMaxSize.Height() > aTabSize.Height() ) 1716cdf0e10cSrcweir { 1717cdf0e10cSrcweir aCurSize.Height() += aMaxSize.Height() - aTabSize.Height(); 1718cdf0e10cSrcweir aTabSize.Height() = aMaxSize.Height(); 1719cdf0e10cSrcweir } 1720cdf0e10cSrcweir if( aMaxSize.Width() > aTabSize.Width() ) 1721cdf0e10cSrcweir { 1722cdf0e10cSrcweir aCurSize.Width() += aMaxSize.Width() - aTabSize.Width(); 1723cdf0e10cSrcweir // and the tab ctrl needs more space, too 1724cdf0e10cSrcweir aTabSize.Width() = aMaxSize.Width(); 1725cdf0e10cSrcweir } 1726cdf0e10cSrcweir maTabCtrl.SetTabPageSizePixel( aTabSize ); 1727cdf0e10cSrcweir maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); 1728cdf0e10cSrcweir } 1729cdf0e10cSrcweir 1730cdf0e10cSrcweir Size aSz = getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ); 1731cdf0e10cSrcweir SetOutputSizePixel( aSz ); 1732cdf0e10cSrcweir } 1733cdf0e10cSrcweir 1734cdf0e10cSrcweir void PrintDialog::DataChanged( const DataChangedEvent& i_rDCEvt ) 1735cdf0e10cSrcweir { 1736cdf0e10cSrcweir // react on settings changed 1737cdf0e10cSrcweir if( i_rDCEvt.GetType() == DATACHANGED_SETTINGS ) 1738cdf0e10cSrcweir checkControlDependencies(); 1739cdf0e10cSrcweir ModalDialog::DataChanged( i_rDCEvt ); 1740cdf0e10cSrcweir } 1741cdf0e10cSrcweir 1742cdf0e10cSrcweir void PrintDialog::checkControlDependencies() 1743cdf0e10cSrcweir { 1744cdf0e10cSrcweir if( maJobPage.maCopyCountField.GetValue() > 1 ) 1745cdf0e10cSrcweir maJobPage.maCollateBox.Enable( maJobPage.mnCollateUIMode == 0 ); 1746cdf0e10cSrcweir else 1747cdf0e10cSrcweir maJobPage.maCollateBox.Enable( sal_False ); 1748cdf0e10cSrcweir 1749cdf0e10cSrcweir Image aImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateImg : maJobPage.maNoCollateImg ); 1750cdf0e10cSrcweir Image aHCImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateHCImg : maJobPage.maNoCollateHCImg ); 1751cdf0e10cSrcweir bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); 1752cdf0e10cSrcweir 1753cdf0e10cSrcweir Size aImgSize( aImg.GetSizePixel() ); 1754cdf0e10cSrcweir Size aHCImgSize( aHCImg.GetSizePixel() ); 1755cdf0e10cSrcweir 1756cdf0e10cSrcweir if( aHCImgSize.Width() > aImgSize.Width() ) 1757cdf0e10cSrcweir aImgSize.Width() = aHCImgSize.Width(); 1758cdf0e10cSrcweir if( aHCImgSize.Height() > aImgSize.Height() ) 1759cdf0e10cSrcweir aImgSize.Height() = aHCImgSize.Height(); 1760cdf0e10cSrcweir 1761cdf0e10cSrcweir // adjust size of image 1762cdf0e10cSrcweir maJobPage.maCollateImage.SetSizePixel( aImgSize ); 1763cdf0e10cSrcweir maJobPage.maCollateImage.SetImage( bHC ? aHCImg : aImg ); 1764cdf0e10cSrcweir maJobPage.maCollateImage.SetModeImage( aHCImg, BMP_COLOR_HIGHCONTRAST ); 1765cdf0e10cSrcweir maJobPage.getLayout()->resize(); 1766cdf0e10cSrcweir 1767cdf0e10cSrcweir // enable setup button only for printers that can be setup 1768cdf0e10cSrcweir bool bHaveSetup = maPController->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ); 1769cdf0e10cSrcweir maJobPage.maSetupButton.Enable( bHaveSetup ); 1770cdf0e10cSrcweir if( bHaveSetup ) 1771cdf0e10cSrcweir { 1772cdf0e10cSrcweir if( ! maJobPage.maSetupButton.IsVisible() ) 1773cdf0e10cSrcweir { 1774cdf0e10cSrcweir Point aPrinterPos( maJobPage.maPrinters.GetPosPixel() ); 1775cdf0e10cSrcweir Point aSetupPos( maJobPage.maSetupButton.GetPosPixel() ); 1776cdf0e10cSrcweir Size aPrinterSize( maJobPage.maPrinters.GetSizePixel() ); 1777cdf0e10cSrcweir aPrinterSize.Width() = aSetupPos.X() - aPrinterPos.X() - LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ).Width(); 1778cdf0e10cSrcweir maJobPage.maPrinters.SetSizePixel( aPrinterSize ); 1779cdf0e10cSrcweir maJobPage.maSetupButton.Show(); 1780cdf0e10cSrcweir getLayout()->resize(); 1781cdf0e10cSrcweir } 1782cdf0e10cSrcweir } 1783cdf0e10cSrcweir else 1784cdf0e10cSrcweir { 1785cdf0e10cSrcweir if( maJobPage.maSetupButton.IsVisible() ) 1786cdf0e10cSrcweir { 1787cdf0e10cSrcweir Point aPrinterPos( maJobPage.maPrinters.GetPosPixel() ); 1788cdf0e10cSrcweir Point aSetupPos( maJobPage.maSetupButton.GetPosPixel() ); 1789cdf0e10cSrcweir Size aPrinterSize( maJobPage.maPrinters.GetSizePixel() ); 1790cdf0e10cSrcweir Size aSetupSize( maJobPage.maSetupButton.GetSizePixel() ); 1791cdf0e10cSrcweir aPrinterSize.Width() = aSetupPos.X() + aSetupSize.Width() - aPrinterPos.X(); 1792cdf0e10cSrcweir maJobPage.maPrinters.SetSizePixel( aPrinterSize ); 1793cdf0e10cSrcweir maJobPage.maSetupButton.Hide(); 1794cdf0e10cSrcweir getLayout()->resize(); 1795cdf0e10cSrcweir } 1796cdf0e10cSrcweir } 1797cdf0e10cSrcweir } 1798cdf0e10cSrcweir 1799cdf0e10cSrcweir void PrintDialog::checkOptionalControlDependencies() 1800cdf0e10cSrcweir { 1801cdf0e10cSrcweir for( std::map< Window*, rtl::OUString >::iterator it = maControlToPropertyMap.begin(); 1802cdf0e10cSrcweir it != maControlToPropertyMap.end(); ++it ) 1803cdf0e10cSrcweir { 1804cdf0e10cSrcweir bool bShouldbeEnabled = maPController->isUIOptionEnabled( it->second ); 1805cdf0e10cSrcweir if( ! bShouldbeEnabled ) 1806cdf0e10cSrcweir { 1807cdf0e10cSrcweir // enable controls that are directly attached to a dependency anyway 1808cdf0e10cSrcweir // if the normally disabled controls get modified, change the dependency 1809cdf0e10cSrcweir // so the control would be enabled 1810cdf0e10cSrcweir // example: in print range "Print All" is selected, "Page Range" is then of course 1811cdf0e10cSrcweir // not selected and the Edit for the Page Range would be disabled 1812cdf0e10cSrcweir // as a convenience we should enable the Edit anyway and automatically select 1813cdf0e10cSrcweir // "Page Range" instead of "Print All" if the Edit gets modified 1814cdf0e10cSrcweir if( maReverseDependencySet.find( it->second ) != maReverseDependencySet.end() ) 1815cdf0e10cSrcweir { 1816cdf0e10cSrcweir rtl::OUString aDep( maPController->getDependency( it->second ) ); 1817cdf0e10cSrcweir // if the dependency is at least enabled, then enable this control anyway 1818cdf0e10cSrcweir if( aDep.getLength() && maPController->isUIOptionEnabled( aDep ) ) 1819cdf0e10cSrcweir bShouldbeEnabled = true; 1820cdf0e10cSrcweir } 1821cdf0e10cSrcweir } 1822cdf0e10cSrcweir 1823cdf0e10cSrcweir if( bShouldbeEnabled && dynamic_cast<RadioButton*>(it->first) ) 1824cdf0e10cSrcweir { 1825cdf0e10cSrcweir std::map< Window*, sal_Int32 >::const_iterator r_it = maControlToNumValMap.find( it->first ); 1826cdf0e10cSrcweir if( r_it != maControlToNumValMap.end() ) 1827cdf0e10cSrcweir { 1828cdf0e10cSrcweir bShouldbeEnabled = maPController->isUIChoiceEnabled( it->second, r_it->second ); 1829cdf0e10cSrcweir } 1830cdf0e10cSrcweir } 1831cdf0e10cSrcweir 1832cdf0e10cSrcweir 1833cdf0e10cSrcweir bool bIsEnabled = it->first->IsEnabled(); 1834cdf0e10cSrcweir // Enable does not do a change check first, so can be less cheap than expected 1835cdf0e10cSrcweir if( bShouldbeEnabled != bIsEnabled ) 1836cdf0e10cSrcweir it->first->Enable( bShouldbeEnabled ); 1837cdf0e10cSrcweir } 1838cdf0e10cSrcweir } 1839cdf0e10cSrcweir 1840cdf0e10cSrcweir static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* i_pRepl, sal_Int32 i_nReplLen, const rtl::OUString& i_rRepl ) 1841cdf0e10cSrcweir { 1842cdf0e10cSrcweir sal_Int32 nPos = i_rOrig.indexOfAsciiL( i_pRepl, i_nReplLen ); 1843cdf0e10cSrcweir if( nPos != -1 ) 1844cdf0e10cSrcweir { 1845cdf0e10cSrcweir rtl::OUStringBuffer aBuf( i_rOrig.getLength() ); 1846cdf0e10cSrcweir aBuf.append( i_rOrig.getStr(), nPos ); 1847cdf0e10cSrcweir aBuf.append( i_rRepl ); 1848cdf0e10cSrcweir if( nPos + i_nReplLen < i_rOrig.getLength() ) 1849cdf0e10cSrcweir aBuf.append( i_rOrig.getStr() + nPos + i_nReplLen ); 1850cdf0e10cSrcweir return aBuf.makeStringAndClear(); 1851cdf0e10cSrcweir } 1852cdf0e10cSrcweir return i_rOrig; 1853cdf0e10cSrcweir } 1854cdf0e10cSrcweir 1855cdf0e10cSrcweir void PrintDialog::updatePrinterText() 1856cdf0e10cSrcweir { 1857cdf0e10cSrcweir String aDefPrt( Printer::GetDefaultPrinterName() ); 1858cdf0e10cSrcweir const QueueInfo* pInfo = Printer::GetQueueInfo( maJobPage.maPrinters.GetSelectEntry(), true ); 1859cdf0e10cSrcweir if( pInfo ) 1860cdf0e10cSrcweir { 1861cdf0e10cSrcweir maJobPage.maLocationTxt.SetText( pInfo->GetLocation() ); 1862cdf0e10cSrcweir maJobPage.maCommentTxt.SetText( pInfo->GetComment() ); 1863cdf0e10cSrcweir // FIXME: status text 1864cdf0e10cSrcweir rtl::OUString aStatus; 1865cdf0e10cSrcweir if( aDefPrt == pInfo->GetPrinterName() ) 1866cdf0e10cSrcweir aStatus = maDefPrtText; 1867cdf0e10cSrcweir maJobPage.maStatusTxt.SetText( aStatus ); 1868cdf0e10cSrcweir } 1869cdf0e10cSrcweir else 1870cdf0e10cSrcweir { 1871cdf0e10cSrcweir maJobPage.maLocationTxt.SetText( String() ); 1872cdf0e10cSrcweir maJobPage.maCommentTxt.SetText( String() ); 1873cdf0e10cSrcweir maJobPage.maStatusTxt.SetText( String() ); 1874cdf0e10cSrcweir } 1875cdf0e10cSrcweir } 1876cdf0e10cSrcweir 1877cdf0e10cSrcweir void PrintDialog::setPreviewText( sal_Int32 ) 1878cdf0e10cSrcweir { 1879cdf0e10cSrcweir rtl::OUString aNewText( searchAndReplace( maPageStr, "%n", 2, rtl::OUString::valueOf( mnCachedPages ) ) ); 1880cdf0e10cSrcweir maNumPagesText.SetText( aNewText ); 1881cdf0e10cSrcweir 1882cdf0e10cSrcweir // if layout is already established the refresh layout of 1883cdf0e10cSrcweir // preview controls since text length may have changes 1884cdf0e10cSrcweir if( mxPreviewCtrls.get() ) 1885cdf0e10cSrcweir mxPreviewCtrls->setManagedArea( mxPreviewCtrls->getManagedArea() ); 1886cdf0e10cSrcweir } 1887cdf0e10cSrcweir 1888cdf0e10cSrcweir void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) 1889cdf0e10cSrcweir { 1890cdf0e10cSrcweir // page range may have changed depending on options 1891cdf0e10cSrcweir sal_Int32 nPages = maPController->getFilteredPageCount(); 1892cdf0e10cSrcweir mnCachedPages = nPages; 1893cdf0e10cSrcweir 1894cdf0e10cSrcweir if( mnCurPage >= nPages ) 1895cdf0e10cSrcweir mnCurPage = nPages-1; 1896cdf0e10cSrcweir if( mnCurPage < 0 ) 1897cdf0e10cSrcweir mnCurPage = 0; 1898cdf0e10cSrcweir 1899cdf0e10cSrcweir setPreviewText( mnCurPage ); 1900cdf0e10cSrcweir 1901cdf0e10cSrcweir maPageEdit.SetMin( 1 ); 1902cdf0e10cSrcweir maPageEdit.SetMax( nPages ); 1903cdf0e10cSrcweir 1904cdf0e10cSrcweir if( i_bNewPage ) 1905cdf0e10cSrcweir { 1906cdf0e10cSrcweir const MapMode aMapMode( MAP_100TH_MM ); 1907cdf0e10cSrcweir GDIMetaFile aMtf; 1908cdf0e10cSrcweir boost::shared_ptr<Printer> aPrt( maPController->getPrinter() ); 1909cdf0e10cSrcweir if( nPages > 0 ) 1910cdf0e10cSrcweir { 1911cdf0e10cSrcweir PrinterController::PageSize aPageSize = 1912cdf0e10cSrcweir maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); 1913cdf0e10cSrcweir if( ! aPageSize.bFullPaper ) 1914cdf0e10cSrcweir { 1915cdf0e10cSrcweir Point aOff( aPrt->PixelToLogic( aPrt->GetPageOffsetPixel(), aMapMode ) ); 1916cdf0e10cSrcweir aMtf.Move( aOff.X(), aOff.Y() ); 1917cdf0e10cSrcweir } 1918cdf0e10cSrcweir } 1919cdf0e10cSrcweir 1920cdf0e10cSrcweir Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); 1921cdf0e10cSrcweir maPreviewWindow.setPreview( aMtf, aCurPageSize, 1922cdf0e10cSrcweir aPrt->GetPaperName( false ), 1923cdf0e10cSrcweir nPages > 0 ? rtl::OUString() : maNoPageStr, 1924cdf0e10cSrcweir aPrt->ImplGetDPIX(), aPrt->ImplGetDPIY(), 1925cdf0e10cSrcweir aPrt->GetPrinterOptions().IsConvertToGreyscales() 1926cdf0e10cSrcweir ); 1927cdf0e10cSrcweir 1928cdf0e10cSrcweir maForwardBtn.Enable( mnCurPage < nPages-1 ); 1929cdf0e10cSrcweir maBackwardBtn.Enable( mnCurPage != 0 ); 1930cdf0e10cSrcweir maPageEdit.Enable( nPages > 1 ); 1931cdf0e10cSrcweir } 1932cdf0e10cSrcweir } 1933cdf0e10cSrcweir 1934cdf0e10cSrcweir Size PrintDialog::getJobPageSize() 1935cdf0e10cSrcweir { 1936cdf0e10cSrcweir if( maFirstPageSize.Width() == 0 && maFirstPageSize.Height() == 0) 1937cdf0e10cSrcweir { 1938cdf0e10cSrcweir maFirstPageSize = maNupPortraitSize; 1939cdf0e10cSrcweir GDIMetaFile aMtf; 1940cdf0e10cSrcweir if( maPController->getPageCountProtected() > 0 ) 1941cdf0e10cSrcweir { 1942cdf0e10cSrcweir PrinterController::PageSize aPageSize = maPController->getPageFile( 0, aMtf, true ); 1943cdf0e10cSrcweir maFirstPageSize = aPageSize.aSize; 1944cdf0e10cSrcweir } 1945cdf0e10cSrcweir } 1946cdf0e10cSrcweir return maFirstPageSize; 1947cdf0e10cSrcweir } 1948cdf0e10cSrcweir 1949cdf0e10cSrcweir void PrintDialog::updateNupFromPages() 1950cdf0e10cSrcweir { 1951cdf0e10cSrcweir long nPages = long(maNUpPage.maNupPagesBox.GetEntryData(maNUpPage.maNupPagesBox.GetSelectEntryPos())); 1952cdf0e10cSrcweir int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); 1953cdf0e10cSrcweir int nCols = int(maNUpPage.maNupColEdt.GetValue()); 1954cdf0e10cSrcweir long nPageMargin = long(maNUpPage.maPageMarginEdt.Denormalize(maNUpPage.maPageMarginEdt.GetValue( FUNIT_100TH_MM ))); 1955cdf0e10cSrcweir long nSheetMargin = long(maNUpPage.maSheetMarginEdt.Denormalize(maNUpPage.maSheetMarginEdt.GetValue( FUNIT_100TH_MM ))); 1956cdf0e10cSrcweir bool bCustom = false; 1957cdf0e10cSrcweir 1958cdf0e10cSrcweir if( nPages == 1 ) 1959cdf0e10cSrcweir { 1960cdf0e10cSrcweir nRows = nCols = 1; 1961cdf0e10cSrcweir nSheetMargin = 0; 1962cdf0e10cSrcweir nPageMargin = 0; 1963cdf0e10cSrcweir } 1964cdf0e10cSrcweir else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 ) 1965cdf0e10cSrcweir { 1966cdf0e10cSrcweir Size aJobPageSize( getJobPageSize() ); 1967cdf0e10cSrcweir bool bPortrait = aJobPageSize.Width() < aJobPageSize.Height(); 1968cdf0e10cSrcweir if( nPages == 2 ) 1969cdf0e10cSrcweir { 1970cdf0e10cSrcweir if( bPortrait ) 1971cdf0e10cSrcweir nRows = 1, nCols = 2; 1972cdf0e10cSrcweir else 1973cdf0e10cSrcweir nRows = 2, nCols = 1; 1974cdf0e10cSrcweir } 1975cdf0e10cSrcweir else if( nPages == 4 ) 1976cdf0e10cSrcweir nRows = nCols = 2; 1977cdf0e10cSrcweir else if( nPages == 6 ) 1978cdf0e10cSrcweir { 1979cdf0e10cSrcweir if( bPortrait ) 1980cdf0e10cSrcweir nRows = 2, nCols = 3; 1981cdf0e10cSrcweir else 1982cdf0e10cSrcweir nRows = 3, nCols = 2; 1983cdf0e10cSrcweir } 1984cdf0e10cSrcweir else if( nPages == 9 ) 1985cdf0e10cSrcweir nRows = nCols = 3; 1986cdf0e10cSrcweir else if( nPages == 16 ) 1987cdf0e10cSrcweir nRows = nCols = 4; 1988cdf0e10cSrcweir nPageMargin = 0; 1989cdf0e10cSrcweir nSheetMargin = 0; 1990cdf0e10cSrcweir } 1991cdf0e10cSrcweir else 1992cdf0e10cSrcweir bCustom = true; 1993cdf0e10cSrcweir 1994cdf0e10cSrcweir if( nPages > 1 ) 1995cdf0e10cSrcweir { 1996cdf0e10cSrcweir // set upper limits for margins based on job page size and rows/columns 1997cdf0e10cSrcweir Size aSize( getJobPageSize() ); 1998cdf0e10cSrcweir 1999cdf0e10cSrcweir // maximum sheet distance: 1/2 sheet 2000cdf0e10cSrcweir long nHorzMax = aSize.Width()/2; 2001cdf0e10cSrcweir long nVertMax = aSize.Height()/2; 2002cdf0e10cSrcweir if( nSheetMargin > nHorzMax ) 2003cdf0e10cSrcweir nSheetMargin = nHorzMax; 2004cdf0e10cSrcweir if( nSheetMargin > nVertMax ) 2005cdf0e10cSrcweir nSheetMargin = nVertMax; 2006cdf0e10cSrcweir 2007cdf0e10cSrcweir maNUpPage.maSheetMarginEdt.SetMax( 2008cdf0e10cSrcweir maNUpPage.maSheetMarginEdt.Normalize( 2009cdf0e10cSrcweir nHorzMax > nVertMax ? nVertMax : nHorzMax ), FUNIT_100TH_MM ); 2010cdf0e10cSrcweir 2011cdf0e10cSrcweir // maximum page distance 2012cdf0e10cSrcweir nHorzMax = (aSize.Width() - 2*nSheetMargin); 2013cdf0e10cSrcweir if( nCols > 1 ) 2014cdf0e10cSrcweir nHorzMax /= (nCols-1); 2015cdf0e10cSrcweir nVertMax = (aSize.Height() - 2*nSheetMargin); 2016cdf0e10cSrcweir if( nRows > 1 ) 2017cdf0e10cSrcweir nHorzMax /= (nRows-1); 2018cdf0e10cSrcweir 2019cdf0e10cSrcweir if( nPageMargin > nHorzMax ) 2020cdf0e10cSrcweir nPageMargin = nHorzMax; 2021cdf0e10cSrcweir if( nPageMargin > nVertMax ) 2022cdf0e10cSrcweir nPageMargin = nVertMax; 2023cdf0e10cSrcweir 2024cdf0e10cSrcweir maNUpPage.maPageMarginEdt.SetMax( 2025cdf0e10cSrcweir maNUpPage.maSheetMarginEdt.Normalize( 2026cdf0e10cSrcweir nHorzMax > nVertMax ? nVertMax : nHorzMax ), FUNIT_100TH_MM ); 2027cdf0e10cSrcweir } 2028cdf0e10cSrcweir 2029cdf0e10cSrcweir maNUpPage.maNupRowsEdt.SetValue( nRows ); 2030cdf0e10cSrcweir maNUpPage.maNupColEdt.SetValue( nCols ); 2031cdf0e10cSrcweir maNUpPage.maPageMarginEdt.SetValue( maNUpPage.maPageMarginEdt.Normalize( nPageMargin ), FUNIT_100TH_MM ); 2032cdf0e10cSrcweir maNUpPage.maSheetMarginEdt.SetValue( maNUpPage.maSheetMarginEdt.Normalize( nSheetMargin ), FUNIT_100TH_MM ); 2033cdf0e10cSrcweir 2034cdf0e10cSrcweir maNUpPage.showAdvancedControls( bCustom ); 2035cdf0e10cSrcweir if( bCustom ) 2036cdf0e10cSrcweir { 2037cdf0e10cSrcweir // see if we have to enlarge the dialog to make the tab page fit 2038cdf0e10cSrcweir Size aCurSize( maNUpPage.getLayout()->getOptimalSize( WINDOWSIZE_PREFERRED ) ); 2039cdf0e10cSrcweir Size aTabSize( maTabCtrl.GetTabPageSizePixel() ); 2040cdf0e10cSrcweir if( aTabSize.Height() < aCurSize.Height() ) 2041cdf0e10cSrcweir { 2042cdf0e10cSrcweir Size aDlgSize( GetSizePixel() ); 2043cdf0e10cSrcweir aDlgSize.Height() += aCurSize.Height() - aTabSize.Height(); 2044cdf0e10cSrcweir SetSizePixel( aDlgSize ); 2045cdf0e10cSrcweir } 2046cdf0e10cSrcweir } 2047cdf0e10cSrcweir 2048cdf0e10cSrcweir updateNup(); 2049cdf0e10cSrcweir } 2050cdf0e10cSrcweir 2051cdf0e10cSrcweir void PrintDialog::updateNup() 2052cdf0e10cSrcweir { 2053cdf0e10cSrcweir int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); 2054cdf0e10cSrcweir int nCols = int(maNUpPage.maNupColEdt.GetValue()); 2055cdf0e10cSrcweir long nPageMargin = long(maNUpPage.maPageMarginEdt.Denormalize(maNUpPage.maPageMarginEdt.GetValue( FUNIT_100TH_MM ))); 2056cdf0e10cSrcweir long nSheetMargin = long(maNUpPage.maSheetMarginEdt.Denormalize(maNUpPage.maSheetMarginEdt.GetValue( FUNIT_100TH_MM ))); 2057cdf0e10cSrcweir 2058cdf0e10cSrcweir PrinterController::MultiPageSetup aMPS; 2059cdf0e10cSrcweir aMPS.nRows = nRows; 2060cdf0e10cSrcweir aMPS.nColumns = nCols; 2061cdf0e10cSrcweir aMPS.nRepeat = 1; 2062cdf0e10cSrcweir aMPS.nLeftMargin = 2063cdf0e10cSrcweir aMPS.nTopMargin = 2064cdf0e10cSrcweir aMPS.nRightMargin = 2065cdf0e10cSrcweir aMPS.nBottomMargin = nSheetMargin; 2066cdf0e10cSrcweir 2067cdf0e10cSrcweir aMPS.nHorizontalSpacing = 2068cdf0e10cSrcweir aMPS.nVerticalSpacing = nPageMargin; 2069cdf0e10cSrcweir 2070cdf0e10cSrcweir aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked(); 2071cdf0e10cSrcweir 2072cdf0e10cSrcweir int nOrderMode = int(sal_IntPtr(maNUpPage.maNupOrderBox.GetEntryData( 2073cdf0e10cSrcweir maNUpPage.maNupOrderBox.GetSelectEntryPos() ))); 2074cdf0e10cSrcweir if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTB ) 2075cdf0e10cSrcweir aMPS.nOrder = PrinterController::LRTB; 2076cdf0e10cSrcweir else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TBLR ) 2077cdf0e10cSrcweir aMPS.nOrder = PrinterController::TBLR; 2078cdf0e10cSrcweir else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_RLTB ) 2079cdf0e10cSrcweir aMPS.nOrder = PrinterController::RLTB; 2080cdf0e10cSrcweir else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TBRL ) 2081cdf0e10cSrcweir aMPS.nOrder = PrinterController::TBRL; 2082cdf0e10cSrcweir 2083cdf0e10cSrcweir int nOrientationMode = int(sal_IntPtr(maNUpPage.maNupOrientationBox.GetEntryData( 2084cdf0e10cSrcweir maNUpPage.maNupOrientationBox.GetSelectEntryPos() ))); 2085cdf0e10cSrcweir if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE ) 2086cdf0e10cSrcweir aMPS.aPaperSize = maNupLandscapeSize; 2087cdf0e10cSrcweir else if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT ) 2088cdf0e10cSrcweir aMPS.aPaperSize = maNupPortraitSize; 2089cdf0e10cSrcweir else // automatic mode 2090cdf0e10cSrcweir { 2091cdf0e10cSrcweir // get size of first real page to see if it is portrait or landscape 2092cdf0e10cSrcweir // we assume same page sizes for all the pages for this 2093cdf0e10cSrcweir Size aPageSize = getJobPageSize(); 2094cdf0e10cSrcweir 2095cdf0e10cSrcweir Size aMultiSize( aPageSize.Width() * nCols, aPageSize.Height() * nRows ); 2096cdf0e10cSrcweir if( aMultiSize.Width() > aMultiSize.Height() ) // fits better on landscape 2097cdf0e10cSrcweir aMPS.aPaperSize = maNupLandscapeSize; 2098cdf0e10cSrcweir else 2099cdf0e10cSrcweir aMPS.aPaperSize = maNupPortraitSize; 2100cdf0e10cSrcweir } 2101cdf0e10cSrcweir 2102cdf0e10cSrcweir maPController->setMultipage( aMPS ); 2103cdf0e10cSrcweir 2104cdf0e10cSrcweir maNUpPage.maNupOrderWin.setValues( nOrderMode, nCols, nRows ); 2105cdf0e10cSrcweir 2106cdf0e10cSrcweir preparePreview( true, true ); 2107cdf0e10cSrcweir } 2108cdf0e10cSrcweir 2109cdf0e10cSrcweir IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) 2110cdf0e10cSrcweir { 2111cdf0e10cSrcweir if( pBox == &maJobPage.maPrinters ) 2112cdf0e10cSrcweir { 2113cdf0e10cSrcweir String aNewPrinter( pBox->GetSelectEntry() ); 2114cdf0e10cSrcweir // set new printer 2115cdf0e10cSrcweir maPController->setPrinter( boost::shared_ptr<Printer>( new Printer( aNewPrinter ) ) ); 2116cdf0e10cSrcweir maPController->resetPrinterOptions( maOptionsPage.maToFileBox.IsChecked() ); 2117cdf0e10cSrcweir // update text fields 2118cdf0e10cSrcweir updatePrinterText(); 2119cdf0e10cSrcweir preparePreview( true, false ); 2120cdf0e10cSrcweir } 2121cdf0e10cSrcweir else if( pBox == &maNUpPage.maNupOrientationBox || pBox == &maNUpPage.maNupOrderBox ) 2122cdf0e10cSrcweir { 2123cdf0e10cSrcweir updateNup(); 2124cdf0e10cSrcweir } 2125cdf0e10cSrcweir else if( pBox == &maNUpPage.maNupPagesBox ) 2126cdf0e10cSrcweir { 2127cdf0e10cSrcweir if( !maNUpPage.maPagesBtn.IsChecked() ) 2128cdf0e10cSrcweir maNUpPage.maPagesBtn.Check(); 2129cdf0e10cSrcweir updateNupFromPages(); 2130cdf0e10cSrcweir } 2131cdf0e10cSrcweir 2132cdf0e10cSrcweir return 0; 2133cdf0e10cSrcweir } 2134cdf0e10cSrcweir 2135cdf0e10cSrcweir IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) 2136cdf0e10cSrcweir { 2137cdf0e10cSrcweir if( pButton == &maOKButton || pButton == &maCancelButton ) 2138cdf0e10cSrcweir { 2139cdf0e10cSrcweir storeToSettings(); 2140cdf0e10cSrcweir EndDialog( pButton == &maOKButton ); 2141cdf0e10cSrcweir } 2142cdf0e10cSrcweir else if( pButton == &maHelpButton ) 2143cdf0e10cSrcweir { 2144cdf0e10cSrcweir // start help system 2145cdf0e10cSrcweir Help* pHelp = Application::GetHelp(); 2146cdf0e10cSrcweir if( pHelp ) 2147cdf0e10cSrcweir { 2148cdf0e10cSrcweir pHelp->Start( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:OK" ) ), &maOKButton ); 2149cdf0e10cSrcweir } 2150cdf0e10cSrcweir } 2151cdf0e10cSrcweir else if( pButton == &maForwardBtn ) 2152cdf0e10cSrcweir { 2153cdf0e10cSrcweir previewForward(); 2154cdf0e10cSrcweir } 2155cdf0e10cSrcweir else if( pButton == &maBackwardBtn ) 2156cdf0e10cSrcweir { 2157cdf0e10cSrcweir previewBackward(); 2158cdf0e10cSrcweir } 2159cdf0e10cSrcweir else if( pButton == &maOptionsPage.maToFileBox ) 2160cdf0e10cSrcweir { 2161cdf0e10cSrcweir maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); 2162cdf0e10cSrcweir maPController->resetPrinterOptions( maOptionsPage.maToFileBox.IsChecked() ); 2163cdf0e10cSrcweir getLayout()->resize(); 2164cdf0e10cSrcweir preparePreview( true, true ); 2165cdf0e10cSrcweir } 2166cdf0e10cSrcweir else if( pButton == &maNUpPage.maBrochureBtn ) 2167cdf0e10cSrcweir { 2168cdf0e10cSrcweir PropertyValue* pVal = getValueForWindow( pButton ); 2169cdf0e10cSrcweir if( pVal ) 2170cdf0e10cSrcweir { 2171cdf0e10cSrcweir sal_Bool bVal = maNUpPage.maBrochureBtn.IsChecked(); 2172cdf0e10cSrcweir pVal->Value <<= bVal; 2173cdf0e10cSrcweir 2174cdf0e10cSrcweir checkOptionalControlDependencies(); 2175cdf0e10cSrcweir 2176cdf0e10cSrcweir // update preview and page settings 2177cdf0e10cSrcweir preparePreview(); 2178cdf0e10cSrcweir } 2179cdf0e10cSrcweir if( maNUpPage.maBrochureBtn.IsChecked() ) 2180cdf0e10cSrcweir { 2181cdf0e10cSrcweir maNUpPage.maNupPagesBox.SelectEntryPos( 0 ); 2182cdf0e10cSrcweir updateNupFromPages(); 2183cdf0e10cSrcweir maNUpPage.showAdvancedControls( false ); 2184cdf0e10cSrcweir maNUpPage.enableNupControls( false ); 2185cdf0e10cSrcweir } 2186cdf0e10cSrcweir } 2187cdf0e10cSrcweir else if( pButton == &maNUpPage.maPagesBtn ) 2188cdf0e10cSrcweir { 2189cdf0e10cSrcweir maNUpPage.enableNupControls( true ); 2190cdf0e10cSrcweir updateNupFromPages(); 2191cdf0e10cSrcweir } 2192cdf0e10cSrcweir else if( pButton == &maJobPage.maDetailsBtn ) 2193cdf0e10cSrcweir { 2194cdf0e10cSrcweir bool bShow = maJobPage.maDetailsBtn.IsChecked(); 2195cdf0e10cSrcweir maJobPage.mxDetails->show( bShow ); 2196cdf0e10cSrcweir if( bShow ) 2197cdf0e10cSrcweir { 2198cdf0e10cSrcweir maDetailsCollapsedSize = GetOutputSizePixel(); 2199cdf0e10cSrcweir // enlarge dialog if necessary 2200cdf0e10cSrcweir Size aMinSize( maJobPage.getLayout()->getOptimalSize( WINDOWSIZE_MINIMUM ) ); 2201cdf0e10cSrcweir Size aCurSize( maJobPage.GetSizePixel() ); 2202cdf0e10cSrcweir if( aCurSize.Height() < aMinSize.Height() ) 2203cdf0e10cSrcweir { 2204cdf0e10cSrcweir Size aDlgSize( GetOutputSizePixel() ); 2205cdf0e10cSrcweir aDlgSize.Height() += aMinSize.Height() - aCurSize.Height(); 2206cdf0e10cSrcweir SetOutputSizePixel( aDlgSize ); 2207cdf0e10cSrcweir } 2208cdf0e10cSrcweir maDetailsExpandedSize = GetOutputSizePixel(); 2209cdf0e10cSrcweir } 2210cdf0e10cSrcweir else if( maDetailsCollapsedSize.Width() > 0 && 2211cdf0e10cSrcweir maDetailsCollapsedSize.Height() > 0 ) 2212cdf0e10cSrcweir { 2213cdf0e10cSrcweir // if the user did not resize the dialog 2214cdf0e10cSrcweir // make it smaller again on collapsing the details 2215cdf0e10cSrcweir Size aDlgSize( GetOutputSizePixel() ); 2216cdf0e10cSrcweir if( aDlgSize == maDetailsExpandedSize && 2217cdf0e10cSrcweir aDlgSize.Height() > maDetailsCollapsedSize.Height() ) 2218cdf0e10cSrcweir { 2219cdf0e10cSrcweir SetOutputSizePixel( maDetailsCollapsedSize ); 2220cdf0e10cSrcweir } 2221cdf0e10cSrcweir } 2222cdf0e10cSrcweir } 2223cdf0e10cSrcweir else if( pButton == &maJobPage.maCollateBox ) 2224cdf0e10cSrcweir { 2225cdf0e10cSrcweir maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), 2226cdf0e10cSrcweir makeAny( sal_Bool(isCollate()) ) ); 2227cdf0e10cSrcweir checkControlDependencies(); 2228cdf0e10cSrcweir } 2229cdf0e10cSrcweir else if( pButton == &maJobPage.maReverseOrderBox ) 2230cdf0e10cSrcweir { 2231cdf0e10cSrcweir sal_Bool bChecked = maJobPage.maReverseOrderBox.IsChecked(); 2232cdf0e10cSrcweir maPController->setReversePrint( bChecked ); 2233cdf0e10cSrcweir maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverse" ) ), 2234cdf0e10cSrcweir makeAny( bChecked ) ); 2235cdf0e10cSrcweir preparePreview( true, true ); 2236cdf0e10cSrcweir } 2237cdf0e10cSrcweir else if( pButton == &maNUpPage.maBorderCB ) 2238cdf0e10cSrcweir { 2239cdf0e10cSrcweir updateNup(); 2240cdf0e10cSrcweir } 2241cdf0e10cSrcweir else 2242cdf0e10cSrcweir { 2243cdf0e10cSrcweir if( pButton == &maJobPage.maSetupButton ) 2244cdf0e10cSrcweir { 2245cdf0e10cSrcweir maPController->setupPrinter( this ); 2246cdf0e10cSrcweir preparePreview( true, true ); 2247cdf0e10cSrcweir } 2248cdf0e10cSrcweir checkControlDependencies(); 2249cdf0e10cSrcweir } 2250cdf0e10cSrcweir return 0; 2251cdf0e10cSrcweir } 2252cdf0e10cSrcweir 2253cdf0e10cSrcweir IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) 2254cdf0e10cSrcweir { 2255cdf0e10cSrcweir checkControlDependencies(); 2256cdf0e10cSrcweir if( pEdit == &maNUpPage.maNupRowsEdt || pEdit == &maNUpPage.maNupColEdt || 2257cdf0e10cSrcweir pEdit == &maNUpPage.maSheetMarginEdt || pEdit == &maNUpPage.maPageMarginEdt 2258cdf0e10cSrcweir ) 2259cdf0e10cSrcweir { 2260cdf0e10cSrcweir updateNupFromPages(); 2261cdf0e10cSrcweir } 2262cdf0e10cSrcweir else if( pEdit == &maPageEdit ) 2263cdf0e10cSrcweir { 2264cdf0e10cSrcweir mnCurPage = sal_Int32( maPageEdit.GetValue() - 1 ); 2265cdf0e10cSrcweir preparePreview( true, true ); 2266cdf0e10cSrcweir } 2267cdf0e10cSrcweir else if( pEdit == &maJobPage.maCopyCountField ) 2268cdf0e10cSrcweir { 2269cdf0e10cSrcweir maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), 2270cdf0e10cSrcweir makeAny( sal_Int32(maJobPage.maCopyCountField.GetValue()) ) ); 2271cdf0e10cSrcweir maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), 2272cdf0e10cSrcweir makeAny( sal_Bool(isCollate()) ) ); 2273cdf0e10cSrcweir } 2274cdf0e10cSrcweir return 0; 2275cdf0e10cSrcweir } 2276cdf0e10cSrcweir 2277cdf0e10cSrcweir IMPL_LINK( PrintDialog, UIOptionsChanged, void*, EMPTYARG ) 2278cdf0e10cSrcweir { 2279cdf0e10cSrcweir checkOptionalControlDependencies(); 2280cdf0e10cSrcweir return 0; 2281cdf0e10cSrcweir } 2282cdf0e10cSrcweir 2283cdf0e10cSrcweir PropertyValue* PrintDialog::getValueForWindow( Window* i_pWindow ) const 2284cdf0e10cSrcweir { 2285cdf0e10cSrcweir PropertyValue* pVal = NULL; 2286cdf0e10cSrcweir std::map< Window*, rtl::OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow ); 2287cdf0e10cSrcweir if( it != maControlToPropertyMap.end() ) 2288cdf0e10cSrcweir { 2289cdf0e10cSrcweir pVal = maPController->getValue( it->second ); 2290cdf0e10cSrcweir DBG_ASSERT( pVal, "property value not found" ); 2291cdf0e10cSrcweir } 2292cdf0e10cSrcweir else 2293cdf0e10cSrcweir { 2294cdf0e10cSrcweir DBG_ERROR( "changed control not in property map" ); 2295cdf0e10cSrcweir } 2296cdf0e10cSrcweir return pVal; 2297cdf0e10cSrcweir } 2298cdf0e10cSrcweir 2299cdf0e10cSrcweir void PrintDialog::updateWindowFromProperty( const rtl::OUString& i_rProperty ) 2300cdf0e10cSrcweir { 2301cdf0e10cSrcweir beans::PropertyValue* pValue = maPController->getValue( i_rProperty ); 2302cdf0e10cSrcweir std::map< rtl::OUString, std::vector< Window* > >::const_iterator it = maPropertyToWindowMap.find( i_rProperty ); 2303cdf0e10cSrcweir if( pValue && it != maPropertyToWindowMap.end() ) 2304cdf0e10cSrcweir { 2305cdf0e10cSrcweir const std::vector< Window* >& rWindows( it->second ); 2306cdf0e10cSrcweir if( ! rWindows.empty() ) 2307cdf0e10cSrcweir { 2308cdf0e10cSrcweir sal_Bool bVal = sal_False; 2309cdf0e10cSrcweir sal_Int32 nVal = -1; 2310cdf0e10cSrcweir if( pValue->Value >>= bVal ) 2311cdf0e10cSrcweir { 2312cdf0e10cSrcweir // we should have a CheckBox for this one 2313cdf0e10cSrcweir CheckBox* pBox = dynamic_cast< CheckBox* >( rWindows.front() ); 2314cdf0e10cSrcweir if( pBox ) 2315cdf0e10cSrcweir { 2316cdf0e10cSrcweir pBox->Check( bVal ); 2317cdf0e10cSrcweir } 2318cdf0e10cSrcweir else if( i_rProperty.equalsAscii( "PrintProspect" ) ) 2319cdf0e10cSrcweir { 2320cdf0e10cSrcweir // EVIL special case 2321cdf0e10cSrcweir if( bVal ) 2322cdf0e10cSrcweir maNUpPage.maBrochureBtn.Check(); 2323cdf0e10cSrcweir else 2324cdf0e10cSrcweir maNUpPage.maPagesBtn.Check(); 2325cdf0e10cSrcweir } 2326cdf0e10cSrcweir else 2327cdf0e10cSrcweir { 2328cdf0e10cSrcweir DBG_ASSERT( 0, "missing a checkbox" ); 2329cdf0e10cSrcweir } 2330cdf0e10cSrcweir } 2331cdf0e10cSrcweir else if( pValue->Value >>= nVal ) 2332cdf0e10cSrcweir { 2333cdf0e10cSrcweir // this could be a ListBox or a RadioButtonGroup 2334cdf0e10cSrcweir ListBox* pList = dynamic_cast< ListBox* >( rWindows.front() ); 2335cdf0e10cSrcweir if( pList ) 2336cdf0e10cSrcweir { 2337cdf0e10cSrcweir pList->SelectEntryPos( static_cast< sal_uInt16 >(nVal) ); 2338cdf0e10cSrcweir } 2339cdf0e10cSrcweir else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) ) 2340cdf0e10cSrcweir { 2341cdf0e10cSrcweir RadioButton* pBtn = dynamic_cast< RadioButton* >( rWindows[nVal] ); 2342cdf0e10cSrcweir DBG_ASSERT( pBtn, "unexpected control for property" ); 2343cdf0e10cSrcweir if( pBtn ) 2344cdf0e10cSrcweir pBtn->Check(); 2345cdf0e10cSrcweir } 2346cdf0e10cSrcweir } 2347cdf0e10cSrcweir } 2348cdf0e10cSrcweir } 2349cdf0e10cSrcweir } 2350cdf0e10cSrcweir 2351cdf0e10cSrcweir void PrintDialog::makeEnabled( Window* i_pWindow ) 2352cdf0e10cSrcweir { 2353cdf0e10cSrcweir std::map< Window*, rtl::OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow ); 2354cdf0e10cSrcweir if( it != maControlToPropertyMap.end() ) 2355cdf0e10cSrcweir { 2356cdf0e10cSrcweir rtl::OUString aDependency( maPController->makeEnabled( it->second ) ); 2357cdf0e10cSrcweir if( aDependency.getLength() ) 2358cdf0e10cSrcweir updateWindowFromProperty( aDependency ); 2359cdf0e10cSrcweir } 2360cdf0e10cSrcweir } 2361cdf0e10cSrcweir 2362cdf0e10cSrcweir IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox*, i_pBox ) 2363cdf0e10cSrcweir { 2364cdf0e10cSrcweir PropertyValue* pVal = getValueForWindow( i_pBox ); 2365cdf0e10cSrcweir if( pVal ) 2366cdf0e10cSrcweir { 2367cdf0e10cSrcweir makeEnabled( i_pBox ); 2368cdf0e10cSrcweir 2369cdf0e10cSrcweir sal_Bool bVal = i_pBox->IsChecked(); 2370cdf0e10cSrcweir pVal->Value <<= bVal; 2371cdf0e10cSrcweir 2372cdf0e10cSrcweir checkOptionalControlDependencies(); 2373cdf0e10cSrcweir 2374cdf0e10cSrcweir // update preview and page settings 2375cdf0e10cSrcweir preparePreview(); 2376cdf0e10cSrcweir } 2377cdf0e10cSrcweir return 0; 2378cdf0e10cSrcweir } 2379cdf0e10cSrcweir 2380cdf0e10cSrcweir IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn ) 2381cdf0e10cSrcweir { 2382cdf0e10cSrcweir // this handler gets called for all radiobuttons that get unchecked, too 2383cdf0e10cSrcweir // however we only want one notificaction for the new value (that is for 2384cdf0e10cSrcweir // the button that gets checked) 2385cdf0e10cSrcweir if( i_pBtn->IsChecked() ) 2386cdf0e10cSrcweir { 2387cdf0e10cSrcweir PropertyValue* pVal = getValueForWindow( i_pBtn ); 2388cdf0e10cSrcweir std::map< Window*, sal_Int32 >::const_iterator it = maControlToNumValMap.find( i_pBtn ); 2389cdf0e10cSrcweir if( pVal && it != maControlToNumValMap.end() ) 2390cdf0e10cSrcweir { 2391cdf0e10cSrcweir makeEnabled( i_pBtn ); 2392cdf0e10cSrcweir 2393cdf0e10cSrcweir sal_Int32 nVal = it->second; 2394cdf0e10cSrcweir pVal->Value <<= nVal; 2395cdf0e10cSrcweir 2396cdf0e10cSrcweir checkOptionalControlDependencies(); 2397cdf0e10cSrcweir 2398cdf0e10cSrcweir // update preview and page settings 2399cdf0e10cSrcweir preparePreview(); 2400cdf0e10cSrcweir } 2401cdf0e10cSrcweir } 2402cdf0e10cSrcweir return 0; 2403cdf0e10cSrcweir } 2404cdf0e10cSrcweir 2405cdf0e10cSrcweir IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox*, i_pBox ) 2406cdf0e10cSrcweir { 2407cdf0e10cSrcweir PropertyValue* pVal = getValueForWindow( i_pBox ); 2408cdf0e10cSrcweir if( pVal ) 2409cdf0e10cSrcweir { 2410cdf0e10cSrcweir makeEnabled( i_pBox ); 2411cdf0e10cSrcweir 2412cdf0e10cSrcweir sal_Int32 nVal( i_pBox->GetSelectEntryPos() ); 2413cdf0e10cSrcweir pVal->Value <<= nVal; 2414cdf0e10cSrcweir 2415cdf0e10cSrcweir checkOptionalControlDependencies(); 2416cdf0e10cSrcweir 2417cdf0e10cSrcweir // update preview and page settings 2418cdf0e10cSrcweir preparePreview(); 2419cdf0e10cSrcweir } 2420cdf0e10cSrcweir return 0; 2421cdf0e10cSrcweir } 2422cdf0e10cSrcweir 2423cdf0e10cSrcweir IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit*, i_pBox ) 2424cdf0e10cSrcweir { 2425cdf0e10cSrcweir PropertyValue* pVal = getValueForWindow( i_pBox ); 2426cdf0e10cSrcweir if( pVal ) 2427cdf0e10cSrcweir { 2428cdf0e10cSrcweir makeEnabled( i_pBox ); 2429cdf0e10cSrcweir 2430cdf0e10cSrcweir NumericField* pNum = dynamic_cast<NumericField*>(i_pBox); 2431cdf0e10cSrcweir MetricField* pMetric = dynamic_cast<MetricField*>(i_pBox); 2432cdf0e10cSrcweir if( pNum ) 2433cdf0e10cSrcweir { 2434cdf0e10cSrcweir sal_Int64 nVal = pNum->GetValue(); 2435cdf0e10cSrcweir pVal->Value <<= nVal; 2436cdf0e10cSrcweir } 2437cdf0e10cSrcweir else if( pMetric ) 2438cdf0e10cSrcweir { 2439cdf0e10cSrcweir sal_Int64 nVal = pMetric->GetValue(); 2440cdf0e10cSrcweir pVal->Value <<= nVal; 2441cdf0e10cSrcweir } 2442cdf0e10cSrcweir else 2443cdf0e10cSrcweir { 2444cdf0e10cSrcweir rtl::OUString aVal( i_pBox->GetText() ); 2445cdf0e10cSrcweir pVal->Value <<= aVal; 2446cdf0e10cSrcweir } 2447cdf0e10cSrcweir 2448cdf0e10cSrcweir checkOptionalControlDependencies(); 2449cdf0e10cSrcweir 2450cdf0e10cSrcweir // update preview and page settings 2451cdf0e10cSrcweir preparePreview(); 2452cdf0e10cSrcweir } 2453cdf0e10cSrcweir return 0; 2454cdf0e10cSrcweir } 2455cdf0e10cSrcweir 2456cdf0e10cSrcweir void PrintDialog::Command( const CommandEvent& rEvt ) 2457cdf0e10cSrcweir { 2458cdf0e10cSrcweir if( rEvt.GetCommand() == COMMAND_WHEEL ) 2459cdf0e10cSrcweir { 2460cdf0e10cSrcweir const CommandWheelData* pWheelData = rEvt.GetWheelData(); 2461cdf0e10cSrcweir if( pWheelData->GetDelta() > 0 ) 2462cdf0e10cSrcweir previewForward(); 2463cdf0e10cSrcweir else if( pWheelData->GetDelta() < 0 ) 2464cdf0e10cSrcweir previewBackward(); 2465cdf0e10cSrcweir /* 2466cdf0e10cSrcweir else 2467cdf0e10cSrcweir huh ? 2468cdf0e10cSrcweir */ 2469cdf0e10cSrcweir } 2470cdf0e10cSrcweir } 2471cdf0e10cSrcweir 2472cdf0e10cSrcweir void PrintDialog::Resize() 2473cdf0e10cSrcweir { 2474cdf0e10cSrcweir // maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); 2475cdf0e10cSrcweir // and do the preview; however the metafile does not need to be gotten anew 2476cdf0e10cSrcweir preparePreview( false ); 2477cdf0e10cSrcweir 2478cdf0e10cSrcweir // do an invalidate for the benefit of the grouping elements 2479cdf0e10cSrcweir Invalidate(); 2480cdf0e10cSrcweir } 2481cdf0e10cSrcweir 2482cdf0e10cSrcweir void PrintDialog::previewForward() 2483cdf0e10cSrcweir { 2484cdf0e10cSrcweir maPageEdit.Up(); 2485cdf0e10cSrcweir } 2486cdf0e10cSrcweir 2487cdf0e10cSrcweir void PrintDialog::previewBackward() 2488cdf0e10cSrcweir { 2489cdf0e10cSrcweir maPageEdit.Down(); 2490cdf0e10cSrcweir } 2491cdf0e10cSrcweir 2492cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2493cdf0e10cSrcweir // 2494cdf0e10cSrcweir // PrintProgressDialog 2495cdf0e10cSrcweir // 2496cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2497cdf0e10cSrcweir 2498cdf0e10cSrcweir PrintProgressDialog::PrintProgressDialog( Window* i_pParent, int i_nMax ) : 2499cdf0e10cSrcweir ModelessDialog( i_pParent, VclResId( SV_DLG_PRINT_PROGRESS ) ), 2500cdf0e10cSrcweir maText( this, VclResId( SV_PRINT_PROGRESS_TEXT ) ), 2501cdf0e10cSrcweir maButton( this, VclResId( SV_PRINT_PROGRESS_CANCEL ) ), 2502cdf0e10cSrcweir mbCanceled( false ), 2503cdf0e10cSrcweir mnCur( 0 ), 2504cdf0e10cSrcweir mnMax( i_nMax ), 2505cdf0e10cSrcweir mnProgressHeight( 15 ), 2506cdf0e10cSrcweir mbNativeProgress( false ) 2507cdf0e10cSrcweir { 2508cdf0e10cSrcweir FreeResource(); 2509cdf0e10cSrcweir 2510cdf0e10cSrcweir if( mnMax < 1 ) 2511cdf0e10cSrcweir mnMax = 1; 2512cdf0e10cSrcweir 2513cdf0e10cSrcweir maStr = maText.GetText(); 2514cdf0e10cSrcweir 2515cdf0e10cSrcweir maButton.SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) ); 2516cdf0e10cSrcweir 2517cdf0e10cSrcweir } 2518cdf0e10cSrcweir 2519cdf0e10cSrcweir PrintProgressDialog::~PrintProgressDialog() 2520cdf0e10cSrcweir { 2521cdf0e10cSrcweir } 2522cdf0e10cSrcweir 2523cdf0e10cSrcweir IMPL_LINK( PrintProgressDialog, ClickHdl, Button*, pButton ) 2524cdf0e10cSrcweir { 2525cdf0e10cSrcweir if( pButton == &maButton ) 2526cdf0e10cSrcweir mbCanceled = true; 2527cdf0e10cSrcweir 2528cdf0e10cSrcweir return 0; 2529cdf0e10cSrcweir } 2530cdf0e10cSrcweir 2531cdf0e10cSrcweir void PrintProgressDialog::implCalcProgressRect() 2532cdf0e10cSrcweir { 2533cdf0e10cSrcweir if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) ) 2534cdf0e10cSrcweir { 2535cdf0e10cSrcweir ImplControlValue aValue; 2536cdf0e10cSrcweir Rectangle aControlRegion( Point(), Size( 100, mnProgressHeight ) ); 2537cdf0e10cSrcweir Rectangle aNativeControlRegion, aNativeContentRegion; 2538cdf0e10cSrcweir if( GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, 2539cdf0e10cSrcweir CTRL_STATE_ENABLED, aValue, rtl::OUString(), 2540cdf0e10cSrcweir aNativeControlRegion, aNativeContentRegion ) ) 2541cdf0e10cSrcweir { 2542cdf0e10cSrcweir mnProgressHeight = aNativeControlRegion.GetHeight(); 2543cdf0e10cSrcweir } 2544cdf0e10cSrcweir mbNativeProgress = true; 2545cdf0e10cSrcweir } 2546cdf0e10cSrcweir maProgressRect = Rectangle( Point( 10, maText.GetPosPixel().Y() + maText.GetSizePixel().Height() + 8 ), 2547cdf0e10cSrcweir Size( GetSizePixel().Width() - 20, mnProgressHeight ) ); 2548cdf0e10cSrcweir } 2549cdf0e10cSrcweir 2550cdf0e10cSrcweir void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax ) 2551cdf0e10cSrcweir { 2552cdf0e10cSrcweir if( maProgressRect.IsEmpty() ) 2553cdf0e10cSrcweir implCalcProgressRect(); 2554cdf0e10cSrcweir 2555cdf0e10cSrcweir mnCur = i_nCurrent; 2556cdf0e10cSrcweir if( i_nMax != -1 ) 2557cdf0e10cSrcweir mnMax = i_nMax; 2558cdf0e10cSrcweir 2559cdf0e10cSrcweir if( mnMax < 1 ) 2560cdf0e10cSrcweir mnMax = 1; 2561cdf0e10cSrcweir 2562cdf0e10cSrcweir rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, rtl::OUString::valueOf( mnCur ) ) ); 2563cdf0e10cSrcweir aNewText = searchAndReplace( aNewText, "%n", 2, rtl::OUString::valueOf( mnMax ) ); 2564cdf0e10cSrcweir maText.SetText( aNewText ); 2565cdf0e10cSrcweir 2566cdf0e10cSrcweir // update progress 2567cdf0e10cSrcweir Invalidate( maProgressRect, INVALIDATE_UPDATE ); 2568cdf0e10cSrcweir } 2569cdf0e10cSrcweir 2570cdf0e10cSrcweir void PrintProgressDialog::tick() 2571cdf0e10cSrcweir { 2572cdf0e10cSrcweir if( mnCur < mnMax ) 2573cdf0e10cSrcweir setProgress( ++mnCur ); 2574cdf0e10cSrcweir } 2575cdf0e10cSrcweir 2576cdf0e10cSrcweir void PrintProgressDialog::reset() 2577cdf0e10cSrcweir { 2578cdf0e10cSrcweir mbCanceled = false; 2579cdf0e10cSrcweir setProgress( 0 ); 2580cdf0e10cSrcweir } 2581cdf0e10cSrcweir 2582cdf0e10cSrcweir void PrintProgressDialog::Paint( const Rectangle& ) 2583cdf0e10cSrcweir { 2584cdf0e10cSrcweir if( maProgressRect.IsEmpty() ) 2585cdf0e10cSrcweir implCalcProgressRect(); 2586cdf0e10cSrcweir 2587cdf0e10cSrcweir Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); 2588cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 2589cdf0e10cSrcweir Color aPrgsColor = rStyleSettings.GetHighlightColor(); 2590cdf0e10cSrcweir if ( aPrgsColor == rStyleSettings.GetFaceColor() ) 2591cdf0e10cSrcweir aPrgsColor = rStyleSettings.GetDarkShadowColor(); 2592cdf0e10cSrcweir SetLineColor(); 2593cdf0e10cSrcweir SetFillColor( aPrgsColor ); 2594cdf0e10cSrcweir 2595cdf0e10cSrcweir const long nOffset = 3; 2596cdf0e10cSrcweir const long nWidth = 3*mnProgressHeight/2; 2597cdf0e10cSrcweir const long nFullWidth = nWidth + nOffset; 2598cdf0e10cSrcweir const long nMaxCount = maProgressRect.GetWidth() / nFullWidth; 2599cdf0e10cSrcweir DrawProgress( this, maProgressRect.TopLeft(), 2600cdf0e10cSrcweir nOffset, 2601cdf0e10cSrcweir nWidth, 2602cdf0e10cSrcweir mnProgressHeight, 2603cdf0e10cSrcweir static_cast<sal_uInt16>(0), 2604cdf0e10cSrcweir static_cast<sal_uInt16>(10000*mnCur/mnMax), 2605cdf0e10cSrcweir static_cast<sal_uInt16>(10000/nMaxCount), 2606cdf0e10cSrcweir maProgressRect 2607cdf0e10cSrcweir ); 2608cdf0e10cSrcweir Pop(); 2609cdf0e10cSrcweir 2610cdf0e10cSrcweir if( ! mbNativeProgress ) 2611cdf0e10cSrcweir { 2612cdf0e10cSrcweir DecorationView aDecoView( this ); 2613cdf0e10cSrcweir Rectangle aFrameRect( maProgressRect ); 2614cdf0e10cSrcweir aFrameRect.Left() -= nOffset; 2615cdf0e10cSrcweir aFrameRect.Right() += nOffset; 2616cdf0e10cSrcweir aFrameRect.Top() -= nOffset; 2617cdf0e10cSrcweir aFrameRect.Bottom() += nOffset; 2618cdf0e10cSrcweir aDecoView.DrawFrame( aFrameRect ); 2619cdf0e10cSrcweir } 2620cdf0e10cSrcweir } 2621cdf0e10cSrcweir 2622