LibreOffice Module chart2 (master) 1
Chart2PanelFactory.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
21
23#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
27#include <vcl/weldutils.hxx>
28
30#include "ChartTypePanel.hxx"
31#include "ChartSeriesPanel.hxx"
32#include <ChartController.hxx>
33#include "ChartAxisPanel.hxx"
35#include "ChartAreaPanel.hxx"
36#include "ChartLinePanel.hxx"
37
38using namespace css::uno;
39
40namespace chart::sidebar {
41
43{
44}
45
47{
48}
49
51 const OUString& rsResourceURL,
52 const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
53{
55
56 try
57 {
58 const ::comphelper::NamedValueCollection aArguments (rArguments);
60 Reference<css::awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<css::awt::XWindow>()));
62
63 weld::Widget* pParent(nullptr);
64 if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
65 pParent = pTunnel->getWidget();
66
67 if (!pParent)
68 throw RuntimeException(
69 "PanelFactory::createUIElement called without ParentWindow",
70 nullptr);
71 if ( ! xFrame.is())
72 throw RuntimeException(
73 "PanelFactory::createUIElement called without Frame",
74 nullptr);
75 if (!xController.is())
76 throw RuntimeException(
77 "ChartPanelFactory::createUIElement called without Controller",
78 nullptr);
79
80 ChartController* pController = dynamic_cast<ChartController*>(xController.get());
81 if (!pController)
82 throw RuntimeException(
83 "ChartPanelFactory::createUIElement called without valid ChartController",
84 nullptr);
85
86 std::unique_ptr<PanelLayout> xPanel;
87 if (rsResourceURL.endsWith("/ElementsPanel"))
88 xPanel = ChartElementsPanel::Create( pParent, pController );
89 else if (rsResourceURL.endsWith("/TypePanel"))
90 xPanel = std::make_unique<ChartTypePanel>(pParent, pController);
91 else if (rsResourceURL.endsWith("/SeriesPanel"))
92 xPanel = ChartSeriesPanel::Create(pParent, pController);
93 else if (rsResourceURL.endsWith("/AxisPanel"))
94 xPanel = ChartAxisPanel::Create(pParent, pController);
95 else if (rsResourceURL.endsWith("/ErrorBarPanel"))
96 xPanel = ChartErrorBarPanel::Create(pParent, pController);
97 else if (rsResourceURL.endsWith("/AreaPanel"))
98 xPanel = ChartAreaPanel::Create(pParent, xFrame, pController);
99 else if (rsResourceURL.endsWith("/LinePanel"))
100 xPanel = ChartLinePanel::Create(pParent, xFrame, pController);
101
102 if (xPanel)
104 rsResourceURL,
105 xFrame,
106 std::move(xPanel),
107 css::ui::LayoutSize(-1,-1,-1));
108 }
109 catch (const css::uno::RuntimeException &)
110 {
111 throw;
112 }
113 catch (const css::uno::Exception&)
114 {
115 css::uno::Any anyEx = cppu::getCaughtException();
116 throw css::lang::WrappedTargetRuntimeException(
117 "ChartPanelFactory::createUIElement exception",
118 nullptr, anyEx );
119 }
120
121 return xElement;
122}
123
125{
126 return "org.libreoffice.comp.chart2.sidebar.ChartPanelFactory";
127}
128
129sal_Bool ChartPanelFactory::supportsService(OUString const & ServiceName)
130{
132}
133
135{
136 return { "com.sun.star.ui.UIElementFactory" };
137}
138
139} // end of namespace chart::sidebar
140
141extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
142org_libreoffice_comp_chart2_sidebar_ChartPanelFactory(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
143{
144 return cppu::acquire(new ::chart::sidebar::ChartPanelFactory());
145}
146
147/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_libreoffice_comp_chart2_sidebar_ChartPanelFactory(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, ChartController *pController)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, ChartController *pController)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, ChartController *pController)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, ChartController *pController)
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame, ChartController *pController)
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement(const OUString &rsResourceURL, const ::css::uno::Sequence< css::beans::PropertyValue > &rArguments) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, ChartController *pController)
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< XController > xController
Reference< XFrame > xFrame
unsigned char sal_Bool