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"
29 #include "TableEditPanel.hxx"
30 #include <navipi.hxx>
31 #include <redlndlg.hxx>
32 
35 #include <vcl/window.hxx>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <cppuhelper/compbase.hxx>
39 #include <cppuhelper/basemutex.hxx>
41 
42 
43 using namespace css;
44 using namespace css::uno;
45 
46 namespace {
47 
48 typedef ::cppu::WeakComponentImplHelper <
49  css::ui::XUIElementFactory, css::lang::XServiceInfo
51 
52 class SwPanelFactory
53  : private ::cppu::BaseMutex
54  , public PanelFactoryInterfaceBase
55 {
56 private:
57  SwPanelFactory(SwPanelFactory const&) = delete;
58  SwPanelFactory& operator=(SwPanelFactory const&) = delete;
59 
60 public:
61  SwPanelFactory();
62 
63  // XUIElementFactory
64  css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement(
65  const OUString& rsResourceURL,
66  const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
67 
68  OUString SAL_CALL getImplementationName() override
69  { return "org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"; }
70 
71  sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
72  { return cppu::supportsService(this, ServiceName); }
73 
74  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
75  { return css::uno::Sequence<OUString>{"com.sun.star.ui.UIElementFactory"}; }
76 };
77 
78 SwPanelFactory::SwPanelFactory()
79  : PanelFactoryInterfaceBase(m_aMutex)
80 {
81 }
82 
83 Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
84  const OUString& rsResourceURL,
85  const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
86 {
87  Reference<ui::XUIElement> xElement;
88 
89  const ::comphelper::NamedValueCollection aArguments (rArguments);
90  Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
91  Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
92  const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
93  SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
94 
95  VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
96  if ( ! xParentWindow.is() || pParentWindow==nullptr)
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  VclPtr<vcl::Window> pPanel = sw::sidebar::PageStylesPanel::Create( pParentWindow, xFrame, pBindings );
113  rsResourceURL,
114  xFrame,
115  pPanel,
116  ui::LayoutSize(-1,-1,-1));
117  }
118  else if(rsResourceURL.endsWith("/PageFormatPanel"))
119  {
120  VclPtr<vcl::Window> pPanel = sw::sidebar::PageFormatPanel::Create( pParentWindow, xFrame, pBindings );
122  rsResourceURL,
123  xFrame,
124  pPanel,
125  ui::LayoutSize(-1,-1,-1));
126  }
127  else if(rsResourceURL.endsWith("/PageHeaderPanel"))
128  {
129  VclPtr<vcl::Window> pPanel = sw::sidebar::PageHeaderPanel::Create( pParentWindow, xFrame, pBindings );
131  rsResourceURL,
132  xFrame,
133  pPanel,
134  ui::LayoutSize(-1,-1,-1));
135  }
136  else if(rsResourceURL.endsWith("/PageFooterPanel"))
137  {
138  VclPtr<vcl::Window> pPanel = sw::sidebar::PageFooterPanel::Create( pParentWindow, xFrame, pBindings );
140  rsResourceURL,
141  xFrame,
142  pPanel,
143  ui::LayoutSize(-1,-1,-1));
144  }
145  else if (rsResourceURL.endsWith("/WrapPropertyPanel"))
146  {
147  VclPtr<vcl::Window> pPanel = sw::sidebar::WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings );
149  rsResourceURL,
150  xFrame,
151  pPanel,
152  ui::LayoutSize(-1,-1,-1));
153  }
154  else if (rsResourceURL.endsWith("/NavigatorPanel"))
155  {
156  VclPtrInstance<SwNavigationPI> pPanel(pBindings, pParentWindow);
158  rsResourceURL,
159  xFrame,
160  pPanel,
161  ui::LayoutSize(0,-1,-1));
162  }
163  else if (rsResourceURL.endsWith("/ManageChangesPanel"))
164  {
165  VclPtrInstance<SwRedlineAcceptPanel> pPanel(pParentWindow, xFrame);
167  rsResourceURL,
168  xFrame,
169  pPanel,
170  ui::LayoutSize(-1,-1,-1));
171  }
172  else if (rsResourceURL.endsWith("/StylePresetsPanel"))
173  {
174  VclPtr<vcl::Window> pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame);
176  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
177  }
178  else if (rsResourceURL.endsWith("/ThemePanel"))
179  {
180  VclPtr<vcl::Window> pPanel = sw::sidebar::ThemePanel::Create(pParentWindow, xFrame);
182  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
183  }
184  else if (rsResourceURL.endsWith("/TableEditPanel"))
185  {
186  VclPtr<vcl::Window> pPanel = sw::sidebar::TableEditPanel::Create(pParentWindow, xFrame, pBindings );
188  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
189  }
190 
191  return xElement;
192 }
193 
194 }
195 
196 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
198  css::uno::XComponentContext *,
199  css::uno::Sequence<css::uno::Any> const &)
200 {
201  return cppu::acquire(new SwPanelFactory());
202 }
203 
204 /* 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:402
Reference< XFrame > xFrame
static VclPtr< vcl::Window > GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
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
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)
css::uno::Sequence< OUString > getSupportedServiceNames()
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 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)