android: Update app-specific/MIME type icons
[LibreOffice.git] / slideshow / source / engine / shapesubset.cxx
blob74c3af2f7e22b4b2ddfc1c8fec740ce36335b4f0
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 <comphelper/diagnose_ex.hxx>
23 #include <shapesubset.hxx>
24 #include <utility>
27 using namespace ::com::sun::star;
29 namespace slideshow::internal
31 ShapeSubset::ShapeSubset( AttributableShapeSharedPtr xOriginalShape,
32 const DocTreeNode& rTreeNode,
33 SubsettableShapeManagerSharedPtr xShapeManager ) :
34 mpOriginalShape(std::move( xOriginalShape )),
35 mpSubsetShape(),
36 maTreeNode( rTreeNode ),
37 mpShapeManager(std::move( xShapeManager ))
39 ENSURE_OR_THROW( mpShapeManager,
40 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
43 ShapeSubset::ShapeSubset( const ShapeSubsetSharedPtr& rOriginalSubset,
44 const DocTreeNode& rTreeNode ) :
45 mpOriginalShape( rOriginalSubset->mpSubsetShape ?
46 rOriginalSubset->mpSubsetShape :
47 rOriginalSubset->mpOriginalShape ),
48 mpSubsetShape(),
49 maTreeNode( rTreeNode ),
50 mpShapeManager( rOriginalSubset->mpShapeManager )
52 ENSURE_OR_THROW( mpShapeManager,
53 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
54 ENSURE_OR_THROW( rOriginalSubset->maTreeNode.isEmpty() ||
55 (rTreeNode.getStartIndex() >= rOriginalSubset->maTreeNode.getStartIndex() &&
56 rTreeNode.getEndIndex() <= rOriginalSubset->maTreeNode.getEndIndex()),
57 "ShapeSubset::ShapeSubset(): Subset is bigger than parent" );
60 ShapeSubset::ShapeSubset( AttributableShapeSharedPtr xOriginalShape,
61 SubsettableShapeManagerSharedPtr xShapeManager ) :
62 mpOriginalShape(std::move( xOriginalShape )),
63 mpSubsetShape(),
64 maTreeNode(),
65 mpShapeManager(std::move( xShapeManager ))
67 ENSURE_OR_THROW( mpShapeManager,
68 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
71 ShapeSubset::~ShapeSubset()
73 try
75 // if not done yet: revoke subset from original
76 disableSubsetShape();
78 catch (const uno::Exception&)
80 TOOLS_WARN_EXCEPTION("slideshow", "");
84 AttributableShapeSharedPtr const & ShapeSubset::getSubsetShape() const
86 return mpSubsetShape ? mpSubsetShape : mpOriginalShape;
89 void ShapeSubset::enableSubsetShape()
91 if( !mpSubsetShape &&
92 !maTreeNode.isEmpty() )
94 mpSubsetShape = mpShapeManager->getSubsetShape(
95 mpOriginalShape,
96 maTreeNode );
100 void ShapeSubset::disableSubsetShape()
102 if( mpSubsetShape )
104 mpShapeManager->revokeSubset( mpOriginalShape,
105 mpSubsetShape );
106 mpSubsetShape.reset();
110 bool ShapeSubset::isFullSet() const
112 return maTreeNode.isEmpty();
115 const DocTreeNode& ShapeSubset::getSubset() const
117 return maTreeNode;
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */