LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewobjectcontactofsdrobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 42 59 71.2 %
Date: 2015-06-13 12:38:46 Functions: 9 9 100.0 %
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             : 
      21             : #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
      22             : #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
      23             : #include <svx/sdr/contact/objectcontact.hxx>
      24             : #include <svx/sdr/contact/displayinfo.hxx>
      25             : #include <sdr/contact/objectcontactofpageview.hxx>
      26             : #include <sdr/contact/viewcontactofsdrole2obj.hxx>
      27             : #include <svx/sdrpagewindow.hxx>
      28             : #include <svx/sdrpaintwindow.hxx>
      29             : #include <svx/svdobj.hxx>
      30             : #include <svx/svdoole2.hxx>
      31             : #include <svx/svdview.hxx>
      32             : #include <vcl/outdev.hxx>
      33             : 
      34             : #include "fmobj.hxx"
      35             : 
      36             : namespace sdr { namespace contact {
      37             : 
      38      184491 : const SdrObject& ViewObjectContactOfSdrObj::getSdrObject() const
      39             : {
      40      184491 :     return static_cast< ViewContactOfSdrObj& >(GetViewContact()).GetSdrObject();
      41             : }
      42             : 
      43       51208 : ViewObjectContactOfSdrObj::ViewObjectContactOfSdrObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
      44       51208 : :   ViewObjectContact(rObjectContact, rViewContact)
      45             : {
      46       51208 : }
      47             : 
      48       82158 : ViewObjectContactOfSdrObj::~ViewObjectContactOfSdrObj()
      49             : {
      50       82158 : }
      51             : 
      52       72108 : bool ViewObjectContactOfSdrObj::isPrimitiveVisibleOnAnyLayer(const SetOfByte& aLayers) const
      53             : {
      54       72108 :     return aLayers.IsSet(getSdrObject().GetLayer());
      55             : }
      56             : 
      57       92239 : bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
      58             : {
      59       92239 :     const SdrObject& rObject = getSdrObject();
      60             : 
      61             :     // Test layer visibility
      62       92239 :     if(!isPrimitiveVisibleOnAnyLayer(rDisplayInfo.GetProcessLayers()))
      63             :     {
      64       26637 :         return false;
      65             :     }
      66             : 
      67       65602 :     if(GetObjectContact().isOutputToPrinter() )
      68             :     {
      69             :         // Test if print output but not printable
      70           0 :         if( !rObject.IsPrintable())
      71           0 :             return false;
      72             :     }
      73             :     else
      74             :     {
      75             :         // test is object is not visible on screen
      76       65602 :         if( !rObject.IsVisible() )
      77           0 :             return false;
      78             :     }
      79             : 
      80             :     // Test for hidden object on MasterPage
      81       65602 :     if(rDisplayInfo.GetSubContentActive() && rObject.IsNotVisibleAsMaster())
      82             :     {
      83         140 :         return false;
      84             :     }
      85             : 
      86             :     // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
      87       65462 :     const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
      88             : 
      89       65462 :     if(pSdrPageView)
      90             :     {
      91       64267 :         const SdrView& rSdrView = pSdrPageView->GetView();
      92       64267 :         const bool bHideOle(rSdrView.getHideOle());
      93       64267 :         const bool bHideChart(rSdrView.getHideChart());
      94       64267 :         const bool bHideDraw(rSdrView.getHideDraw());
      95       64267 :         const bool bHideFormControl(rSdrView.getHideFormControl());
      96             : 
      97       64267 :         if(bHideOle || bHideChart || bHideDraw || bHideFormControl)
      98             :         {
      99           0 :             if(OBJ_OLE2 == rObject.GetObjIdentifier())
     100             :             {
     101           0 :                 if(static_cast<const SdrOle2Obj&>(rObject).IsChart())
     102             :                 {
     103             :                     // chart
     104           0 :                     if(bHideChart)
     105             :                     {
     106           0 :                         return false;
     107             :                     }
     108             :                 }
     109             :                 else
     110             :                 {
     111             :                     // OLE
     112           0 :                     if(bHideOle)
     113             :                     {
     114           0 :                         return false;
     115             :                     }
     116             :                 }
     117             :             }
     118           0 :             else if(OBJ_GRAF == rObject.GetObjIdentifier())
     119             :             {
     120             :                 // graphic handled like OLE
     121           0 :                 if(bHideOle)
     122             :                 {
     123           0 :                     return false;
     124             :                 }
     125             :             }
     126             :             else
     127             :             {
     128           0 :                 const bool bIsFormControl = dynamic_cast< const FmFormObj * >( &rObject ) != 0;
     129           0 :                 if(bIsFormControl && bHideFormControl)
     130             :                 {
     131           0 :                     return false;
     132             :                 }
     133             :                 // any other draw object
     134           0 :                 if(!bIsFormControl && bHideDraw)
     135             :                 {
     136           0 :                     return false;
     137             :                 }
     138             :             }
     139             :         }
     140             :     }
     141             : 
     142             :     // Check if this object is in the visible range.
     143       65462 :     const drawinglayer::geometry::ViewInformation2D& rViewInfo = GetObjectContact().getViewInformation2D();
     144       65462 :     basegfx::B2DRange aObjRange = GetViewContact().getRange(rViewInfo);
     145       65462 :     if (!aObjRange.isEmpty())
     146             :     {
     147          64 :         const basegfx::B2DRange& rViewRange = rViewInfo.getViewport();
     148          64 :         bool bVisible = rViewRange.isEmpty() || rViewRange.overlaps(aObjRange);
     149          64 :         if (!bVisible)
     150           2 :             return false;
     151             :     }
     152             : 
     153       65460 :     return true;
     154             : }
     155             : 
     156        4194 : boost::optional<const OutputDevice&> ViewObjectContactOfSdrObj::getPageViewOutputDevice() const
     157             : {
     158        4194 :     ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &GetObjectContact() );
     159        4194 :     if ( pPageViewContact )
     160             :     {
     161             :         // if the PageWindow has a patched PaintWindow, use the original PaintWindow
     162             :         // this ensures that our control is _not_ re-created just because somebody
     163             :         // (temporarily) changed the window to paint onto.
     164             :         // #i72429# / 2007-02-20 / frank.schoenheit (at) sun.com
     165        4192 :         SdrPageWindow& rPageWindow( pPageViewContact->GetPageWindow() );
     166        4192 :         if ( rPageWindow.GetOriginalPaintWindow() )
     167        3853 :             return rPageWindow.GetOriginalPaintWindow()->GetOutputDevice();
     168             : 
     169         339 :         return rPageWindow.GetPaintWindow().GetOutputDevice();
     170             :     }
     171           2 :     return boost::optional<const OutputDevice&>();
     172             : }
     173             : 
     174         435 : }}
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11