1*03b7fc75SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*03b7fc75SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*03b7fc75SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*03b7fc75SAndrew Rist * distributed with this work for additional information 6*03b7fc75SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*03b7fc75SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*03b7fc75SAndrew Rist * "License"); you may not use this file except in compliance 9*03b7fc75SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*03b7fc75SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*03b7fc75SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*03b7fc75SAndrew Rist * software distributed under the License is distributed on an 15*03b7fc75SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*03b7fc75SAndrew Rist * KIND, either express or implied. See the License for the 17*03b7fc75SAndrew Rist * specific language governing permissions and limitations 18*03b7fc75SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*03b7fc75SAndrew Rist *************************************************************/ 21*03b7fc75SAndrew Rist 22*03b7fc75SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #if ! defined INCLUDED_DP_INTERACT_H 25cdf0e10cSrcweir #define INCLUDED_DP_INTERACT_H 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "rtl/ref.hxx" 28cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx" 29cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 30cdf0e10cSrcweir #include "com/sun/star/ucb/XCommandEnvironment.hpp" 31cdf0e10cSrcweir #include "com/sun/star/task/XAbortChannel.hpp" 32cdf0e10cSrcweir #include "dp_misc_api.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace css = ::com::sun::star; 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace dp_misc 37cdf0e10cSrcweir { 38cdf0e10cSrcweir 39cdf0e10cSrcweir inline void progressUpdate( 40cdf0e10cSrcweir ::rtl::OUString const & status, 41cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir if (xCmdEnv.is()) { 44cdf0e10cSrcweir css::uno::Reference<css::ucb::XProgressHandler> xProgressHandler( 45cdf0e10cSrcweir xCmdEnv->getProgressHandler() ); 46cdf0e10cSrcweir if (xProgressHandler.is()) { 47cdf0e10cSrcweir xProgressHandler->update( css::uno::makeAny(status) ); 48cdf0e10cSrcweir } 49cdf0e10cSrcweir } 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir //============================================================================== 53cdf0e10cSrcweir class ProgressLevel 54cdf0e10cSrcweir { 55cdf0e10cSrcweir css::uno::Reference<css::ucb::XProgressHandler> m_xProgressHandler; 56cdf0e10cSrcweir 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir inline ~ProgressLevel(); 59cdf0e10cSrcweir inline ProgressLevel( 60cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, 61cdf0e10cSrcweir ::rtl::OUString const & status ); 62cdf0e10cSrcweir 63cdf0e10cSrcweir inline void update( ::rtl::OUString const & status ) const; 64cdf0e10cSrcweir inline void update( css::uno::Any const & status ) const; 65cdf0e10cSrcweir }; 66cdf0e10cSrcweir 67cdf0e10cSrcweir //______________________________________________________________________________ 68cdf0e10cSrcweir inline ProgressLevel::ProgressLevel( 69cdf0e10cSrcweir css::uno::Reference< css::ucb::XCommandEnvironment > const & xCmdEnv, 70cdf0e10cSrcweir ::rtl::OUString const & status ) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir if (xCmdEnv.is()) 73cdf0e10cSrcweir m_xProgressHandler = xCmdEnv->getProgressHandler(); 74cdf0e10cSrcweir if (m_xProgressHandler.is()) 75cdf0e10cSrcweir m_xProgressHandler->push( css::uno::makeAny(status) ); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir //______________________________________________________________________________ 79cdf0e10cSrcweir inline ProgressLevel::~ProgressLevel() 80cdf0e10cSrcweir { 81cdf0e10cSrcweir if (m_xProgressHandler.is()) 82cdf0e10cSrcweir m_xProgressHandler->pop(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir //______________________________________________________________________________ 86cdf0e10cSrcweir inline void ProgressLevel::update( ::rtl::OUString const & status ) const 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if (m_xProgressHandler.is()) 89cdf0e10cSrcweir m_xProgressHandler->update( css::uno::makeAny(status) ); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir //______________________________________________________________________________ 93cdf0e10cSrcweir inline void ProgressLevel::update( css::uno::Any const & status ) const 94cdf0e10cSrcweir { 95cdf0e10cSrcweir if (m_xProgressHandler.is()) 96cdf0e10cSrcweir m_xProgressHandler->update( status ); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir //############################################################################## 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** @return true if ia handler is present and any selection has been chosen 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool interactContinuation( 104cdf0e10cSrcweir css::uno::Any const & request, 105cdf0e10cSrcweir css::uno::Type const & continuation, 106cdf0e10cSrcweir css::uno::Reference<css::ucb::XCommandEnvironment> const & xCmdEnv, 107cdf0e10cSrcweir bool * pcont, bool * pabort ); 108cdf0e10cSrcweir 109cdf0e10cSrcweir //############################################################################## 110cdf0e10cSrcweir 111cdf0e10cSrcweir //============================================================================== 112cdf0e10cSrcweir class DESKTOP_DEPLOYMENTMISC_DLLPUBLIC AbortChannel : 113cdf0e10cSrcweir public ::cppu::WeakImplHelper1<css::task::XAbortChannel> 114cdf0e10cSrcweir { 115cdf0e10cSrcweir bool m_aborted; 116cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> m_xNext; 117cdf0e10cSrcweir 118cdf0e10cSrcweir public: 119cdf0e10cSrcweir inline AbortChannel() : m_aborted( false ) {} 120cdf0e10cSrcweir inline static AbortChannel * get( 121cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xAbortChannel ) 122cdf0e10cSrcweir { return static_cast<AbortChannel *>(xAbortChannel.get()); } 123cdf0e10cSrcweir 124cdf0e10cSrcweir inline bool isAborted() const { return m_aborted; } 125cdf0e10cSrcweir 126cdf0e10cSrcweir // XAbortChannel 127cdf0e10cSrcweir virtual void SAL_CALL sendAbort() throw (css::uno::RuntimeException); 128cdf0e10cSrcweir 129cdf0e10cSrcweir class SAL_DLLPRIVATE Chain 130cdf0e10cSrcweir { 131cdf0e10cSrcweir const ::rtl::Reference<AbortChannel> m_abortChannel; 132cdf0e10cSrcweir public: 133cdf0e10cSrcweir inline Chain( 134cdf0e10cSrcweir ::rtl::Reference<AbortChannel> const & abortChannel, 135cdf0e10cSrcweir css::uno::Reference<css::task::XAbortChannel> const & xNext ) 136cdf0e10cSrcweir : m_abortChannel( abortChannel ) 137cdf0e10cSrcweir { if (m_abortChannel.is()) m_abortChannel->m_xNext = xNext; } 138cdf0e10cSrcweir inline ~Chain() 139cdf0e10cSrcweir { if (m_abortChannel.is()) m_abortChannel->m_xNext.clear(); } 140cdf0e10cSrcweir }; 141cdf0e10cSrcweir friend class Chain; 142cdf0e10cSrcweir }; 143cdf0e10cSrcweir 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir #endif 147