LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/propctrlr - defaulthelpprovider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 58 0.0 %
Date: 2012-12-17 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             :     /** === begin UNO using === **/
      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             :     /** === end UNO using === **/
      61             : 
      62             :     //====================================================================
      63             :     //= DefaultHelpProvider
      64             :     //====================================================================
      65             :     //--------------------------------------------------------------------
      66           0 :     DefaultHelpProvider::DefaultHelpProvider( const Reference< XComponentContext >& _rxContext )
      67             :         :m_aContext( _rxContext )
      68           0 :         ,m_bConstructed( false )
      69             :     {
      70           0 :     }
      71             : 
      72             :     //--------------------------------------------------------------------
      73           0 :     DefaultHelpProvider::~DefaultHelpProvider()
      74             :     {
      75           0 :     }
      76             : 
      77             :     //------------------------------------------------------------------------
      78           0 :     ::rtl::OUString DefaultHelpProvider::getImplementationName_static(  ) throw(RuntimeException)
      79             :     {
      80           0 :         return ::rtl::OUString("org.openoffice.comp.extensions.DefaultHelpProvider");
      81             :     }
      82             : 
      83             :     //------------------------------------------------------------------------
      84           0 :     Sequence< ::rtl::OUString > DefaultHelpProvider::getSupportedServiceNames_static(  ) throw(RuntimeException)
      85             :     {
      86           0 :         Sequence< ::rtl::OUString > aSupported(1);
      87           0 :         aSupported[0] = ::rtl::OUString("com.sun.star.inspection.DefaultHelpProvider");
      88           0 :         return aSupported;
      89             :     }
      90             : 
      91             :     //------------------------------------------------------------------------
      92           0 :     Reference< XInterface > SAL_CALL DefaultHelpProvider::Create( const Reference< XComponentContext >& _rxContext )
      93             :     {
      94           0 :         return *new DefaultHelpProvider( _rxContext );
      95             :     }
      96             : 
      97             :     //--------------------------------------------------------------------
      98           0 :     void SAL_CALL DefaultHelpProvider::focusGained( const Reference< XPropertyControl >& _Control ) throw (RuntimeException)
      99             :     {
     100           0 :         if ( !m_xInspectorUI.is() )
     101           0 :             throw RuntimeException( ::rtl::OUString(), *this );
     102             : 
     103             :         try
     104             :         {
     105           0 :             m_xInspectorUI->setHelpSectionText( impl_getHelpText_nothrow( _Control ) );
     106             :         }
     107           0 :         catch( const Exception& )
     108             :         {
     109             :             DBG_UNHANDLED_EXCEPTION();
     110             :         }
     111           0 :     }
     112             : 
     113             :     //--------------------------------------------------------------------
     114           0 :     void SAL_CALL DefaultHelpProvider::valueChanged( const Reference< XPropertyControl >& /*_Control*/ ) throw (RuntimeException)
     115             :     {
     116             :         // not interested in
     117           0 :     }
     118             : 
     119             :     //--------------------------------------------------------------------
     120           0 :     void SAL_CALL DefaultHelpProvider::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
     121             :     {
     122           0 :         if ( m_bConstructed )
     123           0 :             throw AlreadyInitializedException();
     124             : 
     125           0 :         StlSyntaxSequence< Any > arguments( _arguments );
     126           0 :         if ( arguments.size() == 1 )
     127             :         {   // constructor: "create( XObjectInspectorUI )"
     128           0 :             Reference< XObjectInspectorUI > xUI( arguments[0], UNO_QUERY );
     129           0 :             create( xUI );
     130           0 :             return;
     131             :         }
     132             : 
     133           0 :         throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
     134             :     }
     135             : 
     136             :     //--------------------------------------------------------------------
     137           0 :     void DefaultHelpProvider::create( const Reference< XObjectInspectorUI >& _rxUI )
     138             :     {
     139           0 :         if ( !_rxUI.is() )
     140           0 :             throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
     141             : 
     142             :         try
     143             :         {
     144           0 :             m_xInspectorUI = _rxUI;
     145           0 :             m_xInspectorUI->registerControlObserver( this );
     146             :         }
     147           0 :         catch( const Exception& )
     148             :         {
     149             :             DBG_UNHANDLED_EXCEPTION();
     150             :         }
     151             : 
     152           0 :         m_bConstructed = true;
     153           0 :     }
     154             : 
     155             :     //--------------------------------------------------------------------
     156           0 :     Window* DefaultHelpProvider::impl_getVclControlWindow_nothrow( const Reference< XPropertyControl >& _rxControl )
     157             :     {
     158           0 :         Window* pControlWindow = NULL;
     159             :         OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getVclControlWindow_nothrow: illegal control!" );
     160           0 :         if ( !_rxControl.is() )
     161           0 :             return pControlWindow;
     162             : 
     163             :         try
     164             :         {
     165           0 :             Reference< XWindow > xControlWindow( _rxControl->getControlWindow(), UNO_QUERY_THROW );
     166           0 :             pControlWindow = VCLUnoHelper::GetWindow( xControlWindow );
     167             :         }
     168           0 :         catch( const Exception& )
     169             :         {
     170             :             DBG_UNHANDLED_EXCEPTION();
     171             :         }
     172             : 
     173           0 :         return pControlWindow;
     174             :     }
     175             : 
     176             :     //--------------------------------------------------------------------
     177           0 :     ::rtl::OUString DefaultHelpProvider::impl_getHelpText_nothrow( const Reference< XPropertyControl >& _rxControl )
     178             :     {
     179           0 :         ::rtl::OUString sHelpText;
     180             :         OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getHelpText_nothrow: illegal control!" );
     181           0 :         if ( !_rxControl.is() )
     182           0 :             return sHelpText;
     183             : 
     184           0 :         Window* pControlWindow( impl_getVclControlWindow_nothrow( _rxControl ) );
     185             :         OSL_ENSURE( pControlWindow, "DefaultHelpProvider::impl_getHelpText_nothrow: could not determine the VCL window!" );
     186           0 :         if ( !pControlWindow )
     187           0 :             return sHelpText;
     188             : 
     189           0 :         sHelpText = pControlWindow->GetHelpText();
     190           0 :         return sHelpText;
     191             :     }
     192             : //........................................................................
     193             : } // namespace pcr
     194             : //........................................................................
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10