LCOV - code coverage report
Current view: top level - svx/source/svdraw - sdrmasterpagedescriptor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 38 76.3 %
Date: 2012-08-25 Functions: 7 10 70.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 38 42.1 %

           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                 :            : #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                 :        630 :     sdr::contact::ViewContact* MasterPageDescriptor::CreateObjectSpecificViewContact()
      35                 :            :     {
      36         [ +  - ]:        630 :         return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
      37                 :            :     }
      38                 :            : 
      39                 :        630 :     MasterPageDescriptor::MasterPageDescriptor(SdrPage& aOwnerPage, SdrPage& aUsedPage)
      40                 :            :     :   maOwnerPage(aOwnerPage),
      41                 :            :         maUsedPage(aUsedPage),
      42                 :        630 :         mpViewContact(0L)
      43                 :            :     {
      44                 :            :         // all layers visible
      45                 :        630 :         maVisibleLayers.SetAll();
      46                 :            : 
      47                 :            :         // register at used page
      48         [ +  - ]:        630 :         maUsedPage.AddPageUser(*this);
      49                 :        630 :     }
      50                 :            : 
      51                 :        621 :     MasterPageDescriptor::~MasterPageDescriptor()
      52                 :            :     {
      53                 :            :         // de-register at used page
      54         [ +  - ]:        621 :         maUsedPage.RemovePageUser(*this);
      55                 :            : 
      56         [ +  - ]:        621 :         if(mpViewContact)
      57                 :            :         {
      58 [ +  - ][ +  - ]:        621 :             delete mpViewContact;
      59                 :        621 :             mpViewContact = 0L;
      60                 :            :         }
      61         [ -  + ]:       1242 :     }
      62                 :            : 
      63                 :            :     // ViewContact part
      64                 :       5635 :     sdr::contact::ViewContact& MasterPageDescriptor::GetViewContact() const
      65                 :            :     {
      66         [ +  + ]:       5635 :         if(!mpViewContact)
      67                 :            :         {
      68                 :            :             const_cast< MasterPageDescriptor* >(this)->mpViewContact =
      69                 :        630 :                 const_cast< MasterPageDescriptor* >(this)->CreateObjectSpecificViewContact();
      70                 :            :         }
      71                 :            : 
      72                 :       5635 :         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                 :         97 :     void MasterPageDescriptor::SetVisibleLayers(const SetOfByte& rNew)
      84                 :            :     {
      85         [ -  + ]:         97 :         if(rNew != maVisibleLayers)
      86                 :            :         {
      87                 :          0 :             maVisibleLayers = rNew;
      88                 :          0 :             GetViewContact().ActionChanged();
      89                 :            :         }
      90                 :         97 :     }
      91                 :            : 
      92                 :            :     // operators
      93                 :          0 :     sal_Bool MasterPageDescriptor::operator==(const MasterPageDescriptor& rCandidate) const
      94                 :            :     {
      95                 :            :         return (&maOwnerPage == &rCandidate.maOwnerPage
      96                 :            :             && &maUsedPage == &rCandidate.maUsedPage
      97 [ #  # ][ #  # ]:          0 :             && maVisibleLayers == rCandidate.maVisibleLayers);
                 [ #  # ]
      98                 :            :     }
      99                 :            : 
     100                 :          0 :     sal_Bool MasterPageDescriptor::operator!=(const MasterPageDescriptor& rCandidate) const
     101                 :            :     {
     102                 :            :         return (&maOwnerPage != &rCandidate.maOwnerPage
     103                 :            :             || &maUsedPage != &rCandidate.maUsedPage
     104 [ #  # ][ #  # ]:          0 :             || maVisibleLayers != rCandidate.maVisibleLayers);
                 [ #  # ]
     105                 :            :     }
     106                 :            : 
     107                 :       1481 :     const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const
     108                 :            :     {
     109                 :       1481 :         const SdrPage* pCorrectPage = &GetOwnerPage();
     110                 :       1481 :         const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties();
     111                 :            : 
     112         [ +  - ]:       1481 :         if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
     113                 :            :         {
     114                 :       1481 :             pCorrectPage = &GetUsedPage();
     115                 :       1481 :             pCorrectProperties = &pCorrectPage->getSdrPageProperties();
     116                 :            :         }
     117                 :            : 
     118 [ +  - ][ +  + ]:       1481 :         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                 :         11 :             pCorrectProperties = 0;
     125                 :            :         }
     126                 :            : 
     127                 :       1481 :         return pCorrectProperties;
     128                 :            :     }
     129                 :            : } // end of namespace sdr
     130                 :            : 
     131                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10