1facb16e7SArmin Le Grand /**************************************************************
2facb16e7SArmin Le Grand *
3facb16e7SArmin Le Grand * Licensed to the Apache Software Foundation (ASF) under one
4facb16e7SArmin Le Grand * or more contributor license agreements. See the NOTICE file
5facb16e7SArmin Le Grand * distributed with this work for additional information
6facb16e7SArmin Le Grand * regarding copyright ownership. The ASF licenses this file
7facb16e7SArmin Le Grand * to you under the Apache License, Version 2.0 (the
8facb16e7SArmin Le Grand * "License"); you may not use this file except in compliance
9facb16e7SArmin Le Grand * with the License. You may obtain a copy of the License at
10facb16e7SArmin Le Grand *
11facb16e7SArmin Le Grand * http://www.apache.org/licenses/LICENSE-2.0
12facb16e7SArmin Le Grand *
13facb16e7SArmin Le Grand * Unless required by applicable law or agreed to in writing,
14facb16e7SArmin Le Grand * software distributed under the License is distributed on an
15facb16e7SArmin Le Grand * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16facb16e7SArmin Le Grand * KIND, either express or implied. See the License for the
17facb16e7SArmin Le Grand * specific language governing permissions and limitations
18facb16e7SArmin Le Grand * under the License.
19facb16e7SArmin Le Grand *
20facb16e7SArmin Le Grand *************************************************************/
21facb16e7SArmin Le Grand
22facb16e7SArmin Le Grand #include "precompiled_sc.hxx"
23facb16e7SArmin Le Grand
24facb16e7SArmin Le Grand #include "ScPanelFactory.hxx"
25facb16e7SArmin Le Grand
26facb16e7SArmin Le Grand #include <AlignmentPropertyPanel.hxx>
27facb16e7SArmin Le Grand #include <CellAppearancePropertyPanel.hxx>
284e8031e0SArmin Le Grand #include <NumberFormatPropertyPanel.hxx>
293c226292SAndre Fischer #include <navipi.hxx>
304847afebSAndre Fischer #include <dwfunctr.hxx>
314847afebSAndre Fischer #include "sc.hrc"
32facb16e7SArmin Le Grand
33facb16e7SArmin Le Grand #include <sfx2/sidebar/SidebarPanelBase.hxx>
34facb16e7SArmin Le Grand #include <sfx2/sfxbasecontroller.hxx>
35facb16e7SArmin Le Grand #include <toolkit/helper/vclunohelper.hxx>
36facb16e7SArmin Le Grand #include <vcl/window.hxx>
37facb16e7SArmin Le Grand #include <rtl/ref.hxx>
38facb16e7SArmin Le Grand #include <comphelper/namedvaluecollection.hxx>
39facb16e7SArmin Le Grand
40facb16e7SArmin Le Grand #include <boost/bind.hpp>
41facb16e7SArmin Le Grand
42facb16e7SArmin Le Grand
43facb16e7SArmin Le Grand using namespace css;
44facb16e7SArmin Le Grand using namespace cssu;
45facb16e7SArmin Le Grand using ::rtl::OUString;
46facb16e7SArmin Le Grand
47facb16e7SArmin Le Grand
48facb16e7SArmin Le Grand namespace sc { namespace sidebar {
49facb16e7SArmin Le Grand
50facb16e7SArmin Le Grand #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
51facb16e7SArmin Le Grand #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory"
52facb16e7SArmin Le Grand #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
53facb16e7SArmin Le Grand
54facb16e7SArmin Le Grand
getImplementationName(void)55facb16e7SArmin Le Grand ::rtl::OUString SAL_CALL ScPanelFactory::getImplementationName (void)
56facb16e7SArmin Le Grand {
57facb16e7SArmin Le Grand return A2S(IMPLEMENTATION_NAME);
58facb16e7SArmin Le Grand }
59facb16e7SArmin Le Grand
60facb16e7SArmin Le Grand
createInstance(const uno::Reference<lang::XMultiServiceFactory> &)61facb16e7SArmin Le Grand cssu::Reference<cssu::XInterface> SAL_CALL ScPanelFactory::createInstance(
62facb16e7SArmin Le Grand const uno::Reference<lang::XMultiServiceFactory>& )
63facb16e7SArmin Le Grand {
64facb16e7SArmin Le Grand ::rtl::Reference<ScPanelFactory> pPanelFactory (new ScPanelFactory());
65facb16e7SArmin Le Grand cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY);
66facb16e7SArmin Le Grand return xService;
67facb16e7SArmin Le Grand }
68facb16e7SArmin Le Grand
69facb16e7SArmin Le Grand
getSupportedServiceNames(void)70facb16e7SArmin Le Grand cssu::Sequence<OUString> SAL_CALL ScPanelFactory::getSupportedServiceNames (void)
71facb16e7SArmin Le Grand {
72facb16e7SArmin Le Grand cssu::Sequence<OUString> aServiceNames (1);
73facb16e7SArmin Le Grand aServiceNames[0] = A2S(SERVICE_NAME);
74facb16e7SArmin Le Grand return aServiceNames;
75facb16e7SArmin Le Grand
76facb16e7SArmin Le Grand }
77facb16e7SArmin Le Grand
78facb16e7SArmin Le Grand
ScPanelFactory(void)79facb16e7SArmin Le Grand ScPanelFactory::ScPanelFactory (void)
80facb16e7SArmin Le Grand : PanelFactoryInterfaceBase(m_aMutex)
81facb16e7SArmin Le Grand {
82facb16e7SArmin Le Grand }
83facb16e7SArmin Le Grand
84facb16e7SArmin Le Grand
~ScPanelFactory(void)85facb16e7SArmin Le Grand ScPanelFactory::~ScPanelFactory (void)
86facb16e7SArmin Le Grand {
87facb16e7SArmin Le Grand }
88facb16e7SArmin Le Grand
89facb16e7SArmin Le Grand
createUIElement(const::rtl::OUString & rsResourceURL,const::cssu::Sequence<css::beans::PropertyValue> & rArguments)90facb16e7SArmin Le Grand Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
91facb16e7SArmin Le Grand const ::rtl::OUString& rsResourceURL,
92facb16e7SArmin Le Grand const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
93facb16e7SArmin Le Grand throw(
94facb16e7SArmin Le Grand container::NoSuchElementException,
95facb16e7SArmin Le Grand lang::IllegalArgumentException,
96facb16e7SArmin Le Grand RuntimeException)
97facb16e7SArmin Le Grand {
98facb16e7SArmin Le Grand Reference<ui::XUIElement> xElement;
99facb16e7SArmin Le Grand
100facb16e7SArmin Le Grand const ::comphelper::NamedValueCollection aArguments (rArguments);
101facb16e7SArmin Le Grand Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
102facb16e7SArmin Le Grand Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
103facb16e7SArmin Le Grand const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
104facb16e7SArmin Le Grand SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
105facb16e7SArmin Le Grand
106facb16e7SArmin Le Grand ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
107facb16e7SArmin Le Grand if ( ! xParentWindow.is() || pParentWindow==NULL)
108facb16e7SArmin Le Grand throw RuntimeException(
109facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without ParentWindow"),
110facb16e7SArmin Le Grand NULL);
111facb16e7SArmin Le Grand if ( ! xFrame.is())
112facb16e7SArmin Le Grand throw RuntimeException(
113facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without Frame"),
114facb16e7SArmin Le Grand NULL);
115facb16e7SArmin Le Grand if (pBindings == NULL)
116facb16e7SArmin Le Grand throw RuntimeException(
117facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without SfxBindings"),
118facb16e7SArmin Le Grand NULL);
119facb16e7SArmin Le Grand
120facb16e7SArmin Le Grand #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
121facb16e7SArmin Le Grand if (DoesResourceEndWith("/AlignmentPropertyPanel"))
122facb16e7SArmin Le Grand {
123facb16e7SArmin Le Grand AlignmentPropertyPanel* pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings );
124facb16e7SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create(
125facb16e7SArmin Le Grand rsResourceURL,
126facb16e7SArmin Le Grand xFrame,
127facb16e7SArmin Le Grand pPanel,
128facb16e7SArmin Le Grand ui::LayoutSize(-1,-1,-1));
129facb16e7SArmin Le Grand }
1304e8031e0SArmin Le Grand else if (DoesResourceEndWith("/CellAppearancePropertyPanel"))
131facb16e7SArmin Le Grand {
132facb16e7SArmin Le Grand CellAppearancePropertyPanel* pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
133facb16e7SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create(
134facb16e7SArmin Le Grand rsResourceURL,
135facb16e7SArmin Le Grand xFrame,
136facb16e7SArmin Le Grand pPanel,
137facb16e7SArmin Le Grand ui::LayoutSize(-1,-1,-1));
138facb16e7SArmin Le Grand }
1394e8031e0SArmin Le Grand else if (DoesResourceEndWith("/NumberFormatPropertyPanel"))
1404e8031e0SArmin Le Grand {
1414e8031e0SArmin Le Grand NumberFormatPropertyPanel* pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings );
1424e8031e0SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create(
1434e8031e0SArmin Le Grand rsResourceURL,
1444e8031e0SArmin Le Grand xFrame,
1454e8031e0SArmin Le Grand pPanel,
1464e8031e0SArmin Le Grand ui::LayoutSize(-1,-1,-1));
1474e8031e0SArmin Le Grand }
1483c226292SAndre Fischer else if (DoesResourceEndWith("/NavigatorPanel"))
1493c226292SAndre Fischer {
150*37fee4fdSAndre Fischer Window* pPanel = new ScNavigatorDlg(pBindings, NULL, pParentWindow, false);
1513c226292SAndre Fischer xElement = sfx2::sidebar::SidebarPanelBase::Create(
1523c226292SAndre Fischer rsResourceURL,
1533c226292SAndre Fischer xFrame,
1543c226292SAndre Fischer pPanel,
1553c226292SAndre Fischer ui::LayoutSize(0,-1,-1));
1563c226292SAndre Fischer }
1574847afebSAndre Fischer else if (DoesResourceEndWith("/FunctionsPanel"))
1584847afebSAndre Fischer {
1594847afebSAndre Fischer Window* pPanel = new ScFunctionDockWin(pBindings, NULL, pParentWindow, ScResId(FID_FUNCTION_BOX));
1604847afebSAndre Fischer xElement = sfx2::sidebar::SidebarPanelBase::Create(
1614847afebSAndre Fischer rsResourceURL,
1624847afebSAndre Fischer xFrame,
1634847afebSAndre Fischer pPanel,
1644847afebSAndre Fischer ui::LayoutSize(0,-1,-1));
1654847afebSAndre Fischer }
166facb16e7SArmin Le Grand #undef DoesResourceEndWith
167facb16e7SArmin Le Grand
168facb16e7SArmin Le Grand return xElement;
169facb16e7SArmin Le Grand }
170facb16e7SArmin Le Grand
171facb16e7SArmin Le Grand } } // end of namespace sc::sidebar
172facb16e7SArmin Le Grand
173facb16e7SArmin Le Grand // eof
174