LCOV - code coverage report
Current view: top level - vcl/source/window - printdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1405 0.0 %
Date: 2012-08-25 Functions: 0 90 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 3353 0.0 %

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

Generated by: LCOV version 1.10