LibreOffice Module sd (master) 1
PanelFactory.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
20#include "PanelFactory.hxx"
21#include <framework/Pane.hxx>
22#include <ViewShellBase.hxx>
23#include <DrawController.hxx>
24#include "LayoutMenu.hxx"
29#include "NavigatorWrapper.hxx"
31#include <TableDesignPane.hxx>
32#include "SlideBackground.hxx"
33
35#include <com/sun/star/uno/XComponentContext.hpp>
39#include <vcl/weldutils.hxx>
40
41using namespace css;
42using namespace css::uno;
43using namespace ::sd::framework;
44
45namespace sd::sidebar {
46
47//----- PanelFactory --------------------------------------------------------
48
50{
51}
52
54{
55}
56
57// XUIElementFactory
58
59Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
60 const OUString& rsUIElementResourceURL,
61 const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
62{
63 // Process arguments.
64 const ::comphelper::NamedValueCollection aArguments (rArguments);
65 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
66 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
67 Reference<ui::XSidebar> xSidebar (aArguments.getOrDefault("Sidebar", Reference<ui::XSidebar>()));
68
69 // Throw exceptions when the arguments are not as expected.
70 weld::Widget* pParent(nullptr);
71 if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
72 pParent = pTunnel->getWidget();
73
74 if (!pParent)
75 throw RuntimeException(
76 "PanelFactory::createUIElement called without ParentWindow");
77 if ( ! xFrame.is())
78 throw RuntimeException(
79 "PanelFactory::createUIElement called without XFrame");
80
81 // Tunnel through the controller to obtain a ViewShellBase.
82 ViewShellBase* pBase = nullptr;
83 rtl::Reference<sd::DrawController> pController = dynamic_cast<sd::DrawController*>(xFrame->getController().get());
84 if (pController != nullptr)
85 pBase = pController->GetViewShellBase();
86 if (pBase == nullptr)
87 throw RuntimeException("can not get ViewShellBase for frame");
88
89 // Get bindings from given arguments.
90 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
91 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
92
93 // Create a framework view.
94 std::unique_ptr<PanelLayout> xControl;
95 css::ui::LayoutSize aLayoutSize (-1,-1,-1);
96
101 if (rsUIElementResourceURL.endsWith("/CustomAnimations"))
102 xControl = std::make_unique<CustomAnimationPane>(pParent, *pBase);
103 else if (rsUIElementResourceURL.endsWith("/Layouts"))
104 xControl = std::make_unique<LayoutMenu>(pParent, *pBase, xSidebar);
105 else if (rsUIElementResourceURL.endsWith("/AllMasterPages"))
106 xControl = AllMasterPagesSelector::Create(pParent, *pBase, xSidebar);
107 else if (rsUIElementResourceURL.endsWith("/RecentMasterPages"))
108 xControl = RecentMasterPagesSelector::Create(pParent, *pBase, xSidebar);
109 else if (rsUIElementResourceURL.endsWith("/UsedMasterPages"))
110 xControl = CurrentMasterPagesSelector::Create(pParent, *pBase, xSidebar);
111 else if (rsUIElementResourceURL.endsWith("/SlideTransitions"))
112 xControl = std::make_unique<SlideTransitionPane>(pParent, *pBase);
113 else if (rsUIElementResourceURL.endsWith("/TableDesign"))
114 xControl = std::make_unique<TableDesignPane>(pParent, *pBase);
115 else if (rsUIElementResourceURL.endsWith("/NavigatorPanel"))
116 xControl = std::make_unique<NavigatorWrapper>(pParent, *pBase, pBindings);
117 else if (rsUIElementResourceURL.endsWith("/SlideBackgroundPanel"))
118 xControl = std::make_unique<SlideBackground>(pParent, *pBase, xFrame, pBindings);
119
120 if (!xControl)
121 throw lang::IllegalArgumentException();
122
123 // Create a wrapper around the control that implements the
124 // necessary UNO interfaces.
126 rsUIElementResourceURL,
127 xFrame,
128 std::move(xControl),
129 aLayoutSize);
130}
131
133 return "org.openoffice.comp.Draw.framework.PanelFactory";
134}
135
136sal_Bool PanelFactory::supportsService(OUString const & ServiceName) {
138}
139
140css::uno::Sequence<OUString> PanelFactory::getSupportedServiceNames() {
141 return {"com.sun.star.drawing.framework.PanelFactory"};
142}
143
144} // end of namespace sd::sidebar
145
146
147extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
149 css::uno::Sequence<css::uno::Any> const &)
150{
151 return cppu::acquire(new sd::sidebar::PanelFactory);
152}
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_openoffice_comp_Draw_framework_PanelFactory_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
The DrawController is the UNO controller for Impress and Draw.
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, ViewShellBase &rViewShellBase, const css::uno::Reference< css::ui::XSidebar > &rxSidebar)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, ViewShellBase &rViewShellBase, const css::uno::Reference< css::ui::XSidebar > &rxSidebar)
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement(const OUString &rsResourceURL, const css::uno::Sequence< css::beans::PropertyValue > &rArguments) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~PanelFactory() override
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, ViewShellBase &rViewShellBase, const css::uno::Reference< css::ui::XSidebar > &rxSidebar)
static css::uno::Reference< css::ui::XUIElement > Create(const OUString &rsResourceURL, const css::uno::Reference< css::frame::XFrame > &rxFrame, std::unique_ptr< PanelLayout > xControl, const css::ui::LayoutSize &rLayoutSize)
Sequence< PropertyValue > aArguments
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< XFrame > xFrame
unsigned char sal_Bool