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