LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewobjectcontactofmasterpagedescriptor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 45 97.8 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 55 100 55.0 %

           Branch data     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/viewobjectcontactofmasterpagedescriptor.hxx>
      22                 :            : #include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
      23                 :            : #include <svx/sdr/contact/displayinfo.hxx>
      24                 :            : #include <svx/sdr/contact/objectcontact.hxx>
      25                 :            : #include <svx/svdpagv.hxx>
      26                 :            : #include <svx/svdview.hxx>
      27                 :            : #include <svx/svdpage.hxx>
      28                 :            : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
      29                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      30                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      31                 :            : 
      32                 :            : //////////////////////////////////////////////////////////////////////////////
      33                 :            : 
      34                 :            : namespace sdr
      35                 :            : {
      36                 :            :     namespace contact
      37                 :            :     {
      38                 :        405 :         ViewObjectContactOfMasterPageDescriptor::ViewObjectContactOfMasterPageDescriptor(ObjectContact& rObjectContact, ViewContact& rViewContact)
      39                 :        405 :         :   ViewObjectContact(rObjectContact, rViewContact)
      40                 :            :         {
      41                 :        405 :         }
      42                 :            : 
      43                 :        405 :         ViewObjectContactOfMasterPageDescriptor::~ViewObjectContactOfMasterPageDescriptor()
      44                 :            :         {
      45         [ -  + ]:        810 :         }
      46                 :            : 
      47                 :       2482 :         sdr::MasterPageDescriptor& ViewObjectContactOfMasterPageDescriptor::GetMasterPageDescriptor() const
      48                 :            :         {
      49                 :       2482 :             return static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).GetMasterPageDescriptor();
      50                 :            :         }
      51                 :            : 
      52                 :       2482 :         bool ViewObjectContactOfMasterPageDescriptor::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
      53                 :            :         {
      54         [ +  + ]:       2482 :             if(rDisplayInfo.GetControlLayerProcessingActive())
      55                 :            :             {
      56                 :       1241 :                 return false;
      57                 :            :             }
      58                 :            : 
      59         [ -  + ]:       1241 :             if(!rDisplayInfo.GetPageProcessingActive())
      60                 :            :             {
      61                 :          0 :                 return false;
      62                 :            :             }
      63                 :            : 
      64                 :       2482 :             return true;
      65                 :            :         }
      66                 :            : 
      67                 :       2482 :         drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfMasterPageDescriptor::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
      68                 :            :         {
      69         [ +  - ]:       2482 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
      70         [ +  - ]:       2482 :             drawinglayer::primitive2d::Primitive2DSequence xMasterPageSequence;
      71                 :       2482 :             const sdr::MasterPageDescriptor& rDescriptor = GetMasterPageDescriptor();
      72                 :            : 
      73                 :            :             // used range (retval) is fixed here, it's the MasterPage fill range
      74                 :       2482 :             const SdrPage& rOwnerPage = rDescriptor.GetOwnerPage();
      75                 :            :             const basegfx::B2DRange aPageFillRange(
      76 [ +  - ][ +  - ]:       2482 :                 rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
      77 [ +  - ][ +  - ]:       4964 :                 rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(), rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
         [ +  - ][ +  - ]
                 [ +  - ]
      78                 :            : 
      79                 :            :             // Modify DisplayInfo for MasterPageContent collection; remember original layers and
      80                 :            :             // set combined LayerSet; set MasterPagePaint flag
      81                 :       2482 :             const SetOfByte aRememberedLayers(rDisplayInfo.GetProcessLayers());
      82                 :       2482 :             SetOfByte aPreprocessedLayers(aRememberedLayers);
      83         [ +  - ]:       2482 :             aPreprocessedLayers &= rDescriptor.GetVisibleLayers();
      84         [ +  - ]:       2482 :             rDisplayInfo.SetProcessLayers(aPreprocessedLayers);
      85         [ +  - ]:       2482 :             rDisplayInfo.SetSubContentActive(true);
      86                 :            : 
      87                 :            :             // check layer visibility (traditionally was member of layer 1)
      88         [ +  + ]:       2482 :             if(aPreprocessedLayers.IsSet(1))
      89                 :            :             {
      90                 :            :                 // hide PageBackground for special DrawModes; historical reasons
      91 [ +  - ][ +  - ]:       1241 :                 if(!GetObjectContact().isDrawModeGray() && !GetObjectContact().isDrawModeHighContrast())
         [ +  - ][ +  - ]
                 [ +  - ]
      92                 :            :                 {
      93                 :            :                     // if visible, create the default background primitive sequence
      94 [ +  - ][ +  - ]:       1241 :                     xRetval = static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).getViewIndependentPrimitive2DSequence();
                 [ +  - ]
      95                 :            :                 }
      96                 :            :             }
      97                 :            : 
      98                 :            :             // hide MasterPage content? Test self here for hierarchy
      99 [ +  - ][ +  + ]:       2482 :             if(isPrimitiveVisible(rDisplayInfo))
     100                 :            :             {
     101                 :            :                 // get the VOC of the Master-SdrPage and get it's object hierarchy
     102         [ +  - ]:       1241 :                 ViewContact& rViewContactOfMasterPage(rDescriptor.GetUsedPage().GetViewContact());
     103         [ +  - ]:       1241 :                 ViewObjectContact& rVOCOfMasterPage(rViewContactOfMasterPage.GetViewObjectContact(GetObjectContact()));
     104                 :            : 
     105 [ +  - ][ +  - ]:       1241 :                 xMasterPageSequence = rVOCOfMasterPage.getPrimitive2DSequenceHierarchy(rDisplayInfo);
                 [ +  - ]
     106                 :            :             }
     107                 :            : 
     108                 :            :             // reset DisplayInfo changes for MasterPage paint
     109         [ +  - ]:       2482 :             rDisplayInfo.SetProcessLayers(aRememberedLayers);
     110         [ +  - ]:       2482 :             rDisplayInfo.SetSubContentActive(false);
     111                 :            : 
     112         [ +  + ]:       2482 :             if(xMasterPageSequence.hasElements())
     113                 :            :             {
     114                 :            :                 // get range of MasterPage sub hierarchy
     115                 :        154 :                 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
     116         [ +  - ]:        154 :                 const basegfx::B2DRange aSubHierarchyRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xMasterPageSequence, rViewInformation2D));
     117                 :            : 
     118 [ +  - ][ +  + ]:        154 :                 if(aPageFillRange.isInside(aSubHierarchyRange))
     119                 :            :                 {
     120                 :            :                     // completely inside, just render MasterPage content. Add to target
     121         [ +  - ]:        123 :                     drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xMasterPageSequence);
     122                 :            :                 }
     123 [ +  - ][ +  - ]:         31 :                 else if(aPageFillRange.overlaps(aSubHierarchyRange))
     124                 :            :                 {
     125                 :            :                     // overlapping, compute common area
     126                 :         31 :                     basegfx::B2DRange aCommonArea(aPageFillRange);
     127         [ +  - ]:         31 :                     aCommonArea.intersect(aSubHierarchyRange);
     128                 :            : 
     129                 :            :                     // need to create a clip primitive, add clipped list to target
     130                 :            :                     const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MaskPrimitive2D(
     131 [ +  - ][ +  - ]:         31 :                         basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aCommonArea)), xMasterPageSequence));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     132         [ +  - ]:        154 :                     drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
     133                 :            :                 }
     134                 :            :             }
     135                 :            : 
     136                 :            :             // return grouped primitive
     137         [ +  - ]:       2482 :             return xRetval;
     138                 :            :         }
     139                 :            :     } // end of namespace contact
     140                 :            : } // end of namespace sdr
     141                 :            : 
     142                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10