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

Generated by: LCOV version 1.10