1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "dp_interact.h"
22 #include "cppuhelper/exc_hlp.hxx"
23 #include "cppuhelper/implbase1.hxx"
24 #include "com/sun/star/task/XInteractionAbort.hpp"
27 using namespace ::com::sun::star
;
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star::ucb
;
34 //==============================================================================
35 class InteractionContinuationImpl
: public ::cppu::OWeakObject
,
36 public task::XInteractionContinuation
42 inline InteractionContinuationImpl( Type
const & type
, bool * pselect
)
47 static_cast< Reference
<task::XInteractionContinuation
>
48 const *>(0) ).isAssignableFrom(m_type
) ); }
51 virtual void SAL_CALL
acquire() throw ();
52 virtual void SAL_CALL
release() throw ();
53 virtual Any SAL_CALL
queryInterface( Type
const & type
)
54 throw (RuntimeException
);
56 // XInteractionContinuation
57 virtual void SAL_CALL
select() throw (RuntimeException
);
61 //______________________________________________________________________________
62 void InteractionContinuationImpl::acquire() throw ()
64 OWeakObject::acquire();
67 //______________________________________________________________________________
68 void InteractionContinuationImpl::release() throw ()
70 OWeakObject::release();
73 //______________________________________________________________________________
74 Any
InteractionContinuationImpl::queryInterface( Type
const & type
)
75 throw (RuntimeException
)
77 if (type
.isAssignableFrom( m_type
)) {
78 Reference
<task::XInteractionContinuation
> xThis(this);
79 return Any( &xThis
, type
);
82 return OWeakObject::queryInterface(type
);
85 // XInteractionContinuation
86 //______________________________________________________________________________
87 void InteractionContinuationImpl::select() throw (RuntimeException
)
92 //==============================================================================
93 class InteractionRequest
:
94 public ::cppu::WeakImplHelper1
<task::XInteractionRequest
>
97 Sequence
< Reference
<task::XInteractionContinuation
> > m_conts
;
100 inline InteractionRequest(
102 Sequence
< Reference
<task::XInteractionContinuation
> > const & conts
)
103 : m_request( request
),
107 // XInteractionRequest
108 virtual Any SAL_CALL
getRequest()
109 throw (RuntimeException
);
110 virtual Sequence
< Reference
<task::XInteractionContinuation
> >
111 SAL_CALL
getContinuations() throw (RuntimeException
);
114 // XInteractionRequest
115 //______________________________________________________________________________
116 Any
InteractionRequest::getRequest() throw (RuntimeException
)
121 //______________________________________________________________________________
122 Sequence
< Reference
< task::XInteractionContinuation
> >
123 InteractionRequest::getContinuations() throw (RuntimeException
)
130 //==============================================================================
131 bool interactContinuation( Any
const & request
,
132 Type
const & continuation
,
133 Reference
<XCommandEnvironment
> const & xCmdEnv
,
134 bool * pcont
, bool * pabort
)
137 task::XInteractionContinuation::static_type().isAssignableFrom(
140 Reference
<task::XInteractionHandler
> xInteractionHandler(
141 xCmdEnv
->getInteractionHandler() );
142 if (xInteractionHandler
.is()) {
145 Sequence
< Reference
<task::XInteractionContinuation
> > conts( 2 );
146 conts
[ 0 ] = new InteractionContinuationImpl(
147 continuation
, &cont
);
148 conts
[ 1 ] = new InteractionContinuationImpl(
149 task::XInteractionAbort::static_type(), &abort
);
150 xInteractionHandler
->handle(
151 new InteractionRequest( request
, conts
) );
165 //______________________________________________________________________________
166 void AbortChannel::sendAbort() throw (RuntimeException
)
170 m_xNext
->sendAbort();
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */