1ff0525f2SOliver-Rainer Wittmann /**************************************************************
2*fb399032Smseidel *
3ff0525f2SOliver-Rainer Wittmann * Licensed to the Apache Software Foundation (ASF) under one
4ff0525f2SOliver-Rainer Wittmann * or more contributor license agreements. See the NOTICE file
5ff0525f2SOliver-Rainer Wittmann * distributed with this work for additional information
6ff0525f2SOliver-Rainer Wittmann * regarding copyright ownership. The ASF licenses this file
7ff0525f2SOliver-Rainer Wittmann * to you under the Apache License, Version 2.0 (the
8ff0525f2SOliver-Rainer Wittmann * "License"); you may not use this file except in compliance
9ff0525f2SOliver-Rainer Wittmann * with the License. You may obtain a copy of the License at
10*fb399032Smseidel *
11ff0525f2SOliver-Rainer Wittmann * http://www.apache.org/licenses/LICENSE-2.0
12*fb399032Smseidel *
13ff0525f2SOliver-Rainer Wittmann * Unless required by applicable law or agreed to in writing,
14ff0525f2SOliver-Rainer Wittmann * software distributed under the License is distributed on an
15ff0525f2SOliver-Rainer Wittmann * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ff0525f2SOliver-Rainer Wittmann * KIND, either express or implied. See the License for the
17ff0525f2SOliver-Rainer Wittmann * specific language governing permissions and limitations
18ff0525f2SOliver-Rainer Wittmann * under the License.
19*fb399032Smseidel *
20ff0525f2SOliver-Rainer Wittmann *************************************************************/
21ff0525f2SOliver-Rainer Wittmann
22*fb399032Smseidel
23*fb399032Smseidel
24ff0525f2SOliver-Rainer Wittmann #include "precompiled_sw.hxx"
25ff0525f2SOliver-Rainer Wittmann
26ff0525f2SOliver-Rainer Wittmann #include "SwPanelFactory.hxx"
27ff0525f2SOliver-Rainer Wittmann
28ff0525f2SOliver-Rainer Wittmann #include <PagePropertyPanel.hxx>
29721f296aSOliver-Rainer Wittmann #include <WrapPropertyPanel.hxx>
30b7d08b69SAndre Fischer #include <navipi.hxx>
31ff0525f2SOliver-Rainer Wittmann
32ff0525f2SOliver-Rainer Wittmann #include <sfx2/sidebar/SidebarPanelBase.hxx>
33ff0525f2SOliver-Rainer Wittmann #include <sfx2/sfxbasecontroller.hxx>
34ff0525f2SOliver-Rainer Wittmann #include <toolkit/helper/vclunohelper.hxx>
35ff0525f2SOliver-Rainer Wittmann #include <vcl/window.hxx>
36ff0525f2SOliver-Rainer Wittmann #include <rtl/ref.hxx>
37ff0525f2SOliver-Rainer Wittmann #include <comphelper/namedvaluecollection.hxx>
38ff0525f2SOliver-Rainer Wittmann
39ff0525f2SOliver-Rainer Wittmann #include <boost/bind.hpp>
40ff0525f2SOliver-Rainer Wittmann
41ff0525f2SOliver-Rainer Wittmann
42ff0525f2SOliver-Rainer Wittmann using namespace css;
43ff0525f2SOliver-Rainer Wittmann using namespace cssu;
44ff0525f2SOliver-Rainer Wittmann using ::rtl::OUString;
45ff0525f2SOliver-Rainer Wittmann
46ff0525f2SOliver-Rainer Wittmann
47ff0525f2SOliver-Rainer Wittmann namespace sw { namespace sidebar {
48ff0525f2SOliver-Rainer Wittmann
49ff0525f2SOliver-Rainer Wittmann #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
50ff0525f2SOliver-Rainer Wittmann #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"
51ff0525f2SOliver-Rainer Wittmann #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
52ff0525f2SOliver-Rainer Wittmann
53ff0525f2SOliver-Rainer Wittmann
getImplementationName(void)54ff0525f2SOliver-Rainer Wittmann ::rtl::OUString SAL_CALL SwPanelFactory::getImplementationName (void)
55ff0525f2SOliver-Rainer Wittmann {
56*fb399032Smseidel return A2S(IMPLEMENTATION_NAME);
57ff0525f2SOliver-Rainer Wittmann }
58ff0525f2SOliver-Rainer Wittmann
59ff0525f2SOliver-Rainer Wittmann
createInstance(const uno::Reference<lang::XMultiServiceFactory> &)60ff0525f2SOliver-Rainer Wittmann cssu::Reference<cssu::XInterface> SAL_CALL SwPanelFactory::createInstance(
61*fb399032Smseidel const uno::Reference<lang::XMultiServiceFactory>& )
62ff0525f2SOliver-Rainer Wittmann {
63*fb399032Smseidel ::rtl::Reference<SwPanelFactory> pPanelFactory (new SwPanelFactory());
64*fb399032Smseidel cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY);
65*fb399032Smseidel return xService;
66ff0525f2SOliver-Rainer Wittmann }
67ff0525f2SOliver-Rainer Wittmann
68ff0525f2SOliver-Rainer Wittmann
getSupportedServiceNames(void)69ff0525f2SOliver-Rainer Wittmann cssu::Sequence<OUString> SAL_CALL SwPanelFactory::getSupportedServiceNames (void)
70ff0525f2SOliver-Rainer Wittmann {
71*fb399032Smseidel cssu::Sequence<OUString> aServiceNames (1);
72*fb399032Smseidel aServiceNames[0] = A2S(SERVICE_NAME);
73*fb399032Smseidel return aServiceNames;
74ff0525f2SOliver-Rainer Wittmann
75ff0525f2SOliver-Rainer Wittmann }
76ff0525f2SOliver-Rainer Wittmann
77ff0525f2SOliver-Rainer Wittmann
SwPanelFactory(void)78ff0525f2SOliver-Rainer Wittmann SwPanelFactory::SwPanelFactory (void)
79*fb399032Smseidel : PanelFactoryInterfaceBase(m_aMutex)
80ff0525f2SOliver-Rainer Wittmann {
81ff0525f2SOliver-Rainer Wittmann }
82ff0525f2SOliver-Rainer Wittmann
83ff0525f2SOliver-Rainer Wittmann
~SwPanelFactory(void)84ff0525f2SOliver-Rainer Wittmann SwPanelFactory::~SwPanelFactory (void)
85ff0525f2SOliver-Rainer Wittmann {
86ff0525f2SOliver-Rainer Wittmann }
87ff0525f2SOliver-Rainer Wittmann
88ff0525f2SOliver-Rainer Wittmann
createUIElement(const::rtl::OUString & rsResourceURL,const::cssu::Sequence<css::beans::PropertyValue> & rArguments)89ff0525f2SOliver-Rainer Wittmann Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
90*fb399032Smseidel const ::rtl::OUString& rsResourceURL,
91*fb399032Smseidel const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
92*fb399032Smseidel throw(
93*fb399032Smseidel container::NoSuchElementException,
94*fb399032Smseidel lang::IllegalArgumentException,
95*fb399032Smseidel RuntimeException)
96ff0525f2SOliver-Rainer Wittmann {
97*fb399032Smseidel Reference<ui::XUIElement> xElement;
98*fb399032Smseidel
99*fb399032Smseidel const ::comphelper::NamedValueCollection aArguments (rArguments);
100*fb399032Smseidel Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
101*fb399032Smseidel Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
102*fb399032Smseidel const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
103*fb399032Smseidel SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
104*fb399032Smseidel
105*fb399032Smseidel ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
106*fb399032Smseidel if ( ! xParentWindow.is() || pParentWindow==NULL)
107*fb399032Smseidel throw RuntimeException(
108*fb399032Smseidel A2S("PanelFactory::createUIElement called without ParentWindow"),
109*fb399032Smseidel NULL);
110*fb399032Smseidel if ( ! xFrame.is())
111*fb399032Smseidel throw RuntimeException(
112*fb399032Smseidel A2S("PanelFactory::createUIElement called without Frame"),
113*fb399032Smseidel NULL);
114*fb399032Smseidel if (pBindings == NULL)
115*fb399032Smseidel throw RuntimeException(
116*fb399032Smseidel A2S("PanelFactory::createUIElement called without SfxBindings"),
117*fb399032Smseidel NULL);
118ff0525f2SOliver-Rainer Wittmann
119ff0525f2SOliver-Rainer Wittmann #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
120*fb399032Smseidel if (DoesResourceEndWith("/PagePropertyPanel"))
121*fb399032Smseidel {
122*fb399032Smseidel PagePropertyPanel* pPanel = PagePropertyPanel::Create( pParentWindow, xFrame, pBindings );
123*fb399032Smseidel xElement = sfx2::sidebar::SidebarPanelBase::Create(
124*fb399032Smseidel rsResourceURL,
125*fb399032Smseidel xFrame,
126*fb399032Smseidel pPanel,
127*fb399032Smseidel ui::LayoutSize(-1,-1,-1));
128*fb399032Smseidel }
129*fb399032Smseidel else if (DoesResourceEndWith("/WrapPropertyPanel"))
130*fb399032Smseidel {
131*fb399032Smseidel WrapPropertyPanel* pPanel = WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings );
132*fb399032Smseidel xElement = sfx2::sidebar::SidebarPanelBase::Create(
133*fb399032Smseidel rsResourceURL,
134*fb399032Smseidel xFrame,
135*fb399032Smseidel pPanel,
136*fb399032Smseidel ui::LayoutSize(-1,-1,-1));
137*fb399032Smseidel }
138*fb399032Smseidel else if (DoesResourceEndWith("/NavigatorPanel"))
139*fb399032Smseidel {
140*fb399032Smseidel Window* pPanel = new SwNavigationPI(pBindings, NULL, pParentWindow);
141*fb399032Smseidel xElement = sfx2::sidebar::SidebarPanelBase::Create(
142*fb399032Smseidel rsResourceURL,
143*fb399032Smseidel xFrame,
144*fb399032Smseidel pPanel,
145*fb399032Smseidel ui::LayoutSize(0,-1,-1));
146*fb399032Smseidel }
147ff0525f2SOliver-Rainer Wittmann #undef DoesResourceEndWith
148ff0525f2SOliver-Rainer Wittmann
149*fb399032Smseidel return xElement;
150ff0525f2SOliver-Rainer Wittmann }
151ff0525f2SOliver-Rainer Wittmann
152ff0525f2SOliver-Rainer Wittmann } } // end of namespace sw::sidebar
153ff0525f2SOliver-Rainer Wittmann
154*fb399032Smseidel /* vim: set noet sw=4 ts=4: */
155