Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / engine / shapesubset.cxx
blob2dccbc09d51646a9955b41a22168d689d78cc1de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <tools/diagnose_ex.h>
23 #include <comphelper/anytostring.hxx>
24 #include <cppuhelper/exc_hlp.hxx>
26 #include <shapesubset.hxx>
29 using namespace ::com::sun::star;
31 namespace slideshow
33 namespace internal
35 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
36 const DocTreeNode& rTreeNode,
37 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
38 mpOriginalShape( rOriginalShape ),
39 mpSubsetShape(),
40 maTreeNode( rTreeNode ),
41 mpShapeManager( rShapeManager )
43 ENSURE_OR_THROW( mpShapeManager,
44 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
47 ShapeSubset::ShapeSubset( const ShapeSubsetSharedPtr& rOriginalSubset,
48 const DocTreeNode& rTreeNode ) :
49 mpOriginalShape( rOriginalSubset->mpSubsetShape ?
50 rOriginalSubset->mpSubsetShape :
51 rOriginalSubset->mpOriginalShape ),
52 mpSubsetShape(),
53 maTreeNode( rTreeNode ),
54 mpShapeManager( rOriginalSubset->mpShapeManager )
56 ENSURE_OR_THROW( mpShapeManager,
57 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
58 ENSURE_OR_THROW( rOriginalSubset->maTreeNode.isEmpty() ||
59 (rTreeNode.getStartIndex() >= rOriginalSubset->maTreeNode.getStartIndex() &&
60 rTreeNode.getEndIndex() <= rOriginalSubset->maTreeNode.getEndIndex()),
61 "ShapeSubset::ShapeSubset(): Subset is bigger than parent" );
64 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
65 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
66 mpOriginalShape( rOriginalShape ),
67 mpSubsetShape(),
68 maTreeNode(),
69 mpShapeManager( rShapeManager )
71 ENSURE_OR_THROW( mpShapeManager,
72 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
75 ShapeSubset::~ShapeSubset()
77 try
79 // if not done yet: revoke subset from original
80 disableSubsetShape();
82 catch (const uno::Exception& e)
84 SAL_WARN("slideshow", e);
88 AttributableShapeSharedPtr const & ShapeSubset::getSubsetShape() const
90 return mpSubsetShape ? mpSubsetShape : mpOriginalShape;
93 void ShapeSubset::enableSubsetShape()
95 if( !mpSubsetShape &&
96 !maTreeNode.isEmpty() )
98 mpSubsetShape = mpShapeManager->getSubsetShape(
99 mpOriginalShape,
100 maTreeNode );
104 void ShapeSubset::disableSubsetShape()
106 if( mpSubsetShape )
108 mpShapeManager->revokeSubset( mpOriginalShape,
109 mpSubsetShape );
110 mpSubsetShape.reset();
114 bool ShapeSubset::isFullSet() const
116 return maTreeNode.isEmpty();
119 const DocTreeNode& ShapeSubset::getSubset() const
121 return maTreeNode;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */