1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shapeattributelayerholder.hxx,v $
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 #ifndef INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYERHOLDER_HXX
32 #define INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYERHOLDER_HXX
34 #include "attributableshape.hxx"
35 #include "shapeattributelayer.hxx"
37 #include <boost/noncopyable.hpp>
43 /** Holds a ShapeAttributeLayer, together with the associated
46 Use this class to hold ShapeAttributeLayer objects the
47 RAII way. When this object gets deleted, it will
48 automatically revoke the attribute layer for the given
49 shape (this encapsulates the somewhat clumsy notification
50 process that is required for shape and attribute layer
53 class ShapeAttributeLayerHolder
: private boost::noncopyable
56 /** Create a ShapeAttributeLayerHolder instance.
58 This constructor creates an empty attribute holder, to
59 generate an attribute layer, you have to manually call
60 createAttributeLayer().
62 ShapeAttributeLayerHolder() :
68 ~ShapeAttributeLayerHolder()
70 reset(); // ensures that the last attribute layer is
71 // correctly deregistered from the shape.
76 if( mpShape
&& mpAttributeLayer
)
77 mpShape
->revokeAttributeLayer( mpAttributeLayer
);
80 /** This constructor receives a pointer to the Shape, from
81 which attribute layers should be generated. Initially,
82 this object does not create an attribute layer, you
83 have to manually call createAttributeLayer().
86 Shape for which attribute layers should be generated.
88 bool createAttributeLayer( const AttributableShapeSharedPtr
& rShape
)
95 mpAttributeLayer
= mpShape
->createAttributeLayer();
97 return mpAttributeLayer
;
100 ShapeAttributeLayerSharedPtr
get() const
102 return mpAttributeLayer
;
106 AttributableShapeSharedPtr mpShape
;
107 ShapeAttributeLayerSharedPtr mpAttributeLayer
;
113 #endif /* INCLUDED_SLIDESHOW_SHAPEATTRIBUTELAYERHOLDER_HXX */