LCOV - code coverage report
Current view: top level - framework/source/tabwin - tabwinfactory.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 47 0.0 %
Date: 2014-04-14 Functions: 0 13 0.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 <tabwin/tabwinfactory.hxx>
      21             : #include <tabwin/tabwindow.hxx>
      22             : 
      23             : #include <com/sun/star/util/XURLTransformer.hpp>
      24             : #include <com/sun/star/lang/XInitialization.hpp>
      25             : #include <com/sun/star/awt/Toolkit.hpp>
      26             : #include <com/sun/star/awt/XTopWindow.hpp>
      27             : #include <com/sun/star/awt/WindowAttribute.hpp>
      28             : 
      29             : #include <vcl/svapp.hxx>
      30             : #include <rtl/ustrbuf.hxx>
      31             : 
      32             : //  Defines
      33             : 
      34             : using namespace com::sun::star::uno;
      35             : using namespace com::sun::star::lang;
      36             : using namespace com::sun::star::beans;
      37             : using namespace com::sun::star::util;
      38             : 
      39             : namespace framework
      40             : {
      41             : 
      42             : //  XInterface, XTypeProvider, XServiceInfo
      43             : 
      44           0 : DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2(   TabWinFactory                                   ,
      45             :                                             ::cppu::OWeakObject                             ,
      46             :                                             SERVICENAME_TABWINFACTORY                       ,
      47             :                                             IMPLEMENTATIONNAME_TABWINFACTORY
      48             :                                         )
      49             : 
      50           0 : DEFINE_INIT_SERVICE                     (   TabWinFactory, {} )
      51             : 
      52           0 : TabWinFactory::TabWinFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
      53           0 :     m_xContext( xContext )
      54             : {
      55           0 : }
      56             : 
      57           0 : TabWinFactory::~TabWinFactory()
      58             : {
      59           0 : }
      60             : 
      61           0 : css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithContext(
      62             :     const css::uno::Reference< css::uno::XComponentContext >& xContext )
      63             : throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
      64             : {
      65           0 :     css::uno::Sequence< css::uno::Any > aArgs;
      66             : 
      67           0 :     return createInstanceWithArgumentsAndContext( aArgs, xContext );
      68             : }
      69             : 
      70           0 : css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithArgumentsAndContext(
      71             :     const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& )
      72             : throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
      73             : {
      74           0 :     const OUString aTopWindowArgName( "TopWindow");
      75             : 
      76             :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
      77           0 :     SolarMutexResettableGuard aLock;
      78           0 :     css::uno::Reference< css::awt::XToolkit2 > xToolkit = m_xToolkit;
      79           0 :     css::uno::Reference< css::uno::XComponentContext > xContext( m_xContext );
      80           0 :     aLock.clear();
      81             :     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
      82             : 
      83           0 :     css::uno::Reference< css::uno::XInterface > xReturn;
      84           0 :     css::uno::Reference< css::awt::XTopWindow > xTopWindow;
      85           0 :     css::beans::PropertyValue                   aPropValue;
      86             : 
      87           0 :     for ( sal_Int32 i = 0; i < Arguments.getLength(); i++ )
      88             :     {
      89           0 :         if ( Arguments[i] >>= aPropValue )
      90             :         {
      91           0 :             if ( aPropValue.Name == aTopWindowArgName )
      92           0 :                 aPropValue.Value >>= xTopWindow;
      93             :         }
      94             :     }
      95             : 
      96           0 :     if ( !xToolkit.is() && xContext.is() )
      97             :     {
      98           0 :         xToolkit = css::awt::Toolkit::create( xContext );
      99             :         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     100           0 :         aLock.reset();
     101           0 :         m_xToolkit = xToolkit;
     102           0 :         aLock.clear();
     103             :         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
     104             :     }
     105             : 
     106           0 :     if ( !xTopWindow.is() )
     107             :     {
     108             :         // describe window properties.
     109           0 :         css::awt::WindowDescriptor aDescriptor;
     110           0 :         aDescriptor.Type                =   css::awt::WindowClass_TOP;
     111           0 :         aDescriptor.ParentIndex         =   -1;
     112           0 :         aDescriptor.Parent              =   css::uno::Reference< css::awt::XWindowPeer >();
     113           0 :         aDescriptor.Bounds              =   css::awt::Rectangle(0,0,0,0);
     114             :         aDescriptor.WindowAttributes    =   css::awt::WindowAttribute::BORDER|
     115             :                                             css::awt::WindowAttribute::SIZEABLE|
     116             :                                             css::awt::WindowAttribute::MOVEABLE|
     117             :                                             css::awt::WindowAttribute::CLOSEABLE|
     118           0 :                                             css::awt::WindowAttribute::MINSIZE;
     119             : 
     120             :         // create a parent window
     121           0 :         xTopWindow = css::uno::Reference< css::awt::XTopWindow >(
     122           0 :                         xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY );
     123             :     }
     124             : 
     125           0 :     if ( xTopWindow.is() )
     126             :     {
     127           0 :         TabWindow* pTabWindow = new TabWindow( xContext );
     128             : 
     129           0 :         css::uno::Sequence< css::uno::Any > aArgs( 1 );
     130             : 
     131           0 :         aPropValue.Name  = aTopWindowArgName;
     132           0 :         aPropValue.Value = css::uno::makeAny( xTopWindow );
     133           0 :         aArgs[0] = css::uno::makeAny( aPropValue );
     134           0 :         pTabWindow->initialize( aArgs );
     135             : 
     136           0 :         xReturn = css::uno::Reference< css::uno::XInterface >(
     137           0 :                     static_cast< OWeakObject* >( pTabWindow ), css::uno::UNO_QUERY );
     138             :     }
     139             : 
     140           0 :     return xReturn;
     141             : }
     142             : 
     143             : }
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10