summaryrefslogtreecommitdiff
path: root/embedserv
diff options
context:
space:
mode:
authorAndreas Bille <abi@openoffice.org>2003-03-27 15:20:06 +0000
committerAndreas Bille <abi@openoffice.org>2003-03-27 15:20:06 +0000
commit0f757610e5cb4de88a9ef20a7563f9da2973f6ee (patch)
treef4087782eec4ae445ceb916206aa76fe71f6dddd /embedserv
parent2f7ab7745e7e1f2881e59c0bc8d5e9f0f691b059 (diff)
#i2822# implemented interceptor for SaveAll,CloseDoc and Save
Diffstat (limited to 'embedserv')
-rw-r--r--embedserv/source/embed/docholder.cxx27
-rwxr-xr-xembedserv/source/embed/ed_ioleobject.cxx56
-rw-r--r--embedserv/source/embed/intercept.cxx250
-rwxr-xr-xembedserv/source/embed/makefile.mk12
-rwxr-xr-xembedserv/util/makefile.mk7
5 files changed, 322 insertions, 30 deletions
diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx
index 86dd2e8093b7..5760987db7e8 100644
--- a/embedserv/source/embed/docholder.cxx
+++ b/embedserv/source/embed/docholder.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: docholder.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: abi $ $Date: 2003-03-26 13:51:22 $
+ * last change: $Author: abi $ $Date: 2003-03-27 16:18:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,8 @@
#include "docholder.hxx"
#include "embeddoc.hxx"
+#include "intercept.hxx"
+
#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
#include <com/sun/star/frame/XComponentLoader.hpp>
@@ -89,7 +91,9 @@
#ifndef _COM_SUN_STAR_UTIL_XMODIFYBROADCASTER_HPP_
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#endif
-
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDERINTERCEPTION_HPP_
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
@@ -182,8 +186,11 @@ void DocumentHolder::CloseFrame()
}
catch( const uno::Exception& ) {
}
- else
- uno::Reference<lang::XComponent>(m_xFrame,uno::UNO_QUERY)->dispose();
+ else {
+ uno::Reference<lang::XComponent> xComp(m_xFrame,uno::UNO_QUERY);
+ if(xComp.is())
+ xComp->dispose();
+ }
m_xFrame = uno::Reference< frame::XFrame >();
}
@@ -229,6 +236,16 @@ uno::Reference< frame::XFrame > DocumentHolder::DocumentFrame()
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_blank")),0);
}
+ if( m_xFrame.is() )
+ {
+ // intercept
+ uno::Reference<frame::XDispatchProviderInterception>
+ xDPI(m_xFrame,uno::UNO_QUERY);
+ if(xDPI.is())
+ xDPI->registerDispatchProviderInterceptor(
+ new Interceptor(m_pOLEInterface));
+ }
+
return m_xFrame;
}
diff --git a/embedserv/source/embed/ed_ioleobject.cxx b/embedserv/source/embed/ed_ioleobject.cxx
index 37029d5fb1ff..e40201835cdc 100755
--- a/embedserv/source/embed/ed_ioleobject.cxx
+++ b/embedserv/source/embed/ed_ioleobject.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ed_ioleobject.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: mav $ $Date: 2003-03-27 15:17:36 $
+ * last change: $Author: abi $ $Date: 2003-03-27 16:18:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -107,7 +107,10 @@ STDMETHODIMP EmbedDocument_Impl::Close( DWORD dwSaveOption )
if ( m_pClientSite )
m_pClientSite->OnShowWindow( FALSE );
- for ( AdviseSinkHashMapIterator iAdvise = m_aAdviseHashMap.begin(); iAdvise != m_aAdviseHashMap.end(); iAdvise++ )
+ AdviseSinkHashMap aAHM(m_aAdviseHashMap);
+
+ for ( AdviseSinkHashMapIterator iAdvise = aAHM.begin();
+ iAdvise != aAHM.end(); iAdvise++ )
{
if ( iAdvise->second )
iAdvise->second->OnClose();
@@ -137,20 +140,6 @@ STDMETHODIMP EmbedDocument_Impl::GetClipboardData( DWORD dwReserved, IDataObject
}
-void EmbedDocument_Impl::notify()
-{
- for ( AdviseSinkHashMapIterator iAdvise =
- m_aAdviseHashMap.begin();
- iAdvise != m_aAdviseHashMap.end();
- iAdvise++ )
- if ( iAdvise->second )
- iAdvise->second->OnViewChange( DVASPECT_CONTENT, -1 );
-
- if ( m_pDAdviseHolder )
- m_pDAdviseHolder->SendOnDataChange( (IDataObject*)this, 0, 0 );
-}
-
-
STDMETHODIMP EmbedDocument_Impl::DoVerb( LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect )
{
if ( iVerb == OLEIVERB_PRIMARY || iVerb == OLEIVERB_SHOW || iVerb == OLEIVERB_OPEN )
@@ -305,3 +294,36 @@ STDMETHODIMP EmbedDocument_Impl::SetColorScheme( LOGPALETTE *pLogpal )
return E_NOTIMPL;
}
+
+// C++ - methods
+
+void EmbedDocument_Impl::SaveObject()
+{
+ if(m_pClientSite) {
+ m_pClientSite->SaveObject();
+
+ for ( AdviseSinkHashMapIterator iAdvise =
+ m_aAdviseHashMap.begin();
+ iAdvise != m_aAdviseHashMap.end();
+ iAdvise++ )
+ if ( iAdvise->second )
+ iAdvise->second->OnSave( );
+ }
+
+ notify();
+}
+
+
+void EmbedDocument_Impl::notify()
+{
+ for ( AdviseSinkHashMapIterator iAdvise =
+ m_aAdviseHashMap.begin();
+ iAdvise != m_aAdviseHashMap.end();
+ iAdvise++ )
+ if ( iAdvise->second )
+ iAdvise->second->OnViewChange( DVASPECT_CONTENT, -1 );
+
+ if ( m_pDAdviseHolder )
+ m_pDAdviseHolder->SendOnDataChange( (IDataObject*)this, 0, 0 );
+}
+
diff --git a/embedserv/source/embed/intercept.cxx b/embedserv/source/embed/intercept.cxx
new file mode 100644
index 000000000000..8981a5f71d5e
--- /dev/null
+++ b/embedserv/source/embed/intercept.cxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * $RCSfile: intercept.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: abi $ $Date: 2003-03-27 16:18:27 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include "intercept.hxx"
+#ifndef _EMBEDDOC_HXX_
+#include "embeddoc.hxx"
+#endif
+
+
+
+using namespace ::com::sun::star;
+
+
+
+#define IUL 3
+
+
+
+uno::Sequence<::rtl::OUString> Interceptor::m_aInterceptedURL(IUL);
+
+
+
+Interceptor::Interceptor(EmbedDocument_Impl* pOLEInterface)
+ : m_pOLEInterface(pOLEInterface)
+{
+ m_aInterceptedURL[0] = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(".uno:Save"));
+ m_aInterceptedURL[1] = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(".uno:SaveAll"));
+ m_aInterceptedURL[2] = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(".uno:CloseDoc"));
+}
+
+
+
+
+//XDispatch
+void SAL_CALL
+Interceptor::dispatch(
+ const util::URL& URL,
+ const uno::Sequence<
+ beans::PropertyValue >& Arguments )
+ throw (uno::RuntimeException)
+{
+ if(m_pOLEInterface)
+ if(URL.Complete == m_aInterceptedURL[0])
+ m_pOLEInterface->SaveObject();
+ else if(URL.Complete == m_aInterceptedURL[2])
+ m_pOLEInterface->Close(1);
+}
+
+
+void SAL_CALL
+Interceptor::addStatusListener(
+ const uno::Reference<
+ frame::XStatusListener >& Control,
+ const util::URL& URL )
+ throw (
+ uno::RuntimeException
+ )
+{
+ return;
+}
+
+
+void SAL_CALL
+Interceptor::removeStatusListener(
+ const uno::Reference<
+ frame::XStatusListener >& Control,
+ const util::URL& URL )
+ throw (
+ uno::RuntimeException
+ )
+{
+ return;
+}
+
+
+//XInterceptorInfo
+uno::Sequence< ::rtl::OUString >
+SAL_CALL
+Interceptor::getInterceptedURLs( )
+ throw (
+ uno::RuntimeException
+ )
+{
+ // now implemented as update
+
+ return m_aInterceptedURL;
+}
+
+
+// XDispatchProvider
+
+uno::Reference< frame::XDispatch > SAL_CALL
+Interceptor::queryDispatch(
+ const util::URL& URL,
+ const ::rtl::OUString& TargetFrameName,
+ sal_Int32 SearchFlags )
+ throw (
+ uno::RuntimeException
+ )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ if(URL.Complete == m_aInterceptedURL[0])
+ return (frame::XDispatch*)this;
+ else if(URL.Complete == m_aInterceptedURL[1])
+ return (frame::XDispatch*)0 ;
+ else if(URL.Complete == m_aInterceptedURL[2])
+ return (frame::XDispatch*)this;
+ else {
+ if(m_xSlaveDispatchProvider.is())
+ return m_xSlaveDispatchProvider->queryDispatch(
+ URL,TargetFrameName,SearchFlags);
+ else
+ return uno::Reference<frame::XDispatch>(0);
+ }
+}
+
+uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL
+Interceptor::queryDispatches(
+ const uno::Sequence<frame::DispatchDescriptor >& Requests )
+ throw (
+ uno::RuntimeException
+ )
+{
+ uno::Sequence< uno::Reference< frame::XDispatch > > aRet;
+ osl::MutexGuard aGuard(m_aMutex);
+ if(m_xSlaveDispatchProvider.is())
+ aRet = m_xSlaveDispatchProvider->queryDispatches(Requests);
+ else
+ aRet.realloc(Requests.getLength());
+
+ for(sal_Int32 i = 0; i < Requests.getLength(); ++i)
+ if(m_aInterceptedURL[0] == Requests[i].FeatureURL.Complete)
+ aRet[i] = (frame::XDispatch*) this;
+ else if(m_aInterceptedURL[1] == Requests[i].FeatureURL.Complete)
+ aRet[i] = (frame::XDispatch*) 0;
+ else if(m_aInterceptedURL[2] == Requests[i].FeatureURL.Complete)
+ aRet[i] = (frame::XDispatch*) this;
+
+ return aRet;
+}
+
+
+
+//XDispatchProviderInterceptor
+
+uno::Reference< frame::XDispatchProvider > SAL_CALL
+Interceptor::getSlaveDispatchProvider( )
+ throw (
+ uno::RuntimeException
+ )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ return m_xSlaveDispatchProvider;
+}
+
+void SAL_CALL
+Interceptor::setSlaveDispatchProvider(
+ const uno::Reference< frame::XDispatchProvider >& NewDispatchProvider )
+ throw (
+ uno::RuntimeException
+ )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ m_xSlaveDispatchProvider = NewDispatchProvider;
+}
+
+
+uno::Reference< frame::XDispatchProvider > SAL_CALL
+Interceptor::getMasterDispatchProvider( )
+ throw (
+ uno::RuntimeException
+ )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ return m_xMasterDispatchProvider;
+}
+
+
+void SAL_CALL
+Interceptor::setMasterDispatchProvider(
+ const uno::Reference< frame::XDispatchProvider >& NewSupplier )
+ throw (
+ uno::RuntimeException
+ )
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ m_xMasterDispatchProvider = NewSupplier;
+}
diff --git a/embedserv/source/embed/makefile.mk b/embedserv/source/embed/makefile.mk
index d0bff12f72dd..489df6a8eaa3 100755
--- a/embedserv/source/embed/makefile.mk
+++ b/embedserv/source/embed/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: mav $ $Date: 2003-03-12 15:37:58 $
+# last change: $Author: abi $ $Date: 2003-03-27 16:18:27 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -88,13 +88,15 @@ SLOFILES = \
$(SLO)$/ed_idataobj.obj \
$(SLO)$/ed_ioleobject.obj \
$(SLO)$/guid.obj \
- $(SLO)$/esdll.obj
+ $(SLO)$/esdll.obj \
+ $(SLO)$/intercept.obj
EXCEPTIONSFILES= \
- $(SLO)$/register.obj \
+ $(SLO)$/register.obj \
$(SLO)$/docholder.obj \
$(SLO)$/ed_ipersiststr.obj \
- $(SLO)$/ed_idataobj.obj
+ $(SLO)$/ed_idataobj.obj \
+ $(SLO)$/intercept.obj
# --- Targets -------------------------------------------------------
diff --git a/embedserv/util/makefile.mk b/embedserv/util/makefile.mk
index dcf4bd207c0b..c7edd4e4013f 100755
--- a/embedserv/util/makefile.mk
+++ b/embedserv/util/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.4 $
+# $Revision: 1.5 $
#
-# last change: $Author: mav $ $Date: 2003-03-19 10:58:50 $
+# last change: $Author: abi $ $Date: 2003-03-27 16:20:06 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -86,7 +86,8 @@ SHL1OBJS= \
$(SLO)$/ed_idataobj.obj \
$(SLO)$/ed_ioleobject.obj \
$(SLO)$/guid.obj \
- $(SLO)$/esdll.obj
+ $(SLO)$/esdll.obj \
+ $(SLO)$/intercept.obj
SHL1STDLIBS=\
$(SALLIB) \