1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "Chart2PanelFactory.hxx"
22 #include <sfx2/sidebar/SidebarPanelBase.hxx>
23 #include <toolkit/helper/vclunohelper.hxx>
24 #include <vcl/window.hxx>
25 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
26 #include <cppuhelper/exc_hlp.hxx>
27 #include <comphelper/namedvaluecollection.hxx>
28 #include <cppuhelper/supportsservice.hxx>
30 #include "ChartElementsPanel.hxx"
31 #include "ChartTypePanel.hxx"
32 #include "ChartSeriesPanel.hxx"
33 #include <ChartController.hxx>
34 #include "ChartAxisPanel.hxx"
35 #include "ChartErrorBarPanel.hxx"
36 #include "ChartAreaPanel.hxx"
37 #include "ChartLinePanel.hxx"
39 using namespace css::uno
;
41 namespace chart
{ namespace sidebar
{
43 ChartPanelFactory::ChartPanelFactory()
44 : PanelFactoryInterfaceBase(m_aMutex
)
48 ChartPanelFactory::~ChartPanelFactory()
52 Reference
<css::ui::XUIElement
> SAL_CALL
ChartPanelFactory::createUIElement (
53 const OUString
& rsResourceURL
,
54 const ::css::uno::Sequence
<css::beans::PropertyValue
>& rArguments
)
56 Reference
<css::ui::XUIElement
> xElement
;
60 const ::comphelper::NamedValueCollection
aArguments (rArguments
);
61 Reference
<css::frame::XFrame
> xFrame (aArguments
.getOrDefault("Frame", Reference
<css::frame::XFrame
>()));
62 Reference
<css::awt::XWindow
> xParentWindow (aArguments
.getOrDefault("ParentWindow", Reference
<css::awt::XWindow
>()));
63 Reference
<css::frame::XController
> xController (aArguments
.getOrDefault("Controller", Reference
<css::frame::XController
>()));
65 VclPtr
<vcl::Window
> pParentWindow
= VCLUnoHelper::GetWindow(xParentWindow
);
66 if ( ! xParentWindow
.is() || pParentWindow
==nullptr)
67 throw RuntimeException(
68 "PanelFactory::createUIElement called without ParentWindow",
71 throw RuntimeException(
72 "PanelFactory::createUIElement called without Frame",
74 if (!xController
.is())
75 throw RuntimeException(
76 "ChartPanelFactory::createUIElement called without Controller",
79 ChartController
* pController
= dynamic_cast<ChartController
*>(xController
.get());
81 throw RuntimeException(
82 "ChartPanelFactory::createUIElement called without valid ChartController",
85 VclPtr
<vcl::Window
> pPanel
;
86 if (rsResourceURL
.endsWith("/ElementsPanel"))
87 pPanel
= ChartElementsPanel::Create( pParentWindow
, xFrame
, pController
);
88 else if (rsResourceURL
.endsWith("/TypePanel"))
90 //pPanel = ChartTypePanel::Create( pParentWindow, xFrame, pController );
91 VclPtrInstance
<ChartTypePanel
> ppPanel(pParentWindow
, xFrame
, pController
);
92 xElement
= sfx2::sidebar::SidebarPanelBase::Create(
96 css::ui::LayoutSize(-1,-1,-1));
98 else if (rsResourceURL
.endsWith("/SeriesPanel"))
99 pPanel
= ChartSeriesPanel::Create(pParentWindow
, xFrame
, pController
);
100 else if (rsResourceURL
.endsWith("/AxisPanel"))
101 pPanel
= ChartAxisPanel::Create(pParentWindow
, xFrame
, pController
);
102 else if (rsResourceURL
.endsWith("/ErrorBarPanel"))
103 pPanel
= ChartErrorBarPanel::Create(pParentWindow
, xFrame
, pController
);
104 else if (rsResourceURL
.endsWith("/AreaPanel"))
105 pPanel
= ChartAreaPanel::Create(pParentWindow
, xFrame
, pController
);
106 else if (rsResourceURL
.endsWith("/LinePanel"))
107 pPanel
= ChartLinePanel::Create(pParentWindow
, xFrame
, pController
);
110 xElement
= sfx2::sidebar::SidebarPanelBase::Create(
114 css::ui::LayoutSize(-1,-1,-1));
116 catch (const css::uno::RuntimeException
&)
120 catch (const css::uno::Exception
&)
122 css::uno::Any anyEx
= cppu::getCaughtException();
123 throw css::lang::WrappedTargetRuntimeException(
124 "ChartPanelFactory::createUIElement exception",
131 OUString
ChartPanelFactory::getImplementationName()
133 return "org.libreoffice.comp.chart2.sidebar.ChartPanelFactory";
136 sal_Bool
ChartPanelFactory::supportsService(OUString
const & ServiceName
)
138 return cppu::supportsService(this, ServiceName
);
141 css::uno::Sequence
<OUString
> ChartPanelFactory::getSupportedServiceNames()
143 return { "com.sun.star.ui.UIElementFactory" };
146 } } // end of namespace chart::sidebar
148 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
149 org_libreoffice_comp_chart2_sidebar_ChartPanelFactory(css::uno::XComponentContext
*, css::uno::Sequence
<css::uno::Any
> const &)
151 return cppu::acquire(new ::chart::sidebar::ChartPanelFactory());
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */