nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / uibase / sidebar / SwPanelFactory.cxx
blob68e5c0684d6a603d31c1f1a8b310f15f45d49602
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/ui/XUIElementFactory.hpp>
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"
29 #include "WriterInspectorTextPanel.hxx"
30 #include "TableEditPanel.hxx"
31 #include <navipi.hxx>
32 #include <redlndlg.hxx>
34 #include <sfx2/sidebar/SidebarPanelBase.hxx>
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <vcl/window.hxx>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <comphelper/namedvaluecollection.hxx>
39 #include <cppuhelper/compbase.hxx>
40 #include <cppuhelper/basemutex.hxx>
41 #include <cppuhelper/supportsservice.hxx>
44 using namespace css;
45 using namespace css::uno;
47 namespace {
49 typedef ::cppu::WeakComponentImplHelper <
50 css::ui::XUIElementFactory, css::lang::XServiceInfo
51 > PanelFactoryInterfaceBase;
53 class SwPanelFactory
54 : private ::cppu::BaseMutex
55 , public PanelFactoryInterfaceBase
57 private:
58 SwPanelFactory(SwPanelFactory const&) = delete;
59 SwPanelFactory& operator=(SwPanelFactory const&) = delete;
61 public:
62 SwPanelFactory();
64 // XUIElementFactory
65 css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement(
66 const OUString& rsResourceURL,
67 const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
69 OUString SAL_CALL getImplementationName() override
70 { return "org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"; }
72 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
73 { return cppu::supportsService(this, ServiceName); }
75 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
76 { return css::uno::Sequence<OUString>{"com.sun.star.ui.UIElementFactory"}; }
79 SwPanelFactory::SwPanelFactory()
80 : PanelFactoryInterfaceBase(m_aMutex)
84 Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
85 const OUString& rsResourceURL,
86 const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
88 Reference<ui::XUIElement> xElement;
90 const ::comphelper::NamedValueCollection aArguments (rArguments);
91 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
92 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
93 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
94 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
96 VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
97 if ( ! xParentWindow.is() || pParentWindow==nullptr)
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);
110 if(rsResourceURL.endsWith("/PageStylesPanel"))
112 VclPtr<vcl::Window> pPanel = sw::sidebar::PageStylesPanel::Create( pParentWindow, xFrame, pBindings );
113 xElement = sfx2::sidebar::SidebarPanelBase::Create(
114 rsResourceURL,
115 xFrame,
116 pPanel,
117 ui::LayoutSize(-1,-1,-1));
119 else if(rsResourceURL.endsWith("/PageFormatPanel"))
121 VclPtr<vcl::Window> pPanel = sw::sidebar::PageFormatPanel::Create( pParentWindow, xFrame, pBindings );
122 xElement = sfx2::sidebar::SidebarPanelBase::Create(
123 rsResourceURL,
124 xFrame,
125 pPanel,
126 ui::LayoutSize(-1,-1,-1));
128 else if(rsResourceURL.endsWith("/PageHeaderPanel"))
130 VclPtr<vcl::Window> pPanel = sw::sidebar::PageHeaderPanel::Create( pParentWindow, xFrame, pBindings );
131 xElement = sfx2::sidebar::SidebarPanelBase::Create(
132 rsResourceURL,
133 xFrame,
134 pPanel,
135 ui::LayoutSize(-1,-1,-1));
137 else if(rsResourceURL.endsWith("/PageFooterPanel"))
139 VclPtr<vcl::Window> pPanel = sw::sidebar::PageFooterPanel::Create( pParentWindow, xFrame, pBindings );
140 xElement = sfx2::sidebar::SidebarPanelBase::Create(
141 rsResourceURL,
142 xFrame,
143 pPanel,
144 ui::LayoutSize(-1,-1,-1));
146 else if (rsResourceURL.endsWith("/WrapPropertyPanel"))
148 VclPtr<vcl::Window> pPanel = sw::sidebar::WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings );
149 xElement = sfx2::sidebar::SidebarPanelBase::Create(
150 rsResourceURL,
151 xFrame,
152 pPanel,
153 ui::LayoutSize(-1,-1,-1));
155 else if (rsResourceURL.endsWith("/NavigatorPanel"))
157 VclPtr<vcl::Window> pPanel = SwNavigationPI::Create( pParentWindow, xFrame, pBindings );
158 xElement = sfx2::sidebar::SidebarPanelBase::Create(
159 rsResourceURL,
160 xFrame,
161 pPanel,
162 ui::LayoutSize(0,-1,-1));
164 else if (rsResourceURL.endsWith("/ManageChangesPanel"))
166 VclPtrInstance<SwRedlineAcceptPanel> pPanel(pParentWindow, xFrame);
167 xElement = sfx2::sidebar::SidebarPanelBase::Create(
168 rsResourceURL,
169 xFrame,
170 pPanel,
171 ui::LayoutSize(-1,-1,-1));
173 else if (rsResourceURL.endsWith("/WriterInspectorTextPanel"))
175 VclPtr<vcl::Window> pPanel = sw::sidebar::WriterInspectorTextPanel::Create( pParentWindow, xFrame);
176 xElement = sfx2::sidebar::SidebarPanelBase::Create(
177 rsResourceURL,
178 xFrame,
179 pPanel,
180 ui::LayoutSize(0,-1,-1));
182 else if (rsResourceURL.endsWith("/StylePresetsPanel"))
184 VclPtr<vcl::Window> pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame);
185 xElement = sfx2::sidebar::SidebarPanelBase::Create(
186 rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
188 else if (rsResourceURL.endsWith("/ThemePanel"))
190 VclPtr<vcl::Window> pPanel = sw::sidebar::ThemePanel::Create(pParentWindow, xFrame);
191 xElement = sfx2::sidebar::SidebarPanelBase::Create(
192 rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
194 else if (rsResourceURL.endsWith("/TableEditPanel"))
196 VclPtr<vcl::Window> pPanel = sw::sidebar::TableEditPanel::Create(pParentWindow, xFrame, pBindings );
197 xElement = sfx2::sidebar::SidebarPanelBase::Create(
198 rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
201 return xElement;
206 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
207 org_apache_openoffice_comp_sw_sidebar_SwPanelFactory_get_implementation(
208 css::uno::XComponentContext *,
209 css::uno::Sequence<css::uno::Any> const &)
211 return cppu::acquire(new SwPanelFactory());
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */