LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/sidebar - ScPanelFactory.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 54 1.9 %
Date: 2013-07-09 Functions: 2 9 22.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10