LCOV - code coverage report
Current view: top level - sw/source/uibase/sidebar - SwPanelFactory.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 53 62.3 %
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 <com/sun/star/ui/XUIElementFactory.hpp>
      21             : 
      22             : #include <ThemePanel.hxx>
      23             : #include <StylePresetsPanel.hxx>
      24             : #include <PagePropertyPanel.hxx>
      25             : #include <WrapPropertyPanel.hxx>
      26             : #include <navipi.hxx>
      27             : #include <redlndlg.hxx>
      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/XServiceInfo.hpp>
      35             : #include <comphelper/namedvaluecollection.hxx>
      36             : #include <cppuhelper/compbase.hxx>
      37             : #include <cppuhelper/basemutex.hxx>
      38             : #include <cppuhelper/supportsservice.hxx>
      39             : 
      40             : #include <boost/bind.hpp>
      41             : #include <boost/noncopyable.hpp>
      42             : 
      43             : using namespace css;
      44             : using namespace css::uno;
      45             : 
      46             : namespace {
      47             : 
      48             : typedef ::cppu::WeakComponentImplHelper <
      49             :         css::ui::XUIElementFactory, css::lang::XServiceInfo
      50             :         > PanelFactoryInterfaceBase;
      51             : 
      52             : class SwPanelFactory
      53             :     : private ::boost::noncopyable,
      54             :       private ::cppu::BaseMutex,
      55             :       public PanelFactoryInterfaceBase
      56             : {
      57             : public:
      58             :     SwPanelFactory();
      59             :     virtual ~SwPanelFactory();
      60             : 
      61             :     // XUIElementFactory
      62             :     css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement(
      63             :         const OUString& rsResourceURL,
      64             :         const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
      65             :         throw(
      66             :             css::container::NoSuchElementException,
      67             :             css::lang::IllegalArgumentException,
      68             :             css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      69             : 
      70           1 :     OUString SAL_CALL getImplementationName()
      71             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      72           1 :     { return OUString("org.apache.openoffice.comp.sw.sidebar.SwPanelFactory"); }
      73             : 
      74           0 :     sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
      75             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      76           0 :     { return cppu::supportsService(this, ServiceName); }
      77             : 
      78           1 :     css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
      79             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      80           1 :     { return css::uno::Sequence<OUString>{"com.sun.star.ui.UIElementFactory"}; }
      81             : };
      82             : 
      83         352 : SwPanelFactory::SwPanelFactory()
      84         352 :     : PanelFactoryInterfaceBase(m_aMutex)
      85             : {
      86         352 : }
      87             : 
      88         704 : SwPanelFactory::~SwPanelFactory()
      89             : {
      90         704 : }
      91             : 
      92         351 : Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
      93             :     const OUString& rsResourceURL,
      94             :     const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
      95             :     throw(
      96             :         container::NoSuchElementException,
      97             :         lang::IllegalArgumentException,
      98             :         RuntimeException, std::exception)
      99             : {
     100         351 :     Reference<ui::XUIElement> xElement;
     101             : 
     102         702 :     const ::comphelper::NamedValueCollection aArguments (rArguments);
     103         702 :     Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
     104         702 :     Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
     105         351 :     const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
     106         351 :     SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
     107             : 
     108         351 :     vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
     109         351 :     if ( ! xParentWindow.is() || pParentWindow==NULL)
     110             :         throw RuntimeException(
     111             :             "PanelFactory::createUIElement called without ParentWindow",
     112           0 :             NULL);
     113         351 :     if ( ! xFrame.is())
     114             :         throw RuntimeException(
     115             :             "PanelFactory::createUIElement called without Frame",
     116           0 :             NULL);
     117         351 :     if (pBindings == NULL)
     118             :         throw RuntimeException(
     119             :             "PanelFactory::createUIElement called without SfxBindings",
     120           0 :             NULL);
     121             : 
     122         351 :     if (rsResourceURL.endsWith("/PagePropertyPanel"))
     123             :     {
     124         350 :         VclPtr<vcl::Window> pPanel = sw::sidebar::PagePropertyPanel::Create( pParentWindow, xFrame, pBindings );
     125         674 :         xElement = sfx2::sidebar::SidebarPanelBase::Create(
     126             :             rsResourceURL,
     127             :             xFrame,
     128             :             pPanel,
     129         674 :             ui::LayoutSize(-1,-1,-1));
     130             :     }
     131           1 :     else if (rsResourceURL.endsWith("/WrapPropertyPanel"))
     132             :     {
     133           0 :         VclPtr<vcl::Window> pPanel = sw::sidebar::WrapPropertyPanel::Create( pParentWindow, xFrame, pBindings );
     134           0 :         xElement = sfx2::sidebar::SidebarPanelBase::Create(
     135             :             rsResourceURL,
     136             :             xFrame,
     137             :             pPanel,
     138           0 :             ui::LayoutSize(-1,-1,-1));
     139             :     }
     140           1 :     else if (rsResourceURL.endsWith("/NavigatorPanel"))
     141             :     {
     142           1 :         VclPtrInstance<SwNavigationPI> pPanel(pBindings, nullptr, pParentWindow);
     143           3 :         xElement = sfx2::sidebar::SidebarPanelBase::Create(
     144             :             rsResourceURL,
     145             :             xFrame,
     146             :             pPanel,
     147           3 :             ui::LayoutSize(0,-1,-1));
     148             :     }
     149           0 :     else if (rsResourceURL.endsWith("/ManageChangesPanel"))
     150             :     {
     151           0 :         VclPtrInstance<SwRedlineAcceptPanel> pPanel(pParentWindow, xFrame);
     152           0 :         xElement = sfx2::sidebar::SidebarPanelBase::Create(
     153             :             rsResourceURL,
     154             :             xFrame,
     155             :             pPanel,
     156           0 :             ui::LayoutSize(-1,-1,-1));
     157             :     }
     158           0 :     else if (rsResourceURL.endsWith("/StylePresetsPanel"))
     159             :     {
     160           0 :         VclPtr<vcl::Window> pPanel = sw::sidebar::StylePresetsPanel::Create(pParentWindow, xFrame, pBindings);
     161           0 :         xElement = sfx2::sidebar::SidebarPanelBase::Create(
     162           0 :                         rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
     163             :     }
     164           0 :     else if (rsResourceURL.endsWith("/ThemePanel"))
     165             :     {
     166           0 :         VclPtr<vcl::Window> pPanel = sw::sidebar::ThemePanel::Create(pParentWindow, xFrame, pBindings);
     167           0 :         xElement = sfx2::sidebar::SidebarPanelBase::Create(
     168           0 :                         rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1));
     169             :     }
     170             : 
     171         676 :     return xElement;
     172             : }
     173             : 
     174             : }
     175             : 
     176             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     177         352 : org_apache_openoffice_comp_sw_sidebar_SwPanelFactory_get_implementation(
     178             :     css::uno::XComponentContext *,
     179             :     css::uno::Sequence<css::uno::Any> const &)
     180             : {
     181         352 :     return cppu::acquire(new SwPanelFactory());
     182         177 : }
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11