nss: upgrade to release 3.73
[LibreOffice.git] / slideshow / source / engine / shapesubset.cxx
blob5525195fe81f6bb31bf634f65ec1cb4c24223479
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 <shapesubset.hxx>
26 using namespace ::com::sun::star;
28 namespace slideshow::internal
30 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
31 const DocTreeNode& rTreeNode,
32 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
33 mpOriginalShape( rOriginalShape ),
34 mpSubsetShape(),
35 maTreeNode( rTreeNode ),
36 mpShapeManager( rShapeManager )
38 ENSURE_OR_THROW( mpShapeManager,
39 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
42 ShapeSubset::ShapeSubset( const ShapeSubsetSharedPtr& rOriginalSubset,
43 const DocTreeNode& rTreeNode ) :
44 mpOriginalShape( rOriginalSubset->mpSubsetShape ?
45 rOriginalSubset->mpSubsetShape :
46 rOriginalSubset->mpOriginalShape ),
47 mpSubsetShape(),
48 maTreeNode( rTreeNode ),
49 mpShapeManager( rOriginalSubset->mpShapeManager )
51 ENSURE_OR_THROW( mpShapeManager,
52 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
53 ENSURE_OR_THROW( rOriginalSubset->maTreeNode.isEmpty() ||
54 (rTreeNode.getStartIndex() >= rOriginalSubset->maTreeNode.getStartIndex() &&
55 rTreeNode.getEndIndex() <= rOriginalSubset->maTreeNode.getEndIndex()),
56 "ShapeSubset::ShapeSubset(): Subset is bigger than parent" );
59 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
60 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
61 mpOriginalShape( rOriginalShape ),
62 mpSubsetShape(),
63 maTreeNode(),
64 mpShapeManager( rShapeManager )
66 ENSURE_OR_THROW( mpShapeManager,
67 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
70 ShapeSubset::~ShapeSubset()
72 try
74 // if not done yet: revoke subset from original
75 disableSubsetShape();
77 catch (const uno::Exception&)
79 TOOLS_WARN_EXCEPTION("slideshow", "");
83 AttributableShapeSharedPtr const & ShapeSubset::getSubsetShape() const
85 return mpSubsetShape ? mpSubsetShape : mpOriginalShape;
88 void ShapeSubset::enableSubsetShape()
90 if( !mpSubsetShape &&
91 !maTreeNode.isEmpty() )
93 mpSubsetShape = mpShapeManager->getSubsetShape(
94 mpOriginalShape,
95 maTreeNode );
99 void ShapeSubset::disableSubsetShape()
101 if( mpSubsetShape )
103 mpShapeManager->revokeSubset( mpOriginalShape,
104 mpSubsetShape );
105 mpSubsetShape.reset();
109 bool ShapeSubset::isFullSet() const
111 return maTreeNode.isEmpty();
114 const DocTreeNode& ShapeSubset::getSubset() const
116 return maTreeNode;
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */