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 <navipi.hxx>
30 #include <redlndlg.hxx>
31 
35 #include <vcl/window.hxx>
36 #include <rtl/ref.hxx>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <cppuhelper/compbase.hxx>
40 #include <cppuhelper/basemutex.hxx>
42 
43 
44 using namespace css;
45 using namespace css::uno;
46 
47 namespace {
48 
49 typedef ::cppu::WeakComponentImplHelper <
50  css::ui::XUIElementFactory, css::lang::XServiceInfo
52 
53 class SwPanelFactory
54  : private ::cppu::BaseMutex
55  , public PanelFactoryInterfaceBase
56 {
57 private:
58  SwPanelFactory(SwPanelFactory const&) = delete;
59  SwPanelFactory& operator=(SwPanelFactory const&) = delete;
60 
61 public:
62  SwPanelFactory();
63 
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;
68 
69  OUString SAL_CALL getImplementationName() override
70  { return "org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"; }
71 
72  sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
73  { return cppu::supportsService(this, ServiceName); }
74 
75  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
76  { return css::uno::Sequence<OUString>{"com.sun.star.ui.UIElementFactory"}; }
77 };
78 
79 SwPanelFactory::SwPanelFactory()
80  : PanelFactoryInterfaceBase(m_aMutex)
81 {
82 }
83 
84 Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
85  const OUString& rsResourceURL,
86  const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
87 {
88  Reference<ui::XUIElement> xElement;
89 
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);
95 
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);
109 
110  if(rsResourceURL.endsWith("/PageStylesPanel"))
111  {
112  VclPtr<vcl::Window> pPanel = sw::sidebar::PageStylesPanel::Create( pParentWindow, xFrame, pBindings );
114  rsResourceURL,
115  xFrame,
116  pPanel,
117  ui::LayoutSize(-1,-1,-1));
118  }
119  else if(rsResourceURL.endsWith("/PageFormatPanel"))
120  {
121  VclPtr<vcl::Window> pPanel = sw::sidebar::PageFormatPanel::Create( pParentWindow, xFrame, pBindings );
123  rsResourceURL,
124  xFrame,
125  pPanel,
126  ui::LayoutSize(-1,-1,-1));
127  }
128  else if(rsResourceURL.endsWith("/PageHeaderPanel"))
129  {
130  VclPtr<vcl::Window> pPanel = sw::sidebar::PageHeaderPanel::Create( pParentWindow, xFrame, pBindings );
132  rsResourceURL,
133  xFrame,
134  pPanel,
135  ui::LayoutSize(-1,-1,-1));
136  }
137  else if(rsResourceURL.endsWith("/PageFooterPanel"))
138  {
139  VclPtr<vcl::Window> pPanel = sw::sidebar::PageFooterPanel::Create( pParentWindow, xFrame, pBindings );
141  rsResourceURL,
142  xFrame,
143  pPanel,
144  ui::LayoutSize(-1,-1,-1));
145  }
146  else if (rsResourceURL.endsWith("/WrapPropertyPanel"))
147  {
148  VclPtr<vcl::Window> pPanel = sw::sidebar::WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings );
150  rsResourceURL,
151  xFrame,
152  pPanel,
153  ui::LayoutSize(-1,-1,-1));
154  }
155  else if (rsResourceURL.endsWith("/NavigatorPanel"))
156  {
157  VclPtrInstance<SwNavigationPI> pPanel(pBindings, pParentWindow);
159  rsResourceURL,
160  xFrame,
161  pPanel,
162  ui::LayoutSize(0,-1,-1));
163  }
164  else if (rsResourceURL.endsWith("/ManageChangesPanel"))
165  {
166  VclPtrInstance<SwRedlineAcceptPanel> pPanel(pParentWindow, xFrame);
168  rsResourceURL,
169  xFrame,
170  pPanel,
171  ui::LayoutSize(-1,-1,-1));
172  }
173  else if (rsResourceURL.endsWith("/StylePresetsPanel"))
174  {
175  VclPtr<vcl::Window> pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame);
177  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
178  }
179  else if (rsResourceURL.endsWith("/ThemePanel"))
180  {
181  VclPtr<vcl::Window> pPanel = sw::sidebar::ThemePanel::Create(pParentWindow, xFrame);
183  rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
184  }
185 
186  return xElement;
187 }
188 
189 }
190 
191 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
193  css::uno::XComponentContext *,
194  css::uno::Sequence<css::uno::Any> const &)
195 {
196  return cppu::acquire(new SwPanelFactory());
197 }
198 
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::osl::Mutex m_aMutex
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 css::uno::Reference< css::frame::XFrame > &rxFrame)
Definition: ThemePanel.cxx:416
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)
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 ::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)