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