LibreOffice Module svx (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 <config_features.h>
21
35#if HAVE_FEATURE_AVMEDIA
37#endif
38#include <GalleryControl.hxx>
39#include "EmptyPanel.hxx"
41#include <sfx2/templdlg.hxx>
42#include <vcl/weldutils.hxx>
46#include <com/sun/star/lang/XServiceInfo.hpp>
47#include <com/sun/star/ui/XSidebar.hpp>
48#include <com/sun/star/ui/XUIElementFactory.hpp>
49#include <com/sun/star/uno/XComponentContext.hpp>
50
51using namespace css;
52using namespace css::uno;
53using namespace svx::sidebar;
54
55
56namespace {
57
58/* Why this is not used ? Doesn't it need to inherit from XServiceInfo ?
59constexpr OUStringLiteral IMPLEMENTATION_NAME = u"org.apache.openoffice.comp.svx.sidebar.PanelFactory";
60constexpr OUStringLiteral SERVICE_NAME = u"com.sun.star.ui.UIElementFactory";
61*/
62
65
66class PanelFactory
68{
69public:
70 PanelFactory();
71 PanelFactory(const PanelFactory&) = delete;
72 PanelFactory& operator=(const PanelFactory&) = delete;
73
74 // XUIElementFactory
75 css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement (
76 const OUString& rsResourceURL,
77 const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
78
79 OUString SAL_CALL getImplementationName() override
80 { return "org.apache.openoffice.comp.svx.sidebar.PanelFactory"; }
81
82 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
83 { return cppu::supportsService(this, ServiceName); }
84
85 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
86 { return {"com.sun.star.ui.UIElementFactory"}; }
87};
88
89PanelFactory::PanelFactory()
90{
91}
92
93Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
94 const OUString& rsResourceURL,
95 const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
96{
97 const ::comphelper::NamedValueCollection aArguments (rArguments);
98 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
99 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
100 Reference<ui::XSidebar> xSidebar (aArguments.getOrDefault("Sidebar", Reference<ui::XSidebar>()));
101 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
102 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
103
104 weld::Widget* pParent(nullptr);
105 if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
106 pParent = pTunnel->getWidget();
107
108 if (!pParent)
109 throw RuntimeException(
110 "PanelFactory::createUIElement called without ParentWindow",
111 nullptr);
112 if ( ! xFrame.is())
113 throw RuntimeException(
114 "PanelFactory::createUIElement called without Frame",
115 nullptr);
116 if (pBindings == nullptr)
117 throw RuntimeException(
118 "PanelFactory::createUIElement called without SfxBindings",
119 nullptr);
120
121 std::unique_ptr<PanelLayout> xControl;
122 ui::LayoutSize aLayoutSize (-1,-1,-1);
123
124 if (rsResourceURL.endsWith("/TextPropertyPanel"))
125 {
126 xControl = TextPropertyPanel::Create(pParent, xFrame);
127 }
128 else if (rsResourceURL.endsWith("/StylesPropertyPanel"))
129 {
130 xControl = StylesPropertyPanel::Create(pParent, xFrame);
131 }
132 else if (rsResourceURL.endsWith("/ParaPropertyPanel"))
133 {
134 xControl = ParaPropertyPanel::Create(pParent, xFrame, pBindings, xSidebar);
135 }
136 else if (rsResourceURL.endsWith("/ListsPropertyPanel"))
137 {
138 xControl = ListsPropertyPanel::Create(pParent, xFrame);
139 }
140 else if (rsResourceURL.endsWith("/AreaPropertyPanel"))
141 {
142 xControl = AreaPropertyPanel::Create(pParent, xFrame, pBindings);
143 }
144 else if (rsResourceURL.endsWith("/FontworkPropertyPanel"))
145 {
146 xControl = FontworkPropertyPanel::Create(pParent, xFrame);
147 }
148 else if (rsResourceURL.endsWith("/ShadowPropertyPanel"))
149 {
150 xControl = ShadowPropertyPanel::Create(pParent, pBindings);
151 }
152 else if (rsResourceURL.endsWith("/EffectPropertyPanel"))
153 {
154 xControl = EffectPropertyPanel::Create(pParent, pBindings);
155 }
156 else if (rsResourceURL.endsWith("/GraphicPropertyPanel"))
157 {
158 xControl = GraphicPropertyPanel::Create(pParent, pBindings);
159 }
160 else if (rsResourceURL.endsWith("/LinePropertyPanel"))
161 {
162 xControl = LinePropertyPanel::Create(pParent, xFrame, pBindings);
163 }
164 else if (rsResourceURL.endsWith("/PosSizePropertyPanel"))
165 {
166 xControl = PosSizePropertyPanel::Create(pParent, xFrame, pBindings, xSidebar);
167 }
168 else if (rsResourceURL.endsWith("/DefaultShapesPanel"))
169 {
170 xControl = DefaultShapesPanel::Create(pParent, xFrame);
171 }
172#if HAVE_FEATURE_AVMEDIA
173 else if (rsResourceURL.endsWith("/MediaPlaybackPanel"))
174 {
175 xControl = MediaPlaybackPanel::Create(pParent, pBindings);
176 }
177#endif
178 else if (rsResourceURL.endsWith("/GalleryPanel"))
179 {
180 xControl = std::make_unique<GalleryControl>(pParent);
181 aLayoutSize = ui::LayoutSize(300,-1,400);
182 }
183 else if (rsResourceURL.endsWith("/StyleListPanel"))
184 {
185 xControl = std::make_unique<SfxTemplatePanelControl>(pBindings, pParent);
186 aLayoutSize = ui::LayoutSize(0,-1,-1);
187 }
188 else if (rsResourceURL.endsWith("/EmptyPanel"))
189 {
190 xControl = std::make_unique<EmptyPanel>(pParent);
191 aLayoutSize = ui::LayoutSize(20,-1, 50);
192 }
193 else if (rsResourceURL.endsWith("/TextColumnsPropertyPanel"))
194 {
195 xControl = TextColumnsPropertyPanel::Create(pParent, pBindings);
196 }
197
198 if (xControl)
199 {
201 rsResourceURL,
202 xFrame,
203 std::move(xControl),
204 aLayoutSize);
205 }
206 else
207 return Reference<ui::XUIElement>();
208}
209
210}
211
212extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
214 css::uno::XComponentContext *,
215 css::uno::Sequence<css::uno::Any> const &)
216{
217 return cppu::acquire(new PanelFactory);
218}
219
220/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_apache_openoffice_comp_svx_sidebar_PanelFactory_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
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
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:34
Reference< XFrame > xFrame
unsigned char sal_Bool