LCOV - code coverage report
Current view: top level - sw/source/ui/docvw - PageBreakWin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 62 237 26.2 %
Date: 2012-08-25 Functions: 10 21 47.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 48 461 10.4 %

           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                 :            : #include <globals.hrc>
      29                 :            : #include <popup.hrc>
      30                 :            : #include <utlui.hrc>
      31                 :            : 
      32                 :            : #include <cmdid.h>
      33                 :            : #include <cntfrm.hxx>
      34                 :            : #include <DashedLine.hxx>
      35                 :            : #include <doc.hxx>
      36                 :            : #include <edtwin.hxx>
      37                 :            : #include <fmtpdsc.hxx>
      38                 :            : #include <IDocumentUndoRedo.hxx>
      39                 :            : #include <PageBreakWin.hxx>
      40                 :            : #include <pagefrm.hxx>
      41                 :            : #include <PostItMgr.hxx>
      42                 :            : #include <uiitems.hxx>
      43                 :            : #include <view.hxx>
      44                 :            : #include <viewopt.hxx>
      45                 :            : #include <wrtsh.hxx>
      46                 :            : 
      47                 :            : #include <basegfx/color/bcolortools.hxx>
      48                 :            : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      49                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      50                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      51                 :            : #include <basegfx/range/b2drectangle.hxx>
      52                 :            : #include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
      53                 :            : #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
      54                 :            : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      55                 :            : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      56                 :            : #include <editeng/brkitem.hxx>
      57                 :            : #include <sfx2/dispatch.hxx>
      58                 :            : #include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
      59                 :            : #include <vcl/svapp.hxx>
      60                 :            : 
      61                 :            : #define BUTTON_WIDTH 30
      62                 :            : #define BUTTON_HEIGHT 19
      63                 :            : #define ARROW_WIDTH 9
      64                 :            : 
      65                 :            : using namespace basegfx;
      66                 :            : using namespace basegfx::tools;
      67                 :            : using namespace drawinglayer::primitive2d;
      68                 :            : 
      69                 :            : namespace
      70                 :            : {
      71         [ -  + ]:         18 :     class SwBreakDashedLine : public SwDashedLine
      72                 :            :     {
      73                 :            :         private:
      74                 :            :             SwPageBreakWin* m_pWin;
      75                 :            : 
      76                 :            :         public:
      77                 :         12 :             SwBreakDashedLine( Window* pParent, Color& ( *pColorFn )(), SwPageBreakWin* pWin ) :
      78                 :            :                 SwDashedLine( pParent, pColorFn ),
      79                 :         12 :                 m_pWin( pWin ) {};
      80                 :            : 
      81                 :            :             virtual void MouseMove( const MouseEvent& rMEvt );
      82                 :            :     };
      83                 :            : 
      84                 :          0 :     void SwBreakDashedLine::MouseMove( const MouseEvent& rMEvt )
      85                 :            :     {
      86         [ #  # ]:          0 :         if ( rMEvt.IsLeaveWindow() )
      87                 :            :         {
      88                 :            :             // don't fade if we just move to the 'button'
      89         [ #  # ]:          0 :             Point aEventPos( GetPosPixel() + rMEvt.GetPosPixel() );
      90 [ #  # ][ #  # ]:          0 :             if ( !m_pWin->Contains( aEventPos ) || !m_pWin->IsVisible() )
         [ #  # ][ #  # ]
                 [ #  # ]
      91         [ #  # ]:          0 :                 m_pWin->Fade( false );
      92                 :            :         }
      93         [ #  # ]:          0 :         else if ( !m_pWin->IsVisible() )
      94                 :            :         {
      95                 :          0 :             m_pWin->Fade( true );
      96                 :            :         }
      97                 :            : 
      98 [ #  # ][ #  # ]:          0 :         if ( !rMEvt.IsSynthetic() && !m_pWin->IsVisible() )
                 [ #  # ]
      99                 :            :         {
     100                 :          0 :             Point* pPtr = new Point( rMEvt.GetPosPixel() );
     101                 :          0 :             m_pWin->UpdatePosition( pPtr );
     102                 :            :         }
     103                 :          0 :     }
     104                 :            : }
     105                 :            : 
     106                 :         12 : SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm ) :
     107                 :            :     MenuButton( pEditWin, WB_DIALOGCONTROL ),
     108                 :            :     SwFrameControl( pEditWin, pPageFrm ),
     109                 :            :     m_pPopupMenu( NULL ),
     110                 :            :     m_pLine( NULL ),
     111                 :            :     m_bIsAppearing( false ),
     112                 :            :     m_nFadeRate( 100 ),
     113                 :            :     m_nDelayAppearing( 0 ),
     114                 :            :     m_bDestroyed( false ),
     115         [ +  - ]:         12 :     m_pMousePt( NULL )
     116                 :            : {
     117                 :            :     // Use pixels for the rest of the drawing
     118 [ +  - ][ +  - ]:         12 :     SetMapMode( MapMode ( MAP_PIXEL ) );
                 [ +  - ]
     119                 :            : 
     120                 :            :     // Create the line control
     121 [ +  - ][ +  - ]:         12 :     m_pLine = new SwBreakDashedLine( GetEditWin(), &SwViewOption::GetPageBreakColor, this );
     122                 :            : 
     123                 :            :     // Create the popup menu
     124 [ +  - ][ +  - ]:         12 :     m_pPopupMenu = new PopupMenu( SW_RES( MN_PAGEBREAK_BUTTON ) );
     125         [ +  - ]:         12 :     m_pPopupMenu->SetDeactivateHdl( LINK( this, SwPageBreakWin, HideHandler ) );
     126         [ +  - ]:         12 :     SetPopupMenu( m_pPopupMenu );
     127                 :            : 
     128         [ +  - ]:         12 :     m_aFadeTimer.SetTimeout( 50 );
     129         [ +  - ]:         12 :     m_aFadeTimer.SetTimeoutHdl( LINK( this, SwPageBreakWin, FadeHandler ) );
     130                 :         12 : }
     131                 :            : 
     132         [ +  - ]:          9 : SwPageBreakWin::~SwPageBreakWin( )
     133                 :            : {
     134                 :          9 :     m_bDestroyed = true;
     135         [ +  - ]:          9 :     m_aFadeTimer.Stop();
     136                 :            : 
     137 [ +  - ][ +  - ]:          9 :     delete m_pPopupMenu;
     138 [ +  - ][ +  - ]:          9 :     delete m_pLine;
     139                 :          9 :     delete m_pMousePt;
     140         [ -  + ]:         18 : }
     141                 :            : 
     142                 :          0 : void SwPageBreakWin::Paint( const Rectangle& )
     143                 :            : {
     144 [ #  # ][ #  # ]:          0 :     const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
                 [ #  # ]
     145                 :            : 
     146                 :            :     // Properly paint the control
     147         [ #  # ]:          0 :     BColor aColor = SwViewOption::GetPageBreakColor().getBColor();
     148                 :            : 
     149         [ #  # ]:          0 :     BColor aHslLine = rgb2hsl( aColor );
     150                 :          0 :     double nLuminance = aHslLine.getZ();
     151                 :          0 :     nLuminance += ( 1.0 - nLuminance ) * 0.75;
     152         [ #  # ]:          0 :     if ( aHslLine.getZ() > 0.7 )
     153                 :          0 :         nLuminance = aHslLine.getZ() * 0.7;
     154                 :          0 :     aHslLine.setZ( nLuminance );
     155         [ #  # ]:          0 :     BColor aOtherColor = hsl2rgb( aHslLine );
     156                 :            : 
     157         [ #  # ]:          0 :     const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
     158         [ #  # ]:          0 :     if ( rSettings.GetHighContrastMode( ) )
     159                 :            :     {
     160         [ #  # ]:          0 :         aColor = rSettings.GetDialogTextColor().getBColor();
     161         [ #  # ]:          0 :         aOtherColor = rSettings.GetDialogColor( ).getBColor();
     162                 :            :     }
     163                 :            : 
     164 [ #  # ][ #  # ]:          0 :     bool bRtl = Application::GetSettings().GetLayoutRTL();
     165                 :            : 
     166         [ #  # ]:          0 :     Primitive2DSequence aSeq( 3 );
     167                 :          0 :     B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ),
     168         [ #  # ]:          0 :            double( aRect.Right() ), double( aRect.Bottom( ) ) );
     169         [ #  # ]:          0 :     B2DPolygon aPolygon = createPolygonFromRect( aBRect, 3.0 / BUTTON_WIDTH, 3.0 / BUTTON_HEIGHT );
     170                 :            : 
     171                 :            :     // Create the polygon primitives
     172         [ #  # ]:          0 :     aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
     173 [ #  # ][ #  # ]:          0 :             B2DPolyPolygon( aPolygon ), aOtherColor ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     174         [ #  # ]:          0 :     aSeq[1] = Primitive2DReference( new PolygonHairlinePrimitive2D(
     175 [ #  # ][ #  # ]:          0 :             aPolygon, aColor ) );
         [ #  # ][ #  # ]
     176                 :            : 
     177                 :            :     // Create the primitive for the image
     178         [ #  # ]:          0 :     Image aImg( SW_RES( IMG_PAGE_BREAK ) );
     179                 :          0 :     double nImgOfstX = 3.0;
     180         [ #  # ]:          0 :     if ( bRtl )
     181         [ #  # ]:          0 :         nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3.0;
     182         [ #  # ]:          0 :     aSeq[2] = Primitive2DReference( new DiscreteBitmapPrimitive2D(
     183 [ #  # ][ #  # ]:          0 :             aImg.GetBitmapEx(), B2DPoint( nImgOfstX, 1.0 ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     184                 :            : 
     185                 :          0 :     double nTop = double( aRect.getHeight() ) / 2.0;
     186                 :          0 :     double nBottom = nTop + 4.0;
     187                 :          0 :     double nLeft = aRect.getWidth( ) - ARROW_WIDTH - 6.0;
     188         [ #  # ]:          0 :     if ( bRtl )
     189                 :          0 :         nLeft = ARROW_WIDTH - 2.0;
     190                 :          0 :     double nRight = nLeft + 8.0;
     191                 :            : 
     192         [ #  # ]:          0 :     B2DPolygon aTriangle;
     193         [ #  # ]:          0 :     aTriangle.append( B2DPoint( nLeft, nTop ) );
     194         [ #  # ]:          0 :     aTriangle.append( B2DPoint( nRight, nTop ) );
     195         [ #  # ]:          0 :     aTriangle.append( B2DPoint( ( nLeft + nRight ) / 2.0, nBottom ) );
     196         [ #  # ]:          0 :     aTriangle.setClosed( true );
     197                 :            : 
     198                 :          0 :     BColor aTriangleColor = Color( COL_BLACK ).getBColor( );
     199 [ #  # ][ #  # ]:          0 :     if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
     200         [ #  # ]:          0 :         aTriangleColor = Color( COL_WHITE ).getBColor( );
     201                 :            : 
     202         [ #  # ]:          0 :     aSeq.realloc( aSeq.getLength() + 1 );
     203         [ #  # ]:          0 :     aSeq[ aSeq.getLength() - 1 ] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
     204 [ #  # ][ #  # ]:          0 :                B2DPolyPolygon( aTriangle ), aTriangleColor ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     205                 :            : 
     206         [ #  # ]:          0 :     Primitive2DSequence aGhostedSeq( 1 );
     207                 :          0 :     double nFadeRate = double( m_nFadeRate ) / 100.0;
     208         [ #  # ]:          0 :     aGhostedSeq[0] = Primitive2DReference( new ModifiedColorPrimitive2D(
     209 [ #  # ][ #  # ]:          0 :                 aSeq, BColorModifier( Color( COL_WHITE ).getBColor(), 1.0 - nFadeRate, BCOLORMODIFYMODE_INTERPOLATE ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     210                 :            : 
     211                 :            :     // Create the processor and process the primitives
     212         [ #  # ]:          0 :     const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
     213                 :            :     drawinglayer::processor2d::BaseProcessor2D * pProcessor =
     214                 :            :         drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
     215         [ #  # ]:          0 :                     *this, aNewViewInfos );
     216                 :            : 
     217 [ #  # ][ #  # ]:          0 :     pProcessor->process( aGhostedSeq );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     218                 :          0 : }
     219                 :            : 
     220                 :          0 : void SwPageBreakWin::Select( )
     221                 :            : {
     222         [ #  # ]:          0 :     SwFrameControlPtr pThis = GetEditWin()->GetFrameControlsManager( ).GetControl( PageBreak, GetFrame() );
     223                 :            : 
     224      [ #  #  # ]:          0 :     switch( GetCurItemId( ) )
     225                 :            :     {
     226                 :            :         case FN_PAGEBREAK_EDIT:
     227                 :            :             {
     228                 :          0 :                 const SwLayoutFrm* pBodyFrm = static_cast< const SwLayoutFrm* >( GetPageFrame()->Lower() );
     229 [ #  # ][ #  # ]:          0 :                 while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
                 [ #  # ]
     230                 :          0 :                     pBodyFrm = static_cast< const SwLayoutFrm* >( pBodyFrm->GetNext() );
     231                 :            : 
     232                 :          0 :                 SwEditWin* pEditWin = GetEditWin();
     233                 :            : 
     234         [ #  # ]:          0 :                 if ( pBodyFrm )
     235                 :            :                 {
     236                 :          0 :                     SwWrtShell& rSh = pEditWin->GetView().GetWrtShell();
     237                 :          0 :                     sal_Bool bOldLock = rSh.IsViewLocked();
     238                 :          0 :                     rSh.LockView( sal_True );
     239                 :            : 
     240         [ #  # ]:          0 :                     if ( pBodyFrm->Lower()->IsTabFrm() )
     241                 :            :                     {
     242         [ #  # ]:          0 :                         rSh.Push( );
     243         [ #  # ]:          0 :                         rSh.ClearMark();
     244                 :            : 
     245         [ #  # ]:          0 :                         SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
     246                 :          0 :                         SwCntntNode* pNd = pCnt->GetNode();
     247 [ #  # ][ #  # ]:          0 :                         rSh.SetSelection( *pNd );
                 [ #  # ]
     248                 :            : 
     249 [ #  # ][ #  # ]:          0 :                         SfxUInt16Item aItem( pEditWin->GetView().GetPool( ).GetWhich( FN_FORMAT_TABLE_DLG ), TP_TABLE_TEXTFLOW );
     250                 :          0 :                         pEditWin->GetView().GetViewFrame()->GetDispatcher()->Execute(
     251         [ #  # ]:          0 :                                 FN_FORMAT_TABLE_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, NULL );
     252                 :            : 
     253 [ #  # ][ #  # ]:          0 :                         rSh.Pop( sal_False );
     254                 :            :                     }
     255                 :            :                     else
     256                 :            :                     {
     257         [ #  # ]:          0 :                         SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
     258                 :          0 :                         SwCntntNode* pNd = pCnt->GetNode();
     259                 :            : 
     260         [ #  # ]:          0 :                         SwPaM aPaM( *pNd );
     261 [ #  # ][ #  # ]:          0 :                         SwPaMItem aPaMItem( pEditWin->GetView().GetPool( ).GetWhich( FN_PARAM_PAM ), &aPaM );
     262 [ #  # ][ #  # ]:          0 :                         SfxUInt16Item aItem( pEditWin->GetView().GetPool( ).GetWhich( SID_PARA_DLG ), TP_PARA_EXT );
     263                 :          0 :                         pEditWin->GetView().GetViewFrame()->GetDispatcher()->Execute(
     264 [ #  # ][ #  # ]:          0 :                                 SID_PARA_DLG, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aItem, &aPaMItem, NULL );
         [ #  # ][ #  # ]
     265                 :            :                     }
     266                 :          0 :                     rSh.LockView( bOldLock );
     267         [ #  # ]:          0 :                     pEditWin->GrabFocus( );
     268                 :            :                 }
     269                 :            :             }
     270                 :          0 :             break;
     271                 :            :         case FN_PAGEBREAK_DELETE:
     272                 :            :             {
     273                 :          0 :                 const SwLayoutFrm* pBodyFrm = static_cast< const SwLayoutFrm* >( GetPageFrame()->Lower() );
     274 [ #  # ][ #  # ]:          0 :                 while ( pBodyFrm && !pBodyFrm->IsBodyFrm() )
                 [ #  # ]
     275                 :          0 :                     pBodyFrm = static_cast< const SwLayoutFrm* >( pBodyFrm->GetNext() );
     276                 :            : 
     277         [ #  # ]:          0 :                 if ( pBodyFrm )
     278                 :            :                 {
     279         [ #  # ]:          0 :                     SwCntntFrm *pCnt = const_cast< SwCntntFrm* >( pBodyFrm->ContainsCntnt() );
     280                 :          0 :                     SwCntntNode* pNd = pCnt->GetNode();
     281                 :            : 
     282 [ #  # ][ #  # ]:          0 :                     pNd->GetDoc()->GetIDocumentUndoRedo( ).StartUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
     283                 :            : 
     284         [ #  # ]:          0 :                     SfxItemSet aSet( GetEditWin()->GetView().GetWrtShell().GetAttrPool(),
     285                 :            :                             RES_PAGEDESC, RES_PAGEDESC,
     286                 :            :                             RES_BREAK, RES_BREAK,
     287         [ #  # ]:          0 :                             NULL );
     288 [ #  # ][ #  # ]:          0 :                     aSet.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
                 [ #  # ]
     289 [ #  # ][ #  # ]:          0 :                     aSet.Put( SwFmtPageDesc( NULL ) );
                 [ #  # ]
     290                 :            : 
     291         [ #  # ]:          0 :                     SwPaM aPaM( *pNd );
     292         [ #  # ]:          0 :                     pNd->GetDoc()->InsertItemSet( aPaM, aSet, nsSetAttrMode::SETATTR_DEFAULT );
     293                 :            : 
     294 [ #  # ][ #  # ]:          0 :                     pNd->GetDoc()->GetIDocumentUndoRedo( ).EndUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
         [ #  # ][ #  # ]
     295                 :            :                 }
     296                 :            :             }
     297                 :          0 :             break;
     298                 :            :     }
     299                 :            : 
     300                 :            :     // Only fade if there is more than this temporary shared pointer:
     301                 :            :     // The main reference has been deleted due to a page break removal
     302         [ #  # ]:          0 :     if ( pThis.use_count() > 1 )
     303 [ #  # ][ #  # ]:          0 :         Fade( false );
     304                 :          0 : }
     305                 :            : 
     306                 :          0 : void SwPageBreakWin::MouseMove( const MouseEvent& rMEvt )
     307                 :            : {
     308         [ #  # ]:          0 :     if ( rMEvt.IsLeaveWindow() )
     309                 :            :     {
     310                 :            :         // don't fade if we just move to the 'line', or the popup menu is open
     311                 :          0 :         Point aEventPos( rMEvt.GetPosPixel() + rMEvt.GetPosPixel() );
     312 [ #  # ][ #  # ]:          0 :         if ( !Contains( aEventPos ) && !PopupMenu::IsInExecute() )
         [ #  # ][ #  # ]
                 [ #  # ]
     313         [ #  # ]:          0 :             Fade( false );
     314                 :            :     }
     315         [ #  # ]:          0 :     else if ( !IsVisible() )
     316                 :          0 :         Fade( true );
     317                 :          0 : }
     318                 :            : 
     319                 :          0 : void SwPageBreakWin::Activate( )
     320                 :            : {
     321                 :          0 :     Fade( true );
     322                 :          0 :     MenuButton::Activate();
     323                 :          0 : }
     324                 :            : 
     325                 :         30 : void SwPageBreakWin::UpdatePosition( const Point* pEvtPt )
     326                 :            : {
     327         [ -  + ]:         30 :     if ( pEvtPt != NULL )
     328                 :            :     {
     329         [ #  # ]:          0 :         if ( pEvtPt == m_pMousePt )
     330                 :         30 :             return;
     331                 :          0 :         delete m_pMousePt;
     332                 :          0 :         m_pMousePt = pEvtPt;
     333                 :            :     }
     334                 :            : 
     335                 :         30 :     const SwPageFrm* pPageFrm = GetPageFrame();
     336                 :         30 :     const SwFrm* pPrevPage = pPageFrm;
     337 [ -  + ][ +  -  :         90 :     do
             +  -  -  + ]
     338                 :            :     {
     339                 :         30 :         pPrevPage = pPrevPage->GetPrev();
     340                 :            :     }
     341                 :         30 :     while ( pPrevPage && ( ( pPrevPage->Frm().Top( ) == pPageFrm->Frm().Top( ) )
     342                 :         30 :                 || static_cast< const SwPageFrm* >( pPrevPage )->IsEmptyPage( ) ) );
     343                 :            : 
     344 [ +  - ][ +  - ]:         30 :     Rectangle aBoundRect = GetEditWin()->LogicToPixel( pPageFrm->GetBoundRect().SVRect() );
                 [ +  - ]
     345 [ +  - ][ +  - ]:         30 :     Rectangle aFrmRect = GetEditWin()->LogicToPixel( pPageFrm->Frm().SVRect() );
     346                 :            : 
     347                 :         30 :     long nYLineOffset = ( aBoundRect.Top() + aFrmRect.Top() ) / 2;
     348         [ +  - ]:         30 :     if ( pPrevPage )
     349                 :            :     {
     350 [ +  - ][ +  - ]:         30 :         Rectangle aPrevFrmRect = GetEditWin()->LogicToPixel( pPrevPage->Frm().SVRect() );
     351                 :         30 :         nYLineOffset = ( aPrevFrmRect.Bottom() + aFrmRect.Top() ) / 2;
     352                 :            :     }
     353                 :            : 
     354                 :            :     // Get the page + sidebar coords
     355                 :         30 :     long nPgLeft = aFrmRect.Left();
     356                 :         30 :     long nPgRight = aFrmRect.Right();
     357                 :            : 
     358                 :         30 :     unsigned long nSidebarWidth = 0;
     359         [ +  - ]:         30 :     const SwPostItMgr* pPostItMngr = GetEditWin()->GetView().GetWrtShell().GetPostItMgr();
     360 [ +  - ][ +  - ]:         30 :     if ( pPostItMngr && pPostItMngr->HasNotes() && pPostItMngr->ShowNotes() )
         [ -  + ][ #  # ]
         [ #  # ][ -  + ]
     361 [ #  # ][ #  # ]:          0 :         nSidebarWidth = pPostItMngr->GetSidebarBorderWidth( true ) + pPostItMngr->GetSidebarWidth( true );
     362                 :            : 
     363 [ +  - ][ -  + ]:         30 :     if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_LEFT )
     364                 :          0 :         nPgLeft -= nSidebarWidth;
     365 [ +  - ][ +  - ]:         30 :     else if ( pPageFrm->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT )
     366                 :         30 :         nPgRight += nSidebarWidth;
     367                 :            : 
     368                 :         30 :     Size aBtnSize( BUTTON_WIDTH + ARROW_WIDTH, BUTTON_HEIGHT );
     369                 :            : 
     370                 :            :     // Place the button on the left or right?
     371         [ +  - ]:         30 :     Rectangle aVisArea = GetEditWin()->LogicToPixel( GetEditWin()->GetView().GetVisArea() );
     372                 :            : 
     373         [ +  - ]:         30 :     long nLineLeft = std::max( nPgLeft, aVisArea.Left() );
     374         [ +  - ]:         30 :     long nLineRight = std::min( nPgRight, aVisArea.Right() );
     375                 :         30 :     long nBtnLeft = nLineLeft;
     376                 :            : 
     377         [ -  + ]:         30 :     if ( m_pMousePt )
     378                 :            :     {
     379                 :          0 :         nBtnLeft = nLineLeft + m_pMousePt->X() - aBtnSize.getWidth() / 2;
     380                 :            : 
     381         [ #  # ]:          0 :         if ( nBtnLeft < nLineLeft )
     382                 :          0 :             nBtnLeft = nLineLeft;
     383         [ #  # ]:          0 :         else if ( ( nBtnLeft + aBtnSize.getWidth() ) > nLineRight )
     384                 :          0 :             nBtnLeft = nLineRight - aBtnSize.getWidth();
     385                 :            :     }
     386                 :            : 
     387                 :            :     // Set the button position
     388                 :         30 :     Point aBtnPos( nBtnLeft, nYLineOffset - BUTTON_HEIGHT / 2 );
     389         [ +  - ]:         30 :     SetPosSizePixel( aBtnPos, aBtnSize );
     390                 :            : 
     391                 :            :     // Set the line position
     392                 :         30 :     Point aLinePos( nLineLeft, nYLineOffset - 5 );
     393                 :         30 :     Size aLineSize( nLineRight - nLineLeft, 10 );
     394         [ +  - ]:         30 :     m_pLine->SetPosSizePixel( aLinePos, aLineSize );
     395                 :            : }
     396                 :            : 
     397                 :         42 : void SwPageBreakWin::ShowAll( bool bShow )
     398                 :            : {
     399                 :         42 :     m_pLine->Show( bShow );
     400                 :         42 : }
     401                 :            : 
     402                 :          0 : bool SwPageBreakWin::Contains( const Point &rDocPt ) const
     403                 :            : {
     404 [ #  # ][ #  # ]:          0 :     Rectangle aRect( GetPosPixel(), GetSizePixel() );
                 [ #  # ]
     405 [ #  # ][ #  # ]:          0 :     if ( aRect.IsInside( rDocPt ) )
     406                 :          0 :         return true;
     407                 :            : 
     408 [ #  # ][ #  # ]:          0 :     Rectangle aLineRect( m_pLine->GetPosPixel(), m_pLine->GetSizePixel() );
                 [ #  # ]
     409 [ #  # ][ #  # ]:          0 :     if ( aLineRect.IsInside( rDocPt ) )
     410                 :          0 :         return true;
     411                 :            : 
     412                 :          0 :     return false;
     413                 :            : }
     414                 :            : 
     415                 :         30 : const SwPageFrm* SwPageBreakWin::GetPageFrame( )
     416                 :            : {
     417                 :         30 :     return static_cast< const SwPageFrm * >( GetFrame( ) );
     418                 :            : }
     419                 :            : 
     420                 :         12 : void SwPageBreakWin::SetReadonly( bool bReadonly )
     421                 :            : {
     422                 :         12 :     ShowAll( !bReadonly );
     423                 :         12 : }
     424                 :            : 
     425                 :          0 : void SwPageBreakWin::Fade( bool bFadeIn )
     426                 :            : {
     427                 :          0 :     m_bIsAppearing = bFadeIn;
     428         [ #  # ]:          0 :     if ( bFadeIn )
     429                 :          0 :         m_nDelayAppearing = 0;
     430                 :            : 
     431 [ #  # ][ #  # ]:          0 :     if ( !m_bDestroyed && m_aFadeTimer.IsActive( ) )
                 [ #  # ]
     432                 :          0 :         m_aFadeTimer.Stop();
     433         [ #  # ]:          0 :     if ( !m_bDestroyed )
     434                 :          0 :         m_aFadeTimer.Start( );
     435                 :          0 : }
     436                 :            : 
     437                 :          0 : IMPL_LINK_NOARG(SwPageBreakWin, HideHandler)
     438                 :            : {
     439                 :          0 :     Fade( false );
     440                 :            : 
     441                 :          0 :     return 0;
     442                 :            : }
     443                 :            : 
     444                 :          0 : IMPL_LINK_NOARG(SwPageBreakWin, FadeHandler)
     445                 :            : {
     446                 :          0 :     const int TICKS_BEFORE_WE_APPEAR = 10;
     447 [ #  # ][ #  # ]:          0 :     if ( m_bIsAppearing && m_nDelayAppearing < TICKS_BEFORE_WE_APPEAR )
     448                 :            :     {
     449                 :          0 :         ++m_nDelayAppearing;
     450                 :          0 :         m_aFadeTimer.Start();
     451                 :          0 :         return 0;
     452                 :            :     }
     453                 :            : 
     454 [ #  # ][ #  # ]:          0 :     if ( m_bIsAppearing && m_nFadeRate > 0 )
     455                 :          0 :         m_nFadeRate -= 25;
     456 [ #  # ][ #  # ]:          0 :     else if ( !m_bIsAppearing && m_nFadeRate < 100 )
     457                 :          0 :         m_nFadeRate += 25;
     458                 :            : 
     459 [ #  # ][ #  # ]:          0 :     if ( m_nFadeRate != 100 && !IsVisible() )
                 [ #  # ]
     460                 :          0 :         Show();
     461 [ #  # ][ #  # ]:          0 :     else if ( m_nFadeRate == 100 && IsVisible( ) )
                 [ #  # ]
     462                 :          0 :         Hide();
     463                 :            :     else
     464                 :            :     {
     465                 :          0 :         UpdatePosition();
     466                 :          0 :         Invalidate();
     467                 :            :     }
     468                 :            : 
     469 [ #  # ][ #  # ]:          0 :     if ( IsVisible( ) && m_nFadeRate > 0 && m_nFadeRate < 100 )
         [ #  # ][ #  # ]
     470                 :          0 :         m_aFadeTimer.Start();
     471                 :            : 
     472                 :          0 :     return 0;
     473                 :            : }
     474                 :            : 
     475                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10