LibreOffice Module sd (master) 1
PresentationFactory.cxx
Go to the documentation of this file.
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
21
22#include <DrawController.hxx>
23#include <com/sun/star/drawing/framework/XControllerManager.hpp>
24#include <com/sun/star/drawing/framework/XView.hpp>
28#include <slideshow.hxx>
29
30namespace com::sun::star::uno { class XComponentContext; }
31
32using namespace ::com::sun::star;
33using namespace ::com::sun::star::uno;
34using namespace ::com::sun::star::lang;
36
37
38namespace sd::framework {
39
40namespace {
41
42typedef comphelper::WeakComponentImplHelper<XView> PresentationViewInterfaceBase;
43
48class PresentationView
49 : public PresentationViewInterfaceBase
50{
51public:
52 explicit PresentationView (const Reference<XResourceId>& rxViewId)
53 : mxResourceId(rxViewId) {};
54
55 // XView
56
57 virtual Reference<XResourceId> SAL_CALL getResourceId() override
58 { return mxResourceId; };
59
60 virtual sal_Bool SAL_CALL isAnchorOnly() override
61 { return false; }
62
63private:
64 Reference<XResourceId> mxResourceId;
65};
66
67} // end of anonymous namespace.
68
69//===== PresentationFactory ===================================================
70
71constexpr OUStringLiteral gsPresentationViewURL = u"private:resource/view/Presentation";
72
74 const rtl::Reference<::sd::DrawController>& rxController)
75 : mxController(rxController)
76{
77}
78
80{
81}
82
83//----- XViewFactory ----------------------------------------------------------
84
85Reference<XResource> SAL_CALL PresentationFactory::createResource (
86 const Reference<XResourceId>& rxViewId)
87{
89
90 if (rxViewId.is())
91 if ( ! rxViewId->hasAnchor() && rxViewId->getResourceURL() == gsPresentationViewURL)
92 return new PresentationView(rxViewId);
93
94 return Reference<XResource>();
95}
96
98 const Reference<XResource>&)
99{
101
102 if (mxController)
103 {
104 ViewShellBase* pBase = mxController->GetViewShellBase();
105 if (pBase != nullptr)
106 SlideShow::Stop( *pBase );
107 }
108}
109
110//===== XConfigurationChangeListener ==========================================
111
113 const ConfigurationChangeEvent&)
114{}
115
116//===== lang::XEventListener ==================================================
117
119 const lang::EventObject&)
120{}
121
123{
124 if (m_bDisposed)
125 {
126 throw lang::DisposedException ("PresentationFactory object has already been disposed",
127 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
128 }
129}
130
132{
133 try
134 {
135 Reference<XConfigurationController> xCC (rxController->getConfigurationController());
136 if (xCC.is())
137 xCC->addResourceFactory(
139 new PresentationFactory(rxController));
140 }
141 catch (RuntimeException&)
142 {
144 }
145}
146
147} // end of namespace sd::framework
148
149
150/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XResourceId > mxResourceId
static void Stop(ViewShellBase const &rBase)
Definition: slideshow.cxx:201
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
virtual css::uno::Reference< css::drawing::framework::XResource > SAL_CALL createResource(const css::uno::Reference< css::drawing::framework::XResourceId > &rxViewId) override
virtual void SAL_CALL releaseResource(const css::uno::Reference< css::drawing::framework::XResource > &xView) override
virtual void SAL_CALL notifyConfigurationChange(const css::drawing::framework::ConfigurationChangeEvent &rEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &rEventObject) override
static void install(const rtl::Reference<::sd::DrawController > &rxController)
PresentationFactory(const rtl::Reference<::sd::DrawController > &rxController)
rtl::Reference<::sd::DrawController > mxController
#define DBG_UNHANDLED_EXCEPTION(...)
float u
constexpr OUStringLiteral gsPresentationViewURL
unsigned char sal_Bool