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

Generated by: LCOV version 1.11