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 
36 #include <vcl/window.hxx>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <cppuhelper/compbase.hxx>
41 #include <cppuhelper/basemutex.hxx>
43 
44 
45 using namespace css;
46 using namespace css::uno;
47 
48 namespace {
49 
50 typedef ::cppu::WeakComponentImplHelper <
51  css::ui::XUIElementFactory, css::lang::XServiceInfo
53 
54 class SwPanelFactory
55  : private ::cppu::BaseMutex
56  , public PanelFactoryInterfaceBase
57 {
58 private:
59  SwPanelFactory(SwPanelFactory const&) = delete;
60  SwPanelFactory& operator=(SwPanelFactory const&) = delete;
61 
62 public:
63  SwPanelFactory();
64 
65  // XUIElementFactory
66  css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement(
67  const OUString& rsResourceURL,
68  const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
69 
70  OUString SAL_CALL getImplementationName() override
71  { return "org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"; }
72 
73  sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
74  { return cppu::supportsService(this, ServiceName); }
75 
76  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
77  { return css::uno::Sequence<OUString>{"com.sun.star.ui.UIElementFactory"}; }
78 };
79 
80 SwPanelFactory::SwPanelFactory()
81  : PanelFactoryInterfaceBase(m_aMutex)
82 {
83 }
84 
85 Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
86  const OUString& rsResourceURL,
87  const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
88 {
89  Reference<ui::XUIElement> xElement;
90 
91  const ::comphelper::NamedValueCollection aArguments (rArguments);
92  Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
93  Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
94  const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
95  SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
96 
97  VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
98  if ( ! xParentWindow.is() || pParentWindow==nullptr)
99  throw RuntimeException(
100  "PanelFactory::createUIElement called without ParentWindow",
101  nullptr);
102  if ( ! xFrame.is())
103  throw RuntimeException(
104  "PanelFactory::createUIElement called without Frame",
105  nullptr);
106  if (pBindings == nullptr)
107  throw RuntimeException(
108  "PanelFactory::createUIElement called without SfxBindings",
109  nullptr);
110 
111  if(rsResourceURL.endsWith("/PageStylesPanel"))
112  {
113  VclPtr<vcl::Window> pPanel = sw::sidebar::PageStylesPanel::Create( pParentWindow, xFrame, pBindings );
115  rsResourceURL,
116  xFrame,
117  pPanel,
118  ui::LayoutSize(-1,-1,-1));
119  }
120  else if(rsResourceURL.endsWith("/PageFormatPanel"))
121  {
122  VclPtr<vcl::Window> pPanel = sw::sidebar::PageFormatPanel::Create( pParentWindow, xFrame, pBindings );
124  rsResourceURL,
125  xFrame,
126  pPanel,
127  ui::LayoutSize(-1,-1,-1));
128  }
129  else if(rsResourceURL.endsWith("/PageHeaderPanel"))
130  {
131  VclPtr<vcl::Window> pPanel = sw::sidebar::PageHeaderPanel::Create( pParentWindow, xFrame, pBindings );
133  rsResourceURL,
134  xFrame,
135  pPanel,
136  ui::LayoutSize(-1,-1,-1));
137  }
138  else if(rsResourceURL.endsWith("/PageFooterPanel"))
139  {
140  VclPtr<vcl::Window> pPanel = sw::sidebar::PageFooterPanel::Create( pParentWindow, xFrame, pBindings );
142  rsResourceURL,
143  xFrame,
144  pPanel,
145  ui::LayoutSize(-1,-1,-1));
146  }
147  else if (rsResourceURL.endsWith("/WrapPropertyPanel"))
148  {
149  VclPtr<vcl::Window> pPanel = sw::sidebar::WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings );
151  rsResourceURL,
152  xFrame,
153  pPanel,
154  ui::LayoutSize(-1,-1,-1));
155  }
156  else if (rsResourceURL.endsWith("/NavigatorPanel"))
157  {
158  VclPtr<vcl::Window> pPanel = SwNavigationPI::Create( pParentWindow, xFrame, pBindings );
160  rsResourceURL,
161  xFrame,
162  pPanel,
163  ui::LayoutSize(0,-1,-1));
164  }
165  else if (rsResourceURL.endsWith("/ManageChangesPanel"))
166  {
167  VclPtrInstance<SwRedlineAcceptPanel> pPanel(pParentWindow, xFrame);
169  rsResourceURL,
170  xFrame,
171  pPanel,
172  ui::LayoutSize(-1,-1,-1));
173  }
174  else if (rsResourceURL.endsWith("/WriterInspectorTextPanel"))
175  {
178  rsResourceURL,
179  xFrame,
180  pPanel,
181  ui::LayoutSize(0,-1,-1));
182  }
183  else if (rsResourceURL.endsWith("/StylePresetsPanel"))
184  {
185  VclPtr<vcl::Window> pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame);
187  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
188  }
189  else if (rsResourceURL.endsWith("/ThemePanel"))
190  {
191  VclPtr<vcl::Window> pPanel = sw::sidebar::ThemePanel::Create(pParentWindow, xFrame);
193  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
194  }
195  else if (rsResourceURL.endsWith("/TableEditPanel"))
196  {
197  VclPtr<vcl::Window> pPanel = sw::sidebar::TableEditPanel::Create(pParentWindow, xFrame, pBindings );
199  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
200  }
201 
202  return xElement;
203 }
204 
205 }
206 
207 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
209  css::uno::XComponentContext *,
210  css::uno::Sequence<css::uno::Any> const &)
211 {
212  return cppu::acquire(new SwPanelFactory());
213 }
214 
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)
osl::Mutex m_aMutex
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
Definition: ThemePanel.cxx:400
Reference< XFrame > xFrame
static VclPtr< vcl::Window > GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)
Sequence< PropertyValue > aArguments
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
static css::uno::Reference< css::ui::XUIElement > Create(const OUString &rsResourceURL, const css::uno::Reference< css::frame::XFrame > &rxFrame, vcl::Window *pControl, const css::ui::LayoutSize &rLayoutSize)
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 &)
::cppu::WeakComponentImplHelper< css::ui::XUIElementFactory, css::lang::XServiceInfo > PanelFactoryInterfaceBase
unsigned char sal_Bool
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)
Definition: navipi.cxx:492
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame, SfxBindings *pBindings)