LCOV - code coverage report
Current view: top level - sw/source/core/view - vdraw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 76 114 66.7 %
Date: 2012-08-25 Functions: 6 7 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 105 244 43.0 %

           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                 :            : #include <svx/svdmodel.hxx>
      30                 :            : #include <svx/svdpage.hxx>
      31                 :            : #include <tools/shl.hxx>
      32                 :            : #include <swmodule.hxx>
      33                 :            : #include <svtools/accessibilityoptions.hxx>
      34                 :            : #include <svx/svdpagv.hxx>
      35                 :            : #include <fmtanchr.hxx>
      36                 :            : #include <frmfmt.hxx>
      37                 :            : 
      38                 :            : #include <svx/svdoutl.hxx>
      39                 :            : 
      40                 :            : #include "fesh.hxx"
      41                 :            : #include "pagefrm.hxx"
      42                 :            : #include "rootfrm.hxx"
      43                 :            : #include "viewimp.hxx"
      44                 :            : #include "dflyobj.hxx"
      45                 :            : #include "viewopt.hxx"
      46                 :            : #include "printdata.hxx"
      47                 :            : #include "dcontact.hxx"
      48                 :            : #include "dview.hxx"
      49                 :            : #include "flyfrm.hxx"
      50                 :            : #include <vcl/svapp.hxx>
      51                 :            : 
      52                 :            : #include <IDocumentDrawModelAccess.hxx>
      53                 :            : 
      54                 :            : 
      55                 :      68566 : void SwViewImp::StartAction()
      56                 :            : {
      57         [ +  - ]:      68566 :     if ( HasDrawView() )
      58                 :            :     {
      59         [ +  - ]:      68566 :         SET_CURR_SHELL( GetShell() );
      60 [ +  - ][ +  - ]:      68566 :         if ( pSh->ISA(SwFEShell) )
                 [ +  - ]
      61 [ +  - ][ +  - ]:      68566 :             ((SwFEShell*)pSh)->HideChainMarker(); // might have changed
      62                 :            :     }
      63                 :      68566 : }
      64                 :            : 
      65                 :            : 
      66                 :      35760 : void SwViewImp::EndAction()
      67                 :            : {
      68         [ +  - ]:      35760 :     if ( HasDrawView() )
      69                 :            :     {
      70         [ +  - ]:      35760 :         SET_CURR_SHELL( GetShell() );
      71 [ +  - ][ +  - ]:      35760 :         if ( pSh->ISA(SwFEShell) )
                 [ +  - ]
      72 [ +  - ][ +  - ]:      35760 :             ((SwFEShell*)pSh)->SetChainMarker(); // might have changed
      73                 :            :     }
      74                 :      35760 : }
      75                 :            : 
      76                 :            : 
      77                 :       3001 : void SwViewImp::LockPaint()
      78                 :            : {
      79         [ +  - ]:       3001 :     if ( HasDrawView() )
      80                 :            :     {
      81                 :       3001 :         bResetHdlHiddenPaint = !GetDrawView()->areMarkHandlesHidden();
      82                 :       3001 :         GetDrawView()->hideMarkHandles();
      83                 :            :     }
      84                 :            :     else
      85                 :            :     {
      86                 :          0 :         bResetHdlHiddenPaint = sal_False;
      87                 :            :     }
      88                 :       3001 : }
      89                 :            : 
      90                 :            : 
      91                 :       3001 : void SwViewImp::UnlockPaint()
      92                 :            : {
      93         [ +  - ]:       3001 :     if ( bResetHdlHiddenPaint )
      94                 :       3001 :         GetDrawView()->showMarkHandles();
      95                 :       3001 : }
      96                 :            : 
      97                 :            : 
      98                 :      24756 : void SwViewImp::PaintLayer( const SdrLayerID _nLayerID,
      99                 :            :                             SwPrintData const*const pPrintData,
     100                 :            :                             const SwRect& ,
     101                 :            :                             const Color* _pPageBackgrdColor,
     102                 :            :                             const bool _bIsPageRightToLeft,
     103                 :            :                             sdr::contact::ViewObjectContactRedirector* pRedirector ) const
     104                 :            : {
     105         [ +  - ]:      24756 :     if ( HasDrawView() )
     106                 :            :     {
     107                 :            :         //change the draw mode in high contrast mode
     108                 :      24756 :         OutputDevice* pOutDev = GetShell()->GetOut();
     109                 :      24756 :         sal_uLong nOldDrawMode = pOutDev->GetDrawMode();
     110 [ #  # ][ -  + ]:      49474 :         if( GetShell()->GetWin() &&
           [ +  +  -  +  
                   #  # ]
     111         [ +  - ]:      24718 :             Application::GetSettings().GetStyleSettings().GetHighContrastMode() &&
     112 [ #  # ][ #  # ]:          0 :             (!GetShell()->IsPreView()||SW_MOD()->GetAccessibilityOptions().GetIsForPagePreviews()))
                 [ #  # ]
     113                 :            :         {
     114                 :            :             pOutDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
     115         [ #  # ]:          0 :                                 DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
     116                 :            :         }
     117                 :            : 
     118                 :            :         // For correct handling of accessibility, high contrast, the
     119                 :            :         // page background color is set as the background color at the
     120                 :            :         // outliner of the draw view.  Only necessary for the layers
     121                 :            :         // hell and heaven
     122                 :      24756 :         Color aOldOutlinerBackgrdColor;
     123                 :            :         // set default horizontal text direction on painting <hell> or
     124                 :            :         // <heaven>.
     125                 :      24756 :         EEHorizontalTextDirection aOldEEHoriTextDir = EE_HTEXTDIR_L2R;
     126         [ +  - ]:      24756 :         const IDocumentDrawModelAccess* pIDDMA = GetShell()->getIDocumentDrawModelAccess();
     127 [ +  - ][ +  + ]:      37134 :         if ( (_nLayerID == pIDDMA->GetHellId()) ||
         [ +  - ][ +  - ]
     128         [ +  - ]:      12378 :              (_nLayerID == pIDDMA->GetHeavenId()) )
     129                 :            :         {
     130                 :            :             OSL_ENSURE( _pPageBackgrdColor,
     131                 :            :                     "incorrect usage of SwViewImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>");
     132         [ +  - ]:      24756 :             if ( _pPageBackgrdColor )
     133                 :            :             {
     134                 :            :                 aOldOutlinerBackgrdColor =
     135 [ +  - ][ +  - ]:      24756 :                         GetDrawView()->GetModel()->GetDrawOutliner().GetBackgroundColor();
     136 [ +  - ][ +  - ]:      24756 :                 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( *_pPageBackgrdColor );
     137                 :            :             }
     138                 :            : 
     139                 :            :             aOldEEHoriTextDir =
     140 [ +  - ][ +  - ]:      24756 :                 GetDrawView()->GetModel()->GetDrawOutliner().GetDefaultHorizontalTextDirection();
     141                 :            :             EEHorizontalTextDirection aEEHoriTextDirOfPage =
     142         [ -  + ]:      24756 :                 _bIsPageRightToLeft ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
     143 [ +  - ][ +  - ]:      24756 :             GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aEEHoriTextDirOfPage );
     144                 :            :         }
     145                 :            : 
     146         [ +  - ]:      24756 :         pOutDev->Push( PUSH_LINECOLOR ); // #114231#
     147         [ -  + ]:      24756 :         if (pPrintData)
     148                 :            :         {
     149                 :            :             // hide drawings but not form controls (form controls are handled elsewhere)
     150                 :          0 :             SdrView &rSdrView = const_cast< SdrView & >(GetPageView()->GetView());
     151                 :          0 :             rSdrView.setHideDraw( !pPrintData->IsPrintDraw() );
     152                 :            :         }
     153         [ +  - ]:      24756 :         GetPageView()->DrawLayer( _nLayerID, pOutDev, pRedirector );
     154         [ +  - ]:      24756 :         pOutDev->Pop();
     155                 :            : 
     156                 :            :         // reset background color of the outliner & default horiz. text dir.
     157 [ +  - ][ +  + ]:      37134 :         if ( (_nLayerID == pIDDMA->GetHellId()) ||
         [ +  - ][ +  - ]
     158         [ +  - ]:      12378 :              (_nLayerID == pIDDMA->GetHeavenId()) )
     159                 :            :         {
     160 [ +  - ][ +  - ]:      24756 :             GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( aOldOutlinerBackgrdColor );
     161 [ +  - ][ +  - ]:      24756 :             GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aOldEEHoriTextDir );
     162                 :            :         }
     163                 :            : 
     164         [ +  - ]:      24756 :         pOutDev->SetDrawMode( nOldDrawMode );
     165                 :            :     }
     166                 :      24756 : }
     167                 :            : 
     168                 :            : 
     169                 :            : #define WIEDUWILLST 400
     170                 :            : 
     171                 :          0 : sal_Bool SwViewImp::IsDragPossible( const Point &rPoint )
     172                 :            : {
     173         [ #  # ]:          0 :     if ( !HasDrawView() )
     174                 :          0 :         return sal_False;
     175                 :            : 
     176                 :          0 :     const SdrMarkList &rMrkList = GetDrawView()->GetMarkedObjectList();
     177                 :            : 
     178         [ #  # ]:          0 :     if( !rMrkList.GetMarkCount() )
     179                 :          0 :         return sal_False;
     180                 :            : 
     181 [ #  # ][ #  # ]:          0 :     SdrObject *pO = rMrkList.GetMark(rMrkList.GetMarkCount()-1)->GetMarkedSdrObj();
     182                 :            : 
     183                 :          0 :     SwRect aRect;
     184 [ #  # ][ #  # ]:          0 :     if( pO && ::CalcClipRect( pO, aRect, sal_False ) )
         [ #  # ][ #  # ]
     185                 :            :     {
     186                 :          0 :         SwRect aTmp;
     187         [ #  # ]:          0 :         ::CalcClipRect( pO, aTmp, sal_True );
     188         [ #  # ]:          0 :         aRect.Union( aTmp );
     189                 :            :     }
     190                 :            :     else
     191         [ #  # ]:          0 :         aRect = GetShell()->GetLayout()->Frm();
     192                 :            : 
     193                 :          0 :     aRect.Top(    aRect.Top()    - WIEDUWILLST );
     194                 :          0 :     aRect.Bottom( aRect.Bottom() + WIEDUWILLST );
     195                 :          0 :     aRect.Left(   aRect.Left()   - WIEDUWILLST );
     196                 :          0 :     aRect.Right(  aRect.Right()  + WIEDUWILLST );
     197         [ #  # ]:          0 :     return aRect.IsInside( rPoint );
     198                 :            : }
     199                 :            : 
     200                 :            : 
     201                 :       1542 : void SwViewImp::NotifySizeChg( const Size &rNewSz )
     202                 :            : {
     203         [ +  + ]:       1542 :     if ( !HasDrawView() )
     204                 :            :         return;
     205                 :            : 
     206         [ +  - ]:        160 :     if ( GetPageView() )
     207         [ +  - ]:        160 :         GetPageView()->GetPage()->SetSize( rNewSz );
     208                 :            : 
     209                 :            :     // Limitation of the work area
     210         [ +  - ]:        160 :     const Rectangle aRect( Point( DOCUMENTBORDER, DOCUMENTBORDER ), rNewSz );
     211                 :        160 :     const Rectangle &rOldWork = GetDrawView()->GetWorkArea();
     212                 :        160 :     sal_Bool bCheckDrawObjs = sal_False;
     213 [ +  + ][ +  - ]:        160 :     if ( aRect != rOldWork )
     214                 :            :     {
     215 [ +  + ][ +  + ]:        158 :         if ( rOldWork.Bottom() > aRect.Bottom() || rOldWork.Right() > aRect.Right())
                 [ +  + ]
     216                 :         53 :             bCheckDrawObjs = sal_True;
     217                 :        158 :         GetDrawView()->SetWorkArea( aRect );
     218                 :            :     }
     219         [ +  + ]:        160 :     if ( !bCheckDrawObjs )
     220                 :            :         return;
     221                 :            : 
     222                 :            :     OSL_ENSURE( pSh->getIDocumentDrawModelAccess()->GetDrawModel(), "NotifySizeChg without DrawModel" );
     223 [ +  - ][ +  - ]:         53 :     SdrPage* pPage = pSh->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 );
                 [ +  - ]
     224         [ +  - ]:         53 :     const sal_uLong nObjs = pPage->GetObjCount();
     225         [ +  + ]:       1564 :     for( sal_uLong nObj = 0; nObj < nObjs; ++nObj )
     226                 :            :     {
     227         [ +  - ]:         22 :         SdrObject *pObj = pPage->GetObj( nObj );
     228 [ +  - ][ +  - ]:         22 :         if( !pObj->ISA(SwVirtFlyDrawObj) )
                 [ +  + ]
     229                 :            :         {
     230                 :            :             // Objects not anchored to the frame, do not need to be adjusted
     231         [ +  - ]:         14 :             const SwContact *pCont = (SwContact*)GetUserCall(pObj);
     232                 :            :             // this function might be called by the InsertDocument, when
     233                 :            :             // a PageDesc-Attribute is set on a node. Then the SdrObject
     234                 :            :             // must not have an UserCall.
     235 [ +  - ][ +  - ]:         14 :             if( !pCont || !pCont->ISA(SwDrawContact) )
         [ +  - ][ -  + ]
                 [ -  + ]
     236                 :          0 :                 continue;
     237                 :            : 
     238         [ +  - ]:         14 :             const SwFrm *pAnchor = ((SwDrawContact*)pCont)->GetAnchorFrm();
     239 [ +  - ][ +  - ]:         56 :             if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->IsValid() ||
                 [ +  - ]
           [ +  -  +  - ]
           [ +  -  +  + ]
                 [ +  + ]
     240         [ +  - ]:         28 :                  !pAnchor->GetUpper() || !pAnchor->FindPageFrm() ||
     241         [ +  - ]:         14 :                  (FLY_AS_CHAR == pCont->GetFmt()->GetAnchor().GetAnchorId()) )
     242                 :            :             {
     243                 :          6 :                 continue;
     244                 :            :             }
     245                 :            : 
     246                 :            :             // no move for drawing objects in header/footer
     247 [ +  - ][ -  + ]:          8 :             if ( pAnchor->FindFooterOrHeader() )
     248                 :            :             {
     249                 :          0 :                 continue;
     250                 :            :             }
     251                 :            : 
     252         [ +  - ]:          8 :             const Rectangle aBound( pObj->GetCurrentBoundRect() );
     253 [ +  - ][ -  + ]:          8 :             if ( !aRect.IsInside( aBound ) )
     254                 :            :             {
     255                 :          0 :                 Size aSz;
     256         [ #  # ]:          0 :                 if ( aBound.Left() > aRect.Right() )
     257                 :          0 :                     aSz.Width() = (aRect.Right() - aBound.Left()) - MINFLY;
     258         [ #  # ]:          0 :                 if ( aBound.Top() > aRect.Bottom() )
     259                 :          0 :                     aSz.Height() = (aRect.Bottom() - aBound.Top()) - MINFLY;
     260 [ #  # ][ #  # ]:          0 :                 if ( aSz.Width() || aSz.Height() )
                 [ #  # ]
     261         [ #  # ]:          0 :                     pObj->Move( aSz );
     262                 :            : 
     263                 :            :                 // Don't let large objects dissappear to the top
     264                 :          0 :                 aSz.Width() = aSz.Height() = 0;
     265         [ #  # ]:          0 :                 if ( aBound.Bottom() < aRect.Top() )
     266                 :          0 :                     aSz.Width() = (aBound.Bottom() - aRect.Top()) - MINFLY;
     267         [ #  # ]:          0 :                 if ( aBound.Right() < aRect.Left() )
     268                 :          0 :                     aSz.Height() = (aBound.Right() - aRect.Left()) - MINFLY;
     269 [ #  # ][ #  # ]:          0 :                 if ( aSz.Width() || aSz.Height() )
                 [ #  # ]
     270         [ #  # ]:         14 :                     pObj->Move( aSz );
     271                 :            :             }
     272                 :            :         }
     273                 :            :     }
     274                 :            : }
     275                 :            : 
     276                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10