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 <comphelper/anytostring.hxx>
24 #include <cppuhelper/exc_hlp.hxx>
26 #include <shapesubset.hxx>
29 using namespace ::com::sun::star
;
35 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr
& rOriginalShape
,
36 const DocTreeNode
& rTreeNode
,
37 const SubsettableShapeManagerSharedPtr
& rShapeManager
) :
38 mpOriginalShape( rOriginalShape
),
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
),
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
),
69 mpShapeManager( rShapeManager
)
71 ENSURE_OR_THROW( mpShapeManager
,
72 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
75 ShapeSubset::~ShapeSubset()
79 // if not done yet: revoke subset from original
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()
96 !maTreeNode
.isEmpty() )
98 mpSubsetShape
= mpShapeManager
->getSubsetShape(
104 void ShapeSubset::disableSubsetShape()
108 mpShapeManager
->revokeSubset( mpOriginalShape
,
110 mpSubsetShape
.reset();
114 bool ShapeSubset::isFullSet() const
116 return maTreeNode
.isEmpty();
119 const DocTreeNode
& ShapeSubset::getSubset() const
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */