LCOV - code coverage report
Current view: top level - sc/source/ui/sidebar - ScPanelFactory.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 39 52 75.0 %
Date: 2015-06-13 12:38:46 Functions: 9 10 90.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/XMultiServiceFactory.hpp>
      35             : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      36             : #include <comphelper/namedvaluecollection.hxx>
      37             : #include <cppuhelper/supportsservice.hxx>
      38             : #include <boost/bind.hpp>
      39             : 
      40             : using namespace css;
      41             : using namespace css::uno;
      42             : using ::rtl::OUString;
      43             : 
      44             : namespace sc { namespace sidebar {
      45             : 
      46         529 : ScPanelFactory::ScPanelFactory()
      47         529 :     : PanelFactoryInterfaceBase(m_aMutex)
      48             : {
      49         529 : }
      50             : 
      51        1058 : ScPanelFactory::~ScPanelFactory()
      52             : {
      53        1058 : }
      54             : 
      55         528 : Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
      56             :     const ::rtl::OUString& rsResourceURL,
      57             :     const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments)
      58             :     throw(
      59             :         container::NoSuchElementException,
      60             :         lang::IllegalArgumentException,
      61             :         RuntimeException, std::exception)
      62             : {
      63         528 :     Reference<ui::XUIElement> xElement;
      64             : 
      65             :     try
      66             :     {
      67         528 :         const ::comphelper::NamedValueCollection aArguments (rArguments);
      68        1056 :         Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
      69        1056 :         Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
      70         528 :         const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
      71         528 :         SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
      72             : 
      73         528 :         vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
      74         528 :         if ( ! xParentWindow.is() || pParentWindow==NULL)
      75             :             throw RuntimeException(
      76             :                 "PanelFactory::createUIElement called without ParentWindow",
      77           0 :                 NULL);
      78         528 :         if ( ! xFrame.is())
      79             :             throw RuntimeException(
      80             :                 "PanelFactory::createUIElement called without Frame",
      81           0 :                 NULL);
      82         528 :         if (pBindings == NULL)
      83             :             throw RuntimeException(
      84             :                 "PanelFactory::createUIElement called without SfxBindings",
      85           0 :                 NULL);
      86             : 
      87         528 :         sal_Int32 nMinimumSize = -1;
      88        1056 :         VclPtr<vcl::Window> pPanel;
      89         528 :         if (rsResourceURL.endsWith("/AlignmentPropertyPanel"))
      90         176 :             pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings );
      91         352 :         else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel"))
      92         176 :             pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
      93         176 :         else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel"))
      94         176 :             pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings );
      95           0 :         else if (rsResourceURL.endsWith("/NavigatorPanel"))
      96             :         {
      97           0 :             pPanel = VclPtr<ScNavigatorDlg>::Create(pBindings, nullptr, pParentWindow, false);
      98           0 :             nMinimumSize = 0;
      99             :         }
     100           0 :         else if (rsResourceURL.endsWith("/FunctionsPanel"))
     101             :         {
     102           0 :             pPanel = VclPtr<ScFunctionDockWin>::Create(pBindings, nullptr, pParentWindow, ScResId(FID_FUNCTION_BOX));
     103           0 :             nMinimumSize = 0;
     104             :         }
     105             : 
     106         453 :         if (pPanel)
     107         906 :             xElement = sfx2::sidebar::SidebarPanelBase::Create(
     108             :                 rsResourceURL,
     109             :                 xFrame,
     110             :                 pPanel,
     111         981 :                 ui::LayoutSize(nMinimumSize,-1,-1));
     112             :     }
     113           0 :     catch (const uno::RuntimeException &)
     114             :     {
     115           0 :         throw;
     116             :     }
     117         150 :     catch (const uno::Exception& e)
     118             :     {
     119             :         throw lang::WrappedTargetRuntimeException(
     120             :             OUString("ScPanelFactory::createUIElement exception"),
     121          75 :             0, uno::makeAny(e));
     122             :     }
     123             : 
     124         453 :     return xElement;
     125             : }
     126             : 
     127           1 : OUString ScPanelFactory::getImplementationName()
     128             :     throw (css::uno::RuntimeException, std::exception)
     129             : {
     130           1 :     return OUString("org.apache.openoffice.comp.sc.sidebar.ScPanelFactory");
     131             : }
     132             : 
     133           0 : sal_Bool ScPanelFactory::supportsService(OUString const & ServiceName)
     134             :     throw (css::uno::RuntimeException, std::exception)
     135             : {
     136           0 :     return cppu::supportsService(this, ServiceName);
     137             : }
     138             : 
     139           1 : css::uno::Sequence<OUString> ScPanelFactory::getSupportedServiceNames()
     140             :     throw (css::uno::RuntimeException, std::exception)
     141             : {
     142           1 :     css::uno::Sequence<OUString> aServiceNames(1);
     143           1 :     aServiceNames[0] = "com.sun.star.ui.UIElementFactory";
     144           1 :     return aServiceNames;
     145             : }
     146             : 
     147             : } } // end of namespace sc::sidebar
     148             : 
     149             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* SAL_CALL
     150         529 : ScPanelFactory_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &)
     151             : {
     152         529 :     return cppu::acquire(new sc::sidebar::ScPanelFactory());
     153         156 : }
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11