merge the formfield patch from ooo-build
[ooovba.git] / slideshow / source / engine / shapesubset.cxx
bloba1e2d6835c94431f994c6f4f5d559dcbfda2ca5e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapesubset.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
34 #include <canvas/debug.hxx>
35 #include <tools/diagnose_ex.h>
37 #include <comphelper/anytostring.hxx>
38 #include <cppuhelper/exc_hlp.hxx>
40 #include "shapesubset.hxx"
43 using namespace ::com::sun::star;
45 namespace slideshow
47 namespace internal
49 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
50 const DocTreeNode& rTreeNode,
51 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
52 mpOriginalShape( rOriginalShape ),
53 mpSubsetShape(),
54 maTreeNode( rTreeNode ),
55 mpShapeManager( rShapeManager )
57 ENSURE_OR_THROW( mpShapeManager,
58 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
61 ShapeSubset::ShapeSubset( const ShapeSubsetSharedPtr& rOriginalSubset,
62 const DocTreeNode& rTreeNode ) :
63 mpOriginalShape( rOriginalSubset->mpSubsetShape ?
64 rOriginalSubset->mpSubsetShape :
65 rOriginalSubset->mpOriginalShape ),
66 mpSubsetShape(),
67 maTreeNode( rTreeNode ),
68 mpShapeManager( rOriginalSubset->mpShapeManager )
70 ENSURE_OR_THROW( mpShapeManager,
71 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
72 ENSURE_OR_THROW( rOriginalSubset->maTreeNode.isEmpty() ||
73 (rTreeNode.getStartIndex() >= rOriginalSubset->maTreeNode.getStartIndex() &&
74 rTreeNode.getEndIndex() <= rOriginalSubset->maTreeNode.getEndIndex()),
75 "ShapeSubset::ShapeSubset(): Subset is bigger than parent" );
78 ShapeSubset::ShapeSubset( const AttributableShapeSharedPtr& rOriginalShape,
79 const SubsettableShapeManagerSharedPtr& rShapeManager ) :
80 mpOriginalShape( rOriginalShape ),
81 mpSubsetShape(),
82 maTreeNode(),
83 mpShapeManager( rShapeManager )
85 ENSURE_OR_THROW( mpShapeManager,
86 "ShapeSubset::ShapeSubset(): Invalid shape manager" );
89 ShapeSubset::~ShapeSubset()
91 try
93 // if not done yet: revoke subset from original
94 disableSubsetShape();
96 catch (uno::Exception &)
98 OSL_ENSURE( false, rtl::OUStringToOString(
99 comphelper::anyToString(
100 cppu::getCaughtException() ),
101 RTL_TEXTENCODING_UTF8 ).getStr() );
105 AttributableShapeSharedPtr ShapeSubset::getSubsetShape() const
107 return mpSubsetShape ? mpSubsetShape : mpOriginalShape;
110 bool ShapeSubset::enableSubsetShape()
112 if( !mpSubsetShape &&
113 !maTreeNode.isEmpty() )
115 mpSubsetShape = mpShapeManager->getSubsetShape(
116 mpOriginalShape,
117 maTreeNode );
120 return mpSubsetShape;
123 void ShapeSubset::disableSubsetShape()
125 if( mpSubsetShape )
127 mpShapeManager->revokeSubset( mpOriginalShape,
128 mpSubsetShape );
129 mpSubsetShape.reset();
133 bool ShapeSubset::isFullSet() const
135 return maTreeNode.isEmpty();
138 DocTreeNode ShapeSubset::getSubset() const
140 return maTreeNode;