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