1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_extensions.hxx" 30*cdf0e10cSrcweir #include "buttonnavigationhandler.hxx" 31*cdf0e10cSrcweir #include "formstrings.hxx" 32*cdf0e10cSrcweir #include "formmetadata.hxx" 33*cdf0e10cSrcweir #include "pushbuttonnavigation.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir /** === begin UNO includes === **/ 36*cdf0e10cSrcweir /** === end UNO includes === **/ 37*cdf0e10cSrcweir #include <tools/debug.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir //------------------------------------------------------------------------ 40*cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_ButtonNavigationHandler() 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir ::pcr::ButtonNavigationHandler::registerImplementation(); 43*cdf0e10cSrcweir } 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir //........................................................................ 46*cdf0e10cSrcweir namespace pcr 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir //........................................................................ 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 51*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 52*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 53*cdf0e10cSrcweir using namespace ::com::sun::star::script; 54*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 55*cdf0e10cSrcweir using namespace ::com::sun::star::inspection; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir //==================================================================== 58*cdf0e10cSrcweir //= ButtonNavigationHandler 59*cdf0e10cSrcweir //==================================================================== 60*cdf0e10cSrcweir DBG_NAME( ButtonNavigationHandler ) 61*cdf0e10cSrcweir //-------------------------------------------------------------------- 62*cdf0e10cSrcweir ButtonNavigationHandler::ButtonNavigationHandler( const Reference< XComponentContext >& _rxContext ) 63*cdf0e10cSrcweir :ButtonNavigationHandler_Base( _rxContext ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir DBG_CTOR( ButtonNavigationHandler, NULL ); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir m_aContext.createComponent( 68*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) ), 69*cdf0e10cSrcweir m_xSlaveHandler ); 70*cdf0e10cSrcweir if ( !m_xSlaveHandler.is() ) 71*cdf0e10cSrcweir throw RuntimeException(); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir //-------------------------------------------------------------------- 75*cdf0e10cSrcweir ButtonNavigationHandler::~ButtonNavigationHandler( ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir DBG_DTOR( ButtonNavigationHandler, NULL ); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //-------------------------------------------------------------------- 81*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ButtonNavigationHandler::getImplementationName_static( ) throw (RuntimeException) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.ButtonNavigationHandler" ) ); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir //-------------------------------------------------------------------- 87*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getSupportedServiceNames_static( ) throw (RuntimeException) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported( 1 ); 90*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.ButtonNavigationHandler" ) ); 91*cdf0e10cSrcweir return aSupported; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir //-------------------------------------------------------------------- 95*cdf0e10cSrcweir void SAL_CALL ButtonNavigationHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir ButtonNavigationHandler_Base::inspect( _rxIntrospectee ); 98*cdf0e10cSrcweir m_xSlaveHandler->inspect( _rxIntrospectee ); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir //-------------------------------------------------------------------- 102*cdf0e10cSrcweir PropertyState SAL_CALL ButtonNavigationHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 105*cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); 106*cdf0e10cSrcweir PropertyState eState = PropertyState_DIRECT_VALUE; 107*cdf0e10cSrcweir switch ( nPropId ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir case PROPERTY_ID_BUTTONTYPE: 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 112*cdf0e10cSrcweir eState = aHelper.getCurrentButtonTypeState(); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir break; 115*cdf0e10cSrcweir case PROPERTY_ID_TARGET_URL: 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 118*cdf0e10cSrcweir eState = aHelper.getCurrentTargetURLState(); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir break; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir default: 123*cdf0e10cSrcweir DBG_ERROR( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" ); 124*cdf0e10cSrcweir break; 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir return eState; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir //-------------------------------------------------------------------- 131*cdf0e10cSrcweir Any SAL_CALL ButtonNavigationHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 134*cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir Any aReturn; 137*cdf0e10cSrcweir switch ( nPropId ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir case PROPERTY_ID_BUTTONTYPE: 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 142*cdf0e10cSrcweir aReturn = aHelper.getCurrentButtonType(); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir break; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir case PROPERTY_ID_TARGET_URL: 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 149*cdf0e10cSrcweir aReturn = aHelper.getCurrentTargetURL(); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir break; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir default: 154*cdf0e10cSrcweir DBG_ERROR( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" ); 155*cdf0e10cSrcweir break; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir return aReturn; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir //-------------------------------------------------------------------- 162*cdf0e10cSrcweir void SAL_CALL ButtonNavigationHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 165*cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); 166*cdf0e10cSrcweir switch ( nPropId ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir case PROPERTY_ID_BUTTONTYPE: 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 171*cdf0e10cSrcweir aHelper.setCurrentButtonType( _rValue ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir break; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir case PROPERTY_ID_TARGET_URL: 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 178*cdf0e10cSrcweir aHelper.setCurrentTargetURL( _rValue ); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir break; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir default: 183*cdf0e10cSrcweir OSL_ENSURE( sal_False, "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir //-------------------------------------------------------------------- 188*cdf0e10cSrcweir bool ButtonNavigationHandler::isNavigationCapableButton( const Reference< XPropertySet >& _rxComponent ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir Reference< XPropertySetInfo > xPSI; 191*cdf0e10cSrcweir if ( _rxComponent.is() ) 192*cdf0e10cSrcweir xPSI = _rxComponent->getPropertySetInfo(); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir return xPSI.is() 195*cdf0e10cSrcweir && xPSI->hasPropertyByName( PROPERTY_TARGET_URL ) 196*cdf0e10cSrcweir && xPSI->hasPropertyByName( PROPERTY_BUTTONTYPE ); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir //-------------------------------------------------------------------- 200*cdf0e10cSrcweir Sequence< Property > SAL_CALL ButtonNavigationHandler::doDescribeSupportedProperties() const 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir ::std::vector< Property > aProperties; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir if ( isNavigationCapableButton( m_xComponent ) ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir addStringPropertyDescription( aProperties, PROPERTY_TARGET_URL ); 207*cdf0e10cSrcweir implAddPropertyDescription( aProperties, PROPERTY_BUTTONTYPE, ::getCppuType( static_cast< sal_Int32* >( NULL ) ) ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir if ( aProperties.empty() ) 211*cdf0e10cSrcweir return Sequence< Property >(); 212*cdf0e10cSrcweir return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir //-------------------------------------------------------------------- 216*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getActuatingProperties( ) throw (RuntimeException) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir Sequence< ::rtl::OUString > aActuating( 2 ); 219*cdf0e10cSrcweir aActuating[0] = PROPERTY_BUTTONTYPE; 220*cdf0e10cSrcweir aActuating[1] = PROPERTY_TARGET_URL; 221*cdf0e10cSrcweir return aActuating; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir //-------------------------------------------------------------------- 225*cdf0e10cSrcweir InteractiveSelectionResult SAL_CALL ButtonNavigationHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 228*cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir InteractiveSelectionResult eReturn( InteractiveSelectionResult_Cancelled ); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir switch ( nPropId ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir case PROPERTY_ID_TARGET_URL: 235*cdf0e10cSrcweir eReturn = m_xSlaveHandler->onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI ); 236*cdf0e10cSrcweir break; 237*cdf0e10cSrcweir default: 238*cdf0e10cSrcweir eReturn = ButtonNavigationHandler_Base::onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI ); 239*cdf0e10cSrcweir break; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir return eReturn; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir //-------------------------------------------------------------------- 246*cdf0e10cSrcweir 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) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 249*cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) ); 250*cdf0e10cSrcweir switch ( nPropId ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir case PROPERTY_ID_BUTTONTYPE: 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 255*cdf0e10cSrcweir _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, aHelper.currentButtonTypeIsOpenURL() ); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir break; 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir case PROPERTY_ID_TARGET_URL: 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir PushButtonNavigation aHelper( m_xComponent ); 262*cdf0e10cSrcweir _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME, aHelper.hasNonEmptyCurrentTargetURL() ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir break; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir default: 267*cdf0e10cSrcweir OSL_ENSURE( sal_False, "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" ); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir //-------------------------------------------------------------------- 272*cdf0e10cSrcweir LineDescriptor SAL_CALL ButtonNavigationHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyControlFactory >& _rxControlFactory ) throw (UnknownPropertyException, NullPointerException, RuntimeException) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 275*cdf0e10cSrcweir PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir LineDescriptor aReturn; 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir switch ( nPropId ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir case PROPERTY_ID_TARGET_URL: 282*cdf0e10cSrcweir aReturn = m_xSlaveHandler->describePropertyLine( _rPropertyName, _rxControlFactory ); 283*cdf0e10cSrcweir break; 284*cdf0e10cSrcweir default: 285*cdf0e10cSrcweir aReturn = ButtonNavigationHandler_Base::describePropertyLine( _rPropertyName, _rxControlFactory ); 286*cdf0e10cSrcweir break; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir return aReturn; 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir //........................................................................ 293*cdf0e10cSrcweir } // namespace pcr 294*cdf0e10cSrcweir //........................................................................ 295*cdf0e10cSrcweir 296