LCOV - code coverage report
Current view: top level - sw/source/core/view - vdraw.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 79 116 68.1 %
Date: 2014-04-11 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svx/svdmodel.hxx>
      21             : #include <svx/svdpage.hxx>
      22             : #include <tools/shl.hxx>
      23             : #include <swmodule.hxx>
      24             : #include <svtools/accessibilityoptions.hxx>
      25             : #include <svx/svdpagv.hxx>
      26             : #include <fmtanchr.hxx>
      27             : #include <frmfmt.hxx>
      28             : 
      29             : #include <svx/svdoutl.hxx>
      30             : 
      31             : #include "fesh.hxx"
      32             : #include "pagefrm.hxx"
      33             : #include "rootfrm.hxx"
      34             : #include "viewimp.hxx"
      35             : #include "dflyobj.hxx"
      36             : #include "viewopt.hxx"
      37             : #include "printdata.hxx"
      38             : #include "dcontact.hxx"
      39             : #include "dview.hxx"
      40             : #include "flyfrm.hxx"
      41             : #include <vcl/svapp.hxx>
      42             : #include <vcl/settings.hxx>
      43             : 
      44             : #include <IDocumentDrawModelAccess.hxx>
      45             : 
      46       46853 : void SwViewImp::StartAction()
      47             : {
      48       46853 :     if ( HasDrawView() )
      49             :     {
      50       46853 :         SET_CURR_SHELL( GetShell() );
      51       46853 :         if ( pSh->ISA(SwFEShell) )
      52       46853 :             ((SwFEShell*)pSh)->HideChainMarker(); // might have changed
      53             :     }
      54       46853 : }
      55             : 
      56       26206 : void SwViewImp::EndAction()
      57             : {
      58       26206 :     if ( HasDrawView() )
      59             :     {
      60       26206 :         SET_CURR_SHELL( GetShell() );
      61       26206 :         if ( pSh->ISA(SwFEShell) )
      62       26206 :             ((SwFEShell*)pSh)->SetChainMarker(); // might have changed
      63             :     }
      64       26206 : }
      65             : 
      66        6108 : void SwViewImp::LockPaint()
      67             : {
      68        6108 :     if ( HasDrawView() )
      69             :     {
      70        6108 :         bResetHdlHiddenPaint = !GetDrawView()->areMarkHandlesHidden();
      71        6108 :         GetDrawView()->hideMarkHandles();
      72             :     }
      73             :     else
      74             :     {
      75           0 :         bResetHdlHiddenPaint = false;
      76             :     }
      77        6108 : }
      78             : 
      79        6108 : void SwViewImp::UnlockPaint()
      80             : {
      81        6108 :     if ( bResetHdlHiddenPaint )
      82        6108 :         GetDrawView()->showMarkHandles();
      83        6108 : }
      84             : 
      85       13622 : void SwViewImp::PaintLayer( const SdrLayerID _nLayerID,
      86             :                             SwPrintData const*const pPrintData,
      87             :                             const SwRect& aPaintRect,
      88             :                             const Color* _pPageBackgrdColor,
      89             :                             const bool _bIsPageRightToLeft,
      90             :                             sdr::contact::ViewObjectContactRedirector* pRedirector ) const
      91             : {
      92       13622 :     if ( HasDrawView() )
      93             :     {
      94             :         //change the draw mode in high contrast mode
      95       13622 :         OutputDevice* pOutDev = GetShell()->GetOut();
      96       13622 :         sal_uLong nOldDrawMode = pOutDev->GetDrawMode();
      97       40826 :         if( GetShell()->GetWin() &&
      98       13622 :             Application::GetSettings().GetStyleSettings().GetHighContrastMode() &&
      99           0 :             (!GetShell()->IsPreview()||SW_MOD()->GetAccessibilityOptions().GetIsForPagePreviews()))
     100             :         {
     101             :             pOutDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
     102           0 :                                 DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
     103             :         }
     104             : 
     105             :         // For correct handling of accessibility, high contrast, the
     106             :         // page background color is set as the background color at the
     107             :         // outliner of the draw view.  Only necessary for the layers
     108             :         // hell and heaven
     109       13622 :         Color aOldOutlinerBackgrdColor;
     110             :         // set default horizontal text direction on painting <hell> or
     111             :         // <heaven>.
     112       13622 :         EEHorizontalTextDirection aOldEEHoriTextDir = EE_HTEXTDIR_L2R;
     113       13622 :         const IDocumentDrawModelAccess* pIDDMA = GetShell()->getIDocumentDrawModelAccess();
     114       20433 :         if ( (_nLayerID == pIDDMA->GetHellId()) ||
     115        6811 :              (_nLayerID == pIDDMA->GetHeavenId()) )
     116             :         {
     117             :             OSL_ENSURE( _pPageBackgrdColor,
     118             :                     "incorrect usage of SwViewImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>");
     119       13622 :             if ( _pPageBackgrdColor )
     120             :             {
     121             :                 aOldOutlinerBackgrdColor =
     122       13622 :                         GetDrawView()->GetModel()->GetDrawOutliner().GetBackgroundColor();
     123       13622 :                 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( *_pPageBackgrdColor );
     124             :             }
     125             : 
     126             :             aOldEEHoriTextDir =
     127       13622 :                 GetDrawView()->GetModel()->GetDrawOutliner().GetDefaultHorizontalTextDirection();
     128             :             EEHorizontalTextDirection aEEHoriTextDirOfPage =
     129       13622 :                 _bIsPageRightToLeft ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
     130       13622 :             GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aEEHoriTextDirOfPage );
     131             :         }
     132             : 
     133       13622 :         pOutDev->Push( PUSH_LINECOLOR ); // #114231#
     134       13622 :         if (pPrintData)
     135             :         {
     136             :             // hide drawings but not form controls (form controls are handled elsewhere)
     137           0 :             SdrView &rSdrView = const_cast< SdrView & >(GetPageView()->GetView());
     138           0 :             rSdrView.setHideDraw( !pPrintData->IsPrintDraw() );
     139             :         }
     140       13622 :         GetPageView()->DrawLayer( _nLayerID, pOutDev, pRedirector, aPaintRect.SVRect() );
     141       13622 :         pOutDev->Pop();
     142             : 
     143             :         // reset background color of the outliner & default horiz. text dir.
     144       20433 :         if ( (_nLayerID == pIDDMA->GetHellId()) ||
     145        6811 :              (_nLayerID == pIDDMA->GetHeavenId()) )
     146             :         {
     147       13622 :             GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( aOldOutlinerBackgrdColor );
     148       13622 :             GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aOldEEHoriTextDir );
     149             :         }
     150             : 
     151       13622 :         pOutDev->SetDrawMode( nOldDrawMode );
     152             :     }
     153       13622 : }
     154             : 
     155             : #define FUZZY_EDGE 400
     156             : 
     157           0 : bool SwViewImp::IsDragPossible( const Point &rPoint )
     158             : {
     159           0 :     if ( !HasDrawView() )
     160           0 :         return false;
     161             : 
     162           0 :     const SdrMarkList &rMrkList = GetDrawView()->GetMarkedObjectList();
     163             : 
     164           0 :     if( !rMrkList.GetMarkCount() )
     165           0 :         return false;
     166             : 
     167           0 :     SdrObject *pO = rMrkList.GetMark(rMrkList.GetMarkCount()-1)->GetMarkedSdrObj();
     168             : 
     169           0 :     SwRect aRect;
     170           0 :     if( pO && ::CalcClipRect( pO, aRect, sal_False ) )
     171             :     {
     172           0 :         SwRect aTmp;
     173           0 :         ::CalcClipRect( pO, aTmp, sal_True );
     174           0 :         aRect.Union( aTmp );
     175             :     }
     176             :     else
     177           0 :         aRect = GetShell()->GetLayout()->Frm();
     178             : 
     179           0 :     aRect.Top(    aRect.Top()    - FUZZY_EDGE );
     180           0 :     aRect.Bottom( aRect.Bottom() + FUZZY_EDGE );
     181           0 :     aRect.Left(   aRect.Left()   - FUZZY_EDGE );
     182           0 :     aRect.Right(  aRect.Right()  + FUZZY_EDGE );
     183           0 :     return aRect.IsInside( rPoint );
     184             : }
     185             : 
     186        3004 : void SwViewImp::NotifySizeChg( const Size &rNewSz )
     187             : {
     188        3004 :     if ( !HasDrawView() )
     189        5204 :         return;
     190             : 
     191         603 :     if ( GetPageView() )
     192         603 :         GetPageView()->GetPage()->SetSize( rNewSz );
     193             : 
     194             :     // Limitation of the work area
     195         603 :     const Rectangle aRect( Point( DOCUMENTBORDER, DOCUMENTBORDER ), rNewSz );
     196         603 :     const Rectangle &rOldWork = GetDrawView()->GetWorkArea();
     197         603 :     bool bCheckDrawObjs = false;
     198         603 :     if ( aRect != rOldWork )
     199             :     {
     200         597 :         if ( rOldWork.Bottom() > aRect.Bottom() || rOldWork.Right() > aRect.Right())
     201         201 :             bCheckDrawObjs = true;
     202         597 :         GetDrawView()->SetWorkArea( aRect );
     203             :     }
     204         603 :     if ( !bCheckDrawObjs )
     205         402 :         return;
     206             : 
     207             :     OSL_ENSURE( pSh->getIDocumentDrawModelAccess()->GetDrawModel(), "NotifySizeChg without DrawModel" );
     208         201 :     SdrPage* pPage = pSh->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 );
     209         201 :     const sal_uLong nObjs = pPage->GetObjCount();
     210        2180 :     for( sal_uLong nObj = 0; nObj < nObjs; ++nObj )
     211             :     {
     212        1979 :         SdrObject *pObj = pPage->GetObj( nObj );
     213        1979 :         if( !pObj->ISA(SwVirtFlyDrawObj) )
     214             :         {
     215             :             // Objects not anchored to the frame, do not need to be adjusted
     216         481 :             const SwContact *pCont = (SwContact*)GetUserCall(pObj);
     217             :             // this function might be called by the InsertDocument, when
     218             :             // a PageDesc-Attribute is set on a node. Then the SdrObject
     219             :             // must not have an UserCall.
     220         481 :             if( !pCont || !pCont->ISA(SwDrawContact) )
     221         525 :                 continue;
     222             : 
     223         413 :             const SwFrm *pAnchor = ((SwDrawContact*)pCont)->GetAnchorFrm();
     224        1189 :             if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->IsValid() ||
     225        1568 :                  !pAnchor->GetUpper() || !pAnchor->FindPageFrm() ||
     226         385 :                  (FLY_AS_CHAR == pCont->GetFmt()->GetAnchor().GetAnchorId()) )
     227             :             {
     228          29 :                 continue;
     229             :             }
     230             : 
     231             :             // no move for drawing objects in header/footer
     232         384 :             if ( pAnchor->FindFooterOrHeader() )
     233             :             {
     234         360 :                 continue;
     235             :             }
     236             : 
     237          24 :             const Rectangle aBound( pObj->GetCurrentBoundRect() );
     238          24 :             if ( !aRect.IsInside( aBound ) )
     239             :             {
     240           0 :                 Size aSz;
     241           0 :                 if ( aBound.Left() > aRect.Right() )
     242           0 :                     aSz.Width() = (aRect.Right() - aBound.Left()) - MINFLY;
     243           0 :                 if ( aBound.Top() > aRect.Bottom() )
     244           0 :                     aSz.Height() = (aRect.Bottom() - aBound.Top()) - MINFLY;
     245           0 :                 if ( aSz.Width() || aSz.Height() )
     246           0 :                     pObj->Move( aSz );
     247             : 
     248             :                 // Don't let large objects dissappear to the top
     249           0 :                 aSz.Width() = aSz.Height() = 0;
     250           0 :                 if ( aBound.Bottom() < aRect.Top() )
     251           0 :                     aSz.Width() = (aBound.Bottom() - aRect.Top()) - MINFLY;
     252           0 :                 if ( aBound.Right() < aRect.Left() )
     253           0 :                     aSz.Height() = (aBound.Right() - aRect.Left()) - MINFLY;
     254           0 :                 if ( aSz.Width() || aSz.Height() )
     255           0 :                     pObj->Move( aSz );
     256             :             }
     257             :         }
     258             :     }
     259             : }
     260             : 
     261             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10