LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - defaulthelpprovider.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 58 15.5 %
Date: 2015-06-13 12:38:46 Functions: 3 13 23.1 %
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 "defaulthelpprovider.hxx"
      22             : #include "pcrcommon.hxx"
      23             : #include "pcrservices.hxx"
      24             : #include "modulepcr.hxx"
      25             : 
      26             : #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
      27             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      28             : #include <com/sun/star/awt/XVclWindowPeer.hpp>
      29             : 
      30             : #include <toolkit/helper/vclunohelper.hxx>
      31             : #include <vcl/window.hxx>
      32             : #include <tools/diagnose_ex.h>
      33             : 
      34             : 
      35           2 : extern "C" void SAL_CALL createRegistryInfo_DefaultHelpProvider()
      36             : {
      37           2 :     ::pcr::OAutoRegistration< ::pcr::DefaultHelpProvider > aAutoRegistration;
      38           2 : }
      39             : 
      40             : 
      41             : namespace pcr
      42             : {
      43             : 
      44             : 
      45             :     using ::com::sun::star::uno::Reference;
      46             :     using ::com::sun::star::uno::XComponentContext;
      47             :     using ::com::sun::star::inspection::XPropertyControl;
      48             :     using ::com::sun::star::uno::RuntimeException;
      49             :     using ::com::sun::star::uno::Sequence;
      50             :     using ::com::sun::star::uno::Any;
      51             :     using ::com::sun::star::uno::Exception;
      52             :     using ::com::sun::star::inspection::XObjectInspectorUI;
      53             :     using ::com::sun::star::uno::XInterface;
      54             :     using ::com::sun::star::ucb::AlreadyInitializedException;
      55             :     using ::com::sun::star::lang::IllegalArgumentException;
      56             :     using ::com::sun::star::uno::UNO_QUERY;
      57             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      58             :     using ::com::sun::star::awt::XWindow;
      59             :     using ::com::sun::star::awt::XVclWindowPeer;
      60             : 
      61           0 :     DefaultHelpProvider::DefaultHelpProvider()
      62           0 :         :m_bConstructed( false )
      63             :     {
      64           0 :     }
      65             : 
      66             : 
      67           0 :     DefaultHelpProvider::~DefaultHelpProvider()
      68             :     {
      69           0 :     }
      70             : 
      71             : 
      72           2 :     OUString DefaultHelpProvider::getImplementationName_static(  ) throw(RuntimeException)
      73             :     {
      74           2 :         return OUString("org.openoffice.comp.extensions.DefaultHelpProvider");
      75             :     }
      76             : 
      77             : 
      78           2 :     Sequence< OUString > DefaultHelpProvider::getSupportedServiceNames_static(  ) throw(RuntimeException)
      79             :     {
      80           2 :         Sequence< OUString > aSupported(1);
      81           2 :         aSupported[0] = "com.sun.star.inspection.DefaultHelpProvider";
      82           2 :         return aSupported;
      83             :     }
      84             : 
      85             : 
      86           0 :     Reference< XInterface > SAL_CALL DefaultHelpProvider::Create( const Reference< XComponentContext >& )
      87             :     {
      88           0 :         return *new DefaultHelpProvider;
      89             :     }
      90             : 
      91             : 
      92           0 :     void SAL_CALL DefaultHelpProvider::focusGained( const Reference< XPropertyControl >& _Control ) throw (RuntimeException, std::exception)
      93             :     {
      94           0 :         if ( !m_xInspectorUI.is() )
      95           0 :             throw RuntimeException( OUString(), *this );
      96             : 
      97             :         try
      98             :         {
      99           0 :             m_xInspectorUI->setHelpSectionText( impl_getHelpText_nothrow( _Control ) );
     100             :         }
     101           0 :         catch( const Exception& )
     102             :         {
     103             :             DBG_UNHANDLED_EXCEPTION();
     104             :         }
     105           0 :     }
     106             : 
     107             : 
     108           0 :     void SAL_CALL DefaultHelpProvider::valueChanged( const Reference< XPropertyControl >& /*_Control*/ ) throw (RuntimeException, std::exception)
     109             :     {
     110             :         // not interested in
     111           0 :     }
     112             : 
     113             : 
     114           0 :     void SAL_CALL DefaultHelpProvider::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException, std::exception)
     115             :     {
     116           0 :         if ( m_bConstructed )
     117           0 :             throw AlreadyInitializedException();
     118             : 
     119           0 :         StlSyntaxSequence< Any > arguments( _arguments );
     120           0 :         if ( arguments.size() == 1 )
     121             :         {   // constructor: "create( XObjectInspectorUI )"
     122           0 :             Reference< XObjectInspectorUI > xUI( arguments[0], UNO_QUERY );
     123           0 :             create( xUI );
     124           0 :             return;
     125             :         }
     126             : 
     127           0 :         throw IllegalArgumentException( OUString(), *this, 0 );
     128             :     }
     129             : 
     130             : 
     131           0 :     void DefaultHelpProvider::create( const Reference< XObjectInspectorUI >& _rxUI )
     132             :     {
     133           0 :         if ( !_rxUI.is() )
     134           0 :             throw IllegalArgumentException( OUString(), *this, 1 );
     135             : 
     136             :         try
     137             :         {
     138           0 :             m_xInspectorUI = _rxUI;
     139           0 :             m_xInspectorUI->registerControlObserver( this );
     140             :         }
     141           0 :         catch( const Exception& )
     142             :         {
     143             :             DBG_UNHANDLED_EXCEPTION();
     144             :         }
     145             : 
     146           0 :         m_bConstructed = true;
     147           0 :     }
     148             : 
     149             : 
     150           0 :     vcl::Window* DefaultHelpProvider::impl_getVclControlWindow_nothrow( const Reference< XPropertyControl >& _rxControl )
     151             :     {
     152           0 :         vcl::Window* pControlWindow = NULL;
     153             :         OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getVclControlWindow_nothrow: illegal control!" );
     154           0 :         if ( !_rxControl.is() )
     155           0 :             return pControlWindow;
     156             : 
     157             :         try
     158             :         {
     159           0 :             Reference< XWindow > xControlWindow( _rxControl->getControlWindow(), UNO_QUERY_THROW );
     160           0 :             pControlWindow = VCLUnoHelper::GetWindow( xControlWindow );
     161             :         }
     162           0 :         catch( const Exception& )
     163             :         {
     164             :             DBG_UNHANDLED_EXCEPTION();
     165             :         }
     166             : 
     167           0 :         return pControlWindow;
     168             :     }
     169             : 
     170             : 
     171           0 :     OUString DefaultHelpProvider::impl_getHelpText_nothrow( const Reference< XPropertyControl >& _rxControl )
     172             :     {
     173           0 :         OUString sHelpText;
     174             :         OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getHelpText_nothrow: illegal control!" );
     175           0 :         if ( !_rxControl.is() )
     176           0 :             return sHelpText;
     177             : 
     178           0 :         vcl::Window* pControlWindow( impl_getVclControlWindow_nothrow( _rxControl ) );
     179             :         OSL_ENSURE( pControlWindow, "DefaultHelpProvider::impl_getHelpText_nothrow: could not determine the VCL window!" );
     180           0 :         if ( !pControlWindow )
     181           0 :             return sHelpText;
     182             : 
     183           0 :         sHelpText = pControlWindow->GetHelpText();
     184           0 :         return sHelpText;
     185             :     }
     186             : 
     187             : } // namespace pcr
     188             : 
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11