LibreOffice Module sc (master) 1
ScPanelFactory.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 "ScPanelFactory.hxx"
21
25#include <navipi.hxx>
26#include <dwfunctr.hxx>
27
29#include <vcl/weldutils.hxx>
30#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
34
35using namespace css;
36using namespace css::uno;
37
38namespace sc::sidebar {
39
41{
42}
43
45{
46}
47
48Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
49 const OUString& rsResourceURL,
50 const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
51{
52 Reference<ui::XUIElement> xElement;
53
54 try
55 {
56 const ::comphelper::NamedValueCollection aArguments (rArguments);
57 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
58 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
59 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
60 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
61
62 weld::Widget* pParent(nullptr);
63 if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
64 pParent = pTunnel->getWidget();
65
66 if (!pParent)
67 throw RuntimeException(
68 "PanelFactory::createUIElement called without ParentWindow",
69 nullptr);
70 if ( ! xFrame.is())
71 throw RuntimeException(
72 "PanelFactory::createUIElement called without Frame",
73 nullptr);
74 if (pBindings == nullptr)
75 throw RuntimeException(
76 "PanelFactory::createUIElement called without SfxBindings",
77 nullptr);
78
79 sal_Int32 nMinimumSize = -1;
80 std::unique_ptr<PanelLayout> xPanel;
81 if (rsResourceURL.endsWith("/AlignmentPropertyPanel"))
82 xPanel = AlignmentPropertyPanel::Create( pParent, xFrame, pBindings );
83 else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel"))
84 xPanel = CellAppearancePropertyPanel::Create( pParent, xFrame, pBindings );
85 else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel"))
86 xPanel = NumberFormatPropertyPanel::Create( pParent, xFrame, pBindings );
87 else if (rsResourceURL.endsWith("/NavigatorPanel"))
88 {
89 xPanel = std::make_unique<ScNavigatorDlg>(pBindings, pParent, nullptr);
90 nMinimumSize = 0;
91 }
92 else if (rsResourceURL.endsWith("/FunctionsPanel"))
93 {
94 xPanel = std::make_unique<ScFunctionWin>(pParent);
95 nMinimumSize = 0;
96 }
97
98 if (xPanel)
100 rsResourceURL,
101 xFrame,
102 std::move(xPanel),
103 ui::LayoutSize(nMinimumSize,-1,-1));
104 }
105 catch (const uno::RuntimeException &)
106 {
107 throw;
108 }
109 catch (const uno::Exception&)
110 {
111 css::uno::Any anyEx = cppu::getCaughtException();
112 throw lang::WrappedTargetRuntimeException(
113 "ScPanelFactory::createUIElement exception",
114 nullptr, anyEx);
115 }
116
117 return xElement;
118}
119
121{
122 return "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory";
123}
124
125sal_Bool ScPanelFactory::supportsService(OUString const & ServiceName)
126{
128}
129
130css::uno::Sequence<OUString> ScPanelFactory::getSupportedServiceNames()
131{
132 return { "com.sun.star.ui.UIElementFactory" };
133}
134
135} // end of namespace sc::sidebar
136
137extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
138ScPanelFactory_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
139{
140 return cppu::acquire(new sc::sidebar::ScPanelFactory());
141}
142
143/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ScPanelFactory_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
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, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, SfxBindings *pBindings)
virtual ~ScPanelFactory() override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement(const OUString &rsResourceURL, const ::css::uno::Sequence< css::beans::PropertyValue > &rArguments) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OUString SAL_CALL getImplementationName() override
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)
Sequence< PropertyValue > aArguments
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Any SAL_CALL getCaughtException()
Reference< XFrame > xFrame
unsigned char sal_Bool