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