LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/inc - shapeattributelayerholder.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 19 0.0 %
Date: 2012-12-27 Functions: 0 5 0.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             : #ifndef INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYERHOLDER_HXX
      21             : #define INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYERHOLDER_HXX
      22             : 
      23             : #include "attributableshape.hxx"
      24             : #include "shapeattributelayer.hxx"
      25             : 
      26             : #include <boost/noncopyable.hpp>
      27             : 
      28             : namespace slideshow
      29             : {
      30             :     namespace internal
      31             :     {
      32             :         /** Holds a ShapeAttributeLayer, together with the associated
      33             :             Shape
      34             : 
      35             :             Use this class to hold ShapeAttributeLayer objects the
      36             :             RAII way. When this object gets deleted, it will
      37             :             automatically revoke the attribute layer for the given
      38             :             shape (this encapsulates the somewhat clumsy notification
      39             :             process that is required for shape and attribute layer
      40             :             interaction).
      41             :          */
      42             :         class ShapeAttributeLayerHolder : private boost::noncopyable
      43             :         {
      44             :         public:
      45             :             /** Create a ShapeAttributeLayerHolder instance.
      46             : 
      47             :                 This constructor creates an empty attribute holder, to
      48             :                 generate an attribute layer, you have to manually call
      49             :                 createAttributeLayer().
      50             :              */
      51           0 :             ShapeAttributeLayerHolder() :
      52             :                 mpShape(),
      53           0 :                 mpAttributeLayer()
      54             :             {
      55           0 :             }
      56             : 
      57           0 :             ~ShapeAttributeLayerHolder()
      58           0 :             {
      59           0 :                 reset(); // ensures that the last attribute layer is
      60             :                          // correctly deregistered from the shape.
      61           0 :             }
      62             : 
      63           0 :             void reset()
      64             :             {
      65           0 :                 if( mpShape && mpAttributeLayer )
      66           0 :                     mpShape->revokeAttributeLayer( mpAttributeLayer );
      67           0 :             }
      68             : 
      69             :             /** This constructor receives a pointer to the Shape, from
      70             :                 which attribute layers should be generated. Initially,
      71             :                 this object does not create an attribute layer, you
      72             :                 have to manually call createAttributeLayer().
      73             : 
      74             :                 @param rShape
      75             :                 Shape for which attribute layers should be generated.
      76             :             */
      77           0 :             bool createAttributeLayer( const AttributableShapeSharedPtr& rShape )
      78             :             {
      79           0 :                 reset();
      80             : 
      81           0 :                 mpShape = rShape;
      82             : 
      83           0 :                 if( mpShape )
      84           0 :                     mpAttributeLayer = mpShape->createAttributeLayer();
      85             : 
      86           0 :                 return mpAttributeLayer;
      87             :             }
      88             : 
      89           0 :             ShapeAttributeLayerSharedPtr get() const
      90             :             {
      91           0 :                 return mpAttributeLayer;
      92             :             }
      93             : 
      94             :         private:
      95             :             AttributableShapeSharedPtr      mpShape;
      96             :             ShapeAttributeLayerSharedPtr    mpAttributeLayer;
      97             :         };
      98             : 
      99             :     }
     100             : }
     101             : 
     102             : #endif /* INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYERHOLDER_HXX */
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10