Tag: cws_src680_odbmacros2 User: fs Date: 2008-02-06 21:44:28+0000 Modified: dba/dbaccess/source/ui/browser/unodatbr.cxx
Log: #i49133# don't support XScriptInvocationContext if our associated document does not support XEmbeddedScripts, or if we cannot unambiguously be associated with with a dooc File Changes: Directory: /dba/dbaccess/source/ui/browser/ =========================================== File [changed]: unodatbr.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/unodatbr.cxx?r1=1.192.2.8&r2=1.192.2.9 Delta lines: +68 -5 -------------------- --- unodatbr.cxx 2008-02-06 08:35:51+0000 1.192.2.8 +++ unodatbr.cxx 2008-02-06 21:44:26+0000 1.192.2.9 @@ -4,9 +4,9 @@ * * $RCSfile: unodatbr.cxx,v $ * - * $Revision: 1.192.2.8 $ + * $Revision: 1.192.2.9 $ * - * last change: $Author: fs $ $Date: 2008/02/06 08:35:51 $ + * last change: $Author: fs $ $Date: 2008/02/06 21:44:26 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -255,6 +255,14 @@ //------------------------------------------------------------------------------ Any SAL_CALL SbaTableQueryBrowser::queryInterface(const Type& _rType) throw (RuntimeException) { + if ( _rType.equals( XScriptInvocationContext::static_type() ) ) + { + OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::queryInterface: did not initialize this, yet!" ); + if ( !!m_aDocScriptSupport && *m_aDocScriptSupport ) + return makeAny( Reference< XScriptInvocationContext >( this ) ); + return Any(); + } + Any aReturn = SbaXDataBrowserController::queryInterface(_rType); if (!aReturn.hasValue()) aReturn = SbaTableQueryBrowser_Base::queryInterface(_rType); @@ -264,10 +272,24 @@ //------------------------------------------------------------------------------ Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) throw (RuntimeException) { - return ::comphelper::concatSequences( + Sequence< Type > aTypes( ::comphelper::concatSequences( SbaXDataBrowserController::getTypes(), SbaTableQueryBrowser_Base::getTypes() + ) ); + + OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::getTypes: did not initialize this, yet!" ); + if ( !m_aDocScriptSupport || !*m_aDocScriptSupport ) + { + Sequence< Type > aStrippedTypes( aTypes.getLength() - 1 ); + ::std::remove_copy_if( + aTypes.getConstArray(), + aTypes.getConstArray() + aTypes.getLength(), + aStrippedTypes.getArray(), + ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() ) ); + aTypes = aStrippedTypes; + } + return aTypes; } //------------------------------------------------------------------------------ @@ -2820,6 +2842,33 @@ } // ------------------------------------------------------------------------- +namespace +{ + Reference< XInterface > lcl_getDataSource( const Reference< XNameAccess >& _rxDatabaseContext, + const ::rtl::OUString& _rDataSourceName, const Reference< XConnection >& _rxConnection ) + { + Reference< XDataSource > xDataSource; + try + { + if ( _rDataSourceName.getLength() && _rxDatabaseContext->hasByName( _rDataSourceName ) ) + xDataSource.set( _rxDatabaseContext->getByName( _rDataSourceName ), UNO_QUERY_THROW ); + + if ( !xDataSource.is() ) + { + Reference< XChild > xConnAsChild( _rxConnection, UNO_QUERY ); + if ( xConnAsChild.is() ) + xDataSource.set( xConnAsChild->getParent(), UNO_QUERY_THROW ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xDataSource; + } +} + +// ------------------------------------------------------------------------- void SbaTableQueryBrowser::impl_initialize() { ::vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2851,8 +2900,9 @@ rArguments.get_ensureType( "Frame", xFrame ); rArguments.get_ensureType( (::rtl::OUString)PROPERTY_SHOWMENU, m_bShowMenu ); - sal_Bool bShowTreeView = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_SHOWTREEVIEW, sal_True ); m_bEnableBrowser = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_SHOWTREEVIEWBUTTON, sal_True ); + sal_Bool bShowTreeView = ( m_bEnableBrowser ) + && ( rArguments.getOrDefault( (::rtl::OUString)PROPERTY_SHOWTREEVIEW, sal_True ) ); if ( bShowTreeView ) showExplorer(); @@ -2954,6 +3004,19 @@ else initializeTreeModel(); + if ( m_bEnableBrowser ) + { + m_aDocScriptSupport = ::boost::optional< bool >( false ); + } + else + { + // we are not used as "browser", but as mere view for a single table/query/command. In particular, + // there is a specific database document which we belong to. + Reference< XOfficeDatabaseDocument > xDocument( getDataSourceOrModel( + lcl_getDataSource( m_xDatabaseContext, sInitialDataSourceName, xConnection ) ), UNO_QUERY ); + m_aDocScriptSupport = ::boost::optional< bool >( Reference< XEmbeddedScripts >( xDocument, UNO_QUERY ).is() ); + } + if ( implSelect( sInitialDataSourceName, sInitialCommand, nInitialDisplayCommandType, bEsacpeProcessing, xConnection, sal_True ) ) { try --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
