1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SV_PRNDLG_HXX 29 #define _SV_PRNDLG_HXX 30 31 #include <vcl/dllapi.h> 32 33 #include "print.h" 34 35 #include "vcl/print.hxx" 36 #include "vcl/dialog.hxx" 37 #include "vcl/fixed.hxx" 38 #include "vcl/button.hxx" 39 #include "vcl/gdimtf.hxx" 40 #include "vcl/lstbox.hxx" 41 #include "vcl/field.hxx" 42 #include "vcl/tabctrl.hxx" 43 #include "vcl/tabpage.hxx" 44 #include "vcl/arrange.hxx" 45 #include "vcl/virdev.hxx" 46 47 #include <boost/shared_ptr.hpp> 48 #include <map> 49 50 namespace vcl 51 { 52 class PrintDialog : public ModalDialog 53 { 54 class PrintPreviewWindow : public Window 55 { 56 GDIMetaFile maMtf; 57 Size maOrigSize; 58 Size maPreviewSize; 59 VirtualDevice maPageVDev; 60 rtl::OUString maReplacementString; 61 rtl::OUString maToolTipString; 62 bool mbGreyscale; 63 FixedLine maHorzDim; 64 FixedLine maVertDim; 65 66 bool useHCColorReplacement() const; 67 public: 68 PrintPreviewWindow( Window* pParent, const ResId& ); 69 virtual ~PrintPreviewWindow(); 70 71 virtual void Paint( const Rectangle& rRect ); 72 virtual void Command( const CommandEvent& ); 73 virtual void Resize(); 74 virtual void DataChanged( const DataChangedEvent& ); 75 76 void setPreview( const GDIMetaFile&, const Size& i_rPaperSize, 77 const rtl::OUString& i_rPaperName, 78 const rtl::OUString& i_rNoPageString, 79 sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, 80 bool i_bGreyscale 81 ); 82 }; 83 84 class ShowNupOrderWindow : public Window 85 { 86 int mnOrderMode; 87 int mnRows; 88 int mnColumns; 89 void ImplInitSettings(); 90 public: 91 ShowNupOrderWindow( Window* pParent ); 92 virtual ~ShowNupOrderWindow(); 93 94 virtual void Paint( const Rectangle& ); 95 96 void setValues( int i_nOrderMode, int i_nColumns, int i_nRows ) 97 { 98 mnOrderMode = i_nOrderMode; 99 mnRows = i_nRows; 100 mnColumns = i_nColumns; 101 Invalidate(); 102 } 103 }; 104 105 class NUpTabPage : public TabPage 106 { 107 public: 108 FixedLine maNupLine; 109 RadioButton maPagesBtn; 110 RadioButton maBrochureBtn; 111 FixedText maPagesBoxTitleTxt; 112 ListBox maNupPagesBox; 113 114 // controls for "Custom" page mode 115 FixedText maNupNumPagesTxt; 116 NumericField maNupColEdt; 117 FixedText maNupTimesTxt; 118 NumericField maNupRowsEdt; 119 FixedText maPageMarginTxt1; 120 MetricField maPageMarginEdt; 121 FixedText maPageMarginTxt2; 122 FixedText maSheetMarginTxt1; 123 MetricField maSheetMarginEdt; 124 FixedText maSheetMarginTxt2; 125 FixedText maNupOrientationTxt; 126 ListBox maNupOrientationBox; 127 128 // page order ("left to right, then down") 129 FixedText maNupOrderTxt; 130 ListBox maNupOrderBox; 131 ShowNupOrderWindow maNupOrderWin; 132 // border around each page 133 CheckBox maBorderCB; 134 135 boost::shared_ptr< vcl::RowOrColumn > mxBrochureDep; 136 boost::shared_ptr< vcl::LabeledElement >mxPagesBtnLabel; 137 138 void setupLayout(); 139 140 NUpTabPage( Window*, const ResId& ); 141 virtual ~NUpTabPage(); 142 143 void readFromSettings(); 144 void storeToSettings(); 145 void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& ); 146 void enableNupControls( bool bEnable ); 147 148 void showAdvancedControls( bool ); 149 150 // virtual void Resize(); 151 }; 152 153 class JobTabPage : public TabPage 154 { 155 public: 156 FixedLine maPrinterFL; 157 ListBox maPrinters; 158 DisclosureButton maDetailsBtn; 159 FixedText maStatusLabel; 160 FixedText maStatusTxt; 161 FixedText maLocationLabel; 162 FixedText maLocationTxt; 163 FixedText maCommentLabel; 164 FixedText maCommentTxt; 165 166 PushButton maSetupButton; 167 168 FixedLine maCopies; 169 FixedLine maCopySpacer; 170 FixedText maCopyCount; 171 NumericField maCopyCountField; 172 CheckBox maCollateBox; 173 FixedImage maCollateImage; 174 CheckBox maReverseOrderBox; 175 176 Image maCollateImg; 177 Image maCollateHCImg; 178 Image maNoCollateImg; 179 Image maNoCollateHCImg; 180 181 long mnCollateUIMode; 182 183 boost::shared_ptr<vcl::RowOrColumn> mxPrintRange; 184 boost::shared_ptr<vcl::WindowArranger> mxDetails; 185 186 JobTabPage( Window*, const ResId& ); 187 virtual ~JobTabPage(); 188 189 void readFromSettings(); 190 void storeToSettings(); 191 192 // virtual void Resize(); 193 194 void setupLayout(); 195 }; 196 197 class OutputOptPage : public TabPage 198 { 199 public: 200 FixedLine maOptionsLine; 201 CheckBox maToFileBox; 202 CheckBox maCollateSingleJobsBox; 203 204 boost::shared_ptr<vcl::RowOrColumn> mxOptGroup; 205 206 OutputOptPage( Window*, const ResId& ); 207 virtual ~OutputOptPage(); 208 209 void readFromSettings(); 210 void storeToSettings(); 211 212 // virtual void Resize(); 213 214 void setupLayout(); 215 }; 216 217 OKButton maOKButton; 218 CancelButton maCancelButton; 219 HelpButton maHelpButton; 220 PrintPreviewWindow maPreviewWindow; 221 NumericField maPageEdit; 222 FixedText maNumPagesText; 223 PushButton maBackwardBtn; 224 PushButton maForwardBtn; 225 226 TabControl maTabCtrl; 227 NUpTabPage maNUpPage; 228 JobTabPage maJobPage; 229 OutputOptPage maOptionsPage; 230 231 FixedLine maButtonLine; 232 233 boost::shared_ptr< PrinterController > maPController; 234 235 rtl::OUString maPageStr; 236 rtl::OUString maNoPageStr; 237 sal_Int32 mnCurPage; 238 sal_Int32 mnCachedPages; 239 240 std::list< Window* > maControls; 241 std::map< Window*, rtl::OUString > maControlToPropertyMap; 242 std::map< rtl::OUString, std::vector< Window* > > 243 maPropertyToWindowMap; 244 std::map< Window*, sal_Int32 > maControlToNumValMap; 245 std::set< rtl::OUString > maReverseDependencySet; 246 247 Size maNupPortraitSize; 248 Size maNupLandscapeSize; 249 250 // internal, used for automatic Nup-Portrait/landscape 251 Size maFirstPageSize; 252 253 rtl::OUString maPrintToFileText; 254 rtl::OUString maPrintText; 255 rtl::OUString maDefPrtText; 256 257 boost::shared_ptr<vcl::RowOrColumn> mxPreviewCtrls; 258 259 Size maDetailsCollapsedSize; 260 Size maDetailsExpandedSize; 261 262 sal_Bool mbShowLayoutPage; 263 264 Size getJobPageSize(); 265 void updateNup(); 266 void updateNupFromPages(); 267 void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); 268 void setPreviewText( sal_Int32 ); 269 void updatePrinterText(); 270 void checkControlDependencies(); 271 void checkOptionalControlDependencies(); 272 void makeEnabled( Window* ); 273 void updateWindowFromProperty( const rtl::OUString& ); 274 void setupOptionalUI(); 275 void readFromSettings(); 276 void storeToSettings(); 277 com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; 278 279 virtual void Resize(); 280 virtual void Command( const CommandEvent& ); 281 virtual void DataChanged( const DataChangedEvent& ); 282 283 DECL_LINK( SelectHdl, ListBox* ); 284 DECL_LINK( ClickHdl, Button* ); 285 DECL_LINK( ModifyHdl, Edit* ); 286 DECL_LINK( UIOptionsChanged, void* ); 287 288 DECL_LINK( UIOption_CheckHdl, CheckBox* ); 289 DECL_LINK( UIOption_RadioHdl, RadioButton* ); 290 DECL_LINK( UIOption_SelectHdl, ListBox* ); 291 DECL_LINK( UIOption_ModifyHdl, Edit* ); 292 293 void setupLayout(); 294 public: 295 PrintDialog( Window*, const boost::shared_ptr< PrinterController >& ); 296 virtual ~PrintDialog(); 297 298 bool isPrintToFile(); 299 int getCopyCount(); 300 bool isCollate(); 301 bool isSingleJobs(); 302 303 void previewForward(); 304 void previewBackward(); 305 }; 306 307 class PrintProgressDialog : public ModelessDialog 308 { 309 String maStr; 310 FixedText maText; 311 CancelButton maButton; 312 313 bool mbCanceled; 314 sal_Int32 mnCur; 315 sal_Int32 mnMax; 316 long mnProgressHeight; 317 Rectangle maProgressRect; 318 bool mbNativeProgress; 319 320 DECL_LINK( ClickHdl, Button* ); 321 322 void implCalcProgressRect(); 323 public: 324 PrintProgressDialog( Window* i_pParent, int i_nMax ); 325 ~PrintProgressDialog(); 326 327 bool isCanceled() const { return mbCanceled; } 328 void setProgress( int i_nCurrent, int i_nMax = -1 ); 329 void tick(); 330 void reset(); 331 332 virtual void Paint( const Rectangle& ); 333 }; 334 } 335 336 337 #endif // _SV_PRNDLG_HXX 338