update credits
[LibreOffice.git] / fpicker / source / office / fpinteraction.cxx
blob78a441b65d23c9df3a0fd9d400ce0382580dd22d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "fpinteraction.hxx"
21 #include <tools/debug.hxx>
22 #include <com/sun/star/ucb/InteractiveIOException.hpp>
23 #include <com/sun/star/task/XInteractionAbort.hpp>
24 #include <com/sun/star/task/XInteractionApprove.hpp>
25 #include <com/sun/star/task/XInteractionDisapprove.hpp>
26 #include <com/sun/star/task/XInteractionRetry.hpp>
28 //........................................................................
29 namespace svt
31 //........................................................................
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::task;
34 using namespace ::com::sun::star::ucb;
36 //====================================================================
37 //= OFilePickerInteractionHandler
38 //====================================================================
39 DBG_NAME( OFilePickerInteractionHandler )
40 //--------------------------------------------------------------------
41 OFilePickerInteractionHandler::OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxMaster )
42 :m_xMaster( _rxMaster )
43 ,m_bUsed( sal_False )
44 ,m_eInterceptions( OFilePickerInteractionHandler::E_NOINTERCEPTION )
46 DBG_CTOR( OFilePickerInteractionHandler, NULL );
47 DBG_ASSERT( m_xMaster.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
50 //--------------------------------------------------------------------
51 OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
53 DBG_DTOR( OFilePickerInteractionHandler, NULL );
56 //--------------------------------------------------------------------
57 void SAL_CALL OFilePickerInteractionHandler::handle( const Reference< XInteractionRequest >& _rxRequest ) throw (RuntimeException)
59 if (!_rxRequest.is())
60 return;
62 m_bUsed = sal_True;
64 // extract some generic continuations ... might we need it later
65 // if something goes wrong.
66 Reference< XInteractionAbort > xAbort;
67 Reference< XInteractionApprove > xApprove;
68 Reference< XInteractionDisapprove > xDisapprove;
69 Reference< XInteractionRetry > xRetry;
71 const Sequence< Reference< XInteractionContinuation > > lConts = _rxRequest->getContinuations();
72 const Reference< XInteractionContinuation >* pConts = lConts.getConstArray();
73 for (sal_Int32 i=0; i<lConts.getLength(); ++i)
75 if (!xAbort.is())
76 xAbort = Reference< XInteractionAbort >(pConts[i], UNO_QUERY);
77 if (!xApprove.is())
78 xApprove = Reference< XInteractionApprove >(pConts[i], UNO_QUERY);
79 if (!xDisapprove.is())
80 xDisapprove = Reference< XInteractionDisapprove >(pConts[i], UNO_QUERY);
81 if (!xRetry.is())
82 xRetry = Reference< XInteractionRetry >(pConts[i], UNO_QUERY);
85 // safe the original request for later analyzing!
86 m_aException = _rxRequest->getRequest();
88 // intercept some interesting interactions
90 // The "does not exist" interaction will be supressed here completely.
91 if (m_eInterceptions & OFilePickerInteractionHandler::E_DOESNOTEXIST)
93 InteractiveIOException aIoException;
94 if (
95 (m_aException >>= aIoException ) &&
96 (IOErrorCode_NOT_EXISTING == aIoException.Code)
99 if (xAbort.is())
100 xAbort->select();
101 return;
105 // no master => abort this operation ...
106 if (!m_xMaster.is())
108 if (xAbort.is())
109 xAbort->select();
110 return;
113 // forward it to our master - so he can handle all
114 // not interesting interactions :-)
115 m_xMaster->handle(_rxRequest);
118 //--------------------------------------------------------------------
119 void OFilePickerInteractionHandler::enableInterceptions( EInterceptedInteractions eInterceptions )
121 m_eInterceptions = eInterceptions;
124 //--------------------------------------------------------------------
125 sal_Bool OFilePickerInteractionHandler::wasUsed() const
127 return m_bUsed;
130 //--------------------------------------------------------------------
131 void OFilePickerInteractionHandler::resetUseState()
133 m_bUsed = sal_False;
136 //--------------------------------------------------------------------
137 void OFilePickerInteractionHandler::forgetRequest()
139 m_aException = Any();
142 //--------------------------------------------------------------------
143 sal_Bool OFilePickerInteractionHandler::wasAccessDenied() const
145 InteractiveIOException aIoException;
146 if (
147 (m_aException >>= aIoException ) &&
148 (IOErrorCode_ACCESS_DENIED == aIoException.Code)
151 return sal_True;
153 return sal_False;
156 //........................................................................
157 } // namespace svt
158 //........................................................................
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */