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.h,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 #if ! defined INCLUDED_DP_INTERACT_H
32 #define INCLUDED_DP_INTERACT_H
34 #include "rtl/ref.hxx"
35 #include "cppuhelper/implbase1.hxx"
36 #include "com/sun/star/uno/XComponentContext.hpp"
37 #include "com/sun/star/ucb/XCommandEnvironment.hpp"
38 #include "com/sun/star/task/XAbortChannel.hpp"
39 #include "dp_misc_api.hxx"
41 namespace css
= ::com::sun::star
;
46 inline void progressUpdate(
47 ::rtl::OUString
const & status
,
48 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
)
51 css::uno::Reference
<css::ucb::XProgressHandler
> xProgressHandler(
52 xCmdEnv
->getProgressHandler() );
53 if (xProgressHandler
.is()) {
54 xProgressHandler
->update( css::uno::makeAny(status
) );
59 //==============================================================================
62 css::uno::Reference
<css::ucb::XProgressHandler
> m_xProgressHandler
;
65 inline ~ProgressLevel();
67 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
,
68 ::rtl::OUString
const & status
);
70 inline void update( ::rtl::OUString
const & status
) const;
71 inline void update( css::uno::Any
const & status
) const;
74 //______________________________________________________________________________
75 inline ProgressLevel::ProgressLevel(
76 css::uno::Reference
< css::ucb::XCommandEnvironment
> const & xCmdEnv
,
77 ::rtl::OUString
const & status
)
80 m_xProgressHandler
= xCmdEnv
->getProgressHandler();
81 if (m_xProgressHandler
.is())
82 m_xProgressHandler
->push( css::uno::makeAny(status
) );
85 //______________________________________________________________________________
86 inline ProgressLevel::~ProgressLevel()
88 if (m_xProgressHandler
.is())
89 m_xProgressHandler
->pop();
92 //______________________________________________________________________________
93 inline void ProgressLevel::update( ::rtl::OUString
const & status
) const
95 if (m_xProgressHandler
.is())
96 m_xProgressHandler
->update( css::uno::makeAny(status
) );
99 //______________________________________________________________________________
100 inline void ProgressLevel::update( css::uno::Any
const & status
) const
102 if (m_xProgressHandler
.is())
103 m_xProgressHandler
->update( status
);
106 //##############################################################################
108 /** @return true if ia handler is present and any selection has been chosen
110 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
bool interactContinuation(
111 css::uno::Any
const & request
,
112 css::uno::Type
const & continuation
,
113 css::uno::Reference
<css::ucb::XCommandEnvironment
> const & xCmdEnv
,
114 bool * pcont
, bool * pabort
);
116 //##############################################################################
118 //==============================================================================
119 class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC AbortChannel
:
120 public ::cppu::WeakImplHelper1
<css::task::XAbortChannel
>
123 css::uno::Reference
<css::task::XAbortChannel
> m_xNext
;
126 inline AbortChannel() : m_aborted( false ) {}
127 inline static AbortChannel
* get(
128 css::uno::Reference
<css::task::XAbortChannel
> const & xAbortChannel
)
129 { return static_cast<AbortChannel
*>(xAbortChannel
.get()); }
131 inline bool isAborted() const { return m_aborted
; }
134 virtual void SAL_CALL
sendAbort() throw (css::uno::RuntimeException
);
136 class SAL_DLLPRIVATE Chain
138 const ::rtl::Reference
<AbortChannel
> m_abortChannel
;
141 ::rtl::Reference
<AbortChannel
> const & abortChannel
,
142 css::uno::Reference
<css::task::XAbortChannel
> const & xNext
)
143 : m_abortChannel( abortChannel
)
144 { if (m_abortChannel
.is()) m_abortChannel
->m_xNext
= xNext
; }
146 { if (m_abortChannel
.is()) m_abortChannel
->m_xNext
.clear(); }