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

Generated by: LCOV version 1.10