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> 29*3c226292SAndre Fischer #include <navipi.hxx> 30facb16e7SArmin Le Grand 31facb16e7SArmin Le Grand #include <sfx2/sidebar/SidebarPanelBase.hxx> 32facb16e7SArmin Le Grand #include <sfx2/sfxbasecontroller.hxx> 33facb16e7SArmin Le Grand #include <toolkit/helper/vclunohelper.hxx> 34facb16e7SArmin Le Grand #include <vcl/window.hxx> 35facb16e7SArmin Le Grand #include <rtl/ref.hxx> 36facb16e7SArmin Le Grand #include <comphelper/namedvaluecollection.hxx> 37facb16e7SArmin Le Grand 38facb16e7SArmin Le Grand #include <boost/bind.hpp> 39facb16e7SArmin Le Grand 40facb16e7SArmin Le Grand 41facb16e7SArmin Le Grand using namespace css; 42facb16e7SArmin Le Grand using namespace cssu; 43facb16e7SArmin Le Grand using ::rtl::OUString; 44facb16e7SArmin Le Grand 45facb16e7SArmin Le Grand 46facb16e7SArmin Le Grand namespace sc { namespace sidebar { 47facb16e7SArmin Le Grand 48facb16e7SArmin Le Grand #define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 49facb16e7SArmin Le Grand #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory" 50facb16e7SArmin Le Grand #define SERVICE_NAME "com.sun.star.ui.UIElementFactory" 51facb16e7SArmin Le Grand 52facb16e7SArmin Le Grand 53facb16e7SArmin Le Grand ::rtl::OUString SAL_CALL ScPanelFactory::getImplementationName (void) 54facb16e7SArmin Le Grand { 55facb16e7SArmin Le Grand return A2S(IMPLEMENTATION_NAME); 56facb16e7SArmin Le Grand } 57facb16e7SArmin Le Grand 58facb16e7SArmin Le Grand 59facb16e7SArmin Le Grand cssu::Reference<cssu::XInterface> SAL_CALL ScPanelFactory::createInstance( 60facb16e7SArmin Le Grand const uno::Reference<lang::XMultiServiceFactory>& ) 61facb16e7SArmin Le Grand { 62facb16e7SArmin Le Grand ::rtl::Reference<ScPanelFactory> pPanelFactory (new ScPanelFactory()); 63facb16e7SArmin Le Grand cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY); 64facb16e7SArmin Le Grand return xService; 65facb16e7SArmin Le Grand } 66facb16e7SArmin Le Grand 67facb16e7SArmin Le Grand 68facb16e7SArmin Le Grand cssu::Sequence<OUString> SAL_CALL ScPanelFactory::getSupportedServiceNames (void) 69facb16e7SArmin Le Grand { 70facb16e7SArmin Le Grand cssu::Sequence<OUString> aServiceNames (1); 71facb16e7SArmin Le Grand aServiceNames[0] = A2S(SERVICE_NAME); 72facb16e7SArmin Le Grand return aServiceNames; 73facb16e7SArmin Le Grand 74facb16e7SArmin Le Grand } 75facb16e7SArmin Le Grand 76facb16e7SArmin Le Grand 77facb16e7SArmin Le Grand ScPanelFactory::ScPanelFactory (void) 78facb16e7SArmin Le Grand : PanelFactoryInterfaceBase(m_aMutex) 79facb16e7SArmin Le Grand { 80facb16e7SArmin Le Grand } 81facb16e7SArmin Le Grand 82facb16e7SArmin Le Grand 83facb16e7SArmin Le Grand ScPanelFactory::~ScPanelFactory (void) 84facb16e7SArmin Le Grand { 85facb16e7SArmin Le Grand } 86facb16e7SArmin Le Grand 87facb16e7SArmin Le Grand 88facb16e7SArmin Le Grand Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement ( 89facb16e7SArmin Le Grand const ::rtl::OUString& rsResourceURL, 90facb16e7SArmin Le Grand const ::cssu::Sequence<css::beans::PropertyValue>& rArguments) 91facb16e7SArmin Le Grand throw( 92facb16e7SArmin Le Grand container::NoSuchElementException, 93facb16e7SArmin Le Grand lang::IllegalArgumentException, 94facb16e7SArmin Le Grand RuntimeException) 95facb16e7SArmin Le Grand { 96facb16e7SArmin Le Grand Reference<ui::XUIElement> xElement; 97facb16e7SArmin Le Grand 98facb16e7SArmin Le Grand const ::comphelper::NamedValueCollection aArguments (rArguments); 99facb16e7SArmin Le Grand Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>())); 100facb16e7SArmin Le Grand Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>())); 101facb16e7SArmin Le Grand const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); 102facb16e7SArmin Le Grand SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); 103facb16e7SArmin Le Grand 104facb16e7SArmin Le Grand ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); 105facb16e7SArmin Le Grand if ( ! xParentWindow.is() || pParentWindow==NULL) 106facb16e7SArmin Le Grand throw RuntimeException( 107facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without ParentWindow"), 108facb16e7SArmin Le Grand NULL); 109facb16e7SArmin Le Grand if ( ! xFrame.is()) 110facb16e7SArmin Le Grand throw RuntimeException( 111facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without Frame"), 112facb16e7SArmin Le Grand NULL); 113facb16e7SArmin Le Grand if (pBindings == NULL) 114facb16e7SArmin Le Grand throw RuntimeException( 115facb16e7SArmin Le Grand A2S("PanelFactory::createUIElement called without SfxBindings"), 116facb16e7SArmin Le Grand NULL); 117facb16e7SArmin Le Grand 118facb16e7SArmin Le Grand #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s)) 119facb16e7SArmin Le Grand if (DoesResourceEndWith("/AlignmentPropertyPanel")) 120facb16e7SArmin Le Grand { 121facb16e7SArmin Le Grand AlignmentPropertyPanel* pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings ); 122facb16e7SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create( 123facb16e7SArmin Le Grand rsResourceURL, 124facb16e7SArmin Le Grand xFrame, 125facb16e7SArmin Le Grand pPanel, 126facb16e7SArmin Le Grand ui::LayoutSize(-1,-1,-1)); 127facb16e7SArmin Le Grand } 1284e8031e0SArmin Le Grand else if (DoesResourceEndWith("/CellAppearancePropertyPanel")) 129facb16e7SArmin Le Grand { 130facb16e7SArmin Le Grand CellAppearancePropertyPanel* pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings ); 131facb16e7SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create( 132facb16e7SArmin Le Grand rsResourceURL, 133facb16e7SArmin Le Grand xFrame, 134facb16e7SArmin Le Grand pPanel, 135facb16e7SArmin Le Grand ui::LayoutSize(-1,-1,-1)); 136facb16e7SArmin Le Grand } 1374e8031e0SArmin Le Grand else if (DoesResourceEndWith("/NumberFormatPropertyPanel")) 1384e8031e0SArmin Le Grand { 1394e8031e0SArmin Le Grand NumberFormatPropertyPanel* pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings ); 1404e8031e0SArmin Le Grand xElement = sfx2::sidebar::SidebarPanelBase::Create( 1414e8031e0SArmin Le Grand rsResourceURL, 1424e8031e0SArmin Le Grand xFrame, 1434e8031e0SArmin Le Grand pPanel, 1444e8031e0SArmin Le Grand ui::LayoutSize(-1,-1,-1)); 1454e8031e0SArmin Le Grand } 146*3c226292SAndre Fischer else if (DoesResourceEndWith("/NavigatorPanel")) 147*3c226292SAndre Fischer { 148*3c226292SAndre Fischer Window* pPanel = new ScNavigatorDlg(pBindings, NULL, pParentWindow); 149*3c226292SAndre Fischer xElement = sfx2::sidebar::SidebarPanelBase::Create( 150*3c226292SAndre Fischer rsResourceURL, 151*3c226292SAndre Fischer xFrame, 152*3c226292SAndre Fischer pPanel, 153*3c226292SAndre Fischer ui::LayoutSize(0,-1,-1)); 154*3c226292SAndre Fischer } 155facb16e7SArmin Le Grand #undef DoesResourceEndWith 156facb16e7SArmin Le Grand 157facb16e7SArmin Le Grand return xElement; 158facb16e7SArmin Le Grand } 159facb16e7SArmin Le Grand 160facb16e7SArmin Le Grand } } // end of namespace sc::sidebar 161facb16e7SArmin Le Grand 162facb16e7SArmin Le Grand // eof 163