LCOV - code coverage report
Current view: top level - libreoffice/uui/source - interactionhandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 50 44.0 %
Date: 2012-12-27 Functions: 6 11 54.5 %
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 "iahndl.hxx"
      21             : #include "interactionhandler.hxx"
      22             : #include "comphelper/namedvaluecollection.hxx"
      23             : #include "com/sun/star/awt/XWindow.hpp"
      24             : 
      25             : using namespace com::sun::star;
      26             : 
      27           4 : UUIInteractionHandler::UUIInteractionHandler(
      28             :     uno::Reference< lang::XMultiServiceFactory > const &
      29             :         rServiceFactory)
      30             :     SAL_THROW(())
      31             :         : m_xServiceFactory(rServiceFactory),
      32           4 :           m_pImpl(new UUIInteractionHelper(m_xServiceFactory))
      33             : {
      34           4 : }
      35             : 
      36           9 : UUIInteractionHandler::~UUIInteractionHandler()
      37             : {
      38           3 :     delete m_pImpl;
      39           6 : }
      40             : 
      41           0 : rtl::OUString SAL_CALL UUIInteractionHandler::getImplementationName()
      42             :     throw (uno::RuntimeException)
      43             : {
      44           0 :     return rtl::OUString::createFromAscii(m_aImplementationName);
      45             : }
      46             : 
      47             : sal_Bool SAL_CALL
      48           0 : UUIInteractionHandler::supportsService(rtl::OUString const & rServiceName)
      49             :     throw (uno::RuntimeException)
      50             : {
      51             :     uno::Sequence< rtl::OUString >
      52           0 :     aNames(getSupportedServiceNames_static());
      53           0 :     for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
      54           0 :         if (aNames[i] == rServiceName)
      55           0 :             return true;
      56           0 :     return false;
      57             : }
      58             : 
      59             : uno::Sequence< rtl::OUString > SAL_CALL
      60           0 : UUIInteractionHandler::getSupportedServiceNames()
      61             :     throw (uno::RuntimeException)
      62             : {
      63           0 :     return getSupportedServiceNames_static();
      64             : }
      65             : 
      66             : void SAL_CALL
      67           4 : UUIInteractionHandler::initialize(
      68             :     uno::Sequence< uno::Any > const & rArguments)
      69             :     throw (uno::Exception)
      70             : {
      71           4 :     delete m_pImpl;
      72             : 
      73             :     // The old-style InteractionHandler service supported a sequence of
      74             :     // PropertyValue, while the new-style service now uses constructors to pass
      75             :     // in Parent and Context values; for backwards compatibility, keep support
      76             :     // for a PropertyValue sequence, too:
      77           4 :     uno::Reference< awt::XWindow > xWindow;
      78           4 :     rtl::OUString aContext;
      79          12 :     if (!((rArguments.getLength() == 1 && (rArguments[0] >>= xWindow)) ||
      80           0 :           (rArguments.getLength() == 2 && (rArguments[0] >>= xWindow) &&
      81           8 :            (rArguments[1] >>= aContext))))
      82             :     {
      83           0 :         ::comphelper::NamedValueCollection aProperties( rArguments );
      84           0 :         if ( aProperties.has( "Parent" ) )
      85             :         {
      86           0 :             OSL_VERIFY( aProperties.get( "Parent" ) >>= xWindow );
      87             :         }
      88           0 :         if ( aProperties.has( "Context" ) )
      89             :         {
      90           0 :             OSL_VERIFY( aProperties.get( "Context" ) >>= aContext );
      91           0 :         }
      92             :     }
      93             : 
      94           4 :     m_pImpl = new UUIInteractionHelper(m_xServiceFactory, xWindow, aContext);
      95           4 : }
      96             : 
      97             : void SAL_CALL
      98           0 : UUIInteractionHandler::handle(
      99             :     uno::Reference< task::XInteractionRequest > const & rRequest)
     100             :     throw (uno::RuntimeException)
     101             : {
     102             :     try
     103             :     {
     104           0 :         m_pImpl->handleRequest(rRequest);
     105             :     }
     106           0 :     catch (uno::RuntimeException const & ex)
     107             :     {
     108           0 :         throw uno::RuntimeException(ex.Message, *this);
     109             :     }
     110           0 : }
     111             : 
     112           0 : ::sal_Bool SAL_CALL UUIInteractionHandler::handleInteractionRequest(
     113             :     const uno::Reference< task::XInteractionRequest >& _Request ) throw ( uno::RuntimeException )
     114             : {
     115             :     try
     116             :     {
     117           0 :         return m_pImpl->handleRequest( _Request );
     118             :     }
     119           0 :     catch (uno::RuntimeException const & ex)
     120             :     {
     121           0 :         throw uno::RuntimeException( ex.Message, *this );
     122             :     }
     123             : }
     124             : 
     125             : char const UUIInteractionHandler::m_aImplementationName[]
     126             :     = "com.sun.star.comp.uui.UUIInteractionHandler";
     127             : 
     128             : uno::Sequence< OUString >
     129           2 : UUIInteractionHandler::getSupportedServiceNames_static()
     130             : {
     131           2 :     uno::Sequence< OUString > aNames(3);
     132           2 :     aNames[0] = "com.sun.star.task.InteractionHandler";
     133             :     // added to indicate support for configuration.backend.MergeRecoveryRequest
     134           2 :     aNames[1] = "com.sun.star.configuration.backend.InteractionHandler";
     135           2 :     aNames[2] = "com.sun.star.uui.InteractionHandler";
     136             :     // for backwards compatibility
     137           2 :     return aNames;
     138             : }
     139             : 
     140             : uno::Reference< uno::XInterface > SAL_CALL
     141           4 : UUIInteractionHandler::createInstance(
     142             :     uno::Reference< lang::XMultiServiceFactory > const &
     143             :         rServiceFactory)
     144             :     SAL_THROW((uno::Exception))
     145             : {
     146             :     try
     147             :     {
     148           4 :         return *new UUIInteractionHandler(rServiceFactory);
     149             :     }
     150           0 :     catch (std::bad_alloc const &)
     151             :     {
     152           0 :         throw uno::RuntimeException(OUString("out of memory"), 0);
     153             :     }
     154             : }
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10