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
22#include "ThemePanel.hxx"
23#include "StylePresetsPanel.hxx"
24#include "PageStylesPanel.hxx"
25#include "PageFormatPanel.hxx"
26#include "PageHeaderPanel.hxx"
27#include "PageFooterPanel.hxx"
28#include "WrapPropertyPanel.hxx"
30#include "TableEditPanel.hxx"
31#include <navipi.hxx>
32#include <redlndlg.hxx>
33
35#include <vcl/weldutils.hxx>
36#include <com/sun/star/lang/XServiceInfo.hpp>
37#include <com/sun/star/uno/XComponentContext.hpp>
41
42
43using namespace css;
44using namespace css::uno;
45
46namespace {
47
49 css::ui::XUIElementFactory, css::lang::XServiceInfo
51
52class SwPanelFactory final : public PanelFactoryInterfaceBase
53{
54private:
55 SwPanelFactory(SwPanelFactory const&) = delete;
56 SwPanelFactory& operator=(SwPanelFactory const&) = delete;
57
58public:
59 SwPanelFactory();
60
61 // XUIElementFactory
62 css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement(
63 const OUString& rsResourceURL,
64 const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
65
66 OUString SAL_CALL getImplementationName() override
67 { return "org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"; }
68
69 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
70 { return cppu::supportsService(this, ServiceName); }
71
72 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
73 { return {"com.sun.star.ui.UIElementFactory"}; }
74};
75
76SwPanelFactory::SwPanelFactory()
77{
78}
79
80Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
81 const OUString& rsResourceURL,
82 const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
83{
84 Reference<ui::XUIElement> xElement;
85
86 const ::comphelper::NamedValueCollection aArguments (rArguments);
87 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
88 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
89 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
90 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
91
92 weld::Widget* pParent(nullptr);
93 if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
94 pParent = pTunnel->getWidget();
95
96 if (!pParent)
97 throw RuntimeException(
98 "PanelFactory::createUIElement called without ParentWindow",
99 nullptr);
100 if ( ! xFrame.is())
101 throw RuntimeException(
102 "PanelFactory::createUIElement called without Frame",
103 nullptr);
104 if (pBindings == nullptr)
105 throw RuntimeException(
106 "PanelFactory::createUIElement called without SfxBindings",
107 nullptr);
108
109 if(rsResourceURL.endsWith("/PageStylesPanel"))
110 {
111 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageStylesPanel::Create( pParent, pBindings );
113 rsResourceURL,
114 xFrame,
115 std::move(xPanel),
116 ui::LayoutSize(-1,-1,-1));
117 }
118 else if(rsResourceURL.endsWith("/PageFormatPanel"))
119 {
120 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageFormatPanel::Create( pParent, pBindings );
122 rsResourceURL,
123 xFrame,
124 std::move(xPanel),
125 ui::LayoutSize(-1,-1,-1));
126 }
127 else if(rsResourceURL.endsWith("/PageHeaderPanel"))
128 {
129 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageHeaderPanel::Create( pParent, pBindings );
131 rsResourceURL,
132 xFrame,
133 std::move(xPanel),
134 ui::LayoutSize(-1,-1,-1));
135 }
136 else if(rsResourceURL.endsWith("/PageFooterPanel"))
137 {
138 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::PageFooterPanel::Create( pParent, pBindings );
140 rsResourceURL,
141 xFrame,
142 std::move(xPanel),
143 ui::LayoutSize(-1,-1,-1));
144 }
145 else if (rsResourceURL.endsWith("/WrapPropertyPanel"))
146 {
147 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::WrapPropertyPanel::Create( pParent, xFrame, pBindings );
149 rsResourceURL,
150 xFrame,
151 std::move(xPanel),
152 ui::LayoutSize(-1,-1,-1));
153 }
154 else if (rsResourceURL.endsWith("/NavigatorPanel"))
155 {
156 std::unique_ptr<PanelLayout> xPanel = SwNavigationPI::Create( pParent, xFrame, pBindings );
158 rsResourceURL,
159 xFrame,
160 std::move(xPanel),
161 ui::LayoutSize(0,-1,-1));
162 }
163 else if (rsResourceURL.endsWith("/ManageChangesPanel"))
164 {
165 auto xPanel = std::make_unique<SwRedlineAcceptPanel>(pParent);
167 rsResourceURL,
168 xFrame,
169 std::move(xPanel),
170 ui::LayoutSize(0,-1,-1));
171 }
172 else if (rsResourceURL.endsWith("/WriterInspectorTextPanel"))
173 {
174 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::WriterInspectorTextPanel::Create(pParent);
176 rsResourceURL,
177 xFrame,
178 std::move(xPanel),
179 ui::LayoutSize(0,-1,-1));
180 }
181 else if (rsResourceURL.endsWith("/StylePresetsPanel"))
182 {
183 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::StylePresetsPanel::Create(pParent);
185 rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1));
186 }
187 else if (rsResourceURL.endsWith("/ThemePanel"))
188 {
189 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::ThemePanel::Create(pParent);
191 rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1));
192 }
193 else if (rsResourceURL.endsWith("/TableEditPanel"))
194 {
195 std::unique_ptr<PanelLayout> xPanel = sw::sidebar::TableEditPanel::Create(pParent, xFrame, pBindings );
197 rsResourceURL, xFrame, std::move(xPanel), ui::LayoutSize(-1,-1,-1));
198 }
199
200 return xElement;
201}
202
203}
204
205extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
207 css::uno::XComponentContext *,
208 css::uno::Sequence<css::uno::Any> const &)
209{
210 return cppu::acquire(new SwPanelFactory());
211}
212
213/* 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:488
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)
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:425
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