12ee96f1cSAndrew Rist /**************************************************************
2*103e116fSmseidel *
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
10*103e116fSmseidel *
112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*103e116fSmseidel *
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.
19*103e116fSmseidel *
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 {
61*103e116fSmseidel if ( a100Btn.IsChecked() )
62cdf0e10cSrcweir return 100;
63*103e116fSmseidel 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 {
77*103e116fSmseidel if ( nNewFactor == 100 )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir a100Btn.Check();
80cdf0e10cSrcweir a100Btn.GrabFocus();
81cdf0e10cSrcweir }
82*103e116fSmseidel 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*103e116fSmseidel case ZOOMBTN_OPTIMAL: // Optimal button
119cdf0e10cSrcweir aOptimalBtn.Hide();
120cdf0e10cSrcweir break;
121cdf0e10cSrcweir
122*103e116fSmseidel case ZOOMBTN_PAGEWIDTH: // Page Width button
123cdf0e10cSrcweir aPageWidthBtn.Hide();
124cdf0e10cSrcweir break;
125cdf0e10cSrcweir
126*103e116fSmseidel case ZOOMBTN_WHOLEPAGE: // Entire Page button
127cdf0e10cSrcweir aWholePageBtn.Hide();
128cdf0e10cSrcweir break;
129cdf0e10cSrcweir
130cdf0e10cSrcweir default:
131*103e116fSmseidel 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" );
140*103e116fSmseidel aUserEdit.SetMin( nMin );
141cdf0e10cSrcweir aUserEdit.SetFirst( nMin );
142*103e116fSmseidel 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
152*103e116fSmseidel aZoomFl ( this, CUI_RES( FL_ZOOM ) ),
153*103e116fSmseidel aOptimalBtn ( this, CUI_RES( BTN_OPTIMAL ) ),
154*103e116fSmseidel aWholePageBtn ( this, CUI_RES( BTN_WHOLE_PAGE ) ),
155*103e116fSmseidel aPageWidthBtn ( this, CUI_RES( BTN_PAGE_WIDTH ) ),
156*103e116fSmseidel a100Btn ( this, CUI_RES( BTN_100 ) ),
157*103e116fSmseidel aUserBtn ( this, CUI_RES( BTN_USER ) ),
158*103e116fSmseidel aUserEdit ( this, CUI_RES( ED_USER ) ),
159*103e116fSmseidel
160*103e116fSmseidel aViewLayoutFl ( this, CUI_RES( FL_VIEWLAYOUT ) ),
161*103e116fSmseidel aAutomaticBtn ( this, CUI_RES( BTN_AUTOMATIC ) ),
162*103e116fSmseidel aSingleBtn ( this, CUI_RES( BTN_SINGLE ) ),
163*103e116fSmseidel aColumnsBtn ( this, CUI_RES( BTN_COLUMNS ) ),
164*103e116fSmseidel aColumnsEdit ( this, CUI_RES( ED_COLUMNS ) ),
165*103e116fSmseidel aBookModeChk ( this, CUI_RES( CHK_BOOK ) ),
166*103e116fSmseidel
167*103e116fSmseidel aBottomFl ( this, CUI_RES( FL_BOTTOM ) ),
168*103e116fSmseidel aOKBtn ( this, CUI_RES( BTN_ZOOM_OK ) ),
169*103e116fSmseidel aCancelBtn ( this, CUI_RES( BTN_ZOOM_CANCEL ) ),
170*103e116fSmseidel aHelpBtn ( this, CUI_RES( BTN_ZOOM_HELP ) ),
171cdf0e10cSrcweir
172cdf0e10cSrcweir rSet ( rCoreSet ),
173*103e116fSmseidel pOutSet ( NULL ),
174cdf0e10cSrcweir bModified ( sal_False )
175cdf0e10cSrcweir
176cdf0e10cSrcweir {
177cdf0e10cSrcweir #if ENABLE_LAYOUT
178*103e116fSmseidel SetHelpId (".uno:Zoom");
179cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
180cdf0e10cSrcweir Link aLink = LINK( this, SvxZoomDialog, UserHdl );
181*103e116fSmseidel a100Btn.SetClickHdl( aLink );
182*103e116fSmseidel aOptimalBtn.SetClickHdl( aLink );
183cdf0e10cSrcweir aPageWidthBtn.SetClickHdl( aLink );
184cdf0e10cSrcweir aWholePageBtn.SetClickHdl( aLink );
185cdf0e10cSrcweir aUserBtn.SetClickHdl( aLink );
186cdf0e10cSrcweir
187*103e116fSmseidel Link aViewLayoutLink = LINK( this, SvxZoomDialog, ViewLayoutUserHdl );
188*103e116fSmseidel aAutomaticBtn.SetClickHdl( aViewLayoutLink );
189*103e116fSmseidel aSingleBtn.SetClickHdl( aViewLayoutLink );
190*103e116fSmseidel aColumnsBtn.SetClickHdl( aViewLayoutLink );
191cdf0e10cSrcweir
192*103e116fSmseidel Link aViewLayoutSpinLink = LINK( this, SvxZoomDialog, ViewLayoutSpinHdl );
193*103e116fSmseidel aColumnsEdit.SetModifyHdl( aViewLayoutSpinLink );
194cdf0e10cSrcweir
195*103e116fSmseidel Link aViewLayoutCheckLink = LINK( this, SvxZoomDialog, ViewLayoutCheckHdl );
196*103e116fSmseidel aBookModeChk.SetClickHdl( aViewLayoutCheckLink );
197cdf0e10cSrcweir
198*103e116fSmseidel aOKBtn.SetClickHdl( LINK( this, SvxZoomDialog, OKHdl ) );
199cdf0e10cSrcweir aUserEdit.SetModifyHdl( LINK( this, SvxZoomDialog, SpinHdl ) );
200cdf0e10cSrcweir
201*103e116fSmseidel // 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*103e116fSmseidel // initialize UserEdit
217cdf0e10cSrcweir if ( nMin > nValue )
218cdf0e10cSrcweir nMin = nValue;
219cdf0e10cSrcweir if ( nMax < nValue )
220cdf0e10cSrcweir nMax = nValue;
221*103e116fSmseidel aUserEdit.SetMin( nMin );
222cdf0e10cSrcweir aUserEdit.SetFirst( nMin );
223*103e116fSmseidel 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);
232*103e116fSmseidel 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;
240*103e116fSmseidel const sal_uInt16 nZoom = rZoomItem.GetValue();
241*103e116fSmseidel const SvxZoomType eType = rZoomItem.GetType();
242*103e116fSmseidel 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;
258*103e116fSmseidel case SVX_ZOOM_PAGEWIDTH_NOBORDER:
259*103e116fSmseidel break;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262*103e116fSmseidel if ( !(SVX_ZOOM_ENABLE_100 & nValSet) )
263cdf0e10cSrcweir a100Btn.Disable();
264*103e116fSmseidel 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();
270*103e116fSmseidel SetFactor( nZoom, nBtnId );
271cdf0e10cSrcweir }
272cdf0e10cSrcweir else
273cdf0e10cSrcweir {
274*103e116fSmseidel const sal_uInt16 nZoom = ( (const SfxUInt16Item&)rItem ).GetValue();
275*103e116fSmseidel SetFactor( nZoom );
276cdf0e10cSrcweir }
277cdf0e10cSrcweir
278*103e116fSmseidel const SfxPoolItem* pViewLayoutItem = 0;
279*103e116fSmseidel if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_VIEWLAYOUT, sal_False, &pViewLayoutItem ) )
280*103e116fSmseidel {
281*103e116fSmseidel const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem*>(pViewLayoutItem)->GetValue();
282*103e116fSmseidel const bool bBookMode = static_cast<const SvxViewLayoutItem*>(pViewLayoutItem)->IsBookMode();
283*103e116fSmseidel
284*103e116fSmseidel if ( 0 == nColumns )
285*103e116fSmseidel {
286*103e116fSmseidel aAutomaticBtn.Check();
287*103e116fSmseidel aColumnsEdit.SetValue( 2 );
288*103e116fSmseidel aColumnsEdit.Disable();
289*103e116fSmseidel aBookModeChk.Disable();
290*103e116fSmseidel }
291*103e116fSmseidel else if ( 1 == nColumns)
292*103e116fSmseidel {
293*103e116fSmseidel aSingleBtn.Check();
294*103e116fSmseidel aColumnsEdit.SetValue( 2 );
295*103e116fSmseidel aColumnsEdit.Disable();
296*103e116fSmseidel aBookModeChk.Disable();
297*103e116fSmseidel }
298*103e116fSmseidel else
299*103e116fSmseidel {
300*103e116fSmseidel aColumnsBtn.Check();
301*103e116fSmseidel if ( !bBookMode )
302*103e116fSmseidel {
303*103e116fSmseidel aColumnsEdit.SetValue( nColumns );
304*103e116fSmseidel if ( 0 != nColumns % 2 )
305*103e116fSmseidel aBookModeChk.Disable();
306*103e116fSmseidel }
307*103e116fSmseidel else
308*103e116fSmseidel {
309*103e116fSmseidel aColumnsEdit.SetValue( nColumns );
310*103e116fSmseidel aBookModeChk.Check();
311*103e116fSmseidel }
312*103e116fSmseidel }
313*103e116fSmseidel }
314*103e116fSmseidel else
315*103e116fSmseidel {
316*103e116fSmseidel // hide view layout related controls:
317*103e116fSmseidel aViewLayoutFl.Disable();
318*103e116fSmseidel aAutomaticBtn.Disable();
319*103e116fSmseidel aSingleBtn.Disable();
320*103e116fSmseidel aColumnsBtn.Disable();
321*103e116fSmseidel aColumnsEdit.Disable();
322*103e116fSmseidel aBookModeChk.Disable();
323*103e116fSmseidel }
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 {
366*103e116fSmseidel bModified |= sal_True;
367*103e116fSmseidel
368*103e116fSmseidel if ( pBtn == &aAutomaticBtn )
369*103e116fSmseidel {
370*103e116fSmseidel aColumnsEdit.Disable();
371*103e116fSmseidel aBookModeChk.Disable();
372*103e116fSmseidel }
373*103e116fSmseidel else if ( pBtn == &aSingleBtn )
374*103e116fSmseidel {
375*103e116fSmseidel aColumnsEdit.Disable();
376*103e116fSmseidel aBookModeChk.Disable();
377*103e116fSmseidel }
378*103e116fSmseidel else if ( pBtn == &aColumnsBtn )
379*103e116fSmseidel {
380*103e116fSmseidel aColumnsEdit.Enable();
381*103e116fSmseidel aColumnsEdit.GrabFocus();
382*103e116fSmseidel if ( 0 == aColumnsEdit.GetValue() % 2 )
383*103e116fSmseidel aBookModeChk.Enable();
384*103e116fSmseidel }
385*103e116fSmseidel else
386*103e116fSmseidel {
387*103e116fSmseidel DBG_ERROR( "Wrong button" );
388*103e116fSmseidel return 0;
389*103e116fSmseidel }
390*103e116fSmseidel
391*103e116fSmseidel return 0;
392cdf0e10cSrcweir }
393cdf0e10cSrcweir
394cdf0e10cSrcweir // -----------------------------------------------------------------------
395cdf0e10cSrcweir
IMPL_LINK(SvxZoomDialog,ViewLayoutSpinHdl,MetricField *,pEdt)396cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, ViewLayoutSpinHdl, MetricField *, pEdt )
397cdf0e10cSrcweir {
398*103e116fSmseidel if ( pEdt == &aColumnsEdit && !aColumnsBtn.IsChecked() )
399*103e116fSmseidel return 0;
400cdf0e10cSrcweir
401*103e116fSmseidel if ( 0 == aColumnsEdit.GetValue() % 2 )
402*103e116fSmseidel aBookModeChk.Enable();
403*103e116fSmseidel else
404*103e116fSmseidel {
405*103e116fSmseidel aBookModeChk.Check( sal_False );
406*103e116fSmseidel aBookModeChk.Disable();
407*103e116fSmseidel }
408cdf0e10cSrcweir
409*103e116fSmseidel bModified |= sal_True;
410cdf0e10cSrcweir
411*103e116fSmseidel return 0;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir
414cdf0e10cSrcweir // -----------------------------------------------------------------------
415cdf0e10cSrcweir
IMPL_LINK(SvxZoomDialog,ViewLayoutCheckHdl,CheckBox *,pChk)416cdf0e10cSrcweir IMPL_LINK( SvxZoomDialog, ViewLayoutCheckHdl, CheckBox *, pChk )
417cdf0e10cSrcweir {
418*103e116fSmseidel if ( pChk == &aBookModeChk && !aColumnsBtn.IsChecked() )
419*103e116fSmseidel return 0;
420cdf0e10cSrcweir
421*103e116fSmseidel bModified |= sal_True;
422cdf0e10cSrcweir
423*103e116fSmseidel 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 {
432*103e116fSmseidel SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, 0, rSet.GetPool()->GetWhich( SID_ATTR_ZOOM ) );
433*103e116fSmseidel 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() )
442*103e116fSmseidel aZoomItem.SetType( SVX_ZOOM_OPTIMAL );
443cdf0e10cSrcweir else if ( aPageWidthBtn.IsChecked() )
444*103e116fSmseidel aZoomItem.SetType( SVX_ZOOM_PAGEWIDTH );
445cdf0e10cSrcweir else if ( aWholePageBtn.IsChecked() )
446*103e116fSmseidel aZoomItem.SetType( SVX_ZOOM_WHOLEPAGE );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir else
449*103e116fSmseidel aZoomItem.SetValue( nFactor );
450*103e116fSmseidel
451*103e116fSmseidel if ( aAutomaticBtn.IsChecked() )
452*103e116fSmseidel {
453*103e116fSmseidel aViewLayoutItem.SetValue( 0 );
454*103e116fSmseidel aViewLayoutItem.SetBookMode( false );
455*103e116fSmseidel }
456*103e116fSmseidel if ( aSingleBtn.IsChecked() )
457*103e116fSmseidel {
458*103e116fSmseidel aViewLayoutItem.SetValue( 1 );
459*103e116fSmseidel aViewLayoutItem.SetBookMode( false );
460*103e116fSmseidel }
461*103e116fSmseidel else if ( aColumnsBtn.IsChecked() )
462*103e116fSmseidel {
463*103e116fSmseidel aViewLayoutItem.SetValue( static_cast<sal_uInt16>(aColumnsEdit.GetValue()) );
464*103e116fSmseidel aViewLayoutItem.SetBookMode( aBookModeChk.IsChecked() );
465*103e116fSmseidel }
466*103e116fSmseidel }
467cdf0e10cSrcweir else
468cdf0e10cSrcweir {
469cdf0e10cSrcweir DBG_ERROR( "Wrong Button" );
470cdf0e10cSrcweir return 0;
471cdf0e10cSrcweir }
472cdf0e10cSrcweir pOutSet = new SfxItemSet( rSet );
473*103e116fSmseidel pOutSet->Put( aZoomItem );
474cdf0e10cSrcweir
475*103e116fSmseidel // don't set attribute in case the whole view layout stuff is disabled:
476*103e116fSmseidel if ( aViewLayoutFl.IsEnabled() )
477*103e116fSmseidel pOutSet->Put( aViewLayoutItem );
478cdf0e10cSrcweir
479*103e116fSmseidel // 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*103e116fSmseidel /* vim: set noet sw=4 ts=4: */
493