Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / inc / shapeattributelayerholder.hxx
blobba596adcdf43ae690502e52656d8487ac1b3e07f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 namespace slideshow
28 namespace internal
30 /** Holds a ShapeAttributeLayer, together with the associated
31 Shape
33 Use this class to hold ShapeAttributeLayer objects the
34 RAII way. When this object gets deleted, it will
35 automatically revoke the attribute layer for the given
36 shape (this encapsulates the somewhat clumsy notification
37 process that is required for shape and attribute layer
38 interaction).
40 class ShapeAttributeLayerHolder
42 public:
43 /** Create a ShapeAttributeLayerHolder instance.
45 This constructor creates an empty attribute holder, to
46 generate an attribute layer, you have to manually call
47 createAttributeLayer().
49 ShapeAttributeLayerHolder() :
50 mpShape(),
51 mpAttributeLayer()
55 ~ShapeAttributeLayerHolder()
57 reset(); // ensures that the last attribute layer is
58 // correctly deregistered from the shape.
61 ShapeAttributeLayerHolder(const ShapeAttributeLayerHolder&) = delete;
62 ShapeAttributeLayerHolder& operator=(const ShapeAttributeLayerHolder&) = delete;
64 void reset()
66 if( mpShape && mpAttributeLayer )
67 mpShape->revokeAttributeLayer( mpAttributeLayer );
70 /** This constructor receives a pointer to the Shape, from
71 which attribute layers should be generated. Initially,
72 this object does not create an attribute layer, you
73 have to manually call createAttributeLayer().
75 @param rShape
76 Shape for which attribute layers should be generated.
78 bool createAttributeLayer( const AttributableShapeSharedPtr& rShape )
80 reset();
82 mpShape = rShape;
84 if( mpShape )
85 mpAttributeLayer = mpShape->createAttributeLayer();
87 return static_cast< bool >(mpAttributeLayer);
90 const ShapeAttributeLayerSharedPtr& get() const
92 return mpAttributeLayer;
95 private:
96 AttributableShapeSharedPtr mpShape;
97 ShapeAttributeLayerSharedPtr mpAttributeLayer;
103 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYERHOLDER_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */