LCOV - code coverage report
Current view: top level - svx/source/dialog - hdft.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 486 0.2 %
Date: 2014-04-11 Functions: 2 33 6.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10