LCOV - code coverage report
Current view: top level - sc/source/ui/sidebar - ScPanelFactory.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 56 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "ScPanelFactory.hxx"
      21             : 
      22             : #include <AlignmentPropertyPanel.hxx>
      23             : #include <CellAppearancePropertyPanel.hxx>
      24             : #include <NumberFormatPropertyPanel.hxx>
      25             : #include <navipi.hxx>
      26             : #include <dwfunctr.hxx>
      27             : #include "sc.hrc"
      28             : 
      29             : #include <sfx2/sidebar/SidebarPanelBase.hxx>
      30             : #include <sfx2/sfxbasecontroller.hxx>
      31             : #include <toolkit/helper/vclunohelper.hxx>
      32             : #include <vcl/window.hxx>
      33             : #include <rtl/ref.hxx>
      34             : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      35             : #include <comphelper/namedvaluecollection.hxx>
      36             : 
      37             : #include <boost/bind.hpp>
      38             : 
      39             : 
      40             : using namespace css;
      41             : using namespace cssu;
      42             : using ::rtl::OUString;
      43             : 
      44             : 
      45             : namespace sc { namespace sidebar {
      46             : 
      47             : #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory"
      48             : #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
      49             : 
      50             : 
      51           0 : ::rtl::OUString SAL_CALL ScPanelFactory::getImplementationName (void)
      52             : {
      53           0 :     return OUString(IMPLEMENTATION_NAME);
      54             : }
      55             : 
      56             : 
      57           0 : cssu::Reference<cssu::XInterface> SAL_CALL ScPanelFactory::createInstance(
      58             :     const uno::Reference<lang::XMultiServiceFactory>& )
      59             : {
      60           0 :     ::rtl::Reference<ScPanelFactory> pPanelFactory (new ScPanelFactory());
      61           0 :     cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY);
      62           0 :     return xService;
      63             : }
      64             : 
      65             : 
      66           0 : cssu::Sequence<OUString> SAL_CALL ScPanelFactory::getSupportedServiceNames (void)
      67             : {
      68           0 :     cssu::Sequence<OUString> aServiceNames (1);
      69           0 :     aServiceNames[0] = SERVICE_NAME;
      70           0 :     return aServiceNames;
      71             : 
      72             : }
      73             : 
      74             : 
      75           0 : ScPanelFactory::ScPanelFactory (void)
      76           0 :     : PanelFactoryInterfaceBase(m_aMutex)
      77             : {
      78           0 : }
      79             : 
      80             : 
      81           0 : ScPanelFactory::~ScPanelFactory (void)
      82             : {
      83           0 : }
      84             : 
      85             : 
      86           0 : Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
      87             :     const ::rtl::OUString& rsResourceURL,
      88             :     const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
      89             :     throw(
      90             :         container::NoSuchElementException,
      91             :         lang::IllegalArgumentException,
      92             :         RuntimeException, std::exception)
      93             : {
      94           0 :     Reference<ui::XUIElement> xElement;
      95             : 
      96             :     try
      97             :     {
      98           0 :         const ::comphelper::NamedValueCollection aArguments (rArguments);
      99           0 :         Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
     100           0 :         Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
     101           0 :         const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
     102           0 :         SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
     103             : 
     104           0 :         ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
     105           0 :         if ( ! xParentWindow.is() || pParentWindow==NULL)
     106             :             throw RuntimeException(
     107             :                 "PanelFactory::createUIElement called without ParentWindow",
     108           0 :                 NULL);
     109           0 :         if ( ! xFrame.is())
     110             :             throw RuntimeException(
     111             :                 "PanelFactory::createUIElement called without Frame",
     112           0 :                 NULL);
     113           0 :         if (pBindings == NULL)
     114             :             throw RuntimeException(
     115             :                 "PanelFactory::createUIElement called without SfxBindings",
     116           0 :                 NULL);
     117             : 
     118             :     #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
     119           0 :         if (DoesResourceEndWith("/AlignmentPropertyPanel"))
     120             :         {
     121           0 :             AlignmentPropertyPanel* pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings );
     122           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     123             :                 rsResourceURL,
     124             :                 xFrame,
     125             :                 pPanel,
     126           0 :                 ui::LayoutSize(-1,-1,-1));
     127             :         }
     128           0 :         else if (DoesResourceEndWith("/CellAppearancePropertyPanel"))
     129             :         {
     130           0 :             CellAppearancePropertyPanel* pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
     131           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     132             :                 rsResourceURL,
     133             :                 xFrame,
     134             :                 pPanel,
     135           0 :                 ui::LayoutSize(-1,-1,-1));
     136             :         }
     137           0 :         else if (DoesResourceEndWith("/NumberFormatPropertyPanel"))
     138             :         {
     139           0 :             NumberFormatPropertyPanel* pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings );
     140           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     141             :                 rsResourceURL,
     142             :                 xFrame,
     143             :                 pPanel,
     144           0 :                 ui::LayoutSize(-1,-1,-1));
     145             :         }
     146           0 :         else if (DoesResourceEndWith("/NavigatorPanel"))
     147             :         {
     148           0 :             Window* pPanel = new ScNavigatorDlg(pBindings, NULL, pParentWindow, false);
     149           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     150             :                 rsResourceURL,
     151             :                 xFrame,
     152             :                 pPanel,
     153           0 :                 ui::LayoutSize(0,-1,-1));
     154             :         }
     155           0 :         else if (DoesResourceEndWith("/FunctionsPanel"))
     156             :         {
     157           0 :             Window* pPanel = new ScFunctionDockWin(pBindings, NULL, pParentWindow, ScResId(FID_FUNCTION_BOX));
     158           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     159             :                 rsResourceURL,
     160             :                 xFrame,
     161             :                 pPanel,
     162           0 :                 ui::LayoutSize(0,-1,-1));
     163           0 :         }
     164             : #undef DoesResourceEndWith
     165             :     }
     166           0 :     catch (const uno::RuntimeException &)
     167             :     {
     168           0 :         throw;
     169             :     }
     170           0 :     catch (const uno::Exception& e)
     171             :     {
     172             :         throw lang::WrappedTargetRuntimeException(
     173             :             OUString("ScPanelFactory::createUIElement exception"),
     174           0 :             0, uno::makeAny(e));
     175             :     }
     176             : 
     177           0 :     return xElement;
     178             : }
     179             : 
     180           0 : } } // end of namespace sc::sidebar
     181             : 
     182             : // eof
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10