LCOV - code coverage report
Current view: top level - sw/source/ui/uiview - viewmdi.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 150 346 43.4 %
Date: 2012-08-25 Functions: 14 28 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 100 427 23.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <string>
      31                 :            : 
      32                 :            : #include "hintids.hxx"
      33                 :            : #include <vcl/svapp.hxx>
      34                 :            : #include <sfx2/dispatch.hxx>
      35                 :            : #include <svx/ruler.hxx>
      36                 :            : #include <editeng/lrspitem.hxx>
      37                 :            : #include <svl/srchitem.hxx>
      38                 :            : #include <sfx2/request.hxx>
      39                 :            : #include <swmodule.hxx>
      40                 :            : #include <view.hxx>
      41                 :            : #include <wrtsh.hxx>
      42                 :            : #include <docsh.hxx>
      43                 :            : #include <viewopt.hxx>
      44                 :            : #include <frmatr.hxx>
      45                 :            : #include <wdocsh.hxx>
      46                 :            : #include <uitool.hxx>
      47                 :            : #include <edtwin.hxx>
      48                 :            : #include <pagedesc.hxx>
      49                 :            : #include <IMark.hxx>
      50                 :            : #include <fldbas.hxx>
      51                 :            : #include <workctrl.hxx>
      52                 :            : #include <usrpref.hxx>
      53                 :            : #include <scroll.hxx>
      54                 :            : #include <wview.hxx>
      55                 :            : 
      56                 :            : #include <cmdid.h>
      57                 :            : #include <view.hrc>
      58                 :            : #include <ribbar.hrc>
      59                 :            : #include <helpid.h>
      60                 :            : #include <globals.hrc>
      61                 :            : 
      62                 :            : #include <IDocumentSettingAccess.hxx>
      63                 :            : #include <PostItMgr.hxx>
      64                 :            : 
      65                 :            : sal_uInt16  SwView::nMoveType = NID_PGE;
      66                 :            : sal_Int32 SwView::nActMark = 0;
      67                 :            : 
      68                 :            : 
      69                 :            : #define VIEW_IMAGECOLOR COL_LIGHTBLUE
      70                 :            : 
      71                 :            : using namespace ::com::sun::star::uno;
      72                 :            : using namespace ::com::sun::star::frame;
      73                 :            : 
      74                 :         92 : void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, sal_Bool bViewOnly )
      75                 :            : {
      76         [ +  - ]:         92 :     _SetZoom( GetEditWin().GetOutputSizePixel(), eZoomType, nFactor, bViewOnly );
      77                 :         92 : }
      78                 :            : 
      79                 :         95 : void SwView::_SetZoom( const Size &rEditSize, SvxZoomType eZoomType,
      80                 :            :                         short nFactor, sal_Bool bViewOnly )
      81                 :            : {
      82                 :         95 :     sal_Bool bUnLockView = !pWrtShell->IsViewLocked();
      83                 :         95 :     pWrtShell->LockView( sal_True );
      84                 :         95 :     pWrtShell->LockPaint();
      85                 :            : 
      86                 :            :     {
      87         [ +  - ]:         95 :     ACT_KONTEXT(pWrtShell);
      88                 :            : 
      89                 :         95 :     long nFac = nFactor;
      90                 :            : 
      91 [ +  - ][ +  - ]:         95 :     sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
         [ +  - ][ -  + ]
                 [ #  # ]
      92 [ +  - ][ +  - ]:         95 :     SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
      93                 :            : 
      94 [ +  - ][ +  - ]:         95 :     const SwPageDesc &rDesc = pWrtShell->GetPageDesc( pWrtShell->GetCurPageDesc() );
      95         [ +  - ]:         95 :     const SvxLRSpaceItem &rLRSpace = rDesc.GetMaster().GetLRSpace();
      96                 :         95 :     const SwViewOption *pOpt = pWrtShell->GetViewOptions();
      97                 :         95 :     long lLeftMargin = 0;
      98                 :            : 
      99         [ +  + ]:         95 :     if( eZoomType != SVX_ZOOM_PERCENT )
     100                 :            :     {
     101                 :         14 :         const bool bAutomaticViewLayout = 0 == pOpt->GetViewLayoutColumns();
     102                 :            : 
     103         [ +  - ]:         14 :         const SwRect aPageRect( pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
     104         [ +  - ]:         14 :         const SwRect aRootRect( pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) );
     105                 :         14 :         Size aPageSize( aPageRect.SSize() );
     106                 :         14 :         Size aRootSize( aRootRect.SSize() );
     107                 :            : 
     108                 :            :         //mod #i6193# added sidebar width
     109                 :         14 :         SwPostItMgr* pPostItMgr = GetPostItMgr();
     110 [ -  + ][ #  # ]:         14 :         if (pPostItMgr->HasNotes() && pPostItMgr->ShowNotes())
         [ #  # ][ -  + ]
                 [ +  - ]
     111 [ #  # ][ #  # ]:          0 :             aPageSize.Width() += pPostItMgr->GetSidebarWidth() + pPostItMgr->GetSidebarBorderWidth();
     112                 :            : 
     113         [ +  - ]:         14 :         const MapMode aTmpMap( MAP_TWIP );
     114         [ +  - ]:         14 :         const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
     115                 :            : 
     116         [ -  + ]:         14 :         if( nsUseOnPage::PD_MIRROR == rDesc.GetUseOn() )    // gespiegelte Seiten
     117                 :            :         {
     118         [ #  # ]:          0 :             const SvxLRSpaceItem &rLeftLRSpace = rDesc.GetLeft().GetLRSpace();
     119                 :          0 :             aPageSize.Width() += Abs( long(rLeftLRSpace.GetLeft()) - long(rLRSpace.GetLeft()) );
     120                 :            :         }
     121                 :            : 
     122         [ -  + ]:         14 :         if( SVX_ZOOM_OPTIMAL == eZoomType )
     123                 :            :         {
     124 [ #  # ][ #  # ]:          0 :             if (!pPostItMgr->HasNotes() || !pPostItMgr->ShowNotes())
         [ #  # ][ #  # ]
                 [ #  # ]
     125                 :          0 :                 aPageSize.Width() -= ( rLRSpace.GetLeft() + rLRSpace.GetRight() + nLeftOfst * 2 );
     126                 :          0 :             lLeftMargin = long(rLRSpace.GetLeft()) + DOCUMENTBORDER + nLeftOfst;
     127                 :          0 :             nFac = aWindowSize.Width() * 100 / aPageSize.Width();
     128                 :            :         }
     129 [ +  - ][ +  + ]:         14 :         else if(SVX_ZOOM_WHOLEPAGE == eZoomType || SVX_ZOOM_PAGEWIDTH == eZoomType )
     130                 :            :         {
     131                 :          6 :             const long nOf = DOCUMENTBORDER * 2L;
     132         [ +  - ]:          6 :             long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
     133                 :          6 :             nTmpWidth += nOf;
     134                 :          6 :             aPageSize.Height() += nOf;
     135                 :          6 :             nFac = aWindowSize.Width() * 100 / nTmpWidth;
     136                 :            : 
     137         [ -  + ]:          6 :             if ( SVX_ZOOM_WHOLEPAGE == eZoomType )
     138                 :            :             {
     139                 :          0 :                 long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
     140                 :          0 :                 nFac = Min( nFac, nVisPercent );
     141                 :          6 :             }
     142                 :            :         }
     143                 :            :         else
     144                 :            :         {
     145         [ +  - ]:          8 :             const long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
     146                 :          8 :             nFac = aWindowSize.Width() * 100 / nTmpWidth;
     147         [ +  - ]:         14 :         }
     148                 :            :     }
     149                 :            : 
     150                 :         95 :     nFac = Max( long( MINZOOM ), nFac );
     151                 :            : 
     152         [ +  - ]:         95 :     SwViewOption aOpt( *pOpt );
     153 [ +  - ][ +  - ]:         95 :     if ( !GetViewFrame()->GetFrame().IsInPlace() )
                 [ +  - ]
     154                 :            :     {
     155                 :            :         //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen
     156                 :            :         //View updaten.
     157   [ -  +  #  #  :         95 :         if ( !bViewOnly &&
           #  # ][ -  + ]
     158                 :          0 :                 (sal_uInt16(nFac)      != pUsrPref->GetZoom() ||
     159                 :          0 :                 sal_uInt8  (eZoomType) != pUsrPref->GetZoomType()) )
     160                 :            :         {
     161                 :          0 :             pUsrPref->SetZoom    ( sal_uInt16(nFac) );
     162                 :          0 :             pUsrPref->SetZoomType( eZoomType );
     163         [ #  # ]:          0 :             SW_MOD()->ApplyUsrPref( *pUsrPref,
     164                 :            :                     bViewOnly ? this: 0,
     165 [ #  # ][ #  # ]:          0 :                     bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
                 [ #  # ]
     166         [ #  # ]:          0 :             pUsrPref->SetModified();
     167                 :            :         }
     168         [ +  + ]:         95 :         if ( pOpt->GetZoom() != (sal_uInt16) nFac )
     169                 :            :         {
     170                 :         84 :             aOpt.SetZoom    ( sal_uInt16(nFac) );
     171                 :         84 :             aOpt.SetReadonly(pOpt->IsReadonly());
     172         [ +  - ]:         84 :             pWrtShell->ApplyViewOptions( aOpt );
     173                 :            :         }
     174         [ +  + ]:         95 :         if ( eZoomType != SVX_ZOOM_PERCENT )
     175                 :            :         {
     176                 :         14 :             Point aPos;
     177                 :            : 
     178         [ -  + ]:         14 :             if ( eZoomType == SVX_ZOOM_WHOLEPAGE )
     179         [ #  # ]:          0 :                 aPos.Y() = pWrtShell->GetAnyCurRect(RECT_PAGE).Top() - DOCUMENTBORDER;
     180                 :            :             else
     181                 :            :             {
     182                 :            :                 //sicherstellen, dass sich der Cursor im sichtbaren
     183                 :            :                 //Bereich befindet, damit nur 1x gescrollt wird
     184                 :         14 :                 aPos.X() = lLeftMargin;
     185                 :         14 :                 const SwRect &rCharRect = pWrtShell->GetCharRect();
     186         [ -  + ]:         28 :                 if ( rCharRect.Top() > GetVisArea().Bottom() ||
           [ +  -  -  + ]
     187                 :         14 :                     rCharRect.Bottom() < aPos.Y() )
     188                 :          0 :                     aPos.Y() = rCharRect.Top() - rCharRect.Height();
     189                 :            :                 else
     190                 :         14 :                     aPos.Y() = GetVisArea().Top();
     191                 :            :             }
     192         [ +  - ]:         14 :             SetVisArea( aPos );
     193                 :            :         }
     194                 :            :         // OS: Notloesung - in CalcVisArea wird u.U. wieder SetZoom gerufen und
     195                 :            :         // dann werden falsche Werte eingestellt
     196                 :         95 :         ((SwViewOption*)pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
     197         [ +  - ]:         95 :         CalcVisArea( rEditSize );   //fuer das Neuberechnen des sichtbaren Bereiches
     198                 :            :     }
     199         [ #  # ]:          0 :     else if ( sal_uInt16(nFac) != pOpt->GetZoom() )
     200                 :            :     {
     201                 :          0 :         aOpt.SetZoom    ( sal_uInt16(nFac) );
     202         [ #  # ]:          0 :         pWrtShell->ApplyViewOptions( aOpt );
     203                 :            :     }
     204                 :            : 
     205         [ +  - ]:         95 :     const Fraction aFrac( nFac, 100 );
     206         [ +  - ]:         95 :     pVRuler->SetZoom( aFrac );
     207         [ +  - ]:         95 :     pVRuler->ForceUpdate();
     208         [ +  - ]:         95 :     pHRuler->SetZoom( aFrac );
     209         [ +  - ]:         95 :     pHRuler->ForceUpdate();
     210 [ +  - ][ +  - ]:         95 :     ((SwViewOption*)pWrtShell->GetViewOptions())->SetZoomType( eZoomType );
     211                 :            :     }
     212                 :         95 :     pWrtShell->UnlockPaint();
     213         [ +  + ]:         95 :     if( bUnLockView )
     214                 :         92 :         pWrtShell->LockView( sal_False );
     215                 :         95 : }
     216                 :            : 
     217                 :          0 : void SwView::SetViewLayout( sal_uInt16 nColumns, bool bBookMode, sal_Bool bViewOnly )
     218                 :            : {
     219                 :          0 :     const sal_Bool bUnLockView = !pWrtShell->IsViewLocked();
     220                 :          0 :     pWrtShell->LockView( sal_True );
     221                 :          0 :     pWrtShell->LockPaint();
     222                 :            : 
     223                 :            :     {
     224                 :            : 
     225         [ #  # ]:          0 :     ACT_KONTEXT(pWrtShell);
     226                 :            : 
     227 [ #  # ][ #  # ]:          0 :     if ( !GetViewFrame()->GetFrame().IsInPlace() && !bViewOnly )
         [ #  # ][ #  # ]
                 [ #  # ]
     228                 :            :     {
     229 [ #  # ][ #  # ]:          0 :         const sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
         [ #  # ][ #  # ]
                 [ #  # ]
     230 [ #  # ][ #  # ]:          0 :         SwMasterUsrPref *pUsrPref = (SwMasterUsrPref*)SW_MOD()->GetUsrPref(bWeb);
     231                 :            : 
     232                 :            :         //MasterUsrPrefs updaten UND DANACH die ViewOptions der aktuellen
     233                 :            :         //View updaten.
     234   [ #  #  #  # ]:          0 :         if ( nColumns  != pUsrPref->GetViewLayoutColumns() ||
                 [ #  # ]
     235                 :          0 :              bBookMode != pUsrPref->IsViewLayoutBookMode() )
     236                 :            :         {
     237                 :          0 :             pUsrPref->SetViewLayoutColumns( nColumns );
     238                 :          0 :             pUsrPref->SetViewLayoutBookMode( bBookMode );
     239         [ #  # ]:          0 :             SW_MOD()->ApplyUsrPref( *pUsrPref,
     240                 :            :                     bViewOnly ? this: 0,
     241 [ #  # ][ #  # ]:          0 :                     bViewOnly ? VIEWOPT_DEST_VIEW_ONLY : 0 );
                 [ #  # ]
     242         [ #  # ]:          0 :             pUsrPref->SetModified();
     243                 :            :         }
     244                 :            :     }
     245                 :            : 
     246                 :          0 :     const SwViewOption *pOpt = pWrtShell->GetViewOptions();
     247                 :            : 
     248         [ #  # ]:          0 :     if ( nColumns  != pOpt->GetViewLayoutColumns() ||
           [ #  #  #  # ]
     249                 :          0 :          bBookMode != pOpt->IsViewLayoutBookMode() )
     250                 :            :     {
     251         [ #  # ]:          0 :         SwViewOption aOpt( *pOpt );
     252                 :          0 :         aOpt.SetViewLayoutColumns( nColumns );
     253                 :          0 :         aOpt.SetViewLayoutBookMode( bBookMode );
     254 [ #  # ][ #  # ]:          0 :         pWrtShell->ApplyViewOptions( aOpt );
     255                 :            :     }
     256                 :            : 
     257         [ #  # ]:          0 :     pVRuler->ForceUpdate();
     258 [ #  # ][ #  # ]:          0 :     pHRuler->ForceUpdate();
     259                 :            : 
     260                 :            :     }
     261                 :            : 
     262                 :          0 :     pWrtShell->UnlockPaint();
     263         [ #  # ]:          0 :     if( bUnLockView )
     264                 :          0 :         pWrtShell->LockView( sal_False );
     265                 :            : 
     266                 :          0 :     SfxBindings& rBnd = GetViewFrame()->GetBindings();
     267                 :          0 :     rBnd.Invalidate( SID_ATTR_VIEWLAYOUT );
     268                 :          0 :     rBnd.Invalidate( SID_ATTR_ZOOMSLIDER);
     269                 :          0 : }
     270                 :            : 
     271                 :            : /*
     272                 :            :  * Scrollbar - Handler
     273                 :            :  */
     274                 :      96074 : IMPL_LINK( SwView, WindowChildEventListener, VclSimpleEvent*, pEvent )
     275                 :            : {
     276                 :            :     OSL_ENSURE( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
     277 [ +  - ][ +  - ]:      96074 :     if ( pEvent && pEvent->ISA( VclWindowEvent ) )
                 [ +  - ]
     278                 :            :     {
     279                 :      96074 :         VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent );
     280                 :            :         OSL_ENSURE( pVclEvent->GetWindow(), "Window???" );
     281                 :      96074 :         Window* pChildWin = static_cast< Window* >( pVclEvent->GetData() );
     282                 :            : 
     283      [ +  +  + ]:      96074 :         switch ( pVclEvent->GetId() )
     284                 :            :         {
     285                 :            :             case VCLEVENT_WINDOW_HIDE:
     286         [ +  + ]:       1578 :                 if( pChildWin == pHScrollbar )
     287                 :         35 :                     ShowHScrollbar( sal_False );
     288         [ +  + ]:       1543 :                 else if( pChildWin == pVScrollbar )
     289                 :         28 :                     ShowVScrollbar( sal_False );
     290                 :       1578 :                 break;
     291                 :            :             case VCLEVENT_WINDOW_SHOW:
     292         [ +  + ]:      18866 :                 if( pChildWin == pHScrollbar )
     293                 :       1309 :                     ShowHScrollbar( sal_True );
     294         [ +  + ]:      17557 :                 else if( pChildWin == pVScrollbar )
     295                 :       1312 :                     ShowVScrollbar( sal_True );
     296                 :      96074 :                 break;
     297                 :            :         }
     298                 :            :     }
     299                 :            : 
     300                 :      96074 :     return 0;
     301                 :            : }
     302                 :            : 
     303                 :       2636 : int SwView::_CreateScrollbar( sal_Bool bHori )
     304                 :            : {
     305                 :       2636 :     Window *pMDI = &GetViewFrame()->GetWindow();
     306         [ +  + ]:       2636 :     SwScrollbar** ppScrollbar = bHori ? &pHScrollbar : &pVScrollbar;
     307                 :            : 
     308                 :            :     OSL_ENSURE( !*ppScrollbar, "vorher abpruefen!" );
     309                 :            : 
     310         [ +  + ]:       2636 :     if( !bHori )
     311                 :       1318 :         CreatePageButtons( !bShowAtResize );
     312                 :            : 
     313         [ +  - ]:       2636 :     *ppScrollbar = new SwScrollbar( pMDI, bHori );
     314                 :       2636 :     UpdateScrollbars();
     315         [ +  + ]:       2636 :     if(bHori)
     316                 :       1318 :         (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, EndScrollHdl ));
     317                 :            :     else
     318                 :       1318 :         (*ppScrollbar)->SetScrollHdl( LINK( this, SwView, ScrollHdl ));
     319                 :       2636 :     (*ppScrollbar)->SetEndScrollHdl( LINK( this, SwView, EndScrollHdl ));
     320                 :            : 
     321                 :       2636 :     (*ppScrollbar)->EnableDrag( sal_True );
     322                 :            : 
     323                 :       2636 :     (*ppScrollbar)->SetAuto( sal_True );
     324                 :            : 
     325         [ -  + ]:       2636 :     if(GetWindow())
     326                 :          0 :         InvalidateBorder();
     327                 :            : 
     328                 :            :     // Scrollbar muss nochmals getestet werden, da im InvalidateBorder u.U. der
     329                 :            :     // Scrollbar wieder geloescht wurde
     330 [ -  + ][ #  # ]:       2636 :     if ( !bShowAtResize && (*ppScrollbar))
     331                 :          0 :         (*ppScrollbar)->ExtendedShow();
     332                 :            : 
     333                 :       2636 :     return 1;
     334                 :            : }
     335                 :            : 
     336                 :       1318 : void SwView::CreatePageButtons(sal_Bool bShow)
     337                 :            : {
     338         [ +  - ]:       1318 :     Window *pMDI = &GetViewFrame()->GetWindow();
     339 [ +  - ][ +  - ]:       1318 :     pPageUpBtn      = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEUP ), sal_True );
     340         [ +  - ]:       1318 :     pPageUpBtn->SetHelpId(HID_SCRL_PAGEUP);
     341 [ +  - ][ +  - ]:       1318 :     pPageDownBtn    = new SwHlpImageButton(pMDI, SW_RES( BTN_PAGEDOWN ), sal_False );
     342         [ +  - ]:       1318 :     pPageDownBtn->SetHelpId(HID_SCRL_PAGEDOWN);
     343 [ +  - ][ +  - ]:       1318 :     Reference< XFrame > xFrame = GetViewFrame()->GetFrame().GetFrameInterface();
     344 [ +  - ][ +  - ]:       1318 :     pNaviBtn = new SwNaviImageButton(pMDI, xFrame );
     345         [ +  - ]:       1318 :     pNaviBtn->SetHelpId(HID_SCRL_NAVI);
     346         [ +  - ]:       1318 :     Link aLk( LINK( this, SwView, BtnPage ) );
     347                 :       1318 :     pPageUpBtn->SetClickHdl( aLk );
     348                 :       1318 :     pPageDownBtn->SetClickHdl( aLk );
     349         [ -  + ]:       1318 :     if(nMoveType != NID_PGE)
     350                 :            :     {
     351                 :          0 :         Color aColor(VIEW_IMAGECOLOR);
     352         [ #  # ]:          0 :         SetImageButtonColor(aColor);
     353                 :            :     }
     354                 :            : 
     355         [ -  + ]:       1318 :     if(bShow)
     356                 :            :     {
     357         [ #  # ]:          0 :         pPageUpBtn->Show();
     358         [ #  # ]:          0 :         pPageDownBtn->Show();
     359         [ #  # ]:          0 :         pNaviBtn->Show();
     360                 :       1318 :     }
     361                 :       1318 : };
     362                 :            : 
     363                 :            : /*
     364                 :            :  * Button-Handler
     365                 :            :  */
     366                 :          0 : IMPL_LINK( SwView, BtnPage, Button *, pButton )
     367                 :            : {
     368                 :            :     // #i75416# move the execution of the search to an asynchronously called static link
     369                 :          0 :     bool* pbNext = new bool( (pButton == pPageDownBtn) );
     370         [ #  # ]:          0 :     Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
     371                 :          0 :     return 0;
     372                 :            : }
     373                 :            : 
     374                 :          0 : IMPL_STATIC_LINK( SwView, MoveNavigationHdl, bool *, pbNext )
     375                 :            : {
     376         [ #  # ]:          0 :     if ( !pbNext )
     377                 :          0 :         return 0;
     378                 :          0 :     bool bNext = *pbNext;
     379                 :          0 :     SwWrtShell& rSh = pThis->GetWrtShell();
     380   [ #  #  #  #  :          0 :     switch( nMoveType )
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     381                 :            :     {
     382                 :            :         case NID_PGE:
     383         [ #  # ]:          0 :             bNext ? pThis->PhyPageDown() : pThis->PhyPageUp();
     384                 :          0 :         break;
     385                 :            :         case NID_TBL :
     386                 :          0 :             rSh.EnterStdMode();
     387         [ #  # ]:          0 :             if(bNext)
     388                 :          0 :                 rSh.MoveTable(fnTableNext, fnTableStart);
     389                 :            :             else
     390                 :          0 :                 rSh.MoveTable(fnTablePrev, fnTableStart);
     391                 :          0 :         break;
     392                 :            :         case NID_FRM :
     393                 :            :         case NID_GRF:
     394                 :            :         case NID_OLE:
     395                 :            :         {
     396                 :          0 :             sal_uInt16 eType = GOTOOBJ_FLY_FRM;
     397         [ #  # ]:          0 :             if(nMoveType == NID_GRF)
     398                 :          0 :                 eType = GOTOOBJ_FLY_GRF;
     399         [ #  # ]:          0 :             else if(nMoveType == NID_OLE)
     400                 :          0 :                 eType = GOTOOBJ_FLY_OLE;
     401                 :            :             sal_Bool bSuccess = bNext ?
     402                 :          0 :                     rSh.GotoNextFly(eType) :
     403         [ #  # ]:          0 :                         rSh.GotoPrevFly(eType);
     404         [ #  # ]:          0 :             if(bSuccess)
     405                 :            :             {
     406                 :          0 :                 rSh.HideCrsr();
     407                 :          0 :                 rSh.EnterSelFrmMode();
     408                 :            :             }
     409                 :            :         }
     410                 :          0 :         break;
     411                 :            :         case NID_DRW :
     412                 :            :         case NID_CTRL:
     413                 :            :             rSh.GotoObj(bNext,
     414                 :            :                     nMoveType == NID_DRW ?
     415                 :            :                         GOTOOBJ_DRAW_SIMPLE :
     416         [ #  # ]:          0 :                         GOTOOBJ_DRAW_CONTROL);
     417                 :          0 :         break;
     418                 :            :         case NID_REG :
     419                 :          0 :             rSh.EnterStdMode();
     420         [ #  # ]:          0 :             if(bNext)
     421                 :          0 :                 rSh.MoveRegion(fnRegionNext, fnRegionStart);
     422                 :            :             else
     423                 :          0 :                 rSh.MoveRegion(fnRegionPrev, fnRegionStart);
     424                 :            : 
     425                 :          0 :         break;
     426                 :            :         case NID_BKM :
     427                 :          0 :             rSh.EnterStdMode();
     428                 :            :             pThis->GetViewFrame()->GetDispatcher()->Execute(bNext ?
     429                 :            :                                         FN_NEXT_BOOKMARK :
     430         [ #  # ]:          0 :                                             FN_PREV_BOOKMARK);
     431                 :          0 :         break;
     432                 :            :         case NID_OUTL:
     433                 :          0 :             rSh.EnterStdMode();
     434         [ #  # ]:          0 :             bNext ? rSh.GotoNextOutline() : rSh.GotoPrevOutline();
     435                 :          0 :         break;
     436                 :            :         case NID_SEL :
     437         [ #  # ]:          0 :             bNext ? rSh.GoNextCrsr() : rSh.GoPrevCrsr();
     438                 :          0 :         break;
     439                 :            :         case NID_FTN:
     440                 :          0 :             rSh.EnterStdMode();
     441                 :            :             bNext ?
     442                 :          0 :                 rSh.GotoNextFtnAnchor() :
     443         [ #  # ]:          0 :                     rSh.GotoPrevFtnAnchor();
     444                 :          0 :         break;
     445                 :            :         case NID_MARK:
     446                 :            :         {
     447                 :            :             // unselect
     448         [ #  # ]:          0 :             rSh.MoveCrsr();
     449         [ #  # ]:          0 :             rSh.EnterStdMode();
     450                 :            : 
     451                 :            :             // collect navigator reminders
     452         [ #  # ]:          0 :             IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
     453         [ #  # ]:          0 :             ::std::vector< const ::sw::mark::IMark* > vNavMarks;
     454 [ #  # ][ #  # ]:          0 :             for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
         [ #  # ][ #  # ]
     455         [ #  # ]:          0 :                 ppMark != pMarkAccess->getMarksEnd();
     456                 :            :                 ppMark++)
     457                 :            :             {
     458 [ #  # ][ #  # ]:          0 :                 if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER )
     459         [ #  # ]:          0 :                     vNavMarks.push_back(ppMark->get());
     460                 :            :             }
     461                 :            : 
     462                 :            :             // move
     463         [ #  # ]:          0 :             if(!vNavMarks.empty())
     464                 :            :             {
     465         [ #  # ]:          0 :                 if(bNext)
     466                 :            :                 {
     467                 :          0 :                     nActMark++;
     468 [ #  # ][ #  # ]:          0 :                     if (nActMark >= MAX_MARKS || nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
                 [ #  # ]
     469                 :          0 :                         nActMark = 0;
     470                 :            :                 }
     471                 :            :                 else
     472                 :            :                 {
     473                 :          0 :                     nActMark--;
     474 [ #  # ][ #  # ]:          0 :                     if (nActMark < 0 || nActMark >= static_cast<sal_Int32>(vNavMarks.size()))
                 [ #  # ]
     475                 :          0 :                         nActMark = vNavMarks.size()-1;
     476                 :            :                 }
     477 [ #  # ][ #  # ]:          0 :                 rSh.GotoMark(vNavMarks[nActMark]);
     478                 :          0 :             }
     479                 :            :         }
     480                 :          0 :         break;
     481                 :            :         case NID_POSTIT:
     482                 :            :         {
     483                 :          0 :             sw::sidebarwindows::SwSidebarWin* pPostIt = pThis->GetPostItMgr()->GetActiveSidebarWin();
     484         [ #  # ]:          0 :             if (pPostIt)
     485                 :          0 :                 pThis->GetPostItMgr()->SetActiveSidebarWin(0);
     486                 :          0 :             SwFieldType* pFldType = rSh.GetFldType(0, RES_POSTITFLD);
     487         [ #  # ]:          0 :             if (rSh.MoveFldType(pFldType, bNext))
     488                 :          0 :                 pThis->GetViewFrame()->GetDispatcher()->Execute(FN_POSTIT);
     489                 :            :             else
     490                 :            :                 //first/last item
     491                 :          0 :                 pThis->GetPostItMgr()->SetActiveSidebarWin(pPostIt);
     492                 :            :         }
     493                 :          0 :         break;
     494                 :            :         case NID_SRCH_REP:
     495         [ #  # ]:          0 :         if(pSrchItem)
     496                 :            :         {
     497                 :          0 :             sal_Bool bBackward = pSrchItem->GetBackward();
     498 [ #  # ][ #  # ]:          0 :             if(rSh.HasSelection() && !bNext == rSh.IsCrsrPtAtEnd())
         [ #  # ][ #  # ]
                 [ #  # ]
     499         [ #  # ]:          0 :                 rSh.SwapPam();
     500                 :          0 :             pSrchItem->SetBackward(!bNext);
     501         [ #  # ]:          0 :             SfxRequest aReq(FN_REPEAT_SEARCH, SFX_CALLMODE_SLOT, pThis->GetPool());
     502         [ #  # ]:          0 :             pThis->ExecSearch(aReq);
     503         [ #  # ]:          0 :             pSrchItem->SetBackward(bBackward);
     504                 :            :         }
     505                 :          0 :         break;
     506                 :            :         case NID_INDEX_ENTRY:
     507                 :          0 :             rSh.GotoNxtPrvTOXMark(bNext);
     508                 :          0 :         break;
     509                 :            : 
     510                 :            :         case NID_TABLE_FORMULA:
     511                 :          0 :             rSh.GotoNxtPrvTblFormula( bNext );
     512                 :          0 :             break;
     513                 :            : 
     514                 :            :         case NID_TABLE_FORMULA_ERROR:
     515                 :          0 :             rSh.GotoNxtPrvTblFormula( bNext, sal_True );
     516                 :          0 :             break;
     517                 :            :     }
     518                 :          0 :     pThis->pEditWin->GrabFocus();
     519                 :          0 :     delete pbNext;
     520                 :          0 :     return 0;
     521                 :            : }
     522                 :            : 
     523                 :       1420 : int SwView::CreateTab()
     524                 :            : {
     525 [ +  - ][ +  + ]:       1420 :     pHRuler->SetActive(GetFrame() && IsActive());
     526                 :            : 
     527                 :       1420 :     pHRuler->Show();
     528                 :       1420 :     InvalidateBorder();
     529                 :       1420 :     return 1;
     530                 :            : }
     531                 :            : 
     532                 :        114 : int SwView::KillTab()
     533                 :            : {
     534                 :        114 :     pHRuler->Hide();
     535                 :        114 :     InvalidateBorder();
     536                 :        114 :     return 1;
     537                 :            : }
     538                 :            : 
     539                 :          0 : void SwView::ChangeTabMetric( FieldUnit eUnit )
     540                 :            : {
     541         [ #  # ]:          0 :     if(pHRuler->GetUnit() != eUnit )
     542                 :            :     {
     543                 :          0 :         pHRuler->SetUnit( eUnit );
     544                 :          0 :         pHRuler->Invalidate();
     545                 :            :     }
     546                 :          0 : }
     547                 :            : 
     548                 :          0 : void SwView::ChangeVLinealMetric( FieldUnit eUnit )
     549                 :            : {
     550         [ #  # ]:          0 :     if(pVRuler->GetUnit() != eUnit)
     551                 :            :     {
     552                 :          0 :         pVRuler->SetUnit( eUnit );
     553                 :          0 :         pVRuler->Invalidate();
     554                 :            :     }
     555                 :          0 : }
     556                 :            : 
     557                 :          2 : void SwView::GetVLinealMetric(FieldUnit& eToFill) const
     558                 :            : {
     559                 :          2 :     eToFill = pVRuler->GetUnit();
     560                 :          2 : }
     561                 :            : 
     562                 :          2 : void SwView::GetHLinealMetric(FieldUnit& eToFill) const
     563                 :            : {
     564                 :          2 :     eToFill = pHRuler->GetUnit();
     565                 :          2 : }
     566                 :            : 
     567                 :       1410 : int SwView::CreateVLineal()
     568                 :            : {
     569         [ +  - ]:       1410 :     pHRuler->SetBorderPos( pVRuler->GetSizePixel().Width()-1 );
     570                 :            : 
     571 [ +  - ][ +  + ]:       1410 :     pVRuler->SetActive(GetFrame() && IsActive());
     572                 :       1410 :     pVRuler->Show();
     573                 :       1410 :     InvalidateBorder();
     574                 :       1410 :     return 1;
     575                 :            : }
     576                 :            : 
     577                 :        120 : int SwView::KillVLineal()
     578                 :            : {
     579                 :        120 :     pVRuler->Hide();
     580                 :        120 :     pHRuler->SetBorderPos( 0 );
     581                 :        120 :     InvalidateBorder();
     582                 :        120 :     return 1;
     583                 :            : }
     584                 :            : 
     585                 :          0 : IMPL_LINK( SwView, ExecRulerClick, Ruler *, pRuler )
     586                 :            : {
     587                 :          0 :     sal_uInt16 nDefPage = 0;
     588         [ #  # ]:          0 :     switch( pRuler->GetClickType() )
     589                 :            :     {
     590                 :            :         case RULER_TYPE_DONTKNOW:
     591                 :            :         case RULER_TYPE_OUTSIDE:
     592                 :            :         case RULER_TYPE_INDENT:
     593                 :            :         case RULER_TYPE_MARGIN1:
     594                 :            :         case RULER_TYPE_MARGIN2:
     595                 :          0 :             nDefPage = TP_PARA_STD;
     596                 :          0 :         break;
     597                 :            :         default:
     598                 :          0 :             nDefPage = TP_TABULATOR;
     599                 :            : 
     600                 :            :     }
     601                 :            : 
     602         [ #  # ]:          0 :     SfxUInt16Item aDefPage(SID_PARA_DLG, nDefPage);
     603                 :            :     GetViewFrame()->GetDispatcher()->Execute( SID_PARA_DLG,
     604                 :            :                                 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
     605         [ #  # ]:          0 :                                 &aDefPage, 0L );
     606         [ #  # ]:          0 :     return 0;
     607                 :            : }
     608                 :            : 
     609                 :          0 : sal_uInt16 SwView::GetMoveType()
     610                 :            : {
     611                 :          0 :     return nMoveType;
     612                 :            : }
     613                 :            : 
     614                 :          0 : void SwView::SetMoveType(sal_uInt16 nSet)
     615                 :            : {
     616                 :          0 :     sal_Bool bLastPage = nMoveType == NID_PGE;
     617                 :          0 :     nMoveType = nSet;
     618                 :          0 :     sal_Bool bNewPage = nMoveType == NID_PGE;
     619         [ #  # ]:          0 :     if(bNewPage != bLastPage)
     620                 :            :     {
     621         [ #  # ]:          0 :         Color aColor(bNewPage ? COL_BLACK : VIEW_IMAGECOLOR);
     622         [ #  # ]:          0 :         const TypeId aTypeId = TYPE(SwView);
     623         [ #  # ]:          0 :         SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
     624         [ #  # ]:          0 :         while( pView )
     625                 :            :         {
     626         [ #  # ]:          0 :             pView->SetImageButtonColor(aColor);
     627         [ #  # ]:          0 :             pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
     628                 :            :         }
     629                 :            :     }
     630                 :          0 : }
     631                 :            : 
     632                 :          0 : void SwView::SetActMark(sal_Int32 nSet)
     633                 :            : {
     634                 :          0 :     nActMark = nSet;
     635                 :          0 : }
     636                 :            : 
     637                 :          0 : void SwView::SetImageButtonColor(Color& rColor)
     638                 :            : {
     639         [ #  # ]:          0 :     if(pPageUpBtn)
     640                 :            :     {
     641                 :          0 :         pPageUpBtn->SetControlForeground(rColor);
     642                 :          0 :         pPageDownBtn->SetControlForeground(rColor);
     643                 :            :     }
     644                 :          0 : }
     645                 :            : 
     646                 :       2668 : void SwView::ShowHScrollbar(sal_Bool bShow)
     647                 :            : {
     648                 :            :     OSL_ENSURE(pHScrollbar, "Scrollbar invalid");
     649                 :       2668 :     pHScrollbar->ExtendedShow(bShow);
     650                 :       2668 : }
     651                 :            : 
     652                 :          0 : sal_Bool SwView::IsHScrollbarVisible()const
     653                 :            : {
     654                 :            :     OSL_ENSURE(pHScrollbar, "Scrollbar invalid");
     655 [ #  # ][ #  # ]:          0 :     return pHScrollbar->IsVisible( sal_False ) || pHScrollbar->IsAuto();
     656                 :            : }
     657                 :            : 
     658                 :       2664 : void SwView::ShowVScrollbar(sal_Bool bShow)
     659                 :            : {
     660                 :            :     OSL_ENSURE(pVScrollbar, "Scrollbar invalid");
     661                 :       2664 :     pVScrollbar->ExtendedShow(bShow);
     662                 :       2664 :     pPageUpBtn->Show(bShow);
     663                 :       2664 :     pPageDownBtn->Show(bShow);
     664                 :       2664 :     pNaviBtn->Show(bShow);
     665                 :       2664 : }
     666                 :            : 
     667                 :          0 : sal_Bool SwView::IsVScrollbarVisible()const
     668                 :            : {
     669                 :            :     OSL_ENSURE(pVScrollbar, "Scrollbar invalid");
     670                 :          0 :     return pVScrollbar->IsVisible( sal_False );
     671                 :            : }
     672                 :            : 
     673                 :            : 
     674                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10