summaryrefslogtreecommitdiff
path: root/embedserv/source/embed
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2003-03-19 07:35:38 +0000
committerMikhail Voitenko <mav@openoffice.org>2003-03-19 07:35:38 +0000
commitb9dc9f9a522ffa816fc3dcef9a0b4f24fa2c8c76 (patch)
treecd33a13f69ea0db4d7ef597b55c3c8bd8448758b /embedserv/source/embed
parent0744f579c54cf02c7e581eab49ded1e184919140 (diff)
#i2822# office termination
Diffstat (limited to 'embedserv/source/embed')
-rw-r--r--embedserv/source/embed/docholder.cxx74
-rwxr-xr-xembedserv/source/embed/ed_ipersiststr.cxx7
2 files changed, 75 insertions, 6 deletions
diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx
index 8e91d4a1c631..bcf19ef457c0 100644
--- a/embedserv/source/embed/docholder.cxx
+++ b/embedserv/source/embed/docholder.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: docholder.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: mav $ $Date: 2003-03-12 15:37:57 $
+ * last change: $Author: mav $ $Date: 2003-03-19 08:35:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,9 @@
#include "docholder.hxx"
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
#ifndef _COM_SUN_STAR_UTIL_XCLOSEBROADCASTER_HPP_
#include <com/sun/star/util/XCloseBroadcaster.hpp>
#endif
@@ -70,20 +73,68 @@
#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
#endif
+#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
+#include <com/sun/star/frame/XDesktop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XFRAMESSUPPLIER_HPP_
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
using namespace ::com::sun::star;
// add mutex locking ???
-DocumentHolder::DocumentHolder()
+DocumentHolder::DocumentHolder( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+: m_xFactory( xFactory )
{
+ const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
+ uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
+ if ( xDesktop.is() )
+ xDesktop->addTerminateListener( (frame::XTerminateListener*)this );
}
DocumentHolder::~DocumentHolder()
{
if ( m_xDocument.is() )
CloseDocument();
+
+ if ( m_xFactory.is() )
+ FreeOffice();
+}
+
+void DocumentHolder::FreeOffice()
+{
+ const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
+ uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
+ if ( xDesktop.is() )
+ {
+ xDesktop->removeTerminateListener( (frame::XTerminateListener*)this );
+
+ uno::Reference< frame::XFramesSupplier > xFramesSupplier( xDesktop, uno::UNO_QUERY );
+ if ( xFramesSupplier.is() )
+ {
+ uno::Reference< frame::XFrames > xFrames = xFramesSupplier->getFrames();
+ if ( xFrames.is() && !xFrames->hasElements() )
+ {
+ try
+ {
+ xDesktop->terminate();
+ }
+ catch( uno::Exception & )
+ {}
+ }
+ }
+
+ m_xFactory = uno::Reference< lang::XMultiServiceFactory >();
+ }
}
void DocumentHolder::CloseDocument()
@@ -143,3 +194,20 @@ void SAL_CALL DocumentHolder::notifyClosing( const lang::EventObject& aSource )
m_xDocument = uno::Reference< frame::XModel >();
}
+void SAL_CALL DocumentHolder::queryTermination( const lang::EventObject& aSource )
+ throw( frame::TerminationVetoException )
+{
+ if ( m_xDocument.is() )
+ throw frame::TerminationVetoException();
+}
+
+void SAL_CALL DocumentHolder::notifyTermination( const lang::EventObject& aSource )
+{
+ OSL_ENSURE( !m_xDocument.is(), "Just a disaster..." );
+
+ uno::Reference< frame::XDesktop > xDesktop( aSource.Source, uno::UNO_QUERY );
+
+ if ( xDesktop.is() )
+ xDesktop->removeTerminateListener( (frame::XTerminateListener*)this );
+}
+
diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx
index 4fd5ff5ba033..69cc8ebb08e4 100755
--- a/embedserv/source/embed/ed_ipersiststr.cxx
+++ b/embedserv/source/embed/ed_ipersiststr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ed_ipersiststr.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: mav $ $Date: 2003-03-17 11:02:34 $
+ * last change: $Author: mav $ $Date: 2003-03-19 08:35:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -227,13 +227,14 @@ EmbedDocument_Impl::EmbedDocument_Impl( const uno::Reference< lang::XMultiServic
, m_bIsDirty( sal_False )
, m_nAdviseNum( 0 )
{
- m_pDocHolder = new DocumentHolder();
+ m_pDocHolder = new DocumentHolder( xFactory );
m_pDocHolder->acquire();
}
EmbedDocument_Impl::~EmbedDocument_Impl()
{
m_pDocHolder->CloseDocument();
+ m_pDocHolder->FreeOffice();
m_pDocHolder->release();
}