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

Generated by: LCOV version 1.11