1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hdft.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/shl.hxx>
36 #include <svtools/itemiter.hxx>
37 #include <sfx2/app.hxx>
38 #include <sfx2/objsh.hxx>
39 #include <sfx2/module.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/graph.hxx>
43 #include <svx/dialogs.hrc>
59 #include <svx/hdft.hxx>
60 #include <svx/pageitem.hxx>
61 //CHINA001 #include "bbdlg.hxx"
62 #include "dlgutil.hxx"
63 #include <svx/dialmgr.hxx>
64 #include "htmlmode.hxx"
66 #include <svx/brshitem.hxx>
67 #include <svx/lrspitem.hxx>
68 #include <svx/ulspitem.hxx>
69 #include <svx/shaditem.hxx>
70 #include <svx/sizeitem.hxx>
71 #include <svx/boxitem.hxx>
73 #include <svx/svxdlg.hxx> //CHINA001
74 #include <svx/dialogs.hrc> //CHINA001
75 // static ----------------------------------------------------------------
77 // --> OD 2004-06-18 #i19922#
78 //static const long MINBODY = 284; // 0,5cm in twips aufgerundet
79 static const long MINBODY
= 56; // 1mm in twips rounded
81 // default distance to Header or footer
82 static const long DEF_DIST_WRITER
= 500; // 5mm (Writer)
83 static const long DEF_DIST_CALC
= 250; // 2,5mm (Calc)
85 static USHORT pRanges
[] =
87 SID_ATTR_BRUSH
, SID_ATTR_BRUSH
,
88 SID_ATTR_BORDER_OUTER
, SID_ATTR_BORDER_OUTER
,
89 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
90 SID_ATTR_BORDER_SHADOW
, SID_ATTR_BORDER_SHADOW
,
91 SID_ATTR_LRSPACE
, SID_ATTR_LRSPACE
,
92 SID_ATTR_ULSPACE
, SID_ATTR_ULSPACE
,
93 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
94 SID_ATTR_PAGE_HEADERSET
, SID_ATTR_PAGE_HEADERSET
,
95 SID_ATTR_PAGE_FOOTERSET
, SID_ATTR_PAGE_FOOTERSET
,
96 SID_ATTR_PAGE_ON
, SID_ATTR_PAGE_ON
,
97 SID_ATTR_PAGE_DYNAMIC
, SID_ATTR_PAGE_DYNAMIC
,
98 SID_ATTR_PAGE_SHARED
, SID_ATTR_PAGE_SHARED
,
99 SID_ATTR_HDFT_DYNAMIC_SPACING
, SID_ATTR_HDFT_DYNAMIC_SPACING
,
103 /*--------------------------------------------------------------------
105 --------------------------------------------------------------------*/
107 // gibt den Bereich der Which-Werte zurueck
110 USHORT
* SvxHeaderPage::GetRanges()
115 //------------------------------------------------------------------------
117 SfxTabPage
* SvxHeaderPage::Create( Window
* pParent
, const SfxItemSet
& rSet
)
119 return new SvxHeaderPage( pParent
, rSet
);
122 //------------------------------------------------------------------------
124 USHORT
* SvxFooterPage::GetRanges()
129 // -----------------------------------------------------------------------
131 SfxTabPage
* SvxFooterPage::Create( Window
* pParent
, const SfxItemSet
& rSet
)
133 return new SvxFooterPage( pParent
, rSet
);
136 // -----------------------------------------------------------------------
138 SvxHeaderPage::SvxHeaderPage( Window
* pParent
, const SfxItemSet
& rAttr
) :
140 SvxHFPage( pParent
, RID_SVXPAGE_HEADER
, rAttr
, SID_ATTR_PAGE_HEADERSET
)
145 // -----------------------------------------------------------------------
147 SvxFooterPage::SvxFooterPage( Window
* pParent
, const SfxItemSet
& rAttr
) :
149 SvxHFPage( pParent
, RID_SVXPAGE_FOOTER
, rAttr
, SID_ATTR_PAGE_FOOTERSET
)
154 // -----------------------------------------------------------------------
156 SvxHFPage::SvxHFPage( Window
* pParent
, USHORT nResId
, const SfxItemSet
& rAttr
, USHORT nSetId
) :
158 SfxTabPage( pParent
, SVX_RES( nResId
), rAttr
),
160 aTurnOnBox ( this, SVX_RES( CB_TURNON
) ),
161 aCntSharedBox ( this, SVX_RES( CB_SHARED
) ),
162 aLMLbl ( this, SVX_RES( FT_LMARGIN
) ),
163 aLMEdit ( this, SVX_RES( ED_LMARGIN
) ),
164 aRMLbl ( this, SVX_RES( FT_RMARGIN
) ),
165 aRMEdit ( this, SVX_RES( ED_RMARGIN
) ),
166 aDistFT ( this, SVX_RES( FT_DIST
) ),
167 aDistEdit ( this, SVX_RES( ED_DIST
) ),
168 aDynSpacingCB ( this, SVX_RES( CB_DYNSPACING
) ),
169 aHeightFT ( this, SVX_RES( FT_HEIGHT
) ),
170 aHeightEdit ( this, SVX_RES( ED_HEIGHT
) ),
171 aHeightDynBtn ( this, SVX_RES( CB_HEIGHT_DYN
) ),
172 aFrm ( this, SVX_RES( FL_FRAME
) ),
173 aBspWin ( this, SVX_RES( WN_BSP
) ),
174 aBackgroundBtn ( this, SVX_RES( BTN_EXTRAS
) ),
178 bDisableQueryBox ( FALSE
),
179 bEnableBackgroundSelector ( TRUE
)
183 aBspWin
.EnableRTL( FALSE
);
185 // diese Page braucht ExchangeSupport
186 SetExchangeSupport();
191 FieldUnit eFUnit
= GetModuleFieldUnit( &rAttr
);
192 SetFieldUnit( aDistEdit
, eFUnit
);
193 SetFieldUnit( aHeightEdit
, eFUnit
);
194 SetFieldUnit( aLMEdit
, eFUnit
);
195 SetFieldUnit( aRMEdit
, eFUnit
);
198 // -----------------------------------------------------------------------
200 SvxHFPage::~SvxHFPage()
205 // -----------------------------------------------------------------------
207 BOOL
SvxHFPage::FillItemSet( SfxItemSet
& rSet
)
209 const USHORT nWSize
= GetWhich( SID_ATTR_PAGE_SIZE
);
210 const USHORT nWLRSpace
= GetWhich( SID_ATTR_LRSPACE
);
211 const USHORT nWULSpace
= GetWhich( SID_ATTR_ULSPACE
);
212 const USHORT nWOn
= GetWhich( SID_ATTR_PAGE_ON
);
213 const USHORT nWDynamic
= GetWhich( SID_ATTR_PAGE_DYNAMIC
);
214 const USHORT nWDynSpacing
= GetWhich( SID_ATTR_HDFT_DYNAMIC_SPACING
);
215 const USHORT nWShared
= GetWhich( SID_ATTR_PAGE_SHARED
);
216 const USHORT nWBrush
= GetWhich( SID_ATTR_BRUSH
);
217 const USHORT nWBox
= GetWhich( SID_ATTR_BORDER_OUTER
);
218 const USHORT nWBoxInfo
= GetWhich( SID_ATTR_BORDER_INNER
);
219 const USHORT nWShadow
= GetWhich( SID_ATTR_BORDER_SHADOW
);
220 const USHORT aWhichTab
[] = { nWSize
, nWSize
,
221 nWLRSpace
, nWLRSpace
,
222 nWULSpace
, nWULSpace
,
224 nWDynamic
, nWDynamic
,
227 nWBoxInfo
, nWBoxInfo
,
230 nWDynSpacing
, nWDynSpacing
,
232 const SfxItemSet
& rOldSet
= GetItemSet();
233 SfxItemPool
* pPool
= rOldSet
.GetPool();
234 DBG_ASSERT( pPool
, "no pool :-(" );
235 SfxMapUnit eUnit
= pPool
->GetMetric( nWSize
);
236 SfxItemSet
aSet ( *pPool
, aWhichTab
);
238 //--------------------------------------------------------------------
240 aSet
.Put( SfxBoolItem( nWOn
, aTurnOnBox
.IsChecked() ) );
241 aSet
.Put( SfxBoolItem( nWDynamic
, aHeightDynBtn
.IsChecked() ) );
242 aSet
.Put( SfxBoolItem( nWShared
, aCntSharedBox
.IsChecked() ) );
243 if(aDynSpacingCB
.IsVisible() && SFX_WHICH_MAX
> nWDynSpacing
)
245 SfxBoolItem
* pBoolItem
= (SfxBoolItem
*)pPool
->GetDefaultItem(nWDynSpacing
).Clone();
246 pBoolItem
->SetValue(aDynSpacingCB
.IsChecked());
247 aSet
.Put(*pBoolItem
);
252 SvxSizeItem
aSizeItem( (const SvxSizeItem
&)rOldSet
.Get( nWSize
) );
253 Size
aSize( aSizeItem
.GetSize() );
254 long nDist
= GetCoreValue( aDistEdit
, eUnit
);
255 long nH
= GetCoreValue( aHeightEdit
, eUnit
);
258 // if ( !aHeightDynBtn.IsChecked() )
259 nH
+= nDist
; // dann Abstand dazu addieren
261 aSizeItem
.SetSize( aSize
);
262 aSet
.Put( aSizeItem
);
265 SvxLRSpaceItem
aLR( nWLRSpace
);
266 aLR
.SetLeft( (USHORT
)GetCoreValue( aLMEdit
, eUnit
) );
267 aLR
.SetRight( (USHORT
)GetCoreValue( aRMEdit
, eUnit
) );
270 SvxULSpaceItem
aUL( nWULSpace
);
271 if ( nId
== SID_ATTR_PAGE_HEADERSET
)
272 aUL
.SetLower( (USHORT
)nDist
);
274 aUL
.SetUpper( (USHORT
)nDist
);
277 // Hintergrund und Umrandung?
282 const SfxItemSet
* _pSet
;
283 const SfxPoolItem
* pItem
;
286 GetItemSet().GetItemState( GetWhich( nId
), FALSE
, &pItem
) )
288 _pSet
= &( (SvxSetItem
*)pItem
)->GetItemSet();
290 if ( _pSet
->GetItemState( nWBrush
) == SFX_ITEM_SET
)
291 aSet
.Put( (const SvxBrushItem
&)_pSet
->Get( nWBrush
) );
292 if ( _pSet
->GetItemState( nWBoxInfo
) == SFX_ITEM_SET
)
293 aSet
.Put( (const SvxBoxInfoItem
&)_pSet
->Get( nWBoxInfo
) );
294 if ( _pSet
->GetItemState( nWBox
) == SFX_ITEM_SET
)
295 aSet
.Put( (const SvxBoxItem
&)_pSet
->Get( nWBox
) );
296 if ( _pSet
->GetItemState( nWShadow
) == SFX_ITEM_SET
)
297 aSet
.Put( (const SvxShadowItem
&)_pSet
->Get( nWShadow
) );
301 // Das SetItem wegschreiben
302 SvxSetItem
aSetItem( GetWhich( nId
), aSet
);
303 rSet
.Put( aSetItem
);
308 // -----------------------------------------------------------------------
309 void SvxHFPage::Reset( const SfxItemSet
& rSet
)
311 ActivatePage( rSet
);
312 ResetBackground_Impl( rSet
);
314 SfxItemPool
* pPool
= GetItemSet().GetPool();
315 DBG_ASSERT( pPool
, "Wo ist der Pool" );
316 SfxMapUnit eUnit
= pPool
->GetMetric( GetWhich( SID_ATTR_PAGE_SIZE
) );
318 // Kopf-/Fusszeilen-Attribute auswerten
320 const SvxSetItem
* pSetItem
= 0;
322 if ( SFX_ITEM_SET
== rSet
.GetItemState( GetWhich(nId
), FALSE
,
323 (const SfxPoolItem
**)&pSetItem
) )
325 const SfxItemSet
& rHeaderSet
= pSetItem
->GetItemSet();
326 const SfxBoolItem
& rHeaderOn
=
327 (const SfxBoolItem
&)rHeaderSet
.Get(GetWhich(SID_ATTR_PAGE_ON
));
329 aTurnOnBox
.Check(rHeaderOn
.GetValue());
331 if ( rHeaderOn
.GetValue() )
333 const SfxBoolItem
& rDynamic
=
334 (const SfxBoolItem
&)rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_DYNAMIC
) );
335 const SfxBoolItem
& rShared
=
336 (const SfxBoolItem
&)rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_SHARED
) );
337 const SvxSizeItem
& rSize
=
338 (const SvxSizeItem
&)rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_SIZE
) );
339 const SvxULSpaceItem
& rUL
=
340 (const SvxULSpaceItem
&)rHeaderSet
.Get( GetWhich( SID_ATTR_ULSPACE
) );
341 const SvxLRSpaceItem
& rLR
=
342 (const SvxLRSpaceItem
&)rHeaderSet
.Get( GetWhich( SID_ATTR_LRSPACE
) );
343 if(aDynSpacingCB
.IsVisible())
345 const SfxBoolItem
& rDynSpacing
=
346 (const SfxBoolItem
&)rHeaderSet
.Get(GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING
));
347 aDynSpacingCB
.Check(rDynSpacing
.GetValue());
351 if ( nId
== SID_ATTR_PAGE_HEADERSET
)
353 SetMetricValue( aDistEdit
, rUL
.GetLower(), eUnit
);
354 SetMetricValue( aHeightEdit
, rSize
.GetSize().Height() - rUL
.GetLower(), eUnit
);
358 SetMetricValue( aDistEdit
, rUL
.GetUpper(), eUnit
);
359 SetMetricValue( aHeightEdit
, rSize
.GetSize().Height() - rUL
.GetUpper(), eUnit
);
362 aHeightDynBtn
.Check(rDynamic
.GetValue());
363 SetMetricValue( aLMEdit
, rLR
.GetLeft(), eUnit
);
364 SetMetricValue( aRMEdit
, rLR
.GetRight(), eUnit
);
365 aCntSharedBox
.Check(rShared
.GetValue());
372 // defaults for distance and height
373 long nDefaultDist
= DEF_DIST_WRITER
;
374 const SfxPoolItem
* pExt1
= GetItem( rSet
, SID_ATTR_PAGE_EXT1
);
375 const SfxPoolItem
* pExt2
= GetItem( rSet
, SID_ATTR_PAGE_EXT2
);
377 if ( pExt1
&& pExt1
->ISA(SfxBoolItem
) && pExt2
&& pExt2
->ISA(SfxBoolItem
) )
378 nDefaultDist
= DEF_DIST_CALC
;
380 SetMetricValue( aDistEdit
, nDefaultDist
, SFX_MAPUNIT_100TH_MM
);
381 SetMetricValue( aHeightEdit
, 500, SFX_MAPUNIT_100TH_MM
);
386 aTurnOnBox
.Check( FALSE
);
387 aHeightDynBtn
.Check( TRUE
);
388 aCntSharedBox
.Check( TRUE
);
393 aTurnOnBox
.SaveValue();
394 aDistEdit
.SaveValue();
395 aHeightEdit
.SaveValue();
396 aHeightDynBtn
.SaveValue();
399 aCntSharedBox
.SaveValue();
402 USHORT nHtmlMode
= 0;
403 const SfxPoolItem
* pItem
= 0;
404 SfxObjectShell
* pShell
;
405 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_HTML_MODE
, FALSE
, &pItem
) ||
406 ( 0 != (pShell
= SfxObjectShell::Current()) &&
407 0 != (pItem
= pShell
->GetItem(SID_HTML_MODE
))))
409 nHtmlMode
= ((SfxUInt16Item
*)pItem
)->GetValue();
410 if(nHtmlMode
&& HTMLMODE_ON
)
412 aCntSharedBox
.Hide();
413 aBackgroundBtn
.Hide();
419 /*--------------------------------------------------------------------
420 Beschreibung: Handler initialisieren
421 --------------------------------------------------------------------*/
423 void SvxHFPage::InitHandler()
425 aTurnOnBox
.SetClickHdl(LINK(this, SvxHFPage
, TurnOnHdl
));
426 aDistEdit
.SetModifyHdl(LINK(this, SvxHFPage
, DistModify
));
427 aDistEdit
.SetLoseFocusHdl(LINK(this, SvxHFPage
, RangeHdl
));
429 aHeightEdit
.SetModifyHdl(LINK(this, SvxHFPage
, HeightModify
));
430 aHeightEdit
.SetLoseFocusHdl(LINK(this,SvxHFPage
,RangeHdl
));
432 aLMEdit
.SetModifyHdl(LINK(this, SvxHFPage
, BorderModify
));
433 aLMEdit
.SetLoseFocusHdl(LINK(this, SvxHFPage
, RangeHdl
));
434 aRMEdit
.SetModifyHdl(LINK(this, SvxHFPage
, BorderModify
));
435 aRMEdit
.SetLoseFocusHdl(LINK(this, SvxHFPage
, RangeHdl
));
436 aBackgroundBtn
.SetClickHdl(LINK(this,SvxHFPage
, BackgroundHdl
));
439 /*--------------------------------------------------------------------
440 Beschreibung: Ein/aus
441 --------------------------------------------------------------------*/
443 IMPL_LINK( SvxHFPage
, TurnOnHdl
, CheckBox
*, pBox
)
445 if ( aTurnOnBox
.IsChecked() )
449 aDynSpacingCB
.Enable();
451 aHeightEdit
.Enable();
452 aHeightDynBtn
.Enable();
458 USHORT nUsage
= aBspWin
.GetUsage();
460 if( nUsage
== SVX_PAGE_RIGHT
|| nUsage
== SVX_PAGE_LEFT
)
461 aCntSharedBox
.Disable();
463 aCntSharedBox
.Enable();
464 aBackgroundBtn
.Enable();
470 if ( !bDisableQueryBox
&& pBox
&& aTurnOnBox
.GetSavedValue() == TRUE
)
471 bDelete
= ( QueryBox( this, SVX_RES( RID_SVXQBX_DELETE_HEADFOOT
) ).Execute() == RET_YES
);
477 aDynSpacingCB
.Enable(FALSE
);
479 aHeightEdit
.Disable();
480 aHeightDynBtn
.Disable();
487 aCntSharedBox
.Disable();
488 aBackgroundBtn
.Disable();
497 /*--------------------------------------------------------------------
498 Beschreibung: Abstand im Bsp Modifizieren
499 --------------------------------------------------------------------*/
501 IMPL_LINK_INLINE_START( SvxHFPage
, DistModify
, MetricField
*, EMPTYARG
)
506 IMPL_LINK_INLINE_END( SvxHFPage
, DistModify
, MetricField
*, EMPTYARG
)
508 IMPL_LINK_INLINE_START( SvxHFPage
, HeightModify
, MetricField
*, EMPTYARG
)
514 IMPL_LINK_INLINE_END( SvxHFPage
, HeightModify
, MetricField
*, EMPTYARG
)
516 /*--------------------------------------------------------------------
517 Beschreibung: Raender einstellen
518 --------------------------------------------------------------------*/
520 IMPL_LINK_INLINE_START( SvxHFPage
, BorderModify
, MetricField
*, EMPTYARG
)
525 IMPL_LINK_INLINE_END( SvxHFPage
, BorderModify
, MetricField
*, EMPTYARG
)
527 /*--------------------------------------------------------------------
528 Beschreibung: Hintergrund
529 --------------------------------------------------------------------*/
531 IMPL_LINK( SvxHFPage
, BackgroundHdl
, Button
*, EMPTYARG
)
535 // nur die n"otigen Items f"uer Umrandung und Hintergrund benutzen
536 USHORT nBrush
= GetWhich( SID_ATTR_BRUSH
);
537 USHORT nOuter
= GetWhich( SID_ATTR_BORDER_OUTER
);
538 USHORT nInner
= GetWhich( SID_ATTR_BORDER_INNER
, sal_False
);
539 USHORT nShadow
= GetWhich( SID_ATTR_BORDER_SHADOW
);
541 // einen leeren Set erzeugenc
542 pBBSet
= new SfxItemSet( *GetItemSet().GetPool(), nBrush
, nBrush
,
543 nOuter
, nOuter
, nInner
, nInner
,
544 nShadow
, nShadow
, 0 );
545 const SfxPoolItem
* pItem
;
548 GetItemSet().GetItemState( GetWhich( nId
), FALSE
, &pItem
) )
549 // wenn es schon einen gesetzen Set gibt, dann diesen benutzen
550 pBBSet
->Put( ( (SvxSetItem
*)pItem
)->GetItemSet() );
553 GetItemSet().GetItemState( nInner
, FALSE
, &pItem
) )
554 // das gesetze InfoItem wird immer ben"otigt
555 pBBSet
->Put( *pItem
);
558 //CHINA001 SvxBorderBackgroundDlg* pDlg =
559 //CHINA001 new SvxBorderBackgroundDlg( this, *pBBSet, bEnableBackgroundSelector );
560 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
563 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSvxBorderBackgroundDlg( this, *pBBSet
, RID_SVXDLG_BBDLG
,bEnableBackgroundSelector
);
564 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
565 if ( pDlg
->Execute() == RET_OK
&& pDlg
->GetOutputItemSet() )
567 SfxItemIter
aIter( *pDlg
->GetOutputItemSet() );
568 const SfxPoolItem
* pItem
= aIter
.FirstItem();
572 if ( !IsInvalidItem( pItem
) )
573 pBBSet
->Put( *pItem
);
574 pItem
= aIter
.NextItem();
577 //----------------------------------------------------------------
579 USHORT nWhich
= GetWhich( SID_ATTR_BRUSH
);
581 if ( pBBSet
->GetItemState( nWhich
) == SFX_ITEM_SET
)
583 const SvxBrushItem
& rItem
= (const SvxBrushItem
&)pBBSet
->Get( nWhich
);
584 if ( nId
== SID_ATTR_PAGE_HEADERSET
)
585 aBspWin
.SetHdColor( rItem
.GetColor() );
587 aBspWin
.SetFtColor( rItem
.GetColor() );
590 //----------------------------------------------------------------
592 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
594 if ( pBBSet
->GetItemState( nWhich
) == SFX_ITEM_SET
)
596 const SvxBoxItem
& rItem
= (const SvxBoxItem
&)pBBSet
->Get( nWhich
);
598 if ( nId
== SID_ATTR_PAGE_HEADERSET
)
599 aBspWin
.SetHdBorder( rItem
);
601 aBspWin
.SetFtBorder( rItem
);
611 /*--------------------------------------------------------------------
613 --------------------------------------------------------------------*/
615 void SvxHFPage::UpdateExample()
617 if ( nId
== SID_ATTR_PAGE_HEADERSET
)
619 aBspWin
.SetHeader( aTurnOnBox
.IsChecked() );
620 aBspWin
.SetHdHeight( GetCoreValue( aHeightEdit
, SFX_MAPUNIT_TWIP
) );
621 aBspWin
.SetHdDist( GetCoreValue( aDistEdit
, SFX_MAPUNIT_TWIP
) );
622 aBspWin
.SetHdLeft( GetCoreValue( aLMEdit
, SFX_MAPUNIT_TWIP
) );
623 aBspWin
.SetHdRight( GetCoreValue( aRMEdit
, SFX_MAPUNIT_TWIP
) );
627 aBspWin
.SetFooter( aTurnOnBox
.IsChecked() );
628 aBspWin
.SetFtHeight( GetCoreValue( aHeightEdit
, SFX_MAPUNIT_TWIP
) );
629 aBspWin
.SetFtDist( GetCoreValue( aDistEdit
, SFX_MAPUNIT_TWIP
) );
630 aBspWin
.SetFtLeft( GetCoreValue( aLMEdit
, SFX_MAPUNIT_TWIP
) );
631 aBspWin
.SetFtRight( GetCoreValue( aRMEdit
, SFX_MAPUNIT_TWIP
) );
633 aBspWin
.Invalidate();
636 /*--------------------------------------------------------------------
637 Beschreibung: Hintergrund im Beispiel setzen
638 --------------------------------------------------------------------*/
640 void SvxHFPage::ResetBackground_Impl( const SfxItemSet
& rSet
)
642 USHORT nWhich
= GetWhich( SID_ATTR_PAGE_HEADERSET
);
644 if ( rSet
.GetItemState( nWhich
, FALSE
) == SFX_ITEM_SET
)
646 const SvxSetItem
& rSetItem
=
647 (const SvxSetItem
&)rSet
.Get( nWhich
, FALSE
);
648 const SfxItemSet
& rTmpSet
= rSetItem
.GetItemSet();
649 const SfxBoolItem
& rOn
=
650 (const SfxBoolItem
&)rTmpSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
652 if ( rOn
.GetValue() )
654 nWhich
= GetWhich( SID_ATTR_BRUSH
);
656 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
658 const SvxBrushItem
& rItem
= (const SvxBrushItem
&)rTmpSet
.Get( nWhich
);
659 aBspWin
.SetHdColor( rItem
.GetColor() );
661 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
663 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
665 const SvxBoxItem
& rItem
=
666 (const SvxBoxItem
&)rTmpSet
.Get( nWhich
);
667 aBspWin
.SetHdBorder( rItem
);
672 nWhich
= GetWhich( SID_ATTR_PAGE_FOOTERSET
);
674 if ( rSet
.GetItemState( nWhich
, FALSE
) == SFX_ITEM_SET
)
676 const SvxSetItem
& rSetItem
=
677 (const SvxSetItem
&)rSet
.Get( nWhich
, FALSE
);
678 const SfxItemSet
& rTmpSet
= rSetItem
.GetItemSet();
679 const SfxBoolItem
& rOn
=
680 (const SfxBoolItem
&)rTmpSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
682 if ( rOn
.GetValue() )
684 nWhich
= GetWhich( SID_ATTR_BRUSH
);
686 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
688 const SvxBrushItem
& rItem
= (const SvxBrushItem
&)rTmpSet
.Get( nWhich
);
689 aBspWin
.SetFtColor( rItem
.GetColor() );
691 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
693 if ( rTmpSet
.GetItemState( nWhich
) == SFX_ITEM_SET
)
695 const SvxBoxItem
& rItem
=
696 (const SvxBoxItem
&)rTmpSet
.Get( nWhich
);
697 aBspWin
.SetFtBorder( rItem
);
701 nWhich
= GetWhich( SID_ATTR_BRUSH
);
703 if ( rSet
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
705 const SvxBrushItem
& rItem
= (const SvxBrushItem
&)rSet
.Get( nWhich
);
706 aBspWin
.SetColor( rItem
.GetColor() );
707 const Graphic
* pGrf
= rItem
.GetGraphic();
711 Bitmap aBitmap
= pGrf
->GetBitmap();
712 aBspWin
.SetBitmap( &aBitmap
);
715 aBspWin
.SetBitmap( NULL
);
717 nWhich
= GetWhich( SID_ATTR_BORDER_OUTER
);
719 if ( rSet
.GetItemState( nWhich
) >= SFX_ITEM_AVAILABLE
)
721 const SvxBoxItem
& rItem
= (const SvxBoxItem
&)rSet
.Get( nWhich
);
722 aBspWin
.SetBorder( rItem
);
726 /*--------------------------------------------------------------------
728 --------------------------------------------------------------------*/
730 void SvxHFPage::ActivatePage( const SfxItemSet
& rSet
)
732 const SfxPoolItem
* pItem
= GetItem( rSet
, SID_ATTR_LRSPACE
);
736 // linken und rechten Rand einstellen
737 const SvxLRSpaceItem
& rLRSpace
= (const SvxLRSpaceItem
&)*pItem
;
739 aBspWin
.SetLeft( rLRSpace
.GetLeft() );
740 aBspWin
.SetRight( rLRSpace
.GetRight() );
744 aBspWin
.SetLeft( 0 );
745 aBspWin
.SetRight( 0 );
748 pItem
= GetItem( rSet
, SID_ATTR_ULSPACE
);
752 // oberen und unteren Rand einstellen
753 const SvxULSpaceItem
& rULSpace
= (const SvxULSpaceItem
&)*pItem
;
755 aBspWin
.SetTop( rULSpace
.GetUpper() );
756 aBspWin
.SetBottom( rULSpace
.GetLower() );
761 aBspWin
.SetBottom( 0 );
764 USHORT nUsage
= SVX_PAGE_ALL
;
765 pItem
= GetItem( rSet
, SID_ATTR_PAGE
);
768 nUsage
= ( (const SvxPageItem
*)pItem
)->GetPageUsage();
770 aBspWin
.SetUsage( nUsage
);
772 if ( SVX_PAGE_RIGHT
== nUsage
|| SVX_PAGE_LEFT
== nUsage
)
773 aCntSharedBox
.Disable();
775 aCntSharedBox
.Enable();
776 pItem
= GetItem( rSet
, SID_ATTR_PAGE_SIZE
);
780 // Orientation und Size aus dem PageItem
781 const SvxSizeItem
& rSize
= (const SvxSizeItem
&)*pItem
;
782 // die Groesse ist ggf. schon geswappt (Querformat)
783 aBspWin
.SetSize( rSize
.GetSize() );
786 // Kopfzeilen-Attribute auswerten
787 const SvxSetItem
* pSetItem
= 0;
789 if ( SFX_ITEM_SET
== rSet
.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET
),
791 (const SfxPoolItem
**)&pSetItem
) )
793 const SfxItemSet
& rHeaderSet
= pSetItem
->GetItemSet();
794 const SfxBoolItem
& rHeaderOn
=
795 (const SfxBoolItem
&)rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
797 if ( rHeaderOn
.GetValue() )
799 const SvxSizeItem
& rSize
= (const SvxSizeItem
&)
800 rHeaderSet
.Get( GetWhich( SID_ATTR_PAGE_SIZE
) );
801 const SvxULSpaceItem
& rUL
= (const SvxULSpaceItem
&)
802 rHeaderSet
.Get( GetWhich(SID_ATTR_ULSPACE
) );
803 const SvxLRSpaceItem
& rLR
= (const SvxLRSpaceItem
&)
804 rHeaderSet
.Get( GetWhich( SID_ATTR_LRSPACE
) );
805 long nDist
= rUL
.GetLower();
807 aBspWin
.SetHdHeight( rSize
.GetSize().Height() - nDist
);
808 aBspWin
.SetHdDist( nDist
);
809 aBspWin
.SetHdLeft( rLR
.GetLeft() );
810 aBspWin
.SetHdRight( rLR
.GetRight() );
811 aBspWin
.SetHeader( TRUE
);
819 aBspWin
.SetHeader( FALSE
);
821 if ( SID_ATTR_PAGE_HEADERSET
== nId
)
822 aCntSharedBox
.Disable();
826 if ( SFX_ITEM_SET
== rSet
.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET
),
828 (const SfxPoolItem
**)&pSetItem
) )
830 const SfxItemSet
& rFooterSet
= pSetItem
->GetItemSet();
831 const SfxBoolItem
& rFooterOn
=
832 (const SfxBoolItem
&)rFooterSet
.Get( GetWhich( SID_ATTR_PAGE_ON
) );
834 if ( rFooterOn
.GetValue() )
836 const SvxSizeItem
& rSize
= (const SvxSizeItem
&)
837 rFooterSet
.Get( GetWhich( SID_ATTR_PAGE_SIZE
) );
838 const SvxULSpaceItem
& rUL
= (const SvxULSpaceItem
&)
839 rFooterSet
.Get( GetWhich( SID_ATTR_ULSPACE
) );
840 const SvxLRSpaceItem
& rLR
= (const SvxLRSpaceItem
&)
841 rFooterSet
.Get( GetWhich( SID_ATTR_LRSPACE
) );
842 long nDist
= rUL
.GetUpper();
844 aBspWin
.SetFtHeight( rSize
.GetSize().Height() - nDist
);
845 aBspWin
.SetFtDist( nDist
);
846 aBspWin
.SetFtLeft( rLR
.GetLeft() );
847 aBspWin
.SetFtRight( rLR
.GetRight() );
848 aBspWin
.SetFooter( TRUE
);
856 aBspWin
.SetFooter( FALSE
);
858 if ( SID_ATTR_PAGE_FOOTERSET
== nId
)
859 aCntSharedBox
.Disable();
862 pItem
= GetItem( rSet
, SID_ATTR_PAGE_EXT1
);
864 if ( pItem
&& pItem
->ISA(SfxBoolItem
) )
866 aBspWin
.SetTable( TRUE
);
867 aBspWin
.SetHorz( ( (SfxBoolItem
*)pItem
)->GetValue() );
870 pItem
= GetItem( rSet
, SID_ATTR_PAGE_EXT2
);
872 if ( pItem
&& pItem
->ISA(SfxBoolItem
) )
874 aBspWin
.SetTable( TRUE
);
875 aBspWin
.SetVert( ( (SfxBoolItem
*)pItem
)->GetValue() );
877 ResetBackground_Impl( rSet
);
881 /*--------------------------------------------------------------------
883 --------------------------------------------------------------------*/
885 int SvxHFPage::DeactivatePage( SfxItemSet
* _pSet
)
888 FillItemSet( *_pSet
);
892 /*--------------------------------------------------------------------
894 --------------------------------------------------------------------*/
896 IMPL_LINK( SvxHFPage
, RangeHdl
, Edit
*, EMPTYARG
)
898 long nHHeight
= aBspWin
.GetHdHeight();
899 long nHDist
= aBspWin
.GetHdDist();
901 long nFHeight
= aBspWin
.GetFtHeight();
902 long nFDist
= aBspWin
.GetFtDist();
904 long nHeight
= Max( (long)MINBODY
,
905 static_cast<long>(aHeightEdit
.Denormalize( aHeightEdit
.GetValue( FUNIT_TWIP
) ) ) );
906 long nDist
= aTurnOnBox
.IsChecked() ?
907 static_cast<long>(aDistEdit
.Denormalize( aDistEdit
.GetValue( FUNIT_TWIP
) )) : 0;
912 if ( nId
== SID_ATTR_PAGE_HEADERSET
)
923 // Aktuelle Werte der Seitenraender
924 long nBT
= aBspWin
.GetTop();
925 long nBB
= aBspWin
.GetBottom();
926 long nBL
= aBspWin
.GetLeft();
927 long nBR
= aBspWin
.GetRight();
929 long nH
= aBspWin
.GetSize().Height();
930 long nW
= aBspWin
.GetSize().Width();
933 if ( nId
== SID_ATTR_PAGE_HEADERSET
)
936 nMin
= ( nH
- nBB
- nBT
) / 5; // 20%
937 nMax
= Max( nH
- nMin
- nHDist
- nFDist
- nFHeight
- nBB
- nBT
,
939 aHeightEdit
.SetMax( aHeightEdit
.Normalize( nMax
), FUNIT_TWIP
);
940 nMin
= ( nH
- nBB
- nBT
) / 5; // 20%
941 nDist
= Max( nH
- nMin
- nHHeight
- nFDist
- nFHeight
- nBB
- nBT
,
943 aDistEdit
.SetMax( aDistEdit
.Normalize( nDist
), FUNIT_TWIP
);
948 nMin
= ( nH
- nBT
- nBB
) / 5; // 20%
949 nMax
= Max( nH
- nMin
- nFDist
- nHDist
- nHHeight
- nBT
- nBB
,
951 aHeightEdit
.SetMax( aHeightEdit
.Normalize( nMax
), FUNIT_TWIP
);
952 nMin
= ( nH
- nBT
- nBB
) / 5; // 20%
953 nDist
= Max( nH
- nMin
- nFHeight
- nHDist
- nHHeight
- nBT
- nBB
,
955 aDistEdit
.SetMax( aDistEdit
.Normalize( nDist
), FUNIT_TWIP
);
958 // Einzuege beschraenken
959 nMax
= nW
- nBL
- nBR
-
960 static_cast<long>(aRMEdit
.Denormalize( aRMEdit
.GetValue( FUNIT_TWIP
) )) - MINBODY
;
961 aLMEdit
.SetMax( aLMEdit
.Normalize( nMax
), FUNIT_TWIP
);
963 nMax
= nW
- nBL
- nBR
-
964 static_cast<long>(aLMEdit
.Denormalize( aLMEdit
.GetValue( FUNIT_TWIP
) )) - MINBODY
;
965 aRMEdit
.SetMax( aLMEdit
.Normalize( nMax
), FUNIT_TWIP
);
968 /* -----------------------------26.08.2002 12:49------------------------------
970 ---------------------------------------------------------------------------*/
971 void lcl_Move(Window
& rWin
, sal_Int32 nDiff
)
973 Point
aPos(rWin
.GetPosPixel());
975 rWin
.SetPosPixel(aPos
);
977 void SvxHFPage::EnableDynamicSpacing()
979 aDynSpacingCB
.Show();
980 //move all following controls
981 Window
* aMoveWindows
[] =
989 sal_Int32 nOffset
= aTurnOnBox
.GetPosPixel().Y() - aCntSharedBox
.GetPosPixel().Y();
991 while(aMoveWindows
[nIdx
])
992 lcl_Move(*aMoveWindows
[nIdx
++], nOffset
);