fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / sidebar / ScPanelFactory.cxx
blob7857685aa1c28a83b049d349de52f0e449e6a64e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "ScPanelFactory.hxx"
22 #include "AlignmentPropertyPanel.hxx"
23 #include "CellAppearancePropertyPanel.hxx"
24 #include "NumberFormatPropertyPanel.hxx"
25 #include <navipi.hxx>
26 #include <dwfunctr.hxx>
27 #include "sc.hrc"
29 #include <sfx2/sidebar/SidebarPanelBase.hxx>
30 #include <sfx2/sfxbasecontroller.hxx>
31 #include <toolkit/helper/vclunohelper.hxx>
32 #include <vcl/window.hxx>
33 #include <rtl/ref.hxx>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
36 #include <comphelper/namedvaluecollection.hxx>
37 #include <cppuhelper/supportsservice.hxx>
38 #include <boost/bind.hpp>
40 using namespace css;
41 using namespace css::uno;
42 using ::rtl::OUString;
44 namespace sc { namespace sidebar {
46 ScPanelFactory::ScPanelFactory()
47 : PanelFactoryInterfaceBase(m_aMutex)
51 ScPanelFactory::~ScPanelFactory()
55 Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
56 const ::rtl::OUString& rsResourceURL,
57 const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
58 throw(
59 container::NoSuchElementException,
60 lang::IllegalArgumentException,
61 RuntimeException, std::exception)
63 Reference<ui::XUIElement> xElement;
65 try
67 const ::comphelper::NamedValueCollection aArguments (rArguments);
68 Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
69 Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
70 const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
71 SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
73 vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
74 if ( ! xParentWindow.is() || pParentWindow==NULL)
75 throw RuntimeException(
76 "PanelFactory::createUIElement called without ParentWindow",
77 NULL);
78 if ( ! xFrame.is())
79 throw RuntimeException(
80 "PanelFactory::createUIElement called without Frame",
81 NULL);
82 if (pBindings == NULL)
83 throw RuntimeException(
84 "PanelFactory::createUIElement called without SfxBindings",
85 NULL);
87 sal_Int32 nMinimumSize = -1;
88 VclPtr<vcl::Window> pPanel;
89 if (rsResourceURL.endsWith("/AlignmentPropertyPanel"))
90 pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings );
91 else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel"))
92 pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
93 else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel"))
94 pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings );
95 else if (rsResourceURL.endsWith("/NavigatorPanel"))
97 pPanel = VclPtr<ScNavigatorDlg>::Create(pBindings, nullptr, pParentWindow, false);
98 nMinimumSize = 0;
100 else if (rsResourceURL.endsWith("/FunctionsPanel"))
102 pPanel = VclPtr<ScFunctionDockWin>::Create(pBindings, nullptr, pParentWindow, ScResId(FID_FUNCTION_BOX));
103 nMinimumSize = 0;
106 if (pPanel)
107 xElement = sfx2::sidebar::SidebarPanelBase::Create(
108 rsResourceURL,
109 xFrame,
110 pPanel,
111 ui::LayoutSize(nMinimumSize,-1,-1));
113 catch (const uno::RuntimeException &)
115 throw;
117 catch (const uno::Exception& e)
119 throw lang::WrappedTargetRuntimeException(
120 OUString("ScPanelFactory::createUIElement exception"),
121 0, uno::makeAny(e));
124 return xElement;
127 OUString ScPanelFactory::getImplementationName()
128 throw (css::uno::RuntimeException, std::exception)
130 return OUString("org.apache.openoffice.comp.sc.sidebar.ScPanelFactory");
133 sal_Bool ScPanelFactory::supportsService(OUString const & ServiceName)
134 throw (css::uno::RuntimeException, std::exception)
136 return cppu::supportsService(this, ServiceName);
139 css::uno::Sequence<OUString> ScPanelFactory::getSupportedServiceNames()
140 throw (css::uno::RuntimeException, std::exception)
142 css::uno::Sequence<OUString> aServiceNames(1);
143 aServiceNames[0] = "com.sun.star.ui.UIElementFactory";
144 return aServiceNames;
147 } } // end of namespace sc::sidebar
149 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* SAL_CALL
150 ScPanelFactory_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
152 return cppu::acquire(new sc::sidebar::ScPanelFactory());
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */