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

Generated by: LCOV version 1.10