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 .
21 #include <com/sun/star/lang/XComponent.hpp>
22 #include <com/sun/star/container/XIndexContainer.hpp>
23 #include <com/sun/star/container/XNamed.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <comphelper/interfacecontainer4.hxx>
26 #include <osl/mutex.hxx>
28 #include <cppuhelper/implbase.hxx>
29 #include <comphelper/servicehelper.hxx>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
33 #include <unomodel.hxx>
34 #include <drawdoc.hxx>
39 class SdXCustomPresentation
: public ::cppu::WeakImplHelper
< css::container::XIndexContainer
,
40 css::container::XNamed
,
41 css::lang::XComponent
,
42 css::lang::XServiceInfo
>
45 SdCustomShow
* mpSdCustomShow
;
46 SdXImpressDocument
* mpModel
;
49 std::mutex aDisposeContainerMutex
;
50 ::comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
> aDisposeListeners
;
54 SdXCustomPresentation() noexcept
;
55 explicit SdXCustomPresentation( SdCustomShow
* mpSdCustomShow
) noexcept
;
56 virtual ~SdXCustomPresentation() noexcept override
;
59 SdCustomShow
* GetSdCustomShow() const noexcept
{ return mpSdCustomShow
; }
60 void SetSdCustomShow( SdCustomShow
* pShow
) noexcept
{ mpSdCustomShow
= pShow
; }
61 SdXImpressDocument
* GetModel() const noexcept
{ return mpModel
; }
64 virtual OUString SAL_CALL
getImplementationName() override
;
65 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
66 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
69 virtual void SAL_CALL
insertByIndex( sal_Int32 Index
, const css::uno::Any
& Element
) override
;
70 virtual void SAL_CALL
removeByIndex( sal_Int32 Index
) override
;
73 virtual void SAL_CALL
replaceByIndex( sal_Int32 Index
, const css::uno::Any
& Element
) override
;
76 virtual css::uno::Type SAL_CALL
getElementType() override
;
77 virtual sal_Bool SAL_CALL
hasElements() override
;
80 virtual sal_Int32 SAL_CALL
getCount() override
;
81 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
84 virtual OUString SAL_CALL
getName( ) override
;
85 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
88 virtual void SAL_CALL
dispose( ) override
;
89 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
90 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
93 class SdXCustomPresentationAccess final
: public ::cppu::WeakImplHelper
< css::container::XNameContainer
,
94 css::lang::XSingleServiceFactory
,
95 css::lang::XServiceInfo
>
98 SdXImpressDocument
& mrModel
;
101 inline SdCustomShowList
* GetCustomShowList() const noexcept
;
102 SdCustomShow
* getSdCustomShow( std::u16string_view Name
) const noexcept
;
105 explicit SdXCustomPresentationAccess(SdXImpressDocument
& rMyModel
) noexcept
;
106 virtual ~SdXCustomPresentationAccess() noexcept override
;
109 virtual OUString SAL_CALL
getImplementationName() override
;
110 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
111 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
113 // XSingleServiceFactory
114 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstance( ) override
;
115 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
createInstanceWithArguments( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
118 virtual void SAL_CALL
insertByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
119 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
122 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
125 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
126 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
127 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
130 virtual css::uno::Type SAL_CALL
getElementType() override
;
131 virtual sal_Bool SAL_CALL
hasElements() override
;
134 inline SdCustomShowList
* SdXCustomPresentationAccess::GetCustomShowList() const noexcept
137 return mrModel
.GetDoc()->GetCustomShowList();
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */