loplugin:unnecessaryvirtual
[LibreOffice.git] / svx / inc / shapecollection.hxx
blob44988281bb75682b77550beef4ba770024b89e10
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 .
19 #pragma once
21 #include <cppuhelper/implbase3.hxx>
22 #include <comphelper/interfacecontainer4.hxx>
23 #include <com/sun/star/drawing/XShapes.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/lang/XComponent.hpp>
26 #include <mutex>
27 #include <vector>
29 class SvxShapeCollection final
30 : public cppu::WeakAggImplHelper3<css::drawing::XShapes, css::lang::XServiceInfo,
31 css::lang::XComponent>
33 private:
34 std::mutex m_aMutex;
35 std::vector<css::uno::Reference<css::drawing::XShape>> maShapeContainer;
36 comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> maEventListeners;
37 bool bDisposed = false;
38 bool bInDispose = false;
40 public:
41 SvxShapeCollection() noexcept;
43 // XInterface
44 virtual void SAL_CALL release() noexcept override;
46 // XComponent
47 virtual void SAL_CALL dispose() override;
48 virtual void SAL_CALL
49 addEventListener(const css::uno::Reference<css::lang::XEventListener>& aListener) override;
50 virtual void SAL_CALL
51 removeEventListener(const css::uno::Reference<css::lang::XEventListener>& aListener) override;
53 // XIndexAccess
54 virtual sal_Int32 SAL_CALL getCount() override;
55 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override;
57 // XElementAccess
58 virtual css::uno::Type SAL_CALL getElementType() override;
59 virtual sal_Bool SAL_CALL hasElements() override;
61 // XShapes
62 virtual void SAL_CALL add(const css::uno::Reference<css::drawing::XShape>& xShape) override;
63 virtual void SAL_CALL remove(const css::uno::Reference<css::drawing::XShape>& xShape) override;
65 // XServiceInfo
66 virtual OUString SAL_CALL getImplementationName() override;
67 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
68 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
70 void getAllShapes(std::vector<css::uno::Reference<css::drawing::XShape>>& rShapes) const;
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */