1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_cui.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // include --------------------------------------------------------------- 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <tools/shl.hxx> 34*cdf0e10cSrcweir #include <svl/itemset.hxx> 35*cdf0e10cSrcweir #include <svl/itempool.hxx> 36*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 37*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #define _SVX_ZOOM_CXX 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <cuires.hrc> 42*cdf0e10cSrcweir #include "zoom.hrc" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include "zoom.hxx" 45*cdf0e10cSrcweir #include <svx/zoomitem.hxx> 46*cdf0e10cSrcweir #include <svx/viewlayoutitem.hxx> 47*cdf0e10cSrcweir #include <dialmgr.hxx> 48*cdf0e10cSrcweir #include <svx/zoom_def.hxx> 49*cdf0e10cSrcweir #include <svx/dialogs.hrc> // RID_SVXDLG_ZOOM 50*cdf0e10cSrcweir #include <layout/layout-pre.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #if ENABLE_LAYOUT 53*cdf0e10cSrcweir #undef CUI_RES 54*cdf0e10cSrcweir #define CUI_RES(x) #x 55*cdf0e10cSrcweir #undef SfxModalDialog 56*cdf0e10cSrcweir #define SfxModalDialog( parent, id ) Dialog( parent, "zoom.xml", id ) 57*cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */ 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir // static ---------------------------------------------------------------- 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir #define SPECIAL_FACTOR ((sal_uInt16)0xFFFF) 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // class SvxZoomDialog --------------------------------------------------- 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir sal_uInt16 SvxZoomDialog::GetFactor() const 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir if ( a100Btn.IsChecked() ) 68*cdf0e10cSrcweir return 100; 69*cdf0e10cSrcweir if ( aUserBtn.IsChecked() ) 70*cdf0e10cSrcweir return (sal_uInt16)aUserEdit.GetValue(); 71*cdf0e10cSrcweir else 72*cdf0e10cSrcweir return SPECIAL_FACTOR; 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // ----------------------------------------------------------------------- 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir void SvxZoomDialog::SetFactor( sal_uInt16 nNewFactor, sal_uInt16 nBtnId ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir aUserEdit.Disable(); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir if ( !nBtnId ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir if ( nNewFactor == 100 ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir a100Btn.Check(); 86*cdf0e10cSrcweir a100Btn.GrabFocus(); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir else 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir aUserBtn.Check(); 91*cdf0e10cSrcweir aUserEdit.Enable(); 92*cdf0e10cSrcweir aUserEdit.SetValue( (long)nNewFactor ); 93*cdf0e10cSrcweir aUserEdit.GrabFocus(); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir else 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir aUserEdit.SetValue( (long)nNewFactor ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir if ( ZOOMBTN_OPTIMAL == nBtnId ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir aOptimalBtn.Check(); 103*cdf0e10cSrcweir aOptimalBtn.GrabFocus(); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir else if ( ZOOMBTN_PAGEWIDTH == nBtnId ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir aPageWidthBtn.Check(); 108*cdf0e10cSrcweir aPageWidthBtn.GrabFocus(); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir else if ( ZOOMBTN_WHOLEPAGE == nBtnId ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir aWholePageBtn.Check(); 113*cdf0e10cSrcweir aWholePageBtn.GrabFocus(); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir // ----------------------------------------------------------------------- 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir void SvxZoomDialog::HideButton( sal_uInt16 nBtnId ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir switch ( nBtnId ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir case ZOOMBTN_OPTIMAL: // Optimal-Button 125*cdf0e10cSrcweir aOptimalBtn.Hide(); 126*cdf0e10cSrcweir break; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir case ZOOMBTN_PAGEWIDTH: // Seitenbreite-Button 129*cdf0e10cSrcweir aPageWidthBtn.Hide(); 130*cdf0e10cSrcweir break; 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir case ZOOMBTN_WHOLEPAGE: // Ganze Seite-Button 133*cdf0e10cSrcweir aWholePageBtn.Hide(); 134*cdf0e10cSrcweir break; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir default: 137*cdf0e10cSrcweir DBG_ERROR( "Falsche Button-Nummer!!!" ); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir // ----------------------------------------------------------------------- 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir void SvxZoomDialog::SetLimits( sal_uInt16 nMin, sal_uInt16 nMax ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir DBG_ASSERT( nMin < nMax, "invalid limits" ); 146*cdf0e10cSrcweir aUserEdit.SetMin( nMin ); 147*cdf0e10cSrcweir aUserEdit.SetFirst( nMin ); 148*cdf0e10cSrcweir aUserEdit.SetMax( nMax ); 149*cdf0e10cSrcweir aUserEdit.SetLast( nMax ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // ----------------------------------------------------------------------- 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir SvxZoomDialog::SvxZoomDialog( Window* pParent, const SfxItemSet& rCoreSet ) : 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_ZOOM ) ), 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir aZoomFl ( this, CUI_RES( FL_ZOOM ) ), 159*cdf0e10cSrcweir aOptimalBtn ( this, CUI_RES( BTN_OPTIMAL ) ), 160*cdf0e10cSrcweir aWholePageBtn ( this, CUI_RES( BTN_WHOLE_PAGE ) ), 161*cdf0e10cSrcweir aPageWidthBtn ( this, CUI_RES( BTN_PAGE_WIDTH ) ), 162*cdf0e10cSrcweir a100Btn ( this, CUI_RES( BTN_100 ) ), 163*cdf0e10cSrcweir aUserBtn ( this, CUI_RES( BTN_USER ) ), 164*cdf0e10cSrcweir aUserEdit ( this, CUI_RES( ED_USER ) ), 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir aViewLayoutFl ( this, CUI_RES( FL_VIEWLAYOUT ) ), 167*cdf0e10cSrcweir aAutomaticBtn ( this, CUI_RES( BTN_AUTOMATIC ) ), 168*cdf0e10cSrcweir aSingleBtn ( this, CUI_RES( BTN_SINGLE ) ), 169*cdf0e10cSrcweir aColumnsBtn ( this, CUI_RES( BTN_COLUMNS ) ), 170*cdf0e10cSrcweir aColumnsEdit ( this, CUI_RES( ED_COLUMNS ) ), 171*cdf0e10cSrcweir aBookModeChk ( this, CUI_RES( CHK_BOOK ) ), 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir aBottomFl ( this, CUI_RES( FL_BOTTOM ) ), 174*cdf0e10cSrcweir aOKBtn ( this, CUI_RES( BTN_ZOOM_OK ) ), 175*cdf0e10cSrcweir aCancelBtn ( this, CUI_RES( BTN_ZOOM_CANCEL ) ), 176*cdf0e10cSrcweir aHelpBtn ( this, CUI_RES( BTN_ZOOM_HELP ) ), 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir rSet ( rCoreSet ), 179*cdf0e10cSrcweir pOutSet ( NULL ), 180*cdf0e10cSrcweir bModified ( sal_False ) 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir #if ENABLE_LAYOUT 184*cdf0e10cSrcweir SetHelpId (".uno:Zoom"); 185*cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */ 186*cdf0e10cSrcweir Link aLink = LINK( this, SvxZoomDialog, UserHdl ); 187*cdf0e10cSrcweir a100Btn.SetClickHdl( aLink ); 188*cdf0e10cSrcweir aOptimalBtn.SetClickHdl( aLink ); 189*cdf0e10cSrcweir aPageWidthBtn.SetClickHdl( aLink ); 190*cdf0e10cSrcweir aWholePageBtn.SetClickHdl( aLink ); 191*cdf0e10cSrcweir aUserBtn.SetClickHdl( aLink ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir Link aViewLayoutLink = LINK( this, SvxZoomDialog, ViewLayoutUserHdl ); 194*cdf0e10cSrcweir aAutomaticBtn.SetClickHdl( aViewLayoutLink ); 195*cdf0e10cSrcweir aSingleBtn.SetClickHdl( aViewLayoutLink ); 196*cdf0e10cSrcweir aColumnsBtn.SetClickHdl( aViewLayoutLink ); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir Link aViewLayoutSpinLink = LINK( this, SvxZoomDialog, ViewLayoutSpinHdl ); 199*cdf0e10cSrcweir aColumnsEdit.SetModifyHdl( aViewLayoutSpinLink ); 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir Link aViewLayoutCheckLink = LINK( this, SvxZoomDialog, ViewLayoutCheckHdl ); 202*cdf0e10cSrcweir aBookModeChk.SetClickHdl( aViewLayoutCheckLink ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir aOKBtn.SetClickHdl( LINK( this, SvxZoomDialog, OKHdl ) ); 205*cdf0e10cSrcweir aUserEdit.SetModifyHdl( LINK( this, SvxZoomDialog, SpinHdl ) ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // Default-Werte 208*cdf0e10cSrcweir sal_uInt16 nValue = 100; 209*cdf0e10cSrcweir sal_uInt16 nMin = 10; 210*cdf0e10cSrcweir sal_uInt16 nMax = 1000; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // ggf. erst den alten Wert besorgen 213*cdf0e10cSrcweir const SfxUInt16Item* pOldUserItem = 0; 214*cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::Current(); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir if ( pSh ) 217*cdf0e10cSrcweir pOldUserItem = (const SfxUInt16Item*)pSh->GetItem( SID_ATTR_ZOOM_USER ); 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir if ( pOldUserItem ) 220*cdf0e10cSrcweir nValue = pOldUserItem->GetValue(); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // UserEdit initialisieren 223*cdf0e10cSrcweir if ( nMin > nValue ) 224*cdf0e10cSrcweir nMin = nValue; 225*cdf0e10cSrcweir if ( nMax < nValue ) 226*cdf0e10cSrcweir nMax = nValue; 227*cdf0e10cSrcweir aUserEdit.SetMin( nMin ); 228*cdf0e10cSrcweir aUserEdit.SetFirst( nMin ); 229*cdf0e10cSrcweir aUserEdit.SetMax( nMax ); 230*cdf0e10cSrcweir aUserEdit.SetLast( nMax ); 231*cdf0e10cSrcweir aUserEdit.SetValue( nValue ); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir aUserEdit.SetAccessibleRelationLabeledBy( &aUserBtn ); 234*cdf0e10cSrcweir aUserEdit.SetAccessibleName(aUserBtn.GetText()); 235*cdf0e10cSrcweir aColumnsEdit.SetAccessibleRelationLabeledBy(&aColumnsBtn); 236*cdf0e10cSrcweir aColumnsEdit.SetAccessibleName(aColumnsBtn.GetText()); 237*cdf0e10cSrcweir aColumnsEdit.SetAccessibleRelationMemberOf(&aColumnsBtn); 238*cdf0e10cSrcweir aBookModeChk.SetAccessibleRelationLabeledBy(&aColumnsBtn); 239*cdf0e10cSrcweir aBookModeChk.SetAccessibleRelationMemberOf(&aColumnsBtn); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir const SfxPoolItem& rItem = rSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_ZOOM ) ); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir if ( rItem.ISA(SvxZoomItem) ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir const SvxZoomItem& rZoomItem = (const SvxZoomItem&)rItem; 246*cdf0e10cSrcweir const sal_uInt16 nZoom = rZoomItem.GetValue(); 247*cdf0e10cSrcweir const SvxZoomType eType = rZoomItem.GetType(); 248*cdf0e10cSrcweir const sal_uInt16 nValSet = rZoomItem.GetValueSet(); 249*cdf0e10cSrcweir sal_uInt16 nBtnId = 0; 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir switch ( eType ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir case SVX_ZOOM_OPTIMAL: 254*cdf0e10cSrcweir nBtnId = ZOOMBTN_OPTIMAL; 255*cdf0e10cSrcweir break; 256*cdf0e10cSrcweir case SVX_ZOOM_PAGEWIDTH: 257*cdf0e10cSrcweir nBtnId = ZOOMBTN_PAGEWIDTH; 258*cdf0e10cSrcweir break; 259*cdf0e10cSrcweir case SVX_ZOOM_WHOLEPAGE: 260*cdf0e10cSrcweir nBtnId = ZOOMBTN_WHOLEPAGE; 261*cdf0e10cSrcweir break; 262*cdf0e10cSrcweir case SVX_ZOOM_PERCENT: 263*cdf0e10cSrcweir break; 264*cdf0e10cSrcweir case SVX_ZOOM_PAGEWIDTH_NOBORDER: 265*cdf0e10cSrcweir break; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir if ( !(SVX_ZOOM_ENABLE_100 & nValSet) ) 269*cdf0e10cSrcweir a100Btn.Disable(); 270*cdf0e10cSrcweir if ( !(SVX_ZOOM_ENABLE_OPTIMAL & nValSet) ) 271*cdf0e10cSrcweir aOptimalBtn.Disable(); 272*cdf0e10cSrcweir if ( !(SVX_ZOOM_ENABLE_PAGEWIDTH & nValSet) ) 273*cdf0e10cSrcweir aPageWidthBtn.Disable(); 274*cdf0e10cSrcweir if ( !(SVX_ZOOM_ENABLE_WHOLEPAGE & nValSet) ) 275*cdf0e10cSrcweir aWholePageBtn.Disable(); 276*cdf0e10cSrcweir SetFactor( nZoom, nBtnId ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir else 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir const sal_uInt16 nZoom = ( (const SfxUInt16Item&)rItem ).GetValue(); 281*cdf0e10cSrcweir SetFactor( nZoom ); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir const SfxPoolItem* pViewLayoutItem = 0; 285*cdf0e10cSrcweir if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_VIEWLAYOUT, sal_False, &pViewLayoutItem ) ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem*>(pViewLayoutItem)->GetValue(); 288*cdf0e10cSrcweir const bool bBookMode = static_cast<const SvxViewLayoutItem*>(pViewLayoutItem)->IsBookMode(); 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir if ( 0 == nColumns ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir aAutomaticBtn.Check(); 293*cdf0e10cSrcweir aColumnsEdit.SetValue( 2 ); 294*cdf0e10cSrcweir aColumnsEdit.Disable(); 295*cdf0e10cSrcweir aBookModeChk.Disable(); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir else if ( 1 == nColumns) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir aSingleBtn.Check(); 300*cdf0e10cSrcweir aColumnsEdit.SetValue( 2 ); 301*cdf0e10cSrcweir aColumnsEdit.Disable(); 302*cdf0e10cSrcweir aBookModeChk.Disable(); 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir else 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir aColumnsBtn.Check(); 307*cdf0e10cSrcweir if ( !bBookMode ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir aColumnsEdit.SetValue( nColumns ); 310*cdf0e10cSrcweir if ( 0 != nColumns % 2 ) 311*cdf0e10cSrcweir aBookModeChk.Disable(); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir else 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir aColumnsEdit.SetValue( nColumns ); 316*cdf0e10cSrcweir aBookModeChk.Check(); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir else 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir // hide view layout related controls: 323*cdf0e10cSrcweir aViewLayoutFl.Disable(); 324*cdf0e10cSrcweir aAutomaticBtn.Disable(); 325*cdf0e10cSrcweir aSingleBtn.Disable(); 326*cdf0e10cSrcweir aColumnsBtn.Disable(); 327*cdf0e10cSrcweir aColumnsEdit.Disable(); 328*cdf0e10cSrcweir aBookModeChk.Disable(); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir FreeResource(); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir // ----------------------------------------------------------------------- 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir SvxZoomDialog::~SvxZoomDialog() 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir delete pOutSet; 339*cdf0e10cSrcweir pOutSet = 0; 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir // ----------------------------------------------------------------------- 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, UserHdl, RadioButton *, pBtn ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir bModified |= sal_True; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if ( pBtn == &aUserBtn ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir aUserEdit.Enable(); 351*cdf0e10cSrcweir aUserEdit.GrabFocus(); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir else 354*cdf0e10cSrcweir aUserEdit.Disable(); 355*cdf0e10cSrcweir return 0; 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // ----------------------------------------------------------------------- 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, SpinHdl, MetricField *, EMPTYARG ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir if ( !aUserBtn.IsChecked() ) 363*cdf0e10cSrcweir return 0; 364*cdf0e10cSrcweir bModified |= sal_True; 365*cdf0e10cSrcweir return 0; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir // ----------------------------------------------------------------------- 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, ViewLayoutUserHdl, RadioButton *, pBtn ) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir bModified |= sal_True; 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir if ( pBtn == &aAutomaticBtn ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir aColumnsEdit.Disable(); 377*cdf0e10cSrcweir aBookModeChk.Disable(); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir else if ( pBtn == &aSingleBtn ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir aColumnsEdit.Disable(); 382*cdf0e10cSrcweir aBookModeChk.Disable(); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir else if ( pBtn == &aColumnsBtn ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir aColumnsEdit.Enable(); 387*cdf0e10cSrcweir aColumnsEdit.GrabFocus(); 388*cdf0e10cSrcweir if ( 0 == aColumnsEdit.GetValue() % 2 ) 389*cdf0e10cSrcweir aBookModeChk.Enable(); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir else 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir DBG_ERROR( "Wrong Button" ); 394*cdf0e10cSrcweir return 0; 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir return 0; 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir // ----------------------------------------------------------------------- 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, ViewLayoutSpinHdl, MetricField *, pEdt ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir if ( pEdt == &aColumnsEdit && !aColumnsBtn.IsChecked() ) 405*cdf0e10cSrcweir return 0; 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir if ( 0 == aColumnsEdit.GetValue() % 2 ) 408*cdf0e10cSrcweir aBookModeChk.Enable(); 409*cdf0e10cSrcweir else 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir aBookModeChk.Check( sal_False ); 412*cdf0e10cSrcweir aBookModeChk.Disable(); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir bModified |= sal_True; 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir return 0; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir // ----------------------------------------------------------------------- 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, ViewLayoutCheckHdl, CheckBox *, pChk ) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir if ( pChk == &aBookModeChk && !aColumnsBtn.IsChecked() ) 425*cdf0e10cSrcweir return 0; 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir bModified |= sal_True; 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir return 0; 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir // ----------------------------------------------------------------------- 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, OKHdl, Button *, pBtn ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir if ( bModified || &aOKBtn != pBtn ) 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, 0, rSet.GetPool()->GetWhich( SID_ATTR_ZOOM ) ); 439*cdf0e10cSrcweir SvxViewLayoutItem aViewLayoutItem( 0, false, rSet.GetPool()->GetWhich( SID_ATTR_VIEWLAYOUT ) ); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir if ( &aOKBtn == pBtn ) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir sal_uInt16 nFactor = GetFactor(); 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir if ( SPECIAL_FACTOR == nFactor ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir if ( aOptimalBtn.IsChecked() ) 448*cdf0e10cSrcweir aZoomItem.SetType( SVX_ZOOM_OPTIMAL ); 449*cdf0e10cSrcweir else if ( aPageWidthBtn.IsChecked() ) 450*cdf0e10cSrcweir aZoomItem.SetType( SVX_ZOOM_PAGEWIDTH ); 451*cdf0e10cSrcweir else if ( aWholePageBtn.IsChecked() ) 452*cdf0e10cSrcweir aZoomItem.SetType( SVX_ZOOM_WHOLEPAGE ); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir else 455*cdf0e10cSrcweir aZoomItem.SetValue( nFactor ); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir if ( aAutomaticBtn.IsChecked() ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir aViewLayoutItem.SetValue( 0 ); 460*cdf0e10cSrcweir aViewLayoutItem.SetBookMode( false ); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir if ( aSingleBtn.IsChecked() ) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir aViewLayoutItem.SetValue( 1 ); 465*cdf0e10cSrcweir aViewLayoutItem.SetBookMode( false ); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir else if ( aColumnsBtn.IsChecked() ) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir aViewLayoutItem.SetValue( static_cast<sal_uInt16>(aColumnsEdit.GetValue()) ); 470*cdf0e10cSrcweir aViewLayoutItem.SetBookMode( aBookModeChk.IsChecked() ); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir else 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir DBG_ERROR( "Wrong Button" ); 476*cdf0e10cSrcweir return 0; 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir pOutSet = new SfxItemSet( rSet ); 479*cdf0e10cSrcweir pOutSet->Put( aZoomItem ); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir // don't set attribute in case the whole viewlayout stuff is disabled: 482*cdf0e10cSrcweir if ( aViewLayoutFl.IsEnabled() ) 483*cdf0e10cSrcweir pOutSet->Put( aViewLayoutItem ); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir // Wert aus dem UserEdit "uber den Dialog hinaus merken 486*cdf0e10cSrcweir SfxObjectShell* pSh = SfxObjectShell::Current(); 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir if ( pSh ) 489*cdf0e10cSrcweir pSh->PutItem( SfxUInt16Item( SID_ATTR_ZOOM_USER, 490*cdf0e10cSrcweir (sal_uInt16)aUserEdit.GetValue() ) ); 491*cdf0e10cSrcweir EndDialog( RET_OK ); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir else 494*cdf0e10cSrcweir EndDialog( RET_CANCEL ); 495*cdf0e10cSrcweir return 0; 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir 499