xref: /aoo42x/main/cui/source/tabpages/page.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_cui.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // include ---------------------------------------------------------------
32*cdf0e10cSrcweir #include <sfx2/app.hxx>
33*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
34*cdf0e10cSrcweir #include <tools/resary.hxx>
35*cdf0e10cSrcweir #include <vcl/graph.hxx>
36*cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
37*cdf0e10cSrcweir #include <svl/itemiter.hxx>
38*cdf0e10cSrcweir #include <svl/languageoptions.hxx>
39*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
40*cdf0e10cSrcweir #include <unotools/configitem.hxx>
41*cdf0e10cSrcweir #include "svx/htmlmode.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #define _SVX_PAGE_CXX
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <cuires.hrc>
46*cdf0e10cSrcweir #include "page.hrc"
47*cdf0e10cSrcweir #include "helpid.hrc"
48*cdf0e10cSrcweir #include "page.hxx"
49*cdf0e10cSrcweir #include <svx/pageitem.hxx>
50*cdf0e10cSrcweir #include <editeng/brshitem.hxx>
51*cdf0e10cSrcweir #include <editeng/boxitem.hxx>
52*cdf0e10cSrcweir #include <editeng/shaditem.hxx>
53*cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
54*cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
55*cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
56*cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
57*cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
58*cdf0e10cSrcweir #include "svx/dlgutil.hxx"
59*cdf0e10cSrcweir #include <dialmgr.hxx>
60*cdf0e10cSrcweir #include <editeng/paperinf.hxx>
61*cdf0e10cSrcweir #include <dialmgr.hxx>
62*cdf0e10cSrcweir #include <sfx2/module.hxx>
63*cdf0e10cSrcweir #include <svl/stritem.hxx>
64*cdf0e10cSrcweir #include <svx/dialogs.hrc>  // for RID_SVXPAGE_PAGE
65*cdf0e10cSrcweir #include <editeng/eerdll.hxx>
66*cdf0e10cSrcweir #include <editeng/editrids.hrc> // for RID_SVXSTR_PAPERBIN...,
67*cdf0e10cSrcweir #include <svx/svxids.hrc>
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir // #i4219#
70*cdf0e10cSrcweir #include <svtools/optionsdrawinglayer.hxx>
71*cdf0e10cSrcweir #include <svl/slstitm.hxx> //CHINA001
72*cdf0e10cSrcweir #include <svl/aeitem.hxx> //CHINA001
73*cdf0e10cSrcweir #include <sfx2/request.hxx> //CHINA001
74*cdf0e10cSrcweir // configuration helper =======================================================
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir /** Helper to get a configuration setting.
77*cdf0e10cSrcweir     @descr  This is a HACK to get a configuration item directly. Normally the
78*cdf0e10cSrcweir     OfaHtmlOptions class from 'offmgr' project would do the job, but we cannot
79*cdf0e10cSrcweir     use it here. On the other hand, the OfaHtmlOptions cannot be moved to
80*cdf0e10cSrcweir     'svtools', because it uses 'svx' itself...
81*cdf0e10cSrcweir     The correct way would be to move OfaHtmlOptions to 'svtools' anyway, and to
82*cdf0e10cSrcweir     remove the dependency from 'svx' (a call to the static function
83*cdf0e10cSrcweir     SvxTextEncodingBox::GetBestMimeEncoding(), which contains low level
84*cdf0e10cSrcweir     operations that can be moved to lower projects, i.e. 'rtl'). Then this
85*cdf0e10cSrcweir     class can be removed, and the OfaHtmlOptions can be used instead. */
86*cdf0e10cSrcweir class SvxHtmlExportModeConfigItem_Impl : public utl::ConfigItem
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir public:
89*cdf0e10cSrcweir     explicit                    SvxHtmlExportModeConfigItem_Impl();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     /** Returns the HTML export mode, as read from the configuration. */
92*cdf0e10cSrcweir     inline sal_Int32            GetExportMode() const { return mnExpMode; }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     /** Returns true, if the current HTML export mode is set to HTML 3.2. */
95*cdf0e10cSrcweir     inline bool                 IsExportModeHTML32() const { return mnExpMode == 0; } // 0 == HTML_CFG_HTML32, see offmgr/htmlcfg.hxx
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     virtual void    Commit();
98*cdf0e10cSrcweir 	virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames);
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir private:
101*cdf0e10cSrcweir     sal_Int32                   mnExpMode;
102*cdf0e10cSrcweir };
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir SvxHtmlExportModeConfigItem_Impl::SvxHtmlExportModeConfigItem_Impl() :
105*cdf0e10cSrcweir     utl::ConfigItem( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Filter/HTML/Export" ) ) ),
106*cdf0e10cSrcweir     mnExpMode( 3 )  // default to 3 == HTML_CFG_NS40, see offmgr/htmlcfg.hxx
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir     using com::sun::star::uno::Sequence;
109*cdf0e10cSrcweir     using com::sun::star::uno::Any;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     Sequence< rtl::OUString > aPropNames( 1 );
112*cdf0e10cSrcweir     aPropNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Browser" ) );
113*cdf0e10cSrcweir     Sequence< Any > aPropValues( GetProperties( aPropNames ) );
114*cdf0e10cSrcweir     if( aPropValues.getLength() == 1 )
115*cdf0e10cSrcweir         aPropValues[ 0 ] >>= mnExpMode;
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir void SvxHtmlExportModeConfigItem_Impl::Commit()
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir void SvxHtmlExportModeConfigItem_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir // static ----------------------------------------------------------------
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir static const long MINBODY 		= 284;	// 0,5cm in twips aufgerundet
129*cdf0e10cSrcweir //static const long PRINT_OFFSET 	= 17;	// 0,03cm in twips abgerundet
130*cdf0e10cSrcweir static const long PRINT_OFFSET 	= 0;	// why was this ever set to 17 ? it led to wrong right and bottom margins.
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir static sal_uInt16 pRanges[] =
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	SID_ATTR_BORDER_OUTER,
135*cdf0e10cSrcweir 	SID_ATTR_BORDER_SHADOW,
136*cdf0e10cSrcweir 	SID_ATTR_LRSPACE,
137*cdf0e10cSrcweir 	SID_ATTR_PAGE_SHARED,
138*cdf0e10cSrcweir 	SID_SWREGISTER_COLLECTION,
139*cdf0e10cSrcweir 	SID_SWREGISTER_MODE,
140*cdf0e10cSrcweir 	0
141*cdf0e10cSrcweir };
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir // ------- Mapping Seitenlayout ------------------------------------------
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir sal_uInt16 aArr[] =
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	SVX_PAGE_ALL,
148*cdf0e10cSrcweir 	SVX_PAGE_MIRROR,
149*cdf0e10cSrcweir 	SVX_PAGE_RIGHT,
150*cdf0e10cSrcweir 	SVX_PAGE_LEFT
151*cdf0e10cSrcweir };
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir // -----------------------------------------------------------------------
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir sal_uInt16 PageUsageToPos_Impl( sal_uInt16 nUsage )
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir 	const sal_uInt16 nCount = sizeof(aArr) / sizeof(sal_uInt16);
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nCount; ++i )
160*cdf0e10cSrcweir 		if ( aArr[i] == ( nUsage & 0x000f ) )
161*cdf0e10cSrcweir 			return i;
162*cdf0e10cSrcweir 	return SVX_PAGE_ALL;
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir // -----------------------------------------------------------------------
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir sal_uInt16 PosToPageUsage_Impl( sal_uInt16 nPos )
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir 	const sal_uInt16 nCount = sizeof(aArr) / sizeof(sal_uInt16);
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	if ( nPos >= nCount )
172*cdf0e10cSrcweir 		return 0;
173*cdf0e10cSrcweir 	return aArr[nPos];
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir // -----------------------------------------------------------------------
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir Size GetMinBorderSpace_Impl( const SvxShadowItem& rShadow, const SvxBoxItem& rBox )
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir 	Size aSz;
181*cdf0e10cSrcweir 	aSz.Height() = rShadow.CalcShadowSpace( SHADOW_BOTTOM ) + rBox.CalcLineSpace( BOX_LINE_BOTTOM );
182*cdf0e10cSrcweir 	aSz.Height() += rShadow.CalcShadowSpace( SHADOW_TOP ) + rBox.CalcLineSpace( BOX_LINE_TOP );
183*cdf0e10cSrcweir 	aSz.Width() = rShadow.CalcShadowSpace( SHADOW_LEFT ) + rBox.CalcLineSpace( BOX_LINE_LEFT );
184*cdf0e10cSrcweir 	aSz.Width() += rShadow.CalcShadowSpace( SHADOW_RIGHT ) + rBox.CalcLineSpace( BOX_LINE_RIGHT );
185*cdf0e10cSrcweir 	return aSz;
186*cdf0e10cSrcweir }
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir // -----------------------------------------------------------------------
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir long ConvertLong_Impl( const long nIn, SfxMapUnit eUnit )
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir 	return OutputDevice::LogicToLogic( nIn, (MapUnit)eUnit, MAP_TWIP );
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir sal_Bool IsEqualSize_Impl( const SvxSizeItem* pSize, const Size& rSize )
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir 	if ( pSize )
198*cdf0e10cSrcweir 	{
199*cdf0e10cSrcweir 		Size aSize = pSize->GetSize();
200*cdf0e10cSrcweir 		long nDiffW = Abs( rSize.Width () - aSize.Width () );
201*cdf0e10cSrcweir 		long nDiffH = Abs( rSize.Height() - aSize.Height() );
202*cdf0e10cSrcweir 		return ( nDiffW < 10 && nDiffH < 10 );
203*cdf0e10cSrcweir 	}
204*cdf0e10cSrcweir 	else
205*cdf0e10cSrcweir 		return sal_False;
206*cdf0e10cSrcweir }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir // -----------------------------------------------------------------------
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir #define MARGIN_LEFT		( (MarginPosition)0x0001 )
211*cdf0e10cSrcweir #define MARGIN_RIGHT	( (MarginPosition)0x0002 )
212*cdf0e10cSrcweir #define MARGIN_TOP		( (MarginPosition)0x0004 )
213*cdf0e10cSrcweir #define MARGIN_BOTTOM	( (MarginPosition)0x0008 )
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir struct SvxPage_Impl
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir 	MarginPosition	m_nPos;
218*cdf0e10cSrcweir     Printer*        mpDefPrinter;
219*cdf0e10cSrcweir     bool            mbDelPrinter;
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir     SvxPage_Impl() :
222*cdf0e10cSrcweir         m_nPos( 0 ),
223*cdf0e10cSrcweir         mpDefPrinter( 0 ),
224*cdf0e10cSrcweir         mbDelPrinter( false ) {}
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     ~SvxPage_Impl() { if ( mbDelPrinter ) delete mpDefPrinter; }
227*cdf0e10cSrcweir };
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir // class SvxPageDescPage --------------------------------------------------
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir // gibt den Bereich der Which-Werte zur"uck
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir sal_uInt16* SvxPageDescPage::GetRanges()
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	return pRanges;
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir // -----------------------------------------------------------------------
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir SfxTabPage* SvxPageDescPage::Create( Window* pParent, const SfxItemSet& rSet )
241*cdf0e10cSrcweir {
242*cdf0e10cSrcweir 	return new SvxPageDescPage( pParent, rSet );
243*cdf0e10cSrcweir }
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir // -----------------------------------------------------------------------
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir SvxPageDescPage::SvxPageDescPage( Window* pParent, const SfxItemSet& rAttr ) :
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_PAGE ), rAttr ),
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir     aPaperSizeFl        ( this, CUI_RES( FL_PAPER_SIZE ) ),
252*cdf0e10cSrcweir     aPaperFormatText    ( this, CUI_RES( FT_PAPER_FORMAT ) ),
253*cdf0e10cSrcweir     aPaperSizeBox       ( this, CUI_RES( LB_PAPER_SIZE ) ),
254*cdf0e10cSrcweir     aPaperWidthText     ( this, CUI_RES( FT_PAPER_WIDTH ) ),
255*cdf0e10cSrcweir     aPaperWidthEdit     ( this, CUI_RES( ED_PAPER_WIDTH ) ),
256*cdf0e10cSrcweir     aPaperHeightText    ( this, CUI_RES( FT_PAPER_HEIGHT ) ),
257*cdf0e10cSrcweir     aPaperHeightEdit    ( this, CUI_RES( ED_PAPER_HEIGHT ) ),
258*cdf0e10cSrcweir     aOrientationFT      ( this, CUI_RES( FT_ORIENTATION ) ),
259*cdf0e10cSrcweir 	aPortraitBtn        ( this, CUI_RES( RB_PORTRAIT ) ),
260*cdf0e10cSrcweir     aLandscapeBtn       ( this, CUI_RES( RB_LANDSCAPE ) ),
261*cdf0e10cSrcweir 	aBspWin             ( this, CUI_RES( WN_BSP ) ),
262*cdf0e10cSrcweir     aTextFlowLbl        ( this, CUI_RES( FT_TEXT_FLOW ) ),
263*cdf0e10cSrcweir     aTextFlowBox        ( this, CUI_RES( LB_TEXT_FLOW ) ),
264*cdf0e10cSrcweir 	aPaperTrayLbl       ( this, CUI_RES( FT_PAPER_TRAY ) ),
265*cdf0e10cSrcweir     aPaperTrayBox       ( this, CUI_RES( LB_PAPER_TRAY ) ),
266*cdf0e10cSrcweir 	aMarginFl           ( this, CUI_RES( FL_MARGIN ) ),
267*cdf0e10cSrcweir     aLeftMarginLbl      ( this, CUI_RES( FT_LEFT_MARGIN ) ),
268*cdf0e10cSrcweir 	aLeftMarginEdit		( this, CUI_RES( ED_LEFT_MARGIN ) ),
269*cdf0e10cSrcweir 	aRightMarginLbl		( this, CUI_RES( FT_RIGHT_MARGIN ) ),
270*cdf0e10cSrcweir 	aRightMarginEdit	( this, CUI_RES( ED_RIGHT_MARGIN ) ),
271*cdf0e10cSrcweir 	aTopMarginLbl		( this, CUI_RES( FT_TOP_MARGIN ) ),
272*cdf0e10cSrcweir 	aTopMarginEdit		( this, CUI_RES( ED_TOP_MARGIN ) ),
273*cdf0e10cSrcweir 	aBottomMarginLbl	( this, CUI_RES( FT_BOTTOM_MARGIN ) ),
274*cdf0e10cSrcweir 	aBottomMarginEdit	( this, CUI_RES( ED_BOTTOM_MARGIN ) ),
275*cdf0e10cSrcweir     aBottomSeparatorFl  ( this, CUI_RES( FL_BOTTOM_SEP ) ),
276*cdf0e10cSrcweir     aLayoutFL           ( this, CUI_RES( FL_LAYOUT ) ),
277*cdf0e10cSrcweir 	aPageText			( this, CUI_RES( FT_PAGELAYOUT ) ),
278*cdf0e10cSrcweir     aLayoutBox          ( this, CUI_RES( LB_LAYOUT ) ),
279*cdf0e10cSrcweir 	aNumberFormatText	( this, CUI_RES( FT_NUMBER_FORMAT ) ),
280*cdf0e10cSrcweir 	aNumberFormatBox	( this, CUI_RES( LB_NUMBER_FORMAT ) ),
281*cdf0e10cSrcweir     aTblAlignFT         ( this, CUI_RES( FT_TBL_ALIGN ) ),
282*cdf0e10cSrcweir     aHorzBox            ( this, CUI_RES( CB_HORZ ) ),
283*cdf0e10cSrcweir 	aVertBox			( this, CUI_RES( CB_VERT ) ),
284*cdf0e10cSrcweir 	aAdaptBox			( this, CUI_RES( CB_ADAPT ) ),
285*cdf0e10cSrcweir 	aRegisterCB         ( this, CUI_RES( CB_REGISTER ) ),
286*cdf0e10cSrcweir 	aRegisterFT         ( this, CUI_RES( FT_REGISTER ) ),
287*cdf0e10cSrcweir 	aRegisterLB       	( this, CUI_RES( LB_REGISTER ) ),
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	aInsideText			( 		CUI_RES( STR_INSIDE ) ),
290*cdf0e10cSrcweir 	aOutsideText		( 		CUI_RES( STR_OUTSIDE ) ),
291*cdf0e10cSrcweir 	aPrintRangeQueryText(		CUI_RES( STR_QUERY_PRINTRANGE ) ),
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	bLandscape			( sal_False ),
294*cdf0e10cSrcweir 	eMode				( SVX_PAGE_MODE_STANDARD ),
295*cdf0e10cSrcweir 	ePaperStart			( PAPER_A3 ),
296*cdf0e10cSrcweir 	ePaperEnd 			( PAPER_ENV_DL ),
297*cdf0e10cSrcweir 	pImpl				( new SvxPage_Impl )
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir {
300*cdf0e10cSrcweir 	bBorderModified = sal_False;
301*cdf0e10cSrcweir 	FreeResource();
302*cdf0e10cSrcweir     aBspWin.EnableRTL( sal_False );
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir 	// diese Page braucht ExchangeSupport
305*cdf0e10cSrcweir 	SetExchangeSupport();
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir     SvtLanguageOptions aLangOptions;
308*cdf0e10cSrcweir     sal_Bool bCJK = aLangOptions.IsAsianTypographyEnabled();
309*cdf0e10cSrcweir     sal_Bool bCTL = aLangOptions.IsCTLFontEnabled();
310*cdf0e10cSrcweir     sal_Bool bWeb = sal_False;
311*cdf0e10cSrcweir     const SfxPoolItem* pItem;
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     SfxObjectShell* pShell;
314*cdf0e10cSrcweir     if(SFX_ITEM_SET == rAttr.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
315*cdf0e10cSrcweir 		( 0 != (pShell = SfxObjectShell::Current()) &&
316*cdf0e10cSrcweir 					0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
317*cdf0e10cSrcweir         bWeb = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON);
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir     // #109989# get the HTML export setting from configuration.
320*cdf0e10cSrcweir     // !! This is a hack, see comments in SvxHtmlExportModeConfigItem_Impl class above.
321*cdf0e10cSrcweir     bool bHTML32 = SvxHtmlExportModeConfigItem_Impl().IsExportModeHTML32();
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir     //  fill text flow listbox with valid entries
324*cdf0e10cSrcweir     aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_HORI ), FRMDIR_HORI_LEFT_TOP );
325*cdf0e10cSrcweir     if( bCTL )
326*cdf0e10cSrcweir         aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_HORI ), FRMDIR_HORI_RIGHT_TOP );
327*cdf0e10cSrcweir     // #109989# do not show vertical directions in Writer/Web
328*cdf0e10cSrcweir     if( !bWeb )
329*cdf0e10cSrcweir     {
330*cdf0e10cSrcweir         if( bCJK )
331*cdf0e10cSrcweir         {
332*cdf0e10cSrcweir             aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_RTL_VERT ), FRMDIR_VERT_TOP_RIGHT );
333*cdf0e10cSrcweir //            aTextFlowBox.InsertEntryValue( CUI_RESSTR( RID_SVXSTR_PAGEDIR_LTR_VERT ), FRMDIR_VERT_TOP_LEFT );
334*cdf0e10cSrcweir         }
335*cdf0e10cSrcweir     }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     // #109989# show the text direction box in Writer/Web too, but only, if HTML export mode is not HTML3.2.
338*cdf0e10cSrcweir     if( !(bWeb && bHTML32) && (bCJK || bCTL) &&
339*cdf0e10cSrcweir         SFX_ITEM_UNKNOWN < rAttr.GetItemState(GetWhich( SID_ATTR_FRAMEDIRECTION )))
340*cdf0e10cSrcweir     {
341*cdf0e10cSrcweir         aTextFlowLbl.Show();
342*cdf0e10cSrcweir         aTextFlowBox.Show();
343*cdf0e10cSrcweir         aTextFlowBox.SetSelectHdl(LINK(this, SvxPageDescPage, FrameDirectionModify_Impl ));
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir         aBspWin.EnableFrameDirection(sal_True);
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir     Init_Impl();
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 	FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
350*cdf0e10cSrcweir 	SetFieldUnit( aLeftMarginEdit, eFUnit );
351*cdf0e10cSrcweir 	SetFieldUnit( aRightMarginEdit, eFUnit );
352*cdf0e10cSrcweir 	SetFieldUnit( aTopMarginEdit, eFUnit );
353*cdf0e10cSrcweir 	SetFieldUnit( aBottomMarginEdit, eFUnit );
354*cdf0e10cSrcweir 	SetFieldUnit( aPaperWidthEdit, eFUnit );
355*cdf0e10cSrcweir 	SetFieldUnit( aPaperHeightEdit, eFUnit );
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir     if ( SfxViewShell::Current() && SfxViewShell::Current()->GetPrinter() )
358*cdf0e10cSrcweir         pImpl->mpDefPrinter = (Printer*)SfxViewShell::Current()->GetPrinter();
359*cdf0e10cSrcweir 	else
360*cdf0e10cSrcweir 	{
361*cdf0e10cSrcweir         pImpl->mpDefPrinter = new Printer;
362*cdf0e10cSrcweir         pImpl->mbDelPrinter = true;
363*cdf0e10cSrcweir 	}
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     MapMode aOldMode = pImpl->mpDefPrinter->GetMapMode();
366*cdf0e10cSrcweir     pImpl->mpDefPrinter->SetMapMode( MAP_TWIP );
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir 	// First- und Last-Werte f"ur die R"ander setzen
369*cdf0e10cSrcweir     Size aPaperSize = pImpl->mpDefPrinter->GetPaperSize();
370*cdf0e10cSrcweir     Size aPrintSize = pImpl->mpDefPrinter->GetOutputSize();
371*cdf0e10cSrcweir 	/*
372*cdf0e10cSrcweir 	 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren,
373*cdf0e10cSrcweir 	 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des
374*cdf0e10cSrcweir 	 * Koordinatensystems verschoben ist.
375*cdf0e10cSrcweir 	 */
376*cdf0e10cSrcweir     Point aPrintOffset = pImpl->mpDefPrinter->GetPageOffset() -
377*cdf0e10cSrcweir                          pImpl->mpDefPrinter->PixelToLogic( Point() );
378*cdf0e10cSrcweir     pImpl->mpDefPrinter->SetMapMode( aOldMode );
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir     long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
381*cdf0e10cSrcweir 	aLeftMarginEdit.SetFirst( aLeftMarginEdit.Normalize( aPrintOffset.X() ), FUNIT_TWIP );
382*cdf0e10cSrcweir 	nFirstLeftMargin = static_cast<long>(aLeftMarginEdit.GetFirst());
383*cdf0e10cSrcweir 	aRightMarginEdit.SetFirst( aRightMarginEdit.Normalize(
384*cdf0e10cSrcweir 		aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset ), FUNIT_TWIP);
385*cdf0e10cSrcweir 	nFirstRightMargin = static_cast<long>(aRightMarginEdit.GetFirst());
386*cdf0e10cSrcweir 	aTopMarginEdit.SetFirst( aTopMarginEdit.Normalize( aPrintOffset.Y() ), FUNIT_TWIP );
387*cdf0e10cSrcweir 	nFirstTopMargin = static_cast<long>(aTopMarginEdit.GetFirst());
388*cdf0e10cSrcweir 	aBottomMarginEdit.SetFirst( aBottomMarginEdit.Normalize(
389*cdf0e10cSrcweir 		aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset ), FUNIT_TWIP );
390*cdf0e10cSrcweir 	nFirstBottomMargin = static_cast<long>(aBottomMarginEdit.GetFirst());
391*cdf0e10cSrcweir 	aLeftMarginEdit.SetLast( aLeftMarginEdit.Normalize(
392*cdf0e10cSrcweir 		aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
393*cdf0e10cSrcweir 	nLastLeftMargin = static_cast<long>(aLeftMarginEdit.GetLast());
394*cdf0e10cSrcweir 	aRightMarginEdit.SetLast( aRightMarginEdit.Normalize(
395*cdf0e10cSrcweir 		aPrintOffset.X() + aPrintSize.Width() ), FUNIT_TWIP );
396*cdf0e10cSrcweir 	nLastRightMargin = static_cast<long>(aRightMarginEdit.GetLast());
397*cdf0e10cSrcweir 	aTopMarginEdit.SetLast( aTopMarginEdit.Normalize(
398*cdf0e10cSrcweir 		aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
399*cdf0e10cSrcweir 	nLastTopMargin = static_cast<long>(aTopMarginEdit.GetLast());
400*cdf0e10cSrcweir 	aBottomMarginEdit.SetLast( aBottomMarginEdit.Normalize(
401*cdf0e10cSrcweir 		aPrintOffset.Y() + aPrintSize.Height() ), FUNIT_TWIP );
402*cdf0e10cSrcweir 	nLastBottomMargin = static_cast<long>(aBottomMarginEdit.GetLast());
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 	// #i4219# get DrawingLayer options
405*cdf0e10cSrcweir     const SvtOptionsDrawinglayer aDrawinglayerOpt;
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 	// #i4219# take Maximum now from configuration (1/100th cm)
408*cdf0e10cSrcweir 	// was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000
409*cdf0e10cSrcweir 	aPaperWidthEdit.SetMax(aPaperWidthEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
410*cdf0e10cSrcweir 	aPaperWidthEdit.SetLast(aPaperWidthEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperWidth()), FUNIT_CM);
411*cdf0e10cSrcweir 	aPaperHeightEdit.SetMax(aPaperHeightEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
412*cdf0e10cSrcweir 	aPaperHeightEdit.SetLast(aPaperHeightEdit.Normalize(aDrawinglayerOpt.GetMaximumPaperHeight()), FUNIT_CM);
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 	// #i4219# also for margins (1/100th cm). Was: 9999, keeping.
415*cdf0e10cSrcweir 	aLeftMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
416*cdf0e10cSrcweir 	aLeftMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperLeftMargin());
417*cdf0e10cSrcweir 	aRightMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperRightMargin());
418*cdf0e10cSrcweir 	aRightMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperRightMargin());
419*cdf0e10cSrcweir 	aTopMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperTopMargin());
420*cdf0e10cSrcweir 	aTopMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperTopMargin());
421*cdf0e10cSrcweir 	aBottomMarginEdit.SetMax(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
422*cdf0e10cSrcweir 	aBottomMarginEdit.SetLast(aDrawinglayerOpt.GetMaximumPaperBottomMargin());
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 	aPortraitBtn.SetAccessibleRelationMemberOf(&aOrientationFT);
425*cdf0e10cSrcweir 	aLandscapeBtn.SetAccessibleRelationMemberOf(&aOrientationFT);
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir // -----------------------------------------------------------------------
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir SvxPageDescPage::~SvxPageDescPage()
431*cdf0e10cSrcweir {
432*cdf0e10cSrcweir 	delete pImpl;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir // -----------------------------------------------------------------------
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir void SvxPageDescPage::Init_Impl()
438*cdf0e10cSrcweir {
439*cdf0e10cSrcweir 	aLeftText = aLeftMarginLbl.GetText();
440*cdf0e10cSrcweir 	aRightText = aRightMarginLbl.GetText();
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 		// Handler einstellen
443*cdf0e10cSrcweir 	aLayoutBox.SetSelectHdl( LINK( this, SvxPageDescPage, LayoutHdl_Impl ) );
444*cdf0e10cSrcweir     aPaperSizeBox.SetDropDownLineCount(10);
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir 	aPaperTrayBox.SetGetFocusHdl(
447*cdf0e10cSrcweir 		LINK( this, SvxPageDescPage, PaperBinHdl_Impl ) );
448*cdf0e10cSrcweir 	aPaperSizeBox.SetSelectHdl(
449*cdf0e10cSrcweir 		LINK( this, SvxPageDescPage, PaperSizeSelect_Impl ) );
450*cdf0e10cSrcweir 	aPaperWidthEdit.SetModifyHdl(
451*cdf0e10cSrcweir 		LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
452*cdf0e10cSrcweir 	aPaperHeightEdit.SetModifyHdl(
453*cdf0e10cSrcweir 		LINK( this, SvxPageDescPage, PaperSizeModify_Impl ) );
454*cdf0e10cSrcweir 	aLandscapeBtn.SetClickHdl(
455*cdf0e10cSrcweir 		LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
456*cdf0e10cSrcweir 	aPortraitBtn.SetClickHdl(
457*cdf0e10cSrcweir 		LINK( this, SvxPageDescPage, SwapOrientation_Impl ) );
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 	Link aLink = LINK( this, SvxPageDescPage, BorderModify_Impl );
460*cdf0e10cSrcweir 	aLeftMarginEdit.SetModifyHdl( aLink );
461*cdf0e10cSrcweir 	aRightMarginEdit.SetModifyHdl( aLink );
462*cdf0e10cSrcweir 	aTopMarginEdit.SetModifyHdl( aLink );
463*cdf0e10cSrcweir 	aBottomMarginEdit.SetModifyHdl( aLink );
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 	aLink = LINK( this, SvxPageDescPage, RangeHdl_Impl );
466*cdf0e10cSrcweir 	aPaperWidthEdit.SetLoseFocusHdl( aLink );
467*cdf0e10cSrcweir 	aPaperHeightEdit.SetLoseFocusHdl( aLink );
468*cdf0e10cSrcweir 	aLeftMarginEdit.SetLoseFocusHdl( aLink );
469*cdf0e10cSrcweir 	aRightMarginEdit.SetLoseFocusHdl( aLink );
470*cdf0e10cSrcweir 	aTopMarginEdit.SetLoseFocusHdl( aLink );
471*cdf0e10cSrcweir 	aBottomMarginEdit.SetLoseFocusHdl( aLink );
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir 	aHorzBox.SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
474*cdf0e10cSrcweir 	aVertBox.SetClickHdl( LINK( this, SvxPageDescPage, CenterHdl_Impl ) );
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir // -----------------------------------------------------------------------
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir void SvxPageDescPage::Reset( const SfxItemSet& rSet )
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir 	SfxItemPool* pPool = rSet.GetPool();
483*cdf0e10cSrcweir 	DBG_ASSERT( pPool, "Wo ist der Pool" );
484*cdf0e10cSrcweir 	SfxMapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) );
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 	// R"ander (Links/Rechts) einstellen
487*cdf0e10cSrcweir 	const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_LRSPACE );
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir 	if ( pItem )
490*cdf0e10cSrcweir 	{
491*cdf0e10cSrcweir 		const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)*pItem;
492*cdf0e10cSrcweir 		SetMetricValue( aLeftMarginEdit, rLRSpace.GetLeft(), eUnit );
493*cdf0e10cSrcweir 		aBspWin.SetLeft(
494*cdf0e10cSrcweir 			(sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetLeft(), eUnit ) );
495*cdf0e10cSrcweir 		SetMetricValue( aRightMarginEdit, rLRSpace.GetRight(), eUnit );
496*cdf0e10cSrcweir 		aBspWin.SetRight(
497*cdf0e10cSrcweir 			(sal_uInt16)ConvertLong_Impl( (long)rLRSpace.GetRight(), eUnit ) );
498*cdf0e10cSrcweir 	}
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	// R"ander (Oben/Unten) einstellen
501*cdf0e10cSrcweir 	pItem = GetItem( rSet, SID_ATTR_ULSPACE );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 	if ( pItem )
504*cdf0e10cSrcweir 	{
505*cdf0e10cSrcweir 		const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)*pItem;
506*cdf0e10cSrcweir 		SetMetricValue( aTopMarginEdit, rULSpace.GetUpper(), eUnit );
507*cdf0e10cSrcweir 		aBspWin.SetTop(
508*cdf0e10cSrcweir 			(sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetUpper(), eUnit ) );
509*cdf0e10cSrcweir 		SetMetricValue( aBottomMarginEdit, rULSpace.GetLower(), eUnit );
510*cdf0e10cSrcweir 		aBspWin.SetBottom(
511*cdf0e10cSrcweir 			(sal_uInt16)ConvertLong_Impl( (long)rULSpace.GetLower(), eUnit ) );
512*cdf0e10cSrcweir 	}
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir     // allgemeine Seitendaten
515*cdf0e10cSrcweir 	SvxNumType eNumType = SVX_ARABIC;
516*cdf0e10cSrcweir     bLandscape = ( pImpl->mpDefPrinter->GetOrientation() == ORIENTATION_LANDSCAPE );
517*cdf0e10cSrcweir 	sal_uInt16 nUse = (sal_uInt16)SVX_PAGE_ALL;
518*cdf0e10cSrcweir 	pItem = GetItem( rSet, SID_ATTR_PAGE );
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir 	if ( pItem )
521*cdf0e10cSrcweir 	{
522*cdf0e10cSrcweir 		const SvxPageItem& rItem = (const SvxPageItem&)*pItem;
523*cdf0e10cSrcweir 		eNumType = rItem.GetNumType();
524*cdf0e10cSrcweir 		nUse = rItem.GetPageUsage();
525*cdf0e10cSrcweir 		bLandscape = rItem.IsLandscape();
526*cdf0e10cSrcweir 	}
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 	// Ausrichtung
529*cdf0e10cSrcweir 	aLayoutBox.SelectEntryPos( ::PageUsageToPos_Impl( nUse ) );
530*cdf0e10cSrcweir 	aBspWin.SetUsage( nUse );
531*cdf0e10cSrcweir 	LayoutHdl_Impl( 0 );
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir 	// Numerierungsart der Seitenvorlage einstellen
534*cdf0e10cSrcweir 	aNumberFormatBox.SelectEntryPos( sal::static_int_cast< sal_uInt16 >(eNumType) );
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 	// Aktueller Papierschacht
537*cdf0e10cSrcweir 	aPaperTrayBox.Clear();
538*cdf0e10cSrcweir 	sal_uInt8 nPaperBin = PAPERBIN_PRINTER_SETTINGS;
539*cdf0e10cSrcweir 	pItem = GetItem( rSet, SID_ATTR_PAGE_PAPERBIN );
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 	if ( pItem )
542*cdf0e10cSrcweir 	{
543*cdf0e10cSrcweir 		nPaperBin = ( (const SvxPaperBinItem*)pItem )->GetValue();
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir         if ( nPaperBin >= pImpl->mpDefPrinter->GetPaperBinCount() )
546*cdf0e10cSrcweir 			nPaperBin = PAPERBIN_PRINTER_SETTINGS;
547*cdf0e10cSrcweir 	}
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir 	String aBinName;
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 	if ( PAPERBIN_PRINTER_SETTINGS	== nPaperBin )
552*cdf0e10cSrcweir 		aBinName = EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS );
553*cdf0e10cSrcweir 	else
554*cdf0e10cSrcweir         aBinName = pImpl->mpDefPrinter->GetPaperBinName( (sal_uInt16)nPaperBin );
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 	sal_uInt16 nEntryPos = aPaperTrayBox.InsertEntry( aBinName );
557*cdf0e10cSrcweir 	aPaperTrayBox.SetEntryData( nEntryPos, (void*)(sal_uLong)nPaperBin );
558*cdf0e10cSrcweir 	aPaperTrayBox.SelectEntry( aBinName );
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 	// Size rausholen
561*cdf0e10cSrcweir     Size aPaperSize = SvxPaperInfo::GetPaperSize( pImpl->mpDefPrinter );
562*cdf0e10cSrcweir 	pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir 	if ( pItem )
565*cdf0e10cSrcweir 		aPaperSize = ( (const SvxSizeItem*)pItem )->GetSize();
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 	FASTBOOL bOrientationSupport =
568*cdf0e10cSrcweir         pImpl->mpDefPrinter->HasSupport( SUPPORT_SET_ORIENTATION );
569*cdf0e10cSrcweir #ifdef OS2
570*cdf0e10cSrcweir 	// unter OS/2 wird bei HasSupport() immer sal_True returned
571*cdf0e10cSrcweir 	// aber nur als Dummy, deshalb FALSE
572*cdf0e10cSrcweir 	bOrientationSupport = sal_False;
573*cdf0e10cSrcweir #endif
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir 	if ( !bOrientationSupport &&
576*cdf0e10cSrcweir 		 aPaperSize.Width() > aPaperSize.Height() )
577*cdf0e10cSrcweir 		bLandscape = sal_True;
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir 	aLandscapeBtn.Check( bLandscape );
580*cdf0e10cSrcweir 	aPortraitBtn.Check( !bLandscape );
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 	aBspWin.SetSize( Size( ConvertLong_Impl( aPaperSize.Width(), eUnit ),
583*cdf0e10cSrcweir 						   ConvertLong_Impl( aPaperSize.Height(), eUnit ) ) );
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 	aPaperSize = OutputDevice::LogicToLogic(aPaperSize, (MapUnit)eUnit, MAP_100TH_MM);
586*cdf0e10cSrcweir 	if ( bLandscape )
587*cdf0e10cSrcweir 		Swap( aPaperSize );
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 	// Actual Paper Format
590*cdf0e10cSrcweir 	Paper ePaper = SvxPaperInfo::GetSvxPaper( aPaperSize, MAP_100TH_MM, sal_True );
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir 	if ( PAPER_USER != ePaper )
593*cdf0e10cSrcweir 		aPaperSize = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir 	if ( bLandscape )
596*cdf0e10cSrcweir 		Swap( aPaperSize );
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 	// Werte in die Edits eintragen
599*cdf0e10cSrcweir 	SetMetricValue( aPaperHeightEdit, aPaperSize.Height(), SFX_MAPUNIT_100TH_MM );
600*cdf0e10cSrcweir 	SetMetricValue( aPaperWidthEdit, aPaperSize.Width(), SFX_MAPUNIT_100TH_MM );
601*cdf0e10cSrcweir 	aPaperSizeBox.Clear();
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	sal_uInt16 nActPos = LISTBOX_ENTRY_NOTFOUND;
604*cdf0e10cSrcweir 	sal_uInt16 nAryId = RID_SVXSTRARY_PAPERSIZE_STD;
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir 	if ( ePaperStart != PAPER_A3 )
607*cdf0e10cSrcweir 		nAryId = RID_SVXSTRARY_PAPERSIZE_DRAW;
608*cdf0e10cSrcweir 	ResStringArray aPaperAry( CUI_RES( nAryId ) );
609*cdf0e10cSrcweir 	sal_uInt32 nCnt = aPaperAry.Count();
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir     sal_uInt16 nUserPos = LISTBOX_ENTRY_NOTFOUND;
612*cdf0e10cSrcweir 	for ( sal_uInt32 i = 0; i < nCnt; ++i )
613*cdf0e10cSrcweir 	{
614*cdf0e10cSrcweir 		String aStr = aPaperAry.GetString(i);
615*cdf0e10cSrcweir 		Paper eSize = (Paper)aPaperAry.GetValue(i);
616*cdf0e10cSrcweir 		sal_uInt16 nPos = aPaperSizeBox.InsertEntry( aStr );
617*cdf0e10cSrcweir 		aPaperSizeBox.SetEntryData( nPos, (void*)(sal_uLong)eSize );
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 		if ( eSize == ePaper )
620*cdf0e10cSrcweir 			nActPos = nPos;
621*cdf0e10cSrcweir         if( eSize == PAPER_USER )
622*cdf0e10cSrcweir             nUserPos = nPos;
623*cdf0e10cSrcweir 	}
624*cdf0e10cSrcweir 	// preselect current paper format - #115915#: ePaper might not be in aPaperSizeBox so use PAPER_USER instead
625*cdf0e10cSrcweir     aPaperSizeBox.SelectEntryPos( nActPos != LISTBOX_ENTRY_NOTFOUND ? nActPos : nUserPos );
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir     // Applikationsspezifisch
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir 	switch ( eMode )
630*cdf0e10cSrcweir 	{
631*cdf0e10cSrcweir 		case SVX_PAGE_MODE_CENTER:
632*cdf0e10cSrcweir 		{
633*cdf0e10cSrcweir             aTblAlignFT.Show();
634*cdf0e10cSrcweir             aHorzBox.Show();
635*cdf0e10cSrcweir 			aVertBox.Show();
636*cdf0e10cSrcweir             DisableVerticalPageDir();
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 			// Horizontale Ausrichtung
639*cdf0e10cSrcweir 			pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
640*cdf0e10cSrcweir 			aHorzBox.Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue()
641*cdf0e10cSrcweir 								  : sal_False );
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir 			// Vertikale Ausrichtung
644*cdf0e10cSrcweir 			pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
645*cdf0e10cSrcweir 			aVertBox.Check( pItem ? ( (const SfxBoolItem*)pItem )->GetValue()
646*cdf0e10cSrcweir 								  : sal_False );
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 			// Beispiel-Fenster auf Tabelle setzen
649*cdf0e10cSrcweir 			aBspWin.SetTable( sal_True );
650*cdf0e10cSrcweir 			aBspWin.SetHorz( aHorzBox.IsChecked() );
651*cdf0e10cSrcweir 			aBspWin.SetVert( aVertBox.IsChecked() );
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 			break;
654*cdf0e10cSrcweir 		}
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir 		case SVX_PAGE_MODE_PRESENTATION:
657*cdf0e10cSrcweir 		{
658*cdf0e10cSrcweir             DisableVerticalPageDir();
659*cdf0e10cSrcweir 			aAdaptBox.Show();
660*cdf0e10cSrcweir 			pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
661*cdf0e10cSrcweir 			aAdaptBox.Check( pItem ?
662*cdf0e10cSrcweir 				( (const SfxBoolItem*)pItem )->GetValue() : sal_False );
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir 			//!!! hidden, weil von StarDraw nicht implementiert
665*cdf0e10cSrcweir 			aLayoutBox.Hide();
666*cdf0e10cSrcweir 			aPageText.Hide();
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir 			break;
669*cdf0e10cSrcweir 		}
670*cdf0e10cSrcweir         default: ;//prevent warning
671*cdf0e10cSrcweir 	}
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 	// im Beispiel Hintergrund und Umrandung anzeigen
675*cdf0e10cSrcweir 	ResetBackground_Impl( rSet );
676*cdf0e10cSrcweir //!	UpdateExample_Impl();
677*cdf0e10cSrcweir 	RangeHdl_Impl( 0 );
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir 	// Header Footer anzeigen
680*cdf0e10cSrcweir 	InitHeadFoot_Impl( rSet );
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir 	// R"ander auf Hoch/Quer updaten, dann Beispiel updaten
683*cdf0e10cSrcweir 	bBorderModified = sal_False;
684*cdf0e10cSrcweir 	SwapFirstValues_Impl( sal_False );
685*cdf0e10cSrcweir 	UpdateExample_Impl();
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir 	// Alte Werte sichern
688*cdf0e10cSrcweir 	aLeftMarginEdit.SaveValue();
689*cdf0e10cSrcweir 	aRightMarginEdit.SaveValue();
690*cdf0e10cSrcweir 	aTopMarginEdit.SaveValue();
691*cdf0e10cSrcweir 	aBottomMarginEdit.SaveValue();
692*cdf0e10cSrcweir 	aLayoutBox.SaveValue();
693*cdf0e10cSrcweir 	aNumberFormatBox.SaveValue();
694*cdf0e10cSrcweir 	aPaperSizeBox.SaveValue();
695*cdf0e10cSrcweir 	aPaperWidthEdit.SaveValue();
696*cdf0e10cSrcweir 	aPaperHeightEdit.SaveValue();
697*cdf0e10cSrcweir 	aPortraitBtn.SaveValue();
698*cdf0e10cSrcweir 	aLandscapeBtn.SaveValue();
699*cdf0e10cSrcweir 	aPaperTrayBox.SaveValue();
700*cdf0e10cSrcweir 	aVertBox.SaveValue();
701*cdf0e10cSrcweir 	aHorzBox.SaveValue();
702*cdf0e10cSrcweir     aAdaptBox.SaveValue();
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir 	CheckMarginEdits( true );
705*cdf0e10cSrcweir 
706*cdf0e10cSrcweir 	// Registerhaltigkeit
707*cdf0e10cSrcweir 	if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_MODE))
708*cdf0e10cSrcweir 	{
709*cdf0e10cSrcweir 		aRegisterCB.Check(((const SfxBoolItem&)rSet.Get(
710*cdf0e10cSrcweir 								SID_SWREGISTER_MODE)).GetValue());
711*cdf0e10cSrcweir 		aRegisterCB.SaveValue();
712*cdf0e10cSrcweir 		RegisterModify(&aRegisterCB);
713*cdf0e10cSrcweir 	}
714*cdf0e10cSrcweir 	if(SFX_ITEM_SET == rSet.GetItemState(SID_SWREGISTER_COLLECTION))
715*cdf0e10cSrcweir 	{
716*cdf0e10cSrcweir 		aRegisterLB.SelectEntry(
717*cdf0e10cSrcweir 				((const SfxStringItem&)rSet.Get(SID_SWREGISTER_COLLECTION)).GetValue());
718*cdf0e10cSrcweir 		aRegisterLB.SaveValue();
719*cdf0e10cSrcweir 	}
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir 	SfxItemState eState = rSet.GetItemState( GetWhich( SID_ATTR_FRAMEDIRECTION ),
722*cdf0e10cSrcweir 												sal_True, &pItem );
723*cdf0e10cSrcweir 	if( SFX_ITEM_UNKNOWN != eState )
724*cdf0e10cSrcweir 	{
725*cdf0e10cSrcweir         sal_uInt32 nVal  = SFX_ITEM_SET == eState
726*cdf0e10cSrcweir 								? ((SvxFrameDirectionItem*)pItem)->GetValue()
727*cdf0e10cSrcweir                                 : 0;
728*cdf0e10cSrcweir         aTextFlowBox.SelectEntryValue( static_cast< SvxFrameDirection >( nVal ) );
729*cdf0e10cSrcweir 		aTextFlowBox.SaveValue();
730*cdf0e10cSrcweir         aBspWin.SetFrameDirection(nVal);
731*cdf0e10cSrcweir 	}
732*cdf0e10cSrcweir }
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir // -----------------------------------------------------------------------
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir void SvxPageDescPage::FillUserData()
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir 	if ( SVX_PAGE_MODE_PRESENTATION == eMode )
739*cdf0e10cSrcweir 		SetUserData( UniString::CreateFromInt32( (sal_Int32)aAdaptBox.IsChecked() ) );
740*cdf0e10cSrcweir }
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir // -----------------------------------------------------------------------
743*cdf0e10cSrcweir 
744*cdf0e10cSrcweir sal_Bool SvxPageDescPage::FillItemSet( SfxItemSet& rSet )
745*cdf0e10cSrcweir {
746*cdf0e10cSrcweir 	sal_Bool bModified = sal_False;
747*cdf0e10cSrcweir 	const SfxItemSet& rOldSet = GetItemSet();
748*cdf0e10cSrcweir 	SfxItemPool* pPool = rOldSet.GetPool();
749*cdf0e10cSrcweir 	DBG_ASSERT( pPool, "Wo ist der Pool" );
750*cdf0e10cSrcweir 	sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
751*cdf0e10cSrcweir 	SfxMapUnit eUnit = pPool->GetMetric( nWhich );
752*cdf0e10cSrcweir 	const SfxPoolItem* pOld = 0;
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir 	// alten linken und rechten Rand kopieren
755*cdf0e10cSrcweir 	SvxLRSpaceItem aMargin( (const SvxLRSpaceItem&)rOldSet.Get( nWhich ) );
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 	// alten  oberen und unteren Rand kopieren
758*cdf0e10cSrcweir 	nWhich = GetWhich( SID_ATTR_ULSPACE );
759*cdf0e10cSrcweir 	SvxULSpaceItem aTopMargin( (const SvxULSpaceItem&)rOldSet.Get( nWhich ) );
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 	if ( aLeftMarginEdit.GetText() != aLeftMarginEdit.GetSavedValue() )
762*cdf0e10cSrcweir 	{
763*cdf0e10cSrcweir 		aMargin.SetLeft( (sal_uInt16)GetCoreValue( aLeftMarginEdit, eUnit ) );
764*cdf0e10cSrcweir 		bModified |= sal_True;
765*cdf0e10cSrcweir 	}
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir 	if ( aRightMarginEdit.GetText() != aRightMarginEdit.GetSavedValue() )
768*cdf0e10cSrcweir 	{
769*cdf0e10cSrcweir 		aMargin.SetRight( (sal_uInt16)GetCoreValue( aRightMarginEdit, eUnit ) );
770*cdf0e10cSrcweir 		bModified |= sal_True;
771*cdf0e10cSrcweir 	}
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir 	// Linken und rechten Rand setzen
774*cdf0e10cSrcweir 	if ( bModified )
775*cdf0e10cSrcweir 	{
776*cdf0e10cSrcweir 		pOld = GetOldItem( rSet, SID_ATTR_LRSPACE );
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir 		if ( !pOld || !( *(const SvxLRSpaceItem*)pOld == aMargin ) )
779*cdf0e10cSrcweir 			rSet.Put( aMargin );
780*cdf0e10cSrcweir 		else
781*cdf0e10cSrcweir 			bModified = sal_False;
782*cdf0e10cSrcweir 	}
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 	sal_Bool bMod = sal_False;
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir 	if ( aTopMarginEdit.GetText() != aTopMarginEdit.GetSavedValue() )
787*cdf0e10cSrcweir 	{
788*cdf0e10cSrcweir 		aTopMargin.SetUpper( (sal_uInt16)GetCoreValue( aTopMarginEdit, eUnit ) );
789*cdf0e10cSrcweir 		bMod |= sal_True;
790*cdf0e10cSrcweir 	}
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir 	if ( aBottomMarginEdit.GetText() != aBottomMarginEdit.GetSavedValue() )
793*cdf0e10cSrcweir 	{
794*cdf0e10cSrcweir 		aTopMargin.SetLower( (sal_uInt16)GetCoreValue( aBottomMarginEdit, eUnit ) );
795*cdf0e10cSrcweir 		bMod |= sal_True;
796*cdf0e10cSrcweir 	}
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir 	// unteren oberen Rand setzen
799*cdf0e10cSrcweir 	//
800*cdf0e10cSrcweir 	if ( bMod )
801*cdf0e10cSrcweir 	{
802*cdf0e10cSrcweir 		pOld = GetOldItem( rSet, SID_ATTR_ULSPACE );
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir 		if ( !pOld || !( *(const SvxULSpaceItem*)pOld == aTopMargin ) )
805*cdf0e10cSrcweir 		{
806*cdf0e10cSrcweir 			bModified |= sal_True;
807*cdf0e10cSrcweir 			rSet.Put( aTopMargin );
808*cdf0e10cSrcweir 		}
809*cdf0e10cSrcweir 	}
810*cdf0e10cSrcweir 
811*cdf0e10cSrcweir 	// Druckerschacht
812*cdf0e10cSrcweir 	nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN );
813*cdf0e10cSrcweir 	sal_uInt16 nPos = aPaperTrayBox.GetSelectEntryPos();
814*cdf0e10cSrcweir 	sal_uInt16 nBin = (sal_uInt16)(sal_uLong)aPaperTrayBox.GetEntryData( nPos );
815*cdf0e10cSrcweir 	pOld = GetOldItem( rSet, SID_ATTR_PAGE_PAPERBIN );
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir 	if ( !pOld || ( (const SvxPaperBinItem*)pOld )->GetValue() != nBin )
818*cdf0e10cSrcweir 	{
819*cdf0e10cSrcweir 		rSet.Put( SvxPaperBinItem( nWhich, (sal_uInt8)nBin ) );
820*cdf0e10cSrcweir 		bModified |= sal_True;
821*cdf0e10cSrcweir 	}
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir 	nPos = aPaperSizeBox.GetSelectEntryPos();
824*cdf0e10cSrcweir 	Paper ePaper = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData( nPos );
825*cdf0e10cSrcweir 	const sal_uInt16 nOld = aPaperSizeBox.GetSavedValue();
826*cdf0e10cSrcweir 	sal_Bool bChecked = aLandscapeBtn.IsChecked();
827*cdf0e10cSrcweir 
828*cdf0e10cSrcweir 	if ( PAPER_USER == ePaper )
829*cdf0e10cSrcweir 	{
830*cdf0e10cSrcweir 		if ( nOld != nPos						||
831*cdf0e10cSrcweir 			 aPaperWidthEdit.IsValueModified()  ||
832*cdf0e10cSrcweir 			 aPaperHeightEdit.IsValueModified() ||
833*cdf0e10cSrcweir 			 bChecked != aLandscapeBtn.GetSavedValue() )
834*cdf0e10cSrcweir 		{
835*cdf0e10cSrcweir 			Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ),
836*cdf0e10cSrcweir 						GetCoreValue( aPaperHeightEdit, eUnit ) );
837*cdf0e10cSrcweir 			pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE );
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir 			if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize )
840*cdf0e10cSrcweir 			{
841*cdf0e10cSrcweir 				rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
842*cdf0e10cSrcweir 				bModified |= sal_True;
843*cdf0e10cSrcweir 			}
844*cdf0e10cSrcweir 		}
845*cdf0e10cSrcweir 	}
846*cdf0e10cSrcweir 	else
847*cdf0e10cSrcweir 	{
848*cdf0e10cSrcweir 		if ( nOld != nPos || bChecked != aLandscapeBtn.GetSavedValue() )
849*cdf0e10cSrcweir 		{
850*cdf0e10cSrcweir 			Size aSize( SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)eUnit ) );
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir 			if ( bChecked )
853*cdf0e10cSrcweir 				Swap( aSize );
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir 			pOld = GetOldItem( rSet, SID_ATTR_PAGE_SIZE );
856*cdf0e10cSrcweir 
857*cdf0e10cSrcweir 			if ( !pOld || ( (const SvxSizeItem*)pOld )->GetSize() != aSize )
858*cdf0e10cSrcweir 			{
859*cdf0e10cSrcweir 				rSet.Put( SvxSizeItem( GetWhich(SID_ATTR_PAGE_SIZE), aSize ) );
860*cdf0e10cSrcweir 				bModified |= sal_True;
861*cdf0e10cSrcweir 			}
862*cdf0e10cSrcweir 		}
863*cdf0e10cSrcweir 	}
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 	// sonstiges Zeug der Page
866*cdf0e10cSrcweir 	nWhich = GetWhich( SID_ATTR_PAGE );
867*cdf0e10cSrcweir 	SvxPageItem aPage( (const SvxPageItem&)rOldSet.Get( nWhich ) );
868*cdf0e10cSrcweir 	bMod = 	aLayoutBox.GetSelectEntryPos()  != aLayoutBox.GetSavedValue();
869*cdf0e10cSrcweir 
870*cdf0e10cSrcweir 	if ( bMod )
871*cdf0e10cSrcweir 		aPage.SetPageUsage(
872*cdf0e10cSrcweir 			::PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ) );
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir 	if ( bChecked != aLandscapeBtn.GetSavedValue() )
875*cdf0e10cSrcweir 	{
876*cdf0e10cSrcweir 		aPage.SetLandscape(bChecked);
877*cdf0e10cSrcweir 		bMod |= sal_True;
878*cdf0e10cSrcweir 	}
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir 	// Einstellen der Numerierungsart der Seite
881*cdf0e10cSrcweir 	nPos = aNumberFormatBox.GetSelectEntryPos();
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir 	if ( nPos != aNumberFormatBox.GetSavedValue() )
884*cdf0e10cSrcweir 	{
885*cdf0e10cSrcweir 		aPage.SetNumType( (SvxNumType)nPos );
886*cdf0e10cSrcweir 		bMod |= sal_True;
887*cdf0e10cSrcweir 	}
888*cdf0e10cSrcweir 
889*cdf0e10cSrcweir 	if ( bMod )
890*cdf0e10cSrcweir 	{
891*cdf0e10cSrcweir 		pOld = GetOldItem( rSet, SID_ATTR_PAGE );
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir 		if ( !pOld || !( *(const SvxPageItem*)pOld == aPage ) )
894*cdf0e10cSrcweir 		{
895*cdf0e10cSrcweir 			rSet.Put( aPage );
896*cdf0e10cSrcweir 			bModified |= sal_True;
897*cdf0e10cSrcweir 		}
898*cdf0e10cSrcweir 	}
899*cdf0e10cSrcweir 	else if ( SFX_ITEM_DEFAULT == rOldSet.GetItemState( nWhich ) )
900*cdf0e10cSrcweir 		rSet.ClearItem( nWhich );
901*cdf0e10cSrcweir 	else
902*cdf0e10cSrcweir 		rSet.Put( rOldSet.Get( nWhich ) );
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir 	// Modispezifische Controls auswerten
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir 	switch ( eMode )
907*cdf0e10cSrcweir 	{
908*cdf0e10cSrcweir 		case SVX_PAGE_MODE_CENTER:
909*cdf0e10cSrcweir 		{
910*cdf0e10cSrcweir 			if ( aHorzBox.IsChecked() != aHorzBox.GetSavedValue() )
911*cdf0e10cSrcweir 			{
912*cdf0e10cSrcweir 				SfxBoolItem aHorz( GetWhich( SID_ATTR_PAGE_EXT1 ),
913*cdf0e10cSrcweir 								   aHorzBox.IsChecked() );
914*cdf0e10cSrcweir 				rSet.Put( aHorz );
915*cdf0e10cSrcweir 				bModified |= sal_True;
916*cdf0e10cSrcweir 			}
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir 			if ( aVertBox.IsChecked() != aVertBox.GetSavedValue() )
919*cdf0e10cSrcweir 			{
920*cdf0e10cSrcweir 				SfxBoolItem aVert( GetWhich( SID_ATTR_PAGE_EXT2 ),
921*cdf0e10cSrcweir 								   aVertBox.IsChecked() );
922*cdf0e10cSrcweir 				rSet.Put( aVert );
923*cdf0e10cSrcweir 				bModified |= sal_True;
924*cdf0e10cSrcweir 			}
925*cdf0e10cSrcweir 			break;
926*cdf0e10cSrcweir 		}
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir 		case SVX_PAGE_MODE_PRESENTATION:
929*cdf0e10cSrcweir 		{
930*cdf0e10cSrcweir 			// immer putten, damit Draw das auswerten kann
931*cdf0e10cSrcweir 			rSet.Put( SfxBoolItem( GetWhich( SID_ATTR_PAGE_EXT1 ),
932*cdf0e10cSrcweir 					  aAdaptBox.IsChecked() ) );
933*cdf0e10cSrcweir 			bModified |= sal_True;
934*cdf0e10cSrcweir 			break;
935*cdf0e10cSrcweir 		}
936*cdf0e10cSrcweir         default: ;//prevent warning
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir 	}
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir 	if(aRegisterCB.IsVisible() &&
941*cdf0e10cSrcweir 		(aRegisterCB.IsChecked() || aRegisterCB.GetSavedValue() != aRegisterCB.IsChecked()))
942*cdf0e10cSrcweir 	{
943*cdf0e10cSrcweir 		const SfxBoolItem& rRegItem = (const SfxBoolItem&)rOldSet.Get(SID_SWREGISTER_MODE);
944*cdf0e10cSrcweir 		SfxBoolItem* pRegItem = (SfxBoolItem*)rRegItem.Clone();
945*cdf0e10cSrcweir 		sal_Bool bCheck = aRegisterCB.IsChecked();
946*cdf0e10cSrcweir 		pRegItem->SetValue(bCheck);
947*cdf0e10cSrcweir 		rSet.Put(*pRegItem);
948*cdf0e10cSrcweir 		bModified |= sal_True;
949*cdf0e10cSrcweir 		if(bCheck)
950*cdf0e10cSrcweir 		{
951*cdf0e10cSrcweir 			bModified |= sal_True;
952*cdf0e10cSrcweir 			rSet.Put(SfxStringItem(SID_SWREGISTER_COLLECTION,
953*cdf0e10cSrcweir 							aRegisterLB.GetSelectEntry()));
954*cdf0e10cSrcweir 		}
955*cdf0e10cSrcweir 		delete pRegItem;
956*cdf0e10cSrcweir 	}
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir     SvxFrameDirection eDirection = aTextFlowBox.GetSelectEntryValue();
959*cdf0e10cSrcweir     if( aTextFlowBox.IsVisible() && (eDirection != aTextFlowBox.GetSavedValue()) )
960*cdf0e10cSrcweir 	{
961*cdf0e10cSrcweir         rSet.Put( SvxFrameDirectionItem( eDirection, GetWhich( SID_ATTR_FRAMEDIRECTION ) ) );
962*cdf0e10cSrcweir 		bModified = sal_True;
963*cdf0e10cSrcweir 	}
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir 	return bModified;
966*cdf0e10cSrcweir }
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir // -----------------------------------------------------------------------
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, LayoutHdl_Impl, ListBox *, EMPTYARG )
971*cdf0e10cSrcweir {
972*cdf0e10cSrcweir 	// innen au\sen umschalten
973*cdf0e10cSrcweir 	const sal_uInt16 nPos = PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() );
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir 	if ( nPos == SVX_PAGE_MIRROR )
976*cdf0e10cSrcweir 	{
977*cdf0e10cSrcweir 		if ( aLeftMarginLbl.GetText() != aInsideText )
978*cdf0e10cSrcweir 			aLeftMarginLbl.SetText( aInsideText );
979*cdf0e10cSrcweir 
980*cdf0e10cSrcweir 		if ( aRightMarginLbl.GetText() != aOutsideText )
981*cdf0e10cSrcweir 			aRightMarginLbl.SetText( aOutsideText );
982*cdf0e10cSrcweir 	}
983*cdf0e10cSrcweir 	else
984*cdf0e10cSrcweir 	{
985*cdf0e10cSrcweir 		if ( aLeftMarginLbl.GetText() != aLeftText )
986*cdf0e10cSrcweir 			aLeftMarginLbl.SetText( aLeftText );
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir 		if ( aRightMarginLbl.GetText() != aRightText )
989*cdf0e10cSrcweir 			aRightMarginLbl.SetText( aRightText );
990*cdf0e10cSrcweir 	}
991*cdf0e10cSrcweir     UpdateExample_Impl( true );
992*cdf0e10cSrcweir 	return 0;
993*cdf0e10cSrcweir }
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir // -----------------------------------------------------------------------
996*cdf0e10cSrcweir 
997*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, PaperBinHdl_Impl, ListBox *, EMPTYARG )
998*cdf0e10cSrcweir {
999*cdf0e10cSrcweir 	if ( aPaperTrayBox.GetEntryCount() > 1 )
1000*cdf0e10cSrcweir 		// schon gef"ullt
1001*cdf0e10cSrcweir 		return 0;
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir 	// Schacht-Box initialisieren
1004*cdf0e10cSrcweir 	String aOldName = aPaperTrayBox.GetSelectEntry();
1005*cdf0e10cSrcweir 	aPaperTrayBox.SetUpdateMode( sal_False );
1006*cdf0e10cSrcweir 	aPaperTrayBox.Clear();
1007*cdf0e10cSrcweir 	sal_uInt16 nEntryPos = aPaperTrayBox.InsertEntry(
1008*cdf0e10cSrcweir 		EE_RESSTR( RID_SVXSTR_PAPERBIN_SETTINGS ) );
1009*cdf0e10cSrcweir 	aPaperTrayBox.SetEntryData( nEntryPos,
1010*cdf0e10cSrcweir 		(void*)(sal_uLong)PAPERBIN_PRINTER_SETTINGS );
1011*cdf0e10cSrcweir 	String aPaperBin( EditResId( RID_SVXSTR_PAPERBIN ) );
1012*cdf0e10cSrcweir     sal_uInt16 nBinCount = pImpl->mpDefPrinter->GetPaperBinCount();
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nBinCount; ++i )
1015*cdf0e10cSrcweir 	{
1016*cdf0e10cSrcweir         String aName = pImpl->mpDefPrinter->GetPaperBinName(i);
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir 		if ( !aName.Len() )
1019*cdf0e10cSrcweir 		{
1020*cdf0e10cSrcweir 			aName = aPaperBin;
1021*cdf0e10cSrcweir 			aName.Append( sal_Unicode(' ') );
1022*cdf0e10cSrcweir 			aName.Append( UniString::CreateFromInt32( i+1 ) );
1023*cdf0e10cSrcweir 		}
1024*cdf0e10cSrcweir 		nEntryPos = aPaperTrayBox.InsertEntry( aName );
1025*cdf0e10cSrcweir 		aPaperTrayBox.SetEntryData( nEntryPos, (void*)(sal_uLong)i );
1026*cdf0e10cSrcweir 	}
1027*cdf0e10cSrcweir 	aPaperTrayBox.SelectEntry( aOldName );
1028*cdf0e10cSrcweir 	aPaperTrayBox.SetUpdateMode( sal_True );
1029*cdf0e10cSrcweir 
1030*cdf0e10cSrcweir     return 0;
1031*cdf0e10cSrcweir }
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir // -----------------------------------------------------------------------
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, PaperSizeSelect_Impl, ListBox *, pBox )
1036*cdf0e10cSrcweir {
1037*cdf0e10cSrcweir 	const sal_uInt16 nPos = pBox->GetSelectEntryPos();
1038*cdf0e10cSrcweir 	Paper ePaper = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData( nPos );
1039*cdf0e10cSrcweir 
1040*cdf0e10cSrcweir 	if ( ePaper != PAPER_USER )
1041*cdf0e10cSrcweir 	{
1042*cdf0e10cSrcweir 		Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM ) );
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir 		if ( aLandscapeBtn.IsChecked() )
1045*cdf0e10cSrcweir 			Swap( aSize );
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir 		if ( aSize.Height() < aPaperHeightEdit.GetMin( FUNIT_100TH_MM ) )
1048*cdf0e10cSrcweir 			aPaperHeightEdit.SetMin(
1049*cdf0e10cSrcweir 				aPaperHeightEdit.Normalize( aSize.Height() ), FUNIT_100TH_MM );
1050*cdf0e10cSrcweir 		if ( aSize.Width() < aPaperWidthEdit.GetMin( FUNIT_100TH_MM ) )
1051*cdf0e10cSrcweir 			aPaperWidthEdit.SetMin(
1052*cdf0e10cSrcweir 				aPaperWidthEdit.Normalize( aSize.Width() ), FUNIT_100TH_MM );
1053*cdf0e10cSrcweir 		SetMetricValue( aPaperHeightEdit, aSize.Height(), SFX_MAPUNIT_100TH_MM );
1054*cdf0e10cSrcweir 		SetMetricValue( aPaperWidthEdit, aSize.Width(), SFX_MAPUNIT_100TH_MM );
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir 		// R"ander ggf. neu berechnen
1057*cdf0e10cSrcweir 		CalcMargin_Impl();
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 		RangeHdl_Impl( 0 );
1060*cdf0e10cSrcweir 		UpdateExample_Impl( true );
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir 		if ( eMode == SVX_PAGE_MODE_PRESENTATION )
1063*cdf0e10cSrcweir 		{
1064*cdf0e10cSrcweir 			// Draw: bei Papierformat soll der Rand 1cm betragen
1065*cdf0e10cSrcweir 			long nTmp = 0;
1066*cdf0e10cSrcweir 			sal_Bool bScreen = ( PAPER_SCREEN == ePaper );
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir 			if ( !bScreen )
1069*cdf0e10cSrcweir 				// bei Bildschirm keinen Rand
1070*cdf0e10cSrcweir 				nTmp = 1; // entspr. 1cm
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir 			// Abfragen, ob fuer Raender 0 gesetzt ist:
1073*cdf0e10cSrcweir 			if ( bScreen || aRightMarginEdit.GetValue() == 0 )
1074*cdf0e10cSrcweir 			{
1075*cdf0e10cSrcweir 				SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_CM );
1076*cdf0e10cSrcweir 				if ( !bScreen &&
1077*cdf0e10cSrcweir 					 aRightMarginEdit.GetFirst() > aRightMarginEdit.GetValue() )
1078*cdf0e10cSrcweir 					aRightMarginEdit.SetValue( aRightMarginEdit.GetFirst() );
1079*cdf0e10cSrcweir 			}
1080*cdf0e10cSrcweir 			if ( bScreen || aLeftMarginEdit.GetValue() == 0 )
1081*cdf0e10cSrcweir 			{
1082*cdf0e10cSrcweir 				SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_CM );
1083*cdf0e10cSrcweir 				if ( !bScreen &&
1084*cdf0e10cSrcweir 					 aLeftMarginEdit.GetFirst() > aLeftMarginEdit.GetValue() )
1085*cdf0e10cSrcweir 					aLeftMarginEdit.SetValue( aLeftMarginEdit.GetFirst() );
1086*cdf0e10cSrcweir 			}
1087*cdf0e10cSrcweir 			if ( bScreen || aBottomMarginEdit.GetValue() == 0 )
1088*cdf0e10cSrcweir 			{
1089*cdf0e10cSrcweir 				SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_CM );
1090*cdf0e10cSrcweir 				if ( !bScreen &&
1091*cdf0e10cSrcweir 					 aBottomMarginEdit.GetFirst() > aBottomMarginEdit.GetValue() )
1092*cdf0e10cSrcweir 					aBottomMarginEdit.SetValue( aBottomMarginEdit.GetFirst() );
1093*cdf0e10cSrcweir 			}
1094*cdf0e10cSrcweir 			if ( bScreen || aTopMarginEdit.GetValue() == 0 )
1095*cdf0e10cSrcweir 			{
1096*cdf0e10cSrcweir 				SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_CM );
1097*cdf0e10cSrcweir 				if ( !bScreen &&
1098*cdf0e10cSrcweir 					 aTopMarginEdit.GetFirst() > aTopMarginEdit.GetValue() )
1099*cdf0e10cSrcweir 					aTopMarginEdit.SetValue( aTopMarginEdit.GetFirst() );
1100*cdf0e10cSrcweir 			}
1101*cdf0e10cSrcweir 			UpdateExample_Impl( true );
1102*cdf0e10cSrcweir 		}
1103*cdf0e10cSrcweir 	}
1104*cdf0e10cSrcweir 	return 0;
1105*cdf0e10cSrcweir }
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir // -----------------------------------------------------------------------
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, PaperSizeModify_Impl, Edit *, EMPTYARG )
1110*cdf0e10cSrcweir {
1111*cdf0e10cSrcweir 	sal_uInt16 nWhich = GetWhich( SID_ATTR_LRSPACE );
1112*cdf0e10cSrcweir 	SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWhich );
1113*cdf0e10cSrcweir 	Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ),
1114*cdf0e10cSrcweir 				GetCoreValue( aPaperHeightEdit, eUnit ) );
1115*cdf0e10cSrcweir 	Paper ePaper = SvxPaperInfo::GetSvxPaper( aSize, (MapUnit)eUnit, sal_True );
1116*cdf0e10cSrcweir 	sal_uInt16 nEntryCount = aPaperSizeBox.GetEntryCount();
1117*cdf0e10cSrcweir 
1118*cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < nEntryCount; ++i )
1119*cdf0e10cSrcweir 	{
1120*cdf0e10cSrcweir 		Paper eTmp = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData(i);
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir 		if ( eTmp == ePaper )
1123*cdf0e10cSrcweir 		{
1124*cdf0e10cSrcweir 			aPaperSizeBox.SelectEntryPos(i);
1125*cdf0e10cSrcweir 			break;
1126*cdf0e10cSrcweir 		}
1127*cdf0e10cSrcweir 	}
1128*cdf0e10cSrcweir 	UpdateExample_Impl( true );
1129*cdf0e10cSrcweir 	return 0;
1130*cdf0e10cSrcweir }
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir // -----------------------------------------------------------------------
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, SwapOrientation_Impl, RadioButton *, pBtn )
1135*cdf0e10cSrcweir {
1136*cdf0e10cSrcweir 	if (
1137*cdf0e10cSrcweir         (!bLandscape && pBtn == &aLandscapeBtn) ||
1138*cdf0e10cSrcweir 		(bLandscape  && pBtn == &aPortraitBtn)
1139*cdf0e10cSrcweir        )
1140*cdf0e10cSrcweir 	{
1141*cdf0e10cSrcweir 		bLandscape = aLandscapeBtn.IsChecked();
1142*cdf0e10cSrcweir 
1143*cdf0e10cSrcweir 		const long lWidth = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_100TH_MM );
1144*cdf0e10cSrcweir 		const long lHeight = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_100TH_MM );
1145*cdf0e10cSrcweir 
1146*cdf0e10cSrcweir         // swap with and height
1147*cdf0e10cSrcweir 		SetMetricValue( aPaperWidthEdit, lHeight, SFX_MAPUNIT_100TH_MM );
1148*cdf0e10cSrcweir 		SetMetricValue( aPaperHeightEdit, lWidth, SFX_MAPUNIT_100TH_MM );
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir         // recalculate margins if necessary
1151*cdf0e10cSrcweir 		CalcMargin_Impl();
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir 		PaperSizeSelect_Impl( &aPaperSizeBox );
1154*cdf0e10cSrcweir 		RangeHdl_Impl( 0 );
1155*cdf0e10cSrcweir 		SwapFirstValues_Impl( bBorderModified );
1156*cdf0e10cSrcweir         UpdateExample_Impl( true );
1157*cdf0e10cSrcweir 	}
1158*cdf0e10cSrcweir 	return 0;
1159*cdf0e10cSrcweir }
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir // -----------------------------------------------------------------------
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir void SvxPageDescPage::SwapFirstValues_Impl( FASTBOOL bSet )
1164*cdf0e10cSrcweir {
1165*cdf0e10cSrcweir     MapMode aOldMode = pImpl->mpDefPrinter->GetMapMode();
1166*cdf0e10cSrcweir 	Orientation	eOri = ORIENTATION_PORTRAIT;
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir 	if ( bLandscape )
1169*cdf0e10cSrcweir 		eOri = ORIENTATION_LANDSCAPE;
1170*cdf0e10cSrcweir     Orientation eOldOri = pImpl->mpDefPrinter->GetOrientation();
1171*cdf0e10cSrcweir     pImpl->mpDefPrinter->SetOrientation( eOri );
1172*cdf0e10cSrcweir     pImpl->mpDefPrinter->SetMapMode( MAP_TWIP );
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir 	// First- und Last-Werte f"ur die R"ander setzen
1175*cdf0e10cSrcweir     Size aPaperSize = pImpl->mpDefPrinter->GetPaperSize();
1176*cdf0e10cSrcweir     Size aPrintSize = pImpl->mpDefPrinter->GetOutputSize();
1177*cdf0e10cSrcweir 	/*
1178*cdf0e10cSrcweir 	 * einen Punkt ( 0,0 ) in logische Koordinaten zu konvertieren,
1179*cdf0e10cSrcweir 	 * sieht aus wie Unsinn; ist aber sinnvoll, wenn der Ursprung des
1180*cdf0e10cSrcweir 	 * Koordinatensystems verschoben ist.
1181*cdf0e10cSrcweir 	 */
1182*cdf0e10cSrcweir     Point aPrintOffset = pImpl->mpDefPrinter->GetPageOffset() -
1183*cdf0e10cSrcweir                          pImpl->mpDefPrinter->PixelToLogic( Point() );
1184*cdf0e10cSrcweir     pImpl->mpDefPrinter->SetMapMode( aOldMode );
1185*cdf0e10cSrcweir     pImpl->mpDefPrinter->SetOrientation( eOldOri );
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir     sal_Int64 nSetL = aLeftMarginEdit.Denormalize(
1188*cdf0e10cSrcweir 					aLeftMarginEdit.GetValue( FUNIT_TWIP ) );
1189*cdf0e10cSrcweir 	sal_Int64 nSetR = aRightMarginEdit.Denormalize(
1190*cdf0e10cSrcweir 					aRightMarginEdit.GetValue( FUNIT_TWIP ) );
1191*cdf0e10cSrcweir 	sal_Int64 nSetT = aTopMarginEdit.Denormalize(
1192*cdf0e10cSrcweir 					aTopMarginEdit.GetValue( FUNIT_TWIP ) );
1193*cdf0e10cSrcweir 	sal_Int64 nSetB = aBottomMarginEdit.Denormalize(
1194*cdf0e10cSrcweir 					aBottomMarginEdit.GetValue( FUNIT_TWIP ) );
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir 	long nOffset = !aPrintOffset.X() && !aPrintOffset.Y() ? 0 : PRINT_OFFSET;
1197*cdf0e10cSrcweir 	long nNewL = aPrintOffset.X();
1198*cdf0e10cSrcweir 	long nNewR =
1199*cdf0e10cSrcweir 		aPaperSize.Width() - aPrintSize.Width() - aPrintOffset.X() + nOffset;
1200*cdf0e10cSrcweir 	long nNewT = aPrintOffset.Y();
1201*cdf0e10cSrcweir 	long nNewB =
1202*cdf0e10cSrcweir 		aPaperSize.Height() - aPrintSize.Height() - aPrintOffset.Y() + nOffset;
1203*cdf0e10cSrcweir 
1204*cdf0e10cSrcweir 	aLeftMarginEdit.SetFirst( aLeftMarginEdit.Normalize( nNewL ), FUNIT_TWIP );
1205*cdf0e10cSrcweir 	nFirstLeftMargin = static_cast<long>(aLeftMarginEdit.GetFirst());
1206*cdf0e10cSrcweir 	aRightMarginEdit.SetFirst( aRightMarginEdit.Normalize( nNewR ), FUNIT_TWIP );
1207*cdf0e10cSrcweir 	nFirstRightMargin = static_cast<long>(aRightMarginEdit.GetFirst());
1208*cdf0e10cSrcweir 	aTopMarginEdit.SetFirst( aTopMarginEdit.Normalize( nNewT ), FUNIT_TWIP );
1209*cdf0e10cSrcweir 	nFirstTopMargin = static_cast<long>(aTopMarginEdit.GetFirst());
1210*cdf0e10cSrcweir 	aBottomMarginEdit.SetFirst(	aBottomMarginEdit.Normalize( nNewB ), FUNIT_TWIP );
1211*cdf0e10cSrcweir 	nFirstBottomMargin = static_cast<long>(aBottomMarginEdit.GetFirst());
1212*cdf0e10cSrcweir 
1213*cdf0e10cSrcweir 	if ( bSet )
1214*cdf0e10cSrcweir 	{
1215*cdf0e10cSrcweir 		// ggf. auch die Werte umsetzen,
1216*cdf0e10cSrcweir 		if ( nSetL < nNewL )
1217*cdf0e10cSrcweir 			aLeftMarginEdit.SetValue( aLeftMarginEdit.Normalize( nNewL ),
1218*cdf0e10cSrcweir 									  FUNIT_TWIP );
1219*cdf0e10cSrcweir 		if ( nSetR < nNewR )
1220*cdf0e10cSrcweir 			aRightMarginEdit.SetValue( aRightMarginEdit.Normalize( nNewR ),
1221*cdf0e10cSrcweir 									   FUNIT_TWIP );
1222*cdf0e10cSrcweir 		if ( nSetT < nNewT )
1223*cdf0e10cSrcweir 			aTopMarginEdit.SetValue( aTopMarginEdit.Normalize( nNewT ),
1224*cdf0e10cSrcweir 									 FUNIT_TWIP );
1225*cdf0e10cSrcweir 		if ( nSetB < nNewB )
1226*cdf0e10cSrcweir 			aBottomMarginEdit.SetValue( aBottomMarginEdit.Normalize( nNewB ),
1227*cdf0e10cSrcweir 										FUNIT_TWIP );
1228*cdf0e10cSrcweir 	}
1229*cdf0e10cSrcweir }
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir // -----------------------------------------------------------------------
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG )
1234*cdf0e10cSrcweir {
1235*cdf0e10cSrcweir 	if ( !bBorderModified )
1236*cdf0e10cSrcweir 		bBorderModified = sal_True;
1237*cdf0e10cSrcweir 	UpdateExample_Impl();
1238*cdf0e10cSrcweir 	return 0;
1239*cdf0e10cSrcweir }
1240*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxPageDescPage, BorderModify_Impl, MetricField *, EMPTYARG )
1241*cdf0e10cSrcweir 
1242*cdf0e10cSrcweir // -----------------------------------------------------------------------
1243*cdf0e10cSrcweir 
1244*cdf0e10cSrcweir void SvxPageDescPage::UpdateExample_Impl( bool bResetbackground )
1245*cdf0e10cSrcweir {
1246*cdf0e10cSrcweir 	// Size
1247*cdf0e10cSrcweir 	Size aSize(	GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP ),
1248*cdf0e10cSrcweir 				GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP ) );
1249*cdf0e10cSrcweir 
1250*cdf0e10cSrcweir 	aBspWin.SetSize( aSize );
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir 	// R"ander
1253*cdf0e10cSrcweir 	aBspWin.SetTop( GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP ) );
1254*cdf0e10cSrcweir 	aBspWin.SetBottom( GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP ) );
1255*cdf0e10cSrcweir 	aBspWin.SetLeft( GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP ) );
1256*cdf0e10cSrcweir 	aBspWin.SetRight( GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP ) );
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir 	// Layout
1259*cdf0e10cSrcweir 	aBspWin.SetUsage( PosToPageUsage_Impl( aLayoutBox.GetSelectEntryPos() ) );
1260*cdf0e10cSrcweir     if ( bResetbackground )
1261*cdf0e10cSrcweir         aBspWin.ResetBackground();
1262*cdf0e10cSrcweir 	aBspWin.Invalidate();
1263*cdf0e10cSrcweir }
1264*cdf0e10cSrcweir 
1265*cdf0e10cSrcweir // -----------------------------------------------------------------------
1266*cdf0e10cSrcweir 
1267*cdf0e10cSrcweir void SvxPageDescPage::ResetBackground_Impl( const SfxItemSet& rSet )
1268*cdf0e10cSrcweir {
1269*cdf0e10cSrcweir 	sal_uInt16 nWhich = GetWhich( SID_ATTR_PAGE_HEADERSET );
1270*cdf0e10cSrcweir 
1271*cdf0e10cSrcweir 	if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
1272*cdf0e10cSrcweir 	{
1273*cdf0e10cSrcweir 		const SvxSetItem& rSetItem =
1274*cdf0e10cSrcweir 			(const SvxSetItem&)rSet.Get( nWhich, sal_False );
1275*cdf0e10cSrcweir 		const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1276*cdf0e10cSrcweir 		const SfxBoolItem& rOn =
1277*cdf0e10cSrcweir 			(const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir 		if ( rOn.GetValue() )
1280*cdf0e10cSrcweir 		{
1281*cdf0e10cSrcweir 			nWhich = GetWhich( SID_ATTR_BRUSH );
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir 			if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1284*cdf0e10cSrcweir 			{
1285*cdf0e10cSrcweir 				const SvxBrushItem& rItem =
1286*cdf0e10cSrcweir 					(const SvxBrushItem&)rTmpSet.Get( nWhich );
1287*cdf0e10cSrcweir 				aBspWin.SetHdColor( rItem.GetColor() );
1288*cdf0e10cSrcweir 			}
1289*cdf0e10cSrcweir 			nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1290*cdf0e10cSrcweir 
1291*cdf0e10cSrcweir 			if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1292*cdf0e10cSrcweir 			{
1293*cdf0e10cSrcweir 				const SvxBoxItem& rItem =
1294*cdf0e10cSrcweir 					(const SvxBoxItem&)rTmpSet.Get( nWhich );
1295*cdf0e10cSrcweir 				aBspWin.SetHdBorder( rItem );
1296*cdf0e10cSrcweir 			}
1297*cdf0e10cSrcweir 		}
1298*cdf0e10cSrcweir 	}
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir 	nWhich = GetWhich( SID_ATTR_PAGE_FOOTERSET );
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir 	if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET )
1303*cdf0e10cSrcweir 	{
1304*cdf0e10cSrcweir 		const SvxSetItem& rSetItem =
1305*cdf0e10cSrcweir 			(const SvxSetItem&)rSet.Get( nWhich, sal_False );
1306*cdf0e10cSrcweir 		const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
1307*cdf0e10cSrcweir 		const SfxBoolItem& rOn =
1308*cdf0e10cSrcweir 			(const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir 		if ( rOn.GetValue() )
1311*cdf0e10cSrcweir 		{
1312*cdf0e10cSrcweir 			nWhich = GetWhich( SID_ATTR_BRUSH );
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir 			if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1315*cdf0e10cSrcweir 			{
1316*cdf0e10cSrcweir 				const SvxBrushItem& rItem =
1317*cdf0e10cSrcweir 					(const SvxBrushItem&)rTmpSet.Get( nWhich );
1318*cdf0e10cSrcweir 				aBspWin.SetFtColor( rItem.GetColor() );
1319*cdf0e10cSrcweir 			}
1320*cdf0e10cSrcweir 			nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1321*cdf0e10cSrcweir 
1322*cdf0e10cSrcweir 			if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
1323*cdf0e10cSrcweir 			{
1324*cdf0e10cSrcweir 				const SvxBoxItem& rItem =
1325*cdf0e10cSrcweir 					(const SvxBoxItem&)rTmpSet.Get( nWhich );
1326*cdf0e10cSrcweir 				aBspWin.SetFtBorder( rItem );
1327*cdf0e10cSrcweir 			}
1328*cdf0e10cSrcweir 		}
1329*cdf0e10cSrcweir 	}
1330*cdf0e10cSrcweir 
1331*cdf0e10cSrcweir 	const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_BRUSH );
1332*cdf0e10cSrcweir 
1333*cdf0e10cSrcweir 	if ( pItem )
1334*cdf0e10cSrcweir 	{
1335*cdf0e10cSrcweir 		aBspWin.SetColor( ( (const SvxBrushItem*)pItem )->GetColor() );
1336*cdf0e10cSrcweir 		const Graphic* pGrf = ( (const SvxBrushItem*)pItem )->GetGraphic();
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir 		if ( pGrf )
1339*cdf0e10cSrcweir 		{
1340*cdf0e10cSrcweir 			Bitmap aBitmap = pGrf->GetBitmap();
1341*cdf0e10cSrcweir 			aBspWin.SetBitmap( &aBitmap );
1342*cdf0e10cSrcweir 		}
1343*cdf0e10cSrcweir 		else
1344*cdf0e10cSrcweir 			aBspWin.SetBitmap( NULL );
1345*cdf0e10cSrcweir 	}
1346*cdf0e10cSrcweir 
1347*cdf0e10cSrcweir 	pItem = GetItem( rSet, SID_ATTR_BORDER_OUTER );
1348*cdf0e10cSrcweir 
1349*cdf0e10cSrcweir 	if ( pItem )
1350*cdf0e10cSrcweir 		aBspWin.SetBorder( (SvxBoxItem&)*pItem );
1351*cdf0e10cSrcweir }
1352*cdf0e10cSrcweir 
1353*cdf0e10cSrcweir // -----------------------------------------------------------------------
1354*cdf0e10cSrcweir 
1355*cdf0e10cSrcweir void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet )
1356*cdf0e10cSrcweir {
1357*cdf0e10cSrcweir 	bLandscape = aLandscapeBtn.IsChecked();
1358*cdf0e10cSrcweir 	const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
1359*cdf0e10cSrcweir 
1360*cdf0e10cSrcweir 	if ( pItem )
1361*cdf0e10cSrcweir 		aBspWin.SetSize( ( (const SvxSizeItem*)pItem )->GetSize() );
1362*cdf0e10cSrcweir 
1363*cdf0e10cSrcweir 	const SvxSetItem* pSetItem = 0;
1364*cdf0e10cSrcweir 
1365*cdf0e10cSrcweir 	// Kopfzeilen-Attribute auswerten
1366*cdf0e10cSrcweir 
1367*cdf0e10cSrcweir 	if ( SFX_ITEM_SET ==
1368*cdf0e10cSrcweir 		 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
1369*cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**)&pSetItem ) )
1370*cdf0e10cSrcweir 	{
1371*cdf0e10cSrcweir 		const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
1372*cdf0e10cSrcweir 		const SfxBoolItem& rHeaderOn =
1373*cdf0e10cSrcweir 			(const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1374*cdf0e10cSrcweir 
1375*cdf0e10cSrcweir 		if ( rHeaderOn.GetValue() )
1376*cdf0e10cSrcweir 		{
1377*cdf0e10cSrcweir 			const SvxSizeItem& rSize = (const SvxSizeItem&)
1378*cdf0e10cSrcweir 				rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1379*cdf0e10cSrcweir 			const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
1380*cdf0e10cSrcweir 				rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
1381*cdf0e10cSrcweir 			long nDist = rUL.GetLower();
1382*cdf0e10cSrcweir 			aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist );
1383*cdf0e10cSrcweir 			aBspWin.SetHdDist( nDist );
1384*cdf0e10cSrcweir 			const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
1385*cdf0e10cSrcweir 				rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
1386*cdf0e10cSrcweir 			aBspWin.SetHdLeft( rLR.GetLeft() );
1387*cdf0e10cSrcweir 			aBspWin.SetHdRight( rLR.GetRight() );
1388*cdf0e10cSrcweir 			aBspWin.SetHeader( sal_True );
1389*cdf0e10cSrcweir 		}
1390*cdf0e10cSrcweir 		else
1391*cdf0e10cSrcweir 			aBspWin.SetHeader( sal_False );
1392*cdf0e10cSrcweir 
1393*cdf0e10cSrcweir 		// im Beispiel Hintergrund und Umrandung anzeigen
1394*cdf0e10cSrcweir 		sal_uInt16 nWhich = GetWhich( SID_ATTR_BRUSH );
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir 		if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1397*cdf0e10cSrcweir 		{
1398*cdf0e10cSrcweir 			const SvxBrushItem& rItem =
1399*cdf0e10cSrcweir 				(const SvxBrushItem&)rHeaderSet.Get( nWhich );
1400*cdf0e10cSrcweir 			aBspWin.SetHdColor( rItem.GetColor() );
1401*cdf0e10cSrcweir 		}
1402*cdf0e10cSrcweir 		nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1403*cdf0e10cSrcweir 
1404*cdf0e10cSrcweir 		if ( rHeaderSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1405*cdf0e10cSrcweir 		{
1406*cdf0e10cSrcweir 			const SvxBoxItem& rItem =
1407*cdf0e10cSrcweir 				(const SvxBoxItem&)rHeaderSet.Get( nWhich );
1408*cdf0e10cSrcweir 			aBspWin.SetHdBorder( rItem );
1409*cdf0e10cSrcweir 		}
1410*cdf0e10cSrcweir 	}
1411*cdf0e10cSrcweir 
1412*cdf0e10cSrcweir 	// Fusszeilen-Attribute auswerten
1413*cdf0e10cSrcweir 
1414*cdf0e10cSrcweir 	if ( SFX_ITEM_SET ==
1415*cdf0e10cSrcweir 		 rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
1416*cdf0e10cSrcweir 							sal_False, (const SfxPoolItem**)&pSetItem ) )
1417*cdf0e10cSrcweir 	{
1418*cdf0e10cSrcweir 		const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
1419*cdf0e10cSrcweir 		const SfxBoolItem& rFooterOn =
1420*cdf0e10cSrcweir 			(const SfxBoolItem&)rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir 		if ( rFooterOn.GetValue() )
1423*cdf0e10cSrcweir 		{
1424*cdf0e10cSrcweir 			const SvxSizeItem& rSize = (const SvxSizeItem&)
1425*cdf0e10cSrcweir 				rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1426*cdf0e10cSrcweir 			const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
1427*cdf0e10cSrcweir 				rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
1428*cdf0e10cSrcweir 			long nDist = rUL.GetUpper();
1429*cdf0e10cSrcweir 			aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist );
1430*cdf0e10cSrcweir 			aBspWin.SetFtDist( nDist );
1431*cdf0e10cSrcweir 			const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
1432*cdf0e10cSrcweir 				rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
1433*cdf0e10cSrcweir 			aBspWin.SetFtLeft( rLR.GetLeft() );
1434*cdf0e10cSrcweir 			aBspWin.SetFtRight( rLR.GetRight() );
1435*cdf0e10cSrcweir 			aBspWin.SetFooter( sal_True );
1436*cdf0e10cSrcweir 		}
1437*cdf0e10cSrcweir 		else
1438*cdf0e10cSrcweir 			aBspWin.SetFooter( sal_False );
1439*cdf0e10cSrcweir 
1440*cdf0e10cSrcweir 		// im Beispiel Hintergrund und Umrandung anzeigen
1441*cdf0e10cSrcweir 		sal_uInt16 nWhich = GetWhich( SID_ATTR_BRUSH );
1442*cdf0e10cSrcweir 
1443*cdf0e10cSrcweir 		if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1444*cdf0e10cSrcweir 		{
1445*cdf0e10cSrcweir 			const SvxBrushItem& rItem =
1446*cdf0e10cSrcweir 				(const SvxBrushItem&)rFooterSet.Get( nWhich );
1447*cdf0e10cSrcweir 			aBspWin.SetFtColor( rItem.GetColor() );
1448*cdf0e10cSrcweir 		}
1449*cdf0e10cSrcweir 		nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
1450*cdf0e10cSrcweir 
1451*cdf0e10cSrcweir 		if ( rFooterSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
1452*cdf0e10cSrcweir 		{
1453*cdf0e10cSrcweir 			const SvxBoxItem& rItem =
1454*cdf0e10cSrcweir 				(const SvxBoxItem&)rFooterSet.Get( nWhich );
1455*cdf0e10cSrcweir 			aBspWin.SetFtBorder( rItem );
1456*cdf0e10cSrcweir 		}
1457*cdf0e10cSrcweir 	}
1458*cdf0e10cSrcweir }
1459*cdf0e10cSrcweir 
1460*cdf0e10cSrcweir // -----------------------------------------------------------------------
1461*cdf0e10cSrcweir 
1462*cdf0e10cSrcweir void SvxPageDescPage::ActivatePage( const SfxItemSet& rSet )
1463*cdf0e10cSrcweir {
1464*cdf0e10cSrcweir 	InitHeadFoot_Impl( rSet );
1465*cdf0e10cSrcweir 	ResetBackground_Impl( rSet );
1466*cdf0e10cSrcweir 	RangeHdl_Impl( 0 );
1467*cdf0e10cSrcweir }
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir // -----------------------------------------------------------------------
1470*cdf0e10cSrcweir 
1471*cdf0e10cSrcweir int SvxPageDescPage::DeactivatePage( SfxItemSet* _pSet )
1472*cdf0e10cSrcweir {
1473*cdf0e10cSrcweir 	// Abfrage, ob die Seitenr"ander ausserhalb des Druckbereichs liegen
1474*cdf0e10cSrcweir 	// Wenn nicht, dann den Anwender fragen, ob sie "ubernommen werden sollen.
1475*cdf0e10cSrcweir 	// Wenn nicht, dann auf der TabPage bleiben.
1476*cdf0e10cSrcweir 	sal_uInt16 nPos = aPaperSizeBox.GetSelectEntryPos();
1477*cdf0e10cSrcweir 	Paper ePaper = (Paper)(sal_uLong)aPaperSizeBox.GetEntryData( nPos );
1478*cdf0e10cSrcweir 
1479*cdf0e10cSrcweir 	if ( ePaper != PAPER_SCREEN && IsMarginOutOfRange() )
1480*cdf0e10cSrcweir 	{
1481*cdf0e10cSrcweir 		if ( QueryBox( this, WB_YES_NO | WB_DEF_NO, aPrintRangeQueryText ).Execute() == RET_NO )
1482*cdf0e10cSrcweir 		{
1483*cdf0e10cSrcweir 			MetricField* pField = NULL;
1484*cdf0e10cSrcweir 			if ( IsPrinterRangeOverflow( aLeftMarginEdit, nFirstLeftMargin, nLastLeftMargin, MARGIN_LEFT ) )
1485*cdf0e10cSrcweir 				pField = &aLeftMarginEdit;
1486*cdf0e10cSrcweir 			if (	IsPrinterRangeOverflow( aRightMarginEdit, nFirstRightMargin, nLastRightMargin, MARGIN_RIGHT )
1487*cdf0e10cSrcweir 				 && !pField )
1488*cdf0e10cSrcweir 				pField = &aRightMarginEdit;
1489*cdf0e10cSrcweir 			if (	IsPrinterRangeOverflow( aTopMarginEdit, nFirstTopMargin, nLastTopMargin, MARGIN_TOP )
1490*cdf0e10cSrcweir 				 && !pField )
1491*cdf0e10cSrcweir 				pField = &aTopMarginEdit;
1492*cdf0e10cSrcweir 			if (	IsPrinterRangeOverflow( aBottomMarginEdit, nFirstBottomMargin, nLastBottomMargin, MARGIN_BOTTOM )
1493*cdf0e10cSrcweir 				 && !pField )
1494*cdf0e10cSrcweir 				pField = &aBottomMarginEdit;
1495*cdf0e10cSrcweir 			if ( pField )
1496*cdf0e10cSrcweir 				pField->GrabFocus();
1497*cdf0e10cSrcweir 			UpdateExample_Impl();
1498*cdf0e10cSrcweir 			return KEEP_PAGE;
1499*cdf0e10cSrcweir 		}
1500*cdf0e10cSrcweir 		else
1501*cdf0e10cSrcweir 			CheckMarginEdits( false );
1502*cdf0e10cSrcweir 	}
1503*cdf0e10cSrcweir 
1504*cdf0e10cSrcweir     if ( _pSet )
1505*cdf0e10cSrcweir 	{
1506*cdf0e10cSrcweir         FillItemSet( *_pSet );
1507*cdf0e10cSrcweir 
1508*cdf0e10cSrcweir 		// ggf. hoch/quer putten
1509*cdf0e10cSrcweir 		sal_uInt16 nWh = GetWhich( SID_ATTR_PAGE_SIZE );
1510*cdf0e10cSrcweir 		SfxMapUnit eUnit = GetItemSet().GetPool()->GetMetric( nWh );
1511*cdf0e10cSrcweir 		Size aSize( GetCoreValue( aPaperWidthEdit, eUnit ),
1512*cdf0e10cSrcweir 					GetCoreValue( aPaperHeightEdit, eUnit ) );
1513*cdf0e10cSrcweir 
1514*cdf0e10cSrcweir         // putten, wenn aktuelle Gr"o/se unterschiedlich zum Wert in _pSet
1515*cdf0e10cSrcweir         const SvxSizeItem* pSize = (const SvxSizeItem*)GetItem( *_pSet, SID_ATTR_PAGE_SIZE );
1516*cdf0e10cSrcweir 		if ( aSize.Width() && ( !pSize || !IsEqualSize_Impl( pSize, aSize ) ) )
1517*cdf0e10cSrcweir             _pSet->Put( SvxSizeItem( nWh, aSize ) );
1518*cdf0e10cSrcweir 	}
1519*cdf0e10cSrcweir 
1520*cdf0e10cSrcweir 	return LEAVE_PAGE;
1521*cdf0e10cSrcweir }
1522*cdf0e10cSrcweir 
1523*cdf0e10cSrcweir // -----------------------------------------------------------------------
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, RangeHdl_Impl, Edit *, EMPTYARG )
1526*cdf0e10cSrcweir {
1527*cdf0e10cSrcweir 	// Aktuelle Header-Breite/H"ohe aus dem Bsp
1528*cdf0e10cSrcweir 	long nHHeight = aBspWin.GetHdHeight();
1529*cdf0e10cSrcweir 	long nHDist = aBspWin.GetHdDist();
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir 	// Aktuelle Footer-Breite/H"ohe aus dem Bsp
1532*cdf0e10cSrcweir 	long nFHeight = aBspWin.GetFtHeight();
1533*cdf0e10cSrcweir 	long nFDist = aBspWin.GetFtDist();
1534*cdf0e10cSrcweir 
1535*cdf0e10cSrcweir 	// Aktuelle Header/Footer-R"ander aus dem Bsp
1536*cdf0e10cSrcweir 	long nHFLeft = Max( aBspWin.GetHdLeft(), aBspWin.GetFtLeft() );
1537*cdf0e10cSrcweir 	long nHFRight = Max( aBspWin.GetHdRight(), aBspWin.GetFtRight() );
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir 	// Aktuelle Werte der Seitenr"ander
1540*cdf0e10cSrcweir 	long nBT = static_cast<long>(aTopMarginEdit.Denormalize(aTopMarginEdit.GetValue(FUNIT_TWIP)));
1541*cdf0e10cSrcweir 	long nBB = static_cast<long>(aBottomMarginEdit.Denormalize(aBottomMarginEdit.GetValue(FUNIT_TWIP)));
1542*cdf0e10cSrcweir 	long nBL = static_cast<long>(aLeftMarginEdit.Denormalize(aLeftMarginEdit.GetValue(FUNIT_TWIP)));
1543*cdf0e10cSrcweir 	long nBR = static_cast<long>(aRightMarginEdit.Denormalize(aRightMarginEdit.GetValue(FUNIT_TWIP)));
1544*cdf0e10cSrcweir 
1545*cdf0e10cSrcweir 	// Breite Umrandung der Seite berechnen
1546*cdf0e10cSrcweir     const SfxItemSet* _pSet = &GetItemSet();
1547*cdf0e10cSrcweir 	Size aBorder;
1548*cdf0e10cSrcweir 
1549*cdf0e10cSrcweir     if ( _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_SHADOW) ) >=
1550*cdf0e10cSrcweir 			SFX_ITEM_AVAILABLE &&
1551*cdf0e10cSrcweir          _pSet->GetItemState( GetWhich(SID_ATTR_BORDER_OUTER)  ) >=
1552*cdf0e10cSrcweir 			SFX_ITEM_AVAILABLE )
1553*cdf0e10cSrcweir 	{
1554*cdf0e10cSrcweir 		aBorder = ( GetMinBorderSpace_Impl(
1555*cdf0e10cSrcweir             (const SvxShadowItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW)),
1556*cdf0e10cSrcweir             (const SvxBoxItem&)_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER))));
1557*cdf0e10cSrcweir 	}
1558*cdf0e10cSrcweir 
1559*cdf0e10cSrcweir 	long nH  = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP)));
1560*cdf0e10cSrcweir 	long nW  = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP)));
1561*cdf0e10cSrcweir 
1562*cdf0e10cSrcweir 	// Grenzen Papier
1563*cdf0e10cSrcweir 	// Maximum liegt bei 54cm
1564*cdf0e10cSrcweir 	//
1565*cdf0e10cSrcweir 	long nMin = nHHeight + nHDist + nFDist + nFHeight + nBT + nBB +
1566*cdf0e10cSrcweir 				MINBODY + aBorder.Height();
1567*cdf0e10cSrcweir 	aPaperHeightEdit.SetMin(aPaperHeightEdit.Normalize(nMin), FUNIT_TWIP);
1568*cdf0e10cSrcweir 
1569*cdf0e10cSrcweir 	nMin = MINBODY + nBL + nBR + aBorder.Width();
1570*cdf0e10cSrcweir 	aPaperWidthEdit.SetMin(aPaperWidthEdit.Normalize(nMin), FUNIT_TWIP);
1571*cdf0e10cSrcweir 
1572*cdf0e10cSrcweir 	// Falls sich die Papiergr"o\se ge"adert hat
1573*cdf0e10cSrcweir 	nH = static_cast<long>(aPaperHeightEdit.Denormalize(aPaperHeightEdit.GetValue(FUNIT_TWIP)));
1574*cdf0e10cSrcweir 	nW = static_cast<long>(aPaperWidthEdit.Denormalize(aPaperWidthEdit.GetValue(FUNIT_TWIP)));
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir 	// Top
1577*cdf0e10cSrcweir 	long nMax =	nH - nBB - aBorder.Height() - MINBODY -
1578*cdf0e10cSrcweir 				nFDist - nFHeight -	nHDist - nHHeight;
1579*cdf0e10cSrcweir 
1580*cdf0e10cSrcweir 	aTopMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
1581*cdf0e10cSrcweir 
1582*cdf0e10cSrcweir 	// Bottom
1583*cdf0e10cSrcweir 	nMax = nH - nBT - aBorder.Height() - MINBODY -
1584*cdf0e10cSrcweir 		   nFDist - nFHeight - nHDist - nHHeight;
1585*cdf0e10cSrcweir 
1586*cdf0e10cSrcweir 	aBottomMarginEdit.SetMax(aTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir 	// Left
1589*cdf0e10cSrcweir 	nMax = nW - nBR - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1590*cdf0e10cSrcweir 	aLeftMarginEdit.SetMax(aLeftMarginEdit.Normalize(nMax), FUNIT_TWIP);
1591*cdf0e10cSrcweir 
1592*cdf0e10cSrcweir 	// Right
1593*cdf0e10cSrcweir 	nMax = nW - nBL - MINBODY - aBorder.Width() - nHFLeft - nHFRight;
1594*cdf0e10cSrcweir 	aRightMarginEdit.SetMax(aRightMarginEdit.Normalize(nMax), FUNIT_TWIP);
1595*cdf0e10cSrcweir 	return 0;
1596*cdf0e10cSrcweir }
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir // -----------------------------------------------------------------------
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir void SvxPageDescPage::CalcMargin_Impl()
1601*cdf0e10cSrcweir {
1602*cdf0e10cSrcweir 	// Aktuelle Werte der Seitenr"ander
1603*cdf0e10cSrcweir 	long nBT = GetCoreValue( aTopMarginEdit, SFX_MAPUNIT_TWIP );
1604*cdf0e10cSrcweir 	long nBB = GetCoreValue( aBottomMarginEdit, SFX_MAPUNIT_TWIP );
1605*cdf0e10cSrcweir 
1606*cdf0e10cSrcweir 	long nBL = GetCoreValue( aLeftMarginEdit, SFX_MAPUNIT_TWIP );
1607*cdf0e10cSrcweir 	long nBR = GetCoreValue( aRightMarginEdit, SFX_MAPUNIT_TWIP );
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir 	long nH  = GetCoreValue( aPaperHeightEdit, SFX_MAPUNIT_TWIP );
1610*cdf0e10cSrcweir 	long nW  = GetCoreValue( aPaperWidthEdit, SFX_MAPUNIT_TWIP );
1611*cdf0e10cSrcweir 
1612*cdf0e10cSrcweir 	long nWidth = nBL + nBR + MINBODY;
1613*cdf0e10cSrcweir 	long nHeight = nBT + nBB + MINBODY;
1614*cdf0e10cSrcweir 
1615*cdf0e10cSrcweir 	if ( nWidth > nW || nHeight > nH )
1616*cdf0e10cSrcweir 	{
1617*cdf0e10cSrcweir 		if ( nWidth > nW )
1618*cdf0e10cSrcweir 		{
1619*cdf0e10cSrcweir 			long nTmp = nBL <= nBR ? nBR : nBL;
1620*cdf0e10cSrcweir 			nTmp -= nWidth - nW;
1621*cdf0e10cSrcweir 
1622*cdf0e10cSrcweir 			if ( nBL <= nBR )
1623*cdf0e10cSrcweir 				SetMetricValue( aRightMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1624*cdf0e10cSrcweir 			else
1625*cdf0e10cSrcweir 				SetMetricValue( aLeftMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1626*cdf0e10cSrcweir 		}
1627*cdf0e10cSrcweir 
1628*cdf0e10cSrcweir 		if ( nHeight > nH )
1629*cdf0e10cSrcweir 		{
1630*cdf0e10cSrcweir 			long nTmp = nBT <= nBB ? nBB : nBT;
1631*cdf0e10cSrcweir 			nTmp -= nHeight - nH;
1632*cdf0e10cSrcweir 
1633*cdf0e10cSrcweir 			if ( nBT <= nBB )
1634*cdf0e10cSrcweir 				SetMetricValue( aBottomMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1635*cdf0e10cSrcweir 			else
1636*cdf0e10cSrcweir 				SetMetricValue( aTopMarginEdit, nTmp, SFX_MAPUNIT_TWIP );
1637*cdf0e10cSrcweir 		}
1638*cdf0e10cSrcweir 	}
1639*cdf0e10cSrcweir }
1640*cdf0e10cSrcweir 
1641*cdf0e10cSrcweir // -----------------------------------------------------------------------
1642*cdf0e10cSrcweir 
1643*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG )
1644*cdf0e10cSrcweir {
1645*cdf0e10cSrcweir     aBspWin.SetHorz( aHorzBox.IsChecked() );
1646*cdf0e10cSrcweir     aBspWin.SetVert( aVertBox.IsChecked() );
1647*cdf0e10cSrcweir     UpdateExample_Impl();
1648*cdf0e10cSrcweir 	return 0;
1649*cdf0e10cSrcweir }
1650*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvxPageDescPage, CenterHdl_Impl, CheckBox *, EMPTYARG )
1651*cdf0e10cSrcweir 
1652*cdf0e10cSrcweir // -----------------------------------------------------------------------
1653*cdf0e10cSrcweir 
1654*cdf0e10cSrcweir void SvxPageDescPage::SetCollectionList(const List* pList)
1655*cdf0e10cSrcweir {
1656*cdf0e10cSrcweir 	sStandardRegister = *(String*)pList->GetObject(0);
1657*cdf0e10cSrcweir 	for( sal_uInt16 i = 1; i < pList->Count(); i++   )
1658*cdf0e10cSrcweir 	{
1659*cdf0e10cSrcweir 		aRegisterLB.InsertEntry(*(String*)pList->GetObject(i));
1660*cdf0e10cSrcweir 	}
1661*cdf0e10cSrcweir 
1662*cdf0e10cSrcweir 	aRegisterCB  .Show();
1663*cdf0e10cSrcweir 	aRegisterFT  .Show();
1664*cdf0e10cSrcweir 	aRegisterLB.Show();
1665*cdf0e10cSrcweir 	aRegisterCB.SetClickHdl(LINK(this, SvxPageDescPage, RegisterModify));
1666*cdf0e10cSrcweir }
1667*cdf0e10cSrcweir 
1668*cdf0e10cSrcweir // -----------------------------------------------------------------------
1669*cdf0e10cSrcweir 
1670*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, RegisterModify, CheckBox*, pBox )
1671*cdf0e10cSrcweir {
1672*cdf0e10cSrcweir 	sal_Bool bEnable = sal_False;
1673*cdf0e10cSrcweir 	if(pBox->IsChecked())
1674*cdf0e10cSrcweir 	{
1675*cdf0e10cSrcweir 		bEnable = sal_True;
1676*cdf0e10cSrcweir 		if(USHRT_MAX == aRegisterLB.GetSelectEntryPos())
1677*cdf0e10cSrcweir 			aRegisterLB.SelectEntry(sStandardRegister);
1678*cdf0e10cSrcweir 	}
1679*cdf0e10cSrcweir 	aRegisterFT.Enable( bEnable );
1680*cdf0e10cSrcweir 	aRegisterLB.Enable( bEnable );
1681*cdf0e10cSrcweir 	return 0;
1682*cdf0e10cSrcweir }
1683*cdf0e10cSrcweir 
1684*cdf0e10cSrcweir // ----------------------------------------------------------------------------
1685*cdf0e10cSrcweir 
1686*cdf0e10cSrcweir void SvxPageDescPage::DisableVerticalPageDir()
1687*cdf0e10cSrcweir {
1688*cdf0e10cSrcweir     aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_RIGHT );
1689*cdf0e10cSrcweir     aTextFlowBox.RemoveEntryValue( FRMDIR_VERT_TOP_LEFT );
1690*cdf0e10cSrcweir     if( aTextFlowBox.GetEntryCount() < 2 )
1691*cdf0e10cSrcweir     {
1692*cdf0e10cSrcweir         aTextFlowLbl.Hide();
1693*cdf0e10cSrcweir         aTextFlowBox.Hide();
1694*cdf0e10cSrcweir         aBspWin.EnableFrameDirection( sal_False );
1695*cdf0e10cSrcweir     }
1696*cdf0e10cSrcweir }
1697*cdf0e10cSrcweir 
1698*cdf0e10cSrcweir IMPL_LINK( SvxPageDescPage, FrameDirectionModify_Impl, ListBox*,  EMPTYARG)
1699*cdf0e10cSrcweir {
1700*cdf0e10cSrcweir     aBspWin.SetFrameDirection( (sal_uInt32) aTextFlowBox.GetSelectEntryValue() );
1701*cdf0e10cSrcweir     aBspWin.Invalidate();
1702*cdf0e10cSrcweir     return 0;
1703*cdf0e10cSrcweir }
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir bool SvxPageDescPage::IsPrinterRangeOverflow(
1706*cdf0e10cSrcweir 	MetricField& rField, long nFirstMargin, long nLastMargin, MarginPosition nPos )
1707*cdf0e10cSrcweir {
1708*cdf0e10cSrcweir 	bool bRet = false;
1709*cdf0e10cSrcweir 	bool bCheck = ( ( pImpl->m_nPos & nPos ) == 0 );
1710*cdf0e10cSrcweir 	long nValue = static_cast<long>(rField.GetValue());
1711*cdf0e10cSrcweir 	if ( bCheck &&
1712*cdf0e10cSrcweir 		 (  nValue < nFirstMargin || nValue > nLastMargin ) &&
1713*cdf0e10cSrcweir 		 rField.GetText() != rField.GetSavedValue() )
1714*cdf0e10cSrcweir 	{
1715*cdf0e10cSrcweir 		rField.SetValue( nValue < nFirstMargin ? nFirstMargin : nLastMargin );
1716*cdf0e10cSrcweir  		bRet = true;
1717*cdf0e10cSrcweir 	}
1718*cdf0e10cSrcweir 
1719*cdf0e10cSrcweir 	return bRet;
1720*cdf0e10cSrcweir }
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir /** Check if a value of a margin edit is outside the printer paper margins
1723*cdf0e10cSrcweir 	and save this information.
1724*cdf0e10cSrcweir */
1725*cdf0e10cSrcweir void SvxPageDescPage::CheckMarginEdits( bool _bClear )
1726*cdf0e10cSrcweir {
1727*cdf0e10cSrcweir 	if ( _bClear )
1728*cdf0e10cSrcweir 		pImpl->m_nPos = 0;
1729*cdf0e10cSrcweir 
1730*cdf0e10cSrcweir 	sal_Int64 nValue = aLeftMarginEdit.GetValue();
1731*cdf0e10cSrcweir 	if (  nValue < nFirstLeftMargin || nValue > nLastLeftMargin )
1732*cdf0e10cSrcweir 		pImpl->m_nPos |= MARGIN_LEFT;
1733*cdf0e10cSrcweir 	nValue = aRightMarginEdit.GetValue();
1734*cdf0e10cSrcweir 	if (  nValue < nFirstRightMargin || nValue > nLastRightMargin )
1735*cdf0e10cSrcweir 		pImpl->m_nPos |= MARGIN_RIGHT;
1736*cdf0e10cSrcweir 	nValue = aTopMarginEdit.GetValue();
1737*cdf0e10cSrcweir 	if (  nValue < nFirstTopMargin || nValue > nLastTopMargin )
1738*cdf0e10cSrcweir 		pImpl->m_nPos |= MARGIN_TOP;
1739*cdf0e10cSrcweir 	nValue = aBottomMarginEdit.GetValue();
1740*cdf0e10cSrcweir 	if (  nValue < nFirstBottomMargin || nValue > nLastBottomMargin )
1741*cdf0e10cSrcweir 		pImpl->m_nPos |= MARGIN_BOTTOM;
1742*cdf0e10cSrcweir }
1743*cdf0e10cSrcweir 
1744*cdf0e10cSrcweir bool SvxPageDescPage::IsMarginOutOfRange()
1745*cdf0e10cSrcweir {
1746*cdf0e10cSrcweir 	bool bRet = ( ( ( !( pImpl->m_nPos & MARGIN_LEFT ) &&
1747*cdf0e10cSrcweir 					  ( aLeftMarginEdit.GetText() != aLeftMarginEdit.GetSavedValue() ) ) &&
1748*cdf0e10cSrcweir 					( aLeftMarginEdit.GetValue() < nFirstLeftMargin ||
1749*cdf0e10cSrcweir 					  aLeftMarginEdit.GetValue() > nLastLeftMargin ) ) ||
1750*cdf0e10cSrcweir 				  ( ( !( pImpl->m_nPos & MARGIN_RIGHT ) &&
1751*cdf0e10cSrcweir 					  ( aRightMarginEdit.GetText() != aRightMarginEdit.GetSavedValue() ) ) &&
1752*cdf0e10cSrcweir 					( aRightMarginEdit.GetValue() < nFirstRightMargin ||
1753*cdf0e10cSrcweir 					  aRightMarginEdit.GetValue() > nLastRightMargin ) ) ||
1754*cdf0e10cSrcweir 				  ( ( !( pImpl->m_nPos & MARGIN_TOP ) &&
1755*cdf0e10cSrcweir 					  ( aTopMarginEdit.GetText() != aTopMarginEdit.GetSavedValue() ) ) &&
1756*cdf0e10cSrcweir 					( aTopMarginEdit.GetValue() < nFirstTopMargin ||
1757*cdf0e10cSrcweir 					  aTopMarginEdit.GetValue() > nLastTopMargin ) ) ||
1758*cdf0e10cSrcweir 				  ( ( !( pImpl->m_nPos & MARGIN_BOTTOM ) &&
1759*cdf0e10cSrcweir 					  ( aBottomMarginEdit.GetText() != aBottomMarginEdit.GetSavedValue() ) ) &&
1760*cdf0e10cSrcweir 					( aBottomMarginEdit.GetValue() < nFirstBottomMargin ||
1761*cdf0e10cSrcweir 					  aBottomMarginEdit.GetValue() > nLastBottomMargin ) ) );
1762*cdf0e10cSrcweir 	return bRet;
1763*cdf0e10cSrcweir }
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir void SvxPageDescPage::PageCreated (SfxAllItemSet aSet) //add CHINA001
1766*cdf0e10cSrcweir {
1767*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pModeItem,SfxAllEnumItem,SID_ENUM_PAGE_MODE,sal_False);
1768*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pPaperStartItem,SfxAllEnumItem,SID_PAPER_START,sal_False);
1769*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pPaperEndItem,SfxAllEnumItem,SID_PAPER_END,sal_False);
1770*cdf0e10cSrcweir 	SFX_ITEMSET_ARG (&aSet,pCollectListItem,SfxStringListItem,SID_COLLECT_LIST,sal_False);
1771*cdf0e10cSrcweir 	if (pModeItem)
1772*cdf0e10cSrcweir 		SetMode((SvxModeType)pModeItem->GetEnumValue());
1773*cdf0e10cSrcweir 	if (pPaperStartItem && pPaperEndItem)
1774*cdf0e10cSrcweir 		SetPaperFormatRanges( (Paper)pPaperStartItem->GetEnumValue(), (Paper)pPaperEndItem->GetEnumValue() );
1775*cdf0e10cSrcweir 	if (pCollectListItem)
1776*cdf0e10cSrcweir 		SetCollectionList(pCollectListItem->GetList());
1777*cdf0e10cSrcweir }
1778