LCOV - code coverage report
Current view: top level - sw/source/ui/docvw - HeaderFooterWin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 258 0.0 %
Date: 2012-08-25 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 516 0.0 %

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

Generated by: LCOV version 1.10