1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERPANEFACTORY_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERPANEFACTORY_HXX
22 
23 #include <cppuhelper/compbase.hxx>
24 #include <cppuhelper/basemutex.hxx>
25 #include <com/sun/star/frame/XController.hpp>
26 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
27 #include <com/sun/star/drawing/framework/XPane.hpp>
28 #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <rtl/ref.hxx>
31 #include <map>
32 #include <memory>
33 
34 namespace sdext::presenter {
35 
36 class PresenterController;
37 
38 typedef ::cppu::WeakComponentImplHelper <
39     css::drawing::framework::XResourceFactory
40 > PresenterPaneFactoryInterfaceBase;
41 
42 /** The PresenterPaneFactory provides a fixed set of panes.
43 
44     In order to make the presenter screen more easily extendable in the
45     future the set of supported panes could be made extendable on demand.
46 */
47 class PresenterPaneFactory
48     : public ::cppu::BaseMutex,
49       public PresenterPaneFactoryInterfaceBase
50 {
51 public:
52     static constexpr OUStringLiteral msCurrentSlidePreviewPaneURL
53         = u"private:resource/pane/Presenter/Pane1";
54     static constexpr OUStringLiteral msNextSlidePreviewPaneURL
55         = u"private:resource/pane/Presenter/Pane2";
56     static constexpr OUStringLiteral msNotesPaneURL = u"private:resource/pane/Presenter/Pane3";
57     static constexpr OUStringLiteral msToolBarPaneURL = u"private:resource/pane/Presenter/Pane4";
58     static constexpr OUStringLiteral msSlideSorterPaneURL
59         = u"private:resource/pane/Presenter/Pane5";
60 
61     /** Create a new instance of this class and register it as resource
62         factory in the drawing framework of the given controller.
63         This registration keeps it alive.  When the drawing framework is
64         shut down and releases its reference to the factory then the factory
65         is destroyed.
66     */
67     static css::uno::Reference<css::drawing::framework::XResourceFactory> Create (
68         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
69         const css::uno::Reference<css::frame::XController>& rxController,
70         const ::rtl::Reference<PresenterController>& rpPresenterController);
71     virtual ~PresenterPaneFactory() override;
72 
73     virtual void SAL_CALL disposing() override;
74 
75     // XResourceFactory
76 
77     virtual css::uno::Reference<css::drawing::framework::XResource>
78         SAL_CALL createResource (
79             const css::uno::Reference<
80                 css::drawing::framework::XResourceId>& rxPaneId) override;
81 
82     virtual void SAL_CALL
83         releaseResource (
84             const css::uno::Reference<css::drawing::framework::XResource>&
85                 rxPane) override;
86 
87 private:
88     css::uno::WeakReference<css::uno::XComponentContext> mxComponentContextWeak;
89     css::uno::WeakReference<css::drawing::framework::XConfigurationController>
90         mxConfigurationControllerWeak;
91     ::rtl::Reference<PresenterController> mpPresenterController;
92     typedef ::std::map<OUString, css::uno::Reference<css::drawing::framework::XResource> >
93         ResourceContainer;
94     std::unique_ptr<ResourceContainer> mpResourceCache;
95 
96     PresenterPaneFactory (
97         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
98         const ::rtl::Reference<PresenterController>& rpPresenterController);
99 
100     void Register (const css::uno::Reference<css::frame::XController>& rxController);
101 
102     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
103         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId);
104     css::uno::Reference<css::drawing::framework::XResource> CreatePane (
105         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
106         const css::uno::Reference<css::drawing::framework::XPane>& rxParentPane,
107         const bool bIsSpritePane);
108 
109     /// @throws css::lang::DisposedException
110     void ThrowIfDisposed() const;
111 };
112 
113 }
114 
115 #endif
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
118