LibreOffice Module sw (master) 1
SwPanelFactory.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 <com/sun/star/ui/XUIElementFactory.hpp>
21
23#include "ThemePanel.hxx"
24#include "StylePresetsPanel.hxx"
25#include "PageStylesPanel.hxx"
26#include "PageFormatPanel.hxx"
27#include "PageHeaderPanel.hxx"
28#include "PageFooterPanel.hxx"
29#include "WrapPropertyPanel.hxx"
31#include "TableEditPanel.hxx"
32#include <navipi.hxx>
33#include <redlndlg.hxx>
34
36#include <vcl/weldutils.hxx>
37#include <com/sun/star/lang/XServiceInfo.hpp>
38#include <com/sun/star/uno/XComponentContext.hpp>
42
43
44using namespace css;
45using namespace css::uno;
46
47namespace {
48
50 css::ui::XUIElementFactory, css::lang::XServiceInfo
52
53class SwPanelFactory final : public PanelFactoryInterfaceBase
54{
55private:
56 SwPanelFactory(SwPanelFactory const&) = delete;
57 SwPanelFactory& operator=(SwPanelFactory const&) = delete;
58
59public:
60 SwPanelFactory();
61
62 // XUIElementFactory
63 css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement(
64 const OUString& rsResourceURL,
65 const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
66
67 OUString SAL_CALL getImplementationName() override
68 { return "org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"; }
69
70 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
71 { return cppu::supportsService(this, ServiceName); }
72
73 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
74 { return {"com.sun.star.ui.UIElementFactory"}; }
75};
76
77SwPanelFactory::SwPanelFactory()
78{
79}
80
81Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
82 const OUString& rsResourceURL,
83 const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
84{
85 Reference<ui::XUIElement> xElement;
86
87 const ::comphelper::NamedValueCollection aArguments (rArguments);
88 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
89 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
90 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
91 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
92
93 weld::Widget* pParent(nullptr);
94 if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
95 pParent = pTunnel->getWidget();
96
97 if (!pParent)
98 throw RuntimeException(
99 "PanelFactory::createUIElement called without ParentWindow",
100 nullptr);
101 if ( ! xFrame.is())
102 throw RuntimeException(
103 "PanelFactory::createUIElement called without Frame",
104 nullptr);
105 if (pBindings == nullptr)
106 throw RuntimeException(
107 "PanelFactory::createUIElement called without SfxBindings",
108 nullptr);
109
110 if(rsResourceURL.endsWith("/PageStylesPanel"))
111 {
112 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageStylesPanel::Create( pParent, pBindings );
114 rsResourceURL,
115 xFrame,
116 std::move(xPanel),
117 ui::LayoutSize(-1,-1,-1));
118 }
119 else if(rsResourceURL.endsWith("/PageFormatPanel"))
120 {
121 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageFormatPanel::Create( pParent, pBindings );
123 rsResourceURL,
124 xFrame,
125 std::move(xPanel),
126 ui::LayoutSize(-1,-1,-1));
127 }
128 else if(rsResourceURL.endsWith("/PageHeaderPanel"))
129 {
130 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageHeaderPanel::Create( pParent, pBindings );
132 rsResourceURL,
133 xFrame,
134 std::move(xPanel),
135 ui::LayoutSize(-1,-1,-1));
136 }
137 else if(rsResourceURL.endsWith("/PageFooterPanel"))
138 {
139 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageFooterPanel::Create( pParent, pBindings );
141 rsResourceURL,
142 xFrame,
143 std::move(xPanel),
144 ui::LayoutSize(-1,-1,-1));
145 }
146 else if (rsResourceURL.endsWith("/WrapPropertyPanel"))
147 {
148 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::WrapPropertyPanel::Create( pParent, xFrame, pBindings );
150 rsResourceURL,
151 xFrame,
152 std::move(xPanel),
153 ui::LayoutSize(-1,-1,-1));
154 }
155 else if (rsResourceURL.endsWith("/NavigatorPanel"))
156 {
157 std::unique_ptr<PanelLayout> xPanel = SwNavigationPI::Create( pParent, xFrame, pBindings );
159 rsResourceURL,
160 xFrame,
161 std::move(xPanel),
162 ui::LayoutSize(0,-1,-1));
163 }
164 else if (rsResourceURL.endsWith("/ManageChangesPanel"))
165 {
166 auto xPanel = std::make_unique<SwRedlineAcceptPanel>(pParent);
168 rsResourceURL,
169 xFrame,
170 std::move(xPanel),
171 ui::LayoutSize(0,-1,-1));
172 }
173 else if (rsResourceURL.endsWith("/WriterInspectorTextPanel"))
174 {
175 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::WriterInspectorTextPanel::Create(pParent);
177 rsResourceURL,
178 xFrame,
179 std::move(xPanel),
180 ui::LayoutSize(0,-1,-1));
181 }
182 else if (rsResourceURL.endsWith("/StylePresetsPanel"))
183 {
184 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::StylePresetsPanel::Create(pParent);
186 rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1));
187 }
188 else if (rsResourceURL.endsWith("/ThemePanel"))
189 {
190 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::ThemePanel::Create(pParent);
192 rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1));
193 }
194 else if (rsResourceURL.endsWith("/TableEditPanel"))
195 {
196 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::TableEditPanel::Create(pParent, xFrame, pBindings );
198 rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1));
199 }
200 else if (rsResourceURL.endsWith("/A11yCheckIssuesPanel"))
201 {
202 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::A11yCheckIssuesPanel::Create(pParent, pBindings);
204 rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1));
205 }
206
207 return xElement;
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 SwPanelFactory());
218}
219
220/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_apache_openoffice_comp_sw_sidebar_SwPanelFactory_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)
Definition: navipi.cxx:499
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)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent)
Definition: ThemePanel.cxx:29
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent)
Sequence< PropertyValue > aArguments
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Reference< XFrame > xFrame
unsigned char sal_Bool