LCOV - code coverage report
Current view: top level - sw/source/core/uibase/docvw - HeaderFooterWin.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 261 0.4 %
Date: 2014-04-11 Functions: 2 20 10.0 %
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             : 
      10             : #include <app.hrc>
      11             : #include <docvw.hrc>
      12             : #include <globals.hrc>
      13             : #include <popup.hrc>
      14             : #include <svtools/svtools.hrc>
      15             : 
      16             : #include <cmdid.h>
      17             : #include <DashedLine.hxx>
      18             : #include <docsh.hxx>
      19             : #include <edtwin.hxx>
      20             : #include <fmthdft.hxx>
      21             : #include <HeaderFooterWin.hxx>
      22             : #include <pagedesc.hxx>
      23             : #include <pagefrm.hxx>
      24             : #include <SwRewriter.hxx>
      25             : #include <view.hxx>
      26             : #include <viewopt.hxx>
      27             : #include <wrtsh.hxx>
      28             : 
      29             : #include <basegfx/color/bcolortools.hxx>
      30             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      31             : #include <basegfx/polygon/b2dpolygon.hxx>
      32             : #include <basegfx/range/b2drectangle.hxx>
      33             : #include <basegfx/vector/b2dsize.hxx>
      34             : #include <drawinglayer/attribute/fillgradientattribute.hxx>
      35             : #include <drawinglayer/attribute/fontattribute.hxx>
      36             : #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
      37             : #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
      38             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      39             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      40             : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
      41             : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
      42             : #include <editeng/boxitem.hxx>
      43             : #include <svtools/svtresid.hxx>
      44             : #include <svx/hdft.hxx>
      45             : #include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
      46             : #include <vcl/decoview.hxx>
      47             : #include <vcl/gradient.hxx>
      48             : #include <vcl/menubtn.hxx>
      49             : #include <vcl/svapp.hxx>
      50             : #include <vcl/settings.hxx>
      51             : 
      52             : #define TEXT_PADDING 5
      53             : #define BOX_DISTANCE 10
      54             : #define BUTTON_WIDTH 18
      55             : 
      56             : using namespace basegfx;
      57             : using namespace basegfx::tools;
      58             : using namespace drawinglayer::attribute;
      59             : 
      60             : namespace
      61             : {
      62           0 :     static basegfx::BColor lcl_GetFillColor( basegfx::BColor aLineColor )
      63             :     {
      64           0 :         basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
      65           0 :         double nLuminance = aHslLine.getZ() * 2.5;
      66           0 :         if ( nLuminance == 0 )
      67           0 :             nLuminance = 0.5;
      68           0 :         else if ( nLuminance >= 1.0 )
      69           0 :             nLuminance = aHslLine.getZ() * 0.4;
      70           0 :         aHslLine.setZ( nLuminance );
      71           0 :         return basegfx::tools::hsl2rgb( aHslLine );
      72             :     }
      73             : 
      74           0 :     static basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor )
      75             :     {
      76           0 :         basegfx::BColor aHslDark = basegfx::tools::rgb2hsl( aDarkColor );
      77           0 :         double nLuminance = aHslDark.getZ() * 255 + 20;
      78           0 :         aHslDark.setZ( nLuminance / 255.0 );
      79           0 :         return basegfx::tools::hsl2rgb( aHslDark );
      80             :     }
      81             : 
      82           0 :     static B2DPolygon lcl_GetPolygon( const Rectangle& rRect, bool bHeader )
      83             :     {
      84           0 :         const double nRadius = 3;
      85           0 :         const double nKappa((M_SQRT2 - 1.0) * 4.0 / 3.0);
      86             : 
      87           0 :         B2DPolygon aPolygon;
      88           0 :         aPolygon.append( B2DPoint( rRect.Left(), rRect.Top() ) );
      89             : 
      90             :         {
      91           0 :             B2DPoint aCorner( rRect.Left(), rRect.Bottom() );
      92           0 :             B2DPoint aStart( rRect.Left(), rRect.Bottom() - nRadius );
      93           0 :             B2DPoint aEnd( rRect.Left() + nRadius, rRect.Bottom() );
      94           0 :             aPolygon.append( aStart );
      95             :             aPolygon.appendBezierSegment(
      96             :                     interpolate( aStart, aCorner, nKappa ),
      97             :                     interpolate( aEnd, aCorner, nKappa ),
      98           0 :                     aEnd );
      99             :         }
     100             : 
     101             :         {
     102           0 :             B2DPoint aCorner( rRect.Right(), rRect.Bottom() );
     103           0 :             B2DPoint aStart( rRect.Right() - nRadius, rRect.Bottom() );
     104           0 :             B2DPoint aEnd( rRect.Right(), rRect.Bottom() - nRadius );
     105           0 :             aPolygon.append( aStart );
     106             :             aPolygon.appendBezierSegment(
     107             :                     interpolate( aStart, aCorner, nKappa ),
     108             :                     interpolate( aEnd, aCorner, nKappa ),
     109           0 :                     aEnd );
     110             :         }
     111             : 
     112           0 :         aPolygon.append( B2DPoint( rRect.Right(), rRect.Top() ) );
     113             : 
     114           0 :         if ( !bHeader )
     115             :         {
     116           0 :             B2DRectangle aBRect( rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() );
     117             :             B2DHomMatrix aRotation = createRotateAroundPoint(
     118           0 :                    aBRect.getCenterX(), aBRect.getCenterY(), M_PI );
     119           0 :             aPolygon.transform( aRotation );
     120             :         }
     121             : 
     122           0 :         return aPolygon;
     123             :     }
     124             : }
     125             : 
     126           0 : SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader ) :
     127             :     MenuButton( pEditWin, WB_DIALOGCONTROL ),
     128             :     SwFrameControl( pEditWin, pPageFrm ),
     129             :     m_sLabel( ),
     130             :     m_bIsHeader( bHeader ),
     131             :     m_pPopupMenu( NULL ),
     132             :     m_pLine( NULL ),
     133             :     m_bIsAppearing( false ),
     134             :     m_nFadeRate( 100 ),
     135           0 :     m_aFadeTimer( )
     136             : {
     137             :     // Get the font and configure it
     138           0 :     Font aFont = GetSettings().GetStyleSettings().GetToolFont();
     139           0 :     SetZoomedPointFont( aFont );
     140             : 
     141             :     // Use pixels for the rest of the drawing
     142           0 :     SetMapMode( MapMode ( MAP_PIXEL ) );
     143             : 
     144             :     // Create the line control
     145           0 :     m_pLine = new SwDashedLine( GetEditWin(), &SwViewOption::GetHeaderFooterMarkColor );
     146           0 :     m_pLine->SetZOrder( this, WINDOW_ZORDER_BEFOR );
     147             : 
     148             :     // Create and set the PopupMenu
     149           0 :     m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) );
     150             : 
     151             :     // Rewrite the menu entries' text
     152           0 :     if ( m_bIsHeader )
     153             :     {
     154           0 :         m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_HEADER ) );
     155           0 :         m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_HEADER ) );
     156             :     }
     157             :     else
     158             :     {
     159           0 :         m_pPopupMenu->SetItemText( FN_HEADERFOOTER_EDIT, SW_RESSTR( STR_FORMAT_FOOTER ) );
     160           0 :         m_pPopupMenu->SetItemText( FN_HEADERFOOTER_DELETE, SW_RESSTR( STR_DELETE_FOOTER ) );
     161             :     }
     162             : 
     163           0 :     SetPopupMenu( m_pPopupMenu );
     164             : 
     165           0 :     m_aFadeTimer.SetTimeout( 50 );
     166           0 :     m_aFadeTimer.SetTimeoutHdl( LINK( this, SwHeaderFooterWin, FadeHandler ) );
     167           0 : }
     168             : 
     169           0 : SwHeaderFooterWin::~SwHeaderFooterWin( )
     170             : {
     171           0 :     delete m_pPopupMenu;
     172           0 :     delete m_pLine;
     173           0 : }
     174             : 
     175           0 : const SwPageFrm* SwHeaderFooterWin::GetPageFrame( )
     176             : {
     177           0 :     return static_cast< const SwPageFrm * >( GetFrame( ) );
     178             : }
     179             : 
     180           0 : void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineEnd )
     181             : {
     182             :     // Compute the text to show
     183           0 :     m_sLabel = SW_RESSTR( STR_HEADER_TITLE );
     184           0 :     if ( !m_bIsHeader )
     185           0 :         m_sLabel = SW_RESSTR( STR_FOOTER_TITLE );
     186           0 :     sal_Int32 nPos = m_sLabel.lastIndexOf( "%1" );
     187           0 :     m_sLabel = m_sLabel.replaceAt( nPos, 2, GetPageFrame()->GetPageDesc()->GetName() );
     188             : 
     189             :     // Compute the text size and get the box position & size from it
     190           0 :     Rectangle aTextRect;
     191           0 :     GetTextBoundRect( aTextRect, OUString( m_sLabel ) );
     192           0 :     Rectangle aTextPxRect = LogicToPixel( aTextRect );
     193           0 :     FontMetric aFontMetric = GetFontMetric( GetFont() );
     194           0 :     Size  aBoxSize ( aTextPxRect.GetWidth() + BUTTON_WIDTH + TEXT_PADDING * 2,
     195           0 :                      aFontMetric.GetLineHeight() + TEXT_PADDING  * 2 );
     196             : 
     197           0 :     long nYFooterOff = 0;
     198           0 :     if ( !m_bIsHeader )
     199           0 :         nYFooterOff = aBoxSize.Height();
     200             : 
     201           0 :     Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
     202           0 :                    aOffset.Y() - nYFooterOff );
     203             : 
     204           0 :     if ( Application::GetSettings().GetLayoutRTL() )
     205             :     {
     206           0 :         aBoxPos.setX( aOffset.X() + BOX_DISTANCE );
     207             :     }
     208             : 
     209             :     // Set the position & Size of the window
     210           0 :     SetPosSizePixel( aBoxPos, aBoxSize );
     211             : 
     212           0 :     double nYLinePos = aBoxPos.Y();
     213           0 :     if ( !m_bIsHeader )
     214           0 :         nYLinePos += aBoxSize.Height();
     215           0 :     Point aLinePos( nXLineStart, nYLinePos );
     216           0 :     Size aLineSize( nXLineEnd - nXLineStart, 1 );
     217           0 :     m_pLine->SetPosSizePixel( aLinePos, aLineSize );
     218           0 : }
     219             : 
     220           0 : void SwHeaderFooterWin::ShowAll( bool bShow )
     221             : {
     222           0 :     if ( !PopupMenu::IsInExecute() )
     223             :     {
     224           0 :         m_bIsAppearing = bShow;
     225             : 
     226           0 :         if ( m_aFadeTimer.IsActive( ) )
     227           0 :             m_aFadeTimer.Stop();
     228           0 :         m_aFadeTimer.Start( );
     229             :     }
     230           0 : }
     231             : 
     232           0 : bool SwHeaderFooterWin::Contains( const Point &rDocPt ) const
     233             : {
     234           0 :     Rectangle aRect( GetPosPixel(), GetSizePixel() );
     235           0 :     if ( aRect.IsInside( rDocPt ) )
     236           0 :         return true;
     237             : 
     238           0 :     Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
     239           0 :     if ( aLineRect.IsInside( rDocPt ) )
     240           0 :         return true;
     241             : 
     242           0 :     return false;
     243             : }
     244             : 
     245           0 : void SwHeaderFooterWin::Paint( const Rectangle& )
     246             : {
     247           0 :     const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
     248           0 :     drawinglayer::primitive2d::Primitive2DSequence aSeq( 3 );
     249             : 
     250           0 :     B2DPolygon aPolygon = lcl_GetPolygon( aRect, m_bIsHeader );
     251             : 
     252             :     // Colors
     253           0 :     basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
     254           0 :     basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
     255           0 :     basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor );
     256             : 
     257           0 :     const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     258           0 :     if ( rSettings.GetHighContrastMode() )
     259             :     {
     260           0 :         aFillColor = rSettings.GetDialogColor( ).getBColor();
     261           0 :         aLineColor = rSettings.GetDialogTextColor( ).getBColor();
     262             : 
     263           0 :         aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
     264           0 :                 B2DPolyPolygon( aPolygon ), aFillColor ) );
     265             :     }
     266             :     else
     267             :     {
     268           0 :         B2DRectangle aGradientRect( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() );
     269           0 :         double nAngle = M_PI;
     270           0 :         if ( m_bIsHeader )
     271           0 :             nAngle = 0;
     272             :         FillGradientAttribute aFillAttrs( GRADIENTSTYLE_LINEAR, 0.0, 0.0, 0.0, nAngle,
     273           0 :                 aLighterColor, aFillColor, 10 );
     274           0 :         aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::FillGradientPrimitive2D(
     275           0 :                 aGradientRect, aFillAttrs ) );
     276             :     }
     277             : 
     278             :     // Create the border lines primitive
     279           0 :     aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
     280           0 :             aPolygon, aLineColor ) );
     281             : 
     282             :     // Create the text primitive
     283           0 :     B2DVector aFontSize;
     284             :     FontAttribute aFontAttr = drawinglayer::primitive2d::getFontAttributeFromVclFont(
     285           0 :            aFontSize, GetFont(), false, false );
     286             : 
     287           0 :     FontMetric aFontMetric = GetFontMetric( GetFont() );
     288           0 :     double nTextOffsetY = aFontMetric.GetAscent() + TEXT_PADDING;
     289           0 :     Point aTextPos( TEXT_PADDING, nTextOffsetY );
     290             : 
     291             :     basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
     292             :                 aFontSize.getX(), aFontSize.getY(),
     293           0 :                 double( aTextPos.X() ), double( aTextPos.Y() ) ) );
     294             : 
     295           0 :     aSeq[2] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
     296             :                 aTextMatrix,
     297           0 :                 OUString( m_sLabel ), 0, m_sLabel.getLength(),
     298             :                 std::vector< double >( ),
     299             :                 aFontAttr,
     300             :                 com::sun::star::lang::Locale(),
     301           0 :                 aLineColor ) );
     302             : 
     303             :     // Create the 'plus' or 'arrow' primitive
     304           0 :     B2DRectangle aSignArea( B2DPoint( aRect.Right() - BUTTON_WIDTH, 0.0 ),
     305           0 :                             B2DSize( aRect.Right(), aRect.getHeight() ) );
     306             : 
     307           0 :     B2DPolygon aSign;
     308           0 :     if ( IsEmptyHeaderFooter( ) )
     309             :     {
     310             :         // Create the + polygon
     311           0 :         double nLeft = aSignArea.getMinX() + TEXT_PADDING;
     312           0 :         double nRight = aSignArea.getMaxX() - TEXT_PADDING;
     313           0 :         double nHalfW = ( nRight - nLeft ) / 2.0;
     314             : 
     315           0 :         double nTop = aSignArea.getCenterY() - nHalfW;
     316           0 :         double nBottom = aSignArea.getCenterY() + nHalfW;
     317             : 
     318           0 :         aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() - 1.0 ) );
     319           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() - 1.0 ) );
     320           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nTop ) );
     321           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nTop ) );
     322           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() - 1.0 ) );
     323           0 :         aSign.append( B2DPoint( nRight, aSignArea.getCenterY() - 1.0 ) );
     324           0 :         aSign.append( B2DPoint( nRight, aSignArea.getCenterY() + 1.0 ) );
     325           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, aSignArea.getCenterY() + 1.0 ) );
     326           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() + 1.0, nBottom ) );
     327           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, nBottom ) );
     328           0 :         aSign.append( B2DPoint( aSignArea.getCenterX() - 1.0, aSignArea.getCenterY() + 1.0  ) );
     329           0 :         aSign.append( B2DPoint( nLeft, aSignArea.getCenterY() + 1.0  ) );
     330           0 :         aSign.setClosed( true );
     331             :     }
     332             :     else
     333             :     {
     334             :         // Create the v polygon
     335           0 :         B2DPoint aLeft( aSignArea.getMinX() + TEXT_PADDING, aSignArea.getCenterY() );
     336           0 :         B2DPoint aRight( aSignArea.getMaxX() - TEXT_PADDING, aSignArea.getCenterY() );
     337           0 :         B2DPoint aBottom( ( aLeft.getX() + aRight.getX() ) / 2.0, aLeft.getY() + 4.0 );
     338           0 :         aSign.append( aLeft );
     339           0 :         aSign.append( aRight );
     340           0 :         aSign.append( aBottom );
     341           0 :         aSign.setClosed( true );
     342             :     }
     343             : 
     344           0 :     BColor aSignColor = Color( COL_BLACK ).getBColor( );
     345           0 :     if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
     346           0 :         aSignColor = Color( COL_WHITE ).getBColor( );
     347             : 
     348           0 :     aSeq.realloc( aSeq.getLength() + 1 );
     349           0 :     aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
     350           0 :             B2DPolyPolygon( aSign ), aSignColor ) );
     351             : 
     352             :     // Create the processor and process the primitives
     353           0 :     const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
     354             :     drawinglayer::processor2d::BaseProcessor2D * pProcessor =
     355             :         drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
     356           0 :                     *this, aNewViewInfos );
     357             : 
     358             :     // TODO Ghost it all if needed
     359           0 :     drawinglayer::primitive2d::Primitive2DSequence aGhostedSeq( 1 );
     360           0 :     double nFadeRate = double( m_nFadeRate ) / 100.0;
     361             :     const basegfx::BColorModifierSharedPtr aBColorModifier(
     362             :         new basegfx::BColorModifier_interpolate(
     363             :             Color( COL_WHITE ).getBColor(),
     364           0 :             1.0 - nFadeRate));
     365           0 :     aGhostedSeq[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
     366           0 :                 aSeq, aBColorModifier ) );
     367             : 
     368           0 :     pProcessor->process( aGhostedSeq );
     369           0 :     delete pProcessor;
     370           0 : }
     371             : 
     372           0 : bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
     373             : {
     374           0 :     bool bResult = true;
     375             : 
     376             :     // Actually check it
     377           0 :     const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
     378             : 
     379           0 :     bool const bFirst(GetPageFrame()->OnFirstPage());
     380           0 :     const SwFrmFmt *const pFmt = (GetPageFrame()->OnRightPage())
     381           0 :         ? pDesc->GetRightFmt(bFirst)
     382           0 :         : pDesc->GetLeftFmt(bFirst);
     383             : 
     384           0 :     if ( pFmt )
     385             :     {
     386           0 :         if ( m_bIsHeader )
     387           0 :             bResult = !pFmt->GetHeader().IsActive();
     388             :         else
     389           0 :             bResult = !pFmt->GetFooter().IsActive();
     390             :     }
     391             : 
     392           0 :     return bResult;
     393             : }
     394             : 
     395           0 : void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
     396             : {
     397           0 :     SwView& rView = GetEditWin()->GetView();
     398           0 :     SwWrtShell& rSh = rView.GetWrtShell();
     399             : 
     400           0 :     const OUString& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
     401           0 :     switch ( nSlot )
     402             :     {
     403             :         case FN_HEADERFOOTER_EDIT:
     404             :             {
     405           0 :                 OString sPageId = m_bIsHeader ? OString("header") : OString("footer");
     406           0 :                 rView.GetDocShell()->FormatPage(rStyleName, sPageId, rSh);
     407             :             }
     408           0 :             break;
     409             :         case FN_HEADERFOOTER_BORDERBACK:
     410             :             {
     411           0 :                 const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
     412           0 :                 const SwFrmFmt& rMaster = pDesc->GetMaster();
     413           0 :                 SwFrmFmt* pHFFmt = const_cast< SwFrmFmt* >( rMaster.GetFooter().GetFooterFmt() );
     414           0 :                 if ( m_bIsHeader )
     415           0 :                     pHFFmt = const_cast< SwFrmFmt* >( rMaster.GetHeader().GetHeaderFmt() );
     416             : 
     417           0 :                 SfxItemPool* pPool = pHFFmt->GetAttrSet().GetPool();
     418             :                 SfxItemSet aSet( *pPool,
     419             :                        RES_BACKGROUND, RES_BACKGROUND,
     420             :                        RES_BOX, RES_BOX,
     421             :                        SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
     422           0 :                        RES_SHADOW, RES_SHADOW, 0 );
     423             : 
     424           0 :                 aSet.Put( pHFFmt->GetAttrSet() );
     425             : 
     426             :                 // Create a box info item... needed by the dialog
     427           0 :                 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
     428             :                 const SfxPoolItem *pBoxInfo;
     429           0 :                 if ( SFX_ITEM_SET == pHFFmt->GetAttrSet().GetItemState( SID_ATTR_BORDER_INNER,
     430           0 :                                                         true, &pBoxInfo) )
     431           0 :                     aBoxInfo = *(SvxBoxInfoItem*)pBoxInfo;
     432             : 
     433           0 :                 aBoxInfo.SetTable( false );
     434           0 :                 aBoxInfo.SetDist( true);
     435           0 :                 aBoxInfo.SetMinDist( false );
     436           0 :                 aBoxInfo.SetDefDist( MIN_BORDER_DIST );
     437           0 :                 aBoxInfo.SetValid( VALID_DISABLE );
     438           0 :                 aSet.Put( aBoxInfo );
     439             : 
     440           0 :                 if ( svx::ShowBorderBackgroundDlg( this, &aSet, true ) )
     441             :                 {
     442             :                     const SfxPoolItem* pItem;
     443           0 :                     if ( SFX_ITEM_SET == aSet.GetItemState( RES_BACKGROUND, false, &pItem ) ) {
     444           0 :                         pHFFmt->SetFmtAttr( *pItem );
     445           0 :                         rView.GetDocShell()->SetModified(true);
     446             :                     }
     447             : 
     448           0 :                     if ( SFX_ITEM_SET == aSet.GetItemState( RES_BOX, false, &pItem ) ) {
     449           0 :                         pHFFmt->SetFmtAttr( *pItem );
     450           0 :                         rView.GetDocShell()->SetModified(true);
     451             :                     }
     452             : 
     453           0 :                     if ( SFX_ITEM_SET == aSet.GetItemState( RES_SHADOW, false, &pItem ) ) {
     454           0 :                         pHFFmt->SetFmtAttr( *pItem );
     455           0 :                         rView.GetDocShell()->SetModified(true);
     456             :                     }
     457           0 :                 }
     458             :             }
     459           0 :             break;
     460             :         case FN_HEADERFOOTER_DELETE:
     461             :             {
     462           0 :                 rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true );
     463             :             }
     464           0 :             break;
     465             :         default:
     466           0 :             break;
     467           0 :     }
     468           0 : }
     469             : 
     470           0 : void SwHeaderFooterWin::SetReadonly( bool bReadonly )
     471             : {
     472           0 :     ShowAll( !bReadonly );
     473           0 : }
     474             : 
     475           0 : void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
     476             : {
     477           0 :     if ( IsEmptyHeaderFooter( ) )
     478             :     {
     479           0 :         SwView& rView = GetEditWin()->GetView();
     480           0 :         SwWrtShell& rSh = rView.GetWrtShell();
     481             : 
     482           0 :         const OUString& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
     483           0 :         rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, true, false );
     484             :     }
     485             :     else
     486           0 :         MenuButton::MouseButtonDown( rMEvt );
     487           0 : }
     488             : 
     489           0 : void SwHeaderFooterWin::Select( )
     490             : {
     491           0 :     ExecuteCommand( GetCurItemId() );
     492           0 : }
     493             : 
     494           0 : IMPL_LINK_NOARG(SwHeaderFooterWin, FadeHandler)
     495             : {
     496           0 :     if ( m_bIsAppearing && m_nFadeRate > 0 )
     497           0 :         m_nFadeRate -= 25;
     498           0 :     else if ( !m_bIsAppearing && m_nFadeRate < 100 )
     499           0 :         m_nFadeRate += 25;
     500             : 
     501           0 :     if ( m_nFadeRate != 100 && !IsVisible() )
     502             :     {
     503           0 :         Show( true );
     504           0 :         m_pLine->Show( true );
     505             :     }
     506           0 :     else if ( m_nFadeRate == 100 && IsVisible( ) )
     507             :     {
     508           0 :         Show( false );
     509           0 :         m_pLine->Show( false );
     510             :     }
     511             :     else
     512           0 :         Invalidate();
     513             : 
     514           0 :     if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 )
     515           0 :         m_aFadeTimer.Start();
     516             : 
     517           0 :     return 0;
     518         111 : }
     519             : 
     520             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10