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 2435fa8f12SArmin Le Grand #include <text/TextPropertyPanel.hxx> 2535fa8f12SArmin Le Grand #include <geometry/AreaPropertyPanel.hxx> 26*2bdfcea1SArmin Le Grand #include <geometry/GraphicPropertyPanel.hxx> 2758e893aeSArmin Le Grand #include <geometry/LinePropertyPanel.hxx> 2835fa8f12SArmin Le Grand #include <geometry/TransformationPropertyPanel.hxx> 2995a18594SAndre Fischer #include <sfx2/sidebar/SidebarPanelBase.hxx> 3095a18594SAndre Fischer #include <sfx2/sfxbasecontroller.hxx> 31b9e67834SAndre Fischer #include <toolkit/helper/vclunohelper.hxx> 32b9e67834SAndre Fischer #include <vcl/window.hxx> 33b9e67834SAndre Fischer #include <rtl/ref.hxx> 347a32b0c8SAndre Fischer #include <comphelper/namedvaluecollection.hxx> 357a32b0c8SAndre Fischer 367a32b0c8SAndre Fischer #include <boost/bind.hpp> 37b9e67834SAndre Fischer 38b9e67834SAndre Fischer 39b9e67834SAndre Fischer using namespace css; 40b9e67834SAndre Fischer using namespace cssu; 41b9e67834SAndre Fischer using ::rtl::OUString; 42b9e67834SAndre Fischer 43b9e67834SAndre Fischer 44b9e67834SAndre Fischer namespace svx { namespace sidebar { 45b9e67834SAndre Fischer 46b9e67834SAndre Fischer #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 47b9e67834SAndre Fischer #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.svx.sidebar.PanelFactory" 48b9e67834SAndre Fischer #define SERVICE_NAME "com.sun.star.ui.UIElementFactory" 49b9e67834SAndre Fischer 50b9e67834SAndre Fischer 51b9e67834SAndre Fischer ::rtl::OUString SAL_CALL PanelFactory::getImplementationName (void) 52b9e67834SAndre Fischer { 53b9e67834SAndre Fischer return A2S(IMPLEMENTATION_NAME); 54b9e67834SAndre Fischer } 55b9e67834SAndre Fischer 56b9e67834SAndre Fischer 57b9e67834SAndre Fischer 58b9e67834SAndre Fischer 59b9e67834SAndre Fischer cssu::Reference<cssu::XInterface> SAL_CALL PanelFactory::createInstance ( 60b9e67834SAndre Fischer const uno::Reference<lang::XMultiServiceFactory>& rxFactory) 61b9e67834SAndre Fischer { 62b9e67834SAndre Fischer (void)rxFactory; 63b9e67834SAndre Fischer 64b9e67834SAndre Fischer ::rtl::Reference<PanelFactory> pPanelFactory (new PanelFactory()); 65b9e67834SAndre Fischer cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY); 66b9e67834SAndre Fischer return xService; 67b9e67834SAndre Fischer } 68b9e67834SAndre Fischer 69b9e67834SAndre Fischer 70b9e67834SAndre Fischer 71b9e67834SAndre Fischer 72b9e67834SAndre Fischer cssu::Sequence<OUString> SAL_CALL PanelFactory::getSupportedServiceNames (void) 73b9e67834SAndre Fischer { 74b9e67834SAndre Fischer cssu::Sequence<OUString> aServiceNames (1); 75b9e67834SAndre Fischer aServiceNames[0] = A2S(SERVICE_NAME); 76b9e67834SAndre Fischer return aServiceNames; 77b9e67834SAndre Fischer 78b9e67834SAndre Fischer } 79b9e67834SAndre Fischer 80b9e67834SAndre Fischer 81b9e67834SAndre Fischer 82b9e67834SAndre Fischer 83b9e67834SAndre Fischer PanelFactory::PanelFactory (void) 84b9e67834SAndre Fischer : PanelFactoryInterfaceBase(m_aMutex) 85b9e67834SAndre Fischer { 86b9e67834SAndre Fischer } 87b9e67834SAndre Fischer 88b9e67834SAndre Fischer 89b9e67834SAndre Fischer 90b9e67834SAndre Fischer 91b9e67834SAndre Fischer PanelFactory::~PanelFactory (void) 92b9e67834SAndre Fischer { 93b9e67834SAndre Fischer } 94b9e67834SAndre Fischer 95b9e67834SAndre Fischer 96b9e67834SAndre Fischer 97b9e67834SAndre Fischer 98b9e67834SAndre Fischer Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement ( 99b9e67834SAndre Fischer const ::rtl::OUString& rsResourceURL, 100b9e67834SAndre Fischer const ::cssu::Sequence<css::beans::PropertyValue>& rArguments) 101b9e67834SAndre Fischer throw( 102b9e67834SAndre Fischer container::NoSuchElementException, 103b9e67834SAndre Fischer lang::IllegalArgumentException, 104b9e67834SAndre Fischer RuntimeException) 105b9e67834SAndre Fischer { 106b9e67834SAndre Fischer Reference<ui::XUIElement> xElement; 107b9e67834SAndre Fischer 1087a32b0c8SAndre Fischer const ::comphelper::NamedValueCollection aArguments (rArguments); 1097a32b0c8SAndre Fischer Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>())); 1107a32b0c8SAndre Fischer Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>())); 1117a32b0c8SAndre Fischer const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); 1127a32b0c8SAndre Fischer SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); 113b9e67834SAndre Fischer 114b9e67834SAndre Fischer ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); 115b9e67834SAndre Fischer if ( ! xParentWindow.is() || pParentWindow==NULL) 116b9e67834SAndre Fischer throw RuntimeException( 117b9e67834SAndre Fischer A2S("PanelFactory::createUIElement called without ParentWindow"), 118b9e67834SAndre Fischer NULL); 119b9e67834SAndre Fischer if ( ! xFrame.is()) 120b9e67834SAndre Fischer throw RuntimeException( 121b9e67834SAndre Fischer A2S("PanelFactory::createUIElement called without Frame"), 122b9e67834SAndre Fischer NULL); 123b9e67834SAndre Fischer if (pBindings == NULL) 124b9e67834SAndre Fischer throw RuntimeException( 125b9e67834SAndre Fischer A2S("PanelFactory::createUIElement called without SfxBindings"), 126b9e67834SAndre Fischer NULL); 127b9e67834SAndre Fischer 128b9e67834SAndre Fischer if (rsResourceURL.endsWithAsciiL("/TextPropertyPanel", strlen("/TextPropertyPanel"))) 12995a18594SAndre Fischer { 13095a18594SAndre Fischer TextPropertyPanel* pPanel = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings); 13195a18594SAndre Fischer xElement = sfx2::sidebar::SidebarPanelBase::Create( 13295a18594SAndre Fischer rsResourceURL, 13395a18594SAndre Fischer xFrame, 1347a32b0c8SAndre Fischer pPanel, 1357a32b0c8SAndre Fischer ::boost::bind(&TextPropertyPanel::ShowMenu, pPanel)); 13695a18594SAndre Fischer } 1375d65efa0SAndre Fischer else if (rsResourceURL.endsWithAsciiL("/AreaPropertyPanel", strlen("/AreaPropertyPanel"))) 13866c1fc23SArmin Le Grand { 13966c1fc23SArmin Le Grand AreaPropertyPanel* pPanel = AreaPropertyPanel::Create(pParentWindow, xFrame, pBindings); 14066c1fc23SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create( 14166c1fc23SArmin Le Grand rsResourceURL, 14266c1fc23SArmin Le Grand xFrame, 1435d65efa0SAndre Fischer pPanel, 1446cdc6e4fSArmin Le Grand ::boost::bind(&AreaPropertyPanel::ShowMenu, pPanel)); 14566c1fc23SArmin Le Grand } 146*2bdfcea1SArmin Le Grand else if (rsResourceURL.endsWithAsciiL("/GraphicPropertyPanel", strlen("/GraphicPropertyPanel"))) 147*2bdfcea1SArmin Le Grand { 148*2bdfcea1SArmin Le Grand GraphicPropertyPanel* pPanel = GraphicPropertyPanel::Create(pParentWindow, xFrame, pBindings); 149*2bdfcea1SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create( 150*2bdfcea1SArmin Le Grand rsResourceURL, 151*2bdfcea1SArmin Le Grand xFrame, 152*2bdfcea1SArmin Le Grand pPanel, 153*2bdfcea1SArmin Le Grand ::boost::function<void(void)>()); 154*2bdfcea1SArmin Le Grand } 15558e893aeSArmin Le Grand else if (rsResourceURL.endsWithAsciiL("/LinePropertyPanel", strlen("/LinePropertyPanel"))) 15658e893aeSArmin Le Grand { 15758e893aeSArmin Le Grand LinePropertyPanel* pPanel = LinePropertyPanel::Create(pParentWindow, xFrame, pBindings); 15858e893aeSArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create( 15958e893aeSArmin Le Grand rsResourceURL, 16058e893aeSArmin Le Grand xFrame, 16158e893aeSArmin Le Grand pPanel, 1626cdc6e4fSArmin Le Grand ::boost::bind(&LinePropertyPanel::ShowMenu, pPanel)); 16358e893aeSArmin Le Grand } 16435fa8f12SArmin Le Grand else if (rsResourceURL.endsWithAsciiL("/TransformationPropertyPanel", strlen("/TransformationPropertyPanel"))) 16535fa8f12SArmin Le Grand { 1666cdc6e4fSArmin Le Grand TransformationPropertyPanel* pPanel = TransformationPropertyPanel::Create(pParentWindow, xFrame, pBindings); 16735fa8f12SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create( 16835fa8f12SArmin Le Grand rsResourceURL, 16935fa8f12SArmin Le Grand xFrame, 17035fa8f12SArmin Le Grand pPanel, 1716cdc6e4fSArmin Le Grand ::boost::bind(&TransformationPropertyPanel::ShowMenu, pPanel)); 17235fa8f12SArmin Le Grand } 17366c1fc23SArmin Le Grand 174b9e67834SAndre Fischer return xElement; 175b9e67834SAndre Fischer } 176b9e67834SAndre Fischer 177b9e67834SAndre Fischer } } // end of namespace svx::sidebar 17835fa8f12SArmin Le Grand 17935fa8f12SArmin Le Grand // eof 180