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