LCOV - code coverage report
Current view: top level - slideshow/source/engine - shapesubset.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 38 0.0 %
Date: 2014-04-14 Functions: 0 9 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             : 
      21             : #include <canvas/debug.hxx>
      22             : #include <tools/diagnose_ex.h>
      23             : 
      24             : #include <comphelper/anytostring.hxx>
      25             : #include <cppuhelper/exc_hlp.hxx>
      26             : 
      27             : #include "shapesubset.hxx"
      28             : 
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32             : namespace slideshow
      33             : {
      34             :     namespace internal
      35             :     {
      36           0 :         ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr&       rOriginalShape,
      37             :                                   const DocTreeNode&                      rTreeNode,
      38             :                                   const SubsettableShapeManagerSharedPtr& rShapeManager ) :
      39             :             mpOriginalShape( rOriginalShape ),
      40             :             mpSubsetShape(),
      41             :             maTreeNode( rTreeNode ),
      42           0 :             mpShapeManager( rShapeManager )
      43             :         {
      44           0 :             ENSURE_OR_THROW( mpShapeManager,
      45             :                               "ShapeSubset::ShapeSubset(): Invalid shape manager" );
      46           0 :         }
      47             : 
      48           0 :         ShapeSubset::ShapeSubset( const ShapeSubsetSharedPtr&   rOriginalSubset,
      49             :                                   const DocTreeNode&            rTreeNode ) :
      50           0 :             mpOriginalShape( rOriginalSubset->mpSubsetShape ?
      51           0 :                              rOriginalSubset->mpSubsetShape :
      52           0 :                              rOriginalSubset->mpOriginalShape ),
      53             :             mpSubsetShape(),
      54             :             maTreeNode( rTreeNode ),
      55           0 :             mpShapeManager( rOriginalSubset->mpShapeManager )
      56             :         {
      57           0 :             ENSURE_OR_THROW( mpShapeManager,
      58             :                               "ShapeSubset::ShapeSubset(): Invalid shape manager" );
      59           0 :             ENSURE_OR_THROW( rOriginalSubset->maTreeNode.isEmpty() ||
      60             :                               (rTreeNode.getStartIndex() >= rOriginalSubset->maTreeNode.getStartIndex() &&
      61             :                                rTreeNode.getEndIndex() <= rOriginalSubset->maTreeNode.getEndIndex()),
      62             :                               "ShapeSubset::ShapeSubset(): Subset is bigger than parent" );
      63           0 :         }
      64             : 
      65           0 :         ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr&       rOriginalShape,
      66             :                                   const SubsettableShapeManagerSharedPtr& rShapeManager ) :
      67             :             mpOriginalShape( rOriginalShape ),
      68             :             mpSubsetShape(),
      69             :             maTreeNode(),
      70           0 :             mpShapeManager( rShapeManager )
      71             :         {
      72           0 :             ENSURE_OR_THROW( mpShapeManager,
      73             :                               "ShapeSubset::ShapeSubset(): Invalid shape manager" );
      74           0 :         }
      75             : 
      76           0 :         ShapeSubset::~ShapeSubset()
      77             :         {
      78             :             try
      79             :             {
      80             :                 // if not done yet: revoke subset from original
      81           0 :                 disableSubsetShape();
      82             :             }
      83           0 :             catch (uno::Exception &)
      84             :             {
      85             :                 OSL_FAIL( OUStringToOString(
      86             :                                 comphelper::anyToString(
      87             :                                     cppu::getCaughtException() ),
      88             :                                 RTL_TEXTENCODING_UTF8 ).getStr() );
      89             :             }
      90           0 :         }
      91             : 
      92           0 :         AttributableShapeSharedPtr ShapeSubset::getSubsetShape() const
      93             :         {
      94           0 :             return mpSubsetShape ? mpSubsetShape : mpOriginalShape;
      95             :         }
      96             : 
      97           0 :         bool ShapeSubset::enableSubsetShape()
      98             :         {
      99           0 :             if( !mpSubsetShape &&
     100           0 :                 !maTreeNode.isEmpty() )
     101             :             {
     102           0 :                 mpSubsetShape = mpShapeManager->getSubsetShape(
     103             :                     mpOriginalShape,
     104           0 :                     maTreeNode );
     105             :             }
     106             : 
     107           0 :             return static_cast< bool >(mpSubsetShape);
     108             :         }
     109             : 
     110           0 :         void ShapeSubset::disableSubsetShape()
     111             :         {
     112           0 :             if( mpSubsetShape )
     113             :             {
     114           0 :                 mpShapeManager->revokeSubset( mpOriginalShape,
     115           0 :                                               mpSubsetShape );
     116           0 :                 mpSubsetShape.reset();
     117             :             }
     118           0 :         }
     119             : 
     120           0 :         bool ShapeSubset::isFullSet() const
     121             :         {
     122           0 :             return maTreeNode.isEmpty();
     123             :         }
     124             : 
     125           0 :         DocTreeNode ShapeSubset::getSubset() const
     126             :         {
     127           0 :             return maTreeNode;
     128             :         }
     129             : 
     130             :     }
     131             : }
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10