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
22*8e9b0a85Smseidel
23*8e9b0a85Smseidel
24facb16e7SArmin Le Grand #include "precompiled_sc.hxx"
25facb16e7SArmin Le Grand
26facb16e7SArmin Le Grand #include "ScPanelFactory.hxx"
27facb16e7SArmin Le Grand
28facb16e7SArmin Le Grand #include <AlignmentPropertyPanel.hxx>
29facb16e7SArmin Le Grand #include <CellAppearancePropertyPanel.hxx>
304e8031e0SArmin Le Grand #include <NumberFormatPropertyPanel.hxx>
313c226292SAndre Fischer #include <navipi.hxx>
324847afebSAndre Fischer #include <dwfunctr.hxx>
334847afebSAndre Fischer #include "sc.hrc"
34facb16e7SArmin Le Grand
35facb16e7SArmin Le Grand #include <sfx2/sidebar/SidebarPanelBase.hxx>
36facb16e7SArmin Le Grand #include <sfx2/sfxbasecontroller.hxx>
37facb16e7SArmin Le Grand #include <toolkit/helper/vclunohelper.hxx>
38facb16e7SArmin Le Grand #include <vcl/window.hxx>
39facb16e7SArmin Le Grand #include <rtl/ref.hxx>
40facb16e7SArmin Le Grand #include <comphelper/namedvaluecollection.hxx>
41facb16e7SArmin Le Grand
42facb16e7SArmin Le Grand #include <boost/bind.hpp>
43facb16e7SArmin Le Grand
44facb16e7SArmin Le Grand
45facb16e7SArmin Le Grand using namespace css;
46facb16e7SArmin Le Grand using namespace cssu;
47facb16e7SArmin Le Grand using ::rtl::OUString;
48facb16e7SArmin Le Grand
49facb16e7SArmin Le Grand
50facb16e7SArmin Le Grand namespace sc { namespace sidebar {
51facb16e7SArmin Le Grand
52facb16e7SArmin Le Grand #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
53facb16e7SArmin Le Grand #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory"
54facb16e7SArmin Le Grand #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
55facb16e7SArmin Le Grand
56facb16e7SArmin Le Grand
getImplementationName(void)57facb16e7SArmin Le Grand ::rtl::OUString SAL_CALL ScPanelFactory::getImplementationName (void)
58facb16e7SArmin Le Grand {
59facb16e7SArmin Le Grand return A2S(IMPLEMENTATION_NAME);
60facb16e7SArmin Le Grand }
61facb16e7SArmin Le Grand
62facb16e7SArmin Le Grand
createInstance(const uno::Reference<lang::XMultiServiceFactory> &)63facb16e7SArmin Le Grand cssu::Reference<cssu::XInterface> SAL_CALL ScPanelFactory::createInstance(
64facb16e7SArmin Le Grand const uno::Reference<lang::XMultiServiceFactory>& )
65facb16e7SArmin Le Grand {
66facb16e7SArmin Le Grand ::rtl::Reference<ScPanelFactory> pPanelFactory (new ScPanelFactory());
67facb16e7SArmin Le Grand cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY);
68facb16e7SArmin Le Grand return xService;
69facb16e7SArmin Le Grand }
70facb16e7SArmin Le Grand
71facb16e7SArmin Le Grand
getSupportedServiceNames(void)72facb16e7SArmin Le Grand cssu::Sequence<OUString> SAL_CALL ScPanelFactory::getSupportedServiceNames (void)
73facb16e7SArmin Le Grand {
74facb16e7SArmin Le Grand cssu::Sequence<OUString> aServiceNames (1);
75facb16e7SArmin Le Grand aServiceNames[0] = A2S(SERVICE_NAME);
76facb16e7SArmin Le Grand return aServiceNames;
77facb16e7SArmin Le Grand
78facb16e7SArmin Le Grand }
79facb16e7SArmin Le Grand
80facb16e7SArmin Le Grand
ScPanelFactory(void)81facb16e7SArmin Le Grand ScPanelFactory::ScPanelFactory (void)
82facb16e7SArmin Le Grand : PanelFactoryInterfaceBase(m_aMutex)
83facb16e7SArmin Le Grand {
84facb16e7SArmin Le Grand }
85facb16e7SArmin Le Grand
86facb16e7SArmin Le Grand
~ScPanelFactory(void)87facb16e7SArmin Le Grand ScPanelFactory::~ScPanelFactory (void)
88facb16e7SArmin Le Grand {
89facb16e7SArmin Le Grand }
90facb16e7SArmin Le Grand
91facb16e7SArmin Le Grand
createUIElement(const::rtl::OUString & rsResourceURL,const::cssu::Sequence<css::beans::PropertyValue> & rArguments)92facb16e7SArmin Le Grand Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
93facb16e7SArmin Le Grand const ::rtl::OUString& rsResourceURL,
94facb16e7SArmin Le Grand const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
95facb16e7SArmin Le Grand throw(
96facb16e7SArmin Le Grand container::NoSuchElementException,
97facb16e7SArmin Le Grand lang::IllegalArgumentException,
98facb16e7SArmin Le Grand RuntimeException)
99facb16e7SArmin Le Grand {
100facb16e7SArmin Le Grand Reference<ui::XUIElement> xElement;
101facb16e7SArmin Le Grand
102facb16e7SArmin Le Grand const ::comphelper::NamedValueCollection aArguments (rArguments);
103facb16e7SArmin Le Grand Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
104facb16e7SArmin Le Grand Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
105facb16e7SArmin Le Grand const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
106facb16e7SArmin Le Grand SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
107facb16e7SArmin Le Grand
108facb16e7SArmin Le Grand ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
109facb16e7SArmin Le Grand if ( ! xParentWindow.is() || pParentWindow==NULL)
110facb16e7SArmin Le Grand throw RuntimeException(
111facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without ParentWindow"),
112facb16e7SArmin Le Grand NULL);
113facb16e7SArmin Le Grand if ( ! xFrame.is())
114facb16e7SArmin Le Grand throw RuntimeException(
115facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without Frame"),
116facb16e7SArmin Le Grand NULL);
117facb16e7SArmin Le Grand if (pBindings == NULL)
118facb16e7SArmin Le Grand throw RuntimeException(
119facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without SfxBindings"),
120facb16e7SArmin Le Grand NULL);
121facb16e7SArmin Le Grand
122facb16e7SArmin Le Grand #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
123facb16e7SArmin Le Grand if (DoesResourceEndWith("/AlignmentPropertyPanel"))
124facb16e7SArmin Le Grand {
125facb16e7SArmin Le Grand AlignmentPropertyPanel* pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings );
126facb16e7SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create(
127facb16e7SArmin Le Grand rsResourceURL,
128facb16e7SArmin Le Grand xFrame,
129facb16e7SArmin Le Grand pPanel,
130facb16e7SArmin Le Grand ui::LayoutSize(-1,-1,-1));
131facb16e7SArmin Le Grand }
1324e8031e0SArmin Le Grand else if (DoesResourceEndWith("/CellAppearancePropertyPanel"))
133facb16e7SArmin Le Grand {
134facb16e7SArmin Le Grand CellAppearancePropertyPanel* pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
135facb16e7SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create(
136facb16e7SArmin Le Grand rsResourceURL,
137facb16e7SArmin Le Grand xFrame,
138facb16e7SArmin Le Grand pPanel,
139facb16e7SArmin Le Grand ui::LayoutSize(-1,-1,-1));
140facb16e7SArmin Le Grand }
1414e8031e0SArmin Le Grand else if (DoesResourceEndWith("/NumberFormatPropertyPanel"))
1424e8031e0SArmin Le Grand {
1434e8031e0SArmin Le Grand NumberFormatPropertyPanel* pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings );
1444e8031e0SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create(
1454e8031e0SArmin Le Grand rsResourceURL,
1464e8031e0SArmin Le Grand xFrame,
1474e8031e0SArmin Le Grand pPanel,
1484e8031e0SArmin Le Grand ui::LayoutSize(-1,-1,-1));
1494e8031e0SArmin Le Grand }
1503c226292SAndre Fischer else if (DoesResourceEndWith("/NavigatorPanel"))
1513c226292SAndre Fischer {
15237fee4fdSAndre Fischer Window* pPanel = new ScNavigatorDlg(pBindings, NULL, pParentWindow, false);
1533c226292SAndre Fischer xElement = sfx2::sidebar::SidebarPanelBase::Create(
1543c226292SAndre Fischer rsResourceURL,
1553c226292SAndre Fischer xFrame,
1563c226292SAndre Fischer pPanel,
1573c226292SAndre Fischer ui::LayoutSize(0,-1,-1));
1583c226292SAndre Fischer }
1594847afebSAndre Fischer else if (DoesResourceEndWith("/FunctionsPanel"))
1604847afebSAndre Fischer {
1614847afebSAndre Fischer Window* pPanel = new ScFunctionDockWin(pBindings, NULL, pParentWindow, ScResId(FID_FUNCTION_BOX));
1624847afebSAndre Fischer xElement = sfx2::sidebar::SidebarPanelBase::Create(
1634847afebSAndre Fischer rsResourceURL,
1644847afebSAndre Fischer xFrame,
1654847afebSAndre Fischer pPanel,
1664847afebSAndre Fischer ui::LayoutSize(0,-1,-1));
1674847afebSAndre Fischer }
168facb16e7SArmin Le Grand #undef DoesResourceEndWith
169facb16e7SArmin Le Grand
170facb16e7SArmin Le Grand return xElement;
171facb16e7SArmin Le Grand }
172facb16e7SArmin Le Grand
173facb16e7SArmin Le Grand } } // end of namespace sc::sidebar
174facb16e7SArmin Le Grand
175*8e9b0a85Smseidel /* vim: set noet sw=4 ts=4: */
176