merge the formfield patch from ooo-build
[ooovba.git] / desktop / source / deployment / inc / dp_interact.h
blobcd54bf972384e5540e5ef3a78cd41fe36876774b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dp_interact.h,v $
10 * $Revision: 1.7 $
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;
43 namespace dp_misc
46 inline void progressUpdate(
47 ::rtl::OUString const & status,
48 css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv )
50 if (xCmdEnv.is()) {
51 css::uno::Reference<css::ucb::XProgressHandler> xProgressHandler(
52 xCmdEnv->getProgressHandler() );
53 if (xProgressHandler.is()) {
54 xProgressHandler->update( css::uno::makeAny(status) );
59 //==============================================================================
60 class ProgressLevel
62 css::uno::Reference<css::ucb::XProgressHandler> m_xProgressHandler;
64 public:
65 inline ~ProgressLevel();
66 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 )
79 if (xCmdEnv.is())
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>
122 bool m_aborted;
123 css::uno::Reference<css::task::XAbortChannel> m_xNext;
125 public:
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; }
133 // XAbortChannel
134 virtual void SAL_CALL sendAbort() throw (css::uno::RuntimeException);
136 class SAL_DLLPRIVATE Chain
138 const ::rtl::Reference<AbortChannel> m_abortChannel;
139 public:
140 inline Chain(
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; }
145 inline ~Chain()
146 { if (m_abortChannel.is()) m_abortChannel->m_xNext.clear(); }
148 friend class Chain;
153 #endif