Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / console / PresenterViewFactory.hxx
blob3f31342f2ce12e0d095ecb7b9e9cf169df49792c
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_SDEXT_SOURCE_PRESENTER_PRESENTERVIEWFACTORY_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERVIEWFACTORY_HXX
23 #include "PresenterController.hxx"
24 #include <cppuhelper/compbase.hxx>
25 #include <cppuhelper/basemutex.hxx>
26 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
27 #include <com/sun/star/drawing/framework/XResourceFactory.hpp>
28 #include <com/sun/star/drawing/framework/XView.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <unotools/weakref.hxx>
31 #include <rtl/ref.hxx>
32 #include <memory>
34 namespace sd { class DrawController; }
36 namespace sdext::presenter {
38 typedef ::cppu::WeakComponentImplHelper <
39 css::drawing::framework::XResourceFactory
40 > PresenterViewFactoryInterfaceBase;
42 /** Base class for presenter views that allows the view factory to store
43 them in a cache and reuse deactivated views.
45 class SAL_LOPLUGIN_ANNOTATE("crosscast") CachablePresenterView
47 public:
48 virtual void ActivatePresenterView();
50 /** Called when the view is put into a cache. The view must not paint
51 itself while being deactivated.
53 virtual void DeactivatePresenterView();
55 /** Called before the view is disposed. This gives the view the
56 opportunity to trigger actions that may lead to (synchronous)
57 callbacks that do not result in DisposedExceptions.
59 virtual void ReleaseView();
61 protected:
62 bool mbIsPresenterViewActive;
64 CachablePresenterView();
66 ~CachablePresenterView() {}
69 /** Factory of the presenter screen specific views. The supported set of
70 views includes:
71 a life view of the current slide,
72 a static preview of the next slide,
73 the notes of the current slide,
74 a tool bar
76 class PresenterViewFactory
77 : public ::cppu::BaseMutex,
78 public PresenterViewFactoryInterfaceBase
80 public:
81 static constexpr OUStringLiteral msCurrentSlidePreviewViewURL
82 = u"private:resource/view/Presenter/CurrentSlidePreview";
83 static constexpr OUStringLiteral msNextSlidePreviewViewURL
84 = u"private:resource/view/Presenter/NextSlidePreview";
85 static constexpr OUStringLiteral msNotesViewURL = u"private:resource/view/Presenter/Notes";
86 static constexpr OUStringLiteral msToolBarViewURL = u"private:resource/view/Presenter/ToolBar";
87 static constexpr OUStringLiteral msSlideSorterURL
88 = u"private:resource/view/Presenter/SlideSorter";
89 static constexpr OUStringLiteral msHelpViewURL = u"private:resource/view/Presenter/Help";
91 /** Create a new instance of this class and register it as resource
92 factory in the drawing framework of the given controller.
93 This registration keeps it alive. When the drawing framework is
94 shut down and releases its reference to the factory then the factory
95 is destroyed.
97 static css::uno::Reference<css::drawing::framework::XResourceFactory> Create (
98 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
99 const ::rtl::Reference<::sd::DrawController>& rxController,
100 const ::rtl::Reference<PresenterController>& rpPresenterController);
101 virtual ~PresenterViewFactory() override;
103 virtual void SAL_CALL disposing() override;
105 // XResourceFactory
107 virtual css::uno::Reference<css::drawing::framework::XResource>
108 SAL_CALL createResource (
109 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) override;
111 virtual void SAL_CALL
112 releaseResource (
113 const css::uno::Reference<css::drawing::framework::XResource>& rxPane) override;
115 private:
116 css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
117 css::uno::Reference<css::drawing::framework::XConfigurationController>
118 mxConfigurationController;
119 unotools::WeakReference<::sd::DrawController> mxControllerWeak;
120 ::rtl::Reference<PresenterController> mpPresenterController;
121 typedef ::std::pair<css::uno::Reference<css::drawing::framework::XView>,
122 css::uno::Reference<css::drawing::framework::XPane> > ViewResourceDescriptor;
123 typedef ::std::map<OUString, ViewResourceDescriptor> ResourceContainer;
124 std::unique_ptr<ResourceContainer> mpResourceCache;
126 PresenterViewFactory (
127 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
128 const rtl::Reference<::sd::DrawController>& rxController,
129 ::rtl::Reference<PresenterController> pPresenterController);
131 void Register (const ::rtl::Reference<::sd::DrawController>& rxController);
133 css::uno::Reference<css::drawing::framework::XView> CreateSlideShowView(
134 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
136 css::uno::Reference<css::drawing::framework::XView> CreateSlidePreviewView(
137 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
138 const css::uno::Reference<css::drawing::framework::XPane>& rxPane) const;
140 css::uno::Reference<css::drawing::framework::XView> CreateToolBarView(
141 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
143 css::uno::Reference<css::drawing::framework::XView> CreateNotesView(
144 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
146 css::uno::Reference<css::drawing::framework::XView> CreateSlideSorterView(
147 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
149 css::uno::Reference<css::drawing::framework::XView> CreateHelpView(
150 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId) const;
152 css::uno::Reference<css::drawing::framework::XResource> GetViewFromCache (
153 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
154 const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane) const;
155 css::uno::Reference<css::drawing::framework::XResource> CreateView(
156 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
157 const css::uno::Reference<css::drawing::framework::XPane>& rxAnchorPane);
159 /// @throws css::lang::DisposedException
160 void ThrowIfDisposed() const;
165 #endif
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */