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

Generated by: LCOV version 1.10