1*2a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2a97ec55SAndrew Rist * distributed with this work for additional information 6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 10*2a97ec55SAndrew Rist * 11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2a97ec55SAndrew Rist * 13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an 15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 17*2a97ec55SAndrew Rist * specific language governing permissions and limitations 18*2a97ec55SAndrew Rist * under the License. 19*2a97ec55SAndrew Rist * 20*2a97ec55SAndrew Rist *************************************************************/ 21*2a97ec55SAndrew Rist 22*2a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir #include "sqlcommanddesign.hxx" 27cdf0e10cSrcweir #include "formstrings.hxx" 28cdf0e10cSrcweir #ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_ 29cdf0e10cSrcweir #include "formresid.hrc" 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_ 32cdf0e10cSrcweir #include "modulepcr.hxx" 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #include "unourl.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir /** === begin UNO includes === **/ 37cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 38cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp> 39cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 40cdf0e10cSrcweir #include <com/sun/star/frame/XTitle.hpp> 41cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp> 42cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 43cdf0e10cSrcweir #include <com/sun/star/lang/NullPointerException.hpp> 44cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 45cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp> 46cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp> 47cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 48cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp> 49cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 50cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 51cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp> 52cdf0e10cSrcweir /** === end UNO includes === **/ 53cdf0e10cSrcweir 54cdf0e10cSrcweir #include <svtools/localresaccess.hxx> 55cdf0e10cSrcweir #include <tools/diagnose_ex.h> 56cdf0e10cSrcweir #include <osl/diagnose.h> 57cdf0e10cSrcweir 58cdf0e10cSrcweir //........................................................................ 59cdf0e10cSrcweir namespace pcr 60cdf0e10cSrcweir { 61cdf0e10cSrcweir //........................................................................ 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** === begin UNO using === **/ 64cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 65cdf0e10cSrcweir using ::com::sun::star::lang::XMultiComponentFactory; 66cdf0e10cSrcweir using ::com::sun::star::beans::PropertyChangeEvent; 67cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 68cdf0e10cSrcweir using ::com::sun::star::frame::XFrame; 69cdf0e10cSrcweir using ::com::sun::star::awt::XTopWindow; 70cdf0e10cSrcweir using ::com::sun::star::awt::XWindow; 71cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 72cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 73cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 74cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue; 75cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 76cdf0e10cSrcweir using ::com::sun::star::lang::XComponent; 77cdf0e10cSrcweir using ::com::sun::star::frame::XComponentLoader; 78cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 79cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySetInfo; 80cdf0e10cSrcweir using ::com::sun::star::frame::XController; 81cdf0e10cSrcweir using ::com::sun::star::frame::XTitle; 82cdf0e10cSrcweir using ::com::sun::star::lang::EventObject; 83cdf0e10cSrcweir using ::com::sun::star::lang::NullPointerException; 84cdf0e10cSrcweir using ::com::sun::star::lang::DisposedException; 85cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 86cdf0e10cSrcweir using ::com::sun::star::uno::XComponentContext; 87cdf0e10cSrcweir using ::com::sun::star::frame::XFramesSupplier; 88cdf0e10cSrcweir using ::com::sun::star::frame::XFrames; 89cdf0e10cSrcweir using ::com::sun::star::util::XCloseable; 90cdf0e10cSrcweir using ::com::sun::star::uno::TypeClass_STRING; 91cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 92cdf0e10cSrcweir using ::com::sun::star::frame::XDispatchProvider; 93cdf0e10cSrcweir using ::com::sun::star::frame::XDispatch; 94cdf0e10cSrcweir using ::com::sun::star::uno::Any; 95cdf0e10cSrcweir /** === end UNO using === **/ 96cdf0e10cSrcweir namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag; 97cdf0e10cSrcweir namespace CommandType = ::com::sun::star::sdb::CommandType; 98cdf0e10cSrcweir 99cdf0e10cSrcweir //==================================================================== 100cdf0e10cSrcweir //= ISQLCommandAdapter 101cdf0e10cSrcweir //==================================================================== 102cdf0e10cSrcweir //-------------------------------------------------------------------- ~ISQLCommandAdapter()103cdf0e10cSrcweir ISQLCommandAdapter::~ISQLCommandAdapter() 104cdf0e10cSrcweir { 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir //==================================================================== 108cdf0e10cSrcweir //= SQLCommandDesigner 109cdf0e10cSrcweir //==================================================================== 110cdf0e10cSrcweir //-------------------------------------------------------------------- SQLCommandDesigner(const Reference<XComponentContext> & _rxContext,const::rtl::Reference<ISQLCommandAdapter> & _rxPropertyAdapter,const::dbtools::SharedConnection & _rConnection,const Link & _rCloseLink)111cdf0e10cSrcweir SQLCommandDesigner::SQLCommandDesigner( const Reference< XComponentContext >& _rxContext, 112cdf0e10cSrcweir const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter, 113cdf0e10cSrcweir const ::dbtools::SharedConnection& _rConnection, const Link& _rCloseLink ) 114cdf0e10cSrcweir :m_xContext( _rxContext ) 115cdf0e10cSrcweir ,m_xConnection( _rConnection ) 116cdf0e10cSrcweir ,m_xObjectAdapter( _rxPropertyAdapter ) 117cdf0e10cSrcweir ,m_aCloseLink( _rCloseLink ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir if ( m_xContext.is() ) 120cdf0e10cSrcweir m_xORB = m_xContext->getServiceManager(); 121cdf0e10cSrcweir if ( !m_xORB.is() || !_rxPropertyAdapter.is() || !m_xConnection.is() ) 122cdf0e10cSrcweir throw NullPointerException(); 123cdf0e10cSrcweir 124cdf0e10cSrcweir impl_doOpenDesignerFrame_nothrow(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir //-------------------------------------------------------------------- ~SQLCommandDesigner()128cdf0e10cSrcweir SQLCommandDesigner::~SQLCommandDesigner() 129cdf0e10cSrcweir { 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir //-------------------------------------------------------------------- propertyChange(const PropertyChangeEvent & Event)133cdf0e10cSrcweir void SAL_CALL SQLCommandDesigner::propertyChange( const PropertyChangeEvent& Event ) throw (RuntimeException) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir OSL_ENSURE( m_xDesigner.is() && ( Event.Source == m_xDesigner ), "SQLCommandDesigner::propertyChange: where did this come from?" ); 136cdf0e10cSrcweir 137cdf0e10cSrcweir if ( m_xDesigner.is() && ( Event.Source == m_xDesigner ) ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir try 140cdf0e10cSrcweir { 141cdf0e10cSrcweir if ( PROPERTY_ACTIVECOMMAND == Event.PropertyName ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir ::rtl::OUString sCommand; 144cdf0e10cSrcweir OSL_VERIFY( Event.NewValue >>= sCommand ); 145cdf0e10cSrcweir m_xObjectAdapter->setSQLCommand( sCommand ); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir else if ( PROPERTY_ESCAPE_PROCESSING == Event.PropertyName ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir sal_Bool bEscapeProcessing( sal_False ); 150cdf0e10cSrcweir OSL_VERIFY( Event.NewValue >>= bEscapeProcessing ); 151cdf0e10cSrcweir m_xObjectAdapter->setEscapeProcessing( bEscapeProcessing ); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir } 154cdf0e10cSrcweir catch( const RuntimeException& ) { throw; } 155cdf0e10cSrcweir catch( const Exception& ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir // not allowed to leave, so silence it 158cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir } 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir //-------------------------------------------------------------------- disposing(const EventObject & Source)164cdf0e10cSrcweir void SAL_CALL SQLCommandDesigner::disposing( const EventObject& Source ) throw (RuntimeException) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir if ( m_xDesigner.is() && ( Source.Source == m_xDesigner ) ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir impl_designerClosed_nothrow(); 169cdf0e10cSrcweir m_xDesigner.clear(); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir //-------------------------------------------------------------------- dispose()174cdf0e10cSrcweir void SQLCommandDesigner::dispose() 175cdf0e10cSrcweir { 176cdf0e10cSrcweir if ( impl_isDisposed() ) 177cdf0e10cSrcweir return; 178cdf0e10cSrcweir 179cdf0e10cSrcweir if ( isActive() ) 180cdf0e10cSrcweir impl_closeDesigner_nothrow(); 181cdf0e10cSrcweir 182cdf0e10cSrcweir m_xConnection.clear(); 183cdf0e10cSrcweir m_xContext.clear(); 184cdf0e10cSrcweir m_xORB.clear(); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir //-------------------------------------------------------------------- impl_checkDisposed_throw() const188cdf0e10cSrcweir void SQLCommandDesigner::impl_checkDisposed_throw() const 189cdf0e10cSrcweir { 190cdf0e10cSrcweir if ( impl_isDisposed() ) 191cdf0e10cSrcweir throw DisposedException(); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir //-------------------------------------------------------------------- raise() const195cdf0e10cSrcweir void SQLCommandDesigner::raise() const 196cdf0e10cSrcweir { 197cdf0e10cSrcweir impl_checkDisposed_throw(); 198cdf0e10cSrcweir impl_raise_nothrow(); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir //------------------------------------------------------------------------ suspend() const202cdf0e10cSrcweir bool SQLCommandDesigner::suspend() const 203cdf0e10cSrcweir { 204cdf0e10cSrcweir impl_checkDisposed_throw(); 205cdf0e10cSrcweir return impl_trySuspendDesigner_nothrow(); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir //-------------------------------------------------------------------- impl_raise_nothrow() const209cdf0e10cSrcweir void SQLCommandDesigner::impl_raise_nothrow() const 210cdf0e10cSrcweir { 211cdf0e10cSrcweir OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_raise_nothrow: not active!" ); 212cdf0e10cSrcweir if ( !isActive() ) 213cdf0e10cSrcweir return; 214cdf0e10cSrcweir 215cdf0e10cSrcweir try 216cdf0e10cSrcweir { 217cdf0e10cSrcweir // activate the frame for this component 218cdf0e10cSrcweir Reference< XFrame > xFrame( m_xDesigner->getFrame(), UNO_QUERY_THROW ); 219cdf0e10cSrcweir Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW ); 220cdf0e10cSrcweir Reference< XTopWindow > xTopWindow( xWindow, UNO_QUERY_THROW ); 221cdf0e10cSrcweir 222cdf0e10cSrcweir xTopWindow->toFront(); 223cdf0e10cSrcweir xWindow->setFocus(); 224cdf0e10cSrcweir } 225cdf0e10cSrcweir catch( const Exception& ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir //-------------------------------------------------------------------- impl_doOpenDesignerFrame_nothrow()232cdf0e10cSrcweir void SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow() 233cdf0e10cSrcweir { 234cdf0e10cSrcweir OSL_PRECOND( !isActive(), 235cdf0e10cSrcweir "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: already active!" ); 236cdf0e10cSrcweir OSL_PRECOND( m_xConnection.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: this will crash!" ); 237cdf0e10cSrcweir osl_incrementInterlockedCount(&m_refCount); 238cdf0e10cSrcweir 239cdf0e10cSrcweir try 240cdf0e10cSrcweir { 241cdf0e10cSrcweir // for various reasons, we don't want the new frame to appear in the desktop's frame list 242cdf0e10cSrcweir // thus, we create a blank frame at the desktop, remove it from the desktop's frame list 243cdf0e10cSrcweir // immediately, and then load the component into this blank (and now parent-less) frame 244cdf0e10cSrcweir Reference< XComponentLoader > xLoader( impl_createEmptyParentlessTask_nothrow(), UNO_QUERY_THROW ); 245cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 5 ); 246cdf0e10cSrcweir aArgs[0].Name = PROPERTY_ACTIVE_CONNECTION; 247cdf0e10cSrcweir aArgs[0].Value <<= m_xConnection.getTyped(); 248cdf0e10cSrcweir 249cdf0e10cSrcweir aArgs[1].Name = PROPERTY_COMMAND; 250cdf0e10cSrcweir aArgs[1].Value <<= m_xObjectAdapter->getSQLCommand(); 251cdf0e10cSrcweir aArgs[2].Name = PROPERTY_COMMANDTYPE; 252cdf0e10cSrcweir aArgs[2].Value <<= (sal_Int32)CommandType::COMMAND; 253cdf0e10cSrcweir aArgs[3].Name = PROPERTY_ESCAPE_PROCESSING; 254cdf0e10cSrcweir aArgs[3].Value <<= m_xObjectAdapter->getEscapeProcessing(); 255cdf0e10cSrcweir 256cdf0e10cSrcweir aArgs[4].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GraphicalDesign" ) ); 257cdf0e10cSrcweir aArgs[4].Value <<= m_xObjectAdapter->getEscapeProcessing(); 258cdf0e10cSrcweir 259cdf0e10cSrcweir Reference< XComponent > xQueryDesign = xLoader->loadComponentFromURL( 260cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".component:DB/QueryDesign" ) ), 261cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), 262cdf0e10cSrcweir FrameSearchFlag::TASKS | FrameSearchFlag::CREATE, 263cdf0e10cSrcweir aArgs 264cdf0e10cSrcweir ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir // remember this newly loaded component - we need to care for it e.g. when we're suspended 267cdf0e10cSrcweir m_xDesigner = m_xDesigner.query( xQueryDesign ); 268cdf0e10cSrcweir OSL_ENSURE( m_xDesigner.is() || !xQueryDesign.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the component is expected to be a controller!" ); 269cdf0e10cSrcweir if ( m_xDesigner.is() ) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir Reference< XPropertySet > xQueryDesignProps( m_xDesigner, UNO_QUERY ); 272cdf0e10cSrcweir OSL_ENSURE( xQueryDesignProps.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the controller should have properties!" ); 273cdf0e10cSrcweir if ( xQueryDesignProps.is() ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir xQueryDesignProps->addPropertyChangeListener( PROPERTY_ACTIVECOMMAND, this ); 276cdf0e10cSrcweir xQueryDesignProps->addPropertyChangeListener( PROPERTY_ESCAPE_PROCESSING, this ); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir // get the frame which we just opened and set it's title 281cdf0e10cSrcweir Reference< XTitle> xTitle(xQueryDesign,UNO_QUERY); 282cdf0e10cSrcweir if ( xTitle.is() ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir ::svt::OLocalResourceAccess aEnumStrings( PcrRes( RID_RSC_ENUM_COMMAND_TYPE ), RSC_RESOURCE ); 285cdf0e10cSrcweir ::rtl::OUString sDisplayName = String( PcrRes( CommandType::COMMAND + 1 ) ); 286cdf0e10cSrcweir xTitle->setTitle( sDisplayName ); 287cdf0e10cSrcweir } 288cdf0e10cSrcweir } 289cdf0e10cSrcweir catch( const Exception& ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 292cdf0e10cSrcweir m_xDesigner.clear(); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir osl_decrementInterlockedCount(&m_refCount); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir //------------------------------------------------------------------------ impl_createEmptyParentlessTask_nothrow() const298cdf0e10cSrcweir Reference< XFrame > SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow( ) const 299cdf0e10cSrcweir { 300cdf0e10cSrcweir OSL_PRECOND( m_xORB.is(), "SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: this will crash!" ); 301cdf0e10cSrcweir 302cdf0e10cSrcweir Reference< XFrame > xFrame; 303cdf0e10cSrcweir try 304cdf0e10cSrcweir { 305cdf0e10cSrcweir Reference< XInterface > xDesktop ( m_xORB->createInstanceWithContext( SERVICE_DESKTOP, m_xContext ) ); 306cdf0e10cSrcweir Reference< XFrame > xDesktopFrame ( xDesktop, UNO_QUERY_THROW ); 307cdf0e10cSrcweir Reference< XFramesSupplier > xSuppDesktopFrames( xDesktopFrame, UNO_QUERY_THROW ); 308cdf0e10cSrcweir 309cdf0e10cSrcweir Reference< XFrames > xDesktopFramesCollection( xSuppDesktopFrames->getFrames(), UNO_QUERY_THROW ); 310cdf0e10cSrcweir xFrame = xDesktopFrame->findFrame( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), FrameSearchFlag::CREATE ); 311cdf0e10cSrcweir OSL_ENSURE( xFrame.is(), "SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: could not create an empty frame!" ); 312cdf0e10cSrcweir xDesktopFramesCollection->remove( xFrame ); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir catch( const Exception& ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir return xFrame; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir //------------------------------------------------------------------------ impl_designerClosed_nothrow()322cdf0e10cSrcweir void SQLCommandDesigner::impl_designerClosed_nothrow() 323cdf0e10cSrcweir { 324cdf0e10cSrcweir if ( m_aCloseLink.IsSet() ) 325cdf0e10cSrcweir m_aCloseLink.Call( this ); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir //------------------------------------------------------------------------ impl_closeDesigner_nothrow()329cdf0e10cSrcweir void SQLCommandDesigner::impl_closeDesigner_nothrow() 330cdf0e10cSrcweir { 331cdf0e10cSrcweir OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_closeDesigner_nothrow: invalid calle!" ); 332cdf0e10cSrcweir // close it 333cdf0e10cSrcweir try 334cdf0e10cSrcweir { 335cdf0e10cSrcweir // do not listen anymore .... 336cdf0e10cSrcweir Reference< XPropertySet > xProps( m_xDesigner, UNO_QUERY ); 337cdf0e10cSrcweir if ( xProps.is() ) 338cdf0e10cSrcweir xProps->removePropertyChangeListener( PROPERTY_ACTIVECOMMAND, this ); 339cdf0e10cSrcweir 340cdf0e10cSrcweir // we need to close the frame via the "user interface", by dispatching a close command, 341cdf0e10cSrcweir // instead of calling XCloseable::close directly. The latter method would also close 342cdf0e10cSrcweir // the frame, but not care for things like shutting down the office when the last 343cdf0e10cSrcweir // frame is gone ... 344cdf0e10cSrcweir const UnoURL aCloseURL( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CloseDoc" ) ), 345cdf0e10cSrcweir Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY ) ); 346cdf0e10cSrcweir 347cdf0e10cSrcweir Reference< XDispatchProvider > xProvider( m_xDesigner->getFrame(), UNO_QUERY_THROW ); 348cdf0e10cSrcweir Reference< XDispatch > xDispatch( xProvider->queryDispatch( aCloseURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_top" ) ), FrameSearchFlag::SELF ) ); 349cdf0e10cSrcweir OSL_ENSURE( xDispatch.is(), "SQLCommandDesigner::impl_closeDesigner_nothrow: no dispatcher for the CloseDoc command!" ); 350cdf0e10cSrcweir if ( xDispatch.is() ) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir xDispatch->dispatch( aCloseURL, Sequence< PropertyValue >( ) ); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir else 355cdf0e10cSrcweir { 356cdf0e10cSrcweir // fallback: use the XCloseable::close (with all possible disadvantages) 357cdf0e10cSrcweir Reference< XCloseable > xClose( m_xDesigner->getFrame(), UNO_QUERY ); 358cdf0e10cSrcweir if ( xClose.is() ) 359cdf0e10cSrcweir xClose->close( sal_True ); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir } 362cdf0e10cSrcweir catch( const Exception& ) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir m_xDesigner.clear(); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir //------------------------------------------------------------------------ impl_trySuspendDesigner_nothrow() const371cdf0e10cSrcweir bool SQLCommandDesigner::impl_trySuspendDesigner_nothrow() const 372cdf0e10cSrcweir { 373cdf0e10cSrcweir OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_trySuspendDesigner_nothrow: no active designer, this will crash!" ); 374cdf0e10cSrcweir sal_Bool bAllow = sal_True; 375cdf0e10cSrcweir try 376cdf0e10cSrcweir { 377cdf0e10cSrcweir bAllow = m_xDesigner->suspend( sal_True ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir catch( const Exception& ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir return bAllow; 384cdf0e10cSrcweir } 385cdf0e10cSrcweir 386cdf0e10cSrcweir //........................................................................ 387cdf0e10cSrcweir } // namespace pcr 388cdf0e10cSrcweir //........................................................................ 389cdf0e10cSrcweir 390