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

Generated by: LCOV version 1.10