LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewobjectcontactofmasterpagedescriptor.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 45 46 97.8 %
Date: 2014-11-03 Functions: 8 8 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 <sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
      22             : #include <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         414 :         ViewObjectContactOfMasterPageDescriptor::ViewObjectContactOfMasterPageDescriptor(ObjectContact& rObjectContact, ViewContact& rViewContact)
      39         414 :         :   ViewObjectContact(rObjectContact, rViewContact)
      40             :         {
      41         414 :         }
      42             : 
      43         828 :         ViewObjectContactOfMasterPageDescriptor::~ViewObjectContactOfMasterPageDescriptor()
      44             :         {
      45         828 :         }
      46             : 
      47        1552 :         sdr::MasterPageDescriptor& ViewObjectContactOfMasterPageDescriptor::GetMasterPageDescriptor() const
      48             :         {
      49        1552 :             return static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).GetMasterPageDescriptor();
      50             :         }
      51             : 
      52        1552 :         bool ViewObjectContactOfMasterPageDescriptor::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
      53             :         {
      54        1552 :             if(rDisplayInfo.GetControlLayerProcessingActive())
      55             :             {
      56         776 :                 return false;
      57             :             }
      58             : 
      59         776 :             if(!rDisplayInfo.GetPageProcessingActive())
      60             :             {
      61           0 :                 return false;
      62             :             }
      63             : 
      64         776 :             return true;
      65             :         }
      66             : 
      67        1552 :         drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfMasterPageDescriptor::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
      68             :         {
      69        1552 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
      70        3104 :             drawinglayer::primitive2d::Primitive2DSequence xMasterPageSequence;
      71        1552 :             const sdr::MasterPageDescriptor& rDescriptor = GetMasterPageDescriptor();
      72             : 
      73             :             // used range (retval) is fixed here, it's the MasterPage fill range
      74        1552 :             const SdrPage& rOwnerPage = rDescriptor.GetOwnerPage();
      75             :             const basegfx::B2DRange aPageFillRange(
      76        3104 :                 rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
      77        4656 :                 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        1552 :             const SetOfByte aRememberedLayers(rDisplayInfo.GetProcessLayers());
      82        1552 :             SetOfByte aPreprocessedLayers(aRememberedLayers);
      83        1552 :             aPreprocessedLayers &= rDescriptor.GetVisibleLayers();
      84        1552 :             rDisplayInfo.SetProcessLayers(aPreprocessedLayers);
      85        1552 :             rDisplayInfo.SetSubContentActive(true);
      86             : 
      87             :             // check layer visibility (traditionally was member of layer 1)
      88        1552 :             if(aPreprocessedLayers.IsSet(1))
      89             :             {
      90             :                 // hide PageBackground for special DrawModes; historical reasons
      91         776 :                 if(!GetObjectContact().isDrawModeGray() && !GetObjectContact().isDrawModeHighContrast())
      92             :                 {
      93             :                     // if visible, create the default background primitive sequence
      94         776 :                     xRetval = static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).getViewIndependentPrimitive2DSequence();
      95             :                 }
      96             :             }
      97             : 
      98             :             // hide MasterPage content? Test self here for hierarchy
      99        1552 :             if(isPrimitiveVisible(rDisplayInfo))
     100             :             {
     101             :                 // get the VOC of the Master-SdrPage and get its object hierarchy
     102         776 :                 ViewContact& rViewContactOfMasterPage(rDescriptor.GetUsedPage().GetViewContact());
     103         776 :                 ViewObjectContact& rVOCOfMasterPage(rViewContactOfMasterPage.GetViewObjectContact(GetObjectContact()));
     104             : 
     105         776 :                 xMasterPageSequence = rVOCOfMasterPage.getPrimitive2DSequenceHierarchy(rDisplayInfo);
     106             :             }
     107             : 
     108             :             // reset DisplayInfo changes for MasterPage paint
     109        1552 :             rDisplayInfo.SetProcessLayers(aRememberedLayers);
     110        1552 :             rDisplayInfo.SetSubContentActive(false);
     111             : 
     112        1552 :             if(xMasterPageSequence.hasElements())
     113             :             {
     114             :                 // get range of MasterPage sub hierarchy
     115          87 :                 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
     116          87 :                 const basegfx::B2DRange aSubHierarchyRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xMasterPageSequence, rViewInformation2D));
     117             : 
     118          87 :                 if(aPageFillRange.isInside(aSubHierarchyRange))
     119             :                 {
     120             :                     // completely inside, just render MasterPage content. Add to target
     121          70 :                     drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xMasterPageSequence);
     122             :                 }
     123          17 :                 else if(aPageFillRange.overlaps(aSubHierarchyRange))
     124             :                 {
     125             :                     // overlapping, compute common area
     126          17 :                     basegfx::B2DRange aCommonArea(aPageFillRange);
     127          17 :                     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          17 :                         basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aCommonArea)), xMasterPageSequence));
     132          17 :                     drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
     133             :                 }
     134             :             }
     135             : 
     136             :             // return grouped primitive
     137        3104 :             return xRetval;
     138             :         }
     139             :     } // end of namespace contact
     140         651 : } // end of namespace sdr
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10