Bump version to 24.04.3.4
[LibreOffice.git] / slideshow / source / inc / shapeattributelayerholder.hxx
blob4c123b4e514f34356a6cefe1c7012231f8fe4bb6
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::internal
28 /** Holds a ShapeAttributeLayer, together with the associated
29 Shape
31 Use this class to hold ShapeAttributeLayer objects the
32 RAII way. When this object gets deleted, it will
33 automatically revoke the attribute layer for the given
34 shape (this encapsulates the somewhat clumsy notification
35 process that is required for shape and attribute layer
36 interaction).
38 class ShapeAttributeLayerHolder
40 public:
41 /** Create a ShapeAttributeLayerHolder instance.
43 This constructor creates an empty attribute holder, to
44 generate an attribute layer, you have to manually call
45 createAttributeLayer().
47 ShapeAttributeLayerHolder() :
48 mpShape(),
49 mpAttributeLayer()
53 ~ShapeAttributeLayerHolder()
55 reset(); // ensures that the last attribute layer is
56 // correctly deregistered from the shape.
59 ShapeAttributeLayerHolder(const ShapeAttributeLayerHolder&) = delete;
60 ShapeAttributeLayerHolder& operator=(const ShapeAttributeLayerHolder&) = delete;
62 void reset()
64 if( mpShape && mpAttributeLayer )
65 mpShape->revokeAttributeLayer( mpAttributeLayer );
68 /** This constructor receives a pointer to the Shape, from
69 which attribute layers should be generated. Initially,
70 this object does not create an attribute layer, you
71 have to manually call createAttributeLayer().
73 @param rShape
74 Shape for which attribute layers should be generated.
76 bool createAttributeLayer( const AttributableShapeSharedPtr& rShape )
78 reset();
80 mpShape = rShape;
82 if( mpShape )
83 mpAttributeLayer = mpShape->createAttributeLayer();
85 return static_cast< bool >(mpAttributeLayer);
88 const ShapeAttributeLayerSharedPtr& get() const
90 return mpAttributeLayer;
93 private:
94 AttributableShapeSharedPtr mpShape;
95 ShapeAttributeLayerSharedPtr mpAttributeLayer;
100 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEATTRIBUTELAYERHOLDER_HXX
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */