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_forms.hxx" 30*cdf0e10cSrcweir #include "formnavigation.hxx" 31*cdf0e10cSrcweir #include "urltransformer.hxx" 32*cdf0e10cSrcweir #include "controlfeatureinterception.hxx" 33*cdf0e10cSrcweir #include "frm_strings.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <com/sun/star/form/runtime/FormFeature.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <tools/debug.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir //......................................................................... 41*cdf0e10cSrcweir namespace frm 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir //......................................................................... 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 46*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 47*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 48*cdf0e10cSrcweir using namespace ::com::sun::star::util; 49*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 50*cdf0e10cSrcweir namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //================================================================== 53*cdf0e10cSrcweir //= OFormNavigationHelper 54*cdf0e10cSrcweir //================================================================== 55*cdf0e10cSrcweir DBG_NAME( OFormNavigationHelper ) 56*cdf0e10cSrcweir //------------------------------------------------------------------ 57*cdf0e10cSrcweir OFormNavigationHelper::OFormNavigationHelper( const Reference< XMultiServiceFactory >& _rxORB ) 58*cdf0e10cSrcweir :m_xORB( _rxORB ) 59*cdf0e10cSrcweir ,m_nConnectedFeatures( 0 ) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir DBG_CTOR( OFormNavigationHelper, NULL ); 62*cdf0e10cSrcweir m_pFeatureInterception.reset( new ControlFeatureInterception( m_xORB ) ); 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir //------------------------------------------------------------------ 66*cdf0e10cSrcweir OFormNavigationHelper::~OFormNavigationHelper() 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir DBG_DTOR( OFormNavigationHelper, NULL ); 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir //------------------------------------------------------------------ 72*cdf0e10cSrcweir void SAL_CALL OFormNavigationHelper::dispose( ) throw( RuntimeException ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir m_pFeatureInterception->dispose(); 75*cdf0e10cSrcweir disconnectDispatchers(); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir //------------------------------------------------------------------ 79*cdf0e10cSrcweir void OFormNavigationHelper::interceptorsChanged( ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir updateDispatches(); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir //------------------------------------------------------------------ 85*cdf0e10cSrcweir void OFormNavigationHelper::featureStateChanged( sal_Int16 /*_nFeatureId*/, sal_Bool /*_bEnabled*/ ) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir // not interested in 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir //------------------------------------------------------------------ 91*cdf0e10cSrcweir void OFormNavigationHelper::allFeatureStatesChanged( ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir // not interested in 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir //------------------------------------------------------------------ 97*cdf0e10cSrcweir void SAL_CALL OFormNavigationHelper::registerDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir m_pFeatureInterception->registerDispatchProviderInterceptor( _rxInterceptor ); 100*cdf0e10cSrcweir interceptorsChanged(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir //------------------------------------------------------------------ 104*cdf0e10cSrcweir void SAL_CALL OFormNavigationHelper::releaseDispatchProviderInterceptor( const Reference< XDispatchProviderInterceptor >& _rxInterceptor ) throw (RuntimeException) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir m_pFeatureInterception->releaseDispatchProviderInterceptor( _rxInterceptor ); 107*cdf0e10cSrcweir interceptorsChanged(); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir //------------------------------------------------------------------ 111*cdf0e10cSrcweir void SAL_CALL OFormNavigationHelper::statusChanged( const FeatureStateEvent& _rState ) throw (RuntimeException) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin(); 114*cdf0e10cSrcweir aFeature != m_aSupportedFeatures.end(); 115*cdf0e10cSrcweir ++aFeature 116*cdf0e10cSrcweir ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir if ( aFeature->second.aURL.Main == _rState.FeatureURL.Main ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir if ( ( aFeature->second.bCachedState != _rState.IsEnabled ) 121*cdf0e10cSrcweir || ( aFeature->second.aCachedAdditionalState != _rState.State ) 122*cdf0e10cSrcweir ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir // change the cached state 125*cdf0e10cSrcweir aFeature->second.bCachedState = _rState.IsEnabled; 126*cdf0e10cSrcweir aFeature->second.aCachedAdditionalState = _rState.State; 127*cdf0e10cSrcweir // tell derivees what happened 128*cdf0e10cSrcweir featureStateChanged( aFeature->first, _rState.IsEnabled ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir return; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // unreachable 135*cdf0e10cSrcweir DBG_ERROR( "OFormNavigationHelper::statusChanged: huh? An invalid/unknown URL?" ); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir //------------------------------------------------------------------ 139*cdf0e10cSrcweir void SAL_CALL OFormNavigationHelper::disposing( const EventObject& _rSource ) throw (RuntimeException) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir // was it one of our external dispatchers? 142*cdf0e10cSrcweir if ( m_nConnectedFeatures ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin(); 145*cdf0e10cSrcweir aFeature != m_aSupportedFeatures.end(); 146*cdf0e10cSrcweir ++aFeature 147*cdf0e10cSrcweir ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir if ( aFeature->second.xDispatcher == _rSource.Source ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir aFeature->second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL ); 152*cdf0e10cSrcweir aFeature->second.xDispatcher = NULL; 153*cdf0e10cSrcweir aFeature->second.bCachedState = sal_False; 154*cdf0e10cSrcweir aFeature->second.aCachedAdditionalState.clear(); 155*cdf0e10cSrcweir --m_nConnectedFeatures; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir featureStateChanged( aFeature->first, sal_False ); 158*cdf0e10cSrcweir break; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir //------------------------------------------------------------------ 165*cdf0e10cSrcweir void OFormNavigationHelper::updateDispatches() 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir if ( !m_nConnectedFeatures ) 168*cdf0e10cSrcweir { // we don't have any dispatchers yet -> do the initial connect 169*cdf0e10cSrcweir connectDispatchers(); 170*cdf0e10cSrcweir return; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir initializeSupportedFeatures(); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir m_nConnectedFeatures = 0; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir Reference< XDispatch > xNewDispatcher; 178*cdf0e10cSrcweir Reference< XDispatch > xCurrentDispatcher; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin(); 181*cdf0e10cSrcweir aFeature != m_aSupportedFeatures.end(); 182*cdf0e10cSrcweir ++aFeature 183*cdf0e10cSrcweir ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir xNewDispatcher = queryDispatch( aFeature->second.aURL ); 186*cdf0e10cSrcweir xCurrentDispatcher = aFeature->second.xDispatcher; 187*cdf0e10cSrcweir if ( xNewDispatcher != xCurrentDispatcher ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir // the dispatcher for this particular URL changed 190*cdf0e10cSrcweir if ( xCurrentDispatcher.is() ) 191*cdf0e10cSrcweir xCurrentDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL ); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir xCurrentDispatcher = aFeature->second.xDispatcher = xNewDispatcher; 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir if ( xCurrentDispatcher.is() ) 196*cdf0e10cSrcweir xCurrentDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL ); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir if ( xCurrentDispatcher.is() ) 200*cdf0e10cSrcweir ++m_nConnectedFeatures; 201*cdf0e10cSrcweir else 202*cdf0e10cSrcweir aFeature->second.bCachedState = sal_False; 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir // notify derivee that (potentially) all features changed their state 206*cdf0e10cSrcweir allFeatureStatesChanged( ); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir //------------------------------------------------------------------ 210*cdf0e10cSrcweir void OFormNavigationHelper::connectDispatchers() 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir if ( m_nConnectedFeatures ) 213*cdf0e10cSrcweir { // already connected -> just do an update 214*cdf0e10cSrcweir updateDispatches(); 215*cdf0e10cSrcweir return; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir initializeSupportedFeatures(); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir m_nConnectedFeatures = 0; 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin(); 223*cdf0e10cSrcweir aFeature != m_aSupportedFeatures.end(); 224*cdf0e10cSrcweir ++aFeature 225*cdf0e10cSrcweir ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir aFeature->second.bCachedState = sal_False; 228*cdf0e10cSrcweir aFeature->second.aCachedAdditionalState.clear(); 229*cdf0e10cSrcweir aFeature->second.xDispatcher = queryDispatch( aFeature->second.aURL ); 230*cdf0e10cSrcweir if ( aFeature->second.xDispatcher.is() ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir ++m_nConnectedFeatures; 233*cdf0e10cSrcweir aFeature->second.xDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL ); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir // notify derivee that (potentially) all features changed their state 238*cdf0e10cSrcweir allFeatureStatesChanged( ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir //------------------------------------------------------------------ 242*cdf0e10cSrcweir void OFormNavigationHelper::disconnectDispatchers() 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir if ( m_nConnectedFeatures ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin(); 247*cdf0e10cSrcweir aFeature != m_aSupportedFeatures.end(); 248*cdf0e10cSrcweir ++aFeature 249*cdf0e10cSrcweir ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir if ( aFeature->second.xDispatcher.is() ) 252*cdf0e10cSrcweir aFeature->second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir aFeature->second.xDispatcher = NULL; 255*cdf0e10cSrcweir aFeature->second.bCachedState = sal_False; 256*cdf0e10cSrcweir aFeature->second.aCachedAdditionalState.clear(); 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir m_nConnectedFeatures = 0; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir // notify derivee that (potentially) all features changed their state 263*cdf0e10cSrcweir allFeatureStatesChanged( ); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir //------------------------------------------------------------------ 267*cdf0e10cSrcweir void OFormNavigationHelper::initializeSupportedFeatures( ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir if ( m_aSupportedFeatures.empty() ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir // ask the derivee which feature ids it wants us to support 272*cdf0e10cSrcweir ::std::vector< sal_Int16 > aFeatureIds; 273*cdf0e10cSrcweir getSupportedFeatures( aFeatureIds ); 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir OFormNavigationMapper aUrlMapper( m_xORB ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir for ( ::std::vector< sal_Int16 >::const_iterator aLoop = aFeatureIds.begin(); 278*cdf0e10cSrcweir aLoop != aFeatureIds.end(); 279*cdf0e10cSrcweir ++aLoop 280*cdf0e10cSrcweir ) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir FeatureInfo aFeatureInfo; 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir bool bKnownId = 285*cdf0e10cSrcweir aUrlMapper.getFeatureURL( *aLoop, aFeatureInfo.aURL ); 286*cdf0e10cSrcweir DBG_ASSERT( bKnownId, "OFormNavigationHelper::initializeSupportedFeatures: unknown feature id!" ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir if ( bKnownId ) 289*cdf0e10cSrcweir // add to our map 290*cdf0e10cSrcweir m_aSupportedFeatures.insert( FeatureMap::value_type( *aLoop, aFeatureInfo ) ); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir //------------------------------------------------------------------ 296*cdf0e10cSrcweir Reference< XDispatch > OFormNavigationHelper::queryDispatch( const URL& _rURL ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir return m_pFeatureInterception->queryDispatch( _rURL ); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir //------------------------------------------------------------------ 302*cdf0e10cSrcweir void OFormNavigationHelper::dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamAsciiName, 303*cdf0e10cSrcweir const Any& _rParamValue ) const 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); 306*cdf0e10cSrcweir if ( m_aSupportedFeatures.end() != aInfo ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir if ( aInfo->second.xDispatcher.is() ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 311*cdf0e10cSrcweir aArgs[0].Name = ::rtl::OUString::createFromAscii( _pParamAsciiName ); 312*cdf0e10cSrcweir aArgs[0].Value = _rParamValue; 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir aInfo->second.xDispatcher->dispatch( aInfo->second.aURL, aArgs ); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir //------------------------------------------------------------------ 320*cdf0e10cSrcweir void OFormNavigationHelper::dispatch( sal_Int16 _nFeatureId ) const 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); 323*cdf0e10cSrcweir if ( m_aSupportedFeatures.end() != aInfo ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir if ( aInfo->second.xDispatcher.is() ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir Sequence< PropertyValue > aEmptyArgs; 328*cdf0e10cSrcweir aInfo->second.xDispatcher->dispatch( aInfo->second.aURL, aEmptyArgs ); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir //------------------------------------------------------------------ 334*cdf0e10cSrcweir bool OFormNavigationHelper::isEnabled( sal_Int16 _nFeatureId ) const 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); 337*cdf0e10cSrcweir if ( m_aSupportedFeatures.end() != aInfo ) 338*cdf0e10cSrcweir return aInfo->second.bCachedState; 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir return false; 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir //------------------------------------------------------------------ 344*cdf0e10cSrcweir bool OFormNavigationHelper::getBooleanState( sal_Int16 _nFeatureId ) const 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir sal_Bool bState = sal_False; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); 349*cdf0e10cSrcweir if ( m_aSupportedFeatures.end() != aInfo ) 350*cdf0e10cSrcweir aInfo->second.aCachedAdditionalState >>= bState; 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir return (bool)bState; 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir //------------------------------------------------------------------ 356*cdf0e10cSrcweir ::rtl::OUString OFormNavigationHelper::getStringState( sal_Int16 _nFeatureId ) const 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir ::rtl::OUString sState; 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); 361*cdf0e10cSrcweir if ( m_aSupportedFeatures.end() != aInfo ) 362*cdf0e10cSrcweir aInfo->second.aCachedAdditionalState >>= sState; 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir return sState; 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir //------------------------------------------------------------------ 368*cdf0e10cSrcweir sal_Int32 OFormNavigationHelper::getIntegerState( sal_Int16 _nFeatureId ) const 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir sal_Int32 nState = 0; 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); 373*cdf0e10cSrcweir if ( m_aSupportedFeatures.end() != aInfo ) 374*cdf0e10cSrcweir aInfo->second.aCachedAdditionalState >>= nState; 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir return nState; 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir //------------------------------------------------------------------ 380*cdf0e10cSrcweir void OFormNavigationHelper::invalidateSupportedFeaturesSet() 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir disconnectDispatchers( ); 383*cdf0e10cSrcweir // no supported features anymore: 384*cdf0e10cSrcweir FeatureMap aEmpty; 385*cdf0e10cSrcweir m_aSupportedFeatures.swap( aEmpty ); 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir //================================================================== 389*cdf0e10cSrcweir //= OFormNavigationMapper 390*cdf0e10cSrcweir //================================================================== 391*cdf0e10cSrcweir //------------------------------------------------------------------ 392*cdf0e10cSrcweir OFormNavigationMapper::OFormNavigationMapper( const Reference< XMultiServiceFactory >& _rxORB ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir m_pUrlTransformer.reset( new UrlTransformer( _rxORB ) ); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir //------------------------------------------------------------------ 398*cdf0e10cSrcweir OFormNavigationMapper::~OFormNavigationMapper( ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir //------------------------------------------------------------------ 403*cdf0e10cSrcweir bool OFormNavigationMapper::getFeatureURL( sal_Int16 _nFeatureId, URL& /* [out] */ _rURL ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir // get the ascii version of the URL 406*cdf0e10cSrcweir const char* pAsciiURL = getFeatureURLAscii( _nFeatureId ); 407*cdf0e10cSrcweir if ( pAsciiURL ) 408*cdf0e10cSrcweir _rURL = m_pUrlTransformer->getStrictURLFromAscii( pAsciiURL ); 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir return ( pAsciiURL != NULL ); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir //------------------------------------------------------------------ 414*cdf0e10cSrcweir namespace 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir struct FeatureURL 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir const sal_Int16 nFormFeature; 419*cdf0e10cSrcweir const sal_Char* pAsciiURL; 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir FeatureURL( const sal_Int16 _nFormFeature, const sal_Char* _pAsciiURL ) 422*cdf0e10cSrcweir :nFormFeature( _nFormFeature ) 423*cdf0e10cSrcweir ,pAsciiURL( _pAsciiURL ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir }; 427*cdf0e10cSrcweir const FeatureURL* lcl_getFeatureTable() 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir static const FeatureURL s_aFeatureURLs[] = 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir FeatureURL( FormFeature::MoveAbsolute, URL_FORM_POSITION ), 432*cdf0e10cSrcweir FeatureURL( FormFeature::TotalRecords, URL_FORM_RECORDCOUNT ), 433*cdf0e10cSrcweir FeatureURL( FormFeature::MoveToFirst, URL_RECORD_FIRST ), 434*cdf0e10cSrcweir FeatureURL( FormFeature::MoveToPrevious, URL_RECORD_PREV ), 435*cdf0e10cSrcweir FeatureURL( FormFeature::MoveToNext, URL_RECORD_NEXT ), 436*cdf0e10cSrcweir FeatureURL( FormFeature::MoveToLast, URL_RECORD_LAST ), 437*cdf0e10cSrcweir FeatureURL( FormFeature::SaveRecordChanges, URL_RECORD_SAVE ), 438*cdf0e10cSrcweir FeatureURL( FormFeature::UndoRecordChanges, URL_RECORD_UNDO ), 439*cdf0e10cSrcweir FeatureURL( FormFeature::MoveToInsertRow, URL_RECORD_NEW ), 440*cdf0e10cSrcweir FeatureURL( FormFeature::DeleteRecord, URL_RECORD_DELETE ), 441*cdf0e10cSrcweir FeatureURL( FormFeature::ReloadForm, URL_FORM_REFRESH ), 442*cdf0e10cSrcweir FeatureURL( FormFeature::RefreshCurrentControl, URL_FORM_REFRESH_CURRENT_CONTROL ), 443*cdf0e10cSrcweir FeatureURL( FormFeature::SortAscending, URL_FORM_SORT_UP ), 444*cdf0e10cSrcweir FeatureURL( FormFeature::SortDescending, URL_FORM_SORT_DOWN ), 445*cdf0e10cSrcweir FeatureURL( FormFeature::InteractiveSort, URL_FORM_SORT ), 446*cdf0e10cSrcweir FeatureURL( FormFeature::AutoFilter, URL_FORM_AUTO_FILTER ), 447*cdf0e10cSrcweir FeatureURL( FormFeature::InteractiveFilter, URL_FORM_FILTER ), 448*cdf0e10cSrcweir FeatureURL( FormFeature::ToggleApplyFilter, URL_FORM_APPLY_FILTER ), 449*cdf0e10cSrcweir FeatureURL( FormFeature::RemoveFilterAndSort, URL_FORM_REMOVE_FILTER ), 450*cdf0e10cSrcweir FeatureURL( 0, NULL ) 451*cdf0e10cSrcweir }; 452*cdf0e10cSrcweir return s_aFeatureURLs; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir //------------------------------------------------------------------ 457*cdf0e10cSrcweir const char* OFormNavigationMapper::getFeatureURLAscii( sal_Int16 _nFeatureId ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir const FeatureURL* pFeatures = lcl_getFeatureTable(); 460*cdf0e10cSrcweir while ( pFeatures->pAsciiURL ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir if ( pFeatures->nFormFeature == _nFeatureId ) 463*cdf0e10cSrcweir return pFeatures->pAsciiURL; 464*cdf0e10cSrcweir ++pFeatures; 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir return NULL; 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir //------------------------------------------------------------------ 470*cdf0e10cSrcweir sal_Int16 OFormNavigationMapper::getFeatureId( const ::rtl::OUString& _rCompleteURL ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir const FeatureURL* pFeatures = lcl_getFeatureTable(); 473*cdf0e10cSrcweir while ( pFeatures->pAsciiURL ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir if ( _rCompleteURL.compareToAscii( pFeatures->pAsciiURL ) == 0 ) 476*cdf0e10cSrcweir return pFeatures->nFormFeature; 477*cdf0e10cSrcweir ++pFeatures; 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir return -1; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir //......................................................................... 483*cdf0e10cSrcweir } // namespace frm 484*cdf0e10cSrcweir //......................................................................... 485