xref: /aoo42x/main/sd/source/ui/dlg/tpoption.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sd.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #ifdef SD_DLLIMPLEMENTATION
32*cdf0e10cSrcweir #undef SD_DLLIMPLEMENTATION
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
41*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
42*cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
43*cdf0e10cSrcweir #include <sfx2/module.hxx>
44*cdf0e10cSrcweir #include <sfx2/app.hxx>
45*cdf0e10cSrcweir #include <svx/svxids.hrc>
46*cdf0e10cSrcweir #include <svx/dialogs.hrc>
47*cdf0e10cSrcweir #include <svx/strarray.hxx>
48*cdf0e10cSrcweir #include <svx/dlgutil.hxx>
49*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #include "sdattr.hxx"
52*cdf0e10cSrcweir #include "sdresid.hxx"
53*cdf0e10cSrcweir #include "optsitem.hxx"
54*cdf0e10cSrcweir #include "tpoption.hrc"
55*cdf0e10cSrcweir #include "tpoption.hxx"
56*cdf0e10cSrcweir #include "strings.hrc"
57*cdf0e10cSrcweir #include "app.hrc"
58*cdf0e10cSrcweir #include <svl/intitem.hxx>
59*cdf0e10cSrcweir #include <sfx2/request.hxx>
60*cdf0e10cSrcweir #define DLGWIN this->GetParent()->GetParent()
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir using namespace ::com::sun::star;
63*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir /*************************************************************************
66*cdf0e10cSrcweir |*
67*cdf0e10cSrcweir |*	TabPage zum Einstellen der Fang-Optionen
68*cdf0e10cSrcweir |*
69*cdf0e10cSrcweir \************************************************************************/
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir SdTpOptionsSnap::SdTpOptionsSnap( Window* pParent, const SfxItemSet& rInAttrs  ) :
72*cdf0e10cSrcweir         SvxGridTabPage(pParent, rInAttrs)
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir     aGrpSnap.Show();
75*cdf0e10cSrcweir     aCbxSnapHelplines.Show();
76*cdf0e10cSrcweir     aCbxSnapBorder.Show();
77*cdf0e10cSrcweir     aCbxSnapFrame.Show();
78*cdf0e10cSrcweir     aCbxSnapPoints.Show();
79*cdf0e10cSrcweir     aFtSnapArea.Show();
80*cdf0e10cSrcweir     aMtrFldSnapArea.Show();
81*cdf0e10cSrcweir     aGrpOrtho.Show();
82*cdf0e10cSrcweir     aCbxOrtho.Show();
83*cdf0e10cSrcweir     aCbxBigOrtho.Show();
84*cdf0e10cSrcweir     aCbxRotate.Show();
85*cdf0e10cSrcweir     aMtrFldAngle.Show();
86*cdf0e10cSrcweir     aFtBezAngle.Show();
87*cdf0e10cSrcweir     aMtrFldBezAngle.Show();
88*cdf0e10cSrcweir     aSeparatorFL.Show();
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir // -----------------------------------------------------------------------
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir SdTpOptionsSnap::~SdTpOptionsSnap()
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir // -----------------------------------------------------------------------
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir sal_Bool SdTpOptionsSnap::FillItemSet( SfxItemSet& rAttrs )
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir     SvxGridTabPage::FillItemSet(rAttrs);
102*cdf0e10cSrcweir     SdOptionsSnapItem* pOptsItem = NULL;
103*cdf0e10cSrcweir //    if(SFX_ITEM_SET != rAttrs.GetItemState( ATTR_OPTIONS_SNAP, sal_False, (const SfxPoolItem**)&pOptsItem ))
104*cdf0e10cSrcweir //        pExampleSet->GetItemState( ATTR_OPTIONS_SNAP, sal_False, (const SfxPoolItem**)&pOptsItem );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	SdOptionsSnapItem aOptsItem( ATTR_OPTIONS_SNAP );
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetSnapHelplines( aCbxSnapHelplines.IsChecked() );
109*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetSnapBorder( aCbxSnapBorder.IsChecked() );
110*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetSnapFrame( aCbxSnapFrame.IsChecked() );
111*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetSnapPoints( aCbxSnapPoints.IsChecked() );
112*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetOrtho( aCbxOrtho.IsChecked() );
113*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetBigOrtho( aCbxBigOrtho.IsChecked() );
114*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetRotate( aCbxRotate.IsChecked() );
115*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetSnapArea( (sal_Int16) aMtrFldSnapArea.GetValue() );
116*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetAngle( (sal_Int16) aMtrFldAngle.GetValue() );
117*cdf0e10cSrcweir 	aOptsItem.GetOptionsSnap().SetEliminatePolyPointLimitAngle( (sal_Int16) aMtrFldBezAngle.GetValue() );
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	if( pOptsItem == NULL || !(aOptsItem == *pOptsItem) )
120*cdf0e10cSrcweir 		rAttrs.Put( aOptsItem );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 	// Evtl. vorhandenes GridItem wird geholt, um nicht versehentlich
123*cdf0e10cSrcweir 	// irgendwelche Standardwerte einzustellen
124*cdf0e10cSrcweir 	return( sal_True );
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir // -----------------------------------------------------------------------
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir void SdTpOptionsSnap::Reset( const SfxItemSet& rAttrs )
130*cdf0e10cSrcweir {
131*cdf0e10cSrcweir     SvxGridTabPage::Reset(rAttrs);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	SdOptionsSnapItem aOptsItem( (const SdOptionsSnapItem&) rAttrs.
134*cdf0e10cSrcweir 						Get( ATTR_OPTIONS_SNAP ) );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	aCbxSnapHelplines.Check( aOptsItem.GetOptionsSnap().IsSnapHelplines() );
137*cdf0e10cSrcweir 	aCbxSnapBorder.Check( aOptsItem.GetOptionsSnap().IsSnapBorder() );
138*cdf0e10cSrcweir 	aCbxSnapFrame.Check( aOptsItem.GetOptionsSnap().IsSnapFrame() );
139*cdf0e10cSrcweir 	aCbxSnapPoints.Check( aOptsItem.GetOptionsSnap().IsSnapPoints() );
140*cdf0e10cSrcweir 	aCbxOrtho.Check( aOptsItem.GetOptionsSnap().IsOrtho() );
141*cdf0e10cSrcweir 	aCbxBigOrtho.Check( aOptsItem.GetOptionsSnap().IsBigOrtho() );
142*cdf0e10cSrcweir 	aCbxRotate.Check( aOptsItem.GetOptionsSnap().IsRotate() );
143*cdf0e10cSrcweir 	aMtrFldSnapArea.SetValue( aOptsItem.GetOptionsSnap().GetSnapArea() );
144*cdf0e10cSrcweir 	aMtrFldAngle.SetValue( aOptsItem.GetOptionsSnap().GetAngle() );
145*cdf0e10cSrcweir 	aMtrFldBezAngle.SetValue( aOptsItem.GetOptionsSnap().GetEliminatePolyPointLimitAngle() );
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     aCbxRotate.GetClickHdl().Call(0);
148*cdf0e10cSrcweir }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir // -----------------------------------------------------------------------
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir SfxTabPage* SdTpOptionsSnap::Create( Window* pWindow,
153*cdf0e10cSrcweir 				const SfxItemSet& rAttrs )
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir 	return( new SdTpOptionsSnap( pWindow, rAttrs ) );
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir /*************************************************************************
159*cdf0e10cSrcweir |*
160*cdf0e10cSrcweir |*	TabPage zum Einstellen der Inhalte-Optionen
161*cdf0e10cSrcweir |*
162*cdf0e10cSrcweir \************************************************************************/
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir SdTpOptionsContents::SdTpOptionsContents( Window* pParent, const SfxItemSet& rInAttrs  ) :
165*cdf0e10cSrcweir 		SfxTabPage          ( pParent, SdResId( TP_OPTIONS_CONTENTS ), rInAttrs ),
166*cdf0e10cSrcweir         aGrpDisplay         ( this, SdResId( GRP_DISPLAY ) ),
167*cdf0e10cSrcweir 		aCbxRuler           ( this, SdResId( CBX_RULER ) ),
168*cdf0e10cSrcweir 		aCbxDragStripes     ( this, SdResId( CBX_HELPLINES ) ),
169*cdf0e10cSrcweir 		aCbxHandlesBezier   ( this, SdResId( CBX_HANDLES_BEZIER ) ),
170*cdf0e10cSrcweir 		aCbxMoveOutline     ( this, SdResId( CBX_MOVE_OUTLINE ) )
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir 	FreeResource();
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir // -----------------------------------------------------------------------
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir SdTpOptionsContents::~SdTpOptionsContents()
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir // -----------------------------------------------------------------------
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir sal_Bool SdTpOptionsContents::FillItemSet( SfxItemSet& rAttrs )
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir 	sal_Bool bModified = sal_False;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     if( aCbxRuler.GetSavedValue()           != aCbxRuler.IsChecked() ||
188*cdf0e10cSrcweir 		aCbxMoveOutline.GetSavedValue()		!= aCbxMoveOutline.IsChecked() ||
189*cdf0e10cSrcweir 		aCbxDragStripes.GetSavedValue()		!= aCbxDragStripes.IsChecked() ||
190*cdf0e10cSrcweir 		//aCbxHelplines.GetSavedValue()		!= aCbxHelplines.IsChecked() ||
191*cdf0e10cSrcweir 		aCbxHandlesBezier.GetSavedValue()	!= aCbxHandlesBezier.IsChecked() )
192*cdf0e10cSrcweir 	{
193*cdf0e10cSrcweir         SdOptionsLayoutItem aOptsItem( ATTR_OPTIONS_LAYOUT );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         aOptsItem.GetOptionsLayout().SetRulerVisible( aCbxRuler.IsChecked() );
196*cdf0e10cSrcweir         aOptsItem.GetOptionsLayout().SetMoveOutline( aCbxMoveOutline.IsChecked() );
197*cdf0e10cSrcweir         aOptsItem.GetOptionsLayout().SetDragStripes( aCbxDragStripes.IsChecked() );
198*cdf0e10cSrcweir         aOptsItem.GetOptionsLayout().SetHandlesBezier( aCbxHandlesBezier.IsChecked() );
199*cdf0e10cSrcweir         //aOptsItem.GetOptionsLayout().SetHelplines( aCbxHelplines.IsChecked() );
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir         rAttrs.Put( aOptsItem );
202*cdf0e10cSrcweir         bModified = sal_True;
203*cdf0e10cSrcweir 	}
204*cdf0e10cSrcweir     return( bModified );
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir // -----------------------------------------------------------------------
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir void SdTpOptionsContents::Reset( const SfxItemSet& rAttrs )
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir 	SdOptionsContentsItem aOptsItem( (const SdOptionsContentsItem&) rAttrs.
212*cdf0e10cSrcweir 						Get( ATTR_OPTIONS_CONTENTS ) );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     SdOptionsLayoutItem aLayoutItem( (const SdOptionsLayoutItem&) rAttrs.
215*cdf0e10cSrcweir 						Get( ATTR_OPTIONS_LAYOUT ) );
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     aCbxRuler.Check( aLayoutItem.GetOptionsLayout().IsRulerVisible() );
218*cdf0e10cSrcweir     aCbxMoveOutline.Check( aLayoutItem.GetOptionsLayout().IsMoveOutline() );
219*cdf0e10cSrcweir     aCbxDragStripes.Check( aLayoutItem.GetOptionsLayout().IsDragStripes() );
220*cdf0e10cSrcweir     aCbxHandlesBezier.Check( aLayoutItem.GetOptionsLayout().IsHandlesBezier() );
221*cdf0e10cSrcweir     //aCbxHelplines.Check( aLayoutItem.GetOptionsLayout().IsHelplines() );
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	aCbxRuler.SaveValue();
224*cdf0e10cSrcweir 	aCbxMoveOutline.SaveValue();
225*cdf0e10cSrcweir 	aCbxDragStripes.SaveValue();
226*cdf0e10cSrcweir 	aCbxHandlesBezier.SaveValue();
227*cdf0e10cSrcweir 	//aCbxHelplines.SaveValue();
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir // -----------------------------------------------------------------------
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir SfxTabPage* SdTpOptionsContents::Create( Window* pWindow,
233*cdf0e10cSrcweir 				const SfxItemSet& rAttrs )
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	return( new SdTpOptionsContents( pWindow, rAttrs ) );
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir /*************************************************************************
239*cdf0e10cSrcweir |*
240*cdf0e10cSrcweir |*	TabPage zum Einstellen der Sonstige-Optionen
241*cdf0e10cSrcweir |*
242*cdf0e10cSrcweir \************************************************************************/
243*cdf0e10cSrcweir #define TABLE_COUNT 12
244*cdf0e10cSrcweir #define TOKEN (sal_Unicode(':'))
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir SdTpOptionsMisc::SdTpOptionsMisc( Window* pParent, const SfxItemSet& rInAttrs  ) :
247*cdf0e10cSrcweir 		SfxTabPage          ( pParent, SdResId( TP_OPTIONS_MISC ), rInAttrs ),
248*cdf0e10cSrcweir 	aGrpText                    ( this, SdResId( GRP_TEXT ) ),
249*cdf0e10cSrcweir 	aCbxQuickEdit               ( this, SdResId( CBX_QUICKEDIT ) ),
250*cdf0e10cSrcweir 	aCbxPickThrough             ( this, SdResId( CBX_PICKTHROUGH ) ),
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	// Template & Layout laufen z.Z. synchron!
253*cdf0e10cSrcweir 	aGrpProgramStart            ( this, SdResId( GRP_PROGRAMSTART ) ),
254*cdf0e10cSrcweir 	aCbxStartWithTemplate       ( this, SdResId( CBX_START_WITH_TEMPLATE ) ),
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     aGrpSettings                ( this, SdResId( GRP_SETTINGS ) ),
257*cdf0e10cSrcweir 	aCbxMasterPageCache         ( this, SdResId( CBX_MASTERPAGE_CACHE ) ),
258*cdf0e10cSrcweir 	aCbxCopy                    ( this, SdResId( CBX_COPY ) ),
259*cdf0e10cSrcweir 	aCbxMarkedHitMovesAlways    ( this, SdResId( CBX_MARKED_HIT_MOVES_ALWAYS ) ),
260*cdf0e10cSrcweir 	aCbxCrookNoContortion       ( this, SdResId( CBX_CROOK_NO_CONTORTION ) ),
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     aTxtMetric                  ( this, SdResId( FT_METRIC ) ),
263*cdf0e10cSrcweir     aLbMetric                   ( this, SdResId( LB_METRIC ) ),
264*cdf0e10cSrcweir     aTxtTabstop                 ( this, SdResId( FT_TABSTOP ) ),
265*cdf0e10cSrcweir     aMtrFldTabstop              ( this, SdResId( MTR_FLD_TABSTOP ) ),
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 	aCbxStartWithActualPage		( this, SdResId( CBX_START_WITH_ACTUAL_PAGE ) ),
268*cdf0e10cSrcweir 	aGrpStartWithActualPage     ( this, SdResId( GRP_START_WITH_ACTUAL_PAGE ) ),
269*cdf0e10cSrcweir 	aTxtCompatibility			( this, SdResId( FT_COMPATIBILITY ) ),
270*cdf0e10cSrcweir     aCbxUsePrinterMetrics       ( this, SdResId( CB_USE_PRINTER_METRICS ) ),
271*cdf0e10cSrcweir     aCbxCompatibility           ( this, SdResId( CB_MERGE_PARA_DIST ) ),
272*cdf0e10cSrcweir     aGrpScale                   ( this, SdResId( GRP_SCALE ) ),
273*cdf0e10cSrcweir     aFtScale                    ( this, SdResId( FT_SCALE ) ),
274*cdf0e10cSrcweir     aCbScale                    ( this, SdResId( CB_SCALE ) ),
275*cdf0e10cSrcweir     aFtOriginal                 ( this, SdResId( FT_ORIGINAL ) ),
276*cdf0e10cSrcweir     aFtEquivalent               ( this, SdResId( FT_EQUIVALENT ) ),
277*cdf0e10cSrcweir     aFtPageWidth                ( this, SdResId( FT_PAGEWIDTH ) ),
278*cdf0e10cSrcweir     aFiInfo1                    ( this, SdResId( FI_INFO_1 ) ),
279*cdf0e10cSrcweir     aMtrFldOriginalWidth        ( this, SdResId( MTR_FLD_ORIGINAL_WIDTH ) ),
280*cdf0e10cSrcweir     aFtPageHeight               ( this, SdResId( FT_PAGEHEIGHT ) ),
281*cdf0e10cSrcweir     aFiInfo2                    ( this, SdResId( FI_INFO_2 ) ),
282*cdf0e10cSrcweir     aMtrFldOriginalHeight       ( this, SdResId( MTR_FLD_ORIGINAL_HEIGHT ) ),
283*cdf0e10cSrcweir     aMtrFldInfo1                ( this, WinBits( WB_HIDE ) ),
284*cdf0e10cSrcweir     aMtrFldInfo2                ( this, WinBits( WB_HIDE ) )
285*cdf0e10cSrcweir {
286*cdf0e10cSrcweir 	FreeResource();
287*cdf0e10cSrcweir     SetExchangeSupport();
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir     // Metrik einstellen
290*cdf0e10cSrcweir 	FieldUnit eFUnit;
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 	sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
293*cdf0e10cSrcweir 	if ( rInAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
294*cdf0e10cSrcweir 	{
295*cdf0e10cSrcweir 		const SfxUInt16Item& rItem = (SfxUInt16Item&)rInAttrs.Get( nWhich );
296*cdf0e10cSrcweir 		eFUnit = (FieldUnit)rItem.GetValue();
297*cdf0e10cSrcweir 	}
298*cdf0e10cSrcweir 	else
299*cdf0e10cSrcweir 		eFUnit = SfxModule::GetCurrentFieldUnit();
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 	SetFieldUnit( aMtrFldTabstop, eFUnit );
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 	// ListBox mit Metriken f"ullen
304*cdf0e10cSrcweir 	SvxStringArray aMetricArr( RID_SVXSTR_FIELDUNIT_TABLE );
305*cdf0e10cSrcweir 	sal_uInt16 i;
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	for ( i = 0; i < aMetricArr.Count(); ++i )
308*cdf0e10cSrcweir 	{
309*cdf0e10cSrcweir 		String sMetric = aMetricArr.GetStringByPos( i );
310*cdf0e10cSrcweir 		long nFieldUnit = aMetricArr.GetValue( i );
311*cdf0e10cSrcweir 		sal_uInt16 nPos = aLbMetric.InsertEntry( sMetric );
312*cdf0e10cSrcweir 		aLbMetric.SetEntryData( nPos, (void*)nFieldUnit );
313*cdf0e10cSrcweir 	}
314*cdf0e10cSrcweir     aLbMetric.SetSelectHdl( LINK( this, SdTpOptionsMisc, SelectMetricHdl_Impl ) );
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir     SetFieldUnit( aMtrFldOriginalWidth, eFUnit );
317*cdf0e10cSrcweir 	SetFieldUnit( aMtrFldOriginalHeight, eFUnit );
318*cdf0e10cSrcweir 	aMtrFldOriginalWidth.SetLast( 999999999 );
319*cdf0e10cSrcweir 	aMtrFldOriginalWidth.SetMax( 999999999 );
320*cdf0e10cSrcweir 	aMtrFldOriginalHeight.SetLast( 999999999 );
321*cdf0e10cSrcweir 	aMtrFldOriginalHeight.SetMax( 999999999 );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	// Temporaere Fields fuer Info-Texte (fuer Formatierung/Berechnung)
324*cdf0e10cSrcweir 	aMtrFldInfo1.SetUnit( eFUnit );
325*cdf0e10cSrcweir 	aMtrFldInfo1.SetMax( 999999999 );
326*cdf0e10cSrcweir 	aMtrFldInfo1.SetDecimalDigits( 2 );
327*cdf0e10cSrcweir 	aMtrFldInfo2.SetUnit( eFUnit );
328*cdf0e10cSrcweir 	aMtrFldInfo2.SetMax( 999999999 );
329*cdf0e10cSrcweir 	aMtrFldInfo2.SetDecimalDigits( 2 );
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 	// PoolUnit ermitteln
332*cdf0e10cSrcweir     SfxItemPool* pPool = rInAttrs.GetPool();
333*cdf0e10cSrcweir 	DBG_ASSERT( pPool, "Wo ist der Pool?" );
334*cdf0e10cSrcweir 	ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 	// Fuellen der CB
337*cdf0e10cSrcweir 	sal_uInt16 aTable[ TABLE_COUNT ] =
338*cdf0e10cSrcweir 		{ 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 };
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir     for( i = 0; i < TABLE_COUNT; i++ )
341*cdf0e10cSrcweir 		aCbScale.InsertEntry( GetScale( 1, aTable[i] ) );
342*cdf0e10cSrcweir 	for( i = 1; i < TABLE_COUNT; i++ )
343*cdf0e10cSrcweir 		aCbScale.InsertEntry( GetScale(  aTable[i], 1 ) );
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir // -----------------------------------------------------------------------
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir SdTpOptionsMisc::~SdTpOptionsMisc()
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir }
351*cdf0e10cSrcweir // -----------------------------------------------------------------------
352*cdf0e10cSrcweir void SdTpOptionsMisc::ActivatePage( const SfxItemSet& rSet )
353*cdf0e10cSrcweir {
354*cdf0e10cSrcweir 	// Hier muss noch einmal SaveValue gerufen werden, da sonst u.U.
355*cdf0e10cSrcweir 	// der Wert in anderen TabPages keine Wirkung hat
356*cdf0e10cSrcweir 	aLbMetric.SaveValue();
357*cdf0e10cSrcweir     // Metrik ggfs. aendern (da TabPage im Dialog liegt,
358*cdf0e10cSrcweir 	// wo die Metrik eingestellt werden kann
359*cdf0e10cSrcweir 	const SfxPoolItem* pAttr = NULL;
360*cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC , sal_False,
361*cdf0e10cSrcweir 									(const SfxPoolItem**)&pAttr ))
362*cdf0e10cSrcweir 	{
363*cdf0e10cSrcweir 		const SfxUInt16Item* pItem = (SfxUInt16Item*) pAttr;
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 		FieldUnit eFUnit = (FieldUnit)(long)pItem->GetValue();
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 		if( eFUnit != aMtrFldOriginalWidth.GetUnit() )
368*cdf0e10cSrcweir 		{
369*cdf0e10cSrcweir 			// Metriken einstellen
370*cdf0e10cSrcweir 			sal_Int64 nVal = aMtrFldOriginalWidth.Denormalize( aMtrFldOriginalWidth.GetValue( FUNIT_TWIP ) );
371*cdf0e10cSrcweir 			SetFieldUnit( aMtrFldOriginalWidth, eFUnit, sal_True );
372*cdf0e10cSrcweir 			aMtrFldOriginalWidth.SetValue( aMtrFldOriginalWidth.Normalize( nVal ), FUNIT_TWIP );
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 			nVal = aMtrFldOriginalHeight.Denormalize( aMtrFldOriginalHeight.GetValue( FUNIT_TWIP ) );
375*cdf0e10cSrcweir 			SetFieldUnit( aMtrFldOriginalHeight, eFUnit, sal_True );
376*cdf0e10cSrcweir 			aMtrFldOriginalHeight.SetValue( aMtrFldOriginalHeight.Normalize( nVal ), FUNIT_TWIP );
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 			if( nWidth != 0 && nHeight != 0 )
380*cdf0e10cSrcweir 			{
381*cdf0e10cSrcweir 				aMtrFldInfo1.SetUnit( eFUnit );
382*cdf0e10cSrcweir 				aMtrFldInfo2.SetUnit( eFUnit );
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 				SetMetricValue( aMtrFldInfo1, nWidth, ePoolUnit );
385*cdf0e10cSrcweir 				aInfo1 = aMtrFldInfo1.GetText();
386*cdf0e10cSrcweir 				aFiInfo1.SetText( aInfo1 );
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 				SetMetricValue( aMtrFldInfo2, nHeight, ePoolUnit );
389*cdf0e10cSrcweir 				aInfo2 = aMtrFldInfo2.GetText();
390*cdf0e10cSrcweir 				aFiInfo2.SetText( aInfo2 );
391*cdf0e10cSrcweir 			}
392*cdf0e10cSrcweir 		}
393*cdf0e10cSrcweir 	}
394*cdf0e10cSrcweir }
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir // -----------------------------------------------------------------------
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir int SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet )
399*cdf0e10cSrcweir {
400*cdf0e10cSrcweir     // Parsercheck
401*cdf0e10cSrcweir 	sal_Int32 nX, nY;
402*cdf0e10cSrcweir 	if( SetScale( aCbScale.GetText(), nX, nY ) )
403*cdf0e10cSrcweir 	{
404*cdf0e10cSrcweir 		if( pActiveSet )
405*cdf0e10cSrcweir 			FillItemSet( *pActiveSet );
406*cdf0e10cSrcweir         return( LEAVE_PAGE );
407*cdf0e10cSrcweir     }
408*cdf0e10cSrcweir 	WarningBox aWarnBox( GetParent(), WB_YES_NO, String( SdResId( STR_WARN_SCALE_FAIL ) ) );
409*cdf0e10cSrcweir 	short nReturn = aWarnBox.Execute();
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 	if( nReturn == RET_YES )
412*cdf0e10cSrcweir 		return( KEEP_PAGE );
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 	if( pActiveSet )
415*cdf0e10cSrcweir 		FillItemSet( *pActiveSet );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	return( LEAVE_PAGE );
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir // -----------------------------------------------------------------------
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir sal_Bool SdTpOptionsMisc::FillItemSet( SfxItemSet& rAttrs )
423*cdf0e10cSrcweir {
424*cdf0e10cSrcweir 	sal_Bool bModified = sal_False;
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 	if( aCbxStartWithTemplate.GetSavedValue() 	!= aCbxStartWithTemplate.IsChecked() ||
427*cdf0e10cSrcweir 		aCbxMarkedHitMovesAlways.GetSavedValue()!= aCbxMarkedHitMovesAlways.IsChecked() ||
428*cdf0e10cSrcweir 		aCbxCrookNoContortion.GetSavedValue() 	!= aCbxCrookNoContortion.IsChecked() ||
429*cdf0e10cSrcweir 		aCbxQuickEdit.GetSavedValue() 			!= aCbxQuickEdit.IsChecked() ||
430*cdf0e10cSrcweir 		aCbxPickThrough.GetSavedValue() 		!= aCbxPickThrough.IsChecked() ||
431*cdf0e10cSrcweir 		aCbxMasterPageCache.GetSavedValue() 	!= aCbxMasterPageCache.IsChecked() ||
432*cdf0e10cSrcweir 		aCbxCopy.GetSavedValue() 				!= aCbxCopy.IsChecked() ||
433*cdf0e10cSrcweir 		aCbxStartWithActualPage.GetSavedValue() != aCbxStartWithActualPage.IsChecked() ||
434*cdf0e10cSrcweir 		aCbxCompatibility.GetSavedValue()		!= aCbxCompatibility.IsChecked() ||
435*cdf0e10cSrcweir 		aCbxUsePrinterMetrics.GetSavedValue()   != aCbxUsePrinterMetrics.IsChecked() )
436*cdf0e10cSrcweir 	{
437*cdf0e10cSrcweir 		SdOptionsMiscItem aOptsItem( ATTR_OPTIONS_MISC );
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetStartWithTemplate( aCbxStartWithTemplate.IsChecked() );
440*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( aCbxMarkedHitMovesAlways.IsChecked() );
441*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetCrookNoContortion( aCbxCrookNoContortion.IsChecked() );
442*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetQuickEdit( aCbxQuickEdit.IsChecked() );
443*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetPickThrough( aCbxPickThrough.IsChecked() );
444*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching( aCbxMasterPageCache.IsChecked() );
445*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetDragWithCopy( aCbxCopy.IsChecked() );
446*cdf0e10cSrcweir 		aOptsItem.GetOptionsMisc().SetStartWithActualPage( aCbxStartWithActualPage.IsChecked() );
447*cdf0e10cSrcweir         aOptsItem.GetOptionsMisc().SetSummationOfParagraphs( aCbxCompatibility.IsChecked() );
448*cdf0e10cSrcweir         aOptsItem.GetOptionsMisc().SetPrinterIndependentLayout (
449*cdf0e10cSrcweir             aCbxUsePrinterMetrics.IsChecked()
450*cdf0e10cSrcweir             ? ::com::sun::star::document::PrinterIndependentLayout::DISABLED
451*cdf0e10cSrcweir             : ::com::sun::star::document::PrinterIndependentLayout::ENABLED);
452*cdf0e10cSrcweir 		rAttrs.Put( aOptsItem );
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 		bModified = sal_True;
455*cdf0e10cSrcweir 	}
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	// Metrik
458*cdf0e10cSrcweir 	const sal_uInt16 nMPos = aLbMetric.GetSelectEntryPos();
459*cdf0e10cSrcweir 	if ( nMPos != aLbMetric.GetSavedValue() )
460*cdf0e10cSrcweir 	{
461*cdf0e10cSrcweir 		sal_uInt16 nFieldUnit = (sal_uInt16)(long)aLbMetric.GetEntryData( nMPos );
462*cdf0e10cSrcweir 		rAttrs.Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC ),
463*cdf0e10cSrcweir 									 (sal_uInt16)nFieldUnit ) );
464*cdf0e10cSrcweir 		bModified |= sal_True;
465*cdf0e10cSrcweir 	}
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir 	// Tabulatorabstand
468*cdf0e10cSrcweir 	if( aMtrFldTabstop.GetText() != aMtrFldTabstop.GetSavedValue() )
469*cdf0e10cSrcweir 	{
470*cdf0e10cSrcweir 		sal_uInt16 nWh = GetWhich( SID_ATTR_DEFTABSTOP );
471*cdf0e10cSrcweir 		SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWh );
472*cdf0e10cSrcweir 		SfxUInt16Item aDef( nWh,(sal_uInt16)GetCoreValue( aMtrFldTabstop, eUnit ) );
473*cdf0e10cSrcweir 		rAttrs.Put( aDef );
474*cdf0e10cSrcweir 		bModified |= sal_True;
475*cdf0e10cSrcweir 	}
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	sal_Int32 nX, nY;
478*cdf0e10cSrcweir 	if( SetScale( aCbScale.GetText(), nX, nY ) )
479*cdf0e10cSrcweir 	{
480*cdf0e10cSrcweir 		rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) );
481*cdf0e10cSrcweir 		rAttrs.Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) );
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir 		bModified = sal_True;
484*cdf0e10cSrcweir 	}
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir     return( bModified );
487*cdf0e10cSrcweir }
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir // -----------------------------------------------------------------------
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir void SdTpOptionsMisc::Reset( const SfxItemSet& rAttrs )
492*cdf0e10cSrcweir {
493*cdf0e10cSrcweir 	SdOptionsMiscItem aOptsItem( (const SdOptionsMiscItem&) rAttrs.
494*cdf0e10cSrcweir 						Get( ATTR_OPTIONS_MISC ) );
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	aCbxStartWithTemplate.Check( aOptsItem.GetOptionsMisc().IsStartWithTemplate() );
497*cdf0e10cSrcweir 	aCbxMarkedHitMovesAlways.Check( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() );
498*cdf0e10cSrcweir 	aCbxCrookNoContortion.Check( aOptsItem.GetOptionsMisc().IsCrookNoContortion() );
499*cdf0e10cSrcweir 	aCbxQuickEdit.Check( aOptsItem.GetOptionsMisc().IsQuickEdit() );
500*cdf0e10cSrcweir 	aCbxPickThrough.Check( aOptsItem.GetOptionsMisc().IsPickThrough() );
501*cdf0e10cSrcweir 	aCbxMasterPageCache.Check( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() );
502*cdf0e10cSrcweir 	aCbxCopy.Check( aOptsItem.GetOptionsMisc().IsDragWithCopy() );
503*cdf0e10cSrcweir 	aCbxStartWithActualPage.Check( aOptsItem.GetOptionsMisc().IsStartWithActualPage() );
504*cdf0e10cSrcweir     aCbxCompatibility.Check( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() );
505*cdf0e10cSrcweir     aCbxUsePrinterMetrics.Check( aOptsItem.GetOptionsMisc().GetPrinterIndependentLayout()==1 );
506*cdf0e10cSrcweir 	aCbxStartWithTemplate.SaveValue();
507*cdf0e10cSrcweir 	aCbxMarkedHitMovesAlways.SaveValue();
508*cdf0e10cSrcweir 	aCbxCrookNoContortion.SaveValue();
509*cdf0e10cSrcweir 	aCbxQuickEdit.SaveValue();
510*cdf0e10cSrcweir 	aCbxPickThrough.SaveValue();
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir 	aCbxMasterPageCache.SaveValue();
513*cdf0e10cSrcweir 	aCbxCopy.SaveValue();
514*cdf0e10cSrcweir 	aCbxStartWithActualPage.SaveValue();
515*cdf0e10cSrcweir 	aCbxCompatibility.SaveValue();
516*cdf0e10cSrcweir 	aCbxUsePrinterMetrics.SaveValue();
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir     // Metrik
519*cdf0e10cSrcweir 	sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC );
520*cdf0e10cSrcweir 	aLbMetric.SetNoSelection();
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 	if ( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
523*cdf0e10cSrcweir 	{
524*cdf0e10cSrcweir 		const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
525*cdf0e10cSrcweir 		long nFieldUnit = (long)rItem.GetValue();
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir 		for ( sal_uInt16 i = 0; i < aLbMetric.GetEntryCount(); ++i )
528*cdf0e10cSrcweir 		{
529*cdf0e10cSrcweir 			if ( (long)aLbMetric.GetEntryData( i ) == nFieldUnit )
530*cdf0e10cSrcweir 			{
531*cdf0e10cSrcweir 				aLbMetric.SelectEntryPos( i );
532*cdf0e10cSrcweir 				break;
533*cdf0e10cSrcweir 			}
534*cdf0e10cSrcweir 		}
535*cdf0e10cSrcweir 	}
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir 	// Tabulatorabstand
538*cdf0e10cSrcweir 	nWhich = GetWhich( SID_ATTR_DEFTABSTOP );
539*cdf0e10cSrcweir 	if( rAttrs.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
540*cdf0e10cSrcweir 	{
541*cdf0e10cSrcweir 		SfxMapUnit eUnit = rAttrs.GetPool()->GetMetric( nWhich );
542*cdf0e10cSrcweir 		const SfxUInt16Item& rItem = (SfxUInt16Item&)rAttrs.Get( nWhich );
543*cdf0e10cSrcweir 		SetMetricValue( aMtrFldTabstop, rItem.GetValue(), eUnit );
544*cdf0e10cSrcweir 	}
545*cdf0e10cSrcweir 	aLbMetric.SaveValue();
546*cdf0e10cSrcweir 	aMtrFldTabstop.SaveValue();
547*cdf0e10cSrcweir     //Scale
548*cdf0e10cSrcweir     sal_Int32 nX = ( (const SfxInt32Item&) rAttrs.
549*cdf0e10cSrcweir 				 Get( ATTR_OPTIONS_SCALE_X ) ).GetValue();
550*cdf0e10cSrcweir 	sal_Int32 nY = ( (const SfxInt32Item&) rAttrs.
551*cdf0e10cSrcweir 				 Get( ATTR_OPTIONS_SCALE_Y ) ).GetValue();
552*cdf0e10cSrcweir 	nWidth = ( (const SfxUInt32Item&) rAttrs.
553*cdf0e10cSrcweir 					Get( ATTR_OPTIONS_SCALE_WIDTH ) ).GetValue();
554*cdf0e10cSrcweir 	nHeight = ( (const SfxUInt32Item&) rAttrs.
555*cdf0e10cSrcweir 					Get( ATTR_OPTIONS_SCALE_HEIGHT ) ).GetValue();
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir 	aCbScale.SetText( GetScale( nX, nY ) );
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir     // #92067# broken feature disabled for 6.0
560*cdf0e10cSrcweir     aFtOriginal.Hide();
561*cdf0e10cSrcweir     aFtEquivalent.Hide();
562*cdf0e10cSrcweir     aMtrFldOriginalWidth.Hide();
563*cdf0e10cSrcweir     aMtrFldOriginalWidth.SetText( aInfo1 ); // leer
564*cdf0e10cSrcweir     aMtrFldOriginalHeight.Hide();
565*cdf0e10cSrcweir     aMtrFldOriginalHeight.SetText( aInfo2 ); //leer
566*cdf0e10cSrcweir     aFtPageWidth.Hide();
567*cdf0e10cSrcweir     aFtPageHeight.Hide();
568*cdf0e10cSrcweir     aFiInfo1.Hide();
569*cdf0e10cSrcweir     aFiInfo2.Hide();
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir     UpdateCompatibilityControls ();
572*cdf0e10cSrcweir }
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir // -----------------------------------------------------------------------
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir SfxTabPage* SdTpOptionsMisc::Create( Window* pWindow,
577*cdf0e10cSrcweir 				const SfxItemSet& rAttrs )
578*cdf0e10cSrcweir {
579*cdf0e10cSrcweir 	return( new SdTpOptionsMisc( pWindow, rAttrs ) );
580*cdf0e10cSrcweir }
581*cdf0e10cSrcweir //------------------------------------------------------------------------
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir IMPL_LINK( SdTpOptionsMisc, SelectMetricHdl_Impl, ListBox *, EMPTYARG )
584*cdf0e10cSrcweir {
585*cdf0e10cSrcweir 	sal_uInt16 nPos = aLbMetric.GetSelectEntryPos();
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir 	if( nPos != LISTBOX_ENTRY_NOTFOUND )
588*cdf0e10cSrcweir 	{
589*cdf0e10cSrcweir 		FieldUnit eUnit = (FieldUnit)(long)aLbMetric.GetEntryData( nPos );
590*cdf0e10cSrcweir 		sal_Int64 nVal =
591*cdf0e10cSrcweir 			aMtrFldTabstop.Denormalize( aMtrFldTabstop.GetValue( FUNIT_TWIP ) );
592*cdf0e10cSrcweir 		SetFieldUnit( aMtrFldTabstop, eUnit );
593*cdf0e10cSrcweir 		aMtrFldTabstop.SetValue( aMtrFldTabstop.Normalize( nVal ), FUNIT_TWIP );
594*cdf0e10cSrcweir 	}
595*cdf0e10cSrcweir 	return 0;
596*cdf0e10cSrcweir }
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir namespace {
600*cdf0e10cSrcweir void lcl_MoveWin( Window& rWin, long nYDiff)
601*cdf0e10cSrcweir {
602*cdf0e10cSrcweir     Point aPos(rWin.GetPosPixel());
603*cdf0e10cSrcweir     aPos.Y() += nYDiff;
604*cdf0e10cSrcweir     rWin.SetPosPixel (aPos);
605*cdf0e10cSrcweir }
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir void lcl_MoveWin( Window& rWin, long nXdiff, long nYdiff)
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir     Point aPos(rWin.GetPosPixel());
610*cdf0e10cSrcweir     aPos.X() += nXdiff;
611*cdf0e10cSrcweir     aPos.Y() += nYdiff;
612*cdf0e10cSrcweir     rWin.SetPosPixel(aPos);
613*cdf0e10cSrcweir }
614*cdf0e10cSrcweir }
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir void SdTpOptionsMisc::SetImpressMode (void)
617*cdf0e10cSrcweir {
618*cdf0e10cSrcweir     long nDialogWidth = GetSizePixel().Width();
619*cdf0e10cSrcweir     long nLineHeight = aCbxPickThrough.GetPosPixel().Y()
620*cdf0e10cSrcweir         - aCbxQuickEdit.GetPosPixel().Y();
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir     // Put both "Text objects" check boxes side by side.
623*cdf0e10cSrcweir     lcl_MoveWin (aCbxPickThrough,
624*cdf0e10cSrcweir         nDialogWidth/2 - aCbxPickThrough.GetPosPixel().X(),
625*cdf0e10cSrcweir         -nLineHeight);
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir     // Move the other controls up one line.
628*cdf0e10cSrcweir     lcl_MoveWin (aGrpProgramStart, -nLineHeight);
629*cdf0e10cSrcweir     lcl_MoveWin (aCbxStartWithTemplate, -nLineHeight);
630*cdf0e10cSrcweir     lcl_MoveWin (aGrpSettings, -nLineHeight);
631*cdf0e10cSrcweir     lcl_MoveWin (aCbxMasterPageCache, -nLineHeight);
632*cdf0e10cSrcweir     lcl_MoveWin (aCbxCopy, -nLineHeight);
633*cdf0e10cSrcweir     lcl_MoveWin (aCbxMarkedHitMovesAlways, -nLineHeight);
634*cdf0e10cSrcweir     lcl_MoveWin (aCbxCrookNoContortion, -nLineHeight);
635*cdf0e10cSrcweir     lcl_MoveWin (aTxtMetric, -nLineHeight);
636*cdf0e10cSrcweir     lcl_MoveWin (aLbMetric, -nLineHeight);
637*cdf0e10cSrcweir     lcl_MoveWin (aTxtTabstop, -nLineHeight);
638*cdf0e10cSrcweir     lcl_MoveWin (aMtrFldTabstop, -nLineHeight);
639*cdf0e10cSrcweir     lcl_MoveWin (aGrpStartWithActualPage, -nLineHeight);
640*cdf0e10cSrcweir     lcl_MoveWin (aCbxStartWithActualPage, -nLineHeight);
641*cdf0e10cSrcweir     lcl_MoveWin (aTxtCompatibility, -nLineHeight);
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir     // Move the printer-independent-metrics check box up two lines to change
644*cdf0e10cSrcweir     // places with spacing-between-paragraphs check box.
645*cdf0e10cSrcweir     lcl_MoveWin (aCbxUsePrinterMetrics, -2*nLineHeight);
646*cdf0e10cSrcweir }
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir void    SdTpOptionsMisc::SetDrawMode()
649*cdf0e10cSrcweir {
650*cdf0e10cSrcweir     aCbxStartWithTemplate.Hide();
651*cdf0e10cSrcweir     aGrpProgramStart.Hide();
652*cdf0e10cSrcweir     aCbxStartWithActualPage.Hide();
653*cdf0e10cSrcweir 	aCbxCompatibility.Hide();
654*cdf0e10cSrcweir     aGrpStartWithActualPage.Hide();
655*cdf0e10cSrcweir     aCbxCrookNoContortion.Show();
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir     aGrpScale.Show();
658*cdf0e10cSrcweir     aFtScale.Show();
659*cdf0e10cSrcweir     aCbScale.Show();
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir     aFtOriginal.Show();
662*cdf0e10cSrcweir     aFtEquivalent.Show();
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir     aFtPageWidth.Show();
665*cdf0e10cSrcweir     aFiInfo1.Show();
666*cdf0e10cSrcweir     aMtrFldOriginalWidth.Show();
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir     aFtPageHeight.Show();
669*cdf0e10cSrcweir     aFiInfo2.Show();
670*cdf0e10cSrcweir     aMtrFldOriginalHeight.Show();
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir     long nDiff = aGrpSettings.GetPosPixel().Y() - aGrpProgramStart.GetPosPixel().Y();
673*cdf0e10cSrcweir     lcl_MoveWin( aGrpSettings, -nDiff );
674*cdf0e10cSrcweir     lcl_MoveWin( aCbxMasterPageCache, -nDiff );
675*cdf0e10cSrcweir     lcl_MoveWin( aCbxCopy, -nDiff );
676*cdf0e10cSrcweir     lcl_MoveWin( aCbxMarkedHitMovesAlways, -nDiff );
677*cdf0e10cSrcweir     lcl_MoveWin( aCbxCrookNoContortion, -nDiff );
678*cdf0e10cSrcweir     nDiff -= aCbxCrookNoContortion.GetPosPixel().Y() - aCbxMarkedHitMovesAlways.GetPosPixel().Y();
679*cdf0e10cSrcweir     lcl_MoveWin( aTxtMetric, -nDiff );
680*cdf0e10cSrcweir     lcl_MoveWin( aLbMetric, -nDiff );
681*cdf0e10cSrcweir     lcl_MoveWin( aTxtTabstop, -nDiff );
682*cdf0e10cSrcweir     lcl_MoveWin( aMtrFldTabstop, -nDiff );
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir     // Move the scale controls so that they are visually centered betwen the
685*cdf0e10cSrcweir     // group controls above and below.
686*cdf0e10cSrcweir     lcl_MoveWin (aFtScale, -17);
687*cdf0e10cSrcweir     lcl_MoveWin (aCbScale, -17);
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir     // Move the printer-independent-metrics check box in the place that the
690*cdf0e10cSrcweir     // spacing-between-paragraphs check box normally is in.
691*cdf0e10cSrcweir     aCbxUsePrinterMetrics.SetPosPixel (aCbxCompatibility.GetPosPixel());
692*cdf0e10cSrcweir }
693*cdf0e10cSrcweir // -----------------------------------------------------------------------
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir IMPL_LINK( SdTpOptionsMisc, ModifyScaleHdl, void *, EMPTYARG )
696*cdf0e10cSrcweir {
697*cdf0e10cSrcweir 	// Originalgroesse berechnen
698*cdf0e10cSrcweir 	sal_Int32 nX, nY;
699*cdf0e10cSrcweir 	if( SetScale( aCbScale.GetText(), nX, nY ) )
700*cdf0e10cSrcweir 	{
701*cdf0e10cSrcweir 		sal_Int32 nW = nWidth * nY / nX;
702*cdf0e10cSrcweir 		sal_Int32 nH = nHeight * nY / nX;
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir 		SetMetricValue( aMtrFldOriginalWidth, nW, ePoolUnit );
705*cdf0e10cSrcweir 		SetMetricValue( aMtrFldOriginalHeight, nH, ePoolUnit );
706*cdf0e10cSrcweir 	}
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir 	return( 0L );
709*cdf0e10cSrcweir }
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir // -----------------------------------------------------------------------
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir IMPL_LINK( SdTpOptionsMisc, ModifyOriginalScaleHdl, void *, EMPTYARG )
714*cdf0e10cSrcweir {
715*cdf0e10cSrcweir 	// Berechnen des Massstabs
716*cdf0e10cSrcweir 	long nOrgW = static_cast<long>(aMtrFldOriginalWidth.GetValue());
717*cdf0e10cSrcweir 	long nOrgH = static_cast<long>(aMtrFldOriginalHeight.GetValue());
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 	if( nOrgW == 0 || nOrgH == 0 )
720*cdf0e10cSrcweir 		return( 0L );
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir 	Fraction aFract1( nOrgW, static_cast<long>(aMtrFldInfo1.GetValue()) );
723*cdf0e10cSrcweir 	Fraction aFract2( nOrgH, static_cast<long>(aMtrFldInfo2.GetValue()) );
724*cdf0e10cSrcweir 	Fraction aFract( aFract1 > aFract2 ? aFract1 : aFract2 );
725*cdf0e10cSrcweir 
726*cdf0e10cSrcweir 	long nValue;
727*cdf0e10cSrcweir 	if( aFract < Fraction( 1, 1 ) )
728*cdf0e10cSrcweir 	{
729*cdf0e10cSrcweir 		// Fraction umdrehen
730*cdf0e10cSrcweir 		aFract1 = aFract;
731*cdf0e10cSrcweir 		aFract = Fraction( aFract1.GetDenominator(), aFract1.GetNumerator() );
732*cdf0e10cSrcweir 		nValue = aFract;
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir         // #92067# Swap nominator and denominator
735*cdf0e10cSrcweir 		aCbScale.SetText( GetScale( nValue, 1 ) );
736*cdf0e10cSrcweir 	}
737*cdf0e10cSrcweir 	else
738*cdf0e10cSrcweir 	{
739*cdf0e10cSrcweir 		double fValue = aFract;
740*cdf0e10cSrcweir 		nValue = aFract;
741*cdf0e10cSrcweir 		if( fValue > (double)nValue )
742*cdf0e10cSrcweir 			nValue++;
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir         // #92067# Swap nominator and denominator
745*cdf0e10cSrcweir 		aCbScale.SetText( GetScale( 1, nValue ) );
746*cdf0e10cSrcweir 	}
747*cdf0e10cSrcweir 	return( 0L );
748*cdf0e10cSrcweir }
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir // -----------------------------------------------------------------------
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir String SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY )
753*cdf0e10cSrcweir {
754*cdf0e10cSrcweir 	String aScale( UniString::CreateFromInt32( nX ) );
755*cdf0e10cSrcweir 	aScale.Append( TOKEN );
756*cdf0e10cSrcweir 	aScale.Append( UniString::CreateFromInt32( nY ) );
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir 	return( aScale );
759*cdf0e10cSrcweir }
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir // -----------------------------------------------------------------------
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir sal_Bool SdTpOptionsMisc::SetScale( const String& aScale, sal_Int32& rX, sal_Int32& rY )
764*cdf0e10cSrcweir {
765*cdf0e10cSrcweir 	if( aScale.GetTokenCount( TOKEN ) != 2 )
766*cdf0e10cSrcweir 		return( sal_False );
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 	ByteString aTmp( aScale.GetToken( 0, TOKEN ), RTL_TEXTENCODING_ASCII_US );
769*cdf0e10cSrcweir 	if( !aTmp.IsNumericAscii() )
770*cdf0e10cSrcweir 		return( sal_False );
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir 	rX = (long) aTmp.ToInt32();
773*cdf0e10cSrcweir 	if( rX == 0 )
774*cdf0e10cSrcweir 		return( sal_False );
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 	aTmp = ByteString( aScale.GetToken( 1, TOKEN ), RTL_TEXTENCODING_ASCII_US );
777*cdf0e10cSrcweir 	if( !aTmp.IsNumericAscii() )
778*cdf0e10cSrcweir 		return( sal_False );
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir 	rY = (long) aTmp.ToInt32();
781*cdf0e10cSrcweir 	if( rY == 0 )
782*cdf0e10cSrcweir 		return( sal_False );
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 	return( sal_True );
785*cdf0e10cSrcweir }
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir void SdTpOptionsMisc::UpdateCompatibilityControls (void)
791*cdf0e10cSrcweir {
792*cdf0e10cSrcweir     // Disable the compatibility controls by default.  Enable them only when
793*cdf0e10cSrcweir     // there is at least one open document.
794*cdf0e10cSrcweir     sal_Bool bIsEnabled = sal_False;
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir     try
797*cdf0e10cSrcweir     {
798*cdf0e10cSrcweir         // Get a component enumeration from the desktop and search it for documents.
799*cdf0e10cSrcweir         Reference<lang::XMultiServiceFactory> xFactory (
800*cdf0e10cSrcweir             ::comphelper::getProcessServiceFactory ());
801*cdf0e10cSrcweir         do
802*cdf0e10cSrcweir         {
803*cdf0e10cSrcweir             if ( ! xFactory.is())
804*cdf0e10cSrcweir                 break;
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir             Reference<frame::XDesktop> xDesktop (xFactory->createInstance (
807*cdf0e10cSrcweir                 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY);
808*cdf0e10cSrcweir             if ( ! xDesktop.is())
809*cdf0e10cSrcweir                 break;
810*cdf0e10cSrcweir 
811*cdf0e10cSrcweir             Reference<container::XEnumerationAccess> xComponents (
812*cdf0e10cSrcweir                 xDesktop->getComponents(), UNO_QUERY);
813*cdf0e10cSrcweir             if ( ! xComponents.is())
814*cdf0e10cSrcweir                 break;
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir             Reference<container::XEnumeration> xEnumeration (
817*cdf0e10cSrcweir                 xComponents->createEnumeration());
818*cdf0e10cSrcweir             if ( ! xEnumeration.is())
819*cdf0e10cSrcweir                 break;
820*cdf0e10cSrcweir 
821*cdf0e10cSrcweir             while (xEnumeration->hasMoreElements())
822*cdf0e10cSrcweir             {
823*cdf0e10cSrcweir                 Reference<frame::XModel> xModel (xEnumeration->nextElement(), UNO_QUERY);
824*cdf0e10cSrcweir                 if (xModel.is())
825*cdf0e10cSrcweir                 {
826*cdf0e10cSrcweir                     // There is at leas one model/document: Enable the compatibility controls.
827*cdf0e10cSrcweir                     bIsEnabled = sal_True;
828*cdf0e10cSrcweir                     break;
829*cdf0e10cSrcweir                 }
830*cdf0e10cSrcweir             }
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir         }
833*cdf0e10cSrcweir         while (false); // One 'loop'.
834*cdf0e10cSrcweir     }
835*cdf0e10cSrcweir     catch (uno::Exception e)
836*cdf0e10cSrcweir     {
837*cdf0e10cSrcweir         // When there is an exception then simply use the default value of
838*cdf0e10cSrcweir         // bIsEnabled and disable the controls.
839*cdf0e10cSrcweir     }
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir     aTxtCompatibility.Enable (bIsEnabled);
842*cdf0e10cSrcweir 	aCbxCompatibility.Enable(bIsEnabled);
843*cdf0e10cSrcweir     aCbxUsePrinterMetrics.Enable (bIsEnabled);
844*cdf0e10cSrcweir }
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir void SdTpOptionsMisc::PageCreated (SfxAllItemSet aSet)
847*cdf0e10cSrcweir {
848*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pFlagItem,SfxUInt32Item,SID_SDMODE_FLAG,sal_False);
849*cdf0e10cSrcweir 	if (pFlagItem)
850*cdf0e10cSrcweir 	{
851*cdf0e10cSrcweir 		sal_uInt32 nFlags=pFlagItem->GetValue();
852*cdf0e10cSrcweir 		if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE )
853*cdf0e10cSrcweir 			SetDrawMode();
854*cdf0e10cSrcweir 		if ( ( nFlags & SD_IMPRESS_MODE ) == SD_IMPRESS_MODE )
855*cdf0e10cSrcweir 			SetImpressMode();
856*cdf0e10cSrcweir 	}
857*cdf0e10cSrcweir }
858*cdf0e10cSrcweir 
859