Tag: cws_src680_dba24d User: oj Date: 2007-11-22 11:47:47+0000 Modified: dba/dbaccess/source/ui/app/AppController.hxx dba/dbaccess/source/ui/app/AppControllerGen.cxx
Log: #i83805# new command to suspend and shutdown the emebedded object File Changes: Directory: /dba/dbaccess/source/ui/app/ ======================================= File [changed]: AppController.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.hxx?r1=1.20&r2=1.20.22.1 Delta lines: +4 -4 ------------------- --- AppController.hxx 2007-09-26 14:46:38+0000 1.20 +++ AppController.hxx 2007-11-22 11:47:45+0000 1.20.22.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppController.hxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.20.22.1 $ * - * last change: $Author: hr $ $Date: 2007/09/26 14:46:38 $ + * last change: $Author: oj $ $Date: 2007/11/22 11:47:45 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -393,7 +393,7 @@ @return <TRUE/> if the document could be suspended, otherwise <FALSE/>. */ - sal_Bool suspendDocument(const TDocuments::key_type& _xComponent,sal_Bool _bSuspend); + sal_Bool suspendDocument(const TDocuments::value_type& _xComponent,sal_Bool _bSuspend); /** suspend all open documents. @return File [changed]: AppControllerGen.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppControllerGen.cxx?r1=1.28.28.1&r2=1.28.28.2 Delta lines: +44 -71 --------------------- --- AppControllerGen.cxx 2007-11-08 14:13:49+0000 1.28.28.1 +++ AppControllerGen.cxx 2007-11-22 11:47:45+0000 1.28.28.2 @@ -4,9 +4,9 @@ * * $RCSfile: AppControllerGen.cxx,v $ * - * $Revision: 1.28.28.1 $ + * $Revision: 1.28.28.2 $ * - * last change: $Author: fs $ $Date: 2007/11/08 14:13:49 $ + * last change: $Author: oj $ $Date: 2007/11/22 11:47:45 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -39,6 +39,11 @@ #ifndef DBAUI_APPCONTROLLER_HXX #include "AppController.hxx" #endif + +#include <com/sun/star/ucb/Command.hpp> +#include <com/sun/star/ucb/XCommandProcessor.hpp> +#include <com/sun/star/ucb/XCommandEnvironment.hpp> + #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ #include <com/sun/star/sdb/XQueriesSupplier.hpp> #endif @@ -502,27 +507,39 @@ } } // ----------------------------------------------------------------------------- -sal_Bool OApplicationController::suspendDocument(const TDocuments::key_type& _xComponent,sal_Bool _bSuspend) +sal_Bool OApplicationController::suspendDocument(const TDocuments::value_type& _aComponent,sal_Bool _bSuspend) { sal_Bool bSuspended = sal_True; Reference<XController> xController; - Reference<XModel> xModel(_xComponent,UNO_QUERY); + Reference<XModel> xModel(_aComponent.first,UNO_QUERY); if ( xModel.is() ) xController = xModel->getCurrentController(); else { - xController.set(_xComponent,UNO_QUERY); + xController.set(_aComponent.first,UNO_QUERY); if ( !xController.is() ) { - Reference<XFrame> xFrame(_xComponent,UNO_QUERY); + Reference<XFrame> xFrame(_aComponent.first,UNO_QUERY); if ( xFrame.is() ) xController = xFrame->getController(); } } - if ( xController.is() && xController != *this ) + { + Reference< XCommandProcessor > xContent(_aComponent.second,UNO_QUERY); + if ( xContent.is() ) + { + if ( _bSuspend ) + { + Command aCommand; + aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("shutdown")); + xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >()) >>= bSuspended; + } + } + else bSuspended = xController->suspend(_bSuspend); + } return bSuspended; } @@ -533,12 +550,14 @@ sal_Bool bSubSuspended = sal_True; Reference<XModel> xModel; sal_Int32 nSuspendPos = 1; + try { - TDocuments::iterator aIter = m_aDocuments.begin(); - TDocuments::iterator aEnd = m_aDocuments.end(); + TDocuments aCopy = m_aDocuments; + TDocuments::iterator aIter = aCopy.begin(); + TDocuments::iterator aEnd = aCopy.end(); for (; aIter != aEnd && bSubSuspended; ++aIter,++nSuspendPos) - bSubSuspended = suspendDocument(aIter->first,bSuspend); + bSubSuspended = suspendDocument(*aIter,bSuspend); } catch(Exception) { @@ -554,77 +573,31 @@ Reference< XComponent > xDocument = document->first; if ( xDocument.is() ) xDocument->removeEventListener(static_cast<XFrameActionListener*>(this)); - } - document = m_aDocuments.begin(); - // first of all we have to set the second to NULL - for (; document != documentEnd ; ) - { - TDocuments::iterator aPos = document++; - aPos->second = NULL; // this may also dispose the document - } - // work on copy - TDocuments aDocuments = m_aDocuments; - document = aDocuments.begin(); - documentEnd = aDocuments.end(); - for (; document != documentEnd ; ++document ) - { - Reference<XController> xController; - xModel.set(document->first,UNO_QUERY); - if ( xModel.is() ) - xController = xModel->getCurrentController(); - else - { - xController.set(document->first,UNO_QUERY); - if ( !xController.is() ) - { + Reference<XFrame> xFrame(document->first,UNO_QUERY); if ( xFrame.is() ) - xController = xFrame->getController(); - } - } - - if ( xController.is() && xController != *this ) - { - // Reference< com::sun::star::util::XCloseable> xCloseable(xController->getFrame(),UNO_QUERY); - // if ( xCloseable.is() ) - // xCloseable->close(sal_True); - ::com::sun::star::util::URL aUrl;// getURLForId(DISPATCH_CLOSEWIN); - aUrl.Complete = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:CloseDoc")); - if (m_xUrlTransformer.is()) - m_xUrlTransformer->parseStrict(aUrl); - try { - Reference<XDispatchProvider> xFrame(xController->getFrame(),UNO_QUERY); - - rtl::Reference< CloseChecker > xCloseChecker = new CloseChecker(); - Reference<XComponent> xComponent(xFrame, UNO_QUERY); - if (xComponent.is()) - { - xComponent->addEventListener( xCloseChecker.get() ); - } - xFrame->queryDispatch(aUrl, rtl::OUString::createFromAscii("_self"), 0)->dispatch( aUrl, Sequence< PropertyValue >() ); - - if (! xCloseChecker->isClosed()) + Reference<XController> xController = xFrame->getController(); + if ( xController.is() ) { - bSubSuspended = sal_False; + Reference< com::sun::star::util::XCloseable> xCloseable(xController->getFrame(),UNO_QUERY); + if ( xCloseable.is() ) + xCloseable->close(sal_True); } - if (xComponent.is()) - { - xComponent->removeEventListener( xCloseChecker.get() ); } } - catch(Exception &e) + document = m_aDocuments.begin(); + // first of all we have to set the second to NULL + for (; document != documentEnd ; ) { - (void)e; - // bCheck = sal_False; - } - } + TDocuments::iterator aPos = document++; + aPos->second = NULL; // this may also dispose the document } } catch(Exception) { } - if (bSubSuspended == sal_True) + if ( bSubSuspended ) { // remove the document only at save or discard, but not at cancel state. m_aDocuments.clear(); @@ -637,7 +610,7 @@ try { for (; aIter != aEnd && nSuspendPos ; ++aIter,--nSuspendPos) - suspendDocument(aIter->first,!bSuspend); + suspendDocument(*aIter,!bSuspend); } catch(Exception) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
