1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dp_interact.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_desktop.hxx"
34 #include "dp_interact.h"
35 #include "cppuhelper/exc_hlp.hxx"
36 #include "cppuhelper/implbase1.hxx"
37 #include "com/sun/star/task/XInteractionAbort.hpp"
40 using namespace ::com::sun::star
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::ucb
;
43 using ::rtl::OUString
;
48 //==============================================================================
49 class InteractionContinuationImpl
: public ::cppu::OWeakObject
,
50 public task::XInteractionContinuation
56 inline InteractionContinuationImpl( Type
const & type
, bool * pselect
)
61 static_cast< Reference
<task::XInteractionContinuation
>
62 const *>(0) ).isAssignableFrom(m_type
) ); }
65 virtual void SAL_CALL
acquire() throw ();
66 virtual void SAL_CALL
release() throw ();
67 virtual Any SAL_CALL
queryInterface( Type
const & type
)
68 throw (RuntimeException
);
70 // XInteractionContinuation
71 virtual void SAL_CALL
select() throw (RuntimeException
);
75 //______________________________________________________________________________
76 void InteractionContinuationImpl::acquire() throw ()
78 OWeakObject::acquire();
81 //______________________________________________________________________________
82 void InteractionContinuationImpl::release() throw ()
84 OWeakObject::release();
87 //______________________________________________________________________________
88 Any
InteractionContinuationImpl::queryInterface( Type
const & type
)
89 throw (RuntimeException
)
91 if (type
.isAssignableFrom( m_type
)) {
92 Reference
<task::XInteractionContinuation
> xThis(this);
93 return Any( &xThis
, type
);
96 return OWeakObject::queryInterface(type
);
99 // XInteractionContinuation
100 //______________________________________________________________________________
101 void InteractionContinuationImpl::select() throw (RuntimeException
)
106 //==============================================================================
107 class InteractionRequest
:
108 public ::cppu::WeakImplHelper1
<task::XInteractionRequest
>
111 Sequence
< Reference
<task::XInteractionContinuation
> > m_conts
;
114 inline InteractionRequest(
116 Sequence
< Reference
<task::XInteractionContinuation
> > const & conts
)
117 : m_request( request
),
121 // XInteractionRequest
122 virtual Any SAL_CALL
getRequest()
123 throw (RuntimeException
);
124 virtual Sequence
< Reference
<task::XInteractionContinuation
> >
125 SAL_CALL
getContinuations() throw (RuntimeException
);
128 // XInteractionRequest
129 //______________________________________________________________________________
130 Any
InteractionRequest::getRequest() throw (RuntimeException
)
135 //______________________________________________________________________________
136 Sequence
< Reference
< task::XInteractionContinuation
> >
137 InteractionRequest::getContinuations() throw (RuntimeException
)
144 //==============================================================================
145 bool interactContinuation( Any
const & request
,
146 Type
const & continuation
,
147 Reference
<XCommandEnvironment
> const & xCmdEnv
,
148 bool * pcont
, bool * pabort
)
151 task::XInteractionContinuation::static_type().isAssignableFrom(
154 Reference
<task::XInteractionHandler
> xInteractionHandler(
155 xCmdEnv
->getInteractionHandler() );
156 if (xInteractionHandler
.is()) {
159 Sequence
< Reference
<task::XInteractionContinuation
> > conts( 2 );
160 conts
[ 0 ] = new InteractionContinuationImpl(
161 continuation
, &cont
);
162 conts
[ 1 ] = new InteractionContinuationImpl(
163 task::XInteractionAbort::static_type(), &abort
);
164 xInteractionHandler
->handle(
165 new InteractionRequest( request
, conts
) );
179 //______________________________________________________________________________
180 void AbortChannel::sendAbort() throw (RuntimeException
)
184 m_xNext
->sendAbort();