1b9e67834SAndre Fischer /**************************************************************
2b9e67834SAndre Fischer  *
3b9e67834SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4b9e67834SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5b9e67834SAndre Fischer  * distributed with this work for additional information
6b9e67834SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7b9e67834SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8b9e67834SAndre Fischer  * "License"); you may not use this file except in compliance
9b9e67834SAndre Fischer  * with the License.  You may obtain a copy of the License at
10b9e67834SAndre Fischer  *
11b9e67834SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12b9e67834SAndre Fischer  *
13b9e67834SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14b9e67834SAndre Fischer  * software distributed under the License is distributed on an
15b9e67834SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b9e67834SAndre Fischer  * KIND, either express or implied.  See the License for the
17b9e67834SAndre Fischer  * specific language governing permissions and limitations
18b9e67834SAndre Fischer  * under the License.
19b9e67834SAndre Fischer  *
20b9e67834SAndre Fischer  *************************************************************/
21b9e67834SAndre Fischer 
22b9e67834SAndre Fischer #include "sidebar/PanelFactory.hxx"
23b9e67834SAndre Fischer 
2402c50d82SAndre Fischer #include "text/TextPropertyPanel.hxx"
25766ce4d0SZheng Fan #include "paragraph/ParaPropertyPanel.hxx"
268dcb2a10SAndre Fischer #include "area/AreaPropertyPanel.hxx"
278dcb2a10SAndre Fischer #include "graphic/GraphicPropertyPanel.hxx"
288dcb2a10SAndre Fischer #include "line/LinePropertyPanel.hxx"
29ee093554SAndre Fischer #include "possize/PosSizePropertyPanel.hxx"
30a8eaca58SAndre Fischer #include "GalleryControl.hxx"
31f120fe41SAndre Fischer #include "debug/ColorPanel.hxx"
32f120fe41SAndre Fischer #include "debug/ContextPanel.hxx"
33f120fe41SAndre Fischer #include "debug/NotYetImplementedPanel.hxx"
34f120fe41SAndre Fischer #include "EmptyPanel.hxx"
3595a18594SAndre Fischer #include <sfx2/sidebar/SidebarPanelBase.hxx>
3695a18594SAndre Fischer #include <sfx2/sfxbasecontroller.hxx>
37*bd7afb38SAndre Fischer #include <sfx2/templdlg.hxx>
38b9e67834SAndre Fischer #include <toolkit/helper/vclunohelper.hxx>
39b9e67834SAndre Fischer #include <vcl/window.hxx>
40b9e67834SAndre Fischer #include <rtl/ref.hxx>
417a32b0c8SAndre Fischer #include <comphelper/namedvaluecollection.hxx>
427a32b0c8SAndre Fischer 
4302c50d82SAndre Fischer 
447a32b0c8SAndre Fischer #include <boost/bind.hpp>
45b9e67834SAndre Fischer 
46b9e67834SAndre Fischer 
47b9e67834SAndre Fischer using namespace css;
48b9e67834SAndre Fischer using namespace cssu;
49b9e67834SAndre Fischer using ::rtl::OUString;
50b9e67834SAndre Fischer 
51b9e67834SAndre Fischer 
52b9e67834SAndre Fischer namespace svx { namespace sidebar {
53b9e67834SAndre Fischer 
54b9e67834SAndre Fischer #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
55b9e67834SAndre Fischer #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.svx.sidebar.PanelFactory"
56b9e67834SAndre Fischer #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
57b9e67834SAndre Fischer 
58b9e67834SAndre Fischer 
59b9e67834SAndre Fischer ::rtl::OUString SAL_CALL PanelFactory::getImplementationName (void)
60b9e67834SAndre Fischer {
61b9e67834SAndre Fischer     return A2S(IMPLEMENTATION_NAME);
62b9e67834SAndre Fischer }
63b9e67834SAndre Fischer 
64b9e67834SAndre Fischer 
65b9e67834SAndre Fischer 
66b9e67834SAndre Fischer 
67b9e67834SAndre Fischer cssu::Reference<cssu::XInterface> SAL_CALL PanelFactory::createInstance (
68b9e67834SAndre Fischer     const uno::Reference<lang::XMultiServiceFactory>& rxFactory)
69b9e67834SAndre Fischer {
70b9e67834SAndre Fischer     (void)rxFactory;
71b9e67834SAndre Fischer 
72b9e67834SAndre Fischer     ::rtl::Reference<PanelFactory> pPanelFactory (new PanelFactory());
73b9e67834SAndre Fischer     cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY);
74b9e67834SAndre Fischer     return xService;
75b9e67834SAndre Fischer }
76b9e67834SAndre Fischer 
77b9e67834SAndre Fischer 
78b9e67834SAndre Fischer 
79b9e67834SAndre Fischer 
80b9e67834SAndre Fischer cssu::Sequence<OUString> SAL_CALL PanelFactory::getSupportedServiceNames (void)
81b9e67834SAndre Fischer {
82b9e67834SAndre Fischer     cssu::Sequence<OUString> aServiceNames (1);
83b9e67834SAndre Fischer     aServiceNames[0] = A2S(SERVICE_NAME);
84b9e67834SAndre Fischer     return aServiceNames;
85b9e67834SAndre Fischer 
86b9e67834SAndre Fischer }
87b9e67834SAndre Fischer 
88b9e67834SAndre Fischer 
89b9e67834SAndre Fischer 
90b9e67834SAndre Fischer 
91b9e67834SAndre Fischer PanelFactory::PanelFactory (void)
92b9e67834SAndre Fischer     : PanelFactoryInterfaceBase(m_aMutex)
93b9e67834SAndre Fischer {
94b9e67834SAndre Fischer }
95b9e67834SAndre Fischer 
96b9e67834SAndre Fischer 
97b9e67834SAndre Fischer 
98b9e67834SAndre Fischer 
99b9e67834SAndre Fischer PanelFactory::~PanelFactory (void)
100b9e67834SAndre Fischer {
101b9e67834SAndre Fischer }
102b9e67834SAndre Fischer 
103b9e67834SAndre Fischer 
104b9e67834SAndre Fischer 
105b9e67834SAndre Fischer 
106b9e67834SAndre Fischer Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
107b9e67834SAndre Fischer     const ::rtl::OUString& rsResourceURL,
108b9e67834SAndre Fischer     const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
109b9e67834SAndre Fischer     throw(
110b9e67834SAndre Fischer         container::NoSuchElementException,
111b9e67834SAndre Fischer         lang::IllegalArgumentException,
112b9e67834SAndre Fischer         RuntimeException)
113b9e67834SAndre Fischer {
114b9e67834SAndre Fischer     Reference<ui::XUIElement> xElement;
115b9e67834SAndre Fischer 
1167a32b0c8SAndre Fischer     const ::comphelper::NamedValueCollection aArguments (rArguments);
1177a32b0c8SAndre Fischer     Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
1187a32b0c8SAndre Fischer     Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
1197a32b0c8SAndre Fischer     const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
1207a32b0c8SAndre Fischer     SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
121b9e67834SAndre Fischer 
122b9e67834SAndre Fischer     ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
123b9e67834SAndre Fischer     if ( ! xParentWindow.is() || pParentWindow==NULL)
124b9e67834SAndre Fischer         throw RuntimeException(
125b9e67834SAndre Fischer             A2S("PanelFactory::createUIElement called without ParentWindow"),
126b9e67834SAndre Fischer             NULL);
127b9e67834SAndre Fischer     if ( ! xFrame.is())
128b9e67834SAndre Fischer         throw RuntimeException(
129b9e67834SAndre Fischer             A2S("PanelFactory::createUIElement called without Frame"),
130b9e67834SAndre Fischer             NULL);
131b9e67834SAndre Fischer     if (pBindings == NULL)
132b9e67834SAndre Fischer         throw RuntimeException(
133b9e67834SAndre Fischer             A2S("PanelFactory::createUIElement called without SfxBindings"),
134b9e67834SAndre Fischer             NULL);
135b9e67834SAndre Fischer 
13602c50d82SAndre Fischer #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
13702c50d82SAndre Fischer     if (DoesResourceEndWith("/TextPropertyPanel"))
13895a18594SAndre Fischer     {
13995a18594SAndre Fischer         TextPropertyPanel* pPanel = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings);
14095a18594SAndre Fischer         xElement = sfx2::sidebar::SidebarPanelBase::Create(
14195a18594SAndre Fischer             rsResourceURL,
14295a18594SAndre Fischer             xFrame,
1437a32b0c8SAndre Fischer             pPanel,
14402c50d82SAndre Fischer             ui::LayoutSize(-1,-1,-1));
14595a18594SAndre Fischer     }
146766ce4d0SZheng Fan     if (DoesResourceEndWith("/ParaPropertyPanel"))
147766ce4d0SZheng Fan     {
148766ce4d0SZheng Fan         ParaPropertyPanel* pPanel = ParaPropertyPanel::Create(pParentWindow, xFrame, pBindings);
149766ce4d0SZheng Fan         xElement = sfx2::sidebar::SidebarPanelBase::Create(
150766ce4d0SZheng Fan             rsResourceURL,
151766ce4d0SZheng Fan             xFrame,
152766ce4d0SZheng Fan             pPanel,
153766ce4d0SZheng Fan             //::boost::bind(&ParaPropertyPanel::ShowMenu, pPanel),
154766ce4d0SZheng Fan             ui::LayoutSize(-1,-1,-1));
155766ce4d0SZheng Fan     }
15602c50d82SAndre Fischer     else if (DoesResourceEndWith("/AreaPropertyPanel"))
15766c1fc23SArmin Le Grand     {
15866c1fc23SArmin Le Grand         AreaPropertyPanel* pPanel = AreaPropertyPanel::Create(pParentWindow, xFrame, pBindings);
15966c1fc23SArmin Le Grand         xElement = sfx2::sidebar::SidebarPanelBase::Create(
16066c1fc23SArmin Le Grand             rsResourceURL,
16166c1fc23SArmin Le Grand             xFrame,
1625d65efa0SAndre Fischer             pPanel,
16302c50d82SAndre Fischer             ui::LayoutSize(-1,-1,-1));
16466c1fc23SArmin Le Grand     }
16502c50d82SAndre Fischer     else if (DoesResourceEndWith("/GraphicPropertyPanel"))
1662bdfcea1SArmin Le Grand     {
1672bdfcea1SArmin Le Grand         GraphicPropertyPanel* pPanel = GraphicPropertyPanel::Create(pParentWindow, xFrame, pBindings);
1682bdfcea1SArmin Le Grand         xElement = sfx2::sidebar::SidebarPanelBase::Create(
1692bdfcea1SArmin Le Grand             rsResourceURL,
1702bdfcea1SArmin Le Grand             xFrame,
1712bdfcea1SArmin Le Grand             pPanel,
17202c50d82SAndre Fischer             ui::LayoutSize(-1,-1,-1));
1732bdfcea1SArmin Le Grand     }
17402c50d82SAndre Fischer     else if (DoesResourceEndWith("/LinePropertyPanel"))
17558e893aeSArmin Le Grand     {
17658e893aeSArmin Le Grand         LinePropertyPanel* pPanel = LinePropertyPanel::Create(pParentWindow, xFrame, pBindings);
17758e893aeSArmin Le Grand         xElement = sfx2::sidebar::SidebarPanelBase::Create(
17858e893aeSArmin Le Grand             rsResourceURL,
17958e893aeSArmin Le Grand             xFrame,
18058e893aeSArmin Le Grand             pPanel,
18102c50d82SAndre Fischer             ui::LayoutSize(-1,-1,-1));
18258e893aeSArmin Le Grand     }
183ee093554SAndre Fischer     else if (DoesResourceEndWith("/PosSizePropertyPanel"))
18435fa8f12SArmin Le Grand     {
185ee093554SAndre Fischer         PosSizePropertyPanel* pPanel = PosSizePropertyPanel::Create(pParentWindow, xFrame, pBindings);
18635fa8f12SArmin Le Grand         xElement = sfx2::sidebar::SidebarPanelBase::Create(
18735fa8f12SArmin Le Grand             rsResourceURL,
18835fa8f12SArmin Le Grand             xFrame,
18935fa8f12SArmin Le Grand             pPanel,
19002c50d82SAndre Fischer             ui::LayoutSize(-1,-1,-1));
19102c50d82SAndre Fischer     }
19202c50d82SAndre Fischer     else if (DoesResourceEndWith("/GalleryPanel"))
19302c50d82SAndre Fischer     {
19402c50d82SAndre Fischer         GalleryControl* pGalleryControl = new GalleryControl(
19502c50d82SAndre Fischer             pBindings,
19602c50d82SAndre Fischer             pParentWindow);
19702c50d82SAndre Fischer         xElement = sfx2::sidebar::SidebarPanelBase::Create(
19802c50d82SAndre Fischer             rsResourceURL,
19902c50d82SAndre Fischer             xFrame,
20002c50d82SAndre Fischer             pGalleryControl,
20102c50d82SAndre Fischer             ui::LayoutSize(300,-1,400));
20235fa8f12SArmin Le Grand     }
203*bd7afb38SAndre Fischer     else if (DoesResourceEndWith("/StyleListPanel"))
204*bd7afb38SAndre Fischer     {
205*bd7afb38SAndre Fischer         Window* pControl = new SfxTemplatePanelControl(pBindings, pParentWindow);
206*bd7afb38SAndre Fischer         xElement = sfx2::sidebar::SidebarPanelBase::Create(
207*bd7afb38SAndre Fischer             rsResourceURL,
208*bd7afb38SAndre Fischer             xFrame,
209*bd7afb38SAndre Fischer             pControl,
210*bd7afb38SAndre Fischer             ui::LayoutSize(0,-1,-1));
211*bd7afb38SAndre Fischer     }
2122d839242SAndre Fischer     else if (DoesResourceEndWith("/Debug_ColorPanel"))
2132d839242SAndre Fischer     {
214f120fe41SAndre Fischer         ColorPanel* pPanel = new ColorPanel(pParentWindow);
2152d839242SAndre Fischer         xElement = sfx2::sidebar::SidebarPanelBase::Create(
2162d839242SAndre Fischer             rsResourceURL,
2172d839242SAndre Fischer             xFrame,
218f120fe41SAndre Fischer             pPanel,
2192d839242SAndre Fischer             ui::LayoutSize(300,-1,400));
2202d839242SAndre Fischer     }
221f120fe41SAndre Fischer     else if (DoesResourceEndWith("/Debug_ContextPanel"))
222f120fe41SAndre Fischer     {
223f120fe41SAndre Fischer         ContextPanel* pPanel = new ContextPanel(pParentWindow);
224f120fe41SAndre Fischer         xElement = sfx2::sidebar::SidebarPanelBase::Create(
225f120fe41SAndre Fischer             rsResourceURL,
226f120fe41SAndre Fischer             xFrame,
227f120fe41SAndre Fischer             pPanel,
228f120fe41SAndre Fischer             ui::LayoutSize(45,45,45));
229f120fe41SAndre Fischer     }
230f120fe41SAndre Fischer     else if (DoesResourceEndWith("/Debug_NotYetImplementedPanel"))
231f120fe41SAndre Fischer     {
232f120fe41SAndre Fischer         NotYetImplementedPanel* pPanel = new NotYetImplementedPanel(pParentWindow);
233f120fe41SAndre Fischer         xElement = sfx2::sidebar::SidebarPanelBase::Create(
234f120fe41SAndre Fischer             rsResourceURL,
235f120fe41SAndre Fischer             xFrame,
236f120fe41SAndre Fischer             pPanel,
237f120fe41SAndre Fischer             ui::LayoutSize(20,25,25));
238f120fe41SAndre Fischer     }
239f120fe41SAndre Fischer     else if (DoesResourceEndWith("/EmptyPanel"))
240f120fe41SAndre Fischer     {
241f120fe41SAndre Fischer         EmptyPanel* pPanel = new EmptyPanel(pParentWindow);
242f120fe41SAndre Fischer         xElement = sfx2::sidebar::SidebarPanelBase::Create(
243f120fe41SAndre Fischer             rsResourceURL,
244f120fe41SAndre Fischer             xFrame,
245f120fe41SAndre Fischer             pPanel,
246a5761a6eSAndre Fischer             ui::LayoutSize(20,-1, 50));
247f120fe41SAndre Fischer     }
24802c50d82SAndre Fischer #undef DoesResourceEndWith
24966c1fc23SArmin Le Grand 
250b9e67834SAndre Fischer     return xElement;
251b9e67834SAndre Fischer }
252b9e67834SAndre Fischer 
253b9e67834SAndre Fischer } } // end of namespace svx::sidebar
25435fa8f12SArmin Le Grand 
25535fa8f12SArmin Le Grand // eof
256