LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/propctrlr - buttonnavigationhandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 111 0.0 %
Date: 2012-12-17 Functions: 0 16 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             : #include "buttonnavigationhandler.hxx"
      21             : #include "formstrings.hxx"
      22             : #include "formmetadata.hxx"
      23             : #include "pushbuttonnavigation.hxx"
      24             : 
      25             : #include <tools/debug.hxx>
      26             : 
      27             : //------------------------------------------------------------------------
      28           0 : extern "C" void SAL_CALL createRegistryInfo_ButtonNavigationHandler()
      29             : {
      30           0 :     ::pcr::ButtonNavigationHandler::registerImplementation();
      31           0 : }
      32             : 
      33             : //........................................................................
      34             : namespace pcr
      35             : {
      36             : //........................................................................
      37             : 
      38             :     using namespace ::com::sun::star::uno;
      39             :     using namespace ::com::sun::star::lang;
      40             :     using namespace ::com::sun::star::beans;
      41             :     using namespace ::com::sun::star::script;
      42             :     using namespace ::com::sun::star::frame;
      43             :     using namespace ::com::sun::star::inspection;
      44             : 
      45             :     //====================================================================
      46             :     //= ButtonNavigationHandler
      47             :     //====================================================================
      48             :     DBG_NAME( ButtonNavigationHandler )
      49             :     //--------------------------------------------------------------------
      50           0 :     ButtonNavigationHandler::ButtonNavigationHandler( const Reference< XComponentContext >& _rxContext )
      51           0 :         :ButtonNavigationHandler_Base( _rxContext )
      52             :     {
      53             :         DBG_CTOR( ButtonNavigationHandler, NULL );
      54             : 
      55             :         m_aContext.createComponent(
      56             :             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) ),
      57           0 :             m_xSlaveHandler );
      58           0 :         if ( !m_xSlaveHandler.is() )
      59           0 :             throw RuntimeException();
      60           0 :     }
      61             : 
      62             :     //--------------------------------------------------------------------
      63           0 :     ButtonNavigationHandler::~ButtonNavigationHandler( )
      64             :     {
      65             :         DBG_DTOR( ButtonNavigationHandler, NULL );
      66           0 :     }
      67             : 
      68             :     //--------------------------------------------------------------------
      69           0 :     ::rtl::OUString SAL_CALL ButtonNavigationHandler::getImplementationName_static(  ) throw (RuntimeException)
      70             :     {
      71           0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.ButtonNavigationHandler" ) );
      72             :     }
      73             : 
      74             :     //--------------------------------------------------------------------
      75           0 :     Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getSupportedServiceNames_static(  ) throw (RuntimeException)
      76             :     {
      77           0 :         Sequence< ::rtl::OUString > aSupported( 1 );
      78           0 :         aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.ButtonNavigationHandler" ) );
      79           0 :         return aSupported;
      80             :     }
      81             : 
      82             :     //--------------------------------------------------------------------
      83           0 :     void SAL_CALL ButtonNavigationHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
      84             :     {
      85           0 :         ButtonNavigationHandler_Base::inspect( _rxIntrospectee );
      86           0 :         m_xSlaveHandler->inspect( _rxIntrospectee );
      87           0 :     }
      88             : 
      89             :     //--------------------------------------------------------------------
      90           0 :     PropertyState  SAL_CALL ButtonNavigationHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
      91             :     {
      92           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      93           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
      94           0 :         PropertyState eState = PropertyState_DIRECT_VALUE;
      95           0 :         switch ( nPropId )
      96             :         {
      97             :         case PROPERTY_ID_BUTTONTYPE:
      98             :         {
      99           0 :             PushButtonNavigation aHelper( m_xComponent );
     100           0 :             eState = aHelper.getCurrentButtonTypeState();
     101             :         }
     102           0 :         break;
     103             :         case PROPERTY_ID_TARGET_URL:
     104             :         {
     105           0 :             PushButtonNavigation aHelper( m_xComponent );
     106           0 :             eState = aHelper.getCurrentTargetURLState();
     107             :         }
     108           0 :         break;
     109             : 
     110             :         default:
     111             :             OSL_FAIL( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" );
     112           0 :             break;
     113             :         }
     114             : 
     115           0 :         return eState;
     116             :     }
     117             : 
     118             :     //--------------------------------------------------------------------
     119           0 :     Any SAL_CALL ButtonNavigationHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
     120             :     {
     121           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     122           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     123             : 
     124           0 :         Any aReturn;
     125           0 :         switch ( nPropId )
     126             :         {
     127             :         case PROPERTY_ID_BUTTONTYPE:
     128             :         {
     129           0 :             PushButtonNavigation aHelper( m_xComponent );
     130           0 :             aReturn = aHelper.getCurrentButtonType();
     131             :         }
     132           0 :         break;
     133             : 
     134             :         case PROPERTY_ID_TARGET_URL:
     135             :         {
     136           0 :             PushButtonNavigation aHelper( m_xComponent );
     137           0 :             aReturn = aHelper.getCurrentTargetURL();
     138             :         }
     139           0 :         break;
     140             : 
     141             :         default:
     142             :             OSL_FAIL( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" );
     143           0 :             break;
     144             :         }
     145             : 
     146           0 :         return aReturn;
     147             :     }
     148             : 
     149             :     //--------------------------------------------------------------------
     150           0 :     void SAL_CALL ButtonNavigationHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
     151             :     {
     152           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     153           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     154           0 :         switch ( nPropId )
     155             :         {
     156             :         case PROPERTY_ID_BUTTONTYPE:
     157             :         {
     158           0 :             PushButtonNavigation aHelper( m_xComponent );
     159           0 :             aHelper.setCurrentButtonType( _rValue );
     160             :         }
     161           0 :         break;
     162             : 
     163             :         case PROPERTY_ID_TARGET_URL:
     164             :         {
     165           0 :             PushButtonNavigation aHelper( m_xComponent );
     166           0 :             aHelper.setCurrentTargetURL( _rValue );
     167             :         }
     168           0 :         break;
     169             : 
     170             :         default:
     171             :             OSL_FAIL( "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" );
     172           0 :         }
     173           0 :     }
     174             : 
     175             :     //--------------------------------------------------------------------
     176           0 :     bool ButtonNavigationHandler::isNavigationCapableButton( const Reference< XPropertySet >& _rxComponent )
     177             :     {
     178           0 :         Reference< XPropertySetInfo > xPSI;
     179           0 :         if ( _rxComponent.is() )
     180           0 :             xPSI = _rxComponent->getPropertySetInfo();
     181             : 
     182           0 :         return xPSI.is()
     183           0 :             && xPSI->hasPropertyByName( PROPERTY_TARGET_URL )
     184           0 :             && xPSI->hasPropertyByName( PROPERTY_BUTTONTYPE );
     185             :     }
     186             : 
     187             :     //--------------------------------------------------------------------
     188           0 :     Sequence< Property > SAL_CALL ButtonNavigationHandler::doDescribeSupportedProperties() const
     189             :     {
     190           0 :         ::std::vector< Property > aProperties;
     191             : 
     192           0 :         if ( isNavigationCapableButton( m_xComponent ) )
     193             :         {
     194           0 :             addStringPropertyDescription( aProperties, PROPERTY_TARGET_URL );
     195           0 :             implAddPropertyDescription( aProperties, PROPERTY_BUTTONTYPE, ::getCppuType( static_cast< sal_Int32* >( NULL ) ) );
     196             :         }
     197             : 
     198           0 :         if ( aProperties.empty() )
     199           0 :             return Sequence< Property >();
     200           0 :         return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
     201             :     }
     202             : 
     203             :     //--------------------------------------------------------------------
     204           0 :     Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getActuatingProperties( ) throw (RuntimeException)
     205             :     {
     206           0 :         Sequence< ::rtl::OUString > aActuating( 2 );
     207           0 :         aActuating[0] = PROPERTY_BUTTONTYPE;
     208           0 :         aActuating[1] = PROPERTY_TARGET_URL;
     209           0 :         return aActuating;
     210             :     }
     211             : 
     212             :     //--------------------------------------------------------------------
     213           0 :     InteractiveSelectionResult SAL_CALL ButtonNavigationHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
     214             :     {
     215           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     216           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     217             : 
     218           0 :         InteractiveSelectionResult eReturn( InteractiveSelectionResult_Cancelled );
     219             : 
     220           0 :         switch ( nPropId )
     221             :         {
     222             :         case PROPERTY_ID_TARGET_URL:
     223           0 :             eReturn = m_xSlaveHandler->onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
     224           0 :             break;
     225             :         default:
     226           0 :             eReturn = ButtonNavigationHandler_Base::onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
     227           0 :             break;
     228             :         }
     229             : 
     230           0 :         return eReturn;
     231             :     }
     232             : 
     233             :     //--------------------------------------------------------------------
     234           0 :     void SAL_CALL ButtonNavigationHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
     235             :     {
     236           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     237           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
     238           0 :         switch ( nPropId )
     239             :         {
     240             :         case PROPERTY_ID_BUTTONTYPE:
     241             :         {
     242           0 :             PushButtonNavigation aHelper( m_xComponent );
     243           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, aHelper.currentButtonTypeIsOpenURL() );
     244             :         }
     245           0 :         break;
     246             : 
     247             :         case PROPERTY_ID_TARGET_URL:
     248             :         {
     249           0 :             PushButtonNavigation aHelper( m_xComponent );
     250           0 :             _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME, aHelper.hasNonEmptyCurrentTargetURL() );
     251             :         }
     252           0 :         break;
     253             : 
     254             :         default:
     255             :             OSL_FAIL( "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" );
     256           0 :         }
     257           0 :     }
     258             : 
     259             :     //--------------------------------------------------------------------
     260           0 :     LineDescriptor SAL_CALL ButtonNavigationHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyControlFactory >& _rxControlFactory ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
     261             :     {
     262           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     263           0 :         PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
     264             : 
     265           0 :         LineDescriptor aReturn;
     266             : 
     267           0 :         switch ( nPropId )
     268             :         {
     269             :         case PROPERTY_ID_TARGET_URL:
     270           0 :             aReturn = m_xSlaveHandler->describePropertyLine( _rPropertyName, _rxControlFactory );
     271           0 :             break;
     272             :         default:
     273           0 :             aReturn = ButtonNavigationHandler_Base::describePropertyLine( _rPropertyName, _rxControlFactory );
     274           0 :             break;
     275             :         }
     276             : 
     277           0 :         return aReturn;
     278             :     }
     279             : 
     280             : //........................................................................
     281             : }   // namespace pcr
     282             : //........................................................................
     283             : 
     284             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10