From 6bbed3ff07a33bcd0143d62d5e5e31c96223bfa6 Mon Sep 17 00:00:00 2001 From: Andreas Bille Date: Wed, 26 Mar 2003 10:38:37 +0000 Subject: #i2822# part of impl of IOleObject --- embedserv/source/embed/docholder.cxx | 133 ++++++++++++++++++++++++++++++++--- embedserv/source/inc/docholder.hxx | 6 +- 2 files changed, 126 insertions(+), 13 deletions(-) (limited to 'embedserv/source') diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index f26463f97356..f62ab64d7f30 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -2,9 +2,9 @@ * * $RCSfile: docholder.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mav $ $Date: 2003-03-26 10:56:51 $ + * last change: $Author: abi $ $Date: 2003-03-26 11:37:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,7 +60,11 @@ ************************************************************************/ #include "docholder.hxx" +#include "embeddoc.hxx" +#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_ +#include +#endif #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include #endif @@ -82,18 +86,25 @@ #ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ #include #endif - +#ifndef _COM_SUN_STAR_UTIL_XMODIFYBROADCASTER_HPP_ +#include +#endif #ifndef _OSL_DIAGNOSE_H_ #include #endif + using namespace ::com::sun::star; +extern ::rtl::OUString getFilterNameFromGUID_Impl( GUID* ); + // add mutex locking ??? -DocumentHolder::DocumentHolder( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) -: m_xFactory( xFactory ) +DocumentHolder::DocumentHolder( const uno::Reference< lang::XMultiServiceFactory >& xFactory,EmbedDocument_Impl *pOLEInterface) + : m_xFactory( xFactory ), + m_nStreamMode(0), + m_pOLEInterface(pOLEInterface) { const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) ); uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY ); @@ -155,20 +166,39 @@ void DocumentHolder::CloseDocument() {} } } - m_xDocument = uno::Reference< frame::XModel >(); + m_nStreamMode = 0; + + uno::Reference xCloseable( + m_xFrame,uno::UNO_QUERY); + if(xCloseable.is()) + try { + xCloseable->close(sal_True); + } + catch( const uno::Exception& ) { + } + + m_xFrame = uno::Reference< frame::XFrame >(); } -void DocumentHolder::SetDocument( const uno::Reference< frame::XModel >& xDoc ) +void DocumentHolder::SetDocument( const uno::Reference< frame::XModel >& xDoc, + DWORD nStreamMode) { if ( m_xDocument.is() ) CloseDocument(); m_xDocument = xDoc; + m_nStreamMode = nStreamMode; + uno::Reference< util::XCloseBroadcaster > xBroadcaster( m_xDocument, uno::UNO_QUERY ); if ( xBroadcaster.is() ) xBroadcaster->addCloseListener( (util::XCloseListener*)this ); +// uno::Reference< util::XModifyBroadcaster > xMB( +// m_xDocument,uno::UNO_QUERY ); +// if(xMB.is()) +// xMB->addModifyListener((util::XModifyListener*)this); + if ( m_xDocument.is() ) { // set the document mode to embedded @@ -179,6 +209,78 @@ void DocumentHolder::SetDocument( const uno::Reference< frame::XModel >& xDoc ) } } + +uno::Reference< frame::XFrame > DocumentHolder::DocumentFrame() +{ + if(! m_xFrame.is() ) + { + rtl::OUString aDesktopSrvNm( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")); + + uno::Reference xDesktop( + m_xFactory->createInstance(aDesktopSrvNm), + uno::UNO_QUERY); + + uno::Reference xFrame( + xDesktop,uno::UNO_QUERY); + + if( xFrame.is() ) + m_xFrame = xFrame->findFrame( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_blank")),0); + } + + return m_xFrame; +} + + +void DocumentHolder::show() +{ + if(m_xFrame.is()) + m_xFrame->activate(); + else { + uno::Reference xComponentLoader( + DocumentFrame(),uno::UNO_QUERY); + + if(xComponentLoader.is()) + { + uno::Sequence aSeq(2); + + uno::Any aAny; + aAny <<= uno::Reference( + GetDocument(),uno::UNO_QUERY); + aSeq[0] = beans::PropertyValue( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Model")), + -1, + aAny, + beans::PropertyState_DIRECT_VALUE); + + aAny <<= sal_False; + aSeq[1] = beans::PropertyValue( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("ReadOnly")), + -1, + aAny, + beans::PropertyState_DIRECT_VALUE); + + xComponentLoader->loadComponentFromURL( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("private:object")), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_self")), + 0, + aSeq); + } + } +} + + +void DocumentHolder::hide() +{ + if(m_xFrame.is()) + m_xFrame->deactivate(); +} + + void SAL_CALL DocumentHolder::disposing( const com::sun::star::lang::EventObject& aSource ) { if ( m_xDocument.is() && m_xDocument == aSource.Source ) @@ -194,11 +296,16 @@ void SAL_CALL DocumentHolder::queryClosing( const lang::EventObject& aSource, sa void SAL_CALL DocumentHolder::notifyClosing( const lang::EventObject& aSource ) { - uno::Reference< util::XCloseBroadcaster > xEventBroadcaster( aSource.Source, uno::UNO_QUERY ); - + uno::Reference< util::XCloseBroadcaster > xEventBroadcaster( + aSource.Source, uno::UNO_QUERY ); if ( xEventBroadcaster.is() ) xEventBroadcaster->removeCloseListener( (util::XCloseListener*)this ); + uno::Reference< util::XModifyBroadcaster > xModifyBroadcaster( + aSource.Source,uno::UNO_QUERY ); + if(xModifyBroadcaster.is()) + xModifyBroadcaster->removeModifyListener((util::XModifyListener*)this); + if ( m_xDocument.is() && m_xDocument == aSource.Source ) m_xDocument = uno::Reference< frame::XModel >(); } @@ -220,3 +327,11 @@ void SAL_CALL DocumentHolder::notifyTermination( const lang::EventObject& aSourc xDesktop->removeTerminateListener( (frame::XTerminateListener*)this ); } + + +void SAL_CALL DocumentHolder::modified( const lang::EventObject& aEvent ) + throw (uno::RuntimeException) +{ + if(m_pOLEInterface) + m_pOLEInterface->notify(); +} diff --git a/embedserv/source/inc/docholder.hxx b/embedserv/source/inc/docholder.hxx index da3b52561e6b..924291d8c639 100644 --- a/embedserv/source/inc/docholder.hxx +++ b/embedserv/source/inc/docholder.hxx @@ -2,9 +2,9 @@ * * $RCSfile: docholder.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: abi $ $Date: 2003-03-26 11:13:01 $ + * last change: $Author: abi $ $Date: 2003-03-26 11:38:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,8 +99,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; - sal_Bool IsReadOnly() const; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > DocumentFrame(); public: -- cgit v1.2.3