1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #ifdef SD_DLLIMPLEMENTATION 28 #undef SD_DLLIMPLEMENTATION 29 #endif 30 31 32 #include "sdattr.hxx" 33 #include "optsitem.hxx" 34 #include "prntopts.hrc" 35 #include "sdresid.hxx" 36 #include "prntopts.hxx" 37 #include "app.hrc" 38 #include <svl/intitem.hxx> 39 #include <sfx2/request.hxx> 40 41 /************************************************************************* 42 |* 43 |* Dialog zum Aendern der Print-Optionen 44 |* 45 \************************************************************************/ 46 47 SdPrintOptions::SdPrintOptions( Window* pParent, const SfxItemSet& rInAttrs ) : 48 SfxTabPage ( pParent, SdResId( TP_PRINT_OPTIONS ), rInAttrs ), 49 50 aGrpPrint ( this, SdResId( GRP_PRINT ) ), 51 aCbxDraw ( this, SdResId( CBX_DRAW ) ), 52 aCbxNotes ( this, SdResId( CBX_NOTES ) ), 53 aCbxHandout ( this, SdResId( CBX_HANDOUTS ) ), 54 aCbxOutline ( this, SdResId( CBX_OUTLINE ) ), 55 56 aSeparator1FL ( this, SdResId( FL_SEPARATOR1 ) ), 57 aGrpOutput ( this, SdResId( GRP_OUTPUT ) ), 58 aRbtColor ( this, SdResId( RBT_COLOR ) ), 59 aRbtGrayscale ( this, SdResId( RBT_GRAYSCALE ) ), 60 aRbtBlackWhite ( this, SdResId( RBT_BLACKWHITE ) ), 61 62 aGrpPrintExt ( this, SdResId( GRP_PRINT_EXT ) ), 63 aCbxPagename ( this, SdResId( CBX_PAGENAME ) ), 64 aCbxDate ( this, SdResId( CBX_DATE ) ), 65 aCbxTime ( this, SdResId( CBX_TIME ) ), 66 aCbxHiddenPages ( this, SdResId( CBX_HIDDEN_PAGES ) ), 67 68 aSeparator2FL ( this, SdResId( FL_SEPARATOR2 ) ), 69 aGrpPageoptions ( this, SdResId( GRP_PAGE ) ), 70 aRbtDefault ( this, SdResId( RBT_DEFAULT ) ), 71 aRbtPagesize ( this, SdResId( RBT_PAGESIZE ) ), 72 aRbtPagetile ( this, SdResId( RBT_PAGETILE ) ), 73 aRbtBooklet ( this, SdResId( RBT_BOOKLET ) ), 74 aCbxFront ( this, SdResId( CBX_FRONT ) ), 75 aCbxBack ( this, SdResId( CBX_BACK ) ), 76 77 aCbxPaperbin ( this, SdResId( CBX_PAPERBIN ) ), 78 79 rOutAttrs ( rInAttrs ) 80 { 81 FreeResource(); 82 83 Link aLink = LINK( this, SdPrintOptions, ClickBookletHdl ); 84 aRbtDefault.SetClickHdl( aLink ); 85 aRbtPagesize.SetClickHdl( aLink ); 86 aRbtPagetile.SetClickHdl( aLink ); 87 aRbtBooklet.SetClickHdl( aLink ); 88 89 aLink = LINK( this, SdPrintOptions, ClickCheckboxHdl ); 90 aCbxDraw.SetClickHdl( aLink ); 91 aCbxNotes.SetClickHdl( aLink ); 92 aCbxHandout.SetClickHdl( aLink ); 93 aCbxOutline.SetClickHdl( aLink ); 94 95 #ifndef QUARTZ 96 SetDrawMode(); 97 #endif 98 99 aCbxFront.SetAccessibleRelationLabeledBy( &aRbtBooklet ); 100 aCbxBack.SetAccessibleRelationLabeledBy( &aRbtBooklet ); 101 } 102 103 // ----------------------------------------------------------------------- 104 105 SdPrintOptions::~SdPrintOptions() 106 { 107 } 108 109 // ----------------------------------------------------------------------- 110 111 sal_Bool SdPrintOptions::FillItemSet( SfxItemSet& rAttrs ) 112 { 113 if( aCbxDraw.GetSavedValue() != aCbxDraw.IsChecked() || 114 aCbxNotes.GetSavedValue() != aCbxNotes.IsChecked() || 115 aCbxHandout.GetSavedValue() != aCbxHandout.IsChecked() || 116 aCbxOutline.GetSavedValue() != aCbxOutline.IsChecked() || 117 aCbxDate.GetSavedValue() != aCbxDate.IsChecked() || 118 aCbxTime.GetSavedValue() != aCbxTime.IsChecked() || 119 aCbxPagename.GetSavedValue() != aCbxPagename.IsChecked() || 120 aCbxHiddenPages.GetSavedValue() != aCbxHiddenPages.IsChecked() || 121 aRbtPagesize.GetSavedValue() != aRbtPagesize.IsChecked() || 122 aRbtPagetile.GetSavedValue() != aRbtPagetile.IsChecked() || 123 aRbtBooklet.GetSavedValue() != aRbtBooklet.IsChecked() || 124 aCbxFront.GetSavedValue() != aCbxFront.IsChecked() || 125 aCbxBack.GetSavedValue() != aCbxBack.IsChecked() || 126 aCbxPaperbin.GetSavedValue() != aCbxPaperbin.IsChecked() || 127 aRbtColor.GetSavedValue() != aRbtColor.IsChecked() || 128 aRbtGrayscale.GetSavedValue() != aRbtGrayscale.IsChecked() || 129 aRbtBlackWhite.GetSavedValue() != aRbtBlackWhite.IsChecked() ) 130 { 131 SdOptionsPrintItem aOptions( ATTR_OPTIONS_PRINT ); 132 133 aOptions.GetOptionsPrint().SetDraw( aCbxDraw.IsChecked() ); 134 aOptions.GetOptionsPrint().SetNotes( aCbxNotes.IsChecked() ); 135 aOptions.GetOptionsPrint().SetHandout( aCbxHandout.IsChecked() ); 136 aOptions.GetOptionsPrint().SetOutline( aCbxOutline.IsChecked() ); 137 aOptions.GetOptionsPrint().SetDate( aCbxDate.IsChecked() ); 138 aOptions.GetOptionsPrint().SetTime( aCbxTime.IsChecked() ); 139 aOptions.GetOptionsPrint().SetPagename( aCbxPagename.IsChecked() ); 140 aOptions.GetOptionsPrint().SetHiddenPages( aCbxHiddenPages.IsChecked() ); 141 aOptions.GetOptionsPrint().SetPagesize( aRbtPagesize.IsChecked() ); 142 aOptions.GetOptionsPrint().SetPagetile( aRbtPagetile.IsChecked() ); 143 aOptions.GetOptionsPrint().SetBooklet( aRbtBooklet.IsChecked() ); 144 aOptions.GetOptionsPrint().SetFrontPage( aCbxFront.IsChecked() ); 145 aOptions.GetOptionsPrint().SetBackPage( aCbxBack.IsChecked() ); 146 aOptions.GetOptionsPrint().SetPaperbin( aCbxPaperbin.IsChecked() ); 147 148 sal_uInt16 nQuality = 0; // Standard, also Color 149 if( aRbtGrayscale.IsChecked() ) 150 nQuality = 1; 151 if( aRbtBlackWhite.IsChecked() ) 152 nQuality = 2; 153 aOptions.GetOptionsPrint().SetOutputQuality( nQuality ); 154 155 rAttrs.Put( aOptions ); 156 157 return( sal_True ); 158 } 159 return( sal_False ); 160 } 161 162 // ----------------------------------------------------------------------- 163 164 void SdPrintOptions::Reset( const SfxItemSet& rAttrs ) 165 { 166 const SdOptionsPrintItem* pPrintOpts = NULL; 167 if( SFX_ITEM_SET == rAttrs.GetItemState( ATTR_OPTIONS_PRINT, sal_False, 168 (const SfxPoolItem**) &pPrintOpts ) ) 169 { 170 aCbxDraw.Check( pPrintOpts->GetOptionsPrint().IsDraw() ); 171 aCbxNotes.Check( pPrintOpts->GetOptionsPrint().IsNotes() ); 172 aCbxHandout.Check( pPrintOpts->GetOptionsPrint().IsHandout() ); 173 aCbxOutline.Check( pPrintOpts->GetOptionsPrint().IsOutline() ); 174 aCbxDate.Check( pPrintOpts->GetOptionsPrint().IsDate() ); 175 aCbxTime.Check( pPrintOpts->GetOptionsPrint().IsTime() ); 176 aCbxPagename.Check( pPrintOpts->GetOptionsPrint().IsPagename() ); 177 aCbxHiddenPages.Check( pPrintOpts->GetOptionsPrint().IsHiddenPages() ); 178 aRbtPagesize.Check( pPrintOpts->GetOptionsPrint().IsPagesize() ); 179 aRbtPagetile.Check( pPrintOpts->GetOptionsPrint().IsPagetile() ); 180 aRbtBooklet.Check( pPrintOpts->GetOptionsPrint().IsBooklet() ); 181 aCbxFront.Check( pPrintOpts->GetOptionsPrint().IsFrontPage() ); 182 aCbxBack.Check( pPrintOpts->GetOptionsPrint().IsBackPage() ); 183 aCbxPaperbin.Check( pPrintOpts->GetOptionsPrint().IsPaperbin() ); 184 185 if( !aRbtPagesize.IsChecked() && 186 !aRbtPagetile.IsChecked() && 187 !aRbtBooklet.IsChecked() ) 188 { 189 aRbtDefault.Check(); 190 } 191 192 sal_uInt16 nQuality = pPrintOpts->GetOptionsPrint().GetOutputQuality(); 193 if( nQuality == 0 ) 194 aRbtColor.Check(); 195 else if( nQuality == 1 ) 196 aRbtGrayscale.Check(); 197 else 198 aRbtBlackWhite.Check(); 199 } 200 aCbxDraw.SaveValue(); 201 aCbxNotes.SaveValue(); 202 aCbxHandout.SaveValue(); 203 aCbxOutline.SaveValue(); 204 aCbxDate.SaveValue(); 205 aCbxTime.SaveValue(); 206 aCbxPagename.SaveValue(); 207 aCbxHiddenPages.SaveValue(); 208 aRbtPagesize.SaveValue(); 209 aRbtPagetile.SaveValue(); 210 aRbtBooklet.SaveValue(); 211 aCbxPaperbin.SaveValue(); 212 aRbtColor.SaveValue(); 213 aRbtGrayscale.SaveValue(); 214 aRbtBlackWhite.SaveValue(); 215 216 ClickBookletHdl( NULL ); 217 } 218 219 // ----------------------------------------------------------------------- 220 221 SfxTabPage* SdPrintOptions::Create( Window* pWindow, 222 const SfxItemSet& rOutAttrs ) 223 { 224 return( new SdPrintOptions( pWindow, rOutAttrs ) ); 225 } 226 227 //----------------------------------------------------------------------- 228 229 IMPL_LINK( SdPrintOptions, ClickCheckboxHdl, CheckBox *, pCbx ) 230 { 231 // there must be at least one of them checked 232 if( !aCbxDraw.IsChecked() && !aCbxNotes.IsChecked() && !aCbxOutline.IsChecked() && !aCbxHandout.IsChecked() ) 233 pCbx->Check(); 234 235 updateControls(); 236 return 0; 237 } 238 239 //----------------------------------------------------------------------- 240 241 IMPL_LINK( SdPrintOptions, ClickBookletHdl, CheckBox *, EMPTYARG ) 242 { 243 updateControls(); 244 return 0; 245 } 246 247 void SdPrintOptions::updateControls() 248 { 249 aCbxFront.Enable(aRbtBooklet.IsChecked()); 250 aCbxBack.Enable(aRbtBooklet.IsChecked()); 251 252 aCbxDate.Enable( !aRbtBooklet.IsChecked() ); 253 aCbxTime.Enable( !aRbtBooklet.IsChecked() ); 254 255 aCbxPagename.Enable( !aRbtBooklet.IsChecked() && (aCbxDraw.IsChecked() || aCbxNotes.IsChecked() || aCbxOutline.IsChecked()) ); 256 } 257 258 /* -----------------------------04.05.01 10:53-------------------------------- 259 260 ---------------------------------------------------------------------------*/ 261 void lcl_MoveRB_Impl(Window& rBtn, long nXDiff) 262 { 263 Point aPos(rBtn.GetPosPixel()); 264 aPos.X() -= nXDiff; 265 rBtn.SetPosPixel(aPos); 266 } 267 268 void SdPrintOptions::SetDrawMode() 269 { 270 if(aCbxNotes.IsVisible()) 271 { 272 aCbxNotes.Hide(); 273 aCbxHandout.Hide(); 274 aCbxOutline.Hide(); 275 aCbxDraw.Hide(); 276 aGrpPrint.Hide(); 277 278 aSeparator1FL.Hide(); 279 long nXDiff = aGrpOutput.GetPosPixel().X() - aGrpPrint.GetPosPixel().X(); 280 lcl_MoveRB_Impl(aRbtColor, nXDiff); 281 lcl_MoveRB_Impl(aRbtGrayscale, nXDiff); 282 lcl_MoveRB_Impl(aRbtBlackWhite, nXDiff); 283 lcl_MoveRB_Impl(aGrpOutput, nXDiff); 284 285 long nWidth = aGrpOutput.GetSizePixel().Width() + nXDiff; 286 Size aSize(aGrpOutput.GetSizePixel()); 287 aSize.Width() = nWidth; 288 aGrpOutput.SetSizePixel(aSize); 289 } 290 } 291 292 void SdPrintOptions::PageCreated (SfxAllItemSet 293 #ifdef QUARTZ 294 aSet 295 #endif 296 ) 297 { 298 #ifdef QUARTZ 299 SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False); 300 if (pFlagItem) 301 { 302 sal_uInt32 nFlags=pFlagItem->GetValue(); 303 if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE ) 304 SetDrawMode(); 305 } 306 #else 307 SetDrawMode(); 308 #endif 309 } 310 311