LCOV - code coverage report
Current view: top level - svx/source/sidebar - PanelFactory.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 60 1.7 %
Date: 2014-04-11 Functions: 2 7 28.6 %
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 "text/TextPropertyPanel.hxx"
      20             : #include "paragraph/ParaPropertyPanel.hxx"
      21             : #include "area/AreaPropertyPanel.hxx"
      22             : #include "graphic/GraphicPropertyPanel.hxx"
      23             : #include "line/LinePropertyPanel.hxx"
      24             : #include "possize/PosSizePropertyPanel.hxx"
      25             : #include "insert/InsertPropertyPanel.hxx"
      26             : #include "GalleryControl.hxx"
      27             : #include "debug/ColorPanel.hxx"
      28             : #include "debug/ContextPanel.hxx"
      29             : #include "debug/NotYetImplementedPanel.hxx"
      30             : #include "EmptyPanel.hxx"
      31             : #include <sfx2/sidebar/SidebarPanelBase.hxx>
      32             : #include <sfx2/sidebar/Tools.hxx>
      33             : #include <sfx2/sfxbasecontroller.hxx>
      34             : #include <sfx2/templdlg.hxx>
      35             : #include <toolkit/helper/vclunohelper.hxx>
      36             : #include <vcl/window.hxx>
      37             : #include <rtl/ref.hxx>
      38             : #include <comphelper/namedvaluecollection.hxx>
      39             : #include <cppuhelper/basemutex.hxx>
      40             : #include <cppuhelper/compbase1.hxx>
      41             : #include <com/sun/star/ui/XSidebar.hpp>
      42             : #include <com/sun/star/ui/XUIElementFactory.hpp>
      43             : 
      44             : #include <boost/bind.hpp>
      45             : #include <boost/noncopyable.hpp>
      46             : 
      47             : namespace cssu = ::com::sun::star::uno;
      48             : using namespace css;
      49             : using namespace cssu;
      50             : using namespace svx::sidebar;
      51             : 
      52             : 
      53             : namespace {
      54             : 
      55             : /* Why this is not used ? Doesn't it need to inherit from XServiceInfo ?
      56             : #define IMPLEMENTATION_NAME "org.apache.openoffice.comp.svx.sidebar.PanelFactory"
      57             : #define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
      58             : */
      59             : 
      60             : typedef ::cppu::WeakComponentImplHelper1< css::ui::XUIElementFactory >
      61             :     PanelFactoryInterfaceBase;
      62             : 
      63             : class PanelFactory
      64             :     : private ::boost::noncopyable,
      65             :       private ::cppu::BaseMutex,
      66             :       public PanelFactoryInterfaceBase
      67             : {
      68             : public:
      69             :     PanelFactory (void);
      70             :     virtual ~PanelFactory (void);
      71             : 
      72             :     // XUIElementFactory
      73             :     cssu::Reference<css::ui::XUIElement> SAL_CALL createUIElement (
      74             :         const ::rtl::OUString& rsResourceURL,
      75             :         const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
      76             :         throw(
      77             :             css::container::NoSuchElementException,
      78             :             css::lang::IllegalArgumentException,
      79             :             cssu::RuntimeException, std::exception) SAL_OVERRIDE;
      80             : };
      81             : 
      82           0 : PanelFactory::PanelFactory (void)
      83           0 :     : PanelFactoryInterfaceBase(m_aMutex)
      84             : {
      85           0 : }
      86             : 
      87             : 
      88             : 
      89             : 
      90           0 : PanelFactory::~PanelFactory (void)
      91             : {
      92           0 : }
      93             : 
      94             : 
      95             : 
      96             : 
      97           0 : Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
      98             :     const ::rtl::OUString& rsResourceURL,
      99             :     const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
     100             :     throw(
     101             :         container::NoSuchElementException,
     102             :         lang::IllegalArgumentException,
     103             :         RuntimeException, std::exception)
     104             : {
     105           0 :     const ::comphelper::NamedValueCollection aArguments (rArguments);
     106           0 :     Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
     107           0 :     Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
     108           0 :     Reference<ui::XSidebar> xSidebar (aArguments.getOrDefault("Sidebar", Reference<ui::XSidebar>()));
     109           0 :     const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
     110           0 :     SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
     111             :     ::sfx2::sidebar::EnumContext aContext (
     112             :         aArguments.getOrDefault("ApplicationName", OUString()),
     113           0 :         aArguments.getOrDefault("ContextName", OUString()));
     114             : 
     115           0 :     ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
     116           0 :     if ( ! xParentWindow.is() || pParentWindow==NULL)
     117             :         throw RuntimeException(
     118             :             "PanelFactory::createUIElement called without ParentWindow",
     119           0 :             NULL);
     120           0 :     if ( ! xFrame.is())
     121             :         throw RuntimeException(
     122             :             "PanelFactory::createUIElement called without Frame",
     123           0 :             NULL);
     124           0 :     if (pBindings == NULL)
     125             :         throw RuntimeException(
     126             :             "PanelFactory::createUIElement called without SfxBindings",
     127           0 :             NULL);
     128             : 
     129           0 :     Window* pControl = NULL;
     130           0 :     ui::LayoutSize aLayoutSize (-1,-1,-1);
     131             : 
     132             : #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
     133           0 :     if (DoesResourceEndWith("/TextPropertyPanel"))
     134             :     {
     135           0 :         pControl = TextPropertyPanel::Create(pParentWindow, xFrame, pBindings, aContext);
     136             :     }
     137           0 :     else if (DoesResourceEndWith("/ParaPropertyPanel"))
     138             :     {
     139           0 :         pControl = ParaPropertyPanel::Create(pParentWindow, xFrame, pBindings, xSidebar);
     140             :     }
     141           0 :     else if (DoesResourceEndWith("/AreaPropertyPanel"))
     142             :     {
     143           0 :         pControl = AreaPropertyPanel::Create(pParentWindow, xFrame, pBindings);
     144             :     }
     145           0 :     else if (DoesResourceEndWith("/GraphicPropertyPanel"))
     146             :     {
     147           0 :         pControl = GraphicPropertyPanel::Create(pParentWindow, xFrame, pBindings);
     148             :     }
     149           0 :     else if (DoesResourceEndWith("/LinePropertyPanel"))
     150             :     {
     151           0 :         pControl = LinePropertyPanel::Create(pParentWindow, xFrame, pBindings);
     152             :     }
     153           0 :     else if (DoesResourceEndWith("/PosSizePropertyPanel"))
     154             :     {
     155           0 :         pControl = PosSizePropertyPanel::Create(pParentWindow, xFrame, pBindings, xSidebar);
     156             :     }
     157           0 :     else if (DoesResourceEndWith("/InsertPropertyPanel"))
     158             :     {
     159           0 :         pControl = new InsertPropertyPanel(pParentWindow, xFrame);
     160             :     }
     161           0 :     else if (DoesResourceEndWith("/GalleryPanel"))
     162             :     {
     163           0 :         pControl = new GalleryControl(pBindings, pParentWindow);
     164           0 :         aLayoutSize = ui::LayoutSize(300,-1,400);
     165             :     }
     166           0 :     else if (DoesResourceEndWith("/StyleListPanel"))
     167             :     {
     168           0 :         pControl = new SfxTemplatePanelControl(pBindings, pParentWindow);
     169           0 :         aLayoutSize = ui::LayoutSize(0,-1,-1);
     170             :     }
     171           0 :     else if (DoesResourceEndWith("/Debug_ColorPanel"))
     172             :     {
     173           0 :         pControl = new ColorPanel(pParentWindow);
     174           0 :         aLayoutSize = ui::LayoutSize(300,-1,400);
     175             :     }
     176           0 :     else if (DoesResourceEndWith("/Debug_ContextPanel"))
     177             :     {
     178           0 :         pControl = new ContextPanel(pParentWindow);
     179           0 :         aLayoutSize = ui::LayoutSize(45,45,45);
     180             :     }
     181           0 :     else if (DoesResourceEndWith("/Debug_NotYetImplementedPanel"))
     182             :     {
     183           0 :         pControl = new NotYetImplementedPanel(pParentWindow);
     184           0 :         aLayoutSize = ui::LayoutSize(20,25,25);
     185             :     }
     186           0 :     else if (DoesResourceEndWith("/EmptyPanel"))
     187             :     {
     188           0 :         pControl = new EmptyPanel(pParentWindow);
     189           0 :         aLayoutSize = ui::LayoutSize(20,-1, 50);
     190             :     }
     191             : #undef DoesResourceEndWith
     192             : 
     193           0 :     if (pControl != NULL)
     194             :     {
     195             :         return sfx2::sidebar::SidebarPanelBase::Create(
     196             :             rsResourceURL,
     197             :             xFrame,
     198             :             pControl,
     199           0 :             aLayoutSize);
     200             :     }
     201             :     else
     202           0 :         return Reference<ui::XUIElement>();
     203             : }
     204             : 
     205             : }
     206             : 
     207             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     208           0 : org_apache_openoffice_comp_svx_sidebar_PanelFactory_get_implementation(
     209             :     css::uno::XComponentContext *,
     210             :     css::uno::Sequence<css::uno::Any> const &)
     211             : {
     212           0 :     return cppu::acquire(new PanelFactory);
     213         255 : }

Generated by: LCOV version 1.10