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 .
20 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYERHOLDER_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYERHOLDER_HXX
23 #include "attributableshape.hxx"
24 #include "shapeattributelayer.hxx"
26 #include <boost/noncopyable.hpp>
32 /** Holds a ShapeAttributeLayer, together with the associated
35 Use this class to hold ShapeAttributeLayer objects the
36 RAII way. When this object gets deleted, it will
37 automatically revoke the attribute layer for the given
38 shape (this encapsulates the somewhat clumsy notification
39 process that is required for shape and attribute layer
42 class ShapeAttributeLayerHolder
: private boost::noncopyable
45 /** Create a ShapeAttributeLayerHolder instance.
47 This constructor creates an empty attribute holder, to
48 generate an attribute layer, you have to manually call
49 createAttributeLayer().
51 ShapeAttributeLayerHolder() :
57 ~ShapeAttributeLayerHolder()
59 reset(); // ensures that the last attribute layer is
60 // correctly deregistered from the shape.
65 if( mpShape
&& mpAttributeLayer
)
66 mpShape
->revokeAttributeLayer( mpAttributeLayer
);
69 /** This constructor receives a pointer to the Shape, from
70 which attribute layers should be generated. Initially,
71 this object does not create an attribute layer, you
72 have to manually call createAttributeLayer().
75 Shape for which attribute layers should be generated.
77 bool createAttributeLayer( const AttributableShapeSharedPtr
& rShape
)
84 mpAttributeLayer
= mpShape
->createAttributeLayer();
86 return static_cast< bool >(mpAttributeLayer
);
89 ShapeAttributeLayerSharedPtr
get() const
91 return mpAttributeLayer
;
95 AttributableShapeSharedPtr mpShape
;
96 ShapeAttributeLayerSharedPtr mpAttributeLayer
;
102 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYERHOLDER_HXX
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */