LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/core/recovery - subcomponentloader.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 50 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             : 
      21             : #include "subcomponentloader.hxx"
      22             : 
      23             : #include <com/sun/star/ucb/Command.hpp>
      24             : #include <com/sun/star/frame/XController2.hpp>
      25             : 
      26             : #include <tools/diagnose_ex.h>
      27             : 
      28             : //........................................................................
      29             : namespace dbaccess
      30             : {
      31             : //........................................................................
      32             : 
      33             :     /** === begin UNO using === **/
      34             :     using ::com::sun::star::uno::Reference;
      35             :     using ::com::sun::star::uno::XInterface;
      36             :     using ::com::sun::star::uno::UNO_QUERY;
      37             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      38             :     using ::com::sun::star::uno::UNO_SET_THROW;
      39             :     using ::com::sun::star::uno::Exception;
      40             :     using ::com::sun::star::uno::RuntimeException;
      41             :     using ::com::sun::star::uno::Any;
      42             :     using ::com::sun::star::uno::makeAny;
      43             :     using ::com::sun::star::uno::Sequence;
      44             :     using ::com::sun::star::uno::Type;
      45             :     using ::com::sun::star::frame::XController;
      46             :     using ::com::sun::star::frame::XFrame;
      47             :     using ::com::sun::star::awt::XWindow;
      48             :     using ::com::sun::star::awt::WindowEvent;
      49             :     using ::com::sun::star::lang::EventObject;
      50             :     using ::com::sun::star::ucb::Command;
      51             :     using ::com::sun::star::ucb::XCommandProcessor;
      52             :     using ::com::sun::star::frame::XController2;
      53             :     using ::com::sun::star::lang::XComponent;
      54             :     /** === end UNO using === **/
      55             : 
      56             :     //====================================================================
      57             :     //= SubComponentLoader
      58             :     //====================================================================
      59           0 :     struct DBACCESS_DLLPRIVATE SubComponentLoader_Data
      60             :     {
      61             :         const Reference< XCommandProcessor >    xDocDefCommands;
      62             :         const Reference< XComponent >           xNonDocComponent;
      63             :         Reference< XWindow >                    xAppComponentWindow;
      64             : 
      65           0 :         SubComponentLoader_Data( const Reference< XCommandProcessor >& i_rDocumentDefinition )
      66             :             :xDocDefCommands( i_rDocumentDefinition, UNO_SET_THROW )
      67           0 :             ,xNonDocComponent()
      68             :         {
      69           0 :         }
      70             : 
      71           0 :         SubComponentLoader_Data( const Reference< XComponent >& i_rNonDocumentComponent )
      72             :             :xDocDefCommands()
      73           0 :             ,xNonDocComponent( i_rNonDocumentComponent, UNO_SET_THROW )
      74             :         {
      75           0 :         }
      76             :     };
      77             : 
      78             :     //====================================================================
      79             :     //= helper
      80             :     //====================================================================
      81             :     namespace
      82             :     {
      83             :         //................................................................
      84           0 :         void lcl_onWindowShown_nothrow( const SubComponentLoader_Data& i_rData )
      85             :         {
      86             :             try
      87             :             {
      88           0 :                 if ( i_rData.xDocDefCommands.is() )
      89             :                 {
      90           0 :                     Command aCommandOpen;
      91           0 :                     aCommandOpen.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "show" ) );
      92             : 
      93           0 :                     const sal_Int32 nCommandIdentifier = i_rData.xDocDefCommands->createCommandIdentifier();
      94           0 :                     i_rData.xDocDefCommands->execute( aCommandOpen, nCommandIdentifier, NULL );
      95             :                 }
      96             :                 else
      97             :                 {
      98           0 :                     const Reference< XController > xController( i_rData.xNonDocComponent, UNO_QUERY_THROW );
      99           0 :                     const Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
     100           0 :                     const Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
     101           0 :                     xWindow->setVisible( sal_True );
     102             :                 }
     103             :             }
     104           0 :             catch( const Exception& )
     105             :             {
     106             :                 DBG_UNHANDLED_EXCEPTION();
     107             :             }
     108           0 :         }
     109             :     }
     110             : 
     111             :     //====================================================================
     112             :     //= SubComponentLoader
     113             :     //====================================================================
     114             :     //--------------------------------------------------------------------
     115           0 :     SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
     116             :             const Reference< XCommandProcessor >& i_rSubDocumentDefinition )
     117           0 :         :m_pData( new SubComponentLoader_Data( i_rSubDocumentDefinition ) )
     118             :     {
     119             :         // add as window listener to the controller's container window, so we get notified when it is shown
     120           0 :         Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
     121           0 :         m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
     122             : 
     123           0 :         osl_atomic_increment( &m_refCount );
     124             :         {
     125           0 :             m_pData->xAppComponentWindow->addWindowListener( this );
     126             :         }
     127           0 :         osl_atomic_decrement( &m_refCount );
     128           0 :     }
     129             : 
     130             :     //--------------------------------------------------------------------
     131           0 :     SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
     132             :             const Reference< XComponent >& i_rNonDocumentComponent )
     133           0 :         :m_pData( new SubComponentLoader_Data( i_rNonDocumentComponent ) )
     134             :     {
     135             :         // add as window listener to the controller's container window, so we get notified when it is shown
     136           0 :         Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
     137           0 :         m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
     138             : 
     139           0 :         osl_atomic_increment( &m_refCount );
     140             :         {
     141           0 :             m_pData->xAppComponentWindow->addWindowListener( this );
     142             :         }
     143           0 :         osl_atomic_decrement( &m_refCount );
     144           0 :     }
     145             : 
     146             :     //--------------------------------------------------------------------
     147           0 :     SubComponentLoader::~SubComponentLoader()
     148             :     {
     149           0 :         delete m_pData, m_pData = NULL;
     150           0 :     }
     151             : 
     152             :     //--------------------------------------------------------------------
     153           0 :     void SAL_CALL SubComponentLoader::windowResized( const WindowEvent& i_rEvent ) throw (RuntimeException)
     154             :     {
     155             :         // not interested in
     156             :         (void)i_rEvent;
     157           0 :     }
     158             : 
     159             :     //--------------------------------------------------------------------
     160           0 :     void SAL_CALL SubComponentLoader::windowMoved( const WindowEvent& i_rEvent ) throw (RuntimeException)
     161             :     {
     162             :         // not interested in
     163             :         (void)i_rEvent;
     164           0 :     }
     165             : 
     166             :     //--------------------------------------------------------------------
     167           0 :     void SAL_CALL SubComponentLoader::windowShown( const EventObject& i_rEvent ) throw (RuntimeException)
     168             :     {
     169             :         (void)i_rEvent;
     170             : 
     171           0 :         lcl_onWindowShown_nothrow( *m_pData );
     172           0 :         m_pData->xAppComponentWindow->removeWindowListener( this );
     173           0 :     }
     174             : 
     175             :     //--------------------------------------------------------------------
     176           0 :     void SAL_CALL SubComponentLoader::windowHidden( const EventObject& i_rEvent ) throw (RuntimeException)
     177             :     {
     178             :         // not interested in
     179             :         (void)i_rEvent;
     180           0 :     }
     181             : 
     182             :     //--------------------------------------------------------------------
     183           0 :     void SAL_CALL SubComponentLoader::disposing( const EventObject& i_rEvent ) throw (RuntimeException)
     184             :     {
     185             :         // not interested in
     186             :         (void)i_rEvent;
     187           0 :     }
     188             : 
     189             : //........................................................................
     190             : } // namespace dbaccess
     191             : //........................................................................
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10