xref: /trunk/main/svx/source/dialog/hdft.cxx (revision 56b35d86)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_svx.hxx"
24 
25 #include <tools/shl.hxx>
26 #include <svl/itemiter.hxx>
27 #include <sfx2/app.hxx>
28 #include <sfx2/objsh.hxx>
29 #include <sfx2/module.hxx>
30 #include <vcl/msgbox.hxx>
31 #include <vcl/graph.hxx>
32 #include <sfx2/sfxsids.hrc>
33 #include <svx/svxids.hrc>
34 #include <svx/dialogs.hrc>
35 #include "hdft.hrc"
36 #include <svl/intitem.hxx>
37 #define _SVX_HDFT_CXX
38 #include <svx/hdft.hxx>
39 #include <svx/pageitem.hxx>
40 #include "svx/dlgutil.hxx"
41 #include <svx/dialmgr.hxx>
42 #include "svx/htmlmode.hxx"
43 #include <editeng/brshitem.hxx>
44 #include <editeng/lrspitem.hxx>
45 #include <editeng/ulspitem.hxx>
46 #include <editeng/shaditem.hxx>
47 #include <editeng/sizeitem.hxx>
48 #include <editeng/boxitem.hxx>
49 #include <svx/svxdlg.hxx> //CHINA001
50 #include <svx/dialogs.hrc> //CHINA001
51 
52 //UUUU
53 #include <svx/xdef.hxx>
54 #include <svx/xenum.hxx>
55 #include <svx/xfillit0.hxx>
56 #include <svx/unobrushitemhelper.hxx>
57 #include <sfx2/request.hxx>
58 
59 // static ----------------------------------------------------------------
60 
61 // --> OD 2004-06-18 #i19922#
62 //static const long MINBODY = 284;            // 0,5cm in twips aufgerundet
63 static const long MINBODY = 56;  // 1mm in twips rounded
64 
65 // default distance to Header or footer
66 static const long DEF_DIST_WRITER = 500;	// 5mm (Writer)
67 static const long DEF_DIST_CALC = 250;		// 2,5mm (Calc)
68 
69 static sal_uInt16 pRanges[] =
70 {
71 	SID_ATTR_BRUSH,			 SID_ATTR_BRUSH,
72 
73     //UUUU Support DrawingLayer FillStyles (no real call to below GetRanges()
74     // detected, still do the complete transition)
75     XATTR_FILL_FIRST,        XATTR_FILL_LAST,
76 
77 	SID_ATTR_BORDER_OUTER,	 SID_ATTR_BORDER_OUTER,
78 	SID_ATTR_BORDER_INNER,	 SID_ATTR_BORDER_INNER,
79 	SID_ATTR_BORDER_SHADOW,	 SID_ATTR_BORDER_SHADOW,
80 	SID_ATTR_LRSPACE,		 SID_ATTR_LRSPACE,
81 	SID_ATTR_ULSPACE,		 SID_ATTR_ULSPACE,
82 	SID_ATTR_PAGE_SIZE,		 SID_ATTR_PAGE_SIZE,
83 	SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_HEADERSET,
84 	SID_ATTR_PAGE_FOOTERSET, SID_ATTR_PAGE_FOOTERSET,
85 	SID_ATTR_PAGE_ON,		 SID_ATTR_PAGE_ON,
86 	SID_ATTR_PAGE_DYNAMIC,	 SID_ATTR_PAGE_DYNAMIC,
87 	SID_ATTR_PAGE_SHARED,	 SID_ATTR_PAGE_SHARED,
88     SID_ATTR_HDFT_DYNAMIC_SPACING, SID_ATTR_HDFT_DYNAMIC_SPACING,
89 	0
90 };
91 
92 /*--------------------------------------------------------------------
93 	Beschreibung:
94  --------------------------------------------------------------------*/
95 
96 // gibt den Bereich der Which-Werte zurueck
97 
98 
GetRanges()99 sal_uInt16* SvxHeaderPage::GetRanges()
100 {
101 	return pRanges;
102 }
103 
104 //------------------------------------------------------------------------
105 
Create(Window * pParent,const SfxItemSet & rSet)106 SfxTabPage* SvxHeaderPage::Create( Window* pParent, const SfxItemSet& rSet )
107 {
108 	return new SvxHeaderPage( pParent, rSet );
109 }
110 
111 //------------------------------------------------------------------------
112 
GetRanges()113 sal_uInt16* SvxFooterPage::GetRanges()
114 {
115 	return pRanges;
116 }
117 
118 // -----------------------------------------------------------------------
119 
Create(Window * pParent,const SfxItemSet & rSet)120 SfxTabPage* SvxFooterPage::Create( Window* pParent, const SfxItemSet& rSet )
121 {
122 	return new SvxFooterPage( pParent, rSet );
123 }
124 
125 // -----------------------------------------------------------------------
126 
SvxHeaderPage(Window * pParent,const SfxItemSet & rAttr)127 SvxHeaderPage::SvxHeaderPage( Window* pParent, const SfxItemSet& rAttr ) :
128 
129 	SvxHFPage( pParent, RID_SVXPAGE_HEADER, rAttr, SID_ATTR_PAGE_HEADERSET )
130 
131 {
132 }
133 
134 // -----------------------------------------------------------------------
135 
SvxFooterPage(Window * pParent,const SfxItemSet & rAttr)136 SvxFooterPage::SvxFooterPage( Window* pParent, const SfxItemSet& rAttr ) :
137 
138 	SvxHFPage( pParent, RID_SVXPAGE_FOOTER, rAttr, SID_ATTR_PAGE_FOOTERSET )
139 
140 {
141 }
142 
143 // -----------------------------------------------------------------------
144 
SvxHFPage(Window * pParent,sal_uInt16 nResId,const SfxItemSet & rAttr,sal_uInt16 nSetId)145 SvxHFPage::SvxHFPage( Window* pParent, sal_uInt16 nResId, const SfxItemSet& rAttr, sal_uInt16 nSetId )
146 :   SfxTabPage( pParent, SVX_RES( nResId ), rAttr ),
147 
148     aFrm            ( this, SVX_RES( FL_FRAME ) ),
149 	aTurnOnBox		( this, SVX_RES( CB_TURNON ) ),
150     aCntSharedBox   ( this, SVX_RES( CB_SHARED ) ),
151     aLMLbl          ( this, SVX_RES( FT_LMARGIN ) ),
152     aLMEdit         ( this, SVX_RES( ED_LMARGIN ) ),
153     aRMLbl          ( this, SVX_RES( FT_RMARGIN ) ),
154     aRMEdit         ( this, SVX_RES( ED_RMARGIN ) ),
155     aDistFT         ( this, SVX_RES( FT_DIST ) ),
156 	aDistEdit		( this, SVX_RES( ED_DIST ) ),
157     aDynSpacingCB   ( this, SVX_RES( CB_DYNSPACING ) ),
158     aHeightFT       ( this, SVX_RES( FT_HEIGHT ) ),
159 	aHeightEdit		( this, SVX_RES( ED_HEIGHT ) ),
160 	aHeightDynBtn	( this, SVX_RES( CB_HEIGHT_DYN ) ),
161 	aBspWin			( this, SVX_RES( WN_BSP ) ),
162 	aBackgroundBtn	( this, SVX_RES( BTN_EXTRAS ) ),
163 
164     nId             ( nSetId ),
165     pBBSet          ( NULL ),
166 
167     // bitfield
168     mbDisableQueryBox(false),
169     mbEnableBackgroundSelector(true),
170     mbEnableDrawingLayerFillStyles(false)
171 {
172 	InitHandler();
173     aBspWin.EnableRTL( sal_False );
174 
175 	// diese Page braucht ExchangeSupport
176 	SetExchangeSupport();
177 
178 	FreeResource();
179 
180 	// Metrik einstellen
181 	FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
182 	SetFieldUnit( aDistEdit, eFUnit );
183 	SetFieldUnit( aHeightEdit, eFUnit );
184 	SetFieldUnit( aLMEdit, eFUnit );
185 	SetFieldUnit( aRMEdit, eFUnit );
186 
187 	aTurnOnBox.SetAccessibleRelationMemberOf( &aFrm );
188 	aCntSharedBox.SetAccessibleRelationMemberOf( &aFrm );
189 	aLMLbl.SetAccessibleRelationMemberOf( &aFrm );
190 	aLMEdit.SetAccessibleRelationMemberOf( &aFrm );
191 	aRMLbl.SetAccessibleRelationMemberOf( &aFrm );
192 	aRMEdit.SetAccessibleRelationMemberOf( &aFrm );
193 	aDistFT.SetAccessibleRelationMemberOf( &aFrm );
194 	aDistEdit.SetAccessibleRelationMemberOf( &aFrm );
195 	aDynSpacingCB.SetAccessibleRelationMemberOf( &aFrm );
196 	aHeightFT.SetAccessibleRelationMemberOf( &aFrm );
197 	aHeightEdit.SetAccessibleRelationMemberOf( &aFrm );
198 	aHeightDynBtn.SetAccessibleRelationMemberOf( &aFrm );
199 	aBackgroundBtn.SetAccessibleRelationMemberOf(&aFrm);
200 }
201 
202 // -----------------------------------------------------------------------
203 
~SvxHFPage()204 SvxHFPage::~SvxHFPage()
205 {
206 	delete pBBSet;
207 }
208 
209 // -----------------------------------------------------------------------
210 
FillItemSet(SfxItemSet & rSet)211 sal_Bool SvxHFPage::FillItemSet( SfxItemSet& rSet )
212 {
213     const sal_uInt16 nWSize = GetWhich(SID_ATTR_PAGE_SIZE);
214     const sal_uInt16 nWLRSpace = GetWhich(SID_ATTR_LRSPACE);
215     const sal_uInt16 nWULSpace = GetWhich(SID_ATTR_ULSPACE);
216     const sal_uInt16 nWOn = GetWhich(SID_ATTR_PAGE_ON);
217     const sal_uInt16 nWDynamic = GetWhich(SID_ATTR_PAGE_DYNAMIC);
218     const sal_uInt16 nWDynSpacing = GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING);
219     const sal_uInt16 nWShared = GetWhich(SID_ATTR_PAGE_SHARED);
220     const sal_uInt16 nWBrush = GetWhich(SID_ATTR_BRUSH);
221     const sal_uInt16 nWBox = GetWhich(SID_ATTR_BORDER_OUTER);
222     const sal_uInt16 nWBoxInfo = GetWhich(SID_ATTR_BORDER_INNER);
223     const sal_uInt16 nWShadow = GetWhich(SID_ATTR_BORDER_SHADOW);
224 
225     const sal_uInt16 aWhichTab[] = {
226         nWSize, nWSize,
227         nWLRSpace, nWLRSpace,
228         nWULSpace, nWULSpace,
229         nWOn, nWOn,
230         nWDynamic, nWDynamic,
231         nWShared, nWShared,
232         nWBrush, nWBrush,
233         nWBoxInfo, nWBoxInfo,
234         nWBox, nWBox,
235         nWShadow, nWShadow,
236         nWDynSpacing, nWDynSpacing,
237 
238         //UUUU take over DrawingLayer FillStyles
239         XATTR_FILL_FIRST, XATTR_FILL_LAST,                // [1014
240 
241         0, 0};
242 
243     const SfxItemSet& rOldSet = GetItemSet();
244     SfxItemPool* pPool = rOldSet.GetPool();
245     DBG_ASSERT(pPool,"no pool :-(");
246     SfxMapUnit eUnit = pPool->GetMetric(nWSize);
247     SfxItemSet aSet(*pPool,aWhichTab);
248 
249     if(mbEnableDrawingLayerFillStyles)
250     {
251         //UUUU When using the XATTR_FILLSTYLE DrawingLayer FillStyle definition
252         // extra action has to be done here since the pool default is XFILL_SOLID
253         // instead of XFILL_NONE (to have the default blue fill color at start).
254         aSet.Put(XFillStyleItem(XFILL_NONE));
255     }
256 
257 	//--------------------------------------------------------------------
258 
259 	aSet.Put( SfxBoolItem( nWOn,	  aTurnOnBox.IsChecked() ) );
260 	aSet.Put( SfxBoolItem( nWDynamic, aHeightDynBtn.IsChecked() ) );
261 	aSet.Put( SfxBoolItem( nWShared,  aCntSharedBox.IsChecked() ) );
262     if(aDynSpacingCB.IsVisible() && SFX_WHICH_MAX > nWDynSpacing)
263     {
264         SfxBoolItem* pBoolItem = (SfxBoolItem*)pPool->GetDefaultItem(nWDynSpacing).Clone();
265         pBoolItem->SetValue(aDynSpacingCB.IsChecked());
266         aSet.Put(*pBoolItem);
267         delete pBoolItem;
268     }
269 
270 	// Groesse
271 	SvxSizeItem aSizeItem( (const SvxSizeItem&)rOldSet.Get( nWSize ) );
272 	Size		aSize( aSizeItem.GetSize() );
273 	long		nDist = GetCoreValue( aDistEdit, eUnit );
274 	long		nH	  = GetCoreValue( aHeightEdit, eUnit );
275 
276 	// fixe Hoehe?
277 //	if ( !aHeightDynBtn.IsChecked() )
278 		nH += nDist; // dann Abstand dazu addieren
279 	aSize.Height() = nH;
280 	aSizeItem.SetSize( aSize );
281 	aSet.Put( aSizeItem );
282 
283 	// Raender
284 	SvxLRSpaceItem aLR( nWLRSpace );
285 	aLR.SetLeft( (sal_uInt16)GetCoreValue( aLMEdit, eUnit ) );
286 	aLR.SetRight( (sal_uInt16)GetCoreValue( aRMEdit, eUnit ) );
287 	aSet.Put( aLR );
288 
289 	SvxULSpaceItem aUL( nWULSpace );
290 	if ( nId == SID_ATTR_PAGE_HEADERSET )
291 		aUL.SetLower( (sal_uInt16)nDist );
292 	else
293 		aUL.SetUpper( (sal_uInt16)nDist );
294 	aSet.Put( aUL );
295 
296     // Hintergrund und Umrandung?
297     if(pBBSet)
298     {
299         aSet.Put(*pBBSet);
300     }
301     else
302     {
303         const SfxItemSet* _pSet;
304         const SfxPoolItem* pItem;
305 
306         if(SFX_ITEM_SET == GetItemSet().GetItemState(GetWhich(nId), sal_False, &pItem))
307         {
308             _pSet = &(static_cast< const SvxSetItem* >(pItem)->GetItemSet());
309 
310             if(_pSet->GetItemState(nWBrush) == SFX_ITEM_SET)
311             {
312                 aSet.Put(_pSet->Get(nWBrush));
313             }
314 
315             if(_pSet->GetItemState(nWBoxInfo) == SFX_ITEM_SET)
316             {
317                 aSet.Put(_pSet->Get(nWBoxInfo));
318             }
319 
320             if(_pSet->GetItemState(nWBox) == SFX_ITEM_SET)
321             {
322                 aSet.Put(_pSet->Get(nWBox));
323             }
324 
325             if(_pSet->GetItemState(nWShadow) == SFX_ITEM_SET)
326             {
327                 aSet.Put(_pSet->Get(nWShadow));
328             }
329 
330             //UUUU take care of [XATTR_XATTR_FILL_FIRST .. XATTR_FILL_LAST]
331             for(sal_uInt16 nFillStyleId(XATTR_FILL_FIRST); nFillStyleId <= XATTR_FILL_LAST; nFillStyleId++)
332             {
333                 if(_pSet->GetItemState(nFillStyleId) == SFX_ITEM_SET)
334                 {
335                     aSet.Put(_pSet->Get(nFillStyleId));
336                 }
337             }
338         }
339     }
340 
341 	// Das SetItem wegschreiben
342 	SvxSetItem aSetItem( GetWhich( nId ), aSet );
343 	rSet.Put( aSetItem );
344 
345 	return sal_True;
346 }
347 
348 // -----------------------------------------------------------------------
Reset(const SfxItemSet & rSet)349 void SvxHFPage::Reset( const SfxItemSet& rSet )
350 {
351 	ActivatePage( rSet );
352 	ResetBackground_Impl( rSet );
353 
354 	SfxItemPool* pPool = GetItemSet().GetPool();
355 	DBG_ASSERT( pPool, "Wo ist der Pool" );
356 	SfxMapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_PAGE_SIZE ) );
357 
358 	// Kopf-/Fusszeilen-Attribute auswerten
359 	//
360 	const SvxSetItem* pSetItem = 0;
361 
362 	if ( SFX_ITEM_SET == rSet.GetItemState( GetWhich(nId), sal_False,
363 											(const SfxPoolItem**)&pSetItem ) )
364 	{
365 		const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
366 		const SfxBoolItem& rHeaderOn =
367 			(const SfxBoolItem&)rHeaderSet.Get(GetWhich(SID_ATTR_PAGE_ON));
368 
369 		aTurnOnBox.Check(rHeaderOn.GetValue());
370 
371 		if ( rHeaderOn.GetValue() )
372 		{
373 			const SfxBoolItem& rDynamic =
374 				(const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_DYNAMIC ) );
375 			const SfxBoolItem& rShared =
376 				(const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SHARED ) );
377 			const SvxSizeItem& rSize =
378 				(const SvxSizeItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
379 			const SvxULSpaceItem& rUL =
380 				(const SvxULSpaceItem&)rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
381 			const SvxLRSpaceItem& rLR =
382 				(const SvxLRSpaceItem&)rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
383             if(aDynSpacingCB.IsVisible())
384             {
385                 const SfxBoolItem& rDynSpacing =
386                     (const SfxBoolItem&)rHeaderSet.Get(GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING));
387                 aDynSpacingCB.Check(rDynSpacing.GetValue());
388             }
389 
390 
391             if ( nId == SID_ATTR_PAGE_HEADERSET )
392 			{	// Kopfzeile
393 				SetMetricValue( aDistEdit, rUL.GetLower(), eUnit );
394 				SetMetricValue( aHeightEdit, rSize.GetSize().Height() - rUL.GetLower(), eUnit );
395 			}
396 			else
397 			{	// Fusszeile
398 				SetMetricValue( aDistEdit, rUL.GetUpper(), eUnit );
399 				SetMetricValue( aHeightEdit, rSize.GetSize().Height() - rUL.GetUpper(), eUnit );
400 			}
401 
402 			aHeightDynBtn.Check(rDynamic.GetValue());
403 			SetMetricValue( aLMEdit, rLR.GetLeft(), eUnit );
404 			SetMetricValue( aRMEdit, rLR.GetRight(), eUnit );
405 			aCntSharedBox.Check(rShared.GetValue());
406 		}
407 		else
408 			pSetItem = 0;
409 	}
410 	else
411 	{
412 		// defaults for distance and height
413 		long nDefaultDist = DEF_DIST_WRITER;
414 		const SfxPoolItem* pExt1 = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
415 		const SfxPoolItem* pExt2 = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
416 
417 		if ( pExt1 && pExt1->ISA(SfxBoolItem) && pExt2 && pExt2->ISA(SfxBoolItem) )
418 			nDefaultDist = DEF_DIST_CALC;
419 
420 		SetMetricValue( aDistEdit, nDefaultDist, SFX_MAPUNIT_100TH_MM );
421 		SetMetricValue( aHeightEdit, 500, SFX_MAPUNIT_100TH_MM );
422 	}
423 
424 	if ( !pSetItem )
425 	{
426 		aTurnOnBox.Check( sal_False );
427 		aHeightDynBtn.Check( sal_True );
428 		aCntSharedBox.Check( sal_True );
429 	}
430 
431 	TurnOnHdl(0);
432 
433 	aTurnOnBox.SaveValue();
434 	aDistEdit.SaveValue();
435 	aHeightEdit.SaveValue();
436 	aHeightDynBtn.SaveValue();
437 	aLMEdit.SaveValue();
438 	aRMEdit.SaveValue();
439 	aCntSharedBox.SaveValue();
440 	RangeHdl( 0 );
441 
442 	sal_uInt16 nHtmlMode = 0;
443 	const SfxPoolItem* pItem = 0;
444 	SfxObjectShell* pShell;
445 	if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem) ||
446 		( 0 != (pShell = SfxObjectShell::Current()) &&
447 					0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
448 	{
449 		nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
450 		if(nHtmlMode & HTMLMODE_ON)
451 		{
452 			aCntSharedBox.Hide();
453 			aBackgroundBtn.Hide();
454 		}
455 	}
456 
457 }
458 
459 /*--------------------------------------------------------------------
460 	Beschreibung:	Handler initialisieren
461  --------------------------------------------------------------------*/
462 
InitHandler()463 void SvxHFPage::InitHandler()
464 {
465 	aTurnOnBox.SetClickHdl(LINK(this, 	SvxHFPage, TurnOnHdl));
466 	aDistEdit.SetModifyHdl(LINK(this, 	SvxHFPage, DistModify));
467 	aDistEdit.SetLoseFocusHdl(LINK(this, SvxHFPage, RangeHdl));
468 
469 	aHeightEdit.SetModifyHdl(LINK(this, 	SvxHFPage, HeightModify));
470 	aHeightEdit.SetLoseFocusHdl(LINK(this,SvxHFPage,RangeHdl));
471 
472 	aLMEdit.SetModifyHdl(LINK(this, 		SvxHFPage, BorderModify));
473 	aLMEdit.SetLoseFocusHdl(LINK(this,	SvxHFPage, RangeHdl));
474 	aRMEdit.SetModifyHdl(LINK(this, 		SvxHFPage, BorderModify));
475 	aRMEdit.SetLoseFocusHdl(LINK(this,	SvxHFPage, RangeHdl));
476 	aBackgroundBtn.SetClickHdl(LINK(this,SvxHFPage, BackgroundHdl));
477 }
478 
479 /*--------------------------------------------------------------------
480 	Beschreibung:	Ein/aus
481  --------------------------------------------------------------------*/
482 
IMPL_LINK(SvxHFPage,TurnOnHdl,CheckBox *,pBox)483 IMPL_LINK( SvxHFPage, TurnOnHdl, CheckBox *, pBox )
484 {
485 	if ( aTurnOnBox.IsChecked() )
486 	{
487 		aDistFT.Enable();
488 		aDistEdit.Enable();
489         aDynSpacingCB.Enable();
490 		aHeightFT.Enable();
491 		aHeightEdit.Enable();
492 		aHeightDynBtn.Enable();
493 		aLMLbl.Enable();
494 		aLMEdit.Enable();
495 		aRMLbl.Enable();
496 		aRMEdit.Enable();
497 
498 		sal_uInt16 nUsage = aBspWin.GetUsage();
499 
500 		if( nUsage == SVX_PAGE_RIGHT || nUsage == SVX_PAGE_LEFT )
501 			aCntSharedBox.Disable();
502 		else
503 			aCntSharedBox.Enable();
504 		aBackgroundBtn.Enable();
505 	}
506 	else
507 	{
508 		sal_Bool bDelete = sal_True;
509 
510 		if ( !mbDisableQueryBox && pBox && aTurnOnBox.GetSavedValue() == sal_True )
511 			bDelete = ( QueryBox( this, SVX_RES( RID_SVXQBX_DELETE_HEADFOOT ) ).Execute() == RET_YES );
512 
513 		if ( bDelete )
514 		{
515 			aDistFT.Disable();
516 			aDistEdit.Disable();
517             aDynSpacingCB.Enable(sal_False);
518             aHeightFT.Disable();
519 			aHeightEdit.Disable();
520 			aHeightDynBtn.Disable();
521 
522 			aLMLbl.Disable();
523 			aLMEdit.Disable();
524 			aRMLbl.Disable();
525 			aRMEdit.Disable();
526 
527 			aCntSharedBox.Disable();
528 			aBackgroundBtn.Disable();
529 		}
530 		else
531 			aTurnOnBox.Check();
532 	}
533 	UpdateExample();
534 	return 0;
535 }
536 
537 /*--------------------------------------------------------------------
538 	Beschreibung:	Abstand im Bsp Modifizieren
539  --------------------------------------------------------------------*/
540 
IMPL_LINK_INLINE_START(SvxHFPage,DistModify,MetricField *,EMPTYARG)541 IMPL_LINK_INLINE_START( SvxHFPage, DistModify, MetricField *, EMPTYARG )
542 {
543 	UpdateExample();
544 	return 0;
545 }
IMPL_LINK_INLINE_END(SvxHFPage,DistModify,MetricField *,EMPTYARG)546 IMPL_LINK_INLINE_END( SvxHFPage, DistModify, MetricField *, EMPTYARG )
547 
548 IMPL_LINK_INLINE_START( SvxHFPage, HeightModify, MetricField *, EMPTYARG )
549 {
550 	UpdateExample();
551 
552 	return 0;
553 }
IMPL_LINK_INLINE_END(SvxHFPage,HeightModify,MetricField *,EMPTYARG)554 IMPL_LINK_INLINE_END( SvxHFPage, HeightModify, MetricField *, EMPTYARG )
555 
556 /*--------------------------------------------------------------------
557 	Beschreibung: Raender einstellen
558  --------------------------------------------------------------------*/
559 
560 IMPL_LINK_INLINE_START( SvxHFPage, BorderModify, MetricField *, EMPTYARG )
561 {
562 	UpdateExample();
563 	return 0;
564 }
IMPL_LINK_INLINE_END(SvxHFPage,BorderModify,MetricField *,EMPTYARG)565 IMPL_LINK_INLINE_END( SvxHFPage, BorderModify, MetricField *, EMPTYARG )
566 
567 /*--------------------------------------------------------------------
568 	Beschreibung:	Hintergrund
569  --------------------------------------------------------------------*/
570 
571 IMPL_LINK( SvxHFPage, BackgroundHdl, Button *, EMPTYARG )
572 {
573     if(!pBBSet)
574     {
575         // nur die n"otigen Items f"uer Umrandung und Hintergrund benutzen
576         const sal_uInt16 nOuter(GetWhich(SID_ATTR_BORDER_OUTER));
577         const sal_uInt16 nInner(GetWhich(SID_ATTR_BORDER_INNER, sal_False));
578         const sal_uInt16 nShadow(GetWhich(SID_ATTR_BORDER_SHADOW));
579 
580         if(mbEnableDrawingLayerFillStyles)
581         {
582             pBBSet = new SfxItemSet(
583                 *GetItemSet().GetPool(),
584                 XATTR_FILL_FIRST, XATTR_FILL_LAST,  // DrawingLayer FillStyle definitions
585                 SID_COLOR_TABLE, SID_BITMAP_LIST,   // XPropertyLists for Color, Gradient, Hatch and Graphic fills
586                 nOuter, nOuter,
587                 nInner, nInner,
588                 nShadow, nShadow,
589                 0, 0);
590 
591             //UUUU copy items for XPropertyList entries from the DrawModel so that
592             // the Area TabPage can access them
593             static const sal_uInt16 nCopyFlags[] = {
594                 SID_COLOR_TABLE,
595                 SID_GRADIENT_LIST,
596                 SID_HATCH_LIST,
597                 SID_BITMAP_LIST,
598                 0
599             };
600 
601             for(sal_uInt16 a(0); nCopyFlags[a]; a++)
602             {
603                 const SfxPoolItem* pItem = GetItemSet().GetItem(nCopyFlags[a]);
604 
605                 if(pItem)
606                 {
607                     pBBSet->Put(*pItem);
608                 }
609                 else
610                 {
611                     OSL_ENSURE(false, "XPropertyList missing (!)");
612                 }
613             }
614         }
615         else
616         {
617             const sal_uInt16 nBrush(GetWhich(SID_ATTR_BRUSH));
618 
619             pBBSet = new SfxItemSet(
620                 *GetItemSet().GetPool(),
621                 nBrush, nBrush,
622                 nOuter, nOuter,
623                 nInner, nInner,
624                 nShadow, nShadow,
625                 0, 0);
626         }
627 
628         const SfxPoolItem* pItem;
629 
630         if(SFX_ITEM_SET == GetItemSet().GetItemState(GetWhich(nId), sal_False, &pItem))
631         {
632             // If a SfxItemSet from the SetItem for SID_ATTR_PAGE_HEADERSET or
633             // SID_ATTR_PAGE_FOOTERSET exists, use it's content
634             pBBSet->Put(((SvxSetItem*)pItem)->GetItemSet());
635         }
636         else
637         {
638             if(mbEnableDrawingLayerFillStyles)
639             {
640                 //UUUU The style for header/footer is not yet created, need to reset
641                 // XFillStyleItem to XFILL_NONE which is the same as in the style
642                 // initialization. This needs to be done since the pool default for
643                 // XFillStyleItem is XFILL_SOLID
644                 pBBSet->Put(XFillStyleItem(XFILL_NONE));
645             }
646         }
647 
648         if(SFX_ITEM_SET == GetItemSet().GetItemState(nInner, sal_False, &pItem))
649         {
650             // das gesetze InfoItem wird immer ben"otigt
651             pBBSet->Put(*pItem);
652         }
653     }
654 
655     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
656 
657     if(pFact)
658     {
659         //UUUU
660         SfxAbstractTabDialog* pDlg = pFact->CreateSvxBorderBackgroundDlg(
661             this,
662             *pBBSet,
663             mbEnableBackgroundSelector,
664             mbEnableDrawingLayerFillStyles);
665 
666         DBG_ASSERT(pDlg,"Dialogdiet fail!");//CHINA001
667         if(RET_OK == pDlg->Execute() && pDlg->GetOutputItemSet())
668         {
669             SfxItemIter aIter(*pDlg->GetOutputItemSet());
670             const SfxPoolItem* pItem = aIter.FirstItem();
671 
672             while(pItem)
673             {
674                 if(!IsInvalidItem(pItem))
675                 {
676                     pBBSet->Put(*pItem);
677                 }
678 
679                 pItem = aIter.NextItem();
680             }
681 
682             //----------------------------------------------------------------
683             {
684                 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes;
685 
686                 if(mbEnableDrawingLayerFillStyles)
687                 {
688                     //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
689                     aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(*pBBSet));
690                 }
691                 else
692                 {
693                     const sal_uInt16 nWhich = GetWhich(SID_ATTR_BRUSH);
694 
695                     if(pBBSet->GetItemState(nWhich) == SFX_ITEM_SET)
696                     {
697                         //UUUU create FillAttributes from SvxBrushItem
698                         const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(pBBSet->Get(nWhich));
699                         SfxItemSet aTempSet(*pBBSet->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
700 
701                         setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
702                         aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
703                     }
704                 }
705 
706                 if(SID_ATTR_PAGE_HEADERSET == nId)
707                 {
708                     //aBspWin.SetHdColor(rItem.GetColor());
709                     aBspWin.setHeaderFillAttributes(aFillAttributes);
710                 }
711                 else
712                 {
713                     //aBspWin.SetFtColor(rItem.GetColor());
714                     aBspWin.setFooterFillAttributes(aFillAttributes);
715                 }
716             }
717 
718             //----------------------------------------------------------------
719             {
720                 const sal_uInt16 nWhich = GetWhich(SID_ATTR_BORDER_OUTER);
721 
722                 if(pBBSet->GetItemState(nWhich) == SFX_ITEM_SET)
723                 {
724                     const SvxBoxItem& rItem = (const SvxBoxItem&)pBBSet->Get(nWhich);
725 
726                     if(nId == SID_ATTR_PAGE_HEADERSET)
727                         aBspWin.SetHdBorder(rItem);
728                     else
729                         aBspWin.SetFtBorder(rItem);
730                 }
731             }
732 
733             UpdateExample();
734         }
735         delete pDlg;
736     }
737     return 0;
738 }
739 
740 /*--------------------------------------------------------------------
741 	Beschreibung:	Bsp
742  --------------------------------------------------------------------*/
743 
UpdateExample()744 void SvxHFPage::UpdateExample()
745 {
746 	if ( nId == SID_ATTR_PAGE_HEADERSET )
747 	{
748 		aBspWin.SetHeader( aTurnOnBox.IsChecked() );
749 		aBspWin.SetHdHeight( GetCoreValue( aHeightEdit, SFX_MAPUNIT_TWIP ) );
750 		aBspWin.SetHdDist( GetCoreValue( aDistEdit, SFX_MAPUNIT_TWIP ) );
751 		aBspWin.SetHdLeft( GetCoreValue( aLMEdit, SFX_MAPUNIT_TWIP ) );
752 		aBspWin.SetHdRight( GetCoreValue( aRMEdit, SFX_MAPUNIT_TWIP ) );
753 	}
754 	else
755 	{
756 		aBspWin.SetFooter( aTurnOnBox.IsChecked() );
757 		aBspWin.SetFtHeight( GetCoreValue( aHeightEdit, SFX_MAPUNIT_TWIP ) );
758 		aBspWin.SetFtDist( GetCoreValue( aDistEdit, SFX_MAPUNIT_TWIP ) );
759 		aBspWin.SetFtLeft( GetCoreValue( aLMEdit, SFX_MAPUNIT_TWIP ) );
760 		aBspWin.SetFtRight( GetCoreValue( aRMEdit, SFX_MAPUNIT_TWIP ) );
761 	}
762 	aBspWin.Invalidate();
763 }
764 
765 /*--------------------------------------------------------------------
766 	Beschreibung: Hintergrund im Beispiel setzen
767  --------------------------------------------------------------------*/
768 
ResetBackground_Impl(const SfxItemSet & rSet)769 void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet )
770 {
771     sal_uInt16 nWhich(GetWhich(SID_ATTR_PAGE_HEADERSET));
772 
773     if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False))
774     {
775         const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, sal_False));
776         const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
777         const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
778 
779         if(rOn.GetValue())
780         {
781             drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes;
782 
783             if(mbEnableDrawingLayerFillStyles)
784             {
785                 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
786                 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet));
787             }
788             else
789             {
790                 nWhich = GetWhich(SID_ATTR_BRUSH);
791 
792                 if(SFX_ITEM_SET == rTmpSet.GetItemState(nWhich))
793                 {
794                     //UUUU create FillAttributes from SvxBrushItem
795                     const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
796                     SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
797 
798                     setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
799                     aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
800                 }
801             }
802 
803             aBspWin.setHeaderFillAttributes(aHeaderFillAttributes);
804             nWhich = GetWhich(SID_ATTR_BORDER_OUTER);
805 
806             if(rTmpSet.GetItemState(nWhich) == SFX_ITEM_SET)
807             {
808                 const SvxBoxItem& rItem =
809                     (const SvxBoxItem&)rTmpSet.Get(nWhich);
810                 aBspWin.SetHdBorder(rItem);
811             }
812         }
813     }
814 
815     nWhich = GetWhich(SID_ATTR_PAGE_FOOTERSET);
816 
817     if(SFX_ITEM_SET == rSet.GetItemState(nWhich, sal_False))
818     {
819         const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, sal_False));
820         const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
821         const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
822 
823         if(rOn.GetValue())
824         {
825             drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes;
826 
827             if(mbEnableDrawingLayerFillStyles)
828             {
829                 //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
830                 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet));
831             }
832             else
833             {
834                 nWhich = GetWhich(SID_ATTR_BRUSH);
835 
836                 if(SFX_ITEM_SET == rTmpSet.GetItemState(nWhich))
837                 {
838                     //UUUU create FillAttributes from SvxBrushItem
839                     const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
840                     SfxItemSet aTempSet(*rTmpSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
841 
842                     setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
843                     aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
844                 }
845             }
846 
847             aBspWin.setFooterFillAttributes(aFooterFillAttributes);
848             nWhich = GetWhich(SID_ATTR_BORDER_OUTER);
849 
850             if(rTmpSet.GetItemState(nWhich) == SFX_ITEM_SET)
851             {
852                 const SvxBoxItem& rItem = static_cast< const SvxBoxItem& >(rTmpSet.Get(nWhich));
853                 aBspWin.SetFtBorder(rItem);
854             }
855         }
856     }
857 
858     drawinglayer::attribute::SdrAllFillAttributesHelperPtr aPageFillAttributes;
859 
860     if(mbEnableDrawingLayerFillStyles)
861     {
862         //UUUU create FillAttributes directly from DrawingLayer FillStyle entries
863         aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rSet));
864     }
865     else
866     {
867         nWhich = GetWhich(SID_ATTR_BRUSH);
868 
869         if(rSet.GetItemState(nWhich) >= SFX_ITEM_AVAILABLE)
870         {
871             //UUUU create FillAttributes from SvxBrushItem
872             const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rSet.Get(nWhich));
873             SfxItemSet aTempSet(*rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
874 
875             setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
876             aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
877         }
878     }
879 
880     aBspWin.setPageFillAttributes(aPageFillAttributes);
881     nWhich = GetWhich(SID_ATTR_BORDER_OUTER);
882 
883     if(rSet.GetItemState(nWhich) >= SFX_ITEM_AVAILABLE)
884     {
885         const SvxBoxItem& rItem = static_cast< const SvxBoxItem& >(rSet.Get(nWhich));
886         aBspWin.SetBorder(rItem);
887     }
888 }
889 
890 /*--------------------------------------------------------------------
891 	Beschreibung:
892  --------------------------------------------------------------------*/
893 
ActivatePage(const SfxItemSet & rSet)894 void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
895 {
896 	const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_LRSPACE );
897 
898 	if ( pItem )
899 	{
900 		// linken und rechten Rand einstellen
901 		const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)*pItem;
902 
903 		aBspWin.SetLeft( rLRSpace.GetLeft() );
904 		aBspWin.SetRight( rLRSpace.GetRight() );
905 	}
906 	else
907 	{
908 		aBspWin.SetLeft( 0 );
909 		aBspWin.SetRight( 0 );
910 	}
911 
912 	pItem = GetItem( rSet, SID_ATTR_ULSPACE );
913 
914 	if ( pItem )
915 	{
916 		// oberen und unteren Rand einstellen
917 		const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)*pItem;
918 
919 		aBspWin.SetTop( rULSpace.GetUpper() );
920 		aBspWin.SetBottom( rULSpace.GetLower() );
921 	}
922 	else
923 	{
924 		aBspWin.SetTop( 0 );
925 		aBspWin.SetBottom( 0 );
926 	}
927 
928 	sal_uInt16 nUsage = SVX_PAGE_ALL;
929 	pItem = GetItem( rSet, SID_ATTR_PAGE );
930 
931 	if ( pItem )
932 		nUsage = ( (const SvxPageItem*)pItem )->GetPageUsage();
933 
934 	aBspWin.SetUsage( nUsage );
935 
936 	if ( SVX_PAGE_RIGHT == nUsage || SVX_PAGE_LEFT == nUsage )
937 		aCntSharedBox.Disable();
938 	else
939 		aCntSharedBox.Enable();
940 	pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
941 
942 	if ( pItem )
943 	{
944 		// Orientation und Size aus dem PageItem
945 		const SvxSizeItem& rSize = (const SvxSizeItem&)*pItem;
946 		// die Groesse ist ggf. schon geswappt (Querformat)
947 		aBspWin.SetSize( rSize.GetSize() );
948 	}
949 
950 	// Kopfzeilen-Attribute auswerten
951 	const SvxSetItem* pSetItem = 0;
952 
953 	if ( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
954 											sal_False,
955 											(const SfxPoolItem**)&pSetItem ) )
956 	{
957 		const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
958 		const SfxBoolItem& rHeaderOn =
959 			(const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
960 
961 		if ( rHeaderOn.GetValue() )
962 		{
963 			const SvxSizeItem& rSize = (const SvxSizeItem&)
964 				rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
965 			const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
966 				rHeaderSet.Get( GetWhich(SID_ATTR_ULSPACE ) );
967 			const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
968 				rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
969 			long nDist = rUL.GetLower();
970 
971 			aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist );
972 			aBspWin.SetHdDist( nDist );
973 			aBspWin.SetHdLeft( rLR.GetLeft() );
974 			aBspWin.SetHdRight( rLR.GetRight() );
975 			aBspWin.SetHeader( sal_True );
976 		}
977 		else
978 			pSetItem = 0;
979 	}
980 
981 	if ( !pSetItem )
982 	{
983 		aBspWin.SetHeader( sal_False );
984 
985 		if ( SID_ATTR_PAGE_HEADERSET == nId )
986 			aCntSharedBox.Disable();
987 	}
988 	pSetItem = 0;
989 
990 	if ( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
991 											sal_False,
992 											(const SfxPoolItem**)&pSetItem ) )
993 	{
994 		const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
995 		const SfxBoolItem& rFooterOn =
996 			(const SfxBoolItem&)rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
997 
998 		if ( rFooterOn.GetValue() )
999 		{
1000 			const SvxSizeItem& rSize = (const SvxSizeItem&)
1001 				rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
1002 			const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
1003 				rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
1004 			const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
1005 				rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
1006 			long nDist = rUL.GetUpper();
1007 
1008 			aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist );
1009 			aBspWin.SetFtDist( nDist );
1010 			aBspWin.SetFtLeft( rLR.GetLeft() );
1011 			aBspWin.SetFtRight( rLR.GetRight() );
1012 			aBspWin.SetFooter( sal_True );
1013 		}
1014 		else
1015 			pSetItem = 0;
1016 	}
1017 
1018 	if ( !pSetItem )
1019 	{
1020 		aBspWin.SetFooter( sal_False );
1021 
1022 		if ( SID_ATTR_PAGE_FOOTERSET == nId )
1023 			aCntSharedBox.Disable();
1024 	}
1025 
1026 	pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
1027 
1028 	if ( pItem && pItem->ISA(SfxBoolItem) )
1029 	{
1030 		aBspWin.SetTable( sal_True );
1031 		aBspWin.SetHorz( ( (SfxBoolItem*)pItem )->GetValue() );
1032 	}
1033 
1034 	pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
1035 
1036 	if ( pItem && pItem->ISA(SfxBoolItem) )
1037 	{
1038 		aBspWin.SetTable( sal_True );
1039 		aBspWin.SetVert( ( (SfxBoolItem*)pItem )->GetValue() );
1040 	}
1041 	ResetBackground_Impl( rSet );
1042 	RangeHdl( 0 );
1043 }
1044 
1045 /*--------------------------------------------------------------------
1046 	Beschreibung:
1047  --------------------------------------------------------------------*/
1048 
DeactivatePage(SfxItemSet * _pSet)1049 int SvxHFPage::DeactivatePage( SfxItemSet* _pSet )
1050 {
1051     if ( _pSet )
1052         FillItemSet( *_pSet );
1053 	return LEAVE_PAGE;
1054 }
1055 
1056 /*--------------------------------------------------------------------
1057 	Beschreibung:	Berech
1058  --------------------------------------------------------------------*/
1059 
IMPL_LINK(SvxHFPage,RangeHdl,Edit *,EMPTYARG)1060 IMPL_LINK( SvxHFPage, RangeHdl, Edit *, EMPTYARG )
1061 {
1062 	long nHHeight = aBspWin.GetHdHeight();
1063 	long nHDist   = aBspWin.GetHdDist();
1064 
1065 	long nFHeight = aBspWin.GetFtHeight();
1066 	long nFDist   = aBspWin.GetFtDist();
1067 
1068 	long nHeight = Max( (long)MINBODY,
1069 		static_cast<long>(aHeightEdit.Denormalize( aHeightEdit.GetValue( FUNIT_TWIP ) ) ) );
1070 	long nDist   = aTurnOnBox.IsChecked() ?
1071 		static_cast<long>(aDistEdit.Denormalize( aDistEdit.GetValue( FUNIT_TWIP ) )) : 0;
1072 
1073 	long nMin;
1074 	long nMax;
1075 
1076 	if ( nId == SID_ATTR_PAGE_HEADERSET )
1077 	{
1078 		nHHeight = nHeight;
1079 		nHDist   = nDist;
1080 	}
1081 	else
1082 	{
1083 		nFHeight = nHeight;
1084 		nFDist 	 = nDist;
1085 	}
1086 
1087 	// Aktuelle Werte der Seitenraender
1088 	long nBT = aBspWin.GetTop();
1089 	long nBB = aBspWin.GetBottom();
1090 	long nBL = aBspWin.GetLeft();
1091 	long nBR = aBspWin.GetRight();
1092 
1093 	long nH  = aBspWin.GetSize().Height();
1094 	long nW  = aBspWin.GetSize().Width();
1095 
1096 	// Grenzen
1097 	if ( nId == SID_ATTR_PAGE_HEADERSET )
1098 	{
1099 		// Header
1100 		nMin = ( nH - nBB - nBT ) / 5; // 20%
1101 		nMax = Max( nH - nMin - nHDist - nFDist - nFHeight - nBB - nBT,
1102 					nMin );
1103 		aHeightEdit.SetMax( aHeightEdit.Normalize( nMax ), FUNIT_TWIP );
1104 		nMin = ( nH - nBB - nBT ) / 5; // 20%
1105 		nDist = Max( nH - nMin - nHHeight - nFDist - nFHeight - nBB - nBT,
1106 					 long(0) );
1107 		aDistEdit.SetMax( aDistEdit.Normalize( nDist ), FUNIT_TWIP );
1108 	}
1109 	else
1110 	{
1111 		// Footer
1112 		nMin = ( nH - nBT - nBB ) / 5; // 20%
1113 		nMax = Max( nH - nMin - nFDist - nHDist - nHHeight - nBT - nBB,
1114 					nMin );
1115 		aHeightEdit.SetMax( aHeightEdit.Normalize( nMax ), FUNIT_TWIP );
1116         nMin = ( nH - nBT - nBB ) / 5; // 20%
1117 		nDist = Max( nH - nMin - nFHeight - nHDist - nHHeight - nBT - nBB,
1118 					 long(0) );
1119 		aDistEdit.SetMax( aDistEdit.Normalize( nDist ), FUNIT_TWIP );
1120 	}
1121 
1122 	// Einzuege beschraenken
1123 	nMax = nW - nBL - nBR -
1124 		   static_cast<long>(aRMEdit.Denormalize( aRMEdit.GetValue( FUNIT_TWIP ) )) - MINBODY;
1125 	aLMEdit.SetMax( aLMEdit.Normalize( nMax ), FUNIT_TWIP );
1126 
1127 	nMax = nW - nBL - nBR -
1128 		   static_cast<long>(aLMEdit.Denormalize( aLMEdit.GetValue( FUNIT_TWIP ) )) - MINBODY;
1129 	aRMEdit.SetMax( aLMEdit.Normalize( nMax ), FUNIT_TWIP );
1130 	return 0;
1131 }
1132 /* -----------------------------26.08.2002 12:49------------------------------
1133 
1134  ---------------------------------------------------------------------------*/
lcl_Move(Window & rWin,sal_Int32 nDiff)1135 void lcl_Move(Window& rWin, sal_Int32 nDiff)
1136 {
1137 	Point aPos(rWin.GetPosPixel());
1138 	aPos.Y() -= nDiff;
1139 	rWin.SetPosPixel(aPos);
1140 }
1141 
EnableDynamicSpacing()1142 void SvxHFPage::EnableDynamicSpacing()
1143 {
1144     aDynSpacingCB.Show();
1145     //move all following controls
1146     Window* aMoveWindows[] =
1147     {
1148         &aHeightFT,
1149         &aHeightEdit,
1150         &aHeightDynBtn,
1151         &aBackgroundBtn,
1152         0
1153     };
1154     sal_Int32 nOffset = aTurnOnBox.GetPosPixel().Y() - aCntSharedBox.GetPosPixel().Y();
1155     sal_Int32 nIdx = 0;
1156     while(aMoveWindows[nIdx])
1157         lcl_Move(*aMoveWindows[nIdx++], nOffset);
1158 }
1159 
PageCreated(SfxAllItemSet aSet)1160 void SvxHFPage::PageCreated(SfxAllItemSet aSet)
1161 {
1162     //UUUU
1163     SFX_ITEMSET_ARG (&aSet, pSupportDrawingLayerFillStyleItem, SfxBoolItem, SID_DRAWINGLAYER_FILLSTYLES, sal_False);
1164 
1165     if(pSupportDrawingLayerFillStyleItem)
1166     {
1167         const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue());
1168 
1169         EnableDrawingLayerFillStyles(bNew);
1170     }
1171 }
1172 
1173 //eof
1174