2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "ScPanelFactory.hxx"
21 #include <AlignmentPropertyPanel.hxx>
22 #include <CellAppearancePropertyPanel.hxx>
23 #include <NumberFormatPropertyPanel.hxx>
25 #include <dwfunctr.hxx>
28 #include <sfx2/sidebar/SidebarPanelBase.hxx>
29 #include <sfx2/sfxbasecontroller.hxx>
30 #include <toolkit/helper/vclunohelper.hxx>
31 #include <vcl/window.hxx>
32 #include <rtl/ref.hxx>
33 #include <comphelper/namedvaluecollection.hxx>
35 #include <boost/bind.hpp>
40 using ::rtl::OUString
;
43 namespace sc
{ namespace sidebar
{
45 #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
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 A2S(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] = A2S(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 A2S("PanelFactory::createUIElement called without ParentWindow"),
107 throw RuntimeException(
108 A2S("PanelFactory::createUIElement called without Frame"),
110 if (pBindings
== NULL
)
111 throw RuntimeException(
112 A2S("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