LCOV - code coverage report
Current view: top level - svx/source/svdraw - sdrmasterpagedescriptor.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 42 69.0 %
Date: 2015-06-13 12:38:46 Functions: 7 10 70.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             : #include <svx/sdrmasterpagedescriptor.hxx>
      21             : #include <sdr/contact/viewcontactofmasterpagedescriptor.hxx>
      22             : #include <svx/svdpage.hxx>
      23             : #include <svx/svdobj.hxx>
      24             : #include <svx/xfillit0.hxx>
      25             : #include <svl/itemset.hxx>
      26             : 
      27             : using namespace com::sun::star;
      28             : 
      29             : namespace sdr
      30             : {
      31             :     // ViewContact part
      32        2008 :     sdr::contact::ViewContact* MasterPageDescriptor::CreateObjectSpecificViewContact()
      33             :     {
      34        2008 :         return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
      35             :     }
      36             : 
      37        2008 :     MasterPageDescriptor::MasterPageDescriptor(SdrPage& aOwnerPage, SdrPage& aUsedPage)
      38             :     :   maOwnerPage(aOwnerPage),
      39             :         maUsedPage(aUsedPage),
      40        2008 :         mpViewContact(0L)
      41             :     {
      42             :         // all layers visible
      43        2008 :         maVisibleLayers.SetAll();
      44             : 
      45             :         // register at used page
      46        2008 :         maUsedPage.AddPageUser(*this);
      47        2008 :     }
      48             : 
      49        5979 :     MasterPageDescriptor::~MasterPageDescriptor()
      50             :     {
      51             :         // de-register at used page
      52        1993 :         maUsedPage.RemovePageUser(*this);
      53             : 
      54        1993 :         if(mpViewContact)
      55             :         {
      56        1993 :             delete mpViewContact;
      57        1993 :             mpViewContact = 0L;
      58             :         }
      59        3986 :     }
      60             : 
      61             :     // ViewContact part
      62       12345 :     sdr::contact::ViewContact& MasterPageDescriptor::GetViewContact() const
      63             :     {
      64       12345 :         if(!mpViewContact)
      65             :         {
      66             :             const_cast< MasterPageDescriptor* >(this)->mpViewContact =
      67        2008 :                 const_cast< MasterPageDescriptor* >(this)->CreateObjectSpecificViewContact();
      68             :         }
      69             : 
      70       12345 :         return *mpViewContact;
      71             :     }
      72             : 
      73             :     // this method is called form the destructor of the referenced page.
      74             :     // do all necessary action to forget the page. It is not necessary to call
      75             :     // RemovePageUser(), that is done form the destructor.
      76           0 :     void MasterPageDescriptor::PageInDestruction(const SdrPage& /*rPage*/)
      77             :     {
      78           0 :         maOwnerPage.TRG_ClearMasterPage();
      79           0 :     }
      80             : 
      81         515 :     void MasterPageDescriptor::SetVisibleLayers(const SetOfByte& rNew)
      82             :     {
      83         515 :         if(rNew != maVisibleLayers)
      84             :         {
      85           0 :             maVisibleLayers = rNew;
      86           0 :             GetViewContact().ActionChanged();
      87             :         }
      88         515 :     }
      89             : 
      90             :     // operators
      91           0 :     bool MasterPageDescriptor::operator==(const MasterPageDescriptor& rCandidate) const
      92             :     {
      93           0 :         return (&maOwnerPage == &rCandidate.maOwnerPage
      94           0 :             && &maUsedPage == &rCandidate.maUsedPage
      95           0 :             && maVisibleLayers == rCandidate.maVisibleLayers);
      96             :     }
      97             : 
      98           0 :     bool MasterPageDescriptor::operator!=(const MasterPageDescriptor& rCandidate) const
      99             :     {
     100           0 :         return (&maOwnerPage != &rCandidate.maOwnerPage
     101           0 :             || &maUsedPage != &rCandidate.maUsedPage
     102           0 :             || maVisibleLayers != rCandidate.maVisibleLayers);
     103             :     }
     104             : 
     105        1183 :     const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const
     106             :     {
     107        1183 :         const SdrPage* pCorrectPage = &GetOwnerPage();
     108        1183 :         const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties();
     109             : 
     110        1183 :         if(drawing::FillStyle_NONE == static_cast<const XFillStyleItem&>(pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
     111             :         {
     112        1183 :             pCorrectPage = &GetUsedPage();
     113        1183 :             pCorrectProperties = &pCorrectPage->getSdrPageProperties();
     114             :         }
     115             : 
     116        1183 :         if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet())
     117             :         {
     118             :             // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
     119             :             // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
     120             :             // MasterPages should have a StyleSheet excactly for this reason, but historically
     121             :             // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
     122           9 :             pCorrectProperties = 0;
     123             :         }
     124             : 
     125        1183 :         return pCorrectProperties;
     126             :     }
     127             : } // end of namespace sdr
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11