1*b557fc96SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b557fc96SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b557fc96SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b557fc96SAndrew Rist * distributed with this work for additional information 6*b557fc96SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b557fc96SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b557fc96SAndrew Rist * "License"); you may not use this file except in compliance 9*b557fc96SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b557fc96SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b557fc96SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b557fc96SAndrew Rist * software distributed under the License is distributed on an 15*b557fc96SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b557fc96SAndrew Rist * KIND, either express or implied. See the License for the 17*b557fc96SAndrew Rist * specific language governing permissions and limitations 18*b557fc96SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b557fc96SAndrew Rist *************************************************************/ 21*b557fc96SAndrew Rist 22*b557fc96SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_fpicker.hxx" 26cdf0e10cSrcweir #include "fpinteraction.hxx" 27cdf0e10cSrcweir #include <tools/debug.hxx> 28cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp> 29cdf0e10cSrcweir #include <com/sun/star/task/XInteractionAbort.hpp> 30cdf0e10cSrcweir #include <com/sun/star/task/XInteractionApprove.hpp> 31cdf0e10cSrcweir #include <com/sun/star/task/XInteractionDisapprove.hpp> 32cdf0e10cSrcweir #include <com/sun/star/task/XInteractionRetry.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweir //........................................................................ 35cdf0e10cSrcweir namespace svt 36cdf0e10cSrcweir { 37cdf0e10cSrcweir //........................................................................ 38cdf0e10cSrcweir using namespace ::com::sun::star::uno; 39cdf0e10cSrcweir using namespace ::com::sun::star::task; 40cdf0e10cSrcweir using namespace ::com::sun::star::ucb; 41cdf0e10cSrcweir 42cdf0e10cSrcweir //==================================================================== 43cdf0e10cSrcweir //= OFilePickerInteractionHandler 44cdf0e10cSrcweir //==================================================================== DBG_NAME(OFilePickerInteractionHandler)45cdf0e10cSrcweir DBG_NAME( OFilePickerInteractionHandler ) 46cdf0e10cSrcweir //-------------------------------------------------------------------- 47cdf0e10cSrcweir OFilePickerInteractionHandler::OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxMaster ) 48cdf0e10cSrcweir :m_xMaster( _rxMaster ) 49cdf0e10cSrcweir ,m_bUsed( sal_False ) 50cdf0e10cSrcweir ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir DBG_CTOR( OFilePickerInteractionHandler, NULL ); 53cdf0e10cSrcweir DBG_ASSERT( m_xMaster.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" ); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir //-------------------------------------------------------------------- ~OFilePickerInteractionHandler()57cdf0e10cSrcweir OFilePickerInteractionHandler::~OFilePickerInteractionHandler( ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir DBG_DTOR( OFilePickerInteractionHandler, NULL ); 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir //-------------------------------------------------------------------- handle(const Reference<XInteractionRequest> & _rxRequest)63cdf0e10cSrcweir void SAL_CALL OFilePickerInteractionHandler::handle( const Reference< XInteractionRequest >& _rxRequest ) throw (RuntimeException) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir if (!_rxRequest.is()) 66cdf0e10cSrcweir return; 67cdf0e10cSrcweir 68cdf0e10cSrcweir m_bUsed = sal_True; 69cdf0e10cSrcweir 70cdf0e10cSrcweir // extract some generic continuations ... might we need it later 71cdf0e10cSrcweir // if something goes wrong. 72cdf0e10cSrcweir Reference< XInteractionAbort > xAbort; 73cdf0e10cSrcweir Reference< XInteractionApprove > xApprove; 74cdf0e10cSrcweir Reference< XInteractionDisapprove > xDisapprove; 75cdf0e10cSrcweir Reference< XInteractionRetry > xRetry; 76cdf0e10cSrcweir 77cdf0e10cSrcweir const Sequence< Reference< XInteractionContinuation > > lConts = _rxRequest->getContinuations(); 78cdf0e10cSrcweir const Reference< XInteractionContinuation >* pConts = lConts.getConstArray(); 79cdf0e10cSrcweir for (sal_Int32 i=0; i<lConts.getLength(); ++i) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir if (!xAbort.is()) 82cdf0e10cSrcweir xAbort = Reference< XInteractionAbort >(pConts[i], UNO_QUERY); 83cdf0e10cSrcweir if (!xApprove.is()) 84cdf0e10cSrcweir xApprove = Reference< XInteractionApprove >(pConts[i], UNO_QUERY); 85cdf0e10cSrcweir if (!xDisapprove.is()) 86cdf0e10cSrcweir xDisapprove = Reference< XInteractionDisapprove >(pConts[i], UNO_QUERY); 87cdf0e10cSrcweir if (!xRetry.is()) 88cdf0e10cSrcweir xRetry = Reference< XInteractionRetry >(pConts[i], UNO_QUERY); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir // safe the original request for later analyzing! 92cdf0e10cSrcweir m_aException = _rxRequest->getRequest(); 93cdf0e10cSrcweir 94cdf0e10cSrcweir // intercept some interesting interactions 95cdf0e10cSrcweir 96cdf0e10cSrcweir // The "does not exist" interaction will be supressed here completly. 97cdf0e10cSrcweir if (m_eInterceptions & OFilePickerInteractionHandler::E_DOESNOTEXIST) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir InteractiveIOException aIoException; 100cdf0e10cSrcweir if ( 101cdf0e10cSrcweir (m_aException >>= aIoException ) && 102cdf0e10cSrcweir (IOErrorCode_NOT_EXISTING == aIoException.Code) 103cdf0e10cSrcweir ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir if (xAbort.is()) 106cdf0e10cSrcweir xAbort->select(); 107cdf0e10cSrcweir return; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir // no master => abort this operation ... 112cdf0e10cSrcweir if (!m_xMaster.is()) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir if (xAbort.is()) 115cdf0e10cSrcweir xAbort->select(); 116cdf0e10cSrcweir return; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir // forward it to our master - so he can handle all 120cdf0e10cSrcweir // not interesting interactions :-) 121cdf0e10cSrcweir m_xMaster->handle(_rxRequest); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir //-------------------------------------------------------------------- enableInterceptions(EInterceptedInteractions eInterceptions)125cdf0e10cSrcweir void OFilePickerInteractionHandler::enableInterceptions( EInterceptedInteractions eInterceptions ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir m_eInterceptions = eInterceptions; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir //-------------------------------------------------------------------- wasUsed() const131cdf0e10cSrcweir sal_Bool OFilePickerInteractionHandler::wasUsed() const 132cdf0e10cSrcweir { 133cdf0e10cSrcweir return m_bUsed; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir //-------------------------------------------------------------------- resetUseState()137cdf0e10cSrcweir void OFilePickerInteractionHandler::resetUseState() 138cdf0e10cSrcweir { 139cdf0e10cSrcweir m_bUsed = sal_False; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir //-------------------------------------------------------------------- forgetRequest()143cdf0e10cSrcweir void OFilePickerInteractionHandler::forgetRequest() 144cdf0e10cSrcweir { 145cdf0e10cSrcweir m_aException = Any(); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir //-------------------------------------------------------------------- wasAccessDenied() const149cdf0e10cSrcweir sal_Bool OFilePickerInteractionHandler::wasAccessDenied() const 150cdf0e10cSrcweir { 151cdf0e10cSrcweir InteractiveIOException aIoException; 152cdf0e10cSrcweir if ( 153cdf0e10cSrcweir (m_aException >>= aIoException ) && 154cdf0e10cSrcweir (IOErrorCode_ACCESS_DENIED == aIoException.Code) 155cdf0e10cSrcweir ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir return sal_True; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir return sal_False; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir //........................................................................ 163cdf0e10cSrcweir } // namespace svt 164cdf0e10cSrcweir //........................................................................ 165cdf0e10cSrcweir 166