LCOV - code coverage report
Current view: top level - sc/source/ui/sidebar - ScPanelFactory.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 56 1.8 %
Date: 2014-11-03 Functions: 2 9 22.2 %
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             : using namespace css;
      40             : using namespace css::uno;
      41             : using ::rtl::OUString;
      42             : 
      43             : namespace sc { namespace sidebar {
      44             : 
      45             : #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory"
      46             : #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
      47             : 
      48           0 : ::rtl::OUString SAL_CALL ScPanelFactory::getImplementationName (void)
      49             : {
      50           0 :     return OUString(IMPLEMENTATION_NAME);
      51             : }
      52             : 
      53           0 : css::uno::Reference<css::uno::XInterface> SAL_CALL ScPanelFactory::createInstance(
      54             :     const uno::Reference<lang::XMultiServiceFactory>& )
      55             : {
      56           0 :     ::rtl::Reference<ScPanelFactory> pPanelFactory (new ScPanelFactory());
      57           0 :     css::uno::Reference<css::uno::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), css::uno::UNO_QUERY);
      58           0 :     return xService;
      59             : }
      60             : 
      61           0 : css::uno::Sequence<OUString> SAL_CALL ScPanelFactory::getSupportedServiceNames (void)
      62             : {
      63           0 :     css::uno::Sequence<OUString> aServiceNames (1);
      64           0 :     aServiceNames[0] = SERVICE_NAME;
      65           0 :     return aServiceNames;
      66             : 
      67             : }
      68             : 
      69           0 : ScPanelFactory::ScPanelFactory (void)
      70           0 :     : PanelFactoryInterfaceBase(m_aMutex)
      71             : {
      72           0 : }
      73             : 
      74           0 : ScPanelFactory::~ScPanelFactory (void)
      75             : {
      76           0 : }
      77             : 
      78           0 : Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
      79             :     const ::rtl::OUString& rsResourceURL,
      80             :     const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
      81             :     throw(
      82             :         container::NoSuchElementException,
      83             :         lang::IllegalArgumentException,
      84             :         RuntimeException, std::exception)
      85             : {
      86           0 :     Reference<ui::XUIElement> xElement;
      87             : 
      88             :     try
      89             :     {
      90           0 :         const ::comphelper::NamedValueCollection aArguments (rArguments);
      91           0 :         Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
      92           0 :         Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
      93           0 :         const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
      94           0 :         SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
      95             : 
      96           0 :         vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
      97           0 :         if ( ! xParentWindow.is() || pParentWindow==NULL)
      98             :             throw RuntimeException(
      99             :                 "PanelFactory::createUIElement called without ParentWindow",
     100           0 :                 NULL);
     101           0 :         if ( ! xFrame.is())
     102             :             throw RuntimeException(
     103             :                 "PanelFactory::createUIElement called without Frame",
     104           0 :                 NULL);
     105           0 :         if (pBindings == NULL)
     106             :             throw RuntimeException(
     107             :                 "PanelFactory::createUIElement called without SfxBindings",
     108           0 :                 NULL);
     109             : 
     110             :     #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
     111           0 :         if (DoesResourceEndWith("/AlignmentPropertyPanel"))
     112             :         {
     113           0 :             AlignmentPropertyPanel* pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings );
     114           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     115             :                 rsResourceURL,
     116             :                 xFrame,
     117             :                 pPanel,
     118           0 :                 ui::LayoutSize(-1,-1,-1));
     119             :         }
     120           0 :         else if (DoesResourceEndWith("/CellAppearancePropertyPanel"))
     121             :         {
     122           0 :             CellAppearancePropertyPanel* pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
     123           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     124             :                 rsResourceURL,
     125             :                 xFrame,
     126             :                 pPanel,
     127           0 :                 ui::LayoutSize(-1,-1,-1));
     128             :         }
     129           0 :         else if (DoesResourceEndWith("/NumberFormatPropertyPanel"))
     130             :         {
     131           0 :             NumberFormatPropertyPanel* pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings );
     132           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     133             :                 rsResourceURL,
     134             :                 xFrame,
     135             :                 pPanel,
     136           0 :                 ui::LayoutSize(-1,-1,-1));
     137             :         }
     138           0 :         else if (DoesResourceEndWith("/NavigatorPanel"))
     139             :         {
     140           0 :             vcl::Window* pPanel = new ScNavigatorDlg(pBindings, NULL, pParentWindow, false);
     141           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     142             :                 rsResourceURL,
     143             :                 xFrame,
     144             :                 pPanel,
     145           0 :                 ui::LayoutSize(0,-1,-1));
     146             :         }
     147           0 :         else if (DoesResourceEndWith("/FunctionsPanel"))
     148             :         {
     149           0 :             vcl::Window* pPanel = new ScFunctionDockWin(pBindings, NULL, pParentWindow, ScResId(FID_FUNCTION_BOX));
     150           0 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     151             :                 rsResourceURL,
     152             :                 xFrame,
     153             :                 pPanel,
     154           0 :                 ui::LayoutSize(0,-1,-1));
     155           0 :         }
     156             : #undef DoesResourceEndWith
     157             :     }
     158           0 :     catch (const uno::RuntimeException &)
     159             :     {
     160           0 :         throw;
     161             :     }
     162           0 :     catch (const uno::Exception& e)
     163             :     {
     164             :         throw lang::WrappedTargetRuntimeException(
     165             :             OUString("ScPanelFactory::createUIElement exception"),
     166           0 :             0, uno::makeAny(e));
     167             :     }
     168             : 
     169           0 :     return xElement;
     170             : }
     171             : 
     172         228 : } } // end of namespace sc::sidebar
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10