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