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 "ScPanelFactory.hxx"
22 #include <AlignmentPropertyPanel.hxx>
23 #include <CellAppearancePropertyPanel.hxx>
24 #include <NumberFormatPropertyPanel.hxx>
26 #include <dwfunctr.hxx>
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 <comphelper/namedvaluecollection.hxx>
36 #include <boost/bind.hpp>
41 using ::rtl::OUString
;
44 namespace sc
{ namespace sidebar
{
46 #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory"
47 #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
50 ::rtl::OUString SAL_CALL
ScPanelFactory::getImplementationName (void)
52 return OUString(IMPLEMENTATION_NAME
);
56 cssu::Reference
<cssu::XInterface
> SAL_CALL
ScPanelFactory::createInstance(
57 const uno::Reference
<lang::XMultiServiceFactory
>& )
59 ::rtl::Reference
<ScPanelFactory
> pPanelFactory (new ScPanelFactory());
60 cssu::Reference
<cssu::XInterface
> xService (static_cast<XWeak
*>(pPanelFactory
.get()), cssu::UNO_QUERY
);
65 cssu::Sequence
<OUString
> SAL_CALL
ScPanelFactory::getSupportedServiceNames (void)
67 cssu::Sequence
<OUString
> aServiceNames (1);
68 aServiceNames
[0] = SERVICE_NAME
;
74 ScPanelFactory::ScPanelFactory (void)
75 : PanelFactoryInterfaceBase(m_aMutex
)
80 ScPanelFactory::~ScPanelFactory (void)
85 Reference
<ui::XUIElement
> SAL_CALL
ScPanelFactory::createUIElement (
86 const ::rtl::OUString
& rsResourceURL
,
87 const ::cssu::Sequence
<css::beans::PropertyValue
>& rArguments
)
89 container::NoSuchElementException
,
90 lang::IllegalArgumentException
,
93 Reference
<ui::XUIElement
> xElement
;
95 const ::comphelper::NamedValueCollection
aArguments (rArguments
);
96 Reference
<frame::XFrame
> xFrame (aArguments
.getOrDefault("Frame", Reference
<frame::XFrame
>()));
97 Reference
<awt::XWindow
> xParentWindow (aArguments
.getOrDefault("ParentWindow", Reference
<awt::XWindow
>()));
98 const sal_uInt64
nBindingsValue (aArguments
.getOrDefault("SfxBindings", sal_uInt64(0)));
99 SfxBindings
* pBindings
= reinterpret_cast<SfxBindings
*>(nBindingsValue
);
101 ::Window
* pParentWindow
= VCLUnoHelper::GetWindow(xParentWindow
);
102 if ( ! xParentWindow
.is() || pParentWindow
==NULL
)
103 throw RuntimeException(
104 "PanelFactory::createUIElement called without ParentWindow",
107 throw RuntimeException(
108 "PanelFactory::createUIElement called without Frame",
110 if (pBindings
== NULL
)
111 throw RuntimeException(
112 "PanelFactory::createUIElement called without SfxBindings",
115 #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
116 if (DoesResourceEndWith("/AlignmentPropertyPanel"))
118 AlignmentPropertyPanel
* pPanel
= AlignmentPropertyPanel::Create( pParentWindow
, xFrame
, pBindings
);
119 xElement
= sfx2::sidebar::SidebarPanelBase::Create(
123 ui::LayoutSize(-1,-1,-1));
125 else if (DoesResourceEndWith("/CellAppearancePropertyPanel"))
127 CellAppearancePropertyPanel
* pPanel
= CellAppearancePropertyPanel::Create( pParentWindow
, xFrame
, pBindings
);
128 xElement
= sfx2::sidebar::SidebarPanelBase::Create(
132 ui::LayoutSize(-1,-1,-1));
134 else if (DoesResourceEndWith("/NumberFormatPropertyPanel"))
136 NumberFormatPropertyPanel
* pPanel
= NumberFormatPropertyPanel::Create( pParentWindow
, xFrame
, pBindings
);
137 xElement
= sfx2::sidebar::SidebarPanelBase::Create(
141 ui::LayoutSize(-1,-1,-1));
143 else if (DoesResourceEndWith("/NavigatorPanel"))
145 Window
* pPanel
= new ScNavigatorDlg(pBindings
, NULL
, pParentWindow
, false);
146 xElement
= sfx2::sidebar::SidebarPanelBase::Create(
150 ui::LayoutSize(0,-1,-1));
152 else if (DoesResourceEndWith("/FunctionsPanel"))
154 Window
* pPanel
= new ScFunctionDockWin(pBindings
, NULL
, pParentWindow
, ScResId(FID_FUNCTION_BOX
));
155 xElement
= sfx2::sidebar::SidebarPanelBase::Create(
159 ui::LayoutSize(0,-1,-1));
161 #undef DoesResourceEndWith
166 } } // end of namespace sc::sidebar
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */