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

Generated by: LCOV version 1.10