1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
),
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
),
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
),
64 mpShapeManager( rShapeManager
)
66 ENSURE_OR_THROW( mpShapeManager
,
67 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
70 ShapeSubset::~ShapeSubset()
74 // if not done yet: revoke subset from original
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()
91 !maTreeNode
.isEmpty() )
93 mpSubsetShape
= mpShapeManager
->getSubsetShape(
99 void ShapeSubset::disableSubsetShape()
103 mpShapeManager
->revokeSubset( mpOriginalShape
,
105 mpSubsetShape
.reset();
109 bool ShapeSubset::isFullSet() const
111 return maTreeNode
.isEmpty();
114 const DocTreeNode
& ShapeSubset::getSubset() const
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */