1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <svl/itemiter.hxx>
21 #include <sfx2/app.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <sfx2/module.hxx>
24 #include <vcl/graph.hxx>
25 #include <sfx2/sfxsids.hrc>
26 #include <svx/svxids.hrc>
27
28 #include <svl/intitem.hxx>
29 #include <svtools/unitconv.hxx>
30
31 #include <svx/hdft.hxx>
32 #include <svx/pageitem.hxx>
33
34 #include <svx/dlgutil.hxx>
35 #include <sfx2/htmlmode.hxx>
36
37 #include <editeng/brushitem.hxx>
38 #include <editeng/lrspitem.hxx>
39 #include <editeng/ulspitem.hxx>
40 #include <editeng/shaditem.hxx>
41 #include <editeng/sizeitem.hxx>
42 #include <editeng/boxitem.hxx>
43
44 #include <svx/svxdlg.hxx>
45 #include <memory>
46
47 #include <svx/xdef.hxx>
48 #include <svx/xenum.hxx>
49 #include <svx/xfillit0.hxx>
50 #include <svx/unobrushitemhelper.hxx>
51 #include <sfx2/request.hxx>
52
53 using namespace com::sun::star;
54
55 // Word 97 incompatibility (#i19922#)
56 // #i19922# - tdf#126051 see cui/source/tabpages/page.cxx and sw/source/uibase/sidebar/PageMarginControl.hxx
57 static const long MINBODY = 56; // 1mm in twips rounded
58
59 // default distance to Header or footer
60 static const long DEF_DIST_WRITER = 500; // 5mm (Writer)
61 static const long DEF_DIST_CALC = 250; // 2.5mm (Calc)
62
63 const sal_uInt16 SvxHFPage::pRanges[] =
64 {
65 SID_ATTR_BRUSH, SID_ATTR_BRUSH,
66
67 // Support DrawingLayer FillStyles (no real call to below GetRanges()
68 // detected, still do the complete transition)
69 XATTR_FILL_FIRST, XATTR_FILL_LAST,
70
71 SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_OUTER,
72 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
73 SID_ATTR_BORDER_SHADOW, SID_ATTR_BORDER_SHADOW,
74 SID_ATTR_LRSPACE, SID_ATTR_LRSPACE,
75 SID_ATTR_ULSPACE, SID_ATTR_ULSPACE,
76 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
77 SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_HEADERSET,
78 SID_ATTR_PAGE_FOOTERSET, SID_ATTR_PAGE_FOOTERSET,
79 SID_ATTR_PAGE_ON, SID_ATTR_PAGE_ON,
80 SID_ATTR_PAGE_DYNAMIC, SID_ATTR_PAGE_DYNAMIC,
81 SID_ATTR_PAGE_SHARED, SID_ATTR_PAGE_SHARED,
82 SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST,
83 SID_ATTR_HDFT_DYNAMIC_SPACING, SID_ATTR_HDFT_DYNAMIC_SPACING,
84 0
85 };
86
87 namespace svx {
88
ShowBorderBackgroundDlg(weld::Window * pParent,SfxItemSet * pBBSet)89 bool ShowBorderBackgroundDlg(weld::Window* pParent, SfxItemSet* pBBSet)
90 {
91 bool bRes = false;
92 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
93 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxBorderBackgroundDlg(pParent, *pBBSet, true /*bEnableDrawingLayerFillStyles*/));
94 if ( pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet() )
95 {
96 SfxItemIter aIter( *pDlg->GetOutputItemSet() );
97
98 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
99 {
100 if ( !IsInvalidItem( pItem ) )
101 pBBSet->Put( *pItem );
102 }
103 bRes = true;
104 }
105 return bRes;
106 }
107 }
108
Create(weld::Container * pPage,weld::DialogController * pController,const SfxItemSet * rSet)109 std::unique_ptr<SfxTabPage> SvxHeaderPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
110 {
111 return std::make_unique<SvxHeaderPage>( pPage, pController, *rSet );
112 }
113
Create(weld::Container * pPage,weld::DialogController * pController,const SfxItemSet * rSet)114 std::unique_ptr<SfxTabPage> SvxFooterPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
115 {
116 return std::make_unique<SvxFooterPage>( pPage, pController, *rSet );
117 }
118
SvxHeaderPage(weld::Container * pPage,weld::DialogController * pController,const SfxItemSet & rAttr)119 SvxHeaderPage::SvxHeaderPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
120 : SvxHFPage( pPage, pController, rAttr, SID_ATTR_PAGE_HEADERSET )
121 {
122 }
123
SvxFooterPage(weld::Container * pPage,weld::DialogController * pController,const SfxItemSet & rAttr)124 SvxFooterPage::SvxFooterPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
125 : SvxHFPage( pPage, pController, rAttr, SID_ATTR_PAGE_FOOTERSET )
126 {
127 }
128
SvxHFPage(weld::Container * pPage,weld::DialogController * pController,const SfxItemSet & rSet,sal_uInt16 nSetId)129 SvxHFPage::SvxHFPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet, sal_uInt16 nSetId)
130 : SfxTabPage(pPage, pController, "svx/ui/headfootformatpage.ui", "HFFormatPage", &rSet)
131 , nId(nSetId)
132 , mbDisableQueryBox(false)
133 , mbEnableDrawingLayerFillStyles(false)
134 , m_xCntSharedBox(m_xBuilder->weld_check_button("checkSameLR"))
135 , m_xCntSharedFirstBox(m_xBuilder->weld_check_button("checkSameFP"))
136 , m_xLMLbl(m_xBuilder->weld_label("labelLeftMarg"))
137 , m_xLMEdit(m_xBuilder->weld_metric_spin_button("spinMargLeft", FieldUnit::CM))
138 , m_xRMLbl(m_xBuilder->weld_label("labelRightMarg"))
139 , m_xRMEdit(m_xBuilder->weld_metric_spin_button("spinMargRight", FieldUnit::CM))
140 , m_xDistFT(m_xBuilder->weld_label("labelSpacing"))
141 , m_xDistEdit(m_xBuilder->weld_metric_spin_button("spinSpacing", FieldUnit::CM))
142 , m_xDynSpacingCB(m_xBuilder->weld_check_button("checkDynSpacing"))
143 , m_xHeightFT(m_xBuilder->weld_label("labelHeight"))
144 , m_xHeightEdit(m_xBuilder->weld_metric_spin_button("spinHeight", FieldUnit::CM))
145 , m_xHeightDynBtn(m_xBuilder->weld_check_button("checkAutofit"))
146 , m_xBackgroundBtn(m_xBuilder->weld_button("buttonMore"))
147 , m_xBspWin(new weld::CustomWeld(*m_xBuilder, "drawingareaPageHF", m_aBspWin))
148 {
149 //swap header <-> footer in UI
150 if (nId == SID_ATTR_PAGE_FOOTERSET)
151 {
152 m_xContainer->set_help_id("svx/ui/headfootformatpage/FFormatPage");
153 m_xPageLbl = m_xBuilder->weld_label("labelFooterFormat");
154 m_xTurnOnBox = m_xBuilder->weld_check_button("checkFooterOn");
155
156 /* Set custom HIDs for the Footer help page (shared/01/05040400.xhp)
157 otherwise it would display the same extended help
158 on both the Header and Footer tabs */
159 m_xCntSharedBox->set_help_id( "SVX_HID_FOOTER_CHECKSAMELR" );
160 m_xCntSharedFirstBox->set_help_id( "SVX_HID_FOOTER_CHECKSAMEFP" );
161 m_xLMEdit->set_help_id( "SVX_HID_FOOTER_SPINMARGLEFT" );
162 m_xRMEdit->set_help_id( "SVX_HID_FOOTER_SPINMARGRIGHT" );
163 m_xDistEdit->set_help_id( "SVX_HID_FOOTER_SPINSPACING" );
164 m_xDynSpacingCB->set_help_id( "SVX_HID_FOOTER_CHECKDYNSPACING" );
165 m_xHeightEdit->set_help_id( "SVX_HID_FOOTER_SPINHEIGHT" );
166 m_xHeightDynBtn->set_help_id( "SVX_HID_FOOTER_CHECKAUTOFIT" );
167 m_xBackgroundBtn->set_help_id( "SVX_HID_FOOTER_BUTTONMORE" );
168 }
169 else //Header
170 {
171 m_xContainer->set_help_id("svx/ui/headfootformatpage/HFormatPage");
172 m_xPageLbl = m_xBuilder->weld_label("labelHeaderFormat");
173 m_xTurnOnBox = m_xBuilder->weld_check_button("checkHeaderOn");
174 }
175 m_xTurnOnBox->show();
176 m_xPageLbl->show();
177
178 InitHandler();
179 m_aBspWin.EnableRTL(false);
180
181 // This Page needs ExchangeSupport
182 SetExchangeSupport();
183
184 // Set metrics
185 FieldUnit eFUnit = GetModuleFieldUnit( rSet );
186 SetFieldUnit( *m_xDistEdit, eFUnit );
187 SetFieldUnit( *m_xHeightEdit, eFUnit );
188 SetFieldUnit( *m_xLMEdit, eFUnit );
189 SetFieldUnit( *m_xRMEdit, eFUnit );
190 }
191
~SvxHFPage()192 SvxHFPage::~SvxHFPage()
193 {
194 }
195
FillItemSet(SfxItemSet * rSet)196 bool SvxHFPage::FillItemSet( SfxItemSet* rSet )
197 {
198 const sal_uInt16 nWSize = GetWhich(SID_ATTR_PAGE_SIZE);
199 const sal_uInt16 nWLRSpace = GetWhich(SID_ATTR_LRSPACE);
200 const sal_uInt16 nWULSpace = GetWhich(SID_ATTR_ULSPACE);
201 const sal_uInt16 nWOn = GetWhich(SID_ATTR_PAGE_ON);
202 const sal_uInt16 nWDynamic = GetWhich(SID_ATTR_PAGE_DYNAMIC);
203 const sal_uInt16 nWDynSpacing = GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING);
204 const sal_uInt16 nWShared = GetWhich(SID_ATTR_PAGE_SHARED);
205 const sal_uInt16 nWSharedFirst = GetWhich( SID_ATTR_PAGE_SHARED_FIRST );
206 const sal_uInt16 nWBrush = GetWhich(SID_ATTR_BRUSH);
207 const sal_uInt16 nWBox = GetWhich(SID_ATTR_BORDER_OUTER);
208 const sal_uInt16 nWBoxInfo = GetWhich(SID_ATTR_BORDER_INNER);
209 const sal_uInt16 nWShadow = GetWhich(SID_ATTR_BORDER_SHADOW);
210
211 const sal_uInt16 aWhichTab[] = {
212 nWSize, nWSize,
213 nWLRSpace, nWLRSpace,
214 nWULSpace, nWULSpace,
215 nWOn, nWOn,
216 nWDynamic, nWDynamic,
217 nWShared, nWShared,
218 nWSharedFirst, nWSharedFirst,
219 nWBrush, nWBrush,
220 nWBoxInfo, nWBoxInfo,
221 nWBox, nWBox,
222 nWShadow, nWShadow,
223 nWDynSpacing, nWDynSpacing,
224
225 // take over DrawingLayer FillStyles
226 XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014
227
228 0, 0};
229
230 const SfxItemSet& rOldSet = GetItemSet();
231 SfxItemPool* pPool = rOldSet.GetPool();
232 DBG_ASSERT(pPool,"no pool :-(");
233 MapUnit eUnit = pPool->GetMetric(nWSize);
234 SfxItemSet aSet(*pPool,aWhichTab);
235
236 if(mbEnableDrawingLayerFillStyles)
237 {
238 // When using the XATTR_FILLSTYLE DrawingLayer FillStyle definition
239 // extra action has to be done here since the pool default is drawing::FillStyle_SOLID
240 // instead of drawing::FillStyle_NONE (to have the default blue fill color at start).
241 aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
242 }
243
244 aSet.Put( SfxBoolItem( nWOn, m_xTurnOnBox->get_active() ) );
245 aSet.Put( SfxBoolItem( nWDynamic, m_xHeightDynBtn->get_active() ) );
246 aSet.Put( SfxBoolItem( nWShared, m_xCntSharedBox->get_active() ) );
247 if(m_xCntSharedFirstBox->get_visible())
248 aSet.Put(SfxBoolItem(nWSharedFirst, m_xCntSharedFirstBox->get_active()));
249 if (m_xDynSpacingCB->get_visible() && SfxItemPool::IsWhich(nWDynSpacing))
250 {
251 std::unique_ptr<SfxBoolItem> pBoolItem(static_cast<SfxBoolItem*>(pPool->GetDefaultItem(nWDynSpacing).Clone()));
252 pBoolItem->SetValue(m_xDynSpacingCB->get_active());
253 aSet.Put(std::move(pBoolItem));
254 }
255
256 // Size
257 SvxSizeItem aSizeItem( static_cast<const SvxSizeItem&>(rOldSet.Get( nWSize )) );
258 Size aSize( aSizeItem.GetSize() );
259 long nDist = GetCoreValue( *m_xDistEdit, eUnit );
260 long nH = GetCoreValue( *m_xHeightEdit, eUnit );
261
262 nH += nDist; // add distance
263 aSize.setHeight( nH );
264 aSizeItem.SetSize( aSize );
265 aSet.Put( aSizeItem );
266
267 // Margins
268 SvxLRSpaceItem aLR( nWLRSpace );
269 aLR.SetLeft( static_cast<sal_uInt16>(GetCoreValue( *m_xLMEdit, eUnit )) );
270 aLR.SetRight( static_cast<sal_uInt16>(GetCoreValue( *m_xRMEdit, eUnit )) );
271 aSet.Put( aLR );
272
273 SvxULSpaceItem aUL( nWULSpace );
274 if ( nId == SID_ATTR_PAGE_HEADERSET )
275 aUL.SetLower( static_cast<sal_uInt16>(nDist) );
276 else
277 aUL.SetUpper( static_cast<sal_uInt16>(nDist) );
278 aSet.Put( aUL );
279
280 // Background and border?
281 if (pBBSet)
282 {
283 aSet.Put(*pBBSet);
284 }
285 else
286 {
287 const SfxPoolItem* pItem;
288
289 if(SfxItemState::SET == GetItemSet().GetItemState(GetWhich(nId), false, &pItem))
290 {
291 const SfxItemSet* _pSet = &(static_cast< const SvxSetItem* >(pItem)->GetItemSet());
292
293 if(_pSet->GetItemState(nWBrush) == SfxItemState::SET)
294 {
295 aSet.Put(_pSet->Get(nWBrush));
296 }
297
298 if(_pSet->GetItemState(nWBoxInfo) == SfxItemState::SET)
299 {
300 aSet.Put(_pSet->Get(nWBoxInfo));
301 }
302
303 if(_pSet->GetItemState(nWBox) == SfxItemState::SET)
304 {
305 aSet.Put(_pSet->Get(nWBox));
306 }
307
308 if(_pSet->GetItemState(nWShadow) == SfxItemState::SET)
309 {
310 aSet.Put(_pSet->Get(nWShadow));
311 }
312
313 // take care of [XATTR_XATTR_FILL_FIRST .. XATTR_FILL_LAST]
314 for(sal_uInt16 nFillStyleId(XATTR_FILL_FIRST); nFillStyleId <= XATTR_FILL_LAST; nFillStyleId++)
315 {
316 if(_pSet->GetItemState(nFillStyleId) == SfxItemState::SET)
317 {
318 aSet.Put(_pSet->Get(nFillStyleId));
319 }
320 }
321 }
322 }
323
324 // Flush the SetItem
325 SvxSetItem aSetItem( GetWhich( nId ), aSet );
326 rSet->Put( aSetItem );
327
328 return true;
329 }
330
331
Reset(const SfxItemSet * rSet)332 void SvxHFPage::Reset( const SfxItemSet* rSet )
333 {
334 ActivatePage( *rSet );
335 ResetBackground_Impl( *rSet );
336
337 SfxItemPool* pPool = GetItemSet().GetPool();
338 DBG_ASSERT( pPool, "Where is the pool" );
339 MapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_PAGE_SIZE ) );
340
341 //hide "same content on first page when this is calc
342 bool bIsCalc = false;
343 const SfxPoolItem* pExt1 = GetItem(*rSet, SID_ATTR_PAGE_EXT1);
344 const SfxPoolItem* pExt2 = GetItem(*rSet, SID_ATTR_PAGE_EXT2);
345 if (dynamic_cast<const SfxBoolItem*>(pExt1) && dynamic_cast<const SfxBoolItem*>(pExt2) )
346 bIsCalc = true;
347 m_xCntSharedFirstBox->set_visible(!bIsCalc);
348
349 // Evaluate header-/footer- attributes
350 const SvxSetItem* pSetItem = nullptr;
351
352 if ( SfxItemState::SET == rSet->GetItemState( GetWhich(nId), false,
353 reinterpret_cast<const SfxPoolItem**>(&pSetItem) ) )
354 {
355 const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
356 const SfxBoolItem& rHeaderOn =
357 static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
358
359 m_xTurnOnBox->set_active(rHeaderOn.GetValue());
360
361 if ( rHeaderOn.GetValue() )
362 {
363 const SfxBoolItem& rDynamic =
364 static_cast<const SfxBoolItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_DYNAMIC ) ));
365 const SfxBoolItem& rShared =
366 static_cast<const SfxBoolItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SHARED ) ));
367 const SfxBoolItem* pSharedFirst = nullptr;
368 if (rHeaderSet.HasItem(GetWhich(SID_ATTR_PAGE_SHARED_FIRST)))
369 pSharedFirst = static_cast<const SfxBoolItem*>(&rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SHARED_FIRST ) ));
370 const SvxSizeItem& rSize =
371 static_cast<const SvxSizeItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ));
372 const SvxULSpaceItem& rUL =
373 static_cast<const SvxULSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ));
374 const SvxLRSpaceItem& rLR =
375 static_cast<const SvxLRSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
376 if (m_xDynSpacingCB->get_visible())
377 {
378 const SfxBoolItem& rDynSpacing =
379 static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING)));
380 m_xDynSpacingCB->set_active(rDynSpacing.GetValue());
381 }
382
383
384 if ( nId == SID_ATTR_PAGE_HEADERSET )
385 { // Header
386 SetMetricValue( *m_xDistEdit, rUL.GetLower(), eUnit );
387 SetMetricValue( *m_xHeightEdit, rSize.GetSize().Height() - rUL.GetLower(), eUnit );
388 }
389 else
390 { // Footer
391 SetMetricValue( *m_xDistEdit, rUL.GetUpper(), eUnit );
392 SetMetricValue( *m_xHeightEdit, rSize.GetSize().Height() - rUL.GetUpper(), eUnit );
393 }
394
395 m_xHeightDynBtn->set_active(rDynamic.GetValue());
396 SetMetricValue( *m_xLMEdit, rLR.GetLeft(), eUnit );
397 SetMetricValue( *m_xRMEdit, rLR.GetRight(), eUnit );
398 m_xCntSharedBox->set_active(rShared.GetValue());
399 if (pSharedFirst)
400 m_xCntSharedFirstBox->set_active(pSharedFirst->GetValue());
401 else
402 m_xCntSharedFirstBox->hide();
403 }
404 else
405 pSetItem = nullptr;
406 }
407 else
408 {
409 // defaults for distance and height
410 long nDefaultDist = bIsCalc ? DEF_DIST_CALC : DEF_DIST_WRITER;
411 SetMetricValue( *m_xDistEdit, nDefaultDist, MapUnit::Map100thMM );
412 SetMetricValue( *m_xHeightEdit, 500, MapUnit::Map100thMM );
413 }
414
415 if ( !pSetItem )
416 {
417 m_xTurnOnBox->set_active(false);
418 m_xHeightDynBtn->set_active(true);
419 m_xCntSharedBox->set_active(true);
420 m_xCntSharedFirstBox->set_active(true);
421 }
422
423 TurnOn(nullptr);
424
425 m_xTurnOnBox->save_state();
426 m_xDistEdit->save_value();
427 m_xHeightEdit->save_value();
428 m_xHeightDynBtn->save_state();
429 m_xLMEdit->save_value();
430 m_xRMEdit->save_value();
431 m_xCntSharedBox->save_state();
432 RangeHdl();
433
434 const SfxPoolItem* pItem = nullptr;
435 SfxObjectShell* pShell;
436 if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem) ||
437 ( nullptr != (pShell = SfxObjectShell::Current()) &&
438 nullptr != (pItem = pShell->GetItem(SID_HTML_MODE))))
439 {
440 sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
441 if (nHtmlMode & HTMLMODE_ON)
442 {
443 m_xCntSharedBox->hide();
444 m_xBackgroundBtn->hide();
445 }
446 }
447
448 }
449
InitHandler()450 void SvxHFPage::InitHandler()
451 {
452 m_xTurnOnBox->connect_toggled(LINK(this, SvxHFPage, TurnOnHdl));
453 m_xDistEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl));
454 m_xHeightEdit->connect_value_changed(LINK(this,SvxHFPage,ValueChangeHdl));
455
456 m_xLMEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl));
457 m_xRMEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl));
458 m_xBackgroundBtn->connect_clicked(LINK(this,SvxHFPage, BackgroundHdl));
459 }
460
TurnOn(const weld::ToggleButton * pBox)461 void SvxHFPage::TurnOn(const weld::ToggleButton* pBox)
462 {
463 if (m_xTurnOnBox->get_active())
464 {
465 m_xDistFT->set_sensitive(true);
466 m_xDistEdit->set_sensitive(true);
467 m_xDynSpacingCB->set_sensitive(true);
468 m_xHeightFT->set_sensitive(true);
469 m_xHeightEdit->set_sensitive(true);
470 m_xHeightDynBtn->set_sensitive(true);
471 m_xLMLbl->set_sensitive(true);
472 m_xLMEdit->set_sensitive(true);
473 m_xRMLbl->set_sensitive(true);
474 m_xRMEdit->set_sensitive(true);
475
476 SvxPageUsage nUsage = m_aBspWin.GetUsage();
477
478 if( nUsage == SvxPageUsage::Right || nUsage == SvxPageUsage::Left )
479 m_xCntSharedBox->set_sensitive(false);
480 else
481 {
482 m_xCntSharedBox->set_sensitive(true);
483 m_xCntSharedFirstBox->set_sensitive(true);
484 }
485 m_xBackgroundBtn->set_sensitive(true);
486 }
487 else
488 {
489 bool bDelete = true;
490
491 if (!mbDisableQueryBox && pBox && m_xTurnOnBox->get_saved_state() == TRISTATE_TRUE)
492 {
493 short nResult;
494 if (nId == SID_ATTR_PAGE_HEADERSET)
495 {
496 DeleteHeaderDialog aDlg(GetFrameWeld());
497 nResult = aDlg.run();
498 }
499 else
500 {
501 DeleteFooterDialog aDlg(GetFrameWeld());
502 nResult = aDlg.run();
503 }
504 bDelete = nResult == RET_YES;
505 }
506
507 if ( bDelete )
508 {
509 m_xDistFT->set_sensitive(false);
510 m_xDistEdit->set_sensitive(false);
511 m_xDynSpacingCB->set_sensitive(false);
512 m_xHeightFT->set_sensitive(false);
513 m_xHeightEdit->set_sensitive(false);
514 m_xHeightDynBtn->set_sensitive(false);
515
516 m_xLMLbl->set_sensitive(false);
517 m_xLMEdit->set_sensitive(false);
518 m_xRMLbl->set_sensitive(false);
519 m_xRMEdit->set_sensitive(false);
520
521 m_xCntSharedBox->set_sensitive(false);
522 m_xBackgroundBtn->set_sensitive(false);
523 m_xCntSharedFirstBox->set_sensitive(false);
524 }
525 else
526 m_xTurnOnBox->set_active(true);
527 }
528 UpdateExample();
529 }
530
IMPL_LINK(SvxHFPage,TurnOnHdl,weld::ToggleButton &,rBox,void)531 IMPL_LINK(SvxHFPage, TurnOnHdl, weld::ToggleButton&, rBox, void)
532 {
533 TurnOn(&rBox);
534 }
535
IMPL_LINK_NOARG(SvxHFPage,BackgroundHdl,weld::Button &,void)536 IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, weld::Button&, void)
537 {
538 if(!pBBSet)
539 {
540 // Use only the necessary items for border and background
541 const sal_uInt16 nOuter(GetWhich(SID_ATTR_BORDER_OUTER));
542 const sal_uInt16 nInner(GetWhich(SID_ATTR_BORDER_INNER, false));
543 const sal_uInt16 nShadow(GetWhich(SID_ATTR_BORDER_SHADOW));
544
545 if(mbEnableDrawingLayerFillStyles)
546 {
547 pBBSet.reset(new SfxItemSet(
548 *GetItemSet().GetPool(),
549 {{XATTR_FILL_FIRST, XATTR_FILL_LAST}, // DrawingLayer FillStyle definitions
550 {SID_COLOR_TABLE, SID_PATTERN_LIST}, // XPropertyLists for Color, Gradient, Hatch and Graphic fills
551 {nOuter, nOuter},
552 {nInner, nInner},
553 {nShadow, nShadow}}));
554
555 // copy items for XPropertyList entries from the DrawModel so that
556 // the Area TabPage can access them
557 static const sal_uInt16 nCopyFlags[] = {
558 SID_COLOR_TABLE,
559 SID_GRADIENT_LIST,
560 SID_HATCH_LIST,
561 SID_BITMAP_LIST,
562 SID_PATTERN_LIST,
563 0
564 };
565
566 for(sal_uInt16 a(0); nCopyFlags[a]; a++)
567 {
568 const SfxPoolItem* pItem = GetItemSet().GetItem(nCopyFlags[a]);
569
570 if(pItem)
571 {
572 pBBSet->Put(*pItem);
573 }
574 else
575 {
576 OSL_ENSURE(false, "XPropertyList missing (!)");
577 }
578 }
579 }
580 else
581 {
582 const sal_uInt16 nBrush(GetWhich(SID_ATTR_BRUSH));
583
584 pBBSet.reset( new SfxItemSet(
585 *GetItemSet().GetPool(),
586 {{XATTR_FILL_FIRST, XATTR_FILL_LAST},
587 {nBrush, nBrush},
588 {nOuter, nOuter},
589 {nInner, nInner},
590 {nShadow, nShadow}}) );
591 }
592
593 const SfxPoolItem* pItem;
594
595 if(SfxItemState::SET == GetItemSet().GetItemState(GetWhich(nId), false, &pItem))
596 {
597 // If a SfxItemSet from the SetItem for SID_ATTR_PAGE_HEADERSET or
598 // SID_ATTR_PAGE_FOOTERSET exists, use its content
599 pBBSet->Put(static_cast<const SvxSetItem*>(pItem)->GetItemSet());
600 }
601 else
602 {
603 if(mbEnableDrawingLayerFillStyles)
604 {
605 // The style for header/footer is not yet created, need to reset
606 // XFillStyleItem to drawing::FillStyle_NONE which is the same as in the style
607 // initialization. This needs to be done since the pool default for
608 // XFillStyleItem is drawing::FillStyle_SOLID
609 pBBSet->Put(XFillStyleItem(drawing::FillStyle_NONE));
610 }
611 }
612
613 if(SfxItemState::SET == GetItemSet().GetItemState(nInner, false, &pItem))
614 {
615 // The set InfoItem is always required
616 pBBSet->Put(*pItem);
617 }
618 }
619
620 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
621
622 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxBorderBackgroundDlg(
623 GetFrameWeld(),
624 *pBBSet,
625 mbEnableDrawingLayerFillStyles));
626
627 if(RET_OK == pDlg->Execute() && pDlg->GetOutputItemSet())
628 {
629 SfxItemIter aIter(*pDlg->GetOutputItemSet());
630
631 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
632 {
633 if(!IsInvalidItem(pItem))
634 {
635 pBBSet->Put(*pItem);
636 }
637 }
638
639 {
640 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes;
641
642 if(mbEnableDrawingLayerFillStyles)
643 {
644 // create FillAttributes directly from DrawingLayer FillStyle entries
645 aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(*pBBSet));
646 }
647 else
648 {
649 const sal_uInt16 nWhich = GetWhich(SID_ATTR_BRUSH);
650
651 if(pBBSet->GetItemState(nWhich) == SfxItemState::SET)
652 {
653 // create FillAttributes from SvxBrushItem
654 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(pBBSet->Get(nWhich));
655 SfxItemSet aTempSet(*pBBSet->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
656
657 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
658 aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
659 }
660 }
661
662 if(SID_ATTR_PAGE_HEADERSET == nId)
663 {
664 //m_aBspWin.SetHdColor(rItem.GetColor());
665 m_aBspWin.setHeaderFillAttributes(aFillAttributes);
666 }
667 else
668 {
669 //m_aBspWin.SetFtColor(rItem.GetColor());
670 m_aBspWin.setFooterFillAttributes(aFillAttributes);
671 }
672 }
673
674 }
675
676 UpdateExample();
677 }
678
UpdateExample()679 void SvxHFPage::UpdateExample()
680 {
681 if ( nId == SID_ATTR_PAGE_HEADERSET )
682 {
683 m_aBspWin.SetHeader( m_xTurnOnBox->get_active() );
684 m_aBspWin.SetHdHeight( GetCoreValue( *m_xHeightEdit, MapUnit::MapTwip ) );
685 m_aBspWin.SetHdDist( GetCoreValue( *m_xDistEdit, MapUnit::MapTwip ) );
686 m_aBspWin.SetHdLeft( GetCoreValue( *m_xLMEdit, MapUnit::MapTwip ) );
687 m_aBspWin.SetHdRight( GetCoreValue( *m_xRMEdit, MapUnit::MapTwip ) );
688 }
689 else
690 {
691 m_aBspWin.SetFooter( m_xTurnOnBox->get_active() );
692 m_aBspWin.SetFtHeight( GetCoreValue( *m_xHeightEdit, MapUnit::MapTwip ) );
693 m_aBspWin.SetFtDist( GetCoreValue( *m_xDistEdit, MapUnit::MapTwip ) );
694 m_aBspWin.SetFtLeft( GetCoreValue( *m_xLMEdit, MapUnit::MapTwip ) );
695 m_aBspWin.SetFtRight( GetCoreValue( *m_xRMEdit, MapUnit::MapTwip ) );
696 }
697 m_aBspWin.Invalidate();
698 }
699
ResetBackground_Impl(const SfxItemSet & rSet)700 void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet )
701 {
702 sal_uInt16 nWhich(GetWhich(SID_ATTR_PAGE_HEADERSET));
703
704 if (SfxItemState::SET == rSet.GetItemState(nWhich, false))
705 {
706 const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, false));
707 const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
708 const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
709
710 if(rOn.GetValue())
711 {
712 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aHeaderFillAttributes;
713
714 if(mbEnableDrawingLayerFillStyles)
715 {
716 // create FillAttributes directly from DrawingLayer FillStyle entries
717 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet));
718 }
719 else
720 {
721 nWhich = GetWhich(SID_ATTR_BRUSH);
722
723 if(SfxItemState::SET == rTmpSet.GetItemState(nWhich))
724 {
725 // create FillAttributes from SvxBrushItem
726 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
727 SfxItemSet aTempSet(*rTmpSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
728
729 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
730 aHeaderFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
731 }
732 }
733
734 m_aBspWin.setHeaderFillAttributes(aHeaderFillAttributes);
735 }
736 }
737
738 nWhich = GetWhich(SID_ATTR_PAGE_FOOTERSET);
739
740 if (SfxItemState::SET == rSet.GetItemState(nWhich, false))
741 {
742 const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, false));
743 const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
744 const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)));
745
746 if(rOn.GetValue())
747 {
748 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes;
749
750 if(mbEnableDrawingLayerFillStyles)
751 {
752 // create FillAttributes directly from DrawingLayer FillStyle entries
753 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rTmpSet));
754 }
755 else
756 {
757 nWhich = GetWhich(SID_ATTR_BRUSH);
758
759 if(SfxItemState::SET == rTmpSet.GetItemState(nWhich))
760 {
761 // create FillAttributes from SvxBrushItem
762 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rTmpSet.Get(nWhich));
763 SfxItemSet aTempSet(*rTmpSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
764
765 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
766 aFooterFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
767 }
768 }
769
770 m_aBspWin.setFooterFillAttributes(aFooterFillAttributes);
771 }
772 }
773
774 drawinglayer::attribute::SdrAllFillAttributesHelperPtr aPageFillAttributes;
775
776 if(mbEnableDrawingLayerFillStyles)
777 {
778 // create FillAttributes directly from DrawingLayer FillStyle entries
779 aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(rSet));
780 }
781 else
782 {
783 nWhich = GetWhich(SID_ATTR_BRUSH);
784
785 if(rSet.GetItemState(nWhich) >= SfxItemState::DEFAULT)
786 {
787 // create FillAttributes from SvxBrushItem
788 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rSet.Get(nWhich));
789 SfxItemSet aTempSet(*rSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
790
791 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
792 aPageFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet));
793 }
794 }
795
796 m_aBspWin.setPageFillAttributes(aPageFillAttributes);
797 }
798
ActivatePage(const SfxItemSet & rSet)799 void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
800 {
801 const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_LRSPACE );
802
803 if ( pItem )
804 {
805 // Set left and right margins
806 const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem);
807
808 m_aBspWin.SetLeft( rLRSpace.GetLeft() );
809 m_aBspWin.SetRight( rLRSpace.GetRight() );
810 }
811 else
812 {
813 m_aBspWin.SetLeft( 0 );
814 m_aBspWin.SetRight( 0 );
815 }
816
817 pItem = GetItem( rSet, SID_ATTR_ULSPACE );
818
819 if ( pItem )
820 {
821 // Set top and bottom margins
822 const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(*pItem);
823
824 m_aBspWin.SetTop( rULSpace.GetUpper() );
825 m_aBspWin.SetBottom( rULSpace.GetLower() );
826 }
827 else
828 {
829 m_aBspWin.SetTop( 0 );
830 m_aBspWin.SetBottom( 0 );
831 }
832
833 SvxPageUsage nUsage = SvxPageUsage::All;
834 pItem = GetItem( rSet, SID_ATTR_PAGE );
835
836 if ( pItem )
837 nUsage = static_cast<const SvxPageItem*>(pItem)->GetPageUsage();
838
839 m_aBspWin.SetUsage( nUsage );
840
841 if ( SvxPageUsage::Right == nUsage || SvxPageUsage::Left == nUsage )
842 m_xCntSharedBox->set_sensitive(false);
843 else
844 {
845 m_xCntSharedBox->set_sensitive(true);
846 m_xCntSharedFirstBox->set_sensitive(true);
847 }
848 pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
849
850 if ( pItem )
851 {
852 // Orientation and Size from the PageItem
853 const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(*pItem);
854 // if the size is already swapped (Landscape)
855 m_aBspWin.SetSize( rSize.GetSize() );
856 }
857
858 // Evaluate Header attribute
859 const SvxSetItem* pSetItem = nullptr;
860
861 if ( SfxItemState::SET == rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
862 false,
863 reinterpret_cast<const SfxPoolItem**>(&pSetItem) ) )
864 {
865 const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
866 const SfxBoolItem& rHeaderOn =
867 static_cast<const SfxBoolItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ));
868
869 if ( rHeaderOn.GetValue() )
870 {
871 const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(
872 rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ));
873 const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(
874 rHeaderSet.Get( GetWhich(SID_ATTR_ULSPACE ) ));
875 const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(
876 rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
877 long nDist = rUL.GetLower();
878
879 m_aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist );
880 m_aBspWin.SetHdDist( nDist );
881 m_aBspWin.SetHdLeft( rLR.GetLeft() );
882 m_aBspWin.SetHdRight( rLR.GetRight() );
883 m_aBspWin.SetHeader( true );
884 }
885 else
886 pSetItem = nullptr;
887 }
888
889 if ( !pSetItem )
890 {
891 m_aBspWin.SetHeader( false );
892
893 if ( SID_ATTR_PAGE_HEADERSET == nId )
894 {
895 m_xCntSharedBox->set_sensitive(false);
896 m_xCntSharedFirstBox->set_sensitive(false);
897 }
898 }
899 pSetItem = nullptr;
900
901 if ( SfxItemState::SET == rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
902 false,
903 reinterpret_cast<const SfxPoolItem**>(&pSetItem) ) )
904 {
905 const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
906 const SfxBoolItem& rFooterOn =
907 static_cast<const SfxBoolItem&>(rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ));
908
909 if ( rFooterOn.GetValue() )
910 {
911 const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(
912 rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ));
913 const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(
914 rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) ));
915 const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(
916 rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ));
917 long nDist = rUL.GetUpper();
918
919 m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist );
920 m_aBspWin.SetFtDist( nDist );
921 m_aBspWin.SetFtLeft( rLR.GetLeft() );
922 m_aBspWin.SetFtRight( rLR.GetRight() );
923 m_aBspWin.SetFooter( true );
924 }
925 else
926 pSetItem = nullptr;
927 }
928
929 if ( !pSetItem )
930 {
931 m_aBspWin.SetFooter( false );
932
933 if ( SID_ATTR_PAGE_FOOTERSET == nId )
934 {
935 m_xCntSharedBox->set_sensitive(false);
936 m_xCntSharedFirstBox->set_sensitive(false);
937 }
938 }
939
940 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
941
942 if ( auto pBoolItem = dynamic_cast<const SfxBoolItem*>( pItem) )
943 {
944 m_aBspWin.SetTable( true );
945 m_aBspWin.SetHorz( pBoolItem->GetValue() );
946 }
947
948 pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
949
950 if ( auto pBoolItem = dynamic_cast<const SfxBoolItem*>( pItem) )
951 {
952 m_aBspWin.SetTable( true );
953 m_aBspWin.SetVert( pBoolItem->GetValue() );
954 }
955 ResetBackground_Impl( rSet );
956 RangeHdl();
957 }
958
DeactivatePage(SfxItemSet * _pSet)959 DeactivateRC SvxHFPage::DeactivatePage( SfxItemSet* _pSet )
960 {
961 if ( _pSet )
962 FillItemSet( _pSet );
963 return DeactivateRC::LeavePage;
964 }
965
IMPL_LINK_NOARG(SvxHFPage,ValueChangeHdl,weld::MetricSpinButton &,void)966 IMPL_LINK_NOARG(SvxHFPage, ValueChangeHdl, weld::MetricSpinButton&, void)
967 {
968 UpdateExample();
969 RangeHdl();
970 }
971
RangeHdl()972 void SvxHFPage::RangeHdl()
973 {
974 long nHHeight = m_aBspWin.GetHdHeight();
975 long nHDist = m_aBspWin.GetHdDist();
976
977 long nFHeight = m_aBspWin.GetFtHeight();
978 long nFDist = m_aBspWin.GetFtDist();
979
980 long nHeight = std::max(long(MINBODY),
981 static_cast<long>(m_xHeightEdit->denormalize(m_xHeightEdit->get_value(FieldUnit::TWIP))));
982 long nDist = m_xTurnOnBox->get_active() ?
983 static_cast<long>(m_xDistEdit->denormalize(m_xDistEdit->get_value(FieldUnit::TWIP))) : 0;
984
985 long nMin;
986 long nMax;
987
988 if ( nId == SID_ATTR_PAGE_HEADERSET )
989 {
990 nHHeight = nHeight;
991 nHDist = nDist;
992 }
993 else
994 {
995 nFHeight = nHeight;
996 nFDist = nDist;
997 }
998
999 // Current values of the side edges
1000 long nBT = m_aBspWin.GetTop();
1001 long nBB = m_aBspWin.GetBottom();
1002 long nBL = m_aBspWin.GetLeft();
1003 long nBR = m_aBspWin.GetRight();
1004
1005 long nH = m_aBspWin.GetSize().Height();
1006 long nW = m_aBspWin.GetSize().Width();
1007
1008 // Borders
1009 if ( nId == SID_ATTR_PAGE_HEADERSET )
1010 {
1011 // Header
1012 nMin = ( nH - nBB - nBT ) / 5; // 20%
1013 nMax = std::max( nH - nMin - nHDist - nFDist - nFHeight - nBB - nBT,
1014 nMin );
1015 m_xHeightEdit->set_max(m_xHeightEdit->normalize(nMax), FieldUnit::TWIP);
1016 nMin = ( nH - nBB - nBT ) / 5; // 20%
1017 nDist = std::max( nH - nMin - nHHeight - nFDist - nFHeight - nBB - nBT,
1018 long(0) );
1019 m_xDistEdit->set_max(m_xDistEdit->normalize(nDist), FieldUnit::TWIP);
1020 }
1021 else
1022 {
1023 // Footer
1024 nMin = ( nH - nBT - nBB ) / 5; // 20%
1025 nMax = std::max( nH - nMin - nFDist - nHDist - nHHeight - nBT - nBB,
1026 nMin );
1027 m_xHeightEdit->set_max(m_xHeightEdit->normalize(nMax), FieldUnit::TWIP);
1028 nMin = ( nH - nBT - nBB ) / 5; // 20%
1029 nDist = std::max( nH - nMin - nFHeight - nHDist - nHHeight - nBT - nBB,
1030 long(0) );
1031 m_xDistEdit->set_max(m_xDistEdit->normalize(nDist), FieldUnit::TWIP);
1032 }
1033
1034 // Limit Indentation
1035 nMax = nW - nBL - nBR -
1036 static_cast<long>(m_xRMEdit->denormalize(m_xRMEdit->get_value(FieldUnit::TWIP))) - MINBODY;
1037 m_xLMEdit->set_max(m_xLMEdit->normalize(nMax), FieldUnit::TWIP);
1038
1039 nMax = nW - nBL - nBR -
1040 static_cast<long>(m_xLMEdit->denormalize(m_xLMEdit->get_value(FieldUnit::TWIP))) - MINBODY;
1041 m_xRMEdit->set_max(m_xLMEdit->normalize(nMax), FieldUnit::TWIP);
1042 }
1043
EnableDynamicSpacing()1044 void SvxHFPage::EnableDynamicSpacing()
1045 {
1046 m_xDynSpacingCB->show();
1047 }
1048
PageCreated(const SfxAllItemSet & rSet)1049 void SvxHFPage::PageCreated(const SfxAllItemSet &rSet)
1050 {
1051 const SfxBoolItem* pSupportDrawingLayerFillStyleItem = rSet.GetItem<SfxBoolItem>(SID_DRAWINGLAYER_FILLSTYLES, false);
1052
1053 if (pSupportDrawingLayerFillStyleItem)
1054 {
1055 const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue());
1056
1057 mbEnableDrawingLayerFillStyles = bNew;
1058 }
1059 }
1060
1061 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1062